UNPKG

@whop/checkout

Version:

Embed Whop checkout on any website

1 lines 22.3 kB
function e(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function t(t){if(Array.isArray(t))return e(t)}function r(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function n(e,t,r){t=u(t);return g(e,C()?Reflect.construct(t,r||[],u(e).constructor):t.apply(e,r))}function i(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function o(e,t,r){if(C()){o=Reflect.construct}else{o=function e(e,t,r){var n=[null];n.push.apply(n,t);var i=Function.bind.apply(e,n);var o=new i;if(r)b(o,r.prototype);return o}}return o.apply(null,arguments)}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function s(e,t,r){if(t)a(e.prototype,t);if(r)a(e,r);return e}function l(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}function u(e){u=Object.setPrototypeOf?Object.getPrototypeOf:function e(e){return e.__proto__||Object.getPrototypeOf(e)};return u(e)}function d(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});if(t)b(e,t)}function c(e,t){if(t!=null&&typeof Symbol!=="undefined"&&t[Symbol.hasInstance]){return!!t[Symbol.hasInstance](e)}else{return e instanceof t}}function p(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function h(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function f(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function v(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var n=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))}n.forEach(function(t){l(e,t,r[t])})}return e}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(t){n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}r.push.apply(r,n)}return r}function y(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{m(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function g(e,t){if(t&&(k(t)==="object"||typeof t==="function")){return t}return r(e)}function b(e,t){b=Object.setPrototypeOf||function e(e,t){e.__proto__=t;return e};return b(e,t)}function w(e){return t(e)||h(e)||A(e)||f()}function k(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function A(t,r){if(!t)return;if(typeof t==="string")return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor)n=t.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(t,r)}function O(e){var t=typeof Map==="function"?new Map:undefined;O=function e(e){if(e===null||!p(e))return e;if(typeof e!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof t!=="undefined"){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return o(e,arguments,u(this).constructor)}r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}});return b(r,e)};return O(e)}function C(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(C=function(){return!!e})()}import{a as R,c as I,d as _,k as S,m as E,o as x,p as L,q as P,r as j,s as M,t as U,u as q,v as T}from"./chunk-VM3BGBF7.mjs";var F="data-whop-checkout-overlay",B=1500,D={padding:"0",border:"0",background:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",position:"fixed",inset:"0",width:"100vw",maxWidth:"100vw",height:"100dvh",maxHeight:"100dvh"},G=null;function W(){return G!==null}function H(){if(!G)return;var e=G.dialog,t=G.cleanup;try{e.close()}catch(e){t()}}function z(e){var t;if(G)return G.channelId===e.channelId?G:null;var r=document.createElement("dialog");r.setAttribute(F,"true"),Object.assign(r.style,D);var n=document.createElement("iframe");n.src=e.iframeSrc,n.style.display="block",n.style.width="100%",n.style.height="100%",n.style.border="0",n.style.background="transparent",n.style.colorScheme="normal",n.setAttribute("frameborder","no"),(t=n.sandbox).add.apply(t,w(j)),n.allow=M,r.appendChild(n),document.body.appendChild(r);var i=document.body.style.overflow;document.body.style.overflow="hidden";var o=_(n,function(e){e.event==="close-overlay"&&H()}),a=!1,s=function(){var t;a||(a=!0,o(),document.body.style.overflow=i,r.remove(),G=null,(t=e.onClose)===null||t===void 0?void 0:t.call(e))};r.addEventListener("close",s),r.addEventListener("cancel",function(e){e.preventDefault();try{var t;var r=new URL(n.src).origin;(t=n.contentWindow)===null||t===void 0?void 0:t.postMessage({__scope:"whop-embedded-checkout",event:"host-cancel-requested"},r)}catch(e){}});try{r.showModal()}catch(e){return o(),document.body.style.overflow=i,r.remove(),null}return G={dialog:r,iframe:n,channelId:e.channelId,cleanup:s},G}function V(e){if(!G||G.channelId!==e)return;var t=G.dialog,r=G.cleanup;try{t.close()}catch(e){r()}}function $(e){var t=null;function r(r){var n;var i=e.getOverlayContext(),o=(r.event==="request-overlay"?P:L)({channelId:r.channelId,theme:i.theme,origin:i.origin,environment:i.environment,locale:i.locale}),a=r.event==="request-requirement-overlay"?r.iframeSrc:void 0,s=o;if(a)try{var l=new URL(a),u=new URL(o);l.origin===u.origin&&l.pathname===u.pathname&&l.searchParams.get("channel")===r.channelId&&!l.searchParams.has("secret")&&(s=l.toString())}catch(e){}if(z({channelId:r.channelId,iframeSrc:s,onClose:function(){var n;t===r.channelId&&(t=null),(n=e.onOverlayClose)===null||n===void 0?void 0:n.call(e)}})){var d;var c=t===r.channelId;t=r.channelId,c||((d=e.onOverlayOpen)===null||d===void 0?void 0:d.call(e))}else(n=e.onOverlayClose)===null||n===void 0?void 0:n.call(e)}function n(e){e.channelId?V(e.channelId):H()}function i(){if(t&&W()){var e=t;window.setTimeout(function(){return V(e)},B)}}function o(){t&&V(t)}return{handleOverlayRequest:r,handleCloseOverlay:n,scheduleAutoCloseAfterComplete:i,closeOwnOverlay:o}}function J(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++){r[n-1]=arguments[n]}if(!e)return;var i=window[e];i===null||i===void 0?void 0:i.apply(void 0,w(r))}function K(e,t){var r=$({getOverlayContext:t.getOverlayContext,onOverlayOpen:t.onOverlayOpen,onOverlayClose:t.onOverlayClose}),n=_(e,function(n){switch(n.event){case"resize":{var i;e.style.height="".concat(n.height,"px"),(i=t.onResize)===null||i===void 0?void 0:i.call(t,n.height);break}case"center":{e.scrollIntoView({block:"center",inline:"center"});break}case"complete":{var o;var a=n.setup_intent_id||n.receipt_id;J(t.getCallback("on-complete"),n.plan_id,a),(o=t.onComplete)===null||o===void 0?void 0:o.call(t,n.plan_id,a),r.scheduleAutoCloseAfterComplete();break}case"state":{J(t.getCallback("on-state-change"),n.state);break}case"address-validation-error":{J(t.getCallback("on-address-validation-error"),{error_message:n.error_message,error_code:n.error_code});break}case"payment-error":{J(t.getCallback("on-payment-error"),{message:n.message,code:n.code});break}case"promo-code-changed":{J(t.getCallback("on-promo-code-changed"),n.promoCode);break}case"identity-captured":{U(n),J(t.getCallback("on-identity-captured"),{email:n.email,user_id:n.user_id});break}case"currencies-available":{var s;var l={base_currency:n.base_currency,optional_currency:n.optional_currency,current_currency:n.current_currency,exchange_rate:n.exchange_rate},u=e.dataset.whopCheckoutIdentifier;u&&((s=window.wco)===null||s===void 0?void 0:s.availableCurrencies.set(u,l)),J(t.getCallback("on-currencies-available"),l);break}case"currency-changed":{var d=e.dataset.whopCheckoutIdentifier;if(d){var c,p;var h=(c=window.wco)===null||c===void 0?void 0:c.availableCurrencies.get(d);h&&((p=window.wco)===null||p===void 0?void 0:p.availableCurrencies.set(d,y(v({},h),{current_currency:n.currency,exchange_rate:n.exchange_rate})))}J(t.getCallback("on-currency-changed"),{currency:n.currency,exchange_rate:n.exchange_rate});break}case"express-method-resolved":{var f;(f=t.onExpressMethodResolved)===null||f===void 0?void 0:f.call(t,n.rendered),J(t.getCallback("on-express-method-resolved"),{rendered:n.rendered});break}case"express-loading":{var m;(m=t.onExpressLoadingChange)===null||m===void 0?void 0:m.call(t,n.loading);break}}},r);return function(){n(),r.closeOwnOverlay()}}var N=["apple-pay","whop-pay"];function Q(e){if(!e)return;var t=Array.from(new Set(e.split(",").map(function(e){return e.trim().toLowerCase()}).filter(function(e){return N.includes(e)})));return t.length>0?t:void 0}var X=["session","hide-price","hide-submit-button","hide-tos","hide-email","disable-email","hide-address","on-state-change","on-address-validation-error","on-promo-code-changed"];function Y(e){var t=X.filter(function(t){return e.hasAttribute(t)}),r=Array.from(e.attributes).map(function(e){return e.name}).filter(function(e){return e.startsWith("style-")});t.length===0&&r.length===0||console.warn("[whop-checkout] Ignoring attributes on <whop-express-checkout-button>: ".concat(w(t).concat(w(r)).join(", ")))}function Z(e){var t={},r=e.getAttribute("prefill-email");return r&&(t.email=r),ee(e,t,"billing"),ee(e,t,"shipping"),t}function ee(e,t,r){var n=r==="billing"?"prefill":"prefill-shipping",i=function(){var e,n;return r==="billing"?((e=t.address)!==null&&e!==void 0?e:t.address={},t.address):((n=t.shippingAddress)!==null&&n!==void 0?n:t.shippingAddress={},t.shippingAddress)},o=e.getAttribute("".concat(n,"-name"));o&&(i().name=o);var a=e.getAttribute("".concat(n,"-address-line1"));a&&(i().line1=a);var s=e.getAttribute("".concat(n,"-address-line2"));s&&(i().line2=s);var l=e.getAttribute("".concat(n,"-address-city"));l&&(i().city=l);var u=e.getAttribute("".concat(n,"-address-country"));u&&(i().country=u);var d=e.getAttribute("".concat(n,"-address-state"));d&&(i().state=d);var c=e.getAttribute("".concat(n,"-address-postal-code"));c&&(i().postalCode=c)}function et(e){var t={},r=e.getAttribute("theme-accent-color");r&&(t.accentColor=r);var n=e.getAttribute("theme-high-contrast");return n!==null&&(t.highContrast=n==="true"),t}var er=new Set;function en(){var e=er.size>0;var t=true,r=false,n=undefined;try{for(var i=document.querySelectorAll("whop-express-checkout-button")[Symbol.iterator](),o;!(t=(o=i.next()).done);t=true){var a=o.value;if(!c(a,HTMLElement))continue;var s=er.has(a);e&&!s?(a.toggleAttribute("data-disabled-by-peer",!0),a.toggleAttribute("inert",!0)):(a.toggleAttribute("data-disabled-by-peer",!1),a.toggleAttribute("inert",!1))}}catch(e){r=true;n=e}finally{try{if(!t&&i.return!=null){i.return()}}finally{if(r){throw n}}}}var ei="whop-express-checkout-button-peer-disabled-styles";function eo(){if(document.getElementById(ei))return;var e=document.createElement("style");e.id=ei,e.textContent="\n whop-express-checkout-button[data-disabled-by-peer] {\n pointer-events: none;\n opacity: 0.55;\n filter: grayscale(0.6);\n transition: opacity 150ms ease, filter 150ms ease;\n }\n ",document.head.appendChild(e)}var ea=["plan-id","checkout-configuration-id","environment","origin","affiliate-code","state-id","setup-future-usage","adaptive-pricing","wuid","promo-code","locale","methods"],es=function(e){return e==="true"?"1":null},el={theme:{key:"theme"},"theme-accent-color":{key:"theme.accentColor"},"theme-high-contrast":{key:"theme.highContrast",transform:es},"return-url":{key:"payment_redirect_url"},"redirect-url":{key:"payment_redirect_url"},"prefill-email":{key:"email"},"prefill-name":{key:"name"},"prefill-address-line1":{key:"address.line1"},"prefill-address-line2":{key:"address.line2"},"prefill-address-city":{key:"address.city"},"prefill-address-country":{key:"address.country"},"prefill-address-state":{key:"address.state"},"prefill-address-postal-code":{key:"address.postal_code"},"prefill-shipping-name":{key:"shipping.name"},"prefill-shipping-address-line1":{key:"shipping.address.line1"},"prefill-shipping-address-line2":{key:"shipping.address.line2"},"prefill-shipping-address-city":{key:"shipping.address.city"},"prefill-shipping-address-country":{key:"shipping.address.country"},"prefill-shipping-address-state":{key:"shipping.address.state"},"prefill-shipping-address-postal-code":{key:"shipping.address.postal_code"}},eu=w(ea).concat(w(Object.keys(el)),["on-complete","skip-redirect"]),ed=null;function ec(){return(typeof HTMLElement==="undefined"?"undefined":k(HTMLElement))>"u"?null:ed||(ed=/*#__PURE__*/function(e){"use strict";d(t,e);function t(){i(this,t);var e;e=n(this,t,arguments);R(e,"iframe",null);R(e,"removeListeners",null);R(e,"pendingIframe",null);R(e,"pendingRemoveListeners",null);R(e,"pendingRendered",null);R(e,"pendingUrlReplace",{});R(e,"urlReplaceScheduled",!1);R(e,"refreshScheduled",!1);R(e,"pendingPostOverlayRefresh",!1);R(e,"clearPositionOnSwap",!1);return e}s(t,[{key:"connectedCallback",value:function e(){this.iframe||this.mount()}},{key:"attributeChangedCallback",value:function e(e,t,r){if(t===r)return;if(!this.iframe){this.isConnected&&ea.includes(e)&&this.scheduleRefresh();return}if(ea.includes(e)){this.scheduleRefresh();return}if(e==="on-complete"||e==="skip-redirect"){var n=e==="skip-redirect"?r:this.getAttribute("skip-redirect"),i=e==="on-complete"?r:this.getAttribute("on-complete"),o=n==="true"||i?"true":null;this.queueUrlReplace("skip_redirect",o);return}var a=el[e];if(a){var s=a.transform?a.transform(r):r;this.queueUrlReplace(a.key,s)}}},{key:"queueUrlReplace",value:function e(e,t){var r=this;this.pendingUrlReplace[e]=t,!this.urlReplaceScheduled&&(this.urlReplaceScheduled=!0,queueMicrotask(function(){var e;r.urlReplaceScheduled=!1;var t=r.pendingUrlReplace;r.pendingUrlReplace={};var n=r.iframe;if(!n)return;var i;try{i=new URL(n.src).origin}catch(e){return}(e=n.contentWindow)===null||e===void 0?void 0:e.postMessage({__scope:"whop-embedded-checkout",event:"update-search-params",params:t},i)}))}},{key:"scheduleRefresh",value:function e(){var e=this;this.refreshScheduled||(this.refreshScheduled=!0,queueMicrotask(function(){if(e.refreshScheduled=!1,!!e.isConnected){if(!e.iframe){e.mount();return}if(e.hasAttribute("data-overlay-open")){e.pendingPostOverlayRefresh=!0;return}e.beginGracefulRefresh()}}))}},{key:"disconnectedCallback",value:function e(){this.unmount()}},{key:"mount",value:function e(){var e=this.buildIframe();e&&(this.appendChild(e.iframe),this.adoptAsLive(e.iframe,e.removeListeners))}},{key:"unmount",value:function e(){this.pendingIframe&&this.pendingRemoveListeners&&(this.teardownIframe(this.pendingIframe,this.pendingRemoveListeners),this.pendingIframe=null,this.pendingRemoveListeners=null,this.pendingRendered=null),this.iframe&&this.removeListeners&&(this.teardownIframe(this.iframe,this.removeListeners),this.iframe=null,this.removeListeners=null),delete this.dataset.state,delete this.dataset.rendered,this.toggleAttribute("data-overlay-open",!1),this.toggleAttribute("data-loading",!1),this.toggleAttribute("data-refreshing",!1),this.clearPositionOnSwap&&(this.style.position="",this.clearPositionOnSwap=!1),en()}},{key:"buildIframe",value:function e(){var e=this;var t;var r,n;var i=(r=this.getAttribute("plan-id"))!==null&&r!==void 0?r:void 0,o=(n=this.getAttribute("checkout-configuration-id"))!==null&&n!==void 0?n:void 0;if(!i&&!o)return this.dataset.state="error",null;var a;var s=(a=this.getAttribute("return-url"))!==null&&a!==void 0?a:this.getAttribute("redirect-url");if(!s)return console.error("[whop-checkout] return-url is required on <whop-express-checkout-button>. Refusing to mount."),this.dataset.state="error",null;this.dataset.state!=="ready"&&(this.dataset.state="mounting"),eo(),Y(this);var l=Q(this.getAttribute("methods"));i&&T(i);var u,d,c,p,h,f,v,m,y;var g=x({planId:i,checkoutConfigurationId:o,theme:(u=this.getAttribute("theme"))!==null&&u!==void 0?u:void 0,origin:(d=this.getAttribute("origin"))!==null&&d!==void 0?d:void 0,utm:this.getAttribute("skip-utm")==="true"?void 0:q(),prefill:Z(this),themeOptions:et(this),affiliateCode:(c=this.getAttribute("affiliate-code"))!==null&&c!==void 0?c:void 0,paymentRedirectUrl:s,stateId:(p=this.getAttribute("state-id"))!==null&&p!==void 0?p:void 0,promoCode:(h=this.getAttribute("promo-code"))!==null&&h!==void 0?h:void 0,environment:E((f=this.getAttribute("environment"))!==null&&f!==void 0?f:void 0),wuid:(v=this.getAttribute("wuid"))!==null&&v!==void 0?v:void 0,adaptivePricing:this.getAttribute("adaptive-pricing")==="true",methods:l,setupFutureUsage:S((m=this.getAttribute("setup-future-usage"))!==null&&m!==void 0?m:void 0),skipRedirect:this.getAttribute("skip-redirect")==="true"||this.hasAttribute("on-complete"),locale:(y=this.getAttribute("locale"))!==null&&y!==void 0?y:void 0}),b=document.createElement("iframe");b.src=g,b.style.display="block",b.style.width="100%",b.style.height="0px",b.style.border="none",b.style.overflow="hidden",b.style.background="transparent",b.style.colorScheme="normal",b.setAttribute("frameborder","no"),(t=b.sandbox).add.apply(t,w(j)),b.allow=M;var k=K(b,{getCallback:function(t){var r;return(r=e.getAttribute(t))!==null&&r!==void 0?r:void 0},getOverlayContext:function(){var t,r,n,i;return{theme:(t=e.getAttribute("theme"))!==null&&t!==void 0?t:void 0,origin:(r=e.getAttribute("origin"))!==null&&r!==void 0?r:void 0,environment:E((n=e.getAttribute("environment"))!==null&&n!==void 0?n:void 0),locale:(i=e.getAttribute("locale"))!==null&&i!==void 0?i:void 0}},onResize:function(t){if(t>0&&e.pendingIframe===b){e.completeGracefulSwap();return}e.iframe===b&&t>0&&e.dataset.state!=="ready"&&(e.dataset.state="ready",e.dispatchEvent(new CustomEvent("ready")))},onExpressMethodResolved:function(t){if(e.pendingIframe===b){e.pendingRendered=t,t==="none"&&e.completeGracefulSwap();return}e.iframe===b&&(e.dataset.rendered=t,e.dispatchEvent(new CustomEvent("express-method-resolved",{detail:{rendered:t}})))},onExpressLoadingChange:function(t){e.iframe===b&&(t?(er.add(e),e.toggleAttribute("data-loading",!0)):(er.delete(e),e.toggleAttribute("data-loading",!1)),en())},onOverlayOpen:function(){e.toggleAttribute("data-overlay-open",!0),e.dispatchEvent(new CustomEvent("overlay-open"))},onOverlayClose:function(){var t=e.iframe;if(t)try{var r;var n=new URL(t.src).origin;(r=t.contentWindow)===null||r===void 0?void 0:r.postMessage({__scope:"whop-embedded-checkout",event:"overlay-closed"},n)}catch(e){}var i=e.hasAttribute("data-overlay-open");e.toggleAttribute("data-overlay-open",!1),i&&e.dispatchEvent(new CustomEvent("overlay-close")),e.pendingPostOverlayRefresh&&(e.pendingPostOverlayRefresh=!1,e.scheduleRefresh())},onComplete:function(t,r){e.iframe===b&&e.dispatchEvent(new CustomEvent("complete",{detail:{planId:t,receiptOrSetupIntentId:r}}))}});return{iframe:b,removeListeners:k}}},{key:"adoptAsLive",value:function e(e,t){var r;this.iframe=e,this.removeListeners=t;var n=this.id;n&&((r=window.wco)===null||r===void 0?void 0:r.identifiedFrames.set(n,e),e.dataset.whopCheckoutIdentifier=n)}},{key:"teardownIframe",value:function e(e,t){var r,n;var i=e.dataset.whopCheckoutIdentifier;i&&((r=window.wco)===null||r===void 0?void 0:r.identifiedFrames.delete(i),(n=window.wco)===null||n===void 0?void 0:n.availableCurrencies.delete(i)),I.remove(e),er.delete(this),t(),e.remove()}},{key:"beginGracefulRefresh",value:function e(){var e=this.iframe,t=this.removeListeners;if(!e||!t){this.mount();return}this.pendingIframe&&this.pendingRemoveListeners&&(this.teardownIframe(this.pendingIframe,this.pendingRemoveListeners),this.pendingIframe=null,this.pendingRemoveListeners=null,this.pendingRendered=null),this.toggleAttribute("data-refreshing",!0),e.setAttribute("inert",""),e.style.opacity="0.55",e.style.filter="grayscale(0.6)",e.style.pointerEvents="none",e.style.transition="opacity 150ms ease, filter 150ms ease";var r=this.dataset.state,n=this.buildIframe();if(!n){e.removeAttribute("inert"),e.style.opacity="",e.style.filter="",e.style.pointerEvents="",e.style.transition="",r===void 0?delete this.dataset.state:this.dataset.state=r,this.toggleAttribute("data-refreshing",!1),this.clearPositionOnSwap&&(this.style.position="",this.clearPositionOnSwap=!1);return}this.style.position||(this.style.position="relative",this.clearPositionOnSwap=!0),n.iframe.style.position="absolute",n.iframe.style.top="0",n.iframe.style.left="0",n.iframe.style.right="0",n.iframe.style.opacity="0",n.iframe.style.pointerEvents="none",this.pendingIframe=n.iframe,this.pendingRemoveListeners=n.removeListeners,this.appendChild(n.iframe)}},{key:"completeGracefulSwap",value:function e(){var e=this.pendingIframe,t=this.pendingRemoveListeners,r=this.pendingRendered,n=this.iframe,i=this.removeListeners;!e||!t||(this.pendingIframe=null,this.pendingRemoveListeners=null,this.pendingRendered=null,n&&i&&this.teardownIframe(n,i),e.style.position="",e.style.top="",e.style.left="",e.style.right="",e.style.opacity="",e.style.pointerEvents="",this.adoptAsLive(e,t),this.toggleAttribute("data-refreshing",!1),this.clearPositionOnSwap&&(this.style.position="",this.clearPositionOnSwap=!1),en(),this.dispatchEvent(new CustomEvent("ready")),r!==null?(this.dataset.rendered=r,this.dispatchEvent(new CustomEvent("express-method-resolved",{detail:{rendered:r}}))):delete this.dataset.rendered)}}],[{key:"observedAttributes",get:function e(){return eu}}]);return t}(O(HTMLElement)),ed)}function ep(){if((typeof window==="undefined"?"undefined":k(window))>"u"||(typeof customElements==="undefined"?"undefined":k(customElements))>"u"||customElements.get("whop-express-checkout-button"))return;var e=ec();e&&customElements.define("whop-express-checkout-button",e)}export{$ as a,K as b,ep as c};