@maytes/checkout-button 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#11](https://github.com/kttipay/maytes-checkout-button/pull/11) [`def33e0`](https://github.com/kttipay/maytes-checkout-button/commit/def33e010bf23b11bc94871e236d35a65deb825e) Thanks [@kos-maytes](https://github.com/kos-maytes)! - `renderButton`'s default `mode` is now `'popup'` instead of `'redirect'`. Pass `mode: 'redirect'` explicitly to keep the previous same-window navigation behavior. Popup mode already falls back to same-window redirect on mobile viewports and when the popup is blocked, so this only changes the desktop no-`mode`-specified path.
8
+
9
+ - [#8](https://github.com/kttipay/maytes-checkout-button/pull/8) [`a6d85e2`](https://github.com/kttipay/maytes-checkout-button/commit/a6d85e23653e340b7a850ad61e882ec2f6cef5d2) Thanks [@kttipaydiogocavaiar](https://github.com/kttipaydiogocavaiar)! - The button never loads the hosted checkout inside an iframe any more. When the button is rendered inside a frame (for example a booking widget embedded on the merchant's page), a phone or a narrow frame used to take the same-window fallback and navigate the frame itself, so the checkout ran as a cross-site iframe where its session cookie is rejected and sign-in ended on "Your session expired". The button now measures the top-level window (or the screen when the top window is cross-origin) and navigates the top-level window; if the browser refuses, it opens the checkout in a new tab; if both are refused, it dispatches `maytes:checkout-failed` with `reason: 'navigation-blocked'` and leaves the button usable. `maytes:checkout-redirected` now carries `detail.target` (`'self' | 'top' | 'tab'`). `redirectToCheckout()` follows the same rule and throws `MaytesError` when it cannot leave the frame. Merchants who deliberately relied on in-frame navigation will see the top-level page change instead; render the button in the top-level page if that is not wanted.
10
+
11
+ <!-- @hash-sri-start -->
12
+
13
+ **SRI hashes** (use these in `<script integrity="..." crossorigin="anonymous">`):
14
+
15
+ ```
16
+ checkout-button.js sha384-+hQ9khxZbVEUhR685659hqmPyN/3RYfbNEI7itac3SkcyYor/94/0mIwVnVwMa8M
17
+ checkout-button.mjs sha384-1areqNcTs9sephTl6S1+sOgACv1/NqIqXBG0Ej11/4OfSDcN92GvQvhhu4K76R5i
18
+ checkout-button.cjs sha384-4c1JuweT47cnpvGlQfv+qQw/3CS+7o2/Dg4qQnLiWM1GDChhHQo0dT+z8705Hy50
19
+ ```
20
+
21
+ **SemVer CDN links** (readable production pins; use with the SRI hashes above):
22
+
23
+ - [checkout-button.js](https://js.maytes.co/v1.1.0/checkout-button.js)
24
+ - [checkout-button.mjs](https://js.maytes.co/v1.1.0/checkout-button.mjs)
25
+ - [checkout-button.cjs](https://js.maytes.co/v1.1.0/checkout-button.cjs)
26
+
27
+ **Hashed CDN links** (byte-level production pins; use with the SRI hashes above):
28
+
29
+ - [checkout-button.811263f9.js](https://js.maytes.co/checkout-button.811263f9.js)
30
+ - [checkout-button.f96c49ee.mjs](https://js.maytes.co/checkout-button.f96c49ee.mjs)
31
+ - [checkout-button.178d8394.cjs](https://js.maytes.co/checkout-button.178d8394.cjs)
32
+
33
+ <!-- @hash-sri-end -->
3
34
  ## 1.0.1
4
35
 
5
36
  ### Patch Changes
@@ -29,6 +60,7 @@ checkout-button.cjs sha384-+O2S6KfO4Pc0VEvL+kTsFzxU14W4EILV6+U5mAdW8X43Xm8Qk1aV
29
60
  - [checkout-button.6d259930.cjs](https://js.maytes.co/checkout-button.6d259930.cjs)
30
61
 
31
62
  <!-- @hash-sri-end -->
63
+
32
64
  ## 1.0.0
33
65
 
34
66
  First public release on npm.
package/README.md CHANGED
@@ -18,14 +18,14 @@
18
18
 
19
19
  ---
20
20
 
21
- Renders a button and launches the Maytes-hosted checkout. Default mode is same-window redirect; `mode: 'popup'` opts desktop browsers into a centered popup with a branded loader and redirect fallback on mobile or when blocked.
21
+ Renders a button and launches the Maytes-hosted checkout in the top-level window. Default mode opens a centered popup on wide viewports, with a branded loader and automatic redirect fallback on phones or when the popup is blocked; `mode: 'redirect'` opts into a redirect always. Inside an iframe every redirect targets the top-level window.
22
22
 
23
23
  **📖 Full integration guide:** [developers.maytes.co/checkout-button](https://developers.maytes.co/checkout-button)
24
24
 
25
25
  - **Framework-agnostic** — same factory whether it's a `<script>` tag or `import { Maytes }`; no React/Vue/Angular binding to keep in sync.
26
26
  - **Zero runtime dependencies** — a small, dependency-free bundle; ESM/CJS ship unminified so your bundler can tree-shake it.
27
27
  - **CSP-safe by construction** — no `eval`, `Function`, or string-form timers; every release is scanned for it before shipping.
28
- - **SRI-verified CDN** — pin a release by SemVer or content hash, both carrying the same integrity hash, published alongside every release.
28
+ - **Evergreen CDN by default** — the recommended `<script>` tag always serves the newest release; pin a SemVer or content-hash URL instead if you'd rather freeze on a tested build.
29
29
  - **Signed provenance** — every npm release carries a [SLSA](https://slsa.dev) provenance attestation back to this repo's build.
30
30
 
31
31
  ## Contents
@@ -40,23 +40,46 @@ Renders a button and launches the Maytes-hosted checkout. Default mode is same-w
40
40
 
41
41
  ### Script tag (CDN)
42
42
 
43
- For production, pin an exact release. The readable SemVer URL and the content-hash URL are two names for the **same release bytes** and share the **same SRI value** — pick either:
43
+ | | Evergreen (recommended) | Pinned |
44
+ |---|---|---|
45
+ | **Use when** | Default — always get the newest `1.x` release | You'd rather freeze on a tested build |
46
+ | **Guarantee** | Always current; a bad release reaches you immediately | The bytes you tested are the bytes shipped, forever |
47
+ | **SRI** | Not possible | Yes |
48
+
49
+ ### Evergreen (recommended)
44
50
 
45
51
  ```html
46
- <script src="https://js.maytes.co/v1.0.0/checkout-button.js"
47
- integrity="sha384-…"
52
+ <script src="https://js.maytes.co/v1/checkout-button.js"
48
53
  crossorigin="anonymous"></script>
49
54
  ```
50
55
 
56
+ No `integrity` attribute is possible here — the bytes change without notice as new `1.x` releases ship. Trust the origin via CSP instead:
57
+
58
+ ```
59
+ Content-Security-Policy: script-src 'self' https://js.maytes.co;
60
+ ```
61
+
62
+ `/v1/` tracks the newest `1.x` release only; it won't jump to a future `2.x` (move to `/v2/checkout-button.js` explicitly once that ships). Poll `https://js.maytes.co/integrity.json` if you want to detect changes yourself.
63
+
64
+ ### Pinned (SemVer or content hash)
65
+
66
+ For a guarantee instead of convenience — freeze on a tested build, update on your own schedule:
67
+
68
+ <!-- @cdn-example-start -->
51
69
  ```html
52
- <script src="https://js.maytes.co/checkout-button.795d508b.js"
70
+ <script src="https://js.maytes.co/v1.1.0/checkout-button.js"
53
71
  integrity="sha384-…"
54
72
  crossorigin="anonymous"></script>
55
73
  ```
56
74
 
57
- `v1.0.0` / `795d508b` are examples. The real version, hash, and SRI for each release live in [`CHANGELOG.md`](./CHANGELOG.md), the matching [release](https://github.com/kttipay/maytes-checkout-button/releases), and `https://js.maytes.co/integrity.json`.
75
+ ```html
76
+ <script src="https://js.maytes.co/checkout-button.811263f9.js"
77
+ integrity="sha384-…"
78
+ crossorigin="anonymous"></script>
79
+ ```
80
+ <!-- @cdn-example-end -->
58
81
 
59
- Use a pinned URL in every environment, development included — pinning is what makes the bytes you tested the bytes your shoppers get.
82
+ Both URLs are the same release bytes with the same SRI value — pick either. Full version/hash/SRI history: [`CHANGELOG.md`](./CHANGELOG.md), [releases](https://github.com/kttipay/maytes-checkout-button/releases), `https://js.maytes.co/integrity.json`. Pinned URLs never change once published.
60
83
 
61
84
  ### npm
62
85
 
@@ -81,8 +104,8 @@ const maytes = Maytes({
81
104
 
82
105
  const cleanup = maytes.renderButton(document.getElementById('slot'), { block: true });
83
106
 
84
- // Optional popup mode:
85
- maytes.renderButton(document.getElementById('popup-slot'), { block: true, mode: 'popup' });
107
+ // Opt into same-window redirect instead of the default popup:
108
+ maytes.renderButton(document.getElementById('redirect-slot'), { block: true, mode: 'redirect' });
86
109
 
87
110
  // Imperative alternatives:
88
111
  maytes.redirectToCheckout({ checkoutId });
@@ -100,11 +123,15 @@ Via the script tag, the same factory is available as the global `window.Maytes(.
100
123
  | Method | Purpose |
101
124
  |---|---|
102
125
  | `Maytes(options)` | Create an SDK instance. `options.createCheckout` mints a checkout server-side; `options.environment` selects the Maytes environment. |
103
- | `renderButton(container, options?)` | Render the button into `container`; returns a cleanup function. Options include `label`, `block`, and `mode: 'redirect' \| 'popup'`. |
126
+ | `renderButton(container, options?)` | Render the button into `container`; returns a cleanup function. Options include `label`, `block`, and `mode: 'redirect' \| 'popup'` (default `'popup'`). |
104
127
  | `redirectToCheckout(options)` | Launch checkout directly (no button). |
105
128
  | `checkoutUrl(options)` | Build the hosted checkout URL. |
106
129
  | `destroy()` | Tear down the instance and its listeners — call this on unmount or when the instance's config/environment changes, not as a reaction to detecting payment success from your own polling (that can tear down a checkout that's still in progress). To remove a single button, use the cleanup function returned by `renderButton()` or hide/disable the button element instead. |
107
130
 
131
+ ### Inside an iframe?
132
+
133
+ The hosted checkout must run in the top-level window (its session cookie is refused inside a cross-site frame). If you render the button inside an iframe, the SDK navigates the top-level window; if the browser refuses, it opens a new tab; if both are refused it dispatches `maytes:checkout-failed` with `reason: 'navigation-blocked'`. When the checkout opens in a new tab, no popup poll starts and no `maytes:checkout-opened` / `maytes:checkout-closed` pair fires — you'll only see `maytes:checkout-redirected` with `target: 'tab'`. A sandboxed iframe needs `allow-scripts allow-same-origin allow-top-navigation` (plus `allow-popups allow-popups-to-escape-sandbox` for the tab fallback). Listen to `maytes:checkout-redirected` and read `event.detail.target` (`'self'`, `'top'` or `'tab'`) if your page needs to know where the checkout went. Rendering the button in the top-level page avoids all of this.
134
+
108
135
  ## Mobile app
109
136
 
110
137
  After checkout, shoppers split the cost with friends using Maytes payment links (`app.maytes.co/…`). On a phone with the Maytes app installed, those links open directly in the app (iOS Universal Links / Android App Links); otherwise they open in the browser. Maytes handles this end to end — merchants integrate only the button and configure nothing for the app.
@@ -86,21 +86,79 @@ var MaytesError = class extends Error {
86
86
  }
87
87
  };
88
88
 
89
+ // src/framing.ts
90
+ function isSecurityError(err) {
91
+ return typeof err === "object" && err !== null && err.name === "SecurityError";
92
+ }
93
+ function isFramed() {
94
+ return window.top !== null && window.top !== window;
95
+ }
96
+ function sameOriginTop() {
97
+ if (!isFramed()) return null;
98
+ const top = window.top;
99
+ try {
100
+ void top.document;
101
+ return top;
102
+ } catch (err) {
103
+ if (!isSecurityError(err)) throw err;
104
+ return null;
105
+ }
106
+ }
107
+ function viewportWidth() {
108
+ if (!isFramed()) return window.innerWidth;
109
+ const top = sameOriginTop();
110
+ if (top !== null) return top.innerWidth;
111
+ const screenWidth = window.screen?.width;
112
+ return typeof screenWidth === "number" && screenWidth > 0 ? screenWidth : window.innerWidth;
113
+ }
114
+ function navigateWindow(target, url, replace) {
115
+ if (replace) {
116
+ target.location.replace(url);
117
+ } else {
118
+ target.location.href = url;
119
+ }
120
+ }
121
+ function severOpener(tab) {
122
+ try {
123
+ tab.opener = null;
124
+ } catch (err) {
125
+ if (!isSecurityError(err)) throw err;
126
+ }
127
+ }
128
+ function navigateTopLevel(url, replace) {
129
+ if (!isFramed()) {
130
+ navigateWindow(window, url, replace);
131
+ return { target: "self" };
132
+ }
133
+ let refusal;
134
+ try {
135
+ navigateWindow(window.top, url, replace);
136
+ return { target: "top" };
137
+ } catch (err) {
138
+ if (!isSecurityError(err)) throw err;
139
+ refusal = err;
140
+ }
141
+ try {
142
+ const tab = window.open(url, "_blank");
143
+ if (tab !== null) {
144
+ severOpener(tab);
145
+ return { target: "tab" };
146
+ }
147
+ return { target: null, cause: refusal };
148
+ } catch (err) {
149
+ return { target: null, cause: err };
150
+ }
151
+ }
152
+
89
153
  // src/overlay.ts
90
154
  var TITLE_ID = "maytes-overlay-title";
91
155
  var STYLE_MARKER = "data-maytes-checkout-button-overlay-styles";
92
156
  var NATIVE_BACKDROP_FALLBACK = "rgba(0, 0, 0, 0.6)";
93
157
  function tryReadTopDocument() {
94
- if (window.top === null || window.top === window) return null;
95
- try {
96
- const topDoc = window.top.document;
97
- return topDoc.body !== null ? topDoc : null;
98
- } catch (err) {
99
- if (!(err instanceof DOMException && err.name === "SecurityError")) {
100
- console.warn("[maytes/checkout-button] unexpected error resolving overlay host", err);
101
- }
102
- return null;
103
- }
158
+ const top = sameOriginTop();
159
+ if (top === null) return null;
160
+ const topDoc = top.document;
161
+ return topDoc.body !== null ? topDoc : null;
104
162
  }
105
163
  function resolveOverlayHost() {
106
164
  return tryReadTopDocument() ?? document;
@@ -148,7 +206,7 @@ function buildOverlay(host, state) {
148
206
  try {
149
207
  state.popupWindow.focus();
150
208
  } catch (err) {
151
- if (!(err instanceof DOMException && err.name === "SecurityError")) throw err;
209
+ if (!isSecurityError(err)) throw err;
152
210
  }
153
211
  }
154
212
  });
@@ -258,10 +316,12 @@ function performRedirect(url, replace) {
258
316
  "redirectToCheckout requires a browser context (window is undefined)"
259
317
  );
260
318
  }
261
- if (replace) {
262
- window.location.replace(url);
263
- } else {
264
- window.location.href = url;
319
+ const outcome = navigateTopLevel(url, replace);
320
+ if (outcome.target === null) {
321
+ throw new MaytesError(
322
+ MaytesErrorCode.Config,
323
+ "redirectToCheckout could not leave the embedding iframe; call it from a user gesture or from the top-level page"
324
+ );
265
325
  }
266
326
  }
267
327
  function makeRedirect(environment, baseUrlOverride) {
@@ -277,7 +337,7 @@ function makeRedirect(environment, baseUrlOverride) {
277
337
  }
278
338
 
279
339
  // src/version.ts
280
- var SDK_VERSION = "1.0.1";
340
+ var SDK_VERSION = "1.1.0";
281
341
 
282
342
  // src/styles.ts
283
343
  var STYLE_ATTR = "data-maytes-checkout-button";
@@ -488,9 +548,6 @@ function isValidCheckoutResult(value) {
488
548
  }
489
549
  return true;
490
550
  }
491
- function isSecurityError(err) {
492
- return err instanceof DOMException && err.name === "SecurityError";
493
- }
494
551
  function refocusPopup(popup) {
495
552
  try {
496
553
  popup.focus();
@@ -531,7 +588,7 @@ function startPopupPoll(state, onClose) {
531
588
  }, POPUP_POLL_INTERVAL_MS);
532
589
  }
533
590
  function isMobileViewport() {
534
- return window.innerWidth <= MOBILE_MAX_WIDTH;
591
+ return viewportWidth() <= MOBILE_MAX_WIDTH;
535
592
  }
536
593
  function openBlankPopup(state) {
537
594
  return window.open("about:blank", state.popupName, popupFeatures());
@@ -592,7 +649,7 @@ function renderButton(state, container, options = {}) {
592
649
  ensureStylesInjected(state.config.cspNonce);
593
650
  const label = options.label ?? "Split with";
594
651
  const block = options.block === true;
595
- const mode = options.mode ?? "redirect";
652
+ const mode = options.mode ?? "popup";
596
653
  if (mode !== "redirect" && mode !== "popup") {
597
654
  throw new MaytesError(
598
655
  MaytesErrorCode.Config,
@@ -633,13 +690,19 @@ function renderButton(state, container, options = {}) {
633
690
  detail: cause === void 0 ? { reason } : { reason, cause }
634
691
  }));
635
692
  };
636
- const dispatchRedirected = (url) => {
637
- document.dispatchEvent(new CustomEvent("maytes:checkout-redirected", { detail: { url } }));
693
+ const dispatchRedirected = (url, target) => {
694
+ const detail = { url, target };
695
+ document.dispatchEvent(new CustomEvent("maytes:checkout-redirected", { detail }));
638
696
  };
639
- const redirectSameWindow = (url) => {
697
+ const navigateAway = (url) => {
698
+ const outcome = navigateTopLevel(url, false);
640
699
  teardownActiveCheckout();
641
- dispatchRedirected(url);
642
- window.location.href = url;
700
+ if (outcome.target === null) {
701
+ console.error("[maytes/checkout-button] could not leave the embedding frame:", outcome.cause);
702
+ dispatchFailed("navigation-blocked", outcome.cause);
703
+ return;
704
+ }
705
+ dispatchRedirected(url, outcome.target);
643
706
  };
644
707
  const closeOrphanPopup = (popup) => {
645
708
  closePopupWindow(popup);
@@ -687,9 +750,9 @@ function renderButton(state, container, options = {}) {
687
750
  navigatePopup(popup, url);
688
751
  } else {
689
752
  if (shouldUsePopup) {
690
- console.warn("[maytes/checkout-button] popup was blocked; falling back to same-window redirect");
753
+ console.warn("[maytes/checkout-button] popup was blocked; redirecting instead");
691
754
  }
692
- redirectSameWindow(url);
755
+ navigateAway(url);
693
756
  }
694
757
  } catch (err) {
695
758
  if (popup !== null && popup.closed) return;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/foundation/brand.generated.ts","../src/branding.ts","../src/errors.ts","../src/framing.ts","../src/overlay.ts","../src/env.ts","../src/redirect.ts","../src/version.ts","../src/styles.ts","../src/button.ts","../src/state.ts","../src/maytes.ts"],"sourcesContent":["import { Maytes } from './maytes.js';\n\nif (typeof window !== 'undefined') {\n (window as unknown as { Maytes: typeof Maytes }).Maytes = Maytes;\n}\n\nexport { Maytes };\nexport { MaytesError, MaytesErrorCode } from './errors.js';\nexport type { MaytesErrorCodeValue } from './errors.js';\nexport type {\n CheckoutFailedDetail,\n CheckoutFailedReason,\n CheckoutRedirectedDetail,\n CheckoutUrlOptions,\n CreateCheckoutFn,\n MaytesEnvironment,\n MaytesFactory,\n MaytesInternalOptions,\n MaytesOptions,\n MaytesSDK,\n RedirectOptions,\n RedirectTarget,\n RenderButtonCleanup,\n RenderButtonMode,\n RenderButtonOptions,\n} from './types.js';\nexport { SDK_VERSION } from './version.js';\n","// GENERATED by scripts/sync-foundation-tokens.mjs from kttipay/designsystem v0.3.0 web/tokens.ts — DO NOT EDIT. Refresh: npm run sync:foundation -- --tag vX.Y.Z\n\n// Subset of the foundation used by the checkout button and the mock showcase:\n// brand.primary <- colorsLight.brand.primary (burgundy/600)\n// brand.secondary <- colorsLight.brand.secondary (orange/500)\n// palette.burgundy.700 <- palette.burgundy.700 (hover shade for brand.primary)\n// palette.base.white <- palette.base.white\n// text.primaryInverse <- colorsLight.text.primaryInverse (text on brand.primary)\n\nexport const FOUNDATION_TAG = 'v0.3.0';\n\nexport const foundation = {\n brand: {\n primary: '#4A0324',\n secondary: '#FE572A',\n },\n palette: {\n burgundy: {\n 700: '#3B021D',\n },\n base: {\n white: '#FFFFFF',\n },\n },\n text: {\n primaryInverse: '#FFFFFF',\n },\n} as const;\n","import { foundation } from './foundation/brand.generated.js';\n\nexport const MAYTES_RICHE = foundation.brand.primary;\nexport const MAYTES_WALLET = foundation.brand.secondary;\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\n\nconst MAYTES_LOGO_PATHS: readonly string[] = [\n 'M392,6.11c-.3-1.61-1.72-2.79-3.38-2.79h-99.97c-1.66,0-3.09,1.19-3.38,2.79l-51.14,275.49c-.36,2.07,1.24,4.03,3.38,4.03h71.07c1.72,0,3.15-1.24,3.38-2.97l5.57-42.24c.23-1.72,1.66-2.97,3.38-2.97h32.45c1.72,0,3.15,1.24,3.38,2.97l5.57,42.24c.23,1.72,1.66,2.97,3.38,2.97h74.46c2.14,0,3.8-1.96,3.38-4.03L392,6.11ZM344.42,174.89h-14.59c-2.07,0-3.62-1.84-3.38-3.86l9.55-74.33c.06-.48.48-.83.95-.83s.89.35.95.83l9.91,74.33c.3,2.02-1.31,3.86-3.38,3.86h0Z',\n 'M218.86,3.32h-77.72c-1.48,0-2.85,1.01-3.27,2.44l-25.63,83.65c-.12.35-.41.6-.83.6s-.71-.23-.83-.6L84.9,5.76c-.41-1.42-1.78-2.44-3.27-2.44H3.44c-1.9,0-3.44,1.54-3.44,3.44v275.43c0,1.9,1.54,3.45,3.44,3.45h71.26c1.9,0,3.44-1.54,3.44-3.45v-77.3l-.83-51.44c0-.53.41-.95.95-.95.41,0,.77.3.89.71l14.42,59.62c.35,1.54,1.72,2.61,3.32,2.61h28.42c1.61,0,2.97-1.06,3.32-2.61l14.47-59.79c.12-.3.35-.53.71-.53.41,0,.71.3.71.71l-.42,51.67-.06.06v77.3c0,1.9,1.54,3.44,3.44,3.44h71.37c1.9,0,3.44-1.54,3.44-3.44V6.77c0-1.9-1.54-3.44-3.44-3.44h0Z',\n 'M1179.6,147c-9.73-11.8-20.71-21.12-47.76-38.44-27.06-16.91-31.69-23.26-31.69-31.68,0-6.76,3.8-11.39,10.56-11.39,8.19,0,14.18,10.44,15.43,26.28.18,2.14,2.13,3.74,4.27,3.26l63.66-14.12c1.6-.36,2.73-1.9,2.61-3.56-3.97-49.3-35-77.36-86.44-77.36-27.47,0-50.25,8.07-67.63,24.09-17.39,16.01-25.82,36.72-25.82,62.53,0,16.91,4.22,32.09,13.12,45.62,8.9,13.53,25.75,28.3,51.56,44.38,14.77,9.32,24.09,16.49,27.88,21.12,4.21,4.63,6.35,9.31,6.35,14.36,0,6.35-4.63,10.56-11.81,10.56-10.5,0-18.15-11.87-19.28-29.66-.12-2.25-2.31-3.91-4.51-3.26l-63.6,18.68c-1.55.42-2.55,1.84-2.43,3.44,1.78,22.84,11.03,41.41,26.88,55.65,16.49,14.36,36.77,21.53,64.24,21.53s50.32-7.59,67.64-23.26c17.74-15.66,26.64-36.37,26.64-61.28,0-22.01-6.35-40.58-19.87-57.49v-.02Z',\n 'M1002.33,3.32h-146.18c-1.9,0-3.44,1.54-3.44,3.44v275.49c0,1.9,1.54,3.44,3.44,3.44h146.18c1.9,0,3.44-1.54,3.44-3.44v-62.05c0-1.9-1.54-3.44-3.44-3.44h-63.3c-1.9,0-3.45-1.54-3.45-3.45v-34.58c0-1.9,1.54-3.44,3.45-3.44v.18h53.63c1.9,0,3.45-1.54,3.45-3.44v-57.84c0-1.9-1.55-3.44-3.45-3.44h-53.63c-1.9,0-3.45-1.54-3.45-3.44v-31.61c0-1.9,1.54-3.44,3.45-3.44h63.3c1.9,0,3.44-1.54,3.44-3.44V6.77c0-1.9-1.54-3.44-3.44-3.44Z',\n 'M840.22,6.77c0-1.9-1.54-3.44-3.44-3.44h-175.31c-1.9,0-3.45,1.54-3.45,3.44v62c0,1.9,1.54,3.44,3.45,3.44h41.77c1.9,0,3.44,1.54,3.44,3.44v206.62c0,1.9,1.54,3.45,3.44,3.45h78.14c1.9,0,3.45-1.54,3.45-3.45V75.7c0-1.9,1.54-3.44,3.45-3.44h41.77c1.9,0,3.44-1.54,3.44-3.44h-.12V6.77h-.02Z',\n 'M607.71,3.38l-.06-.06c-23.23,0-32.59,48.08-40.22,80.25-1.38,5.82-4.74,18.31-7.75,27.31-4.44,13.26-10.68,30.43-22.21,31.93-18.85,2.47-7.14-39.43-7.14-39.43l21.67-92.98c.84-3.6-1.92-7.02-5.58-7.02h-85.49c-3.12,0-5.64,2.46-5.71,5.64l-1.68,75.09c-.48,21.25,5.64,42.31,18.37,59.37,12.72,17.05,38.81,28,63.12,25.9,52.48-7.08,65.46-70.49,68.4-71.1,3.06-.64,2.56,9.3.84,22.15-2.2,16.42-8.46,32.1-18.52,45.27-5.3,6.95-11.13,12.9-16.55,16.37-32.96,22.51-95.69,9.48-122.4-2.7-3.66-1.68-7.75,1.02-7.75,5.04l16.39,83.98c0,.84.18,1.68.54,2.4,9.48,17.83,53.31,19.33,74.43,17.77,32.18-2.04,100.37-29.35,115.32-122.33,12.17-103.08-1.14-162.91-38.06-162.84l.02-.02Z',\n];\n\nexport function buildMaytesLogo(height: string, color: string): SVGSVGElement {\n const svg = document.createElementNS(SVG_NS, 'svg');\n svg.setAttribute('xmlns', SVG_NS);\n svg.setAttribute('viewBox', '0 0 1199.47 289.04');\n svg.style.height = height;\n svg.style.width = 'auto';\n svg.style.color = color;\n for (const d of MAYTES_LOGO_PATHS) {\n const path = document.createElementNS(SVG_NS, 'path');\n path.setAttribute('fill', 'currentColor');\n path.setAttribute('d', d);\n svg.appendChild(path);\n }\n return svg;\n}\n","export const MaytesErrorCode = {\n Config: 'CONFIG',\n} as const;\n\nexport type MaytesErrorCodeValue = (typeof MaytesErrorCode)[keyof typeof MaytesErrorCode];\n\nexport class MaytesError extends Error {\n readonly code: MaytesErrorCodeValue;\n\n constructor(code: MaytesErrorCodeValue, message: string) {\n super(message);\n this.code = code;\n this.name = 'MaytesError';\n }\n}\n","import type { RedirectTarget } from './types.js';\n\nexport interface NavigationOutcome {\n target: RedirectTarget | null;\n cause?: unknown;\n}\n\nexport function isSecurityError(err: unknown): boolean {\n return typeof err === 'object' && err !== null && (err as { name?: unknown }).name === 'SecurityError';\n}\n\nexport function isFramed(): boolean {\n return window.top !== null && window.top !== window;\n}\n\nexport function sameOriginTop(): Window | null {\n if (!isFramed()) return null;\n const top = window.top as Window;\n try {\n void top.document;\n return top;\n } catch (err) {\n if (!isSecurityError(err)) throw err;\n return null;\n }\n}\n\nexport function viewportWidth(): number {\n if (!isFramed()) return window.innerWidth;\n const top = sameOriginTop();\n if (top !== null) return top.innerWidth;\n const screenWidth = window.screen?.width;\n return typeof screenWidth === 'number' && screenWidth > 0 ? screenWidth : window.innerWidth;\n}\n\nfunction navigateWindow(target: Window, url: string, replace: boolean): void {\n if (replace) {\n target.location.replace(url);\n } else {\n target.location.href = url;\n }\n}\n\nfunction severOpener(tab: Window): void {\n try {\n tab.opener = null;\n } catch (err) {\n if (!isSecurityError(err)) throw err;\n }\n}\n\nexport function navigateTopLevel(url: string, replace: boolean): NavigationOutcome {\n if (!isFramed()) {\n navigateWindow(window, url, replace);\n return { target: 'self' };\n }\n let refusal: unknown;\n try {\n navigateWindow(window.top as Window, url, replace);\n return { target: 'top' };\n } catch (err) {\n if (!isSecurityError(err)) throw err;\n refusal = err;\n }\n try {\n const tab = window.open(url, '_blank');\n if (tab !== null) {\n severOpener(tab);\n return { target: 'tab' };\n }\n return { target: null, cause: refusal };\n } catch (err) {\n return { target: null, cause: err };\n }\n}\n","import { buildMaytesLogo, MAYTES_WALLET } from './branding.js';\nimport { isSecurityError, sameOriginTop } from './framing.js';\nimport type { InstanceState } from './state.js';\n\nconst TITLE_ID = 'maytes-overlay-title';\nconst STYLE_MARKER = 'data-maytes-checkout-button-overlay-styles';\nconst NATIVE_BACKDROP_FALLBACK = 'rgba(0, 0, 0, 0.6)';\n\nfunction tryReadTopDocument(): Document | null {\n const top = sameOriginTop();\n if (top === null) return null;\n const topDoc = top.document;\n return topDoc.body !== null ? topDoc : null;\n}\n\nfunction resolveOverlayHost(): Document {\n return tryReadTopDocument() ?? document;\n}\n\nfunction ensureOverlayStylesInTopDocument(host: Document): void {\n if (host === document) return;\n if (host.querySelector(`style[${STYLE_MARKER}]`) !== null) return;\n const localStyle = document.head.querySelector('style[data-maytes-checkout-button]');\n if (localStyle === null) return;\n const copy = host.createElement('style');\n copy.setAttribute(STYLE_MARKER, '');\n const nonce = localStyle.getAttribute('nonce');\n if (nonce !== null) copy.setAttribute('nonce', nonce);\n copy.textContent = localStyle.textContent ?? '';\n host.head.appendChild(copy);\n}\n\nfunction buildOverlay(host: Document, state: InstanceState): HTMLDialogElement {\n const dialog = host.createElement('dialog');\n dialog.className = 'maytes-checkout-overlay';\n dialog.setAttribute('aria-labelledby', TITLE_ID);\n dialog.setAttribute('data-maytes-overlay', '');\n\n const content = host.createElement('div');\n content.className = 'maytes-checkout-overlay__content';\n\n const logoDiv = host.createElement('div');\n logoDiv.setAttribute('aria-hidden', 'true');\n logoDiv.appendChild(buildMaytesLogo('2.5rem', MAYTES_WALLET));\n content.appendChild(logoDiv);\n\n const spinner = host.createElement('div');\n spinner.className = 'maytes-checkout-overlay__spinner';\n spinner.setAttribute('role', 'status');\n spinner.setAttribute('aria-live', 'polite');\n spinner.setAttribute('aria-label', 'Checkout in progress');\n content.appendChild(spinner);\n\n const text = host.createElement('p');\n text.id = TITLE_ID;\n text.className = 'maytes-checkout-overlay__text';\n text.textContent = 'Completing checkout with Maytes…';\n content.appendChild(text);\n\n const link = host.createElement('button');\n link.className = 'maytes-checkout-overlay__link';\n link.type = 'button';\n link.textContent = 'Return to Maytes';\n link.addEventListener('click', () => {\n if (state.popupWindow !== null && !state.popupWindow.closed) {\n try { state.popupWindow.focus(); } catch (err) {\n if (!isSecurityError(err)) throw err;\n }\n }\n });\n content.appendChild(link);\n\n dialog.appendChild(content);\n\n dialog.addEventListener('cancel', (event) => {\n event.preventDefault();\n if (state.popupWindow !== null && !state.popupWindow.closed) state.popupWindow.close();\n hideOverlay(state);\n });\n\n return dialog;\n}\n\nfunction applyNativeBackdropFallback(dialog: HTMLDialogElement): void {\n dialog.style.background = NATIVE_BACKDROP_FALLBACK;\n}\n\nexport function showOverlay(state: InstanceState): void {\n if (state.overlayEl !== null) return;\n const host = resolveOverlayHost();\n ensureOverlayStylesInTopDocument(host);\n const dialog = buildOverlay(host, state);\n state.overlayEl = dialog;\n host.body.appendChild(dialog);\n if (typeof dialog.showModal === 'function') {\n try {\n dialog.showModal();\n } catch (err) {\n console.warn('[maytes/checkout-button] dialog.showModal failed; falling back to inline backdrop', err);\n dialog.setAttribute('open', '');\n applyNativeBackdropFallback(dialog);\n }\n } else {\n dialog.setAttribute('open', '');\n applyNativeBackdropFallback(dialog);\n }\n}\n\nexport function hideOverlay(state: InstanceState): void {\n if (state.overlayEl === null) return;\n const dialog = state.overlayEl;\n const host = dialog.ownerDocument;\n if (typeof dialog.close === 'function' && dialog.open) dialog.close();\n dialog.remove();\n if (host !== document) {\n host.head.querySelector(`style[${STYLE_MARKER}]`)?.remove();\n }\n state.overlayEl = null;\n}\n","import { MaytesError, MaytesErrorCode } from './errors.js';\nimport type { MaytesEnvironment } from './types.js';\n\nexport type InternalEnvironment = MaytesEnvironment | 'staging';\n\nconst ENVIRONMENT_BASE_URLS: Record<InternalEnvironment, string> = {\n staging: 'https://staging-checkout.maytes.co',\n sandbox: 'https://sandbox-checkout.maytes.co',\n production: 'https://checkout.maytes.co',\n};\n\nexport function isValidEnvironment(value: unknown): value is InternalEnvironment {\n return value === 'sandbox' || value === 'production' || value === 'staging';\n}\n\nexport function resolveBaseUrl(environment: InternalEnvironment, override: string | undefined): string {\n if (override !== undefined) return override;\n const url = ENVIRONMENT_BASE_URLS[environment];\n if (url === undefined) {\n throw new MaytesError(MaytesErrorCode.Config, `Unknown environment: ${String(environment)}`);\n }\n return url;\n}\n","import { MaytesError, MaytesErrorCode } from './errors.js';\nimport { resolveBaseUrl, type InternalEnvironment } from './env.js';\nimport { navigateTopLevel } from './framing.js';\nimport type { CheckoutUrlOptions, RedirectOptions } from './types.js';\n\nexport function isHttpUrl(value: string): boolean {\n let parsed: URL;\n try {\n parsed = new URL(value);\n } catch {\n return false;\n }\n return parsed.protocol === 'https:' || parsed.protocol === 'http:';\n}\n\nexport function normalizeBaseUrl(rawBaseUrl: string): string {\n const candidate = rawBaseUrl.trim().replace(/\\/+$/, '');\n let parsed: URL;\n try {\n parsed = new URL(candidate);\n } catch {\n throw new MaytesError(MaytesErrorCode.Config, `baseUrl is not a valid URL: ${candidate}`);\n }\n if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {\n throw new MaytesError(\n MaytesErrorCode.Config,\n `baseUrl must use http or https; got ${parsed.protocol}`,\n );\n }\n return candidate;\n}\n\nfunction requireCheckoutId(id: unknown): string {\n if (typeof id !== 'string' || id.trim().length === 0) {\n throw new MaytesError(MaytesErrorCode.Config, 'checkoutId is required (non-empty string)');\n }\n return id.trim();\n}\n\nexport function buildCheckoutUrl(\n environment: InternalEnvironment,\n baseUrlOverride: string | undefined,\n checkoutId: string,\n): string {\n const id = requireCheckoutId(checkoutId);\n const base = normalizeBaseUrl(resolveBaseUrl(environment, baseUrlOverride));\n return `${base}/?id=${encodeURIComponent(id)}`;\n}\n\nexport function performRedirect(url: string, replace: boolean): void {\n if (typeof window === 'undefined') {\n throw new MaytesError(\n MaytesErrorCode.Config,\n 'redirectToCheckout requires a browser context (window is undefined)',\n );\n }\n const outcome = navigateTopLevel(url, replace);\n if (outcome.target === null) {\n throw new MaytesError(\n MaytesErrorCode.Config,\n 'redirectToCheckout could not leave the embedding iframe; call it from a user gesture or from the top-level page',\n );\n }\n}\n\nexport function makeRedirect(\n environment: InternalEnvironment,\n baseUrlOverride: string | undefined,\n) {\n return {\n checkoutUrl(opts: CheckoutUrlOptions): string {\n return buildCheckoutUrl(environment, baseUrlOverride, opts.checkoutId);\n },\n redirectToCheckout(opts: RedirectOptions): void {\n const url = buildCheckoutUrl(environment, baseUrlOverride, opts.checkoutId);\n performRedirect(url, opts.replace === true);\n },\n };\n}\n","export const SDK_VERSION = '1.1.0';\n","import { foundation } from './foundation/brand.generated.js';\nimport { SDK_VERSION } from './version.js';\n\nconst STYLE_ATTR = 'data-maytes-checkout-button';\nconst STYLE_SELECTOR = `style[${STYLE_ATTR}=\"${SDK_VERSION}\"]`;\nconst REFCOUNT_KEY = `__maytes_checkout_button_styles_refs_${SDK_VERSION}__`;\n\ninterface RefCountWindow extends Window {\n [REFCOUNT_KEY]?: number;\n}\n\n// WEB-LOCAL: no foundation role (a11y focus ring); see MOB-994\nconst FOCUS_RING = '#6b8aff';\n\nconst BUTTON_CSS = `\n.maytes-checkout-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 0.57em;\n padding: 0.71em 1.29em;\n border: none;\n border-radius: 999px;\n background: ${foundation.brand.primary};\n color: ${foundation.text.primaryInverse};\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n font-size: var(--maytes-button-font-size, 14px);\n font-weight: 600;\n line-height: 1;\n cursor: pointer;\n user-select: none;\n transition: background-color 120ms ease, opacity 120ms ease;\n}\n.maytes-checkout-button:hover { background: ${foundation.palette.burgundy[700]}; }\n.maytes-checkout-button:focus-visible {\n outline: 2px solid ${FOCUS_RING};\n outline-offset: 2px;\n}\n.maytes-checkout-button[aria-disabled='true'] {\n cursor: progress;\n opacity: 0.7;\n}\n.maytes-checkout-button--block {\n display: flex;\n width: 100%;\n}\n.maytes-checkout-button__logo { height: 1em; width: auto; flex: none; }\n.maytes-checkout-button__spinner {\n height: 1em;\n width: 1em;\n border-radius: 50%;\n border: 0.14em solid currentColor;\n border-right-color: transparent;\n animation: maytes-checkout-button-spin 0.7s linear infinite;\n}\n@keyframes maytes-checkout-button-spin {\n to { transform: rotate(360deg); }\n}\n.maytes-checkout-overlay {\n position: fixed;\n inset: 0;\n width: 100vw;\n height: 100vh;\n max-width: 100vw;\n max-height: 100vh;\n margin: 0;\n padding: 0;\n border: none;\n background: transparent;\n z-index: 2147483646;\n font: 500 15px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n}\n.maytes-checkout-overlay[open] {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.maytes-checkout-overlay::backdrop {\n background: rgba(0, 0, 0, 0.6);\n backdrop-filter: blur(4px);\n -webkit-backdrop-filter: blur(4px);\n}\n.maytes-checkout-overlay__content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 1.5rem;\n}\n.maytes-checkout-overlay__spinner {\n width: 2.5rem;\n height: 2.5rem;\n border: 4px solid rgba(255, 255, 255, 0.3);\n border-top-color: ${foundation.brand.secondary};\n border-radius: 50%;\n animation: maytes-checkout-button-spin 0.8s linear infinite;\n}\n.maytes-checkout-overlay__text {\n color: ${foundation.text.primaryInverse};\n font-size: 1.125rem;\n font-weight: 500;\n margin: 0;\n}\n.maytes-checkout-overlay__link {\n color: rgba(255, 255, 255, 0.7);\n font-size: 0.875rem;\n text-decoration: underline;\n text-underline-offset: 4px;\n background: none;\n border: none;\n cursor: pointer;\n font-family: inherit;\n transition: color 0.15s;\n}\n.maytes-checkout-overlay__link:hover { color: ${foundation.text.primaryInverse}; }\n@media (prefers-reduced-motion: reduce) {\n .maytes-checkout-overlay__spinner,\n .maytes-checkout-button__spinner { animation: none; }\n}\n`;\n\nexport const POPUP_LOADING_CSS = `\n:root { color-scheme: light; }\nhtml, body { margin: 0; height: 100%; }\nbody.maytes-popup-loading {\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100vh;\n background: ${foundation.brand.primary};\n color: ${foundation.text.primaryInverse};\n font: 500 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n}\n.maytes-popup-loading__content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 1.5rem;\n padding: 2rem;\n text-align: center;\n}\n.maytes-popup-loading__logo { height: 2.75rem; width: auto; }\n.maytes-popup-loading__spinner {\n width: 2.5rem;\n height: 2.5rem;\n border: 4px solid rgba(255, 255, 255, 0.25);\n border-top-color: ${foundation.brand.secondary};\n border-radius: 50%;\n animation: maytes-checkout-button-spin 0.8s linear infinite;\n}\n@keyframes maytes-checkout-button-spin {\n to { transform: rotate(360deg); }\n}\n.maytes-popup-loading__text { margin: 0; font-size: 1.05rem; font-weight: 500; }\n.maytes-popup-loading__slow {\n margin: 0;\n font-size: 0.9rem;\n font-weight: 400;\n color: rgba(255, 255, 255, 0.75);\n max-width: 22rem;\n}\n.maytes-popup-loading__slow[hidden] { display: none; }\n@media (prefers-reduced-motion: reduce) {\n .maytes-popup-loading__spinner { animation: none; }\n}\n`;\n\nfunction getRefCount(): number {\n const w = window as RefCountWindow;\n return w[REFCOUNT_KEY] ?? 0;\n}\n\nfunction setRefCount(value: number): void {\n const w = window as RefCountWindow;\n w[REFCOUNT_KEY] = value;\n}\n\nexport function ensureStylesInjected(cspNonce: string | undefined): void {\n const next = getRefCount() + 1;\n setRefCount(next);\n if (document.head.querySelector(STYLE_SELECTOR) !== null) return;\n const el = document.createElement('style');\n el.setAttribute(STYLE_ATTR, SDK_VERSION);\n if (cspNonce !== undefined && cspNonce !== '') el.setAttribute('nonce', cspNonce);\n el.textContent = BUTTON_CSS;\n document.head.appendChild(el);\n}\n\nexport function releaseStyles(): void {\n const next = Math.max(0, getRefCount() - 1);\n setRefCount(next);\n if (next > 0) return;\n const el = document.head.querySelector(STYLE_SELECTOR);\n if (el !== null) el.remove();\n}\n\nexport function resetStylesForTests(): void {\n setRefCount(0);\n document.head.querySelectorAll(`style[${STYLE_ATTR}]`).forEach((el) => el.remove());\n}\n","import { buildMaytesLogo } from './branding.js';\nimport { foundation } from './foundation/brand.generated.js';\nimport { MaytesError, MaytesErrorCode } from './errors.js';\nimport { isSecurityError, navigateTopLevel, viewportWidth } from './framing.js';\nimport { hideOverlay, showOverlay } from './overlay.js';\nimport { buildCheckoutUrl, isHttpUrl } from './redirect.js';\nimport { ensureStylesInjected, POPUP_LOADING_CSS, releaseStyles } from './styles.js';\nimport type { InstanceState } from './state.js';\nimport type {\n CheckoutFailedReason,\n CheckoutRedirectedDetail,\n RedirectTarget,\n RenderButtonCleanup,\n RenderButtonMode,\n RenderButtonOptions,\n} from './types.js';\n\nconst POPUP_WIDTH = 500;\nconst POPUP_HEIGHT = 800;\nconst POPUP_POLL_INTERVAL_MS = 500;\nconst MOBILE_MAX_WIDTH = 600;\nconst SLOW_NETWORK_DELAY_MS = 8000;\n\nfunction buildLogo(): SVGSVGElement {\n const svg = buildMaytesLogo('1em', 'currentColor');\n svg.setAttribute('class', 'maytes-checkout-button__logo');\n svg.setAttribute('aria-hidden', 'true');\n return svg;\n}\n\nfunction buildSpinner(): HTMLSpanElement {\n const spinner = document.createElement('span');\n spinner.className = 'maytes-checkout-button__spinner';\n spinner.setAttribute('aria-hidden', 'true');\n return spinner;\n}\n\nfunction isValidCheckoutResult(value: unknown): value is { checkoutId: string; checkoutUrl?: string } {\n if (typeof value !== 'object' || value === null) return false;\n const obj = value as { checkoutId?: unknown; checkoutUrl?: unknown };\n if (typeof obj.checkoutId !== 'string' || obj.checkoutId.trim().length === 0) return false;\n if (obj.checkoutUrl !== undefined) {\n if (typeof obj.checkoutUrl !== 'string' || obj.checkoutUrl.trim().length === 0) return false;\n if (!isHttpUrl(obj.checkoutUrl)) return false;\n }\n return true;\n}\n\nfunction refocusPopup(popup: Window): void {\n try { popup.focus(); } catch (err) {\n if (!isSecurityError(err)) throw err;\n }\n}\n\nexport function closePopupWindow(popup: Window | null): void {\n if (popup === null) return;\n try {\n if (!popup.closed) popup.close();\n } catch (err) {\n if (!isSecurityError(err)) throw err;\n }\n}\n\nfunction popupFeatures(): string {\n const screenWidth = window.screen?.width ?? POPUP_WIDTH;\n const screenHeight = window.screen?.height ?? POPUP_HEIGHT;\n const left = Math.max(0, Math.round((screenWidth - POPUP_WIDTH) / 2));\n const top = Math.max(0, Math.round((screenHeight - POPUP_HEIGHT) / 2));\n return `popup=yes,width=${POPUP_WIDTH},height=${POPUP_HEIGHT},left=${left},top=${top},resizable=yes,scrollbars=yes`;\n}\n\nexport function stopPopupPoll(state: InstanceState): void {\n if (state.popupPollHandle !== null) {\n clearInterval(state.popupPollHandle);\n state.popupPollHandle = null;\n }\n}\n\nfunction startPopupPoll(state: InstanceState, onClose: () => void): void {\n stopPopupPoll(state);\n state.popupPollHandle = setInterval(() => {\n const popup = state.popupWindow;\n if (popup === null || popup.closed) {\n stopPopupPoll(state);\n state.popupWindow = null;\n onClose();\n }\n }, POPUP_POLL_INTERVAL_MS);\n}\n\nfunction isMobileViewport(): boolean {\n return viewportWidth() <= MOBILE_MAX_WIDTH;\n}\n\nfunction openBlankPopup(state: InstanceState): Window | null {\n return window.open('about:blank', state.popupName, popupFeatures());\n}\n\nfunction navigatePopup(popup: Window, url: string): void {\n popup.location.replace(url);\n}\n\nfunction removePopupChildren(doc: Document): void {\n while (doc.body.firstChild !== null) doc.body.removeChild(doc.body.firstChild);\n}\n\nfunction paintPopupLoadingScreen(popup: Window, cspNonce: string | undefined): void {\n const doc = popup.document as Document | null;\n if (doc === null || doc.head === null || doc.body === null) return;\n doc.title = 'Maytes checkout';\n doc.documentElement.lang = 'en';\n const style = doc.createElement('style');\n if (cspNonce !== undefined && cspNonce !== '') style.setAttribute('nonce', cspNonce);\n style.textContent = POPUP_LOADING_CSS;\n doc.head.appendChild(style);\n\n doc.body.classList.add('maytes-popup-loading');\n removePopupChildren(doc);\n\n const content = doc.createElement('main');\n content.className = 'maytes-popup-loading__content';\n content.setAttribute('role', 'status');\n content.setAttribute('aria-live', 'polite');\n\n const logo = buildMaytesLogo('2.75rem', foundation.text.primaryInverse);\n logo.setAttribute('class', 'maytes-popup-loading__logo');\n logo.setAttribute('aria-hidden', 'true');\n content.appendChild(logo);\n\n const spinner = doc.createElement('div');\n spinner.className = 'maytes-popup-loading__spinner';\n spinner.setAttribute('aria-hidden', 'true');\n content.appendChild(spinner);\n\n const text = doc.createElement('p');\n text.className = 'maytes-popup-loading__text';\n text.textContent = 'Completing checkout with Maytes…';\n content.appendChild(text);\n\n const slow = doc.createElement('p');\n slow.className = 'maytes-popup-loading__slow';\n slow.hidden = true;\n slow.textContent = 'Still connecting. This can take a moment on slow networks.';\n content.appendChild(slow);\n\n doc.body.appendChild(content);\n setTimeout(() => { slow.hidden = false; }, SLOW_NETWORK_DELAY_MS);\n}\n\nexport function renderButton(\n state: InstanceState,\n container: HTMLElement,\n options: RenderButtonOptions = {},\n): RenderButtonCleanup {\n if (state.destroyed) {\n throw new MaytesError(\n MaytesErrorCode.Config,\n 'renderButton() called on a destroyed Maytes instance',\n );\n }\n if (!(container instanceof HTMLElement)) {\n throw new MaytesError(MaytesErrorCode.Config, 'renderButton(container) requires an HTMLElement');\n }\n\n ensureStylesInjected(state.config.cspNonce);\n\n const label = options.label ?? 'Split with';\n const block = options.block === true;\n const mode: RenderButtonMode = options.mode ?? 'popup';\n if (mode !== 'redirect' && mode !== 'popup') {\n throw new MaytesError(\n MaytesErrorCode.Config,\n \"renderButton({ mode }) must be 'redirect' or 'popup'\",\n );\n }\n\n const button = document.createElement('button');\n button.type = 'button';\n button.className = block\n ? 'maytes-checkout-button maytes-checkout-button--block'\n : 'maytes-checkout-button';\n button.setAttribute('aria-label', `${label} Maytes`);\n\n const labelNode = document.createTextNode(`${label} `);\n const logo = buildLogo();\n button.appendChild(labelNode);\n button.appendChild(logo);\n\n const setBusy = (busy: boolean) => {\n state.busy = busy;\n if (busy) {\n button.setAttribute('aria-disabled', 'true');\n button.setAttribute('aria-busy', 'true');\n logo.replaceWith(buildSpinner());\n } else {\n button.removeAttribute('aria-disabled');\n button.removeAttribute('aria-busy');\n const currentIndicator = button.querySelector('.maytes-checkout-button__spinner, .maytes-checkout-button__logo');\n if (currentIndicator !== null) currentIndicator.replaceWith(buildLogo());\n }\n };\n\n const teardownActiveCheckout = () => {\n hideOverlay(state);\n setBusy(false);\n };\n\n const onPopupClosed = () => {\n teardownActiveCheckout();\n document.dispatchEvent(new CustomEvent('maytes:checkout-closed'));\n };\n\n const dispatchFailed = (reason: CheckoutFailedReason, cause?: unknown): void => {\n document.dispatchEvent(new CustomEvent('maytes:checkout-failed', {\n detail: cause === undefined ? { reason } : { reason, cause },\n }));\n };\n\n const dispatchRedirected = (url: string, target: RedirectTarget): void => {\n const detail: CheckoutRedirectedDetail = { url, target };\n document.dispatchEvent(new CustomEvent('maytes:checkout-redirected', { detail }));\n };\n\n const navigateAway = (url: string): void => {\n const outcome = navigateTopLevel(url, false);\n teardownActiveCheckout();\n if (outcome.target === null) {\n console.error('[maytes/checkout-button] could not leave the embedding frame:', outcome.cause);\n dispatchFailed('navigation-blocked', outcome.cause);\n return;\n }\n dispatchRedirected(url, outcome.target);\n };\n\n const closeOrphanPopup = (popup: Window | null): void => {\n closePopupWindow(popup);\n stopPopupPoll(state);\n if (state.popupWindow === popup) state.popupWindow = null;\n teardownActiveCheckout();\n };\n\n const handleClick = async (): Promise<void> => {\n if (state.busy || state.destroyed) return;\n setBusy(true);\n const shouldUsePopup = mode === 'popup' && !isMobileViewport();\n const popup = shouldUsePopup ? openBlankPopup(state) : null;\n if (popup !== null) {\n state.popupWindow = popup;\n state.popupNavigated = false;\n refocusPopup(popup);\n paintPopupLoadingScreen(popup, state.config.cspNonce);\n showOverlay(state);\n document.dispatchEvent(new CustomEvent('maytes:checkout-opened'));\n startPopupPoll(state, onPopupClosed);\n }\n try {\n const result = await state.config.createCheckout();\n if (state.destroyed || (popup !== null && popup.closed)) {\n closePopupWindow(popup);\n return;\n }\n if (!isValidCheckoutResult(result)) {\n closeOrphanPopup(popup);\n const shapeError = new MaytesError(\n MaytesErrorCode.Config,\n 'createCheckout must resolve to { checkoutId: string, checkoutUrl?: http(s) URL }',\n );\n console.error(shapeError);\n dispatchFailed('invalid-shape', shapeError);\n return;\n }\n const url = result.checkoutUrl ?? buildCheckoutUrl(\n state.config.environment,\n state.config.baseUrl,\n result.checkoutId,\n );\n if (popup !== null) {\n state.popupNavigated = true;\n navigatePopup(popup, url);\n } else {\n if (shouldUsePopup) {\n console.warn('[maytes/checkout-button] popup was blocked; redirecting instead');\n }\n navigateAway(url);\n }\n } catch (err) {\n if (popup !== null && popup.closed) return;\n closeOrphanPopup(popup);\n console.error('[maytes/checkout-button] createCheckout failed:', err);\n dispatchFailed('create-checkout-rejected', err);\n }\n };\n\n button.addEventListener('click', handleClick);\n container.appendChild(button);\n\n let cleaned = false;\n const teardown = (): void => {\n if (cleaned) return;\n cleaned = true;\n button.removeEventListener('click', handleClick);\n button.remove();\n state.teardowns.delete(teardown);\n releaseStyles();\n };\n state.teardowns.add(teardown);\n\n return teardown;\n}\n","import type { MaytesOptions, MaytesInternalOptions } from './types.js';\n\nexport interface InstanceState {\n config: MaytesOptions & MaytesInternalOptions;\n busy: boolean;\n overlayEl: HTMLDialogElement | null;\n popupWindow: Window | null;\n popupNavigated: boolean;\n popupName: string;\n popupPollHandle: ReturnType<typeof setInterval> | null;\n destroyed: boolean;\n teardowns: Set<() => void>;\n}\n\nfunction popupNameSuffix(): string {\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;\n}\n\nfunction generatePopupName(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n try {\n return `maytes-checkout-${crypto.randomUUID()}`;\n } catch {\n return `maytes-checkout-${popupNameSuffix()}`;\n }\n }\n return `maytes-checkout-${popupNameSuffix()}`;\n}\n\nexport function createInstanceState(\n options: MaytesOptions,\n internal: MaytesInternalOptions | undefined,\n): InstanceState {\n const config: MaytesOptions & MaytesInternalOptions = {\n createCheckout: options.createCheckout,\n environment: options.environment,\n };\n if (internal?.baseUrl !== undefined) config.baseUrl = internal.baseUrl;\n if (internal?.cspNonce !== undefined) config.cspNonce = internal.cspNonce;\n return {\n config,\n busy: false,\n overlayEl: null,\n popupWindow: null,\n popupNavigated: false,\n popupName: generatePopupName(),\n popupPollHandle: null,\n destroyed: false,\n teardowns: new Set(),\n };\n}\n","import { closePopupWindow, renderButton, stopPopupPoll } from './button.js';\nimport { isValidEnvironment } from './env.js';\nimport { MaytesError, MaytesErrorCode } from './errors.js';\nimport { hideOverlay } from './overlay.js';\nimport { makeRedirect, normalizeBaseUrl } from './redirect.js';\nimport { createInstanceState } from './state.js';\nimport type {\n MaytesFactory,\n MaytesInternalOptions,\n MaytesOptions,\n MaytesSDK,\n} from './types.js';\n\nfunction validateOptions(options: MaytesOptions): void {\n if (typeof options !== 'object' || options === null) {\n throw new MaytesError(MaytesErrorCode.Config, 'Maytes() requires an options object');\n }\n if (typeof options.createCheckout !== 'function') {\n throw new MaytesError(\n MaytesErrorCode.Config,\n 'Maytes({ createCheckout }) must be an async function returning { checkoutId }',\n );\n }\n if (!isValidEnvironment(options.environment)) {\n throw new MaytesError(\n MaytesErrorCode.Config,\n \"Maytes({ environment }) must be 'sandbox' or 'production'\",\n );\n }\n}\n\nfunction validateInternalOptions(internal: MaytesInternalOptions | undefined): void {\n if (internal === undefined) return;\n if (internal.baseUrl !== undefined) normalizeBaseUrl(internal.baseUrl);\n}\n\nexport const Maytes: MaytesFactory = (options, internal) => {\n validateOptions(options);\n validateInternalOptions(internal);\n\n const state = createInstanceState(options, internal);\n const { checkoutUrl, redirectToCheckout } = makeRedirect(\n state.config.environment,\n state.config.baseUrl,\n );\n\n const sdk: MaytesSDK = {\n renderButton(container, opts) {\n return renderButton(state, container, opts);\n },\n redirectToCheckout(opts) {\n redirectToCheckout(opts);\n },\n checkoutUrl(opts) {\n return checkoutUrl(opts);\n },\n destroy() {\n if (state.destroyed) return;\n state.destroyed = true;\n stopPopupPoll(state);\n hideOverlay(state);\n if (!state.popupNavigated) closePopupWindow(state.popupWindow);\n state.popupWindow = null;\n state.busy = false;\n for (const teardown of [...state.teardowns]) teardown();\n state.teardowns.clear();\n },\n };\n\n return sdk;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,IAAM,aAAa;AAAA,EACxB,OAAO;AAAA,IACL,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AAAA,EACA,SAAS;AAAA,IACP,UAAU;AAAA,MACR,KAAK;AAAA,IACP;AAAA,IACA,MAAM;AAAA,MACJ,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,gBAAgB;AAAA,EAClB;AACF;;;ACzBO,IAAM,eAAe,WAAW,MAAM;AACtC,IAAM,gBAAgB,WAAW,MAAM;AAE9C,IA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AU,MAAM;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AACT;;;AZpEA,IAAI,OAAO,WAAW,aAAa;AACjC,EAAC,OAAgD,SAAS;AAC5D;","names":[]}
@@ -0,0 +1,151 @@
1
+ "use strict";var MaytesCheckoutButton=(()=>{var M=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var fe=(e,t)=>{for(var o in t)M(e,o,{get:t[o],enumerable:!0})},he=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of me(t))!ye.call(e,i)&&i!==o&&M(e,i,{get:()=>t[i],enumerable:!(n=pe(t,i))||n.enumerable});return e};var ge=e=>he(M({},"__esModule",{value:!0}),e);var Ge={};fe(Ge,{Maytes:()=>L,MaytesError:()=>a,MaytesErrorCode:()=>s,SDK_VERSION:()=>h});var u={brand:{primary:"#4A0324",secondary:"#FE572A"},palette:{burgundy:{700:"#3B021D"},base:{white:"#FFFFFF"}},text:{primaryInverse:"#FFFFFF"}};var Ze=u.brand.primary,B=u.brand.secondary,S="http://www.w3.org/2000/svg",be=["M392,6.11c-.3-1.61-1.72-2.79-3.38-2.79h-99.97c-1.66,0-3.09,1.19-3.38,2.79l-51.14,275.49c-.36,2.07,1.24,4.03,3.38,4.03h71.07c1.72,0,3.15-1.24,3.38-2.97l5.57-42.24c.23-1.72,1.66-2.97,3.38-2.97h32.45c1.72,0,3.15,1.24,3.38,2.97l5.57,42.24c.23,1.72,1.66,2.97,3.38,2.97h74.46c2.14,0,3.8-1.96,3.38-4.03L392,6.11ZM344.42,174.89h-14.59c-2.07,0-3.62-1.84-3.38-3.86l9.55-74.33c.06-.48.48-.83.95-.83s.89.35.95.83l9.91,74.33c.3,2.02-1.31,3.86-3.38,3.86h0Z","M218.86,3.32h-77.72c-1.48,0-2.85,1.01-3.27,2.44l-25.63,83.65c-.12.35-.41.6-.83.6s-.71-.23-.83-.6L84.9,5.76c-.41-1.42-1.78-2.44-3.27-2.44H3.44c-1.9,0-3.44,1.54-3.44,3.44v275.43c0,1.9,1.54,3.45,3.44,3.45h71.26c1.9,0,3.44-1.54,3.44-3.45v-77.3l-.83-51.44c0-.53.41-.95.95-.95.41,0,.77.3.89.71l14.42,59.62c.35,1.54,1.72,2.61,3.32,2.61h28.42c1.61,0,2.97-1.06,3.32-2.61l14.47-59.79c.12-.3.35-.53.71-.53.41,0,.71.3.71.71l-.42,51.67-.06.06v77.3c0,1.9,1.54,3.44,3.44,3.44h71.37c1.9,0,3.44-1.54,3.44-3.44V6.77c0-1.9-1.54-3.44-3.44-3.44h0Z","M1179.6,147c-9.73-11.8-20.71-21.12-47.76-38.44-27.06-16.91-31.69-23.26-31.69-31.68,0-6.76,3.8-11.39,10.56-11.39,8.19,0,14.18,10.44,15.43,26.28.18,2.14,2.13,3.74,4.27,3.26l63.66-14.12c1.6-.36,2.73-1.9,2.61-3.56-3.97-49.3-35-77.36-86.44-77.36-27.47,0-50.25,8.07-67.63,24.09-17.39,16.01-25.82,36.72-25.82,62.53,0,16.91,4.22,32.09,13.12,45.62,8.9,13.53,25.75,28.3,51.56,44.38,14.77,9.32,24.09,16.49,27.88,21.12,4.21,4.63,6.35,9.31,6.35,14.36,0,6.35-4.63,10.56-11.81,10.56-10.5,0-18.15-11.87-19.28-29.66-.12-2.25-2.31-3.91-4.51-3.26l-63.6,18.68c-1.55.42-2.55,1.84-2.43,3.44,1.78,22.84,11.03,41.41,26.88,55.65,16.49,14.36,36.77,21.53,64.24,21.53s50.32-7.59,67.64-23.26c17.74-15.66,26.64-36.37,26.64-61.28,0-22.01-6.35-40.58-19.87-57.49v-.02Z","M1002.33,3.32h-146.18c-1.9,0-3.44,1.54-3.44,3.44v275.49c0,1.9,1.54,3.44,3.44,3.44h146.18c1.9,0,3.44-1.54,3.44-3.44v-62.05c0-1.9-1.54-3.44-3.44-3.44h-63.3c-1.9,0-3.45-1.54-3.45-3.45v-34.58c0-1.9,1.54-3.44,3.45-3.44v.18h53.63c1.9,0,3.45-1.54,3.45-3.44v-57.84c0-1.9-1.55-3.44-3.45-3.44h-53.63c-1.9,0-3.45-1.54-3.45-3.44v-31.61c0-1.9,1.54-3.44,3.45-3.44h63.3c1.9,0,3.44-1.54,3.44-3.44V6.77c0-1.9-1.54-3.44-3.44-3.44Z","M840.22,6.77c0-1.9-1.54-3.44-3.44-3.44h-175.31c-1.9,0-3.45,1.54-3.45,3.44v62c0,1.9,1.54,3.44,3.45,3.44h41.77c1.9,0,3.44,1.54,3.44,3.44v206.62c0,1.9,1.54,3.45,3.44,3.45h78.14c1.9,0,3.45-1.54,3.45-3.45V75.7c0-1.9,1.54-3.44,3.45-3.44h41.77c1.9,0,3.44-1.54,3.44-3.44h-.12V6.77h-.02Z","M607.71,3.38l-.06-.06c-23.23,0-32.59,48.08-40.22,80.25-1.38,5.82-4.74,18.31-7.75,27.31-4.44,13.26-10.68,30.43-22.21,31.93-18.85,2.47-7.14-39.43-7.14-39.43l21.67-92.98c.84-3.6-1.92-7.02-5.58-7.02h-85.49c-3.12,0-5.64,2.46-5.71,5.64l-1.68,75.09c-.48,21.25,5.64,42.31,18.37,59.37,12.72,17.05,38.81,28,63.12,25.9,52.48-7.08,65.46-70.49,68.4-71.1,3.06-.64,2.56,9.3.84,22.15-2.2,16.42-8.46,32.1-18.52,45.27-5.3,6.95-11.13,12.9-16.55,16.37-32.96,22.51-95.69,9.48-122.4-2.7-3.66-1.68-7.75,1.02-7.75,5.04l16.39,83.98c0,.84.18,1.68.54,2.4,9.48,17.83,53.31,19.33,74.43,17.77,32.18-2.04,100.37-29.35,115.32-122.33,12.17-103.08-1.14-162.91-38.06-162.84l.02-.02Z"];function g(e,t){let o=document.createElementNS(S,"svg");o.setAttribute("xmlns",S),o.setAttribute("viewBox","0 0 1199.47 289.04"),o.style.height=e,o.style.width="auto",o.style.color=t;for(let n of be){let i=document.createElementNS(S,"path");i.setAttribute("fill","currentColor"),i.setAttribute("d",n),o.appendChild(i)}return o}var s={Config:"CONFIG"},a=class extends Error{constructor(t,o){super(o),this.code=t,this.name="MaytesError"}};function f(e){return typeof e=="object"&&e!==null&&e.name==="SecurityError"}function I(){return window.top!==null&&window.top!==window}function O(){if(!I())return null;let e=window.top;try{return e.document,e}catch(t){if(!f(t))throw t;return null}}function V(){if(!I())return window.innerWidth;let e=O();if(e!==null)return e.innerWidth;let t=window.screen?.width;return typeof t=="number"&&t>0?t:window.innerWidth}function H(e,t,o){o?e.location.replace(t):e.location.href=t}function we(e){try{e.opener=null}catch(t){if(!f(t))throw t}}function v(e,t){if(!I())return H(window,e,t),{target:"self"};let o;try{return H(window.top,e,t),{target:"top"}}catch(n){if(!f(n))throw n;o=n}try{let n=window.open(e,"_blank");return n!==null?(we(n),{target:"tab"}):{target:null,cause:o}}catch(n){return{target:null,cause:n}}}var j="maytes-overlay-title",R="data-maytes-checkout-button-overlay-styles",ve="rgba(0, 0, 0, 0.6)";function ke(){let e=O();if(e===null)return null;let t=e.document;return t.body!==null?t:null}function Ce(){return ke()??document}function Ee(e){if(e===document||e.querySelector(`style[${R}]`)!==null)return;let t=document.head.querySelector("style[data-maytes-checkout-button]");if(t===null)return;let o=e.createElement("style");o.setAttribute(R,"");let n=t.getAttribute("nonce");n!==null&&o.setAttribute("nonce",n),o.textContent=t.textContent??"",e.head.appendChild(o)}function xe(e,t){let o=e.createElement("dialog");o.className="maytes-checkout-overlay",o.setAttribute("aria-labelledby",j),o.setAttribute("data-maytes-overlay","");let n=e.createElement("div");n.className="maytes-checkout-overlay__content";let i=e.createElement("div");i.setAttribute("aria-hidden","true"),i.appendChild(g("2.5rem",B)),n.appendChild(i);let d=e.createElement("div");d.className="maytes-checkout-overlay__spinner",d.setAttribute("role","status"),d.setAttribute("aria-live","polite"),d.setAttribute("aria-label","Checkout in progress"),n.appendChild(d);let r=e.createElement("p");r.id=j,r.className="maytes-checkout-overlay__text",r.textContent="Completing checkout with Maytes\u2026",n.appendChild(r);let p=e.createElement("button");return p.className="maytes-checkout-overlay__link",p.type="button",p.textContent="Return to Maytes",p.addEventListener("click",()=>{if(t.popupWindow!==null&&!t.popupWindow.closed)try{t.popupWindow.focus()}catch(m){if(!f(m))throw m}}),n.appendChild(p),o.appendChild(n),o.addEventListener("cancel",m=>{m.preventDefault(),t.popupWindow!==null&&!t.popupWindow.closed&&t.popupWindow.close(),b(t)}),o}function q(e){e.style.background=ve}function G(e){if(e.overlayEl!==null)return;let t=Ce();Ee(t);let o=xe(t,e);if(e.overlayEl=o,t.body.appendChild(o),typeof o.showModal=="function")try{o.showModal()}catch(n){console.warn("[maytes/checkout-button] dialog.showModal failed; falling back to inline backdrop",n),o.setAttribute("open",""),q(o)}else o.setAttribute("open",""),q(o)}function b(e){if(e.overlayEl===null)return;let t=e.overlayEl,o=t.ownerDocument;typeof t.close=="function"&&t.open&&t.close(),t.remove(),o!==document&&o.head.querySelector(`style[${R}]`)?.remove(),e.overlayEl=null}var _e={staging:"https://staging-checkout.maytes.co",sandbox:"https://sandbox-checkout.maytes.co",production:"https://checkout.maytes.co"};function K(e){return e==="sandbox"||e==="production"||e==="staging"}function z(e,t){if(t!==void 0)return t;let o=_e[e];if(o===void 0)throw new a(s.Config,`Unknown environment: ${String(e)}`);return o}function Y(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol==="https:"||t.protocol==="http:"}function A(e){let t=e.trim().replace(/\/+$/,""),o;try{o=new URL(t)}catch{throw new a(s.Config,`baseUrl is not a valid URL: ${t}`)}if(o.protocol!=="https:"&&o.protocol!=="http:")throw new a(s.Config,`baseUrl must use http or https; got ${o.protocol}`);return t}function Me(e){if(typeof e!="string"||e.trim().length===0)throw new a(s.Config,"checkoutId is required (non-empty string)");return e.trim()}function k(e,t,o){let n=Me(o);return`${A(z(e,t))}/?id=${encodeURIComponent(n)}`}function Se(e,t){if(typeof window>"u")throw new a(s.Config,"redirectToCheckout requires a browser context (window is undefined)");if(v(e,t).target===null)throw new a(s.Config,"redirectToCheckout could not leave the embedding iframe; call it from a user gesture or from the top-level page")}function Z(e,t){return{checkoutUrl(o){return k(e,t,o.checkoutId)},redirectToCheckout(o){let n=k(e,t,o.checkoutId);Se(n,o.replace===!0)}}}var h="1.1.0";var X="data-maytes-checkout-button",J=`style[${X}="${h}"]`,Q=`__maytes_checkout_button_styles_refs_${h}__`,Ie="#6b8aff",Oe=`
2
+ .maytes-checkout-button {
3
+ display: inline-flex;
4
+ align-items: center;
5
+ justify-content: center;
6
+ gap: 0.57em;
7
+ padding: 0.71em 1.29em;
8
+ border: none;
9
+ border-radius: 999px;
10
+ background: ${u.brand.primary};
11
+ color: ${u.text.primaryInverse};
12
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
13
+ font-size: var(--maytes-button-font-size, 14px);
14
+ font-weight: 600;
15
+ line-height: 1;
16
+ cursor: pointer;
17
+ user-select: none;
18
+ transition: background-color 120ms ease, opacity 120ms ease;
19
+ }
20
+ .maytes-checkout-button:hover { background: ${u.palette.burgundy[700]}; }
21
+ .maytes-checkout-button:focus-visible {
22
+ outline: 2px solid ${Ie};
23
+ outline-offset: 2px;
24
+ }
25
+ .maytes-checkout-button[aria-disabled='true'] {
26
+ cursor: progress;
27
+ opacity: 0.7;
28
+ }
29
+ .maytes-checkout-button--block {
30
+ display: flex;
31
+ width: 100%;
32
+ }
33
+ .maytes-checkout-button__logo { height: 1em; width: auto; flex: none; }
34
+ .maytes-checkout-button__spinner {
35
+ height: 1em;
36
+ width: 1em;
37
+ border-radius: 50%;
38
+ border: 0.14em solid currentColor;
39
+ border-right-color: transparent;
40
+ animation: maytes-checkout-button-spin 0.7s linear infinite;
41
+ }
42
+ @keyframes maytes-checkout-button-spin {
43
+ to { transform: rotate(360deg); }
44
+ }
45
+ .maytes-checkout-overlay {
46
+ position: fixed;
47
+ inset: 0;
48
+ width: 100vw;
49
+ height: 100vh;
50
+ max-width: 100vw;
51
+ max-height: 100vh;
52
+ margin: 0;
53
+ padding: 0;
54
+ border: none;
55
+ background: transparent;
56
+ z-index: 2147483646;
57
+ font: 500 15px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
58
+ }
59
+ .maytes-checkout-overlay[open] {
60
+ display: flex;
61
+ align-items: center;
62
+ justify-content: center;
63
+ }
64
+ .maytes-checkout-overlay::backdrop {
65
+ background: rgba(0, 0, 0, 0.6);
66
+ backdrop-filter: blur(4px);
67
+ -webkit-backdrop-filter: blur(4px);
68
+ }
69
+ .maytes-checkout-overlay__content {
70
+ display: flex;
71
+ flex-direction: column;
72
+ align-items: center;
73
+ gap: 1.5rem;
74
+ }
75
+ .maytes-checkout-overlay__spinner {
76
+ width: 2.5rem;
77
+ height: 2.5rem;
78
+ border: 4px solid rgba(255, 255, 255, 0.3);
79
+ border-top-color: ${u.brand.secondary};
80
+ border-radius: 50%;
81
+ animation: maytes-checkout-button-spin 0.8s linear infinite;
82
+ }
83
+ .maytes-checkout-overlay__text {
84
+ color: ${u.text.primaryInverse};
85
+ font-size: 1.125rem;
86
+ font-weight: 500;
87
+ margin: 0;
88
+ }
89
+ .maytes-checkout-overlay__link {
90
+ color: rgba(255, 255, 255, 0.7);
91
+ font-size: 0.875rem;
92
+ text-decoration: underline;
93
+ text-underline-offset: 4px;
94
+ background: none;
95
+ border: none;
96
+ cursor: pointer;
97
+ font-family: inherit;
98
+ transition: color 0.15s;
99
+ }
100
+ .maytes-checkout-overlay__link:hover { color: ${u.text.primaryInverse}; }
101
+ @media (prefers-reduced-motion: reduce) {
102
+ .maytes-checkout-overlay__spinner,
103
+ .maytes-checkout-button__spinner { animation: none; }
104
+ }
105
+ `,ee=`
106
+ :root { color-scheme: light; }
107
+ html, body { margin: 0; height: 100%; }
108
+ body.maytes-popup-loading {
109
+ display: flex;
110
+ align-items: center;
111
+ justify-content: center;
112
+ min-height: 100vh;
113
+ background: ${u.brand.primary};
114
+ color: ${u.text.primaryInverse};
115
+ font: 500 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
116
+ }
117
+ .maytes-popup-loading__content {
118
+ display: flex;
119
+ flex-direction: column;
120
+ align-items: center;
121
+ gap: 1.5rem;
122
+ padding: 2rem;
123
+ text-align: center;
124
+ }
125
+ .maytes-popup-loading__logo { height: 2.75rem; width: auto; }
126
+ .maytes-popup-loading__spinner {
127
+ width: 2.5rem;
128
+ height: 2.5rem;
129
+ border: 4px solid rgba(255, 255, 255, 0.25);
130
+ border-top-color: ${u.brand.secondary};
131
+ border-radius: 50%;
132
+ animation: maytes-checkout-button-spin 0.8s linear infinite;
133
+ }
134
+ @keyframes maytes-checkout-button-spin {
135
+ to { transform: rotate(360deg); }
136
+ }
137
+ .maytes-popup-loading__text { margin: 0; font-size: 1.05rem; font-weight: 500; }
138
+ .maytes-popup-loading__slow {
139
+ margin: 0;
140
+ font-size: 0.9rem;
141
+ font-weight: 400;
142
+ color: rgba(255, 255, 255, 0.75);
143
+ max-width: 22rem;
144
+ }
145
+ .maytes-popup-loading__slow[hidden] { display: none; }
146
+ @media (prefers-reduced-motion: reduce) {
147
+ .maytes-popup-loading__spinner { animation: none; }
148
+ }
149
+ `;function te(){return window[Q]??0}function oe(e){let t=window;t[Q]=e}function ne(e){let t=te()+1;if(oe(t),document.head.querySelector(J)!==null)return;let o=document.createElement("style");o.setAttribute(X,h),e!==void 0&&e!==""&&o.setAttribute("nonce",e),o.textContent=Oe,document.head.appendChild(o)}function re(){let e=Math.max(0,te()-1);if(oe(e),e>0)return;let t=document.head.querySelector(J);t!==null&&t.remove()}var T=500,U=800,Re=500,Ae=600,Te=8e3;function ie(){let e=g("1em","currentColor");return e.setAttribute("class","maytes-checkout-button__logo"),e.setAttribute("aria-hidden","true"),e}function Ue(){let e=document.createElement("span");return e.className="maytes-checkout-button__spinner",e.setAttribute("aria-hidden","true"),e}function Le(e){if(typeof e!="object"||e===null)return!1;let t=e;return!(typeof t.checkoutId!="string"||t.checkoutId.trim().length===0||t.checkoutUrl!==void 0&&(typeof t.checkoutUrl!="string"||t.checkoutUrl.trim().length===0||!Y(t.checkoutUrl)))}function We(e){try{e.focus()}catch(t){if(!f(t))throw t}}function C(e){if(e!==null)try{e.closed||e.close()}catch(t){if(!f(t))throw t}}function Ne(){let e=window.screen?.width??T,t=window.screen?.height??U,o=Math.max(0,Math.round((e-T)/2)),n=Math.max(0,Math.round((t-U)/2));return`popup=yes,width=${T},height=${U},left=${o},top=${n},resizable=yes,scrollbars=yes`}function w(e){e.popupPollHandle!==null&&(clearInterval(e.popupPollHandle),e.popupPollHandle=null)}function Pe(e,t){w(e),e.popupPollHandle=setInterval(()=>{let o=e.popupWindow;(o===null||o.closed)&&(w(e),e.popupWindow=null,t())},Re)}function De(){return V()<=Ae}function Fe(e){return window.open("about:blank",e.popupName,Ne())}function $e(e,t){e.location.replace(t)}function Be(e){for(;e.body.firstChild!==null;)e.body.removeChild(e.body.firstChild)}function He(e,t){let o=e.document;if(o===null||o.head===null||o.body===null)return;o.title="Maytes checkout",o.documentElement.lang="en";let n=o.createElement("style");t!==void 0&&t!==""&&n.setAttribute("nonce",t),n.textContent=ee,o.head.appendChild(n),o.body.classList.add("maytes-popup-loading"),Be(o);let i=o.createElement("main");i.className="maytes-popup-loading__content",i.setAttribute("role","status"),i.setAttribute("aria-live","polite");let d=g("2.75rem",u.text.primaryInverse);d.setAttribute("class","maytes-popup-loading__logo"),d.setAttribute("aria-hidden","true"),i.appendChild(d);let r=o.createElement("div");r.className="maytes-popup-loading__spinner",r.setAttribute("aria-hidden","true"),i.appendChild(r);let p=o.createElement("p");p.className="maytes-popup-loading__text",p.textContent="Completing checkout with Maytes\u2026",i.appendChild(p);let m=o.createElement("p");m.className="maytes-popup-loading__slow",m.hidden=!0,m.textContent="Still connecting. This can take a moment on slow networks.",i.appendChild(m),o.body.appendChild(i),setTimeout(()=>{m.hidden=!1},Te)}function ce(e,t,o={}){if(e.destroyed)throw new a(s.Config,"renderButton() called on a destroyed Maytes instance");if(!(t instanceof HTMLElement))throw new a(s.Config,"renderButton(container) requires an HTMLElement");ne(e.config.cspNonce);let n=o.label??"Split with",i=o.block===!0,d=o.mode??"popup";if(d!=="redirect"&&d!=="popup")throw new a(s.Config,"renderButton({ mode }) must be 'redirect' or 'popup'");let r=document.createElement("button");r.type="button",r.className=i?"maytes-checkout-button maytes-checkout-button--block":"maytes-checkout-button",r.setAttribute("aria-label",`${n} Maytes`);let p=document.createTextNode(`${n} `),m=ie();r.appendChild(p),r.appendChild(m);let W=l=>{if(e.busy=l,l)r.setAttribute("aria-disabled","true"),r.setAttribute("aria-busy","true"),m.replaceWith(Ue());else{r.removeAttribute("aria-disabled"),r.removeAttribute("aria-busy");let c=r.querySelector(".maytes-checkout-button__spinner, .maytes-checkout-button__logo");c!==null&&c.replaceWith(ie())}},E=()=>{b(e),W(!1)},le=()=>{E(),document.dispatchEvent(new CustomEvent("maytes:checkout-closed"))},x=(l,c)=>{document.dispatchEvent(new CustomEvent("maytes:checkout-failed",{detail:c===void 0?{reason:l}:{reason:l,cause:c}}))},ue=(l,c)=>{let y={url:l,target:c};document.dispatchEvent(new CustomEvent("maytes:checkout-redirected",{detail:y}))},de=l=>{let c=v(l,!1);if(E(),c.target===null){console.error("[maytes/checkout-button] could not leave the embedding frame:",c.cause),x("navigation-blocked",c.cause);return}ue(l,c.target)},N=l=>{C(l),w(e),e.popupWindow===l&&(e.popupWindow=null),E()},P=async()=>{if(e.busy||e.destroyed)return;W(!0);let l=d==="popup"&&!De(),c=l?Fe(e):null;c!==null&&(e.popupWindow=c,e.popupNavigated=!1,We(c),He(c,e.config.cspNonce),G(e),document.dispatchEvent(new CustomEvent("maytes:checkout-opened")),Pe(e,le));try{let y=await e.config.createCheckout();if(e.destroyed||c!==null&&c.closed){C(c);return}if(!Le(y)){N(c);let $=new a(s.Config,"createCheckout must resolve to { checkoutId: string, checkoutUrl?: http(s) URL }");console.error($),x("invalid-shape",$);return}let F=y.checkoutUrl??k(e.config.environment,e.config.baseUrl,y.checkoutId);c!==null?(e.popupNavigated=!0,$e(c,F)):(l&&console.warn("[maytes/checkout-button] popup was blocked; redirecting instead"),de(F))}catch(y){if(c!==null&&c.closed)return;N(c),console.error("[maytes/checkout-button] createCheckout failed:",y),x("create-checkout-rejected",y)}};r.addEventListener("click",P),t.appendChild(r);let D=!1,_=()=>{D||(D=!0,r.removeEventListener("click",P),r.remove(),e.teardowns.delete(_),re())};return e.teardowns.add(_),_}function ae(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Ve(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")try{return`maytes-checkout-${crypto.randomUUID()}`}catch{return`maytes-checkout-${ae()}`}return`maytes-checkout-${ae()}`}function se(e,t){let o={createCheckout:e.createCheckout,environment:e.environment};return t?.baseUrl!==void 0&&(o.baseUrl=t.baseUrl),t?.cspNonce!==void 0&&(o.cspNonce=t.cspNonce),{config:o,busy:!1,overlayEl:null,popupWindow:null,popupNavigated:!1,popupName:Ve(),popupPollHandle:null,destroyed:!1,teardowns:new Set}}function je(e){if(typeof e!="object"||e===null)throw new a(s.Config,"Maytes() requires an options object");if(typeof e.createCheckout!="function")throw new a(s.Config,"Maytes({ createCheckout }) must be an async function returning { checkoutId }");if(!K(e.environment))throw new a(s.Config,"Maytes({ environment }) must be 'sandbox' or 'production'")}function qe(e){e!==void 0&&e.baseUrl!==void 0&&A(e.baseUrl)}var L=(e,t)=>{je(e),qe(t);let o=se(e,t),{checkoutUrl:n,redirectToCheckout:i}=Z(o.config.environment,o.config.baseUrl);return{renderButton(r,p){return ce(o,r,p)},redirectToCheckout(r){i(r)},checkoutUrl(r){return n(r)},destroy(){if(!o.destroyed){o.destroyed=!0,w(o),b(o),o.popupNavigated||C(o.popupWindow),o.popupWindow=null,o.busy=!1;for(let r of[...o.teardowns])r();o.teardowns.clear()}}}};typeof window<"u"&&(window.Maytes=L);return ge(Ge);})();
150
+ window.Maytes = MaytesCheckoutButton.Maytes;
151
+ //# sourceMappingURL=checkout-button.js.map