@amos.com/amos-js 0.9.16 → 0.9.18
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/README.md +34 -7
- package/dist/form-skeleton.d.ts +31 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +112 -2
- package/dist/index.mjs +543 -234
- package/dist/messaging.d.ts +7 -0
- package/dist/mount.d.ts +29 -3
- package/dist/plaid-bank-ui.d.ts +21 -0
- package/dist/plaid-session.d.ts +12 -0
- package/dist/plaid.d.ts +82 -0
- package/dist/types.d.ts +28 -2
- package/package.json +1 -1
- package/src/form-skeleton.ts +77 -2
- package/src/index.ts +27 -2
- package/src/messaging.ts +107 -16
- package/src/mount.ts +222 -44
- package/src/payment-method-form.ts +4 -0
- package/src/plaid-bank-ui.ts +421 -0
- package/src/plaid-session.ts +41 -0
- package/src/plaid.ts +215 -0
- package/src/types.ts +31 -2
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ npm install @amos.com/amos-js
|
|
|
14
14
|
|
|
15
15
|
- **Types** for the `postMessage` protocol used between your page and the Amos iframe (`Message`, `Appearance`, `ThemeVariable`). OpenAPI schema types (for example `components["schemas"]["PaymentIntent"]`) come from `@amos.com/node`.
|
|
16
16
|
- **Iframe-targeted helpers** to validate the form, confirm a payment intent, confirm a setup intent, update appearance, etc.
|
|
17
|
-
- **Mount functions** (`mountAmosCreditCardPaymentMethodForm`, `mountAmosBankAccountPaymentMethodForm`, `mountAmosGooglePayButton`, `mountAmosApplePayButton`) that create the iframe, wire up its message protocol, manage its height/opacity, show a field-shaped
|
|
17
|
+
- **Mount functions** (`mountAmosCreditCardPaymentMethodForm`, `mountAmosBankAccountPaymentMethodForm`, `mountAmosGooglePayButton`, `mountAmosApplePayButton`) that create the iframe, wire up its message protocol, manage its height/opacity, show a loading skeleton (field-shaped for card/bank forms, button-shaped for Google Pay / Apple Pay), and return a small controller for updating options and tearing it down.
|
|
18
18
|
- **Lower-level building blocks** (`getCreditCardFormSrc`, `attachPaymentMethodFormListeners`, `attachGooglePayButtonListeners`, `attachApplePayButtonListeners`, ...) for integrators (such as `@amos.com/react-amos-js`) that want to render the iframe element themselves.
|
|
19
19
|
|
|
20
20
|
> **Note:** A server-side SDK (for example `@amos.com/node`) must be used alongside `@amos.com/amos-js` for end-to-end payment processing. `@amos.com/amos-js` is the client-side half.
|
|
@@ -191,7 +191,7 @@ In short, your app orchestrates the payment flow, while sensitive payment data s
|
|
|
191
191
|
|
|
192
192
|
## Appearance
|
|
193
193
|
|
|
194
|
-
Card and bank mount functions (and `attachPaymentMethodFormListeners`) accept an optional `appearance` option that controls the look of the iframe UI. It contains a `themeVariables` object whose keys are CSS custom-property names and whose values are strings, and an optional `labels` setting for field label placement. You can update appearance after page load via the controller's `update({ appearance })` method. Wallet buttons do not take `appearance`.
|
|
194
|
+
Card and bank mount functions (and `attachPaymentMethodFormListeners`) accept an optional `appearance` option that controls the look of the iframe UI, and of the parent-page **Connect bank account** button when ACH verification is required. It contains a `themeVariables` object whose keys are CSS custom-property names and whose values are strings, and an optional `labels` setting for field label placement. You can update appearance after page load via the controller's `update({ appearance })` method. Wallet buttons do not take `appearance`.
|
|
195
195
|
|
|
196
196
|
```ts
|
|
197
197
|
form.update({
|
|
@@ -259,7 +259,7 @@ Radio groups (e.g. account type) always use an above-style group label regardles
|
|
|
259
259
|
| `--control-gap` | Horizontal gap between side-by-side controls | `0.5rem` |
|
|
260
260
|
| `--error-font-size` | Font size of field-level error messages | `0.875rem` |
|
|
261
261
|
| `--radio-size` | Size of radio buttons on the bank account form | `1rem` |
|
|
262
|
-
| `--ring` | Focus ring and outline color
|
|
262
|
+
| `--ring` | Focus ring and outline color (inputs, Connect button) | `oklch(0.708 0 0)` |
|
|
263
263
|
| `--ring-width` | Focus ring width | `3px` |
|
|
264
264
|
| `--radius` | Base border-radius (derived into sm/md/lg/xl) | `0.625rem` |
|
|
265
265
|
|
|
@@ -293,9 +293,35 @@ Mount the secure credit-card payment method form into a container element (an `H
|
|
|
293
293
|
|
|
294
294
|
Same shape as `mountAmosCreditCardPaymentMethodForm`, minus `additionalFields`. Supports the same `billingAddressRequirement` option.
|
|
295
295
|
|
|
296
|
+
When the charge meets the merchant’s ACH verification threshold, the SDK hides the routing/account iframe and renders a **Connect bank account** button in the parent page. The button follows the same outline/focus defaults as Amos UI (`--ring`, `--border`, `--radius`, `--input-height`, …): it inherits those CSS variables from the host page when present, and `appearance.themeVariables` overrides them the same way as the iframe. Clicking it asks the iframe to mint a Plaid Link token, then opens [Plaid Link](https://plaid.com/docs/link/web/) (`Plaid.create({ token }).open()`). Hosts do not proxy Pay API (`GET /merchants`, `POST /plaid_link_tokens`); embed does that with `PAY_API_KEY`. Do not put Plaid secrets in the browser.
|
|
297
|
+
|
|
298
|
+
**Additional `options` (ACH verification):**
|
|
299
|
+
|
|
300
|
+
- `amount` (`string`, major-currency decimal, e.g. `"50.00"`) — same format as Google Pay / Apple Pay. Compared to the threshold the iframe fetches (cents). Omit to always Connect once a threshold exists (setup-intent save, or when you do not know the charge yet). Pass `amount` and `update({ amount })` when it changes if charges under the threshold should stay on the manual form.
|
|
301
|
+
|
|
302
|
+
Compare locally once the iframe posts `ACH_THRESHOLD`: Plaid when the amount (converted to cents) is `>= achThreshold`, or when `amount` is omitted and a threshold is set. No threshold (or `null`) keeps the manual bank form. If `amount` later drops under the threshold, Plaid credentials are dropped and the iframe form is shown again.
|
|
303
|
+
|
|
304
|
+
```ts
|
|
305
|
+
import { mountAmosBankAccountPaymentMethodForm } from "@amos.com/amos-js";
|
|
306
|
+
|
|
307
|
+
const bank = mountAmosBankAccountPaymentMethodForm("#bank-form", {
|
|
308
|
+
renderToken,
|
|
309
|
+
amount: "50.00", // omit to always Connect
|
|
310
|
+
onResult: (result) => {
|
|
311
|
+
/* … */
|
|
312
|
+
},
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
bank.update({ amount: "25.00" });
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
`validateForm` / `confirmPaymentIntent` / `confirmSetupIntent` stay iframe-based. When Plaid succeeded, confirm sends `payment_method.plaid` (`public_token`, `account_id`) and does not require typed account numbers.
|
|
319
|
+
|
|
320
|
+
**CSP:** the parent page must allow Plaid’s script and frames, for example `script-src https://cdn.plaid.com` and `frame-src https://cdn.plaid.com https://*.plaid.com`. Amos never loads `PLAID_SECRET` / `PLAID_CLIENT_ID` in the SDK or embed iframe.
|
|
321
|
+
|
|
296
322
|
### `mountAmosGooglePayButton(container, options)`
|
|
297
323
|
|
|
298
|
-
Mount the secure Google Pay button (express checkout) into a container element.
|
|
324
|
+
Mount the secure Google Pay button (express checkout) into a container element. A button-shaped skeleton is shown immediately and replaced by the iframe once appearance is applied.
|
|
299
325
|
|
|
300
326
|
**Required `options`:**
|
|
301
327
|
|
|
@@ -328,11 +354,11 @@ The wallet iframe is flush with its mount container (`width: 100%`, zero margin)
|
|
|
328
354
|
|
|
329
355
|
**Returns** `AmosGooglePayButtonMountController`:
|
|
330
356
|
|
|
331
|
-
- `iframe`, `update(patch)`, `destroy()`. Use `update({ amount, merchantName })` to push new values into the iframe. Use `update({ height, buttonProps })` to restyle the button.
|
|
357
|
+
- `iframe`, `update(patch)`, `destroy()`. `destroy()` removes the iframe and any loading skeleton. Use `update({ amount, merchantName })` to push new values into the iframe. Use `update({ height, buttonProps })` to restyle the button.
|
|
332
358
|
|
|
333
359
|
### `mountAmosApplePayButton(container, options)`
|
|
334
360
|
|
|
335
|
-
Mount the secure Apple Pay button (express checkout). Same required options and return shape as `mountAmosGooglePayButton`.
|
|
361
|
+
Mount the secure Apple Pay button (express checkout). Same required options and return shape as `mountAmosGooglePayButton`. A button-shaped skeleton is shown immediately and replaced by the iframe once appearance is applied.
|
|
336
362
|
|
|
337
363
|
**Optional visual options:**
|
|
338
364
|
|
|
@@ -396,7 +422,8 @@ Advanced helpers exposed for integrators that need to construct or inspect the m
|
|
|
396
422
|
- **`iframe` argument**: every messaging helper (`validateForm`, `confirmPaymentIntent`, `confirmSetupIntent`, `resetForm`) accepts the `iframe` element directly. With the mount helpers, use `controller.iframe`.
|
|
397
423
|
- **`onResult` is not settlement proof**: `onResult` tells you when to stop waiting (e.g. dismiss a spinner). Verify payment or setup success on your backend via webhooks. On `status: "incomplete"`, unlock your UI — the customer can fix fields in the iframe and retry. Use `result.reason` (`"field_errors"` or `"validation_failed"`) to distinguish recoverable states.
|
|
398
424
|
- **Same components for payment vs setup intents**: `mountAmosCreditCardPaymentMethodForm` and `mountAmosBankAccountPaymentMethodForm` support both payment intents and setup intents. The flow differs only by which server call you make and which confirmation function you use. Handle both outcomes via `onResult`.
|
|
399
|
-
- **Amount format**: for `mountAmosGooglePayButton` and `
|
|
425
|
+
- **Amount format**: for `mountAmosGooglePayButton`, `mountAmosApplePayButton`, and `mountAmosBankAccountPaymentMethodForm`, `amount` is a major-currency decimal string (e.g. `"50.00"` for $50.00). For `components["schemas"]["CreatePaymentIntentInput"]` on the server (card/bank create, and the object the wallet iframe sends to `onInitiatePaymentIntentRequest`), `amount` is a number in cents (e.g. `5000`).
|
|
426
|
+
- **Plaid Link (ACH verification)**: load `cdn.plaid.com` from the **parent** document (see CSP above). Merchants do not proxy Pay API; the bank iframe fetches the ACH threshold and mints link tokens. Confirm still goes through the bank iframe so Amos can attach `plaid` to the payment method.
|
|
400
427
|
- **Apple Pay waiting overlay**: on browsers where Apple's QR handoff opens in a popup (non-Safari), `mountAmosApplePayButton` shows a fixed full-viewport overlay on the host page until payment completes, the popup closes, or the user clicks **Cancel payment**. Avoid stacking other fixed UI above it.
|
|
401
428
|
- **Browser-only**: the mount and messaging helpers require `window` and the DOM. They are not safe to call during server-side rendering — call them from client-side code only (for example, inside a `useEffect`-like hook in your framework of choice).
|
|
402
429
|
|
package/dist/form-skeleton.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { BillingAddressRequirement, CreditCardAdditionalFields } from './payment-method-form';
|
|
2
2
|
import { Appearance } from './types';
|
|
3
|
+
export declare const SKELETON_STYLES = "\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";
|
|
4
|
+
export declare function ensureSkeletonStyles(): void;
|
|
3
5
|
export type PaymentMethodFormSkeletonKind = "card" | "bank";
|
|
4
6
|
export type PaymentMethodFormSkeletonOptions = {
|
|
5
7
|
kind: PaymentMethodFormSkeletonKind;
|
|
@@ -18,3 +20,32 @@ export type PaymentMethodFormSkeleton = {
|
|
|
18
20
|
* ready.
|
|
19
21
|
*/
|
|
20
22
|
export declare function createPaymentMethodFormSkeleton(options: PaymentMethodFormSkeletonOptions): PaymentMethodFormSkeleton;
|
|
23
|
+
export type WalletButtonSkeletonOptions = {
|
|
24
|
+
/** Painted height of the wallet button slot (CSS length). */
|
|
25
|
+
height: string;
|
|
26
|
+
/** Corner radius matching the iframe / native button. */
|
|
27
|
+
borderRadius?: string;
|
|
28
|
+
};
|
|
29
|
+
export type WalletButtonSkeleton = {
|
|
30
|
+
element: HTMLElement;
|
|
31
|
+
update: (options: WalletButtonSkeletonOptions) => void;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Host-page placeholder for Google Pay / Apple Pay: a pulsing bar at
|
|
35
|
+
* the button's height. Shown immediately while the iframe loads, then
|
|
36
|
+
* removed when appearance is ready.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createWalletButtonSkeleton(options: WalletButtonSkeletonOptions): WalletButtonSkeleton;
|
|
39
|
+
/**
|
|
40
|
+
* Corner radius for a wallet-button skeleton. Prefers host iframe
|
|
41
|
+
* chrome, then native Google / Apple button radius, then 4px.
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolveWalletButtonSkeletonBorderRadius({ iframeStyle, buttonProps, }: {
|
|
44
|
+
iframeStyle?: {
|
|
45
|
+
borderRadius?: string | number;
|
|
46
|
+
};
|
|
47
|
+
buttonProps?: {
|
|
48
|
+
buttonRadius?: number;
|
|
49
|
+
style?: Record<string, string | number | undefined>;
|
|
50
|
+
};
|
|
51
|
+
}): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/// <reference types="googlepay" />
|
|
2
2
|
export type { ApplePayButtonController, ApplePayButtonListenerOptions, } from './apple-pay';
|
|
3
3
|
export { attachApplePayButtonListeners, getApplePayButtonInitialHeight, getApplePayButtonSrc, } from './apple-pay';
|
|
4
|
+
export type { PaymentMethodFormSkeleton, PaymentMethodFormSkeletonKind, PaymentMethodFormSkeletonOptions, WalletButtonSkeleton, WalletButtonSkeletonOptions, } from './form-skeleton';
|
|
5
|
+
export { createPaymentMethodFormSkeleton, createWalletButtonSkeleton, ensureSkeletonStyles, resolveWalletButtonSkeletonBorderRadius, SKELETON_STYLES, } from './form-skeleton';
|
|
4
6
|
export type { FormattedGooglePayPaymentData, GooglePayButtonController, GooglePayButtonListenerOptions, } from './google-pay';
|
|
5
7
|
export { attachGooglePayButtonListeners, formatGooglePayPaymentData, getGooglePayButtonInitialHeight, getGooglePayButtonSrc, } from './google-pay';
|
|
6
8
|
export { decodeJwt, getEmbedOrigin } from './jwt';
|
|
7
9
|
export { confirmPaymentIntent, confirmSetupIntent, resetForm, sendConfirmationResult, sendParentReadyMessage, updateAmount, updateAppearance, updateApplePayButton, updateGooglePayButton, updateMerchantName, validateForm, } from './messaging';
|
|
8
|
-
export type { AmosApplePayButtonMountController, AmosApplePayButtonOptions, AmosBankAccountPaymentMethodFormOptions, AmosCreditCardPaymentMethodFormOptions, AmosGooglePayButtonMountController, AmosGooglePayButtonOptions, AmosPaymentMethodFormMountController, } from './mount';
|
|
10
|
+
export type { AmosApplePayButtonMountController, AmosApplePayButtonOptions, AmosBankAccountPaymentMethodFormMountController, AmosBankAccountPaymentMethodFormOptions, AmosCreditCardPaymentMethodFormOptions, AmosGooglePayButtonMountController, AmosGooglePayButtonOptions, AmosPaymentMethodFormMountController, } from './mount';
|
|
9
11
|
export { mountAmosApplePayButton, mountAmosBankAccountPaymentMethodForm, mountAmosCreditCardPaymentMethodForm, mountAmosGooglePayButton, } from './mount';
|
|
10
12
|
export type { BillingAddressRequirement, CreditCardAdditionalFields, PaymentMethodFormController, PaymentMethodFormListenerOptions, } from './payment-method-form';
|
|
11
13
|
export { attachPaymentMethodFormListeners, getBankAccountFormInitialHeight, getBankAccountFormSrc, getCreditCardFormInitialHeight, getCreditCardFormSrc, } from './payment-method-form';
|
|
14
|
+
export type { OpenPlaidLinkInput, PlaidCredentials, PlaidLinkOnSuccessMetadata, } from './plaid';
|
|
15
|
+
export { linkedBankLabelFromMetadata, loadPlaidScript, openPlaidLink, plaidAccountIdFromMetadata, requiresAchVerification, } from './plaid';
|
|
12
16
|
export type { Appearance, AppearanceLabels, ApplePayButtonElementProps, ConfirmationIncompleteReason, ConfirmationResult, GooglePayButtonElementProps, Message, PaymentMethodFormValidityChangeEvent, ThemeVariable, } from './types';
|
|
13
17
|
export { createMessage } from './types';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`data-amos-apple-pay-waiting`;function t({onCancel:t}){let n=document.querySelector(`[${e}]`);if(n)return n;let r=document.createElement(`div`);r.setAttribute(e,`true`),r.setAttribute(`role`,`dialog`),r.setAttribute(`aria-modal`,`true`),r.setAttribute(`aria-labelledby`,`amos-apple-pay-waiting-title`),Object.assign(r.style,{position:`fixed`,inset:`0`,zIndex:`2147483646`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`24px`,boxSizing:`border-box`,background:`rgba(0, 0, 0, 0.55)`,fontFamily:`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif`});let i=document.createElement(`div`);Object.assign(i.style,{width:`100%`,maxWidth:`360px`,borderRadius:`12px`,background:`#fff`,padding:`28px 24px 20px`,boxSizing:`border-box`,textAlign:`center`,boxShadow:`0 12px 40px rgba(0, 0, 0, 0.25)`});let a=document.createElement(`div`);a.setAttribute(`aria-hidden`,`true`),Object.assign(a.style,{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`6px`,marginBottom:`16px`,fontSize:`28px`,fontWeight:`600`,letterSpacing:`-0.02em`,color:`#000`,lineHeight:`1`}),a.innerHTML=`<svg width="22" height="26" viewBox="0 0 814 1000" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M788.1 340.9c-5.8 4.5-108.2 62.2-108.2 190.5 0 148.4 130.3 200.9 134.2 202.2-.6 3.2-20.7 71.9-68.7 141.9-42.8 61.6-87.5 123.1-155.5 123.1s-85.5-39.5-164-39.5c-76.5 0-103.7 40.8-165.9 40.8s-105.6-57-155.5-127C46.7 790.7 0 663 0 541.8c0-194.4 126.4-297.5 250.8-297.5 66.1 0 121.2 43.4 162.7 43.4 39.5 0 101.1-46 176.3-46 28.5 0 130.9 2.6 198.3 99.2zm-234-181.5c31.1-36.9 53.1-88.1 53.1-139.3 0-7.1-.6-14.3-1.9-20.1-50.6 1.9-110.8 33.7-147.1 75.8-28.5 32.4-55.1 83.6-55.1 135.5 0 7.8 1.3 15.6 1.9 18.1 3.2.6 8.4 1.3 13.6 1.3 45.4 0 102.5-30.4 135.5-71.3z"/></svg><span>Pay</span>`;let o=document.createElement(`p`);o.id=`amos-apple-pay-waiting-title`,Object.assign(o.style,{margin:`0 0 20px`,fontSize:`15px`,lineHeight:`1.45`,color:`#1a1a1a`}),o.textContent=`Complete your payment in the open Apple Pay window, or close Apple Pay to continue paying another way.`;let s=document.createElement(`button`);return s.type=`button`,s.textContent=`Cancel payment`,Object.assign(s.style,{display:`block`,width:`100%`,border:`none`,borderRadius:`8px`,padding:`12px 16px`,background:`#2c2c2e`,color:`#fff`,fontSize:`15px`,fontWeight:`500`,cursor:`pointer`}),s.addEventListener(`click`,t),i.append(a,o,s),r.append(i),document.body.append(r),r}function n(){document.querySelector(`[${e}]`)?.remove()}function r(e){let[t=``,n=``,r=``]=e?.split(`.`)??[],i=typeof atob==`function`?atob:e=>Buffer.from(e,`base64`).toString(`utf8`);return{header:JSON.parse(i(t)),payload:JSON.parse(i(n)),signature:r}}function i(e){let{env:t=`sandbox`}=r(e).payload;switch(t){case`production`:return`https://embed.amos.com`;case`sandbox`:return`https://embed-sandbox.amos.com`;default:return`https://embed-sandbox.amos.com`}}function a(e){return e}function
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`data-amos-apple-pay-waiting`;function t({onCancel:t}){let n=document.querySelector(`[${e}]`);if(n)return n;let r=document.createElement(`div`);r.setAttribute(e,`true`),r.setAttribute(`role`,`dialog`),r.setAttribute(`aria-modal`,`true`),r.setAttribute(`aria-labelledby`,`amos-apple-pay-waiting-title`),Object.assign(r.style,{position:`fixed`,inset:`0`,zIndex:`2147483646`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`24px`,boxSizing:`border-box`,background:`rgba(0, 0, 0, 0.55)`,fontFamily:`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif`});let i=document.createElement(`div`);Object.assign(i.style,{width:`100%`,maxWidth:`360px`,borderRadius:`12px`,background:`#fff`,padding:`28px 24px 20px`,boxSizing:`border-box`,textAlign:`center`,boxShadow:`0 12px 40px rgba(0, 0, 0, 0.25)`});let a=document.createElement(`div`);a.setAttribute(`aria-hidden`,`true`),Object.assign(a.style,{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`6px`,marginBottom:`16px`,fontSize:`28px`,fontWeight:`600`,letterSpacing:`-0.02em`,color:`#000`,lineHeight:`1`}),a.innerHTML=`<svg width="22" height="26" viewBox="0 0 814 1000" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M788.1 340.9c-5.8 4.5-108.2 62.2-108.2 190.5 0 148.4 130.3 200.9 134.2 202.2-.6 3.2-20.7 71.9-68.7 141.9-42.8 61.6-87.5 123.1-155.5 123.1s-85.5-39.5-164-39.5c-76.5 0-103.7 40.8-165.9 40.8s-105.6-57-155.5-127C46.7 790.7 0 663 0 541.8c0-194.4 126.4-297.5 250.8-297.5 66.1 0 121.2 43.4 162.7 43.4 39.5 0 101.1-46 176.3-46 28.5 0 130.9 2.6 198.3 99.2zm-234-181.5c31.1-36.9 53.1-88.1 53.1-139.3 0-7.1-.6-14.3-1.9-20.1-50.6 1.9-110.8 33.7-147.1 75.8-28.5 32.4-55.1 83.6-55.1 135.5 0 7.8 1.3 15.6 1.9 18.1 3.2.6 8.4 1.3 13.6 1.3 45.4 0 102.5-30.4 135.5-71.3z"/></svg><span>Pay</span>`;let o=document.createElement(`p`);o.id=`amos-apple-pay-waiting-title`,Object.assign(o.style,{margin:`0 0 20px`,fontSize:`15px`,lineHeight:`1.45`,color:`#1a1a1a`}),o.textContent=`Complete your payment in the open Apple Pay window, or close Apple Pay to continue paying another way.`;let s=document.createElement(`button`);return s.type=`button`,s.textContent=`Cancel payment`,Object.assign(s.style,{display:`block`,width:`100%`,border:`none`,borderRadius:`8px`,padding:`12px 16px`,background:`#2c2c2e`,color:`#fff`,fontSize:`15px`,fontWeight:`500`,cursor:`pointer`}),s.addEventListener(`click`,t),i.append(a,o,s),r.append(i),document.body.append(r),r}function n(){document.querySelector(`[${e}]`)?.remove()}function r(e){let[t=``,n=``,r=``]=e?.split(`.`)??[],i=typeof atob==`function`?atob:e=>Buffer.from(e,`base64`).toString(`utf8`);return{header:JSON.parse(i(t)),payload:JSON.parse(i(n)),signature:r}}function i(e){let{env:t=`sandbox`}=r(e).payload;switch(t){case`production`:return`https://embed.amos.com`;case`sandbox`:return`https://embed-sandbox.amos.com`;default:return`https://embed-sandbox.amos.com`}}var a=new WeakMap;function o(e,t){a.set(e,t)}function s(e){if(e)return a.get(e)}function c(e){e&&a.delete(e)}function l(e){return e}function u(e){return new URL(e.src).origin}function d(e){e?.contentWindow&&e.contentWindow.postMessage(l({type:`PARENT_ACKNOWLEDGED_IFRAME_READY`}),u(e))}function f({iframe:e,appearance:t={}}){e?.contentWindow&&e.contentWindow.postMessage(l({type:`UPDATE_APPEARANCE`,appearance:t}),u(e))}function p({iframe:e,props:t,height:n}){e?.contentWindow&&e.contentWindow.postMessage(l({type:`UPDATE_APPLE_PAY_BUTTON`,height:n,props:t}),u(e))}function m({iframe:e,props:t,height:n}){e?.contentWindow&&e.contentWindow.postMessage(l({type:`UPDATE_GOOGLE_PAY_BUTTON`,height:n,props:t}),u(e))}function h({iframe:e,amount:t}){e?.contentWindow&&e.contentWindow.postMessage(l({type:`UPDATE_AMOUNT`,amount:t}),u(e))}function g({iframe:e,merchantName:t}){e?.contentWindow&&e.contentWindow.postMessage(l({type:`UPDATE_MERCHANT_NAME`,merchantName:t}),u(e))}function _({iframe:e}){let t=s(e);if(t?.requiresVerification)return Promise.resolve(!!t.plaid);let n=crypto.randomUUID();return new Promise(t=>{e?.contentWindow&&e.contentWindow.postMessage(l({type:`VALIDATE_FORM`,requestId:n}),u(e));let r=setTimeout(()=>{window.removeEventListener(`message`,i),t(!1)},5e3);function i(e){e.data.type===`VALIDATE_FORM`&&e.data.requestId===n&&(window.removeEventListener(`message`,i),clearTimeout(r),t(e.data.isValid??!1))}window.addEventListener(`message`,i)})}var v=1e4;function ee({iframe:e}){let t=crypto.randomUUID();return new Promise((n,r)=>{if(!e?.contentWindow){r(Error(`Bank form is not ready.`));return}let i=e.contentWindow;i.postMessage(l({type:`CREATE_PLAID_LINK_TOKEN`,requestId:t}),u(e));let a=setTimeout(()=>{window.removeEventListener(`message`,o),r(Error(`Timed out waiting for Plaid Link token.`))},v);function o(e){if(e.source===i&&e.data.type===`PLAID_LINK_TOKEN`&&e.data.requestId===t){if(window.removeEventListener(`message`,o),clearTimeout(a),e.data.link_token){n(e.data.link_token);return}r(Error(e.data.error??`Could not create Plaid Link token.`))}}window.addEventListener(`message`,o)})}function y({iframe:e}){s(e)?.clearLinked?.(),b(e)}function b(e){e?.contentWindow&&e.contentWindow.postMessage(l({type:`RESET_FORM`}),u(e))}function x({iframe:e,type:t,token:n,id:r}){let i=s(e),a=i?.plaid;i?.requiresVerification&&!a&&b(e),e.contentWindow?.postMessage(l({type:t,token:n,id:r,...a?{plaid:a}:{}}),u(e))}function S({iframe:e,token:t}){if(!e?.contentWindow)return;let{payment_intent_id:n}=r(t).payload;x({iframe:e,type:`CONFIRM_PAYMENT_INTENT`,token:t,id:n??void 0})}function C({iframe:e,token:t}){if(!e?.contentWindow)return;let{setup_intent_id:n}=r(t).payload;x({iframe:e,type:`CONFIRM_SETUP_INTENT`,token:t,id:n??void 0})}function w({iframe:e,result:t}){e?.contentWindow&&e.contentWindow.postMessage(l({type:`CONFIRMATION_RESULT`,result:t}),u(e))}function T(e){return`${i(e)}/iframe/apple-pay?token=${e}`}function E(){return`48px`}function D(e){e.contentWindow?.postMessage(l({type:`APPLE_PAY_CANCEL`}),u(e))}function O(e,{height:r=`48px`,...i}){let a={...i,height:r};function o(){h({iframe:e,amount:a.amount})}function s(){g({iframe:e,merchantName:a.merchantName})}function c(){p({iframe:e,height:a.height??`48px`,props:a.buttonProps??{}})}function l(r){if(r.source===e.contentWindow)switch(r.data.type){case`IFRAME_READY`:d(e),f({iframe:e,appearance:{}}),o(),s(),c();break;case`UPDATE_HEIGHT`:a.onHeightChange?.(r.data.height);break;case`UPDATE_APPEARANCE`:f({iframe:e,appearance:r.data.appearance});break;case`UPDATED_APPEARANCE`:a.onAppearanceReady?.();break;case`APPLE_PAY_WINDOW_OPEN`:t({onCancel:()=>{D(e),n()}});break;case`APPLE_PAY_WINDOW_CLOSE`:n();break;case`CREATE_PAYMENT_INTENT`:a.onInitiatePaymentIntentRequest({paymentIntentCreateAttributes:r.data.paymentIntentCreateAttributes,customerCreateAttributes:r.data.customerCreateAttributes}).then(t=>{S({iframe:e,token:t})}).catch(e=>{n(),a.onResult({status:`failed`,errorMessage:e instanceof Error?e.message:`Unknown error`})});break;case`CONFIRMATION_RESULT`:n(),a.onResult(r.data.result)}}return window.addEventListener(`message`,l),{update(e){let t=`amount`in e,n=`merchantName`in e,r=`height`in e||`buttonProps`in e;a={...a,...e},t&&o(),n&&s(),r&&c()},destroy(){window.removeEventListener(`message`,l),n()}}}var k=`amos-js-form-skeleton-styles`,te={"--accent":`oklch(0.97 0 0)`,"--radius":`0.625rem`,"--input-height":`2.25rem`,"--floating-input-height":`3.25rem`,"--field-gap":`1rem`,"--control-gap":`0.5rem`,"--label-font-size":`0.875rem`},ne=`
|
|
2
2
|
.amos-js-form-skeleton {
|
|
3
3
|
box-sizing: border-box;
|
|
4
4
|
container-type: inline-size;
|
|
@@ -53,6 +53,10 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`data-a
|
|
|
53
53
|
gap: var(--control-gap);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
+
.amos-js-wallet-skeleton {
|
|
57
|
+
flex: none;
|
|
58
|
+
width: 100%;
|
|
59
|
+
}
|
|
56
60
|
@keyframes amos-js-skeleton-pulse {
|
|
57
61
|
50% { opacity: 0.5; }
|
|
58
62
|
}
|
|
@@ -61,4 +65,110 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`data-a
|
|
|
61
65
|
animation: none;
|
|
62
66
|
}
|
|
63
67
|
}
|
|
64
|
-
`;function
|
|
68
|
+
`;function A(){if(document.getElementById(k))return;let e=document.createElement(`style`);e.id=k,e.textContent=ne,document.head.appendChild(e)}function j(e,t){for(let[t,n]of Object.entries(te))e.style.setProperty(t,n);let n=t?.themeVariables;if(n)for(let[t,r]of Object.entries(n))typeof r==`string`&&r.trim()!==``&&e.style.setProperty(t,r.trim())}function M(e,t){let n=document.createElement(`div`);if(n.className=e,t)for(let e of t)n.appendChild(e);return n}function N(e,t){let n=M(`amos-js-form-skeleton-field`);t!==void 0&&(n.style.flexGrow=String(t)),e===`above`&&n.appendChild(M(`amos-js-form-skeleton-label`));let r=M(`amos-js-form-skeleton-input`);return e===`floating`&&r.classList.add(`amos-js-form-skeleton-input-floating`),n.appendChild(r),n}function P(e,t){return M(t?`amos-js-form-skeleton-row-stack`:`amos-js-form-skeleton-row`,e)}function re({labels:e,requirement:t,wrapCountryZip:n}){return t===`full`?[N(e),N(e),P([N(e,1.4),N(e,.7),N(e,.8)],!1),N(e)]:[P([N(e),N(e)],n)]}function ie(e){let t=e.appearance?.labels??`above`,n=e.billingAddressRequirement??`country`;if(e.kind===`card`){let r=[N(t),P([N(t),N(t)],!1)];return e.additionalFields?.cardholderName&&r.push(N(t)),r.push(...re({labels:t,requirement:n,wrapCountryZip:!1})),r}return[N(t),P([N(t),N(t)],!0),N(t),P([N(`above`),N(`above`)],!0),...re({labels:t,requirement:n,wrapCountryZip:!0})]}function ae(e){A();let t=M(`amos-js-form-skeleton`);t.setAttribute(`aria-hidden`,`true`);function n(e){j(t,e.appearance),t.replaceChildren(...ie(e))}return n(e),{element:t,update:n}}function F(e){A();let t=M(`amos-js-form-skeleton-input amos-js-wallet-skeleton`);t.setAttribute(`aria-hidden`,`true`);function n(e){j(t,void 0),t.style.height=e.height,t.style.borderRadius=e.borderRadius??`4px`}return n(e),{element:t,update:n}}function I(e){if(typeof e==`number`&&Number.isFinite(e))return`${e}px`;if(typeof e==`string`&&e.trim()!==``)return e.trim()}function L({iframeStyle:e,buttonProps:t}){return I(e?.borderRadius)??I(t?.buttonRadius)??I(t?.style?.borderRadius)??I(t?.style?.[`--apple-pay-button-border-radius`])??`4px`}function R(e){return`${i(e)}/iframe/google-pay?token=${e}`}function z(){return`48px`}function B(e,{height:t=`48px`,...n}){let r={...n,height:t};function i(){h({iframe:e,amount:r.amount})}function a(){g({iframe:e,merchantName:r.merchantName})}function o(){m({iframe:e,height:r.height??`48px`,props:r.buttonProps??{}})}function s(t){if(t.source===e.contentWindow)switch(t.data.type){case`IFRAME_READY`:d(e),f({iframe:e,appearance:{}}),i(),a(),o();break;case`UPDATE_HEIGHT`:r.onHeightChange?.(t.data.height);break;case`UPDATE_APPEARANCE`:f({iframe:e,appearance:t.data.appearance});break;case`UPDATED_APPEARANCE`:r.onAppearanceReady?.();break;case`CREATE_PAYMENT_INTENT`:r.onInitiatePaymentIntentRequest({paymentIntentCreateAttributes:t.data.paymentIntentCreateAttributes,customerCreateAttributes:t.data.customerCreateAttributes}).then(t=>{S({iframe:e,token:t})}).catch(e=>{r.onResult({status:`failed`,errorMessage:e instanceof Error?e.message:`Unknown error`})});break;case`CONFIRMATION_RESULT`:r.onResult(t.data.result)}}return window.addEventListener(`message`,s),{update(e){let t=`amount`in e,n=`merchantName`in e,s=`height`in e||`buttonProps`in e;r={...r,...e},t&&i(),n&&a(),s&&o()},destroy(){window.removeEventListener(`message`,s)}}}function oe({paymentData:e}){return{paymentMethod:{type:`googlepay`,billing_address_attributes:{name:e.shippingAddress?.name,address_line1:e.shippingAddress?.address1,address_line2:e.shippingAddress?.address2,city:e.shippingAddress?.locality,state:e.shippingAddress?.administrativeArea,postal_code:e.shippingAddress?.postalCode,country:e.shippingAddress?.countryCode,email:e.email,phone:e.shippingAddress?.phoneNumber},card_profile_attributes:{wallet_payload:e.paymentMethodData.tokenizationData.token}}}}var V={country:212,full:452},se=80,H={country:400,full:640};function U(e,t={cardholderName:!1},n=`country`){let r=Object.entries(t).filter(([,e])=>e).map(([e])=>e).join(`,`),a=new URLSearchParams({token:e,additionalFields:r,billingAddressRequirement:n});return`${i(e)}/iframe/card?${a}`}function W(e,t=`country`){let n=new URLSearchParams({token:e,billingAddressRequirement:t});return`${i(e)}/iframe/bank?${n}`}function G(e={cardholderName:!1},t=`country`){return`${(V[t]??V.country)+(e.cardholderName?se:0)}px`}function K(e=`country`){return`${H[e]??H.country}px`}function q(e,t){let n={...t};function r(t){if(t.source===e.contentWindow)switch(t.data.type){case`IFRAME_READY`:d(e),f({iframe:e,appearance:n.appearance});break;case`UPDATE_HEIGHT`:n.onHeightChange?.(t.data.height);break;case`UPDATE_APPEARANCE`:f({iframe:e,appearance:t.data.appearance});break;case`UPDATED_APPEARANCE`:n.onAppearanceReady?.();break;case`FORM_VALIDITY_CHANGE`:if(s(e)?.requiresVerification)break;n.onValidityChange?.({isValid:t.data.isValid});break;case`CONFIRMATION_RESULT`:n.onResult(t.data.result)}}return window.addEventListener(`message`,r),{update(t){let r=`appearance`in t;n={...n,...t},r&&f({iframe:e,appearance:n.appearance})},destroy(){window.removeEventListener(`message`,r)}}}var J=`https://cdn.plaid.com/link/v2/stable/link-initialize.js`;function Y({amount:e,achThreshold:t}){return t==null?!1:e==null||e>=t}function ce(e){if(e==null)return;let t=e.trim();if(t===``)return;let n=Number(t.replace(/[^\d.]/g,``));if(Number.isFinite(n))return Math.round(n*100)}function le(e){return e.account_id??e.account?.id??e.accounts?.[0]?.id}function ue(e){let t=e.account??e.accounts?.[0];return{bankName:e.institution?.name??`Bank account`,last4:t?.mask??``}}var X;function de(){for(let e of document.querySelectorAll(`script[src="${J}"]`))e.remove()}function fe(){return typeof window>`u`?Promise.reject(Error(`Plaid Link requires a browser`)):window.Plaid?Promise.resolve():X||(de(),X=new Promise((e,t)=>{let n=document.createElement(`script`);n.src=J,n.async=!0;let r=e=>{n.remove(),X=void 0,t(Error(e))};n.addEventListener(`load`,()=>{if(window.Plaid){e();return}r(`Plaid Link failed to initialize`)},{once:!0}),n.addEventListener(`error`,()=>r(`Failed to load Plaid Link`),{once:!0}),document.head.append(n)}),X)}async function pe({token:e,onSuccess:t,onExit:n,signal:r}){if(await fe(),r?.aborted)return()=>{};if(!window.Plaid)throw Error(`Plaid Link failed to initialize`);let i=window.Plaid.create({token:e,onSuccess:t,onExit:e=>{n?.(e)}});return r?.aborted?(i.destroy(),()=>{}):(i.open(),()=>{i.destroy()})}var me=`amos-js-plaid-bank-ui-styles`,he=`
|
|
69
|
+
.amos-js-plaid-panel {
|
|
70
|
+
box-sizing: border-box;
|
|
71
|
+
color: var(--foreground, oklch(0.145 0 0));
|
|
72
|
+
display: none;
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
font-family: inherit;
|
|
75
|
+
gap: var(--control-gap, 0.5rem);
|
|
76
|
+
width: 100%;
|
|
77
|
+
}
|
|
78
|
+
.amos-js-plaid-panel[data-mode="connect"],
|
|
79
|
+
.amos-js-plaid-panel[data-mode="linked"] {
|
|
80
|
+
display: flex;
|
|
81
|
+
}
|
|
82
|
+
.amos-js-plaid-connect {
|
|
83
|
+
align-items: center;
|
|
84
|
+
background: var(--background, oklch(1 0 0));
|
|
85
|
+
border: var(--input-border-width, 1px) solid var(--border, oklch(0.922 0 0));
|
|
86
|
+
border-radius: calc(var(--radius, 0.625rem) * 0.8);
|
|
87
|
+
box-shadow: var(--input-shadow, 0 1px 2px 0 rgb(0 0 0 / 0.05));
|
|
88
|
+
box-sizing: border-box;
|
|
89
|
+
color: var(--foreground, oklch(0.145 0 0));
|
|
90
|
+
cursor: pointer;
|
|
91
|
+
display: inline-flex;
|
|
92
|
+
flex-shrink: 0;
|
|
93
|
+
font: inherit;
|
|
94
|
+
font-size: var(--input-font-size, 0.875rem);
|
|
95
|
+
font-weight: 500;
|
|
96
|
+
height: var(--input-height, 2.25rem);
|
|
97
|
+
justify-content: center;
|
|
98
|
+
line-height: 1.25;
|
|
99
|
+
outline: none;
|
|
100
|
+
padding: 0 var(--input-padding, 0.75rem);
|
|
101
|
+
transition: color 150ms, background-color 150ms, border-color 150ms, box-shadow 150ms;
|
|
102
|
+
width: 100%;
|
|
103
|
+
}
|
|
104
|
+
.amos-js-plaid-panel[data-mode="linked"] .amos-js-plaid-connect {
|
|
105
|
+
display: none;
|
|
106
|
+
}
|
|
107
|
+
.amos-js-plaid-connect:hover:not(:disabled) {
|
|
108
|
+
background: var(--accent, oklch(0.97 0 0));
|
|
109
|
+
color: var(--accent-foreground, oklch(0.205 0 0));
|
|
110
|
+
}
|
|
111
|
+
.amos-js-plaid-connect:focus-visible {
|
|
112
|
+
border-color: var(--ring, oklch(0.708 0 0));
|
|
113
|
+
box-shadow:
|
|
114
|
+
var(--input-shadow, 0 1px 2px 0 rgb(0 0 0 / 0.05)),
|
|
115
|
+
0 0 0 var(--ring-width, 3px)
|
|
116
|
+
color-mix(in oklab, var(--ring, oklch(0.708 0 0)) 50%, transparent);
|
|
117
|
+
}
|
|
118
|
+
.amos-js-plaid-connect:disabled {
|
|
119
|
+
cursor: default;
|
|
120
|
+
opacity: 0.5;
|
|
121
|
+
pointer-events: none;
|
|
122
|
+
}
|
|
123
|
+
.amos-js-plaid-linked {
|
|
124
|
+
display: none;
|
|
125
|
+
flex-direction: column;
|
|
126
|
+
gap: 0.25rem;
|
|
127
|
+
}
|
|
128
|
+
.amos-js-plaid-panel[data-mode="linked"] .amos-js-plaid-linked {
|
|
129
|
+
display: flex;
|
|
130
|
+
}
|
|
131
|
+
.amos-js-plaid-linked-name {
|
|
132
|
+
font-size: var(--input-font-size, 0.875rem);
|
|
133
|
+
font-weight: 500;
|
|
134
|
+
}
|
|
135
|
+
.amos-js-plaid-linked-meta {
|
|
136
|
+
color: var(--muted-foreground, oklch(0.556 0 0));
|
|
137
|
+
font-size: 0.75rem;
|
|
138
|
+
}
|
|
139
|
+
.amos-js-plaid-disconnect {
|
|
140
|
+
align-self: flex-start;
|
|
141
|
+
background: none;
|
|
142
|
+
border: none;
|
|
143
|
+
border-radius: calc(var(--radius, 0.625rem) * 0.8);
|
|
144
|
+
color: var(--muted-foreground, oklch(0.556 0 0));
|
|
145
|
+
cursor: pointer;
|
|
146
|
+
font: inherit;
|
|
147
|
+
font-size: var(--input-font-size, 0.875rem);
|
|
148
|
+
margin-top: 0.25rem;
|
|
149
|
+
outline: none;
|
|
150
|
+
padding: 0;
|
|
151
|
+
}
|
|
152
|
+
.amos-js-plaid-disconnect:hover {
|
|
153
|
+
color: var(--accent-foreground, oklch(0.205 0 0));
|
|
154
|
+
}
|
|
155
|
+
.amos-js-plaid-disconnect:focus-visible {
|
|
156
|
+
box-shadow:
|
|
157
|
+
0 0 0 var(--ring-width, 3px)
|
|
158
|
+
color-mix(in oklab, var(--ring, oklch(0.708 0 0)) 50%, transparent);
|
|
159
|
+
}
|
|
160
|
+
.amos-js-plaid-error {
|
|
161
|
+
color: var(--destructive, oklch(0.577 0.245 27.325));
|
|
162
|
+
display: none;
|
|
163
|
+
font-size: var(--error-font-size, 0.875rem);
|
|
164
|
+
margin: 0;
|
|
165
|
+
}
|
|
166
|
+
.amos-js-plaid-error:not(:empty) {
|
|
167
|
+
display: block;
|
|
168
|
+
}
|
|
169
|
+
@media (prefers-reduced-motion: reduce) {
|
|
170
|
+
.amos-js-plaid-connect {
|
|
171
|
+
transition: none;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
`;function ge(){if(document.getElementById(me))return;let e=document.createElement(`style`);e.id=me,e.textContent=he,document.head.append(e)}function _e(e,t,n){for(let t of n)e.style.removeProperty(t);n.length=0;let r=t?.themeVariables;if(r)for(let[t,i]of Object.entries(r))typeof i==`string`&&i.trim()!==``&&(e.style.setProperty(t,i.trim()),n.push(t))}function ve({host:e,iframe:t,options:n}){ge();let r={...n},i=[],a=!1,s,l=!1,u,d=!1,f,p,m=new AbortController,h,g=document.createElement(`div`);g.className=`amos-js-plaid-panel`,g.setAttribute(`data-amos-plaid-panel`,`true`),g.dataset.mode=`hidden`,_e(g,r.appearance,i);let _=document.createElement(`button`);_.type=`button`,_.className=`amos-js-plaid-connect`,_.textContent=`Connect bank account`,_.setAttribute(`data-testid`,`amos-plaid-connect`);let v=document.createElement(`div`);v.className=`amos-js-plaid-linked`;let y=document.createElement(`span`);y.className=`amos-js-plaid-linked-name`;let b=document.createElement(`span`);b.className=`amos-js-plaid-linked-meta`;let x=document.createElement(`button`);x.type=`button`,x.className=`amos-js-plaid-disconnect`,x.textContent=`Disconnect`,x.setAttribute(`aria-label`,`Disconnect bank account`);let S=document.createElement(`p`);S.className=`amos-js-plaid-error`,S.setAttribute(`role`,`alert`),v.append(y,b,x),g.append(_,v,S),e.append(g);let C=t.parentElement;function w(e){S.textContent=e??``}function T(){return a?l?!0:Y({amount:ce(r.amount),achThreshold:s}):!1}function E(){let e=!!h;f!==e&&(f=e,r.onValidityChange?.({isValid:e}))}function D(){let e=T();if(o(t,{requiresVerification:e,plaid:e?h?.credentials:void 0,clearLinked:O}),!e){g.dataset.mode=`hidden`,C&&(C.style.display=``),f=void 0;return}g.dataset.mode=h?`linked`:`connect`,C&&(C.style.display=`none`),h&&(y.textContent=h.bankName,b.textContent=h.last4?`****${h.last4}`:`Connected`),E()}function O(){h=void 0,u=void 0,p?.(),p=void 0,w(void 0),D()}function k(e){if(e.source===t.contentWindow&&e.data.type===`ACH_THRESHOLD`){if(a=!0,s=e.data.achThreshold??void 0,l=e.data.requireVerification===!0,h&&!T()){O();return}D()}}return window.addEventListener(`message`,k),D(),x.addEventListener(`click`,()=>{O()}),_.addEventListener(`click`,()=>{(async()=>{if(!(m.signal.aborted||d)){d=!0,_.disabled=!0,w(void 0);try{if(u||=await ee({iframe:t}),m.signal.aborted)return;let e=u;p?.(),p=await pe({token:e,signal:m.signal,onSuccess:(e,t)=>{if(m.signal.aborted)return;let n=le(t);if(!n){w(`Select a bank account to continue.`);return}let r=ue(t);h={credentials:{public_token:e,account_id:n},bankName:r.bankName,last4:r.last4},u=void 0,D()},onExit:e=>{m.signal.aborted||e?.error_code===`INVALID_LINK_TOKEN`&&(u=void 0)}}),m.signal.aborted&&(p(),p=void 0)}catch(e){if(u=void 0,m.signal.aborted)return;w(e instanceof Error?e.message:`Could not connect bank.`)}finally{d=!1,m.signal.aborted||(_.disabled=!1)}}})()}),{update(e){if(`amount`in e&&(r.amount=e.amount),`onValidityChange`in e&&(r.onValidityChange=e.onValidityChange),`appearance`in e&&(r.appearance=e.appearance,_e(g,r.appearance,i)),h&&!T()){O();return}D()},destroy(){m.abort(),window.removeEventListener(`message`,k),p?.(),p=void 0,c(t),g.remove()}}}function Z(e){if(typeof e==`string`){let t=document.querySelector(e);if(!(t instanceof HTMLElement))throw Error(`[amos-js] Container "${e}" did not match any HTMLElement.`);return t}return e}var ye={width:`calc(100% + 8px)`,transition:`opacity 150ms ease-in, height 200ms ease-in-out`,margin:`0 -4px`,opacity:`0`,border:`0`},be={width:`100%`,transition:`height 200ms ease-in-out`,margin:`0`,opacity:`0`,border:`0`},xe={position:`absolute`,top:`0`,left:`0`,width:`100%`,height:`100%`,margin:`0`,opacity:`0`,transition:`none`,pointerEvents:`none`},Se={position:`absolute`,top:`0`,left:`-4px`,width:`calc(100% + 8px)`,height:`100%`,margin:`0`,transition:`none`,pointerEvents:`none`};function Q({src:e,title:t,name:n,height:r,allow:i,className:a,style:o=ye}){let s=document.createElement(`iframe`);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}function Ce({host:e,iframe:t,listenerOptions:n,skeletonOptions:r}){let i=document.createElement(`div`);i.style.position=`relative`,i.style.width=`100%`,i.setAttribute(`aria-busy`,`true`);let a=ae(r);Object.assign(t.style,Se),i.append(a.element,t),e.appendChild(i);let o=!1,s=!1,c,l=r.appearance,u,d;function f(){return i.getBoundingClientRect().height}function p(){return c?Number.parseFloat(c):NaN}function m(){if(o)return;o=!0,d!==void 0&&(clearTimeout(d),d=void 0);let e=f(),n=p(),r=Number.isFinite(n)?Math.max(n,e):e;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(()=>{t.style.transition=`height 200ms ease-in-out`},400)}function h(){if(o||!s)return;let e=p(),t=f();Number.isFinite(e)&&e>=t-2&&m()}let g=q(t,{...n,onHeightChange:e=>{c=e,o?t.style.height=e:h(),n.onHeightChange?.(e)},onAppearanceReady:()=>{s=!0,h(),!o&&d===void 0&&(d=setTimeout(()=>{m()},1500)),n.onAppearanceReady?.()}});return{iframe:t,update(e){g.update(e),!o&&`appearance`in e&&(l=e.appearance,a.update({...r,appearance:l}))},destroy(){u!==void 0&&clearTimeout(u),d!==void 0&&clearTimeout(d),g.destroy(),i.remove()}}}function $({host:e,iframe:t,listenerOptions:n,iframeStyle:r,attachListeners:i}){let a={height:n.height??`48px`,borderRadius:L({iframeStyle:r,buttonProps:n.buttonProps})},o=F(a),s=document.createElement(`div`);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);let c=!1,l=!1,u,d=n;function f(){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`))}function p(){c||!l||f()}let m=i(t,{...n,onHeightChange:e=>{d.onHeightChange?.(e)},onAppearanceReady:()=>{l=!0,p(),d.onAppearanceReady?.()}});return u=setTimeout(()=>{f()},1500),{iframe:t,update(e){d={...d,...e};let t={...e};delete t.onAppearanceReady,delete t.onHeightChange,m.update(t),a={height:d.height??a.height,borderRadius:L({iframeStyle:r,buttonProps:d.buttonProps})},s.style.height=a.height,c||o.update(a)},destroy(){u!==void 0&&clearTimeout(u),m.destroy(),s.remove()}}}function we(e,t){let n=Z(e),{renderToken:r,additionalFields:i={cardholderName:!1},billingAddressRequirement:a=`country`,...o}=t;return Ce({host:n,iframe:Q({src:U(r,i,a),title:`Secure credit card payment method form powered by Amos`,name:`amos-credit-card-payment-method-form`,height:G(i,a)}),listenerOptions:o,skeletonOptions:{kind:`card`,appearance:o.appearance,additionalFields:i,billingAddressRequirement:a}})}function Te(e,t){let n=Z(e),{renderToken:r,billingAddressRequirement:i=`country`,amount:a,...o}=t,s=Q({src:W(r,i),title:`Secure bank account payment method form powered by Amos`,name:`amos-bank-account-payment-method-form`,height:K(i)}),c=Ce({host:n,iframe:s,listenerOptions:o,skeletonOptions:{kind:`bank`,appearance:o.appearance,billingAddressRequirement:i}}),l=ve({host:n,iframe:s,options:{amount:a,appearance:o.appearance,onValidityChange:o.onValidityChange}});return{iframe:s,update(e){c.update(e),l.update(e)},destroy(){l.destroy(),c.destroy()}}}function Ee(e,t){let n=Z(e),{renderToken:r,iframeClassName:i,iframeStyle:a,...o}=t,s=Q({src:R(r),title:`Secure Google Pay button powered by Amos`,name:`amos-google-pay-button`,height:o.height??z(),allow:`payment`,className:i,style:be});return Object.assign(s.style,a),$({host:n,iframe:s,listenerOptions:o,iframeStyle:a,attachListeners:B})}function De(e,t){let n=Z(e),{renderToken:r,iframeClassName:i,iframeStyle:a,...o}=t,s=Q({src:T(r),title:`Secure Apple Pay button powered by Amos`,name:`amos-apple-pay-button`,height:o.height??E(),allow:`payment`,className:i,style:be});return Object.assign(s.style,a),$({host:n,iframe:s,listenerOptions:o,iframeStyle:a,attachListeners:O})}exports.SKELETON_STYLES=ne,exports.attachApplePayButtonListeners=O,exports.attachGooglePayButtonListeners=B,exports.attachPaymentMethodFormListeners=q,exports.confirmPaymentIntent=S,exports.confirmSetupIntent=C,exports.createMessage=l,exports.createPaymentMethodFormSkeleton=ae,exports.createWalletButtonSkeleton=F,exports.decodeJwt=r,exports.ensureSkeletonStyles=A,exports.formatGooglePayPaymentData=oe,exports.getApplePayButtonInitialHeight=E,exports.getApplePayButtonSrc=T,exports.getBankAccountFormInitialHeight=K,exports.getBankAccountFormSrc=W,exports.getCreditCardFormInitialHeight=G,exports.getCreditCardFormSrc=U,exports.getEmbedOrigin=i,exports.getGooglePayButtonInitialHeight=z,exports.getGooglePayButtonSrc=R,exports.linkedBankLabelFromMetadata=ue,exports.loadPlaidScript=fe,exports.mountAmosApplePayButton=De,exports.mountAmosBankAccountPaymentMethodForm=Te,exports.mountAmosCreditCardPaymentMethodForm=we,exports.mountAmosGooglePayButton=Ee,exports.openPlaidLink=pe,exports.plaidAccountIdFromMetadata=le,exports.requiresAchVerification=Y,exports.resetForm=y,exports.resolveWalletButtonSkeletonBorderRadius=L,exports.sendConfirmationResult=w,exports.sendParentReadyMessage=d,exports.updateAmount=h,exports.updateAppearance=f,exports.updateApplePayButton=p,exports.updateGooglePayButton=m,exports.updateMerchantName=g,exports.validateForm=_;
|