@odus/checkout 1.11.3 → 1.13.0

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.
Files changed (36) hide show
  1. package/README.md +16 -16
  2. package/dist/api/createApplePaySession.mutation.d.ts.map +1 -1
  3. package/dist/api/getCheckoutDetails.query.d.ts.map +1 -1
  4. package/dist/checkout.es.js +160 -141
  5. package/dist/components/checkout/form/Form.d.ts +7 -0
  6. package/dist/components/checkout/form/Form.d.ts.map +1 -1
  7. package/dist/components/checkout/form/FormComponentManager.d.ts +2 -1
  8. package/dist/components/checkout/form/FormComponentManager.d.ts.map +1 -1
  9. package/dist/components/payment-methods/applePay/ApplePayButton.d.ts +1 -0
  10. package/dist/components/payment-methods/applePay/ApplePayButton.d.ts.map +1 -1
  11. package/dist/core/api/CheckoutAPI.service.d.ts.map +1 -1
  12. package/dist/core/constants/apiRoutes.constants.d.ts +14 -0
  13. package/dist/core/constants/apiRoutes.constants.d.ts.map +1 -0
  14. package/dist/elements/BaseElement.d.ts +8 -0
  15. package/dist/elements/BaseElement.d.ts.map +1 -1
  16. package/dist/elements/CardElement.d.ts +10 -3
  17. package/dist/elements/CardElement.d.ts.map +1 -1
  18. package/dist/elements/OdusElements.d.ts +8 -0
  19. package/dist/elements/OdusElements.d.ts.map +1 -1
  20. package/dist/elements/card/VgsCardAdapter.d.ts +2 -0
  21. package/dist/elements/card/VgsCardAdapter.d.ts.map +1 -1
  22. package/dist/elements.es.js +247 -215
  23. package/dist/phone.js +8 -14
  24. package/dist/services/checkout/Checkout.service.d.ts +2 -0
  25. package/dist/services/checkout/Checkout.service.d.ts.map +1 -1
  26. package/dist/services/checkout/CheckoutForm.service.d.ts +2 -0
  27. package/dist/services/checkout/CheckoutForm.service.d.ts.map +1 -1
  28. package/dist/services/telemetry/LoadTimer.service.d.ts +28 -0
  29. package/dist/services/telemetry/LoadTimer.service.d.ts.map +1 -0
  30. package/dist/services/telemetry/Telemetry.service.d.ts.map +1 -1
  31. package/dist/shared.js +633 -583
  32. package/dist/types/telemetry/TelemetryEvents.type.d.ts +35 -0
  33. package/dist/types/telemetry/TelemetryEvents.type.d.ts.map +1 -1
  34. package/package.json +3 -3
  35. package/dist/api/getSupportedPaymentMethods.query.d.ts +0 -7
  36. package/dist/api/getSupportedPaymentMethods.query.d.ts.map +0 -1
@@ -1,7 +1,7 @@
1
- import { $ as e, A as t, C as n, D as r, E as i, F as a, G as o, H as s, I as c, J as l, K as u, L as d, M as f, N as p, O as m, P as h, Q as g, R as _, S as v, V as ee, W as y, X as b, Y as x, Z as S, a as te, b as C, c as ne, d as w, et as T, f as E, g as D, h as O, j as k, k as re, l as A, m as j, n as ie, o as ae, q as M, r as oe, s as N, t as P, tt as F, u as I, v as L, w as R, x as z, y as B, z as V } from "./shared.js";
2
- import { t as H } from "./shared2.js";
1
+ import { $ as e, A as t, C as n, D as r, E as i, F as a, G as o, H as s, I as c, J as l, K as u, L as d, M as f, N as p, O as m, P as h, Q as g, R as _, S as ee, V as te, W as v, X as y, Y as b, Z as x, a as ne, b as S, c as C, d as w, et as T, f as E, g as re, h as D, j as O, k as ie, l as k, m as A, n as ae, nt as j, o as oe, q as M, r as N, rt as P, s as F, t as I, tt as L, u as R, v as z, w as B, x as V, y as H, z as U } from "./shared.js";
2
+ import { t as W } from "./shared2.js";
3
3
  //#region libs/checkout/src/utils/focus/FocusManager.ts
4
- var U = class {
4
+ var G = class {
5
5
  focusSequence = [
6
6
  "cardNumber",
7
7
  "cardExpiry",
@@ -81,19 +81,19 @@ var U = class {
81
81
  };
82
82
  //#endregion
83
83
  //#region libs/checkout/src/utils/helpers/hasAddressConfiguration.util.ts
84
- function W(e) {
84
+ function K(e) {
85
85
  if (!e) return !1;
86
86
  let { billingFields: t, shippingFields: n } = e, r = t && Object.values(t).some((e) => e?.enabled), i = n && Object.values(n).some((e) => e?.enabled);
87
87
  return !!(r || i);
88
88
  }
89
- function G(e) {
89
+ function q(e) {
90
90
  if (!e) return !1;
91
91
  let { billingFields: t, shippingFields: n } = e, r = t?.firstName?.enabled && t?.lastName?.enabled, i = n?.firstName?.enabled && n?.lastName?.enabled;
92
92
  return !!(r || i);
93
93
  }
94
94
  //#endregion
95
95
  //#region libs/checkout/src/components/checkout/form/AddressSection.ts
96
- var K = class extends C {
96
+ var J = class extends S {
97
97
  inputs = /* @__PURE__ */ new Map();
98
98
  type;
99
99
  onChange;
@@ -115,7 +115,7 @@ var K = class extends C {
115
115
  let e = document.createElement("h3");
116
116
  e.className = "address-section-title", e.textContent = t, e.style.color = n.styles.textColor, e.style.fontFamily = `"${n.styles.fontFamily}", sans-serif`, e.style.fontSize = `${n.styles.fontSize}px`, e.style.fontWeight = "normal", this.getElement().appendChild(e);
117
117
  }
118
- 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(n, r, i, a, o), this.grouped && (this.groupMessage = new O({
118
+ 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(n, r, i, a, o), this.grouped && (this.groupMessage = new D({
119
119
  text: "",
120
120
  visible: !1
121
121
  }), this.fieldsContainer.appendChild(this.groupMessage.getElement()));
@@ -227,7 +227,7 @@ var K = class extends C {
227
227
  let t = this.translationFunc("validation.maxLengthExceeded");
228
228
  this.applyFieldError(e, !0, t.replace("{{max}}", String(s)));
229
229
  } else this.applyFieldError(e, !1);
230
- this.onChange(H({
230
+ this.onChange(W({
231
231
  type: "input",
232
232
  target: {
233
233
  name: c,
@@ -237,7 +237,7 @@ var K = class extends C {
237
237
  }
238
238
  });
239
239
  return l.addEventListener("blur", (e) => {
240
- this.onBlur(H({
240
+ this.onBlur(W({
241
241
  type: "blur",
242
242
  target: {
243
243
  name: c,
@@ -247,7 +247,7 @@ var K = class extends C {
247
247
  }), l;
248
248
  }
249
249
  createCountrySelect(e, t, n, r, i, a) {
250
- let o = `${this.type}Address.country`, s = D(i, this.locale), c = new w({
250
+ let o = `${this.type}Address.country`, s = re(i, this.locale), c = new w({
251
251
  name: o,
252
252
  error: !1,
253
253
  errorMsg: void 0,
@@ -261,7 +261,7 @@ var K = class extends C {
261
261
  onChange: (e) => {
262
262
  this.applyFieldError("country", !1);
263
263
  let t = e.target.value;
264
- this.onChange(H({
264
+ this.onChange(W({
265
265
  type: "change",
266
266
  target: {
267
267
  name: o,
@@ -271,7 +271,7 @@ var K = class extends C {
271
271
  }
272
272
  });
273
273
  return c.addEventListener("blur", (e) => {
274
- this.onBlur(H({
274
+ this.onBlur(W({
275
275
  type: "blur",
276
276
  target: {
277
277
  name: o,
@@ -293,7 +293,7 @@ var K = class extends C {
293
293
  if (i && a) {
294
294
  let t = this.inputs.get("state");
295
295
  if (t instanceof w) {
296
- let n = V(e), r = c(n), i = this.translationFunc(d(n));
296
+ let n = U(e), r = c(n), i = this.translationFunc(d(n));
297
297
  t.setOptions(r, i);
298
298
  }
299
299
  this.clearStateValue();
@@ -321,7 +321,7 @@ var K = class extends C {
321
321
  let e = this.inputs.get("state");
322
322
  e && e.setValue("");
323
323
  let t = `${this.type}Address.state`;
324
- this.onChange(H({
324
+ this.onChange(W({
325
325
  type: "input",
326
326
  target: {
327
327
  name: t,
@@ -331,7 +331,7 @@ var K = class extends C {
331
331
  }));
332
332
  }
333
333
  createStateSelect(e, t, n, r, i, a) {
334
- let o = `${this.type}Address.state`, s = V(i), l = c(s), u = this.translationFunc(d(s)), f = new w({
334
+ let o = `${this.type}Address.state`, s = U(i), l = c(s), u = this.translationFunc(d(s)), f = new w({
335
335
  name: o,
336
336
  error: !1,
337
337
  errorMsg: void 0,
@@ -343,7 +343,7 @@ var K = class extends C {
343
343
  options: l,
344
344
  autocomplete: "address-level1",
345
345
  onChange: (e) => {
346
- this.applyFieldError("state", !1), this.onChange(H({
346
+ this.applyFieldError("state", !1), this.onChange(W({
347
347
  type: "change",
348
348
  target: {
349
349
  name: o,
@@ -353,7 +353,7 @@ var K = class extends C {
353
353
  }
354
354
  });
355
355
  return f.addEventListener("blur", (e) => {
356
- this.onBlur(H({
356
+ this.onBlur(W({
357
357
  type: "blur",
358
358
  target: {
359
359
  name: o,
@@ -447,7 +447,7 @@ var K = class extends C {
447
447
  let e = this.inputs.values().next().value;
448
448
  e && e.focus();
449
449
  }
450
- }, q = class {
450
+ }, se = class {
451
451
  input = null;
452
452
  isVgsMode;
453
453
  vgsWrapper = null;
@@ -455,7 +455,7 @@ var K = class extends C {
455
455
  vgsHelperText = null;
456
456
  wrapperElement;
457
457
  _vgsFieldsReady = !1;
458
- _fieldHeight = B(L, 14);
458
+ _fieldHeight = H(z, 14);
459
459
  _borderRadius = 0;
460
460
  constructor(e) {
461
461
  let { value: t, onChange: n, onBlur: r, errorMsg: i, checkoutProfile: a, translationFunc: o, autocomplete: s = "cc-name", isVgsMode: c = !1 } = e;
@@ -463,13 +463,13 @@ var K = class extends C {
463
463
  }
464
464
  buildVgsLayout(e, t) {
465
465
  let n = e.styles.borderRadius;
466
- this._borderRadius = n, this._fieldHeight = B(L, e.styles.fontSize);
466
+ this._borderRadius = n, this._fieldHeight = H(z, e.styles.fontSize);
467
467
  let r = document.createElement("div");
468
468
  r.style.marginBottom = "4px";
469
469
  let i = document.createElement("label");
470
470
  i.className = "input-label", i.textContent = t("cardholderNameLabel"), i.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, i.style.fontSize = `${e.styles.fontSize}px`, r.appendChild(i), this.wrapperElement.appendChild(r), this.vgsWrapper = document.createElement("div"), this.vgsWrapper.className = "vgs-wrap", this.vgsWrapper.style.position = "relative", this.vgsWrapper.style.borderRadius = `${n}px`, this.vgsWrapper.style.height = this._fieldHeight, this.vgsWrapper.style.width = "100%", this.vgsWrapper.style.overflow = "hidden";
471
471
  let a = document.createElement("div");
472
- a.className = "vgs-field-skeleton", this.vgsWrapper.appendChild(a), 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 O({ visible: !1 }), this.wrapperElement.appendChild(this.vgsHelperText.getElement());
472
+ a.className = "vgs-field-skeleton", this.vgsWrapper.appendChild(a), 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 D({ visible: !1 }), this.wrapperElement.appendChild(this.vgsHelperText.getElement());
473
473
  }
474
474
  buildNativeLayout(e, t, n, r, i, a, o) {
475
475
  this.input = new E({
@@ -499,9 +499,9 @@ var K = class extends C {
499
499
  }
500
500
  handleVgsStateChange(e, t) {
501
501
  if (!this.isVgsMode || !this.vgsWrapper) return;
502
- let n = e[A.CARDHOLDER]?.isFocused;
502
+ let n = e[k.CARDHOLDER]?.isFocused;
503
503
  if (this._vgsFieldsReady && (this.vgsWrapper.style.boxShadow = n ? "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;
504
- let r = t[A.CARDHOLDER];
504
+ let r = t[k.CARDHOLDER];
505
505
  r ? (this.vgsHelperText.setText(r), this.vgsHelperText.toggleVisibility(!0)) : this.vgsHelperText.toggleVisibility(!1);
506
506
  }
507
507
  setFieldHeight(e) {
@@ -543,7 +543,7 @@ var K = class extends C {
543
543
  focus() {
544
544
  this.isVgsMode || this.input?.focus();
545
545
  }
546
- }, J = class extends C {
546
+ }, Y = class extends S {
547
547
  constructor() {
548
548
  super("div", ["skeleton-container"]), this.createSkeletonElements();
549
549
  }
@@ -551,14 +551,14 @@ var K = class extends C {
551
551
  this.appendChild(this.createPaymentMethodSkeleton()), this.appendChild(this.createPaymentSeparatorSkeleton());
552
552
  }
553
553
  createPaymentMethodSkeleton() {
554
- let e = j.createDiv(["skeleton-field"]), t = j.createDiv(["skeleton", "skeleton-payment-method"]);
554
+ let e = A.createDiv(["skeleton-field"]), t = A.createDiv(["skeleton", "skeleton-payment-method"]);
555
555
  return e.appendChild(t), e;
556
556
  }
557
557
  createPaymentSeparatorSkeleton() {
558
- let e = j.createDiv(["payment-separator_container"]), t = j.createDiv(["payment-separator__line"]), n = j.createDiv(["skeleton", "skeleton-separator-text"]), r = j.createDiv(["payment-separator__line"]);
558
+ let e = A.createDiv(["payment-separator_container"]), t = A.createDiv(["payment-separator__line"]), n = A.createDiv(["skeleton", "skeleton-separator-text"]), r = A.createDiv(["payment-separator__line"]);
559
559
  return e.appendChild(t), e.appendChild(n), e.appendChild(r), e;
560
560
  }
561
- }, se = class extends C {
561
+ }, ce = class extends S {
562
562
  constructor(e) {
563
563
  let { translationFunc: t, checkoutProfile: n } = e;
564
564
  super("div", ["payment-separator"]);
@@ -569,7 +569,7 @@ var K = class extends C {
569
569
  let o = document.createElement("span");
570
570
  o.className = "payment-separator__line", r.appendChild(i), r.appendChild(a), r.appendChild(o);
571
571
  }
572
- }, ce = class extends C {
572
+ }, le = class extends S {
573
573
  paymentMethods;
574
574
  paymentSeparator;
575
575
  skeleton;
@@ -584,7 +584,7 @@ var K = class extends C {
584
584
  return;
585
585
  }
586
586
  let f = Object.entries(t.additionalPaymentMethods).filter(([e, t]) => {
587
- let n = t.enabled, r = !a || a[e] === !0, i = te(t.countries, d);
587
+ let n = t.enabled, r = !a || a[e] === !0, i = ne(t.countries, d);
588
588
  return n && r && i;
589
589
  }).sort((e, t) => e[1].order - t[1].order);
590
590
  if (f.length === 0) {
@@ -594,7 +594,7 @@ var K = class extends C {
594
594
  for (let [e] of f) switch (e) {
595
595
  case "paypal":
596
596
  if (r) {
597
- let e = new ie({
597
+ let e = new ae({
598
598
  checkoutProfile: t,
599
599
  formData: n,
600
600
  onSubmit: r
@@ -604,7 +604,7 @@ var K = class extends C {
604
604
  break;
605
605
  case "applePay":
606
606
  if (i && s && c) {
607
- let e = t.appearance?.additionalPaymentMethods?.applePay, r = new oe({
607
+ let e = t.appearance?.additionalPaymentMethods?.applePay, r = new N({
608
608
  checkoutProfile: t,
609
609
  formData: n,
610
610
  onSubmit: i,
@@ -621,13 +621,13 @@ var K = class extends C {
621
621
  break;
622
622
  default: console.warn(`[PaymentMethods] Unsupported payment method: ${e}`);
623
623
  }
624
- this.paymentMethods.size > 0 && (this.paymentSeparator = new se({
624
+ this.paymentMethods.size > 0 && (this.paymentSeparator = new ce({
625
625
  translationFunc: o,
626
626
  checkoutProfile: t
627
627
  }), this.getElement().appendChild(this.paymentSeparator.getElement()));
628
628
  }
629
629
  renderSkeleton() {
630
- this.skeleton = new J(), this.getElement().appendChild(this.skeleton.getElement());
630
+ this.skeleton = new Y(), this.getElement().appendChild(this.skeleton.getElement());
631
631
  }
632
632
  updateFormData(e) {
633
633
  let t = this.paymentMethods.get("paypal");
@@ -638,7 +638,7 @@ var K = class extends C {
638
638
  hasVisiblePaymentMethods() {
639
639
  return this.paymentMethods.size > 0 && this.getElement().style.display !== "none";
640
640
  }
641
- }, le = 17, ue = class extends C {
641
+ }, ue = 17, de = class extends S {
642
642
  styles;
643
643
  isHovered = !1;
644
644
  constructor(e) {
@@ -646,7 +646,7 @@ var K = class extends C {
646
646
  }
647
647
  applyStyles() {
648
648
  let e = this.getElement();
649
- 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 === le ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
649
+ 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 === ue ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
650
650
  }
651
651
  handleMouseEnter() {
652
652
  this.isHovered = !0, this.applyStyles();
@@ -657,11 +657,11 @@ var K = class extends C {
657
657
  setDisabled(e) {
658
658
  return this.getElement().disabled = e, e ? (this.addClass("disabled"), this.removeClass("valid")) : (this.removeClass("disabled"), this.addClass("valid")), this.applyStyles(), this;
659
659
  }
660
- }, de = class {
660
+ }, fe = class {
661
661
  button;
662
662
  constructor(e) {
663
663
  let { disabled: t, checkoutProfile: n, translationFunc: r } = e;
664
- this.button = new ue({
664
+ this.button = new de({
665
665
  text: r(`buttonTexts.${n?.layout.actionButton.translationKey}`),
666
666
  styles: {
667
667
  backgroundColor: n.styles.buttonColor,
@@ -685,7 +685,7 @@ var K = class extends C {
685
685
  appendTo(e) {
686
686
  return this.button.appendTo(e), this;
687
687
  }
688
- }, fe = class {
688
+ }, pe = class {
689
689
  formElement;
690
690
  focusManager;
691
691
  translationFunc;
@@ -723,7 +723,7 @@ var K = class extends C {
723
723
  createPaymentMethods(e, t, n = !1) {
724
724
  try {
725
725
  if (!e?.additionalPaymentMethods || Object.keys(e.additionalPaymentMethods).length === 0 || !Object.values(e.additionalPaymentMethods).some((e) => e.enabled)) return;
726
- this.removePaymentMethods(), this.paymentMethods = new ce({
726
+ this.removePaymentMethods(), this.paymentMethods = new le({
727
727
  checkoutProfile: e,
728
728
  formData: t,
729
729
  supportedPaymentMethods: this.supportedPaymentMethods,
@@ -743,7 +743,7 @@ var K = class extends C {
743
743
  createEmailField(e, t, n, r) {
744
744
  try {
745
745
  let i = e.layout.billingFields && Object.values(e.layout.billingFields).some((e) => e?.enabled) || e.layout.shippingFields && Object.values(e.layout.shippingFields).some((e) => e?.enabled);
746
- this.emailField = new ae({
746
+ this.emailField = new oe({
747
747
  value: t.email,
748
748
  onChange: this.onChange,
749
749
  onBlur: this.onBlur,
@@ -788,13 +788,13 @@ var K = class extends C {
788
788
  }
789
789
  if (!this.isCardSupported()) return;
790
790
  if (!this.vgsService) {
791
- this.cardUnavailableNotice = new N({
791
+ this.cardUnavailableNotice = new F({
792
792
  checkoutProfile: e,
793
793
  translationFunc: this.translationFunc
794
794
  }), this.formElement.appendChild(this.cardUnavailableNotice.getElement());
795
795
  return;
796
796
  }
797
- this.cardSection = new ne({
797
+ this.cardSection = new C({
798
798
  checkoutProfile: e,
799
799
  translationFunc: this.translationFunc,
800
800
  vgsService: this.vgsService
@@ -811,7 +811,7 @@ var K = class extends C {
811
811
  this.cardholderSectionSkeleton = this.buildCardholderSkeleton(e), this.formElement.appendChild(this.cardholderSectionSkeleton);
812
812
  return;
813
813
  }
814
- if (this.cardholderSection = new q({
814
+ if (this.cardholderSection = new se({
815
815
  value: t.name,
816
816
  onChange: this.onChange,
817
817
  onBlur: this.onBlur,
@@ -842,7 +842,7 @@ var K = class extends C {
842
842
  zipCode: "",
843
843
  country: ""
844
844
  };
845
- this.billingAddressSection = new K({
845
+ this.billingAddressSection = new J({
846
846
  type: "billing",
847
847
  title: this.translationFunc("address.billingTitle"),
848
848
  checkoutProfile: e,
@@ -873,7 +873,7 @@ var K = class extends C {
873
873
  zipCode: "",
874
874
  country: ""
875
875
  };
876
- this.shippingAddressSection = new K({
876
+ this.shippingAddressSection = new J({
877
877
  type: "shipping",
878
878
  title: this.translationFunc("address.shippingTitle"),
879
879
  checkoutProfile: e,
@@ -893,7 +893,7 @@ var K = class extends C {
893
893
  }
894
894
  createSubmitButton(e, t) {
895
895
  try {
896
- this.submitButton = new de({
896
+ this.submitButton = new fe({
897
897
  disabled: t,
898
898
  checkoutProfile: e,
899
899
  translationFunc: this.translationFunc
@@ -942,7 +942,7 @@ var K = class extends C {
942
942
  return !this.supportedPaymentMethods || !!this.supportedPaymentMethods.card;
943
943
  }
944
944
  buildCardSkeleton(e) {
945
- let t = e.styles.borderRadius, n = B(L, e.styles.fontSize), r = document.createElement("div"), i = document.createElement("div");
945
+ let t = e.styles.borderRadius, n = H(z, e.styles.fontSize), r = document.createElement("div"), i = document.createElement("div");
946
946
  i.style.marginBottom = "4px";
947
947
  let a = document.createElement("label");
948
948
  a.className = "input-label", a.textContent = this.translationFunc("cardInformation"), a.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.style.fontSize = `${e.styles.fontSize}px`, i.appendChild(a), r.appendChild(i);
@@ -971,11 +971,11 @@ var K = class extends C {
971
971
  let i = document.createElement("label");
972
972
  i.className = "input-label", i.textContent = this.translationFunc("cardholderNameLabel"), i.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, i.style.fontSize = `${e.styles.fontSize}px`, r.appendChild(i), n.appendChild(r);
973
973
  let a = document.createElement("div");
974
- return a.style.position = "relative", a.style.borderRadius = `${t}px`, a.style.height = B(L, e.styles.fontSize), a.style.width = "100%", a.style.overflow = "hidden", a.style.background = "#fff", a.appendChild(this.createSkeletonDiv()), n.appendChild(a), n.appendChild(this.createHelperTextSpacer("form-helper-text-anchor")), n;
974
+ return a.style.position = "relative", a.style.borderRadius = `${t}px`, a.style.height = H(z, e.styles.fontSize), a.style.width = "100%", a.style.overflow = "hidden", a.style.background = "#fff", a.appendChild(this.createSkeletonDiv()), n.appendChild(a), n.appendChild(this.createHelperTextSpacer("form-helper-text-anchor")), n;
975
975
  }
976
976
  async mountVgsFields(e) {
977
- if (!this.vgsService || !this.cardSection) return;
978
- let t = z(e.styles.fontFamily);
977
+ if (!this.vgsService || !this.cardSection) return !1;
978
+ let t = V(e.styles.fontFamily);
979
979
  await this.vgsService.whenReady();
980
980
  let n = this.cardSection.getVgsContainerIds(), r = this.cardholderSection?.getVgsContainerId(), i = await t, a = this.cardSection.buildVgsFieldCss(e, i);
981
981
  if (this.cardholderSection && a.cardholderName) {
@@ -984,7 +984,7 @@ var K = class extends C {
984
984
  let t = e["border-radius"];
985
985
  typeof t == "string" && this.cardholderSection.setBorderRadius(parseFloat(t));
986
986
  }
987
- this.vgsService.mountCardFields({
987
+ return this.vgsService.mountCardFields({
988
988
  cardNumber: n.cardNumber ? `#${n.cardNumber}` : void 0,
989
989
  cardExpiry: n.cardExpiry ? `#${n.cardExpiry}` : void 0,
990
990
  cardCvv: n.cardCvv ? `#${n.cardCvv}` : void 0,
@@ -996,7 +996,7 @@ var K = class extends C {
996
996
  cardholderName: this.translationFunc("cardholderNamePlaceholder")
997
997
  }, (e) => this.cardSection?.updateVgsCardBrand(e)), await this.vgsService.waitForFieldsReady(), requestAnimationFrame(() => {
998
998
  this.cardSection?.hideFakePlaceholders(), this.cardholderSection?.hideFakePlaceholder();
999
- });
999
+ }), !0;
1000
1000
  }
1001
1001
  handleVgsStateChange(e, t) {
1002
1002
  this.cardSection?.handleVgsStateChange(e, t), this.cardholderSection?.handleVgsStateChange(e, t);
@@ -1016,7 +1016,7 @@ var K = class extends C {
1016
1016
  }
1017
1017
  this.billingAddressSection &&= (this.billingAddressSection.getElement().remove(), void 0), this.shippingAddressSection &&= (this.shippingAddressSection.getElement().remove(), void 0), this.submitButton &&= (this.submitButton.getElement().remove(), void 0), this.paymentMethods &&= (this.paymentMethods.getElement().remove(), void 0);
1018
1018
  }
1019
- }, pe = class {
1019
+ }, me = class {
1020
1020
  formManager;
1021
1021
  focusManager;
1022
1022
  onFormSubmit;
@@ -1056,7 +1056,7 @@ var K = class extends C {
1056
1056
  clearTouchedFields() {
1057
1057
  this.localTouchedFields.clear();
1058
1058
  }
1059
- }, me = class {
1059
+ }, he = class {
1060
1060
  formManager;
1061
1061
  checkoutProfile;
1062
1062
  formElement;
@@ -1079,7 +1079,7 @@ var K = class extends C {
1079
1079
  if (!e.isLoading) {
1080
1080
  if (e.checkoutProfile) try {
1081
1081
  if (e.checkoutProfile.styles?.fontFamily) try {
1082
- let { cleanup: t } = v({ fontFamily: e.checkoutProfile.styles.fontFamily });
1082
+ let { cleanup: t } = ee({ fontFamily: e.checkoutProfile.styles.fontFamily });
1083
1083
  this.fontCleanup = t, this.formElement.style.fontFamily = e.checkoutProfile.styles.fontFamily;
1084
1084
  } catch (e) {
1085
1085
  console.error("Error loading Google Font:", e);
@@ -1120,7 +1120,7 @@ var K = class extends C {
1120
1120
  if (!r?.isTouched || r.isFocused || r.isValid) continue;
1121
1121
  let i = r.errors?.[0];
1122
1122
  if (!i) continue;
1123
- let a = I(n, i.code);
1123
+ let a = R(n, i.code);
1124
1124
  a && (t[n] = e(a));
1125
1125
  }
1126
1126
  return t;
@@ -1131,17 +1131,17 @@ var K = class extends C {
1131
1131
  cleanup() {
1132
1132
  this.fontCleanup &&= (this.fontCleanup(), void 0);
1133
1133
  }
1134
- }, he = class extends C {
1134
+ }, ge = class extends S {
1135
1135
  titleElement;
1136
1136
  constructor(e = {}) {
1137
1137
  super("div", ["blur-bg"]);
1138
- let t = j.createDiv(["loader"]);
1139
- this.titleElement = new C("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
1138
+ let t = A.createDiv(["loader"]);
1139
+ this.titleElement = new S("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
1140
1140
  }
1141
1141
  setText(e) {
1142
1142
  return this.titleElement.setText(e), this;
1143
1143
  }
1144
- }, Y = {
1144
+ }, X = {
1145
1145
  street: "",
1146
1146
  firstName: "",
1147
1147
  lastName: "",
@@ -1149,7 +1149,7 @@ var K = class extends C {
1149
1149
  city: "",
1150
1150
  zipCode: "",
1151
1151
  country: ""
1152
- }, X = (e, t) => {
1152
+ }, Z = (e, t) => {
1153
1153
  let n = {}, r = `${t}.`;
1154
1154
  return Object.keys(e).forEach((t) => {
1155
1155
  if (t.startsWith(r)) {
@@ -1157,7 +1157,7 @@ var K = class extends C {
1157
1157
  n[i] = e[t];
1158
1158
  }
1159
1159
  }), n;
1160
- }, Z = class {
1160
+ }, _e = class {
1161
1161
  formElement;
1162
1162
  componentManager;
1163
1163
  onLoadingStateChange;
@@ -1169,17 +1169,17 @@ var K = class extends C {
1169
1169
  this.formElement = e.formElement, this.componentManager = e.componentManager, this.onLoadingStateChange = e.onLoadingStateChange;
1170
1170
  }
1171
1171
  updateFormUI(e, t) {
1172
- this.componentManager.updatePaymentMethods(e.formData), this.componentManager.updateEmailField(e.formData.email, !!(e.errors.email && e.touched.email), e.errors.email, e.touched.email ? this.validationSchema.emailSuggestion(e.formData.email) : void 0), this.componentManager.updatePhoneNumberField(e.formData.phoneNumber ?? "", !!(e.errors.phoneNumber && e.touched.phoneNumber), e.errors.phoneNumber), this.componentManager.updateCardholderSection(e.formData.name, !!(e.errors.name && e.touched.name), e.errors.name), this.componentManager.updateBillingAddressSection(e.formData.billingAddress ?? Y, e.errors.billingAddress ?? {}, X(e.touched, "billingAddress")), this.componentManager.updateShippingAddressSection(e.formData.shippingAddress ?? Y, e.errors.shippingAddress ?? {}, X(e.touched, "shippingAddress")), this.componentManager.updateSubmitButton(t);
1172
+ this.componentManager.updatePaymentMethods(e.formData), this.componentManager.updateEmailField(e.formData.email, !!(e.errors.email && e.touched.email), e.errors.email, e.touched.email ? this.validationSchema.emailSuggestion(e.formData.email) : void 0), this.componentManager.updatePhoneNumberField(e.formData.phoneNumber ?? "", !!(e.errors.phoneNumber && e.touched.phoneNumber), e.errors.phoneNumber), this.componentManager.updateCardholderSection(e.formData.name, !!(e.errors.name && e.touched.name), e.errors.name), this.componentManager.updateBillingAddressSection(e.formData.billingAddress ?? X, e.errors.billingAddress ?? {}, Z(e.touched, "billingAddress")), this.componentManager.updateShippingAddressSection(e.formData.shippingAddress ?? X, e.errors.shippingAddress ?? {}, Z(e.touched, "shippingAddress")), this.componentManager.updateSubmitButton(t);
1173
1173
  }
1174
1174
  setLoadingState(e) {
1175
1175
  if (this.onLoadingStateChange) {
1176
1176
  this.onLoadingStateChange(e);
1177
1177
  return;
1178
1178
  }
1179
- e ? (this.hideSkeleton(), this.formSkeleton = new J(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
1179
+ e ? (this.hideSkeleton(), this.formSkeleton = new Y(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
1180
1180
  }
1181
1181
  showSpinner(e) {
1182
- this.hideSpinner(), this.spinner = new he({ text: e }), this.formElement.appendChild(this.spinner.getElement());
1182
+ this.hideSpinner(), this.spinner = new ge({ text: e }), this.formElement.appendChild(this.spinner.getElement());
1183
1183
  }
1184
1184
  hideSpinner() {
1185
1185
  this.spinner &&= (this.spinner.getElement().remove(), void 0);
@@ -1188,7 +1188,7 @@ var K = class extends C {
1188
1188
  this.formSkeleton &&= (this.formSkeleton.getElement().remove(), void 0);
1189
1189
  }
1190
1190
  setErrorMessage(e) {
1191
- this.alert &&= (this.alert.getElement().remove(), void 0), this.alert = new P({ message: e }), this.formElement.insertBefore(this.alert.getElement(), this.formElement.firstChild);
1191
+ this.alert &&= (this.alert.getElement().remove(), void 0), this.alert = new I({ message: e }), this.formElement.insertBefore(this.alert.getElement(), this.formElement.firstChild);
1192
1192
  }
1193
1193
  clearErrorMessage() {
1194
1194
  this.alert &&= (this.alert.getElement().remove(), void 0);
@@ -1207,12 +1207,12 @@ var Q = (e) => ({
1207
1207
  zipCode: "",
1208
1208
  country: "",
1209
1209
  ...e
1210
- }), ge = class extends C {
1210
+ }), ve = class extends S {
1211
1211
  options;
1212
1212
  formManager = h();
1213
1213
  checkoutProfile;
1214
- translation = R();
1215
- focusManager = new U();
1214
+ translation = B();
1215
+ focusManager = new G();
1216
1216
  componentManager;
1217
1217
  eventHandler;
1218
1218
  stateCoordinator;
@@ -1226,7 +1226,7 @@ var Q = (e) => ({
1226
1226
  constructor(e) {
1227
1227
  super("form", ["form-container"]), this.options = e;
1228
1228
  let t = !e.supportedPaymentMethods || !!e.supportedPaymentMethods.card;
1229
- e.vgsJwt && t && (this.vgsJwt = e.vgsJwt, this.vgsService = new o()), this.checkoutProfile = ee({ appearance: e.appearance }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new fe({
1229
+ e.vgsJwt && t && (this.vgsJwt = e.vgsJwt, this.vgsService = new u()), this.checkoutProfile = te({ appearance: e.appearance }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new pe({
1230
1230
  formElement: this.element,
1231
1231
  focusManager: this.focusManager,
1232
1232
  translationFunc: this.translation.t,
@@ -1242,11 +1242,11 @@ var Q = (e) => ({
1242
1242
  checkoutDetails: e.checkoutDetails,
1243
1243
  environment: e.environment,
1244
1244
  vgsService: this.vgsService
1245
- }), this.uiManager = new Z({
1245
+ }), this.uiManager = new _e({
1246
1246
  formElement: this.element,
1247
1247
  componentManager: this.componentManager,
1248
1248
  onLoadingStateChange: e.onLoadingStateChange
1249
- }), this.stateCoordinator = new me({
1249
+ }), this.stateCoordinator = new he({
1250
1250
  formManager: this.formManager,
1251
1251
  checkoutProfile: this.checkoutProfile,
1252
1252
  componentManager: this.componentManager,
@@ -1256,7 +1256,7 @@ var Q = (e) => ({
1256
1256
  onError: (e) => this.uiManager.setErrorMessage(e),
1257
1257
  onLoadingChange: (e) => this.uiManager.setLoadingState(e),
1258
1258
  getInitialFormData: () => this._getFormStateData().formData
1259
- }), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new pe({
1259
+ }), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new me({
1260
1260
  formManager: this.formManager,
1261
1261
  focusManager: this.focusManager,
1262
1262
  onFormSubmit: async () => this.handleSubmit(),
@@ -1291,7 +1291,7 @@ var Q = (e) => ({
1291
1291
  }
1292
1292
  initializeForm() {
1293
1293
  if (this.uiManager.setLoadingState(!0), this.options.errorMsg && this.uiManager.setErrorMessage(this.options.errorMsg), !this.vgsService && this.options.paymentId && this.options.checkoutDetails) {
1294
- this.failCardCaptureClosed(M.NO_TOKENIZATION_SESSION);
1294
+ this.failCardCaptureClosed(l.NO_TOKENIZATION_SESSION);
1295
1295
  return;
1296
1296
  }
1297
1297
  if (this.vgsService) {
@@ -1299,7 +1299,7 @@ var Q = (e) => ({
1299
1299
  e.init(this.options.environment).then((t) => {
1300
1300
  this.vgsService === e && e.createForm(t, (e) => this.handleVgsStateChange(e));
1301
1301
  }).catch((t) => {
1302
- this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(M.INIT_FAILED));
1302
+ this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(l.INIT_FAILED));
1303
1303
  });
1304
1304
  }
1305
1305
  }
@@ -1310,7 +1310,10 @@ var Q = (e) => ({
1310
1310
  return;
1311
1311
  }
1312
1312
  let t = this.isCardCaptureUnavailable;
1313
- this.isCardCaptureUnavailable = !0, this.dropVgsService(), this.stateCoordinator.setVgsMode(!1), this.stateCoordinator.setCardCaptureUnavailable(!0), t || g(l.CARD_CAPTURE_UNAVAILABLE, { reason: e }), this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents(), this.updateFormUI();
1313
+ this.isCardCaptureUnavailable = !0, this.dropVgsService(), this.stateCoordinator.setVgsMode(!1), this.stateCoordinator.setCardCaptureUnavailable(!0), this.reportLoadOutcome({
1314
+ status: "failed",
1315
+ reason: e
1316
+ }), t || T(b.CARD_CAPTURE_UNAVAILABLE, { reason: e }), this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents(), this.updateFormUI();
1314
1317
  }
1315
1318
  dropVgsService() {
1316
1319
  let e = this.vgsService;
@@ -1329,7 +1332,7 @@ var Q = (e) => ({
1329
1332
  phoneNumber: "",
1330
1333
  phoneCountryCode: e.checkoutProfile.layout.phoneNumber.defaultCountry?.toUpperCase() || "US"
1331
1334
  }), e.checkoutProfile.layout.billingFields && this.formManager.getFormState().formData.billingAddress === void 0 && this.formManager.setFormData({ billingAddress: Q() }), e.checkoutProfile.layout.shippingFields && this.formManager.getFormState().formData.shippingAddress === void 0 && this.formManager.setFormData({ shippingAddress: Q() });
1332
- let { formData: t, errors: n, touched: r } = this._getFormStateData(), i = W(e.checkoutProfile.layout);
1335
+ let { formData: t, errors: n, touched: r } = this._getFormStateData(), i = K(e.checkoutProfile.layout);
1333
1336
  try {
1334
1337
  this.componentManager.createPaymentMethods(e.checkoutProfile, t);
1335
1338
  } catch (e) {
@@ -1362,15 +1365,17 @@ var Q = (e) => ({
1362
1365
  } catch (e) {
1363
1366
  console.error("Failed to create card section:", e);
1364
1367
  }
1365
- if (!G(e.checkoutProfile.layout) && this.componentManager.isCardSupported()) try {
1368
+ if (!q(e.checkoutProfile.layout) && this.componentManager.isCardSupported()) try {
1366
1369
  this.componentManager.createCardholderSection(e.checkoutProfile, t, n, r);
1367
1370
  } catch (e) {
1368
1371
  console.error("Failed to create cardholder section:", e);
1369
1372
  }
1370
1373
  if (this.vgsService) {
1371
1374
  let t = this.vgsService, n = ++this.vgsMountGeneration;
1372
- this.componentManager.mountVgsFields(e.checkoutProfile).catch((e) => {
1373
- this.vgsMountGeneration === n && this.vgsService === t && (console.error("Failed to mount VGS fields:", e), this.failCardCaptureClosed(M.FIELDS_NOT_READY));
1375
+ this.componentManager.mountVgsFields(e.checkoutProfile).then((e) => {
1376
+ e && this.vgsMountGeneration === n && this.vgsService === t && this.reportLoadOutcome({ status: "ready" });
1377
+ }).catch((e) => {
1378
+ this.vgsMountGeneration === n && this.vgsService === t && (console.error("Failed to mount VGS fields:", e), this.failCardCaptureClosed(l.FIELDS_NOT_READY));
1374
1379
  });
1375
1380
  }
1376
1381
  try {
@@ -1378,6 +1383,10 @@ var Q = (e) => ({
1378
1383
  } catch (e) {
1379
1384
  console.error("Failed to create submit button:", e);
1380
1385
  }
1386
+ this.options.checkoutDetails && !this.componentManager.isCardSupported() && this.reportLoadOutcome({ status: "ready" });
1387
+ }
1388
+ reportLoadOutcome(e) {
1389
+ this.isDestroyed || this.options.onLoadOutcome?.(e);
1381
1390
  }
1382
1391
  updateFormUI() {
1383
1392
  let e = this.formManager.getFormState();
@@ -1385,7 +1394,7 @@ var Q = (e) => ({
1385
1394
  }
1386
1395
  inferCardholderName() {
1387
1396
  let e = this.checkoutProfile.getState();
1388
- if (!e.checkoutProfile || !G(e.checkoutProfile.layout)) return;
1397
+ if (!e.checkoutProfile || !q(e.checkoutProfile.layout)) return;
1389
1398
  let { formData: t } = this._getFormStateData(), n = t.billingAddress ?? t.shippingAddress;
1390
1399
  if (!n) return;
1391
1400
  let r = [n.firstName?.trim() ?? "", n.lastName?.trim() ?? ""].filter(Boolean).join(" ");
@@ -1468,21 +1477,21 @@ var Q = (e) => ({
1468
1477
  this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = n, this.options.checkoutDetails = r, this.componentManager.setCheckoutDetailsLoaded(!0), this.componentManager.updateSupportedPaymentMethods(n);
1469
1478
  let a = this.componentManager.isCardSupported();
1470
1479
  if (i && a && (this.vgsJwt = i), i && a && !this.vgsService) {
1471
- let e = new o();
1480
+ let e = new u();
1472
1481
  this.vgsService = e, this.componentManager.setVgsService(e), this.stateCoordinator.setVgsMode(!0), e.init(this.options.environment).then((t) => {
1473
1482
  this.vgsService === e && (e.createForm(t, (e) => this.handleVgsStateChange(e)), this.recoverCardCapture(), this.renderFormComponents());
1474
1483
  }).catch((t) => {
1475
- this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(M.INIT_FAILED));
1484
+ this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(l.INIT_FAILED));
1476
1485
  });
1477
1486
  }
1478
- this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t, r), (!i || !a) && this.failCardCaptureClosed(M.NO_TOKENIZATION_SESSION);
1479
- let s = this.checkoutProfile.getState();
1480
- if (s.checkoutProfile) {
1487
+ this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t, r), (!i || !a) && this.failCardCaptureClosed(l.NO_TOKENIZATION_SESSION);
1488
+ let o = this.checkoutProfile.getState();
1489
+ if (o.checkoutProfile) {
1481
1490
  let { formData: e } = this._getFormStateData();
1482
- this.componentManager.createPaymentMethods(s.checkoutProfile, e, !0);
1491
+ this.componentManager.createPaymentMethods(o.checkoutProfile, e, !0);
1483
1492
  }
1484
1493
  }
1485
- }, _e = class {
1494
+ }, ye = class {
1486
1495
  container = null;
1487
1496
  options;
1488
1497
  onSubmit;
@@ -1506,7 +1515,7 @@ var Q = (e) => ({
1506
1515
  }
1507
1516
  }
1508
1517
  renderForm(e) {
1509
- this.container && (this.form &&= (this.form.destroy(), null), this.form = new ge({
1518
+ this.container && (this.form &&= (this.form.destroy(), null), this.form = new ve({
1510
1519
  apiKey: this.options.apiKey,
1511
1520
  onSubmit: this.onSubmit,
1512
1521
  locale: this.options.locale,
@@ -1515,6 +1524,7 @@ var Q = (e) => ({
1515
1524
  environment: this.options.environment,
1516
1525
  appearance: this.options.appearance,
1517
1526
  onLoadingStateChange: this.options.onLoadingStateChange,
1527
+ onLoadOutcome: this.options.onLoadOutcome,
1518
1528
  paymentId: this.options.paymentId,
1519
1529
  checkoutKey: this.options.checkoutKey,
1520
1530
  checkoutDetails: this.options.checkoutDetails,
@@ -1536,7 +1546,7 @@ var Q = (e) => ({
1536
1546
  async associatePayment(e, t, n, r, i) {
1537
1547
  this.options.paymentId = e, this.options.checkoutKey = t, this.options.checkoutDetails = r, this.options.vgsJwt = i, this.options.supportedPaymentMethods = n, this.form && this.form.associatePayment(e, t, n, r, i);
1538
1548
  }
1539
- }, ve = class {
1549
+ }, be = class {
1540
1550
  state;
1541
1551
  listeners = /* @__PURE__ */ new Set();
1542
1552
  constructor(e) {
@@ -1560,7 +1570,7 @@ var Q = (e) => ({
1560
1570
  let e = this.getState();
1561
1571
  this.listeners.forEach((t) => t(e));
1562
1572
  }
1563
- }, ye = "en", $ = class {
1573
+ }, xe = "en", $ = class {
1564
1574
  config;
1565
1575
  _callbacks;
1566
1576
  paymentState;
@@ -1568,22 +1578,27 @@ var Q = (e) => ({
1568
1578
  formManager;
1569
1579
  stateManager;
1570
1580
  sessionId;
1581
+ loadTimer = new v();
1582
+ associationSequence = 0;
1571
1583
  constructor(e) {
1572
- this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(), y(), b({
1584
+ this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(), o(), g({
1573
1585
  environment: this.config.environment,
1574
1586
  sessionId: this.sessionId,
1575
1587
  integration: "dropin"
1576
- }), g(l.CHECKOUT_INITIALIZED, { environment: this.config.environment }), this.apiService = new n(this.config.apiKey, this.config.environment), this.stateManager = new ve({
1588
+ }), T(b.CHECKOUT_INITIALIZED, { environment: this.config.environment }), this.apiService = new n(this.config.apiKey, this.config.environment), this.stateManager = new be({
1577
1589
  mounted: !1,
1578
1590
  form: null
1579
- }), this.formManager = new _e({
1591
+ }), this.formManager = new ye({
1580
1592
  locale: this.config.locale,
1581
1593
  apiKey: this.config.apiKey,
1582
1594
  disableErrorMessages: this.config.disableErrorMessages,
1583
1595
  environment: this.config.environment,
1584
1596
  appearance: this.config.appearance,
1585
1597
  onLoadingStateChange: (...e) => this._callbacks.onLoadingStateChange?.(...e),
1586
- initialValues: this.config.initialValues
1598
+ initialValues: this.config.initialValues,
1599
+ onLoadOutcome: (e) => {
1600
+ this.loadTimer.markMounted(), this.loadTimer.settle(e);
1601
+ }
1587
1602
  }, this.handleSubmit.bind(this));
1588
1603
  }
1589
1604
  validateConfig(e) {
@@ -1593,7 +1608,7 @@ var Q = (e) => ({
1593
1608
  apiKey: e.apiKey,
1594
1609
  returnUrl: e.returnUrl,
1595
1610
  environment: e.environment,
1596
- locale: e.locale || ye,
1611
+ locale: e.locale || xe,
1597
1612
  disableErrorMessages: e.disableErrorMessages ?? !1,
1598
1613
  manualActionHandling: e.manualActionHandling ?? !1,
1599
1614
  appearance: e.appearance,
@@ -1606,23 +1621,23 @@ var Q = (e) => ({
1606
1621
  }
1607
1622
  };
1608
1623
  }
1609
- mount(e) {
1610
- let t;
1624
+ mount(t) {
1625
+ let n;
1611
1626
  try {
1612
- let n = document.querySelector(e);
1613
- if (!n) throw Error(`Container ${e} not found`);
1614
- return t = document.createElement("div"), n.appendChild(t), this.stateManager.updateState({
1615
- form: t,
1627
+ let e = document.querySelector(t);
1628
+ if (!e) throw Error(`Container ${t} not found`);
1629
+ return n = document.createElement("div"), e.appendChild(n), this.stateManager.updateState({
1630
+ form: n,
1616
1631
  mounted: !0
1617
- }), this.formManager.mount(t), g(l.CHECKOUT_MOUNTED, { container_id: e }), this;
1618
- } catch (n) {
1619
- throw t?.remove(), this.stateManager.updateState({
1632
+ }), this.formManager.mount(n), this.loadTimer.markMounted(), T(b.CHECKOUT_MOUNTED, { container_id: t }), this;
1633
+ } catch (r) {
1634
+ throw n?.remove(), this.stateManager.updateState({
1620
1635
  form: null,
1621
1636
  mounted: !1
1622
- }), g(l.CHECKOUT_MOUNT_FAILED, {
1623
- container_id: e,
1624
- error_message: n instanceof Error ? n.message : "Unknown error"
1625
- }), S(n instanceof Error ? n : /* @__PURE__ */ Error("Failed to mount checkout"), { container_id: e }), n;
1637
+ }), T(b.CHECKOUT_MOUNT_FAILED, {
1638
+ container_id: t,
1639
+ error_message: r instanceof Error ? r.message : "Unknown error"
1640
+ }), e(r instanceof Error ? r : /* @__PURE__ */ Error("Failed to mount checkout"), { container_id: t }), r;
1626
1641
  }
1627
1642
  }
1628
1643
  unmount() {
@@ -1633,13 +1648,13 @@ var Q = (e) => ({
1633
1648
  e && e.remove(), this.stateManager.updateState({
1634
1649
  form: null,
1635
1650
  mounted: !1
1636
- }), g(l.CHECKOUT_UNMOUNTED);
1651
+ }), T(b.CHECKOUT_UNMOUNTED);
1637
1652
  });
1638
1653
  }
1639
1654
  async handleSubmit({ formData: e, applePayData: t }) {
1640
1655
  if (!this.paymentState.paymentId || !this.paymentState.checkoutKey) throw Error("Payment must be associated before submitting. Call associatePayment() first.");
1641
1656
  let n = this.getPaymentMethod(e, t);
1642
- g(l.PAYMENT_SUBMIT_STARTED, {
1657
+ T(b.PAYMENT_SUBMIT_STARTED, {
1643
1658
  payment_id: this.paymentState.paymentId,
1644
1659
  payment_method: n
1645
1660
  });
@@ -1652,21 +1667,21 @@ var Q = (e) => ({
1652
1667
  returnUrl: this.config.returnUrl,
1653
1668
  applePayData: t
1654
1669
  }), a = performance.now() - r;
1655
- return T(x.PAYMENT_AUTHORIZATION_TIME, a, "ms", {
1670
+ return j(x.PAYMENT_AUTHORIZATION_TIME, a, "ms", {
1656
1671
  payment_id: this.paymentState.paymentId,
1657
1672
  payment_method: n,
1658
1673
  status: "success"
1659
- }), g(l.PAYMENT_SUBMIT_SUCCESS, {
1674
+ }), T(b.PAYMENT_SUBMIT_SUCCESS, {
1660
1675
  payment_id: this.paymentState.paymentId,
1661
1676
  payment_method: n
1662
1677
  }), this.handlePaymentResponse(i);
1663
1678
  } catch (e) {
1664
1679
  let t = performance.now() - r;
1665
- return T(x.PAYMENT_AUTHORIZATION_TIME, t, "ms", {
1680
+ return j(x.PAYMENT_AUTHORIZATION_TIME, t, "ms", {
1666
1681
  payment_id: this.paymentState.paymentId,
1667
1682
  payment_method: n,
1668
1683
  status: "failed"
1669
- }), g(l.PAYMENT_SUBMIT_FAILED, {
1684
+ }), T(b.PAYMENT_SUBMIT_FAILED, {
1670
1685
  payment_id: this.paymentState.paymentId,
1671
1686
  payment_method: n,
1672
1687
  error_message: e.details?.message ?? "Unknown error"
@@ -1675,15 +1690,15 @@ var Q = (e) => ({
1675
1690
  }
1676
1691
  handlePaymentResponse(e) {
1677
1692
  let t = !1;
1678
- if (e.latestTransaction.status === "authorized" && (g(l.PAYMENT_AUTHORIZED, {
1693
+ if (e.latestTransaction.status === "authorized" && (T(b.PAYMENT_AUTHORIZED, {
1679
1694
  payment_id: this.paymentState.paymentId ?? "",
1680
1695
  status: e.latestTransaction.status
1681
- }), this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status), t = !0), e.latestTransaction.status === "failed" && (g(l.PAYMENT_FAILED, {
1696
+ }), this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status), t = !0), e.latestTransaction.status === "failed" && (T(b.PAYMENT_FAILED, {
1682
1697
  payment_id: this.paymentState.paymentId ?? "",
1683
1698
  status: e.latestTransaction.status
1684
1699
  }), this._callbacks.onPaymentFailed?.(e.latestTransaction.status)), e.status === "requires_action") {
1685
1700
  let { redirectUrl: n } = e.action;
1686
- g(l.PAYMENT_ACTION_REQUIRED, {
1701
+ T(b.PAYMENT_ACTION_REQUIRED, {
1687
1702
  payment_id: this.paymentState.paymentId ?? "",
1688
1703
  status: e.status
1689
1704
  }), this.config.manualActionHandling ? this._callbacks.onActionRequired?.(n) : globalThis.location.href = n, t = !0;
@@ -1716,33 +1731,37 @@ var Q = (e) => ({
1716
1731
  locale: e.locale
1717
1732
  });
1718
1733
  }
1719
- async associatePayment(e, t) {
1720
- if (!e || !t) throw Error("paymentId and checkoutKey are required");
1721
- this.paymentState.paymentId = e, this.paymentState.checkoutKey = t, u(this.config.environment);
1734
+ async associatePayment(t, n) {
1735
+ if (!t || !n) throw Error("paymentId and checkoutKey are required");
1736
+ let r = ++this.associationSequence;
1737
+ this.paymentState.paymentId = t, this.paymentState.checkoutKey = n, M(this.config.environment);
1722
1738
  try {
1723
- let n = await F({
1724
- id: e,
1725
- checkoutKey: t,
1739
+ let e = await P({
1740
+ id: t,
1741
+ checkoutKey: n,
1726
1742
  environment: this.config.environment
1727
1743
  });
1728
- if (!n || !n.supportedPaymentMethods || !Array.isArray(n.supportedPaymentMethods)) throw Error("Invalid response: supportedPaymentMethods must be an array");
1729
- if (!n.supportedPaymentMethods.every((e) => typeof e == "string")) throw Error("Invalid response: all supportedPaymentMethods must be strings");
1730
- this.paymentState.checkoutDetails = {
1731
- amount: n.amount,
1732
- currency: n.currency,
1733
- countryCode: n.countryCode
1744
+ if (!e || !e.supportedPaymentMethods || !Array.isArray(e.supportedPaymentMethods)) throw Error("Invalid response: supportedPaymentMethods must be an array");
1745
+ if (!e.supportedPaymentMethods.every((e) => typeof e == "string")) throw Error("Invalid response: all supportedPaymentMethods must be strings");
1746
+ this.loadTimer.markAssociated(), this.paymentState.checkoutDetails = {
1747
+ amount: e.amount,
1748
+ currency: e.currency,
1749
+ countryCode: e.countryCode
1734
1750
  };
1735
- let r = n.supportedPaymentMethods.reduce((e, t) => (e[t] = !0, e), {});
1736
- await this.formManager.associatePayment(e, t, r, this.paymentState.checkoutDetails, n.vgsJwt), g(l.PAYMENT_ASSOCIATED, {
1737
- payment_id: e,
1738
- currency: n.currency,
1739
- country_code: n.countryCode
1751
+ let r = e.supportedPaymentMethods.reduce((e, t) => (e[t] = !0, e), {});
1752
+ await this.formManager.associatePayment(t, n, r, this.paymentState.checkoutDetails, e.vgsJwt), T(b.PAYMENT_ASSOCIATED, {
1753
+ payment_id: t,
1754
+ currency: e.currency,
1755
+ country_code: e.countryCode
1740
1756
  });
1741
- } catch (t) {
1742
- throw g(l.PAYMENT_ASSOCIATION_FAILED, {
1743
- payment_id: e,
1744
- error_message: t instanceof Error ? t.message : "Unknown error"
1745
- }), S(t instanceof Error ? t : /* @__PURE__ */ Error("Failed to associate payment"), { payment_id: e }), t;
1757
+ } catch (n) {
1758
+ throw T(b.PAYMENT_ASSOCIATION_FAILED, {
1759
+ payment_id: t,
1760
+ error_message: n instanceof Error ? n.message : "Unknown error"
1761
+ }), e(n instanceof Error ? n : /* @__PURE__ */ Error("Failed to associate payment"), { payment_id: t }), r === this.associationSequence && this.loadTimer.settle({
1762
+ status: "failed",
1763
+ reason: y.ASSOCIATION_FAILED
1764
+ }), n;
1746
1765
  }
1747
1766
  }
1748
1767
  setCallbacks(e) {
@@ -1753,4 +1772,4 @@ var Q = (e) => ({
1753
1772
  //#region libs/checkout/src/index.ts
1754
1773
  typeof globalThis < "u" && (globalThis.OdusCheckout = $);
1755
1774
  //#endregion
1756
- export { $ as OdusCheckout, p as deLocale, f as enLocale, k as esLocale, t as frLocale, re as itLocale, m as plLocale, r as ptLocale, S as pushError, g as pushEvent, e as pushLog, T as pushMeasurement, i as trLocale };
1775
+ export { $ as OdusCheckout, p as deLocale, f as enLocale, O as esLocale, t as frLocale, ie as itLocale, m as plLocale, r as ptLocale, e as pushError, T as pushEvent, L as pushLog, j as pushMeasurement, i as trLocale };