@odus/checkout 0.30.0-beta.2 → 0.30.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/checkout.es.js +469 -461
- package/dist/elements.es.js +2 -2
- package/dist/index.css +1 -1
- package/dist/package.json +1 -1
- package/dist/phone.js +1437 -1420
- package/dist/shared.js +1576 -1517
- package/package.json +1 -1
package/dist/checkout.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as
|
|
2
|
-
import {
|
|
1
|
+
import { l as fe, c as me, a as ye, f as q, d as be, C as A, I as pe, b as P, g as ve, S as _, e as ee, H as Se, V as te, h as D, A as Ce, P as Ee, E as Fe, i as Me, j as Ne, k as we, m as Pe, n as ke, o as Ae, F as xe, p as De, q as Ie } from "./shared.js";
|
|
2
|
+
import { r as _t, s as Rt, t as Bt, u as Ut, v as Ot, w as Ht, x as zt, y as $t } from "./shared.js";
|
|
3
3
|
const F = {
|
|
4
4
|
// Checkout lifecycle events
|
|
5
5
|
CHECKOUT_INITIALIZED: "checkout.initialized",
|
|
@@ -16,11 +16,11 @@ const F = {
|
|
|
16
16
|
PAYMENT_AUTHORIZED: "payment.authorized",
|
|
17
17
|
PAYMENT_FAILED: "payment.failed",
|
|
18
18
|
PAYMENT_ACTION_REQUIRED: "payment.action_required"
|
|
19
|
-
},
|
|
19
|
+
}, se = {
|
|
20
20
|
PAYMENT_AUTHORIZATION_TIME: "payment.authorization_time",
|
|
21
21
|
CHECKOUT_LOAD_TIME: "checkout.load_time",
|
|
22
22
|
FORM_RENDER_TIME: "form.render_time"
|
|
23
|
-
},
|
|
23
|
+
}, Te = /^\s*at (?:(.+?) ?\()?((?:file|https?|chrome-extension|webpack-internal):\/\/.+?):(\d+):(\d+)\)?\s*$/, Le = /^([^@]+)@((?:file|https?|chrome-extension|webpack-internal):\/\/[^\s:]+):(\d+):(\d+)$/, Ve = /^(?:([^@]+)@)?((?:file|https?):\/\/[^\s:]+):(\d+):(\d+)$/, Z = (i) => {
|
|
24
24
|
if (!i)
|
|
25
25
|
return [];
|
|
26
26
|
const e = [], t = i.split(`
|
|
@@ -29,7 +29,7 @@ const F = {
|
|
|
29
29
|
const a = s.trim();
|
|
30
30
|
if (!a)
|
|
31
31
|
continue;
|
|
32
|
-
let n =
|
|
32
|
+
let n = Te.exec(a);
|
|
33
33
|
if (n) {
|
|
34
34
|
e.push({
|
|
35
35
|
function: n[1] || "(anonymous)",
|
|
@@ -39,7 +39,7 @@ const F = {
|
|
|
39
39
|
});
|
|
40
40
|
continue;
|
|
41
41
|
}
|
|
42
|
-
n =
|
|
42
|
+
n = Le.exec(a) ?? Ve.exec(a), n && e.push({
|
|
43
43
|
function: n[1] || "(anonymous)",
|
|
44
44
|
filename: n[2],
|
|
45
45
|
lineno: parseInt(n[3], 10),
|
|
@@ -47,9 +47,9 @@ const F = {
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
return e;
|
|
50
|
-
},
|
|
51
|
-
let
|
|
52
|
-
const
|
|
50
|
+
}, _e = "@odus/telemetry", Re = "0.0.1";
|
|
51
|
+
let z, $, X;
|
|
52
|
+
const Be = () => {
|
|
53
53
|
if (typeof navigator > "u")
|
|
54
54
|
return {};
|
|
55
55
|
const i = navigator.userAgent;
|
|
@@ -66,36 +66,36 @@ const Re = () => {
|
|
|
66
66
|
viewportHeight: String(window.innerHeight),
|
|
67
67
|
userAgent: i
|
|
68
68
|
};
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
H = i;
|
|
73
|
-
}, He = () => {
|
|
74
|
-
H = void 0;
|
|
75
|
-
}, ze = (i) => {
|
|
69
|
+
}, Ue = () => typeof window > "u" ? {} : { url: window.location.href }, Oe = (i) => {
|
|
70
|
+
z = void 0, X = void 0, $ = i.sessionTracking?.session ? { id: i.sessionTracking.session.id } : void 0;
|
|
71
|
+
}, He = (i) => {
|
|
76
72
|
z = i;
|
|
73
|
+
}, ze = () => {
|
|
74
|
+
z = void 0;
|
|
77
75
|
}, $e = (i) => {
|
|
78
|
-
|
|
79
|
-
},
|
|
80
|
-
|
|
76
|
+
$ = i;
|
|
77
|
+
}, Ke = (i) => {
|
|
78
|
+
X = i;
|
|
79
|
+
}, qe = () => $?.id, je = (i) => ({
|
|
80
|
+
sdk: { name: _e, version: Re },
|
|
81
81
|
app: i.app,
|
|
82
|
-
user:
|
|
83
|
-
session:
|
|
84
|
-
page:
|
|
85
|
-
browser:
|
|
86
|
-
view:
|
|
87
|
-
}),
|
|
88
|
-
let I = [],
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
82
|
+
user: z,
|
|
83
|
+
session: $,
|
|
84
|
+
page: Ue(),
|
|
85
|
+
browser: Be(),
|
|
86
|
+
view: X
|
|
87
|
+
}), We = 30, Ye = 250, Ge = 6e4;
|
|
88
|
+
let I = [], k = null, Q = 0, R = null, B = null;
|
|
89
|
+
const Ze = (i) => {
|
|
90
|
+
if (k)
|
|
91
91
|
return;
|
|
92
|
-
const e = i.batching?.sendTimeout ??
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
const e = i.batching?.sendTimeout ?? Ye;
|
|
93
|
+
k = setTimeout(() => {
|
|
94
|
+
K(i);
|
|
95
95
|
}, e);
|
|
96
|
-
},
|
|
96
|
+
}, Je = (i, e) => {
|
|
97
97
|
const t = {
|
|
98
|
-
meta:
|
|
98
|
+
meta: je(e)
|
|
99
99
|
};
|
|
100
100
|
for (const s of i)
|
|
101
101
|
switch (s.type) {
|
|
@@ -113,8 +113,8 @@ const Ge = (i) => {
|
|
|
113
113
|
break;
|
|
114
114
|
}
|
|
115
115
|
return t;
|
|
116
|
-
},
|
|
117
|
-
const s = JSON.stringify(i), a =
|
|
116
|
+
}, Xe = (i, e, t = !1) => {
|
|
117
|
+
const s = JSON.stringify(i), a = qe(), n = {
|
|
118
118
|
"Content-Type": "application/json"
|
|
119
119
|
};
|
|
120
120
|
if (a && (n["x-faro-session-id"] = a), t && typeof navigator < "u" && navigator.sendBeacon) {
|
|
@@ -122,7 +122,7 @@ const Ge = (i) => {
|
|
|
122
122
|
navigator.sendBeacon(e, o);
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
|
-
const r = s.length <
|
|
125
|
+
const r = s.length < Ge;
|
|
126
126
|
fetch(e, {
|
|
127
127
|
method: "POST",
|
|
128
128
|
headers: n,
|
|
@@ -131,157 +131,157 @@ const Ge = (i) => {
|
|
|
131
131
|
}).then((o) => {
|
|
132
132
|
if (o.status === 429) {
|
|
133
133
|
const d = o.headers.get("Retry-After"), c = d ? parseInt(d, 10) * 1e3 : 3e4;
|
|
134
|
-
|
|
134
|
+
Q = Date.now() + c;
|
|
135
135
|
}
|
|
136
136
|
}).catch(() => {
|
|
137
137
|
});
|
|
138
|
-
},
|
|
139
|
-
if (
|
|
138
|
+
}, K = (i, e = !1) => {
|
|
139
|
+
if (k && (clearTimeout(k), k = null), I.length === 0)
|
|
140
140
|
return;
|
|
141
|
-
if (Date.now() <
|
|
141
|
+
if (Date.now() < Q) {
|
|
142
142
|
I = [];
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
145
145
|
const t = I;
|
|
146
146
|
I = [];
|
|
147
147
|
try {
|
|
148
|
-
let s =
|
|
148
|
+
let s = Je(t, i);
|
|
149
149
|
if (i.beforeSend) {
|
|
150
150
|
const a = i.beforeSend(s);
|
|
151
151
|
if (!a)
|
|
152
152
|
return;
|
|
153
153
|
s = a;
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
Xe(s, i.url, e);
|
|
156
156
|
} catch {
|
|
157
157
|
}
|
|
158
158
|
}, w = (i, e) => {
|
|
159
159
|
I.push(i);
|
|
160
|
-
const t = e.batching?.itemLimit ??
|
|
160
|
+
const t = e.batching?.itemLimit ?? We;
|
|
161
161
|
if (I.length >= t) {
|
|
162
|
-
|
|
162
|
+
K(e);
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
|
-
|
|
166
|
-
},
|
|
167
|
-
if (I = [],
|
|
165
|
+
Ze(e);
|
|
166
|
+
}, Qe = (i) => {
|
|
167
|
+
if (I = [], Q = 0, k && (clearTimeout(k), k = null), typeof document > "u")
|
|
168
168
|
return;
|
|
169
|
-
|
|
170
|
-
const e = () =>
|
|
171
|
-
|
|
169
|
+
R && document.removeEventListener("visibilitychange", R), B && window.removeEventListener("pagehide", B);
|
|
170
|
+
const e = () => K(i, !0);
|
|
171
|
+
R = () => {
|
|
172
172
|
document.visibilityState === "hidden" && e();
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
let
|
|
176
|
-
const
|
|
177
|
-
typeof window > "u" || (
|
|
173
|
+
}, B = e, document.addEventListener("visibilitychange", R), window.addEventListener("pagehide", B);
|
|
174
|
+
}, ne = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
175
|
+
let ie = null, ae = null;
|
|
176
|
+
const et = (i) => {
|
|
177
|
+
typeof window > "u" || (ie = (e) => {
|
|
178
178
|
const t = e.error instanceof Error ? e.error : new Error(e.message);
|
|
179
179
|
w({
|
|
180
180
|
type: "exception",
|
|
181
181
|
payload: {
|
|
182
182
|
type: t.name,
|
|
183
183
|
value: t.message,
|
|
184
|
-
timestamp:
|
|
185
|
-
stacktrace: t.stack ? { frames:
|
|
184
|
+
timestamp: ne(),
|
|
185
|
+
stacktrace: t.stack ? { frames: Z(t.stack) } : void 0
|
|
186
186
|
}
|
|
187
187
|
}, i);
|
|
188
|
-
},
|
|
188
|
+
}, ae = (e) => {
|
|
189
189
|
const t = e.reason, s = t instanceof Error ? t : new Error(String(t));
|
|
190
190
|
w({
|
|
191
191
|
type: "exception",
|
|
192
192
|
payload: {
|
|
193
193
|
type: s.name,
|
|
194
194
|
value: s.message,
|
|
195
|
-
timestamp:
|
|
196
|
-
stacktrace: s.stack ? { frames:
|
|
195
|
+
timestamp: ne(),
|
|
196
|
+
stacktrace: s.stack ? { frames: Z(s.stack) } : void 0,
|
|
197
197
|
context: { source: "unhandledrejection" }
|
|
198
198
|
}
|
|
199
199
|
}, i);
|
|
200
|
-
}, window.addEventListener("error",
|
|
201
|
-
},
|
|
200
|
+
}, window.addEventListener("error", ie), window.addEventListener("unhandledrejection", ae));
|
|
201
|
+
}, re = "odus_telemetry_session_id", j = () => {
|
|
202
202
|
const i = new Uint8Array(16);
|
|
203
203
|
return crypto.getRandomValues(i), Array.from(i, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
204
|
-
},
|
|
204
|
+
}, tt = (i) => {
|
|
205
205
|
if (i)
|
|
206
206
|
return i;
|
|
207
207
|
if (typeof sessionStorage > "u")
|
|
208
|
-
return
|
|
208
|
+
return j();
|
|
209
209
|
try {
|
|
210
|
-
const e = sessionStorage.getItem(
|
|
210
|
+
const e = sessionStorage.getItem(re);
|
|
211
211
|
if (e)
|
|
212
212
|
return e;
|
|
213
|
-
const t =
|
|
214
|
-
return sessionStorage.setItem(
|
|
213
|
+
const t = j();
|
|
214
|
+
return sessionStorage.setItem(re, t), t;
|
|
215
215
|
} catch {
|
|
216
|
-
return
|
|
216
|
+
return j();
|
|
217
217
|
}
|
|
218
|
-
},
|
|
218
|
+
}, st = (i) => {
|
|
219
219
|
if (!i.sessionTracking?.enabled)
|
|
220
220
|
return;
|
|
221
|
-
const e =
|
|
222
|
-
|
|
223
|
-
},
|
|
221
|
+
const e = tt(i.sessionTracking.session?.id);
|
|
222
|
+
$e({ id: e });
|
|
223
|
+
}, W = () => (/* @__PURE__ */ new Date()).toISOString(), Y = (i, e) => {
|
|
224
224
|
if (typeof PerformanceObserver > "u" || !PerformanceObserver.supportedEntryTypes?.includes(i))
|
|
225
225
|
return;
|
|
226
226
|
new PerformanceObserver((s) => {
|
|
227
227
|
for (const a of s.getEntries())
|
|
228
228
|
e(a);
|
|
229
229
|
}).observe({ type: i, buffered: !0 });
|
|
230
|
-
},
|
|
230
|
+
}, nt = (i) => {
|
|
231
231
|
if (typeof window > "u")
|
|
232
232
|
return;
|
|
233
|
-
|
|
233
|
+
Y("largest-contentful-paint", (t) => {
|
|
234
234
|
w({
|
|
235
235
|
type: "measurement",
|
|
236
236
|
payload: {
|
|
237
237
|
type: "web-vitals",
|
|
238
238
|
values: { lcp: t.startTime },
|
|
239
|
-
timestamp:
|
|
239
|
+
timestamp: W()
|
|
240
240
|
}
|
|
241
241
|
}, i);
|
|
242
242
|
});
|
|
243
243
|
let e = 0;
|
|
244
|
-
|
|
244
|
+
Y("layout-shift", (t) => {
|
|
245
245
|
const s = t;
|
|
246
246
|
s.hadRecentInput || (e += s.value, w({
|
|
247
247
|
type: "measurement",
|
|
248
248
|
payload: {
|
|
249
249
|
type: "web-vitals",
|
|
250
250
|
values: { cls: e },
|
|
251
|
-
timestamp:
|
|
251
|
+
timestamp: W()
|
|
252
252
|
}
|
|
253
253
|
}, i));
|
|
254
|
-
}),
|
|
254
|
+
}), Y("event", (t) => {
|
|
255
255
|
const s = t;
|
|
256
256
|
s.duration > 0 && w({
|
|
257
257
|
type: "measurement",
|
|
258
258
|
payload: {
|
|
259
259
|
type: "web-vitals",
|
|
260
260
|
values: { inp: s.duration },
|
|
261
|
-
timestamp:
|
|
261
|
+
timestamp: W()
|
|
262
262
|
}
|
|
263
263
|
}, i);
|
|
264
264
|
});
|
|
265
|
-
},
|
|
265
|
+
}, H = {
|
|
266
266
|
INFO: "info",
|
|
267
267
|
WARN: "warn",
|
|
268
268
|
ERROR: "error"
|
|
269
|
-
},
|
|
270
|
-
|
|
269
|
+
}, U = () => (/* @__PURE__ */ new Date()).toISOString(), it = (i) => {
|
|
270
|
+
Oe(i), Qe(i);
|
|
271
271
|
const e = i.instrumentations ?? {
|
|
272
272
|
errors: !0,
|
|
273
273
|
webVitals: !0,
|
|
274
274
|
session: !0
|
|
275
275
|
};
|
|
276
|
-
return e.session !== !1 &&
|
|
276
|
+
return e.session !== !1 && st(i), e.errors !== !1 && et(i), e.webVitals !== !1 && nt(i), {
|
|
277
277
|
pushError(t, s) {
|
|
278
278
|
w({
|
|
279
279
|
type: "exception",
|
|
280
280
|
payload: {
|
|
281
281
|
type: t.name,
|
|
282
282
|
value: t.message,
|
|
283
|
-
timestamp:
|
|
284
|
-
stacktrace: t.stack ? { frames:
|
|
283
|
+
timestamp: U(),
|
|
284
|
+
stacktrace: t.stack ? { frames: Z(t.stack) } : void 0,
|
|
285
285
|
context: s?.context
|
|
286
286
|
}
|
|
287
287
|
}, i);
|
|
@@ -291,7 +291,7 @@ const Qe = (i) => {
|
|
|
291
291
|
type: "event",
|
|
292
292
|
payload: {
|
|
293
293
|
name: t,
|
|
294
|
-
timestamp:
|
|
294
|
+
timestamp: U(),
|
|
295
295
|
attributes: s
|
|
296
296
|
}
|
|
297
297
|
}, i);
|
|
@@ -302,7 +302,7 @@ const Qe = (i) => {
|
|
|
302
302
|
payload: {
|
|
303
303
|
type: t.type,
|
|
304
304
|
values: t.values,
|
|
305
|
-
timestamp:
|
|
305
|
+
timestamp: U(),
|
|
306
306
|
context: t.context
|
|
307
307
|
}
|
|
308
308
|
}, i);
|
|
@@ -312,39 +312,39 @@ const Qe = (i) => {
|
|
|
312
312
|
type: "log",
|
|
313
313
|
payload: {
|
|
314
314
|
message: t.join(" "),
|
|
315
|
-
level: s?.level ??
|
|
316
|
-
timestamp:
|
|
315
|
+
level: s?.level ?? H.INFO,
|
|
316
|
+
timestamp: U(),
|
|
317
317
|
context: s?.context
|
|
318
318
|
}
|
|
319
319
|
}, i);
|
|
320
320
|
},
|
|
321
321
|
setUser(t) {
|
|
322
|
-
|
|
322
|
+
He(t);
|
|
323
323
|
},
|
|
324
324
|
resetUser() {
|
|
325
|
-
|
|
325
|
+
ze();
|
|
326
326
|
},
|
|
327
327
|
setView(t) {
|
|
328
|
-
|
|
328
|
+
Ke(t);
|
|
329
329
|
},
|
|
330
330
|
flush() {
|
|
331
|
-
|
|
331
|
+
K(i);
|
|
332
332
|
}
|
|
333
333
|
};
|
|
334
|
-
},
|
|
334
|
+
}, at = (i) => i === "test" ? "https://sandbox-analytics.odus.com/collect" : "https://analytics.odus.com/collect", rt = () => {
|
|
335
335
|
if (typeof window > "u")
|
|
336
336
|
return !1;
|
|
337
337
|
const i = window.location.hostname;
|
|
338
338
|
return i === "localhost" || i === "127.0.0.1" || i === "0.0.0.0" || i === "::1" || i === "[::1]" || i.endsWith(".localhost");
|
|
339
339
|
};
|
|
340
|
-
let
|
|
341
|
-
const
|
|
342
|
-
if (
|
|
343
|
-
return
|
|
344
|
-
if (
|
|
340
|
+
let C = null;
|
|
341
|
+
const ot = (i) => {
|
|
342
|
+
if (C)
|
|
343
|
+
return C;
|
|
344
|
+
if (rt())
|
|
345
345
|
return null;
|
|
346
|
-
const e =
|
|
347
|
-
return
|
|
346
|
+
const e = at(i.environment);
|
|
347
|
+
return C = it({
|
|
348
348
|
url: e,
|
|
349
349
|
app: {
|
|
350
350
|
name: "odus-checkout",
|
|
@@ -375,13 +375,13 @@ const rt = (i) => {
|
|
|
375
375
|
}
|
|
376
376
|
return t;
|
|
377
377
|
}
|
|
378
|
-
}),
|
|
379
|
-
},
|
|
380
|
-
|
|
378
|
+
}), C;
|
|
379
|
+
}, lt = (i, e) => {
|
|
380
|
+
C && C.pushError(i, { context: e });
|
|
381
381
|
}, M = (i, e) => {
|
|
382
|
-
|
|
383
|
-
},
|
|
384
|
-
|
|
382
|
+
C && C.pushEvent(i, e);
|
|
383
|
+
}, oe = (i, e, t, s) => {
|
|
384
|
+
C && C.pushMeasurement({
|
|
385
385
|
type: i,
|
|
386
386
|
values: { [i]: e },
|
|
387
387
|
context: {
|
|
@@ -389,25 +389,25 @@ const rt = (i) => {
|
|
|
389
389
|
...s
|
|
390
390
|
}
|
|
391
391
|
});
|
|
392
|
-
},
|
|
393
|
-
if (!
|
|
392
|
+
}, Tt = (i, e = "info", t) => {
|
|
393
|
+
if (!C) return;
|
|
394
394
|
const s = {
|
|
395
|
-
info:
|
|
396
|
-
warn:
|
|
397
|
-
error:
|
|
395
|
+
info: H.INFO,
|
|
396
|
+
warn: H.WARN,
|
|
397
|
+
error: H.ERROR
|
|
398
398
|
};
|
|
399
|
-
|
|
399
|
+
C.pushLog([i], {
|
|
400
400
|
level: s[e],
|
|
401
401
|
context: t
|
|
402
402
|
});
|
|
403
|
-
},
|
|
403
|
+
}, le = {
|
|
404
404
|
test: "tntwpdhfwng",
|
|
405
405
|
live: "TBD"
|
|
406
|
-
},
|
|
406
|
+
}, de = {
|
|
407
407
|
test: "sandbox",
|
|
408
408
|
live: "live"
|
|
409
409
|
};
|
|
410
|
-
class
|
|
410
|
+
class L {
|
|
411
411
|
vgsForm = null;
|
|
412
412
|
fields = [];
|
|
413
413
|
readyResolve;
|
|
@@ -419,18 +419,18 @@ class T {
|
|
|
419
419
|
});
|
|
420
420
|
}
|
|
421
421
|
async init(e) {
|
|
422
|
-
return this.environment = e, await
|
|
423
|
-
vaultId:
|
|
424
|
-
environment:
|
|
425
|
-
version: "3.
|
|
422
|
+
return this.environment = e, await fe({
|
|
423
|
+
vaultId: le[e],
|
|
424
|
+
environment: de[e],
|
|
425
|
+
version: "3.3.0"
|
|
426
426
|
});
|
|
427
427
|
}
|
|
428
428
|
createForm(e, t) {
|
|
429
429
|
if (!this.environment)
|
|
430
430
|
throw new Error("VGS not initialized — call init() first");
|
|
431
431
|
return this.vgsForm = e.create(
|
|
432
|
-
oe[this.environment],
|
|
433
432
|
le[this.environment],
|
|
433
|
+
de[this.environment],
|
|
434
434
|
t
|
|
435
435
|
), this.readyResolve?.(), this.vgsForm;
|
|
436
436
|
}
|
|
@@ -479,10 +479,10 @@ class T {
|
|
|
479
479
|
luhn: !0
|
|
480
480
|
}
|
|
481
481
|
],
|
|
482
|
-
css: t
|
|
482
|
+
css: t.cardNumber
|
|
483
483
|
});
|
|
484
484
|
n.on("update", (r) => {
|
|
485
|
-
a && a(
|
|
485
|
+
a && a(L.mapCardType(r.cardType));
|
|
486
486
|
}), this.fields.push(n);
|
|
487
487
|
}
|
|
488
488
|
if (e.cardExpiry) {
|
|
@@ -492,7 +492,13 @@ class T {
|
|
|
492
492
|
placeholder: s.cardExpiry,
|
|
493
493
|
autoComplete: "cc-exp",
|
|
494
494
|
validations: ["required", "validCardExpirationDate"],
|
|
495
|
-
|
|
495
|
+
serializers: [
|
|
496
|
+
{
|
|
497
|
+
name: "separate",
|
|
498
|
+
options: { monthName: "month", yearName: "year" }
|
|
499
|
+
}
|
|
500
|
+
],
|
|
501
|
+
css: t.cardExpiry
|
|
496
502
|
}
|
|
497
503
|
);
|
|
498
504
|
this.fields.push(n);
|
|
@@ -502,7 +508,7 @@ class T {
|
|
|
502
508
|
placeholder: s.cardCvv,
|
|
503
509
|
autoComplete: "cc-csc",
|
|
504
510
|
validations: ["required", "validCardSecurityCode"],
|
|
505
|
-
css: t
|
|
511
|
+
css: t.cardCvv
|
|
506
512
|
});
|
|
507
513
|
this.fields.push(n);
|
|
508
514
|
}
|
|
@@ -513,7 +519,7 @@ class T {
|
|
|
513
519
|
placeholder: s.cardholderName,
|
|
514
520
|
autoComplete: "cc-name",
|
|
515
521
|
validations: ["required"],
|
|
516
|
-
css: t
|
|
522
|
+
css: t.cardholderName
|
|
517
523
|
}
|
|
518
524
|
);
|
|
519
525
|
this.fields.push(n);
|
|
@@ -543,7 +549,7 @@ class T {
|
|
|
543
549
|
this.patchCard(e, o.id).then(s).catch(a);
|
|
544
550
|
return;
|
|
545
551
|
}
|
|
546
|
-
s(
|
|
552
|
+
s(L.extractCardResult(o));
|
|
547
553
|
},
|
|
548
554
|
(n) => {
|
|
549
555
|
a(n);
|
|
@@ -586,11 +592,11 @@ class T {
|
|
|
586
592
|
n(new Error("Card update failed: no card ID returned"));
|
|
587
593
|
return;
|
|
588
594
|
}
|
|
589
|
-
const c =
|
|
595
|
+
const c = L.extractCardResult(d), u = o.included?.find(
|
|
590
596
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
591
|
-
(
|
|
597
|
+
(S) => S.type === "card_updates"
|
|
592
598
|
);
|
|
593
|
-
|
|
599
|
+
u?.attributes?.updated_values?.length && (c.updatedValues = u.attributes.updated_values), a(c);
|
|
594
600
|
},
|
|
595
601
|
(r) => {
|
|
596
602
|
n(r);
|
|
@@ -627,7 +633,7 @@ class T {
|
|
|
627
633
|
}[e] ?? "unknown" : "unknown";
|
|
628
634
|
}
|
|
629
635
|
}
|
|
630
|
-
function
|
|
636
|
+
function G(i) {
|
|
631
637
|
return {
|
|
632
638
|
name: "Custom Appearance",
|
|
633
639
|
additionalPaymentMethods: i.additionalPaymentMethods || {},
|
|
@@ -727,16 +733,16 @@ function Y(i) {
|
|
|
727
733
|
}
|
|
728
734
|
};
|
|
729
735
|
}
|
|
730
|
-
function
|
|
736
|
+
function dt({
|
|
731
737
|
appearance: i
|
|
732
738
|
}) {
|
|
733
|
-
const e =
|
|
739
|
+
const e = me({
|
|
734
740
|
checkoutProfile: void 0,
|
|
735
741
|
isLoading: !0,
|
|
736
742
|
error: null
|
|
737
743
|
});
|
|
738
744
|
if (i) {
|
|
739
|
-
const s =
|
|
745
|
+
const s = G(i);
|
|
740
746
|
return Promise.resolve().then(() => {
|
|
741
747
|
e.setState({
|
|
742
748
|
checkoutProfile: s,
|
|
@@ -747,7 +753,7 @@ function lt({
|
|
|
747
753
|
getState: e.getState.bind(e),
|
|
748
754
|
subscribe: e.subscribe.bind(e),
|
|
749
755
|
updateProfile: (a) => {
|
|
750
|
-
const n =
|
|
756
|
+
const n = G(a);
|
|
751
757
|
e.setState({
|
|
752
758
|
checkoutProfile: n,
|
|
753
759
|
isLoading: !1,
|
|
@@ -796,7 +802,7 @@ function lt({
|
|
|
796
802
|
getState: e.getState.bind(e),
|
|
797
803
|
subscribe: e.subscribe.bind(e),
|
|
798
804
|
updateProfile: (s) => {
|
|
799
|
-
const a =
|
|
805
|
+
const a = G(s);
|
|
800
806
|
e.setState({
|
|
801
807
|
checkoutProfile: a,
|
|
802
808
|
isLoading: !1,
|
|
@@ -807,8 +813,8 @@ function lt({
|
|
|
807
813
|
}
|
|
808
814
|
};
|
|
809
815
|
}
|
|
810
|
-
const
|
|
811
|
-
const i =
|
|
816
|
+
const ct = () => {
|
|
817
|
+
const i = ye(), e = me({
|
|
812
818
|
formData: {
|
|
813
819
|
name: "",
|
|
814
820
|
email: "",
|
|
@@ -825,159 +831,159 @@ const dt = () => {
|
|
|
825
831
|
cardCvv: !1
|
|
826
832
|
},
|
|
827
833
|
isValid: !1
|
|
828
|
-
}), t = (l,
|
|
834
|
+
}), t = (l, p, y, m) => {
|
|
829
835
|
if (l === "cardCvv")
|
|
830
|
-
return i.cardCvv(
|
|
831
|
-
if (l === "phoneNumber" &&
|
|
832
|
-
return i.phoneNumber(
|
|
836
|
+
return i.cardCvv(p, y);
|
|
837
|
+
if (l === "phoneNumber" && m)
|
|
838
|
+
return i.phoneNumber(p, m);
|
|
833
839
|
const g = i[l];
|
|
834
|
-
return g?.(
|
|
840
|
+
return g?.(p);
|
|
835
841
|
}, s = (l) => {
|
|
836
|
-
const
|
|
837
|
-
return Object.keys(l).forEach((
|
|
838
|
-
const g = l[
|
|
842
|
+
const p = {};
|
|
843
|
+
return Object.keys(l).forEach((m) => {
|
|
844
|
+
const g = l[m];
|
|
839
845
|
if (g === void 0) return;
|
|
840
846
|
let h;
|
|
841
|
-
|
|
842
|
-
|
|
847
|
+
m === "cardCvv" ? h = t(m, g, l.cardNumber) : m === "phoneNumber" ? h = t(
|
|
848
|
+
m,
|
|
843
849
|
g,
|
|
844
850
|
void 0,
|
|
845
851
|
l.phoneCountryCode
|
|
846
|
-
) : h = t(
|
|
852
|
+
) : h = t(m, g), h && (p[m] = h);
|
|
847
853
|
}), [
|
|
848
854
|
"billingAddress",
|
|
849
855
|
"shippingAddress"
|
|
850
|
-
].forEach((
|
|
851
|
-
const g = l[
|
|
856
|
+
].forEach((m) => {
|
|
857
|
+
const g = l[m];
|
|
852
858
|
if (g && typeof g == "object") {
|
|
853
859
|
const h = {};
|
|
854
860
|
Object.keys(g).forEach(
|
|
855
|
-
(
|
|
856
|
-
const f = g[
|
|
861
|
+
(b) => {
|
|
862
|
+
const f = g[b];
|
|
857
863
|
if (f === void 0) return;
|
|
858
|
-
const
|
|
859
|
-
if (
|
|
860
|
-
const
|
|
864
|
+
const v = i[b];
|
|
865
|
+
if (v) {
|
|
866
|
+
const E = b === "state" ? i.state(f, g.country) : v(
|
|
861
867
|
f
|
|
862
868
|
);
|
|
863
|
-
|
|
869
|
+
E && (h[b] = E);
|
|
864
870
|
}
|
|
865
871
|
}
|
|
866
|
-
), Object.keys(h).length > 0 && (
|
|
872
|
+
), Object.keys(h).length > 0 && (p[m] = h);
|
|
867
873
|
}
|
|
868
|
-
}),
|
|
874
|
+
}), p;
|
|
869
875
|
}, a = (l) => {
|
|
870
|
-
const
|
|
871
|
-
return Object.keys(
|
|
876
|
+
const p = s(l);
|
|
877
|
+
return Object.keys(p).length === 0;
|
|
872
878
|
}, n = "billingAddress.", r = "shippingAddress.", o = (l) => l.startsWith(n) ? {
|
|
873
879
|
parent: "billingAddress",
|
|
874
880
|
field: l.slice(n.length)
|
|
875
881
|
} : l.startsWith(r) ? {
|
|
876
882
|
parent: "shippingAddress",
|
|
877
883
|
field: l.slice(r.length)
|
|
878
|
-
} : null, d = (l,
|
|
884
|
+
} : null, d = (l, p, y, m) => {
|
|
879
885
|
const g = { ...l };
|
|
880
|
-
if (
|
|
881
|
-
g[
|
|
882
|
-
...g[
|
|
883
|
-
[y]:
|
|
886
|
+
if (m)
|
|
887
|
+
g[p] = {
|
|
888
|
+
...g[p],
|
|
889
|
+
[y]: m
|
|
884
890
|
};
|
|
885
891
|
else {
|
|
886
892
|
const h = {
|
|
887
|
-
...g[
|
|
893
|
+
...g[p]
|
|
888
894
|
};
|
|
889
|
-
delete h[y], Object.keys(h).length === 0 ? delete g[
|
|
895
|
+
delete h[y], Object.keys(h).length === 0 ? delete g[p] : g[p] = h;
|
|
890
896
|
}
|
|
891
897
|
return g;
|
|
892
|
-
}, c = (l,
|
|
898
|
+
}, c = (l, p) => {
|
|
893
899
|
const y = e.getState();
|
|
894
|
-
let
|
|
900
|
+
let m = p;
|
|
895
901
|
const g = o(l);
|
|
896
|
-
if (!g && l in
|
|
902
|
+
if (!g && l in q)
|
|
897
903
|
if (l === "cardCvv") {
|
|
898
|
-
const
|
|
899
|
-
|
|
904
|
+
const v = be(y.formData.cardNumber) === "amex" ? 4 : 3;
|
|
905
|
+
m = q.cardCvv(p, v);
|
|
900
906
|
} else
|
|
901
|
-
|
|
907
|
+
m = q[l](p);
|
|
902
908
|
let h;
|
|
903
909
|
if (g) {
|
|
904
|
-
const { parent: f, field:
|
|
910
|
+
const { parent: f, field: v } = g;
|
|
905
911
|
h = {
|
|
906
912
|
...y.formData,
|
|
907
913
|
[f]: {
|
|
908
914
|
...y.formData[f] ?? {},
|
|
909
|
-
[
|
|
915
|
+
[v]: m
|
|
910
916
|
}
|
|
911
917
|
};
|
|
912
918
|
} else
|
|
913
919
|
h = {
|
|
914
920
|
...y.formData,
|
|
915
|
-
[l]:
|
|
921
|
+
[l]: m
|
|
916
922
|
};
|
|
917
|
-
let
|
|
923
|
+
let b = { ...y.errors };
|
|
918
924
|
if (l === "phoneCountryCode" && h.phoneNumber) {
|
|
919
925
|
const f = t(
|
|
920
926
|
"phoneNumber",
|
|
921
927
|
h.phoneNumber,
|
|
922
928
|
void 0,
|
|
923
|
-
|
|
929
|
+
m
|
|
924
930
|
);
|
|
925
|
-
f ?
|
|
931
|
+
f ? b.phoneNumber = f : delete b.phoneNumber;
|
|
926
932
|
}
|
|
927
933
|
if (y.touched[l])
|
|
928
934
|
if (g) {
|
|
929
|
-
const { parent: f, field:
|
|
935
|
+
const { parent: f, field: v } = g, E = h[f];
|
|
930
936
|
let N;
|
|
931
|
-
if (
|
|
932
|
-
N = i.state(
|
|
937
|
+
if (v === "state")
|
|
938
|
+
N = i.state(m, E?.country);
|
|
933
939
|
else {
|
|
934
|
-
const
|
|
935
|
-
N =
|
|
936
|
-
|
|
940
|
+
const x = i[v];
|
|
941
|
+
N = x ? x(
|
|
942
|
+
m
|
|
937
943
|
) : void 0;
|
|
938
944
|
}
|
|
939
|
-
|
|
945
|
+
b = d(b, f, v, N);
|
|
940
946
|
} else {
|
|
941
947
|
let f;
|
|
942
|
-
l === "cardCvv" ? f = t(l,
|
|
948
|
+
l === "cardCvv" ? f = t(l, m, h.cardNumber) : l === "phoneNumber" ? f = t(
|
|
943
949
|
l,
|
|
944
|
-
|
|
950
|
+
m,
|
|
945
951
|
void 0,
|
|
946
952
|
h.phoneCountryCode
|
|
947
|
-
) : f = t(l,
|
|
953
|
+
) : f = t(l, m), f ? b[l] = f : delete b[l];
|
|
948
954
|
}
|
|
949
955
|
e.setState({
|
|
950
956
|
formData: h,
|
|
951
|
-
errors:
|
|
957
|
+
errors: b,
|
|
952
958
|
isValid: a(h)
|
|
953
959
|
});
|
|
954
|
-
},
|
|
955
|
-
const y = e.getState(),
|
|
956
|
-
if (
|
|
957
|
-
const { parent: f, field:
|
|
960
|
+
}, u = (l, p) => {
|
|
961
|
+
const y = e.getState(), m = o(l);
|
|
962
|
+
if (m) {
|
|
963
|
+
const { parent: f, field: v } = m, E = {
|
|
958
964
|
...y.formData,
|
|
959
965
|
[f]: {
|
|
960
966
|
...y.formData[f] ?? {},
|
|
961
|
-
[
|
|
967
|
+
[v]: p
|
|
962
968
|
}
|
|
963
969
|
};
|
|
964
970
|
let N;
|
|
965
|
-
if (
|
|
966
|
-
const
|
|
967
|
-
N = i.state(
|
|
971
|
+
if (v === "state") {
|
|
972
|
+
const V = E[f];
|
|
973
|
+
N = i.state(p, V?.country);
|
|
968
974
|
} else {
|
|
969
|
-
const
|
|
970
|
-
N =
|
|
975
|
+
const V = i[v];
|
|
976
|
+
N = V ? V(p) : void 0;
|
|
971
977
|
}
|
|
972
|
-
const
|
|
978
|
+
const x = d(y.errors, f, v, N);
|
|
973
979
|
e.setState({
|
|
974
|
-
formData:
|
|
980
|
+
formData: E,
|
|
975
981
|
touched: {
|
|
976
982
|
...y.touched,
|
|
977
983
|
[l]: !0
|
|
978
984
|
},
|
|
979
|
-
errors:
|
|
980
|
-
isValid: a(
|
|
985
|
+
errors: x,
|
|
986
|
+
isValid: a(E)
|
|
981
987
|
});
|
|
982
988
|
return;
|
|
983
989
|
}
|
|
@@ -986,18 +992,18 @@ const dt = () => {
|
|
|
986
992
|
[l]: !0
|
|
987
993
|
};
|
|
988
994
|
let h;
|
|
989
|
-
l === "cardCvv" ? h = t(l,
|
|
995
|
+
l === "cardCvv" ? h = t(l, p, y.formData.cardNumber) : l === "phoneNumber" ? h = t(
|
|
990
996
|
l,
|
|
991
|
-
|
|
997
|
+
p,
|
|
992
998
|
void 0,
|
|
993
999
|
y.formData.phoneCountryCode
|
|
994
|
-
) : h = t(l,
|
|
995
|
-
const
|
|
996
|
-
h ?
|
|
1000
|
+
) : h = t(l, p);
|
|
1001
|
+
const b = { ...y.errors };
|
|
1002
|
+
h ? b[l] = h : delete b[l], e.setState({
|
|
997
1003
|
touched: g,
|
|
998
|
-
errors:
|
|
1004
|
+
errors: b
|
|
999
1005
|
});
|
|
1000
|
-
},
|
|
1006
|
+
}, S = (l) => {
|
|
1001
1007
|
const y = {
|
|
1002
1008
|
...e.getState().formData,
|
|
1003
1009
|
...l
|
|
@@ -1011,37 +1017,37 @@ const dt = () => {
|
|
|
1011
1017
|
getFormState: e.getState.bind(e),
|
|
1012
1018
|
subscribe: e.subscribe.bind(e),
|
|
1013
1019
|
handleChange: c,
|
|
1014
|
-
handleBlur:
|
|
1015
|
-
setFormData:
|
|
1020
|
+
handleBlur: u,
|
|
1021
|
+
setFormData: S,
|
|
1016
1022
|
reset: e.resetState.bind(e)
|
|
1017
1023
|
};
|
|
1018
|
-
},
|
|
1019
|
-
async function
|
|
1024
|
+
}, ht = "https://fonts.googleapis.com/css2", ut = /src:\s*url\(([^)]+\.woff2[^)]*)\)/, mt = /\/\*\s*latin\s*\*\/\s*@font-face\s*\{[^}]*src:\s*url\(([^)]+\.woff2[^)]*)\)[^}]*\}/;
|
|
1025
|
+
async function pt(i) {
|
|
1020
1026
|
if (!i) return null;
|
|
1021
|
-
const e = i.trim().replace(/\s+/g, "+"), t = `${
|
|
1027
|
+
const e = i.trim().replace(/\s+/g, "+"), t = `${ht}?family=${e}:wght@400;700&display=swap`;
|
|
1022
1028
|
try {
|
|
1023
1029
|
const s = await fetch(t);
|
|
1024
1030
|
if (!s.ok) return null;
|
|
1025
|
-
const a = await s.text(), n =
|
|
1031
|
+
const a = await s.text(), n = mt.exec(a);
|
|
1026
1032
|
if (n?.[1]) return n[1];
|
|
1027
|
-
const r =
|
|
1033
|
+
const r = ut.exec(a);
|
|
1028
1034
|
return r?.[1] ? r[1] : null;
|
|
1029
1035
|
} catch {
|
|
1030
1036
|
return null;
|
|
1031
1037
|
}
|
|
1032
1038
|
}
|
|
1033
|
-
function
|
|
1039
|
+
function gt(i) {
|
|
1034
1040
|
if (!i) return !1;
|
|
1035
1041
|
const { billingFields: e, shippingFields: t } = i, s = e && Object.values(e).some((n) => n?.enabled), a = t && Object.values(t).some((n) => n?.enabled);
|
|
1036
1042
|
return !!(s || a);
|
|
1037
1043
|
}
|
|
1038
|
-
function
|
|
1044
|
+
function J(i) {
|
|
1039
1045
|
if (!i) return !1;
|
|
1040
1046
|
const { billingFields: e, shippingFields: t } = i, s = e?.firstName?.enabled && e?.lastName?.enabled, a = t?.firstName?.enabled && t?.lastName?.enabled;
|
|
1041
1047
|
return !!(s || a);
|
|
1042
1048
|
}
|
|
1043
|
-
const
|
|
1044
|
-
class
|
|
1049
|
+
const O = /* @__PURE__ */ new Set(["US", "CA"]);
|
|
1050
|
+
class ce extends A {
|
|
1045
1051
|
inputs = /* @__PURE__ */ new Map();
|
|
1046
1052
|
type;
|
|
1047
1053
|
onChange;
|
|
@@ -1086,22 +1092,22 @@ class de extends k {
|
|
|
1086
1092
|
t.street?.enabled && d.push({ kind: "street" });
|
|
1087
1093
|
const c = [];
|
|
1088
1094
|
t.firstName?.enabled && c.push("firstName"), t.lastName?.enabled && c.push("lastName"), c.length > 0 && d.push({ kind: "name", fields: c }), t.country?.enabled && d.push({ kind: "country" });
|
|
1089
|
-
const
|
|
1090
|
-
t.city?.enabled &&
|
|
1091
|
-
const
|
|
1092
|
-
d.forEach((l,
|
|
1093
|
-
const y =
|
|
1095
|
+
const u = [];
|
|
1096
|
+
t.city?.enabled && u.push("city"), t.zipCode?.enabled && u.push("zipCode"), u.length > 0 && d.push({ kind: "cityZip", fields: u }), t.state?.enabled && d.push({ kind: "state" });
|
|
1097
|
+
const S = d.length;
|
|
1098
|
+
d.forEach((l, p) => {
|
|
1099
|
+
const y = p === 0, m = p === S - 1, g = (h, b) => ({
|
|
1094
1100
|
...o,
|
|
1095
1101
|
borderRadius: this.borderRadius(
|
|
1096
1102
|
r,
|
|
1097
1103
|
y && h,
|
|
1098
|
-
y &&
|
|
1099
|
-
|
|
1100
|
-
|
|
1104
|
+
y && b,
|
|
1105
|
+
m && b,
|
|
1106
|
+
m && h
|
|
1101
1107
|
)
|
|
1102
1108
|
});
|
|
1103
1109
|
if (l.kind === "street") {
|
|
1104
|
-
const h = this.createRow(["full"]),
|
|
1110
|
+
const h = this.createRow(["full"]), b = this.createInput(
|
|
1105
1111
|
"street",
|
|
1106
1112
|
t.street?.label ?? this.translationFunc("address.addressLine1"),
|
|
1107
1113
|
s.street,
|
|
@@ -1110,13 +1116,13 @@ class de extends k {
|
|
|
1110
1116
|
g(!0, !0),
|
|
1111
1117
|
"street-address"
|
|
1112
1118
|
);
|
|
1113
|
-
this.inputs.set("street",
|
|
1119
|
+
this.inputs.set("street", b), h.appendChild(b.getElement()), this.fieldsContainer.appendChild(h);
|
|
1114
1120
|
return;
|
|
1115
1121
|
}
|
|
1116
1122
|
if (l.kind === "name") {
|
|
1117
|
-
const h = this.createRow(l.fields.map(() => "half")),
|
|
1123
|
+
const h = this.createRow(l.fields.map(() => "half")), b = l.fields.length === 1;
|
|
1118
1124
|
if (l.fields.includes("firstName")) {
|
|
1119
|
-
const f =
|
|
1125
|
+
const f = b || l.fields[l.fields.length - 1] === "firstName", v = this.createInput(
|
|
1120
1126
|
"firstName",
|
|
1121
1127
|
t.firstName?.label ?? this.translationFunc("address.firstName"),
|
|
1122
1128
|
s.firstName,
|
|
@@ -1125,10 +1131,10 @@ class de extends k {
|
|
|
1125
1131
|
g(!0, f),
|
|
1126
1132
|
"given-name"
|
|
1127
1133
|
);
|
|
1128
|
-
this.inputs.set("firstName",
|
|
1134
|
+
this.inputs.set("firstName", v), h.appendChild(v.getElement());
|
|
1129
1135
|
}
|
|
1130
1136
|
if (l.fields.includes("lastName")) {
|
|
1131
|
-
const f =
|
|
1137
|
+
const f = b || l.fields[0] === "lastName", v = this.createInput(
|
|
1132
1138
|
"lastName",
|
|
1133
1139
|
t.lastName?.label ?? this.translationFunc("address.lastName"),
|
|
1134
1140
|
s.lastName,
|
|
@@ -1137,13 +1143,13 @@ class de extends k {
|
|
|
1137
1143
|
g(f, !0),
|
|
1138
1144
|
"family-name"
|
|
1139
1145
|
);
|
|
1140
|
-
this.inputs.set("lastName",
|
|
1146
|
+
this.inputs.set("lastName", v), h.appendChild(v.getElement());
|
|
1141
1147
|
}
|
|
1142
1148
|
this.fieldsContainer.appendChild(h);
|
|
1143
1149
|
return;
|
|
1144
1150
|
}
|
|
1145
1151
|
if (l.kind === "country") {
|
|
1146
|
-
const h = this.createRow(["full"]),
|
|
1152
|
+
const h = this.createRow(["full"]), b = this.createCountrySelect(
|
|
1147
1153
|
s.country,
|
|
1148
1154
|
a.country,
|
|
1149
1155
|
n.country,
|
|
@@ -1151,13 +1157,13 @@ class de extends k {
|
|
|
1151
1157
|
t.country?.options,
|
|
1152
1158
|
t.country?.label
|
|
1153
1159
|
);
|
|
1154
|
-
this.inputs.set("country",
|
|
1160
|
+
this.inputs.set("country", b), h.appendChild(b.getElement()), this.fieldsContainer.appendChild(h);
|
|
1155
1161
|
return;
|
|
1156
1162
|
}
|
|
1157
1163
|
if (l.kind === "cityZip") {
|
|
1158
|
-
const h = this.createRow(l.fields.map(() => "half")),
|
|
1164
|
+
const h = this.createRow(l.fields.map(() => "half")), b = l.fields.length === 1;
|
|
1159
1165
|
if (l.fields.includes("city")) {
|
|
1160
|
-
const f =
|
|
1166
|
+
const f = b || l.fields[l.fields.length - 1] === "city", v = this.createInput(
|
|
1161
1167
|
"city",
|
|
1162
1168
|
t.city?.label ?? this.translationFunc("address.townCity"),
|
|
1163
1169
|
s.city,
|
|
@@ -1166,10 +1172,10 @@ class de extends k {
|
|
|
1166
1172
|
g(!0, f),
|
|
1167
1173
|
"address-level2"
|
|
1168
1174
|
);
|
|
1169
|
-
this.inputs.set("city",
|
|
1175
|
+
this.inputs.set("city", v), h.appendChild(v.getElement());
|
|
1170
1176
|
}
|
|
1171
1177
|
if (l.fields.includes("zipCode")) {
|
|
1172
|
-
const f =
|
|
1178
|
+
const f = b || l.fields[0] === "zipCode", v = this.createInput(
|
|
1173
1179
|
"zipCode",
|
|
1174
1180
|
t.zipCode?.label ?? this.translationFunc("address.postalCode"),
|
|
1175
1181
|
s.zipCode,
|
|
@@ -1178,7 +1184,7 @@ class de extends k {
|
|
|
1178
1184
|
g(f, !0),
|
|
1179
1185
|
"postal-code"
|
|
1180
1186
|
);
|
|
1181
|
-
this.inputs.set("zipCode",
|
|
1187
|
+
this.inputs.set("zipCode", v), h.appendChild(v.getElement());
|
|
1182
1188
|
}
|
|
1183
1189
|
this.fieldsContainer.appendChild(h);
|
|
1184
1190
|
return;
|
|
@@ -1187,8 +1193,8 @@ class de extends k {
|
|
|
1187
1193
|
const h = this.createRow(["full"]);
|
|
1188
1194
|
if (this.stateFieldConfig = t.state, this.stateRow = h, this.stateStyles = g(!0, !0), this.currentCountry = s.country, t.state?.hiddenForCountries?.includes(
|
|
1189
1195
|
s.country
|
|
1190
|
-
) && (h.style.display = "none"),
|
|
1191
|
-
const
|
|
1196
|
+
) && (h.style.display = "none"), O.has(s.country)) {
|
|
1197
|
+
const v = this.createStateSelect(
|
|
1192
1198
|
s.state,
|
|
1193
1199
|
a.state,
|
|
1194
1200
|
n.state,
|
|
@@ -1196,9 +1202,9 @@ class de extends k {
|
|
|
1196
1202
|
s.country,
|
|
1197
1203
|
t.state?.label
|
|
1198
1204
|
);
|
|
1199
|
-
this.inputs.set("state",
|
|
1205
|
+
this.inputs.set("state", v), h.appendChild(v.getElement());
|
|
1200
1206
|
} else {
|
|
1201
|
-
const
|
|
1207
|
+
const v = this.createInput(
|
|
1202
1208
|
"state",
|
|
1203
1209
|
t.state?.label ?? this.translationFunc("address.state"),
|
|
1204
1210
|
s.state,
|
|
@@ -1207,7 +1213,7 @@ class de extends k {
|
|
|
1207
1213
|
this.stateStyles,
|
|
1208
1214
|
"address-level1"
|
|
1209
1215
|
);
|
|
1210
|
-
this.inputs.set("state",
|
|
1216
|
+
this.inputs.set("state", v), h.appendChild(v.getElement());
|
|
1211
1217
|
}
|
|
1212
1218
|
this.fieldsContainer.appendChild(h);
|
|
1213
1219
|
}
|
|
@@ -1218,7 +1224,7 @@ class de extends k {
|
|
|
1218
1224
|
return t.className = `address-row address-row-${e.length === 1 ? "single" : "double"}`, t;
|
|
1219
1225
|
}
|
|
1220
1226
|
createInput(e, t, s, a, n, r, o) {
|
|
1221
|
-
const d = `${this.type}Address.${e}`, c = new
|
|
1227
|
+
const d = `${this.type}Address.${e}`, c = new pe({
|
|
1222
1228
|
name: d,
|
|
1223
1229
|
error: !1,
|
|
1224
1230
|
errorMsg: void 0,
|
|
@@ -1226,37 +1232,38 @@ class de extends k {
|
|
|
1226
1232
|
...this.grouped ? { placeholder: t } : {
|
|
1227
1233
|
label: t,
|
|
1228
1234
|
placeholder: (() => {
|
|
1229
|
-
const
|
|
1230
|
-
return
|
|
1235
|
+
const u = `address.placeholder.${e}`, S = this.translationFunc(u);
|
|
1236
|
+
return S !== u ? S : t;
|
|
1231
1237
|
})()
|
|
1232
1238
|
},
|
|
1233
1239
|
value: s,
|
|
1234
1240
|
autocomplete: o,
|
|
1235
|
-
onChange: (
|
|
1236
|
-
c.setError(!1)
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1241
|
+
onChange: (u) => {
|
|
1242
|
+
c.setError(!1), this.onChange(
|
|
1243
|
+
P({
|
|
1244
|
+
type: "input",
|
|
1245
|
+
target: {
|
|
1246
|
+
name: d,
|
|
1247
|
+
value: u.target.value
|
|
1248
|
+
}
|
|
1249
|
+
})
|
|
1250
|
+
);
|
|
1245
1251
|
}
|
|
1246
1252
|
});
|
|
1247
|
-
return c.addEventListener("blur", (
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1253
|
+
return c.addEventListener("blur", (u) => {
|
|
1254
|
+
this.onBlur(
|
|
1255
|
+
P({
|
|
1256
|
+
type: "blur",
|
|
1257
|
+
target: {
|
|
1258
|
+
name: d,
|
|
1259
|
+
value: u.target.value
|
|
1260
|
+
}
|
|
1261
|
+
})
|
|
1262
|
+
);
|
|
1256
1263
|
}), c;
|
|
1257
1264
|
}
|
|
1258
1265
|
createCountrySelect(e, t, s, a, n, r) {
|
|
1259
|
-
const o = `${this.type}Address.country`, d =
|
|
1266
|
+
const o = `${this.type}Address.country`, d = ve(n, this.locale), c = new _({
|
|
1260
1267
|
name: o,
|
|
1261
1268
|
error: !1,
|
|
1262
1269
|
errorMsg: void 0,
|
|
@@ -1268,27 +1275,27 @@ class de extends k {
|
|
|
1268
1275
|
value: e,
|
|
1269
1276
|
options: d,
|
|
1270
1277
|
autocomplete: "country",
|
|
1271
|
-
onChange: (
|
|
1278
|
+
onChange: (u) => {
|
|
1272
1279
|
c.setError(!1);
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
name: o,
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
}), this.onChange(l), this.handleCountryChange(b);
|
|
1280
|
+
const S = u.target.value;
|
|
1281
|
+
this.onChange(
|
|
1282
|
+
P({
|
|
1283
|
+
type: "change",
|
|
1284
|
+
target: { name: o, value: S }
|
|
1285
|
+
})
|
|
1286
|
+
), this.handleCountryChange(S);
|
|
1281
1287
|
}
|
|
1282
1288
|
});
|
|
1283
|
-
return c.addEventListener("blur", (
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1289
|
+
return c.addEventListener("blur", (u) => {
|
|
1290
|
+
this.onBlur(
|
|
1291
|
+
P({
|
|
1292
|
+
type: "blur",
|
|
1293
|
+
target: {
|
|
1294
|
+
name: o,
|
|
1295
|
+
value: u.target.value
|
|
1296
|
+
}
|
|
1297
|
+
})
|
|
1298
|
+
);
|
|
1292
1299
|
}), c;
|
|
1293
1300
|
}
|
|
1294
1301
|
handleCountryChange(e) {
|
|
@@ -1300,12 +1307,12 @@ class de extends k {
|
|
|
1300
1307
|
return;
|
|
1301
1308
|
}
|
|
1302
1309
|
if (!a && s && (this.stateRow.style.display = ""), a) return;
|
|
1303
|
-
const n = this.inputs.get("state") instanceof
|
|
1310
|
+
const n = this.inputs.get("state") instanceof _, r = O.has(e);
|
|
1304
1311
|
if (n && r) {
|
|
1305
1312
|
const o = this.inputs.get("state");
|
|
1306
|
-
if (o instanceof
|
|
1307
|
-
const d = e === "CA" ? "CA" : "US", c =
|
|
1308
|
-
o.setOptions(c,
|
|
1313
|
+
if (o instanceof _) {
|
|
1314
|
+
const d = e === "CA" ? "CA" : "US", c = ee(d), u = d === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState");
|
|
1315
|
+
o.setOptions(c, u);
|
|
1309
1316
|
}
|
|
1310
1317
|
this.clearStateValue();
|
|
1311
1318
|
return;
|
|
@@ -1319,7 +1326,7 @@ class de extends k {
|
|
|
1319
1326
|
rebuildStateField(e) {
|
|
1320
1327
|
if (!this.stateRow || !this.stateStyles) return;
|
|
1321
1328
|
const t = this.inputs.get("state");
|
|
1322
|
-
if (t && (t.getElement().remove(), this.inputs.delete("state")),
|
|
1329
|
+
if (t && (t.getElement().remove(), this.inputs.delete("state")), O.has(e)) {
|
|
1323
1330
|
const a = this.createStateSelect(
|
|
1324
1331
|
"",
|
|
1325
1332
|
void 0,
|
|
@@ -1345,48 +1352,49 @@ class de extends k {
|
|
|
1345
1352
|
clearStateValue() {
|
|
1346
1353
|
const e = this.inputs.get("state");
|
|
1347
1354
|
e && e.setValue("");
|
|
1348
|
-
const t = `${this.type}Address.state
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1355
|
+
const t = `${this.type}Address.state`;
|
|
1356
|
+
this.onChange(
|
|
1357
|
+
P({
|
|
1358
|
+
type: "input",
|
|
1359
|
+
target: { name: t, value: "" },
|
|
1360
|
+
detail: { programmatic: !0 }
|
|
1361
|
+
})
|
|
1362
|
+
);
|
|
1356
1363
|
}
|
|
1357
1364
|
createStateSelect(e, t, s, a, n, r) {
|
|
1358
|
-
const o = `${this.type}Address.state`, d = n === "CA" ? "CA" : "US", c =
|
|
1365
|
+
const o = `${this.type}Address.state`, d = n === "CA" ? "CA" : "US", c = ee(d), u = d === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState"), S = new _({
|
|
1359
1366
|
name: o,
|
|
1360
1367
|
error: !1,
|
|
1361
1368
|
errorMsg: void 0,
|
|
1362
1369
|
styles: a,
|
|
1363
|
-
placeholder:
|
|
1364
|
-
...!this.grouped && { label: r ??
|
|
1370
|
+
placeholder: u,
|
|
1371
|
+
...!this.grouped && { label: r ?? u },
|
|
1365
1372
|
value: e,
|
|
1366
1373
|
options: c,
|
|
1367
1374
|
autocomplete: "address-level1",
|
|
1368
1375
|
onChange: (l) => {
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1376
|
+
S.setError(!1), this.onChange(
|
|
1377
|
+
P({
|
|
1378
|
+
type: "change",
|
|
1379
|
+
target: {
|
|
1380
|
+
name: o,
|
|
1381
|
+
value: l.target.value
|
|
1382
|
+
}
|
|
1383
|
+
})
|
|
1384
|
+
);
|
|
1385
|
+
}
|
|
1386
|
+
});
|
|
1387
|
+
return S.addEventListener("blur", (l) => {
|
|
1388
|
+
this.onBlur(
|
|
1389
|
+
P({
|
|
1390
|
+
type: "blur",
|
|
1391
|
+
target: {
|
|
1374
1392
|
name: o,
|
|
1375
1393
|
value: l.target.value
|
|
1376
1394
|
}
|
|
1377
|
-
})
|
|
1378
|
-
|
|
1379
|
-
});
|
|
1380
|
-
return b.addEventListener("blur", (l) => {
|
|
1381
|
-
const u = new Event("blur", { bubbles: !0 });
|
|
1382
|
-
Object.defineProperty(u, "target", {
|
|
1383
|
-
writable: !1,
|
|
1384
|
-
value: {
|
|
1385
|
-
name: o,
|
|
1386
|
-
value: l.target.value
|
|
1387
|
-
}
|
|
1388
|
-
}), this.onBlur(u);
|
|
1389
|
-
}), b;
|
|
1395
|
+
})
|
|
1396
|
+
);
|
|
1397
|
+
}), S;
|
|
1390
1398
|
}
|
|
1391
1399
|
createUngroupedFields(e, t, s, a, n) {
|
|
1392
1400
|
const r = e.styles.borderRadius, o = {
|
|
@@ -1394,21 +1402,21 @@ class de extends k {
|
|
|
1394
1402
|
fontSize: e.styles.fontSize,
|
|
1395
1403
|
fontFamily: e.styles.fontFamily,
|
|
1396
1404
|
borderRadius: `${r}px`
|
|
1397
|
-
}, d = (c,
|
|
1405
|
+
}, d = (c, u, S) => {
|
|
1398
1406
|
if (!t[c]?.enabled) return;
|
|
1399
|
-
const l = t[c]?.label ?? this.translationFunc(
|
|
1407
|
+
const l = t[c]?.label ?? this.translationFunc(u), p = this.createRow(["full"]), y = this.createInput(
|
|
1400
1408
|
c,
|
|
1401
1409
|
l,
|
|
1402
1410
|
s[c],
|
|
1403
1411
|
a[c],
|
|
1404
1412
|
n[c],
|
|
1405
1413
|
o,
|
|
1406
|
-
|
|
1414
|
+
S
|
|
1407
1415
|
);
|
|
1408
|
-
this.inputs.set(c, y),
|
|
1416
|
+
this.inputs.set(c, y), p.appendChild(y.getElement()), this.fieldsContainer.appendChild(p);
|
|
1409
1417
|
};
|
|
1410
1418
|
if (d("firstName", "address.firstName", "given-name"), d("lastName", "address.lastName", "family-name"), d("street", "address.addressLine1", "street-address"), d("city", "address.townCity", "address-level2"), t.country?.enabled) {
|
|
1411
|
-
const c = t.country?.label ?? this.translationFunc("address.chooseCountry"),
|
|
1419
|
+
const c = t.country?.label ?? this.translationFunc("address.chooseCountry"), u = this.createRow(["full"]), S = this.createCountrySelect(
|
|
1412
1420
|
s.country,
|
|
1413
1421
|
a.country,
|
|
1414
1422
|
n.country,
|
|
@@ -1416,7 +1424,7 @@ class de extends k {
|
|
|
1416
1424
|
t.country?.options,
|
|
1417
1425
|
c
|
|
1418
1426
|
);
|
|
1419
|
-
this.inputs.set("country",
|
|
1427
|
+
this.inputs.set("country", S), u.appendChild(S.getElement()), this.fieldsContainer.appendChild(u);
|
|
1420
1428
|
}
|
|
1421
1429
|
if (t.state?.enabled) {
|
|
1422
1430
|
this.stateFieldConfig = t.state;
|
|
@@ -1424,9 +1432,9 @@ class de extends k {
|
|
|
1424
1432
|
this.stateRow = c, this.stateStyles = o, this.currentCountry = s.country, t.state?.hiddenForCountries?.includes(
|
|
1425
1433
|
s.country
|
|
1426
1434
|
) && (c.style.display = "none");
|
|
1427
|
-
const
|
|
1428
|
-
if (
|
|
1429
|
-
const
|
|
1435
|
+
const S = O.has(s.country), l = t.state?.label ?? this.translationFunc("address.state");
|
|
1436
|
+
if (S) {
|
|
1437
|
+
const p = this.createStateSelect(
|
|
1430
1438
|
s.state,
|
|
1431
1439
|
a.state,
|
|
1432
1440
|
n.state,
|
|
@@ -1434,9 +1442,9 @@ class de extends k {
|
|
|
1434
1442
|
s.country,
|
|
1435
1443
|
l
|
|
1436
1444
|
);
|
|
1437
|
-
this.inputs.set("state",
|
|
1445
|
+
this.inputs.set("state", p), c.appendChild(p.getElement());
|
|
1438
1446
|
} else {
|
|
1439
|
-
const
|
|
1447
|
+
const p = this.createInput(
|
|
1440
1448
|
"state",
|
|
1441
1449
|
l,
|
|
1442
1450
|
s.state,
|
|
@@ -1445,7 +1453,7 @@ class de extends k {
|
|
|
1445
1453
|
o,
|
|
1446
1454
|
"address-level1"
|
|
1447
1455
|
);
|
|
1448
|
-
this.inputs.set("state",
|
|
1456
|
+
this.inputs.set("state", p), c.appendChild(p.getElement());
|
|
1449
1457
|
}
|
|
1450
1458
|
this.fieldsContainer.appendChild(c);
|
|
1451
1459
|
}
|
|
@@ -1485,8 +1493,8 @@ class de extends k {
|
|
|
1485
1493
|
if (!n) return;
|
|
1486
1494
|
const r = n.getElement().querySelector("input") || n.getElement().querySelector("select"), o = n.getValue();
|
|
1487
1495
|
!(document.activeElement === r) && !(t === "" && o !== "") && this.setValue(e, t);
|
|
1488
|
-
const
|
|
1489
|
-
this.setError(e,
|
|
1496
|
+
const u = !!(a && s);
|
|
1497
|
+
this.setError(e, u, s);
|
|
1490
1498
|
}
|
|
1491
1499
|
updateAllFields(e, t, s) {
|
|
1492
1500
|
Object.keys(e).forEach((a) => {
|
|
@@ -1503,13 +1511,14 @@ class de extends k {
|
|
|
1503
1511
|
e && e.focus();
|
|
1504
1512
|
}
|
|
1505
1513
|
}
|
|
1506
|
-
class
|
|
1514
|
+
class ft {
|
|
1507
1515
|
input = null;
|
|
1508
1516
|
isVgsMode;
|
|
1509
1517
|
vgsWrapper = null;
|
|
1510
1518
|
vgsContainer = null;
|
|
1511
1519
|
vgsHelperText = null;
|
|
1512
1520
|
wrapperElement;
|
|
1521
|
+
_vgsFieldsReady = !1;
|
|
1513
1522
|
constructor(e) {
|
|
1514
1523
|
const {
|
|
1515
1524
|
value: t,
|
|
@@ -1535,12 +1544,12 @@ class gt {
|
|
|
1535
1544
|
const s = e.styles.borderRadius, a = document.createElement("div");
|
|
1536
1545
|
a.style.marginBottom = "4px";
|
|
1537
1546
|
const n = document.createElement("label");
|
|
1538
|
-
n.className = "input-label", n.textContent = t("cardholderNameLabel"), n.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.appendChild(n), this.wrapperElement.appendChild(a), this.vgsWrapper = document.createElement("div"), this.vgsWrapper.className = "vgs-wrap", this.vgsWrapper.style.position = "relative", this.vgsWrapper.style.borderRadius = `${s}px`, this.vgsWrapper.style.height = "38.5px", this.vgsWrapper.style.width = "100%", this.vgsWrapper.style.overflow = "hidden"
|
|
1547
|
+
n.className = "input-label", n.textContent = t("cardholderNameLabel"), n.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.appendChild(n), this.wrapperElement.appendChild(a), this.vgsWrapper = document.createElement("div"), this.vgsWrapper.className = "vgs-wrap", this.vgsWrapper.style.position = "relative", this.vgsWrapper.style.borderRadius = `${s}px`, this.vgsWrapper.style.height = "38.5px", this.vgsWrapper.style.width = "100%", this.vgsWrapper.style.overflow = "hidden";
|
|
1539
1548
|
const r = document.createElement("div");
|
|
1540
|
-
r.className = "vgs-field-skeleton", this.vgsWrapper.appendChild(r), this.vgsContainer = document.createElement("div"), this.vgsContainer.id = `vgs-cc-name-${Date.now()}`, this.vgsContainer.style.position = "relative", this.vgsContainer.style.zIndex = "1", this.vgsContainer.style.width = "100%", this.vgsContainer.style.height = "100%", this.vgsWrapper.appendChild(this.vgsContainer), this.wrapperElement.appendChild(this.vgsWrapper), this.vgsHelperText = new
|
|
1549
|
+
r.className = "vgs-field-skeleton", this.vgsWrapper.appendChild(r), this.vgsContainer = document.createElement("div"), this.vgsContainer.id = `vgs-cc-name-${Date.now()}`, this.vgsContainer.style.position = "relative", this.vgsContainer.style.zIndex = "1", this.vgsContainer.style.width = "100%", this.vgsContainer.style.height = "100%", this.vgsWrapper.appendChild(this.vgsContainer), this.wrapperElement.appendChild(this.vgsWrapper), this.vgsHelperText = new Se({ visible: !1 }), this.wrapperElement.appendChild(this.vgsHelperText.getElement());
|
|
1541
1550
|
}
|
|
1542
1551
|
buildNativeLayout(e, t, s, a, n, r, o) {
|
|
1543
|
-
this.input = new
|
|
1552
|
+
this.input = new pe({
|
|
1544
1553
|
name: "name",
|
|
1545
1554
|
label: r("cardholderNameLabel"),
|
|
1546
1555
|
error: !1,
|
|
@@ -1555,8 +1564,8 @@ class gt {
|
|
|
1555
1564
|
value: e,
|
|
1556
1565
|
autocomplete: o,
|
|
1557
1566
|
onChange: (d) => {
|
|
1558
|
-
const
|
|
1559
|
-
|
|
1567
|
+
const u = d.target.value, S = u.replace(/[^a-zA-Z\s\-'.]/g, "");
|
|
1568
|
+
u !== S && this.input?.setValue(S), this.input?.setError(!1), this.trim(), t(d);
|
|
1560
1569
|
}
|
|
1561
1570
|
}), this.input.addEventListener("blur", (d) => {
|
|
1562
1571
|
s(d);
|
|
@@ -1567,16 +1576,16 @@ class gt {
|
|
|
1567
1576
|
}
|
|
1568
1577
|
handleVgsStateChange(e, t) {
|
|
1569
1578
|
if (!this.isVgsMode || !this.vgsWrapper) return;
|
|
1570
|
-
const
|
|
1571
|
-
if (this.vgsWrapper.
|
|
1572
|
-
const
|
|
1573
|
-
|
|
1579
|
+
const s = e[te.CARDHOLDER]?.isFocused;
|
|
1580
|
+
if (this._vgsFieldsReady && (this.vgsWrapper.style.boxShadow = s ? "0 0 0 1px rgba(50, 151, 211, 0.7), 0 1px 1px 0 rgba(0, 0, 0, 0.07), 0 0 0 4px rgba(50, 151, 211, 0.3)" : "0 0 0 1px #e0e0e0, 0 2px 4px 0 rgba(0,0,0,0.07), 0 1px 1.5px 0 rgba(0,0,0,0.05)"), !t || !this.vgsHelperText) return;
|
|
1581
|
+
const a = t[te.CARDHOLDER];
|
|
1582
|
+
a ? (this.vgsHelperText.setText(a), this.vgsHelperText.toggleVisibility(!0)) : this.vgsHelperText.toggleVisibility(!1);
|
|
1574
1583
|
}
|
|
1575
1584
|
hideFakePlaceholder() {
|
|
1576
1585
|
if (!this.vgsWrapper) return;
|
|
1577
|
-
this.vgsWrapper.style.boxShadow = "";
|
|
1586
|
+
this._vgsFieldsReady = !0, this.vgsWrapper.style.overflow = "visible", this.vgsWrapper.style.transition = "box-shadow 0.1s ease-in", this.vgsWrapper.style.boxShadow = "0 0 0 1px #e0e0e0, 0 2px 4px 0 rgba(0,0,0,0.07), 0 1px 1.5px 0 rgba(0,0,0,0.05)";
|
|
1578
1587
|
const e = this.vgsWrapper.querySelector(".vgs-field-skeleton");
|
|
1579
|
-
e && e.remove();
|
|
1588
|
+
e && e.remove(), this.vgsContainer?.querySelectorAll("iframe").forEach((t) => t.style.height = "38.5px");
|
|
1580
1589
|
}
|
|
1581
1590
|
getValue() {
|
|
1582
1591
|
return this.isVgsMode ? "" : this.input?.getValue() ?? "";
|
|
@@ -1604,7 +1613,7 @@ class gt {
|
|
|
1604
1613
|
this.isVgsMode || this.input?.focus();
|
|
1605
1614
|
}
|
|
1606
1615
|
}
|
|
1607
|
-
class
|
|
1616
|
+
class ge extends A {
|
|
1608
1617
|
constructor() {
|
|
1609
1618
|
super("div", ["skeleton-container"]), this.createSkeletonElements();
|
|
1610
1619
|
}
|
|
@@ -1628,7 +1637,7 @@ class pe extends k {
|
|
|
1628
1637
|
return e.appendChild(t), e.appendChild(s), e.appendChild(a), e;
|
|
1629
1638
|
}
|
|
1630
1639
|
}
|
|
1631
|
-
class
|
|
1640
|
+
class yt extends A {
|
|
1632
1641
|
constructor(e) {
|
|
1633
1642
|
const { translationFunc: t, checkoutProfile: s } = e;
|
|
1634
1643
|
super("div", ["payment-separator"]);
|
|
@@ -1640,7 +1649,7 @@ class ft extends k {
|
|
|
1640
1649
|
o.className = "payment-separator__line", a.appendChild(n), a.appendChild(r), a.appendChild(o);
|
|
1641
1650
|
}
|
|
1642
1651
|
}
|
|
1643
|
-
class
|
|
1652
|
+
class bt extends A {
|
|
1644
1653
|
paymentMethods;
|
|
1645
1654
|
paymentSeparator;
|
|
1646
1655
|
skeleton;
|
|
@@ -1654,8 +1663,8 @@ class yt extends k {
|
|
|
1654
1663
|
translationFunc: o,
|
|
1655
1664
|
paymentId: d,
|
|
1656
1665
|
checkoutKey: c,
|
|
1657
|
-
checkoutDetails:
|
|
1658
|
-
environment:
|
|
1666
|
+
checkoutDetails: u,
|
|
1667
|
+
environment: S,
|
|
1659
1668
|
countryCode: l
|
|
1660
1669
|
} = e;
|
|
1661
1670
|
if (super("div", ["payment-methods"]), this.paymentMethods = /* @__PURE__ */ new Map(), !t?.additionalPaymentMethods) {
|
|
@@ -1666,42 +1675,42 @@ class yt extends k {
|
|
|
1666
1675
|
this.renderSkeleton();
|
|
1667
1676
|
return;
|
|
1668
1677
|
}
|
|
1669
|
-
const
|
|
1678
|
+
const p = Object.entries(
|
|
1670
1679
|
t.additionalPaymentMethods
|
|
1671
|
-
).filter(([y,
|
|
1672
|
-
const g =
|
|
1673
|
-
return g && h &&
|
|
1674
|
-
}).sort((y,
|
|
1675
|
-
if (
|
|
1680
|
+
).filter(([y, m]) => {
|
|
1681
|
+
const g = m.enabled, h = r ? r[y] === !0 : !0, b = !m.countries || l && m.countries.includes(l);
|
|
1682
|
+
return g && h && b;
|
|
1683
|
+
}).sort((y, m) => y[1].order - m[1].order);
|
|
1684
|
+
if (p.length === 0) {
|
|
1676
1685
|
this.getElement().style.display = "none";
|
|
1677
1686
|
return;
|
|
1678
1687
|
}
|
|
1679
|
-
for (const [y] of
|
|
1688
|
+
for (const [y] of p)
|
|
1680
1689
|
switch (y) {
|
|
1681
1690
|
case "paypal": {
|
|
1682
1691
|
if (a) {
|
|
1683
|
-
const
|
|
1692
|
+
const m = new Ee({
|
|
1684
1693
|
checkoutProfile: t,
|
|
1685
1694
|
formData: s,
|
|
1686
1695
|
onSubmit: a
|
|
1687
1696
|
});
|
|
1688
|
-
this.paymentMethods.set("paypal",
|
|
1697
|
+
this.paymentMethods.set("paypal", m), m.appendTo(this.getElement());
|
|
1689
1698
|
}
|
|
1690
1699
|
break;
|
|
1691
1700
|
}
|
|
1692
1701
|
case "applePay": {
|
|
1693
1702
|
if (n && d && c) {
|
|
1694
|
-
const
|
|
1703
|
+
const m = t.appearance?.additionalPaymentMethods?.applePay, g = new Ce({
|
|
1695
1704
|
checkoutProfile: t,
|
|
1696
1705
|
formData: s,
|
|
1697
1706
|
onSubmit: n,
|
|
1698
1707
|
paymentId: d,
|
|
1699
1708
|
checkoutKey: c,
|
|
1700
|
-
checkoutDetails:
|
|
1701
|
-
environment:
|
|
1702
|
-
displayName:
|
|
1703
|
-
requiredBillingContactFields:
|
|
1704
|
-
requiredShippingContactFields:
|
|
1709
|
+
checkoutDetails: u,
|
|
1710
|
+
environment: S,
|
|
1711
|
+
displayName: m?.displayName,
|
|
1712
|
+
requiredBillingContactFields: m?.requiredBillingContactFields,
|
|
1713
|
+
requiredShippingContactFields: m?.requiredShippingContactFields
|
|
1705
1714
|
});
|
|
1706
1715
|
this.paymentMethods.set("applePay", g), g.appendTo(this.getElement());
|
|
1707
1716
|
}
|
|
@@ -1719,13 +1728,13 @@ class yt extends k {
|
|
|
1719
1728
|
);
|
|
1720
1729
|
break;
|
|
1721
1730
|
}
|
|
1722
|
-
this.paymentMethods.size > 0 && (this.paymentSeparator = new
|
|
1731
|
+
this.paymentMethods.size > 0 && (this.paymentSeparator = new yt({
|
|
1723
1732
|
translationFunc: o,
|
|
1724
1733
|
checkoutProfile: t
|
|
1725
1734
|
}), this.getElement().appendChild(this.paymentSeparator.getElement()));
|
|
1726
1735
|
}
|
|
1727
1736
|
renderSkeleton() {
|
|
1728
|
-
this.skeleton = new
|
|
1737
|
+
this.skeleton = new ge(), this.getElement().appendChild(this.skeleton.getElement());
|
|
1729
1738
|
}
|
|
1730
1739
|
updateFormData(e) {
|
|
1731
1740
|
const t = this.paymentMethods.get("paypal");
|
|
@@ -1737,8 +1746,8 @@ class yt extends k {
|
|
|
1737
1746
|
return this.paymentMethods.size > 0 && this.getElement().style.display !== "none";
|
|
1738
1747
|
}
|
|
1739
1748
|
}
|
|
1740
|
-
const
|
|
1741
|
-
class
|
|
1749
|
+
const vt = 17;
|
|
1750
|
+
class St extends A {
|
|
1742
1751
|
styles;
|
|
1743
1752
|
isHovered = !1;
|
|
1744
1753
|
constructor(e) {
|
|
@@ -1748,7 +1757,7 @@ class vt extends k {
|
|
|
1748
1757
|
}
|
|
1749
1758
|
applyStyles() {
|
|
1750
1759
|
const e = this.getElement();
|
|
1751
|
-
e.style.backgroundColor = this.isHovered ? `color-mix(in srgb, ${this.styles.backgroundColor} 80%, transparent)` : this.styles.backgroundColor, e.disabled ? (e.style.color = "rgb(150, 150, 150)", e.style.backgroundColor = "rgb(200, 200, 200)") : e.style.color = this.styles.color, e.style.borderRadius = this.styles.borderRadius ===
|
|
1760
|
+
e.style.backgroundColor = this.isHovered ? `color-mix(in srgb, ${this.styles.backgroundColor} 80%, transparent)` : this.styles.backgroundColor, e.disabled ? (e.style.color = "rgb(150, 150, 150)", e.style.backgroundColor = "rgb(200, 200, 200)") : e.style.color = this.styles.color, e.style.borderRadius = this.styles.borderRadius === vt ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
|
|
1752
1761
|
}
|
|
1753
1762
|
handleMouseEnter() {
|
|
1754
1763
|
this.isHovered = !0, this.applyStyles();
|
|
@@ -1760,11 +1769,11 @@ class vt extends k {
|
|
|
1760
1769
|
return this.getElement().disabled = e, e ? (this.addClass("disabled"), this.removeClass("valid")) : (this.removeClass("disabled"), this.addClass("valid")), this.applyStyles(), this;
|
|
1761
1770
|
}
|
|
1762
1771
|
}
|
|
1763
|
-
class
|
|
1772
|
+
class Ct {
|
|
1764
1773
|
button;
|
|
1765
1774
|
constructor(e) {
|
|
1766
1775
|
const { disabled: t, checkoutProfile: s, translationFunc: a } = e;
|
|
1767
|
-
this.button = new
|
|
1776
|
+
this.button = new St({
|
|
1768
1777
|
text: a(
|
|
1769
1778
|
`buttonTexts.${s?.layout.actionButton.translationKey}`
|
|
1770
1779
|
),
|
|
@@ -1837,7 +1846,7 @@ class Et {
|
|
|
1837
1846
|
(a) => a.enabled
|
|
1838
1847
|
))
|
|
1839
1848
|
return;
|
|
1840
|
-
this.paymentMethods = new
|
|
1849
|
+
this.paymentMethods = new bt({
|
|
1841
1850
|
checkoutProfile: e,
|
|
1842
1851
|
formData: t,
|
|
1843
1852
|
supportedPaymentMethods: this.supportedPaymentMethods,
|
|
@@ -1864,7 +1873,7 @@ class Et {
|
|
|
1864
1873
|
) || e.layout.shippingFields && Object.values(e.layout.shippingFields).some(
|
|
1865
1874
|
(r) => r?.enabled
|
|
1866
1875
|
);
|
|
1867
|
-
this.emailField = new
|
|
1876
|
+
this.emailField = new Fe({
|
|
1868
1877
|
value: t.email,
|
|
1869
1878
|
onChange: this.onChange,
|
|
1870
1879
|
onBlur: this.onBlur,
|
|
@@ -1882,7 +1891,7 @@ class Et {
|
|
|
1882
1891
|
}
|
|
1883
1892
|
createPhoneNumberField(e, t, s, a) {
|
|
1884
1893
|
const n = document.createElement("div");
|
|
1885
|
-
this.phonePlaceholder = n, this.formElement.appendChild(n),
|
|
1894
|
+
this.phonePlaceholder = n, this.formElement.appendChild(n), Me().then(({ PhoneNumberField: r }) => {
|
|
1886
1895
|
n.isConnected && (this.phoneNumberField = new r({
|
|
1887
1896
|
value: t.phoneNumber ?? "",
|
|
1888
1897
|
onChange: this.onChange,
|
|
@@ -1909,7 +1918,7 @@ class Et {
|
|
|
1909
1918
|
this.cardSectionSkeleton = this.buildCardSkeleton(e), this.formElement.appendChild(this.cardSectionSkeleton);
|
|
1910
1919
|
return;
|
|
1911
1920
|
}
|
|
1912
|
-
if (this.cardSection = new
|
|
1921
|
+
if (this.cardSection = new Ne({
|
|
1913
1922
|
checkoutProfile: e,
|
|
1914
1923
|
cardNumber: t.cardNumber,
|
|
1915
1924
|
cardNumberError: s.cardNumber,
|
|
@@ -1923,13 +1932,12 @@ class Et {
|
|
|
1923
1932
|
onChange: this.onChange,
|
|
1924
1933
|
onBlur: this.onBlur,
|
|
1925
1934
|
onCardBrandChange: () => {
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
}
|
|
1935
|
+
t.cardCvv && this.onBlur(
|
|
1936
|
+
P({
|
|
1937
|
+
type: "blur",
|
|
1938
|
+
target: { name: "cardCvv", value: t.cardCvv }
|
|
1939
|
+
})
|
|
1940
|
+
);
|
|
1933
1941
|
},
|
|
1934
1942
|
translationFunc: this.translationFunc,
|
|
1935
1943
|
vgsService: this.vgsService,
|
|
@@ -1965,7 +1973,7 @@ class Et {
|
|
|
1965
1973
|
this.cardholderSectionSkeleton = this.buildCardholderSkeleton(e), this.formElement.appendChild(this.cardholderSectionSkeleton);
|
|
1966
1974
|
return;
|
|
1967
1975
|
}
|
|
1968
|
-
if (this.cardholderSection = new
|
|
1976
|
+
if (this.cardholderSection = new ft({
|
|
1969
1977
|
value: t.name,
|
|
1970
1978
|
onChange: this.onChange,
|
|
1971
1979
|
onBlur: this.onBlur,
|
|
@@ -1998,7 +2006,7 @@ class Et {
|
|
|
1998
2006
|
zipCode: "",
|
|
1999
2007
|
country: ""
|
|
2000
2008
|
};
|
|
2001
|
-
this.billingAddressSection = new
|
|
2009
|
+
this.billingAddressSection = new ce({
|
|
2002
2010
|
type: "billing",
|
|
2003
2011
|
title: this.translationFunc("address.billingTitle"),
|
|
2004
2012
|
checkoutProfile: e,
|
|
@@ -2031,7 +2039,7 @@ class Et {
|
|
|
2031
2039
|
zipCode: "",
|
|
2032
2040
|
country: ""
|
|
2033
2041
|
};
|
|
2034
|
-
this.shippingAddressSection = new
|
|
2042
|
+
this.shippingAddressSection = new ce({
|
|
2035
2043
|
type: "shipping",
|
|
2036
2044
|
title: this.translationFunc("address.shippingTitle"),
|
|
2037
2045
|
checkoutProfile: e,
|
|
@@ -2051,7 +2059,7 @@ class Et {
|
|
|
2051
2059
|
}
|
|
2052
2060
|
createSubmitButton(e, t) {
|
|
2053
2061
|
try {
|
|
2054
|
-
this.submitButton = new
|
|
2062
|
+
this.submitButton = new Ct({
|
|
2055
2063
|
disabled: t,
|
|
2056
2064
|
checkoutProfile: e,
|
|
2057
2065
|
translationFunc: this.translationFunc
|
|
@@ -2120,8 +2128,8 @@ class Et {
|
|
|
2120
2128
|
d.style.display = "flex", d.style.gap = "8px";
|
|
2121
2129
|
const c = document.createElement("div");
|
|
2122
2130
|
c.style.position = "relative", c.style.flex = "1", c.style.height = "38.5px", c.style.overflow = "hidden", c.style.borderRadius = `${t}px`, c.appendChild(this.createSkeletonDiv()), d.appendChild(c);
|
|
2123
|
-
const
|
|
2124
|
-
return
|
|
2131
|
+
const u = document.createElement("div");
|
|
2132
|
+
return u.style.position = "relative", u.style.flex = "1", u.style.height = "38.5px", u.style.overflow = "hidden", u.style.borderRadius = `${t}px`, u.appendChild(this.createSkeletonDiv()), d.appendChild(u), r.appendChild(d), s.appendChild(r), s;
|
|
2125
2133
|
}
|
|
2126
2134
|
createSkeletonDiv() {
|
|
2127
2135
|
const e = document.createElement("div");
|
|
@@ -2138,7 +2146,7 @@ class Et {
|
|
|
2138
2146
|
async mountVgsFields(e) {
|
|
2139
2147
|
if (!this.vgsService || !this.cardSection) return;
|
|
2140
2148
|
await this.vgsService.whenReady();
|
|
2141
|
-
const t = this.cardSection.getVgsContainerIds(), s = this.cardholderSection?.getVgsContainerId(), a = await
|
|
2149
|
+
const t = this.cardSection.getVgsContainerIds(), s = this.cardholderSection?.getVgsContainerId(), a = await pt(
|
|
2142
2150
|
e.styles.fontFamily
|
|
2143
2151
|
), n = this.cardSection.buildVgsFieldCss(
|
|
2144
2152
|
e,
|
|
@@ -2198,7 +2206,7 @@ class Et {
|
|
|
2198
2206
|
this.billingAddressSection && (this.billingAddressSection.getElement().remove(), this.billingAddressSection = void 0), this.shippingAddressSection && (this.shippingAddressSection.getElement().remove(), this.shippingAddressSection = void 0), this.submitButton && (this.submitButton.getElement().remove(), this.submitButton = void 0), this.paymentMethods && (this.paymentMethods.getElement().remove(), this.paymentMethods = void 0);
|
|
2199
2207
|
}
|
|
2200
2208
|
}
|
|
2201
|
-
class
|
|
2209
|
+
class Ft {
|
|
2202
2210
|
formManager;
|
|
2203
2211
|
focusManager;
|
|
2204
2212
|
onFormSubmit;
|
|
@@ -2239,7 +2247,7 @@ class Ct {
|
|
|
2239
2247
|
this.localTouchedFields.clear();
|
|
2240
2248
|
}
|
|
2241
2249
|
}
|
|
2242
|
-
class
|
|
2250
|
+
class Mt {
|
|
2243
2251
|
formManager;
|
|
2244
2252
|
checkoutProfile;
|
|
2245
2253
|
formElement;
|
|
@@ -2263,7 +2271,7 @@ class Ft {
|
|
|
2263
2271
|
try {
|
|
2264
2272
|
if (e.checkoutProfile.styles?.fontFamily)
|
|
2265
2273
|
try {
|
|
2266
|
-
const { cleanup: t } =
|
|
2274
|
+
const { cleanup: t } = we({
|
|
2267
2275
|
fontFamily: e.checkoutProfile.styles.fontFamily
|
|
2268
2276
|
});
|
|
2269
2277
|
this.fontCleanup = t, this.formElement.style.fontFamily = e.checkoutProfile.styles.fontFamily;
|
|
@@ -2281,16 +2289,16 @@ class Ft {
|
|
|
2281
2289
|
isFormDisabled() {
|
|
2282
2290
|
const e = this.formManager.getFormState(), t = this.checkoutProfile.getState(), s = Object.keys(e.errors).filter(
|
|
2283
2291
|
(f) => f !== "billingAddress" && f !== "shippingAddress"
|
|
2284
|
-
).length > 0, a = e.errors.billingAddress, n = a && typeof a == "object" ? Object.keys(a).length > 0 : !1, r = e.errors.shippingAddress, o = r && typeof r == "object" ? Object.keys(r).length > 0 : !1, d = s || n || o,
|
|
2292
|
+
).length > 0, a = e.errors.billingAddress, n = a && typeof a == "object" ? Object.keys(a).length > 0 : !1, r = e.errors.shippingAddress, o = r && typeof r == "object" ? Object.keys(r).length > 0 : !1, d = s || n || o, u = J(
|
|
2285
2293
|
t.checkoutProfile?.layout
|
|
2286
|
-
) ? !!(e.formData.billingAddress?.firstName || e.formData.billingAddress?.lastName || e.formData.shippingAddress?.firstName || e.formData.shippingAddress?.lastName) : !!e.formData.name, l = t.checkoutProfile?.layout.phoneNumber?.enabled ?? !1 ? !!e.formData.phoneNumber : !0, { billingFields:
|
|
2294
|
+
) ? !!(e.formData.billingAddress?.firstName || e.formData.billingAddress?.lastName || e.formData.shippingAddress?.firstName || e.formData.shippingAddress?.lastName) : !!e.formData.name, l = t.checkoutProfile?.layout.phoneNumber?.enabled ?? !1 ? !!e.formData.phoneNumber : !0, { billingFields: p, shippingFields: y } = t.checkoutProfile?.layout ?? {}, m = /* @__PURE__ */ new Set(["US", "CA"]), g = (f, v) => {
|
|
2287
2295
|
if (!f) return !0;
|
|
2288
|
-
const
|
|
2289
|
-
return Object.entries(f).every(([N,
|
|
2296
|
+
const E = v?.country ?? "";
|
|
2297
|
+
return Object.entries(f).every(([N, x]) => !x?.enabled || N === "state" && (!m.has(E) || x.hiddenForCountries?.includes(E)) ? !0 : !!v?.[N]?.trim());
|
|
2290
2298
|
}, h = !this.isVgsMode || Object.values(this.vgsFieldsState).every(
|
|
2291
2299
|
(f) => f?.isValid === !0
|
|
2292
|
-
),
|
|
2293
|
-
return d || !
|
|
2300
|
+
), b = this.isVgsMode ? !!e.formData.email && l && h && g(p, e.formData.billingAddress) && g(y, e.formData.shippingAddress) : !!e.formData.email && l && u && !!e.formData.cardNumber && !!e.formData.cardCvv && !!e.formData.cardExpiry && g(p, e.formData.billingAddress) && g(y, e.formData.shippingAddress);
|
|
2301
|
+
return d || !b || this.isSubmitting;
|
|
2294
2302
|
}
|
|
2295
2303
|
setSubmitting(e) {
|
|
2296
2304
|
this.isSubmitting = e;
|
|
@@ -2308,7 +2316,7 @@ class Ft {
|
|
|
2308
2316
|
continue;
|
|
2309
2317
|
const n = a.errors?.[0];
|
|
2310
2318
|
if (!n) continue;
|
|
2311
|
-
const r =
|
|
2319
|
+
const r = Pe(s, n.code);
|
|
2312
2320
|
r && (t[s] = e(r));
|
|
2313
2321
|
}
|
|
2314
2322
|
return t;
|
|
@@ -2320,18 +2328,18 @@ class Ft {
|
|
|
2320
2328
|
this.fontCleanup && (this.fontCleanup(), this.fontCleanup = void 0);
|
|
2321
2329
|
}
|
|
2322
2330
|
}
|
|
2323
|
-
class
|
|
2331
|
+
class Nt extends A {
|
|
2324
2332
|
titleElement;
|
|
2325
2333
|
constructor(e = {}) {
|
|
2326
2334
|
super("div", ["blur-bg"]);
|
|
2327
2335
|
const t = D.createDiv(["loader"]);
|
|
2328
|
-
this.titleElement = new
|
|
2336
|
+
this.titleElement = new A("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
|
|
2329
2337
|
}
|
|
2330
2338
|
setText(e) {
|
|
2331
2339
|
return this.titleElement.setText(e), this;
|
|
2332
2340
|
}
|
|
2333
2341
|
}
|
|
2334
|
-
const
|
|
2342
|
+
const he = {
|
|
2335
2343
|
street: "",
|
|
2336
2344
|
firstName: "",
|
|
2337
2345
|
lastName: "",
|
|
@@ -2339,7 +2347,7 @@ const ce = {
|
|
|
2339
2347
|
city: "",
|
|
2340
2348
|
zipCode: "",
|
|
2341
2349
|
country: ""
|
|
2342
|
-
},
|
|
2350
|
+
}, ue = (i, e) => {
|
|
2343
2351
|
const t = {}, s = `${e}.`;
|
|
2344
2352
|
return Object.keys(i).forEach((a) => {
|
|
2345
2353
|
if (a.startsWith(s)) {
|
|
@@ -2348,7 +2356,7 @@ const ce = {
|
|
|
2348
2356
|
}
|
|
2349
2357
|
}), t;
|
|
2350
2358
|
};
|
|
2351
|
-
class
|
|
2359
|
+
class wt {
|
|
2352
2360
|
formElement;
|
|
2353
2361
|
componentManager;
|
|
2354
2362
|
onLoadingStateChange;
|
|
@@ -2382,13 +2390,13 @@ class Nt {
|
|
|
2382
2390
|
!!(e.errors.name && e.touched.name),
|
|
2383
2391
|
e.errors.name
|
|
2384
2392
|
), this.componentManager.updateBillingAddressSection(
|
|
2385
|
-
e.formData.billingAddress ??
|
|
2393
|
+
e.formData.billingAddress ?? he,
|
|
2386
2394
|
e.errors.billingAddress ?? {},
|
|
2387
|
-
|
|
2395
|
+
ue(e.touched, "billingAddress")
|
|
2388
2396
|
), this.componentManager.updateShippingAddressSection(
|
|
2389
|
-
e.formData.shippingAddress ??
|
|
2397
|
+
e.formData.shippingAddress ?? he,
|
|
2390
2398
|
e.errors.shippingAddress ?? {},
|
|
2391
|
-
|
|
2399
|
+
ue(e.touched, "shippingAddress")
|
|
2392
2400
|
), this.componentManager.updateSubmitButton(t);
|
|
2393
2401
|
}
|
|
2394
2402
|
setLoadingState(e) {
|
|
@@ -2396,10 +2404,10 @@ class Nt {
|
|
|
2396
2404
|
this.onLoadingStateChange(e);
|
|
2397
2405
|
return;
|
|
2398
2406
|
}
|
|
2399
|
-
e ? (this.hideSkeleton(), this.formSkeleton = new
|
|
2407
|
+
e ? (this.hideSkeleton(), this.formSkeleton = new ge(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
|
|
2400
2408
|
}
|
|
2401
2409
|
showSpinner(e) {
|
|
2402
|
-
this.hideSpinner(), this.spinner = new
|
|
2410
|
+
this.hideSpinner(), this.spinner = new Nt({ text: e }), this.formElement.appendChild(this.spinner.getElement());
|
|
2403
2411
|
}
|
|
2404
2412
|
hideSpinner() {
|
|
2405
2413
|
this.spinner && (this.spinner.getElement().remove(), this.spinner = void 0);
|
|
@@ -2408,7 +2416,7 @@ class Nt {
|
|
|
2408
2416
|
this.formSkeleton && (this.formSkeleton.getElement().remove(), this.formSkeleton = void 0);
|
|
2409
2417
|
}
|
|
2410
2418
|
setErrorMessage(e) {
|
|
2411
|
-
this.alert && (this.alert.getElement().remove(), this.alert = void 0), this.alert = new
|
|
2419
|
+
this.alert && (this.alert.getElement().remove(), this.alert = void 0), this.alert = new ke({ message: e }), this.formElement.insertBefore(
|
|
2412
2420
|
this.alert.getElement(),
|
|
2413
2421
|
this.formElement.firstChild
|
|
2414
2422
|
);
|
|
@@ -2420,7 +2428,7 @@ class Nt {
|
|
|
2420
2428
|
this.spinner && (this.spinner.getElement().remove(), this.spinner = void 0), this.formSkeleton && (this.formSkeleton.getElement().remove(), this.formSkeleton = void 0), this.alert && (this.alert.getElement().remove(), this.alert = void 0);
|
|
2421
2429
|
}
|
|
2422
2430
|
}
|
|
2423
|
-
const
|
|
2431
|
+
const T = (i) => ({
|
|
2424
2432
|
street: "",
|
|
2425
2433
|
firstName: "",
|
|
2426
2434
|
lastName: "",
|
|
@@ -2430,12 +2438,12 @@ const x = (i) => ({
|
|
|
2430
2438
|
country: "",
|
|
2431
2439
|
...i
|
|
2432
2440
|
});
|
|
2433
|
-
class
|
|
2441
|
+
class Pt extends A {
|
|
2434
2442
|
options;
|
|
2435
|
-
formManager =
|
|
2443
|
+
formManager = ct();
|
|
2436
2444
|
checkoutProfile;
|
|
2437
|
-
translation =
|
|
2438
|
-
focusManager = new
|
|
2445
|
+
translation = Ae();
|
|
2446
|
+
focusManager = new xe();
|
|
2439
2447
|
// Managers
|
|
2440
2448
|
componentManager;
|
|
2441
2449
|
eventHandler;
|
|
@@ -2446,7 +2454,7 @@ class wt extends k {
|
|
|
2446
2454
|
vgsJwt;
|
|
2447
2455
|
vgsCardResult;
|
|
2448
2456
|
constructor(e) {
|
|
2449
|
-
super("form", ["form-container"]), this.options = e, this.vgsJwt = e.vgsJwt, this.vgsJwt && (this.vgsService = new
|
|
2457
|
+
super("form", ["form-container"]), this.options = e, this.vgsJwt = e.vgsJwt, this.vgsJwt && (this.vgsService = new L()), this.checkoutProfile = dt({
|
|
2450
2458
|
appearance: e.appearance
|
|
2451
2459
|
}), e.locale && this.translation.setLocale(e.locale), this.componentManager = new Et({
|
|
2452
2460
|
formElement: this.element,
|
|
@@ -2465,11 +2473,11 @@ class wt extends k {
|
|
|
2465
2473
|
environment: e.environment,
|
|
2466
2474
|
vgsService: this.vgsService,
|
|
2467
2475
|
onVgsStateChange: (t) => this.handleVgsStateChange(t)
|
|
2468
|
-
}), this.uiManager = new
|
|
2476
|
+
}), this.uiManager = new wt({
|
|
2469
2477
|
formElement: this.element,
|
|
2470
2478
|
componentManager: this.componentManager,
|
|
2471
2479
|
onLoadingStateChange: e.onLoadingStateChange
|
|
2472
|
-
}), this.stateCoordinator = new
|
|
2480
|
+
}), this.stateCoordinator = new Mt({
|
|
2473
2481
|
formManager: this.formManager,
|
|
2474
2482
|
checkoutProfile: this.checkoutProfile,
|
|
2475
2483
|
componentManager: this.componentManager,
|
|
@@ -2479,7 +2487,7 @@ class wt extends k {
|
|
|
2479
2487
|
onError: (t) => this.uiManager.setErrorMessage(t),
|
|
2480
2488
|
onLoadingChange: (t) => this.uiManager.setLoadingState(t),
|
|
2481
2489
|
getInitialFormData: () => this._getFormStateData().formData
|
|
2482
|
-
}), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new
|
|
2490
|
+
}), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new Ft({
|
|
2483
2491
|
formManager: this.formManager,
|
|
2484
2492
|
focusManager: this.focusManager,
|
|
2485
2493
|
onFormSubmit: async () => this.handleSubmit(),
|
|
@@ -2504,12 +2512,12 @@ class wt extends k {
|
|
|
2504
2512
|
},
|
|
2505
2513
|
...e.initialValues.name && { name: e.initialValues.name },
|
|
2506
2514
|
...e.initialValues.billingAddress && {
|
|
2507
|
-
billingAddress:
|
|
2515
|
+
billingAddress: T(
|
|
2508
2516
|
e.initialValues.billingAddress
|
|
2509
2517
|
)
|
|
2510
2518
|
},
|
|
2511
2519
|
...e.initialValues.shippingAddress && {
|
|
2512
|
-
shippingAddress:
|
|
2520
|
+
shippingAddress: T(
|
|
2513
2521
|
e.initialValues.shippingAddress
|
|
2514
2522
|
)
|
|
2515
2523
|
}
|
|
@@ -2526,10 +2534,10 @@ class wt extends k {
|
|
|
2526
2534
|
cardNumber: "",
|
|
2527
2535
|
cardCvv: "",
|
|
2528
2536
|
...t?.billingAddress && {
|
|
2529
|
-
billingAddress:
|
|
2537
|
+
billingAddress: T(t.billingAddress)
|
|
2530
2538
|
},
|
|
2531
2539
|
...t?.shippingAddress && {
|
|
2532
|
-
shippingAddress:
|
|
2540
|
+
shippingAddress: T(t.shippingAddress)
|
|
2533
2541
|
}
|
|
2534
2542
|
},
|
|
2535
2543
|
errors: e.errors || {},
|
|
@@ -2556,11 +2564,11 @@ class wt extends k {
|
|
|
2556
2564
|
phoneNumber: "",
|
|
2557
2565
|
phoneCountryCode: e.checkoutProfile.layout.phoneNumber.defaultCountry?.toUpperCase() || "US"
|
|
2558
2566
|
}), e.checkoutProfile.layout.billingFields && this.formManager.getFormState().formData.billingAddress === void 0 && this.formManager.setFormData({
|
|
2559
|
-
billingAddress:
|
|
2567
|
+
billingAddress: T()
|
|
2560
2568
|
}), e.checkoutProfile.layout.shippingFields && this.formManager.getFormState().formData.shippingAddress === void 0 && this.formManager.setFormData({
|
|
2561
|
-
shippingAddress:
|
|
2569
|
+
shippingAddress: T()
|
|
2562
2570
|
});
|
|
2563
|
-
const { formData: t, errors: s, touched: a } = this._getFormStateData(), n =
|
|
2571
|
+
const { formData: t, errors: s, touched: a } = this._getFormStateData(), n = gt(
|
|
2564
2572
|
e.checkoutProfile.layout
|
|
2565
2573
|
);
|
|
2566
2574
|
try {
|
|
@@ -2624,7 +2632,7 @@ class wt extends k {
|
|
|
2624
2632
|
} catch (o) {
|
|
2625
2633
|
console.error("Failed to create card section:", o);
|
|
2626
2634
|
}
|
|
2627
|
-
if (!
|
|
2635
|
+
if (!J(
|
|
2628
2636
|
e.checkoutProfile.layout
|
|
2629
2637
|
))
|
|
2630
2638
|
try {
|
|
@@ -2662,7 +2670,7 @@ class wt extends k {
|
|
|
2662
2670
|
*/
|
|
2663
2671
|
inferCardholderName() {
|
|
2664
2672
|
const e = this.checkoutProfile.getState();
|
|
2665
|
-
if (!e.checkoutProfile || !
|
|
2673
|
+
if (!e.checkoutProfile || !J(
|
|
2666
2674
|
e.checkoutProfile.layout
|
|
2667
2675
|
)) return;
|
|
2668
2676
|
const { formData: s } = this._getFormStateData(), a = s.billingAddress ?? s.shippingAddress;
|
|
@@ -2770,7 +2778,7 @@ class wt extends k {
|
|
|
2770
2778
|
), this.componentManager.cleanup(), this.uiManager.cleanup(), this.getElement().remove();
|
|
2771
2779
|
}
|
|
2772
2780
|
associatePayment(e, t, s, a, n) {
|
|
2773
|
-
this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = s, this.options.checkoutDetails = a, this.componentManager.setCheckoutDetailsLoaded(!0), n && !this.vgsService && (this.vgsJwt = n, this.vgsService = new
|
|
2781
|
+
this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = s, this.options.checkoutDetails = a, this.componentManager.setCheckoutDetailsLoaded(!0), n && !this.vgsService && (this.vgsJwt = n, this.vgsService = new L(), this.componentManager.setVgsService(this.vgsService), this.stateCoordinator.setVgsMode(!0), this.vgsService.init(this.options.environment).then((o) => {
|
|
2774
2782
|
this.vgsService?.createForm(
|
|
2775
2783
|
o,
|
|
2776
2784
|
(d) => this.handleVgsStateChange(d)
|
|
@@ -2795,7 +2803,7 @@ class wt extends k {
|
|
|
2795
2803
|
}
|
|
2796
2804
|
}
|
|
2797
2805
|
}
|
|
2798
|
-
class
|
|
2806
|
+
class kt {
|
|
2799
2807
|
container = null;
|
|
2800
2808
|
options;
|
|
2801
2809
|
onSubmit;
|
|
@@ -2819,7 +2827,7 @@ class Pt {
|
|
|
2819
2827
|
}
|
|
2820
2828
|
}
|
|
2821
2829
|
renderForm(e) {
|
|
2822
|
-
this.container && (this.form && (this.form.destroy(), this.form = null), this.form = new
|
|
2830
|
+
this.container && (this.form && (this.form.destroy(), this.form = null), this.form = new Pt({
|
|
2823
2831
|
apiKey: this.options.apiKey,
|
|
2824
2832
|
onSubmit: this.onSubmit,
|
|
2825
2833
|
locale: this.options.locale,
|
|
@@ -2856,7 +2864,7 @@ class Pt {
|
|
|
2856
2864
|
);
|
|
2857
2865
|
}
|
|
2858
2866
|
}
|
|
2859
|
-
class
|
|
2867
|
+
class At {
|
|
2860
2868
|
state;
|
|
2861
2869
|
listeners = /* @__PURE__ */ new Set();
|
|
2862
2870
|
constructor(e) {
|
|
@@ -2878,7 +2886,7 @@ class kt {
|
|
|
2878
2886
|
this.listeners.forEach((t) => t(e));
|
|
2879
2887
|
}
|
|
2880
2888
|
}
|
|
2881
|
-
const
|
|
2889
|
+
const xt = "en";
|
|
2882
2890
|
class Dt {
|
|
2883
2891
|
config;
|
|
2884
2892
|
paymentState;
|
|
@@ -2887,7 +2895,7 @@ class Dt {
|
|
|
2887
2895
|
stateManager;
|
|
2888
2896
|
sessionId;
|
|
2889
2897
|
constructor(e) {
|
|
2890
|
-
this.config = this.validateConfig(e), this.paymentState = {}, this.sessionId = crypto.randomUUID(),
|
|
2898
|
+
this.config = this.validateConfig(e), this.paymentState = {}, this.sessionId = crypto.randomUUID(), ot({
|
|
2891
2899
|
environment: this.config.environment,
|
|
2892
2900
|
sessionId: this.sessionId
|
|
2893
2901
|
}), M(F.CHECKOUT_INITIALIZED, {
|
|
@@ -2895,10 +2903,10 @@ class Dt {
|
|
|
2895
2903
|
}), this.apiService = new De(
|
|
2896
2904
|
this.config.apiKey,
|
|
2897
2905
|
this.config.environment
|
|
2898
|
-
), this.stateManager = new
|
|
2906
|
+
), this.stateManager = new At({
|
|
2899
2907
|
mounted: !1,
|
|
2900
2908
|
form: null
|
|
2901
|
-
}), this.formManager = new
|
|
2909
|
+
}), this.formManager = new kt(
|
|
2902
2910
|
{
|
|
2903
2911
|
locale: this.config.locale,
|
|
2904
2912
|
apiKey: this.config.apiKey,
|
|
@@ -2920,7 +2928,7 @@ class Dt {
|
|
|
2920
2928
|
apiKey: e.apiKey,
|
|
2921
2929
|
returnUrl: e.returnUrl,
|
|
2922
2930
|
environment: e.environment,
|
|
2923
|
-
locale: e.locale ||
|
|
2931
|
+
locale: e.locale || xt,
|
|
2924
2932
|
disableErrorMessages: e.disableErrorMessages ?? !1,
|
|
2925
2933
|
manualActionHandling: e.manualActionHandling ?? !1,
|
|
2926
2934
|
appearance: e.appearance,
|
|
@@ -2978,8 +2986,8 @@ class Dt {
|
|
|
2978
2986
|
returnUrl: this.config.returnUrl,
|
|
2979
2987
|
applePayData: t
|
|
2980
2988
|
}), r = performance.now() - a;
|
|
2981
|
-
|
|
2982
|
-
|
|
2989
|
+
oe(
|
|
2990
|
+
se.PAYMENT_AUTHORIZATION_TIME,
|
|
2983
2991
|
r,
|
|
2984
2992
|
"ms",
|
|
2985
2993
|
{
|
|
@@ -2993,8 +3001,8 @@ class Dt {
|
|
|
2993
3001
|
}), this.handlePaymentResponse(n);
|
|
2994
3002
|
} catch (n) {
|
|
2995
3003
|
const r = performance.now() - a;
|
|
2996
|
-
|
|
2997
|
-
|
|
3004
|
+
oe(
|
|
3005
|
+
se.PAYMENT_AUTHORIZATION_TIME,
|
|
2998
3006
|
r,
|
|
2999
3007
|
"ms",
|
|
3000
3008
|
{
|
|
@@ -3099,7 +3107,7 @@ class Dt {
|
|
|
3099
3107
|
throw M(F.PAYMENT_ASSOCIATION_FAILED, {
|
|
3100
3108
|
payment_id: e,
|
|
3101
3109
|
error_message: s instanceof Error ? s.message : "Unknown error"
|
|
3102
|
-
}),
|
|
3110
|
+
}), lt(
|
|
3103
3111
|
s instanceof Error ? s : new Error("Failed to associate payment"),
|
|
3104
3112
|
{ payment_id: e }
|
|
3105
3113
|
), s;
|
|
@@ -3109,16 +3117,16 @@ class Dt {
|
|
|
3109
3117
|
typeof globalThis < "u" && (globalThis.OdusCheckout = Dt);
|
|
3110
3118
|
export {
|
|
3111
3119
|
Dt as OdusCheckout,
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
+
_t as deLocale,
|
|
3121
|
+
Rt as enLocale,
|
|
3122
|
+
Bt as esLocale,
|
|
3123
|
+
Ut as frLocale,
|
|
3124
|
+
Ot as itLocale,
|
|
3125
|
+
Ht as plLocale,
|
|
3126
|
+
zt as ptLocale,
|
|
3127
|
+
lt as pushError,
|
|
3120
3128
|
M as pushEvent,
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3129
|
+
Tt as pushLog,
|
|
3130
|
+
oe as pushMeasurement,
|
|
3131
|
+
$t as trLocale
|
|
3124
3132
|
};
|