@odus/checkout 0.1.2 → 0.2.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.
@@ -1,30 +1,30 @@
1
- const M = (n) => n === "test" ? "https://sandbox-api.odus.com" : n === "live" ? "https://api.odus.com" : "http://localhost:3000", D = ({ name: n }) => {
2
- const [e, ...t] = n?.split(" ") || [], [i] = t.reverse();
3
- return { firstName: e, lastName: i };
1
+ const L = (n) => n === "test" ? "https://sandbox-api.odus.com" : n === "live" ? "https://api.odus.com" : "http://localhost:3000", A = ({ name: n }) => {
2
+ const [e, ...t] = n?.split(" ") || [], [a] = t.reverse();
3
+ return { firstName: e, lastName: a };
4
4
  };
5
5
  class V {
6
6
  apiKey;
7
7
  baseUrl;
8
8
  browserInfo;
9
- constructor(e, t, i) {
10
- this.apiKey = e, this.baseUrl = M(t), this.browserInfo = i || { userAgent: navigator.userAgent };
9
+ constructor(e, t, a) {
10
+ this.apiKey = e, this.baseUrl = L(t), this.browserInfo = a || { userAgent: navigator.userAgent };
11
11
  }
12
12
  async fetchApi({
13
13
  endpoint: e,
14
14
  method: t = "POST",
15
- body: i,
16
- customHeaders: a = {}
15
+ body: a,
16
+ customHeaders: i = {}
17
17
  }) {
18
18
  const s = {
19
19
  Authorization: `Bearer ${this.apiKey}`,
20
20
  "Content-Type": "application/json",
21
- ...a
21
+ ...i
22
22
  };
23
23
  try {
24
24
  const r = await fetch(`${this.baseUrl}${e}`, {
25
25
  method: t,
26
26
  headers: s,
27
- body: i ? JSON.stringify(i) : void 0
27
+ body: a ? JSON.stringify(a) : void 0
28
28
  });
29
29
  if (!r.ok) {
30
30
  let o;
@@ -54,25 +54,25 @@ class V {
54
54
  async authorizePayment({
55
55
  paymentId: e,
56
56
  checkoutKey: t,
57
- formData: i,
58
- token: a,
57
+ formData: a,
58
+ token: i,
59
59
  returnUrl: s
60
60
  }) {
61
61
  let r = {};
62
- if (a && i) {
63
- const o = i.cardExpiry.replace(/\s+/g, "").split("/"), l = o[0], c = o[1], { firstName: h, lastName: m } = D({ name: i.name });
62
+ if (i && a) {
63
+ const o = a.cardExpiry.replace(/\s+/g, "").split("/"), l = o[0], c = o[1], { firstName: h, lastName: m } = A({ name: a.name });
64
64
  r = {
65
65
  paymentMethodData: {
66
66
  type: "card",
67
67
  card: {
68
- token: a,
68
+ token: i,
69
69
  expMonth: l,
70
70
  expYear: `20${c}`,
71
- cardholderName: i.name
71
+ cardholderName: a.name
72
72
  }
73
73
  },
74
74
  customerData: {
75
- email: i.email,
75
+ email: a.email,
76
76
  firstName: h,
77
77
  lastName: m
78
78
  },
@@ -100,23 +100,23 @@ class V {
100
100
  });
101
101
  }
102
102
  }
103
- const A = async ({
103
+ const $ = async ({
104
104
  id: n,
105
105
  apiKey: e,
106
106
  environment: t
107
107
  }) => {
108
- const i = M(t), a = await fetch(`${i}/checkout-profiles/${n}`, {
108
+ const a = L(t), i = await fetch(`${a}/checkout-profiles/${n}`, {
109
109
  method: "GET",
110
110
  headers: {
111
111
  "Content-Type": "application/json",
112
112
  Authorization: `Bearer ${e}`
113
113
  }
114
114
  });
115
- if (!a.ok)
116
- throw new Error(`HTTP error! Status: ${a.status}`);
117
- return await a.json();
115
+ if (!i.ok)
116
+ throw new Error(`HTTP error! Status: ${i.status}`);
117
+ return await i.json();
118
118
  };
119
- class $ {
119
+ class R {
120
120
  events = /* @__PURE__ */ new Map();
121
121
  /**
122
122
  * Subscribe to an event
@@ -126,8 +126,8 @@ class $ {
126
126
  */
127
127
  subscribe(e, t) {
128
128
  return this.events.has(e) || this.events.set(e, /* @__PURE__ */ new Set()), this.events.get(e)?.add(t), () => {
129
- const i = this.events.get(e);
130
- i && (i.delete(t), i.size === 0 && this.events.delete(e));
129
+ const a = this.events.get(e);
130
+ a && (a.delete(t), a.size === 0 && this.events.delete(e));
131
131
  };
132
132
  }
133
133
  /**
@@ -136,8 +136,8 @@ class $ {
136
136
  * @param data - The data to pass to subscribers
137
137
  */
138
138
  publish(e, t) {
139
- const i = this.events.get(e);
140
- i && i.forEach((a) => a(t));
139
+ const a = this.events.get(e);
140
+ a && a.forEach((i) => i(t));
141
141
  }
142
142
  /**
143
143
  * Clear all event subscriptions
@@ -154,13 +154,13 @@ class $ {
154
154
  return this.events.get(e)?.size || 0;
155
155
  }
156
156
  }
157
- const R = new $();
158
- class B {
157
+ const B = new R();
158
+ class O {
159
159
  state;
160
160
  initialState;
161
161
  eventBus;
162
162
  stateChangedEvent = "state-changed";
163
- constructor(e, t = R) {
163
+ constructor(e, t = B) {
164
164
  this.initialState = { ...e }, this.state = { ...e }, this.eventBus = t;
165
165
  }
166
166
  /**
@@ -201,41 +201,41 @@ class B {
201
201
  }
202
202
  }
203
203
  function x(n) {
204
- return new B(n);
204
+ return new O(n);
205
205
  }
206
- function O({
206
+ function H({
207
207
  apiKey: n,
208
208
  profileId: e,
209
209
  environment: t
210
210
  }) {
211
- const i = x({
211
+ const a = x({
212
212
  checkoutProfile: void 0,
213
213
  isLoading: !0,
214
214
  error: null
215
- }), a = async () => {
215
+ }), i = async () => {
216
216
  try {
217
- i.setState({ isLoading: !0 });
218
- const s = await A({
217
+ a.setState({ isLoading: !0 });
218
+ const s = await $({
219
219
  apiKey: n,
220
220
  id: e,
221
221
  environment: t
222
222
  });
223
- s && i.setState({
223
+ s && a.setState({
224
224
  checkoutProfile: s,
225
225
  isLoading: !1,
226
226
  error: null
227
227
  });
228
228
  } catch (s) {
229
- i.setState({
229
+ a.setState({
230
230
  error: "Failed to load checkout profile",
231
231
  isLoading: !1
232
232
  }), console.error(s);
233
233
  }
234
234
  };
235
- return a(), {
236
- getState: i.getState.bind(i),
237
- subscribe: i.subscribe.bind(i),
238
- reload: a
235
+ return i(), {
236
+ getState: a.getState.bind(a),
237
+ subscribe: a.subscribe.bind(a),
238
+ reload: i
239
239
  };
240
240
  }
241
241
  const T = {
@@ -244,7 +244,7 @@ const T = {
244
244
  const t = n.replace(/\D/g, "").slice(0, 4);
245
245
  return t.length > 2 ? `${t.slice(0, 2)} / ${t.slice(2)}` : t;
246
246
  }
247
- }, N = {
247
+ }, P = {
248
248
  "gmail.com": [
249
249
  "gmal.com",
250
250
  "gmil.com",
@@ -316,7 +316,7 @@ const T = {
316
316
  "comcast.net": ["comcast.com", "comcat.net", "comcst.net", "comcastnet", "comcast.nt", "comcas.net"],
317
317
  "verizon.net": ["verizon.com", "verizon.nt", "verizonnet", "verizn.net", "verizon.ne", "verzon.net"],
318
318
  "att.net": ["att.com", "at.net", "att.nt", "attnet", "att.ne", "attt.net"]
319
- }, H = (n) => {
319
+ }, j = (n) => {
320
320
  if (!n || n.includes("."))
321
321
  return null;
322
322
  const e = ["com", "net", "org", "edu", "gov", "io", "co"];
@@ -324,60 +324,60 @@ const T = {
324
324
  if (n === "companycok" && t === "co")
325
325
  return "company.co";
326
326
  if (n.endsWith(t) && !n.includes(".")) {
327
- const i = n.length - t.length;
328
- return `${n.substring(0, i)}.${t}`;
327
+ const a = n.length - t.length;
328
+ return `${n.substring(0, a)}.${t}`;
329
329
  }
330
330
  }
331
331
  return null;
332
- }, j = (n, e) => {
332
+ }, K = (n, e) => {
333
333
  if (n.length === 0) return e.length;
334
334
  if (e.length === 0) return n.length;
335
- const t = e.length + 1, i = n.length + 1, a = Array.from(
335
+ const t = e.length + 1, a = n.length + 1, i = Array.from(
336
336
  { length: t },
337
- (s, r) => Array.from({ length: i }, (o, l) => r === 0 ? l : l === 0 ? r : 0)
337
+ (s, r) => Array.from({ length: a }, (o, l) => r === 0 ? l : l === 0 ? r : 0)
338
338
  );
339
339
  for (let s = 1; s < t; s++)
340
- for (let r = 1; r < i; r++) {
340
+ for (let r = 1; r < a; r++) {
341
341
  const o = n[r - 1] === e[s - 1] ? 0 : 1;
342
- a[s][r] = Math.min(
343
- a[s - 1][r] + 1,
342
+ i[s][r] = Math.min(
343
+ i[s - 1][r] + 1,
344
344
  // deletion
345
- a[s][r - 1] + 1,
345
+ i[s][r - 1] + 1,
346
346
  // insertion
347
- a[s - 1][r - 1] + o
347
+ i[s - 1][r - 1] + o
348
348
  // substitution
349
349
  );
350
350
  }
351
- return a[e.length][n.length];
352
- }, K = (n) => {
353
- let t = null, i = 3;
354
- const a = n.toLowerCase();
355
- for (const s of Object.keys(N)) {
356
- const r = j(a, s);
357
- r <= 2 && r < i && (i = r, t = s);
351
+ return i[e.length][n.length];
352
+ }, U = (n) => {
353
+ let t = null, a = 3;
354
+ const i = n.toLowerCase();
355
+ for (const s of Object.keys(P)) {
356
+ const r = K(i, s);
357
+ r <= 2 && r < a && (a = r, t = s);
358
358
  }
359
359
  return t;
360
- }, U = () => {
361
- const { t: n } = L();
360
+ }, q = () => {
361
+ const { t: n } = M();
362
362
  return {
363
363
  validateEmail: (t) => {
364
- const i = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
364
+ const a = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
365
365
  if (!t)
366
366
  return {
367
367
  isValid: !1,
368
368
  message: n("validation.emailInvalid"),
369
369
  suggestion: null
370
370
  };
371
- const a = t.indexOf("@");
372
- if (a === -1)
371
+ const i = t.indexOf("@");
372
+ if (i === -1)
373
373
  return {
374
374
  isValid: !1,
375
375
  message: n("validation.emailInvalid"),
376
376
  suggestion: null
377
377
  };
378
- const s = t.substring(0, a), r = t.substring(a + 1);
378
+ const s = t.substring(0, i), r = t.substring(i + 1);
379
379
  if (!r.includes(".")) {
380
- const l = H(r);
380
+ const l = j(r);
381
381
  if (l)
382
382
  return {
383
383
  isValid: !1,
@@ -386,7 +386,7 @@ const T = {
386
386
  }),
387
387
  suggestion: `${s}@${l}`
388
388
  };
389
- for (const c of Object.keys(N))
389
+ for (const c of Object.keys(P))
390
390
  if (c.replace(/\./g, "") === r)
391
391
  return {
392
392
  isValid: !1,
@@ -396,13 +396,13 @@ const T = {
396
396
  suggestion: `${s}@${c}`
397
397
  };
398
398
  }
399
- if (!i.test(t))
399
+ if (!a.test(t))
400
400
  return {
401
401
  isValid: !1,
402
402
  message: n("validation.emailInvalid"),
403
403
  suggestion: null
404
404
  };
405
- const o = K(r);
405
+ const o = U(r);
406
406
  if (o && o !== r) {
407
407
  const l = `${s}@${o}`;
408
408
  return {
@@ -418,30 +418,30 @@ const T = {
418
418
  };
419
419
  }
420
420
  };
421
- }, q = () => {
422
- const { t: n } = L(), { validateEmail: e } = U();
421
+ }, _ = () => {
422
+ const { t: n } = M(), { validateEmail: e } = q();
423
423
  return {
424
424
  email: (t) => {
425
- const i = e(t);
426
- return i.isValid ? void 0 : i.message;
425
+ const a = e(t);
426
+ return a.isValid ? void 0 : a.message;
427
427
  },
428
428
  name: (t) => {
429
429
  if (!t.trim())
430
430
  return n("validation.nameRequired");
431
431
  },
432
432
  cardExpiry: (t) => {
433
- const i = t.replace(/\s/g, ""), [a, s] = i.split("/").map((m) => m.trim());
434
- if (!a || !s || a.length !== 2 || s.length !== 2)
433
+ const a = t.replace(/\s/g, ""), [i, s] = a.split("/").map((m) => m.trim());
434
+ if (!i || !s || i.length !== 2 || s.length !== 2)
435
435
  return n("validation.cardExpiryFormat");
436
- const r = /* @__PURE__ */ new Date(), o = r.getFullYear() % 100, l = r.getMonth() + 1, c = parseInt(a, 10), h = parseInt(s, 10);
436
+ const r = /* @__PURE__ */ new Date(), o = r.getFullYear() % 100, l = r.getMonth() + 1, c = parseInt(i, 10), h = parseInt(s, 10);
437
437
  if (c < 1 || c > 12)
438
438
  return n("validation.cardExpiryFormat");
439
439
  if (h < o || h === o && c < l)
440
440
  return n("validation.cardExpiryInvalid");
441
441
  }
442
442
  };
443
- }, _ = () => {
444
- const n = q(), e = x({
443
+ }, G = () => {
444
+ const n = _(), e = x({
445
445
  formData: {
446
446
  name: "",
447
447
  email: "",
@@ -457,14 +457,14 @@ const T = {
457
457
  }), t = (l, c) => {
458
458
  const h = n[l];
459
459
  return h?.(c);
460
- }, i = (l) => {
460
+ }, a = (l) => {
461
461
  const c = {};
462
462
  return Object.keys(l).forEach((h) => {
463
463
  const m = t(h, l[h]);
464
464
  m && (c[h] = m);
465
465
  }), c;
466
- }, a = (l) => {
467
- const c = i(l);
466
+ }, i = (l) => {
467
+ const c = a(l);
468
468
  return Object.keys(c).length === 0;
469
469
  }, s = (l, c) => {
470
470
  const h = e.getState();
@@ -481,7 +481,7 @@ const T = {
481
481
  e.setState({
482
482
  formData: u,
483
483
  errors: p,
484
- isValid: a(u)
484
+ isValid: i(u)
485
485
  });
486
486
  }, r = (l, c) => {
487
487
  const h = e.getState(), m = {
@@ -499,7 +499,7 @@ const T = {
499
499
  };
500
500
  e.setState({
501
501
  formData: h,
502
- isValid: a(h)
502
+ isValid: i(h)
503
503
  });
504
504
  };
505
505
  return {
@@ -510,13 +510,13 @@ const T = {
510
510
  setFormData: o,
511
511
  reset: e.resetState.bind(e)
512
512
  };
513
- }, G = async ({
513
+ }, Z = async ({
514
514
  props: n,
515
515
  apiKey: e,
516
516
  environment: t
517
517
  }) => {
518
- const i = M(t), a = await fetch(
519
- `${i}/tokenization/generate-iframe-configuration`,
518
+ const a = L(t), i = await fetch(
519
+ `${a}/tokenization/generate-iframe-configuration`,
520
520
  {
521
521
  method: "POST",
522
522
  headers: {
@@ -526,17 +526,17 @@ const T = {
526
526
  body: JSON.stringify(n)
527
527
  }
528
528
  );
529
- if (!a.ok)
530
- throw new Error(`HTTP error! Status: ${a.status}`);
531
- return await a.json();
529
+ if (!i.ok)
530
+ throw new Error(`HTTP error! Status: ${i.status}`);
531
+ return await i.json();
532
532
  };
533
- function Z({
533
+ function Y({
534
534
  apiKey: n,
535
535
  // scriptLoaded,
536
536
  checkoutProfile: e,
537
537
  inputStyles: t,
538
- setFormData: i,
539
- environment: a
538
+ setFormData: a,
539
+ environment: i
540
540
  }) {
541
541
  const s = x({
542
542
  iframeConfig: void 0,
@@ -550,12 +550,12 @@ function Z({
550
550
  let r = null;
551
551
  const o = async () => {
552
552
  try {
553
- const m = await G({
553
+ const m = await Z({
554
554
  props: {
555
555
  allowedOrigins: [globalThis.location.origin]
556
556
  },
557
557
  apiKey: n,
558
- environment: a
558
+ environment: i
559
559
  });
560
560
  m && (s.setState({
561
561
  iframeConfig: {
@@ -601,7 +601,7 @@ function Z({
601
601
  s.setState({ loadingIframe: !1 });
602
602
  }), r.on("autoCompleteValues", function(u) {
603
603
  const { nameOnCard: p, cardExp: f } = u;
604
- i({
604
+ a({
605
605
  name: p,
606
606
  cardExpiry: f
607
607
  });
@@ -642,70 +642,70 @@ function Z({
642
642
  cleanup: c
643
643
  };
644
644
  }
645
- const Y = "E-Mail", J = "Name des/der Karteninhaber/in", W = "Kartendaten", X = "Vollständiger Name", Q = "MM / JJ", ee = "Das Fenster nicht schließen", te = { pay: "ZAHLEN", submit: "ABSENDEN", getPlan: "MEINEN PLAN ERHALTEN", donate: "spenden", book: "jetzt buchen", order: "jetzt bestellen" }, ie = { emailSuggestion: "Meinten Sie {{email}}?", emailInvalid: "Ihre E-Mail-Adresse ist nicht korrekt", cardExpiryInvalid: "Das Ablaufdatum Ihrer Karte liegt in der Vergangenheit", cardExpiryFormat: "Das Ablaufdatum Ihrer Karte ist unvollständig", cardSecurityFormat: "Der Sicherheitscode Ihrer Karte ist unvollständig", nameRequired: "Gib deinen Namen genau so ein, wie er auf deiner Karte steht", cardNumberInvalid: "Die Kartennummer ist unvollständig" }, ae = {
646
- email: Y,
647
- cardholderNameLabel: J,
648
- cardInformation: W,
649
- cardholderNamePlaceholder: X,
650
- cardExpiry: Q,
651
- loading: ee,
652
- buttonTexts: te,
645
+ const J = "E-Mail", W = "Name des/der Karteninhaber/in", X = "Kartendaten", Q = "Vollständiger Name", ee = "MM / JJ", te = "Das Fenster nicht schließen", ae = { pay: "ZAHLEN", submit: "ABSENDEN", getPlan: "MEINEN PLAN ERHALTEN", donate: "spenden", book: "jetzt buchen", order: "jetzt bestellen" }, ie = { emailSuggestion: "Meinten Sie {{email}}?", emailInvalid: "Ihre E-Mail-Adresse ist nicht korrekt", cardExpiryInvalid: "Das Ablaufdatum Ihrer Karte liegt in der Vergangenheit", cardExpiryFormat: "Das Ablaufdatum Ihrer Karte ist unvollständig", cardSecurityFormat: "Der Sicherheitscode Ihrer Karte ist unvollständig", nameRequired: "Gib deinen Namen genau so ein, wie er auf deiner Karte steht", cardNumberInvalid: "Die Kartennummer ist unvollständig" }, se = {
646
+ email: J,
647
+ cardholderNameLabel: W,
648
+ cardInformation: X,
649
+ cardholderNamePlaceholder: Q,
650
+ cardExpiry: ee,
651
+ loading: te,
652
+ buttonTexts: ae,
653
653
  validation: ie
654
- }, se = "Email", re = "Cardholder name", ne = "Card information", oe = "Full name on card", le = "MM / YY", ce = "Do not close the window", de = { pay: "PAY", submit: "SUBMIT", getPlan: "GET MY PLAN", donate: "DONATE", book: "BOOK NOW", order: "ORDER NOW" }, he = { emailSuggestion: "Did you mean {{email}}?", emailInvalid: "Your email is not correct", cardExpiryInvalid: "Your card's expiration date is in the past", cardExpiryFormat: "Your card’s expiration date is incomplete", cardSecurityFormat: "Your card’s security code is incomplete", nameRequired: "Please enter the name as it appears on your card", cardNumberInvalid: "Your card number is invalid" }, me = {
655
- email: se,
656
- cardholderNameLabel: re,
657
- cardInformation: ne,
658
- cardholderNamePlaceholder: oe,
659
- cardExpiry: le,
660
- loading: ce,
661
- buttonTexts: de,
662
- validation: he
663
- }, ue = "Correo electrónico", pe = "Nombre del titular de la tarjeta", fe = "Información de la tarjeta", ge = "Nombre completo en la tarjeta", ye = "MM / AA", ve = "Por favor, no cierre esta ventana", Ee = { pay: "PAGAR", submit: "ENVIAR", getPlan: "OBTENER MI PLAN", donate: "DONAR", book: "RESERVAR AHORA", order: "ORDENAR AHORA" }, be = { emailSuggestion: "¿Quisiste decir {{email}}?", emailInvalid: "Su correo electrónico no es válido", cardExpiryInvalid: "La fecha de vencimiento de la tarjeta ya pasó", cardExpiryFormat: "La fecha de vencimiento de su tarjeta está incompleta", cardSecurityFormat: "El código de seguridad de su tarjeta está incompleto", nameRequired: "Por favor, ingrese el nombre tal como aparece en su tarjeta", cardNumberInvalid: "Su número de tarjeta no es válido" }, Ce = {
664
- email: ue,
665
- cardholderNameLabel: pe,
666
- cardInformation: fe,
667
- cardholderNamePlaceholder: ge,
668
- cardExpiry: ye,
669
- loading: ve,
670
- buttonTexts: Ee,
671
- validation: be
672
- }, Se = "E-mail", xe = "Nom du titulaire de la carte", Fe = "Informations de la carte", we = "Nom complet figurant sur la carte", Me = "MM / AA", Le = "Veuillez ne pas fermer cette fenêtre", ke = { pay: "PAYER", submit: "ENVOYER", getPlan: "OBTENIR MON PLAN", donate: "FAIRE UN DON", book: "RÉSERVER MAINTENANT", order: "COMMANDER MAINTENANT" }, Te = { emailSuggestion: "Vouliez-vous dire {{email}}?", emailInvalid: "Votre adresse e-mail n’est pas valide", cardExpiryInvalid: "La date d'expiration de votre carte est dans le passé", cardExpiryFormat: "La date d’expiration de votre carte est incomplète", cardSecurityFormat: "Le code de sécurité de votre carte est incomplet", nameRequired: "Veuillez saisir le nom tel qu’il figure sur votre carte", cardNumberInvalid: "Votre numéro de carte est invalide" }, Ie = {
673
- email: Se,
674
- cardholderNameLabel: xe,
675
- cardInformation: Fe,
676
- cardholderNamePlaceholder: we,
654
+ }, re = "Email", ne = "Cardholder name", oe = "Card information", le = "Full name on card", ce = "MM / YY", de = "Do not close the window", he = { pay: "PAY", submit: "SUBMIT", getPlan: "GET MY PLAN", donate: "DONATE", book: "BOOK NOW", order: "ORDER NOW" }, me = { emailSuggestion: "Did you mean {{email}}?", emailInvalid: "Your email is not correct", cardExpiryInvalid: "Your card's expiration date is in the past", cardExpiryFormat: "Your card’s expiration date is incomplete", cardSecurityFormat: "Your card’s security code is incomplete", nameRequired: "Please enter the name as it appears on your card", cardNumberInvalid: "Your card number is invalid" }, ue = {
655
+ email: re,
656
+ cardholderNameLabel: ne,
657
+ cardInformation: oe,
658
+ cardholderNamePlaceholder: le,
659
+ cardExpiry: ce,
660
+ loading: de,
661
+ buttonTexts: he,
662
+ validation: me
663
+ }, pe = "Correo electrónico", fe = "Nombre del titular de la tarjeta", ge = "Información de la tarjeta", ye = "Nombre completo en la tarjeta", ve = "MM / AA", Ee = "Por favor, no cierre esta ventana", be = { pay: "PAGAR", submit: "ENVIAR", getPlan: "OBTENER MI PLAN", donate: "DONAR", book: "RESERVAR AHORA", order: "ORDENAR AHORA" }, Ce = { emailSuggestion: "¿Quisiste decir {{email}}?", emailInvalid: "Su correo electrónico no es válido", cardExpiryInvalid: "La fecha de vencimiento de la tarjeta ya pasó", cardExpiryFormat: "La fecha de vencimiento de su tarjeta está incompleta", cardSecurityFormat: "El código de seguridad de su tarjeta está incompleto", nameRequired: "Por favor, ingrese el nombre tal como aparece en su tarjeta", cardNumberInvalid: "Su número de tarjeta no es válido" }, Se = {
664
+ email: pe,
665
+ cardholderNameLabel: fe,
666
+ cardInformation: ge,
667
+ cardholderNamePlaceholder: ye,
668
+ cardExpiry: ve,
669
+ loading: Ee,
670
+ buttonTexts: be,
671
+ validation: Ce
672
+ }, xe = "E-mail", Fe = "Nom du titulaire de la carte", we = "Informations de la carte", Le = "Nom complet figurant sur la carte", Me = "MM / AA", ke = "Veuillez ne pas fermer cette fenêtre", Te = { pay: "PAYER", submit: "ENVOYER", getPlan: "OBTENIR MON PLAN", donate: "FAIRE UN DON", book: "RÉSERVER MAINTENANT", order: "COMMANDER MAINTENANT" }, Ie = { emailSuggestion: "Vouliez-vous dire {{email}}?", emailInvalid: "Votre adresse e-mail n’est pas valide", cardExpiryInvalid: "La date d'expiration de votre carte est dans le passé", cardExpiryFormat: "La date d’expiration de votre carte est incomplète", cardSecurityFormat: "Le code de sécurité de votre carte est incomplet", nameRequired: "Veuillez saisir le nom tel qu’il figure sur votre carte", cardNumberInvalid: "Votre numéro de carte est invalide" }, ze = {
673
+ email: xe,
674
+ cardholderNameLabel: Fe,
675
+ cardInformation: we,
676
+ cardholderNamePlaceholder: Le,
677
677
  cardExpiry: Me,
678
- loading: Le,
679
- buttonTexts: ke,
680
- validation: Te
681
- }, ze = "Adres e-mail", Ne = "Imię i nazwisko posiadacza karty", Pe = "Informacje o karcie", De = "Imię i nazwisko na karcie", Ve = "MM / RR", Ae = "Proszę nie zamykać tego okna", $e = { pay: "ZAPŁAĆ", submit: "WYŚLIJ", getPlan: "POBIERZ MÓJ PLAN", donate: "PRZEKAŻ DAROWIZNĘ", book: "ZAREZERWUJ TERAZ", order: "ZAMÓW TERAZ" }, Re = { emailSuggestion: "Czy chodziło Ci o {{email}}?", emailInvalid: "Państwa adres e-mail jest nieprawidłowy", cardExpiryInvalid: "Data ważności Państwa karty jest w przeszłości", cardExpiryFormat: "Data ważności Państwa karty jest niekompletna", cardSecurityFormat: "Kod zabezpieczający Państwa karty jest niekompletny", nameRequired: "Proszę wpisać imię i nazwisko tak, jak widnieje na karcie", cardNumberInvalid: "Numer Państwa karty jest nieprawidłowy" }, Be = {
682
- email: ze,
683
- cardholderNameLabel: Ne,
684
- cardInformation: Pe,
685
- cardholderNamePlaceholder: De,
678
+ loading: ke,
679
+ buttonTexts: Te,
680
+ validation: Ie
681
+ }, Ne = "Adres e-mail", Pe = "Imię i nazwisko posiadacza karty", De = "Informacje o karcie", Ae = "Imię i nazwisko na karcie", Ve = "MM / RR", $e = "Proszę nie zamykać tego okna", Re = { pay: "ZAPŁAĆ", submit: "WYŚLIJ", getPlan: "POBIERZ MÓJ PLAN", donate: "PRZEKAŻ DAROWIZNĘ", book: "ZAREZERWUJ TERAZ", order: "ZAMÓW TERAZ" }, Be = { emailSuggestion: "Czy chodziło Ci o {{email}}?", emailInvalid: "Państwa adres e-mail jest nieprawidłowy", cardExpiryInvalid: "Data ważności Państwa karty jest w przeszłości", cardExpiryFormat: "Data ważności Państwa karty jest niekompletna", cardSecurityFormat: "Kod zabezpieczający Państwa karty jest niekompletny", nameRequired: "Proszę wpisać imię i nazwisko tak, jak widnieje na karcie", cardNumberInvalid: "Numer Państwa karty jest nieprawidłowy" }, Oe = {
682
+ email: Ne,
683
+ cardholderNameLabel: Pe,
684
+ cardInformation: De,
685
+ cardholderNamePlaceholder: Ae,
686
686
  cardExpiry: Ve,
687
- loading: Ae,
688
- buttonTexts: $e,
689
- validation: Re
690
- }, Oe = "E-mail", He = "Nome do titular do cartão", je = "Informações do cartão", Ke = "Nome completo no cartão", Ue = "MM / AA", qe = "Por favor, não feche esta janela", _e = { pay: "PAGAR", submit: "ENVIAR", getPlan: "OBTER MEU PLANO", donate: "DOAR", book: "RESERVAR AGORA", order: "FAZER PEDIDO" }, Ge = { emailSuggestion: "Você quis dizer {{email}}?", emailInvalid: "O seu endereço de e-mail não é válido", cardExpiryInvalid: "A data de validade do seu cartão está no passado", cardExpiryFormat: "A data de validade do seu cartão está incompleta", cardSecurityFormat: "O código de segurança do seu cartão está incompleto", nameRequired: "Por favor, insira o nome conforme aparece no cartão", cardNumberInvalid: "O número do seu cartão é inválido" }, Ze = {
691
- email: Oe,
692
- cardholderNameLabel: He,
693
- cardInformation: je,
694
- cardholderNamePlaceholder: Ke,
695
- cardExpiry: Ue,
696
- loading: qe,
697
- buttonTexts: _e,
698
- validation: Ge
687
+ loading: $e,
688
+ buttonTexts: Re,
689
+ validation: Be
690
+ }, He = "E-mail", je = "Nome do titular do cartão", Ke = "Informações do cartão", Ue = "Nome completo no cartão", qe = "MM / AA", _e = "Por favor, não feche esta janela", Ge = { pay: "PAGAR", submit: "ENVIAR", getPlan: "OBTER MEU PLANO", donate: "DOAR", book: "RESERVAR AGORA", order: "FAZER PEDIDO" }, Ze = { emailSuggestion: "Você quis dizer {{email}}?", emailInvalid: "O seu endereço de e-mail não é válido", cardExpiryInvalid: "A data de validade do seu cartão está no passado", cardExpiryFormat: "A data de validade do seu cartão está incompleta", cardSecurityFormat: "O código de segurança do seu cartão está incompleto", nameRequired: "Por favor, insira o nome conforme aparece no cartão", cardNumberInvalid: "O número do seu cartão é inválido" }, Ye = {
691
+ email: He,
692
+ cardholderNameLabel: je,
693
+ cardInformation: Ke,
694
+ cardholderNamePlaceholder: Ue,
695
+ cardExpiry: qe,
696
+ loading: _e,
697
+ buttonTexts: Ge,
698
+ validation: Ze
699
699
  }, I = {
700
- en: me,
701
- de: ae,
702
- es: Ce,
703
- fr: Ie,
704
- pl: Be,
705
- pt: Ze
700
+ en: ue,
701
+ de: se,
702
+ es: Se,
703
+ fr: ze,
704
+ pl: Oe,
705
+ pt: Ye
706
706
  // Add other locales here
707
707
  };
708
- class Ye {
708
+ class Je {
709
709
  locale;
710
710
  loadedLocales = /* @__PURE__ */ new Set();
711
711
  constructor(e = "en") {
@@ -718,85 +718,85 @@ class Ye {
718
718
  return this.locale;
719
719
  }
720
720
  translate(e, t) {
721
- const i = this.getNestedTranslation(e);
722
- return !t || i === e ? i : this.interpolate(i, t);
721
+ const a = this.getNestedTranslation(e);
722
+ return !t || a === e ? a : this.interpolate(a, t);
723
723
  }
724
724
  /* eslint-disable @typescript-eslint/no-explicit-any */
725
725
  getNestedTranslation(e) {
726
- const t = this.locale in I ? I[this.locale] : {}, i = this.findNestedValue(t, e);
727
- return i === void 0 ? e : i;
726
+ const t = this.locale in I ? I[this.locale] : {}, a = this.findNestedValue(t, e);
727
+ return a === void 0 ? e : a;
728
728
  }
729
729
  findNestedValue(e, t) {
730
- const i = t.split(".");
731
- let a = e;
732
- for (const s of i) {
733
- if (a == null || !Object.prototype.hasOwnProperty.call(a, s))
730
+ const a = t.split(".");
731
+ let i = e;
732
+ for (const s of a) {
733
+ if (i == null || !Object.prototype.hasOwnProperty.call(i, s))
734
734
  return;
735
- a = a[s];
735
+ i = i[s];
736
736
  }
737
- return typeof a == "string" ? a : void 0;
737
+ return typeof i == "string" ? i : void 0;
738
738
  }
739
739
  interpolate(e, t) {
740
- return e.replace(/{{(\w+)}}/g, (i, a) => {
741
- const s = t[a];
742
- return s === void 0 ? i : String(s);
740
+ return e.replace(/{{(\w+)}}/g, (a, i) => {
741
+ const s = t[i];
742
+ return s === void 0 ? a : String(s);
743
743
  });
744
744
  }
745
745
  }
746
- const z = ["en", "de", "es", "fr", "pl", "pt"], Je = "en";
747
- function We(n) {
748
- const e = new Ye(), i = (() => {
746
+ const z = ["en", "de", "es", "fr", "pl", "pt"], We = "en";
747
+ function Xe(n) {
748
+ const e = new Je(), a = (() => {
749
749
  const o = navigator?.language?.split("-")[0]?.toLowerCase();
750
- return z.includes(o) ? o : Je;
750
+ return z.includes(o) ? o : We;
751
751
  })();
752
- e.setLocale(i);
753
- const a = x({
754
- locale: i,
752
+ e.setLocale(a);
753
+ const i = x({
754
+ locale: a,
755
755
  translationService: e
756
756
  });
757
757
  return {
758
- store: a,
759
- translate: (o, l) => a.getState().translationService.translate(o, l),
758
+ store: i,
759
+ translate: (o, l) => i.getState().translationService.translate(o, l),
760
760
  setLocale: (o) => {
761
- z.includes(o) && (a.getState().translationService.setLocale(o), a.setState({ locale: o }));
761
+ z.includes(o) && (i.getState().translationService.setLocale(o), i.setState({ locale: o }));
762
762
  },
763
- getLocale: () => a.getValue("locale"),
764
- subscribe: a.subscribe.bind(a)
763
+ getLocale: () => i.getValue("locale"),
764
+ subscribe: i.subscribe.bind(i)
765
765
  };
766
766
  }
767
- const Xe = We(), L = () => {
768
- const { translate: n, getLocale: e, setLocale: t, subscribe: i } = Xe;
767
+ const Qe = Xe(), M = () => {
768
+ const { translate: n, getLocale: e, setLocale: t, subscribe: a } = Qe;
769
769
  return {
770
770
  t: n,
771
771
  translate: n,
772
772
  locale: e(),
773
773
  setLocale: t,
774
- subscribe: i
774
+ subscribe: a
775
775
  };
776
- }, Qe = ({ fontFamily: n }) => {
776
+ }, et = ({ fontFamily: n }) => {
777
777
  if (!n)
778
778
  return { cleanup: () => {
779
779
  } };
780
- const e = n.replace(/\s+/g, "+"), t = `https://fonts.googleapis.com/css2?family=${e}:wght@400;700&display=swap`, i = [...document.head.querySelectorAll("link")].filter(
780
+ const e = n.replace(/\s+/g, "+"), t = `https://fonts.googleapis.com/css2?family=${e}:wght@400;700&display=swap`, a = [...document.head.querySelectorAll("link")].filter(
781
781
  (o) => o.href.includes("fonts.googleapis.com/css2") && o.rel === "stylesheet"
782
- ), a = document.createElement("link");
783
- a.rel = "stylesheet", a.href = t;
784
- const s = i.find(
782
+ ), i = document.createElement("link");
783
+ i.rel = "stylesheet", i.href = t;
784
+ const s = a.find(
785
785
  (o) => o.href.includes(`family=${e}`)
786
786
  );
787
787
  if (s)
788
788
  s.href = t;
789
- else if (i.length > 0) {
790
- const o = i.at(
789
+ else if (a.length > 0) {
790
+ const o = a.at(
791
791
  -1
792
792
  );
793
- o?.nextSibling ? document.head.insertBefore(a, o.nextSibling) : document.head.appendChild(a);
793
+ o?.nextSibling ? document.head.insertBefore(i, o.nextSibling) : document.head.appendChild(i);
794
794
  } else
795
- document.head.appendChild(a);
795
+ document.head.appendChild(i);
796
796
  return { cleanup: () => {
797
- document.head.contains(a) && document.head.removeChild(a);
797
+ document.head.contains(i) && document.head.removeChild(i);
798
798
  } };
799
- }, et = ({
799
+ }, tt = ({
800
800
  scriptSrc: n,
801
801
  async: e = !1
802
802
  }) => {
@@ -814,24 +814,24 @@ const Xe = We(), L = () => {
814
814
  },
815
815
  isLoaded: Promise.resolve(!0)
816
816
  };
817
- const i = document.createElement("script");
818
- i.src = n, i.async = e;
819
- const a = new Promise((r, o) => {
820
- i.onload = () => r(!0), i.onerror = () => {
817
+ const a = document.createElement("script");
818
+ a.src = n, a.async = e;
819
+ const i = new Promise((r, o) => {
820
+ a.onload = () => r(!0), a.onerror = () => {
821
821
  console.error(`Failed to load script: ${n}`), o(new Error(`Failed to load script: ${n}`));
822
822
  };
823
823
  });
824
- return document.head.appendChild(i), {
824
+ return document.head.appendChild(a), {
825
825
  cleanup: () => {
826
- document.head.contains(i) && document.head.removeChild(i);
826
+ document.head.contains(a) && document.head.removeChild(a);
827
827
  },
828
- isLoaded: a
828
+ isLoaded: i
829
829
  };
830
830
  }, S = (n) => Object.entries(n).map(([e, t]) => {
831
- const i = e.replace(/([A-Z])/g, "-$1").toLowerCase(), a = typeof t == "number" ? `${t}px` : t;
832
- return `${i}: ${a}`;
831
+ const a = e.replace(/([A-Z])/g, "-$1").toLowerCase(), i = typeof t == "number" ? `${t}px` : t;
832
+ return `${a}: ${i}`;
833
833
  }).join("; ");
834
- function tt(n) {
834
+ function at(n) {
835
835
  if (!n)
836
836
  return {
837
837
  formContainerStyle: {},
@@ -855,31 +855,31 @@ function tt(n) {
855
855
  lineHeight: 30,
856
856
  boxSizing: "border-box",
857
857
  padding: "0px 12px",
858
- height: 33,
858
+ height: 36,
859
859
  width: "100%",
860
860
  fontFamily: `${n.styles.fontFamily}, sans-serif`
861
861
  }, t = {
862
862
  color: "#717173",
863
863
  opacity: "0.3",
864
864
  fontFamily: `${n.styles.fontFamily}, sans-serif`
865
- }, i = {
866
- color: "#dc2727"
867
865
  }, a = {
866
+ color: "#dc2727"
867
+ }, i = {
868
868
  outline: 0
869
869
  }, s = {
870
870
  fontFamily: `${n.styles.fontFamily}, sans-serif`
871
871
  }, r = {
872
872
  base: S(e),
873
- error: S(i),
874
- focus: S(a),
873
+ error: S(a),
874
+ focus: S(i),
875
875
  placeholder: S(t)
876
876
  };
877
877
  return {
878
878
  formContainerStyle: s,
879
879
  baseStyles: e,
880
880
  placeholderStyles: t,
881
- errorStyles: i,
882
- focusStyles: a,
881
+ errorStyles: a,
882
+ focusStyles: i,
883
883
  inputStyles: r
884
884
  };
885
885
  }
@@ -893,9 +893,9 @@ class d {
893
893
  * @param classNames Optional CSS class names to add
894
894
  * @param attributes Optional attributes to set on the element
895
895
  */
896
- constructor(e, t = [], i = {}) {
897
- this.element = document.createElement(e), t.length > 0 && this.addClass(...t), Object.entries(i).forEach(([a, s]) => {
898
- this.setAttribute(a, s);
896
+ constructor(e, t = [], a = {}) {
897
+ this.element = document.createElement(e), t.length > 0 && this.addClass(...t), Object.entries(a).forEach(([i, s]) => {
898
+ this.setAttribute(i, s);
899
899
  });
900
900
  }
901
901
  /**
@@ -950,14 +950,14 @@ class d {
950
950
  /**
951
951
  * Add an event listener to the element
952
952
  */
953
- addEventListener(e, t, i) {
954
- return this.element.addEventListener(e, t, i), this.eventListeners.push({ type: e, listener: t }), this;
953
+ addEventListener(e, t, a) {
954
+ return this.element.addEventListener(e, t, a), this.eventListeners.push({ type: e, listener: t }), this;
955
955
  }
956
956
  /**
957
957
  * Remove an event listener from the element
958
958
  */
959
- removeEventListener(e, t, i) {
960
- return this.element.removeEventListener(e, t, i), this;
959
+ removeEventListener(e, t, a) {
960
+ return this.element.removeEventListener(e, t, a), this;
961
961
  }
962
962
  /**
963
963
  * Hide this component
@@ -996,27 +996,27 @@ class y {
996
996
  /**
997
997
  * Create a button element
998
998
  */
999
- static createButton(e, t = [], i = {}) {
1000
- const a = new d("button", t, i);
1001
- return a.setText(e), a;
999
+ static createButton(e, t = [], a = {}) {
1000
+ const i = new d("button", t, a);
1001
+ return i.setText(e), i;
1002
1002
  }
1003
1003
  /**
1004
1004
  * Create an input element
1005
1005
  */
1006
- static createInput(e, t = [], i = {}) {
1007
- const a = { type: e, ...i };
1008
- return new d("input", t, a);
1006
+ static createInput(e, t = [], a = {}) {
1007
+ const i = { type: e, ...a };
1008
+ return new d("input", t, i);
1009
1009
  }
1010
1010
  /**
1011
1011
  * Create a text input
1012
1012
  */
1013
- static createTextInput(e = "", t = [], i = {}) {
1014
- const a = {
1013
+ static createTextInput(e = "", t = [], a = {}) {
1014
+ const i = {
1015
1015
  type: "text",
1016
1016
  placeholder: e,
1017
- ...i
1017
+ ...a
1018
1018
  };
1019
- return new d("input", t, a);
1019
+ return new d("input", t, i);
1020
1020
  }
1021
1021
  /**
1022
1022
  * Create a form element
@@ -1027,26 +1027,26 @@ class y {
1027
1027
  /**
1028
1028
  * Create a label element
1029
1029
  */
1030
- static createLabel(e, t = "", i = [], a = {}) {
1031
- const s = t ? { for: t, ...a } : a, r = new d("label", i, s);
1030
+ static createLabel(e, t = "", a = [], i = {}) {
1031
+ const s = t ? { for: t, ...i } : i, r = new d("label", a, s);
1032
1032
  return r.setText(e), r;
1033
1033
  }
1034
1034
  /**
1035
1035
  * Create a select element
1036
1036
  */
1037
- static createSelect(e, t = [], i = {}) {
1038
- const a = new d("select", t, i);
1037
+ static createSelect(e, t = [], a = {}) {
1038
+ const i = new d("select", t, a);
1039
1039
  return e.forEach((s) => {
1040
1040
  const r = document.createElement("option");
1041
- r.value = s.value, r.textContent = s.text, s.selected && (r.selected = !0), a.getElement().appendChild(r);
1042
- }), a;
1041
+ r.value = s.value, r.textContent = s.text, s.selected && (r.selected = !0), i.getElement().appendChild(r);
1042
+ }), i;
1043
1043
  }
1044
1044
  /**
1045
1045
  * Create an image element
1046
1046
  */
1047
- static createImage(e, t = "", i = [], a = {}) {
1048
- const s = { src: e, alt: t, ...a };
1049
- return new d("img", i, s);
1047
+ static createImage(e, t = "", a = [], i = {}) {
1048
+ const s = { src: e, alt: t, ...i };
1049
+ return new d("img", a, s);
1050
1050
  }
1051
1051
  }
1052
1052
  class it extends d {
@@ -1056,10 +1056,10 @@ class it extends d {
1056
1056
  const t = y.createDiv(["error-alert"], {
1057
1057
  role: "alert",
1058
1058
  "aria-live": "polite"
1059
- }), i = y.createDiv(["error-alert-content"]), a = y.createDiv([
1059
+ }), a = y.createDiv(["error-alert-content"]), i = y.createDiv([
1060
1060
  "error-alert-icon-container"
1061
1061
  ]);
1062
- a.getElement().innerHTML = this.createAlertCircleSVG();
1062
+ i.getElement().innerHTML = this.createAlertCircleSVG();
1063
1063
  const s = y.createDiv([
1064
1064
  "error-alert-text-container"
1065
1065
  ]), r = new d("h4", [
@@ -1067,7 +1067,7 @@ class it extends d {
1067
1067
  ]);
1068
1068
  r.setText("Checkout Error"), this.messageComponent = new d("p", [
1069
1069
  "error-alert-message"
1070
- ]), this.messageComponent.setText(e.message || "Bad request"), s.appendChild(r), s.appendChild(this.messageComponent), i.appendChild(a), i.appendChild(s), t.appendChild(i), this.appendChild(t);
1070
+ ]), this.messageComponent.setText(e.message || "Bad request"), s.appendChild(r), s.appendChild(this.messageComponent), a.appendChild(i), a.appendChild(s), t.appendChild(a), this.appendChild(t);
1071
1071
  }
1072
1072
  createAlertCircleSVG() {
1073
1073
  return `
@@ -1092,12 +1092,12 @@ class it extends d {
1092
1092
  return this.messageComponent.setText(e), this;
1093
1093
  }
1094
1094
  }
1095
- class at extends d {
1095
+ class N extends d {
1096
1096
  titleElement;
1097
- constructor(e) {
1097
+ constructor(e = {}) {
1098
1098
  super("div", ["blur-bg"]);
1099
1099
  const t = y.createDiv(["loader"]);
1100
- this.titleElement = new d("h3", ["title"]), this.titleElement.setText(e.text), this.appendChild(t), this.appendChild(this.titleElement);
1100
+ this.titleElement = new d("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
1101
1101
  }
1102
1102
  setText(e) {
1103
1103
  return this.titleElement.setText(e), this;
@@ -1128,7 +1128,7 @@ class k extends d {
1128
1128
  helperText = null;
1129
1129
  constructor(e) {
1130
1130
  if (super("div", ["input-wrapper"]), e.label && e.styles) {
1131
- const i = new st({
1131
+ const a = new st({
1132
1132
  styles: {
1133
1133
  color: e.styles.color,
1134
1134
  fontSize: e.styles.fontSize
@@ -1136,7 +1136,7 @@ class k extends d {
1136
1136
  label: e.label,
1137
1137
  id: e.name
1138
1138
  });
1139
- this.appendChild(i);
1139
+ this.appendChild(a);
1140
1140
  }
1141
1141
  const t = {
1142
1142
  id: e.name,
@@ -1148,8 +1148,8 @@ class k extends d {
1148
1148
  [],
1149
1149
  t
1150
1150
  ), e.styles) {
1151
- const i = this.inputElement.getElement();
1152
- i.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, i.style.color = e.styles.color, i.style.fontSize = `${e.styles.fontSize}px`, i.style.borderRadius = e.styles.borderRadius;
1151
+ const a = this.inputElement.getElement();
1152
+ a.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.style.color = e.styles.color, a.style.fontSize = `${e.styles.fontSize}px`, a.style.borderRadius = e.styles.borderRadius;
1153
1153
  }
1154
1154
  e.onChange && this.inputElement.getElement().addEventListener("input", e.onChange), this.getElement().appendChild(this.inputElement.getElement()), e.error && (this.helperText = new v({ text: e.errorMsg }), this.appendChild(this.helperText));
1155
1155
  }
@@ -1160,11 +1160,11 @@ class k extends d {
1160
1160
  return this.inputElement.getElement().value = e, this;
1161
1161
  }
1162
1162
  setError(e, t) {
1163
- const i = this.inputElement.getElement();
1164
- return e ? (i.classList.add("form-input-error"), !this.helperText && t ? (this.helperText = new v({ text: t }), this.appendChild(this.helperText)) : this.helperText && t && this.helperText.setText(t)) : (i.classList.remove("form-input-error"), this.helperText && (this.helperText.getElement().remove(), this.helperText = null)), this;
1163
+ const a = this.inputElement.getElement();
1164
+ return e ? (a.classList.add("form-input-error"), !this.helperText && t ? (this.helperText = new v({ text: t }), this.appendChild(this.helperText)) : this.helperText && t && this.helperText.setText(t)) : (a.classList.remove("form-input-error"), this.helperText && (this.helperText.getElement().remove(), this.helperText = null)), this;
1165
1165
  }
1166
- addEventListener(e, t, i) {
1167
- return this.inputElement.getElement().addEventListener(e, t, i), this;
1166
+ addEventListener(e, t, a) {
1167
+ return this.inputElement.getElement().addEventListener(e, t, a), this;
1168
1168
  }
1169
1169
  }
1170
1170
  class rt {
@@ -1172,8 +1172,8 @@ class rt {
1172
1172
  constructor(e) {
1173
1173
  const {
1174
1174
  value: t,
1175
- onChange: i,
1176
- onBlur: a,
1175
+ onChange: a,
1176
+ onBlur: i,
1177
1177
  error: s,
1178
1178
  errorMsg: r,
1179
1179
  checkoutProfile: o,
@@ -1193,10 +1193,10 @@ class rt {
1193
1193
  placeholder: l("cardholderNamePlaceholder"),
1194
1194
  value: t,
1195
1195
  onChange: (c) => {
1196
- this.trim(), i(c);
1196
+ this.trim(), a(c);
1197
1197
  }
1198
1198
  }), this.input.addEventListener("blur", (c) => {
1199
- a(c);
1199
+ i(c);
1200
1200
  });
1201
1201
  }
1202
1202
  getValue() {
@@ -1224,8 +1224,8 @@ class nt extends d {
1224
1224
  super("div", []);
1225
1225
  const t = document.createElement("div");
1226
1226
  t.className = e.isLoading ? "loading" : "", t.style.borderRadius = `0px 0px ${e.styles.borderRadius}px 0px`;
1227
- const i = document.createElement("div");
1228
- i.id = "card-cvv-element", i.className = `card-element ${e.isFocused ? "card-element-focus" : ""}`, i.style.zIndex = e.isFocused ? "2" : "0", t.appendChild(i), this.getElement().appendChild(t);
1227
+ const a = document.createElement("div");
1228
+ a.id = "card-cvv-element", a.className = `card-element ${e.isFocused ? "card-element-focus" : ""}`, a.style.zIndex = e.isFocused ? "2" : "0", t.appendChild(a), this.getElement().appendChild(t);
1229
1229
  }
1230
1230
  setFocused(e) {
1231
1231
  const t = this.getElement().querySelector("#card-cvv-element");
@@ -1260,10 +1260,10 @@ class ht extends d {
1260
1260
  super("div", []), this.cardType = e.cardType;
1261
1261
  const t = document.createElement("label");
1262
1262
  t.setAttribute("for", "cardNumber"), t.textContent = e.label, t.style.color = e.styles.color, t.style.fontSize = `${e.styles.fontSize}px`, t.style.display = "block", t.style.marginBottom = "6px", this.getElement().appendChild(t);
1263
- const i = document.createElement("div");
1264
- i.className = e.isLoading ? "loading" : "", i.style.borderRadius = `${e.styles.borderRadius}px ${e.styles.borderRadius}px 0px 0px`;
1265
1263
  const a = document.createElement("div");
1266
- a.id = "card-element", a.className = `card-element ${e.isFocused ? "card-element-focus" : ""}`, a.style.zIndex = e.isFocused ? "2" : "0";
1264
+ a.className = e.isLoading ? "loading" : "", a.style.borderRadius = `${e.styles.borderRadius}px ${e.styles.borderRadius}px 0px 0px`;
1265
+ const i = document.createElement("div");
1266
+ i.id = "card-element", i.className = `card-element ${e.isFocused ? "card-element-focus" : ""}`, i.style.zIndex = e.isFocused ? "2" : "0";
1267
1267
  const s = document.createElement("div");
1268
1268
  if (s.className = "cards-position", e.cardType === "unknown")
1269
1269
  E.forEach((r) => {
@@ -1273,13 +1273,13 @@ class ht extends d {
1273
1273
  const r = E.find((o) => o.type === e.cardType);
1274
1274
  r && s.appendChild(this.createCardIcon(r));
1275
1275
  }
1276
- a.appendChild(s), i.appendChild(a), this.getElement().appendChild(i);
1276
+ i.appendChild(s), a.appendChild(i), this.getElement().appendChild(a);
1277
1277
  }
1278
1278
  createCardIcon(e) {
1279
1279
  const t = document.createElement("div");
1280
1280
  t.className = "card-icon";
1281
- const i = document.createElement("img");
1282
- return i.src = e.imgSrc, t.appendChild(i), t;
1281
+ const a = document.createElement("img");
1282
+ return a.src = e.imgSrc, t.appendChild(a), t;
1283
1283
  }
1284
1284
  setFocused(e) {
1285
1285
  const t = this.getElement().querySelector(
@@ -1298,16 +1298,16 @@ class ht extends d {
1298
1298
  if (this.cardType === t)
1299
1299
  return this;
1300
1300
  this.cardType = t;
1301
- const i = this.getElement().querySelector(".cards-position");
1302
- if (i)
1303
- if (i.innerHTML = "", this.cardType === "unknown")
1304
- E.forEach((a) => {
1305
- i.appendChild(this.createCardIcon(a));
1301
+ const a = this.getElement().querySelector(".cards-position");
1302
+ if (a)
1303
+ if (a.innerHTML = "", this.cardType === "unknown")
1304
+ E.forEach((i) => {
1305
+ a.appendChild(this.createCardIcon(i));
1306
1306
  });
1307
1307
  else {
1308
- const a = E.find((s) => s.type === this.cardType);
1309
- a ? i.appendChild(this.createCardIcon(a)) : E.forEach((s) => {
1310
- i.appendChild(this.createCardIcon(s));
1308
+ const i = E.find((s) => s.type === this.cardType);
1309
+ i ? a.appendChild(this.createCardIcon(i)) : E.forEach((s) => {
1310
+ a.appendChild(this.createCardIcon(s));
1311
1311
  });
1312
1312
  }
1313
1313
  return this;
@@ -1322,8 +1322,8 @@ class mt extends d {
1322
1322
  super("div", []);
1323
1323
  const {
1324
1324
  checkoutProfile: t,
1325
- isLoading: i,
1326
- isFocused: a,
1325
+ isLoading: a,
1326
+ isFocused: i,
1327
1327
  isCvvFocused: s,
1328
1328
  isCcValid: r,
1329
1329
  isCvvValid: o,
@@ -1342,8 +1342,8 @@ class mt extends d {
1342
1342
  borderRadius: t.styles.borderRadius
1343
1343
  },
1344
1344
  label: f("cardInformation"),
1345
- isLoading: i,
1346
- isFocused: a,
1345
+ isLoading: a,
1346
+ isFocused: i,
1347
1347
  cardType: l
1348
1348
  }), b.appendChild(this.cardNumber.getElement());
1349
1349
  const C = document.createElement("div");
@@ -1372,16 +1372,16 @@ class mt extends d {
1372
1372
  "Tab"
1373
1373
  ].includes(w.key) && !/^\d$/.test(w.key) && w.preventDefault();
1374
1374
  });
1375
- const P = this.cardExpiry.getElement();
1376
- P.style.height = "100%";
1375
+ const D = this.cardExpiry.getElement();
1376
+ D.style.height = "100%";
1377
1377
  const F = document.createElement("div");
1378
1378
  if (F.className = "input-wrapper", this.cardCvv = new nt({
1379
1379
  styles: {
1380
1380
  borderRadius: typeof t.styles.borderRadius == "number" ? t.styles.borderRadius : 0
1381
1381
  },
1382
- isLoading: i,
1382
+ isLoading: a,
1383
1383
  isFocused: s
1384
- }), F.appendChild(this.cardCvv.getElement()), C.appendChild(this.cardExpiry.getElement()), C.appendChild(F), b.appendChild(C), this.getElement().appendChild(b), a && !r) {
1384
+ }), F.appendChild(this.cardCvv.getElement()), C.appendChild(this.cardExpiry.getElement()), C.appendChild(F), b.appendChild(C), this.getElement().appendChild(b), i && !r) {
1385
1385
  const g = new v({
1386
1386
  text: f("validation.cardNumberInvalid")
1387
1387
  });
@@ -1397,8 +1397,8 @@ class mt extends d {
1397
1397
  updateCardType(e) {
1398
1398
  return this.cardNumber.updateCardType(e), this;
1399
1399
  }
1400
- updateCardExpiry(e, t, i) {
1401
- return this.cardExpiry.setValue(e), t && i ? this.cardExpiry.setError(!0, t) : this.cardExpiry.setError(!1), this;
1400
+ updateCardExpiry(e, t, a) {
1401
+ return this.cardExpiry.setValue(e), t && a ? this.cardExpiry.setError(!0, t) : this.cardExpiry.setError(!1), this;
1402
1402
  }
1403
1403
  getCardExpiryValue() {
1404
1404
  return this.cardExpiry.getValue();
@@ -1407,31 +1407,31 @@ class mt extends d {
1407
1407
  const e = this.getCardExpiryValue().trim();
1408
1408
  return this.cardExpiry.setValue(e), this;
1409
1409
  }
1410
- updateCardNumberValidation(e, t, i) {
1410
+ updateCardNumberValidation(e, t, a) {
1411
1411
  if (this.cardNumber.setFocused(e), e && !t) {
1412
1412
  if (!this.validationMessages.has("cardNumber")) {
1413
- const a = new v({
1414
- text: i("validation.cardNumberInvalid")
1413
+ const i = new v({
1414
+ text: a("validation.cardNumberInvalid")
1415
1415
  });
1416
- this.validationMessages.set("cardNumber", a), this.appendChild(a);
1416
+ this.validationMessages.set("cardNumber", i), this.appendChild(i);
1417
1417
  }
1418
1418
  } else {
1419
- const a = this.validationMessages.get("cardNumber");
1420
- a && (a.getElement().remove(), this.validationMessages.delete("cardNumber"));
1419
+ const i = this.validationMessages.get("cardNumber");
1420
+ i && (i.getElement().remove(), this.validationMessages.delete("cardNumber"));
1421
1421
  }
1422
1422
  return this;
1423
1423
  }
1424
- updateCardCvvValidation(e, t, i) {
1424
+ updateCardCvvValidation(e, t, a) {
1425
1425
  if (this.cardCvv.setFocused(e), e && !t) {
1426
1426
  if (!this.validationMessages.has("cardCvv")) {
1427
- const a = new v({
1428
- text: i("validation.cardSecurityFormat")
1427
+ const i = new v({
1428
+ text: a("validation.cardSecurityFormat")
1429
1429
  });
1430
- this.validationMessages.set("cardCvv", a), this.appendChild(a);
1430
+ this.validationMessages.set("cardCvv", i), this.appendChild(i);
1431
1431
  }
1432
1432
  } else {
1433
- const a = this.validationMessages.get("cardCvv");
1434
- a && (a.getElement().remove(), this.validationMessages.delete("cardCvv"));
1433
+ const i = this.validationMessages.get("cardCvv");
1434
+ i && (i.getElement().remove(), this.validationMessages.delete("cardCvv"));
1435
1435
  }
1436
1436
  return this;
1437
1437
  }
@@ -1444,8 +1444,8 @@ class ut {
1444
1444
  constructor(e) {
1445
1445
  const {
1446
1446
  value: t,
1447
- onChange: i,
1448
- onBlur: a,
1447
+ onChange: a,
1448
+ onBlur: i,
1449
1449
  error: s,
1450
1450
  errorMsg: r,
1451
1451
  checkoutProfile: o,
@@ -1467,9 +1467,9 @@ class ut {
1467
1467
  value: t,
1468
1468
  // Wrap the original onChange to apply trim before calling it
1469
1469
  onChange: (c) => {
1470
- this.trim(), i(c);
1470
+ this.trim(), a(c);
1471
1471
  }
1472
- }), this.input.addEventListener("blur", a);
1472
+ }), this.input.addEventListener("blur", i);
1473
1473
  }
1474
1474
  getValue() {
1475
1475
  return this.input.getValue();
@@ -1498,12 +1498,12 @@ class ft extends d {
1498
1498
  isSubmitting = !1;
1499
1499
  constructor(e) {
1500
1500
  super("div", ["paypal"]);
1501
- const { formData: t, onSubmit: i } = e;
1502
- this.formData = t, this.onSubmit = i, this.getElement().style.cursor = i ? "pointer" : "default", this.getElement().style.opacity = "1";
1503
- const a = document.createElement("div");
1504
- a.className = "paypal-icon-container";
1501
+ const { formData: t, onSubmit: a } = e;
1502
+ this.formData = t, this.onSubmit = a, this.getElement().style.cursor = a ? "pointer" : "default", this.getElement().style.opacity = "1";
1503
+ const i = document.createElement("div");
1504
+ i.className = "paypal-icon-container";
1505
1505
  const s = document.createElement("img");
1506
- s.src = pt, s.style.width = "69px", s.style.height = "22px", s.style.maxWidth = "100%", s.style.display = "block", s.style.height = "auto", a.appendChild(s), this.getElement().appendChild(a), i && this.getElement().addEventListener("click", () => this.handleSubmit());
1506
+ s.src = pt, s.style.width = "69px", s.style.height = "22px", s.style.maxWidth = "100%", s.style.display = "block", s.style.height = "auto", i.appendChild(s), this.getElement().appendChild(i), a && this.getElement().addEventListener("click", () => this.handleSubmit());
1507
1507
  }
1508
1508
  async handleSubmit() {
1509
1509
  if (!(!this.onSubmit || this.isSubmitting)) {
@@ -1527,7 +1527,7 @@ class ft extends d {
1527
1527
  class gt extends d {
1528
1528
  paymentMethods;
1529
1529
  constructor(e) {
1530
- const { checkoutProfile: t, formData: i, onPaypalSubmit: a } = e;
1530
+ const { checkoutProfile: t, formData: a, onPaypalSubmit: i } = e;
1531
1531
  if (!t?.additionalPaymentMethods) {
1532
1532
  super("div", ["payment-methods"]), this.paymentMethods = /* @__PURE__ */ new Map(), this.getElement().style.display = "none";
1533
1533
  return;
@@ -1543,11 +1543,11 @@ class gt extends d {
1543
1543
  for (const [r] of s)
1544
1544
  switch (r) {
1545
1545
  case "paypal": {
1546
- if (a) {
1546
+ if (i) {
1547
1547
  const o = new ft({
1548
1548
  checkoutProfile: t,
1549
- formData: i,
1550
- onSubmit: a
1549
+ formData: a,
1550
+ onSubmit: i
1551
1551
  });
1552
1552
  this.paymentMethods.set("paypal", o), o.appendTo(this.getElement());
1553
1553
  }
@@ -1590,17 +1590,17 @@ class vt extends d {
1590
1590
  class Et {
1591
1591
  button;
1592
1592
  constructor(e) {
1593
- const { disabled: t, checkoutProfile: i, translationFunc: a } = e;
1593
+ const { disabled: t, checkoutProfile: a, translationFunc: i } = e;
1594
1594
  this.button = new vt({
1595
- text: a(
1596
- `buttonTexts.${i?.layout.actionButton.translationKey}`
1595
+ text: i(
1596
+ `buttonTexts.${a?.layout.actionButton.translationKey}`
1597
1597
  ),
1598
1598
  styles: {
1599
- backgroundColor: i.styles.buttonColor,
1600
- color: i.styles.buttonTextColor,
1601
- fontFamily: i.styles.fontFamily,
1602
- borderRadius: i.styles.borderRadius,
1603
- fontSize: i.styles.buttonFontSize
1599
+ backgroundColor: a.styles.buttonColor,
1600
+ color: a.styles.buttonTextColor,
1601
+ fontFamily: a.styles.fontFamily,
1602
+ borderRadius: a.styles.borderRadius,
1603
+ fontSize: a.styles.buttonFontSize
1604
1604
  },
1605
1605
  disabled: t
1606
1606
  });
@@ -1611,8 +1611,8 @@ class Et {
1611
1611
  setDisabled(e) {
1612
1612
  return this.button.setDisabled(e), this;
1613
1613
  }
1614
- addEventListener(e, t, i) {
1615
- return this.button.addEventListener(e, t, i), this;
1614
+ addEventListener(e, t, a) {
1615
+ return this.button.addEventListener(e, t, a), this;
1616
1616
  }
1617
1617
  appendTo(e) {
1618
1618
  return this.button.appendTo(e), this;
@@ -1633,16 +1633,16 @@ class St extends d {
1633
1633
  spinner;
1634
1634
  alert;
1635
1635
  // factories
1636
- formManager = _();
1636
+ formManager = G();
1637
1637
  checkoutProfile;
1638
- translation = L();
1638
+ translation = M();
1639
1639
  iframeHook;
1640
1640
  constructor(e) {
1641
- super("form", ["form-container"]), this.options = e, this.checkoutProfile = O({
1641
+ super("form", ["form-container"]), this.options = e, this.checkoutProfile = H({
1642
1642
  apiKey: e.apiKey,
1643
1643
  profileId: e.profileId,
1644
1644
  environment: e.environment
1645
- }), e.locale && this.translation.setLocale(e.locale), this.getElement().style.opacity = "0", this.getElement().style.transition = "opacity 0.5s ease-in-out", this.getElement().addEventListener("submit", this.handleSubmit), this.getElement().addEventListener("keydown", this.handleKeyDown), this.formManager.subscribe(this.handleFormStateChange), this.checkoutProfile.subscribe(this.handleProfileStateChange), this.initializeForm(), this.appendTo(e.container);
1645
+ }), e.locale && this.translation.setLocale(e.locale), this.getElement().addEventListener("submit", this.handleSubmit), this.getElement().addEventListener("keydown", this.handleKeyDown), this.formManager.subscribe(this.handleFormStateChange), this.checkoutProfile.subscribe(this.handleProfileStateChange), this.initializeForm(), this.appendTo(e.container);
1646
1646
  }
1647
1647
  _getFormStateData() {
1648
1648
  const e = this.formManager.getFormState();
@@ -1661,10 +1661,10 @@ class St extends d {
1661
1661
  };
1662
1662
  handleProfileStateChange = (e) => {
1663
1663
  if (!e.isLoading)
1664
- if (this.hideSpinner(), e.checkoutProfile)
1664
+ if (this.setLoadingState(!1), e.checkoutProfile)
1665
1665
  try {
1666
1666
  if (e.checkoutProfile.styles?.fontFamily) {
1667
- const { cleanup: t } = Qe({
1667
+ const { cleanup: t } = et({
1668
1668
  fontFamily: e.checkoutProfile.styles.fontFamily
1669
1669
  });
1670
1670
  this.fontCleanup = t;
@@ -1687,15 +1687,15 @@ class St extends d {
1687
1687
  setTimeout(() => this.initializeTokenExIframe(), 500);
1688
1688
  return;
1689
1689
  }
1690
- const { inputStyles: t, formContainerStyle: i } = tt(
1690
+ const { inputStyles: t, formContainerStyle: a } = at(
1691
1691
  e.checkoutProfile
1692
1692
  );
1693
- this.applyFormContainerStyles(i), this.iframeHook = Z({
1693
+ this.applyFormContainerStyles(a), this.iframeHook = Y({
1694
1694
  apiKey: this.options.apiKey,
1695
1695
  checkoutProfile: e.checkoutProfile,
1696
1696
  inputStyles: t,
1697
- setFormData: (a) => {
1698
- this.formManager.setFormData(a);
1697
+ setFormData: (i) => {
1698
+ this.formManager.setFormData(i);
1699
1699
  },
1700
1700
  environment: this.options.environment
1701
1701
  }), this.iframeHook?.subscribe(this.handleIframeStateChange), this.renderFormComponents();
@@ -1718,7 +1718,7 @@ class St extends d {
1718
1718
  createCardSection = (e) => {
1719
1719
  if (this.iframeHook && !this.cardSection)
1720
1720
  try {
1721
- const { formData: t, errors: i, touched: a } = this._getFormStateData(), s = this.iframeHook.getState();
1721
+ const { formData: t, errors: a, touched: i } = this._getFormStateData(), s = this.iframeHook.getState();
1722
1722
  this.cardSection = new mt({
1723
1723
  checkoutProfile: e,
1724
1724
  isLoading: s.loadingIframe,
@@ -1728,24 +1728,24 @@ class St extends d {
1728
1728
  isCvvValid: s.isCvvValid,
1729
1729
  cardType: s.possibleCardType,
1730
1730
  cardExpiry: t.cardExpiry,
1731
- cardExpiryError: i.cardExpiry,
1732
- cardExpiryTouched: !!a.cardExpiry,
1731
+ cardExpiryError: a.cardExpiry,
1732
+ cardExpiryTouched: !!i.cardExpiry,
1733
1733
  onChange: this.handleChange,
1734
1734
  onBlur: this.handleBlur,
1735
1735
  translationFunc: this.translation.t
1736
- }), this.element.appendChild(this.cardSection.getElement()), this.updateFormUI(), this.cardSection && this.emailField && this.cardholderSection && this.submitButton && this.animateFormVisibility();
1736
+ }), this.element.appendChild(this.cardSection.getElement()), this.updateFormUI(), this.cardSection && this.emailField && this.cardholderSection && this.submitButton;
1737
1737
  } catch {
1738
1738
  this.setErrorMessage("Card section temporarily unavailabl");
1739
1739
  }
1740
1740
  };
1741
1741
  initializeForm() {
1742
- this.showSpinner("Loading checkout form..."), this.options.errorMsg && this.setErrorMessage(this.options.errorMsg);
1743
- const e = this.options.environment === "test" ? bt : Ct, { cleanup: t, isLoaded: i } = et({
1742
+ this.setLoadingState(!0), this.options.errorMsg && this.setErrorMessage(this.options.errorMsg);
1743
+ const e = this.options.environment === "test" ? bt : Ct, { cleanup: t, isLoaded: a } = tt({
1744
1744
  scriptSrc: e
1745
1745
  });
1746
- this.scriptCleanup = t, i.then(() => {
1746
+ this.scriptCleanup = t, a.then(() => {
1747
1747
  }).catch(() => {
1748
- this.setErrorMessage(
1748
+ this.setLoadingState(!1), this.setErrorMessage(
1749
1749
  "Failed to load payment system. Please try again later."
1750
1750
  );
1751
1751
  });
@@ -1758,53 +1758,45 @@ class St extends d {
1758
1758
  this.setErrorMessage("Failed to load checkout configuration");
1759
1759
  return;
1760
1760
  }
1761
- this.createPaymentMethods(e.checkoutProfile), this.createEmailField(e.checkoutProfile), this.createCardSection(e.checkoutProfile), this.createCardholderSection(e.checkoutProfile), this.createSubmitButton(e.checkoutProfile), this.animateFormVisibility();
1761
+ this.createPaymentMethods(e.checkoutProfile), this.createEmailField(e.checkoutProfile), this.createCardSection(e.checkoutProfile), this.createCardholderSection(e.checkoutProfile), this.createSubmitButton(e.checkoutProfile);
1762
1762
  } catch {
1763
1763
  this.setErrorMessage("Failed to render checkout form components");
1764
1764
  }
1765
1765
  }
1766
- /**
1767
- * Animate the form's visibility by transitioning opacity
1768
- */
1769
- animateFormVisibility() {
1770
- setTimeout(() => {
1771
- this.getElement().style.opacity = "1";
1772
- }, 100);
1773
- }
1774
1766
  createPaymentMethods(e) {
1775
1767
  if (!e?.additionalPaymentMethods || Object.entries(
1776
1768
  e.additionalPaymentMethods
1777
- ).filter(([, a]) => a.enabled).length === 0)
1769
+ ).filter(([, i]) => i.enabled).length === 0)
1778
1770
  return;
1779
- const { formData: i } = this._getFormStateData();
1771
+ const { formData: a } = this._getFormStateData();
1780
1772
  this.paymentMethods = new gt({
1781
1773
  checkoutProfile: e,
1782
- formData: i,
1774
+ formData: a,
1783
1775
  onPaypalSubmit: async () => {
1784
1776
  await this.handlePaypalSubmit();
1785
1777
  }
1786
1778
  }), this.appendChild(this.paymentMethods);
1787
1779
  }
1788
1780
  createEmailField(e) {
1789
- const { formData: t, errors: i, touched: a } = this._getFormStateData();
1781
+ const { formData: t, errors: a, touched: i } = this._getFormStateData();
1790
1782
  this.emailField = new ut({
1791
1783
  value: t.email,
1792
1784
  onChange: this.handleChange,
1793
1785
  onBlur: this.handleBlur,
1794
- error: !!(i.email && a.email),
1795
- errorMsg: i.email,
1786
+ error: !!(a.email && i.email),
1787
+ errorMsg: a.email,
1796
1788
  checkoutProfile: e,
1797
1789
  translationFunc: this.translation.t
1798
1790
  }), this.element.appendChild(this.emailField.getElement());
1799
1791
  }
1800
1792
  createCardholderSection(e) {
1801
- const { formData: t, errors: i, touched: a } = this._getFormStateData();
1793
+ const { formData: t, errors: a, touched: i } = this._getFormStateData();
1802
1794
  this.cardholderSection = new rt({
1803
1795
  value: t.name,
1804
1796
  onChange: this.handleChange,
1805
1797
  onBlur: this.handleBlur,
1806
- error: !!(i.name && a.name),
1807
- errorMsg: i.name,
1798
+ error: !!(a.name && i.name),
1799
+ errorMsg: a.name,
1808
1800
  checkoutProfile: e,
1809
1801
  translationFunc: this.translation.t
1810
1802
  }), this.element.appendChild(this.cardholderSection.getElement());
@@ -1817,12 +1809,12 @@ class St extends d {
1817
1809
  }), this.element.appendChild(this.submitButton.getElement());
1818
1810
  }
1819
1811
  handleChange = (e) => {
1820
- const t = e.target, { name: i, value: a } = t;
1821
- this.formManager.handleChange(i, a);
1812
+ const t = e.target, { name: a, value: i } = t;
1813
+ this.formManager.handleChange(a, i);
1822
1814
  };
1823
1815
  handleBlur = (e) => {
1824
- const t = e.target, { name: i, value: a } = t;
1825
- this.formManager.handleBlur(i, a);
1816
+ const t = e.target, { name: a, value: i } = t;
1817
+ this.formManager.handleBlur(a, i);
1826
1818
  };
1827
1819
  updateFormUI() {
1828
1820
  const e = this.formManager.getFormState();
@@ -1845,15 +1837,22 @@ class St extends d {
1845
1837
  isCvvValid: !1
1846
1838
  };
1847
1839
  this.iframeHook && (t = this.iframeHook.getState());
1848
- const i = Object.keys(e.errors).length > 0, a = (
1840
+ const a = Object.keys(e.errors).length > 0, i = (
1849
1841
  // Only require card validation if CardSection exists
1850
1842
  (!this.cardSection || t.isCcValid && t.isCvvValid) && !!e.formData.email && !!e.formData.name && // Only require card expiry if CardSection exists
1851
1843
  (!this.cardSection || !!e.formData.cardExpiry)
1852
1844
  );
1853
- return i || !a || this.isSubmitting;
1845
+ return a || !i || this.isSubmitting;
1846
+ }
1847
+ setLoadingState(e) {
1848
+ if (this.options.onLoadingStateChange) {
1849
+ this.options.onLoadingStateChange(e);
1850
+ return;
1851
+ }
1852
+ e ? (this.hideSpinner(), this.spinner = new N(), this.appendChild(this.spinner)) : this.hideSpinner();
1854
1853
  }
1855
1854
  showSpinner(e) {
1856
- this.hideSpinner(), this.spinner = new at({ text: e }), this.appendChild(this.spinner);
1855
+ this.hideSpinner(), this.spinner = new N({ text: e }), this.appendChild(this.spinner);
1857
1856
  }
1858
1857
  hideSpinner() {
1859
1858
  this.spinner && (this.spinner.getElement().remove(), this.spinner = void 0);
@@ -1901,7 +1900,7 @@ class St extends d {
1901
1900
  * Update the form error message
1902
1901
  */
1903
1902
  setErrorMessage(e) {
1904
- return this.alert && (this.alert.getElement().remove(), this.alert = void 0), this.alert = new it({ message: e }), this.element.insertBefore(this.alert.getElement(), this.element.firstChild), this.getElement().style.opacity === "0" && this.animateFormVisibility(), this;
1903
+ return this.alert && (this.alert.getElement().remove(), this.alert = void 0), this.alert = new it({ message: e }), this.element.insertBefore(this.alert.getElement(), this.element.firstChild), this;
1905
1904
  }
1906
1905
  /**
1907
1906
  * Clean up resources when the form is destroyed
@@ -1935,7 +1934,8 @@ class xt {
1935
1934
  errorMsg: this.options.disableErrorMessages ? void 0 : e,
1936
1935
  profileId: this.options.profileId,
1937
1936
  container: this.container,
1938
- environment: this.options.environment
1937
+ environment: this.options.environment,
1938
+ onLoadingStateChange: this.options.onLoadingStateChange
1939
1939
  }));
1940
1940
  }
1941
1941
  unmount() {
@@ -1982,7 +1982,8 @@ class wt {
1982
1982
  apiKey: this.config.apiKey,
1983
1983
  profileId: this.config.profileId,
1984
1984
  disableErrorMessages: this.config.disableErrorMessages,
1985
- environment: this.config.environment
1985
+ environment: this.config.environment,
1986
+ onLoadingStateChange: this.config.callbacks.onLoadingStateChange
1986
1987
  },
1987
1988
  this.handleSubmit.bind(this)
1988
1989
  );
@@ -2005,7 +2006,8 @@ class wt {
2005
2006
  callbacks: {
2006
2007
  onPaymentSucceeded: e.callbacks?.onPaymentSucceeded || void 0,
2007
2008
  onPaymentFailed: e.callbacks?.onPaymentFailed || void 0,
2008
- onActionRequired: e.callbacks?.onActionRequired || void 0
2009
+ onActionRequired: e.callbacks?.onActionRequired || void 0,
2010
+ onLoadingStateChange: e.callbacks?.onLoadingStateChange || void 0
2009
2011
  }
2010
2012
  };
2011
2013
  }
@@ -2013,11 +2015,11 @@ class wt {
2013
2015
  const t = document.querySelector(e);
2014
2016
  if (!t)
2015
2017
  throw new Error(`Container ${e} not found`);
2016
- const i = document.createElement("div");
2017
- return t.appendChild(i), this.stateManager.updateState({
2018
- form: i,
2018
+ const a = document.createElement("div");
2019
+ return t.appendChild(a), this.stateManager.updateState({
2020
+ form: a,
2019
2021
  mounted: !0
2020
- }), this.formManager.mount(i), this;
2022
+ }), this.formManager.mount(a), this;
2021
2023
  }
2022
2024
  unmount() {
2023
2025
  const { mounted: e } = this.stateManager.getState();
@@ -2035,16 +2037,16 @@ class wt {
2035
2037
  formData: t
2036
2038
  }) {
2037
2039
  try {
2038
- const i = await this.apiService.authorizePayment({
2040
+ const a = await this.apiService.authorizePayment({
2039
2041
  checkoutKey: this.config.checkoutKey,
2040
2042
  formData: t || null,
2041
2043
  token: e?.token || null,
2042
2044
  paymentId: this.config.paymentId,
2043
2045
  returnUrl: this.config.returnUrl
2044
2046
  });
2045
- this.handlePaymentResponse(i);
2046
- } catch (i) {
2047
- this.handleAuthorizationError(i);
2047
+ this.handlePaymentResponse(a);
2048
+ } catch (a) {
2049
+ this.handleAuthorizationError(a);
2048
2050
  }
2049
2051
  }
2050
2052
  handlePaymentResponse(e) {
@@ -2064,11 +2066,11 @@ class wt {
2064
2066
  typeof globalThis < "u" && (globalThis.OdusCheckout = wt);
2065
2067
  export {
2066
2068
  wt as OdusCheckout,
2067
- ae as deLocale,
2068
- me as enLocale,
2069
- Ce as esLocale,
2070
- Ie as frLocale,
2071
- Be as plLocale,
2072
- Ze as ptLocale
2069
+ se as deLocale,
2070
+ ue as enLocale,
2071
+ Se as esLocale,
2072
+ ze as frLocale,
2073
+ Oe as plLocale,
2074
+ Ye as ptLocale
2073
2075
  };
2074
2076
  //# sourceMappingURL=checkout.es.js.map