@odus/checkout 0.30.0-beta.2 → 0.30.0-beta.4
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.d.ts +1 -0
- package/dist/checkout.d.ts.map +1 -1
- package/dist/checkout.es.js +716 -690
- package/dist/elements.es.js +24 -16
- package/dist/index.css +1 -1
- package/dist/package.json +6 -1
- package/dist/phone.js +1437 -1420
- package/dist/shared.js +1655 -1584
- package/package.json +6 -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 j, 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,46 +16,46 @@ 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
|
-
},
|
|
24
|
-
if (!
|
|
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 = (n) => {
|
|
24
|
+
if (!n)
|
|
25
25
|
return [];
|
|
26
|
-
const e = [], t =
|
|
26
|
+
const e = [], t = n.split(`
|
|
27
27
|
`);
|
|
28
28
|
for (const s of t) {
|
|
29
29
|
const a = s.trim();
|
|
30
30
|
if (!a)
|
|
31
31
|
continue;
|
|
32
|
-
let
|
|
33
|
-
if (
|
|
32
|
+
let i = Te.exec(a);
|
|
33
|
+
if (i) {
|
|
34
34
|
e.push({
|
|
35
|
-
function:
|
|
36
|
-
filename:
|
|
37
|
-
lineno: parseInt(
|
|
38
|
-
colno: parseInt(
|
|
35
|
+
function: i[1] || "(anonymous)",
|
|
36
|
+
filename: i[2],
|
|
37
|
+
lineno: parseInt(i[3], 10),
|
|
38
|
+
colno: parseInt(i[4], 10)
|
|
39
39
|
});
|
|
40
40
|
continue;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
function:
|
|
44
|
-
filename:
|
|
45
|
-
lineno: parseInt(
|
|
46
|
-
colno: parseInt(
|
|
42
|
+
i = Le.exec(a) ?? Ve.exec(a), i && e.push({
|
|
43
|
+
function: i[1] || "(anonymous)",
|
|
44
|
+
filename: i[2],
|
|
45
|
+
lineno: parseInt(i[3], 10),
|
|
46
|
+
colno: parseInt(i[4], 10)
|
|
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
|
-
const
|
|
55
|
+
const n = navigator.userAgent;
|
|
56
56
|
let e, t, s;
|
|
57
|
-
|
|
58
|
-
const a = /Mobi|Android|iPhone|iPad/i.test(
|
|
57
|
+
n.includes("Firefox/") ? (e = "Firefox", t = n.match(/Firefox\/([\d.]+)/)?.[1]) : n.includes("Edg/") ? (e = "Edge", t = n.match(/Edg\/([\d.]+)/)?.[1]) : n.includes("Chrome/") ? (e = "Chrome", t = n.match(/Chrome\/([\d.]+)/)?.[1]) : n.includes("Safari/") && (e = "Safari", t = n.match(/Version\/([\d.]+)/)?.[1]), n.includes("Windows") ? s = "Windows" : n.includes("Mac OS") ? s = "macOS" : n.includes("Linux") ? s = "Linux" : n.includes("Android") ? s = "Android" : (n.includes("iPhone") || n.includes("iPad")) && (s = "iOS");
|
|
58
|
+
const a = /Mobi|Android|iPhone|iPad/i.test(n) || void 0;
|
|
59
59
|
return {
|
|
60
60
|
name: e,
|
|
61
61
|
version: t,
|
|
@@ -64,40 +64,40 @@ const Re = () => {
|
|
|
64
64
|
language: navigator.language,
|
|
65
65
|
viewportWidth: String(window.innerWidth),
|
|
66
66
|
viewportHeight: String(window.innerHeight),
|
|
67
|
-
userAgent:
|
|
67
|
+
userAgent: n
|
|
68
68
|
};
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
}, je = () =>
|
|
80
|
-
sdk: { name:
|
|
81
|
-
app:
|
|
82
|
-
user:
|
|
83
|
-
session:
|
|
84
|
-
page:
|
|
85
|
-
browser:
|
|
86
|
-
view:
|
|
87
|
-
}),
|
|
88
|
-
let I = [],
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
69
|
+
}, Ue = () => typeof window > "u" ? {} : { url: window.location.href }, Oe = (n) => {
|
|
70
|
+
z = void 0, X = void 0, $ = n.sessionTracking?.session ? { id: n.sessionTracking.session.id } : void 0;
|
|
71
|
+
}, He = (n) => {
|
|
72
|
+
z = n;
|
|
73
|
+
}, ze = () => {
|
|
74
|
+
z = void 0;
|
|
75
|
+
}, $e = (n) => {
|
|
76
|
+
$ = n;
|
|
77
|
+
}, Ke = (n) => {
|
|
78
|
+
X = n;
|
|
79
|
+
}, je = () => $?.id, qe = (n) => ({
|
|
80
|
+
sdk: { name: _e, version: Re },
|
|
81
|
+
app: n.app,
|
|
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 = (n) => {
|
|
90
|
+
if (k)
|
|
91
91
|
return;
|
|
92
|
-
const e =
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
const e = n.batching?.sendTimeout ?? Ye;
|
|
93
|
+
k = setTimeout(() => {
|
|
94
|
+
K(n);
|
|
95
95
|
}, e);
|
|
96
|
-
},
|
|
96
|
+
}, Je = (n, e) => {
|
|
97
97
|
const t = {
|
|
98
|
-
meta:
|
|
98
|
+
meta: qe(e)
|
|
99
99
|
};
|
|
100
|
-
for (const s of
|
|
100
|
+
for (const s of n)
|
|
101
101
|
switch (s.type) {
|
|
102
102
|
case "exception":
|
|
103
103
|
(t.exceptions ??= []).push(s.payload);
|
|
@@ -113,188 +113,188 @@ const Ge = (i) => {
|
|
|
113
113
|
break;
|
|
114
114
|
}
|
|
115
115
|
return t;
|
|
116
|
-
},
|
|
117
|
-
const s = JSON.stringify(
|
|
116
|
+
}, Xe = (n, e, t = !1) => {
|
|
117
|
+
const s = JSON.stringify(n), a = je(), i = {
|
|
118
118
|
"Content-Type": "application/json"
|
|
119
119
|
};
|
|
120
|
-
if (a && (
|
|
120
|
+
if (a && (i["x-faro-session-id"] = a), t && typeof navigator < "u" && navigator.sendBeacon) {
|
|
121
121
|
const o = new Blob([s], { type: "application/json" });
|
|
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
|
-
headers:
|
|
128
|
+
headers: i,
|
|
129
129
|
body: s,
|
|
130
130
|
keepalive: r
|
|
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 = (n, 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 =
|
|
149
|
-
if (
|
|
150
|
-
const a =
|
|
148
|
+
let s = Je(t, n);
|
|
149
|
+
if (n.beforeSend) {
|
|
150
|
+
const a = n.beforeSend(s);
|
|
151
151
|
if (!a)
|
|
152
152
|
return;
|
|
153
153
|
s = a;
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
Xe(s, n.url, e);
|
|
156
156
|
} catch {
|
|
157
157
|
}
|
|
158
|
-
}, w = (
|
|
159
|
-
I.push(
|
|
160
|
-
const t = e.batching?.itemLimit ??
|
|
158
|
+
}, w = (n, e) => {
|
|
159
|
+
I.push(n);
|
|
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 = (n) => {
|
|
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(n, !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 = (n) => {
|
|
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
|
-
},
|
|
188
|
-
},
|
|
187
|
+
}, n);
|
|
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
|
-
},
|
|
200
|
-
}, window.addEventListener("error",
|
|
201
|
-
},
|
|
202
|
-
const
|
|
203
|
-
return crypto.getRandomValues(
|
|
204
|
-
},
|
|
205
|
-
if (
|
|
206
|
-
return
|
|
199
|
+
}, n);
|
|
200
|
+
}, window.addEventListener("error", ie), window.addEventListener("unhandledrejection", ae));
|
|
201
|
+
}, re = "odus_telemetry_session_id", q = () => {
|
|
202
|
+
const n = new Uint8Array(16);
|
|
203
|
+
return crypto.getRandomValues(n), Array.from(n, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
204
|
+
}, tt = (n) => {
|
|
205
|
+
if (n)
|
|
206
|
+
return n;
|
|
207
207
|
if (typeof sessionStorage > "u")
|
|
208
|
-
return
|
|
208
|
+
return q();
|
|
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 = q();
|
|
214
|
+
return sessionStorage.setItem(re, t), t;
|
|
215
215
|
} catch {
|
|
216
|
-
return
|
|
216
|
+
return q();
|
|
217
217
|
}
|
|
218
|
-
},
|
|
219
|
-
if (!
|
|
218
|
+
}, st = (n) => {
|
|
219
|
+
if (!n.sessionTracking?.enabled)
|
|
220
220
|
return;
|
|
221
|
-
const e =
|
|
222
|
-
|
|
223
|
-
},
|
|
224
|
-
if (typeof PerformanceObserver > "u" || !PerformanceObserver.supportedEntryTypes?.includes(
|
|
221
|
+
const e = tt(n.sessionTracking.session?.id);
|
|
222
|
+
$e({ id: e });
|
|
223
|
+
}, W = () => (/* @__PURE__ */ new Date()).toISOString(), Y = (n, e) => {
|
|
224
|
+
if (typeof PerformanceObserver > "u" || !PerformanceObserver.supportedEntryTypes?.includes(n))
|
|
225
225
|
return;
|
|
226
226
|
new PerformanceObserver((s) => {
|
|
227
227
|
for (const a of s.getEntries())
|
|
228
228
|
e(a);
|
|
229
|
-
}).observe({ type:
|
|
230
|
-
},
|
|
229
|
+
}).observe({ type: n, buffered: !0 });
|
|
230
|
+
}, nt = (n) => {
|
|
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
|
+
}, n);
|
|
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
|
-
},
|
|
254
|
-
}),
|
|
253
|
+
}, n));
|
|
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
|
+
}, n);
|
|
264
264
|
});
|
|
265
|
-
},
|
|
265
|
+
}, H = {
|
|
266
266
|
INFO: "info",
|
|
267
267
|
WARN: "warn",
|
|
268
268
|
ERROR: "error"
|
|
269
|
-
},
|
|
270
|
-
|
|
271
|
-
const e =
|
|
269
|
+
}, U = () => (/* @__PURE__ */ new Date()).toISOString(), it = (n) => {
|
|
270
|
+
Oe(n), Qe(n);
|
|
271
|
+
const e = n.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(n), e.errors !== !1 && et(n), e.webVitals !== !1 && nt(n), {
|
|
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
|
+
}, n);
|
|
288
288
|
},
|
|
289
289
|
pushEvent(t, s) {
|
|
290
290
|
w({
|
|
291
291
|
type: "event",
|
|
292
292
|
payload: {
|
|
293
293
|
name: t,
|
|
294
|
-
timestamp:
|
|
294
|
+
timestamp: U(),
|
|
295
295
|
attributes: s
|
|
296
296
|
}
|
|
297
|
-
},
|
|
297
|
+
}, n);
|
|
298
298
|
},
|
|
299
299
|
pushMeasurement(t) {
|
|
300
300
|
w({
|
|
@@ -302,59 +302,59 @@ 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
|
+
}, n);
|
|
309
309
|
},
|
|
310
310
|
pushLog(t, s) {
|
|
311
311
|
w({
|
|
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
|
+
}, n);
|
|
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(n);
|
|
332
332
|
}
|
|
333
333
|
};
|
|
334
|
-
},
|
|
334
|
+
}, at = (n) => n === "test" ? "https://sandbox-analytics.odus.com/collect" : "https://analytics.odus.com/collect", rt = () => {
|
|
335
335
|
if (typeof window > "u")
|
|
336
336
|
return !1;
|
|
337
|
-
const
|
|
338
|
-
return
|
|
337
|
+
const n = window.location.hostname;
|
|
338
|
+
return n === "localhost" || n === "127.0.0.1" || n === "0.0.0.0" || n === "::1" || n === "[::1]" || n.endsWith(".localhost");
|
|
339
339
|
};
|
|
340
|
-
let
|
|
341
|
-
const
|
|
342
|
-
if (
|
|
343
|
-
return
|
|
344
|
-
if (
|
|
340
|
+
let C = null;
|
|
341
|
+
const ot = (n) => {
|
|
342
|
+
if (C)
|
|
343
|
+
return C;
|
|
344
|
+
if (rt())
|
|
345
345
|
return null;
|
|
346
|
-
const e =
|
|
347
|
-
return
|
|
346
|
+
const e = at(n.environment);
|
|
347
|
+
return C = it({
|
|
348
348
|
url: e,
|
|
349
349
|
app: {
|
|
350
350
|
name: "odus-checkout",
|
|
351
|
-
environment:
|
|
351
|
+
environment: n.environment === "test" ? "sandbox" : "production"
|
|
352
352
|
},
|
|
353
353
|
isolate: !0,
|
|
354
354
|
sessionTracking: {
|
|
355
355
|
enabled: !0,
|
|
356
356
|
session: {
|
|
357
|
-
id:
|
|
357
|
+
id: n.sessionId
|
|
358
358
|
}
|
|
359
359
|
},
|
|
360
360
|
beforeSend: (t) => {
|
|
@@ -368,46 +368,46 @@ const rt = (i) => {
|
|
|
368
368
|
"card",
|
|
369
369
|
"cvv",
|
|
370
370
|
"pan"
|
|
371
|
-
].forEach((
|
|
372
|
-
s.searchParams.has(
|
|
371
|
+
].forEach((i) => {
|
|
372
|
+
s.searchParams.has(i) && s.searchParams.set(i, "[REDACTED]");
|
|
373
373
|
}), t.meta.view.name = s.toString();
|
|
374
374
|
} catch {
|
|
375
375
|
}
|
|
376
376
|
return t;
|
|
377
377
|
}
|
|
378
|
-
}),
|
|
379
|
-
},
|
|
380
|
-
|
|
381
|
-
}, M = (
|
|
382
|
-
|
|
383
|
-
},
|
|
384
|
-
|
|
385
|
-
type:
|
|
386
|
-
values: { [
|
|
378
|
+
}), C;
|
|
379
|
+
}, lt = (n, e) => {
|
|
380
|
+
C && C.pushError(n, { context: e });
|
|
381
|
+
}, M = (n, e) => {
|
|
382
|
+
C && C.pushEvent(n, e);
|
|
383
|
+
}, oe = (n, e, t, s) => {
|
|
384
|
+
C && C.pushMeasurement({
|
|
385
|
+
type: n,
|
|
386
|
+
values: { [n]: e },
|
|
387
387
|
context: {
|
|
388
388
|
...t && { unit: t },
|
|
389
389
|
...s
|
|
390
390
|
}
|
|
391
391
|
});
|
|
392
|
-
},
|
|
393
|
-
if (!
|
|
392
|
+
}, Tt = (n, 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([n], {
|
|
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
|
}
|
|
@@ -441,7 +441,7 @@ class T {
|
|
|
441
441
|
if (!this.vgsForm)
|
|
442
442
|
throw new Error("VGS form not initialized");
|
|
443
443
|
if (e.cardNumber) {
|
|
444
|
-
const
|
|
444
|
+
const i = this.vgsForm.cardNumberField(e.cardNumber, {
|
|
445
445
|
placeholder: s.cardNumber,
|
|
446
446
|
autoComplete: "cc-number",
|
|
447
447
|
validations: ["required", "validCardNumber"],
|
|
@@ -479,44 +479,50 @@ class T {
|
|
|
479
479
|
luhn: !0
|
|
480
480
|
}
|
|
481
481
|
],
|
|
482
|
-
css: t
|
|
482
|
+
css: t.cardNumber
|
|
483
483
|
});
|
|
484
|
-
|
|
485
|
-
a && a(
|
|
486
|
-
}), this.fields.push(
|
|
484
|
+
i.on("update", (r) => {
|
|
485
|
+
a && a(L.mapCardType(r.cardType));
|
|
486
|
+
}), this.fields.push(i);
|
|
487
487
|
}
|
|
488
488
|
if (e.cardExpiry) {
|
|
489
|
-
const
|
|
489
|
+
const i = this.vgsForm.cardExpirationDateField(
|
|
490
490
|
e.cardExpiry,
|
|
491
491
|
{
|
|
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
|
-
this.fields.push(
|
|
504
|
+
this.fields.push(i);
|
|
499
505
|
}
|
|
500
506
|
if (e.cardCvv) {
|
|
501
|
-
const
|
|
507
|
+
const i = this.vgsForm.cardCVCField(e.cardCvv, {
|
|
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
|
-
this.fields.push(
|
|
513
|
+
this.fields.push(i);
|
|
508
514
|
}
|
|
509
515
|
if (e.cardholderName) {
|
|
510
|
-
const
|
|
516
|
+
const i = this.vgsForm.cardholderNameField(
|
|
511
517
|
e.cardholderName,
|
|
512
518
|
{
|
|
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
|
-
this.fields.push(
|
|
525
|
+
this.fields.push(i);
|
|
520
526
|
}
|
|
521
527
|
}
|
|
522
528
|
waitForFieldsReady() {
|
|
@@ -529,7 +535,7 @@ class T {
|
|
|
529
535
|
return new Promise((s, a) => {
|
|
530
536
|
t.createCard(
|
|
531
537
|
{ auth: e },
|
|
532
|
-
(
|
|
538
|
+
(i, r) => {
|
|
533
539
|
if (r?.errors) {
|
|
534
540
|
a(r.errors);
|
|
535
541
|
return;
|
|
@@ -539,14 +545,14 @@ class T {
|
|
|
539
545
|
a(new Error("Card creation failed: no card ID returned"));
|
|
540
546
|
return;
|
|
541
547
|
}
|
|
542
|
-
if (
|
|
548
|
+
if (i === 303) {
|
|
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
|
-
(
|
|
549
|
-
a(
|
|
554
|
+
(i) => {
|
|
555
|
+
a(i);
|
|
550
556
|
}
|
|
551
557
|
);
|
|
552
558
|
});
|
|
@@ -555,7 +561,7 @@ class T {
|
|
|
555
561
|
if (!this.vgsForm || !this.environment)
|
|
556
562
|
return Promise.reject(new Error("VGS not initialized"));
|
|
557
563
|
const s = this.vgsForm;
|
|
558
|
-
return new Promise((a,
|
|
564
|
+
return new Promise((a, i) => {
|
|
559
565
|
s.submit(
|
|
560
566
|
`/cards/${t}`,
|
|
561
567
|
{
|
|
@@ -578,22 +584,22 @@ class T {
|
|
|
578
584
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
579
585
|
(r, o) => {
|
|
580
586
|
if (r >= 400 || o?.errors) {
|
|
581
|
-
|
|
587
|
+
i(o?.errors ?? new Error("Card update failed"));
|
|
582
588
|
return;
|
|
583
589
|
}
|
|
584
590
|
const d = o?.data;
|
|
585
591
|
if (!d?.id) {
|
|
586
|
-
|
|
592
|
+
i(new Error("Card update failed: no card ID returned"));
|
|
587
593
|
return;
|
|
588
594
|
}
|
|
589
|
-
const c =
|
|
595
|
+
const c = L.extractCardResult(d), m = 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
|
m?.attributes?.updated_values?.length && (c.updatedValues = m.attributes.updated_values), a(c);
|
|
594
600
|
},
|
|
595
601
|
(r) => {
|
|
596
|
-
|
|
602
|
+
i(r);
|
|
597
603
|
}
|
|
598
604
|
);
|
|
599
605
|
});
|
|
@@ -627,11 +633,11 @@ class T {
|
|
|
627
633
|
}[e] ?? "unknown" : "unknown";
|
|
628
634
|
}
|
|
629
635
|
}
|
|
630
|
-
function
|
|
636
|
+
function G(n) {
|
|
631
637
|
return {
|
|
632
638
|
name: "Custom Appearance",
|
|
633
|
-
additionalPaymentMethods:
|
|
634
|
-
styles:
|
|
639
|
+
additionalPaymentMethods: n.additionalPaymentMethods || {},
|
|
640
|
+
styles: n.styles || {
|
|
635
641
|
fontSize: 14,
|
|
636
642
|
textColor: "#000000",
|
|
637
643
|
buttonColor: "#0070f3",
|
|
@@ -641,102 +647,104 @@ function Y(i) {
|
|
|
641
647
|
buttonFontSize: 16
|
|
642
648
|
},
|
|
643
649
|
layout: {
|
|
644
|
-
grouped:
|
|
645
|
-
actionButton:
|
|
650
|
+
grouped: n.layout?.grouped,
|
|
651
|
+
actionButton: n.layout?.actionButton || {
|
|
646
652
|
translationKey: null
|
|
647
653
|
},
|
|
648
|
-
phoneNumber:
|
|
649
|
-
enabled:
|
|
650
|
-
label:
|
|
651
|
-
defaultCountry:
|
|
652
|
-
allowedCountries:
|
|
654
|
+
phoneNumber: n.layout?.phoneNumber ? {
|
|
655
|
+
enabled: n.layout.phoneNumber.enabled,
|
|
656
|
+
label: n.layout.phoneNumber.label,
|
|
657
|
+
defaultCountry: n.layout.phoneNumber.defaultCountry,
|
|
658
|
+
allowedCountries: n.layout.phoneNumber.allowedCountries
|
|
653
659
|
} : void 0,
|
|
654
660
|
billingFields: {
|
|
655
661
|
street: {
|
|
656
|
-
enabled:
|
|
657
|
-
label:
|
|
662
|
+
enabled: n.layout?.billingFields?.street?.enabled ?? !1,
|
|
663
|
+
label: n.layout?.billingFields?.street?.label,
|
|
664
|
+
maxLength: n.layout?.billingFields?.street?.maxLength
|
|
658
665
|
},
|
|
659
666
|
city: {
|
|
660
|
-
enabled:
|
|
661
|
-
label:
|
|
667
|
+
enabled: n.layout?.billingFields?.city?.enabled ?? !1,
|
|
668
|
+
label: n.layout?.billingFields?.city?.label
|
|
662
669
|
},
|
|
663
670
|
state: {
|
|
664
|
-
enabled:
|
|
665
|
-
label:
|
|
666
|
-
hiddenForCountries:
|
|
671
|
+
enabled: n.layout?.billingFields?.state?.enabled ?? !1,
|
|
672
|
+
label: n.layout?.billingFields?.state?.label,
|
|
673
|
+
hiddenForCountries: n.layout?.billingFields?.state?.hiddenForCountries
|
|
667
674
|
},
|
|
668
675
|
zipCode: {
|
|
669
|
-
enabled:
|
|
670
|
-
label:
|
|
676
|
+
enabled: n.layout?.billingFields?.zipCode?.enabled ?? !1,
|
|
677
|
+
label: n.layout?.billingFields?.zipCode?.label
|
|
671
678
|
},
|
|
672
679
|
firstName: {
|
|
673
|
-
enabled:
|
|
674
|
-
label:
|
|
680
|
+
enabled: n.layout?.billingFields?.firstName?.enabled ?? !1,
|
|
681
|
+
label: n.layout?.billingFields?.firstName?.label
|
|
675
682
|
},
|
|
676
683
|
lastName: {
|
|
677
|
-
enabled:
|
|
678
|
-
label:
|
|
684
|
+
enabled: n.layout?.billingFields?.lastName?.enabled ?? !1,
|
|
685
|
+
label: n.layout?.billingFields?.lastName?.label
|
|
679
686
|
},
|
|
680
687
|
country: {
|
|
681
|
-
enabled:
|
|
682
|
-
label:
|
|
683
|
-
options:
|
|
688
|
+
enabled: n.layout?.billingFields?.country?.enabled ?? !1,
|
|
689
|
+
label: n.layout?.billingFields?.country?.label,
|
|
690
|
+
options: n.layout?.billingFields?.country?.options
|
|
684
691
|
}
|
|
685
692
|
},
|
|
686
|
-
shippingFields:
|
|
693
|
+
shippingFields: n.layout?.shippingFields ? {
|
|
687
694
|
street: {
|
|
688
|
-
enabled:
|
|
689
|
-
label:
|
|
695
|
+
enabled: n.layout.shippingFields.street?.enabled ?? !1,
|
|
696
|
+
label: n.layout.shippingFields.street?.label,
|
|
697
|
+
maxLength: n.layout.shippingFields.street?.maxLength
|
|
690
698
|
},
|
|
691
699
|
firstName: {
|
|
692
|
-
enabled:
|
|
693
|
-
label:
|
|
700
|
+
enabled: n.layout.shippingFields.firstName?.enabled ?? !1,
|
|
701
|
+
label: n.layout.shippingFields.firstName?.label
|
|
694
702
|
},
|
|
695
703
|
lastName: {
|
|
696
|
-
enabled:
|
|
697
|
-
label:
|
|
704
|
+
enabled: n.layout.shippingFields.lastName?.enabled ?? !1,
|
|
705
|
+
label: n.layout.shippingFields.lastName?.label
|
|
698
706
|
},
|
|
699
707
|
city: {
|
|
700
|
-
enabled:
|
|
701
|
-
label:
|
|
708
|
+
enabled: n.layout.shippingFields.city?.enabled ?? !1,
|
|
709
|
+
label: n.layout.shippingFields.city?.label
|
|
702
710
|
},
|
|
703
711
|
state: {
|
|
704
|
-
enabled:
|
|
705
|
-
label:
|
|
706
|
-
hiddenForCountries:
|
|
712
|
+
enabled: n.layout.shippingFields.state?.enabled ?? !1,
|
|
713
|
+
label: n.layout.shippingFields.state?.label,
|
|
714
|
+
hiddenForCountries: n.layout.shippingFields.state?.hiddenForCountries
|
|
707
715
|
},
|
|
708
716
|
zipCode: {
|
|
709
|
-
enabled:
|
|
710
|
-
label:
|
|
717
|
+
enabled: n.layout.shippingFields.zipCode?.enabled ?? !1,
|
|
718
|
+
label: n.layout.shippingFields.zipCode?.label
|
|
711
719
|
},
|
|
712
720
|
country: {
|
|
713
|
-
enabled:
|
|
714
|
-
label:
|
|
715
|
-
options:
|
|
721
|
+
enabled: n.layout.shippingFields.country?.enabled ?? !1,
|
|
722
|
+
label: n.layout.shippingFields.country?.label,
|
|
723
|
+
options: n.layout.shippingFields.country?.options
|
|
716
724
|
}
|
|
717
725
|
} : void 0
|
|
718
726
|
},
|
|
719
727
|
appearance: {
|
|
720
|
-
additionalPaymentMethods:
|
|
721
|
-
applePay:
|
|
722
|
-
displayName:
|
|
723
|
-
requiredBillingContactFields:
|
|
724
|
-
requiredShippingContactFields:
|
|
728
|
+
additionalPaymentMethods: n.additionalPaymentMethods ? {
|
|
729
|
+
applePay: n.additionalPaymentMethods.applePay ? {
|
|
730
|
+
displayName: n.additionalPaymentMethods.applePay.displayName,
|
|
731
|
+
requiredBillingContactFields: n.additionalPaymentMethods.applePay.requiredBillingContactFields,
|
|
732
|
+
requiredShippingContactFields: n.additionalPaymentMethods.applePay.requiredShippingContactFields
|
|
725
733
|
} : void 0
|
|
726
734
|
} : void 0
|
|
727
735
|
}
|
|
728
736
|
};
|
|
729
737
|
}
|
|
730
|
-
function
|
|
731
|
-
appearance:
|
|
738
|
+
function dt({
|
|
739
|
+
appearance: n
|
|
732
740
|
}) {
|
|
733
|
-
const e =
|
|
741
|
+
const e = me({
|
|
734
742
|
checkoutProfile: void 0,
|
|
735
743
|
isLoading: !0,
|
|
736
744
|
error: null
|
|
737
745
|
});
|
|
738
|
-
if (
|
|
739
|
-
const s =
|
|
746
|
+
if (n) {
|
|
747
|
+
const s = G(n);
|
|
740
748
|
return Promise.resolve().then(() => {
|
|
741
749
|
e.setState({
|
|
742
750
|
checkoutProfile: s,
|
|
@@ -747,9 +755,9 @@ function lt({
|
|
|
747
755
|
getState: e.getState.bind(e),
|
|
748
756
|
subscribe: e.subscribe.bind(e),
|
|
749
757
|
updateProfile: (a) => {
|
|
750
|
-
const
|
|
758
|
+
const i = G(a);
|
|
751
759
|
e.setState({
|
|
752
|
-
checkoutProfile:
|
|
760
|
+
checkoutProfile: i,
|
|
753
761
|
isLoading: !1,
|
|
754
762
|
error: null
|
|
755
763
|
});
|
|
@@ -796,7 +804,7 @@ function lt({
|
|
|
796
804
|
getState: e.getState.bind(e),
|
|
797
805
|
subscribe: e.subscribe.bind(e),
|
|
798
806
|
updateProfile: (s) => {
|
|
799
|
-
const a =
|
|
807
|
+
const a = G(s);
|
|
800
808
|
e.setState({
|
|
801
809
|
checkoutProfile: a,
|
|
802
810
|
isLoading: !1,
|
|
@@ -807,8 +815,8 @@ function lt({
|
|
|
807
815
|
}
|
|
808
816
|
};
|
|
809
817
|
}
|
|
810
|
-
const
|
|
811
|
-
const
|
|
818
|
+
const ct = () => {
|
|
819
|
+
const n = ye(), e = me({
|
|
812
820
|
formData: {
|
|
813
821
|
name: "",
|
|
814
822
|
email: "",
|
|
@@ -825,159 +833,159 @@ const dt = () => {
|
|
|
825
833
|
cardCvv: !1
|
|
826
834
|
},
|
|
827
835
|
isValid: !1
|
|
828
|
-
}), t = (l,
|
|
836
|
+
}), t = (l, p, y, u) => {
|
|
829
837
|
if (l === "cardCvv")
|
|
830
|
-
return
|
|
831
|
-
if (l === "phoneNumber" &&
|
|
832
|
-
return
|
|
833
|
-
const g =
|
|
834
|
-
return g?.(
|
|
838
|
+
return n.cardCvv(p, y);
|
|
839
|
+
if (l === "phoneNumber" && u)
|
|
840
|
+
return n.phoneNumber(p, u);
|
|
841
|
+
const g = n[l];
|
|
842
|
+
return g?.(p);
|
|
835
843
|
}, s = (l) => {
|
|
836
|
-
const
|
|
837
|
-
return Object.keys(l).forEach((
|
|
838
|
-
const g = l[
|
|
844
|
+
const p = {};
|
|
845
|
+
return Object.keys(l).forEach((u) => {
|
|
846
|
+
const g = l[u];
|
|
839
847
|
if (g === void 0) return;
|
|
840
848
|
let h;
|
|
841
|
-
|
|
842
|
-
|
|
849
|
+
u === "cardCvv" ? h = t(u, g, l.cardNumber) : u === "phoneNumber" ? h = t(
|
|
850
|
+
u,
|
|
843
851
|
g,
|
|
844
852
|
void 0,
|
|
845
853
|
l.phoneCountryCode
|
|
846
|
-
) : h = t(
|
|
854
|
+
) : h = t(u, g), h && (p[u] = h);
|
|
847
855
|
}), [
|
|
848
856
|
"billingAddress",
|
|
849
857
|
"shippingAddress"
|
|
850
|
-
].forEach((
|
|
851
|
-
const g = l[
|
|
858
|
+
].forEach((u) => {
|
|
859
|
+
const g = l[u];
|
|
852
860
|
if (g && typeof g == "object") {
|
|
853
861
|
const h = {};
|
|
854
862
|
Object.keys(g).forEach(
|
|
855
|
-
(
|
|
856
|
-
const f = g[
|
|
863
|
+
(b) => {
|
|
864
|
+
const f = g[b];
|
|
857
865
|
if (f === void 0) return;
|
|
858
|
-
const
|
|
859
|
-
if (
|
|
860
|
-
const
|
|
866
|
+
const v = n[b];
|
|
867
|
+
if (v) {
|
|
868
|
+
const E = b === "state" ? n.state(f, g.country) : v(
|
|
861
869
|
f
|
|
862
870
|
);
|
|
863
|
-
|
|
871
|
+
E && (h[b] = E);
|
|
864
872
|
}
|
|
865
873
|
}
|
|
866
|
-
), Object.keys(h).length > 0 && (u
|
|
874
|
+
), Object.keys(h).length > 0 && (p[u] = h);
|
|
867
875
|
}
|
|
868
|
-
}),
|
|
876
|
+
}), p;
|
|
869
877
|
}, a = (l) => {
|
|
870
|
-
const
|
|
871
|
-
return Object.keys(
|
|
872
|
-
},
|
|
878
|
+
const p = s(l);
|
|
879
|
+
return Object.keys(p).length === 0;
|
|
880
|
+
}, i = "billingAddress.", r = "shippingAddress.", o = (l) => l.startsWith(i) ? {
|
|
873
881
|
parent: "billingAddress",
|
|
874
|
-
field: l.slice(
|
|
882
|
+
field: l.slice(i.length)
|
|
875
883
|
} : l.startsWith(r) ? {
|
|
876
884
|
parent: "shippingAddress",
|
|
877
885
|
field: l.slice(r.length)
|
|
878
|
-
} : null, d = (l,
|
|
886
|
+
} : null, d = (l, p, y, u) => {
|
|
879
887
|
const g = { ...l };
|
|
880
|
-
if (
|
|
881
|
-
g[
|
|
882
|
-
...g[
|
|
883
|
-
[y]:
|
|
888
|
+
if (u)
|
|
889
|
+
g[p] = {
|
|
890
|
+
...g[p],
|
|
891
|
+
[y]: u
|
|
884
892
|
};
|
|
885
893
|
else {
|
|
886
894
|
const h = {
|
|
887
|
-
...g[
|
|
895
|
+
...g[p]
|
|
888
896
|
};
|
|
889
|
-
delete h[y], Object.keys(h).length === 0 ? delete g[
|
|
897
|
+
delete h[y], Object.keys(h).length === 0 ? delete g[p] : g[p] = h;
|
|
890
898
|
}
|
|
891
899
|
return g;
|
|
892
|
-
}, c = (l,
|
|
900
|
+
}, c = (l, p) => {
|
|
893
901
|
const y = e.getState();
|
|
894
|
-
let
|
|
902
|
+
let u = p;
|
|
895
903
|
const g = o(l);
|
|
896
904
|
if (!g && l in j)
|
|
897
905
|
if (l === "cardCvv") {
|
|
898
|
-
const
|
|
899
|
-
|
|
906
|
+
const v = be(y.formData.cardNumber) === "amex" ? 4 : 3;
|
|
907
|
+
u = j.cardCvv(p, v);
|
|
900
908
|
} else
|
|
901
|
-
|
|
909
|
+
u = j[l](p);
|
|
902
910
|
let h;
|
|
903
911
|
if (g) {
|
|
904
|
-
const { parent: f, field:
|
|
912
|
+
const { parent: f, field: v } = g;
|
|
905
913
|
h = {
|
|
906
914
|
...y.formData,
|
|
907
915
|
[f]: {
|
|
908
916
|
...y.formData[f] ?? {},
|
|
909
|
-
[
|
|
917
|
+
[v]: u
|
|
910
918
|
}
|
|
911
919
|
};
|
|
912
920
|
} else
|
|
913
921
|
h = {
|
|
914
922
|
...y.formData,
|
|
915
|
-
[l]:
|
|
923
|
+
[l]: u
|
|
916
924
|
};
|
|
917
|
-
let
|
|
925
|
+
let b = { ...y.errors };
|
|
918
926
|
if (l === "phoneCountryCode" && h.phoneNumber) {
|
|
919
927
|
const f = t(
|
|
920
928
|
"phoneNumber",
|
|
921
929
|
h.phoneNumber,
|
|
922
930
|
void 0,
|
|
923
|
-
|
|
931
|
+
u
|
|
924
932
|
);
|
|
925
|
-
f ?
|
|
933
|
+
f ? b.phoneNumber = f : delete b.phoneNumber;
|
|
926
934
|
}
|
|
927
935
|
if (y.touched[l])
|
|
928
936
|
if (g) {
|
|
929
|
-
const { parent: f, field:
|
|
937
|
+
const { parent: f, field: v } = g, E = h[f];
|
|
930
938
|
let N;
|
|
931
|
-
if (
|
|
932
|
-
N =
|
|
939
|
+
if (v === "state")
|
|
940
|
+
N = n.state(u, E?.country);
|
|
933
941
|
else {
|
|
934
|
-
const
|
|
935
|
-
N =
|
|
936
|
-
|
|
942
|
+
const x = n[v];
|
|
943
|
+
N = x ? x(
|
|
944
|
+
u
|
|
937
945
|
) : void 0;
|
|
938
946
|
}
|
|
939
|
-
|
|
947
|
+
b = d(b, f, v, N);
|
|
940
948
|
} else {
|
|
941
949
|
let f;
|
|
942
|
-
l === "cardCvv" ? f = t(l,
|
|
950
|
+
l === "cardCvv" ? f = t(l, u, h.cardNumber) : l === "phoneNumber" ? f = t(
|
|
943
951
|
l,
|
|
944
|
-
|
|
952
|
+
u,
|
|
945
953
|
void 0,
|
|
946
954
|
h.phoneCountryCode
|
|
947
|
-
) : f = t(l,
|
|
955
|
+
) : f = t(l, u), f ? b[l] = f : delete b[l];
|
|
948
956
|
}
|
|
949
957
|
e.setState({
|
|
950
958
|
formData: h,
|
|
951
|
-
errors:
|
|
959
|
+
errors: b,
|
|
952
960
|
isValid: a(h)
|
|
953
961
|
});
|
|
954
|
-
}, m = (l,
|
|
955
|
-
const y = e.getState(),
|
|
956
|
-
if (
|
|
957
|
-
const { parent: f, field:
|
|
962
|
+
}, m = (l, p) => {
|
|
963
|
+
const y = e.getState(), u = o(l);
|
|
964
|
+
if (u) {
|
|
965
|
+
const { parent: f, field: v } = u, E = {
|
|
958
966
|
...y.formData,
|
|
959
967
|
[f]: {
|
|
960
968
|
...y.formData[f] ?? {},
|
|
961
|
-
[
|
|
969
|
+
[v]: p
|
|
962
970
|
}
|
|
963
971
|
};
|
|
964
972
|
let N;
|
|
965
|
-
if (
|
|
966
|
-
const
|
|
967
|
-
N =
|
|
973
|
+
if (v === "state") {
|
|
974
|
+
const V = E[f];
|
|
975
|
+
N = n.state(p, V?.country);
|
|
968
976
|
} else {
|
|
969
|
-
const
|
|
970
|
-
N =
|
|
977
|
+
const V = n[v];
|
|
978
|
+
N = V ? V(p) : void 0;
|
|
971
979
|
}
|
|
972
|
-
const
|
|
980
|
+
const x = d(y.errors, f, v, N);
|
|
973
981
|
e.setState({
|
|
974
|
-
formData:
|
|
982
|
+
formData: E,
|
|
975
983
|
touched: {
|
|
976
984
|
...y.touched,
|
|
977
985
|
[l]: !0
|
|
978
986
|
},
|
|
979
|
-
errors:
|
|
980
|
-
isValid: a(
|
|
987
|
+
errors: x,
|
|
988
|
+
isValid: a(E)
|
|
981
989
|
});
|
|
982
990
|
return;
|
|
983
991
|
}
|
|
@@ -986,18 +994,18 @@ const dt = () => {
|
|
|
986
994
|
[l]: !0
|
|
987
995
|
};
|
|
988
996
|
let h;
|
|
989
|
-
l === "cardCvv" ? h = t(l,
|
|
997
|
+
l === "cardCvv" ? h = t(l, p, y.formData.cardNumber) : l === "phoneNumber" ? h = t(
|
|
990
998
|
l,
|
|
991
|
-
|
|
999
|
+
p,
|
|
992
1000
|
void 0,
|
|
993
1001
|
y.formData.phoneCountryCode
|
|
994
|
-
) : h = t(l,
|
|
995
|
-
const
|
|
996
|
-
h ?
|
|
1002
|
+
) : h = t(l, p);
|
|
1003
|
+
const b = { ...y.errors };
|
|
1004
|
+
h ? b[l] = h : delete b[l], e.setState({
|
|
997
1005
|
touched: g,
|
|
998
|
-
errors:
|
|
1006
|
+
errors: b
|
|
999
1007
|
});
|
|
1000
|
-
},
|
|
1008
|
+
}, S = (l) => {
|
|
1001
1009
|
const y = {
|
|
1002
1010
|
...e.getState().formData,
|
|
1003
1011
|
...l
|
|
@@ -1012,36 +1020,36 @@ const dt = () => {
|
|
|
1012
1020
|
subscribe: e.subscribe.bind(e),
|
|
1013
1021
|
handleChange: c,
|
|
1014
1022
|
handleBlur: m,
|
|
1015
|
-
setFormData:
|
|
1023
|
+
setFormData: S,
|
|
1016
1024
|
reset: e.resetState.bind(e)
|
|
1017
1025
|
};
|
|
1018
|
-
},
|
|
1019
|
-
async function
|
|
1020
|
-
if (!
|
|
1021
|
-
const e =
|
|
1026
|
+
}, ht = "https://fonts.googleapis.com/css2", ut = /src:\s*url\(([^)]+\.woff2[^)]*)\)/, mt = /\/\*\s*latin\s*\*\/\s*@font-face\s*\{[^}]*src:\s*url\(([^)]+\.woff2[^)]*)\)[^}]*\}/;
|
|
1027
|
+
async function pt(n) {
|
|
1028
|
+
if (!n) return null;
|
|
1029
|
+
const e = n.trim().replace(/\s+/g, "+"), t = `${ht}?family=${e}:wght@400;700&display=swap`;
|
|
1022
1030
|
try {
|
|
1023
1031
|
const s = await fetch(t);
|
|
1024
1032
|
if (!s.ok) return null;
|
|
1025
|
-
const a = await s.text(),
|
|
1026
|
-
if (
|
|
1027
|
-
const r =
|
|
1033
|
+
const a = await s.text(), i = mt.exec(a);
|
|
1034
|
+
if (i?.[1]) return i[1];
|
|
1035
|
+
const r = ut.exec(a);
|
|
1028
1036
|
return r?.[1] ? r[1] : null;
|
|
1029
1037
|
} catch {
|
|
1030
1038
|
return null;
|
|
1031
1039
|
}
|
|
1032
1040
|
}
|
|
1033
|
-
function
|
|
1034
|
-
if (!
|
|
1035
|
-
const { billingFields: e, shippingFields: t } =
|
|
1041
|
+
function gt(n) {
|
|
1042
|
+
if (!n) return !1;
|
|
1043
|
+
const { billingFields: e, shippingFields: t } = n, s = e && Object.values(e).some((i) => i?.enabled), a = t && Object.values(t).some((i) => i?.enabled);
|
|
1036
1044
|
return !!(s || a);
|
|
1037
1045
|
}
|
|
1038
|
-
function
|
|
1039
|
-
if (!
|
|
1040
|
-
const { billingFields: e, shippingFields: t } =
|
|
1046
|
+
function J(n) {
|
|
1047
|
+
if (!n) return !1;
|
|
1048
|
+
const { billingFields: e, shippingFields: t } = n, s = e?.firstName?.enabled && e?.lastName?.enabled, a = t?.firstName?.enabled && t?.lastName?.enabled;
|
|
1041
1049
|
return !!(s || a);
|
|
1042
1050
|
}
|
|
1043
|
-
const
|
|
1044
|
-
class
|
|
1051
|
+
const O = /* @__PURE__ */ new Set(["US", "CA"]);
|
|
1052
|
+
class ce extends A {
|
|
1045
1053
|
inputs = /* @__PURE__ */ new Map();
|
|
1046
1054
|
type;
|
|
1047
1055
|
onChange;
|
|
@@ -1056,25 +1064,25 @@ class de extends k {
|
|
|
1056
1064
|
stateStyles;
|
|
1057
1065
|
constructor(e) {
|
|
1058
1066
|
super("div", ["address-section"]), this.type = e.type, this.onChange = e.onChange, this.onBlur = e.onBlur, this.translationFunc = e.translationFunc, this.locale = e.locale, this.grouped = e.grouped ?? !0;
|
|
1059
|
-
const { title: t, checkoutProfile: s, fieldsConfig: a, values:
|
|
1067
|
+
const { title: t, checkoutProfile: s, fieldsConfig: a, values: i, errors: r, touched: o } = e;
|
|
1060
1068
|
if (this.grouped) {
|
|
1061
1069
|
const d = document.createElement("h3");
|
|
1062
1070
|
d.className = "address-section-title", d.textContent = t, d.style.color = s.styles.textColor, d.style.fontFamily = `"${s.styles.fontFamily}", sans-serif`, d.style.fontSize = `${s.styles.fontSize}px`, d.style.fontWeight = "normal", this.getElement().appendChild(d);
|
|
1063
1071
|
}
|
|
1064
|
-
this.fieldsContainer = document.createElement("div"), this.fieldsContainer.className = "address-fields", this.grouped || this.fieldsContainer.classList.add("address-fields--ungrouped"), this.getElement().appendChild(this.fieldsContainer), this.createFields(s, a,
|
|
1072
|
+
this.fieldsContainer = document.createElement("div"), this.fieldsContainer.className = "address-fields", this.grouped || this.fieldsContainer.classList.add("address-fields--ungrouped"), this.getElement().appendChild(this.fieldsContainer), this.createFields(s, a, i, r, o);
|
|
1065
1073
|
}
|
|
1066
|
-
borderRadius(e, t, s, a,
|
|
1074
|
+
borderRadius(e, t, s, a, i) {
|
|
1067
1075
|
const r = (o) => o ? `${e}px` : "0px";
|
|
1068
|
-
return `${r(t)} ${r(s)} ${r(a)} ${r(
|
|
1076
|
+
return `${r(t)} ${r(s)} ${r(a)} ${r(i)}`;
|
|
1069
1077
|
}
|
|
1070
|
-
createFields(e, t, s, a,
|
|
1078
|
+
createFields(e, t, s, a, i) {
|
|
1071
1079
|
if (!this.grouped) {
|
|
1072
1080
|
this.createUngroupedFields(
|
|
1073
1081
|
e,
|
|
1074
1082
|
t,
|
|
1075
1083
|
s,
|
|
1076
1084
|
a,
|
|
1077
|
-
|
|
1085
|
+
i
|
|
1078
1086
|
);
|
|
1079
1087
|
return;
|
|
1080
1088
|
}
|
|
@@ -1088,97 +1096,98 @@ class de extends k {
|
|
|
1088
1096
|
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
1097
|
const m = [];
|
|
1090
1098
|
t.city?.enabled && m.push("city"), t.zipCode?.enabled && m.push("zipCode"), m.length > 0 && d.push({ kind: "cityZip", fields: m }), t.state?.enabled && d.push({ kind: "state" });
|
|
1091
|
-
const
|
|
1092
|
-
d.forEach((l,
|
|
1093
|
-
const y =
|
|
1099
|
+
const S = d.length;
|
|
1100
|
+
d.forEach((l, p) => {
|
|
1101
|
+
const y = p === 0, u = p === S - 1, g = (h, b) => ({
|
|
1094
1102
|
...o,
|
|
1095
1103
|
borderRadius: this.borderRadius(
|
|
1096
1104
|
r,
|
|
1097
1105
|
y && h,
|
|
1098
|
-
y &&
|
|
1099
|
-
|
|
1100
|
-
|
|
1106
|
+
y && b,
|
|
1107
|
+
u && b,
|
|
1108
|
+
u && h
|
|
1101
1109
|
)
|
|
1102
1110
|
});
|
|
1103
1111
|
if (l.kind === "street") {
|
|
1104
|
-
const h = this.createRow(["full"]),
|
|
1112
|
+
const h = this.createRow(["full"]), b = this.createInput(
|
|
1105
1113
|
"street",
|
|
1106
1114
|
t.street?.label ?? this.translationFunc("address.addressLine1"),
|
|
1107
1115
|
s.street,
|
|
1108
1116
|
a.street,
|
|
1109
|
-
|
|
1117
|
+
i.street,
|
|
1110
1118
|
g(!0, !0),
|
|
1111
|
-
"street-address"
|
|
1119
|
+
"street-address",
|
|
1120
|
+
t.street?.maxLength
|
|
1112
1121
|
);
|
|
1113
|
-
this.inputs.set("street",
|
|
1122
|
+
this.inputs.set("street", b), h.appendChild(b.getElement()), this.fieldsContainer.appendChild(h);
|
|
1114
1123
|
return;
|
|
1115
1124
|
}
|
|
1116
1125
|
if (l.kind === "name") {
|
|
1117
|
-
const h = this.createRow(l.fields.map(() => "half")),
|
|
1126
|
+
const h = this.createRow(l.fields.map(() => "half")), b = l.fields.length === 1;
|
|
1118
1127
|
if (l.fields.includes("firstName")) {
|
|
1119
|
-
const f =
|
|
1128
|
+
const f = b || l.fields[l.fields.length - 1] === "firstName", v = this.createInput(
|
|
1120
1129
|
"firstName",
|
|
1121
1130
|
t.firstName?.label ?? this.translationFunc("address.firstName"),
|
|
1122
1131
|
s.firstName,
|
|
1123
1132
|
a.firstName,
|
|
1124
|
-
|
|
1133
|
+
i.firstName,
|
|
1125
1134
|
g(!0, f),
|
|
1126
1135
|
"given-name"
|
|
1127
1136
|
);
|
|
1128
|
-
this.inputs.set("firstName",
|
|
1137
|
+
this.inputs.set("firstName", v), h.appendChild(v.getElement());
|
|
1129
1138
|
}
|
|
1130
1139
|
if (l.fields.includes("lastName")) {
|
|
1131
|
-
const f =
|
|
1140
|
+
const f = b || l.fields[0] === "lastName", v = this.createInput(
|
|
1132
1141
|
"lastName",
|
|
1133
1142
|
t.lastName?.label ?? this.translationFunc("address.lastName"),
|
|
1134
1143
|
s.lastName,
|
|
1135
1144
|
a.lastName,
|
|
1136
|
-
|
|
1145
|
+
i.lastName,
|
|
1137
1146
|
g(f, !0),
|
|
1138
1147
|
"family-name"
|
|
1139
1148
|
);
|
|
1140
|
-
this.inputs.set("lastName",
|
|
1149
|
+
this.inputs.set("lastName", v), h.appendChild(v.getElement());
|
|
1141
1150
|
}
|
|
1142
1151
|
this.fieldsContainer.appendChild(h);
|
|
1143
1152
|
return;
|
|
1144
1153
|
}
|
|
1145
1154
|
if (l.kind === "country") {
|
|
1146
|
-
const h = this.createRow(["full"]),
|
|
1155
|
+
const h = this.createRow(["full"]), b = this.createCountrySelect(
|
|
1147
1156
|
s.country,
|
|
1148
1157
|
a.country,
|
|
1149
|
-
|
|
1158
|
+
i.country,
|
|
1150
1159
|
g(!0, !0),
|
|
1151
1160
|
t.country?.options,
|
|
1152
1161
|
t.country?.label
|
|
1153
1162
|
);
|
|
1154
|
-
this.inputs.set("country",
|
|
1163
|
+
this.inputs.set("country", b), h.appendChild(b.getElement()), this.fieldsContainer.appendChild(h);
|
|
1155
1164
|
return;
|
|
1156
1165
|
}
|
|
1157
1166
|
if (l.kind === "cityZip") {
|
|
1158
|
-
const h = this.createRow(l.fields.map(() => "half")),
|
|
1167
|
+
const h = this.createRow(l.fields.map(() => "half")), b = l.fields.length === 1;
|
|
1159
1168
|
if (l.fields.includes("city")) {
|
|
1160
|
-
const f =
|
|
1169
|
+
const f = b || l.fields[l.fields.length - 1] === "city", v = this.createInput(
|
|
1161
1170
|
"city",
|
|
1162
1171
|
t.city?.label ?? this.translationFunc("address.townCity"),
|
|
1163
1172
|
s.city,
|
|
1164
1173
|
a.city,
|
|
1165
|
-
|
|
1174
|
+
i.city,
|
|
1166
1175
|
g(!0, f),
|
|
1167
1176
|
"address-level2"
|
|
1168
1177
|
);
|
|
1169
|
-
this.inputs.set("city",
|
|
1178
|
+
this.inputs.set("city", v), h.appendChild(v.getElement());
|
|
1170
1179
|
}
|
|
1171
1180
|
if (l.fields.includes("zipCode")) {
|
|
1172
|
-
const f =
|
|
1181
|
+
const f = b || l.fields[0] === "zipCode", v = this.createInput(
|
|
1173
1182
|
"zipCode",
|
|
1174
1183
|
t.zipCode?.label ?? this.translationFunc("address.postalCode"),
|
|
1175
1184
|
s.zipCode,
|
|
1176
1185
|
a.zipCode,
|
|
1177
|
-
|
|
1186
|
+
i.zipCode,
|
|
1178
1187
|
g(f, !0),
|
|
1179
1188
|
"postal-code"
|
|
1180
1189
|
);
|
|
1181
|
-
this.inputs.set("zipCode",
|
|
1190
|
+
this.inputs.set("zipCode", v), h.appendChild(v.getElement());
|
|
1182
1191
|
}
|
|
1183
1192
|
this.fieldsContainer.appendChild(h);
|
|
1184
1193
|
return;
|
|
@@ -1187,27 +1196,27 @@ class de extends k {
|
|
|
1187
1196
|
const h = this.createRow(["full"]);
|
|
1188
1197
|
if (this.stateFieldConfig = t.state, this.stateRow = h, this.stateStyles = g(!0, !0), this.currentCountry = s.country, t.state?.hiddenForCountries?.includes(
|
|
1189
1198
|
s.country
|
|
1190
|
-
) && (h.style.display = "none"),
|
|
1191
|
-
const
|
|
1199
|
+
) && (h.style.display = "none"), O.has(s.country)) {
|
|
1200
|
+
const v = this.createStateSelect(
|
|
1192
1201
|
s.state,
|
|
1193
1202
|
a.state,
|
|
1194
|
-
|
|
1203
|
+
i.state,
|
|
1195
1204
|
this.stateStyles,
|
|
1196
1205
|
s.country,
|
|
1197
1206
|
t.state?.label
|
|
1198
1207
|
);
|
|
1199
|
-
this.inputs.set("state",
|
|
1208
|
+
this.inputs.set("state", v), h.appendChild(v.getElement());
|
|
1200
1209
|
} else {
|
|
1201
|
-
const
|
|
1210
|
+
const v = this.createInput(
|
|
1202
1211
|
"state",
|
|
1203
1212
|
t.state?.label ?? this.translationFunc("address.state"),
|
|
1204
1213
|
s.state,
|
|
1205
1214
|
a.state,
|
|
1206
|
-
|
|
1215
|
+
i.state,
|
|
1207
1216
|
this.stateStyles,
|
|
1208
1217
|
"address-level1"
|
|
1209
1218
|
);
|
|
1210
|
-
this.inputs.set("state",
|
|
1219
|
+
this.inputs.set("state", v), h.appendChild(v.getElement());
|
|
1211
1220
|
}
|
|
1212
1221
|
this.fieldsContainer.appendChild(h);
|
|
1213
1222
|
}
|
|
@@ -1217,46 +1226,54 @@ class de extends k {
|
|
|
1217
1226
|
const t = document.createElement("div");
|
|
1218
1227
|
return t.className = `address-row address-row-${e.length === 1 ? "single" : "double"}`, t;
|
|
1219
1228
|
}
|
|
1220
|
-
createInput(e, t, s, a,
|
|
1221
|
-
const
|
|
1222
|
-
name:
|
|
1229
|
+
createInput(e, t, s, a, i, r, o, d) {
|
|
1230
|
+
const c = `${this.type}Address.${e}`, m = new pe({
|
|
1231
|
+
name: c,
|
|
1223
1232
|
error: !1,
|
|
1224
1233
|
errorMsg: void 0,
|
|
1225
1234
|
styles: r,
|
|
1235
|
+
maxLength: d,
|
|
1226
1236
|
...this.grouped ? { placeholder: t } : {
|
|
1227
1237
|
label: t,
|
|
1228
1238
|
placeholder: (() => {
|
|
1229
|
-
const
|
|
1230
|
-
return
|
|
1239
|
+
const S = `address.placeholder.${e}`, l = this.translationFunc(S);
|
|
1240
|
+
return l !== S ? l : t;
|
|
1231
1241
|
})()
|
|
1232
1242
|
},
|
|
1233
1243
|
value: s,
|
|
1234
1244
|
autocomplete: o,
|
|
1235
|
-
onChange: (
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
+
onChange: (S) => {
|
|
1246
|
+
const l = S.target.value;
|
|
1247
|
+
if (d && l.length >= d) {
|
|
1248
|
+
const p = this.translationFunc("validation.maxLengthExceeded");
|
|
1249
|
+
m.setError(!0, p.replace("{{max}}", String(d)));
|
|
1250
|
+
} else
|
|
1251
|
+
m.setError(!1);
|
|
1252
|
+
this.onChange(
|
|
1253
|
+
P({
|
|
1254
|
+
type: "input",
|
|
1255
|
+
target: {
|
|
1256
|
+
name: c,
|
|
1257
|
+
value: l
|
|
1258
|
+
}
|
|
1259
|
+
})
|
|
1260
|
+
);
|
|
1245
1261
|
}
|
|
1246
1262
|
});
|
|
1247
|
-
return
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1263
|
+
return m.addEventListener("blur", (S) => {
|
|
1264
|
+
this.onBlur(
|
|
1265
|
+
P({
|
|
1266
|
+
type: "blur",
|
|
1267
|
+
target: {
|
|
1268
|
+
name: c,
|
|
1269
|
+
value: S.target.value
|
|
1270
|
+
}
|
|
1271
|
+
})
|
|
1272
|
+
);
|
|
1273
|
+
}), m;
|
|
1257
1274
|
}
|
|
1258
|
-
createCountrySelect(e, t, s, a,
|
|
1259
|
-
const o = `${this.type}Address.country`, d =
|
|
1275
|
+
createCountrySelect(e, t, s, a, i, r) {
|
|
1276
|
+
const o = `${this.type}Address.country`, d = ve(i, this.locale), c = new _({
|
|
1260
1277
|
name: o,
|
|
1261
1278
|
error: !1,
|
|
1262
1279
|
errorMsg: void 0,
|
|
@@ -1270,25 +1287,25 @@ class de extends k {
|
|
|
1270
1287
|
autocomplete: "country",
|
|
1271
1288
|
onChange: (m) => {
|
|
1272
1289
|
c.setError(!1);
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
name: o,
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
}), this.onChange(l), this.handleCountryChange(b);
|
|
1290
|
+
const S = m.target.value;
|
|
1291
|
+
this.onChange(
|
|
1292
|
+
P({
|
|
1293
|
+
type: "change",
|
|
1294
|
+
target: { name: o, value: S }
|
|
1295
|
+
})
|
|
1296
|
+
), this.handleCountryChange(S);
|
|
1281
1297
|
}
|
|
1282
1298
|
});
|
|
1283
1299
|
return c.addEventListener("blur", (m) => {
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1300
|
+
this.onBlur(
|
|
1301
|
+
P({
|
|
1302
|
+
type: "blur",
|
|
1303
|
+
target: {
|
|
1304
|
+
name: o,
|
|
1305
|
+
value: m.target.value
|
|
1306
|
+
}
|
|
1307
|
+
})
|
|
1308
|
+
);
|
|
1292
1309
|
}), c;
|
|
1293
1310
|
}
|
|
1294
1311
|
handleCountryChange(e) {
|
|
@@ -1300,26 +1317,26 @@ class de extends k {
|
|
|
1300
1317
|
return;
|
|
1301
1318
|
}
|
|
1302
1319
|
if (!a && s && (this.stateRow.style.display = ""), a) return;
|
|
1303
|
-
const
|
|
1304
|
-
if (
|
|
1320
|
+
const i = this.inputs.get("state") instanceof _, r = O.has(e);
|
|
1321
|
+
if (i && r) {
|
|
1305
1322
|
const o = this.inputs.get("state");
|
|
1306
|
-
if (o instanceof
|
|
1307
|
-
const d = e === "CA" ? "CA" : "US", c =
|
|
1323
|
+
if (o instanceof _) {
|
|
1324
|
+
const d = e === "CA" ? "CA" : "US", c = ee(d), m = d === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState");
|
|
1308
1325
|
o.setOptions(c, m);
|
|
1309
1326
|
}
|
|
1310
1327
|
this.clearStateValue();
|
|
1311
1328
|
return;
|
|
1312
1329
|
}
|
|
1313
|
-
if (
|
|
1330
|
+
if (i !== r) {
|
|
1314
1331
|
this.rebuildStateField(e), this.clearStateValue();
|
|
1315
1332
|
return;
|
|
1316
1333
|
}
|
|
1317
|
-
!
|
|
1334
|
+
!i && !r && t !== e && this.clearStateValue();
|
|
1318
1335
|
}
|
|
1319
1336
|
rebuildStateField(e) {
|
|
1320
1337
|
if (!this.stateRow || !this.stateStyles) return;
|
|
1321
1338
|
const t = this.inputs.get("state");
|
|
1322
|
-
if (t && (t.getElement().remove(), this.inputs.delete("state")),
|
|
1339
|
+
if (t && (t.getElement().remove(), this.inputs.delete("state")), O.has(e)) {
|
|
1323
1340
|
const a = this.createStateSelect(
|
|
1324
1341
|
"",
|
|
1325
1342
|
void 0,
|
|
@@ -1345,17 +1362,17 @@ class de extends k {
|
|
|
1345
1362
|
clearStateValue() {
|
|
1346
1363
|
const e = this.inputs.get("state");
|
|
1347
1364
|
e && e.setValue("");
|
|
1348
|
-
const t = `${this.type}Address.state
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1365
|
+
const t = `${this.type}Address.state`;
|
|
1366
|
+
this.onChange(
|
|
1367
|
+
P({
|
|
1368
|
+
type: "input",
|
|
1369
|
+
target: { name: t, value: "" },
|
|
1370
|
+
detail: { programmatic: !0 }
|
|
1371
|
+
})
|
|
1372
|
+
);
|
|
1356
1373
|
}
|
|
1357
|
-
createStateSelect(e, t, s, a,
|
|
1358
|
-
const o = `${this.type}Address.state`, d =
|
|
1374
|
+
createStateSelect(e, t, s, a, i, r) {
|
|
1375
|
+
const o = `${this.type}Address.state`, d = i === "CA" ? "CA" : "US", c = ee(d), m = d === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState"), S = new _({
|
|
1359
1376
|
name: o,
|
|
1360
1377
|
error: !1,
|
|
1361
1378
|
errorMsg: void 0,
|
|
@@ -1366,57 +1383,64 @@ class de extends k {
|
|
|
1366
1383
|
options: c,
|
|
1367
1384
|
autocomplete: "address-level1",
|
|
1368
1385
|
onChange: (l) => {
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1386
|
+
S.setError(!1), this.onChange(
|
|
1387
|
+
P({
|
|
1388
|
+
type: "change",
|
|
1389
|
+
target: {
|
|
1390
|
+
name: o,
|
|
1391
|
+
value: l.target.value
|
|
1392
|
+
}
|
|
1393
|
+
})
|
|
1394
|
+
);
|
|
1395
|
+
}
|
|
1396
|
+
});
|
|
1397
|
+
return S.addEventListener("blur", (l) => {
|
|
1398
|
+
this.onBlur(
|
|
1399
|
+
P({
|
|
1400
|
+
type: "blur",
|
|
1401
|
+
target: {
|
|
1374
1402
|
name: o,
|
|
1375
1403
|
value: l.target.value
|
|
1376
1404
|
}
|
|
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;
|
|
1405
|
+
})
|
|
1406
|
+
);
|
|
1407
|
+
}), S;
|
|
1390
1408
|
}
|
|
1391
|
-
createUngroupedFields(e, t, s, a,
|
|
1409
|
+
createUngroupedFields(e, t, s, a, i) {
|
|
1392
1410
|
const r = e.styles.borderRadius, o = {
|
|
1393
1411
|
color: e.styles.textColor,
|
|
1394
1412
|
fontSize: e.styles.fontSize,
|
|
1395
1413
|
fontFamily: e.styles.fontFamily,
|
|
1396
1414
|
borderRadius: `${r}px`
|
|
1397
|
-
}, d = (c, m,
|
|
1415
|
+
}, d = (c, m, S, l) => {
|
|
1398
1416
|
if (!t[c]?.enabled) return;
|
|
1399
|
-
const
|
|
1417
|
+
const p = t[c]?.label ?? this.translationFunc(m), y = this.createRow(["full"]), u = this.createInput(
|
|
1400
1418
|
c,
|
|
1401
|
-
|
|
1419
|
+
p,
|
|
1402
1420
|
s[c],
|
|
1403
1421
|
a[c],
|
|
1404
|
-
|
|
1422
|
+
i[c],
|
|
1405
1423
|
o,
|
|
1406
|
-
|
|
1424
|
+
S,
|
|
1425
|
+
l
|
|
1407
1426
|
);
|
|
1408
|
-
this.inputs.set(c,
|
|
1427
|
+
this.inputs.set(c, u), y.appendChild(u.getElement()), this.fieldsContainer.appendChild(y);
|
|
1409
1428
|
};
|
|
1410
|
-
if (d("firstName", "address.firstName", "given-name"), d("lastName", "address.lastName", "family-name"), d(
|
|
1411
|
-
|
|
1429
|
+
if (d("firstName", "address.firstName", "given-name"), d("lastName", "address.lastName", "family-name"), d(
|
|
1430
|
+
"street",
|
|
1431
|
+
"address.addressLine1",
|
|
1432
|
+
"street-address",
|
|
1433
|
+
t.street?.maxLength
|
|
1434
|
+
), d("city", "address.townCity", "address-level2"), t.country?.enabled) {
|
|
1435
|
+
const c = t.country?.label ?? this.translationFunc("address.chooseCountry"), m = this.createRow(["full"]), S = this.createCountrySelect(
|
|
1412
1436
|
s.country,
|
|
1413
1437
|
a.country,
|
|
1414
|
-
|
|
1438
|
+
i.country,
|
|
1415
1439
|
o,
|
|
1416
1440
|
t.country?.options,
|
|
1417
1441
|
c
|
|
1418
1442
|
);
|
|
1419
|
-
this.inputs.set("country",
|
|
1443
|
+
this.inputs.set("country", S), m.appendChild(S.getElement()), this.fieldsContainer.appendChild(m);
|
|
1420
1444
|
}
|
|
1421
1445
|
if (t.state?.enabled) {
|
|
1422
1446
|
this.stateFieldConfig = t.state;
|
|
@@ -1424,28 +1448,28 @@ class de extends k {
|
|
|
1424
1448
|
this.stateRow = c, this.stateStyles = o, this.currentCountry = s.country, t.state?.hiddenForCountries?.includes(
|
|
1425
1449
|
s.country
|
|
1426
1450
|
) && (c.style.display = "none");
|
|
1427
|
-
const
|
|
1428
|
-
if (
|
|
1429
|
-
const
|
|
1451
|
+
const S = O.has(s.country), l = t.state?.label ?? this.translationFunc("address.state");
|
|
1452
|
+
if (S) {
|
|
1453
|
+
const p = this.createStateSelect(
|
|
1430
1454
|
s.state,
|
|
1431
1455
|
a.state,
|
|
1432
|
-
|
|
1456
|
+
i.state,
|
|
1433
1457
|
o,
|
|
1434
1458
|
s.country,
|
|
1435
1459
|
l
|
|
1436
1460
|
);
|
|
1437
|
-
this.inputs.set("state",
|
|
1461
|
+
this.inputs.set("state", p), c.appendChild(p.getElement());
|
|
1438
1462
|
} else {
|
|
1439
|
-
const
|
|
1463
|
+
const p = this.createInput(
|
|
1440
1464
|
"state",
|
|
1441
1465
|
l,
|
|
1442
1466
|
s.state,
|
|
1443
1467
|
a.state,
|
|
1444
|
-
|
|
1468
|
+
i.state,
|
|
1445
1469
|
o,
|
|
1446
1470
|
"address-level1"
|
|
1447
1471
|
);
|
|
1448
|
-
this.inputs.set("state",
|
|
1472
|
+
this.inputs.set("state", p), c.appendChild(p.getElement());
|
|
1449
1473
|
}
|
|
1450
1474
|
this.fieldsContainer.appendChild(c);
|
|
1451
1475
|
}
|
|
@@ -1476,14 +1500,14 @@ class de extends k {
|
|
|
1476
1500
|
setError(e, t, s) {
|
|
1477
1501
|
const a = this.inputs.get(e);
|
|
1478
1502
|
if (a) {
|
|
1479
|
-
const
|
|
1480
|
-
document.activeElement !==
|
|
1503
|
+
const i = a.getElement().querySelector("input") || a.getElement().querySelector("select");
|
|
1504
|
+
document.activeElement !== i && a.setError(t, s);
|
|
1481
1505
|
}
|
|
1482
1506
|
}
|
|
1483
1507
|
updateField(e, t, s, a) {
|
|
1484
|
-
const
|
|
1485
|
-
if (!
|
|
1486
|
-
const r =
|
|
1508
|
+
const i = this.inputs.get(e);
|
|
1509
|
+
if (!i) return;
|
|
1510
|
+
const r = i.getElement().querySelector("input") || i.getElement().querySelector("select"), o = i.getValue();
|
|
1487
1511
|
!(document.activeElement === r) && !(t === "" && o !== "") && this.setValue(e, t);
|
|
1488
1512
|
const m = !!(a && s);
|
|
1489
1513
|
this.setError(e, m, s);
|
|
@@ -1503,19 +1527,20 @@ class de extends k {
|
|
|
1503
1527
|
e && e.focus();
|
|
1504
1528
|
}
|
|
1505
1529
|
}
|
|
1506
|
-
class
|
|
1530
|
+
class ft {
|
|
1507
1531
|
input = null;
|
|
1508
1532
|
isVgsMode;
|
|
1509
1533
|
vgsWrapper = null;
|
|
1510
1534
|
vgsContainer = null;
|
|
1511
1535
|
vgsHelperText = null;
|
|
1512
1536
|
wrapperElement;
|
|
1537
|
+
_vgsFieldsReady = !1;
|
|
1513
1538
|
constructor(e) {
|
|
1514
1539
|
const {
|
|
1515
1540
|
value: t,
|
|
1516
1541
|
onChange: s,
|
|
1517
1542
|
onBlur: a,
|
|
1518
|
-
errorMsg:
|
|
1543
|
+
errorMsg: i,
|
|
1519
1544
|
checkoutProfile: r,
|
|
1520
1545
|
translationFunc: o,
|
|
1521
1546
|
autocomplete: d = "cc-name",
|
|
@@ -1525,7 +1550,7 @@ class gt {
|
|
|
1525
1550
|
t,
|
|
1526
1551
|
s,
|
|
1527
1552
|
a,
|
|
1528
|
-
|
|
1553
|
+
i,
|
|
1529
1554
|
r,
|
|
1530
1555
|
o,
|
|
1531
1556
|
d
|
|
@@ -1534,29 +1559,29 @@ class gt {
|
|
|
1534
1559
|
buildVgsLayout(e, t) {
|
|
1535
1560
|
const s = e.styles.borderRadius, a = document.createElement("div");
|
|
1536
1561
|
a.style.marginBottom = "4px";
|
|
1537
|
-
const
|
|
1538
|
-
|
|
1562
|
+
const i = document.createElement("label");
|
|
1563
|
+
i.className = "input-label", i.textContent = t("cardholderNameLabel"), i.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.appendChild(i), 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
1564
|
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
|
|
1565
|
+
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
1566
|
}
|
|
1542
|
-
buildNativeLayout(e, t, s, a,
|
|
1543
|
-
this.input = new
|
|
1567
|
+
buildNativeLayout(e, t, s, a, i, r, o) {
|
|
1568
|
+
this.input = new pe({
|
|
1544
1569
|
name: "name",
|
|
1545
1570
|
label: r("cardholderNameLabel"),
|
|
1546
1571
|
error: !1,
|
|
1547
1572
|
errorMsg: a,
|
|
1548
1573
|
styles: {
|
|
1549
|
-
color:
|
|
1550
|
-
borderRadius: `${
|
|
1551
|
-
fontSize:
|
|
1552
|
-
fontFamily:
|
|
1574
|
+
color: i.styles.textColor,
|
|
1575
|
+
borderRadius: `${i.styles.borderRadius}px`,
|
|
1576
|
+
fontSize: i.styles.fontSize,
|
|
1577
|
+
fontFamily: i.styles.fontFamily
|
|
1553
1578
|
},
|
|
1554
1579
|
placeholder: r("cardholderNamePlaceholder"),
|
|
1555
1580
|
value: e,
|
|
1556
1581
|
autocomplete: o,
|
|
1557
1582
|
onChange: (d) => {
|
|
1558
|
-
const m = d.target.value,
|
|
1559
|
-
m !==
|
|
1583
|
+
const m = d.target.value, S = m.replace(/[^a-zA-Z\s\-'.]/g, "");
|
|
1584
|
+
m !== S && this.input?.setValue(S), this.input?.setError(!1), this.trim(), t(d);
|
|
1560
1585
|
}
|
|
1561
1586
|
}), this.input.addEventListener("blur", (d) => {
|
|
1562
1587
|
s(d);
|
|
@@ -1567,16 +1592,16 @@ class gt {
|
|
|
1567
1592
|
}
|
|
1568
1593
|
handleVgsStateChange(e, t) {
|
|
1569
1594
|
if (!this.isVgsMode || !this.vgsWrapper) return;
|
|
1570
|
-
const
|
|
1571
|
-
if (this.vgsWrapper.
|
|
1572
|
-
const
|
|
1573
|
-
|
|
1595
|
+
const s = e[te.CARDHOLDER]?.isFocused;
|
|
1596
|
+
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;
|
|
1597
|
+
const a = t[te.CARDHOLDER];
|
|
1598
|
+
a ? (this.vgsHelperText.setText(a), this.vgsHelperText.toggleVisibility(!0)) : this.vgsHelperText.toggleVisibility(!1);
|
|
1574
1599
|
}
|
|
1575
1600
|
hideFakePlaceholder() {
|
|
1576
1601
|
if (!this.vgsWrapper) return;
|
|
1577
|
-
this.vgsWrapper.style.boxShadow = "";
|
|
1602
|
+
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
1603
|
const e = this.vgsWrapper.querySelector(".vgs-field-skeleton");
|
|
1579
|
-
e && e.remove();
|
|
1604
|
+
e && e.remove(), this.vgsContainer?.querySelectorAll("iframe").forEach((t) => t.style.height = "38.5px");
|
|
1580
1605
|
}
|
|
1581
1606
|
getValue() {
|
|
1582
1607
|
return this.isVgsMode ? "" : this.input?.getValue() ?? "";
|
|
@@ -1604,7 +1629,7 @@ class gt {
|
|
|
1604
1629
|
this.isVgsMode || this.input?.focus();
|
|
1605
1630
|
}
|
|
1606
1631
|
}
|
|
1607
|
-
class
|
|
1632
|
+
class ge extends A {
|
|
1608
1633
|
constructor() {
|
|
1609
1634
|
super("div", ["skeleton-container"]), this.createSkeletonElements();
|
|
1610
1635
|
}
|
|
@@ -1628,19 +1653,19 @@ class pe extends k {
|
|
|
1628
1653
|
return e.appendChild(t), e.appendChild(s), e.appendChild(a), e;
|
|
1629
1654
|
}
|
|
1630
1655
|
}
|
|
1631
|
-
class
|
|
1656
|
+
class yt extends A {
|
|
1632
1657
|
constructor(e) {
|
|
1633
1658
|
const { translationFunc: t, checkoutProfile: s } = e;
|
|
1634
1659
|
super("div", ["payment-separator"]);
|
|
1635
|
-
const a = this.getElement(),
|
|
1636
|
-
|
|
1660
|
+
const a = this.getElement(), i = document.createElement("span");
|
|
1661
|
+
i.className = "payment-separator__line";
|
|
1637
1662
|
const r = document.createElement("p");
|
|
1638
1663
|
r.textContent = t("pay-with-card"), r.className = "payment-separator__text", r.style.fontFamily = `${s.styles.fontFamily}, sans-serif`;
|
|
1639
1664
|
const o = document.createElement("span");
|
|
1640
|
-
o.className = "payment-separator__line", a.appendChild(
|
|
1665
|
+
o.className = "payment-separator__line", a.appendChild(i), a.appendChild(r), a.appendChild(o);
|
|
1641
1666
|
}
|
|
1642
1667
|
}
|
|
1643
|
-
class
|
|
1668
|
+
class bt extends A {
|
|
1644
1669
|
paymentMethods;
|
|
1645
1670
|
paymentSeparator;
|
|
1646
1671
|
skeleton;
|
|
@@ -1649,13 +1674,13 @@ class yt extends k {
|
|
|
1649
1674
|
checkoutProfile: t,
|
|
1650
1675
|
formData: s,
|
|
1651
1676
|
onPaypalSubmit: a,
|
|
1652
|
-
onApplePaySubmit:
|
|
1677
|
+
onApplePaySubmit: i,
|
|
1653
1678
|
supportedPaymentMethods: r,
|
|
1654
1679
|
translationFunc: o,
|
|
1655
1680
|
paymentId: d,
|
|
1656
1681
|
checkoutKey: c,
|
|
1657
1682
|
checkoutDetails: m,
|
|
1658
|
-
environment:
|
|
1683
|
+
environment: S,
|
|
1659
1684
|
countryCode: l
|
|
1660
1685
|
} = e;
|
|
1661
1686
|
if (super("div", ["payment-methods"]), this.paymentMethods = /* @__PURE__ */ new Map(), !t?.additionalPaymentMethods) {
|
|
@@ -1666,42 +1691,42 @@ class yt extends k {
|
|
|
1666
1691
|
this.renderSkeleton();
|
|
1667
1692
|
return;
|
|
1668
1693
|
}
|
|
1669
|
-
const
|
|
1694
|
+
const p = Object.entries(
|
|
1670
1695
|
t.additionalPaymentMethods
|
|
1671
|
-
).filter(([y,
|
|
1672
|
-
const g =
|
|
1673
|
-
return g && h &&
|
|
1674
|
-
}).sort((y,
|
|
1675
|
-
if (
|
|
1696
|
+
).filter(([y, u]) => {
|
|
1697
|
+
const g = u.enabled, h = r ? r[y] === !0 : !0, b = !u.countries || l && u.countries.includes(l);
|
|
1698
|
+
return g && h && b;
|
|
1699
|
+
}).sort((y, u) => y[1].order - u[1].order);
|
|
1700
|
+
if (p.length === 0) {
|
|
1676
1701
|
this.getElement().style.display = "none";
|
|
1677
1702
|
return;
|
|
1678
1703
|
}
|
|
1679
|
-
for (const [y] of
|
|
1704
|
+
for (const [y] of p)
|
|
1680
1705
|
switch (y) {
|
|
1681
1706
|
case "paypal": {
|
|
1682
1707
|
if (a) {
|
|
1683
|
-
const
|
|
1708
|
+
const u = new Ee({
|
|
1684
1709
|
checkoutProfile: t,
|
|
1685
1710
|
formData: s,
|
|
1686
1711
|
onSubmit: a
|
|
1687
1712
|
});
|
|
1688
|
-
this.paymentMethods.set("paypal",
|
|
1713
|
+
this.paymentMethods.set("paypal", u), u.appendTo(this.getElement());
|
|
1689
1714
|
}
|
|
1690
1715
|
break;
|
|
1691
1716
|
}
|
|
1692
1717
|
case "applePay": {
|
|
1693
|
-
if (
|
|
1694
|
-
const
|
|
1718
|
+
if (i && d && c) {
|
|
1719
|
+
const u = t.appearance?.additionalPaymentMethods?.applePay, g = new Ce({
|
|
1695
1720
|
checkoutProfile: t,
|
|
1696
1721
|
formData: s,
|
|
1697
|
-
onSubmit:
|
|
1722
|
+
onSubmit: i,
|
|
1698
1723
|
paymentId: d,
|
|
1699
1724
|
checkoutKey: c,
|
|
1700
1725
|
checkoutDetails: m,
|
|
1701
|
-
environment:
|
|
1702
|
-
displayName:
|
|
1703
|
-
requiredBillingContactFields:
|
|
1704
|
-
requiredShippingContactFields:
|
|
1726
|
+
environment: S,
|
|
1727
|
+
displayName: u?.displayName,
|
|
1728
|
+
requiredBillingContactFields: u?.requiredBillingContactFields,
|
|
1729
|
+
requiredShippingContactFields: u?.requiredShippingContactFields
|
|
1705
1730
|
});
|
|
1706
1731
|
this.paymentMethods.set("applePay", g), g.appendTo(this.getElement());
|
|
1707
1732
|
}
|
|
@@ -1719,13 +1744,13 @@ class yt extends k {
|
|
|
1719
1744
|
);
|
|
1720
1745
|
break;
|
|
1721
1746
|
}
|
|
1722
|
-
this.paymentMethods.size > 0 && (this.paymentSeparator = new
|
|
1747
|
+
this.paymentMethods.size > 0 && (this.paymentSeparator = new yt({
|
|
1723
1748
|
translationFunc: o,
|
|
1724
1749
|
checkoutProfile: t
|
|
1725
1750
|
}), this.getElement().appendChild(this.paymentSeparator.getElement()));
|
|
1726
1751
|
}
|
|
1727
1752
|
renderSkeleton() {
|
|
1728
|
-
this.skeleton = new
|
|
1753
|
+
this.skeleton = new ge(), this.getElement().appendChild(this.skeleton.getElement());
|
|
1729
1754
|
}
|
|
1730
1755
|
updateFormData(e) {
|
|
1731
1756
|
const t = this.paymentMethods.get("paypal");
|
|
@@ -1737,8 +1762,8 @@ class yt extends k {
|
|
|
1737
1762
|
return this.paymentMethods.size > 0 && this.getElement().style.display !== "none";
|
|
1738
1763
|
}
|
|
1739
1764
|
}
|
|
1740
|
-
const
|
|
1741
|
-
class
|
|
1765
|
+
const vt = 17;
|
|
1766
|
+
class St extends A {
|
|
1742
1767
|
styles;
|
|
1743
1768
|
isHovered = !1;
|
|
1744
1769
|
constructor(e) {
|
|
@@ -1748,7 +1773,7 @@ class vt extends k {
|
|
|
1748
1773
|
}
|
|
1749
1774
|
applyStyles() {
|
|
1750
1775
|
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 ===
|
|
1776
|
+
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
1777
|
}
|
|
1753
1778
|
handleMouseEnter() {
|
|
1754
1779
|
this.isHovered = !0, this.applyStyles();
|
|
@@ -1760,11 +1785,11 @@ class vt extends k {
|
|
|
1760
1785
|
return this.getElement().disabled = e, e ? (this.addClass("disabled"), this.removeClass("valid")) : (this.removeClass("disabled"), this.addClass("valid")), this.applyStyles(), this;
|
|
1761
1786
|
}
|
|
1762
1787
|
}
|
|
1763
|
-
class
|
|
1788
|
+
class Ct {
|
|
1764
1789
|
button;
|
|
1765
1790
|
constructor(e) {
|
|
1766
1791
|
const { disabled: t, checkoutProfile: s, translationFunc: a } = e;
|
|
1767
|
-
this.button = new
|
|
1792
|
+
this.button = new St({
|
|
1768
1793
|
text: a(
|
|
1769
1794
|
`buttonTexts.${s?.layout.actionButton.translationKey}`
|
|
1770
1795
|
),
|
|
@@ -1837,7 +1862,7 @@ class Et {
|
|
|
1837
1862
|
(a) => a.enabled
|
|
1838
1863
|
))
|
|
1839
1864
|
return;
|
|
1840
|
-
this.paymentMethods = new
|
|
1865
|
+
this.paymentMethods = new bt({
|
|
1841
1866
|
checkoutProfile: e,
|
|
1842
1867
|
formData: t,
|
|
1843
1868
|
supportedPaymentMethods: this.supportedPaymentMethods,
|
|
@@ -1859,16 +1884,16 @@ class Et {
|
|
|
1859
1884
|
}
|
|
1860
1885
|
createEmailField(e, t, s, a) {
|
|
1861
1886
|
try {
|
|
1862
|
-
const
|
|
1887
|
+
const i = e.layout.billingFields && Object.values(e.layout.billingFields).some(
|
|
1863
1888
|
(r) => r?.enabled
|
|
1864
1889
|
) || e.layout.shippingFields && Object.values(e.layout.shippingFields).some(
|
|
1865
1890
|
(r) => r?.enabled
|
|
1866
1891
|
);
|
|
1867
|
-
this.emailField = new
|
|
1892
|
+
this.emailField = new Fe({
|
|
1868
1893
|
value: t.email,
|
|
1869
1894
|
onChange: this.onChange,
|
|
1870
1895
|
onBlur: this.onBlur,
|
|
1871
|
-
onTab:
|
|
1896
|
+
onTab: i ? void 0 : () => this.focusManager.focusField(
|
|
1872
1897
|
e.layout.phoneNumber?.enabled ? "phoneNumber" : "cardNumber"
|
|
1873
1898
|
),
|
|
1874
1899
|
error: !!(s.email && a.email),
|
|
@@ -1876,14 +1901,14 @@ class Et {
|
|
|
1876
1901
|
checkoutProfile: e,
|
|
1877
1902
|
translationFunc: this.translationFunc
|
|
1878
1903
|
}), this.emailFocusHandler = () => this.onFieldFocus("email"), this.emailField.getElement().addEventListener("focus", this.emailFocusHandler, !0), this.focusManager.registerField("email", this.emailField), this.formElement.appendChild(this.emailField.getElement());
|
|
1879
|
-
} catch (
|
|
1880
|
-
throw console.error("Error creating email field:",
|
|
1904
|
+
} catch (i) {
|
|
1905
|
+
throw console.error("Error creating email field:", i), i;
|
|
1881
1906
|
}
|
|
1882
1907
|
}
|
|
1883
1908
|
createPhoneNumberField(e, t, s, a) {
|
|
1884
|
-
const
|
|
1885
|
-
this.phonePlaceholder =
|
|
1886
|
-
|
|
1909
|
+
const i = document.createElement("div");
|
|
1910
|
+
this.phonePlaceholder = i, this.formElement.appendChild(i), Me().then(({ PhoneNumberField: r }) => {
|
|
1911
|
+
i.isConnected && (this.phoneNumberField = new r({
|
|
1887
1912
|
value: t.phoneNumber ?? "",
|
|
1888
1913
|
onChange: this.onChange,
|
|
1889
1914
|
onBlur: this.onBlur,
|
|
@@ -1895,9 +1920,9 @@ class Et {
|
|
|
1895
1920
|
defaultCountry: e.layout.phoneNumber?.defaultCountry || "US",
|
|
1896
1921
|
allowedCountries: e.layout.phoneNumber?.allowedCountries,
|
|
1897
1922
|
locale: this.locale
|
|
1898
|
-
}), this.phoneNumberFocusHandler = () => this.onFieldFocus("phoneNumber"), this.phoneNumberField.getElement().addEventListener("focus", this.phoneNumberFocusHandler, !0), this.focusManager.registerField("phoneNumber", this.phoneNumberField),
|
|
1923
|
+
}), this.phoneNumberFocusHandler = () => this.onFieldFocus("phoneNumber"), this.phoneNumberField.getElement().addEventListener("focus", this.phoneNumberFocusHandler, !0), this.focusManager.registerField("phoneNumber", this.phoneNumberField), i.replaceWith(this.phoneNumberField.getElement()), this.phonePlaceholder = void 0);
|
|
1899
1924
|
}).catch((r) => {
|
|
1900
|
-
console.error("Error creating phone number field:", r),
|
|
1925
|
+
console.error("Error creating phone number field:", r), i.remove(), this.phonePlaceholder = void 0;
|
|
1901
1926
|
});
|
|
1902
1927
|
}
|
|
1903
1928
|
setCheckoutDetailsLoaded(e) {
|
|
@@ -1909,7 +1934,7 @@ class Et {
|
|
|
1909
1934
|
this.cardSectionSkeleton = this.buildCardSkeleton(e), this.formElement.appendChild(this.cardSectionSkeleton);
|
|
1910
1935
|
return;
|
|
1911
1936
|
}
|
|
1912
|
-
if (this.cardSection = new
|
|
1937
|
+
if (this.cardSection = new Ne({
|
|
1913
1938
|
checkoutProfile: e,
|
|
1914
1939
|
cardNumber: t.cardNumber,
|
|
1915
1940
|
cardNumberError: s.cardNumber,
|
|
@@ -1923,20 +1948,19 @@ class Et {
|
|
|
1923
1948
|
onChange: this.onChange,
|
|
1924
1949
|
onBlur: this.onBlur,
|
|
1925
1950
|
onCardBrandChange: () => {
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
}
|
|
1951
|
+
t.cardCvv && this.onBlur(
|
|
1952
|
+
P({
|
|
1953
|
+
type: "blur",
|
|
1954
|
+
target: { name: "cardCvv", value: t.cardCvv }
|
|
1955
|
+
})
|
|
1956
|
+
);
|
|
1933
1957
|
},
|
|
1934
1958
|
translationFunc: this.translationFunc,
|
|
1935
1959
|
vgsService: this.vgsService,
|
|
1936
1960
|
onVgsStateChange: this.onVgsStateChange
|
|
1937
1961
|
}), !this.vgsService) {
|
|
1938
|
-
const
|
|
1939
|
-
|
|
1962
|
+
const i = this.cardSection.getElement().querySelector('input[name="cardExpiry"]');
|
|
1963
|
+
i && (this.cardExpiryFocusHandler = () => this.onFieldFocus("cardExpiry"), i.addEventListener(
|
|
1940
1964
|
"focus",
|
|
1941
1965
|
this.cardExpiryFocusHandler
|
|
1942
1966
|
));
|
|
@@ -1955,8 +1979,8 @@ class Et {
|
|
|
1955
1979
|
}), this.focusManager.registerField("cardCvv", {
|
|
1956
1980
|
focus: () => this.cardSection?.focusField("cardCvv")
|
|
1957
1981
|
}), this.formElement.appendChild(this.cardSection.getElement());
|
|
1958
|
-
} catch (
|
|
1959
|
-
throw console.error("Error creating card section:",
|
|
1982
|
+
} catch (i) {
|
|
1983
|
+
throw console.error("Error creating card section:", i), i;
|
|
1960
1984
|
}
|
|
1961
1985
|
}
|
|
1962
1986
|
createCardholderSection(e, t, s, a) {
|
|
@@ -1965,7 +1989,7 @@ class Et {
|
|
|
1965
1989
|
this.cardholderSectionSkeleton = this.buildCardholderSkeleton(e), this.formElement.appendChild(this.cardholderSectionSkeleton);
|
|
1966
1990
|
return;
|
|
1967
1991
|
}
|
|
1968
|
-
if (this.cardholderSection = new
|
|
1992
|
+
if (this.cardholderSection = new ft({
|
|
1969
1993
|
value: t.name,
|
|
1970
1994
|
onChange: this.onChange,
|
|
1971
1995
|
onBlur: this.onBlur,
|
|
@@ -1975,18 +1999,18 @@ class Et {
|
|
|
1975
1999
|
translationFunc: this.translationFunc,
|
|
1976
2000
|
isVgsMode: !!this.vgsService
|
|
1977
2001
|
}), !this.vgsService) {
|
|
1978
|
-
const
|
|
1979
|
-
|
|
2002
|
+
const i = this.cardholderSection.getElement().querySelector('input[name="name"]');
|
|
2003
|
+
i && (this.nameFocusHandler = () => this.onFieldFocus("name"), i.addEventListener("focus", this.nameFocusHandler));
|
|
1980
2004
|
}
|
|
1981
2005
|
this.focusManager.registerField("name", this.cardholderSection), this.formElement.appendChild(this.cardholderSection.getElement());
|
|
1982
|
-
} catch (
|
|
1983
|
-
throw console.error("Error creating cardholder section:",
|
|
2006
|
+
} catch (i) {
|
|
2007
|
+
throw console.error("Error creating cardholder section:", i), i;
|
|
1984
2008
|
}
|
|
1985
2009
|
}
|
|
1986
2010
|
createBillingAddressSection(e, t, s, a) {
|
|
1987
2011
|
try {
|
|
1988
|
-
const
|
|
1989
|
-
if (!
|
|
2012
|
+
const i = e.layout.billingFields;
|
|
2013
|
+
if (!i || !Object.values(i).some(
|
|
1990
2014
|
(d) => d?.enabled
|
|
1991
2015
|
)) return;
|
|
1992
2016
|
const o = {
|
|
@@ -1998,11 +2022,11 @@ class Et {
|
|
|
1998
2022
|
zipCode: "",
|
|
1999
2023
|
country: ""
|
|
2000
2024
|
};
|
|
2001
|
-
this.billingAddressSection = new
|
|
2025
|
+
this.billingAddressSection = new ce({
|
|
2002
2026
|
type: "billing",
|
|
2003
2027
|
title: this.translationFunc("address.billingTitle"),
|
|
2004
2028
|
checkoutProfile: e,
|
|
2005
|
-
fieldsConfig:
|
|
2029
|
+
fieldsConfig: i,
|
|
2006
2030
|
values: t.billingAddress ?? o,
|
|
2007
2031
|
errors: s.billingAddress ?? {},
|
|
2008
2032
|
touched: a.billingAddress ?? {},
|
|
@@ -2012,14 +2036,14 @@ class Et {
|
|
|
2012
2036
|
locale: this.locale,
|
|
2013
2037
|
grouped: e.layout.grouped
|
|
2014
2038
|
}), this.formElement.appendChild(this.billingAddressSection.getElement());
|
|
2015
|
-
} catch (
|
|
2016
|
-
throw console.error("Error creating billing address section:",
|
|
2039
|
+
} catch (i) {
|
|
2040
|
+
throw console.error("Error creating billing address section:", i), i;
|
|
2017
2041
|
}
|
|
2018
2042
|
}
|
|
2019
2043
|
createShippingAddressSection(e, t, s, a) {
|
|
2020
2044
|
try {
|
|
2021
|
-
const
|
|
2022
|
-
if (!
|
|
2045
|
+
const i = e.layout.shippingFields;
|
|
2046
|
+
if (!i || !Object.values(i).some(
|
|
2023
2047
|
(d) => d?.enabled
|
|
2024
2048
|
)) return;
|
|
2025
2049
|
const o = {
|
|
@@ -2031,11 +2055,11 @@ class Et {
|
|
|
2031
2055
|
zipCode: "",
|
|
2032
2056
|
country: ""
|
|
2033
2057
|
};
|
|
2034
|
-
this.shippingAddressSection = new
|
|
2058
|
+
this.shippingAddressSection = new ce({
|
|
2035
2059
|
type: "shipping",
|
|
2036
2060
|
title: this.translationFunc("address.shippingTitle"),
|
|
2037
2061
|
checkoutProfile: e,
|
|
2038
|
-
fieldsConfig:
|
|
2062
|
+
fieldsConfig: i,
|
|
2039
2063
|
values: t.shippingAddress ?? o,
|
|
2040
2064
|
errors: s.shippingAddress ?? {},
|
|
2041
2065
|
touched: a.shippingAddress ?? {},
|
|
@@ -2045,13 +2069,13 @@ class Et {
|
|
|
2045
2069
|
locale: this.locale,
|
|
2046
2070
|
grouped: e.layout.grouped
|
|
2047
2071
|
}), this.formElement.appendChild(this.shippingAddressSection.getElement());
|
|
2048
|
-
} catch (
|
|
2049
|
-
throw console.error("Error creating shipping address section:",
|
|
2072
|
+
} catch (i) {
|
|
2073
|
+
throw console.error("Error creating shipping address section:", i), i;
|
|
2050
2074
|
}
|
|
2051
2075
|
}
|
|
2052
2076
|
createSubmitButton(e, t) {
|
|
2053
2077
|
try {
|
|
2054
|
-
this.submitButton = new
|
|
2078
|
+
this.submitButton = new Ct({
|
|
2055
2079
|
disabled: t,
|
|
2056
2080
|
checkoutProfile: e,
|
|
2057
2081
|
translationFunc: this.translationFunc
|
|
@@ -2066,12 +2090,12 @@ class Et {
|
|
|
2066
2090
|
updatePhoneNumberField(e, t, s) {
|
|
2067
2091
|
this.phoneNumberField && (this.phoneNumberField.setValue(e), this.phoneNumberField.setError(t, s));
|
|
2068
2092
|
}
|
|
2069
|
-
updateCardSection(e, t, s, a,
|
|
2093
|
+
updateCardSection(e, t, s, a, i, r, o, d, c) {
|
|
2070
2094
|
this.cardSection && (this.cardSection.updateCardNumber(
|
|
2071
2095
|
e,
|
|
2072
2096
|
t,
|
|
2073
2097
|
s
|
|
2074
|
-
), this.cardSection.updateCardCvv(a,
|
|
2098
|
+
), this.cardSection.updateCardCvv(a, i, r), this.cardSection.updateCardExpiry(
|
|
2075
2099
|
o,
|
|
2076
2100
|
d,
|
|
2077
2101
|
c
|
|
@@ -2110,8 +2134,8 @@ class Et {
|
|
|
2110
2134
|
buildCardSkeleton(e) {
|
|
2111
2135
|
const t = e.styles.borderRadius, s = document.createElement("div"), a = document.createElement("div");
|
|
2112
2136
|
a.style.marginBottom = "4px";
|
|
2113
|
-
const
|
|
2114
|
-
|
|
2137
|
+
const i = document.createElement("label");
|
|
2138
|
+
i.className = "input-label", i.textContent = this.translationFunc("cardInformation"), i.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.appendChild(i), s.appendChild(a);
|
|
2115
2139
|
const r = document.createElement("div");
|
|
2116
2140
|
r.className = "vgs-card-group", r.style.borderRadius = `${t}px`, r.style.background = "#fff", r.style.display = "flex", r.style.flexDirection = "column", r.style.gap = "8px";
|
|
2117
2141
|
const o = document.createElement("div");
|
|
@@ -2130,17 +2154,17 @@ class Et {
|
|
|
2130
2154
|
buildCardholderSkeleton(e) {
|
|
2131
2155
|
const t = e.styles.borderRadius, s = document.createElement("div"), a = document.createElement("div");
|
|
2132
2156
|
a.style.marginBottom = "4px";
|
|
2133
|
-
const
|
|
2134
|
-
|
|
2157
|
+
const i = document.createElement("label");
|
|
2158
|
+
i.className = "input-label", i.textContent = this.translationFunc("cardholderNameLabel"), i.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.appendChild(i), s.appendChild(a);
|
|
2135
2159
|
const r = document.createElement("div");
|
|
2136
2160
|
return r.style.position = "relative", r.style.borderRadius = `${t}px`, r.style.height = "38.5px", r.style.width = "100%", r.style.overflow = "hidden", r.style.background = "#fff", r.appendChild(this.createSkeletonDiv()), s.appendChild(r), s;
|
|
2137
2161
|
}
|
|
2138
2162
|
async mountVgsFields(e) {
|
|
2139
2163
|
if (!this.vgsService || !this.cardSection) return;
|
|
2140
2164
|
await this.vgsService.whenReady();
|
|
2141
|
-
const t = this.cardSection.getVgsContainerIds(), s = this.cardholderSection?.getVgsContainerId(), a = await
|
|
2165
|
+
const t = this.cardSection.getVgsContainerIds(), s = this.cardholderSection?.getVgsContainerId(), a = await pt(
|
|
2142
2166
|
e.styles.fontFamily
|
|
2143
|
-
),
|
|
2167
|
+
), i = this.cardSection.buildVgsFieldCss(
|
|
2144
2168
|
e,
|
|
2145
2169
|
a
|
|
2146
2170
|
);
|
|
@@ -2151,7 +2175,7 @@ class Et {
|
|
|
2151
2175
|
cardCvv: t.cardCvv ? `#${t.cardCvv}` : void 0,
|
|
2152
2176
|
cardholderName: s ? `#${s}` : void 0
|
|
2153
2177
|
},
|
|
2154
|
-
|
|
2178
|
+
i,
|
|
2155
2179
|
{
|
|
2156
2180
|
cardNumber: "1234 5678 9012 3456",
|
|
2157
2181
|
cardExpiry: this.translationFunc("cardExpiry"),
|
|
@@ -2198,7 +2222,7 @@ class Et {
|
|
|
2198
2222
|
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
2223
|
}
|
|
2200
2224
|
}
|
|
2201
|
-
class
|
|
2225
|
+
class Ft {
|
|
2202
2226
|
formManager;
|
|
2203
2227
|
focusManager;
|
|
2204
2228
|
onFormSubmit;
|
|
@@ -2208,18 +2232,18 @@ class Ct {
|
|
|
2208
2232
|
this.formManager = e.formManager, this.focusManager = e.focusManager, this.onFormSubmit = e.onFormSubmit, this.onUIUpdate = e.onUIUpdate;
|
|
2209
2233
|
}
|
|
2210
2234
|
handleChange = (e) => {
|
|
2211
|
-
const t = e.target, { name: s, value: a } = t,
|
|
2212
|
-
this.formManager.handleChange(
|
|
2235
|
+
const t = e.target, { name: s, value: a } = t, i = s;
|
|
2236
|
+
this.formManager.handleChange(i, a), e instanceof CustomEvent && e.detail?.programmatic ? this.localTouchedFields.delete(i) : this.localTouchedFields.has(i) || (this.localTouchedFields.add(i), this.formManager.handleBlur(i, a));
|
|
2213
2237
|
const { formData: o, errors: d, touched: c } = this.formManager.getFormState();
|
|
2214
2238
|
this.focusManager.handleStateUpdate(o, d, c);
|
|
2215
2239
|
};
|
|
2216
2240
|
handleBlur = (e) => {
|
|
2217
|
-
const t = e.target, { name: s, value: a } = t,
|
|
2218
|
-
this.localTouchedFields.add(
|
|
2241
|
+
const t = e.target, { name: s, value: a } = t, i = s;
|
|
2242
|
+
this.localTouchedFields.add(i), this.formManager.handleBlur(i, a), setTimeout(() => {
|
|
2219
2243
|
this.onUIUpdate();
|
|
2220
2244
|
}, 0);
|
|
2221
2245
|
const { formData: r, errors: o, touched: d } = this.formManager.getFormState();
|
|
2222
|
-
d[
|
|
2246
|
+
d[i] || this.focusManager.handleStateUpdate(r, o, d);
|
|
2223
2247
|
};
|
|
2224
2248
|
handleSubmit = async (e) => {
|
|
2225
2249
|
e.preventDefault(), await this.onFormSubmit(e);
|
|
@@ -2239,7 +2263,7 @@ class Ct {
|
|
|
2239
2263
|
this.localTouchedFields.clear();
|
|
2240
2264
|
}
|
|
2241
2265
|
}
|
|
2242
|
-
class
|
|
2266
|
+
class Mt {
|
|
2243
2267
|
formManager;
|
|
2244
2268
|
checkoutProfile;
|
|
2245
2269
|
formElement;
|
|
@@ -2263,7 +2287,7 @@ class Ft {
|
|
|
2263
2287
|
try {
|
|
2264
2288
|
if (e.checkoutProfile.styles?.fontFamily)
|
|
2265
2289
|
try {
|
|
2266
|
-
const { cleanup: t } =
|
|
2290
|
+
const { cleanup: t } = we({
|
|
2267
2291
|
fontFamily: e.checkoutProfile.styles.fontFamily
|
|
2268
2292
|
});
|
|
2269
2293
|
this.fontCleanup = t, this.formElement.style.fontFamily = e.checkoutProfile.styles.fontFamily;
|
|
@@ -2281,16 +2305,16 @@ class Ft {
|
|
|
2281
2305
|
isFormDisabled() {
|
|
2282
2306
|
const e = this.formManager.getFormState(), t = this.checkoutProfile.getState(), s = Object.keys(e.errors).filter(
|
|
2283
2307
|
(f) => f !== "billingAddress" && f !== "shippingAddress"
|
|
2284
|
-
).length > 0, a = e.errors.billingAddress,
|
|
2308
|
+
).length > 0, a = e.errors.billingAddress, i = 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 || i || o, m = J(
|
|
2285
2309
|
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:
|
|
2310
|
+
) ? !!(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 ?? {}, u = /* @__PURE__ */ new Set(["US", "CA"]), g = (f, v) => {
|
|
2287
2311
|
if (!f) return !0;
|
|
2288
|
-
const
|
|
2289
|
-
return Object.entries(f).every(([N,
|
|
2312
|
+
const E = v?.country ?? "";
|
|
2313
|
+
return Object.entries(f).every(([N, x]) => !x?.enabled || N === "state" && (!u.has(E) || x.hiddenForCountries?.includes(E)) ? !0 : !!v?.[N]?.trim());
|
|
2290
2314
|
}, h = !this.isVgsMode || Object.values(this.vgsFieldsState).every(
|
|
2291
2315
|
(f) => f?.isValid === !0
|
|
2292
|
-
),
|
|
2293
|
-
return d || !
|
|
2316
|
+
), b = this.isVgsMode ? !!e.formData.email && l && h && g(p, e.formData.billingAddress) && g(y, e.formData.shippingAddress) : !!e.formData.email && l && m && !!e.formData.cardNumber && !!e.formData.cardCvv && !!e.formData.cardExpiry && g(p, e.formData.billingAddress) && g(y, e.formData.shippingAddress);
|
|
2317
|
+
return d || !b || this.isSubmitting;
|
|
2294
2318
|
}
|
|
2295
2319
|
setSubmitting(e) {
|
|
2296
2320
|
this.isSubmitting = e;
|
|
@@ -2306,9 +2330,9 @@ class Ft {
|
|
|
2306
2330
|
for (const [s, a] of Object.entries(this.vgsFieldsState)) {
|
|
2307
2331
|
if (!a?.isTouched || a.isFocused || a.isValid)
|
|
2308
2332
|
continue;
|
|
2309
|
-
const
|
|
2310
|
-
if (!
|
|
2311
|
-
const r =
|
|
2333
|
+
const i = a.errors?.[0];
|
|
2334
|
+
if (!i) continue;
|
|
2335
|
+
const r = Pe(s, i.code);
|
|
2312
2336
|
r && (t[s] = e(r));
|
|
2313
2337
|
}
|
|
2314
2338
|
return t;
|
|
@@ -2320,18 +2344,18 @@ class Ft {
|
|
|
2320
2344
|
this.fontCleanup && (this.fontCleanup(), this.fontCleanup = void 0);
|
|
2321
2345
|
}
|
|
2322
2346
|
}
|
|
2323
|
-
class
|
|
2347
|
+
class Nt extends A {
|
|
2324
2348
|
titleElement;
|
|
2325
2349
|
constructor(e = {}) {
|
|
2326
2350
|
super("div", ["blur-bg"]);
|
|
2327
2351
|
const t = D.createDiv(["loader"]);
|
|
2328
|
-
this.titleElement = new
|
|
2352
|
+
this.titleElement = new A("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
|
|
2329
2353
|
}
|
|
2330
2354
|
setText(e) {
|
|
2331
2355
|
return this.titleElement.setText(e), this;
|
|
2332
2356
|
}
|
|
2333
2357
|
}
|
|
2334
|
-
const
|
|
2358
|
+
const he = {
|
|
2335
2359
|
street: "",
|
|
2336
2360
|
firstName: "",
|
|
2337
2361
|
lastName: "",
|
|
@@ -2339,16 +2363,16 @@ const ce = {
|
|
|
2339
2363
|
city: "",
|
|
2340
2364
|
zipCode: "",
|
|
2341
2365
|
country: ""
|
|
2342
|
-
},
|
|
2366
|
+
}, ue = (n, e) => {
|
|
2343
2367
|
const t = {}, s = `${e}.`;
|
|
2344
|
-
return Object.keys(
|
|
2368
|
+
return Object.keys(n).forEach((a) => {
|
|
2345
2369
|
if (a.startsWith(s)) {
|
|
2346
|
-
const
|
|
2347
|
-
t[
|
|
2370
|
+
const i = a.slice(s.length);
|
|
2371
|
+
t[i] = n[a];
|
|
2348
2372
|
}
|
|
2349
2373
|
}), t;
|
|
2350
2374
|
};
|
|
2351
|
-
class
|
|
2375
|
+
class wt {
|
|
2352
2376
|
formElement;
|
|
2353
2377
|
componentManager;
|
|
2354
2378
|
onLoadingStateChange;
|
|
@@ -2382,13 +2406,13 @@ class Nt {
|
|
|
2382
2406
|
!!(e.errors.name && e.touched.name),
|
|
2383
2407
|
e.errors.name
|
|
2384
2408
|
), this.componentManager.updateBillingAddressSection(
|
|
2385
|
-
e.formData.billingAddress ??
|
|
2409
|
+
e.formData.billingAddress ?? he,
|
|
2386
2410
|
e.errors.billingAddress ?? {},
|
|
2387
|
-
|
|
2411
|
+
ue(e.touched, "billingAddress")
|
|
2388
2412
|
), this.componentManager.updateShippingAddressSection(
|
|
2389
|
-
e.formData.shippingAddress ??
|
|
2413
|
+
e.formData.shippingAddress ?? he,
|
|
2390
2414
|
e.errors.shippingAddress ?? {},
|
|
2391
|
-
|
|
2415
|
+
ue(e.touched, "shippingAddress")
|
|
2392
2416
|
), this.componentManager.updateSubmitButton(t);
|
|
2393
2417
|
}
|
|
2394
2418
|
setLoadingState(e) {
|
|
@@ -2396,10 +2420,10 @@ class Nt {
|
|
|
2396
2420
|
this.onLoadingStateChange(e);
|
|
2397
2421
|
return;
|
|
2398
2422
|
}
|
|
2399
|
-
e ? (this.hideSkeleton(), this.formSkeleton = new
|
|
2423
|
+
e ? (this.hideSkeleton(), this.formSkeleton = new ge(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
|
|
2400
2424
|
}
|
|
2401
2425
|
showSpinner(e) {
|
|
2402
|
-
this.hideSpinner(), this.spinner = new
|
|
2426
|
+
this.hideSpinner(), this.spinner = new Nt({ text: e }), this.formElement.appendChild(this.spinner.getElement());
|
|
2403
2427
|
}
|
|
2404
2428
|
hideSpinner() {
|
|
2405
2429
|
this.spinner && (this.spinner.getElement().remove(), this.spinner = void 0);
|
|
@@ -2408,7 +2432,7 @@ class Nt {
|
|
|
2408
2432
|
this.formSkeleton && (this.formSkeleton.getElement().remove(), this.formSkeleton = void 0);
|
|
2409
2433
|
}
|
|
2410
2434
|
setErrorMessage(e) {
|
|
2411
|
-
this.alert && (this.alert.getElement().remove(), this.alert = void 0), this.alert = new
|
|
2435
|
+
this.alert && (this.alert.getElement().remove(), this.alert = void 0), this.alert = new ke({ message: e }), this.formElement.insertBefore(
|
|
2412
2436
|
this.alert.getElement(),
|
|
2413
2437
|
this.formElement.firstChild
|
|
2414
2438
|
);
|
|
@@ -2420,7 +2444,7 @@ class Nt {
|
|
|
2420
2444
|
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
2445
|
}
|
|
2422
2446
|
}
|
|
2423
|
-
const
|
|
2447
|
+
const T = (n) => ({
|
|
2424
2448
|
street: "",
|
|
2425
2449
|
firstName: "",
|
|
2426
2450
|
lastName: "",
|
|
@@ -2428,14 +2452,14 @@ const x = (i) => ({
|
|
|
2428
2452
|
city: "",
|
|
2429
2453
|
zipCode: "",
|
|
2430
2454
|
country: "",
|
|
2431
|
-
...
|
|
2455
|
+
...n
|
|
2432
2456
|
});
|
|
2433
|
-
class
|
|
2457
|
+
class Pt extends A {
|
|
2434
2458
|
options;
|
|
2435
|
-
formManager =
|
|
2459
|
+
formManager = ct();
|
|
2436
2460
|
checkoutProfile;
|
|
2437
|
-
translation =
|
|
2438
|
-
focusManager = new
|
|
2461
|
+
translation = Ae();
|
|
2462
|
+
focusManager = new xe();
|
|
2439
2463
|
// Managers
|
|
2440
2464
|
componentManager;
|
|
2441
2465
|
eventHandler;
|
|
@@ -2446,7 +2470,7 @@ class wt extends k {
|
|
|
2446
2470
|
vgsJwt;
|
|
2447
2471
|
vgsCardResult;
|
|
2448
2472
|
constructor(e) {
|
|
2449
|
-
super("form", ["form-container"]), this.options = e, this.vgsJwt = e.vgsJwt, this.vgsJwt && (this.vgsService = new
|
|
2473
|
+
super("form", ["form-container"]), this.options = e, this.vgsJwt = e.vgsJwt, this.vgsJwt && (this.vgsService = new L()), this.checkoutProfile = dt({
|
|
2450
2474
|
appearance: e.appearance
|
|
2451
2475
|
}), e.locale && this.translation.setLocale(e.locale), this.componentManager = new Et({
|
|
2452
2476
|
formElement: this.element,
|
|
@@ -2465,11 +2489,11 @@ class wt extends k {
|
|
|
2465
2489
|
environment: e.environment,
|
|
2466
2490
|
vgsService: this.vgsService,
|
|
2467
2491
|
onVgsStateChange: (t) => this.handleVgsStateChange(t)
|
|
2468
|
-
}), this.uiManager = new
|
|
2492
|
+
}), this.uiManager = new wt({
|
|
2469
2493
|
formElement: this.element,
|
|
2470
2494
|
componentManager: this.componentManager,
|
|
2471
2495
|
onLoadingStateChange: e.onLoadingStateChange
|
|
2472
|
-
}), this.stateCoordinator = new
|
|
2496
|
+
}), this.stateCoordinator = new Mt({
|
|
2473
2497
|
formManager: this.formManager,
|
|
2474
2498
|
checkoutProfile: this.checkoutProfile,
|
|
2475
2499
|
componentManager: this.componentManager,
|
|
@@ -2479,7 +2503,7 @@ class wt extends k {
|
|
|
2479
2503
|
onError: (t) => this.uiManager.setErrorMessage(t),
|
|
2480
2504
|
onLoadingChange: (t) => this.uiManager.setLoadingState(t),
|
|
2481
2505
|
getInitialFormData: () => this._getFormStateData().formData
|
|
2482
|
-
}), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new
|
|
2506
|
+
}), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new Ft({
|
|
2483
2507
|
formManager: this.formManager,
|
|
2484
2508
|
focusManager: this.focusManager,
|
|
2485
2509
|
onFormSubmit: async () => this.handleSubmit(),
|
|
@@ -2504,12 +2528,12 @@ class wt extends k {
|
|
|
2504
2528
|
},
|
|
2505
2529
|
...e.initialValues.name && { name: e.initialValues.name },
|
|
2506
2530
|
...e.initialValues.billingAddress && {
|
|
2507
|
-
billingAddress:
|
|
2531
|
+
billingAddress: T(
|
|
2508
2532
|
e.initialValues.billingAddress
|
|
2509
2533
|
)
|
|
2510
2534
|
},
|
|
2511
2535
|
...e.initialValues.shippingAddress && {
|
|
2512
|
-
shippingAddress:
|
|
2536
|
+
shippingAddress: T(
|
|
2513
2537
|
e.initialValues.shippingAddress
|
|
2514
2538
|
)
|
|
2515
2539
|
}
|
|
@@ -2526,10 +2550,10 @@ class wt extends k {
|
|
|
2526
2550
|
cardNumber: "",
|
|
2527
2551
|
cardCvv: "",
|
|
2528
2552
|
...t?.billingAddress && {
|
|
2529
|
-
billingAddress:
|
|
2553
|
+
billingAddress: T(t.billingAddress)
|
|
2530
2554
|
},
|
|
2531
2555
|
...t?.shippingAddress && {
|
|
2532
|
-
shippingAddress:
|
|
2556
|
+
shippingAddress: T(t.shippingAddress)
|
|
2533
2557
|
}
|
|
2534
2558
|
},
|
|
2535
2559
|
errors: e.errors || {},
|
|
@@ -2556,11 +2580,11 @@ class wt extends k {
|
|
|
2556
2580
|
phoneNumber: "",
|
|
2557
2581
|
phoneCountryCode: e.checkoutProfile.layout.phoneNumber.defaultCountry?.toUpperCase() || "US"
|
|
2558
2582
|
}), e.checkoutProfile.layout.billingFields && this.formManager.getFormState().formData.billingAddress === void 0 && this.formManager.setFormData({
|
|
2559
|
-
billingAddress:
|
|
2583
|
+
billingAddress: T()
|
|
2560
2584
|
}), e.checkoutProfile.layout.shippingFields && this.formManager.getFormState().formData.shippingAddress === void 0 && this.formManager.setFormData({
|
|
2561
|
-
shippingAddress:
|
|
2585
|
+
shippingAddress: T()
|
|
2562
2586
|
});
|
|
2563
|
-
const { formData: t, errors: s, touched: a } = this._getFormStateData(),
|
|
2587
|
+
const { formData: t, errors: s, touched: a } = this._getFormStateData(), i = gt(
|
|
2564
2588
|
e.checkoutProfile.layout
|
|
2565
2589
|
);
|
|
2566
2590
|
try {
|
|
@@ -2581,7 +2605,7 @@ class wt extends k {
|
|
|
2581
2605
|
} catch (o) {
|
|
2582
2606
|
console.error("Failed to create email field:", o);
|
|
2583
2607
|
}
|
|
2584
|
-
if (
|
|
2608
|
+
if (i) {
|
|
2585
2609
|
try {
|
|
2586
2610
|
this.componentManager.createBillingAddressSection(
|
|
2587
2611
|
e.checkoutProfile,
|
|
@@ -2624,7 +2648,7 @@ class wt extends k {
|
|
|
2624
2648
|
} catch (o) {
|
|
2625
2649
|
console.error("Failed to create card section:", o);
|
|
2626
2650
|
}
|
|
2627
|
-
if (!
|
|
2651
|
+
if (!J(
|
|
2628
2652
|
e.checkoutProfile.layout
|
|
2629
2653
|
))
|
|
2630
2654
|
try {
|
|
@@ -2662,12 +2686,12 @@ class wt extends k {
|
|
|
2662
2686
|
*/
|
|
2663
2687
|
inferCardholderName() {
|
|
2664
2688
|
const e = this.checkoutProfile.getState();
|
|
2665
|
-
if (!e.checkoutProfile || !
|
|
2689
|
+
if (!e.checkoutProfile || !J(
|
|
2666
2690
|
e.checkoutProfile.layout
|
|
2667
2691
|
)) return;
|
|
2668
2692
|
const { formData: s } = this._getFormStateData(), a = s.billingAddress ?? s.shippingAddress;
|
|
2669
2693
|
if (!a) return;
|
|
2670
|
-
const
|
|
2694
|
+
const i = a.firstName?.trim() ?? "", r = a.lastName?.trim() ?? "", o = [i, r].filter(Boolean).join(" ");
|
|
2671
2695
|
o && this.formManager.setFormData({ name: o });
|
|
2672
2696
|
}
|
|
2673
2697
|
/**
|
|
@@ -2678,10 +2702,10 @@ class wt extends k {
|
|
|
2678
2702
|
inferAddresses() {
|
|
2679
2703
|
const e = this.checkoutProfile.getState();
|
|
2680
2704
|
if (!e.checkoutProfile) return;
|
|
2681
|
-
const { billingFields: t, shippingFields: s } = e.checkoutProfile.layout, a = t && Object.values(t).some((o) => o?.enabled),
|
|
2682
|
-
!a &&
|
|
2705
|
+
const { billingFields: t, shippingFields: s } = e.checkoutProfile.layout, a = t && Object.values(t).some((o) => o?.enabled), i = s && Object.values(s).some((o) => o?.enabled), { formData: r } = this._getFormStateData();
|
|
2706
|
+
!a && i && r.shippingAddress ? this.formManager.setFormData({
|
|
2683
2707
|
billingAddress: { ...r.shippingAddress }
|
|
2684
|
-
}) : !
|
|
2708
|
+
}) : !i && a && r.billingAddress && this.formManager.setFormData({
|
|
2685
2709
|
shippingAddress: { ...r.billingAddress }
|
|
2686
2710
|
});
|
|
2687
2711
|
}
|
|
@@ -2769,8 +2793,8 @@ class wt extends k {
|
|
|
2769
2793
|
this.eventHandler.handleKeyDown
|
|
2770
2794
|
), this.componentManager.cleanup(), this.uiManager.cleanup(), this.getElement().remove();
|
|
2771
2795
|
}
|
|
2772
|
-
associatePayment(e, t, s, a,
|
|
2773
|
-
this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = s, this.options.checkoutDetails = a, this.componentManager.setCheckoutDetailsLoaded(!0),
|
|
2796
|
+
associatePayment(e, t, s, a, i) {
|
|
2797
|
+
this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = s, this.options.checkoutDetails = a, this.componentManager.setCheckoutDetailsLoaded(!0), i && !this.vgsService && (this.vgsJwt = i, this.vgsService = new L(), this.componentManager.setVgsService(this.vgsService), this.stateCoordinator.setVgsMode(!0), this.vgsService.init(this.options.environment).then((o) => {
|
|
2774
2798
|
this.vgsService?.createForm(
|
|
2775
2799
|
o,
|
|
2776
2800
|
(d) => this.handleVgsStateChange(d)
|
|
@@ -2783,7 +2807,7 @@ class wt extends k {
|
|
|
2783
2807
|
e,
|
|
2784
2808
|
t,
|
|
2785
2809
|
a
|
|
2786
|
-
), !
|
|
2810
|
+
), !i && this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents();
|
|
2787
2811
|
const r = this.checkoutProfile.getState();
|
|
2788
2812
|
if (r.checkoutProfile) {
|
|
2789
2813
|
const { formData: o } = this._getFormStateData();
|
|
@@ -2795,7 +2819,7 @@ class wt extends k {
|
|
|
2795
2819
|
}
|
|
2796
2820
|
}
|
|
2797
2821
|
}
|
|
2798
|
-
class
|
|
2822
|
+
class kt {
|
|
2799
2823
|
container = null;
|
|
2800
2824
|
options;
|
|
2801
2825
|
onSubmit;
|
|
@@ -2819,7 +2843,7 @@ class Pt {
|
|
|
2819
2843
|
}
|
|
2820
2844
|
}
|
|
2821
2845
|
renderForm(e) {
|
|
2822
|
-
this.container && (this.form && (this.form.destroy(), this.form = null), this.form = new
|
|
2846
|
+
this.container && (this.form && (this.form.destroy(), this.form = null), this.form = new Pt({
|
|
2823
2847
|
apiKey: this.options.apiKey,
|
|
2824
2848
|
onSubmit: this.onSubmit,
|
|
2825
2849
|
locale: this.options.locale,
|
|
@@ -2846,17 +2870,17 @@ class Pt {
|
|
|
2846
2870
|
clearError() {
|
|
2847
2871
|
this.form && this.form.clearErrorMessage();
|
|
2848
2872
|
}
|
|
2849
|
-
async associatePayment(e, t, s, a,
|
|
2850
|
-
this.options.paymentId = e, this.options.checkoutKey = t, this.options.checkoutDetails = a, this.options.vgsJwt =
|
|
2873
|
+
async associatePayment(e, t, s, a, i) {
|
|
2874
|
+
this.options.paymentId = e, this.options.checkoutKey = t, this.options.checkoutDetails = a, this.options.vgsJwt = i, this.form && this.form.associatePayment(
|
|
2851
2875
|
e,
|
|
2852
2876
|
t,
|
|
2853
2877
|
s,
|
|
2854
2878
|
a,
|
|
2855
|
-
|
|
2879
|
+
i
|
|
2856
2880
|
);
|
|
2857
2881
|
}
|
|
2858
2882
|
}
|
|
2859
|
-
class
|
|
2883
|
+
class At {
|
|
2860
2884
|
state;
|
|
2861
2885
|
listeners = /* @__PURE__ */ new Set();
|
|
2862
2886
|
constructor(e) {
|
|
@@ -2878,16 +2902,17 @@ class kt {
|
|
|
2878
2902
|
this.listeners.forEach((t) => t(e));
|
|
2879
2903
|
}
|
|
2880
2904
|
}
|
|
2881
|
-
const
|
|
2905
|
+
const xt = "en";
|
|
2882
2906
|
class Dt {
|
|
2883
2907
|
config;
|
|
2908
|
+
_callbacks;
|
|
2884
2909
|
paymentState;
|
|
2885
2910
|
apiService;
|
|
2886
2911
|
formManager;
|
|
2887
2912
|
stateManager;
|
|
2888
2913
|
sessionId;
|
|
2889
2914
|
constructor(e) {
|
|
2890
|
-
this.config = this.validateConfig(e), this.paymentState = {}, this.sessionId = crypto.randomUUID(),
|
|
2915
|
+
this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(), ot({
|
|
2891
2916
|
environment: this.config.environment,
|
|
2892
2917
|
sessionId: this.sessionId
|
|
2893
2918
|
}), M(F.CHECKOUT_INITIALIZED, {
|
|
@@ -2895,17 +2920,17 @@ class Dt {
|
|
|
2895
2920
|
}), this.apiService = new De(
|
|
2896
2921
|
this.config.apiKey,
|
|
2897
2922
|
this.config.environment
|
|
2898
|
-
), this.stateManager = new
|
|
2923
|
+
), this.stateManager = new At({
|
|
2899
2924
|
mounted: !1,
|
|
2900
2925
|
form: null
|
|
2901
|
-
}), this.formManager = new
|
|
2926
|
+
}), this.formManager = new kt(
|
|
2902
2927
|
{
|
|
2903
2928
|
locale: this.config.locale,
|
|
2904
2929
|
apiKey: this.config.apiKey,
|
|
2905
2930
|
disableErrorMessages: this.config.disableErrorMessages,
|
|
2906
2931
|
environment: this.config.environment,
|
|
2907
2932
|
appearance: this.config.appearance,
|
|
2908
|
-
onLoadingStateChange: this.
|
|
2933
|
+
onLoadingStateChange: (...t) => this._callbacks.onLoadingStateChange?.(...t),
|
|
2909
2934
|
initialValues: this.config.initialValues
|
|
2910
2935
|
},
|
|
2911
2936
|
this.handleSubmit.bind(this)
|
|
@@ -2920,7 +2945,7 @@ class Dt {
|
|
|
2920
2945
|
apiKey: e.apiKey,
|
|
2921
2946
|
returnUrl: e.returnUrl,
|
|
2922
2947
|
environment: e.environment,
|
|
2923
|
-
locale: e.locale ||
|
|
2948
|
+
locale: e.locale || xt,
|
|
2924
2949
|
disableErrorMessages: e.disableErrorMessages ?? !1,
|
|
2925
2950
|
manualActionHandling: e.manualActionHandling ?? !1,
|
|
2926
2951
|
appearance: e.appearance,
|
|
@@ -2971,15 +2996,15 @@ class Dt {
|
|
|
2971
2996
|
});
|
|
2972
2997
|
const a = performance.now();
|
|
2973
2998
|
try {
|
|
2974
|
-
const
|
|
2999
|
+
const i = await this.apiService.authorizePayment({
|
|
2975
3000
|
checkoutKey: this.paymentState.checkoutKey,
|
|
2976
3001
|
formData: e || null,
|
|
2977
3002
|
paymentId: this.paymentState.paymentId,
|
|
2978
3003
|
returnUrl: this.config.returnUrl,
|
|
2979
3004
|
applePayData: t
|
|
2980
3005
|
}), r = performance.now() - a;
|
|
2981
|
-
|
|
2982
|
-
|
|
3006
|
+
oe(
|
|
3007
|
+
se.PAYMENT_AUTHORIZATION_TIME,
|
|
2983
3008
|
r,
|
|
2984
3009
|
"ms",
|
|
2985
3010
|
{
|
|
@@ -2990,11 +3015,11 @@ class Dt {
|
|
|
2990
3015
|
), M(F.PAYMENT_SUBMIT_SUCCESS, {
|
|
2991
3016
|
payment_id: this.paymentState.paymentId,
|
|
2992
3017
|
payment_method: s
|
|
2993
|
-
}), this.handlePaymentResponse(
|
|
2994
|
-
} catch (
|
|
3018
|
+
}), this.handlePaymentResponse(i);
|
|
3019
|
+
} catch (i) {
|
|
2995
3020
|
const r = performance.now() - a;
|
|
2996
|
-
|
|
2997
|
-
|
|
3021
|
+
oe(
|
|
3022
|
+
se.PAYMENT_AUTHORIZATION_TIME,
|
|
2998
3023
|
r,
|
|
2999
3024
|
"ms",
|
|
3000
3025
|
{
|
|
@@ -3005,29 +3030,27 @@ class Dt {
|
|
|
3005
3030
|
), M(F.PAYMENT_SUBMIT_FAILED, {
|
|
3006
3031
|
payment_id: this.paymentState.paymentId,
|
|
3007
3032
|
payment_method: s,
|
|
3008
|
-
error_message:
|
|
3009
|
-
}), this.handleAuthorizationError(
|
|
3033
|
+
error_message: i.details?.message ?? "Unknown error"
|
|
3034
|
+
}), this.handleAuthorizationError(i);
|
|
3010
3035
|
}
|
|
3011
3036
|
}
|
|
3012
3037
|
handlePaymentResponse(e) {
|
|
3013
3038
|
if (e.latestTransaction.status === "authorized" && (M(F.PAYMENT_AUTHORIZED, {
|
|
3014
3039
|
payment_id: this.paymentState.paymentId ?? "",
|
|
3015
3040
|
status: e.latestTransaction.status
|
|
3016
|
-
}), this.
|
|
3017
|
-
e.latestTransaction.status
|
|
3018
|
-
)), e.latestTransaction.status === "failed" && (M(F.PAYMENT_FAILED, {
|
|
3041
|
+
}), this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status)), e.latestTransaction.status === "failed" && (M(F.PAYMENT_FAILED, {
|
|
3019
3042
|
payment_id: this.paymentState.paymentId ?? "",
|
|
3020
3043
|
status: e.latestTransaction.status
|
|
3021
|
-
}), this.
|
|
3044
|
+
}), this._callbacks.onPaymentFailed?.(e.latestTransaction.status)), e.status === "requires_action") {
|
|
3022
3045
|
const { redirectUrl: t } = e.action;
|
|
3023
3046
|
M(F.PAYMENT_ACTION_REQUIRED, {
|
|
3024
3047
|
payment_id: this.paymentState.paymentId ?? "",
|
|
3025
3048
|
status: e.status
|
|
3026
|
-
}), this.config.manualActionHandling ? this.
|
|
3049
|
+
}), this.config.manualActionHandling ? this._callbacks.onActionRequired?.(t) : globalThis.location.href = t;
|
|
3027
3050
|
}
|
|
3028
3051
|
}
|
|
3029
3052
|
handleAuthorizationError(e) {
|
|
3030
|
-
this.
|
|
3053
|
+
this._callbacks.onPaymentFailed?.(e.details?.message);
|
|
3031
3054
|
const { form: t } = this.stateManager.getState();
|
|
3032
3055
|
t && this.formManager.update({ errorMsg: e.details?.message });
|
|
3033
3056
|
}
|
|
@@ -3070,7 +3093,7 @@ class Dt {
|
|
|
3070
3093
|
"Invalid response: supportedPaymentMethods must be an array"
|
|
3071
3094
|
);
|
|
3072
3095
|
if (!s.supportedPaymentMethods.every(
|
|
3073
|
-
(
|
|
3096
|
+
(i) => typeof i == "string"
|
|
3074
3097
|
))
|
|
3075
3098
|
throw new Error(
|
|
3076
3099
|
"Invalid response: all supportedPaymentMethods must be strings"
|
|
@@ -3081,7 +3104,7 @@ class Dt {
|
|
|
3081
3104
|
countryCode: s.countryCode
|
|
3082
3105
|
};
|
|
3083
3106
|
const a = s.supportedPaymentMethods.reduce(
|
|
3084
|
-
(
|
|
3107
|
+
(i, r) => (i[r] = !0, i),
|
|
3085
3108
|
{}
|
|
3086
3109
|
);
|
|
3087
3110
|
await this.formManager.associatePayment(
|
|
@@ -3099,26 +3122,29 @@ class Dt {
|
|
|
3099
3122
|
throw M(F.PAYMENT_ASSOCIATION_FAILED, {
|
|
3100
3123
|
payment_id: e,
|
|
3101
3124
|
error_message: s instanceof Error ? s.message : "Unknown error"
|
|
3102
|
-
}),
|
|
3125
|
+
}), lt(
|
|
3103
3126
|
s instanceof Error ? s : new Error("Failed to associate payment"),
|
|
3104
3127
|
{ payment_id: e }
|
|
3105
3128
|
), s;
|
|
3106
3129
|
}
|
|
3107
3130
|
}
|
|
3131
|
+
setCallbacks(e) {
|
|
3132
|
+
Object.assign(this._callbacks, e);
|
|
3133
|
+
}
|
|
3108
3134
|
}
|
|
3109
3135
|
typeof globalThis < "u" && (globalThis.OdusCheckout = Dt);
|
|
3110
3136
|
export {
|
|
3111
3137
|
Dt as OdusCheckout,
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3138
|
+
_t as deLocale,
|
|
3139
|
+
Rt as enLocale,
|
|
3140
|
+
Bt as esLocale,
|
|
3141
|
+
Ut as frLocale,
|
|
3142
|
+
Ot as itLocale,
|
|
3143
|
+
Ht as plLocale,
|
|
3144
|
+
zt as ptLocale,
|
|
3145
|
+
lt as pushError,
|
|
3120
3146
|
M as pushEvent,
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3147
|
+
Tt as pushLog,
|
|
3148
|
+
oe as pushMeasurement,
|
|
3149
|
+
$t as trLocale
|
|
3124
3150
|
};
|