@maytes/checkout-button 1.0.0 → 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.
@@ -57,21 +57,79 @@ var MaytesError = class extends Error {
57
57
  }
58
58
  };
59
59
 
60
+ // src/framing.ts
61
+ function isSecurityError(err) {
62
+ return typeof err === "object" && err !== null && err.name === "SecurityError";
63
+ }
64
+ function isFramed() {
65
+ return window.top !== null && window.top !== window;
66
+ }
67
+ function sameOriginTop() {
68
+ if (!isFramed()) return null;
69
+ const top = window.top;
70
+ try {
71
+ void top.document;
72
+ return top;
73
+ } catch (err) {
74
+ if (!isSecurityError(err)) throw err;
75
+ return null;
76
+ }
77
+ }
78
+ function viewportWidth() {
79
+ if (!isFramed()) return window.innerWidth;
80
+ const top = sameOriginTop();
81
+ if (top !== null) return top.innerWidth;
82
+ const screenWidth = window.screen?.width;
83
+ return typeof screenWidth === "number" && screenWidth > 0 ? screenWidth : window.innerWidth;
84
+ }
85
+ function navigateWindow(target, url, replace) {
86
+ if (replace) {
87
+ target.location.replace(url);
88
+ } else {
89
+ target.location.href = url;
90
+ }
91
+ }
92
+ function severOpener(tab) {
93
+ try {
94
+ tab.opener = null;
95
+ } catch (err) {
96
+ if (!isSecurityError(err)) throw err;
97
+ }
98
+ }
99
+ function navigateTopLevel(url, replace) {
100
+ if (!isFramed()) {
101
+ navigateWindow(window, url, replace);
102
+ return { target: "self" };
103
+ }
104
+ let refusal;
105
+ try {
106
+ navigateWindow(window.top, url, replace);
107
+ return { target: "top" };
108
+ } catch (err) {
109
+ if (!isSecurityError(err)) throw err;
110
+ refusal = err;
111
+ }
112
+ try {
113
+ const tab = window.open(url, "_blank");
114
+ if (tab !== null) {
115
+ severOpener(tab);
116
+ return { target: "tab" };
117
+ }
118
+ return { target: null, cause: refusal };
119
+ } catch (err) {
120
+ return { target: null, cause: err };
121
+ }
122
+ }
123
+
60
124
  // src/overlay.ts
61
125
  var TITLE_ID = "maytes-overlay-title";
62
126
  var STYLE_MARKER = "data-maytes-checkout-button-overlay-styles";
63
127
  var NATIVE_BACKDROP_FALLBACK = "rgba(0, 0, 0, 0.6)";
64
128
  function tryReadTopDocument() {
65
- if (window.top === null || window.top === window) return null;
66
- try {
67
- const topDoc = window.top.document;
68
- return topDoc.body !== null ? topDoc : null;
69
- } catch (err) {
70
- if (!(err instanceof DOMException && err.name === "SecurityError")) {
71
- console.warn("[maytes/checkout-button] unexpected error resolving overlay host", err);
72
- }
73
- return null;
74
- }
129
+ const top = sameOriginTop();
130
+ if (top === null) return null;
131
+ const topDoc = top.document;
132
+ return topDoc.body !== null ? topDoc : null;
75
133
  }
76
134
  function resolveOverlayHost() {
77
135
  return tryReadTopDocument() ?? document;
@@ -119,7 +177,7 @@ function buildOverlay(host, state) {
119
177
  try {
120
178
  state.popupWindow.focus();
121
179
  } catch (err) {
122
- if (!(err instanceof DOMException && err.name === "SecurityError")) throw err;
180
+ if (!isSecurityError(err)) throw err;
123
181
  }
124
182
  }
125
183
  });
@@ -229,10 +287,12 @@ function performRedirect(url, replace) {
229
287
  "redirectToCheckout requires a browser context (window is undefined)"
230
288
  );
231
289
  }
232
- if (replace) {
233
- window.location.replace(url);
234
- } else {
235
- window.location.href = url;
290
+ const outcome = navigateTopLevel(url, replace);
291
+ if (outcome.target === null) {
292
+ throw new MaytesError(
293
+ MaytesErrorCode.Config,
294
+ "redirectToCheckout could not leave the embedding iframe; call it from a user gesture or from the top-level page"
295
+ );
236
296
  }
237
297
  }
238
298
  function makeRedirect(environment, baseUrlOverride) {
@@ -248,7 +308,7 @@ function makeRedirect(environment, baseUrlOverride) {
248
308
  }
249
309
 
250
310
  // src/version.ts
251
- var SDK_VERSION = "1.0.0";
311
+ var SDK_VERSION = "1.1.0";
252
312
 
253
313
  // src/styles.ts
254
314
  var STYLE_ATTR = "data-maytes-checkout-button";
@@ -459,9 +519,6 @@ function isValidCheckoutResult(value) {
459
519
  }
460
520
  return true;
461
521
  }
462
- function isSecurityError(err) {
463
- return err instanceof DOMException && err.name === "SecurityError";
464
- }
465
522
  function refocusPopup(popup) {
466
523
  try {
467
524
  popup.focus();
@@ -502,7 +559,7 @@ function startPopupPoll(state, onClose) {
502
559
  }, POPUP_POLL_INTERVAL_MS);
503
560
  }
504
561
  function isMobileViewport() {
505
- return window.innerWidth <= MOBILE_MAX_WIDTH;
562
+ return viewportWidth() <= MOBILE_MAX_WIDTH;
506
563
  }
507
564
  function openBlankPopup(state) {
508
565
  return window.open("about:blank", state.popupName, popupFeatures());
@@ -563,7 +620,7 @@ function renderButton(state, container, options = {}) {
563
620
  ensureStylesInjected(state.config.cspNonce);
564
621
  const label = options.label ?? "Split with";
565
622
  const block = options.block === true;
566
- const mode = options.mode ?? "redirect";
623
+ const mode = options.mode ?? "popup";
567
624
  if (mode !== "redirect" && mode !== "popup") {
568
625
  throw new MaytesError(
569
626
  MaytesErrorCode.Config,
@@ -604,13 +661,19 @@ function renderButton(state, container, options = {}) {
604
661
  detail: cause === void 0 ? { reason } : { reason, cause }
605
662
  }));
606
663
  };
607
- const dispatchRedirected = (url) => {
608
- document.dispatchEvent(new CustomEvent("maytes:checkout-redirected", { detail: { url } }));
664
+ const dispatchRedirected = (url, target) => {
665
+ const detail = { url, target };
666
+ document.dispatchEvent(new CustomEvent("maytes:checkout-redirected", { detail }));
609
667
  };
610
- const redirectSameWindow = (url) => {
668
+ const navigateAway = (url) => {
669
+ const outcome = navigateTopLevel(url, false);
611
670
  teardownActiveCheckout();
612
- dispatchRedirected(url);
613
- window.location.href = url;
671
+ if (outcome.target === null) {
672
+ console.error("[maytes/checkout-button] could not leave the embedding frame:", outcome.cause);
673
+ dispatchFailed("navigation-blocked", outcome.cause);
674
+ return;
675
+ }
676
+ dispatchRedirected(url, outcome.target);
614
677
  };
615
678
  const closeOrphanPopup = (popup) => {
616
679
  closePopupWindow(popup);
@@ -625,6 +688,7 @@ function renderButton(state, container, options = {}) {
625
688
  const popup = shouldUsePopup ? openBlankPopup(state) : null;
626
689
  if (popup !== null) {
627
690
  state.popupWindow = popup;
691
+ state.popupNavigated = false;
628
692
  refocusPopup(popup);
629
693
  paintPopupLoadingScreen(popup, state.config.cspNonce);
630
694
  showOverlay(state);
@@ -653,12 +717,13 @@ function renderButton(state, container, options = {}) {
653
717
  result.checkoutId
654
718
  );
655
719
  if (popup !== null) {
720
+ state.popupNavigated = true;
656
721
  navigatePopup(popup, url);
657
722
  } else {
658
723
  if (shouldUsePopup) {
659
- console.warn("[maytes/checkout-button] popup was blocked; falling back to same-window redirect");
724
+ console.warn("[maytes/checkout-button] popup was blocked; redirecting instead");
660
725
  }
661
- redirectSameWindow(url);
726
+ navigateAway(url);
662
727
  }
663
728
  } catch (err) {
664
729
  if (popup !== null && popup.closed) return;
@@ -708,6 +773,7 @@ function createInstanceState(options, internal) {
708
773
  busy: false,
709
774
  overlayEl: null,
710
775
  popupWindow: null,
776
+ popupNavigated: false,
711
777
  popupName: generatePopupName(),
712
778
  popupPollHandle: null,
713
779
  destroyed: false,
@@ -760,7 +826,7 @@ var Maytes = (options, internal) => {
760
826
  state.destroyed = true;
761
827
  stopPopupPoll(state);
762
828
  hideOverlay(state);
763
- closePopupWindow(state.popupWindow);
829
+ if (!state.popupNavigated) closePopupWindow(state.popupWindow);
764
830
  state.popupWindow = null;
765
831
  state.busy = false;
766
832
  for (const teardown of [...state.teardowns]) teardown();
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../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","../src/index.ts"],"sourcesContent":["// 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","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"],"mappings":";AAWO,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,IAAM,SAAS;AAEf,IAAM,oBAAuC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,SAAS,gBAAgB,QAAgB,OAA8B;AAC5E,QAAM,MAAM,SAAS,gBAAgB,QAAQ,KAAK;AAClD,MAAI,aAAa,SAAS,MAAM;AAChC,MAAI,aAAa,WAAW,oBAAoB;AAChD,MAAI,MAAM,SAAS;AACnB,MAAI,MAAM,QAAQ;AAClB,MAAI,MAAM,QAAQ;AAClB,aAAW,KAAK,mBAAmB;A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GAAG;AAC5C,UAAM,IAAI;AAAA,MACR,gBAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,wBAAwB,UAAmD;AAClF,MAAI,aAAa,OAAW;AAC5B,MAAI,SAAS,YAAY,OAAW,kBAAiB,SAAS,OAAO;AACvE;AAEO,IAAM,SAAwB,CAAC,SAAS,aAAa;AAC1D,kBAAgB,OAAO;AACvB,0BAAwB,QAAQ;AAEhC,QAAM,QAAQ,oBAAoB,SAAS,QAAQ;AACnD,QAAM,EAAE,aAAa,mBAAmB,IAAI;AAAA,IAC1C,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,EACf;AAEA,QAAM,MAAiB;AAAA,IACrB,aAAa,WAAW,MAAM;AAC5B,aAAO,aAAa,OAAO,WAAW,IAAI;AAAA,IAC5C;AAAA,IACA,mBAAmB,MAAM;AACvB,yBAAmB,IAAI;AAAA,IACzB;AAAA,IACA,YAAY,MAAM;AAChB,aAAO,YAAY,IAAI;AAAA,IACzB;AAAA,IACA,UAAU;AACR,UAAI,MAAM,UAAW;AACrB,YAAM,YAAY;AAClB,oBAAc,KAAK;AACnB,kBAAY,KAAK;AACjB,UAAI,CAAC,MAAM,eAAgB,kBAAiB,MAAM,WAAW;AAC7D,YAAM,cAAc;AACpB,YAAM,OAAO;AACb,iBAAW,YAAY,CAAC,GAAG,MAAM,SAAS,EAAG,UAAS;AACtD,YAAM,UAAU,MAAM;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AACT;;;ACpEA,IAAI,OAAO,WAAW,aAAa;AACjC,EAAC,OAAgD,SAAS;AAC5D;","names":[]}
@@ -1,4 +1,4 @@
1
- "use strict";var MaytesCheckoutButton=(()=>{var C=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var le=Object.prototype.hasOwnProperty;var ue=(e,o)=>{for(var t in o)C(e,t,{get:o[t],enumerable:!0})},de=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of ae(o))!le.call(e,i)&&i!==t&&C(e,i,{get:()=>o[i],enumerable:!(n=se(o,i))||n.enumerable});return e};var pe=e=>de(C({},"__esModule",{value:!0}),e);var Be={};ue(Be,{Maytes:()=>O,MaytesError:()=>c,MaytesErrorCode:()=>a,SDK_VERSION:()=>f});var u={brand:{primary:"#4A0324",secondary:"#FE572A"},palette:{burgundy:{700:"#3B021D"},base:{white:"#FFFFFF"}},text:{primaryInverse:"#FFFFFF"}};var je=u.brand.primary,W=u.brand.secondary,_="http://www.w3.org/2000/svg",me=["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 h(e,o){let t=document.createElementNS(_,"svg");t.setAttribute("xmlns",_),t.setAttribute("viewBox","0 0 1199.47 289.04"),t.style.height=e,t.style.width="auto",t.style.color=o;for(let n of me){let i=document.createElementNS(_,"path");i.setAttribute("fill","currentColor"),i.setAttribute("d",n),t.appendChild(i)}return t}var a={Config:"CONFIG"},c=class extends Error{constructor(o,t){super(t),this.code=o,this.name="MaytesError"}};var D="maytes-overlay-title",x="data-maytes-checkout-button-overlay-styles",ye="rgba(0, 0, 0, 0.6)";function fe(){if(window.top===null||window.top===window)return null;try{let e=window.top.document;return e.body!==null?e:null}catch(e){return e instanceof DOMException&&e.name==="SecurityError"||console.warn("[maytes/checkout-button] unexpected error resolving overlay host",e),null}}function he(){return fe()??document}function be(e){if(e===document||e.querySelector(`style[${x}]`)!==null)return;let o=document.head.querySelector("style[data-maytes-checkout-button]");if(o===null)return;let t=e.createElement("style");t.setAttribute(x,"");let n=o.getAttribute("nonce");n!==null&&t.setAttribute("nonce",n),t.textContent=o.textContent??"",e.head.appendChild(t)}function ge(e,o){let t=e.createElement("dialog");t.className="maytes-checkout-overlay",t.setAttribute("aria-labelledby",D),t.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(h("2.5rem",W)),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=D,r.className="maytes-checkout-overlay__text",r.textContent="Completing checkout with Maytes\u2026",n.appendChild(r);let m=e.createElement("button");return m.className="maytes-checkout-overlay__link",m.type="button",m.textContent="Return to Maytes",m.addEventListener("click",()=>{if(o.popupWindow!==null&&!o.popupWindow.closed)try{o.popupWindow.focus()}catch(p){if(!(p instanceof DOMException&&p.name==="SecurityError"))throw p}}),n.appendChild(m),t.appendChild(n),t.addEventListener("cancel",p=>{p.preventDefault(),o.popupWindow!==null&&!o.popupWindow.closed&&o.popupWindow.close(),b(o)}),t}function $(e){e.style.background=ye}function B(e){if(e.overlayEl!==null)return;let o=he();be(o);let t=ge(o,e);if(e.overlayEl=t,o.body.appendChild(t),typeof t.showModal=="function")try{t.showModal()}catch(n){console.warn("[maytes/checkout-button] dialog.showModal failed; falling back to inline backdrop",n),t.setAttribute("open",""),$(t)}else t.setAttribute("open",""),$(t)}function b(e){if(e.overlayEl===null)return;let o=e.overlayEl,t=o.ownerDocument;typeof o.close=="function"&&o.open&&o.close(),o.remove(),t!==document&&t.head.querySelector(`style[${x}]`)?.remove(),e.overlayEl=null}var we={staging:"https://staging-checkout.maytes.co",sandbox:"https://sandbox-checkout.maytes.co",production:"https://checkout.maytes.co"};function F(e){return e==="sandbox"||e==="production"||e==="staging"}function H(e,o){if(o!==void 0)return o;let t=we[e];if(t===void 0)throw new c(a.Config,`Unknown environment: ${String(e)}`);return t}function V(e){let o;try{o=new URL(e)}catch{return!1}return o.protocol==="https:"||o.protocol==="http:"}function M(e){let o=e.trim().replace(/\/+$/,""),t;try{t=new URL(o)}catch{throw new c(a.Config,`baseUrl is not a valid URL: ${o}`)}if(t.protocol!=="https:"&&t.protocol!=="http:")throw new c(a.Config,`baseUrl must use http or https; got ${t.protocol}`);return o}function ve(e){if(typeof e!="string"||e.trim().length===0)throw new c(a.Config,"checkoutId is required (non-empty string)");return e.trim()}function w(e,o,t){let n=ve(t);return`${M(H(e,o))}/?id=${encodeURIComponent(n)}`}function ke(e,o){if(typeof window>"u")throw new c(a.Config,"redirectToCheckout requires a browser context (window is undefined)");o?window.location.replace(e):window.location.href=e}function j(e,o){return{checkoutUrl(t){return w(e,o,t.checkoutId)},redirectToCheckout(t){let n=w(e,o,t.checkoutId);ke(n,t.replace===!0)}}}var f="1.0.0";var q="data-maytes-checkout-button",G=`style[${q}="${f}"]`,K=`__maytes_checkout_button_styles_refs_${f}__`,Ee="#6b8aff",Ce=`
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
2
  .maytes-checkout-button {
3
3
  display: inline-flex;
4
4
  align-items: center;
@@ -19,7 +19,7 @@
19
19
  }
20
20
  .maytes-checkout-button:hover { background: ${u.palette.burgundy[700]}; }
21
21
  .maytes-checkout-button:focus-visible {
22
- outline: 2px solid ${Ee};
22
+ outline: 2px solid ${Ie};
23
23
  outline-offset: 2px;
24
24
  }
25
25
  .maytes-checkout-button[aria-disabled='true'] {
@@ -102,7 +102,7 @@
102
102
  .maytes-checkout-overlay__spinner,
103
103
  .maytes-checkout-button__spinner { animation: none; }
104
104
  }
105
- `,z=`
105
+ `,ee=`
106
106
  :root { color-scheme: light; }
107
107
  html, body { margin: 0; height: 100%; }
108
108
  body.maytes-popup-loading {
@@ -146,6 +146,6 @@ body.maytes-popup-loading {
146
146
  @media (prefers-reduced-motion: reduce) {
147
147
  .maytes-popup-loading__spinner { animation: none; }
148
148
  }
149
- `;function Y(){return window[K]??0}function Z(e){let o=window;o[K]=e}function X(e){let o=Y()+1;if(Z(o),document.head.querySelector(G)!==null)return;let t=document.createElement("style");t.setAttribute(q,f),e!==void 0&&e!==""&&t.setAttribute("nonce",e),t.textContent=Ce,document.head.appendChild(t)}function J(){let e=Math.max(0,Y()-1);if(Z(e),e>0)return;let o=document.head.querySelector(G);o!==null&&o.remove()}var S=500,I=800,_e=500,xe=600,Me=8e3;function Q(){let e=h("1em","currentColor");return e.setAttribute("class","maytes-checkout-button__logo"),e.setAttribute("aria-hidden","true"),e}function Se(){let e=document.createElement("span");return e.className="maytes-checkout-button__spinner",e.setAttribute("aria-hidden","true"),e}function Ie(e){if(typeof e!="object"||e===null)return!1;let o=e;return!(typeof o.checkoutId!="string"||o.checkoutId.trim().length===0||o.checkoutUrl!==void 0&&(typeof o.checkoutUrl!="string"||o.checkoutUrl.trim().length===0||!V(o.checkoutUrl)))}function ee(e){return e instanceof DOMException&&e.name==="SecurityError"}function Oe(e){try{e.focus()}catch(o){if(!ee(o))throw o}}function v(e){if(e!==null)try{e.closed||e.close()}catch(o){if(!ee(o))throw o}}function Ae(){let e=window.screen?.width??S,o=window.screen?.height??I,t=Math.max(0,Math.round((e-S)/2)),n=Math.max(0,Math.round((o-I)/2));return`popup=yes,width=${S},height=${I},left=${t},top=${n},resizable=yes,scrollbars=yes`}function g(e){e.popupPollHandle!==null&&(clearInterval(e.popupPollHandle),e.popupPollHandle=null)}function Ue(e,o){g(e),e.popupPollHandle=setInterval(()=>{let t=e.popupWindow;(t===null||t.closed)&&(g(e),e.popupWindow=null,o())},_e)}function Re(){return window.innerWidth<=xe}function Le(e){return window.open("about:blank",e.popupName,Ae())}function Te(e,o){e.location.replace(o)}function Pe(e){for(;e.body.firstChild!==null;)e.body.removeChild(e.body.firstChild)}function Ne(e,o){let t=e.document;if(t===null||t.head===null||t.body===null)return;t.title="Maytes checkout",t.documentElement.lang="en";let n=t.createElement("style");o!==void 0&&o!==""&&n.setAttribute("nonce",o),n.textContent=z,t.head.appendChild(n),t.body.classList.add("maytes-popup-loading"),Pe(t);let i=t.createElement("main");i.className="maytes-popup-loading__content",i.setAttribute("role","status"),i.setAttribute("aria-live","polite");let d=h("2.75rem",u.text.primaryInverse);d.setAttribute("class","maytes-popup-loading__logo"),d.setAttribute("aria-hidden","true"),i.appendChild(d);let r=t.createElement("div");r.className="maytes-popup-loading__spinner",r.setAttribute("aria-hidden","true"),i.appendChild(r);let m=t.createElement("p");m.className="maytes-popup-loading__text",m.textContent="Completing checkout with Maytes\u2026",i.appendChild(m);let p=t.createElement("p");p.className="maytes-popup-loading__slow",p.hidden=!0,p.textContent="Still connecting. This can take a moment on slow networks.",i.appendChild(p),t.body.appendChild(i),setTimeout(()=>{p.hidden=!1},Me)}function te(e,o,t={}){if(e.destroyed)throw new c(a.Config,"renderButton() called on a destroyed Maytes instance");if(!(o instanceof HTMLElement))throw new c(a.Config,"renderButton(container) requires an HTMLElement");X(e.config.cspNonce);let n=t.label??"Split with",i=t.block===!0,d=t.mode??"redirect";if(d!=="redirect"&&d!=="popup")throw new c(a.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 m=document.createTextNode(`${n} `),p=Q();r.appendChild(m),r.appendChild(p);let A=l=>{if(e.busy=l,l)r.setAttribute("aria-disabled","true"),r.setAttribute("aria-busy","true"),p.replaceWith(Se());else{r.removeAttribute("aria-disabled"),r.removeAttribute("aria-busy");let s=r.querySelector(".maytes-checkout-button__spinner, .maytes-checkout-button__logo");s!==null&&s.replaceWith(Q())}},k=()=>{b(e),A(!1)},re=()=>{k(),document.dispatchEvent(new CustomEvent("maytes:checkout-closed"))},U=(l,s)=>{document.dispatchEvent(new CustomEvent("maytes:checkout-failed",{detail:s===void 0?{reason:l}:{reason:l,cause:s}}))},ie=l=>{document.dispatchEvent(new CustomEvent("maytes:checkout-redirected",{detail:{url:l}}))},ce=l=>{k(),ie(l),window.location.href=l},R=l=>{v(l),g(e),e.popupWindow===l&&(e.popupWindow=null),k()},L=async()=>{if(e.busy||e.destroyed)return;A(!0);let l=d==="popup"&&!Re(),s=l?Le(e):null;s!==null&&(e.popupWindow=s,Oe(s),Ne(s,e.config.cspNonce),B(e),document.dispatchEvent(new CustomEvent("maytes:checkout-opened")),Ue(e,re));try{let y=await e.config.createCheckout();if(e.destroyed||s!==null&&s.closed){v(s);return}if(!Ie(y)){R(s);let N=new c(a.Config,"createCheckout must resolve to { checkoutId: string, checkoutUrl?: http(s) URL }");console.error(N),U("invalid-shape",N);return}let P=y.checkoutUrl??w(e.config.environment,e.config.baseUrl,y.checkoutId);s!==null?Te(s,P):(l&&console.warn("[maytes/checkout-button] popup was blocked; falling back to same-window redirect"),ce(P))}catch(y){if(s!==null&&s.closed)return;R(s),console.error("[maytes/checkout-button] createCheckout failed:",y),U("create-checkout-rejected",y)}};r.addEventListener("click",L),o.appendChild(r);let T=!1,E=()=>{T||(T=!0,r.removeEventListener("click",L),r.remove(),e.teardowns.delete(E),J())};return e.teardowns.add(E),E}function oe(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function We(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")try{return`maytes-checkout-${crypto.randomUUID()}`}catch{return`maytes-checkout-${oe()}`}return`maytes-checkout-${oe()}`}function ne(e,o){let t={createCheckout:e.createCheckout,environment:e.environment};return o?.baseUrl!==void 0&&(t.baseUrl=o.baseUrl),o?.cspNonce!==void 0&&(t.cspNonce=o.cspNonce),{config:t,busy:!1,overlayEl:null,popupWindow:null,popupName:We(),popupPollHandle:null,destroyed:!1,teardowns:new Set}}function De(e){if(typeof e!="object"||e===null)throw new c(a.Config,"Maytes() requires an options object");if(typeof e.createCheckout!="function")throw new c(a.Config,"Maytes({ createCheckout }) must be an async function returning { checkoutId }");if(!F(e.environment))throw new c(a.Config,"Maytes({ environment }) must be 'sandbox' or 'production'")}function $e(e){e!==void 0&&e.baseUrl!==void 0&&M(e.baseUrl)}var O=(e,o)=>{De(e),$e(o);let t=ne(e,o),{checkoutUrl:n,redirectToCheckout:i}=j(t.config.environment,t.config.baseUrl);return{renderButton(r,m){return te(t,r,m)},redirectToCheckout(r){i(r)},checkoutUrl(r){return n(r)},destroy(){if(!t.destroyed){t.destroyed=!0,g(t),b(t),v(t.popupWindow),t.popupWindow=null,t.busy=!1;for(let r of[...t.teardowns])r();t.teardowns.clear()}}}};typeof window<"u"&&(window.Maytes=O);return pe(Be);})();
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
150
  window.Maytes = MaytesCheckoutButton.Maytes;
151
151
  //# sourceMappingURL=checkout-button.js.map