@odus/checkout 0.30.0-beta.1 → 0.30.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { l as pe, c as de, a as ge, f as U, d as fe, C as P, I as ce, g as ye, S as H, b as Z, H as be, V as J, e as k, A as ve, P as Se, E as Ee, h as Ce, i as Fe, j as Me, k as Ne, m as we, n as Pe, F as ke, o as Ae, p as De } from "./shared.js";
2
- import { q as Tt, r as Vt, s as _t, t as Bt, u as Ot, v as Rt, w as Ut, x as Ht } from "./shared.js";
3
- const C = {
1
+ import { l as ge, c as ue, a as fe, f as j, d as ye, C as k, I as me, g as be, S as V, b as Q, H as ve, V as ee, e as D, A as Se, P as Ee, E as Ce, h as Fe, i as Me, j as Ne, k as we, m as Pe, n as ke, F as Ae, o as De, p as Ie } from "./shared.js";
2
+ import { q as Vt, r as _t, s as Rt, t as Bt, u as Ut, v as Ot, w as Ht, x as zt } from "./shared.js";
3
+ const F = {
4
4
  // Checkout lifecycle events
5
5
  CHECKOUT_INITIALIZED: "checkout.initialized",
6
6
  CHECKOUT_MOUNTED: "checkout.mounted",
@@ -16,11 +16,11 @@ const C = {
16
16
  PAYMENT_AUTHORIZED: "payment.authorized",
17
17
  PAYMENT_FAILED: "payment.failed",
18
18
  PAYMENT_ACTION_REQUIRED: "payment.action_required"
19
- }, X = {
19
+ }, te = {
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
- }, Ie = /^\s*at (?:(.+?) ?\()?((?:file|https?|chrome-extension|webpack-internal):\/\/.+?):(\d+):(\d+)\)?\s*$/, xe = /^([^@]+)@((?:file|https?|chrome-extension|webpack-internal):\/\/[^\s:]+):(\d+):(\d+)$/, Le = /^(?:([^@]+)@)?((?:file|https?):\/\/[^\s:]+):(\d+):(\d+)$/, q = (i) => {
23
+ }, xe = /^\s*at (?:(.+?) ?\()?((?:file|https?|chrome-extension|webpack-internal):\/\/.+?):(\d+):(\d+)\)?\s*$/, Te = /^([^@]+)@((?:file|https?|chrome-extension|webpack-internal):\/\/[^\s:]+):(\d+):(\d+)$/, Le = /^(?:([^@]+)@)?((?:file|https?):\/\/[^\s:]+):(\d+):(\d+)$/, G = (i) => {
24
24
  if (!i)
25
25
  return [];
26
26
  const e = [], t = i.split(`
@@ -29,7 +29,7 @@ const C = {
29
29
  const a = s.trim();
30
30
  if (!a)
31
31
  continue;
32
- let n = Ie.exec(a);
32
+ let n = xe.exec(a);
33
33
  if (n) {
34
34
  e.push({
35
35
  function: n[1] || "(anonymous)",
@@ -39,7 +39,7 @@ const C = {
39
39
  });
40
40
  continue;
41
41
  }
42
- n = xe.exec(a) ?? Le.exec(a), n && e.push({
42
+ n = Te.exec(a) ?? Le.exec(a), n && e.push({
43
43
  function: n[1] || "(anonymous)",
44
44
  filename: n[2],
45
45
  lineno: parseInt(n[3], 10),
@@ -47,9 +47,9 @@ const C = {
47
47
  });
48
48
  }
49
49
  return e;
50
- }, Te = "@odus/telemetry", Ve = "0.0.1";
51
- let B, O, Y;
52
- const _e = () => {
50
+ }, Ve = "@odus/telemetry", _e = "0.0.1";
51
+ let H, z, J;
52
+ const Re = () => {
53
53
  if (typeof navigator > "u")
54
54
  return {};
55
55
  const i = navigator.userAgent;
@@ -66,36 +66,36 @@ const _e = () => {
66
66
  viewportHeight: String(window.innerHeight),
67
67
  userAgent: i
68
68
  };
69
- }, Be = () => typeof window > "u" ? {} : { url: window.location.href }, Oe = (i) => {
70
- B = void 0, Y = void 0, O = i.sessionTracking?.session ? { id: i.sessionTracking.session.id } : void 0;
71
- }, Re = (i) => {
72
- B = i;
73
- }, Ue = () => {
74
- B = void 0;
75
- }, He = (i) => {
76
- O = i;
69
+ }, Be = () => typeof window > "u" ? {} : { url: window.location.href }, Ue = (i) => {
70
+ H = void 0, J = void 0, z = i.sessionTracking?.session ? { id: i.sessionTracking.session.id } : void 0;
71
+ }, Oe = (i) => {
72
+ H = i;
73
+ }, He = () => {
74
+ H = void 0;
77
75
  }, ze = (i) => {
78
- Y = i;
79
- }, $e = () => O?.id, je = (i) => ({
80
- sdk: { name: Te, version: Ve },
76
+ z = i;
77
+ }, $e = (i) => {
78
+ J = i;
79
+ }, je = () => z?.id, Ke = (i) => ({
80
+ sdk: { name: Ve, version: _e },
81
81
  app: i.app,
82
- user: B,
83
- session: O,
82
+ user: H,
83
+ session: z,
84
84
  page: Be(),
85
- browser: _e(),
86
- view: Y
87
- }), Ke = 30, qe = 250, We = 6e4;
88
- let A = [], w = null, G = 0, L = null, T = null;
89
- const Ye = (i) => {
90
- if (w)
85
+ browser: Re(),
86
+ view: J
87
+ }), qe = 30, We = 250, Ye = 6e4;
88
+ let I = [], P = null, X = 0, _ = null, R = null;
89
+ const Ge = (i) => {
90
+ if (P)
91
91
  return;
92
- const e = i.batching?.sendTimeout ?? qe;
93
- w = setTimeout(() => {
94
- R(i);
92
+ const e = i.batching?.sendTimeout ?? We;
93
+ P = setTimeout(() => {
94
+ $(i);
95
95
  }, e);
96
- }, Ge = (i, e) => {
96
+ }, Ze = (i, e) => {
97
97
  const t = {
98
- meta: je(e)
98
+ meta: Ke(e)
99
99
  };
100
100
  for (const s of i)
101
101
  switch (s.type) {
@@ -113,8 +113,8 @@ const Ye = (i) => {
113
113
  break;
114
114
  }
115
115
  return t;
116
- }, Ze = (i, e, t = !1) => {
117
- const s = JSON.stringify(i), a = $e(), n = {
116
+ }, Je = (i, e, t = !1) => {
117
+ const s = JSON.stringify(i), a = je(), n = {
118
118
  "Content-Type": "application/json"
119
119
  };
120
120
  if (a && (n["x-faro-session-id"] = a), t && typeof navigator < "u" && navigator.sendBeacon) {
@@ -122,7 +122,7 @@ const Ye = (i) => {
122
122
  navigator.sendBeacon(e, o);
123
123
  return;
124
124
  }
125
- const r = s.length < We;
125
+ const r = s.length < Ye;
126
126
  fetch(e, {
127
127
  method: "POST",
128
128
  headers: n,
@@ -131,220 +131,220 @@ const Ye = (i) => {
131
131
  }).then((o) => {
132
132
  if (o.status === 429) {
133
133
  const d = o.headers.get("Retry-After"), c = d ? parseInt(d, 10) * 1e3 : 3e4;
134
- G = Date.now() + c;
134
+ X = Date.now() + c;
135
135
  }
136
136
  }).catch(() => {
137
137
  });
138
- }, R = (i, e = !1) => {
139
- if (w && (clearTimeout(w), w = null), A.length === 0)
138
+ }, $ = (i, e = !1) => {
139
+ if (P && (clearTimeout(P), P = null), I.length === 0)
140
140
  return;
141
- if (Date.now() < G) {
142
- A = [];
141
+ if (Date.now() < X) {
142
+ I = [];
143
143
  return;
144
144
  }
145
- const t = A;
146
- A = [];
145
+ const t = I;
146
+ I = [];
147
147
  try {
148
- let s = Ge(t, i);
148
+ let s = Ze(t, i);
149
149
  if (i.beforeSend) {
150
150
  const a = i.beforeSend(s);
151
151
  if (!a)
152
152
  return;
153
153
  s = a;
154
154
  }
155
- Ze(s, i.url, e);
155
+ Je(s, i.url, e);
156
156
  } catch {
157
157
  }
158
- }, N = (i, e) => {
159
- A.push(i);
160
- const t = e.batching?.itemLimit ?? Ke;
161
- if (A.length >= t) {
162
- R(e);
158
+ }, w = (i, e) => {
159
+ I.push(i);
160
+ const t = e.batching?.itemLimit ?? qe;
161
+ if (I.length >= t) {
162
+ $(e);
163
163
  return;
164
164
  }
165
- Ye(e);
166
- }, Je = (i) => {
167
- if (A = [], G = 0, w && (clearTimeout(w), w = null), typeof document > "u")
165
+ Ge(e);
166
+ }, Xe = (i) => {
167
+ if (I = [], X = 0, P && (clearTimeout(P), P = null), typeof document > "u")
168
168
  return;
169
- L && document.removeEventListener("visibilitychange", L), T && window.removeEventListener("pagehide", T);
170
- const e = () => R(i, !0);
171
- L = () => {
169
+ _ && document.removeEventListener("visibilitychange", _), R && window.removeEventListener("pagehide", R);
170
+ const e = () => $(i, !0);
171
+ _ = () => {
172
172
  document.visibilityState === "hidden" && e();
173
- }, T = e, document.addEventListener("visibilitychange", L), window.addEventListener("pagehide", T);
174
- }, Q = () => (/* @__PURE__ */ new Date()).toISOString();
175
- let ee = null, te = null;
176
- const Xe = (i) => {
177
- typeof window > "u" || (ee = (e) => {
173
+ }, R = e, document.addEventListener("visibilitychange", _), window.addEventListener("pagehide", R);
174
+ }, se = () => (/* @__PURE__ */ new Date()).toISOString();
175
+ let ne = null, ie = null;
176
+ const Qe = (i) => {
177
+ typeof window > "u" || (ne = (e) => {
178
178
  const t = e.error instanceof Error ? e.error : new Error(e.message);
179
- N({
179
+ w({
180
180
  type: "exception",
181
181
  payload: {
182
182
  type: t.name,
183
183
  value: t.message,
184
- timestamp: Q(),
185
- stacktrace: t.stack ? { frames: q(t.stack) } : void 0
184
+ timestamp: se(),
185
+ stacktrace: t.stack ? { frames: G(t.stack) } : void 0
186
186
  }
187
187
  }, i);
188
- }, te = (e) => {
188
+ }, ie = (e) => {
189
189
  const t = e.reason, s = t instanceof Error ? t : new Error(String(t));
190
- N({
190
+ w({
191
191
  type: "exception",
192
192
  payload: {
193
193
  type: s.name,
194
194
  value: s.message,
195
- timestamp: Q(),
196
- stacktrace: s.stack ? { frames: q(s.stack) } : void 0,
195
+ timestamp: se(),
196
+ stacktrace: s.stack ? { frames: G(s.stack) } : void 0,
197
197
  context: { source: "unhandledrejection" }
198
198
  }
199
199
  }, i);
200
- }, window.addEventListener("error", ee), window.addEventListener("unhandledrejection", te));
201
- }, se = "odus_telemetry_session_id", z = () => {
200
+ }, window.addEventListener("error", ne), window.addEventListener("unhandledrejection", ie));
201
+ }, ae = "odus_telemetry_session_id", K = () => {
202
202
  const i = new Uint8Array(16);
203
203
  return crypto.getRandomValues(i), Array.from(i, (e) => e.toString(16).padStart(2, "0")).join("");
204
- }, Qe = (i) => {
204
+ }, et = (i) => {
205
205
  if (i)
206
206
  return i;
207
207
  if (typeof sessionStorage > "u")
208
- return z();
208
+ return K();
209
209
  try {
210
- const e = sessionStorage.getItem(se);
210
+ const e = sessionStorage.getItem(ae);
211
211
  if (e)
212
212
  return e;
213
- const t = z();
214
- return sessionStorage.setItem(se, t), t;
213
+ const t = K();
214
+ return sessionStorage.setItem(ae, t), t;
215
215
  } catch {
216
- return z();
216
+ return K();
217
217
  }
218
- }, et = (i) => {
218
+ }, tt = (i) => {
219
219
  if (!i.sessionTracking?.enabled)
220
220
  return;
221
- const e = Qe(i.sessionTracking.session?.id);
222
- He({ id: e });
223
- }, $ = () => (/* @__PURE__ */ new Date()).toISOString(), j = (i, e) => {
221
+ const e = et(i.sessionTracking.session?.id);
222
+ ze({ id: e });
223
+ }, q = () => (/* @__PURE__ */ new Date()).toISOString(), W = (i, e) => {
224
224
  if (typeof PerformanceObserver > "u" || !PerformanceObserver.supportedEntryTypes?.includes(i))
225
225
  return;
226
226
  new PerformanceObserver((s) => {
227
227
  for (const a of s.getEntries())
228
228
  e(a);
229
229
  }).observe({ type: i, buffered: !0 });
230
- }, tt = (i) => {
230
+ }, st = (i) => {
231
231
  if (typeof window > "u")
232
232
  return;
233
- j("largest-contentful-paint", (t) => {
234
- N({
233
+ W("largest-contentful-paint", (t) => {
234
+ w({
235
235
  type: "measurement",
236
236
  payload: {
237
237
  type: "web-vitals",
238
238
  values: { lcp: t.startTime },
239
- timestamp: $()
239
+ timestamp: q()
240
240
  }
241
241
  }, i);
242
242
  });
243
243
  let e = 0;
244
- j("layout-shift", (t) => {
244
+ W("layout-shift", (t) => {
245
245
  const s = t;
246
- s.hadRecentInput || (e += s.value, N({
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: q()
252
252
  }
253
253
  }, i));
254
- }), j("event", (t) => {
254
+ }), W("event", (t) => {
255
255
  const s = t;
256
- s.duration > 0 && N({
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: q()
262
262
  }
263
263
  }, i);
264
264
  });
265
- }, _ = {
265
+ }, O = {
266
266
  INFO: "info",
267
267
  WARN: "warn",
268
268
  ERROR: "error"
269
- }, V = () => (/* @__PURE__ */ new Date()).toISOString(), st = (i) => {
270
- Oe(i), Je(i);
269
+ }, B = () => (/* @__PURE__ */ new Date()).toISOString(), nt = (i) => {
270
+ Ue(i), Xe(i);
271
271
  const e = i.instrumentations ?? {
272
272
  errors: !0,
273
273
  webVitals: !0,
274
274
  session: !0
275
275
  };
276
- return e.session !== !1 && et(i), e.errors !== !1 && Xe(i), e.webVitals !== !1 && tt(i), {
276
+ return e.session !== !1 && tt(i), e.errors !== !1 && Qe(i), e.webVitals !== !1 && st(i), {
277
277
  pushError(t, s) {
278
- N({
278
+ w({
279
279
  type: "exception",
280
280
  payload: {
281
281
  type: t.name,
282
282
  value: t.message,
283
- timestamp: V(),
284
- stacktrace: t.stack ? { frames: q(t.stack) } : void 0,
283
+ timestamp: B(),
284
+ stacktrace: t.stack ? { frames: G(t.stack) } : void 0,
285
285
  context: s?.context
286
286
  }
287
287
  }, i);
288
288
  },
289
289
  pushEvent(t, s) {
290
- N({
290
+ w({
291
291
  type: "event",
292
292
  payload: {
293
293
  name: t,
294
- timestamp: V(),
294
+ timestamp: B(),
295
295
  attributes: s
296
296
  }
297
297
  }, i);
298
298
  },
299
299
  pushMeasurement(t) {
300
- N({
300
+ w({
301
301
  type: "measurement",
302
302
  payload: {
303
303
  type: t.type,
304
304
  values: t.values,
305
- timestamp: V(),
305
+ timestamp: B(),
306
306
  context: t.context
307
307
  }
308
308
  }, i);
309
309
  },
310
310
  pushLog(t, s) {
311
- N({
311
+ w({
312
312
  type: "log",
313
313
  payload: {
314
314
  message: t.join(" "),
315
- level: s?.level ?? _.INFO,
316
- timestamp: V(),
315
+ level: s?.level ?? O.INFO,
316
+ timestamp: B(),
317
317
  context: s?.context
318
318
  }
319
319
  }, i);
320
320
  },
321
321
  setUser(t) {
322
- Re(t);
322
+ Oe(t);
323
323
  },
324
324
  resetUser() {
325
- Ue();
325
+ He();
326
326
  },
327
327
  setView(t) {
328
- ze(t);
328
+ $e(t);
329
329
  },
330
330
  flush() {
331
- R(i);
331
+ $(i);
332
332
  }
333
333
  };
334
- }, nt = (i) => i === "test" ? "https://sandbox-analytics.odus.com/collect" : "https://analytics.odus.com/collect", it = () => {
334
+ }, it = (i) => i === "test" ? "https://sandbox-analytics.odus.com/collect" : "https://analytics.odus.com/collect", at = () => {
335
335
  if (typeof window > "u")
336
336
  return !1;
337
337
  const i = window.location.hostname;
338
338
  return i === "localhost" || i === "127.0.0.1" || i === "0.0.0.0" || i === "::1" || i === "[::1]" || i.endsWith(".localhost");
339
339
  };
340
340
  let E = null;
341
- const at = (i) => {
341
+ const rt = (i) => {
342
342
  if (E)
343
343
  return E;
344
- if (it())
344
+ if (at())
345
345
  return null;
346
- const e = nt(i.environment);
347
- return E = st({
346
+ const e = it(i.environment);
347
+ return E = nt({
348
348
  url: e,
349
349
  app: {
350
350
  name: "odus-checkout",
@@ -376,11 +376,11 @@ const at = (i) => {
376
376
  return t;
377
377
  }
378
378
  }), E;
379
- }, rt = (i, e) => {
379
+ }, ot = (i, e) => {
380
380
  E && E.pushError(i, { context: e });
381
- }, F = (i, e) => {
381
+ }, M = (i, e) => {
382
382
  E && E.pushEvent(i, e);
383
- }, ne = (i, e, t, s) => {
383
+ }, re = (i, e, t, s) => {
384
384
  E && E.pushMeasurement({
385
385
  type: i,
386
386
  values: { [i]: e },
@@ -389,25 +389,25 @@ const at = (i) => {
389
389
  ...s
390
390
  }
391
391
  });
392
- }, It = (i, e = "info", t) => {
392
+ }, xt = (i, e = "info", t) => {
393
393
  if (!E) return;
394
394
  const s = {
395
- info: _.INFO,
396
- warn: _.WARN,
397
- error: _.ERROR
395
+ info: O.INFO,
396
+ warn: O.WARN,
397
+ error: O.ERROR
398
398
  };
399
399
  E.pushLog([i], {
400
400
  level: s[e],
401
401
  context: t
402
402
  });
403
- }, ie = {
403
+ }, oe = {
404
404
  test: "tntwpdhfwng",
405
405
  live: "TBD"
406
- }, ae = {
406
+ }, le = {
407
407
  test: "sandbox",
408
408
  live: "live"
409
409
  };
410
- class I {
410
+ class T {
411
411
  vgsForm = null;
412
412
  fields = [];
413
413
  readyResolve;
@@ -419,9 +419,9 @@ class I {
419
419
  });
420
420
  }
421
421
  async init(e) {
422
- return this.environment = e, await pe({
423
- vaultId: ie[e],
424
- environment: ae[e],
422
+ return this.environment = e, await ge({
423
+ vaultId: oe[e],
424
+ environment: le[e],
425
425
  version: "3.2.2"
426
426
  });
427
427
  }
@@ -429,8 +429,8 @@ class I {
429
429
  if (!this.environment)
430
430
  throw new Error("VGS not initialized — call init() first");
431
431
  return this.vgsForm = e.create(
432
- ie[this.environment],
433
- ae[this.environment],
432
+ oe[this.environment],
433
+ le[this.environment],
434
434
  t
435
435
  ), this.readyResolve?.(), this.vgsForm;
436
436
  }
@@ -482,7 +482,7 @@ class I {
482
482
  css: t
483
483
  });
484
484
  n.on("update", (r) => {
485
- a && a(I.mapCardType(r.cardType));
485
+ a && a(T.mapCardType(r.cardType));
486
486
  }), this.fields.push(n);
487
487
  }
488
488
  if (e.cardExpiry) {
@@ -543,7 +543,7 @@ class I {
543
543
  this.patchCard(e, o.id).then(s).catch(a);
544
544
  return;
545
545
  }
546
- s(I.extractCardResult(o));
546
+ s(T.extractCardResult(o));
547
547
  },
548
548
  (n) => {
549
549
  a(n);
@@ -586,11 +586,11 @@ class I {
586
586
  n(new Error("Card update failed: no card ID returned"));
587
587
  return;
588
588
  }
589
- const c = I.extractCardResult(d), p = o.included?.find(
589
+ const c = T.extractCardResult(d), m = o.included?.find(
590
590
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
591
591
  (b) => b.type === "card_updates"
592
592
  );
593
- p?.attributes?.updated_values?.length && (c.updatedValues = p.attributes.updated_values), a(c);
593
+ m?.attributes?.updated_values?.length && (c.updatedValues = m.attributes.updated_values), a(c);
594
594
  },
595
595
  (r) => {
596
596
  n(r);
@@ -627,7 +627,7 @@ class I {
627
627
  }[e] ?? "unknown" : "unknown";
628
628
  }
629
629
  }
630
- function K(i) {
630
+ function Y(i) {
631
631
  return {
632
632
  name: "Custom Appearance",
633
633
  additionalPaymentMethods: i.additionalPaymentMethods || {},
@@ -663,7 +663,7 @@ function K(i) {
663
663
  state: {
664
664
  enabled: i.layout?.billingFields?.state?.enabled ?? !1,
665
665
  label: i.layout?.billingFields?.state?.label,
666
- options: i.layout?.billingFields?.state?.options
666
+ hiddenForCountries: i.layout?.billingFields?.state?.hiddenForCountries
667
667
  },
668
668
  zipCode: {
669
669
  enabled: i.layout?.billingFields?.zipCode?.enabled ?? !1,
@@ -703,7 +703,7 @@ function K(i) {
703
703
  state: {
704
704
  enabled: i.layout.shippingFields.state?.enabled ?? !1,
705
705
  label: i.layout.shippingFields.state?.label,
706
- options: i.layout.shippingFields.state?.options
706
+ hiddenForCountries: i.layout.shippingFields.state?.hiddenForCountries
707
707
  },
708
708
  zipCode: {
709
709
  enabled: i.layout.shippingFields.zipCode?.enabled ?? !1,
@@ -727,16 +727,16 @@ function K(i) {
727
727
  }
728
728
  };
729
729
  }
730
- function ot({
730
+ function lt({
731
731
  appearance: i
732
732
  }) {
733
- const e = de({
733
+ const e = ue({
734
734
  checkoutProfile: void 0,
735
735
  isLoading: !0,
736
736
  error: null
737
737
  });
738
738
  if (i) {
739
- const s = K(i);
739
+ const s = Y(i);
740
740
  return Promise.resolve().then(() => {
741
741
  e.setState({
742
742
  checkoutProfile: s,
@@ -747,7 +747,7 @@ function ot({
747
747
  getState: e.getState.bind(e),
748
748
  subscribe: e.subscribe.bind(e),
749
749
  updateProfile: (a) => {
750
- const n = K(a);
750
+ const n = Y(a);
751
751
  e.setState({
752
752
  checkoutProfile: n,
753
753
  isLoading: !1,
@@ -796,7 +796,7 @@ function ot({
796
796
  getState: e.getState.bind(e),
797
797
  subscribe: e.subscribe.bind(e),
798
798
  updateProfile: (s) => {
799
- const a = K(s);
799
+ const a = Y(s);
800
800
  e.setState({
801
801
  checkoutProfile: a,
802
802
  isLoading: !1,
@@ -807,8 +807,8 @@ function ot({
807
807
  }
808
808
  };
809
809
  }
810
- const lt = () => {
811
- const i = ge(), e = de({
810
+ const dt = () => {
811
+ const i = fe(), e = ue({
812
812
  formData: {
813
813
  name: "",
814
814
  email: "",
@@ -825,204 +825,223 @@ const lt = () => {
825
825
  cardCvv: !1
826
826
  },
827
827
  isValid: !1
828
- }), t = (l, g, m, u) => {
828
+ }), t = (l, u, y, p) => {
829
829
  if (l === "cardCvv")
830
- return i.cardCvv(g, m);
831
- if (l === "phoneNumber" && u)
832
- return i.phoneNumber(g, u);
833
- const f = i[l];
834
- return f?.(g);
830
+ return i.cardCvv(u, y);
831
+ if (l === "phoneNumber" && p)
832
+ return i.phoneNumber(u, p);
833
+ const g = i[l];
834
+ return g?.(u);
835
835
  }, s = (l) => {
836
- const g = {};
837
- return Object.keys(l).forEach((u) => {
838
- const f = l[u];
839
- if (f === void 0) return;
836
+ const u = {};
837
+ return Object.keys(l).forEach((p) => {
838
+ const g = l[p];
839
+ if (g === void 0) return;
840
840
  let h;
841
- u === "cardCvv" ? h = t(u, f, l.cardNumber) : u === "phoneNumber" ? h = t(
842
- u,
843
- f,
841
+ p === "cardCvv" ? h = t(p, g, l.cardNumber) : p === "phoneNumber" ? h = t(
842
+ p,
843
+ g,
844
844
  void 0,
845
845
  l.phoneCountryCode
846
- ) : h = t(u, f), h && (g[u] = h);
846
+ ) : h = t(p, g), h && (u[p] = h);
847
847
  }), [
848
848
  "billingAddress",
849
849
  "shippingAddress"
850
- ].forEach((u) => {
851
- const f = l[u];
852
- if (f && typeof f == "object") {
850
+ ].forEach((p) => {
851
+ const g = l[p];
852
+ if (g && typeof g == "object") {
853
853
  const h = {};
854
- Object.keys(f).forEach(
855
- (y) => {
856
- const v = f[y];
857
- if (v === void 0) return;
858
- const S = i[y];
854
+ Object.keys(g).forEach(
855
+ (v) => {
856
+ const f = g[v];
857
+ if (f === void 0) return;
858
+ const S = i[v];
859
859
  if (S) {
860
- const M = S(v);
861
- M && (h[y] = M);
860
+ const C = v === "state" ? i.state(f, g.country) : S(
861
+ f
862
+ );
863
+ C && (h[v] = C);
862
864
  }
863
865
  }
864
- ), Object.keys(h).length > 0 && (g[u] = h);
866
+ ), Object.keys(h).length > 0 && (u[p] = h);
865
867
  }
866
- }), g;
868
+ }), u;
867
869
  }, a = (l) => {
868
- const g = s(l);
869
- return Object.keys(g).length === 0;
870
+ const u = s(l);
871
+ return Object.keys(u).length === 0;
870
872
  }, n = "billingAddress.", r = "shippingAddress.", o = (l) => l.startsWith(n) ? {
871
873
  parent: "billingAddress",
872
874
  field: l.slice(n.length)
873
875
  } : l.startsWith(r) ? {
874
876
  parent: "shippingAddress",
875
877
  field: l.slice(r.length)
876
- } : null, d = (l, g, m, u) => {
877
- const f = { ...l };
878
- if (u)
879
- f[g] = {
880
- ...f[g],
881
- [m]: u
878
+ } : null, d = (l, u, y, p) => {
879
+ const g = { ...l };
880
+ if (p)
881
+ g[u] = {
882
+ ...g[u],
883
+ [y]: p
882
884
  };
883
885
  else {
884
886
  const h = {
885
- ...f[g]
887
+ ...g[u]
886
888
  };
887
- delete h[m], Object.keys(h).length === 0 ? delete f[g] : f[g] = h;
889
+ delete h[y], Object.keys(h).length === 0 ? delete g[u] : g[u] = h;
888
890
  }
889
- return f;
890
- }, c = (l, g) => {
891
- const m = e.getState();
892
- let u = g;
893
- const f = o(l);
894
- if (!f && l in U)
891
+ return g;
892
+ }, c = (l, u) => {
893
+ const y = e.getState();
894
+ let p = u;
895
+ const g = o(l);
896
+ if (!g && l in j)
895
897
  if (l === "cardCvv") {
896
- const S = fe(m.formData.cardNumber) === "amex" ? 4 : 3;
897
- u = U.cardCvv(g, S);
898
+ const S = ye(y.formData.cardNumber) === "amex" ? 4 : 3;
899
+ p = j.cardCvv(u, S);
898
900
  } else
899
- u = U[l](g);
901
+ p = j[l](u);
900
902
  let h;
901
- if (f) {
902
- const { parent: v, field: S } = f;
903
+ if (g) {
904
+ const { parent: f, field: S } = g;
903
905
  h = {
904
- ...m.formData,
905
- [v]: {
906
- ...m.formData[v] ?? {},
907
- [S]: u
906
+ ...y.formData,
907
+ [f]: {
908
+ ...y.formData[f] ?? {},
909
+ [S]: p
908
910
  }
909
911
  };
910
912
  } else
911
913
  h = {
912
- ...m.formData,
913
- [l]: u
914
+ ...y.formData,
915
+ [l]: p
914
916
  };
915
- let y = { ...m.errors };
917
+ let v = { ...y.errors };
916
918
  if (l === "phoneCountryCode" && h.phoneNumber) {
917
- const v = t(
919
+ const f = t(
918
920
  "phoneNumber",
919
921
  h.phoneNumber,
920
922
  void 0,
921
- u
923
+ p
922
924
  );
923
- v ? y.phoneNumber = v : delete y.phoneNumber;
925
+ f ? v.phoneNumber = f : delete v.phoneNumber;
924
926
  }
925
- if (m.touched[l])
926
- if (f) {
927
- const { parent: v, field: S } = f, M = i[S], x = M ? M(
928
- u
929
- ) : void 0;
930
- y = d(y, v, S, x);
927
+ if (y.touched[l])
928
+ if (g) {
929
+ const { parent: f, field: S } = g, C = h[f];
930
+ let N;
931
+ if (S === "state")
932
+ N = i.state(p, C?.country);
933
+ else {
934
+ const A = i[S];
935
+ N = A ? A(
936
+ p
937
+ ) : void 0;
938
+ }
939
+ v = d(v, f, S, N);
931
940
  } else {
932
- let v;
933
- l === "cardCvv" ? v = t(l, u, h.cardNumber) : l === "phoneNumber" ? v = t(
941
+ let f;
942
+ l === "cardCvv" ? f = t(l, p, h.cardNumber) : l === "phoneNumber" ? f = t(
934
943
  l,
935
- u,
944
+ p,
936
945
  void 0,
937
946
  h.phoneCountryCode
938
- ) : v = t(l, u), v ? y[l] = v : delete y[l];
947
+ ) : f = t(l, p), f ? v[l] = f : delete v[l];
939
948
  }
940
949
  e.setState({
941
950
  formData: h,
942
- errors: y,
951
+ errors: v,
943
952
  isValid: a(h)
944
953
  });
945
- }, p = (l, g) => {
946
- const m = e.getState(), u = o(l);
947
- if (u) {
948
- const { parent: v, field: S } = u, M = {
949
- ...m.formData,
950
- [v]: {
951
- ...m.formData[v] ?? {},
952
- [S]: g
954
+ }, m = (l, u) => {
955
+ const y = e.getState(), p = o(l);
956
+ if (p) {
957
+ const { parent: f, field: S } = p, C = {
958
+ ...y.formData,
959
+ [f]: {
960
+ ...y.formData[f] ?? {},
961
+ [S]: u
953
962
  }
954
- }, x = i[S], ue = x ? x(g) : void 0, me = d(m.errors, v, S, ue);
963
+ };
964
+ let N;
965
+ if (S === "state") {
966
+ const L = C[f];
967
+ N = i.state(u, L?.country);
968
+ } else {
969
+ const L = i[S];
970
+ N = L ? L(u) : void 0;
971
+ }
972
+ const A = d(y.errors, f, S, N);
955
973
  e.setState({
956
- formData: M,
974
+ formData: C,
957
975
  touched: {
958
- ...m.touched,
976
+ ...y.touched,
959
977
  [l]: !0
960
978
  },
961
- errors: me,
962
- isValid: a(M)
979
+ errors: A,
980
+ isValid: a(C)
963
981
  });
964
982
  return;
965
983
  }
966
- const f = {
967
- ...m.touched,
984
+ const g = {
985
+ ...y.touched,
968
986
  [l]: !0
969
987
  };
970
988
  let h;
971
- l === "cardCvv" ? h = t(l, g, m.formData.cardNumber) : l === "phoneNumber" ? h = t(
989
+ l === "cardCvv" ? h = t(l, u, y.formData.cardNumber) : l === "phoneNumber" ? h = t(
972
990
  l,
973
- g,
991
+ u,
974
992
  void 0,
975
- m.formData.phoneCountryCode
976
- ) : h = t(l, g);
977
- const y = { ...m.errors };
978
- h ? y[l] = h : delete y[l], e.setState({
979
- touched: f,
980
- errors: y
993
+ y.formData.phoneCountryCode
994
+ ) : h = t(l, u);
995
+ const v = { ...y.errors };
996
+ h ? v[l] = h : delete v[l], e.setState({
997
+ touched: g,
998
+ errors: v
981
999
  });
982
1000
  }, b = (l) => {
983
- const m = {
1001
+ const y = {
984
1002
  ...e.getState().formData,
985
1003
  ...l
986
1004
  };
987
1005
  e.setState({
988
- formData: m,
989
- isValid: a(m)
1006
+ formData: y,
1007
+ isValid: a(y)
990
1008
  });
991
1009
  };
992
1010
  return {
993
1011
  getFormState: e.getState.bind(e),
994
1012
  subscribe: e.subscribe.bind(e),
995
1013
  handleChange: c,
996
- handleBlur: p,
1014
+ handleBlur: m,
997
1015
  setFormData: b,
998
1016
  reset: e.resetState.bind(e)
999
1017
  };
1000
- }, dt = "https://fonts.googleapis.com/css2", ct = /src:\s*url\(([^)]+\.woff2[^)]*)\)/, ht = /\/\*\s*latin\s*\*\/\s*@font-face\s*\{[^}]*src:\s*url\(([^)]+\.woff2[^)]*)\)[^}]*\}/;
1001
- async function ut(i) {
1018
+ }, ct = "https://fonts.googleapis.com/css2", ht = /src:\s*url\(([^)]+\.woff2[^)]*)\)/, ut = /\/\*\s*latin\s*\*\/\s*@font-face\s*\{[^}]*src:\s*url\(([^)]+\.woff2[^)]*)\)[^}]*\}/;
1019
+ async function mt(i) {
1002
1020
  if (!i) return null;
1003
- const e = i.trim().replace(/\s+/g, "+"), t = `${dt}?family=${e}:wght@400;700&display=swap`;
1021
+ const e = i.trim().replace(/\s+/g, "+"), t = `${ct}?family=${e}:wght@400;700&display=swap`;
1004
1022
  try {
1005
1023
  const s = await fetch(t);
1006
1024
  if (!s.ok) return null;
1007
- const a = await s.text(), n = ht.exec(a);
1025
+ const a = await s.text(), n = ut.exec(a);
1008
1026
  if (n?.[1]) return n[1];
1009
- const r = ct.exec(a);
1027
+ const r = ht.exec(a);
1010
1028
  return r?.[1] ? r[1] : null;
1011
1029
  } catch {
1012
1030
  return null;
1013
1031
  }
1014
1032
  }
1015
- function mt(i) {
1033
+ function pt(i) {
1016
1034
  if (!i) return !1;
1017
1035
  const { billingFields: e, shippingFields: t } = i, s = e && Object.values(e).some((n) => n?.enabled), a = t && Object.values(t).some((n) => n?.enabled);
1018
1036
  return !!(s || a);
1019
1037
  }
1020
- function W(i) {
1038
+ function Z(i) {
1021
1039
  if (!i) return !1;
1022
1040
  const { billingFields: e, shippingFields: t } = i, s = e?.firstName?.enabled && e?.lastName?.enabled, a = t?.firstName?.enabled && t?.lastName?.enabled;
1023
1041
  return !!(s || a);
1024
1042
  }
1025
- class re extends P {
1043
+ const U = /* @__PURE__ */ new Set(["US", "CA"]);
1044
+ class de extends k {
1026
1045
  inputs = /* @__PURE__ */ new Map();
1027
1046
  type;
1028
1047
  onChange;
@@ -1030,8 +1049,11 @@ class re extends P {
1030
1049
  fieldsContainer;
1031
1050
  translationFunc;
1032
1051
  locale;
1033
- stateOptions;
1034
1052
  grouped;
1053
+ currentCountry = "";
1054
+ stateRow = null;
1055
+ stateFieldConfig;
1056
+ stateStyles;
1035
1057
  constructor(e) {
1036
1058
  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;
1037
1059
  const { title: t, checkoutProfile: s, fieldsConfig: a, values: n, errors: r, touched: o } = e;
@@ -1064,55 +1086,55 @@ class re extends P {
1064
1086
  t.street?.enabled && d.push({ kind: "street" });
1065
1087
  const c = [];
1066
1088
  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" });
1067
- const p = [];
1068
- t.city?.enabled && p.push("city"), t.zipCode?.enabled && p.push("zipCode"), p.length > 0 && d.push({ kind: "cityZip", fields: p }), t.state?.enabled && d.push({ kind: "state" });
1089
+ const m = [];
1090
+ 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" });
1069
1091
  const b = d.length;
1070
- d.forEach((l, g) => {
1071
- const m = g === 0, u = g === b - 1, f = (h, y) => ({
1092
+ d.forEach((l, u) => {
1093
+ const y = u === 0, p = u === b - 1, g = (h, v) => ({
1072
1094
  ...o,
1073
1095
  borderRadius: this.borderRadius(
1074
1096
  r,
1075
- m && h,
1076
- m && y,
1077
- u && y,
1078
- u && h
1097
+ y && h,
1098
+ y && v,
1099
+ p && v,
1100
+ p && h
1079
1101
  )
1080
1102
  });
1081
1103
  if (l.kind === "street") {
1082
- const h = this.createRow(["full"]), y = this.createInput(
1104
+ const h = this.createRow(["full"]), v = this.createInput(
1083
1105
  "street",
1084
1106
  t.street?.label ?? this.translationFunc("address.addressLine1"),
1085
1107
  s.street,
1086
1108
  a.street,
1087
1109
  n.street,
1088
- f(!0, !0),
1110
+ g(!0, !0),
1089
1111
  "street-address"
1090
1112
  );
1091
- this.inputs.set("street", y), h.appendChild(y.getElement()), this.fieldsContainer.appendChild(h);
1113
+ this.inputs.set("street", v), h.appendChild(v.getElement()), this.fieldsContainer.appendChild(h);
1092
1114
  return;
1093
1115
  }
1094
1116
  if (l.kind === "name") {
1095
- const h = this.createRow(l.fields.map(() => "half")), y = l.fields.length === 1;
1117
+ const h = this.createRow(l.fields.map(() => "half")), v = l.fields.length === 1;
1096
1118
  if (l.fields.includes("firstName")) {
1097
- const v = y || l.fields[l.fields.length - 1] === "firstName", S = this.createInput(
1119
+ const f = v || l.fields[l.fields.length - 1] === "firstName", S = this.createInput(
1098
1120
  "firstName",
1099
1121
  t.firstName?.label ?? this.translationFunc("address.firstName"),
1100
1122
  s.firstName,
1101
1123
  a.firstName,
1102
1124
  n.firstName,
1103
- f(!0, v),
1125
+ g(!0, f),
1104
1126
  "given-name"
1105
1127
  );
1106
1128
  this.inputs.set("firstName", S), h.appendChild(S.getElement());
1107
1129
  }
1108
1130
  if (l.fields.includes("lastName")) {
1109
- const v = y || l.fields[0] === "lastName", S = this.createInput(
1131
+ const f = v || l.fields[0] === "lastName", S = this.createInput(
1110
1132
  "lastName",
1111
1133
  t.lastName?.label ?? this.translationFunc("address.lastName"),
1112
1134
  s.lastName,
1113
1135
  a.lastName,
1114
1136
  n.lastName,
1115
- f(v, !0),
1137
+ g(f, !0),
1116
1138
  "family-name"
1117
1139
  );
1118
1140
  this.inputs.set("lastName", S), h.appendChild(S.getElement());
@@ -1121,39 +1143,39 @@ class re extends P {
1121
1143
  return;
1122
1144
  }
1123
1145
  if (l.kind === "country") {
1124
- const h = this.createRow(["full"]), y = this.createCountrySelect(
1146
+ const h = this.createRow(["full"]), v = this.createCountrySelect(
1125
1147
  s.country,
1126
1148
  a.country,
1127
1149
  n.country,
1128
- f(!0, !0),
1150
+ g(!0, !0),
1129
1151
  t.country?.options,
1130
1152
  t.country?.label
1131
1153
  );
1132
- this.inputs.set("country", y), h.appendChild(y.getElement()), this.fieldsContainer.appendChild(h);
1154
+ this.inputs.set("country", v), h.appendChild(v.getElement()), this.fieldsContainer.appendChild(h);
1133
1155
  return;
1134
1156
  }
1135
1157
  if (l.kind === "cityZip") {
1136
- const h = this.createRow(l.fields.map(() => "half")), y = l.fields.length === 1;
1158
+ const h = this.createRow(l.fields.map(() => "half")), v = l.fields.length === 1;
1137
1159
  if (l.fields.includes("city")) {
1138
- const v = y || l.fields[l.fields.length - 1] === "city", S = this.createInput(
1160
+ const f = v || l.fields[l.fields.length - 1] === "city", S = this.createInput(
1139
1161
  "city",
1140
1162
  t.city?.label ?? this.translationFunc("address.townCity"),
1141
1163
  s.city,
1142
1164
  a.city,
1143
1165
  n.city,
1144
- f(!0, v),
1166
+ g(!0, f),
1145
1167
  "address-level2"
1146
1168
  );
1147
1169
  this.inputs.set("city", S), h.appendChild(S.getElement());
1148
1170
  }
1149
1171
  if (l.fields.includes("zipCode")) {
1150
- const v = y || l.fields[0] === "zipCode", S = this.createInput(
1172
+ const f = v || l.fields[0] === "zipCode", S = this.createInput(
1151
1173
  "zipCode",
1152
1174
  t.zipCode?.label ?? this.translationFunc("address.postalCode"),
1153
1175
  s.zipCode,
1154
1176
  a.zipCode,
1155
1177
  n.zipCode,
1156
- f(v, !0),
1178
+ g(f, !0),
1157
1179
  "postal-code"
1158
1180
  );
1159
1181
  this.inputs.set("zipCode", S), h.appendChild(S.getElement());
@@ -1163,28 +1185,29 @@ class re extends P {
1163
1185
  }
1164
1186
  if (l.kind === "state") {
1165
1187
  const h = this.createRow(["full"]);
1166
- if (this.stateOptions = t.state?.options, t.state?.options && t.state.options.length > 0) {
1167
- const v = this.createStateSelect(
1188
+ if (this.stateFieldConfig = t.state, this.stateRow = h, this.stateStyles = g(!0, !0), this.currentCountry = s.country, t.state?.hiddenForCountries?.includes(
1189
+ s.country
1190
+ ) && (h.style.display = "none"), U.has(s.country)) {
1191
+ const S = this.createStateSelect(
1168
1192
  s.state,
1169
1193
  a.state,
1170
1194
  n.state,
1171
- f(!0, !0),
1172
- t.state?.options,
1195
+ this.stateStyles,
1173
1196
  s.country,
1174
1197
  t.state?.label
1175
1198
  );
1176
- this.inputs.set("state", v), h.appendChild(v.getElement());
1199
+ this.inputs.set("state", S), h.appendChild(S.getElement());
1177
1200
  } else {
1178
- const v = this.createInput(
1201
+ const S = this.createInput(
1179
1202
  "state",
1180
- t.state?.label ?? this.translationFunc("address.chooseState"),
1203
+ t.state?.label ?? this.translationFunc("address.state"),
1181
1204
  s.state,
1182
1205
  a.state,
1183
1206
  n.state,
1184
- f(!0, !0),
1207
+ this.stateStyles,
1185
1208
  "address-level1"
1186
1209
  );
1187
- this.inputs.set("state", v), h.appendChild(v.getElement());
1210
+ this.inputs.set("state", S), h.appendChild(S.getElement());
1188
1211
  }
1189
1212
  this.fieldsContainer.appendChild(h);
1190
1213
  }
@@ -1195,7 +1218,7 @@ class re extends P {
1195
1218
  return t.className = `address-row address-row-${e.length === 1 ? "single" : "double"}`, t;
1196
1219
  }
1197
1220
  createInput(e, t, s, a, n, r, o) {
1198
- const d = `${this.type}Address.${e}`, c = new ce({
1221
+ const d = `${this.type}Address.${e}`, c = new me({
1199
1222
  name: d,
1200
1223
  error: !1,
1201
1224
  errorMsg: void 0,
@@ -1203,37 +1226,37 @@ class re extends P {
1203
1226
  ...this.grouped ? { placeholder: t } : {
1204
1227
  label: t,
1205
1228
  placeholder: (() => {
1206
- const p = `address.placeholder.${e}`, b = this.translationFunc(p);
1207
- return b !== p ? b : t;
1229
+ const m = `address.placeholder.${e}`, b = this.translationFunc(m);
1230
+ return b !== m ? b : t;
1208
1231
  })()
1209
1232
  },
1210
1233
  value: s,
1211
1234
  autocomplete: o,
1212
- onChange: (p) => {
1235
+ onChange: (m) => {
1213
1236
  c.setError(!1);
1214
1237
  const b = new Event("input", { bubbles: !0 });
1215
1238
  Object.defineProperty(b, "target", {
1216
1239
  writable: !1,
1217
1240
  value: {
1218
1241
  name: d,
1219
- value: p.target.value
1242
+ value: m.target.value
1220
1243
  }
1221
1244
  }), this.onChange(b);
1222
1245
  }
1223
1246
  });
1224
- return c.addEventListener("blur", (p) => {
1247
+ return c.addEventListener("blur", (m) => {
1225
1248
  const b = new Event("blur", { bubbles: !0 });
1226
1249
  Object.defineProperty(b, "target", {
1227
1250
  writable: !1,
1228
1251
  value: {
1229
1252
  name: d,
1230
- value: p.target.value
1253
+ value: m.target.value
1231
1254
  }
1232
1255
  }), this.onBlur(b);
1233
1256
  }), c;
1234
1257
  }
1235
1258
  createCountrySelect(e, t, s, a, n, r) {
1236
- const o = `${this.type}Address.country`, d = ye(n, this.locale), c = new H({
1259
+ const o = `${this.type}Address.country`, d = be(n, this.locale), c = new V({
1237
1260
  name: o,
1238
1261
  error: !1,
1239
1262
  errorMsg: void 0,
@@ -1245,70 +1268,125 @@ class re extends P {
1245
1268
  value: e,
1246
1269
  options: d,
1247
1270
  autocomplete: "country",
1248
- onChange: (p) => {
1271
+ onChange: (m) => {
1249
1272
  c.setError(!1);
1250
- const b = p.target.value;
1251
- this.updateStateOptionsForCountry(b);
1252
- const l = new Event("change", { bubbles: !0 });
1273
+ const b = m.target.value, l = new Event("change", { bubbles: !0 });
1253
1274
  Object.defineProperty(l, "target", {
1254
1275
  writable: !1,
1255
1276
  value: {
1256
1277
  name: o,
1257
1278
  value: b
1258
1279
  }
1259
- }), this.onChange(l);
1280
+ }), this.onChange(l), this.handleCountryChange(b);
1260
1281
  }
1261
1282
  });
1262
- return c.addEventListener("blur", (p) => {
1283
+ return c.addEventListener("blur", (m) => {
1263
1284
  const b = new Event("blur", { bubbles: !0 });
1264
1285
  Object.defineProperty(b, "target", {
1265
1286
  writable: !1,
1266
1287
  value: {
1267
1288
  name: o,
1268
- value: p.target.value
1289
+ value: m.target.value
1269
1290
  }
1270
1291
  }), this.onBlur(b);
1271
1292
  }), c;
1272
1293
  }
1273
- updateStateOptionsForCountry(e) {
1294
+ handleCountryChange(e) {
1295
+ const t = this.currentCountry;
1296
+ if (this.currentCountry = e, !this.stateRow || !this.stateFieldConfig?.enabled) return;
1297
+ const s = this.stateFieldConfig.hiddenForCountries?.includes(t), a = this.stateFieldConfig.hiddenForCountries?.includes(e);
1298
+ if (a && !s) {
1299
+ this.stateRow.style.display = "none", this.clearStateValue();
1300
+ return;
1301
+ }
1302
+ if (!a && s && (this.stateRow.style.display = ""), a) return;
1303
+ const n = this.inputs.get("state") instanceof V, r = U.has(e);
1304
+ if (n && r) {
1305
+ const o = this.inputs.get("state");
1306
+ if (o instanceof V) {
1307
+ const d = e === "CA" ? "CA" : "US", c = Q(d), m = d === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState");
1308
+ o.setOptions(c, m);
1309
+ }
1310
+ this.clearStateValue();
1311
+ return;
1312
+ }
1313
+ if (n !== r) {
1314
+ this.rebuildStateField(e), this.clearStateValue();
1315
+ return;
1316
+ }
1317
+ !n && !r && t !== e && this.clearStateValue();
1318
+ }
1319
+ rebuildStateField(e) {
1320
+ if (!this.stateRow || !this.stateStyles) return;
1274
1321
  const t = this.inputs.get("state");
1275
- if (!(t instanceof H)) return;
1276
- const s = e === "CA" ? "CA" : "US", a = Z(this.stateOptions, s), n = s === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState");
1277
- t.setOptions(a, n);
1322
+ if (t && (t.getElement().remove(), this.inputs.delete("state")), U.has(e)) {
1323
+ const a = this.createStateSelect(
1324
+ "",
1325
+ void 0,
1326
+ void 0,
1327
+ this.stateStyles,
1328
+ e,
1329
+ this.stateFieldConfig?.label
1330
+ );
1331
+ this.inputs.set("state", a), this.stateRow.appendChild(a.getElement());
1332
+ } else {
1333
+ const a = this.createInput(
1334
+ "state",
1335
+ this.stateFieldConfig?.label ?? this.translationFunc("address.state"),
1336
+ "",
1337
+ void 0,
1338
+ void 0,
1339
+ this.stateStyles,
1340
+ "address-level1"
1341
+ );
1342
+ this.inputs.set("state", a), this.stateRow.appendChild(a.getElement());
1343
+ }
1278
1344
  }
1279
- createStateSelect(e, t, s, a, n, r, o) {
1280
- const d = `${this.type}Address.state`, c = r === "CA" ? "CA" : "US", p = Z(n, c), b = c === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState"), l = new H({
1281
- name: d,
1345
+ clearStateValue() {
1346
+ const e = this.inputs.get("state");
1347
+ e && e.setValue("");
1348
+ const t = `${this.type}Address.state`, s = new CustomEvent("input", {
1349
+ bubbles: !0,
1350
+ detail: { programmatic: !0 }
1351
+ });
1352
+ Object.defineProperty(s, "target", {
1353
+ writable: !1,
1354
+ value: { name: t, value: "" }
1355
+ }), this.onChange(s);
1356
+ }
1357
+ createStateSelect(e, t, s, a, n, r) {
1358
+ const o = `${this.type}Address.state`, d = n === "CA" ? "CA" : "US", c = Q(d), m = d === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState"), b = new V({
1359
+ name: o,
1282
1360
  error: !1,
1283
1361
  errorMsg: void 0,
1284
1362
  styles: a,
1285
- placeholder: b,
1286
- ...!this.grouped && { label: o ?? b },
1363
+ placeholder: m,
1364
+ ...!this.grouped && { label: r ?? m },
1287
1365
  value: e,
1288
- options: p,
1366
+ options: c,
1289
1367
  autocomplete: "address-level1",
1290
- onChange: (g) => {
1291
- l.setError(!1);
1292
- const m = new Event("change", { bubbles: !0 });
1293
- Object.defineProperty(m, "target", {
1368
+ onChange: (l) => {
1369
+ b.setError(!1);
1370
+ const u = new Event("change", { bubbles: !0 });
1371
+ Object.defineProperty(u, "target", {
1294
1372
  writable: !1,
1295
1373
  value: {
1296
- name: d,
1297
- value: g.target.value
1374
+ name: o,
1375
+ value: l.target.value
1298
1376
  }
1299
- }), this.onChange(m);
1377
+ }), this.onChange(u);
1300
1378
  }
1301
1379
  });
1302
- return l.addEventListener("blur", (g) => {
1303
- const m = new Event("blur", { bubbles: !0 });
1304
- Object.defineProperty(m, "target", {
1380
+ return b.addEventListener("blur", (l) => {
1381
+ const u = new Event("blur", { bubbles: !0 });
1382
+ Object.defineProperty(u, "target", {
1305
1383
  writable: !1,
1306
1384
  value: {
1307
- name: d,
1308
- value: g.target.value
1385
+ name: o,
1386
+ value: l.target.value
1309
1387
  }
1310
- }), this.onBlur(m);
1311
- }), l;
1388
+ }), this.onBlur(u);
1389
+ }), b;
1312
1390
  }
1313
1391
  createUngroupedFields(e, t, s, a, n) {
1314
1392
  const r = e.styles.borderRadius, o = {
@@ -1316,9 +1394,9 @@ class re extends P {
1316
1394
  fontSize: e.styles.fontSize,
1317
1395
  fontFamily: e.styles.fontFamily,
1318
1396
  borderRadius: `${r}px`
1319
- }, d = (c, p, b) => {
1397
+ }, d = (c, m, b) => {
1320
1398
  if (!t[c]?.enabled) return;
1321
- const l = t[c]?.label ?? this.translationFunc(p), g = this.createRow(["full"]), m = this.createInput(
1399
+ const l = t[c]?.label ?? this.translationFunc(m), u = this.createRow(["full"]), y = this.createInput(
1322
1400
  c,
1323
1401
  l,
1324
1402
  s[c],
@@ -1327,10 +1405,10 @@ class re extends P {
1327
1405
  o,
1328
1406
  b
1329
1407
  );
1330
- this.inputs.set(c, m), g.appendChild(m.getElement()), this.fieldsContainer.appendChild(g);
1408
+ this.inputs.set(c, y), u.appendChild(y.getElement()), this.fieldsContainer.appendChild(u);
1331
1409
  };
1332
1410
  if (d("firstName", "address.firstName", "given-name"), d("lastName", "address.lastName", "family-name"), d("street", "address.addressLine1", "street-address"), d("city", "address.townCity", "address-level2"), t.country?.enabled) {
1333
- const c = t.country?.label ?? this.translationFunc("address.chooseCountry"), p = this.createRow(["full"]), b = this.createCountrySelect(
1411
+ const c = t.country?.label ?? this.translationFunc("address.chooseCountry"), m = this.createRow(["full"]), b = this.createCountrySelect(
1334
1412
  s.country,
1335
1413
  a.country,
1336
1414
  n.country,
@@ -1338,33 +1416,36 @@ class re extends P {
1338
1416
  t.country?.options,
1339
1417
  c
1340
1418
  );
1341
- this.inputs.set("country", b), p.appendChild(b.getElement()), this.fieldsContainer.appendChild(p);
1419
+ this.inputs.set("country", b), m.appendChild(b.getElement()), this.fieldsContainer.appendChild(m);
1342
1420
  }
1343
1421
  if (t.state?.enabled) {
1344
- this.stateOptions = t.state?.options;
1345
- const c = this.createRow(["full"]), p = t.state?.options && t.state.options.length > 0, b = t.state?.label ?? this.translationFunc("address.chooseState");
1346
- if (p) {
1347
- const l = this.createStateSelect(
1422
+ this.stateFieldConfig = t.state;
1423
+ const c = this.createRow(["full"]);
1424
+ this.stateRow = c, this.stateStyles = o, this.currentCountry = s.country, t.state?.hiddenForCountries?.includes(
1425
+ s.country
1426
+ ) && (c.style.display = "none");
1427
+ const b = U.has(s.country), l = t.state?.label ?? this.translationFunc("address.state");
1428
+ if (b) {
1429
+ const u = this.createStateSelect(
1348
1430
  s.state,
1349
1431
  a.state,
1350
1432
  n.state,
1351
1433
  o,
1352
- t.state?.options,
1353
1434
  s.country,
1354
- b
1435
+ l
1355
1436
  );
1356
- this.inputs.set("state", l), c.appendChild(l.getElement());
1437
+ this.inputs.set("state", u), c.appendChild(u.getElement());
1357
1438
  } else {
1358
- const l = this.createInput(
1439
+ const u = this.createInput(
1359
1440
  "state",
1360
- b,
1441
+ l,
1361
1442
  s.state,
1362
1443
  a.state,
1363
1444
  n.state,
1364
1445
  o,
1365
1446
  "address-level1"
1366
1447
  );
1367
- this.inputs.set("state", l), c.appendChild(l.getElement());
1448
+ this.inputs.set("state", u), c.appendChild(u.getElement());
1368
1449
  }
1369
1450
  this.fieldsContainer.appendChild(c);
1370
1451
  }
@@ -1401,12 +1482,11 @@ class re extends P {
1401
1482
  }
1402
1483
  updateField(e, t, s, a) {
1403
1484
  const n = this.inputs.get(e);
1404
- if (n) {
1405
- const o = n.getElement().querySelector("input") || n.getElement().querySelector("select"), d = n.getValue();
1406
- !(document.activeElement === o) && !(t === "" && d !== "") && this.setValue(e, t);
1407
- }
1408
- const r = !!(a && s);
1409
- this.setError(e, r, s);
1485
+ if (!n) return;
1486
+ const r = n.getElement().querySelector("input") || n.getElement().querySelector("select"), o = n.getValue();
1487
+ !(document.activeElement === r) && !(t === "" && o !== "") && this.setValue(e, t);
1488
+ const m = !!(a && s);
1489
+ this.setError(e, m, s);
1410
1490
  }
1411
1491
  updateAllFields(e, t, s) {
1412
1492
  Object.keys(e).forEach((a) => {
@@ -1423,7 +1503,7 @@ class re extends P {
1423
1503
  e && e.focus();
1424
1504
  }
1425
1505
  }
1426
- class pt {
1506
+ class gt {
1427
1507
  input = null;
1428
1508
  isVgsMode;
1429
1509
  vgsWrapper = null;
@@ -1457,10 +1537,10 @@ class pt {
1457
1537
  const n = document.createElement("label");
1458
1538
  n.className = "input-label", n.textContent = t("cardholderNameLabel"), n.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.appendChild(n), this.wrapperElement.appendChild(a), this.vgsWrapper = document.createElement("div"), this.vgsWrapper.className = "vgs-wrap", this.vgsWrapper.style.position = "relative", this.vgsWrapper.style.borderRadius = `${s}px`, this.vgsWrapper.style.height = "38.5px", this.vgsWrapper.style.width = "100%", this.vgsWrapper.style.overflow = "hidden", this.vgsWrapper.style.background = "#fff", this.vgsWrapper.style.boxShadow = "none";
1459
1539
  const r = document.createElement("div");
1460
- 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 be({ visible: !1 }), this.wrapperElement.appendChild(this.vgsHelperText.getElement());
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 ve({ visible: !1 }), this.wrapperElement.appendChild(this.vgsHelperText.getElement());
1461
1541
  }
1462
1542
  buildNativeLayout(e, t, s, a, n, r, o) {
1463
- this.input = new ce({
1543
+ this.input = new me({
1464
1544
  name: "name",
1465
1545
  label: r("cardholderNameLabel"),
1466
1546
  error: !1,
@@ -1475,8 +1555,8 @@ class pt {
1475
1555
  value: e,
1476
1556
  autocomplete: o,
1477
1557
  onChange: (d) => {
1478
- const p = d.target.value, b = p.replace(/[^a-zA-Z\s\-'.]/g, "");
1479
- p !== b && this.input?.setValue(b), this.input?.setError(!1), this.trim(), t(d);
1558
+ const m = d.target.value, b = m.replace(/[^a-zA-Z\s\-'.]/g, "");
1559
+ m !== b && this.input?.setValue(b), this.input?.setError(!1), this.trim(), t(d);
1480
1560
  }
1481
1561
  }), this.input.addEventListener("blur", (d) => {
1482
1562
  s(d);
@@ -1487,9 +1567,9 @@ class pt {
1487
1567
  }
1488
1568
  handleVgsStateChange(e, t) {
1489
1569
  if (!this.isVgsMode || !this.vgsWrapper) return;
1490
- const a = !!e[J.CARDHOLDER]?.isFocused;
1570
+ const a = !!e[ee.CARDHOLDER]?.isFocused;
1491
1571
  if (this.vgsWrapper.classList.toggle("vgs-wrap-focused", a), !t || !this.vgsHelperText) return;
1492
- const n = t[J.CARDHOLDER];
1572
+ const n = t[ee.CARDHOLDER];
1493
1573
  n ? (this.vgsHelperText.setText(n), this.vgsHelperText.toggleVisibility(!0)) : this.vgsHelperText.toggleVisibility(!1);
1494
1574
  }
1495
1575
  hideFakePlaceholder() {
@@ -1524,7 +1604,7 @@ class pt {
1524
1604
  this.isVgsMode || this.input?.focus();
1525
1605
  }
1526
1606
  }
1527
- class he extends P {
1607
+ class pe extends k {
1528
1608
  constructor() {
1529
1609
  super("div", ["skeleton-container"]), this.createSkeletonElements();
1530
1610
  }
@@ -1532,23 +1612,23 @@ class he extends P {
1532
1612
  this.appendChild(this.createPaymentMethodSkeleton()), this.appendChild(this.createPaymentSeparatorSkeleton());
1533
1613
  }
1534
1614
  createPaymentMethodSkeleton() {
1535
- const e = k.createDiv(["skeleton-field"]), t = k.createDiv([
1615
+ const e = D.createDiv(["skeleton-field"]), t = D.createDiv([
1536
1616
  "skeleton",
1537
1617
  "skeleton-payment-method"
1538
1618
  ]);
1539
1619
  return e.appendChild(t), e;
1540
1620
  }
1541
1621
  createPaymentSeparatorSkeleton() {
1542
- const e = k.createDiv([
1622
+ const e = D.createDiv([
1543
1623
  "payment-separator_container"
1544
- ]), t = k.createDiv(["payment-separator__line"]), s = k.createDiv([
1624
+ ]), t = D.createDiv(["payment-separator__line"]), s = D.createDiv([
1545
1625
  "skeleton",
1546
1626
  "skeleton-separator-text"
1547
- ]), a = k.createDiv(["payment-separator__line"]);
1627
+ ]), a = D.createDiv(["payment-separator__line"]);
1548
1628
  return e.appendChild(t), e.appendChild(s), e.appendChild(a), e;
1549
1629
  }
1550
1630
  }
1551
- class gt extends P {
1631
+ class ft extends k {
1552
1632
  constructor(e) {
1553
1633
  const { translationFunc: t, checkoutProfile: s } = e;
1554
1634
  super("div", ["payment-separator"]);
@@ -1560,7 +1640,7 @@ class gt extends P {
1560
1640
  o.className = "payment-separator__line", a.appendChild(n), a.appendChild(r), a.appendChild(o);
1561
1641
  }
1562
1642
  }
1563
- class ft extends P {
1643
+ class yt extends k {
1564
1644
  paymentMethods;
1565
1645
  paymentSeparator;
1566
1646
  skeleton;
@@ -1574,7 +1654,7 @@ class ft extends P {
1574
1654
  translationFunc: o,
1575
1655
  paymentId: d,
1576
1656
  checkoutKey: c,
1577
- checkoutDetails: p,
1657
+ checkoutDetails: m,
1578
1658
  environment: b,
1579
1659
  countryCode: l
1580
1660
  } = e;
@@ -1586,44 +1666,44 @@ class ft extends P {
1586
1666
  this.renderSkeleton();
1587
1667
  return;
1588
1668
  }
1589
- const g = Object.entries(
1669
+ const u = Object.entries(
1590
1670
  t.additionalPaymentMethods
1591
- ).filter(([m, u]) => {
1592
- const f = u.enabled, h = r ? r[m] === !0 : !0, y = !u.countries || l && u.countries.includes(l);
1593
- return f && h && y;
1594
- }).sort((m, u) => m[1].order - u[1].order);
1595
- if (g.length === 0) {
1671
+ ).filter(([y, p]) => {
1672
+ const g = p.enabled, h = r ? r[y] === !0 : !0, v = !p.countries || l && p.countries.includes(l);
1673
+ return g && h && v;
1674
+ }).sort((y, p) => y[1].order - p[1].order);
1675
+ if (u.length === 0) {
1596
1676
  this.getElement().style.display = "none";
1597
1677
  return;
1598
1678
  }
1599
- for (const [m] of g)
1600
- switch (m) {
1679
+ for (const [y] of u)
1680
+ switch (y) {
1601
1681
  case "paypal": {
1602
1682
  if (a) {
1603
- const u = new Se({
1683
+ const p = new Ee({
1604
1684
  checkoutProfile: t,
1605
1685
  formData: s,
1606
1686
  onSubmit: a
1607
1687
  });
1608
- this.paymentMethods.set("paypal", u), u.appendTo(this.getElement());
1688
+ this.paymentMethods.set("paypal", p), p.appendTo(this.getElement());
1609
1689
  }
1610
1690
  break;
1611
1691
  }
1612
1692
  case "applePay": {
1613
1693
  if (n && d && c) {
1614
- const u = t.appearance?.additionalPaymentMethods?.applePay, f = new ve({
1694
+ const p = t.appearance?.additionalPaymentMethods?.applePay, g = new Se({
1615
1695
  checkoutProfile: t,
1616
1696
  formData: s,
1617
1697
  onSubmit: n,
1618
1698
  paymentId: d,
1619
1699
  checkoutKey: c,
1620
- checkoutDetails: p,
1700
+ checkoutDetails: m,
1621
1701
  environment: b,
1622
- displayName: u?.displayName,
1623
- requiredBillingContactFields: u?.requiredBillingContactFields,
1624
- requiredShippingContactFields: u?.requiredShippingContactFields
1702
+ displayName: p?.displayName,
1703
+ requiredBillingContactFields: p?.requiredBillingContactFields,
1704
+ requiredShippingContactFields: p?.requiredShippingContactFields
1625
1705
  });
1626
- this.paymentMethods.set("applePay", f), f.appendTo(this.getElement());
1706
+ this.paymentMethods.set("applePay", g), g.appendTo(this.getElement());
1627
1707
  }
1628
1708
  break;
1629
1709
  }
@@ -1635,17 +1715,17 @@ class ft extends P {
1635
1715
  // break;
1636
1716
  default:
1637
1717
  console.warn(
1638
- `[PaymentMethods] Unsupported payment method: ${m}`
1718
+ `[PaymentMethods] Unsupported payment method: ${y}`
1639
1719
  );
1640
1720
  break;
1641
1721
  }
1642
- this.paymentMethods.size > 0 && (this.paymentSeparator = new gt({
1722
+ this.paymentMethods.size > 0 && (this.paymentSeparator = new ft({
1643
1723
  translationFunc: o,
1644
1724
  checkoutProfile: t
1645
1725
  }), this.getElement().appendChild(this.paymentSeparator.getElement()));
1646
1726
  }
1647
1727
  renderSkeleton() {
1648
- this.skeleton = new he(), this.getElement().appendChild(this.skeleton.getElement());
1728
+ this.skeleton = new pe(), this.getElement().appendChild(this.skeleton.getElement());
1649
1729
  }
1650
1730
  updateFormData(e) {
1651
1731
  const t = this.paymentMethods.get("paypal");
@@ -1657,8 +1737,8 @@ class ft extends P {
1657
1737
  return this.paymentMethods.size > 0 && this.getElement().style.display !== "none";
1658
1738
  }
1659
1739
  }
1660
- const yt = 17;
1661
- class bt extends P {
1740
+ const bt = 17;
1741
+ class vt extends k {
1662
1742
  styles;
1663
1743
  isHovered = !1;
1664
1744
  constructor(e) {
@@ -1668,7 +1748,7 @@ class bt extends P {
1668
1748
  }
1669
1749
  applyStyles() {
1670
1750
  const e = this.getElement();
1671
- 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 === yt ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
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 === bt ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
1672
1752
  }
1673
1753
  handleMouseEnter() {
1674
1754
  this.isHovered = !0, this.applyStyles();
@@ -1680,11 +1760,11 @@ class bt extends P {
1680
1760
  return this.getElement().disabled = e, e ? (this.addClass("disabled"), this.removeClass("valid")) : (this.removeClass("disabled"), this.addClass("valid")), this.applyStyles(), this;
1681
1761
  }
1682
1762
  }
1683
- class vt {
1763
+ class St {
1684
1764
  button;
1685
1765
  constructor(e) {
1686
1766
  const { disabled: t, checkoutProfile: s, translationFunc: a } = e;
1687
- this.button = new bt({
1767
+ this.button = new vt({
1688
1768
  text: a(
1689
1769
  `buttonTexts.${s?.layout.actionButton.translationKey}`
1690
1770
  ),
@@ -1711,7 +1791,7 @@ class vt {
1711
1791
  return this.button.appendTo(e), this;
1712
1792
  }
1713
1793
  }
1714
- class St {
1794
+ class Et {
1715
1795
  formElement;
1716
1796
  focusManager;
1717
1797
  translationFunc;
@@ -1757,7 +1837,7 @@ class St {
1757
1837
  (a) => a.enabled
1758
1838
  ))
1759
1839
  return;
1760
- this.paymentMethods = new ft({
1840
+ this.paymentMethods = new yt({
1761
1841
  checkoutProfile: e,
1762
1842
  formData: t,
1763
1843
  supportedPaymentMethods: this.supportedPaymentMethods,
@@ -1784,7 +1864,7 @@ class St {
1784
1864
  ) || e.layout.shippingFields && Object.values(e.layout.shippingFields).some(
1785
1865
  (r) => r?.enabled
1786
1866
  );
1787
- this.emailField = new Ee({
1867
+ this.emailField = new Ce({
1788
1868
  value: t.email,
1789
1869
  onChange: this.onChange,
1790
1870
  onBlur: this.onBlur,
@@ -1802,7 +1882,7 @@ class St {
1802
1882
  }
1803
1883
  createPhoneNumberField(e, t, s, a) {
1804
1884
  const n = document.createElement("div");
1805
- this.phonePlaceholder = n, this.formElement.appendChild(n), Ce().then(({ PhoneNumberField: r }) => {
1885
+ this.phonePlaceholder = n, this.formElement.appendChild(n), Fe().then(({ PhoneNumberField: r }) => {
1806
1886
  n.isConnected && (this.phoneNumberField = new r({
1807
1887
  value: t.phoneNumber ?? "",
1808
1888
  onChange: this.onChange,
@@ -1829,7 +1909,7 @@ class St {
1829
1909
  this.cardSectionSkeleton = this.buildCardSkeleton(e), this.formElement.appendChild(this.cardSectionSkeleton);
1830
1910
  return;
1831
1911
  }
1832
- if (this.cardSection = new Fe({
1912
+ if (this.cardSection = new Me({
1833
1913
  checkoutProfile: e,
1834
1914
  cardNumber: t.cardNumber,
1835
1915
  cardNumberError: s.cardNumber,
@@ -1885,7 +1965,7 @@ class St {
1885
1965
  this.cardholderSectionSkeleton = this.buildCardholderSkeleton(e), this.formElement.appendChild(this.cardholderSectionSkeleton);
1886
1966
  return;
1887
1967
  }
1888
- if (this.cardholderSection = new pt({
1968
+ if (this.cardholderSection = new gt({
1889
1969
  value: t.name,
1890
1970
  onChange: this.onChange,
1891
1971
  onBlur: this.onBlur,
@@ -1918,7 +1998,7 @@ class St {
1918
1998
  zipCode: "",
1919
1999
  country: ""
1920
2000
  };
1921
- this.billingAddressSection = new re({
2001
+ this.billingAddressSection = new de({
1922
2002
  type: "billing",
1923
2003
  title: this.translationFunc("address.billingTitle"),
1924
2004
  checkoutProfile: e,
@@ -1951,7 +2031,7 @@ class St {
1951
2031
  zipCode: "",
1952
2032
  country: ""
1953
2033
  };
1954
- this.shippingAddressSection = new re({
2034
+ this.shippingAddressSection = new de({
1955
2035
  type: "shipping",
1956
2036
  title: this.translationFunc("address.shippingTitle"),
1957
2037
  checkoutProfile: e,
@@ -1971,7 +2051,7 @@ class St {
1971
2051
  }
1972
2052
  createSubmitButton(e, t) {
1973
2053
  try {
1974
- this.submitButton = new vt({
2054
+ this.submitButton = new St({
1975
2055
  disabled: t,
1976
2056
  checkoutProfile: e,
1977
2057
  translationFunc: this.translationFunc
@@ -2040,8 +2120,8 @@ class St {
2040
2120
  d.style.display = "flex", d.style.gap = "8px";
2041
2121
  const c = document.createElement("div");
2042
2122
  c.style.position = "relative", c.style.flex = "1", c.style.height = "38.5px", c.style.overflow = "hidden", c.style.borderRadius = `${t}px`, c.appendChild(this.createSkeletonDiv()), d.appendChild(c);
2043
- const p = document.createElement("div");
2044
- return p.style.position = "relative", p.style.flex = "1", p.style.height = "38.5px", p.style.overflow = "hidden", p.style.borderRadius = `${t}px`, p.appendChild(this.createSkeletonDiv()), d.appendChild(p), r.appendChild(d), s.appendChild(r), s;
2123
+ const m = document.createElement("div");
2124
+ return m.style.position = "relative", m.style.flex = "1", m.style.height = "38.5px", m.style.overflow = "hidden", m.style.borderRadius = `${t}px`, m.appendChild(this.createSkeletonDiv()), d.appendChild(m), r.appendChild(d), s.appendChild(r), s;
2045
2125
  }
2046
2126
  createSkeletonDiv() {
2047
2127
  const e = document.createElement("div");
@@ -2058,7 +2138,7 @@ class St {
2058
2138
  async mountVgsFields(e) {
2059
2139
  if (!this.vgsService || !this.cardSection) return;
2060
2140
  await this.vgsService.whenReady();
2061
- const t = this.cardSection.getVgsContainerIds(), s = this.cardholderSection?.getVgsContainerId(), a = await ut(
2141
+ const t = this.cardSection.getVgsContainerIds(), s = this.cardholderSection?.getVgsContainerId(), a = await mt(
2062
2142
  e.styles.fontFamily
2063
2143
  ), n = this.cardSection.buildVgsFieldCss(
2064
2144
  e,
@@ -2118,7 +2198,7 @@ class St {
2118
2198
  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);
2119
2199
  }
2120
2200
  }
2121
- class Et {
2201
+ class Ct {
2122
2202
  formManager;
2123
2203
  focusManager;
2124
2204
  onFormSubmit;
@@ -2129,9 +2209,9 @@ class Et {
2129
2209
  }
2130
2210
  handleChange = (e) => {
2131
2211
  const t = e.target, { name: s, value: a } = t, n = s;
2132
- this.formManager.handleChange(n, a), this.localTouchedFields.has(n) || (this.localTouchedFields.add(n), this.formManager.handleBlur(n, a));
2133
- const { formData: r, errors: o, touched: d } = this.formManager.getFormState();
2134
- this.focusManager.handleStateUpdate(r, o, d);
2212
+ this.formManager.handleChange(n, a), e instanceof CustomEvent && e.detail?.programmatic ? this.localTouchedFields.delete(n) : this.localTouchedFields.has(n) || (this.localTouchedFields.add(n), this.formManager.handleBlur(n, a));
2213
+ const { formData: o, errors: d, touched: c } = this.formManager.getFormState();
2214
+ this.focusManager.handleStateUpdate(o, d, c);
2135
2215
  };
2136
2216
  handleBlur = (e) => {
2137
2217
  const t = e.target, { name: s, value: a } = t, n = s;
@@ -2159,7 +2239,7 @@ class Et {
2159
2239
  this.localTouchedFields.clear();
2160
2240
  }
2161
2241
  }
2162
- class Ct {
2242
+ class Ft {
2163
2243
  formManager;
2164
2244
  checkoutProfile;
2165
2245
  formElement;
@@ -2183,7 +2263,7 @@ class Ct {
2183
2263
  try {
2184
2264
  if (e.checkoutProfile.styles?.fontFamily)
2185
2265
  try {
2186
- const { cleanup: t } = Me({
2266
+ const { cleanup: t } = Ne({
2187
2267
  fontFamily: e.checkoutProfile.styles.fontFamily
2188
2268
  });
2189
2269
  this.fontCleanup = t, this.formElement.style.fontFamily = e.checkoutProfile.styles.fontFamily;
@@ -2200,15 +2280,17 @@ class Ct {
2200
2280
  };
2201
2281
  isFormDisabled() {
2202
2282
  const e = this.formManager.getFormState(), t = this.checkoutProfile.getState(), s = Object.keys(e.errors).filter(
2203
- (y) => y !== "billingAddress" && y !== "shippingAddress"
2204
- ).length > 0, a = e.errors.billingAddress, n = a && typeof a == "object" ? Object.keys(a).length > 0 : !1, r = e.errors.shippingAddress, o = r && typeof r == "object" ? Object.keys(r).length > 0 : !1, d = s || n || o, p = W(
2283
+ (f) => f !== "billingAddress" && f !== "shippingAddress"
2284
+ ).length > 0, a = e.errors.billingAddress, n = a && typeof a == "object" ? Object.keys(a).length > 0 : !1, r = e.errors.shippingAddress, o = r && typeof r == "object" ? Object.keys(r).length > 0 : !1, d = s || n || o, m = Z(
2205
2285
  t.checkoutProfile?.layout
2206
- ) ? !!(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: g, shippingFields: m } = t.checkoutProfile?.layout ?? {}, u = (y, v) => !y || Object.entries(y).every(
2207
- ([S, M]) => !M?.enabled || !!v?.[S]?.trim()
2208
- ), f = !this.isVgsMode || Object.values(this.vgsFieldsState).every(
2209
- (y) => y?.isValid === !0
2210
- ), h = this.isVgsMode ? !!e.formData.email && l && f && u(g, e.formData.billingAddress) && u(m, e.formData.shippingAddress) : !!e.formData.email && l && p && !!e.formData.cardNumber && !!e.formData.cardCvv && !!e.formData.cardExpiry && u(g, e.formData.billingAddress) && u(m, e.formData.shippingAddress);
2211
- return d || !h || this.isSubmitting;
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: u, shippingFields: y } = t.checkoutProfile?.layout ?? {}, p = /* @__PURE__ */ new Set(["US", "CA"]), g = (f, S) => {
2287
+ if (!f) return !0;
2288
+ const C = S?.country ?? "";
2289
+ return Object.entries(f).every(([N, A]) => !A?.enabled || N === "state" && (!p.has(C) || A.hiddenForCountries?.includes(C)) ? !0 : !!S?.[N]?.trim());
2290
+ }, h = !this.isVgsMode || Object.values(this.vgsFieldsState).every(
2291
+ (f) => f?.isValid === !0
2292
+ ), v = this.isVgsMode ? !!e.formData.email && l && h && g(u, e.formData.billingAddress) && g(y, e.formData.shippingAddress) : !!e.formData.email && l && m && !!e.formData.cardNumber && !!e.formData.cardCvv && !!e.formData.cardExpiry && g(u, e.formData.billingAddress) && g(y, e.formData.shippingAddress);
2293
+ return d || !v || this.isSubmitting;
2212
2294
  }
2213
2295
  setSubmitting(e) {
2214
2296
  this.isSubmitting = e;
@@ -2226,7 +2308,7 @@ class Ct {
2226
2308
  continue;
2227
2309
  const n = a.errors?.[0];
2228
2310
  if (!n) continue;
2229
- const r = Ne(s, n.code);
2311
+ const r = we(s, n.code);
2230
2312
  r && (t[s] = e(r));
2231
2313
  }
2232
2314
  return t;
@@ -2238,18 +2320,18 @@ class Ct {
2238
2320
  this.fontCleanup && (this.fontCleanup(), this.fontCleanup = void 0);
2239
2321
  }
2240
2322
  }
2241
- class Ft extends P {
2323
+ class Mt extends k {
2242
2324
  titleElement;
2243
2325
  constructor(e = {}) {
2244
2326
  super("div", ["blur-bg"]);
2245
- const t = k.createDiv(["loader"]);
2246
- this.titleElement = new P("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
2327
+ const t = D.createDiv(["loader"]);
2328
+ this.titleElement = new k("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
2247
2329
  }
2248
2330
  setText(e) {
2249
2331
  return this.titleElement.setText(e), this;
2250
2332
  }
2251
2333
  }
2252
- const oe = {
2334
+ const ce = {
2253
2335
  street: "",
2254
2336
  firstName: "",
2255
2337
  lastName: "",
@@ -2257,7 +2339,7 @@ const oe = {
2257
2339
  city: "",
2258
2340
  zipCode: "",
2259
2341
  country: ""
2260
- }, le = (i, e) => {
2342
+ }, he = (i, e) => {
2261
2343
  const t = {}, s = `${e}.`;
2262
2344
  return Object.keys(i).forEach((a) => {
2263
2345
  if (a.startsWith(s)) {
@@ -2266,7 +2348,7 @@ const oe = {
2266
2348
  }
2267
2349
  }), t;
2268
2350
  };
2269
- class Mt {
2351
+ class Nt {
2270
2352
  formElement;
2271
2353
  componentManager;
2272
2354
  onLoadingStateChange;
@@ -2300,13 +2382,13 @@ class Mt {
2300
2382
  !!(e.errors.name && e.touched.name),
2301
2383
  e.errors.name
2302
2384
  ), this.componentManager.updateBillingAddressSection(
2303
- e.formData.billingAddress ?? oe,
2385
+ e.formData.billingAddress ?? ce,
2304
2386
  e.errors.billingAddress ?? {},
2305
- le(e.touched, "billingAddress")
2387
+ he(e.touched, "billingAddress")
2306
2388
  ), this.componentManager.updateShippingAddressSection(
2307
- e.formData.shippingAddress ?? oe,
2389
+ e.formData.shippingAddress ?? ce,
2308
2390
  e.errors.shippingAddress ?? {},
2309
- le(e.touched, "shippingAddress")
2391
+ he(e.touched, "shippingAddress")
2310
2392
  ), this.componentManager.updateSubmitButton(t);
2311
2393
  }
2312
2394
  setLoadingState(e) {
@@ -2314,10 +2396,10 @@ class Mt {
2314
2396
  this.onLoadingStateChange(e);
2315
2397
  return;
2316
2398
  }
2317
- e ? (this.hideSkeleton(), this.formSkeleton = new he(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
2399
+ e ? (this.hideSkeleton(), this.formSkeleton = new pe(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
2318
2400
  }
2319
2401
  showSpinner(e) {
2320
- this.hideSpinner(), this.spinner = new Ft({ text: e }), this.formElement.appendChild(this.spinner.getElement());
2402
+ this.hideSpinner(), this.spinner = new Mt({ text: e }), this.formElement.appendChild(this.spinner.getElement());
2321
2403
  }
2322
2404
  hideSpinner() {
2323
2405
  this.spinner && (this.spinner.getElement().remove(), this.spinner = void 0);
@@ -2326,7 +2408,7 @@ class Mt {
2326
2408
  this.formSkeleton && (this.formSkeleton.getElement().remove(), this.formSkeleton = void 0);
2327
2409
  }
2328
2410
  setErrorMessage(e) {
2329
- this.alert && (this.alert.getElement().remove(), this.alert = void 0), this.alert = new we({ message: e }), this.formElement.insertBefore(
2411
+ this.alert && (this.alert.getElement().remove(), this.alert = void 0), this.alert = new Pe({ message: e }), this.formElement.insertBefore(
2330
2412
  this.alert.getElement(),
2331
2413
  this.formElement.firstChild
2332
2414
  );
@@ -2338,7 +2420,7 @@ class Mt {
2338
2420
  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);
2339
2421
  }
2340
2422
  }
2341
- const D = (i) => ({
2423
+ const x = (i) => ({
2342
2424
  street: "",
2343
2425
  firstName: "",
2344
2426
  lastName: "",
@@ -2348,12 +2430,12 @@ const D = (i) => ({
2348
2430
  country: "",
2349
2431
  ...i
2350
2432
  });
2351
- class Nt extends P {
2433
+ class wt extends k {
2352
2434
  options;
2353
- formManager = lt();
2435
+ formManager = dt();
2354
2436
  checkoutProfile;
2355
- translation = Pe();
2356
- focusManager = new ke();
2437
+ translation = ke();
2438
+ focusManager = new Ae();
2357
2439
  // Managers
2358
2440
  componentManager;
2359
2441
  eventHandler;
@@ -2364,9 +2446,9 @@ class Nt extends P {
2364
2446
  vgsJwt;
2365
2447
  vgsCardResult;
2366
2448
  constructor(e) {
2367
- super("form", ["form-container"]), this.options = e, this.vgsJwt = e.vgsJwt, this.vgsJwt && (this.vgsService = new I()), this.checkoutProfile = ot({
2449
+ super("form", ["form-container"]), this.options = e, this.vgsJwt = e.vgsJwt, this.vgsJwt && (this.vgsService = new T()), this.checkoutProfile = lt({
2368
2450
  appearance: e.appearance
2369
- }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new St({
2451
+ }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new Et({
2370
2452
  formElement: this.element,
2371
2453
  focusManager: this.focusManager,
2372
2454
  translationFunc: this.translation.t,
@@ -2383,11 +2465,11 @@ class Nt extends P {
2383
2465
  environment: e.environment,
2384
2466
  vgsService: this.vgsService,
2385
2467
  onVgsStateChange: (t) => this.handleVgsStateChange(t)
2386
- }), this.uiManager = new Mt({
2468
+ }), this.uiManager = new Nt({
2387
2469
  formElement: this.element,
2388
2470
  componentManager: this.componentManager,
2389
2471
  onLoadingStateChange: e.onLoadingStateChange
2390
- }), this.stateCoordinator = new Ct({
2472
+ }), this.stateCoordinator = new Ft({
2391
2473
  formManager: this.formManager,
2392
2474
  checkoutProfile: this.checkoutProfile,
2393
2475
  componentManager: this.componentManager,
@@ -2397,7 +2479,7 @@ class Nt extends P {
2397
2479
  onError: (t) => this.uiManager.setErrorMessage(t),
2398
2480
  onLoadingChange: (t) => this.uiManager.setLoadingState(t),
2399
2481
  getInitialFormData: () => this._getFormStateData().formData
2400
- }), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new Et({
2482
+ }), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new Ct({
2401
2483
  formManager: this.formManager,
2402
2484
  focusManager: this.focusManager,
2403
2485
  onFormSubmit: async () => this.handleSubmit(),
@@ -2422,12 +2504,12 @@ class Nt extends P {
2422
2504
  },
2423
2505
  ...e.initialValues.name && { name: e.initialValues.name },
2424
2506
  ...e.initialValues.billingAddress && {
2425
- billingAddress: D(
2507
+ billingAddress: x(
2426
2508
  e.initialValues.billingAddress
2427
2509
  )
2428
2510
  },
2429
2511
  ...e.initialValues.shippingAddress && {
2430
- shippingAddress: D(
2512
+ shippingAddress: x(
2431
2513
  e.initialValues.shippingAddress
2432
2514
  )
2433
2515
  }
@@ -2444,10 +2526,10 @@ class Nt extends P {
2444
2526
  cardNumber: "",
2445
2527
  cardCvv: "",
2446
2528
  ...t?.billingAddress && {
2447
- billingAddress: D(t.billingAddress)
2529
+ billingAddress: x(t.billingAddress)
2448
2530
  },
2449
2531
  ...t?.shippingAddress && {
2450
- shippingAddress: D(t.shippingAddress)
2532
+ shippingAddress: x(t.shippingAddress)
2451
2533
  }
2452
2534
  },
2453
2535
  errors: e.errors || {},
@@ -2474,11 +2556,11 @@ class Nt extends P {
2474
2556
  phoneNumber: "",
2475
2557
  phoneCountryCode: e.checkoutProfile.layout.phoneNumber.defaultCountry?.toUpperCase() || "US"
2476
2558
  }), e.checkoutProfile.layout.billingFields && this.formManager.getFormState().formData.billingAddress === void 0 && this.formManager.setFormData({
2477
- billingAddress: D()
2559
+ billingAddress: x()
2478
2560
  }), e.checkoutProfile.layout.shippingFields && this.formManager.getFormState().formData.shippingAddress === void 0 && this.formManager.setFormData({
2479
- shippingAddress: D()
2561
+ shippingAddress: x()
2480
2562
  });
2481
- const { formData: t, errors: s, touched: a } = this._getFormStateData(), n = mt(
2563
+ const { formData: t, errors: s, touched: a } = this._getFormStateData(), n = pt(
2482
2564
  e.checkoutProfile.layout
2483
2565
  );
2484
2566
  try {
@@ -2542,7 +2624,7 @@ class Nt extends P {
2542
2624
  } catch (o) {
2543
2625
  console.error("Failed to create card section:", o);
2544
2626
  }
2545
- if (!W(
2627
+ if (!Z(
2546
2628
  e.checkoutProfile.layout
2547
2629
  ))
2548
2630
  try {
@@ -2580,7 +2662,7 @@ class Nt extends P {
2580
2662
  */
2581
2663
  inferCardholderName() {
2582
2664
  const e = this.checkoutProfile.getState();
2583
- if (!e.checkoutProfile || !W(
2665
+ if (!e.checkoutProfile || !Z(
2584
2666
  e.checkoutProfile.layout
2585
2667
  )) return;
2586
2668
  const { formData: s } = this._getFormStateData(), a = s.billingAddress ?? s.shippingAddress;
@@ -2688,7 +2770,7 @@ class Nt extends P {
2688
2770
  ), this.componentManager.cleanup(), this.uiManager.cleanup(), this.getElement().remove();
2689
2771
  }
2690
2772
  associatePayment(e, t, s, a, n) {
2691
- this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = s, this.options.checkoutDetails = a, this.componentManager.setCheckoutDetailsLoaded(!0), n && !this.vgsService && (this.vgsJwt = n, this.vgsService = new I(), this.componentManager.setVgsService(this.vgsService), this.stateCoordinator.setVgsMode(!0), this.vgsService.init(this.options.environment).then((o) => {
2773
+ this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = s, this.options.checkoutDetails = a, this.componentManager.setCheckoutDetailsLoaded(!0), n && !this.vgsService && (this.vgsJwt = n, this.vgsService = new T(), this.componentManager.setVgsService(this.vgsService), this.stateCoordinator.setVgsMode(!0), this.vgsService.init(this.options.environment).then((o) => {
2692
2774
  this.vgsService?.createForm(
2693
2775
  o,
2694
2776
  (d) => this.handleVgsStateChange(d)
@@ -2713,7 +2795,7 @@ class Nt extends P {
2713
2795
  }
2714
2796
  }
2715
2797
  }
2716
- class wt {
2798
+ class Pt {
2717
2799
  container = null;
2718
2800
  options;
2719
2801
  onSubmit;
@@ -2737,7 +2819,7 @@ class wt {
2737
2819
  }
2738
2820
  }
2739
2821
  renderForm(e) {
2740
- this.container && (this.form && (this.form.destroy(), this.form = null), this.form = new Nt({
2822
+ this.container && (this.form && (this.form.destroy(), this.form = null), this.form = new wt({
2741
2823
  apiKey: this.options.apiKey,
2742
2824
  onSubmit: this.onSubmit,
2743
2825
  locale: this.options.locale,
@@ -2774,7 +2856,7 @@ class wt {
2774
2856
  );
2775
2857
  }
2776
2858
  }
2777
- class Pt {
2859
+ class kt {
2778
2860
  state;
2779
2861
  listeners = /* @__PURE__ */ new Set();
2780
2862
  constructor(e) {
@@ -2796,8 +2878,8 @@ class Pt {
2796
2878
  this.listeners.forEach((t) => t(e));
2797
2879
  }
2798
2880
  }
2799
- const kt = "en";
2800
- class At {
2881
+ const At = "en";
2882
+ class Dt {
2801
2883
  config;
2802
2884
  paymentState;
2803
2885
  apiService;
@@ -2805,18 +2887,18 @@ class At {
2805
2887
  stateManager;
2806
2888
  sessionId;
2807
2889
  constructor(e) {
2808
- this.config = this.validateConfig(e), this.paymentState = {}, this.sessionId = crypto.randomUUID(), at({
2890
+ this.config = this.validateConfig(e), this.paymentState = {}, this.sessionId = crypto.randomUUID(), rt({
2809
2891
  environment: this.config.environment,
2810
2892
  sessionId: this.sessionId
2811
- }), F(C.CHECKOUT_INITIALIZED, {
2893
+ }), M(F.CHECKOUT_INITIALIZED, {
2812
2894
  environment: this.config.environment
2813
- }), this.apiService = new Ae(
2895
+ }), this.apiService = new De(
2814
2896
  this.config.apiKey,
2815
2897
  this.config.environment
2816
- ), this.stateManager = new Pt({
2898
+ ), this.stateManager = new kt({
2817
2899
  mounted: !1,
2818
2900
  form: null
2819
- }), this.formManager = new wt(
2901
+ }), this.formManager = new Pt(
2820
2902
  {
2821
2903
  locale: this.config.locale,
2822
2904
  apiKey: this.config.apiKey,
@@ -2838,7 +2920,7 @@ class At {
2838
2920
  apiKey: e.apiKey,
2839
2921
  returnUrl: e.returnUrl,
2840
2922
  environment: e.environment,
2841
- locale: e.locale || kt,
2923
+ locale: e.locale || At,
2842
2924
  disableErrorMessages: e.disableErrorMessages ?? !1,
2843
2925
  manualActionHandling: e.manualActionHandling ?? !1,
2844
2926
  appearance: e.appearance,
@@ -2859,7 +2941,7 @@ class At {
2859
2941
  return t.appendChild(s), this.stateManager.updateState({
2860
2942
  form: s,
2861
2943
  mounted: !0
2862
- }), this.formManager.mount(s), F(C.CHECKOUT_MOUNTED, {
2944
+ }), this.formManager.mount(s), M(F.CHECKOUT_MOUNTED, {
2863
2945
  container_id: e
2864
2946
  }), this;
2865
2947
  }
@@ -2871,7 +2953,7 @@ class At {
2871
2953
  t && t.remove(), this.stateManager.updateState({
2872
2954
  form: null,
2873
2955
  mounted: !1
2874
- }), F(C.CHECKOUT_UNMOUNTED);
2956
+ }), M(F.CHECKOUT_UNMOUNTED);
2875
2957
  });
2876
2958
  }
2877
2959
  async handleSubmit({
@@ -2883,7 +2965,7 @@ class At {
2883
2965
  "Payment must be associated before submitting. Call associatePayment() first."
2884
2966
  );
2885
2967
  const s = this.getPaymentMethod(e, t);
2886
- F(C.PAYMENT_SUBMIT_STARTED, {
2968
+ M(F.PAYMENT_SUBMIT_STARTED, {
2887
2969
  payment_id: this.paymentState.paymentId,
2888
2970
  payment_method: s
2889
2971
  });
@@ -2896,8 +2978,8 @@ class At {
2896
2978
  returnUrl: this.config.returnUrl,
2897
2979
  applePayData: t
2898
2980
  }), r = performance.now() - a;
2899
- ne(
2900
- X.PAYMENT_AUTHORIZATION_TIME,
2981
+ re(
2982
+ te.PAYMENT_AUTHORIZATION_TIME,
2901
2983
  r,
2902
2984
  "ms",
2903
2985
  {
@@ -2905,14 +2987,14 @@ class At {
2905
2987
  payment_method: s,
2906
2988
  status: "success"
2907
2989
  }
2908
- ), F(C.PAYMENT_SUBMIT_SUCCESS, {
2990
+ ), M(F.PAYMENT_SUBMIT_SUCCESS, {
2909
2991
  payment_id: this.paymentState.paymentId,
2910
2992
  payment_method: s
2911
2993
  }), this.handlePaymentResponse(n);
2912
2994
  } catch (n) {
2913
2995
  const r = performance.now() - a;
2914
- ne(
2915
- X.PAYMENT_AUTHORIZATION_TIME,
2996
+ re(
2997
+ te.PAYMENT_AUTHORIZATION_TIME,
2916
2998
  r,
2917
2999
  "ms",
2918
3000
  {
@@ -2920,7 +3002,7 @@ class At {
2920
3002
  payment_method: s,
2921
3003
  status: "failed"
2922
3004
  }
2923
- ), F(C.PAYMENT_SUBMIT_FAILED, {
3005
+ ), M(F.PAYMENT_SUBMIT_FAILED, {
2924
3006
  payment_id: this.paymentState.paymentId,
2925
3007
  payment_method: s,
2926
3008
  error_message: n.details?.message ?? "Unknown error"
@@ -2928,17 +3010,17 @@ class At {
2928
3010
  }
2929
3011
  }
2930
3012
  handlePaymentResponse(e) {
2931
- if (e.latestTransaction.status === "authorized" && (F(C.PAYMENT_AUTHORIZED, {
3013
+ if (e.latestTransaction.status === "authorized" && (M(F.PAYMENT_AUTHORIZED, {
2932
3014
  payment_id: this.paymentState.paymentId ?? "",
2933
3015
  status: e.latestTransaction.status
2934
3016
  }), this.config.callbacks.onPaymentSucceeded?.(
2935
3017
  e.latestTransaction.status
2936
- )), e.latestTransaction.status === "failed" && (F(C.PAYMENT_FAILED, {
3018
+ )), e.latestTransaction.status === "failed" && (M(F.PAYMENT_FAILED, {
2937
3019
  payment_id: this.paymentState.paymentId ?? "",
2938
3020
  status: e.latestTransaction.status
2939
3021
  }), this.config.callbacks.onPaymentFailed?.(e.latestTransaction.status)), e.status === "requires_action") {
2940
3022
  const { redirectUrl: t } = e.action;
2941
- F(C.PAYMENT_ACTION_REQUIRED, {
3023
+ M(F.PAYMENT_ACTION_REQUIRED, {
2942
3024
  payment_id: this.paymentState.paymentId ?? "",
2943
3025
  status: e.status
2944
3026
  }), this.config.manualActionHandling ? this.config.callbacks.onActionRequired?.(t) : globalThis.location.href = t;
@@ -2978,7 +3060,7 @@ class At {
2978
3060
  throw new Error("paymentId and checkoutKey are required");
2979
3061
  this.paymentState.paymentId = e, this.paymentState.checkoutKey = t;
2980
3062
  try {
2981
- const s = await De({
3063
+ const s = await Ie({
2982
3064
  id: e,
2983
3065
  checkoutKey: t,
2984
3066
  environment: this.config.environment
@@ -3008,35 +3090,35 @@ class At {
3008
3090
  a,
3009
3091
  this.paymentState.checkoutDetails,
3010
3092
  s.vgsJwt
3011
- ), F(C.PAYMENT_ASSOCIATED, {
3093
+ ), M(F.PAYMENT_ASSOCIATED, {
3012
3094
  payment_id: e,
3013
3095
  currency: s.currency,
3014
3096
  country_code: s.countryCode
3015
3097
  });
3016
3098
  } catch (s) {
3017
- throw F(C.PAYMENT_ASSOCIATION_FAILED, {
3099
+ throw M(F.PAYMENT_ASSOCIATION_FAILED, {
3018
3100
  payment_id: e,
3019
3101
  error_message: s instanceof Error ? s.message : "Unknown error"
3020
- }), rt(
3102
+ }), ot(
3021
3103
  s instanceof Error ? s : new Error("Failed to associate payment"),
3022
3104
  { payment_id: e }
3023
3105
  ), s;
3024
3106
  }
3025
3107
  }
3026
3108
  }
3027
- typeof globalThis < "u" && (globalThis.OdusCheckout = At);
3109
+ typeof globalThis < "u" && (globalThis.OdusCheckout = Dt);
3028
3110
  export {
3029
- At as OdusCheckout,
3030
- Tt as deLocale,
3031
- Vt as enLocale,
3032
- _t as esLocale,
3111
+ Dt as OdusCheckout,
3112
+ Vt as deLocale,
3113
+ _t as enLocale,
3114
+ Rt as esLocale,
3033
3115
  Bt as frLocale,
3034
- Ot as itLocale,
3035
- Rt as plLocale,
3036
- Ut as ptLocale,
3037
- rt as pushError,
3038
- F as pushEvent,
3039
- It as pushLog,
3040
- ne as pushMeasurement,
3041
- Ht as trLocale
3116
+ Ut as itLocale,
3117
+ Ot as plLocale,
3118
+ Ht as ptLocale,
3119
+ ot as pushError,
3120
+ M as pushEvent,
3121
+ xt as pushLog,
3122
+ re as pushMeasurement,
3123
+ zt as trLocale
3042
3124
  };