@odus/checkout 0.25.0 → 0.26.0-beta.1

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.
@@ -0,0 +1,1496 @@
1
+ import { l as a, I as m, S as y, g as C, b as g, A as E, F as k, i as z, a as c, f as N, J as S, E as P, k as x, P as F, h as R, w as A, m as V, n as M, j as B } from "./Alert-CeFsv_tJ.js";
2
+ const l = ".form-helper-text{color:#dc2727;font-family:var(--odus-font-family, inherit);font-size:12px;font-weight:500;margin-top:4px;display:block;overflow:hidden;max-height:100px;transition:max-height .3s ease-in-out,opacity .3s ease-in-out,margin .3s ease-in-out}.form-helper-text-hidden{max-height:0;opacity:0;margin-top:0;overflow:hidden}", h = ".input-wrapper{display:flex;flex-direction:column;width:100%;min-width:0;flex-grow:1;flex-basis:0;box-sizing:border-box;align-items:stretch}.input-wrapper *{box-sizing:border-box}.form-input{opacity:1;font-size:var(--odus-input-font-size, 16px);font-weight:var(--odus-input-font-weight, 400);letter-spacing:var(--odus-input-letter-spacing, .02em);transition:box-shadow .1s ease-in,border-radius .2s ease-in;box-shadow:0 0 0 1px var(--odus-border-color, #e0e0e0),0 2px 4px #00000012,0 1px 1.5px #0000000d;background:var(--odus-color-background, #fff);padding:var(--odus-input-padding, 8px 12px);border:none;outline:none;line-height:var(--odus-input-line-height, 1.5);z-index:0;box-sizing:border-box;min-height:0;flex:1;width:100%}.form-input[name=cardNumber]{padding-right:100px}.form-input-error{color:#dc2727}.form-input::placeholder{color:var(--odus-input-placeholder-color, #717173);opacity:var(--odus-input-placeholder-opacity, .3)}.form-input:focus{box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d;position:relative;z-index:2}", u = ".input-label{font-family:var(--odus-font-family, inherit);font-size:var(--odus-label-font-size, 14px);font-weight:var(--odus-label-font-weight, 500);color:var(--odus-label-color, var(--odus-color-text, #1a1a1a));letter-spacing:var(--odus-label-letter-spacing, normal);line-height:var(--odus-label-line-height, 1.4);margin-bottom:var(--odus-label-margin-bottom, 6px)}", I = ":host{--odus-font-family: system-ui, sans-serif;--odus-font-size: 16px;--odus-color-error: #dc2727;--odus-color-text: #1a1a1a;--odus-color-background: #ffffff;--odus-border-color: #e0e0e0;--odus-border-radius: 6px;--odus-spacing-sm: 8px;--odus-spacing-md: 16px;--odus-spacing-lg: 24px;--odus-input-height: 44px;--odus-input-padding: 8px 12px;--odus-input-font-size: var(--odus-font-size);--odus-input-font-weight: 400;--odus-input-letter-spacing: .02em;--odus-input-line-height: 1.5;--odus-input-placeholder-color: #717173;--odus-input-placeholder-opacity: .3;--odus-input-focus-shadow: 0 0 0 1px rgba(50, 151, 211, .7), 0 1px 1px 0 rgba(0, 0, 0, .07), 0 0 0 4px rgba(50, 151, 211, .3);--odus-label-font-size: 14px;--odus-label-font-weight: 500;--odus-label-color: var(--odus-color-text);--odus-label-letter-spacing: normal;--odus-label-line-height: 1.4;--odus-label-margin-bottom: 6px;--odus-card-gap: 12px;--odus-button-height: 48px;--odus-button-border-radius: var(--odus-border-radius)}.form-input{opacity:1;font-weight:var(--odus-input-font-weight, 400);letter-spacing:var(--odus-input-letter-spacing, .02em);transition:box-shadow .1s ease-in,border-radius .2s ease-in;box-shadow:0 0 0 1px var(--odus-border-color, #e0e0e0),0 2px 4px #00000012,0 1px 1.5px #0000000d;background:var(--odus-color-background, #fff);padding:var(--odus-input-padding, 8px 12px);border:none;outline:none;line-height:var(--odus-input-line-height, 1.5);z-index:0;box-sizing:border-box;min-height:0;flex:1;width:100%}.form-input::placeholder{color:var(--odus-input-placeholder-color, #717173);opacity:var(--odus-input-placeholder-opacity, .3)}.form-input:focus{box-shadow:var( --odus-input-focus-shadow, 0 0 0 1px rgba(50, 151, 211, .7), 0 1px 1px 0 rgba(0, 0, 0, .07), 0 0 0 4px rgba(50, 151, 211, .3) );position:relative;z-index:2}.input-label{font-family:var(--odus-font-family, inherit)!important;font-size:var(--odus-label-font-size, 14px)!important;font-weight:var(--odus-label-font-weight, 500)!important;color:var(--odus-label-color, var(--odus-color-text, #1a1a1a))!important;letter-spacing:var(--odus-label-letter-spacing, normal)!important;line-height:var(--odus-label-line-height, 1.4)!important;margin-bottom:var(--odus-label-margin-bottom, 6px)!important}.form-helper-text{font-family:var(--odus-font-family, inherit)!important}";
3
+ class d {
4
+ shadowRoot = null;
5
+ host = null;
6
+ options = {};
7
+ listeners = /* @__PURE__ */ new Map();
8
+ get isMounted() {
9
+ return this.host !== null;
10
+ }
11
+ mount(e) {
12
+ this.isMounted && this.unmount();
13
+ const t = typeof e == "string" ? document.querySelector(e) : e;
14
+ if (!t)
15
+ throw new Error(
16
+ `[BaseElement] mount target not found: ${String(e)}`
17
+ );
18
+ this.host = document.createElement("div"), this.shadowRoot = this.host.attachShadow({ mode: "open" });
19
+ const r = document.createElement("style");
20
+ r.textContent = this.getCss(), this.shadowRoot.appendChild(r), t.appendChild(this.host), this.render(), this.emit("ready");
21
+ }
22
+ unmount() {
23
+ this.host?.parentElement?.removeChild(this.host), this.host = null, this.shadowRoot = null;
24
+ }
25
+ destroy() {
26
+ this.unmount(), this.listeners.clear();
27
+ }
28
+ on(e, t) {
29
+ const r = this.listeners.get(e) ?? [];
30
+ return r.push(t), this.listeners.set(e, r), this;
31
+ }
32
+ update(e) {
33
+ if (this.options = { ...this.options, ...e }, this.shadowRoot) {
34
+ const t = this.shadowRoot.querySelector("style");
35
+ t && (t.textContent = this.getCss()), this.render();
36
+ }
37
+ }
38
+ setTheme(e) {
39
+ if (this.host)
40
+ for (const [t, r] of Object.entries(e))
41
+ this.host.style.setProperty(t, r);
42
+ }
43
+ resetTheme(e) {
44
+ if (this.host)
45
+ for (const t of Object.keys(e))
46
+ this.host.style.removeProperty(t);
47
+ }
48
+ get value() {
49
+ return this.getValue();
50
+ }
51
+ get isValid() {
52
+ return this.getIsValid();
53
+ }
54
+ get error() {
55
+ return this.getError();
56
+ }
57
+ emit(e, t) {
58
+ const r = this.listeners.get(e) ?? [];
59
+ for (const o of r)
60
+ o(t);
61
+ this.options.callbacks?.[e]?.(t);
62
+ }
63
+ getCss() {
64
+ return I;
65
+ }
66
+ }
67
+ class L extends d {
68
+ _value = "";
69
+ _error = null;
70
+ _input = null;
71
+ render() {
72
+ if (!this.shadowRoot) return;
73
+ this._input?.getElement().remove();
74
+ const { t: e } = a();
75
+ this._input = new m({
76
+ name: "billingAddress.city",
77
+ label: e("address.city"),
78
+ error: !1,
79
+ placeholder: e("address.city"),
80
+ value: this._value,
81
+ autocomplete: "address-level2",
82
+ onChange: (t) => {
83
+ this._value = t.target.value, this._error = null, this.emit("change", this._value);
84
+ }
85
+ }), this._input.addEventListener("blur", () => {
86
+ const { t } = a();
87
+ this._error = this._value.trim() ? null : t("validation.cityRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
88
+ }), this.shadowRoot.appendChild(this._input.getElement());
89
+ }
90
+ getCss() {
91
+ return super.getCss() + [h, u, l].join(`
92
+ `) + `
93
+ :host { display: block; }
94
+ .form-input {
95
+ color: var(--odus-color-text, #1a1a1a) !important;
96
+ font-family: var(--odus-font-family, system-ui, sans-serif) !important;
97
+ font-size: var(--odus-input-font-size, 16px) !important;
98
+ background: var(--odus-color-background, #ffffff) !important;
99
+ border-radius: var(--odus-border-radius, 6px) !important;
100
+ box-shadow:
101
+ 0 0 0 1px var(--odus-border-color, #e0e0e0),
102
+ 0 2px 4px 0 rgba(0, 0, 0, 0.07),
103
+ 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
104
+ }
105
+ .form-input:focus {
106
+ box-shadow: var(
107
+ --odus-input-focus-shadow,
108
+ 0 0 0 1px rgba(50, 151, 211, 0.7),
109
+ 0 1px 1px 0 rgba(0, 0, 0, 0.07),
110
+ 0 0 0 4px rgba(50, 151, 211, 0.3)
111
+ ) !important;
112
+ outline: none !important;
113
+ }
114
+ .form-input-error {
115
+ color: var(--odus-color-error, #dc2727) !important;
116
+ }
117
+ .form-helper-text {
118
+ color: var(--odus-color-error, #dc2727) !important;
119
+ }
120
+ `;
121
+ }
122
+ getValue() {
123
+ return this._value;
124
+ }
125
+ getIsValid() {
126
+ return !!this._value.trim();
127
+ }
128
+ getError() {
129
+ return this._error;
130
+ }
131
+ }
132
+ const v = `.form-select{opacity:1;font-weight:400;letter-spacing:.02em;transition:box-shadow .1s ease-in,border-radius .2s ease-in;box-shadow:0 0 0 1px #e0e0e0,0 2px 4px #00000012,0 1px 1.5px #0000000d;background:#fff;padding:8px 32px 8px 12px;border:none;outline:none;line-height:1.5;z-index:0;box-sizing:border-box;min-height:0;flex:1;width:100%;cursor:pointer;appearance:none;-webkit-appearance:none;-moz-appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23717173' d='M6 8.5L1.5 4h9L6 8.5z'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 12px center}.form-select-error{color:#dc2727}.form-select-placeholder{color:#d4d4d5}.form-select option[disabled]{color:#717173;opacity:.5}.form-select:focus{box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d;position:relative;z-index:2}`;
133
+ class T extends d {
134
+ _value = "";
135
+ _error = null;
136
+ _select = null;
137
+ _allowedCountries;
138
+ setCountries(e) {
139
+ this._allowedCountries = e.length > 0 ? e : void 0, this._value && this._allowedCountries && !this._allowedCountries.includes(this._value) && (this._value = "", this._error = null, this.emit("change", this._value)), this.shadowRoot && this.render();
140
+ }
141
+ render() {
142
+ if (!this.shadowRoot) return;
143
+ this._select?.getElement().remove(), this.options.initialValue && !this._value && (this._value = String(this.options.initialValue));
144
+ const { t: e } = a();
145
+ this._select = new y({
146
+ name: "billingAddress.country",
147
+ label: e("address.country"),
148
+ error: !1,
149
+ placeholder: e("address.chooseCountry"),
150
+ value: this._value,
151
+ options: C(this._allowedCountries),
152
+ autocomplete: "country",
153
+ onChange: (t) => {
154
+ this._value = t.target.value, this._error = null, this.emit("change", this._value);
155
+ }
156
+ }), this._select.addEventListener("blur", () => {
157
+ const { t } = a();
158
+ this._error = this._value ? null : t("validation.countryRequired"), this._select?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
159
+ }), this.shadowRoot.appendChild(this._select.getElement());
160
+ }
161
+ getCss() {
162
+ return super.getCss() + [u, l, v].join(`
163
+ `) + `
164
+ :host { display: block; }
165
+ .form-select {
166
+ color: var(--odus-color-text, #1a1a1a) !important;
167
+ font-family: var(--odus-font-family, system-ui, sans-serif) !important;
168
+ font-size: var(--odus-input-font-size, 16px) !important;
169
+ background: var(--odus-color-background, #ffffff) !important;
170
+ border-radius: var(--odus-border-radius, 6px) !important;
171
+ box-shadow:
172
+ 0 0 0 1px var(--odus-border-color, #e0e0e0),
173
+ 0 2px 4px 0 rgba(0, 0, 0, 0.07),
174
+ 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
175
+ }
176
+ .form-select:focus {
177
+ box-shadow: var(
178
+ --odus-input-focus-shadow,
179
+ 0 0 0 1px rgba(50, 151, 211, 0.7),
180
+ 0 1px 1px 0 rgba(0, 0, 0, 0.07),
181
+ 0 0 0 4px rgba(50, 151, 211, 0.3)
182
+ ) !important;
183
+ outline: none !important;
184
+ }
185
+ .form-select-error {
186
+ color: var(--odus-color-error, #dc2727) !important;
187
+ }
188
+ .form-helper-text {
189
+ color: var(--odus-color-error, #dc2727) !important;
190
+ }
191
+ `;
192
+ }
193
+ getValue() {
194
+ return this._value;
195
+ }
196
+ getIsValid() {
197
+ return !!this._value;
198
+ }
199
+ getError() {
200
+ return this._error;
201
+ }
202
+ }
203
+ class j extends d {
204
+ _value = "";
205
+ _error = null;
206
+ _input = null;
207
+ render() {
208
+ if (!this.shadowRoot) return;
209
+ this._input?.getElement().remove();
210
+ const { t: e } = a();
211
+ this._input = new m({
212
+ name: "billingAddress.firstName",
213
+ label: e("address.firstName"),
214
+ error: !1,
215
+ placeholder: e("address.firstName"),
216
+ value: this._value,
217
+ autocomplete: "given-name",
218
+ onChange: (t) => {
219
+ this._value = t.target.value, this._error = null, this.emit("change", this._value);
220
+ }
221
+ }), this._input.addEventListener("blur", () => {
222
+ const { t } = a();
223
+ this._error = this._value.trim() ? null : t("validation.firstNameRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
224
+ }), this.shadowRoot.appendChild(this._input.getElement());
225
+ }
226
+ getCss() {
227
+ return super.getCss() + [h, u, l].join(`
228
+ `) + `
229
+ :host { display: block; }
230
+ .form-input {
231
+ color: var(--odus-color-text, #1a1a1a) !important;
232
+ font-family: var(--odus-font-family, system-ui, sans-serif) !important;
233
+ font-size: var(--odus-input-font-size, 16px) !important;
234
+ background: var(--odus-color-background, #ffffff) !important;
235
+ border-radius: var(--odus-border-radius, 6px) !important;
236
+ box-shadow:
237
+ 0 0 0 1px var(--odus-border-color, #e0e0e0),
238
+ 0 2px 4px 0 rgba(0, 0, 0, 0.07),
239
+ 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
240
+ }
241
+ .form-input:focus {
242
+ box-shadow: var(
243
+ --odus-input-focus-shadow,
244
+ 0 0 0 1px rgba(50, 151, 211, 0.7),
245
+ 0 1px 1px 0 rgba(0, 0, 0, 0.07),
246
+ 0 0 0 4px rgba(50, 151, 211, 0.3)
247
+ ) !important;
248
+ outline: none !important;
249
+ }
250
+ .form-input-error {
251
+ color: var(--odus-color-error, #dc2727) !important;
252
+ }
253
+ .form-helper-text {
254
+ color: var(--odus-color-error, #dc2727) !important;
255
+ }
256
+ `;
257
+ }
258
+ getValue() {
259
+ return this._value;
260
+ }
261
+ getIsValid() {
262
+ return !!this._value.trim();
263
+ }
264
+ getError() {
265
+ return this._error;
266
+ }
267
+ }
268
+ class q extends d {
269
+ _value = "";
270
+ _error = null;
271
+ _input = null;
272
+ render() {
273
+ if (!this.shadowRoot) return;
274
+ this._input?.getElement().remove();
275
+ const { t: e } = a();
276
+ this._input = new m({
277
+ name: "billingAddress.lastName",
278
+ label: e("address.lastName"),
279
+ error: !1,
280
+ placeholder: e("address.lastName"),
281
+ value: this._value,
282
+ autocomplete: "family-name",
283
+ onChange: (t) => {
284
+ this._value = t.target.value, this._error = null, this.emit("change", this._value);
285
+ }
286
+ }), this._input.addEventListener("blur", () => {
287
+ const { t } = a();
288
+ this._error = this._value.trim() ? null : t("validation.lastNameRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
289
+ }), this.shadowRoot.appendChild(this._input.getElement());
290
+ }
291
+ getCss() {
292
+ return super.getCss() + [h, u, l].join(`
293
+ `) + `
294
+ :host { display: block; }
295
+ .form-input {
296
+ color: var(--odus-color-text, #1a1a1a) !important;
297
+ font-family: var(--odus-font-family, system-ui, sans-serif) !important;
298
+ font-size: var(--odus-input-font-size, 16px) !important;
299
+ background: var(--odus-color-background, #ffffff) !important;
300
+ border-radius: var(--odus-border-radius, 6px) !important;
301
+ box-shadow:
302
+ 0 0 0 1px var(--odus-border-color, #e0e0e0),
303
+ 0 2px 4px 0 rgba(0, 0, 0, 0.07),
304
+ 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
305
+ }
306
+ .form-input:focus {
307
+ box-shadow: var(
308
+ --odus-input-focus-shadow,
309
+ 0 0 0 1px rgba(50, 151, 211, 0.7),
310
+ 0 1px 1px 0 rgba(0, 0, 0, 0.07),
311
+ 0 0 0 4px rgba(50, 151, 211, 0.3)
312
+ ) !important;
313
+ outline: none !important;
314
+ }
315
+ .form-input-error {
316
+ color: var(--odus-color-error, #dc2727) !important;
317
+ }
318
+ .form-helper-text {
319
+ color: var(--odus-color-error, #dc2727) !important;
320
+ }
321
+ `;
322
+ }
323
+ getValue() {
324
+ return this._value;
325
+ }
326
+ getIsValid() {
327
+ return !!this._value.trim();
328
+ }
329
+ getError() {
330
+ return this._error;
331
+ }
332
+ }
333
+ const b = /* @__PURE__ */ new Set(["US", "CA"]);
334
+ class D extends d {
335
+ _value = "";
336
+ _country = "";
337
+ _input = null;
338
+ _select = null;
339
+ _allowedStates;
340
+ setStates(e) {
341
+ this._allowedStates = e.length > 0 ? e : void 0, this._value && this._allowedStates && !this._allowedStates.includes(this._value) && (this._value = "", this.emit("change", this._value)), this.shadowRoot && this.render();
342
+ }
343
+ setCountry(e) {
344
+ const t = this._country;
345
+ if (this._country = e, !this.shadowRoot) return;
346
+ const r = b.has(t), o = b.has(e);
347
+ if (r && o && t !== e) {
348
+ const { t: s } = a(), i = e, p = s(i === "US" ? "address.chooseState" : "address.chooseProvince");
349
+ this._select?.setOptions(
350
+ g(this._allowedStates, i),
351
+ p
352
+ ), this._value = "";
353
+ return;
354
+ }
355
+ r !== o && (this._value = "", this.render());
356
+ }
357
+ render() {
358
+ if (!this.shadowRoot) return;
359
+ this._input?.getElement().remove(), this._select?.getElement().remove(), this._input = null, this._select = null;
360
+ const e = b.has(this._country);
361
+ if (this._allowedStates || e) {
362
+ const t = e ? this._country : "US";
363
+ this._renderSelect(t);
364
+ } else
365
+ this._renderInput();
366
+ }
367
+ _renderInput() {
368
+ const { t: e } = a();
369
+ this._input = new m({
370
+ name: "billingAddress.state",
371
+ label: e("address.state"),
372
+ error: !1,
373
+ placeholder: e("address.state"),
374
+ value: this._value,
375
+ autocomplete: "address-level1",
376
+ onChange: (t) => {
377
+ this._value = t.target.value, this.emit("change", this._value);
378
+ }
379
+ }), this._input.addEventListener("blur", () => {
380
+ this.emit("blur", this._value);
381
+ }), this.shadowRoot.appendChild(this._input.getElement());
382
+ }
383
+ _renderSelect(e) {
384
+ const { t } = a(), r = g(this._allowedStates, e), o = t(e === "US" ? "address.chooseState" : "address.chooseProvince");
385
+ this._select = new y({
386
+ name: "billingAddress.state",
387
+ label: t("address.state"),
388
+ error: !1,
389
+ placeholder: o,
390
+ value: this._value,
391
+ options: r,
392
+ autocomplete: "address-level1",
393
+ onChange: (s) => {
394
+ this._value = s.target.value, this.emit("change", this._value);
395
+ }
396
+ }), this._select.addEventListener("blur", () => {
397
+ this.emit("blur", this._value);
398
+ }), this.shadowRoot.appendChild(this._select.getElement());
399
+ }
400
+ getCss() {
401
+ return super.getCss() + [h, u, l, v].join(`
402
+ `) + `
403
+ :host { display: block; }
404
+ .form-input,
405
+ .form-select {
406
+ color: var(--odus-color-text, #1a1a1a) !important;
407
+ font-family: var(--odus-font-family, system-ui, sans-serif) !important;
408
+ font-size: var(--odus-input-font-size, 16px) !important;
409
+ background: var(--odus-color-background, #ffffff) !important;
410
+ border-radius: var(--odus-border-radius, 6px) !important;
411
+ box-shadow:
412
+ 0 0 0 1px var(--odus-border-color, #e0e0e0),
413
+ 0 2px 4px 0 rgba(0, 0, 0, 0.07),
414
+ 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
415
+ }
416
+ .form-input:focus,
417
+ .form-select:focus {
418
+ box-shadow: var(
419
+ --odus-input-focus-shadow,
420
+ 0 0 0 1px rgba(50, 151, 211, 0.7),
421
+ 0 1px 1px 0 rgba(0, 0, 0, 0.07),
422
+ 0 0 0 4px rgba(50, 151, 211, 0.3)
423
+ ) !important;
424
+ outline: none !important;
425
+ }
426
+ .form-input-error,
427
+ .form-select-error {
428
+ color: var(--odus-color-error, #dc2727) !important;
429
+ }
430
+ .form-helper-text {
431
+ color: var(--odus-color-error, #dc2727) !important;
432
+ }
433
+ `;
434
+ }
435
+ getValue() {
436
+ return this._value;
437
+ }
438
+ getIsValid() {
439
+ return !0;
440
+ }
441
+ getError() {
442
+ return null;
443
+ }
444
+ }
445
+ class O extends d {
446
+ _value = "";
447
+ _error = null;
448
+ _input = null;
449
+ render() {
450
+ if (!this.shadowRoot) return;
451
+ this._input?.getElement().remove();
452
+ const { t: e } = a();
453
+ this._input = new m({
454
+ name: "billingAddress.street",
455
+ label: e("address.street"),
456
+ error: !1,
457
+ placeholder: e("address.street"),
458
+ value: this._value,
459
+ autocomplete: "street-address",
460
+ onChange: (t) => {
461
+ this._value = t.target.value, this._error = null, this.emit("change", this._value);
462
+ }
463
+ }), this._input.addEventListener("blur", () => {
464
+ const { t } = a();
465
+ this._error = this._value.trim() ? null : t("validation.streetRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
466
+ }), this.shadowRoot.appendChild(this._input.getElement());
467
+ }
468
+ getCss() {
469
+ return super.getCss() + [h, u, l].join(`
470
+ `) + `
471
+ :host { display: block; }
472
+ .form-input {
473
+ color: var(--odus-color-text, #1a1a1a) !important;
474
+ font-family: var(--odus-font-family, system-ui, sans-serif) !important;
475
+ font-size: var(--odus-input-font-size, 16px) !important;
476
+ background: var(--odus-color-background, #ffffff) !important;
477
+ border-radius: var(--odus-border-radius, 6px) !important;
478
+ box-shadow:
479
+ 0 0 0 1px var(--odus-border-color, #e0e0e0),
480
+ 0 2px 4px 0 rgba(0, 0, 0, 0.07),
481
+ 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
482
+ }
483
+ .form-input:focus {
484
+ box-shadow: var(
485
+ --odus-input-focus-shadow,
486
+ 0 0 0 1px rgba(50, 151, 211, 0.7),
487
+ 0 1px 1px 0 rgba(0, 0, 0, 0.07),
488
+ 0 0 0 4px rgba(50, 151, 211, 0.3)
489
+ ) !important;
490
+ outline: none !important;
491
+ }
492
+ .form-input-error {
493
+ color: var(--odus-color-error, #dc2727) !important;
494
+ }
495
+ .form-helper-text {
496
+ color: var(--odus-color-error, #dc2727) !important;
497
+ }
498
+ `;
499
+ }
500
+ getValue() {
501
+ return this._value;
502
+ }
503
+ getIsValid() {
504
+ return !!this._value.trim();
505
+ }
506
+ getError() {
507
+ return this._error;
508
+ }
509
+ }
510
+ class Z extends d {
511
+ _value = "";
512
+ _error = null;
513
+ _input = null;
514
+ render() {
515
+ if (!this.shadowRoot) return;
516
+ this._input?.getElement().remove();
517
+ const { t: e } = a();
518
+ this._input = new m({
519
+ name: "billingAddress.zipCode",
520
+ label: e("address.zipCode"),
521
+ error: !1,
522
+ placeholder: e("address.zipCode"),
523
+ value: this._value,
524
+ autocomplete: "postal-code",
525
+ onChange: (t) => {
526
+ this._value = t.target.value, this._error = null, this.emit("change", this._value);
527
+ }
528
+ }), this._input.addEventListener("blur", () => {
529
+ const { t } = a();
530
+ this._error = this._value.trim() ? null : t("validation.zipCodeRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
531
+ }), this.shadowRoot.appendChild(this._input.getElement());
532
+ }
533
+ getCss() {
534
+ return super.getCss() + [h, u, l].join(`
535
+ `) + `
536
+ :host { display: block; }
537
+ .form-input {
538
+ color: var(--odus-color-text, #1a1a1a) !important;
539
+ font-family: var(--odus-font-family, system-ui, sans-serif) !important;
540
+ font-size: var(--odus-input-font-size, 16px) !important;
541
+ background: var(--odus-color-background, #ffffff) !important;
542
+ border-radius: var(--odus-border-radius, 6px) !important;
543
+ box-shadow:
544
+ 0 0 0 1px var(--odus-border-color, #e0e0e0),
545
+ 0 2px 4px 0 rgba(0, 0, 0, 0.07),
546
+ 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
547
+ }
548
+ .form-input:focus {
549
+ box-shadow: var(
550
+ --odus-input-focus-shadow,
551
+ 0 0 0 1px rgba(50, 151, 211, 0.7),
552
+ 0 1px 1px 0 rgba(0, 0, 0, 0.07),
553
+ 0 0 0 4px rgba(50, 151, 211, 0.3)
554
+ ) !important;
555
+ outline: none !important;
556
+ }
557
+ .form-input-error {
558
+ color: var(--odus-color-error, #dc2727) !important;
559
+ }
560
+ .form-helper-text {
561
+ color: var(--odus-color-error, #dc2727) !important;
562
+ }
563
+ `;
564
+ }
565
+ getValue() {
566
+ return this._value;
567
+ }
568
+ getIsValid() {
569
+ return !!this._value.trim();
570
+ }
571
+ getError() {
572
+ return this._error;
573
+ }
574
+ }
575
+ const K = "apple-pay-button{-webkit-appearance:-apple-pay-button;-apple-pay-button-type:plain;-apple-pay-button-style:black;appearance:-apple-pay-button;height:40px;min-height:40px;border-radius:4px;cursor:pointer;display:inline-block;width:100%;box-sizing:border-box}apple-pay-button:hover{filter:brightness(.9)}", U = {
576
+ name: "odus-elements",
577
+ styles: {
578
+ fontSize: 14,
579
+ textColor: "#000000",
580
+ buttonColor: "#0070f3",
581
+ borderRadius: 4,
582
+ fontFamily: "system-ui",
583
+ buttonTextColor: "#ffffff",
584
+ buttonFontSize: 16
585
+ },
586
+ layout: {
587
+ actionButton: { translationKey: null },
588
+ billingFields: {
589
+ street: { enabled: !1 },
590
+ city: { enabled: !1 },
591
+ state: { enabled: !1 },
592
+ zipCode: { enabled: !1 },
593
+ firstName: { enabled: !1 },
594
+ lastName: { enabled: !1 },
595
+ country: { enabled: !1 }
596
+ }
597
+ },
598
+ additionalPaymentMethods: {}
599
+ };
600
+ class Q extends d {
601
+ _paymentContext = null;
602
+ _applePayData = null;
603
+ _authorized = !1;
604
+ _button = null;
605
+ setPaymentContext(e) {
606
+ this._paymentContext = e, this.isMounted && this.render();
607
+ }
608
+ render() {
609
+ if (!this.shadowRoot || (this._button?.getElement().remove(), this._button = null, !this._paymentContext))
610
+ return;
611
+ const {
612
+ paymentId: e,
613
+ checkoutKey: t,
614
+ environment: r,
615
+ checkoutDetails: o,
616
+ displayName: s,
617
+ countries: i,
618
+ requiredBillingContactFields: p,
619
+ requiredShippingContactFields: _,
620
+ onAuthorize: w
621
+ } = this._paymentContext;
622
+ i?.length && o?.countryCode && !i.map((f) => f.toUpperCase()).includes(o.countryCode.toUpperCase()) || (this._button = new E({
623
+ checkoutProfile: U,
624
+ paymentId: e,
625
+ checkoutKey: t,
626
+ environment: r,
627
+ checkoutDetails: o,
628
+ displayName: s,
629
+ requiredBillingContactFields: p,
630
+ requiredShippingContactFields: _,
631
+ onSubmit: async ({ applePayData: f }) => {
632
+ f && (this._applePayData = f, this._authorized = !0, this.emit("change", f), await w(f));
633
+ }
634
+ }), this.shadowRoot.appendChild(this._button.getElement()));
635
+ }
636
+ getCss() {
637
+ return super.getCss() + K + `
638
+ :host { display: block; }
639
+ apple-pay-button {
640
+ width: 100%;
641
+ height: var(--odus-button-height, 48px);
642
+ border-radius: var(--odus-button-border-radius, 6px);
643
+ }
644
+ `;
645
+ }
646
+ getValue() {
647
+ return this._applePayData;
648
+ }
649
+ getIsValid() {
650
+ return this._authorized;
651
+ }
652
+ getError() {
653
+ return null;
654
+ }
655
+ }
656
+ const G = '.card-element{position:relative;height:38.5px;transition:box-shadow .1s ease-in;box-shadow:0 0 0 1px #e0e0e0,0 2px 4px #00000012,0 1px 1.5px #0000000d;padding:0;border:none;background:#fff;border-radius:inherit;box-sizing:border-box}.card-element iframe{width:100%;min-width:0;display:block}.card-element-focus{box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d}.card-icon{width:18px;transition:opacity .6s ease-in;opacity:1}.card-icon img{max-width:100%;display:block;height:auto}.cards-position{position:absolute;z-index:10;right:12px;top:50%;transform:translateY(-50%);display:flex;align-items:center;gap:8px;pointer-events:none}.loading{position:relative}.loading:after{content:"";position:absolute;inset:0;height:100%;width:100%;background-color:#fff;border-radius:inherit}@media only screen and (min-width: 600px){.card-icon{width:20px}}', J = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvWpIQFjQQCPpaIlJKpegirp5kLkzLB1AxHmnLk73D3TJbAGqr1QmlsWDBtMPMRpdzzUM7ZwX3kzhIuATV4Pe7RKp3nZlVmcrT0YCQXBrTwqZNh775z58GP2kZs+gVfNqBampJPzSB/hB62KkByhECn6grrRjiAVwJyZVEvs/2vrxaEpO+aE16emtX12RgI5JdzdOiNyZEQteU6zRBRJEocPWVxExaOpVVVJ5+UnW0LcalzA+lRGRTrQJ5JguAPiAOzRPTK/lYFFpCAl/F8wtoAVG1c8zO2NcQ0Pko+fmeidRFxJ/did2btV+9Mkze3mBphwFmvnxa35LF+Cs/XJHDwIDAQAB", H = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA8gGPMwBRPuVyJReZGIkWH/+Bf5pnpDN1bSR2cLYLXVT8CaSnTw74qeboSnktgYCi1D9R3Bj2fYzTIwGGZb8KinLdxwbqZmHwrE9cFhCaHbG/E0PbqQGhXP2vbniZTT4M0i0Cbi7ES3Bw5zqNbIZZnX041QEpxLvIyWPKZCX+fBogNMhWfCF779aclChjHkwZMsufThVWE9xklWGxXiytx5aL4I5JPxq0I7cAkZGGs4aF/GxWwPaq7R3wPikJQ0YHnCMfcURzl2Hnw/inqyMy+JB6djTq2/BdzMAhWTh3cDWq9Xu+gEkb/QCd0n1yYIdKuDISlk/AfHdWe34IvzhVyQIDAQAB", W = {
657
+ name: "odus-elements",
658
+ styles: {
659
+ fontSize: 14,
660
+ textColor: "#000000",
661
+ buttonColor: "#0070f3",
662
+ borderRadius: 4,
663
+ fontFamily: "system-ui",
664
+ buttonTextColor: "#ffffff",
665
+ buttonFontSize: 16
666
+ },
667
+ layout: {
668
+ actionButton: { translationKey: null },
669
+ billingFields: {
670
+ street: { enabled: !0 },
671
+ city: { enabled: !0 },
672
+ state: { enabled: !0 },
673
+ zipCode: { enabled: !0 },
674
+ firstName: { enabled: !0 },
675
+ lastName: { enabled: !0 },
676
+ country: { enabled: !0 }
677
+ }
678
+ },
679
+ additionalPaymentMethods: {}
680
+ };
681
+ class Y extends d {
682
+ _cardNumber = "";
683
+ _cardExpiry = "";
684
+ _cardCvv = "";
685
+ _environment = "test";
686
+ _section = null;
687
+ _focusManager = new k();
688
+ _touchedFields = /* @__PURE__ */ new Set();
689
+ _focusHandlers = [];
690
+ setEnvironment(e) {
691
+ this._environment = e;
692
+ }
693
+ render() {
694
+ if (!this.shadowRoot) return;
695
+ this._section?.getElement().remove();
696
+ const { t: e } = a();
697
+ this._section = new z({
698
+ checkoutProfile: W,
699
+ cardNumber: this._cardNumber,
700
+ cardNumberTouched: !1,
701
+ cardCvv: this._cardCvv,
702
+ cardCvvTouched: !1,
703
+ cardExpiry: this._cardExpiry,
704
+ cardExpiryTouched: !1,
705
+ translationFunc: e,
706
+ onChange: (t) => {
707
+ const r = t.target;
708
+ if (r.name === "cardNumber")
709
+ this._cardNumber = r.value;
710
+ else if (r.name === "cardExpiry") {
711
+ const o = N.cardExpiry(r.value);
712
+ this._cardExpiry = o, this._section?.updateCardExpiry(o);
713
+ } else r.name === "cardCvv" && (this._cardCvv = r.value);
714
+ this._touchedFields.add(r.name), this._updateFocusManagerState(), this.emit("change", this.getValue());
715
+ },
716
+ onBlur: (t) => {
717
+ const r = t.target, o = r.name ?? "cardExpiry", s = c();
718
+ if (this._touchedFields.add(o), r.name === "cardNumber") {
719
+ const i = s.cardNumber(this._cardNumber);
720
+ this._section?.updateCardNumber(this._cardNumber, i, !0);
721
+ } else if (r.name === "cardCvv") {
722
+ const i = s.cardCvv(this._cardCvv, this._cardNumber);
723
+ this._section?.updateCardCvv(this._cardCvv, i, !0);
724
+ } else {
725
+ const i = s.cardExpiry(this._cardExpiry);
726
+ this._section?.updateCardExpiry(this._cardExpiry, i, !0);
727
+ }
728
+ this._updateFocusManagerState(), this.emit("blur", this.getValue());
729
+ }
730
+ }), this.shadowRoot.appendChild(this._section.getElement()), this._registerFocusFields();
731
+ }
732
+ focus() {
733
+ this._section?.focus();
734
+ }
735
+ focusField(e) {
736
+ this._section?.focusField(e);
737
+ }
738
+ destroy() {
739
+ this._cleanupFocusHandlers(), super.destroy();
740
+ }
741
+ getCss() {
742
+ return super.getCss() + [h, u, l, G].join(`
743
+ `) + `
744
+ :host { display: block; }
745
+ .card-grid {
746
+ display: flex;
747
+ flex-direction: column;
748
+ gap: var(--odus-card-gap, 12px);
749
+ }
750
+ .card-details {
751
+ display: flex;
752
+ gap: var(--odus-card-gap, 12px);
753
+ }
754
+ .form-input,
755
+ .form-select {
756
+ color: var(--odus-color-text, #1a1a1a) !important;
757
+ font-family: var(--odus-font-family, system-ui, sans-serif) !important;
758
+ font-size: var(--odus-input-font-size, 16px) !important;
759
+ background: var(--odus-color-background, #ffffff) !important;
760
+ border-radius: var(--odus-border-radius, 6px) !important;
761
+ box-shadow:
762
+ 0 0 0 1px var(--odus-border-color, #e0e0e0),
763
+ 0 2px 4px 0 rgba(0, 0, 0, 0.07),
764
+ 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
765
+ }
766
+ .form-input:focus,
767
+ .form-select:focus {
768
+ box-shadow: var(
769
+ --odus-input-focus-shadow,
770
+ 0 0 0 1px rgba(50, 151, 211, 0.7),
771
+ 0 1px 1px 0 rgba(0, 0, 0, 0.07),
772
+ 0 0 0 4px rgba(50, 151, 211, 0.3)
773
+ ) !important;
774
+ outline: none !important;
775
+ }
776
+ .form-input-error,
777
+ .form-select-error {
778
+ color: var(--odus-color-error, #dc2727) !important;
779
+ }
780
+ .form-helper-text {
781
+ color: var(--odus-color-error, #dc2727) !important;
782
+ }
783
+ `;
784
+ }
785
+ getValue() {
786
+ return {
787
+ number: this._cardNumber,
788
+ expiry: this._cardExpiry,
789
+ cvv: this._cardCvv
790
+ };
791
+ }
792
+ getPayload() {
793
+ const e = this._environment === "live" ? H : J, t = new S();
794
+ t.setPublicKey(e);
795
+ const r = this._cardNumber.replace(/\s+/g, ""), o = this._cardExpiry.replace(/\s+/g, "").split("/"), s = o[0] ?? "";
796
+ let i = o[1] ?? "";
797
+ return i.length === 2 && (i = `20${i}`), {
798
+ encryptedCardNumber: t.encrypt(r),
799
+ encryptedCvv: t.encrypt(this._cardCvv),
800
+ expMonth: s,
801
+ expYear: i
802
+ };
803
+ }
804
+ getIsValid() {
805
+ const e = c(), t = this._cardCvv.length >= 3;
806
+ return !e.cardNumber(this._cardNumber) && !e.cardExpiry(this._cardExpiry) && t;
807
+ }
808
+ getError() {
809
+ const e = c();
810
+ return e.cardNumber(this._cardNumber) ?? e.cardExpiry(this._cardExpiry) ?? null;
811
+ }
812
+ _registerFocusFields() {
813
+ if (this._cleanupFocusHandlers(), !this._section) return;
814
+ const e = this._section.getElement();
815
+ this._focusManager.registerField("cardNumber", {
816
+ focus: () => this._section?.focusField("cardNumber")
817
+ }), this._focusManager.registerField("cardExpiry", {
818
+ focus: () => this._section?.focusField("cardExpiry")
819
+ }), this._focusManager.registerField("cardCvv", {
820
+ focus: () => this._section?.focusField("cardCvv")
821
+ });
822
+ const t = ["cardNumber", "cardExpiry", "cardCvv"];
823
+ for (const r of t) {
824
+ const o = e.querySelector(`input[name="${r}"]`);
825
+ if (!o) continue;
826
+ const s = () => this._focusManager.handleFieldFocus(r);
827
+ o.addEventListener("focus", s), this._focusHandlers.push(
828
+ () => o.removeEventListener("focus", s)
829
+ );
830
+ }
831
+ }
832
+ _cleanupFocusHandlers() {
833
+ for (const e of this._focusHandlers)
834
+ e();
835
+ this._focusHandlers = [];
836
+ }
837
+ _updateFocusManagerState() {
838
+ const e = c(), t = {
839
+ cardNumber: this._cardNumber,
840
+ cardExpiry: this._cardExpiry,
841
+ cardCvv: this._cardCvv,
842
+ name: "",
843
+ email: ""
844
+ }, r = {}, o = e.cardNumber(this._cardNumber), s = e.cardExpiry(this._cardExpiry), i = e.cardCvv(this._cardCvv, this._cardNumber);
845
+ o && (r.cardNumber = o), s && (r.cardExpiry = s), i && (r.cardCvv = i);
846
+ const p = {};
847
+ for (const _ of this._touchedFields)
848
+ p[_] = !0;
849
+ this._focusManager.handleStateUpdate(t, r, p);
850
+ }
851
+ }
852
+ class X extends d {
853
+ _value = "";
854
+ _error = null;
855
+ _input = null;
856
+ render() {
857
+ if (!this.shadowRoot) return;
858
+ this._input?.getElement().remove();
859
+ const { t: e } = a();
860
+ this._input = new m({
861
+ name: "billingAddress.cardholderName",
862
+ label: e("cardholderNameLabel"),
863
+ error: !1,
864
+ placeholder: e("cardholderNamePlaceholder"),
865
+ value: this._value,
866
+ autocomplete: "cc-name",
867
+ onChange: (t) => {
868
+ const o = t.target.value, s = o.replace(/[^a-zA-Z\s\-'.]/g, "");
869
+ o !== s && this._input?.setValue(s), this._value = s, this._error = null, this.emit("change", this._value);
870
+ }
871
+ }), this._input.addEventListener("blur", () => {
872
+ const { t } = a();
873
+ this._error = this._value.trim() ? null : t("validation.nameRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
874
+ }), this.shadowRoot.appendChild(this._input.getElement());
875
+ }
876
+ getCss() {
877
+ return super.getCss() + [h, u, l].join(`
878
+ `) + `
879
+ :host { display: block; }
880
+ .form-input {
881
+ color: var(--odus-color-text, #1a1a1a) !important;
882
+ font-family: var(--odus-font-family, system-ui, sans-serif) !important;
883
+ font-size: var(--odus-input-font-size, 16px) !important;
884
+ background: var(--odus-color-background, #ffffff) !important;
885
+ border-radius: var(--odus-border-radius, 6px) !important;
886
+ box-shadow:
887
+ 0 0 0 1px var(--odus-border-color, #e0e0e0),
888
+ 0 2px 4px 0 rgba(0, 0, 0, 0.07),
889
+ 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
890
+ }
891
+ .form-input:focus {
892
+ box-shadow: var(
893
+ --odus-input-focus-shadow,
894
+ 0 0 0 1px rgba(50, 151, 211, 0.7),
895
+ 0 1px 1px 0 rgba(0, 0, 0, 0.07),
896
+ 0 0 0 4px rgba(50, 151, 211, 0.3)
897
+ ) !important;
898
+ outline: none !important;
899
+ }
900
+ .form-input-error {
901
+ color: var(--odus-color-error, #dc2727) !important;
902
+ }
903
+ .form-helper-text {
904
+ color: var(--odus-color-error, #dc2727) !important;
905
+ }
906
+ `;
907
+ }
908
+ getValue() {
909
+ return this._value;
910
+ }
911
+ getIsValid() {
912
+ return !!this._value.trim();
913
+ }
914
+ getError() {
915
+ return this._error;
916
+ }
917
+ }
918
+ const $ = {
919
+ name: "odus-elements",
920
+ styles: {
921
+ fontSize: 14,
922
+ textColor: "#000000",
923
+ buttonColor: "#0070f3",
924
+ borderRadius: 4,
925
+ fontFamily: "system-ui",
926
+ buttonTextColor: "#ffffff",
927
+ buttonFontSize: 16
928
+ },
929
+ layout: {
930
+ actionButton: { translationKey: null },
931
+ billingFields: {
932
+ street: { enabled: !1 },
933
+ city: { enabled: !1 },
934
+ state: { enabled: !1 },
935
+ zipCode: { enabled: !1 },
936
+ firstName: { enabled: !1 },
937
+ lastName: { enabled: !1 },
938
+ country: { enabled: !1 }
939
+ }
940
+ },
941
+ additionalPaymentMethods: {}
942
+ };
943
+ class ee extends d {
944
+ _email = "";
945
+ _error = null;
946
+ _field = null;
947
+ render() {
948
+ if (!this.shadowRoot) return;
949
+ this._field?.getElement().remove(), this.options.initialValue && !this._email && (this._email = String(this.options.initialValue));
950
+ const { t: e } = a();
951
+ this._field = new P({
952
+ value: this._email,
953
+ error: !1,
954
+ checkoutProfile: $,
955
+ translationFunc: e,
956
+ onChange: (t) => {
957
+ const r = t.target;
958
+ this._email = r.value ?? this._field?.getValue() ?? "", this._error = null, this.emit("change", this._email);
959
+ },
960
+ onBlur: () => {
961
+ const t = c();
962
+ this._error = t.email(this._email) ?? null, this._field?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._email);
963
+ }
964
+ }), this.shadowRoot.appendChild(this._field.getElement());
965
+ }
966
+ getCss() {
967
+ return super.getCss() + [h, u, l].join(`
968
+ `) + `
969
+ :host { display: block; }
970
+ .form-input {
971
+ color: var(--odus-color-text, #1a1a1a) !important;
972
+ font-family: var(--odus-font-family, system-ui, sans-serif) !important;
973
+ font-size: var(--odus-input-font-size, 16px) !important;
974
+ background: var(--odus-color-background, #ffffff) !important;
975
+ border-radius: var(--odus-border-radius, 6px) !important;
976
+ box-shadow:
977
+ 0 0 0 1px var(--odus-border-color, #e0e0e0),
978
+ 0 2px 4px 0 rgba(0, 0, 0, 0.07),
979
+ 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
980
+ }
981
+ .form-input:focus {
982
+ box-shadow: var(
983
+ --odus-input-focus-shadow,
984
+ 0 0 0 1px rgba(50, 151, 211, 0.7),
985
+ 0 1px 1px 0 rgba(0, 0, 0, 0.07),
986
+ 0 0 0 4px rgba(50, 151, 211, 0.3)
987
+ ) !important;
988
+ outline: none !important;
989
+ }
990
+ .form-input-error {
991
+ color: var(--odus-color-error, #dc2727) !important;
992
+ }
993
+ .form-helper-text {
994
+ color: var(--odus-color-error, #dc2727) !important;
995
+ }
996
+ `;
997
+ }
998
+ getValue() {
999
+ return this._email;
1000
+ }
1001
+ getIsValid() {
1002
+ return !c().email(this._email);
1003
+ }
1004
+ getError() {
1005
+ return this._error;
1006
+ }
1007
+ }
1008
+ const te = "@keyframes slideIn{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}.error-alert{background-color:#fef2f2;border:1px solid #fecaca;border-radius:8px;padding:16px;box-shadow:0 1px 3px #0000001a,0 1px 2px #0000000f;animation:slideIn .3s ease-out}.error-alert-content{display:flex;align-items:flex-start;gap:12px}.error-alert-icon-container{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:32px;height:32px;background-color:#fee2e2;border-radius:50%;color:#dc2626}.error-alert-icon{color:#dc2626}.error-alert-text-container{flex:1;min-width:0}.error-alert-title{margin:0 0 4px;font-size:14px;font-weight:600;color:#991b1b;line-height:1.4}.error-alert-message{margin:0;font-family:var(--odus-font-family, inherit);font-size:14px;color:#7f1d1d;line-height:1.5;word-break:break-word}";
1009
+ class re extends d {
1010
+ _alert = null;
1011
+ _message = null;
1012
+ render() {
1013
+ this.shadowRoot && (this._alert?.getElement().remove(), this._alert = null, this._message && (this._alert = new x({ message: this._message }), this.shadowRoot.appendChild(this._alert.getElement())));
1014
+ }
1015
+ setError(e) {
1016
+ if (this._message = e, !this.shadowRoot) {
1017
+ this.emit("error", e);
1018
+ return;
1019
+ }
1020
+ this._alert ? this._alert.setMessage(e) : (this._alert = new x({ message: e }), this.shadowRoot.appendChild(this._alert.getElement())), this.emit("error", e);
1021
+ }
1022
+ clearError() {
1023
+ this._message = null, this._alert?.getElement().remove(), this._alert = null;
1024
+ }
1025
+ getCss() {
1026
+ return super.getCss() + te + `
1027
+ :host { display: block; }
1028
+ .error-alert-icon,
1029
+ .error-alert-icon-container {
1030
+ color: var(--odus-color-error, #e53e3e) !important;
1031
+ }
1032
+ .error-alert-message {
1033
+ color: var(--odus-color-text, #1a1a1a) !important;
1034
+ }
1035
+ `;
1036
+ }
1037
+ getValue() {
1038
+ return null;
1039
+ }
1040
+ getIsValid() {
1041
+ return !0;
1042
+ }
1043
+ getError() {
1044
+ return this._message;
1045
+ }
1046
+ }
1047
+ const oe = ".paypal{background-color:#ffc439;color:#253b80;font-weight:700;padding:8px 16px;box-shadow:0 2px 4px #0000001a;text-transform:none;cursor:pointer;border-radius:4px}.paypal:hover{background-color:#ffc439;filter:brightness(.95)}.paypal-icon-container{display:flex;align-items:center;justify-content:center}.paypal-icon-container img{width:69px;height:22px}", se = {
1048
+ name: "odus-elements",
1049
+ styles: {
1050
+ fontSize: 14,
1051
+ textColor: "#000000",
1052
+ buttonColor: "#0070f3",
1053
+ borderRadius: 4,
1054
+ fontFamily: "system-ui",
1055
+ buttonTextColor: "#ffffff",
1056
+ buttonFontSize: 16
1057
+ },
1058
+ layout: {
1059
+ actionButton: { translationKey: null },
1060
+ billingFields: {
1061
+ street: { enabled: !1 },
1062
+ city: { enabled: !1 },
1063
+ state: { enabled: !1 },
1064
+ zipCode: { enabled: !1 },
1065
+ firstName: { enabled: !1 },
1066
+ lastName: { enabled: !1 },
1067
+ country: { enabled: !1 }
1068
+ }
1069
+ },
1070
+ additionalPaymentMethods: {}
1071
+ };
1072
+ class ie extends d {
1073
+ _paymentContext = null;
1074
+ _button = null;
1075
+ setPaymentContext(e) {
1076
+ this._paymentContext = e, this.isMounted && this.render();
1077
+ }
1078
+ render() {
1079
+ if (!this.shadowRoot || (this._button?.getElement().remove(), this._button = null, !this._paymentContext)) return;
1080
+ const { onAuthorize: e } = this._paymentContext;
1081
+ this._button = new F({
1082
+ checkoutProfile: se,
1083
+ onSubmit: async () => {
1084
+ this._button?.setSubmitting(!0);
1085
+ try {
1086
+ await e();
1087
+ } finally {
1088
+ this._button?.setSubmitting(!1);
1089
+ }
1090
+ }
1091
+ }), this.shadowRoot.appendChild(this._button.getElement());
1092
+ }
1093
+ getCss() {
1094
+ return super.getCss() + oe + `
1095
+ :host { display: block; }
1096
+ .paypal {
1097
+ width: 100%;
1098
+ box-sizing: border-box;
1099
+ border-radius: var(--odus-button-border-radius, 6px);
1100
+ display: flex;
1101
+ align-items: center;
1102
+ justify-content: center;
1103
+ }
1104
+ `;
1105
+ }
1106
+ getValue() {
1107
+ return null;
1108
+ }
1109
+ getIsValid() {
1110
+ return !0;
1111
+ }
1112
+ getError() {
1113
+ return null;
1114
+ }
1115
+ }
1116
+ const ae = ".country-dial-code-dropdown{position:relative;display:inline-block}.country-dial-code-trigger{display:flex;align-items:center;gap:6px;padding:8px 8px 8px 12px;background:#fff;border:none;cursor:pointer;font-weight:400;letter-spacing:.02em;line-height:1.5;transition:all .1s ease-in;white-space:nowrap;border-right:1px solid #e0e0e0}.country-dial-code-trigger:hover{background:#f5f5f5}.country-dial-code-trigger:focus{outline:none}.country-dial-code-trigger .country-flag{font-size:14px;line-height:1}.country-dial-code-trigger .country-chevron{color:#717173;flex-shrink:0;transition:transform .15s ease}.country-dial-code-trigger[aria-expanded=true] .country-chevron{transform:rotate(180deg)}.country-dial-code-panel{position:absolute;top:0;left:0;z-index:10000;width:280px;background:#fff;border-radius:8px;box-shadow:0 0 0 1px #0000000d,0 4px 6px -1px #0000001a,0 2px 4px -1px #0000000f;max-height:360px;display:flex;flex-direction:column;overflow:hidden}.country-dial-code-panel.hidden{display:none}.country-search-wrapper{padding:12px;border-bottom:1px solid #e0e0e0;flex-shrink:0}.country-search{width:100%;padding:6px 12px;border:1px solid #e0e0e0;border-radius:6px;font-size:inherit;font-family:inherit;outline:none;transition:all .1s ease-in;box-sizing:border-box}.country-search:focus{border-color:#3297d3b3;box-shadow:0 0 0 3px #3297d31a}.country-search::placeholder{color:#717173;opacity:.6}.countries-list{overflow-y:auto;flex:1;min-height:0}.countries-list::-webkit-scrollbar{width:8px}.countries-list::-webkit-scrollbar-track{background:#f5f5f5}.countries-list::-webkit-scrollbar-thumb{background:#d0d0d0;border-radius:4px}.countries-list::-webkit-scrollbar-thumb:hover{background:#b0b0b0}.country-group-header{padding:8px 16px 4px;font-size:12px;font-weight:600;color:#717173;text-transform:uppercase;letter-spacing:.05em;background:#fafafa;position:sticky;top:0;z-index:1}.country-item{display:flex;align-items:center;gap:12px;padding:10px 16px;width:100%;border:none;background:#fff;cursor:pointer;transition:background .1s ease;text-align:left;font-size:14px;font-family:inherit;color:inherit}.country-item:hover{background:#f5f5f5}.country-item.selected{background:#3297d314;color:#3297d3}.country-item:focus{outline:none;background:#f0f0f0}.country-item .country-flag{font-size:20px;line-height:1;flex-shrink:0}.country-item .country-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.country-item .country-dial-code{color:#717173;font-size:.95em;flex-shrink:0}.country-item.selected .country-dial-code{color:#3297d3cc}.no-results{padding:24px 16px;text-align:center;color:#717173;font-size:14px}.phone-number-field-wrapper{display:flex;width:100%}.phone-number-field-container{display:flex;align-items:stretch;width:100%;border-radius:inherit;transition:box-shadow .1s ease-in,border-radius .2s ease-in;box-shadow:0 0 0 1px #e0e0e0,0 2px 4px #00000012,0 1px 1.5px #0000000d;background:#fff;position:relative}.phone-number-field-container.focused{box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d;z-index:2}.phone-number-field-container.error{box-shadow:0 0 0 1px #dc2727,0 2px 4px #dc27271a}.phone-number-field-container.error.focused{box-shadow:0 0 0 1px #dc2727,0 1px 1px #00000012,0 0 0 4px #dc272733}.phone-number-field-container .country-dial-code-dropdown{flex-shrink:0}.phone-number-field-container .country-dial-code-trigger{height:100%;border:none;box-shadow:none;border-radius:0;border-top-left-radius:var(--phone-border-radius, 0px);border-bottom-left-radius:var(--phone-border-radius, 0px)}.phone-number-field-container .phone-input-wrapper{flex:1;min-width:0}.phone-number-field-container .phone-input-wrapper .form-input{border:none;box-shadow:none;border-radius:0;border-top-right-radius:var(--phone-border-radius, 0px);border-bottom-right-radius:var(--phone-border-radius, 0px);height:100%;padding:8px 12px}.phone-number-field-container .phone-input-wrapper .form-input:focus{box-shadow:none;z-index:auto}", ne = {
1117
+ name: "odus-elements",
1118
+ styles: {
1119
+ fontSize: 14,
1120
+ textColor: "#000000",
1121
+ buttonColor: "#0070f3",
1122
+ borderRadius: 4,
1123
+ fontFamily: "system-ui",
1124
+ buttonTextColor: "#ffffff",
1125
+ buttonFontSize: 16
1126
+ },
1127
+ layout: {
1128
+ actionButton: { translationKey: null },
1129
+ billingFields: {
1130
+ street: { enabled: !1 },
1131
+ city: { enabled: !1 },
1132
+ state: { enabled: !1 },
1133
+ zipCode: { enabled: !1 },
1134
+ firstName: { enabled: !1 },
1135
+ lastName: { enabled: !1 },
1136
+ country: { enabled: !1 }
1137
+ }
1138
+ },
1139
+ additionalPaymentMethods: {}
1140
+ };
1141
+ class de extends d {
1142
+ _phone = "";
1143
+ _error = null;
1144
+ _field = null;
1145
+ render() {
1146
+ if (!this.shadowRoot) return;
1147
+ this._field?.destroy(), this._field?.getElement().remove(), this.options.initialValue && !this._phone && (this._phone = String(this.options.initialValue));
1148
+ const { t: e } = a();
1149
+ this._field = new R({
1150
+ value: this._phone,
1151
+ error: !1,
1152
+ checkoutProfile: ne,
1153
+ translationFunc: e,
1154
+ panelContainer: this.shadowRoot ?? void 0,
1155
+ onChange: () => {
1156
+ this._phone = this._field?.getValue() ?? "", this._error = null, this.emit("change", this._phone);
1157
+ },
1158
+ onBlur: () => {
1159
+ this._phone = this._field?.getValue() ?? "";
1160
+ const t = c(), r = this._field?.getCountry();
1161
+ this._error = t.phoneNumber(this._phone, r) ?? null, this._field?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._phone);
1162
+ }
1163
+ }), this.shadowRoot.appendChild(this._field.getElement());
1164
+ }
1165
+ getCss() {
1166
+ return super.getCss() + [h, u, l, ae].join(`
1167
+ `) + `
1168
+ :host { display: block; }
1169
+ .form-input,
1170
+ .country-dial-code-trigger {
1171
+ color: var(--odus-color-text, #1a1a1a) !important;
1172
+ font-family: var(--odus-font-family, system-ui, sans-serif) !important;
1173
+ font-size: var(--odus-input-font-size, 16px) !important;
1174
+ background: var(--odus-color-background, #ffffff) !important;
1175
+ border-radius: 0 !important;
1176
+ box-shadow: none !important;
1177
+ }
1178
+ .phone-number-field-container {
1179
+ min-height: calc(var(--odus-input-font-size, 16px) * 1.5 + 16px);
1180
+ box-shadow:
1181
+ 0 0 0 1px var(--odus-border-color, #e0e0e0),
1182
+ 0 2px 4px 0 rgba(0, 0, 0, 0.07),
1183
+ 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
1184
+ border-radius: var(--odus-border-radius, 6px) !important;
1185
+ overflow: hidden;
1186
+ }
1187
+ .phone-number-field-container:focus-within {
1188
+ box-shadow: var(
1189
+ --odus-input-focus-shadow,
1190
+ 0 0 0 1px rgba(50, 151, 211, 0.7),
1191
+ 0 1px 1px 0 rgba(0, 0, 0, 0.07),
1192
+ 0 0 0 4px rgba(50, 151, 211, 0.3)
1193
+ ) !important;
1194
+ }
1195
+ .phone-number-field-container.error {
1196
+ box-shadow: 0 0 0 1px var(--odus-color-error, #dc2727) !important;
1197
+ }
1198
+ .form-input:focus {
1199
+ box-shadow: none !important;
1200
+ outline: none !important;
1201
+ }
1202
+ .form-input-error {
1203
+ color: var(--odus-color-error, #dc2727) !important;
1204
+ }
1205
+ .form-helper-text {
1206
+ color: var(--odus-color-error, #dc2727) !important;
1207
+ }
1208
+ `;
1209
+ }
1210
+ getValue() {
1211
+ return this._phone;
1212
+ }
1213
+ getIsValid() {
1214
+ const e = c(), t = this._field?.getCountry();
1215
+ return !e.phoneNumber(this._phone, t);
1216
+ }
1217
+ getError() {
1218
+ return this._error;
1219
+ }
1220
+ }
1221
+ class ue {
1222
+ _config;
1223
+ _apiService;
1224
+ _changeListeners = [];
1225
+ _paymentState = {};
1226
+ _fontCleanup;
1227
+ _card;
1228
+ _email;
1229
+ _phone;
1230
+ _addressStreet;
1231
+ _addressFirstName;
1232
+ _addressLastName;
1233
+ _cardholderName;
1234
+ _addressCity;
1235
+ _addressState;
1236
+ _addressZipCode;
1237
+ _addressCountry;
1238
+ _applePay;
1239
+ _paypal;
1240
+ _error;
1241
+ elements;
1242
+ constructor(e) {
1243
+ this._config = e, e.locale && A.setLocale(e.locale), this._apiService = new V(
1244
+ e.apiKey,
1245
+ e.environment
1246
+ );
1247
+ const t = {};
1248
+ Object.defineProperty(t, "email", {
1249
+ get: () => (this._email || (this._email = new ee(), this._trackElement(this._email)), this._email),
1250
+ enumerable: !0
1251
+ }), Object.defineProperty(t, "phone", {
1252
+ get: () => (this._phone || (this._phone = new de(), this._trackElement(this._phone)), this._phone),
1253
+ enumerable: !0
1254
+ });
1255
+ const r = {};
1256
+ Object.defineProperty(r, "applePay", {
1257
+ get: () => (this._applePay || (this._applePay = new Q(), this._trackElement(this._applePay), this._paymentState.paymentId && this._paymentState.checkoutKey && this._applePay.setPaymentContext({
1258
+ paymentId: this._paymentState.paymentId,
1259
+ checkoutKey: this._paymentState.checkoutKey,
1260
+ environment: this._config.environment,
1261
+ checkoutDetails: this._paymentState.checkoutDetails,
1262
+ ...this._config.additionalPaymentMethods?.applePay,
1263
+ onAuthorize: (i) => this._executeAuthorization({ formData: null, applePayData: i })
1264
+ })), this._applePay),
1265
+ enumerable: !0
1266
+ }), Object.defineProperty(r, "payPal", {
1267
+ get: () => (this._paypal || (this._paypal = new ie(), this._trackElement(this._paypal), this._paymentState.paymentId && this._paymentState.checkoutKey && this._paypal.setPaymentContext({
1268
+ paymentId: this._paymentState.paymentId,
1269
+ checkoutKey: this._paymentState.checkoutKey,
1270
+ onAuthorize: () => this._executeAuthorization({ formData: null })
1271
+ })), this._paypal),
1272
+ enumerable: !0
1273
+ });
1274
+ const o = {};
1275
+ Object.defineProperty(o, "street", {
1276
+ get: () => (this._addressStreet || (this._addressStreet = new O(), this._trackElement(this._addressStreet)), this._addressStreet),
1277
+ enumerable: !0
1278
+ }), Object.defineProperty(o, "firstName", {
1279
+ get: () => (this._addressFirstName || (this._addressFirstName = new j(), this._trackElement(this._addressFirstName)), this._addressFirstName),
1280
+ enumerable: !0
1281
+ }), Object.defineProperty(o, "lastName", {
1282
+ get: () => (this._addressLastName || (this._addressLastName = new q(), this._trackElement(this._addressLastName)), this._addressLastName),
1283
+ enumerable: !0
1284
+ }), Object.defineProperty(o, "city", {
1285
+ get: () => (this._addressCity || (this._addressCity = new L(), this._trackElement(this._addressCity)), this._addressCity),
1286
+ enumerable: !0
1287
+ }), Object.defineProperty(o, "state", {
1288
+ get: () => (this._addressState || (this._addressState = new D(), this._trackElement(this._addressState)), this._addressState),
1289
+ enumerable: !0
1290
+ }), Object.defineProperty(o, "zipCode", {
1291
+ get: () => (this._addressZipCode || (this._addressZipCode = new Z(), this._trackElement(this._addressZipCode)), this._addressZipCode),
1292
+ enumerable: !0
1293
+ }), Object.defineProperty(o, "country", {
1294
+ get: () => (this._addressCountry || (this._addressCountry = new T(), this._trackElement(this._addressCountry), this._addressCountry.on("change", (i) => {
1295
+ this._addressState?.setCountry(i);
1296
+ })), this._addressCountry),
1297
+ enumerable: !0
1298
+ });
1299
+ const s = { contact: t, express: r };
1300
+ Object.defineProperty(s, "card", {
1301
+ get: () => (this._card || (this._card = new Y(), this._card.setEnvironment(this._config.environment), this._trackElement(this._card)), this._card),
1302
+ enumerable: !0
1303
+ }), Object.defineProperty(s, "cardholderName", {
1304
+ get: () => (this._cardholderName || (this._cardholderName = new X(), this._trackElement(this._cardholderName)), this._cardholderName),
1305
+ enumerable: !0
1306
+ }), Object.defineProperty(s, "address", {
1307
+ get: () => o,
1308
+ enumerable: !0
1309
+ }), Object.defineProperty(s, "error", {
1310
+ get: () => (this._error || (this._error = new re(), this._trackElement(this._error)), this._error),
1311
+ enumerable: !0
1312
+ }), this.elements = s;
1313
+ }
1314
+ async associatePayment(e, t) {
1315
+ if (!e || !t)
1316
+ throw new Error("paymentId and checkoutKey are required");
1317
+ this._paymentState.paymentId = e, this._paymentState.checkoutKey = t;
1318
+ const r = await M({
1319
+ id: e,
1320
+ checkoutKey: t,
1321
+ environment: this._config.environment
1322
+ });
1323
+ this._paymentState.checkoutDetails = {
1324
+ amount: r.amount,
1325
+ currency: r.currency,
1326
+ countryCode: r.countryCode
1327
+ }, this._card?.setEnvironment(this._config.environment), this._applePay?.setPaymentContext({
1328
+ paymentId: e,
1329
+ checkoutKey: t,
1330
+ environment: this._config.environment,
1331
+ checkoutDetails: this._paymentState.checkoutDetails,
1332
+ ...this._config.additionalPaymentMethods?.applePay,
1333
+ onAuthorize: (o) => this._executeAuthorization({ formData: null, applePayData: o })
1334
+ }), this._paypal?.setPaymentContext({
1335
+ paymentId: e,
1336
+ checkoutKey: t,
1337
+ onAuthorize: () => this._executeAuthorization({ formData: null })
1338
+ });
1339
+ }
1340
+ validate() {
1341
+ const e = {}, { t } = a();
1342
+ return this._card?.isMounted && !this._card.isValid && (e.card = this._card.error ?? "Card details are invalid"), this._email?.isMounted && !this._email.isValid && (e.email = this._email.error ?? t("validation.emailInvalid")), this._phone?.isMounted && !this._phone.isValid && (e.phone = this._phone.error ?? t("validation.phoneNumberInvalid")), this._addressStreet?.isMounted && !this._addressStreet.isValid && (e["address.street"] = this._addressStreet.error ?? t("validation.streetRequired")), this._addressCity?.isMounted && !this._addressCity.isValid && (e["address.city"] = this._addressCity.error ?? t("validation.cityRequired")), this._addressCountry?.isMounted && !this._addressCountry.isValid && (e["address.country"] = this._addressCountry.error ?? t("validation.countryRequired")), this._addressFirstName?.isMounted && !this._addressFirstName.isValid && (e["address.firstName"] = this._addressFirstName.error ?? t("validation.firstNameRequired")), this._addressLastName?.isMounted && !this._addressLastName.isValid && (e["address.lastName"] = this._addressLastName.error ?? t("validation.lastNameRequired")), this._cardholderName?.isMounted && !this._cardholderName.isValid && (e.cardholderName = this._cardholderName.error ?? t("validation.nameRequired")), this._addressState?.isMounted && !this._addressState.isValid && (e["address.state"] = this._addressState.error ?? t("validation.stateRequired")), this._addressZipCode?.isMounted && !this._addressZipCode.isValid && (e["address.zipCode"] = this._addressZipCode.error ?? t("validation.zipCodeRequired")), this._applePay?.isMounted && !this._applePay.isValid && (e.applePay = "Apple Pay authorization required"), this._paypal?.isMounted && !this._paypal.isValid && (e.paypal = "PayPal authorization required"), { valid: Object.keys(e).length === 0, errors: e };
1343
+ }
1344
+ _getPayload() {
1345
+ if (this._applePay?.isMounted && this._applePay.isValid || this._paypal?.isMounted)
1346
+ return null;
1347
+ const e = this._card?.isMounted ? this._card.value : null;
1348
+ if (!e) return null;
1349
+ const t = this._email?.isMounted ? this._email.value : "", r = this._phone?.isMounted ? this._phone.value : void 0, s = this._addressStreet?.isMounted || this._addressCity?.isMounted || this._addressCountry?.isMounted || this._addressFirstName?.isMounted || this._addressLastName?.isMounted || this._cardholderName?.isMounted || this._addressState?.isMounted || this._addressZipCode?.isMounted ? {
1350
+ street: this._addressStreet?.isMounted ? this._addressStreet.value : "",
1351
+ city: this._addressCity?.isMounted ? this._addressCity.value : "",
1352
+ country: this._addressCountry?.isMounted ? this._addressCountry.value : "",
1353
+ firstName: this._addressFirstName?.isMounted ? this._addressFirstName.value : "",
1354
+ lastName: this._addressLastName?.isMounted ? this._addressLastName.value : "",
1355
+ state: this._addressState?.isMounted ? this._addressState.value : "",
1356
+ zipCode: this._addressZipCode?.isMounted ? this._addressZipCode.value : ""
1357
+ } : void 0, i = this._cardholderName?.isMounted ? this._cardholderName.value : "", p = [
1358
+ s?.firstName ?? "",
1359
+ s?.lastName ?? ""
1360
+ ].filter(Boolean);
1361
+ return {
1362
+ name: i || p.join(" "),
1363
+ email: t,
1364
+ phoneNumber: r || void 0,
1365
+ cardNumber: e.number,
1366
+ cardExpiry: e.expiry,
1367
+ cardCvv: e.cvv,
1368
+ billingAddress: s
1369
+ };
1370
+ }
1371
+ async authorize(e) {
1372
+ if (!this._paymentState.paymentId || !this._paymentState.checkoutKey)
1373
+ throw new Error("Call associatePayment() before authorize()");
1374
+ if (this._applePay?.isMounted && this._applePay.isValid) {
1375
+ await this._executeAuthorization({
1376
+ formData: null,
1377
+ applePayData: this._applePay.value
1378
+ });
1379
+ return;
1380
+ }
1381
+ if (this._paypal?.isMounted) {
1382
+ await this._executeAuthorization({ formData: null });
1383
+ return;
1384
+ }
1385
+ const t = this._getPayload();
1386
+ await this._executeAuthorization({
1387
+ formData: t,
1388
+ applePayData: void 0,
1389
+ customCustomerData: e?.customerData
1390
+ });
1391
+ }
1392
+ applyTheme(e) {
1393
+ const t = e["--odus-font-family"];
1394
+ if (t) {
1395
+ this._fontCleanup?.();
1396
+ const { cleanup: r } = B({ fontFamily: t });
1397
+ this._fontCleanup = r;
1398
+ }
1399
+ for (const r of this._allElements())
1400
+ r.setTheme(e);
1401
+ }
1402
+ resetTheme(e) {
1403
+ "--odus-font-family" in e && (this._fontCleanup?.(), this._fontCleanup = void 0);
1404
+ for (const t of this._allElements())
1405
+ t.resetTheme(e);
1406
+ }
1407
+ get isValid() {
1408
+ return this.validate().valid;
1409
+ }
1410
+ onChange(e) {
1411
+ this._changeListeners.push(e);
1412
+ }
1413
+ destroy() {
1414
+ this._fontCleanup?.(), this._card?.destroy(), this._email?.destroy(), this._phone?.destroy(), this._addressStreet?.destroy(), this._addressFirstName?.destroy(), this._addressLastName?.destroy(), this._cardholderName?.destroy(), this._addressCity?.destroy(), this._addressState?.destroy(), this._addressZipCode?.destroy(), this._addressCountry?.destroy(), this._applePay?.destroy(), this._paypal?.destroy(), this._error?.destroy(), this._changeListeners.length = 0;
1415
+ }
1416
+ _trackElement(e) {
1417
+ e.on("change", () => {
1418
+ for (const t of this._changeListeners)
1419
+ t();
1420
+ });
1421
+ }
1422
+ _allElements() {
1423
+ return [
1424
+ this._card,
1425
+ this._email,
1426
+ this._phone,
1427
+ this._addressStreet,
1428
+ this._addressFirstName,
1429
+ this._addressLastName,
1430
+ this._cardholderName,
1431
+ this._addressCity,
1432
+ this._addressState,
1433
+ this._addressZipCode,
1434
+ this._addressCountry,
1435
+ this._applePay,
1436
+ this._paypal,
1437
+ this._error
1438
+ ].filter((e) => e !== void 0);
1439
+ }
1440
+ async _executeAuthorization({
1441
+ formData: e,
1442
+ applePayData: t,
1443
+ customCustomerData: r
1444
+ }) {
1445
+ try {
1446
+ const o = await this._apiService.authorizePayment({
1447
+ paymentId: this._paymentState.paymentId,
1448
+ checkoutKey: this._paymentState.checkoutKey,
1449
+ formData: e,
1450
+ returnUrl: this._config.returnUrl,
1451
+ applePayData: t,
1452
+ customCustomerData: r
1453
+ });
1454
+ this._handlePaymentResponse(o);
1455
+ } catch (o) {
1456
+ this._handleAuthorizationError(o);
1457
+ }
1458
+ }
1459
+ _handlePaymentResponse(e) {
1460
+ if (e.latestTransaction.status === "authorized") {
1461
+ this._config.callbacks?.onPaymentSucceeded?.(
1462
+ e.latestTransaction.status
1463
+ );
1464
+ return;
1465
+ }
1466
+ if (e.latestTransaction.status === "failed") {
1467
+ this._config.callbacks?.onPaymentFailed?.(
1468
+ e.latestTransaction.status
1469
+ );
1470
+ return;
1471
+ }
1472
+ e.status === "requires_action" && this._config.callbacks?.onActionRequired?.(e.action.redirectUrl);
1473
+ }
1474
+ _handleAuthorizationError(e) {
1475
+ const t = e.details?.message ?? "Payment failed";
1476
+ this._config.callbacks?.onPaymentFailed?.(t), this._error?.isMounted && this._error.setError(t);
1477
+ }
1478
+ }
1479
+ export {
1480
+ L as AddressCityElement,
1481
+ T as AddressCountryElement,
1482
+ j as AddressFirstNameElement,
1483
+ q as AddressLastNameElement,
1484
+ D as AddressStateElement,
1485
+ O as AddressStreetElement,
1486
+ Z as AddressZipCodeElement,
1487
+ Q as ApplePayElement,
1488
+ d as BaseElement,
1489
+ Y as CardElement,
1490
+ X as CardholderElement,
1491
+ ee as EmailElement,
1492
+ re as ErrorElement,
1493
+ ue as OdusElements,
1494
+ ie as PayPalElement,
1495
+ de as PhoneElement
1496
+ };