@amos.com/amos-js 0.10.4 → 0.10.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -83,108 +83,71 @@ function i(e) {
83
83
  }
84
84
  }
85
85
  //#endregion
86
- //#region src/types.ts
87
- function a(e) {
88
- return e;
86
+ //#region src/plaid-session.ts
87
+ var a = /* @__PURE__ */ new WeakMap();
88
+ function o(e, t) {
89
+ a.set(e, t);
90
+ }
91
+ function s(e) {
92
+ if (e) return a.get(e);
89
93
  }
90
- //#endregion
91
- //#region src/log.ts
92
- var o = /* @__PURE__ */ new Set([
93
- "authorization",
94
- "cookie",
95
- "set-cookie",
96
- "x-api-key"
97
- ]), s = /* @__PURE__ */ new Set([
98
- "authorization",
99
- "encrypted_account_number",
100
- "link_token",
101
- "public_token",
102
- "token"
103
- ]);
104
94
  function c(e) {
105
- let t = {};
106
- for (let [n, r] of Object.entries(e)) t[n] = o.has(n.toLowerCase()) ? "[REDACTED]" : r;
107
- return t;
95
+ e && a.delete(e);
108
96
  }
97
+ //#endregion
98
+ //#region src/types.ts
109
99
  function l(e) {
110
- if (Array.isArray(e)) return e.map(l);
111
- if (typeof e == "object" && e) {
112
- let t = {};
113
- for (let [n, r] of Object.entries(e)) t[n] = s.has(n) ? "[REDACTED]" : l(r);
114
- return t;
115
- }
116
100
  return e;
117
101
  }
118
- function u({ iframe: e, message: t, endpoint: n, headers: r = {}, body: i }) {
119
- e.contentWindow?.postMessage(a({
120
- type: "PARENT_INFO_LOG",
121
- message: t,
122
- endpoint: n,
123
- headers: c(r),
124
- body: l(i)
125
- }), new URL(e.src).origin);
126
- }
127
- //#endregion
128
- //#region src/plaid-session.ts
129
- var d = /* @__PURE__ */ new WeakMap();
130
- function f(e, t) {
131
- d.set(e, t);
132
- }
133
- function p(e) {
134
- if (e) return d.get(e);
135
- }
136
- function m(e) {
137
- e && d.delete(e);
138
- }
139
102
  //#endregion
140
103
  //#region src/messaging.ts
141
- function h(e) {
104
+ function u(e) {
142
105
  return new URL(e.src).origin;
143
106
  }
144
- function g(e) {
145
- e?.contentWindow && e.contentWindow.postMessage(a({ type: "PARENT_ACKNOWLEDGED_IFRAME_READY" }), h(e));
107
+ function d(e) {
108
+ e?.contentWindow && e.contentWindow.postMessage(l({ type: "PARENT_ACKNOWLEDGED_IFRAME_READY" }), u(e));
146
109
  }
147
- function _({ iframe: e, appearance: t = {} }) {
148
- e?.contentWindow && e.contentWindow.postMessage(a({
110
+ function f({ iframe: e, appearance: t = {} }) {
111
+ e?.contentWindow && e.contentWindow.postMessage(l({
149
112
  type: "UPDATE_APPEARANCE",
150
113
  appearance: t
151
- }), h(e));
114
+ }), u(e));
152
115
  }
153
- function v({ iframe: e, props: t, height: n }) {
154
- e?.contentWindow && e.contentWindow.postMessage(a({
116
+ function p({ iframe: e, props: t, height: n }) {
117
+ e?.contentWindow && e.contentWindow.postMessage(l({
155
118
  type: "UPDATE_APPLE_PAY_BUTTON",
156
119
  height: n,
157
120
  props: t
158
- }), h(e));
121
+ }), u(e));
159
122
  }
160
- function y({ iframe: e, props: t, height: n }) {
161
- e?.contentWindow && e.contentWindow.postMessage(a({
123
+ function m({ iframe: e, props: t, height: n }) {
124
+ e?.contentWindow && e.contentWindow.postMessage(l({
162
125
  type: "UPDATE_GOOGLE_PAY_BUTTON",
163
126
  height: n,
164
127
  props: t
165
- }), h(e));
128
+ }), u(e));
166
129
  }
167
- function b({ iframe: e, amount: t }) {
168
- e?.contentWindow && e.contentWindow.postMessage(a({
130
+ function h({ iframe: e, amount: t }) {
131
+ e?.contentWindow && e.contentWindow.postMessage(l({
169
132
  type: "UPDATE_AMOUNT",
170
133
  amount: t
171
- }), h(e));
134
+ }), u(e));
172
135
  }
173
- function x({ iframe: e, merchantName: t }) {
174
- e?.contentWindow && e.contentWindow.postMessage(a({
136
+ function g({ iframe: e, merchantName: t }) {
137
+ e?.contentWindow && e.contentWindow.postMessage(l({
175
138
  type: "UPDATE_MERCHANT_NAME",
176
139
  merchantName: t
177
- }), h(e));
140
+ }), u(e));
178
141
  }
179
- function S({ iframe: e }) {
180
- let t = p(e);
142
+ function _({ iframe: e }) {
143
+ let t = s(e);
181
144
  if (t?.requiresVerification) return Promise.resolve(!!t.plaid);
182
145
  let n = crypto.randomUUID();
183
146
  return new Promise((t) => {
184
- e?.contentWindow && e.contentWindow.postMessage(a({
147
+ e?.contentWindow && e.contentWindow.postMessage(l({
185
148
  type: "VALIDATE_FORM",
186
149
  requestId: n
187
- }), h(e));
150
+ }), u(e));
188
151
  let r = setTimeout(() => {
189
152
  window.removeEventListener("message", i), t(!1);
190
153
  }, 5e3);
@@ -194,7 +157,7 @@ function S({ iframe: e }) {
194
157
  window.addEventListener("message", i);
195
158
  });
196
159
  }
197
- var C = 1e4;
160
+ var v = 1e4;
198
161
  function ee({ iframe: e }) {
199
162
  let t = crypto.randomUUID();
200
163
  return new Promise((n, r) => {
@@ -203,129 +166,114 @@ function ee({ iframe: e }) {
203
166
  return;
204
167
  }
205
168
  let i = e.contentWindow;
206
- i.postMessage(a({
169
+ i.postMessage(l({
207
170
  type: "CREATE_PLAID_LINK_TOKEN",
208
171
  requestId: t
209
- }), h(e));
210
- let o = setTimeout(() => {
211
- window.removeEventListener("message", s), r(/* @__PURE__ */ Error("Timed out waiting for Plaid Link token."));
212
- }, C);
213
- function s(e) {
172
+ }), u(e));
173
+ let a = setTimeout(() => {
174
+ window.removeEventListener("message", o), r(/* @__PURE__ */ Error("Timed out waiting for Plaid Link token."));
175
+ }, v);
176
+ function o(e) {
214
177
  if (e.source === i && e.data.type === "PLAID_LINK_TOKEN" && e.data.requestId === t) {
215
- if (window.removeEventListener("message", s), clearTimeout(o), e.data.link_token) {
178
+ if (window.removeEventListener("message", o), clearTimeout(a), e.data.link_token) {
216
179
  n(e.data.link_token);
217
180
  return;
218
181
  }
219
182
  r(Error(e.data.error ?? "Could not create Plaid Link token."));
220
183
  }
221
184
  }
222
- window.addEventListener("message", s);
185
+ window.addEventListener("message", o);
223
186
  });
224
187
  }
225
- function w({ iframe: e }) {
226
- p(e)?.clearLinked?.(), T(e);
188
+ function y({ iframe: e }) {
189
+ s(e)?.clearLinked?.(), b(e);
227
190
  }
228
- function T(e) {
229
- e?.contentWindow && e.contentWindow.postMessage(a({ type: "RESET_FORM" }), h(e));
191
+ function b(e) {
192
+ e?.contentWindow && e.contentWindow.postMessage(l({ type: "RESET_FORM" }), u(e));
230
193
  }
231
- function E({ iframe: e, type: t, token: n, id: r }) {
232
- let i = p(e), o = i?.plaid;
233
- i?.requiresVerification && !o && T(e);
234
- let s = h(e);
235
- u({
236
- iframe: e,
237
- message: t === "CONFIRM_PAYMENT_INTENT" ? "confirmPaymentIntent" : "confirmSetupIntent",
238
- endpoint: t === "CONFIRM_PAYMENT_INTENT" ? "POST /embed/payment_intents/{id}/confirm_with_payment_method" : "POST /embed/setup_intents/{id}/confirm_with_payment_method",
239
- headers: {
240
- origin: window.location.origin,
241
- "iframe-origin": s
242
- },
243
- body: {
244
- id: r,
245
- token: n,
246
- ...o ? { plaid: o } : {}
247
- }
248
- }), e.contentWindow?.postMessage(a({
194
+ function x({ iframe: e, type: t, token: n, id: r }) {
195
+ let i = s(e), a = i?.plaid;
196
+ i?.requiresVerification && !a && b(e), e.contentWindow?.postMessage(l({
249
197
  type: t,
250
198
  token: n,
251
199
  id: r,
252
- ...o ? { plaid: o } : {}
253
- }), h(e));
200
+ ...a ? { plaid: a } : {}
201
+ }), u(e));
254
202
  }
255
- function D({ iframe: e, token: t }) {
203
+ function S({ iframe: e, token: t }) {
256
204
  if (!e?.contentWindow) return;
257
205
  let { payment_intent_id: n } = r(t).payload;
258
- E({
206
+ x({
259
207
  iframe: e,
260
208
  type: "CONFIRM_PAYMENT_INTENT",
261
209
  token: t,
262
210
  id: n ?? void 0
263
211
  });
264
212
  }
265
- function O({ iframe: e, token: t }) {
213
+ function C({ iframe: e, token: t }) {
266
214
  if (!e?.contentWindow) return;
267
215
  let { setup_intent_id: n } = r(t).payload;
268
- E({
216
+ x({
269
217
  iframe: e,
270
218
  type: "CONFIRM_SETUP_INTENT",
271
219
  token: t,
272
220
  id: n ?? void 0
273
221
  });
274
222
  }
275
- function k({ iframe: e, result: t }) {
276
- e?.contentWindow && e.contentWindow.postMessage(a({
223
+ function w({ iframe: e, result: t }) {
224
+ e?.contentWindow && e.contentWindow.postMessage(l({
277
225
  type: "CONFIRMATION_RESULT",
278
226
  result: t
279
- }), h(e));
227
+ }), u(e));
280
228
  }
281
229
  //#endregion
282
230
  //#region src/apple-pay.ts
283
- function A(e) {
231
+ function T(e) {
284
232
  return `${i(e)}/iframe/apple-pay?token=${e}`;
285
233
  }
286
- function j() {
234
+ function E() {
287
235
  return "48px";
288
236
  }
289
- function te(e) {
290
- e.contentWindow?.postMessage(a({ type: "APPLE_PAY_CANCEL" }), h(e));
237
+ function D(e) {
238
+ e.contentWindow?.postMessage(l({ type: "APPLE_PAY_CANCEL" }), u(e));
291
239
  }
292
- function ne(e, { height: r = "48px", ...i }) {
240
+ function O(e, { height: r = "48px", ...i }) {
293
241
  let a = {
294
242
  ...i,
295
243
  height: r
296
- };
297
- function o() {
298
- b({
244
+ }, o = !1;
245
+ function s() {
246
+ h({
299
247
  iframe: e,
300
248
  amount: a.amount
301
249
  });
302
250
  }
303
- function s() {
304
- x({
251
+ function c() {
252
+ g({
305
253
  iframe: e,
306
254
  merchantName: a.merchantName
307
255
  });
308
256
  }
309
- function c() {
310
- v({
257
+ function l() {
258
+ p({
311
259
  iframe: e,
312
260
  height: a.height ?? "48px",
313
261
  props: a.buttonProps ?? {}
314
262
  });
315
263
  }
316
- function l(r) {
264
+ function u(r) {
317
265
  if (r.source === e.contentWindow) switch (r.data.type) {
318
266
  case "IFRAME_READY":
319
- g(e), _({
267
+ o = !0, d(e), f({
320
268
  iframe: e,
321
269
  appearance: {}
322
- }), o(), s(), c();
270
+ }), s(), c(), l();
323
271
  break;
324
272
  case "UPDATE_HEIGHT":
325
273
  a.onHeightChange?.(r.data.height);
326
274
  break;
327
275
  case "UPDATE_APPEARANCE":
328
- _({
276
+ f({
329
277
  iframe: e,
330
278
  appearance: r.data.appearance
331
279
  });
@@ -335,7 +283,7 @@ function ne(e, { height: r = "48px", ...i }) {
335
283
  break;
336
284
  case "APPLE_PAY_WINDOW_OPEN":
337
285
  t({ onCancel: () => {
338
- te(e), n();
286
+ D(e), n();
339
287
  } });
340
288
  break;
341
289
  case "APPLE_PAY_WINDOW_CLOSE":
@@ -346,7 +294,7 @@ function ne(e, { height: r = "48px", ...i }) {
346
294
  paymentIntentCreateAttributes: r.data.paymentIntentCreateAttributes,
347
295
  customerCreateAttributes: r.data.customerCreateAttributes
348
296
  }).then((t) => {
349
- D({
297
+ S({
350
298
  iframe: e,
351
299
  token: t
352
300
  });
@@ -360,22 +308,22 @@ function ne(e, { height: r = "48px", ...i }) {
360
308
  case "CONFIRMATION_RESULT": n(), a.onResult(r.data.result);
361
309
  }
362
310
  }
363
- return window.addEventListener("message", l), {
311
+ return window.addEventListener("message", u), {
364
312
  update(e) {
365
313
  let t = "amount" in e, n = "merchantName" in e, r = "height" in e || "buttonProps" in e;
366
314
  a = {
367
315
  ...a,
368
316
  ...e
369
- }, t && o(), n && s(), r && c();
317
+ }, o && (t && s(), n && c(), r && l());
370
318
  },
371
319
  destroy() {
372
- window.removeEventListener("message", l), n();
320
+ window.removeEventListener("message", u), n();
373
321
  }
374
322
  };
375
323
  }
376
324
  //#endregion
377
325
  //#region src/form-skeleton.ts
378
- var M = "amos-js-form-skeleton-styles", re = {
326
+ var k = "amos-js-form-skeleton-styles", te = {
379
327
  "--accent": "oklch(0.97 0 0)",
380
328
  "--radius": "0.625rem",
381
329
  "--input-height": "2.25rem",
@@ -383,141 +331,141 @@ var M = "amos-js-form-skeleton-styles", re = {
383
331
  "--field-gap": "1rem",
384
332
  "--control-gap": "0.5rem",
385
333
  "--label-font-size": "0.875rem"
386
- }, N = "\n.amos-js-form-skeleton {\n box-sizing: border-box;\n container-type: inline-size;\n display: flex;\n flex-direction: column;\n gap: var(--field-gap);\n margin: 0 -4px;\n padding-block: 0.25rem;\n pointer-events: none;\n width: calc(100% + 8px);\n}\n.amos-js-form-skeleton-field {\n display: flex;\n flex: 1 1 0;\n flex-direction: column;\n min-width: 0;\n width: 100%;\n}\n.amos-js-form-skeleton-label {\n flex-shrink: 0;\n font-size: var(--label-font-size);\n height: 1.75rem;\n line-height: 1.75rem;\n}\n.amos-js-form-skeleton-input {\n animation: amos-js-skeleton-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n background: var(--accent);\n border-radius: calc(var(--radius) * 0.8);\n box-sizing: border-box;\n height: var(--input-height);\n width: 100%;\n}\n.amos-js-form-skeleton-input-floating {\n height: var(--floating-input-height);\n}\n.amos-js-form-skeleton-row {\n align-items: flex-start;\n display: flex;\n gap: var(--control-gap);\n width: 100%;\n}\n.amos-js-form-skeleton-row-stack {\n display: flex;\n flex-direction: column;\n gap: var(--field-gap);\n width: 100%;\n}\n@container (min-width: 24rem) {\n .amos-js-form-skeleton-row-stack {\n align-items: flex-start;\n flex-direction: row;\n gap: var(--control-gap);\n }\n}\n.amos-js-wallet-skeleton {\n flex: none;\n width: 100%;\n}\n@keyframes amos-js-skeleton-pulse {\n 50% { opacity: 0.5; }\n}\n@media (prefers-reduced-motion: reduce) {\n .amos-js-form-skeleton-input {\n animation: none;\n }\n}\n";
387
- function P() {
388
- if (document.getElementById(M)) return;
334
+ }, ne = "\n.amos-js-form-skeleton {\n box-sizing: border-box;\n container-type: inline-size;\n display: flex;\n flex-direction: column;\n gap: var(--field-gap);\n margin: 0 -4px;\n padding-block: 0.25rem;\n pointer-events: none;\n width: calc(100% + 8px);\n}\n.amos-js-form-skeleton-field {\n display: flex;\n flex: 1 1 0;\n flex-direction: column;\n min-width: 0;\n width: 100%;\n}\n.amos-js-form-skeleton-label {\n flex-shrink: 0;\n font-size: var(--label-font-size);\n height: 1.75rem;\n line-height: 1.75rem;\n}\n.amos-js-form-skeleton-input {\n animation: amos-js-skeleton-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n background: var(--accent);\n border-radius: calc(var(--radius) * 0.8);\n box-sizing: border-box;\n height: var(--input-height);\n width: 100%;\n}\n.amos-js-form-skeleton-input-floating {\n height: var(--floating-input-height);\n}\n.amos-js-form-skeleton-row {\n align-items: flex-start;\n display: flex;\n gap: var(--control-gap);\n width: 100%;\n}\n.amos-js-form-skeleton-row-stack {\n display: flex;\n flex-direction: column;\n gap: var(--field-gap);\n width: 100%;\n}\n@container (min-width: 24rem) {\n .amos-js-form-skeleton-row-stack {\n align-items: flex-start;\n flex-direction: row;\n gap: var(--control-gap);\n }\n}\n.amos-js-wallet-skeleton {\n flex: none;\n width: 100%;\n}\n@keyframes amos-js-skeleton-pulse {\n 50% { opacity: 0.5; }\n}\n@media (prefers-reduced-motion: reduce) {\n .amos-js-form-skeleton-input {\n animation: none;\n }\n}\n";
335
+ function A() {
336
+ if (document.getElementById(k)) return;
389
337
  let e = document.createElement("style");
390
- e.id = M, e.textContent = N, document.head.appendChild(e);
338
+ e.id = k, e.textContent = ne, document.head.appendChild(e);
391
339
  }
392
- function ie(e, t) {
393
- for (let [t, n] of Object.entries(re)) e.style.setProperty(t, n);
340
+ function j(e, t) {
341
+ for (let [t, n] of Object.entries(te)) e.style.setProperty(t, n);
394
342
  let n = t?.themeVariables;
395
343
  if (n) for (let [t, r] of Object.entries(n)) typeof r == "string" && r.trim() !== "" && e.style.setProperty(t, r.trim());
396
344
  }
397
- function F(e, t) {
345
+ function M(e, t) {
398
346
  let n = document.createElement("div");
399
347
  if (n.className = e, t) for (let e of t) n.appendChild(e);
400
348
  return n;
401
349
  }
402
- function I(e, t) {
403
- let n = F("amos-js-form-skeleton-field");
404
- t !== void 0 && (n.style.flexGrow = String(t)), e === "above" && n.appendChild(F("amos-js-form-skeleton-label"));
405
- let r = F("amos-js-form-skeleton-input");
350
+ function N(e, t) {
351
+ let n = M("amos-js-form-skeleton-field");
352
+ t !== void 0 && (n.style.flexGrow = String(t)), e === "above" && n.appendChild(M("amos-js-form-skeleton-label"));
353
+ let r = M("amos-js-form-skeleton-input");
406
354
  return e === "floating" && r.classList.add("amos-js-form-skeleton-input-floating"), n.appendChild(r), n;
407
355
  }
408
- function L(e, t) {
409
- return F(t ? "amos-js-form-skeleton-row-stack" : "amos-js-form-skeleton-row", e);
356
+ function P(e, t) {
357
+ return M(t ? "amos-js-form-skeleton-row-stack" : "amos-js-form-skeleton-row", e);
410
358
  }
411
- function R({ labels: e, requirement: t, wrapCountryZip: n }) {
359
+ function re({ labels: e, requirement: t, wrapCountryZip: n }) {
412
360
  return t === "full" ? [
413
- I(e),
414
- I(e),
415
- L([
416
- I(e, 1.4),
417
- I(e, .7),
418
- I(e, .8)
361
+ N(e),
362
+ N(e),
363
+ P([
364
+ N(e, 1.4),
365
+ N(e, .7),
366
+ N(e, .8)
419
367
  ], !1),
420
- I(e)
421
- ] : [L([I(e), I(e)], n)];
368
+ N(e)
369
+ ] : [P([N(e), N(e)], n)];
422
370
  }
423
- function ae(e) {
371
+ function ie(e) {
424
372
  let t = e.appearance?.labels ?? "above", n = e.billingAddressRequirement ?? "country";
425
373
  if (e.kind === "card") {
426
- let r = [I(t), L([I(t), I(t)], !1)];
427
- return e.additionalFields?.cardholderName && r.push(I(t)), r.push(...R({
374
+ let r = [N(t), P([N(t), N(t)], !1)];
375
+ return e.additionalFields?.cardholderName && r.push(N(t)), r.push(...re({
428
376
  labels: t,
429
377
  requirement: n,
430
378
  wrapCountryZip: !1
431
379
  })), r;
432
380
  }
433
381
  return [
434
- I(t),
435
- L([I(t), I(t)], !0),
436
- I(t),
437
- L([I("above"), I("above")], !0),
438
- ...R({
382
+ N(t),
383
+ P([N(t), N(t)], !0),
384
+ N(t),
385
+ P([N("above"), N("above")], !0),
386
+ ...re({
439
387
  labels: t,
440
388
  requirement: n,
441
389
  wrapCountryZip: !0
442
390
  })
443
391
  ];
444
392
  }
445
- function z(e) {
446
- P();
447
- let t = F("amos-js-form-skeleton");
393
+ function ae(e) {
394
+ A();
395
+ let t = M("amos-js-form-skeleton");
448
396
  t.setAttribute("aria-hidden", "true");
449
397
  function n(e) {
450
- ie(t, e.appearance), t.replaceChildren(...ae(e));
398
+ j(t, e.appearance), t.replaceChildren(...ie(e));
451
399
  }
452
400
  return n(e), {
453
401
  element: t,
454
402
  update: n
455
403
  };
456
404
  }
457
- function B(e) {
458
- P();
459
- let t = F("amos-js-form-skeleton-input amos-js-wallet-skeleton");
405
+ function F(e) {
406
+ A();
407
+ let t = M("amos-js-form-skeleton-input amos-js-wallet-skeleton");
460
408
  t.setAttribute("aria-hidden", "true");
461
409
  function n(e) {
462
- ie(t, void 0), t.style.height = e.height, t.style.borderRadius = e.borderRadius ?? "4px";
410
+ j(t, void 0), t.style.height = e.height, t.style.borderRadius = e.borderRadius ?? "4px";
463
411
  }
464
412
  return n(e), {
465
413
  element: t,
466
414
  update: n
467
415
  };
468
416
  }
469
- function V(e) {
417
+ function I(e) {
470
418
  if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
471
419
  if (typeof e == "string" && e.trim() !== "") return e.trim();
472
420
  }
473
- function H({ iframeStyle: e, buttonProps: t }) {
474
- return V(e?.borderRadius) ?? V(t?.buttonRadius) ?? V(t?.style?.borderRadius) ?? V(t?.style?.["--apple-pay-button-border-radius"]) ?? "4px";
421
+ function L({ iframeStyle: e, buttonProps: t }) {
422
+ return I(e?.borderRadius) ?? I(t?.buttonRadius) ?? I(t?.style?.borderRadius) ?? I(t?.style?.["--apple-pay-button-border-radius"]) ?? "4px";
475
423
  }
476
424
  //#endregion
477
425
  //#region src/google-pay.ts
478
- function U(e) {
426
+ function R(e) {
479
427
  return `${i(e)}/iframe/google-pay?token=${e}`;
480
428
  }
481
- function W() {
429
+ function z() {
482
430
  return "48px";
483
431
  }
484
- function G(e, { height: t = "48px", ...n }) {
432
+ function B(e, { height: t = "48px", ...n }) {
485
433
  let r = {
486
434
  ...n,
487
435
  height: t
488
- };
489
- function i() {
490
- b({
436
+ }, i = !1;
437
+ function a() {
438
+ h({
491
439
  iframe: e,
492
440
  amount: r.amount
493
441
  });
494
442
  }
495
- function a() {
496
- x({
443
+ function o() {
444
+ g({
497
445
  iframe: e,
498
446
  merchantName: r.merchantName
499
447
  });
500
448
  }
501
- function o() {
502
- y({
449
+ function s() {
450
+ m({
503
451
  iframe: e,
504
452
  height: r.height ?? "48px",
505
453
  props: r.buttonProps ?? {}
506
454
  });
507
455
  }
508
- function s(t) {
456
+ function c(t) {
509
457
  if (t.source === e.contentWindow) switch (t.data.type) {
510
458
  case "IFRAME_READY":
511
- g(e), _({
459
+ i = !0, d(e), f({
512
460
  iframe: e,
513
461
  appearance: {}
514
- }), i(), a(), o();
462
+ }), a(), o(), s();
515
463
  break;
516
464
  case "UPDATE_HEIGHT":
517
465
  r.onHeightChange?.(t.data.height);
518
466
  break;
519
467
  case "UPDATE_APPEARANCE":
520
- _({
468
+ f({
521
469
  iframe: e,
522
470
  appearance: t.data.appearance
523
471
  });
@@ -530,7 +478,7 @@ function G(e, { height: t = "48px", ...n }) {
530
478
  paymentIntentCreateAttributes: t.data.paymentIntentCreateAttributes,
531
479
  customerCreateAttributes: t.data.customerCreateAttributes
532
480
  }).then((t) => {
533
- D({
481
+ S({
534
482
  iframe: e,
535
483
  token: t
536
484
  });
@@ -544,16 +492,16 @@ function G(e, { height: t = "48px", ...n }) {
544
492
  case "CONFIRMATION_RESULT": r.onResult(t.data.result);
545
493
  }
546
494
  }
547
- return window.addEventListener("message", s), {
495
+ return window.addEventListener("message", c), {
548
496
  update(e) {
549
- let t = "amount" in e, n = "merchantName" in e, s = "height" in e || "buttonProps" in e;
497
+ let t = "amount" in e, n = "merchantName" in e, c = "height" in e || "buttonProps" in e;
550
498
  r = {
551
499
  ...r,
552
500
  ...e
553
- }, t && i(), n && a(), s && o();
501
+ }, i && (t && a(), n && o(), c && s());
554
502
  },
555
503
  destroy() {
556
- window.removeEventListener("message", s);
504
+ window.removeEventListener("message", c);
557
505
  }
558
506
  };
559
507
  }
@@ -576,14 +524,14 @@ function oe({ paymentData: e }) {
576
524
  }
577
525
  //#endregion
578
526
  //#region src/payment-method-form.ts
579
- var K = {
527
+ var V = {
580
528
  country: 212,
581
529
  full: 452
582
- }, se = 80, q = {
530
+ }, se = 80, H = {
583
531
  country: 400,
584
532
  full: 640
585
533
  };
586
- function J(e, t = { cardholderName: !1 }, n = "country") {
534
+ function U(e, t = { cardholderName: !1 }, n = "country") {
587
535
  let r = Object.entries(t).filter(([, e]) => e).map(([e]) => e).join(","), a = new URLSearchParams({
588
536
  token: e,
589
537
  additionalFields: r,
@@ -591,25 +539,25 @@ function J(e, t = { cardholderName: !1 }, n = "country") {
591
539
  });
592
540
  return `${i(e)}/iframe/card?${a}`;
593
541
  }
594
- function Y(e, t = "country", n = "payment") {
542
+ function W(e, t = "country", n = "payment") {
595
543
  let r = new URLSearchParams({
596
544
  token: e,
597
545
  billingAddressRequirement: t
598
546
  });
599
547
  return n === "setup" && r.set("intent", "setup"), `${i(e)}/iframe/bank?${r}`;
600
548
  }
601
- function X(e = { cardholderName: !1 }, t = "country") {
602
- return `${(K[t] ?? K.country) + (e.cardholderName ? se : 0)}px`;
549
+ function G(e = { cardholderName: !1 }, t = "country") {
550
+ return `${(V[t] ?? V.country) + (e.cardholderName ? se : 0)}px`;
603
551
  }
604
- function ce(e = "country") {
605
- return `${q[e] ?? q.country}px`;
552
+ function K(e = "country") {
553
+ return `${H[e] ?? H.country}px`;
606
554
  }
607
- function le(e, t) {
608
- let n = { ...t };
609
- function r(t) {
555
+ function q(e, t) {
556
+ let n = { ...t }, r = !1;
557
+ function i(t) {
610
558
  if (t.source === e.contentWindow) switch (t.data.type) {
611
559
  case "IFRAME_READY":
612
- g(e), _({
560
+ r = !0, d(e), f({
613
561
  iframe: e,
614
562
  appearance: n.appearance
615
563
  });
@@ -618,7 +566,7 @@ function le(e, t) {
618
566
  n.onHeightChange?.(t.data.height);
619
567
  break;
620
568
  case "UPDATE_APPEARANCE":
621
- _({
569
+ f({
622
570
  iframe: e,
623
571
  appearance: t.data.appearance
624
572
  });
@@ -627,7 +575,7 @@ function le(e, t) {
627
575
  n.onAppearanceReady?.();
628
576
  break;
629
577
  case "FORM_VALIDITY_CHANGE":
630
- if (p(e)?.requiresVerification) break;
578
+ if (s(e)?.requiresVerification) break;
631
579
  n.onValidityChange?.({ isValid: t.data.isValid });
632
580
  break;
633
581
  case "CARD_BRAND_CHANGE":
@@ -636,55 +584,55 @@ function le(e, t) {
636
584
  case "CONFIRMATION_RESULT": n.onResult(t.data.result);
637
585
  }
638
586
  }
639
- return window.addEventListener("message", r), {
587
+ return window.addEventListener("message", i), {
640
588
  update(t) {
641
- let r = "appearance" in t;
589
+ let i = "appearance" in t;
642
590
  n = {
643
591
  ...n,
644
592
  ...t
645
- }, r && _({
593
+ }, i && r && f({
646
594
  iframe: e,
647
595
  appearance: n.appearance
648
596
  });
649
597
  },
650
598
  destroy() {
651
- window.removeEventListener("message", r);
599
+ window.removeEventListener("message", i);
652
600
  }
653
601
  };
654
602
  }
655
603
  //#endregion
656
604
  //#region src/plaid.ts
657
- var ue = "https://cdn.plaid.com/link/v2/stable/link-initialize.js";
658
- function de({ amount: e, achThreshold: t }) {
605
+ var J = "https://cdn.plaid.com/link/v2/stable/link-initialize.js";
606
+ function Y({ amount: e, achThreshold: t }) {
659
607
  return t != null && (e ?? 0) >= t;
660
608
  }
661
- function fe(e) {
609
+ function ce(e) {
662
610
  if (e == null) return;
663
611
  let t = e.trim();
664
612
  if (t === "") return;
665
613
  let n = Number(t.replace(/[^\d.]/g, ""));
666
614
  if (Number.isFinite(n)) return Math.round(n * 100);
667
615
  }
668
- function pe(e) {
616
+ function le(e) {
669
617
  return e.account_id ?? e.account?.id ?? e.accounts?.[0]?.id;
670
618
  }
671
- function me(e) {
619
+ function ue(e) {
672
620
  let t = e.account ?? e.accounts?.[0];
673
621
  return {
674
622
  bankName: e.institution?.name ?? "Bank account",
675
623
  last4: t?.mask ?? ""
676
624
  };
677
625
  }
678
- var Z;
679
- function he() {
680
- for (let e of document.querySelectorAll(`script[src="${ue}"]`)) e.remove();
626
+ var X;
627
+ function de() {
628
+ for (let e of document.querySelectorAll(`script[src="${J}"]`)) e.remove();
681
629
  }
682
- function ge() {
683
- return typeof window > "u" ? Promise.reject(/* @__PURE__ */ Error("Plaid Link requires a browser")) : window.Plaid ? Promise.resolve() : Z || (he(), Z = new Promise((e, t) => {
630
+ function fe() {
631
+ return typeof window > "u" ? Promise.reject(/* @__PURE__ */ Error("Plaid Link requires a browser")) : window.Plaid ? Promise.resolve() : X || (de(), X = new Promise((e, t) => {
684
632
  let n = document.createElement("script");
685
- n.src = ue, n.async = !0;
633
+ n.src = J, n.async = !0;
686
634
  let r = (e) => {
687
- n.remove(), Z = void 0, t(Error(e));
635
+ n.remove(), X = void 0, t(Error(e));
688
636
  };
689
637
  n.addEventListener("load", () => {
690
638
  if (window.Plaid) {
@@ -693,10 +641,10 @@ function ge() {
693
641
  }
694
642
  r("Plaid Link failed to initialize");
695
643
  }, { once: !0 }), n.addEventListener("error", () => r("Failed to load Plaid Link"), { once: !0 }), document.head.append(n);
696
- }), Z);
644
+ }), X);
697
645
  }
698
- async function _e({ token: e, onSuccess: t, onExit: n, signal: r }) {
699
- if (await ge(), r?.aborted) return () => {};
646
+ async function pe({ token: e, onSuccess: t, onExit: n, signal: r }) {
647
+ if (await fe(), r?.aborted) return () => {};
700
648
  if (!window.Plaid) throw Error("Plaid Link failed to initialize");
701
649
  let i = window.Plaid.create({
702
650
  token: e,
@@ -711,141 +659,132 @@ async function _e({ token: e, onSuccess: t, onExit: n, signal: r }) {
711
659
  }
712
660
  //#endregion
713
661
  //#region src/plaid-bank-ui.ts
714
- var ve = "amos-js-plaid-bank-ui-styles", ye = "\n.amos-js-plaid-panel {\n box-sizing: border-box;\n color: var(--foreground, oklch(0.145 0 0));\n display: none;\n flex-direction: column;\n font-family: inherit;\n gap: var(--control-gap, 0.5rem);\n width: 100%;\n}\n.amos-js-plaid-panel[data-mode=\"connect\"],\n.amos-js-plaid-panel[data-mode=\"linked\"] {\n display: flex;\n}\n.amos-js-plaid-connect {\n align-items: center;\n background: var(--background, oklch(1 0 0));\n border: var(--input-border-width, 1px) solid var(--border, oklch(0.922 0 0));\n border-radius: calc(var(--radius, 0.625rem) * 0.8);\n box-shadow: var(--input-shadow, 0 1px 2px 0 rgb(0 0 0 / 0.05));\n box-sizing: border-box;\n color: var(--foreground, oklch(0.145 0 0));\n cursor: pointer;\n display: inline-flex;\n flex-shrink: 0;\n font: inherit;\n font-size: var(--input-font-size, 0.875rem);\n font-weight: 500;\n height: var(--input-height, 2.25rem);\n justify-content: center;\n line-height: 1.25;\n outline: none;\n padding: 0 var(--input-padding, 0.75rem);\n transition: color 150ms, background-color 150ms, border-color 150ms, box-shadow 150ms;\n width: 100%;\n}\n.amos-js-plaid-panel[data-mode=\"linked\"] .amos-js-plaid-connect {\n display: none;\n}\n.amos-js-plaid-connect:hover:not(:disabled) {\n background: var(--accent, oklch(0.97 0 0));\n color: var(--accent-foreground, oklch(0.205 0 0));\n}\n.amos-js-plaid-connect:focus-visible {\n border-color: var(--ring, oklch(0.708 0 0));\n box-shadow:\n var(--input-shadow, 0 1px 2px 0 rgb(0 0 0 / 0.05)),\n 0 0 0 var(--ring-width, 3px)\n color-mix(in oklab, var(--ring, oklch(0.708 0 0)) 50%, transparent);\n}\n.amos-js-plaid-connect:disabled {\n cursor: default;\n opacity: 0.5;\n pointer-events: none;\n}\n.amos-js-plaid-linked {\n display: none;\n flex-direction: column;\n gap: 0.25rem;\n}\n.amos-js-plaid-panel[data-mode=\"linked\"] .amos-js-plaid-linked {\n display: flex;\n}\n.amos-js-plaid-linked-name {\n font-size: var(--input-font-size, 0.875rem);\n font-weight: 500;\n}\n.amos-js-plaid-linked-meta {\n color: var(--muted-foreground, oklch(0.556 0 0));\n font-size: 0.75rem;\n}\n.amos-js-plaid-disconnect {\n align-self: flex-start;\n background: none;\n border: none;\n border-radius: calc(var(--radius, 0.625rem) * 0.8);\n color: var(--muted-foreground, oklch(0.556 0 0));\n cursor: pointer;\n font: inherit;\n font-size: var(--input-font-size, 0.875rem);\n margin-top: 0.25rem;\n outline: none;\n padding: 0;\n}\n.amos-js-plaid-disconnect:hover {\n color: var(--accent-foreground, oklch(0.205 0 0));\n}\n.amos-js-plaid-disconnect:focus-visible {\n box-shadow:\n 0 0 0 var(--ring-width, 3px)\n color-mix(in oklab, var(--ring, oklch(0.708 0 0)) 50%, transparent);\n}\n.amos-js-plaid-error {\n color: var(--destructive, oklch(0.577 0.245 27.325));\n display: none;\n font-size: var(--error-font-size, 0.875rem);\n margin: 0;\n}\n.amos-js-plaid-error:not(:empty) {\n display: block;\n}\n@media (prefers-reduced-motion: reduce) {\n .amos-js-plaid-connect {\n transition: none;\n }\n}\n";
715
- function be() {
716
- if (document.getElementById(ve)) return;
662
+ var me = "amos-js-plaid-bank-ui-styles", he = "\n.amos-js-plaid-panel {\n box-sizing: border-box;\n color: var(--foreground, oklch(0.145 0 0));\n display: none;\n flex-direction: column;\n font-family: inherit;\n gap: var(--control-gap, 0.5rem);\n width: 100%;\n}\n.amos-js-plaid-panel[data-mode=\"connect\"],\n.amos-js-plaid-panel[data-mode=\"linked\"] {\n display: flex;\n}\n.amos-js-plaid-connect {\n align-items: center;\n background: var(--background, oklch(1 0 0));\n border: var(--input-border-width, 1px) solid var(--border, oklch(0.922 0 0));\n border-radius: calc(var(--radius, 0.625rem) * 0.8);\n box-shadow: var(--input-shadow, 0 1px 2px 0 rgb(0 0 0 / 0.05));\n box-sizing: border-box;\n color: var(--foreground, oklch(0.145 0 0));\n cursor: pointer;\n display: inline-flex;\n flex-shrink: 0;\n font: inherit;\n font-size: var(--input-font-size, 0.875rem);\n font-weight: 500;\n height: var(--input-height, 2.25rem);\n justify-content: center;\n line-height: 1.25;\n outline: none;\n padding: 0 var(--input-padding, 0.75rem);\n transition: color 150ms, background-color 150ms, border-color 150ms, box-shadow 150ms;\n width: 100%;\n}\n.amos-js-plaid-panel[data-mode=\"linked\"] .amos-js-plaid-connect {\n display: none;\n}\n.amos-js-plaid-connect:hover:not(:disabled) {\n background: var(--accent, oklch(0.97 0 0));\n color: var(--accent-foreground, oklch(0.205 0 0));\n}\n.amos-js-plaid-connect:focus-visible {\n border-color: var(--ring, oklch(0.708 0 0));\n box-shadow:\n var(--input-shadow, 0 1px 2px 0 rgb(0 0 0 / 0.05)),\n 0 0 0 var(--ring-width, 3px)\n color-mix(in oklab, var(--ring, oklch(0.708 0 0)) 50%, transparent);\n}\n.amos-js-plaid-connect:disabled {\n cursor: default;\n opacity: 0.5;\n pointer-events: none;\n}\n.amos-js-plaid-linked {\n display: none;\n flex-direction: column;\n gap: 0.25rem;\n}\n.amos-js-plaid-panel[data-mode=\"linked\"] .amos-js-plaid-linked {\n display: flex;\n}\n.amos-js-plaid-linked-name {\n font-size: var(--input-font-size, 0.875rem);\n font-weight: 500;\n}\n.amos-js-plaid-linked-meta {\n color: var(--muted-foreground, oklch(0.556 0 0));\n font-size: 0.75rem;\n}\n.amos-js-plaid-disconnect {\n align-self: flex-start;\n background: none;\n border: none;\n border-radius: calc(var(--radius, 0.625rem) * 0.8);\n color: var(--muted-foreground, oklch(0.556 0 0));\n cursor: pointer;\n font: inherit;\n font-size: var(--input-font-size, 0.875rem);\n margin-top: 0.25rem;\n outline: none;\n padding: 0;\n}\n.amos-js-plaid-disconnect:hover {\n color: var(--accent-foreground, oklch(0.205 0 0));\n}\n.amos-js-plaid-disconnect:focus-visible {\n box-shadow:\n 0 0 0 var(--ring-width, 3px)\n color-mix(in oklab, var(--ring, oklch(0.708 0 0)) 50%, transparent);\n}\n.amos-js-plaid-error {\n color: var(--destructive, oklch(0.577 0.245 27.325));\n display: none;\n font-size: var(--error-font-size, 0.875rem);\n margin: 0;\n}\n.amos-js-plaid-error:not(:empty) {\n display: block;\n}\n@media (prefers-reduced-motion: reduce) {\n .amos-js-plaid-connect {\n transition: none;\n }\n}\n";
663
+ function ge() {
664
+ if (document.getElementById(me)) return;
717
665
  let e = document.createElement("style");
718
- e.id = ve, e.textContent = ye, document.head.append(e);
666
+ e.id = me, e.textContent = he, document.head.append(e);
719
667
  }
720
- function xe(e, t, n) {
668
+ function _e(e, t, n) {
721
669
  for (let t of n) e.style.removeProperty(t);
722
670
  n.length = 0;
723
671
  let r = t?.themeVariables;
724
672
  if (r) for (let [t, i] of Object.entries(r)) typeof i == "string" && i.trim() !== "" && (e.style.setProperty(t, i.trim()), n.push(t));
725
673
  }
726
- function Se({ host: e, iframe: t, options: n }) {
727
- be();
674
+ function ve({ host: e, iframe: t, options: n }) {
675
+ ge();
728
676
  let r = {
729
677
  ...n,
730
678
  amount: n.amount ?? "0"
731
- }, i = [], a = !1, o, s = !1, c, l = !1, d, p, h = new AbortController(), g, _ = document.createElement("div");
732
- _.className = "amos-js-plaid-panel", _.setAttribute("data-amos-plaid-panel", "true"), _.dataset.mode = "hidden", xe(_, r.appearance, i);
733
- let v = document.createElement("button");
734
- v.type = "button", v.className = "amos-js-plaid-connect", v.textContent = "Connect bank account", v.setAttribute("data-testid", "amos-plaid-connect");
735
- let y = document.createElement("div");
736
- y.className = "amos-js-plaid-linked";
679
+ }, i = [], a = !1, s, l = !1, u, d = !1, f, p, m = new AbortController(), h, g = document.createElement("div");
680
+ g.className = "amos-js-plaid-panel", g.setAttribute("data-amos-plaid-panel", "true"), g.dataset.mode = "hidden", _e(g, r.appearance, i);
681
+ let _ = document.createElement("button");
682
+ _.type = "button", _.className = "amos-js-plaid-connect", _.textContent = "Connect bank account", _.setAttribute("data-testid", "amos-plaid-connect");
683
+ let v = document.createElement("div");
684
+ v.className = "amos-js-plaid-linked";
685
+ let y = document.createElement("span");
686
+ y.className = "amos-js-plaid-linked-name";
737
687
  let b = document.createElement("span");
738
- b.className = "amos-js-plaid-linked-name";
739
- let x = document.createElement("span");
740
- x.className = "amos-js-plaid-linked-meta";
741
- let S = document.createElement("button");
742
- S.type = "button", S.className = "amos-js-plaid-disconnect", S.textContent = "Disconnect", S.setAttribute("aria-label", "Disconnect bank account");
743
- let C = document.createElement("p");
744
- C.className = "amos-js-plaid-error", C.setAttribute("role", "alert"), y.append(b, x, S), _.append(v, y, C), e.append(_);
745
- let w = t.parentElement;
746
- function T(e) {
747
- C.textContent = e ?? "";
688
+ b.className = "amos-js-plaid-linked-meta";
689
+ let x = document.createElement("button");
690
+ x.type = "button", x.className = "amos-js-plaid-disconnect", x.textContent = "Disconnect", x.setAttribute("aria-label", "Disconnect bank account");
691
+ let S = document.createElement("p");
692
+ S.className = "amos-js-plaid-error", S.setAttribute("role", "alert"), v.append(y, b, x), g.append(_, v, S), e.append(g);
693
+ let C = t.parentElement;
694
+ function w(e) {
695
+ S.textContent = e ?? "";
748
696
  }
749
- function E() {
750
- return a ? s ? !0 : de({
751
- amount: fe(r.amount),
752
- achThreshold: o
697
+ function T() {
698
+ return a ? l ? !0 : Y({
699
+ amount: ce(r.amount),
700
+ achThreshold: s
753
701
  }) : !1;
754
702
  }
755
- function D() {
756
- let e = !!g;
757
- d !== e && (d = e, r.onValidityChange?.({ isValid: e }));
703
+ function E() {
704
+ let e = !!h;
705
+ f !== e && (f = e, r.onValidityChange?.({ isValid: e }));
758
706
  }
759
- function O() {
760
- let e = E();
761
- if (f(t, {
707
+ function D() {
708
+ let e = T();
709
+ if (o(t, {
762
710
  requiresVerification: e,
763
- plaid: e ? g?.credentials : void 0,
764
- clearLinked: k
711
+ plaid: e ? h?.credentials : void 0,
712
+ clearLinked: O
765
713
  }), !e) {
766
- _.dataset.mode = "hidden", w && (w.style.display = ""), d = void 0;
714
+ g.dataset.mode = "hidden", C && (C.style.display = ""), f = void 0;
767
715
  return;
768
716
  }
769
- _.dataset.mode = g ? "linked" : "connect", w && (w.style.display = "none"), g && (b.textContent = g.bankName, x.textContent = g.last4 ? `****${g.last4}` : "Connected"), D();
717
+ g.dataset.mode = h ? "linked" : "connect", C && (C.style.display = "none"), h && (y.textContent = h.bankName, b.textContent = h.last4 ? `****${h.last4}` : "Connected"), E();
770
718
  }
771
- function k() {
772
- g = void 0, c = void 0, p?.(), p = void 0, T(void 0), O();
719
+ function O() {
720
+ h = void 0, u = void 0, p?.(), p = void 0, w(void 0), D();
773
721
  }
774
- function A(e) {
722
+ function k(e) {
775
723
  if (e.source === t.contentWindow && e.data.type === "ACH_THRESHOLD") {
776
- if (a = !0, o = e.data.achThreshold ?? void 0, s = e.data.requireVerification === !0, u({
777
- iframe: t,
778
- message: "merchant ach_threshold",
779
- endpoint: "ACH_THRESHOLD",
780
- headers: { origin: e.origin },
781
- body: {
782
- achThreshold: o,
783
- requireVerification: s
784
- }
785
- }), g && !E()) {
786
- k();
724
+ if (a = !0, s = e.data.achThreshold ?? void 0, l = e.data.requireVerification === !0, h && !T()) {
725
+ O();
787
726
  return;
788
727
  }
789
- O();
728
+ D();
790
729
  }
791
730
  }
792
- return window.addEventListener("message", A), O(), S.addEventListener("click", () => {
793
- k();
794
- }), v.addEventListener("click", () => {
731
+ return window.addEventListener("message", k), D(), x.addEventListener("click", () => {
732
+ O();
733
+ }), _.addEventListener("click", () => {
795
734
  (async () => {
796
- if (!(h.signal.aborted || l)) {
797
- l = !0, v.disabled = !0, T(void 0);
735
+ if (!(m.signal.aborted || d)) {
736
+ d = !0, _.disabled = !0, w(void 0);
798
737
  try {
799
- if (c ||= await ee({ iframe: t }), h.signal.aborted) return;
800
- let e = c;
801
- p?.(), p = await _e({
738
+ if (u ||= await ee({ iframe: t }), m.signal.aborted) return;
739
+ let e = u;
740
+ p?.(), p = await pe({
802
741
  token: e,
803
- signal: h.signal,
742
+ signal: m.signal,
804
743
  onSuccess: (e, t) => {
805
- if (h.signal.aborted) return;
806
- let n = pe(t);
744
+ if (m.signal.aborted) return;
745
+ let n = le(t);
807
746
  if (!n) {
808
- T("Select a bank account to continue.");
747
+ w("Select a bank account to continue.");
809
748
  return;
810
749
  }
811
- let r = me(t);
812
- g = {
750
+ let r = ue(t);
751
+ h = {
813
752
  credentials: {
814
753
  public_token: e,
815
754
  account_id: n
816
755
  },
817
756
  bankName: r.bankName,
818
757
  last4: r.last4
819
- }, c = void 0, O();
758
+ }, u = void 0, D();
820
759
  },
821
760
  onExit: (e) => {
822
- h.signal.aborted || e?.error_code === "INVALID_LINK_TOKEN" && (c = void 0);
761
+ m.signal.aborted || e?.error_code === "INVALID_LINK_TOKEN" && (u = void 0);
823
762
  }
824
- }), h.signal.aborted && (p(), p = void 0);
763
+ }), m.signal.aborted && (p(), p = void 0);
825
764
  } catch (e) {
826
- if (c = void 0, h.signal.aborted) return;
827
- T(e instanceof Error ? e.message : "Could not connect bank.");
765
+ if (u = void 0, m.signal.aborted) return;
766
+ w(e instanceof Error ? e.message : "Could not connect bank.");
828
767
  } finally {
829
- l = !1, h.signal.aborted || (v.disabled = !1);
768
+ d = !1, m.signal.aborted || (_.disabled = !1);
830
769
  }
831
770
  }
832
771
  })();
833
772
  }), {
834
773
  update(e) {
835
- if ("amount" in e && (r.amount = e.amount ?? "0"), "onValidityChange" in e && (r.onValidityChange = e.onValidityChange), "appearance" in e && (r.appearance = e.appearance, xe(_, r.appearance, i)), g && !E()) {
836
- k();
774
+ if ("amount" in e && (r.amount = e.amount ?? "0"), "onValidityChange" in e && (r.onValidityChange = e.onValidityChange), "appearance" in e && (r.appearance = e.appearance, _e(g, r.appearance, i)), h && !T()) {
775
+ O();
837
776
  return;
838
777
  }
839
- O();
778
+ D();
840
779
  },
841
780
  destroy() {
842
- h.abort(), window.removeEventListener("message", A), p?.(), p = void 0, m(t), _.remove();
781
+ m.abort(), window.removeEventListener("message", k), p?.(), p = void 0, c(t), g.remove();
843
782
  }
844
783
  };
845
784
  }
846
785
  //#endregion
847
786
  //#region src/mount.ts
848
- function Q(e) {
787
+ function Z(e) {
849
788
  if (typeof e == "string") {
850
789
  let t = document.querySelector(e);
851
790
  if (!(t instanceof HTMLElement)) throw Error(`[amos-js] Container "${e}" did not match any HTMLElement.`);
@@ -853,19 +792,19 @@ function Q(e) {
853
792
  }
854
793
  return e;
855
794
  }
856
- var Ce = {
795
+ var ye = {
857
796
  width: "calc(100% + 8px)",
858
797
  transition: "opacity 150ms ease-in, height 200ms ease-in-out",
859
798
  margin: "0 -4px",
860
799
  opacity: "0",
861
800
  border: "0"
862
- }, we = {
801
+ }, be = {
863
802
  width: "100%",
864
803
  transition: "height 200ms ease-in-out",
865
804
  margin: "0",
866
805
  opacity: "0",
867
806
  border: "0"
868
- }, Te = {
807
+ }, xe = {
869
808
  position: "absolute",
870
809
  top: "0",
871
810
  left: "0",
@@ -875,7 +814,7 @@ var Ce = {
875
814
  opacity: "0",
876
815
  transition: "none",
877
816
  pointerEvents: "none"
878
- }, Ee = {
817
+ }, Se = {
879
818
  position: "absolute",
880
819
  top: "0",
881
820
  left: "-4px",
@@ -885,15 +824,15 @@ var Ce = {
885
824
  transition: "none",
886
825
  pointerEvents: "none"
887
826
  };
888
- function $({ src: e, title: t, name: n, height: r, allow: i, className: a, style: o = Ce }) {
827
+ function Q({ src: e, title: t, name: n, height: r, allow: i, className: a, style: o = ye }) {
889
828
  let s = document.createElement("iframe");
890
829
  return s.src = e, s.title = t, s.name = n, s.setAttribute("role", "presentation"), s.scrolling = "no", i && (s.allow = i), a != null && (s.className = a), Object.assign(s.style, o, { height: r }), s;
891
830
  }
892
- function De({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
831
+ function Ce({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
893
832
  let i = document.createElement("div");
894
833
  i.style.position = "relative", i.style.width = "100%", i.setAttribute("aria-busy", "true");
895
- let a = z(r);
896
- Object.assign(t.style, Ee), i.append(a.element, t), e.appendChild(i);
834
+ let a = ae(r);
835
+ Object.assign(t.style, Se), i.append(a.element, t), e.appendChild(i);
897
836
  let o = !1, s = !1, c, l = r.appearance, u, d;
898
837
  function f() {
899
838
  return i.getBoundingClientRect().height;
@@ -905,7 +844,7 @@ function De({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
905
844
  if (o) return;
906
845
  o = !0, d !== void 0 && (clearTimeout(d), d = void 0);
907
846
  let e = f(), n = p(), r = Number.isFinite(n) ? Math.max(n, e) : e;
908
- t.style.transition = "none", t.style.position = "", t.style.top = "", t.style.left = "", t.style.margin = Ce.margin ?? "", t.style.height = `${r}px`, t.style.opacity = "1", t.style.pointerEvents = "", a.element.remove(), i.removeAttribute("aria-busy"), u = setTimeout(() => {
847
+ t.style.transition = "none", t.style.position = "", t.style.top = "", t.style.left = "", t.style.margin = ye.margin ?? "", t.style.height = `${r}px`, t.style.opacity = "1", t.style.pointerEvents = "", a.element.remove(), i.removeAttribute("aria-busy"), u = setTimeout(() => {
909
848
  t.style.transition = "height 200ms ease-in-out";
910
849
  }, 400);
911
850
  }
@@ -914,7 +853,7 @@ function De({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
914
853
  let e = p(), t = f();
915
854
  Number.isFinite(e) && e >= t - 2 && m();
916
855
  }
917
- let g = le(t, {
856
+ let g = q(t, {
918
857
  ...n,
919
858
  onHeightChange: (e) => {
920
859
  c = e, o ? t.style.height = e : h(), n.onHeightChange?.(e);
@@ -938,15 +877,15 @@ function De({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
938
877
  }
939
878
  };
940
879
  }
941
- function Oe({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachListeners: i }) {
880
+ function $({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachListeners: i }) {
942
881
  let a = {
943
882
  height: n.height ?? "48px",
944
- borderRadius: H({
883
+ borderRadius: L({
945
884
  iframeStyle: r,
946
885
  buttonProps: n.buttonProps
947
886
  })
948
- }, o = B(a), s = document.createElement("div");
949
- s.style.position = "relative", s.style.width = "100%", s.style.height = a.height, s.style.overflow = "hidden", s.setAttribute("aria-busy", "true"), Object.assign(t.style, Te), t.style.height = "100%", s.append(o.element, t), e.appendChild(s);
887
+ }, o = F(a), s = document.createElement("div");
888
+ s.style.position = "relative", s.style.width = "100%", s.style.height = a.height, s.style.overflow = "hidden", s.setAttribute("aria-busy", "true"), Object.assign(t.style, xe), t.style.height = "100%", s.append(o.element, t), e.appendChild(s);
950
889
  let c = !1, l = !1, u, d = n;
951
890
  function f() {
952
891
  c || (c = !0, u !== void 0 && (clearTimeout(u), u = void 0), t.style.opacity = "1", t.style.pointerEvents = "", o.element.remove(), s.removeAttribute("aria-busy"));
@@ -975,7 +914,7 @@ function Oe({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachList
975
914
  let t = { ...e };
976
915
  delete t.onAppearanceReady, delete t.onHeightChange, m.update(t), a = {
977
916
  height: d.height ?? a.height,
978
- borderRadius: H({
917
+ borderRadius: L({
979
918
  iframeStyle: r,
980
919
  buttonProps: d.buttonProps
981
920
  })
@@ -986,15 +925,15 @@ function Oe({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachList
986
925
  }
987
926
  };
988
927
  }
989
- function ke(e, t) {
990
- let n = Q(e), { renderToken: r, additionalFields: i = { cardholderName: !1 }, billingAddressRequirement: a = "country", ...o } = t;
991
- return De({
928
+ function we(e, t) {
929
+ let n = Z(e), { renderToken: r, additionalFields: i = { cardholderName: !1 }, billingAddressRequirement: a = "country", ...o } = t;
930
+ return Ce({
992
931
  host: n,
993
- iframe: $({
994
- src: J(r, i, a),
932
+ iframe: Q({
933
+ src: U(r, i, a),
995
934
  title: "Secure credit card payment method form powered by Amos",
996
935
  name: "amos-credit-card-payment-method-form",
997
- height: X(i, a)
936
+ height: G(i, a)
998
937
  }),
999
938
  listenerOptions: o,
1000
939
  skeletonOptions: {
@@ -1005,13 +944,13 @@ function ke(e, t) {
1005
944
  }
1006
945
  });
1007
946
  }
1008
- function Ae(e, t) {
1009
- let n = Q(e), { renderToken: r, billingAddressRequirement: i = "country", amount: a = "0", intent: o = "payment", ...s } = t, c = $({
1010
- src: Y(r, i, o),
947
+ function Te(e, t) {
948
+ let n = Z(e), { renderToken: r, billingAddressRequirement: i = "country", amount: a = "0", intent: o = "payment", ...s } = t, c = Q({
949
+ src: W(r, i, o),
1011
950
  title: "Secure bank account payment method form powered by Amos",
1012
951
  name: "amos-bank-account-payment-method-form",
1013
- height: ce(i)
1014
- }), l = De({
952
+ height: K(i)
953
+ }), l = Ce({
1015
954
  host: n,
1016
955
  iframe: c,
1017
956
  listenerOptions: s,
@@ -1020,7 +959,7 @@ function Ae(e, t) {
1020
959
  appearance: s.appearance,
1021
960
  billingAddressRequirement: i
1022
961
  }
1023
- }), u = Se({
962
+ }), u = ve({
1024
963
  host: n,
1025
964
  iframe: c,
1026
965
  options: {
@@ -1039,41 +978,41 @@ function Ae(e, t) {
1039
978
  }
1040
979
  };
1041
980
  }
1042
- function je(e, t) {
1043
- let n = Q(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = $({
1044
- src: U(r),
981
+ function Ee(e, t) {
982
+ let n = Z(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = Q({
983
+ src: R(r),
1045
984
  title: "Secure Google Pay button powered by Amos",
1046
985
  name: "amos-google-pay-button",
1047
- height: o.height ?? W(),
986
+ height: o.height ?? z(),
1048
987
  allow: "payment",
1049
988
  className: i,
1050
- style: we
989
+ style: be
1051
990
  });
1052
- return Object.assign(s.style, a), Oe({
991
+ return Object.assign(s.style, a), $({
1053
992
  host: n,
1054
993
  iframe: s,
1055
994
  listenerOptions: o,
1056
995
  iframeStyle: a,
1057
- attachListeners: G
996
+ attachListeners: B
1058
997
  });
1059
998
  }
1060
- function Me(e, t) {
1061
- let n = Q(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = $({
1062
- src: A(r),
999
+ function De(e, t) {
1000
+ let n = Z(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = Q({
1001
+ src: T(r),
1063
1002
  title: "Secure Apple Pay button powered by Amos",
1064
1003
  name: "amos-apple-pay-button",
1065
- height: o.height ?? j(),
1004
+ height: o.height ?? E(),
1066
1005
  allow: "payment",
1067
1006
  className: i,
1068
- style: we
1007
+ style: be
1069
1008
  });
1070
- return Object.assign(s.style, a), Oe({
1009
+ return Object.assign(s.style, a), $({
1071
1010
  host: n,
1072
1011
  iframe: s,
1073
1012
  listenerOptions: o,
1074
1013
  iframeStyle: a,
1075
- attachListeners: ne
1014
+ attachListeners: O
1076
1015
  });
1077
1016
  }
1078
1017
  //#endregion
1079
- export { N as SKELETON_STYLES, ne as attachApplePayButtonListeners, G as attachGooglePayButtonListeners, le as attachPaymentMethodFormListeners, D as confirmPaymentIntent, O as confirmSetupIntent, a as createMessage, z as createPaymentMethodFormSkeleton, B as createWalletButtonSkeleton, r as decodeJwt, P as ensureSkeletonStyles, oe as formatGooglePayPaymentData, j as getApplePayButtonInitialHeight, A as getApplePayButtonSrc, ce as getBankAccountFormInitialHeight, Y as getBankAccountFormSrc, X as getCreditCardFormInitialHeight, J as getCreditCardFormSrc, i as getEmbedOrigin, W as getGooglePayButtonInitialHeight, U as getGooglePayButtonSrc, me as linkedBankLabelFromMetadata, ge as loadPlaidScript, Me as mountAmosApplePayButton, Ae as mountAmosBankAccountPaymentMethodForm, ke as mountAmosCreditCardPaymentMethodForm, je as mountAmosGooglePayButton, _e as openPlaidLink, pe as plaidAccountIdFromMetadata, de as requiresAchVerification, w as resetForm, H as resolveWalletButtonSkeletonBorderRadius, k as sendConfirmationResult, g as sendParentReadyMessage, b as updateAmount, _ as updateAppearance, v as updateApplePayButton, y as updateGooglePayButton, x as updateMerchantName, S as validateForm };
1018
+ export { ne as SKELETON_STYLES, O as attachApplePayButtonListeners, B as attachGooglePayButtonListeners, q as attachPaymentMethodFormListeners, S as confirmPaymentIntent, C as confirmSetupIntent, l as createMessage, ae as createPaymentMethodFormSkeleton, F as createWalletButtonSkeleton, r as decodeJwt, A as ensureSkeletonStyles, oe as formatGooglePayPaymentData, E as getApplePayButtonInitialHeight, T as getApplePayButtonSrc, K as getBankAccountFormInitialHeight, W as getBankAccountFormSrc, G as getCreditCardFormInitialHeight, U as getCreditCardFormSrc, i as getEmbedOrigin, z as getGooglePayButtonInitialHeight, R as getGooglePayButtonSrc, ue as linkedBankLabelFromMetadata, fe as loadPlaidScript, De as mountAmosApplePayButton, Te as mountAmosBankAccountPaymentMethodForm, we as mountAmosCreditCardPaymentMethodForm, Ee as mountAmosGooglePayButton, pe as openPlaidLink, le as plaidAccountIdFromMetadata, Y as requiresAchVerification, y as resetForm, L as resolveWalletButtonSkeletonBorderRadius, w as sendConfirmationResult, d as sendParentReadyMessage, h as updateAmount, f as updateAppearance, p as updateApplePayButton, m as updateGooglePayButton, g as updateMerchantName, _ as validateForm };