@maytes/checkout-button 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +82 -0
- package/README.md +93 -74
- package/dist/checkout-button.299a037b.js +188 -0
- package/dist/checkout-button.299a037b.js.map +1 -0
- package/dist/{checkout-button.2aad12c3.cjs → checkout-button.332d26cc.cjs} +314 -156
- package/dist/checkout-button.332d26cc.cjs.map +1 -0
- package/dist/{checkout-button.aed57a66.mjs → checkout-button.67fdb2e1.mjs} +314 -156
- package/dist/checkout-button.67fdb2e1.mjs.map +1 -0
- package/dist/checkout-button.cjs +314 -156
- package/dist/checkout-button.cjs.map +1 -1
- package/dist/checkout-button.d.cts +40 -4
- package/dist/checkout-button.d.ts +40 -4
- package/dist/checkout-button.element.afe71cd5.js +187 -0
- package/dist/checkout-button.element.afe71cd5.js.map +1 -0
- package/dist/checkout-button.element.js +187 -0
- package/dist/checkout-button.element.js.map +1 -0
- package/dist/checkout-button.js +58 -21
- package/dist/checkout-button.js.map +1 -1
- package/dist/checkout-button.mjs +314 -156
- package/dist/checkout-button.mjs.map +1 -1
- package/dist/element.cjs +201 -0
- package/dist/element.cjs.map +1 -0
- package/dist/element.d.cts +44 -0
- package/dist/element.d.ts +44 -0
- package/dist/element.mjs +180 -0
- package/dist/element.mjs.map +1 -0
- package/dist/integrity.json +37 -26
- package/dist/react.cjs +139 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +30 -0
- package/dist/react.d.ts +30 -0
- package/dist/react.mjs +117 -0
- package/dist/react.mjs.map +1 -0
- package/docs/guides/angular.md +56 -0
- package/docs/guides/api.md +108 -0
- package/docs/guides/events.md +48 -0
- package/docs/guides/launch-behaviour.md +41 -0
- package/docs/guides/nextjs.md +49 -0
- package/docs/guides/own-button.md +41 -0
- package/docs/guides/quickstart-html.md +31 -0
- package/docs/guides/quickstart-npm.md +34 -0
- package/docs/guides/react.md +88 -0
- package/docs/guides/security-csp.md +32 -0
- package/docs/guides/server.md +76 -0
- package/docs/guides/solid.md +44 -0
- package/docs/guides/stripe-payment-element.md +14 -0
- package/docs/guides/svelte.md +46 -0
- package/docs/guides/troubleshooting.md +17 -0
- package/docs/guides/vue-nuxt.md +64 -0
- package/docs/guides/web-component.md +109 -0
- package/package.json +40 -3
- package/dist/checkout-button.2aad12c3.cjs.map +0 -1
- package/dist/checkout-button.4b780d52.js +0 -151
- package/dist/checkout-button.4b780d52.js.map +0 -1
- package/dist/checkout-button.aed57a66.mjs.map +0 -1
|
@@ -1 +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 (host !== document) detachOverlayWhenThisPageHides(state);\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\nfunction detachOverlayWhenThisPageHides(state: InstanceState): void {\n const onPageHide = () => hideOverlay(state);\n window.addEventListener('pagehide', onPageHide);\n state.overlayDetach = () => window.removeEventListener('pagehide', onPageHide);\n}\n\nexport function hideOverlay(state: InstanceState): void {\n if (state.overlayEl === null) return;\n state.overlayDetach?.();\n state.overlayDetach = null;\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.1';\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 overlayDetach: (() => void) | 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 overlayDetach: 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;AACjC,UAAM,OAAO,SAAS,gBAAgB,QAAQ,MAAM;AACpD,SAAK,aAAa,QAAQ,cAAc;AACxC,SAAK,aAAa,KAAK,CAAC;AACxB,QAAI,YAAY,IAAI;AAAA,EACtB;AACA,SAAO;AACT;;;AC9BO,IAAM,kBAAkB;AAAA,EAC7B,QAAQ;AACV;AAIO,IAAM,cAAN,cAA0B,MAAM;AAAA,EAGrC,YAAY,MAA4B,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C5C,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
|
+
{"version":3,"sources":["../src/errors.ts","../src/appearance.ts","../src/foundation/brand.generated.ts","../src/branding.ts","../src/framing.ts","../src/overlay.ts","../src/env.ts","../src/redirect.ts","../src/version.ts","../src/styles.ts","../src/launch.ts","../src/button.ts","../src/state.ts","../src/maytes.ts","../src/index.ts"],"sourcesContent":["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 { MaytesError, MaytesErrorCode } from './errors.js';\nimport type { RenderButtonOptions } from './types.js';\n\nexport const MIN_BUTTON_HEIGHT = 40;\nexport const MAX_BUTTON_HEIGHT = 55;\nexport const MAX_BUTTON_RADIUS = 999;\n\nexport interface ButtonAppearance {\n radius?: number;\n height?: number;\n}\n\nfunction isWholeNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isInteger(value);\n}\n\nexport function assertAppearance(options: Pick<RenderButtonOptions, 'radius' | 'height'>): ButtonAppearance {\n const { radius, height } = options;\n const appearance: ButtonAppearance = {};\n if (height !== undefined) {\n if (!isWholeNumber(height) || height < MIN_BUTTON_HEIGHT || height > MAX_BUTTON_HEIGHT) {\n throw new MaytesError(\n MaytesErrorCode.Config,\n `renderButton({ height }) must be a whole number of pixels from ${MIN_BUTTON_HEIGHT} to ${MAX_BUTTON_HEIGHT}`,\n );\n }\n appearance.height = height;\n }\n if (radius !== undefined) {\n const maxRadius = height === undefined ? MAX_BUTTON_RADIUS : Math.floor(height / 2);\n if (!isWholeNumber(radius) || radius < 0 || radius > maxRadius) {\n throw new MaytesError(\n MaytesErrorCode.Config,\n `renderButton({ radius }) must be a whole number of pixels from 0 to ${maxRadius}`,\n );\n }\n appearance.radius = radius;\n }\n return appearance;\n}\n\nexport function applyAppearance(button: HTMLButtonElement, appearance: ButtonAppearance): void {\n if (appearance.radius !== undefined) button.style.setProperty('--maytes-button-radius', `${appearance.radius}px`);\n if (appearance.height !== undefined) {\n button.style.setProperty('--maytes-button-height', `${appearance.height}px`);\n button.classList.add('maytes-checkout-button--sized');\n }\n}\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","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\nexport type OverlayVariant = 'popup' | 'redirect';\n\nfunction buildOverlay(host: Document, state: InstanceState, variant: OverlayVariant): 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 = variant === 'popup' ? 'Completing checkout with Maytes…' : 'Taking you to Maytes…';\n content.appendChild(text);\n\n if (variant === 'popup') {\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\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, variant: OverlayVariant = 'popup'): void {\n if (state.overlayEl !== null) return;\n const host = resolveOverlayHost();\n ensureOverlayStylesInTopDocument(host);\n const dialog = buildOverlay(host, state, variant);\n state.overlayEl = dialog;\n host.body.appendChild(dialog);\n if (host !== document) detachOverlayWhenThisPageHides(state);\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\nfunction detachOverlayWhenThisPageHides(state: InstanceState): void {\n const onPageHide = () => hideOverlay(state);\n window.addEventListener('pagehide', onPageHide);\n state.overlayDetach = () => window.removeEventListener('pagehide', onPageHide);\n}\n\nexport function hideOverlay(state: InstanceState): void {\n if (state.overlayEl === null) return;\n state.overlayDetach?.();\n state.overlayDetach = null;\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 /* v8 ignore next 6 -- unreachable under jsdom; window is always defined in this SDK's browser-only distribution */\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.2.1';\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 min-height: var(--maytes-button-height, auto);\n padding: 0.71em 1.29em;\n border-radius: var(--maytes-button-radius, 999px);\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 user-select: none;\n}\n.maytes-checkout-button.maytes-checkout-button,\n.maytes-checkout-button.maytes-checkout-button:hover,\n.maytes-checkout-button.maytes-checkout-button:focus,\n.maytes-checkout-button.maytes-checkout-button:active {\n background: ${foundation.brand.primary};\n border: none;\n color: ${foundation.text.primaryInverse};\n box-shadow: none;\n text-decoration: none;\n text-shadow: none;\n filter: none;\n transform: none;\n opacity: 1;\n cursor: pointer;\n transition: background-color 120ms ease, opacity 120ms ease;\n}\n.maytes-checkout-button.maytes-checkout-button:hover { background: ${foundation.palette.burgundy[700]}; }\n.maytes-checkout-button.maytes-checkout-button:focus:not(:focus-visible) { outline: none; }\n.maytes-checkout-button.maytes-checkout-button:focus-visible {\n outline: 2px solid ${FOCUS_RING};\n outline-offset: 2px;\n}\n.maytes-checkout-button.maytes-checkout-button[aria-disabled='true'] {\n cursor: progress;\n opacity: 0.7;\n}\n.maytes-checkout-button.maytes-checkout-button * { transition: none; }\n.maytes-checkout-button.maytes-checkout-button .maytes-checkout-button__logo,\n.maytes-checkout-button.maytes-checkout-button .maytes-checkout-button__logo * {\n animation: none;\n fill: currentColor;\n}\n.maytes-checkout-button--sized {\n box-sizing: border-box;\n white-space: nowrap;\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 font-size: 0.875rem;\n text-underline-offset: 4px;\n font-family: inherit;\n}\n.maytes-checkout-overlay__link.maytes-checkout-overlay__link,\n.maytes-checkout-overlay__link.maytes-checkout-overlay__link:hover,\n.maytes-checkout-overlay__link.maytes-checkout-overlay__link:focus,\n.maytes-checkout-overlay__link.maytes-checkout-overlay__link:active {\n background: none;\n border: none;\n color: rgba(255, 255, 255, 0.7);\n box-shadow: none;\n text-decoration: underline;\n text-shadow: none;\n transform: none;\n opacity: 1;\n cursor: pointer;\n transition: color 0.15s;\n}\n.maytes-checkout-overlay__link.maytes-checkout-overlay__link:hover { color: ${foundation.text.primaryInverse}; }\n.maytes-checkout-overlay__link.maytes-checkout-overlay__link:focus:not(:focus-visible) { outline: none; }\n.maytes-checkout-overlay__link.maytes-checkout-overlay__link:focus-visible {\n outline: 2px solid ${FOCUS_RING};\n outline-offset: 2px;\n}\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 { POPUP_LOADING_CSS } from './styles.js';\nimport type { InstanceState } from './state.js';\nimport type {\n CheckoutEventDetail,\n CheckoutFailedDetail,\n CheckoutFailedReason,\n CheckoutRedirectedDetail,\n LaunchSource,\n OpenCheckoutResult,\n RedirectTarget,\n RenderButtonMode,\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 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\nfunction eventDetail(state: InstanceState, source: LaunchSource): CheckoutEventDetail {\n return { instanceId: state.instanceId, source };\n}\n\nfunction dispatchFailed(origin: CheckoutEventDetail, reason: CheckoutFailedReason, cause?: unknown): void {\n const detail: CheckoutFailedDetail = cause === undefined ? { ...origin, reason } : { ...origin, reason, cause };\n document.dispatchEvent(new CustomEvent('maytes:checkout-failed', { detail }));\n}\n\nfunction dispatchRedirected(origin: CheckoutEventDetail, url: string, target: RedirectTarget): void {\n const detail: CheckoutRedirectedDetail = { ...origin, url, target };\n document.dispatchEvent(new CustomEvent('maytes:checkout-redirected', { detail }));\n}\n\nexport function assertLaunchMode(mode: unknown, caller = 'renderButton'): RenderButtonMode {\n if (mode !== 'redirect' && mode !== 'popup') {\n throw new MaytesError(MaytesErrorCode.Config, `${caller}({ mode }) must be 'redirect' or 'popup'`);\n }\n return mode;\n}\n\nexport function assertRedirectOverlay(value: unknown, caller = 'renderButton'): boolean {\n if (value === undefined) return false;\n if (typeof value !== 'boolean') {\n throw new MaytesError(MaytesErrorCode.Config, `${caller}({ redirectOverlay }) must be true or false`);\n }\n return value;\n}\n\nexport function setInstanceBusy(state: InstanceState, busy: boolean): void {\n state.busy = busy;\n for (const view of [...state.busyViews]) view(busy);\n}\n\nfunction endLaunch(state: InstanceState): void {\n hideOverlay(state);\n setInstanceBusy(state, false);\n}\n\nfunction closeOrphanPopup(state: InstanceState, popup: Window | null): void {\n closePopupWindow(popup);\n stopPopupPoll(state);\n if (state.popupWindow === popup) state.popupWindow = null;\n endLaunch(state);\n}\n\nfunction clearOverlayOnRestore(state: InstanceState): void {\n if (state.restoreDetach !== null) return;\n const onPageShow = (event: PageTransitionEvent): void => {\n if (!event.persisted) return;\n detach();\n endLaunch(state);\n };\n const detach = (): void => {\n window.removeEventListener('pageshow', onPageShow);\n state.restoreDetach = null;\n };\n window.addEventListener('pageshow', onPageShow);\n state.restoreDetach = detach;\n}\n\nfunction navigateAway(\n state: InstanceState,\n origin: CheckoutEventDetail,\n url: string,\n keepOverlay: boolean,\n): OpenCheckoutResult {\n const navigation = navigateTopLevel(url, false);\n if (keepOverlay && (navigation.target === 'self' || navigation.target === 'top')) {\n setInstanceBusy(state, false);\n clearOverlayOnRestore(state);\n } else {\n endLaunch(state);\n }\n if (navigation.target === null) {\n console.error('[maytes/checkout-button] could not leave the embedding frame:', navigation.cause);\n dispatchFailed(origin, 'navigation-blocked', navigation.cause);\n return { outcome: 'failed', reason: 'navigation-blocked' };\n }\n dispatchRedirected(origin, url, navigation.target);\n return { outcome: 'redirected', target: navigation.target };\n}\n\nfunction openPopupLoader(state: InstanceState, origin: CheckoutEventDetail): Window | null {\n const popup = openBlankPopup(state);\n if (popup === null) return 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', { detail: origin }));\n startPopupPoll(state, () => {\n endLaunch(state);\n document.dispatchEvent(new CustomEvent('maytes:checkout-closed', { detail: origin }));\n });\n return popup;\n}\n\nexport async function launchCheckout(\n state: InstanceState,\n mode: RenderButtonMode,\n source: LaunchSource,\n redirectOverlay = false,\n): Promise<OpenCheckoutResult> {\n if (state.busy || state.destroyed) return { outcome: 'ignored' };\n setInstanceBusy(state, true);\n const origin = eventDetail(state, source);\n const shouldUsePopup = mode === 'popup' && !isMobileViewport();\n const popup = shouldUsePopup ? openPopupLoader(state, origin) : null;\n if (popup === null && redirectOverlay) showOverlay(state, 'redirect');\n try {\n const result = await state.config.createCheckout();\n if (state.destroyed || (popup !== null && popup.closed)) {\n closePopupWindow(popup);\n return { outcome: 'closed' };\n }\n if (!isValidCheckoutResult(result)) {\n closeOrphanPopup(state, 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(origin, 'invalid-shape', shapeError);\n return { outcome: 'failed', reason: 'invalid-shape' };\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 return { outcome: 'popup' };\n }\n if (shouldUsePopup) {\n console.warn('[maytes/checkout-button] popup was blocked; redirecting instead');\n }\n return navigateAway(state, origin, url, redirectOverlay);\n } catch (err) {\n if (popup !== null && popup.closed) return { outcome: 'closed' };\n closeOrphanPopup(state, popup);\n console.error('[maytes/checkout-button] createCheckout failed:', err);\n dispatchFailed(origin, 'create-checkout-rejected', err);\n return { outcome: 'failed', reason: 'create-checkout-rejected' };\n }\n}\n","import { applyAppearance, assertAppearance } from './appearance.js';\nimport { buildMaytesLogo } from './branding.js';\nimport { MaytesError, MaytesErrorCode } from './errors.js';\nimport { assertLaunchMode, assertRedirectOverlay, launchCheckout } from './launch.js';\nimport { ensureStylesInjected, releaseStyles } from './styles.js';\nimport type { InstanceState } from './state.js';\nimport type { RenderButtonCleanup, RenderButtonOptions } from './types.js';\n\nexport { closePopupWindow, stopPopupPoll } from './launch.js';\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\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 const appearance = assertAppearance(options);\n const redirectOverlay = assertRedirectOverlay(options.redirectOverlay);\n\n ensureStylesInjected(state.config.cspNonce);\n\n const label = options.label ?? 'Split with';\n const block = options.block === true;\n const mode = assertLaunchMode(options.mode ?? 'popup');\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 applyAppearance(button, appearance);\n button.setAttribute('aria-label', `${label} Maytes`);\n\n const labelNode = document.createTextNode(`${label} `);\n let icon: SVGSVGElement | HTMLSpanElement = buildLogo();\n button.appendChild(labelNode);\n button.appendChild(icon);\n\n const showBusy = (busy: boolean): void => {\n if (busy) {\n button.setAttribute('aria-disabled', 'true');\n button.setAttribute('aria-busy', 'true');\n const spinner = buildSpinner();\n icon.replaceWith(spinner);\n icon = spinner;\n } else {\n button.removeAttribute('aria-disabled');\n button.removeAttribute('aria-busy');\n const nextLogo = buildLogo();\n icon.replaceWith(nextLogo);\n icon = nextLogo;\n }\n };\n let launchedHere = false;\n const followOwnLaunch = (busy: boolean): void => {\n if (!launchedHere) return;\n showBusy(busy);\n if (!busy) launchedHere = false;\n };\n state.busyViews.add(followOwnLaunch);\n\n const handleClick = (): void => {\n if (state.busy || state.destroyed) return;\n launchedHere = true;\n void launchCheckout(state, mode, 'button', redirectOverlay);\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.busyViews.delete(followOwnLaunch);\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 busyViews: Set<(busy: boolean) => void>;\n instanceId: string;\n overlayEl: HTMLDialogElement | null;\n overlayDetach: (() => void) | null;\n restoreDetach: (() => void) | 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 randomSuffix(): string {\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;\n}\n\nfunction randomId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n try {\n return crypto.randomUUID();\n } catch {\n return randomSuffix();\n }\n }\n return randomSuffix();\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 busyViews: new Set(),\n instanceId: randomId(),\n overlayEl: null,\n overlayDetach: null,\n restoreDetach: null,\n popupWindow: null,\n popupNavigated: false,\n popupName: `maytes-checkout-${randomId()}`,\n popupPollHandle: null,\n destroyed: false,\n teardowns: new Set(),\n };\n}\n","import { renderButton } from './button.js';\nimport { assertLaunchMode, assertRedirectOverlay, closePopupWindow, launchCheckout, stopPopupPoll } from './launch.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 instanceId: state.instanceId,\n renderButton(container, opts) {\n return renderButton(state, container, opts);\n },\n openCheckout(opts) {\n if (state.destroyed) {\n throw new MaytesError(MaytesErrorCode.Config, 'openCheckout() called on a destroyed Maytes instance');\n }\n const mode = assertLaunchMode(opts?.mode ?? 'popup', 'openCheckout');\n const redirectOverlay = assertRedirectOverlay(opts?.redirectOverlay, 'openCheckout');\n return launchCheckout(state, mode, 'api', redirectOverlay);\n },\n onBusyChange(listener) {\n if (state.destroyed) {\n throw new MaytesError(MaytesErrorCode.Config, 'onBusyChange() called on a destroyed Maytes instance');\n }\n state.busyViews.add(listener);\n return () => {\n state.busyViews.delete(listener);\n };\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 state.restoreDetach?.();\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 CheckoutClosedDetail,\n CheckoutEventDetail,\n CheckoutFailedDetail,\n CheckoutFailedReason,\n CheckoutOpenedDetail,\n CheckoutRedirectedDetail,\n CheckoutUrlOptions,\n CreateCheckoutFn,\n LaunchSource,\n MaytesEnvironment,\n MaytesFactory,\n MaytesInternalOptions,\n MaytesOptions,\n MaytesSDK,\n OpenCheckoutOptions,\n OpenCheckoutResult,\n RedirectOptions,\n RedirectTarget,\n RenderButtonCleanup,\n RenderButtonMode,\n RenderButtonOptions,\n} from './types.js';\nexport { SDK_VERSION } from './version.js';\n"],"mappings":";AAAO,IAAM,kBAAkB;AAAA,EAC7B,QAAQ;AACV;AAIO,IAAM,cAAN,cAA0B,MAAM;AAAA,EAGrC,YAAY,MAA4B,SAAiB;AACvD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;;;ACXO,IAAM,oBAAoB;AAC1B,IAAM,oBAAoB;AAC1B,IAAM,oBAAoB;AAOjC,SAAS,cAAc,OAAiC;AACtD,SAAO,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK;AAC5D;AAEO,SAAS,iBAAiB,SAA2E;AAC1G,QAAM,EAAE,QAAQ,OAAO,IAAI;AAC3B,QAAM,aAA+B,CAAC;AACtC,MAAI,WAAW,QAAW;AACxB,QAAI,CAAC,cAAc,MAAM,KAAK,SAAS,qBAAqB,SAAS,mBAAmB;AACtF,YAAM,IAAI;AAAA,QACR,gBAAgB;AAAA,QAChB,kEAAkE,iBAAiB,OAAO,iBAAiB;AAAA,MAC7G;AAAA,IACF;AACA,eAAW,SAAS;AAAA,EACtB;AACA,MAAI,WAAW,QAAW;AACxB,UAAM,YAAY,WAAW,SAAY,oBAAoB,KAAK,MAAM,SAAS,CAAC;AAClF,QAAI,CAAC,cAAc,MAAM,KAAK,SAAS,KAA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gD,SAAS;AAC5D;","names":[]}
|
package/dist/element.cjs
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/element.ts
|
|
21
|
+
var element_exports = {};
|
|
22
|
+
__export(element_exports, {
|
|
23
|
+
MAYTES_CHECKOUT_BUTTON_TAG: () => MAYTES_CHECKOUT_BUTTON_TAG,
|
|
24
|
+
MaytesCheckoutButtonElement: () => MaytesCheckoutButtonElement,
|
|
25
|
+
defineMaytesCheckoutButton: () => defineMaytesCheckoutButton,
|
|
26
|
+
readButtonOptions: () => readButtonOptions
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(element_exports);
|
|
29
|
+
var import_checkout_button = require("@maytes/checkout-button");
|
|
30
|
+
var MAYTES_CHECKOUT_BUTTON_TAG = "maytes-checkout-button";
|
|
31
|
+
var OBSERVED_ATTRIBUTES = ["environment", "nonce", "mode", "label", "block", "radius", "height"];
|
|
32
|
+
var INSTANCE_ATTRIBUTES = /* @__PURE__ */ new Set(["environment", "nonce"]);
|
|
33
|
+
var FORWARDED_EVENTS = /* @__PURE__ */ new Map([
|
|
34
|
+
["maytes:checkout-opened", "maytes-opened"],
|
|
35
|
+
["maytes:checkout-closed", "maytes-closed"],
|
|
36
|
+
["maytes:checkout-redirected", "maytes-redirected"],
|
|
37
|
+
["maytes:checkout-failed", "maytes-failed"]
|
|
38
|
+
]);
|
|
39
|
+
var LAUNCH_ENDING_EVENTS = /* @__PURE__ */ new Set(["maytes:checkout-closed", "maytes:checkout-redirected", "maytes:checkout-failed"]);
|
|
40
|
+
var BaseElement = typeof HTMLElement === "undefined" ? class {
|
|
41
|
+
} : HTMLElement;
|
|
42
|
+
function numberAttribute(value) {
|
|
43
|
+
if (value === null || value.trim() === "") return void 0;
|
|
44
|
+
return Number(value);
|
|
45
|
+
}
|
|
46
|
+
function readButtonOptions(element) {
|
|
47
|
+
const options = { block: element.hasAttribute("block") };
|
|
48
|
+
const mode = element.getAttribute("mode");
|
|
49
|
+
if (mode !== null) options.mode = mode;
|
|
50
|
+
const label = element.getAttribute("label");
|
|
51
|
+
if (label !== null) options.label = label;
|
|
52
|
+
const radius = numberAttribute(element.getAttribute("radius"));
|
|
53
|
+
if (radius !== void 0) options.radius = radius;
|
|
54
|
+
const height = numberAttribute(element.getAttribute("height"));
|
|
55
|
+
if (height !== void 0) options.height = height;
|
|
56
|
+
return options;
|
|
57
|
+
}
|
|
58
|
+
var MaytesCheckoutButtonElement = class extends BaseElement {
|
|
59
|
+
constructor() {
|
|
60
|
+
super(...arguments);
|
|
61
|
+
this.checkoutCallback = null;
|
|
62
|
+
this.maytes = null;
|
|
63
|
+
this.removeButton = null;
|
|
64
|
+
this.launching = false;
|
|
65
|
+
this.recreatePending = false;
|
|
66
|
+
this.listening = false;
|
|
67
|
+
this.forward = (event) => {
|
|
68
|
+
const maytes = this.maytes;
|
|
69
|
+
const name = FORWARDED_EVENTS.get(event.type);
|
|
70
|
+
if (maytes === null || name === void 0) return;
|
|
71
|
+
const detail = event.detail;
|
|
72
|
+
if (detail?.instanceId !== maytes.instanceId) return;
|
|
73
|
+
this.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));
|
|
74
|
+
if (LAUNCH_ENDING_EVENTS.has(event.type)) this.launchEnded();
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
static get observedAttributes() {
|
|
78
|
+
return OBSERVED_ATTRIBUTES;
|
|
79
|
+
}
|
|
80
|
+
get createCheckout() {
|
|
81
|
+
return this.checkoutCallback;
|
|
82
|
+
}
|
|
83
|
+
set createCheckout(callback) {
|
|
84
|
+
this.checkoutCallback = typeof callback === "function" ? callback : null;
|
|
85
|
+
this.mount();
|
|
86
|
+
}
|
|
87
|
+
get instanceId() {
|
|
88
|
+
return this.maytes?.instanceId ?? null;
|
|
89
|
+
}
|
|
90
|
+
open(options) {
|
|
91
|
+
if (this.maytes === null) return Promise.resolve({ outcome: "ignored" });
|
|
92
|
+
return this.maytes.openCheckout(options);
|
|
93
|
+
}
|
|
94
|
+
connectedCallback() {
|
|
95
|
+
this.mount();
|
|
96
|
+
}
|
|
97
|
+
disconnectedCallback() {
|
|
98
|
+
queueMicrotask(() => {
|
|
99
|
+
if (!this.isConnected) this.unmount();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
attributeChangedCallback(name, previous, next) {
|
|
103
|
+
if (previous === next) return;
|
|
104
|
+
if (this.maytes === null) {
|
|
105
|
+
this.mount();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (INSTANCE_ATTRIBUTES.has(name)) {
|
|
109
|
+
this.recreateWhenIdle();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this.renderButton(this.maytes);
|
|
113
|
+
}
|
|
114
|
+
mount() {
|
|
115
|
+
if (!this.isConnected || this.checkoutCallback === null || this.maytes !== null) return;
|
|
116
|
+
const nonce = this.getAttribute("nonce");
|
|
117
|
+
let maytes;
|
|
118
|
+
try {
|
|
119
|
+
maytes = (0, import_checkout_button.Maytes)(
|
|
120
|
+
{
|
|
121
|
+
createCheckout: () => this.startCheckout(),
|
|
122
|
+
environment: this.getAttribute("environment")
|
|
123
|
+
},
|
|
124
|
+
nonce === null ? void 0 : { cspNonce: nonce }
|
|
125
|
+
);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
this.reportConfigError(error);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
this.maytes = maytes;
|
|
131
|
+
this.listen();
|
|
132
|
+
this.renderButton(maytes);
|
|
133
|
+
}
|
|
134
|
+
renderButton(maytes) {
|
|
135
|
+
let removeButton;
|
|
136
|
+
try {
|
|
137
|
+
removeButton = maytes.renderButton(this, readButtonOptions(this));
|
|
138
|
+
} catch (error) {
|
|
139
|
+
this.reportConfigError(error);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
this.removeButton?.();
|
|
143
|
+
this.removeButton = removeButton;
|
|
144
|
+
}
|
|
145
|
+
recreateWhenIdle() {
|
|
146
|
+
if (this.launching) {
|
|
147
|
+
this.recreatePending = true;
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
this.unmount();
|
|
151
|
+
this.mount();
|
|
152
|
+
}
|
|
153
|
+
launchEnded() {
|
|
154
|
+
this.launching = false;
|
|
155
|
+
if (!this.recreatePending) return;
|
|
156
|
+
this.recreatePending = false;
|
|
157
|
+
queueMicrotask(() => this.recreateWhenIdle());
|
|
158
|
+
}
|
|
159
|
+
listen() {
|
|
160
|
+
if (this.listening) return;
|
|
161
|
+
this.listening = true;
|
|
162
|
+
for (const type of FORWARDED_EVENTS.keys()) document.addEventListener(type, this.forward);
|
|
163
|
+
}
|
|
164
|
+
unlisten() {
|
|
165
|
+
if (!this.listening) return;
|
|
166
|
+
this.listening = false;
|
|
167
|
+
for (const type of FORWARDED_EVENTS.keys()) document.removeEventListener(type, this.forward);
|
|
168
|
+
}
|
|
169
|
+
reportConfigError(error) {
|
|
170
|
+
if (!(error instanceof import_checkout_button.MaytesError)) throw error;
|
|
171
|
+
console.error("[maytes/checkout-button] <maytes-checkout-button> configuration error:", error);
|
|
172
|
+
const detail = { reason: "config", cause: error };
|
|
173
|
+
this.dispatchEvent(new CustomEvent("maytes-failed", { detail, bubbles: true, composed: true }));
|
|
174
|
+
}
|
|
175
|
+
startCheckout() {
|
|
176
|
+
const callback = this.checkoutCallback;
|
|
177
|
+
if (callback === null) {
|
|
178
|
+
return Promise.reject(new import_checkout_button.MaytesError(import_checkout_button.MaytesErrorCode.Config, "<maytes-checkout-button> has no createCheckout"));
|
|
179
|
+
}
|
|
180
|
+
this.launching = true;
|
|
181
|
+
return callback();
|
|
182
|
+
}
|
|
183
|
+
unmount() {
|
|
184
|
+
this.unlisten();
|
|
185
|
+
this.removeButton?.();
|
|
186
|
+
this.removeButton = null;
|
|
187
|
+
this.maytes?.destroy();
|
|
188
|
+
this.maytes = null;
|
|
189
|
+
this.launching = false;
|
|
190
|
+
this.recreatePending = false;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
function defineMaytesCheckoutButton() {
|
|
194
|
+
if (typeof customElements === "undefined") return false;
|
|
195
|
+
if (customElements.get(MAYTES_CHECKOUT_BUTTON_TAG) === void 0) {
|
|
196
|
+
customElements.define(MAYTES_CHECKOUT_BUTTON_TAG, MaytesCheckoutButtonElement);
|
|
197
|
+
}
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
defineMaytesCheckoutButton();
|
|
201
|
+
//# sourceMappingURL=element.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/element.ts"],"sourcesContent":["import { Maytes, MaytesError, MaytesErrorCode } from '@maytes/checkout-button';\nimport type {\n CheckoutClosedDetail,\n CheckoutFailedDetail,\n CheckoutOpenedDetail,\n CheckoutRedirectedDetail,\n CreateCheckoutFn,\n MaytesEnvironment,\n MaytesSDK,\n OpenCheckoutOptions,\n OpenCheckoutResult,\n RenderButtonCleanup,\n RenderButtonMode,\n RenderButtonOptions,\n} from '@maytes/checkout-button';\n\nexport const MAYTES_CHECKOUT_BUTTON_TAG = 'maytes-checkout-button';\n\nexport interface ElementConfigFailedDetail {\n reason: 'config';\n cause: unknown;\n}\n\nexport type MaytesElementFailedDetail = CheckoutFailedDetail | ElementConfigFailedDetail;\n\nconst OBSERVED_ATTRIBUTES = ['environment', 'nonce', 'mode', 'label', 'block', 'radius', 'height'];\nconst INSTANCE_ATTRIBUTES = new Set(['environment', 'nonce']);\n\nconst FORWARDED_EVENTS = new Map<string, string>([\n ['maytes:checkout-opened', 'maytes-opened'],\n ['maytes:checkout-closed', 'maytes-closed'],\n ['maytes:checkout-redirected', 'maytes-redirected'],\n ['maytes:checkout-failed', 'maytes-failed'],\n]);\n\nconst LAUNCH_ENDING_EVENTS = new Set(['maytes:checkout-closed', 'maytes:checkout-redirected', 'maytes:checkout-failed']);\n\ntype SdkEventDetail = CheckoutOpenedDetail | CheckoutClosedDetail | CheckoutRedirectedDetail | CheckoutFailedDetail;\n\nconst BaseElement = (typeof HTMLElement === 'undefined' ? class {} : HTMLElement) as typeof HTMLElement;\n\nfunction numberAttribute(value: string | null): number | undefined {\n if (value === null || value.trim() === '') return undefined;\n return Number(value);\n}\n\nexport function readButtonOptions(element: Element): RenderButtonOptions {\n const options: RenderButtonOptions = { block: element.hasAttribute('block') };\n const mode = element.getAttribute('mode');\n if (mode !== null) options.mode = mode as RenderButtonMode;\n const label = element.getAttribute('label');\n if (label !== null) options.label = label;\n const radius = numberAttribute(element.getAttribute('radius'));\n if (radius !== undefined) options.radius = radius;\n const height = numberAttribute(element.getAttribute('height'));\n if (height !== undefined) options.height = height;\n return options;\n}\n\nexport class MaytesCheckoutButtonElement extends BaseElement {\n private checkoutCallback: CreateCheckoutFn | null = null;\n private maytes: MaytesSDK | null = null;\n private removeButton: RenderButtonCleanup | null = null;\n private launching = false;\n private recreatePending = false;\n private listening = false;\n\n static get observedAttributes(): string[] {\n return OBSERVED_ATTRIBUTES;\n }\n\n get createCheckout(): CreateCheckoutFn | null {\n return this.checkoutCallback;\n }\n\n set createCheckout(callback: CreateCheckoutFn | null) {\n this.checkoutCallback = typeof callback === 'function' ? callback : null;\n this.mount();\n }\n\n get instanceId(): string | null {\n return this.maytes?.instanceId ?? null;\n }\n\n open(options?: OpenCheckoutOptions): Promise<OpenCheckoutResult> {\n if (this.maytes === null) return Promise.resolve({ outcome: 'ignored' });\n return this.maytes.openCheckout(options);\n }\n\n connectedCallback(): void {\n this.mount();\n }\n\n disconnectedCallback(): void {\n queueMicrotask(() => {\n if (!this.isConnected) this.unmount();\n });\n }\n\n attributeChangedCallback(name: string, previous: string | null, next: string | null): void {\n if (previous === next) return;\n if (this.maytes === null) {\n this.mount();\n return;\n }\n if (INSTANCE_ATTRIBUTES.has(name)) {\n this.recreateWhenIdle();\n return;\n }\n this.renderButton(this.maytes);\n }\n\n private mount(): void {\n if (!this.isConnected || this.checkoutCallback === null || this.maytes !== null) return;\n const nonce = this.getAttribute('nonce');\n let maytes: MaytesSDK;\n try {\n maytes = Maytes(\n {\n createCheckout: () => this.startCheckout(),\n environment: this.getAttribute('environment') as MaytesEnvironment,\n },\n nonce === null ? undefined : { cspNonce: nonce },\n );\n } catch (error) {\n this.reportConfigError(error);\n return;\n }\n this.maytes = maytes;\n this.listen();\n this.renderButton(maytes);\n }\n\n private renderButton(maytes: MaytesSDK): void {\n let removeButton: RenderButtonCleanup;\n try {\n removeButton = maytes.renderButton(this, readButtonOptions(this));\n } catch (error) {\n this.reportConfigError(error);\n return;\n }\n this.removeButton?.();\n this.removeButton = removeButton;\n }\n\n private recreateWhenIdle(): void {\n if (this.launching) {\n this.recreatePending = true;\n return;\n }\n this.unmount();\n this.mount();\n }\n\n private readonly forward = (event: Event): void => {\n const maytes = this.maytes;\n const name = FORWARDED_EVENTS.get(event.type);\n if (maytes === null || name === undefined) return;\n const detail = (event as CustomEvent<SdkEventDetail | undefined>).detail;\n if (detail?.instanceId !== maytes.instanceId) return;\n this.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));\n if (LAUNCH_ENDING_EVENTS.has(event.type)) this.launchEnded();\n };\n\n private launchEnded(): void {\n this.launching = false;\n if (!this.recreatePending) return;\n this.recreatePending = false;\n queueMicrotask(() => this.recreateWhenIdle());\n }\n\n private listen(): void {\n if (this.listening) return;\n this.listening = true;\n for (const type of FORWARDED_EVENTS.keys()) document.addEventListener(type, this.forward);\n }\n\n private unlisten(): void {\n if (!this.listening) return;\n this.listening = false;\n for (const type of FORWARDED_EVENTS.keys()) document.removeEventListener(type, this.forward);\n }\n\n private reportConfigError(error: unknown): void {\n if (!(error instanceof MaytesError)) throw error;\n console.error('[maytes/checkout-button] <maytes-checkout-button> configuration error:', error);\n const detail: ElementConfigFailedDetail = { reason: 'config', cause: error };\n this.dispatchEvent(new CustomEvent('maytes-failed', { detail, bubbles: true, composed: true }));\n }\n\n private startCheckout(): ReturnType<CreateCheckoutFn> {\n const callback = this.checkoutCallback;\n if (callback === null) {\n return Promise.reject(new MaytesError(MaytesErrorCode.Config, '<maytes-checkout-button> has no createCheckout'));\n }\n this.launching = true;\n return callback();\n }\n\n private unmount(): void {\n this.unlisten();\n this.removeButton?.();\n this.removeButton = null;\n this.maytes?.destroy();\n this.maytes = null;\n this.launching = false;\n this.recreatePending = false;\n }\n}\n\nexport function defineMaytesCheckoutButton(): boolean {\n if (typeof customElements === 'undefined') return false;\n if (customElements.get(MAYTES_CHECKOUT_BUTTON_TAG) === undefined) {\n customElements.define(MAYTES_CHECKOUT_BUTTON_TAG, MaytesCheckoutButtonElement);\n }\n return true;\n}\n\ndefineMaytesCheckoutButton();\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'maytes-checkout-button': MaytesCheckoutButtonElement;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAAqD;AAgB9C,IAAM,6BAA6B;AAS1C,IAAM,sBAAsB,CAAC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0E,KAAK;AAC7F,UAAM,SAAoC,EAAE,QAAQ,UAAU,OAAO,MAAM;AAC3E,SAAK,cAAc,IAAI,YAAY,iBAAiB,EAAE,QAAQ,SAAS,MAAM,UAAU,KAAK,CAAC,CAAC;AAAA,EAChG;AAAA,EAEQ,gBAA8C;AACpD,UAAM,WAAW,KAAK;AACtB,QAAI,aAAa,MAAM;AACrB,aAAO,QAAQ,OAAO,IAAI,mCAAY,uCAAgB,QAAQ,gDAAgD,CAAC;AAAA,IACjH;AACA,SAAK,YAAY;AACjB,WAAO,SAAS;AAAA,EAClB;AAAA,EAEQ,UAAgB;AACtB,SAAK,SAAS;AACd,SAAK,eAAe;AACpB,SAAK,eAAe;AACpB,SAAK,QAAQ,QAAQ;AACrB,SAAK,SAAS;AACd,SAAK,YAAY;AACjB,SAAK,kBAAkB;AAAA,EACzB;AACF;AAEO,SAAS,6BAAsC;AACpD,MAAI,OAAO,mBAAmB,YAAa,QAAO;AAClD,MAAI,eAAe,IAAI,0BAA0B,MAAM,QAAW;AAChE,mBAAe,OAAO,4BAA4B,2BAA2B;AAAA,EAC/E;AACA,SAAO;AACT;AAEA,2BAA2B;","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CreateCheckoutFn, OpenCheckoutOptions, OpenCheckoutResult, CheckoutFailedDetail, RenderButtonOptions } from '@maytes/checkout-button';
|
|
2
|
+
|
|
3
|
+
declare const MAYTES_CHECKOUT_BUTTON_TAG = "maytes-checkout-button";
|
|
4
|
+
interface ElementConfigFailedDetail {
|
|
5
|
+
reason: 'config';
|
|
6
|
+
cause: unknown;
|
|
7
|
+
}
|
|
8
|
+
type MaytesElementFailedDetail = CheckoutFailedDetail | ElementConfigFailedDetail;
|
|
9
|
+
declare const BaseElement: typeof HTMLElement;
|
|
10
|
+
declare function readButtonOptions(element: Element): RenderButtonOptions;
|
|
11
|
+
declare class MaytesCheckoutButtonElement extends BaseElement {
|
|
12
|
+
private checkoutCallback;
|
|
13
|
+
private maytes;
|
|
14
|
+
private removeButton;
|
|
15
|
+
private launching;
|
|
16
|
+
private recreatePending;
|
|
17
|
+
private listening;
|
|
18
|
+
static get observedAttributes(): string[];
|
|
19
|
+
get createCheckout(): CreateCheckoutFn | null;
|
|
20
|
+
set createCheckout(callback: CreateCheckoutFn | null);
|
|
21
|
+
get instanceId(): string | null;
|
|
22
|
+
open(options?: OpenCheckoutOptions): Promise<OpenCheckoutResult>;
|
|
23
|
+
connectedCallback(): void;
|
|
24
|
+
disconnectedCallback(): void;
|
|
25
|
+
attributeChangedCallback(name: string, previous: string | null, next: string | null): void;
|
|
26
|
+
private mount;
|
|
27
|
+
private renderButton;
|
|
28
|
+
private recreateWhenIdle;
|
|
29
|
+
private readonly forward;
|
|
30
|
+
private launchEnded;
|
|
31
|
+
private listen;
|
|
32
|
+
private unlisten;
|
|
33
|
+
private reportConfigError;
|
|
34
|
+
private startCheckout;
|
|
35
|
+
private unmount;
|
|
36
|
+
}
|
|
37
|
+
declare function defineMaytesCheckoutButton(): boolean;
|
|
38
|
+
declare global {
|
|
39
|
+
interface HTMLElementTagNameMap {
|
|
40
|
+
'maytes-checkout-button': MaytesCheckoutButtonElement;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { type ElementConfigFailedDetail, MAYTES_CHECKOUT_BUTTON_TAG, MaytesCheckoutButtonElement, type MaytesElementFailedDetail, defineMaytesCheckoutButton, readButtonOptions };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CreateCheckoutFn, OpenCheckoutOptions, OpenCheckoutResult, CheckoutFailedDetail, RenderButtonOptions } from '@maytes/checkout-button';
|
|
2
|
+
|
|
3
|
+
declare const MAYTES_CHECKOUT_BUTTON_TAG = "maytes-checkout-button";
|
|
4
|
+
interface ElementConfigFailedDetail {
|
|
5
|
+
reason: 'config';
|
|
6
|
+
cause: unknown;
|
|
7
|
+
}
|
|
8
|
+
type MaytesElementFailedDetail = CheckoutFailedDetail | ElementConfigFailedDetail;
|
|
9
|
+
declare const BaseElement: typeof HTMLElement;
|
|
10
|
+
declare function readButtonOptions(element: Element): RenderButtonOptions;
|
|
11
|
+
declare class MaytesCheckoutButtonElement extends BaseElement {
|
|
12
|
+
private checkoutCallback;
|
|
13
|
+
private maytes;
|
|
14
|
+
private removeButton;
|
|
15
|
+
private launching;
|
|
16
|
+
private recreatePending;
|
|
17
|
+
private listening;
|
|
18
|
+
static get observedAttributes(): string[];
|
|
19
|
+
get createCheckout(): CreateCheckoutFn | null;
|
|
20
|
+
set createCheckout(callback: CreateCheckoutFn | null);
|
|
21
|
+
get instanceId(): string | null;
|
|
22
|
+
open(options?: OpenCheckoutOptions): Promise<OpenCheckoutResult>;
|
|
23
|
+
connectedCallback(): void;
|
|
24
|
+
disconnectedCallback(): void;
|
|
25
|
+
attributeChangedCallback(name: string, previous: string | null, next: string | null): void;
|
|
26
|
+
private mount;
|
|
27
|
+
private renderButton;
|
|
28
|
+
private recreateWhenIdle;
|
|
29
|
+
private readonly forward;
|
|
30
|
+
private launchEnded;
|
|
31
|
+
private listen;
|
|
32
|
+
private unlisten;
|
|
33
|
+
private reportConfigError;
|
|
34
|
+
private startCheckout;
|
|
35
|
+
private unmount;
|
|
36
|
+
}
|
|
37
|
+
declare function defineMaytesCheckoutButton(): boolean;
|
|
38
|
+
declare global {
|
|
39
|
+
interface HTMLElementTagNameMap {
|
|
40
|
+
'maytes-checkout-button': MaytesCheckoutButtonElement;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { type ElementConfigFailedDetail, MAYTES_CHECKOUT_BUTTON_TAG, MaytesCheckoutButtonElement, type MaytesElementFailedDetail, defineMaytesCheckoutButton, readButtonOptions };
|