@primer-io/primer-js 1.0.5 → 1.0.6
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 +6 -0
- package/README.md +4 -10
- package/dist/primer-loader.js +2 -2
- package/dist/web-types.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -50,15 +50,9 @@ Works with all modern browsers (Chrome, Firefox, Safari, Edge). Internet Explore
|
|
|
50
50
|
|
|
51
51
|
## Documentation
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- [Getting Started Guide](https://web-components.primer.io/documentation/getting-started)
|
|
58
|
-
- [SDK Options Reference](https://web-components.primer.io/sdk-reference/sdk-options-reference)
|
|
59
|
-
- [Events Guide](https://web-components.primer.io/guides/events-guide)
|
|
60
|
-
- [React Integration Guide](https://web-components.primer.io/guides/react-guide)
|
|
61
|
-
- [Styling API Documentation](https://web-components.primer.io/sdk-reference/styling-api-docs)
|
|
53
|
+
- [Get Started](https://primer.io/docs/checkout/primer-checkout/product-overview)
|
|
54
|
+
- [Reference](https://primer.io/docs/sdk/primer-checkout-web/sdk-reference-overview)
|
|
55
|
+
- [Changelogs](https://primer.io/docs/changelogs/primer-checkout-sdk)
|
|
62
56
|
|
|
63
57
|
## Examples
|
|
64
58
|
|
|
@@ -109,7 +103,7 @@ checkout.addEventListener('primer:state-change', (event) => {
|
|
|
109
103
|
|
|
110
104
|
## Support
|
|
111
105
|
|
|
112
|
-
- **Documentation**: [Web Components Documentation](https://
|
|
106
|
+
- **Documentation**: [Web Components Documentation](https://primer.io/docs/sdk/primer-checkout-web/sdk-reference-overview)
|
|
113
107
|
- **API Reference**: [Primer API Docs](https://primer.io/docs/api)
|
|
114
108
|
- **Support**: Contact your Primer account manager
|
|
115
109
|
|
package/dist/primer-loader.js
CHANGED
|
@@ -143,7 +143,7 @@ import{a as Za,b as q,c as Ti,d,e as k}from"./chunks/chunk.QNO3CTH5.js";var ac=q
|
|
|
143
143
|
</html>
|
|
144
144
|
`,$i=class extends gt{constructor(){super(...arguments);k(this,"popup");k(this,"shouldRedirect",!1);k(this,"dialogPromise")}async start(){try{let e=this.callbacks.onStart();(this.config.forceRedirect||this.context.clientOptions.redirect?.forceRedirect||nu())&&(this.shouldRedirect=!0);let a=document.createElement("div");a.setAttribute("style","display: flex; flex-direction: column; gap: var(--primer-size-xlarge);");let i=document.createElement("div");i.setAttribute("style",`display: flex;margin:auto;padding:calc(var(--primer-size-small)*0.5);height: var(--primer-size-xlarge);background-color: ${this.backgroundColor};border-radius:var(--primer-radius-small);`);let n=document.createElement("img");n.src=this.logoSrc,i.appendChild(n),n.setAttribute("style","height:100%;"),a.appendChild(i);let o=document.createElement("p");o.setAttribute("style","max-width: 300px;text-align: center;"),o.innerText=this.context.translate("paymentMethodPopupOverlayDescription","Having trouble viewing the {paymentMethodName} payment page? We'll help you find it!").replace("{paymentMethodName}",this.config.name),a.appendChild(o),this.dialogPromise=this.context.dialogProvider.show({htmlContent:a,showCloseButton:!0,size:"flex",cta:{label:this.context.translate("paymentMethodPopupOverlayBringBackThePaymentPage","Bring back the payment page"),icon:"chevron-left",onClick:()=>{this.popup?.focus()}}}),this.shouldRedirect||(this.openPopup(),this.popup&&await qt(300),this.popup?.isOpen||(this.shouldRedirect=!0));let{action:s}=await e;if(s==="abort")throw new G({message:"Payment creation aborted",code:F.PAYMENT_CREATION_ABORTED,paymentMethod:this.config.type});let l=await this.tokenize();this.callbacks.onFinish(l)}catch(e){this.context.dialogProvider.close(),this.popup?.close(),this.callbacks.onFinish(void 0,e)}}async tokenize(){let{error:e,data:a}=await this.context.pciApi.postRedirectPaymentInstruments({type:"OFF_SESSION_PAYMENT",paymentMethodType:this.config.type,paymentMethodConfigId:this.config.id,sessionInfo:{locale:this.context.locale,platform:Uo()?"MOBILE_WEB":"WEB",browserInfo:Qi(),merchantRedirectUrl:this.context.clientOptions.redirect?.returnUrl}});if(e||!a)throw e??new $({message:"Unable to tokenize payment method",code:F.TOKENIZATION_ERROR});return a}async createPayment(e){try{let a=await super.createPayment(e),i=a.requiredAction?.clientToken;if(!i)throw new $({message:"No client token provided"});let n=Jt(i);if(!tu(n,this.config.type))throw new $({message:"Invalid client token"});if(this.shouldRedirect)return wt({eventName:"PAYMENT_REDIRECT_TO_THIRD_PARTY",paymentMethod:this.config.type,redirectDestinationUrl:n.redirectUrl}),window.location.assign(n.redirectUrl),Promise.resolve(a);if(!this.popup?.isOpen)return this.unselect(a),this.context.dialogProvider.close(),{...a,cancelled:!0};this.popup?.setUrl(n.redirectUrl);let o=(this.dialogPromise??Promise.resolve()).then(()=>({id:"",popupClosed:!0})),s=new Promise(h=>{this.popup?.onClose(()=>{C.debug("Popup closed"),h({id:"",popupClosed:!0})})}),{promise:l,abort:c}=this.pollStatus(n.statusUrl),m=await Promise.race([o,s,l]);if(c(),this.popup?.close(),this.context.dialogProvider.close(),"error"in m)throw m.error;if("popupClosed"in m&&m.popupClosed&&!this.context.clientOptions.redirect?.resumePaymentOnPopupClosure)return this.unselect(a),{...a,cancelled:!0};let g=m.id;if(!g){let h=await this.context.pciApi.getResumeStatus(n.statusUrl);if(h.error||!h.data?.id)throw h.error??new Error("Unable to get resume token");g=h.data.id}return await this.resumePayment(a.id,g)}catch(a){throw this.context.dialogProvider.close(),this.popup?.close(),a}}unselect(e){this.context.clientSessionApi.unselectPaymentMethod(e)}pollStatus(e){let a=!0;return{promise:new Promise(async i=>{for(;a;){let{data:n,error:o}=await this.context.pciApi.getResumeStatus(e);if(o)return void i({error:o});if(await qt(1e3),n?.status==="COMPLETE")return void i({id:n.id})}}),abort:()=>{C.debug("Polling aborted"),a=!1}}}openPopup(){let{name:e,displayMetadata:{popup:a}}=this.config;this.popup=Lp({name:e,height:a?.height??500,width:a?.width??1e3}),this.popup?.setContent(Dp({name:e,background:this.backgroundColor,logoSrc:this.logoSrc,logoAlt:e,message:`Loading ${e}...`}))}get backgroundColor(){let{displayMetadata:{button:e,overlay:a}}=this.config;return a?.backgroundColor.colored||e?.backgroundColor.colored||a?.backgroundColor.light||e?.backgroundColor.light||a?.backgroundColor.dark||e?.backgroundColor.dark||"#FFFFFF"}get logoSrc(){let{displayMetadata:{button:e,overlay:a}}=this.config;return a?.logo.colored||e?.iconUrl.colored||a?.logo.light||e?.iconUrl.light||a?.logo.dark||e?.iconUrl.dark}},Op=[B.ADYEN_AFFIRM,B.ADYEN_BANCONTACT_CARD,B.ADYEN_BANCONTACT_PAYCONIQ,B.ADYEN_EPS,B.ADYEN_KLARNA,B.ADYEN_MBWAY,B.ADYEN_MULTIBANCO,B.GO_CARDLESS,B.KLARNA,B.NETS,B.OMISE_PROMPTPAY,B.PAY_NL_PAYPAL,B.RAPYD_FAST,B.RAPYD_PROMPTPAY,B.STRIPE_ACH,B.XFERS_PAYNOW];async function Bp(r,t){let e=r.configuration.paymentMethods.filter(({type:i})=>!t||t.includes(i)).map(i=>{if(Op.includes(i.type))return C.warn(`Payment method ${i.type} is not supported in sdk core.`),null;if(C.debug("Initializing payment method:",i.type),i.implementationType==="WEB_REDIRECT")return new $i(i,r);if(i.type===B.PAYMENT_CARD)return new lr(i,r);if(i.type===B.PAYPAL)return new cr(i,r);if(i.type===B.APPLE_PAY)return new or(i,r);if(i.type===B.GOOGLE_PAY)return new dr(i,r);if(i.type===B.ADYEN_BLIK)return new sr(i,r)}).map(async i=>{if(!i)return null;try{return await i.setup()?i:null}catch(n){return C.warn(`Failed to initialize payment method ${i.config.type}:`,n),null}});return(await Promise.all(e)).filter(i=>!!i)}function Gp(r,t,e){if(!t.configuration.clientSession.customer?.customerId)throw new G({message:"You must provide a `customerId` in the client session to use the Vault Manager."});let a=[];return{async fetchVaultedPaymentMethods(){let{data:i,error:n}=await t.pciApi.getPaymentInstruments();if(n)throw n;if(!i)throw new G({code:qa.VAULT_ERROR,message:"Missing vaulted payment methods data"});return a=i.data,a},async deleteVaultedPaymentMethod(i){if(!a.find(s=>s.id===i))throw new G({code:qa.VAULT_ERROR,message:"deleteVaultedPaymentMethod: the id provided doesn't match any vaulted payment method"});let{error:o}=await t.pciApi.deletePaymentInstrument(i);if(o)throw o;a=a.filter(s=>s.id!==i)},async startPaymentFlow(i){let n=a.find(s=>s.id===i);if(!n)throw new G({code:qa.VAULT_ERROR,message:"startPaymentFlow: the id provided doesn't match any vaulted payment method"});let o=e.find(s=>s.config.type===n.paymentMethodType);if(!o)throw new $({code:qa.TOKENIZATION_ERROR,message:`Payment instrument type ${n.paymentInstrumentType} is not recognized or not supported.`});await Ca(r,o,n)},async createCvvInput(i){let n={blur:new Set,change:new Set,focus:new Set},o,s=va(t.checkoutSessionId,co);await new Promise(h=>{s.onload=()=>{h()},(typeof i.container=="string"?document.querySelector(i.container):i.container)?.appendChild(s)}),Vi(s,i.style),s.setAttribute("title",i.ariaLabel||"");let l=Xi({namespace:`${t.checkoutSessionId}-${co}`,onMessage:h=>{let T=M=>h(M.data);return window.addEventListener("message",T),()=>window.removeEventListener("message",T)},sendMessage:h=>{s.contentWindow.postMessage(h,"*")}});function c(h,T){h!=="metadata"&&n[h].add(T)}l.setOnFocus(()=>{n.focus.forEach(h=>h())}),l.setOnBlur(()=>{n.blur.forEach(h=>h())}),l.setOnInput(h=>{o=h,n.change.forEach(T=>T())}),l.setCardNetwork(i.cardNetwork??""),l.setOptions({placeholder:i.placeholder??"123",ariaLabel:i.ariaLabel??"CVV",style:i.style});function m(){s.parentNode&&s.remove()}let g=t.subscribeToTeardown(m);return{frame:s,remove:()=>{g(),m()},get metadata(){return{error:o?.error??"cvvRequired",errorCode:o?.error??"cvvRequired",valid:o?.valid??!1,active:o?.focused??!1,dirty:o?.dirty??!1,touched:o?.touched??!1,submitted:!0}},addEventListener:c,addListener:c,removeListener(h,T){h!=="metadata"&&n[h].delete(T)},blur(){l.blur()},focus(){l.focus()},validate(){l.getFieldState().then(h=>{o=h,n.change.forEach(T=>T(o))})}}}}}async function rs(r,t){C.debug("createHeadless",t);let e=await Ip(r,{locale:t.locale,dialogProvider:t.dialogProvider,translate:t.translate,clientOptions:{paypal:t.paypal,applePay:t.applePay,googlePay:t.googlePay,merchantDomain:t.merchantDomain,redirect:t.redirect}}),a=await Bp(e,t.enabledPaymentMethods);t.onClientSessionUpdate?.(e.configuration.clientSession),e.onClientConfigurationUpdate(async n=>{t.onClientSessionUpdate?.(n.clientSession)}),t.onPaymentMethodAction&&e.clientSessionApi.setOnPaymentMethodAction((n,o)=>t.onPaymentMethodAction?.(n,{...o,payment:Fi(o.payment,o.token)??void 0}));let i={environment:Ki?"LOCAL":e.decodedClientToken.env,primerAccountId:e.configuration.primerAccountId,checkoutSessionId:e.checkoutSessionId,clientSessionId:e.configuration.clientSession?.clientSessionId,clientSessionToken:r,sdkVersion:t.sdkVersion,configurationFetchStartTime:e.configurationFetchStartTime};return Fc({environment:Ki?"LOCAL":e.decodedClientToken.env,primerAccountId:i.primerAccountId||"",checkoutSessionId:i.checkoutSessionId,clientSessionId:i.clientSessionId||"",clientSessionToken:i.clientSessionToken,sdkVersion:i.sdkVersion||"",userAgent:typeof navigator<"u"?navigator.userAgent:"unknown"}),t.onAvailablePaymentMethodsLoad?.(a.map(n=>({type:n.config.type,managerType:n.config.type===B.PAYMENT_CARD?Pi.CARD:n.config.implementationType==="NATIVE_SDK"?Pi.NATIVE:Pi.REDIRECT}))),{start:async()=>{if(e.decodedClientToken.intent==="REDIRECTION_END"){let{data:n,error:o}=await e.pciApi.postResumePayment(e.decodedClientToken.paymentId,e.decodedClientToken.resumeToken);as(t,n,o)}},createPaymentMethodManager:async(n,o)=>{let s=a.find(({config:l})=>l.type===n);return s?s instanceof lr?pp(t,e,s,o):s instanceof cr||s instanceof or||s instanceof dr?hp(t,e,s):s instanceof sr?yp(t,e,s):gp(t,e,s):(C.warn(`Payment method ${n} not found`),null)},getSDKUtilities:()=>({getCardNetworkAsset:Eo,getUIOrderAmount:()=>{let{merchantAmount:n,totalOrderAmount:o,currencyCode:s}=e.configuration.clientSession.order;return Yo(e.locale,n??o,s)},getCDNAssets:async n=>{let o=a.find(({config:c})=>c.type===n);if(!o)return;let{backgroundColor:s,iconUrl:l}=o.config.displayMetadata?.button||{};return{assets:{icon:l?.colored||""},colors:{background:s?.colored||"",main:s?.colored||""},description:o.config.name||null,is_primer_app:!1,name:o.config.name,website:null,goatCdnUrl:""}},getPaymentMethodConfiguration:n=>a.find(({config:o})=>o.type===n)?.config,setBillingAddress:async n=>{let{error:o,data:s}=await e.clientSessionApi.setBillingAddress(n);if(o||!s)throw o||new G({message:"Failed to set billing address"})}}),getAnalyticsUtils:()=>i,createVaultManager(){return Gp(t,e,a)},getAssetsManager:()=>({getCardNetworkAsset:Eo,getPaymentMethodAsset:async n=>{let o=a.find(({config:m})=>m.type===n);if(!o)return null;let{backgroundColor:s,iconUrl:l,text:c}=o.config.displayMetadata?.button||{};return{backgroundColor:s,iconUrl:l,paymentMethodName:c,buttonText:c,displayName:o.config.name}}}),refreshClientSession:e.refreshClientConfiguration,getConfiguration:()=>e.configuration,teardown:()=>e.teardown()}}var Eo=r=>{let{asset:t,display:e}=ur(r);return{cardUrl:`${Eu}/brand/card/${t}.svg`,displayName:e}},Kp=new Set(["paymentMethodType","last4Digits","network","accountNumberLastFourDigits","bankName"]);function ta(r){let{id:t,orderId:e,paymentMethodData:a}=r,i={id:t,orderId:e};if(!a||typeof a!="object")return i;let n={};for(let[o,s]of Object.entries(a))Kp.has(o)&&(n[o]=s);return i.paymentMethodData=n,i}var Fp={PAYMENT_CARD:{fields:["last4Digits","network","cardholderName","expirationMonth","expirationYear"]},PAYPAL_BILLING_AGREEMENT:{path:"externalPayerInfo",fields:["externalPayerId","email","firstName","lastName"]},KLARNA_CUSTOMER_TOKEN:{path:"sessionData.billingAddress",fields:["email","firstName","lastName","phoneNumber"]},AUTOMATED_CLEARING_HOUSE:{fields:["accountNumberLastFourDigits","bankName","accountType"]}};function Vp(r,t){let e=r;for(let a of t.split(".")){if(!e||typeof e!="object")return;e=e[a]}return e&&typeof e=="object"?e:void 0}function Up(r,t){if(!r)return;let e={};for(let a of t)r[a]!==void 0&&(e[a]=r[a]);return Object.keys(e).length>0?e:void 0}function is(r){let{id:t,analyticsId:e,paymentMethodType:a,paymentInstrumentType:i,paymentInstrumentData:n,userDescription:o}=r,s=Fp[i],l;if(s&&n&&typeof n=="object"){let c=s.path?Vp(n,s.path):n;l=Up(c,s.fields)}return{id:t,analyticsId:e,paymentMethodType:a,paymentInstrumentType:i,...o&&{userDescription:o},...l&&{paymentInstrumentData:l}}}var aa=class{constructor(t){(this.host=t).addController(this)}hostConnected(){}dispatchEvent(t,e){this.host.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}dispatchSdkState(t){this.dispatchEvent("primer:state-change",t)}dispatchPaymentMethods(t){this.dispatchEvent("primer:methods-update",t)}dispatchCheckoutInitialized(t){this.dispatchEvent("primer:ready",t)}dispatchCardNetworkChange(t){this.dispatchEvent("primer:card-network-change",t)}dispatchBinDataAvailable(t){this.dispatchEvent("primer:bin-data-available",t)}dispatchBinDataLoadingChange(t){this.dispatchEvent("primer:bin-data-loading-change",{loading:t})}dispatchCardSubmit(t){this.dispatchEvent("primer:card-submit",{source:t})}dispatchFormSubmitSuccess(t){this.dispatchEvent("primer:card-success",{result:t})}dispatchFormSubmitErrors(t){this.dispatchEvent("primer:card-error",{errors:t})}dispatchPaymentCancel(t){let e=Math.floor(Date.now()/1e3);this.dispatchEvent("primer:payment-cancel",{...t,timestamp:e})}handleExternalCardSubmit(t){this.dispatchCardSubmit(t.source)}dispatchPaymentStart(t,e){let a=Math.floor(Date.now()/1e3),i=!1,n=new CustomEvent("primer:payment-start",{detail:{paymentMethodType:t,abortPaymentCreation:()=>{i=!0,e.abortPaymentCreation()},continuePaymentCreation:o=>{i=!0,e.continuePaymentCreation(o)},timestamp:a},bubbles:!0,composed:!0,cancelable:!0});return this.host.dispatchEvent(n),n.defaultPrevented?!0:i}dispatchPaymentSuccess(t,e){let a=ta(t),i=Math.floor(Date.now()/1e3);this.dispatchEvent("primer:payment-success",{payment:a,paymentMethodType:e,timestamp:i})}dispatchPaymentFailure(t,e,a){let i=Math.floor(Date.now()/1e3),n=a?ta(a):void 0;this.dispatchEvent("primer:payment-failure",{error:t,payment:n,paymentMethodType:e,timestamp:i})}dispatchVaultMethodsUpdate(t,e){let a=Math.floor(Date.now()/1e3);this.dispatchEvent("primer:vault-methods-update",{vaultedPayments:t,cvvRecapture:e,timestamp:a})}dispatchVaultSelectionChange(t){let e=Math.floor(Date.now()/1e3);this.dispatchEvent("primer:vault-selection-change",{paymentMethodId:t,timestamp:e})}dispatchVaultSubmit(t){this.dispatchEvent("primer:vault-submit",{source:t})}handleExternalVaultSubmit(t){this.dispatchVaultSubmit(t.source)}dispatchShowOtherPaymentsToggle(t,e){this.dispatchEvent("primer:show-other-payments-toggle",{action:t,source:e})}handleExternalShowOtherPaymentsToggle(t){this.dispatchShowOtherPaymentsToggle(t.action,t.source)}dispatchShowOtherPaymentsToggled(t){this.dispatchEvent("primer:show-other-payments-toggled",{expanded:t})}};var yt=class extends Event{constructor(t,e,a,i){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e,this.callback=a,this.subscribe=i??!1}};var ra=class{constructor(t,e,a,i){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(n,o)=>{this.unsubscribe&&(this.unsubscribe!==o&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=n,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(n,o)),this.unsubscribe=o},this.host=t,e.context!==void 0){let n=e;this.context=n.context,this.callback=n.callback,this.subscribe=n.subscribe??!1}else this.context=e,this.callback=a,this.subscribe=i??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new yt(this.context,this.host,this.t,this.subscribe))}};var mr=class{get value(){return this.o}set value(t){this.setValue(t)}setValue(t,e=!1){let a=e||!Object.is(t,this.o);this.o=t,a&&this.updateObservers()}constructor(t){this.subscriptions=new Map,this.updateObservers=()=>{for(let[e,{disposer:a}]of this.subscriptions)e(this.o,a)},t!==void 0&&(this.value=t)}addCallback(t,e,a){if(!a)return void t(this.value);this.subscriptions.has(t)||this.subscriptions.set(t,{disposer:()=>{this.subscriptions.delete(t)},consumerHost:e});let{disposer:i}=this.subscriptions.get(t);t(this.value,i)}clearCallbacks(){this.subscriptions.clear()}};var en=class extends Event{constructor(t,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e}},W=class extends mr{constructor(t,e,a){super(e.context!==void 0?e.initialValue:a),this.onContextRequest=i=>{if(i.context!==this.context)return;let n=i.contextTarget??i.composedPath()[0];n!==this.host&&(i.stopPropagation(),this.addCallback(i.callback,n,i.subscribe))},this.onProviderRequest=i=>{if(i.context!==this.context||(i.contextTarget??i.composedPath()[0])===this.host)return;let n=new Set;for(let[o,{consumerHost:s}]of this.subscriptions)n.has(o)||(n.add(o),s.dispatchEvent(new yt(this.context,s,o,!0)));i.stopPropagation()},this.host=t,e.context!==void 0?this.context=e.context:this.context=e,this.attachListeners(),this.host.addController?.(this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new en(this.context,this.host))}};function A({context:r,subscribe:t}){return(e,a)=>{typeof a=="object"?a.addInitializer((function(){new ra(this,{context:r,callback:i=>{e.set.call(this,i)},subscribe:t})})):e.constructor.addInitializer((i=>{new ra(i,{context:r,callback:n=>{i[a]=n},subscribe:t})}))}}var ft=Symbol("analytics-context");var Ye=Symbol("events-context");var hr="cardNetworksContext";var se="clientOptionsContext";var ia="computedStylesContext";var z="headlessInstanceContext";var gr="configuration";var yr="klarnaCategoriesContext";var Z="managerContext";var vt="paymentMethodsContext";var J="sdkStateContext";var be="vaultManagerContext";var ze="vaultManagerCvvContext";function Hp(r,t,e,a){let i=r,n=e;return{dispatch:o=>{let s=i,l=t(i,o,n);vr(s,l)?i=l:(i=l,a(l))},getState:()=>Object.freeze({...i}),setCallbacks:o=>{n={...n,...o}}}}function vr(r,t,e=0,a=10){if(e>a)return r===t;if(r===t)return!0;if(r==null||t==null||typeof r!="object"||typeof t!="object")return!1;let i=Object.keys(r);if(i.length!==Object.keys(t).length)return!1;for(let n of i){if(!(n in t))return!1;let o=r[n],s=t[n];if(typeof o=="object"&&o!==null&&(typeof s=="object"&&s!==null)){if(!vr(o,s,e+1,a))return!1}else if(o!==s)return!1}return!0}function tn(r){return(t,e,a)=>{let i=r[e.type];if(!i)throw new Error(`No handler for action type: ${e.type}`);return i(t,e,a)}}var Dt=class{constructor(t,e,a,i,n=()=>{this.host.requestUpdate()}){this.host=t;this.stateHandler=n;this.host.addController(this),this._dispatcher=Hp(e,a,i,o=>{this.stateHandler(o)})}get currentState(){return this._dispatcher.getState()}dispatch(t){this._dispatcher.dispatch(t)}setCallbacks(t){this._dispatcher.setCallbacks(t)}hostConnected(){}hostDisconnected(){}},fr=class{constructor(t){this.host=t;this._controllers=[];"addController"in this.host&&this.host.addController(this)}addController(t){this._controllers.push(t)}hostConnected(){this._controllers.forEach(t=>{t.hostConnected&&t.hostConnected()})}hostDisconnected(){this._controllers.forEach(t=>{t.hostDisconnected&&t.hostDisconnected()})}};var ns={isSuccessful:!1,isProcessing:!1,isLoading:!1,primerJsError:null,paymentFailure:null},os=ns;function Yp(r,t){switch(t.type){case"SET_LOADING":return{...r,isLoading:t.payload};case"SET_PROCESSING":return{...r,isProcessing:t.payload,...t.payload&&{primerJsError:null,paymentFailure:null}};case"SET_SUCCESS":return{...r,isSuccessful:t.payload};case"SET_PRIMER_JS_ERROR":return{...r,primerJsError:t.payload};case"SET_PAYMENT_FAILURE":return{...r,isProcessing:!1,paymentFailure:t.payload};case"COMPLETE_PROCESSING":return{...r,isProcessing:!1,isSuccessful:!0};case"RESET":return{isSuccessful:!1,isProcessing:!1,isLoading:!1,primerJsError:null,paymentFailure:null};default:return r}}var br=class extends Dt{constructor(t){super(t,ns,Yp,null,e=>{t.sdkContextController.setSdkState(e),t.primerEventsController.dispatchSdkState(e)})}setLoading(t){this.dispatch({type:"SET_LOADING",payload:t})}setProcessing(t){this.dispatch({type:"SET_PROCESSING",payload:t})}setSuccess(t){this.dispatch({type:"SET_SUCCESS",payload:t})}setPrimerJsError(t){this.dispatch({type:"SET_PRIMER_JS_ERROR",payload:t})}setPaymentFailure(t){this.dispatch({type:"SET_PAYMENT_FAILURE",payload:t})}completeProcessing(){this.dispatch({type:"COMPLETE_PROCESSING"})}reset(){this.dispatch({type:"RESET"})}startLoading(){this.setLoading(!0)}completeLoading(){this.setLoading(!1)}startProcessing(){this.setProcessing(!0)}stopProcessing(){this.setProcessing(!1)}resetError(){this.setPrimerJsError(null),this.setPaymentFailure(null)}forceCompleteLoading(){this.setLoading(!1)}};var Sr=class{constructor(t){this.sdkStateProvider=null;this.paymentMethodsProvider=null;this.paymentManagerProvider=null;this.cardNetworksContext=null;this.vaultManagerCvvProvider=null;this.clientOptionsContext=null;this.headlessUtilsProvider=null;this.configurationProvider=null;this.klarnaCategoriesProvider=null;this.computedStylesProvider=null;this.analyticsProvider=null;this.eventsProvider=null;(this.host=t).addController(this),this.sdkStateProvider=new W(t,{context:J,initialValue:os}),this.paymentMethodsProvider=new W(t,{context:vt,initialValue:null}),this.paymentManagerProvider=new W(t,{context:Z,initialValue:new Map}),this.cardNetworksContext=new W(t,{context:hr,initialValue:null}),this.vaultManagerProvider=new W(t,{context:be,initialValue:null}),this.vaultManagerCvvProvider=new W(t,{context:ze,initialValue:null}),this.clientOptionsContext=new W(t,{context:se,initialValue:null}),this.klarnaCategoriesProvider=new W(t,{context:yr,initialValue:{categories:[],isLoading:!0}}),this.headlessUtilsProvider=new W(t,{context:z,initialValue:null}),this.configurationProvider=new W(t,{context:gr,initialValue:null}),this.computedStylesProvider=new W(t,{context:ia,initialValue:null}),this.analyticsProvider=new W(t,{context:ft,initialValue:null}),this.eventsProvider=new W(t,{context:Ye,initialValue:null})}hostConnected(){}setSdkState(t){this.sdkStateProvider?.setValue(t)}setPaymentMethods(t){this.paymentMethodsProvider?.setValue(t)}setPaymentManagers(t){this.paymentManagerProvider?.setValue(t)}setCardNetworks(t){this.cardNetworksContext?.setValue(t)}setCardNetworksLoadingFalse(){this.cardNetworksContext?.setValue({detectedCardNetwork:this.cardNetworksContext.value?.detectedCardNetwork??null,selectableCardNetworks:this.cardNetworksContext.value?.selectableCardNetworks??[],isLoading:!1})}setVaultManager(t){this.vaultManagerProvider?.setValue(t)}setKlarnaCategories(t){this.klarnaCategoriesProvider?.setValue(t)}setClientOptions(t){this.clientOptionsContext?.setValue(t)}setHeadlessUtils(t){this.headlessUtilsProvider?.setValue(t)}setConfiguration(t){this.configurationProvider?.setValue(t)}setAnalyticsUtils(t){this.analyticsProvider?.setValue(t)}getAnalyticsUtils(){return this.analyticsProvider?.value}setComputedStyles(t){this.computedStylesProvider?.setValue(t)}setVaultManagerCvv(t){this.vaultManagerCvvProvider?.setValue(t)}setEventsController(t){this.eventsProvider?.setValue(t)}};var an=class{constructor(){k(this,"context",null)}initialize(t){this.context=t,P.debug("Session context initialized:",{checkoutSessionId:t.checkoutSessionId,clientSessionId:t.clientSessionId,primerAccountId:t.primerAccountId,environment:t.environment})}getContext(){return this.context}clear(){P.debug("Session context cleared"),this.context=null}isInitialized(){return this.context!==null}setSdkInitStartTime(t){this.context&&(this.context.sdkInitStartTime=t)}getSdkInitStartTime(){return this.context?.sdkInitStartTime}},$e=new an;var zp={LOCAL:"https://analytics.dev.data.primer.io/v1/sdk-logs",DEV:"https://analytics.dev.data.primer.io/v1/sdk-logs",STAGING:"https://analytics.staging.data.primer.io/v1/sdk-logs",SANDBOX:"https://analytics.sandbox.data.primer.io/v1/sdk-logs",PRODUCTION:"https://analytics.production.data.primer.io/v1/sdk-logs"};function ss(r,t={}){let e=$e.getContext();if(!e&&!t?.environment)return;let i={message:r instanceof Error?r.message:typeof r=="string"?r:JSON.stringify(r)};r instanceof Error&&r.stack&&(i.stack=r.stack),e?Object.assign(i,{primer:{checkout_session_id:e.checkoutSessionId,client_session_id:e.clientSessionId,primer_account_id:e.primerAccountId},user_agent:e.userAgent}):(t?.checkoutSessionId&&Object.assign(i,{primer:{checkout_session_id:t.checkoutSessionId}}),t?.clientSessionId&&Object.assign(i,{primer:{client_session_id:t.clientSessionId}}),t?.primerAccountId&&Object.assign(i,{primer:{primer_account_id:t.primerAccountId}}),t?.userAgent&&Object.assign(i,{user_agent:t.userAgent})),t?.metadata&&Object.assign(i,t.metadata),t.status&&(i.status=t.status);let n={message:JSON.stringify(i),hostname:typeof window<"u"?window.location.hostname:"unknown",service:"web-sdk",ddsource:"lambda",ddtags:`env:${e?.environment||t?.environment},version:${e?.sdkVersion||t?.sdkVersion}`};$p(n,{environment:e?.environment||t?.environment,clientSessionToken:e?.clientSessionToken||t?.clientSessionToken})}var ls=(r,t={})=>ss(r,{...t,status:"error"});function ds(r){let t={event:"CHECKOUT_INITIALIZED"};r!==void 0&&(t.init_duration_ms=r),ss("Checkout initialized",{status:"info",metadata:t})}function $p(r,{environment:t,clientSessionToken:e}){if(t==="LOCAL"||r.hostname==="localhost"){P.debug("\u{1F436}\u{1F436}\u{1F436} [Datadog Log] \u{1F436}\u{1F436}\u{1F436}",r);return}let a=zp[t||"LOCAL"];if(!a){P.warn("No logging endpoint configured for current environment");return}fetch(a,{method:"POST",headers:{"Content-Type":"application/json",...e&&{Authorization:`Bearer ${e}`}},body:JSON.stringify(r)}).catch(i=>{P.error("Failed to send log event:",i)})}var H=class H{static _log(t,e,...a){H.enabled&&a.forEach(i=>{i instanceof Error&&i.toJSON})}static log(t,...e){H._log("log",t,...e)}static info(t,...e){H._log("info",t,...e)}static warn(t,...e){H._log("warn",t,...e)}static error(t,...e){H._log("error",t,...e)}static debug(t,...e){this._log("debug",t,...e)}static errorWithDatadog(t,e){let{error:a,status:i="error"}=e||{};if(H.enabled){a instanceof Error&&a.toJSON;try{let n={status:i,metadata:{sdkOptions:H.sdkOptions,clientToken:H.clientToken,error:a}};ls(t,n)}catch{H.enabled}}}static setSdkOptions(t){H.sdkOptions=t}static setClientToken(t){H.clientToken=t}};k(H,"enabled",!0),k(H,"sdkOptions"),k(H,"clientToken"),k(H,"defaultFont","font-family: Consolas, monospace; font-size: 12px;"),k(H,"brandTag","[PRIMER]"),k(H,"brandStyle",`background: #24292e; color: #ffffff; padding: 2px 6px; border-radius: 3px; font-weight: bold; margin-right: 4px; ${H.defaultFont}`),k(H,"styles",{log:`color: #4CAF50; ${H.defaultFont}`,info:`color: #2196F3; ${H.defaultFont}`,warn:`color: #FF9800; ${H.defaultFont}`,error:`color: #F44336; ${H.defaultFont}`,debug:`color: #9C27B0; ${H.defaultFont}`});var P=H;var Ot=class Ot{constructor(t){(this.host=t).addController(this)}processCustomStyles(t){try{let e=JSON.parse(t);this.applyStyles(e)}catch(e){P.error("Error parsing customStyles property.",e instanceof Error?e:new Error(String(e)))}}isValidCssProperty(t){return/^[a-zA-Z][a-zA-Z0-9]*$/.test(t)}isValidCssValue(t){let a=/^[\w\s#.,%()\-+/!]+$/.test(t);return a||P.warn(`Rejected potentially unsafe CSS value: ${t}`),a}getCssVarName(t){let e=Ot.cssVarCache.get(t);return e||(e=`--${t.replace(/([A-Z])/g,(a,i)=>`-${i.toLowerCase()}`)}`,Ot.cssVarCache.set(t,e)),e}applyStyles(t){let e=[];for(let a of Object.keys(t)){let i=t[a];if(!i)continue;if(!this.isValidCssProperty(a)){P.warn(`Skipping invalid CSS property name: ${a}`);continue}if(!this.isValidCssValue(i))continue;let n=this.getCssVarName(a);e.push([n,i])}if(e.length>0)for(let[a,i]of e)this.host.style.setProperty(a,i)}removeStyle(t){let e=this.getCssVarName(t);this.host.style.removeProperty(e)}clearAllStyles(){for(let t of Ot.cssVarCache.keys()){let e=Ot.cssVarCache.get(t);e&&this.host.style.removeProperty(e)}}hostDisconnected(){}};Ot.cssVarCache=new Map;var Ar=Ot;var Cr=globalThis,Er=Cr.ShadowRoot&&(Cr.ShadyCSS===void 0||Cr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,us=Symbol(),cs=new WeakMap,Mr=class{constructor(t,e,a){if(this._$cssResult$=!0,a!==us)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if(Er&&t===void 0){let a=e!==void 0&&e.length===1;a&&(t=cs.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),a&&cs.set(e,t))}return t}toString(){return this.cssText}},ps=r=>new Mr(typeof r=="string"?r:r+"",void 0,us);var rn=(r,t)=>{if(Er)r.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of t){let a=document.createElement("style"),i=Cr.litNonce;i!==void 0&&a.setAttribute("nonce",i),a.textContent=e.cssText,r.appendChild(a)}},Tr=Er?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(let a of t.cssRules)e+=a.cssText;return ps(e)})(r):r;var{is:jp,defineProperty:Wp,getOwnPropertyDescriptor:Zp,getOwnPropertyNames:Jp,getOwnPropertySymbols:qp,getPrototypeOf:Qp}=Object,bt=globalThis,ms=bt.trustedTypes,Xp=ms?ms.emptyScript:"",em=bt.reactiveElementPolyfillSupport,Ma=(r,t)=>r,nn={toAttribute(r,t){switch(t){case Boolean:r=r?Xp:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},Pr=(r,t)=>!jp(r,t),hs={attribute:!0,type:String,converter:nn,reflect:!1,hasChanged:Pr};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),bt.litPropertyMetadata??(bt.litPropertyMetadata=new WeakMap);var Bt=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=hs){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){let a=Symbol(),i=this.getPropertyDescriptor(t,a,e);i!==void 0&&Wp(this.prototype,t,i)}}static getPropertyDescriptor(t,e,a){let{get:i,set:n}=Zp(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get(){return i?.call(this)},set(o){let s=i?.call(this);n.call(this,o),this.requestUpdate(t,s,a)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??hs}static _$Ei(){if(this.hasOwnProperty(Ma("elementProperties")))return;let t=Qp(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Ma("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ma("properties"))){let e=this.properties,a=[...Jp(e),...qp(e)];for(let i of a)this.createProperty(i,e[i])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[a,i]of e)this.elementProperties.set(a,i)}this._$Eh=new Map;for(let[e,a]of this.elementProperties){let i=this._$Eu(e,a);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let a=new Set(t.flat(1/0).reverse());for(let i of a)e.unshift(Tr(i))}else t!==void 0&&e.push(Tr(t));return e}static _$Eu(t,e){let a=e.attribute;return a===!1?void 0:typeof a=="string"?a:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,e=this.constructor.elementProperties;for(let a of e.keys())this.hasOwnProperty(a)&&(t.set(a,this[a]),delete this[a]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return rn(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,a){this._$AK(t,a)}_$EC(t,e){let a=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,a);if(i!==void 0&&a.reflect===!0){let n=(a.converter?.toAttribute!==void 0?a.converter:nn).toAttribute(e,a.type);this._$Em=t,n==null?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){let a=this.constructor,i=a._$Eh.get(t);if(i!==void 0&&this._$Em!==i){let n=a.getPropertyOptions(i),o=typeof n.converter=="function"?{fromAttribute:n.converter}:n.converter?.fromAttribute!==void 0?n.converter:nn;this._$Em=i,this[i]=o.fromAttribute(e,n.type),this._$Em=null}}requestUpdate(t,e,a){if(t!==void 0){if(a??(a=this.constructor.getPropertyOptions(t)),!(a.hasChanged??Pr)(this[t],e))return;this.P(t,e,a)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,a){this._$AL.has(t)||this._$AL.set(t,e),a.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[i,n]of this._$Ep)this[i]=n;this._$Ep=void 0}let a=this.constructor.elementProperties;if(a.size>0)for(let[i,n]of a)n.wrapped!==!0||this._$AL.has(i)||this[i]===void 0||this.P(i,this[i],n)}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach((a=>a.hostUpdate?.())),this.update(e)):this._$EU()}catch(a){throw t=!1,this._$EU(),a}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach((e=>this._$EC(e,this[e])))),this._$EU()}updated(t){}firstUpdated(t){}};Bt.elementStyles=[],Bt.shadowRootOptions={mode:"open"},Bt[Ma("elementProperties")]=new Map,Bt[Ma("finalized")]=new Map,em?.({ReactiveElement:Bt}),(bt.reactiveElementVersions??(bt.reactiveElementVersions=[])).push("2.0.4");var St={INITIAL:0,PENDING:1,COMPLETE:2,ERROR:3},w=Symbol(),O=class{get taskComplete(){return this.t||(this.i===1?this.t=new Promise(((t,e)=>{this.o=t,this.h=e})):this.i===3?this.t=Promise.reject(this.l):this.t=Promise.resolve(this.u)),this.t}constructor(t,e,a){this.p=0,this.i=0,(this._=t).addController(this);let i=typeof e=="object"?e:{task:e,args:a};this.v=i.task,this.j=i.args,this.m=i.argsEqual??gs,this.k=i.onComplete,this.A=i.onError,this.autoRun=i.autoRun??!0,"initialValue"in i&&(this.u=i.initialValue,this.i=2,this.O=this.T?.())}hostUpdate(){this.autoRun===!0&&this.S()}hostUpdated(){this.autoRun==="afterUpdate"&&this.S()}T(){if(this.j===void 0)return;let t=this.j();if(!Array.isArray(t))throw Error("The args function must return an array");return t}async S(){let t=this.T(),e=this.O;this.O=t,t===e||t===void 0||e!==void 0&&this.m(e,t)||await this.run(t)}async run(t){let e,a;t??(t=this.T()),this.O=t,this.i===1?this.q?.abort():(this.t=void 0,this.o=void 0,this.h=void 0),this.i=1,this.autoRun==="afterUpdate"?queueMicrotask((()=>this._.requestUpdate())):this._.requestUpdate();let i=++this.p;this.q=new AbortController;let n=!1;try{e=await this.v(t,{signal:this.q.signal})}catch(o){n=!0,a=o}if(this.p===i){if(e===w)this.i=0;else{if(n===!1){try{this.k?.(e)}catch{}this.i=2,this.o?.(e)}else{try{this.A?.(a)}catch{}this.i=3,this.h?.(a)}this.u=e,this.l=a}this._.requestUpdate()}}abort(t){this.i===1&&this.q?.abort(t)}get value(){return this.u}get error(){return this.l}get status(){return this.i}render(t){switch(this.i){case 0:return t.initial?.();case 1:return t.pending?.();case 2:return t.complete?.(this.value);case 3:return t.error?.(this.error);default:throw Error("Unexpected status: "+this.i)}}},gs=(r,t)=>r===t||r.length===t.length&&r.every(((e,a)=>!Pr(e,t[a])));var tm={SET_LOADING:(r,t)=>({...r,isLoading:t.payload}),SET_UPDATING:(r,t)=>({...r,isUpdating:t.payload}),INITIALIZE_VAULT_MANAGER:(r,t,e)=>({...r,enabled:t.vaultEnabled,cvvRecapture:t.cvvRecapture,showEmptyState:t.showEmptyState,headless:t.headless,deleteVaultedPaymentMethod:e.deleteVaultedPaymentMethod,startVaultedPaymentFlow:e.startVaultedPaymentFlow,createCvvInput:e.createCvvInput}),UPDATE_PAYMENT_METHODS:(r,t)=>({...r,vaultedPaymentMethods:t.payload,isLoading:!1,isUpdating:!1}),SET_ERROR:r=>({...r,isLoading:!1,isUpdating:!1}),DISABLE:r=>({...r,enabled:!1}),RESET:()=>ys},am={INITIALIZE_CVV:(r,t,e)=>({...r,setCvvInput:e.setCvvInput,setSelectedVaultedPaymentMethod:e.setSelectedVaultedPaymentMethod}),SET_FORM_DIRTY:(r,t)=>({...r,formIsDirty:t.payload}),SET_CVV_INPUT:(r,t)=>({...r,cvvInput:t.payload}),SET_SELECTED_VAULTED_PAYMENT_METHOD:(r,t)=>({...r,selectedVaultedPaymentMethod:t.payload}),RESET_CVV:()=>fs},rm=tn(tm),im=tn(am),ys={enabled:!1,isLoading:!1,isUpdating:!1,cvvRecapture:!1,showEmptyState:!1,headless:!1,vaultedPaymentMethods:[],createCvvInput:null,deleteVaultedPaymentMethod:()=>Promise.resolve(),startVaultedPaymentFlow:()=>Promise.resolve()},fs={cvvInput:null,formIsDirty:!1,setCvvInput:()=>{},selectedVaultedPaymentMethod:null,setSelectedVaultedPaymentMethod:()=>{}},on=class extends Dt{constructor(t,e){super(t,ys,rm,e,a=>{t.sdkContextController.setVaultManager(a)})}setLoading(t){this.dispatch({type:"SET_LOADING",payload:t})}setUpdating(t){this.dispatch({type:"SET_UPDATING",payload:t})}initializeVaultManager(t,e,a,i,n){this.dispatch({type:"INITIALIZE_VAULT_MANAGER",payload:t,vaultEnabled:e,cvvRecapture:a,showEmptyState:i,headless:n})}updatePaymentMethods(t){this.dispatch({type:"UPDATE_PAYMENT_METHODS",payload:t})}setError(t){this.dispatch({type:"SET_ERROR",payload:t})}disable(){this.dispatch({type:"DISABLE"})}reset(){this.dispatch({type:"RESET"})}},sn=class extends Dt{constructor(t,e){super(t,fs,im,e,a=>{t.sdkContextController.setVaultManagerCvv(a)})}initializeCvv(t){this.dispatch({type:"INITIALIZE_CVV",createCvvInput:t})}setFormDirty(t){this.dispatch({type:"SET_FORM_DIRTY",payload:t})}setCvvInputState(t){this.dispatch({type:"SET_CVV_INPUT",payload:t})}setSelectedPaymentMethod(t){this.dispatch({type:"SET_SELECTED_VAULTED_PAYMENT_METHOD",payload:t})}resetCvv(){this.dispatch({type:"RESET_CVV"})}},Ea=class extends fr{constructor(e){super(e);this._vaultManager=null;this._options=null;this.createVaultManagerFn=null;this.createCvvInput=e=>{if(!this._vaultManager)throw new Error("Vault manager not initialized");return this._vaultManager.createCvvInput(e)};this.deleteVaultedPaymentMethod=async e=>{if(!this._vaultManager)throw new Error("Vault manager not initialized");try{this.coreController.updatePaymentMethods(this.vaultManagerState.vaultedPaymentMethods),await this._vaultManager.deleteVaultedPaymentMethod(e),await this.fetchVaultedPaymentMethods()}catch(a){let i=a instanceof Error?a:new Error("Failed to delete payment method");throw this.coreController.setError(i),this.host.sdkStateController.setPrimerJsError(i),a}};this.setCvvInput=e=>{this.itemController.setCvvInputState(e)};this.startVaultedPaymentFlow=async()=>{if(!this._vaultManager)throw new Error("Vault manager not initialized");let e=this.vaultItemState.selectedVaultedPaymentMethod,a=this.vaultManagerState.cvvRecapture,i=this.vaultItemState.cvvInput;if(!e||a&&(!i||i.metadata.error)){this.itemController.setFormDirty(!0);return}this.host.sdkStateController.startProcessing();try{await this._vaultManager.startPaymentFlow(e.id,a?{cvv:i.valueToken}:void 0)}catch(n){P.errorWithDatadog("VaultManagerController: Error starting vaulted payment flow",{error:n});let o=n instanceof Error?n:new Error("Failed to start vaulted payment flow");this.coreController.setError(o),this.host.sdkStateController.setPrimerJsError(o),this.host.sdkStateController.stopProcessing()}};this.setSelectedVaultedPaymentMethod=e=>{this.itemController.setSelectedPaymentMethod(e),this.itemController.setFormDirty(!1),this.host.primerEventsController.dispatchVaultSelectionChange(e?.id??null)};this.startVaultPaymentById=async(e,a)=>{if(!this._vaultManager)throw new Error("Vault manager not initialized");let i=this.vaultManagerState.vaultedPaymentMethods.find(n=>n.id===e);if(!i)throw new Error(`Payment method not found: ${e}`);this.setSelectedVaultedPaymentMethod(i),this.host.sdkStateController.startProcessing();try{await this._vaultManager.startPaymentFlow(e,a?.cvv?{cvv:a.cvv}:void 0)}catch(n){P.errorWithDatadog("VaultManagerController: Error starting vaulted payment flow",{error:n});let o=n instanceof Error?n:new Error("Failed to start vaulted payment flow");throw this.coreController.setError(o),this.host.sdkStateController.setPrimerJsError(o),this.host.sdkStateController.stopProcessing(),n}};this.coreController=new on(e,{deleteVaultedPaymentMethod:this.deleteVaultedPaymentMethod.bind(this),startVaultedPaymentFlow:this.startVaultedPaymentFlow.bind(this),createCvvInput:this.createCvvInput}),this.itemController=new sn(e,{setCvvInput:this.setCvvInput.bind(this),setSelectedVaultedPaymentMethod:this.setSelectedVaultedPaymentMethod.bind(this)}),this.addController(this.coreController),this.addController(this.itemController),new O(this.host,{task:async([a,i])=>{if(!a||!i?.vaultEnabled)return this.coreController.disable(),w;this.coreController.setLoading(!0);try{let n=a();this._vaultManager=n,this.coreController.initializeVaultManager(n,i.vaultEnabled,!!i.captureVaultedCardCvv,i.showEmptyState??!1,i.headless??!1),this.itemController.initializeCvv(n.createCvvInput),await this.fetchVaultedPaymentMethods(!0),P.log("VaultManagerController: Vault initialized successfully",{coreState:this.coreController.currentState,cvvState:this.itemController.currentState})}catch(n){P.errorWithDatadog("VaultManagerController: Failed to initialize vault",{error:n});let o=n instanceof Error?n:new Error("Unknown error");this.coreController.setError(o),this.host.sdkStateController.setPrimerJsError(o)}return this._vaultManager},args:()=>[this.createVaultManagerFn,this.options]})}initializeVaultManager(e,a){this.createVaultManagerFn=e,this.options=a??null}get vaultManager(){return this._vaultManager}set vaultManager(e){this._vaultManager=e,this.host.requestUpdate()}get options(){return this._options}set options(e){this._options=e,this.host.requestUpdate()}get vaultManagerState(){return this.coreController.currentState}get vaultItemState(){return this.itemController.currentState}hostDisconnected(){super.hostDisconnected(),this.vaultManager=null,this.coreController.reset()}createVaultedPaymentsArray(e){return e.map(a=>is(a))}updatePaymentMethodsWithEvents(e){this.coreController.updatePaymentMethods(e);let a=this.createVaultedPaymentsArray(e);this.host.primerEventsController.dispatchVaultMethodsUpdate(a,this.vaultManagerState.cvvRecapture),this.host.primerJS?.handleVaultedMethodsUpdate(a,this.vaultManagerState.cvvRecapture),P.log("VaultManagerController: Dispatched vault methods update",{methodCount:e.length,filteredMethodCount:a.length})}async fetchVaultedPaymentMethods(e){if(!this._vaultManager)throw new Error("Vault manager not initialized");try{e||this.coreController.setUpdating(!0);let a=await this._vaultManager.fetchVaultedPaymentMethods();return P.log("VaultManagerController: Fetched payment methods",a),this.updatePaymentMethodsWithEvents(a),a}catch(a){let i=a instanceof Error?a:new Error("Failed to fetch payment methods");throw this.coreController.setError(i),this.host.sdkStateController.setPrimerJsError(i),a}}};var vs=()=>bs.randomUUID?.()||nm(),nm=()=>("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,r=>(r^om()>>r/4).toString(16)),om=()=>(bs.getRandomValues?.(new Uint8Array(1))[0]??Math.random()*16)&15,bs=typeof crypto<"u"?crypto:{};var sm={LOCAL:"https://analytics.sandbox.data.primer.io/v1/sdk-analytic-events",DEV:"https://analytics.dev.data.primer.io/v1/sdk-analytic-events",STAGING:"https://analytics.staging.data.primer.io/v1/sdk-analytic-events",SANDBOX:"https://analytics.sandbox.data.primer.io/v1/sdk-analytic-events",PRODUCTION:"https://analytics.production.data.primer.io/v1/sdk-analytic-events"},ln=class{sendEvent(t){let e=$e.getContext();if(!e)return;let a={id:vs(),timestamp:Math.floor(Date.now()/1e3),sdkType:"WEB",eventName:t.eventName,checkoutSessionId:e.checkoutSessionId,clientSessionId:e.clientSessionId,primerAccountId:e.primerAccountId,sdkVersion:e.sdkVersion,userAgent:e.userAgent,eventType:t.eventType,userLocale:t.userLocale,paymentMethod:t.paymentMethod,paymentId:t.paymentId,redirectDestinationUrl:t.redirectDestinationUrl,threedsProvider:t.threedsProvider,threedsResponse:t.threedsResponse};dm(a,e)}},lm=new ln;function Ss(r){let t={...r,userAgent:r.userAgent||(typeof navigator<"u"?navigator.userAgent:"")};$e.initialize(t)}function X(r){lm.sendEvent(r)}function As(){$e.clear()}async function dm(r,{environment:t,clientSessionToken:e}){if(t==="LOCAL"){P.debug(`Analytics event ${r.eventName}:`,r);return}let a=sm[t];return fetch(a,{method:"POST",headers:{"Content-Type":"application/json",...e&&{Authorization:`Bearer ${e}`}},body:JSON.stringify(r)}).catch(i=>{P.error("Failed to send analytics event:",i)})}var Ta="lit-localize-status";var Cs=r=>typeof r!="string"&&"strTag"in r,Nr=(r,t,e)=>{let a=r[0];for(let i=1;i<r.length;i++)a+=t[e?e[i-1]:i-1],a+=r[i];return a};var Pa=(r=>Cs(r)?Nr(r.strings,r.values):r);var S=Pa,Ms=!1;function dn(r){if(Ms)throw new Error("lit-localize can only be configured once");S=r,Ms=!0}var cn=class{constructor(t){this.__litLocalizeEventHandler=e=>{e.detail.status==="ready"&&this.host.requestUpdate()},this.host=t}hostConnected(){window.addEventListener(Ta,this.__litLocalizeEventHandler)}hostDisconnected(){window.removeEventListener(Ta,this.__litLocalizeEventHandler)}},cm=r=>r.addController(new cn(r)),Es=cm;var D=()=>(r,t)=>(r.addInitializer(Es),r);var Na=class{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._resolve=t,this._reject=e})}resolve(t){this.settled=!0,this._resolve(t)}reject(t){this.settled=!0,this._reject(t)}};var rt=[];for(let r=0;r<256;r++)rt[r]=(r>>4&15).toString(16)+(r&15).toString(16);function Ts(r){let t=0,e=8997,a=0,i=33826,n=0,o=40164,s=0,l=52210;for(let c=0;c<r.length;c++)e^=r.charCodeAt(c),t=e*435,a=i*435,n=o*435,s=l*435,n+=e<<8,s+=i<<8,a+=t>>>16,e=t&65535,n+=a>>>16,i=a&65535,l=s+(n>>>16)&65535,o=n&65535;return rt[l>>8]+rt[l&255]+rt[o>>8]+rt[o&255]+rt[i>>8]+rt[i&255]+rt[e>>8]+rt[e&255]}var um="",pm="h",mm="s";function Ps(r,t){return(t?pm:mm)+Ts(typeof r=="string"?r:r.join(um))}var Ns=new WeakMap,Is=new Map;function ks(r,t,e){if(r){let a=e?.id??hm(t),i=r[a];if(i){if(typeof i=="string")return i;if("strTag"in i)return Nr(i.strings,t.values,i.values);{let n=Ns.get(i);return n===void 0&&(n=i.values,Ns.set(i,n)),{...i,values:n.map(o=>t.values[o])}}}}return Pa(t)}function hm(r){let t=typeof r=="string"?r:r.strings,e=Is.get(t);return e===void 0&&(e=Ps(t,typeof r!="string"&&!("strTag"in r)),Is.set(t,e)),e}function un(r){window.dispatchEvent(new CustomEvent(Ta,{detail:r}))}var kr="",pn,Ls,Lr,mn,Rs,Gt=new Na;Gt.resolve();var Ir=0,xs=r=>(dn(((t,e)=>ks(Rs,t,e))),kr=Ls=r.sourceLocale,Lr=new Set(r.targetLocales),Lr.add(r.sourceLocale),mn=r.loadLocale,{getLocale:gm,setLocale:ym}),gm=()=>kr,ym=r=>{if(r===(pn??kr))return Gt.promise;if(!Lr||!mn)throw new Error("Internal error");if(!Lr.has(r))throw new Error("Invalid locale code");Ir++;let t=Ir;return pn=r,Gt.settled&&(Gt=new Na),un({status:"loading",loadingLocale:r}),(r===Ls?Promise.resolve({templates:void 0}):mn(r)).then(a=>{Ir===t&&(kr=r,pn=void 0,Rs=a.templates,un({status:"ready",readyLocale:r}),Gt.resolve())},a=>{Ir===t&&(un({status:"error",errorLocale:r,errorMessage:a.toString()}),Gt.reject(a))}),Gt.promise};var hn="en",gn=["ar","bg","ca","cs","da","de","el","en-GB","es","es-AR","es-MX","et-EE","fi-FI","fr","he","hr","hu","id","it","ja","ko","lt","lt-LT","lv","lv-LV","ms","nb","nl","nl_NL","pl","pt","pt-BR","ro","ru","sk","sl","sr-RS","sv","th","tr","uk-UA","vi","zf","zh-CN","zh-HK","zh-TW"],yn="You must call `loadLocale` first to set up the localized template.",Rr,xr,_s=r=>{let t=xs({sourceLocale:hn,targetLocales:gn,loadLocale:r});Rr=t.getLocale,xr=t.setLocale};var fn=r=>{_s(r)},vn=r=>{if(!xr)throw new Error(yn);return xr(r)},bn=()=>{if(!Rr)throw new Error(yn);return Rr()};var Ia=new Set(gn);Ia.add(hn);var Sn=r=>{if(typeof r!="string")return!1;if(r==="en")return!0;let t=r.replace("_","-");if(Ia.has(t))return!0;let e=t.split("-")[0];return!!Ia.has(e)},_r=()=>navigator.language||navigator.languages[0]||"en",na=r=>{let t=r.replace("_","-"),e=t.split("-")[0];return e==="en"?"en-GB":Ia.has(t)?t:Ia.has(e)?e:"en-GB"};var wr=globalThis,Dr=wr.ShadowRoot&&(wr.ShadyCSS===void 0||wr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,An=Symbol(),ws=new WeakMap,ka=class{constructor(t,e,a){if(this._$cssResult$=!0,a!==An)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if(Dr&&t===void 0){let a=e!==void 0&&e.length===1;a&&(t=ws.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),a&&ws.set(e,t))}return t}toString(){return this.cssText}},me=r=>new ka(typeof r=="string"?r:r+"",void 0,An),f=(r,...t)=>{let e=r.length===1?r[0]:t.reduce(((a,i,n)=>a+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+r[n+1]),r[0]);return new ka(e,r,An)},Ds=(r,t)=>{if(Dr)r.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of t){let a=document.createElement("style"),i=wr.litNonce;i!==void 0&&a.setAttribute("nonce",i),a.textContent=e.cssText,r.appendChild(a)}},Cn=Dr?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(let a of t.cssRules)e+=a.cssText;return me(e)})(r):r;var{is:fm,defineProperty:vm,getOwnPropertyDescriptor:bm,getOwnPropertyNames:Sm,getOwnPropertySymbols:Am,getPrototypeOf:Cm}=Object,At=globalThis,Os=At.trustedTypes,Mm=Os?Os.emptyScript:"",Em=At.reactiveElementPolyfillSupport,La=(r,t)=>r,Ra={toAttribute(r,t){switch(t){case Boolean:r=r?Mm:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},Or=(r,t)=>!fm(r,t),Bs={attribute:!0,type:String,converter:Ra,reflect:!1,useDefault:!1,hasChanged:Or};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),At.litPropertyMetadata??(At.litPropertyMetadata=new WeakMap);var it=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Bs){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){let a=Symbol(),i=this.getPropertyDescriptor(t,a,e);i!==void 0&&vm(this.prototype,t,i)}}static getPropertyDescriptor(t,e,a){let{get:i,set:n}=bm(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get:i,set(o){let s=i?.call(this);n?.call(this,o),this.requestUpdate(t,s,a)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Bs}static _$Ei(){if(this.hasOwnProperty(La("elementProperties")))return;let t=Cm(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(La("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(La("properties"))){let e=this.properties,a=[...Sm(e),...Am(e)];for(let i of a)this.createProperty(i,e[i])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[a,i]of e)this.elementProperties.set(a,i)}this._$Eh=new Map;for(let[e,a]of this.elementProperties){let i=this._$Eu(e,a);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let a=new Set(t.flat(1/0).reverse());for(let i of a)e.unshift(Cn(i))}else t!==void 0&&e.push(Cn(t));return e}static _$Eu(t,e){let a=e.attribute;return a===!1?void 0:typeof a=="string"?a:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,e=this.constructor.elementProperties;for(let a of e.keys())this.hasOwnProperty(a)&&(t.set(a,this[a]),delete this[a]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Ds(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,a){this._$AK(t,a)}_$ET(t,e){let a=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,a);if(i!==void 0&&a.reflect===!0){let n=(a.converter?.toAttribute!==void 0?a.converter:Ra).toAttribute(e,a.type);this._$Em=t,n==null?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){let a=this.constructor,i=a._$Eh.get(t);if(i!==void 0&&this._$Em!==i){let n=a.getPropertyOptions(i),o=typeof n.converter=="function"?{fromAttribute:n.converter}:n.converter?.fromAttribute!==void 0?n.converter:Ra;this._$Em=i,this[i]=o.fromAttribute(e,n.type)??this._$Ej?.get(i)??null,this._$Em=null}}requestUpdate(t,e,a){if(t!==void 0){let i=this.constructor,n=this[t];if(a??(a=i.getPropertyOptions(t)),!((a.hasChanged??Or)(n,e)||a.useDefault&&a.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(i._$Eu(t,a))))return;this.C(t,e,a)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:a,reflect:i,wrapped:n},o){a&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,o??e??this[t]),n!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||a||(e=void 0),this._$AL.set(t,e)),i===!0&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[i,n]of this._$Ep)this[i]=n;this._$Ep=void 0}let a=this.constructor.elementProperties;if(a.size>0)for(let[i,n]of a){let{wrapped:o}=n,s=this[i];o!==!0||this._$AL.has(i)||s===void 0||this.C(i,void 0,n,s)}}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach((a=>a.hostUpdate?.())),this.update(e)):this._$EM()}catch(a){throw t=!1,this._$EM(),a}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach((e=>this._$ET(e,this[e])))),this._$EM()}updated(t){}firstUpdated(t){}};it.elementStyles=[],it.shadowRootOptions={mode:"open"},it[La("elementProperties")]=new Map,it[La("finalized")]=new Map,Em?.({ReactiveElement:it}),(At.reactiveElementVersions??(At.reactiveElementVersions=[])).push("2.1.0");var _a=globalThis,Br=_a.trustedTypes,Gs=Br?Br.createPolicy("lit-html",{createHTML:r=>r}):void 0,En="$lit$",nt=`lit$${Math.random().toFixed(9).slice(2)}$`,Tn="?"+nt,Tm=`<${Tn}>`,Vt=document,wa=()=>Vt.createComment(""),Da=r=>r===null||typeof r!="object"&&typeof r!="function",Pn=Array.isArray,Ys=r=>Pn(r)||typeof r?.[Symbol.iterator]=="function",Mn=`[
|
|
145
145
|
\f\r]`,xa=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ks=/-->/g,Fs=/>/g,Kt=RegExp(`>|${Mn}(?:([^\\s"'>=/]+)(${Mn}*=${Mn}*(?:[^
|
|
146
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Vs=/'/g,Us=/"/g,zs=/^(?:script|style|textarea|title)$/i,Nn=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),p=Nn(1),Ke=Nn(2),Qv=Nn(3),Se=Symbol.for("lit-noChange"),y=Symbol.for("lit-nothing"),Hs=new WeakMap,Ft=Vt.createTreeWalker(Vt,129);function $s(r,t){if(!Pn(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return Gs!==void 0?Gs.createHTML(t):t}var js=(r,t)=>{let e=r.length-1,a=[],i,n=t===2?"<svg>":t===3?"<math>":"",o=xa;for(let s=0;s<e;s++){let l=r[s],c,m,g=-1,h=0;for(;h<l.length&&(o.lastIndex=h,m=o.exec(l),m!==null);)h=o.lastIndex,o===xa?m[1]==="!--"?o=Ks:m[1]!==void 0?o=Fs:m[2]!==void 0?(zs.test(m[2])&&(i=RegExp("</"+m[2],"g")),o=Kt):m[3]!==void 0&&(o=Kt):o===Kt?m[0]===">"?(o=i??xa,g=-1):m[1]===void 0?g=-2:(g=o.lastIndex-m[2].length,c=m[1],o=m[3]===void 0?Kt:m[3]==='"'?Us:Vs):o===Us||o===Vs?o=Kt:o===Ks||o===Fs?o=xa:(o=Kt,i=void 0);let T=o===Kt&&r[s+1].startsWith("/>")?" ":"";n+=o===xa?l+Tm:g>=0?(a.push(c),l.slice(0,g)+En+l.slice(g)+nt+T):l+nt+(g===-2?s:T)}return[$s(r,n+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),a]},Oa=class r{constructor({strings:t,_$litType$:e},a){let i;this.parts=[];let n=0,o=0,s=t.length-1,l=this.parts,[c,m]=js(t,e);if(this.el=r.createElement(c,a),Ft.currentNode=this.el.content,e===2||e===3){let g=this.el.content.firstChild;g.replaceWith(...g.childNodes)}for(;(i=Ft.nextNode())!==null&&l.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let g of i.getAttributeNames())if(g.endsWith(En)){let h=m[o++],T=i.getAttribute(g).split(nt),M=/([.?@])?(.*)/.exec(h);l.push({type:1,index:n,name:M[2],strings:T,ctor:M[1]==="."?Kr:M[1]==="?"?Fr:M[1]==="@"?Vr:Ht}),i.removeAttribute(g)}else g.startsWith(nt)&&(l.push({type:6,index:n}),i.removeAttribute(g));if(zs.test(i.tagName)){let g=i.textContent.split(nt),h=g.length-1;if(h>0){i.textContent=Br?Br.emptyScript:"";for(let T=0;T<h;T++)i.append(g[T],wa()),Ft.nextNode(),l.push({type:2,index:++n});i.append(g[h],wa())}}}else if(i.nodeType===8)if(i.data===Tn)l.push({type:2,index:n});else{let g=-1;for(;(g=i.data.indexOf(nt,g+1))!==-1;)l.push({type:7,index:n}),g+=nt.length-1}n++}}static createElement(t,e){let a=Vt.createElement("template");return a.innerHTML=t,a}};function Ut(r,t,e=r,a){if(t===Se)return t;let i=a!==void 0?e._$Co?.[a]:e._$Cl,n=Da(t)?void 0:t._$litDirective$;return i?.constructor!==n&&(i?._$AO?.(!1),n===void 0?i=void 0:(i=new n(r),i._$AT(r,e,a)),a!==void 0?(e._$Co??(e._$Co=[]))[a]=i:e._$Cl=i),i!==void 0&&(t=Ut(r,i._$AS(r,t.values),i,a)),t}var Gr=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:e},parts:a}=this._$AD,i=(t?.creationScope??Vt).importNode(e,!0);Ft.currentNode=i;let n=Ft.nextNode(),o=0,s=0,l=a[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new oa(n,n.nextSibling,this,t):l.type===1?c=new l.ctor(n,l.name,l.strings,this,t):l.type===6&&(c=new Ur(n,this,t)),this._$AV.push(c),l=a[++s]}o!==l?.index&&(n=Ft.nextNode(),o++)}return Ft.currentNode=Vt,i}p(t){let e=0;for(let a of this._$AV)a!==void 0&&(a.strings!==void 0?(a._$AI(t,a,e),e+=a.strings.length-2):a._$AI(t[e])),e++}},oa=class r{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,a,i){this.type=2,this._$AH=y,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=a,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Ut(this,t,e),Da(t)?t===y||t==null||t===""?(this._$AH!==y&&this._$AR(),this._$AH=y):t!==this._$AH&&t!==Se&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Ys(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==y&&Da(this._$AH)?this._$AA.nextSibling.data=t:this.T(Vt.createTextNode(t)),this._$AH=t}$(t){let{values:e,_$litType$:a}=t,i=typeof a=="number"?this._$AC(t):(a.el===void 0&&(a.el=Oa.createElement($s(a.h,a.h[0]),this.options)),a);if(this._$AH?._$AD===i)this._$AH.p(e);else{let n=new Gr(i,this),o=n.u(this.options);n.p(e),this.T(o),this._$AH=n}}_$AC(t){let e=Hs.get(t.strings);return e===void 0&&Hs.set(t.strings,e=new Oa(t)),e}k(t){Pn(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,a,i=0;for(let n of t)i===e.length?e.push(a=new r(this.O(wa()),this.O(wa()),this,this.options)):a=e[i],a._$AI(n),i++;i<e.length&&(this._$AR(a&&a._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){let a=t.nextSibling;t.remove(),t=a}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},Ht=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,a,i,n){this.type=1,this._$AH=y,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,a.length>2||a[0]!==""||a[1]!==""?(this._$AH=Array(a.length-1).fill(new String),this.strings=a):this._$AH=y}_$AI(t,e=this,a,i){let n=this.strings,o=!1;if(n===void 0)t=Ut(this,t,e,0),o=!Da(t)||t!==this._$AH&&t!==Se,o&&(this._$AH=t);else{let s=t,l,c;for(t=n[0],l=0;l<n.length-1;l++)c=Ut(this,s[a+l],e,l),c===Se&&(c=this._$AH[l]),o||(o=!Da(c)||c!==this._$AH[l]),c===y?t=y:t!==y&&(t+=(c??"")+n[l+1]),this._$AH[l]=c}o&&!i&&this.j(t)}j(t){t===y?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Kr=class extends Ht{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===y?void 0:t}},Fr=class extends Ht{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==y)}},Vr=class extends Ht{constructor(t,e,a,i,n){super(t,e,a,i,n),this.type=5}_$AI(t,e=this){if((t=Ut(this,t,e,0)??y)===Se)return;let a=this._$AH,i=t===y&&a!==y||t.capture!==a.capture||t.once!==a.once||t.passive!==a.passive,n=t!==y&&(a===y||i);i&&this.element.removeEventListener(this.name,this,a),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},Ur=class{constructor(t,e,a){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=a}get _$AU(){return this._$AM._$AU}_$AI(t){Ut(this,t)}},Ws={M:En,P:nt,A:Tn,C:1,L:js,R:Gr,D:Ys,V:Ut,I:oa,H:Ht,N:Fr,U:Vr,B:Kr,F:Ur},Pm=_a.litHtmlPolyfillSupport;Pm?.(Oa,oa),(_a.litHtmlVersions??(_a.litHtmlVersions=[])).push("3.3.0");var Zs=(r,t,e)=>{let a=e?.renderBefore??t,i=a._$litPart$;if(i===void 0){let n=e?.renderBefore??null;a._$litPart$=i=new oa(t.insertBefore(wa(),n),n,void 0,e??{})}return i._$AI(r),i};var Ba=globalThis,v=class extends it{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;let t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Zs(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Se}};v._$litElement$=!0,v.finalized=!0,Ba.litElementHydrateSupport?.({LitElement:v});var Nm=Ba.litElementPolyfillSupport;Nm?.({LitElement:v});(Ba.litElementVersions??(Ba.litElementVersions=[])).push("4.2.0");var b=r=>(t,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(r,t)})):customElements.define(r,t)};var Im={attribute:!0,type:String,converter:Ra,reflect:!1,hasChanged:Or},km=(r=Im,t,e)=>{let{kind:a,metadata:i}=e,n=globalThis.litPropertyMetadata.get(i);if(n===void 0&&globalThis.litPropertyMetadata.set(i,n=new Map),a==="setter"&&((r=Object.create(r)).wrapped=!0),n.set(e.name,r),a==="accessor"){let{name:o}=e;return{set(s){let l=t.get.call(this);t.set.call(this,s),this.requestUpdate(o,l,r)},init(s){return s!==void 0&&this.C(o,void 0,r,s),s}}}if(a==="setter"){let{name:o}=e;return function(s){let l=this[o];t.call(this,s),this.requestUpdate(o,l,r)}}throw Error("Unsupported decorator location: "+a)};function u(r){return(t,e)=>typeof e=="object"?km(r,t,e):((a,i,n)=>{let o=i.hasOwnProperty(n);return i.constructor.createProperty(n,a),o?Object.getOwnPropertyDescriptor(i,n):void 0})(r,t,e)}function N(r){return u({...r,state:!0,attribute:!1})}var Yt=(r,t,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(r,t,e),e);function _e(r,t){return(e,a,i)=>{let n=o=>o.renderRoot?.querySelector(r)??null;if(t){let{get:o,set:s}=typeof a=="object"?e:i??(()=>{let l=Symbol();return{get(){return this[l]},set(c){this[l]=c}}})();return Yt(e,a,{get(){let l=o.call(this);return l===void 0&&(l=n(this),(l!==null||this.hasUpdated)&&s.call(this,l)),l}})}return Yt(e,a,{get(){return n(this)}})}}function R(r,t,e){return r?t(r):e?.(r)}var I=f` * { box-sizing: border-box; } `,Js=f` :host { display: block; isolation: isolate; position: relative; width: 100%; //Keep the CSS loader in the same position - check css-loader-inline.ts min-height: 64px; } `;var qs="https://sdk.primer.io/web/v2-latest/Primer.min.js",he="20px";var Hr=class{constructor(t){this.paymentMethods=null;this.paymentManagers=null;this.vaultController=null;this.headlessInstance=t,this.vault={createCvvInput:e=>this.createCvvInputInternal(e),startPayment:(e,a)=>this.startVaultPaymentInternal(e,a),delete:e=>this.deleteVaultPaymentMethod(e)}}setPaymentMethods(t){this.paymentMethods=t}setPaymentManagers(t){this.paymentManagers=t}setVaultController(t){this.vaultController=t}async createCvvInputInternal(t){return this.vaultController?this.vaultController.createCvvInput(t):(P.warn("PrimerJS: Vault not available - createCvvInput cannot be called"),null)}async startVaultPaymentInternal(t,e){if(!this.vaultController)throw new Error("Vault manager not initialized");return this.vaultController.startVaultPaymentById(t,e)}async deleteVaultPaymentMethod(t){if(!this.vaultController)throw new Error("Vault manager not initialized");return this.vaultController.deleteVaultedPaymentMethod(t)}async createCvvInput(t){return this.vault.createCvvInput(t)}async startVaultPayment(t,e){return this.vault.startPayment(t,e)}async refreshSession(){if(!this.headlessInstance){P.errorWithDatadog("PrimerJS: Cannot refresh session: Headless instance not available");return}try{await this.headlessInstance.refreshClientSession()}catch(t){throw P.errorWithDatadog("PrimerJS: Error refreshing client session",{error:t}),t}}getPaymentMethods(){return this.paymentMethods?this.paymentMethods:(P.warn("PrimerJS: Payment methods not available"),[])}handlePaymentStart(){this.onPaymentStart&&this.onPaymentStart()}handleVaultedMethodsUpdate(t,e){if(this.onVaultedMethodsUpdate){let a=Math.floor(Date.now()/1e3);this.onVaultedMethodsUpdate({vaultedPayments:t,cvvRecapture:e,timestamp:a})}}setCardholderName(t){if(!this.paymentManagers){P.warn("PrimerJS: Payment managers not available - setCardholderName cannot be called yet");return}let e=this.paymentManagers.get("PAYMENT_CARD");if(!e||e.type!=="PAYMENT_CARD"){P.warn("PrimerJS: Card payment manager not available");return}try{e.manager.setCardholderName(t)}catch(a){P.errorWithDatadog("PrimerJS: Error setting cardholder name",{error:a})}}};var Yr=typeof window<"u"&&typeof window.document<"u";function Lm(r){return document.querySelector(`script[src^="${r}"]`)}function Rm(r,t){let e=document.createElement("script");return e.setAttribute("src",r),e.setAttribute("async",""),e.setAttribute("crossorigin","anonymous"),t&&e.setAttribute("type","module"),e}function Qs(r,t=!1){if(!Yr)throw new Error("Cannot load script in server environment");let e=Lm(r)??Rm(r,t);return new Promise((a,i)=>{e.onload=()=>{a()},e.onerror=()=>{i(new Error(`Failed to load script: ${r}`))},e.parentNode||document.head.appendChild(e)})}var Xs=f` :host { display: contents; } .cta-button { display: block; margin: auto; } `;var ie=class extends v{constructor(){super(...arguments);this.size="large";this.showCloseButton=!1;this.darkMode=!1;this.open=!1}openDialog(){this.open=!0}closeDialog(){let e=()=>{this.open=!1,this.removeEventListener("primer:dialog-close",e)};this.addEventListener("primer:dialog-close",e),this.dialog.startExitAnimation()}connectedCallback(){super.connectedCallback(),this.darkMode&&this.classList.add("primer-dark-theme"),this.open||this.openDialog()}updated(e){super.updated(e),e.has("darkMode")&&(this.darkMode?this.classList.add("primer-dark-theme"):this.classList.remove("primer-dark-theme")),e.has("open")&&this.open&&this.onOpen&&this.onOpen(),e.has("open")&&this.open&&this.onContentRendered&&this.updateComplete.then(()=>{requestAnimationFrame(()=>{this.onContentRendered?.()})})}render(){return this.open?p`<primer-dialog class="${this.darkMode?"primer-dark-theme":""}" .open=${this.open} size=${this.size} .showCloseButton=${this.showCloseButton} @primer:dialog-close="${()=>{this.open=!1}}" ><slot></slot>${this.cta?p`<primer-button @click=${this.cta.onClick} class="cta-button">${this.cta.icon?p`<primer-icon name="${this.cta.icon}" size="sm" color="var(--primer-color-background-outlined-default)" ></primer-icon>`:y} ${this.cta.label}</primer-button>`:y}</primer-dialog>`:y}};ie.styles=[I,Xs],d([u({type:String})],ie.prototype,"size",2),d([u({type:Boolean})],ie.prototype,"showCloseButton",2),d([u({type:Boolean})],ie.prototype,"darkMode",2),d([u({type:Object})],ie.prototype,"onOpen",2),d([u({type:Object})],ie.prototype,"onContentRendered",2),d([u({type:Object})],ie.prototype,"cta",2),d([N()],ie.prototype,"open",2),d([_e("primer-dialog")],ie.prototype,"dialog",2),ie=d([b("primer-portal-dialog"),D()],ie);var zr=class{constructor(){this.currentDialog=null;this.currentResolver=null}async show(t){return new Promise(e=>{let a=new ie;a.size=t.size??"large",a.showCloseButton=t.showCloseButton??!1;let i=document.querySelector("primer-checkout");a.darkMode=i?.classList.contains("primer-dark-theme")??!1,a.onContentRendered=t.onContentReady,a.cta=t.cta;let n=()=>{a.remove(),this.currentDialog=null,this.currentResolver=null,e({success:!1})};a.addEventListener("primer:dialog-close",n),this.currentDialog=a,this.currentResolver=e,document.body.appendChild(a),a.appendChild(t.htmlContent)})}close(){this.currentDialog&&this.currentResolver&&(this.currentDialog.closeDialog(),this.currentResolver({success:!0}),this.currentDialog.remove(),this.currentDialog=null,this.currentResolver=null)}};var xm=Za({"../../../localization/lit-localize/locales/ar.ts":()=>import("./chunks/ar.4ZFBST5B.js"),"../../../localization/lit-localize/locales/bg.ts":()=>import("./chunks/bg.A6DFGUKU.js"),"../../../localization/lit-localize/locales/ca.ts":()=>import("./chunks/ca.3MVWILFG.js"),"../../../localization/lit-localize/locales/cs.ts":()=>import("./chunks/cs.INYY7XZR.js"),"../../../localization/lit-localize/locales/da.ts":()=>import("./chunks/da.Y5IIDRC3.js"),"../../../localization/lit-localize/locales/de.ts":()=>import("./chunks/de.JZT46DAB.js"),"../../../localization/lit-localize/locales/el.ts":()=>import("./chunks/el.FJQOSK4N.js"),"../../../localization/lit-localize/locales/en-GB.ts":()=>import("./chunks/en-GB.TL522NMU.js"),"../../../localization/lit-localize/locales/en.ts":()=>import("./chunks/en.JFPWSECQ.js"),"../../../localization/lit-localize/locales/es-AR.ts":()=>import("./chunks/es-AR.GBZW2HPG.js"),"../../../localization/lit-localize/locales/es-MX.ts":()=>import("./chunks/es-MX.NFJ7HXSV.js"),"../../../localization/lit-localize/locales/es.ts":()=>import("./chunks/es.FX4YBDVU.js"),"../../../localization/lit-localize/locales/et-EE.ts":()=>import("./chunks/et-EE.JZD334EI.js"),"../../../localization/lit-localize/locales/fi-FI.ts":()=>import("./chunks/fi-FI.SHTM3UQK.js"),"../../../localization/lit-localize/locales/fr.ts":()=>import("./chunks/fr.MZYBSJWU.js"),"../../../localization/lit-localize/locales/he.ts":()=>import("./chunks/he.BQXGQQ4P.js"),"../../../localization/lit-localize/locales/hr.ts":()=>import("./chunks/hr.EK5WNO4N.js"),"../../../localization/lit-localize/locales/hu.ts":()=>import("./chunks/hu.N2BVXVWY.js"),"../../../localization/lit-localize/locales/id.ts":()=>import("./chunks/id.IJ37WK5P.js"),"../../../localization/lit-localize/locales/it.ts":()=>import("./chunks/it.2ZUPJDRP.js"),"../../../localization/lit-localize/locales/ja.ts":()=>import("./chunks/ja.BNLF6BZT.js"),"../../../localization/lit-localize/locales/ko.ts":()=>import("./chunks/ko.YJAZTBEF.js"),"../../../localization/lit-localize/locales/lt-LT.ts":()=>import("./chunks/lt-LT.GOVUI3KD.js"),"../../../localization/lit-localize/locales/lt.ts":()=>import("./chunks/lt.IPLRYI7A.js"),"../../../localization/lit-localize/locales/lv-LV.ts":()=>import("./chunks/lv-LV.EA76F4DL.js"),"../../../localization/lit-localize/locales/lv.ts":()=>import("./chunks/lv.I7E6LMWA.js"),"../../../localization/lit-localize/locales/ms.ts":()=>import("./chunks/ms.6I2BVK63.js"),"../../../localization/lit-localize/locales/nb.ts":()=>import("./chunks/nb.BYMLE7EQ.js"),"../../../localization/lit-localize/locales/nl.ts":()=>import("./chunks/nl.QOSIJQZE.js"),"../../../localization/lit-localize/locales/nl_NL.ts":()=>import("./chunks/nl_NL.DVZWMQJN.js"),"../../../localization/lit-localize/locales/pl.ts":()=>import("./chunks/pl.VK5CNTV3.js"),"../../../localization/lit-localize/locales/pt-BR.ts":()=>import("./chunks/pt-BR.22GYWGY5.js"),"../../../localization/lit-localize/locales/pt.ts":()=>import("./chunks/pt.L2PBSEBD.js"),"../../../localization/lit-localize/locales/ro.ts":()=>import("./chunks/ro.VFIM4IS3.js"),"../../../localization/lit-localize/locales/ru.ts":()=>import("./chunks/ru.VLLE4DKK.js"),"../../../localization/lit-localize/locales/sk.ts":()=>import("./chunks/sk.JALTDVLO.js"),"../../../localization/lit-localize/locales/sl.ts":()=>import("./chunks/sl.PQOCETM2.js"),"../../../localization/lit-localize/locales/sr-RS.ts":()=>import("./chunks/sr-RS.RGO57OCW.js"),"../../../localization/lit-localize/locales/sv.ts":()=>import("./chunks/sv.FQJP73FF.js"),"../../../localization/lit-localize/locales/th.ts":()=>import("./chunks/th.QYA26J2E.js"),"../../../localization/lit-localize/locales/tr.ts":()=>import("./chunks/tr.5ZDAANBV.js"),"../../../localization/lit-localize/locales/uk-UA.ts":()=>import("./chunks/uk-UA.FWQ7KVBB.js"),"../../../localization/lit-localize/locales/vi.ts":()=>import("./chunks/vi.GB6QZAMD.js"),"../../../localization/lit-localize/locales/zf.ts":()=>import("./chunks/zf.LNP32XVM.js"),"../../../localization/lit-localize/locales/zh-CN.ts":()=>import("./chunks/zh-CN.OEA7I6ZA.js"),"../../../localization/lit-localize/locales/zh-HK.ts":()=>import("./chunks/zh-HK.OUXNL5ZM.js"),"../../../localization/lit-localize/locales/zh-TW.ts":()=>import("./chunks/zh-TW.C5STTOCA.js")});var sa=null,In=null;async function el(r){if(In===r&&sa)return sa;try{return sa=(await xm(`../../../localization/lit-localize/locales/${r}.ts`)).templates,In=r,sa}catch{return r!=="en-GB"?el("en-GB"):(sa={},In=r,sa)}}async function tl(r){let t=await el(r);return(e,a)=>t[e]??a}var Ct={WORLDPAY_IDEAL:"WORLDPAY_IDEAL",AUTOMATED_CLEARING_HOUSE:"AUTOMATED_CLEARING_HOUSE",ADYEN_KLARNA:"ADYEN_KLARNA",ADYEN_BANCONTACT_CARD:"ADYEN_BANCONTACT_CARD",PAY_NL_KAARTDIRECT:"PAY_NL_KAARTDIRECT",ADYEN_EPS:"ADYEN_EPS",ADYEN_BANCONTACT_PAYCONIQ:"ADYEN_BANCONTACT_PAYCONIQ",OMISE_PROMPTPAY:"OMISE_PROMPTPAY",OMISE_TRUEMONEY:"OMISE_TRUEMONEY",ADYEN_MULTIBANCO:"ADYEN_MULTIBANCO",PACYPAY_WECHAT:"PACYPAY_WECHAT",PACYPAY_ALIPAY:"PACYPAY_ALIPAY",ADYEN_MBWAY:"ADYEN_MBWAY",XENDIT_DANA:"XENDIT_DANA",XENDIT_SHOPEEPAY:"XENDIT_SHOPEEPAY",ADYEN_PAYSHOP:"ADYEN_PAYSHOP",ADYEN_PAYTRAIL:"ADYEN_PAYTRAIL",CLEARPAY:"CLEARPAY",RAPYD_FAST:"RAPYD_FAST",RAPYD_PROMPTPAY:"RAPYD_PROMPTPAY",RAPYD_GCASH:"RAPYD_GCASH",RAPYD_POLI:"RAPYD_POLI",RAPYD_GRABPAY:"RAPYD_GRABPAY",PRIMER_PAYPAL:"PRIMER_PAYPAL",TWOC2P:"TWOC2P",NETS:"NETS",STRIPE_ACH:"STRIPE_ACH",STRIPE_GIROPAY:"STRIPE_GIROPAY",MOLLIE_GIROPAY:"MOLLIE_GIROPAY",MOLLIE_EPS:"MOLLIE_EPS",PAY_NL_EPS:"PAY_NL_EPS",PAY_NL_P24:"PAY_NL_P24",MOLLIE_P24:"MOLLIE_P24",MOLLIE_SOFORT:"MOLLIE_SOFORT",COINBASE:"COINBASE",OPENNODE:"OPENNODE",MOLLIE_GIFT_CARD:"MOLLIE_GIFTCARD",XFERS_PAYNOW:"XFERS_PAYNOW",CARD:"PAYMENT_CARD",APPLE_PAY:"APPLE_PAY",GOOGLE_PAY:"GOOGLE_PAY",PAYPAL:"PAYPAL_ORDER",PAYPAL_VAULTED:"PAYPAL_BILLING_AGREEMENT",GO_CARDLESS:"GOCARDLESS",PAY_NL_IDEAL:"PAY_NL_IDEAL",PAY_NL_SOFORT_BANKING:"PAY_NL_SOFORT_BANKING",PAY_NL_BANCONTACT:"PAY_NL_BANCONTACT",PAY_NL_PAYPAL:"PAY_NL_PAYPAL",PAY_NL_CREDIT_TRANSFER:"PAY_NL_CREDIT_TRANSFER",PAY_NL_DIRECT_DEBIT:"PAY_NL_DIRECT_DEBIT",PAY_NL_GIROPAY:"PAY_NL_GIROPAY",PAY_NL_PAYCONIQ:"PAY_NL_PAYCONIQ",PAY_NL_RIVERTY:"PAY_NL_RIVERTY",HOOLAH:"HOOLAH",ADYEN_BLIK:"ADYEN_BLIK",ADYEN_VIPPS:"ADYEN_VIPPS",ADYEN_GIROPAY:"ADYEN_GIROPAY",ADYEN_SOFORT:"ADYEN_SOFORT",ADYEN_IDEAL:"ADYEN_IDEAL",ADYEN_TRUSTLY:"ADYEN_TRUSTLY",ADYEN_ALIPAY:"ADYEN_ALIPAY",ADYEN_TWINT:"ADYEN_TWINT",ADYEN_MOBILEPAY:"ADYEN_MOBILEPAY",MOLLIE_BANCONTACT:"MOLLIE_BANCONTACT",MOLLIE_IDEAL:"MOLLIE_IDEAL",BUCKAROO_GIROPAY:"BUCKAROO_GIROPAY",BUCKAROO_EPS:"BUCKAROO_EPS",BUCKAROO_SOFORT:"BUCKAROO_SOFORT",BUCKAROO_BANCONTACT:"BUCKAROO_BANCONTACT",BUCKAROO_IDEAL:"BUCKAROO_IDEAL",ATOME:"ATOME",KLARNA_CUSTOMER_TOKEN:"KLARNA_CUSTOMER_TOKEN",DLOCAL_PIX:"DLOCAL_PIX",ALMA:"ALMA",ADYEN_CASHAPP:"ADYEN_CASHAPP",ADYEN_AFFIRM:"ADYEN_AFFIRM"},Ga={WORLDPAY_IDEAL:"WORLDPAY_IDEAL",STRIPE_ACH:"STRIPE_ACH",STRIPE_IDEAL:"STRIPE_IDEAL",ADYEN_KLARNA:"ADYEN_KLARNA",ADYEN_BANCONTACT_CARD:"ADYEN_BANCONTACT_CARD",PAY_NL_KAARTDIRECT:"PAY_NL_KAARTDIRECT",ADYEN_EPS:"ADYEN_EPS",ADYEN_BANCONTACT_PAYCONIQ:"ADYEN_BANCONTACT_PAYCONIQ",OMISE_PROMPTPAY:"OMISE_PROMPTPAY",OMISE_TRUEMONEY:"OMISE_TRUEMONEY",ADYEN_MULTIBANCO:"ADYEN_MULTIBANCO",PACYPAY_WECHAT:"PACYPAY_WECHAT",PACYPAY_ALIPAY:"PACYPAY_ALIPAY",ADYEN_MBWAY:"ADYEN_MBWAY",XENDIT_DANA:"XENDIT_DANA",XENDIT_SHOPEEPAY:"XENDIT_SHOPEEPAY",ADYEN_PAYSHOP:"ADYEN_PAYSHOP",ADYEN_PAYTRAIL:"ADYEN_PAYTRAIL",CLEARPAY:"CLEARPAY",RAPYD_FAST:"RAPYD_FAST",RAPYD_PROMPTPAY:"RAPYD_PROMPTPAY",RAPYD_GCASH:"RAPYD_GCASH",RAPYD_POLI:"RAPYD_POLI",RAPYD_GRABPAY:"RAPYD_GRABPAY",PRIMER_PAYPAL:"PRIMER_PAYPAL",TWOC2P:"TWOC2P",NETS:"NETS",STRIPE_GIROPAY:"STRIPE_GIROPAY",MOLLIE_GIROPAY:"MOLLIE_GIROPAY",MOLLIE_EPS:"MOLLIE_EPS",PAY_NL_EPS:"PAY_NL_EPS",PAY_NL_P24:"PAY_NL_P24",MOLLIE_P24:"MOLLIE_P24",MOLLIE_SOFORT:"MOLLIE_SOFORT",COINBASE:"COINBASE",OPENNODE:"OPENNODE",MOLLIE_GIFT_CARD:"MOLLIE_GIFTCARD",XFERS_PAYNOW:"XFERS_PAYNOW",PAYMENT_CARD:"PAYMENT_CARD",APPLE_PAY:"APPLE_PAY",GOOGLE_PAY:"GOOGLE_PAY",PAYPAL:"PAYPAL",GO_CARDLESS:"GOCARDLESS",KLARNA:"KLARNA",PAY_NL_IDEAL:"PAY_NL_IDEAL",PAY_NL_SOFORT_BANKING:"PAY_NL_SOFORT_BANKING",PAY_NL_BANCONTACT:"PAY_NL_BANCONTACT",PAY_NL_PAYPAL:"PAY_NL_PAYPAL",PAY_NL_CREDIT_TRANSFER:"PAY_NL_CREDIT_TRANSFER",PAY_NL_DIRECT_DEBIT:"PAY_NL_DIRECT_DEBIT",PAY_NL_GIROPAY:"PAY_NL_GIROPAY",PAY_NL_PAYCONIQ:"PAY_NL_PAYCONIQ",PAY_NL_RIVERTY:"PAY_NL_RIVERTY",HOOLAH:"HOOLAH",ADYEN_BLIK:"ADYEN_BLIK",ADYEN_MOBILEPAY:"ADYEN_MOBILEPAY",ADYEN_VIPPS:"ADYEN_VIPPS",ADYEN_GIROPAY:"ADYEN_GIROPAY",ADYEN_SOFORT:"ADYEN_SOFORT",ADYEN_IDEAL:"ADYEN_IDEAL",ADYEN_TRUSTLY:"ADYEN_TRUSTLY",ADYEN_ALIPAY:"ADYEN_ALIPAY",ADYEN_TWINT:"ADYEN_TWINT",ADYEN_BANK_TRANSFER:"ADYEN_BANK_TRANSFER",MOLLIE_BANCONTACT:"MOLLIE_BANCONTACT",MOLLIE_IDEAL:"MOLLIE_IDEAL",BUCKAROO_GIROPAY:"BUCKAROO_GIROPAY",BUCKAROO_EPS:"BUCKAROO_EPS",BUCKAROO_SOFORT:"BUCKAROO_SOFORT",BUCKAROO_BANCONTACT:"BUCKAROO_BANCONTACT",BUCKAROO_IDEAL:"BUCKAROO_IDEAL",ATOME:"ATOME",DLOCAL_PIX:"DLOCAL_PIX",ALMA:"ALMA",ADYEN_CASHAPP:"ADYEN_CASHAPP",ADYEN_AFFIRM:"ADYEN_AFFIRM"};var $r=class r extends Error{constructor(t,e){super(e.message),this.name="PrimerClientError",this.code=t,this.diagnosticsId=e.diagnosticsId||null,this.data=e.data,this.isFromDeveloper=e.isFromDeveloper||!1}static fromErrorCode(t,e){return new r(t,e)}};function al(r,t,e){return r.isDisconnected?!1:(r.host.sdkStateController.currentState.paymentFailure!==null&&X({eventName:"PAYMENT_REATTEMPTED",paymentMethod:t}),r.host.sdkStateController.startProcessing(),r.host.primerEventsController.dispatchPaymentStart(t,e))}function rl(r,t,e){if(!r.isDisconnected&&(P.info("Payment completed:",t),r.host.sdkStateController.completeProcessing(),r.host.primerEventsController.dispatchPaymentSuccess(t,e),X({eventName:"PAYMENT_SUCCESS",paymentId:t?.id,paymentMethod:e}),r.primerJS?.onPaymentSuccess)){let a=Math.floor(Date.now()/1e3);r.primerJS.onPaymentSuccess({payment:ta(t),paymentMethodType:e,timestamp:a})}}function il(r,t,e,a){if(r.isDisconnected)return;(s=>typeof s=="object"&&s!==null&&"response"in s&&typeof s.response=="object"&&s.response!==null&&"status"in s.response&&typeof s.response.status=="number")(t)&&t.response.status>=500?P.errorWithDatadog("Payment failed with server error",{error:t}):P.error("Payment failed:",t);let o=t instanceof $r?{code:t.code||"UNKNOWN_ERROR",message:t.message||"Unknown error occurred",diagnosticsId:t.diagnosticsId,data:t.data}:(()=>{let s=t,l=s instanceof Error&&"code"in s&&typeof s.code=="string"?s.code:"UNKNOWN_ERROR",c=s instanceof Error?s.message:"Unknown error occurred";return{code:l,message:c,data:{error:t}}})();if(r.host.sdkStateController.setPaymentFailure(o),r.host.primerEventsController.dispatchPaymentFailure({code:o.code,message:o.message,diagnosticsId:"diagnosticsId"in o?o.diagnosticsId??void 0:void 0,data:o.data},e,a),X({eventName:"PAYMENT_FAILURE",paymentId:a?.id,paymentMethod:e}),r.primerJS?.onPaymentFailure){let s=Math.floor(Date.now()/1e3);r.primerJS.onPaymentFailure({error:{code:o.code,message:o.message,diagnosticsId:"diagnosticsId"in o?o.diagnosticsId??void 0:void 0,data:o.data},payment:a?ta(a):void 0,paymentMethodType:e,timestamp:s})}}var kn="1.0.5",jr=class{constructor(t){this.createPaymentMethodManager=null;this._paymentsList=[];this.currentSdkInstance=null;this.primerJS=null;this.loadingTimeout=null;this.isDisconnected=!1;(this.host=t).addController(this),this.isDisconnected=!1,this.sdkInstanceTask=new O(t,{args:()=>[this.host.clientToken,this.host.options],task:this.initializeHeadless()}),new O(t,{args:()=>[this.sdkInstanceTask.value,this.paymentsList],task:this.initializeLitContext()})}set paymentsList(t){this._paymentsList=t,this.host.requestUpdate()}get paymentsList(){return this._paymentsList}get primerJSInstance(){return this.primerJS}hostConnected(){this.isDisconnected=!1,this.host.sdkStateController.startLoading(),this.setupLoadingTimeout()}hostDisconnected(){if(this.isDisconnected=!0,this.host.sdkContextController.getAnalyticsUtils()){let e=this.host.sdkStateController.currentState;(e.isProcessing||e.isLoading||this.currentSdkInstance)&&X({eventName:"PAYMENT_FLOW_EXITED"})}this.cleanupResources()}normalizeOptionsForLegacySdk(t){if(t.sdkCore!==!1)return{...t,sdkCore:!0};let e={...t};if(e.card?.cardholderName){let a={...e.card.cardholderName};a.visible===!1&&(a.required=!1),e.card={...e.card,cardholderName:a}}return e}setupLoadingTimeout(){this.clearLoadingTimeout(),this.loadingTimeout=setTimeout(()=>{this.host.sdkStateController.currentState.isLoading&&(P.warn("Loading timeout reached, resetting SDK state"),X({eventName:"PAYMENT_FLOW_EXITED",eventType:"timeout"}),this.cleanupResources(),this.host.sdkStateController.completeLoading())},1e4)}clearLoadingTimeout(){this.loadingTimeout!==null&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null)}cleanupResources(){if(this.clearLoadingTimeout(),this.currentSdkInstance)try{this.paymentsList=[],this.createPaymentMethodManager=null,this.host.sdkStateController.reset(),this.currentSdkInstance.teardown?.(),P.info("SDK instance cleaned up")}catch(t){P.errorWithDatadog("Error cleaning up SDK instance",{error:t})}As(),P.setClientToken(void 0),P.setSdkOptions(void 0),this.currentSdkInstance=null,this.primerJS=null}async _loadV2Sdk(t=qs){let e=window;if(e.Primer&&typeof e.Primer.preloadPrimer=="function"){P.info("SDK already loaded, skipping load script"),await e.Primer.preloadPrimer();return}await Qs(t),await e.Primer.preloadPrimer()}initializeHeadless(){return async([t,e])=>{if(this.isDisconnected)return P.warn("Component disconnected, aborting SDK initialization"),w;if(!t||!e)return w;this.cleanupResources();let a;try{let i;if(e.sdkCore!==!1){let l=new zr,c=na(e.locale||_r()),m=await tl(c);i={createHeadless:(h,T)=>rs(h,{...T,dialogProvider:l,translate:m,sdkVersion:kn,locale:c})}}else await this._loadV2Sdk(),i=window.Primer;this.primerJS=new Hr(null),this.primerJS.setVaultController(this.host.vaultManagerController);let n=this.normalizeOptionsForLegacySdk(e);P.setClientToken(t),P.setSdkOptions(n);let o=await i.createHeadless(t,{...n,onAvailablePaymentMethodsLoad:l=>{this.isDisconnected||(P.info("Configuration payment methods:",l),this.paymentsList=l)},onCheckoutComplete:({payment:l})=>{let c=l?.paymentMethodData?.paymentMethodType;rl({isDisconnected:this.isDisconnected,host:this.host,primerJS:this.primerJS},l,c)},onCheckoutFail:(l,c)=>{let m=c.payment?.paymentMethodData?.paymentMethodType;il({isDisconnected:this.isDisconnected,host:this.host,primerJS:this.primerJS},l,m,c.payment)},onBeforePaymentCreate:(l,c)=>{if(!l.paymentMethodType){P.error("Payment creation started without payment method type"),c?.abortPaymentCreation();return}if(!(al({isDisconnected:this.isDisconnected,host:this.host,primerJS:this.primerJS},l.paymentMethodType,c)||this.isDisconnected)){if(this.primerJS?.onPaymentPrepare){this.primerJS.onPaymentPrepare({paymentMethodType:l.paymentMethodType},c);return}c?.continuePaymentCreation()}},onPaymentMethodAction:(l,c)=>{this.isDisconnected||l==="PAYMENT_METHOD_UNSELECTED"&&(this.host.primerEventsController.dispatchPaymentCancel(c),this.host.sdkStateController.stopProcessing())},onPaymentCreationStart:()=>{this.isDisconnected||this.primerJS&&this.primerJS.handlePaymentStart()}});if(this.createPaymentMethodManager=o.createPaymentMethodManager.bind(o),this.currentSdkInstance=o,this.primerJS&&Object.defineProperty(this.primerJS,"headlessInstance",{value:o,writable:!1}),await o.start(),this.isDisconnected)return this.cleanupResources(),w;this.host.sdkContextController.setClientOptions(e),this.primerJS&&this.host.primerEventsController.dispatchCheckoutInitialized(this.primerJS);let s=o.getSDKUtilities();if(a=o.getAnalyticsUtils?.(),a&&(this.host.sdkContextController.setAnalyticsUtils({...a,sdkVersion:kn}),Ss({environment:a.environment,checkoutSessionId:a.checkoutSessionId,clientSessionId:a.clientSessionId||"",primerAccountId:a.primerAccountId||"",sdkVersion:kn,clientSessionToken:a.clientSessionToken,userAgent:typeof navigator<"u"?navigator.userAgent:""}),a.configurationFetchStartTime&&$e.setSdkInitStartTime(a.configurationFetchStartTime),X({eventName:"SDK_INIT_START"})),this.host.sdkContextController.setHeadlessUtils(s),e.sdkCore&&o.getConfiguration){let l=o.getConfiguration();this.host.sdkContextController.setConfiguration(l)}return this.host.vaultManagerController.initializeVaultManager(o.createVaultManager.bind(o),{vaultEnabled:e.vault?.enabled,captureVaultedCardCvv:!!s.getPaymentMethodConfiguration("PAYMENT_CARD")?.options?.captureVaultedCardCvv,showEmptyState:e.vault?.showEmptyState,headless:e.vault?.headless??!1}),o}catch(i){throw i instanceof Error&&(P.errorWithDatadog("SDK initialization error",{error:i,status:"error"}),this.host.sdkStateController.setPrimerJsError(i)),this.cleanupResources(),i}}}initializeLitContext(){return async([t,e])=>{if(this.isDisconnected)return w;if(!t||!e.length)return w;let a=new Map,i=new Map;try{for(let o of e){if(this.isDisconnected)break;let s=await this.initializePaymentMethodManager(o)();o&&s&&(a.set(o.type,o),i.set(o.type,s))}if(this.isDisconnected)return w;let n=Array.from(a.values());return this.host.sdkContextController.setPaymentManagers(i),this.host.sdkContextController.setPaymentMethods(n),this.primerJS&&(this.primerJS.setPaymentMethods(n),this.primerJS.setPaymentManagers(i)),this.host.primerEventsController.dispatchPaymentMethods(n),P.info("Initialized payment methods:",n),a}catch(n){if(n instanceof Error)throw this.host.sdkStateController.setPrimerJsError(n),n;return null}finally{this.clearLoadingTimeout(),this.isDisconnected||(this.host.sdkStateController.completeLoading(),X({eventName:"SDK_INIT_END"}))}}}initializePaymentMethodManager(t){let{type:e,managerType:a}=t;return async()=>{if(this.isDisconnected||!this.createPaymentMethodManager)return null;if(a==="KLARNA"){let i=await this.createPaymentMethodManager("KLARNA",{onPaymentMethodCategoriesChange:n=>{this.isDisconnected||this.host.sdkContextController.setKlarnaCategories({categories:n,isLoading:!1})}});return i?{type:e,manager:i}:null}try{if(a==="CARD"){let n=await this.createPaymentMethodManager("PAYMENT_CARD",{onBinDataAvailable:o=>{this.isDisconnected||this.host.primerEventsController.dispatchBinDataAvailable(o)},onCardNetworksChange:o=>{if(this.isDisconnected)return;let{detectedCardNetworks:s,selectableCardNetworks:l}=o;this.updateCardNetworksState({detectedCardNetwork:s.preferred??s.items[0],selectableCardNetworks:l?.items??[],isLoading:!1})},onBinDataLoadingChange:o=>{this.isDisconnected||(o?this.updateCardNetworksState({detectedCardNetwork:null,selectableCardNetworks:[],isLoading:!0}):this.host.sdkContextController.setCardNetworksLoadingFalse(),this.host.primerEventsController.dispatchBinDataLoadingChange(o))}});return n?{type:e,manager:n}:null}let i=await this.createPaymentMethodManager(e);return i?{type:e,manager:i}:null}catch(i){return P.errorWithDatadog(`Failed to initialize manager for ${e}`,{error:i}),null}}}updateCardNetworksState(t){this.host.primerEventsController.dispatchCardNetworkChange(t),this.host.sdkContextController.setCardNetworks(t)}};var Wr=class{constructor(t){this.host=t,t.addController(this)}_error(t){let{error:e}=t.detail;this.host.sdkStateController.setPaymentFailure({code:"UNKNOWN_ERROR",message:e.message})}_mandateConfirmed(){this.host.sdkStateController.completeProcessing()}_mandateDeclined(){this.host.sdkStateController.setPaymentFailure({code:"UNKNOWN_ERROR",message:"Mandate declined"})}hostConnected(){this.host.addEventListener("primer-ach-error",this._error.bind(this)),this.host.addEventListener("primer-ach-mandate-confirmed",this._mandateConfirmed.bind(this)),this.host.addEventListener("primer-ach-mandate-declined",this._mandateDeclined.bind(this))}hostDisconnected(){this.host.removeEventListener("primer-ach-error",this._error.bind(this)),this.host.removeEventListener("primer-ach-mandate-confirmed",this._mandateConfirmed.bind(this)),this.host.removeEventListener("primer-ach-mandate-declined",this._mandateDeclined.bind(this))}};var _m=Za({"../../localization/lit-localize/locales/ar.ts":()=>import("./chunks/ar.4ZFBST5B.js"),"../../localization/lit-localize/locales/bg.ts":()=>import("./chunks/bg.A6DFGUKU.js"),"../../localization/lit-localize/locales/ca.ts":()=>import("./chunks/ca.3MVWILFG.js"),"../../localization/lit-localize/locales/cs.ts":()=>import("./chunks/cs.INYY7XZR.js"),"../../localization/lit-localize/locales/da.ts":()=>import("./chunks/da.Y5IIDRC3.js"),"../../localization/lit-localize/locales/de.ts":()=>import("./chunks/de.JZT46DAB.js"),"../../localization/lit-localize/locales/el.ts":()=>import("./chunks/el.FJQOSK4N.js"),"../../localization/lit-localize/locales/en-GB.ts":()=>import("./chunks/en-GB.TL522NMU.js"),"../../localization/lit-localize/locales/en.ts":()=>import("./chunks/en.JFPWSECQ.js"),"../../localization/lit-localize/locales/es-AR.ts":()=>import("./chunks/es-AR.GBZW2HPG.js"),"../../localization/lit-localize/locales/es-MX.ts":()=>import("./chunks/es-MX.NFJ7HXSV.js"),"../../localization/lit-localize/locales/es.ts":()=>import("./chunks/es.FX4YBDVU.js"),"../../localization/lit-localize/locales/et-EE.ts":()=>import("./chunks/et-EE.JZD334EI.js"),"../../localization/lit-localize/locales/fi-FI.ts":()=>import("./chunks/fi-FI.SHTM3UQK.js"),"../../localization/lit-localize/locales/fr.ts":()=>import("./chunks/fr.MZYBSJWU.js"),"../../localization/lit-localize/locales/he.ts":()=>import("./chunks/he.BQXGQQ4P.js"),"../../localization/lit-localize/locales/hr.ts":()=>import("./chunks/hr.EK5WNO4N.js"),"../../localization/lit-localize/locales/hu.ts":()=>import("./chunks/hu.N2BVXVWY.js"),"../../localization/lit-localize/locales/id.ts":()=>import("./chunks/id.IJ37WK5P.js"),"../../localization/lit-localize/locales/it.ts":()=>import("./chunks/it.2ZUPJDRP.js"),"../../localization/lit-localize/locales/ja.ts":()=>import("./chunks/ja.BNLF6BZT.js"),"../../localization/lit-localize/locales/ko.ts":()=>import("./chunks/ko.YJAZTBEF.js"),"../../localization/lit-localize/locales/lt-LT.ts":()=>import("./chunks/lt-LT.GOVUI3KD.js"),"../../localization/lit-localize/locales/lt.ts":()=>import("./chunks/lt.IPLRYI7A.js"),"../../localization/lit-localize/locales/lv-LV.ts":()=>import("./chunks/lv-LV.EA76F4DL.js"),"../../localization/lit-localize/locales/lv.ts":()=>import("./chunks/lv.I7E6LMWA.js"),"../../localization/lit-localize/locales/ms.ts":()=>import("./chunks/ms.6I2BVK63.js"),"../../localization/lit-localize/locales/nb.ts":()=>import("./chunks/nb.BYMLE7EQ.js"),"../../localization/lit-localize/locales/nl.ts":()=>import("./chunks/nl.QOSIJQZE.js"),"../../localization/lit-localize/locales/nl_NL.ts":()=>import("./chunks/nl_NL.DVZWMQJN.js"),"../../localization/lit-localize/locales/pl.ts":()=>import("./chunks/pl.VK5CNTV3.js"),"../../localization/lit-localize/locales/pt-BR.ts":()=>import("./chunks/pt-BR.22GYWGY5.js"),"../../localization/lit-localize/locales/pt.ts":()=>import("./chunks/pt.L2PBSEBD.js"),"../../localization/lit-localize/locales/ro.ts":()=>import("./chunks/ro.VFIM4IS3.js"),"../../localization/lit-localize/locales/ru.ts":()=>import("./chunks/ru.VLLE4DKK.js"),"../../localization/lit-localize/locales/sk.ts":()=>import("./chunks/sk.JALTDVLO.js"),"../../localization/lit-localize/locales/sl.ts":()=>import("./chunks/sl.PQOCETM2.js"),"../../localization/lit-localize/locales/sr-RS.ts":()=>import("./chunks/sr-RS.RGO57OCW.js"),"../../localization/lit-localize/locales/sv.ts":()=>import("./chunks/sv.FQJP73FF.js"),"../../localization/lit-localize/locales/th.ts":()=>import("./chunks/th.QYA26J2E.js"),"../../localization/lit-localize/locales/tr.ts":()=>import("./chunks/tr.5ZDAANBV.js"),"../../localization/lit-localize/locales/uk-UA.ts":()=>import("./chunks/uk-UA.FWQ7KVBB.js"),"../../localization/lit-localize/locales/vi.ts":()=>import("./chunks/vi.GB6QZAMD.js"),"../../localization/lit-localize/locales/zf.ts":()=>import("./chunks/zf.LNP32XVM.js"),"../../localization/lit-localize/locales/zh-CN.ts":()=>import("./chunks/zh-CN.OEA7I6ZA.js"),"../../localization/lit-localize/locales/zh-HK.ts":()=>import("./chunks/zh-HK.OUXNL5ZM.js"),"../../localization/lit-localize/locales/zh-TW.ts":()=>import("./chunks/zh-TW.C5STTOCA.js")});fn(r=>_m(`../../localization/lit-localize/locales/${r}.ts`));var wm={LOADER_DISABLED:"loader-disabled",CUSTOM_STYLES:"custom-styles",CLIENT_TOKEN:"client-token",JS_INIT:"js-initialized"},Ne=class extends v{constructor(){super();this.customStyles="";this.clientToken="";this.options={};this.disableLoader=!1;this._jsInitialized=!1;this.previousLoadingState=!0;this.hasAssignedContent=!1;this._loadingTimeoutId=null;this._eventListenerController=null;this._classObserver=null;this.locale=na(_r());this.onSlotChange=e=>{let i=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=i.length>0,this.requestUpdate()};this.sdkContextController=new Sr(this),this.sdkStateController=new br(this),this.primerEventsController=new aa(this),this.styleProcessingController=new Ar(this),this.vaultManagerController=new Ea(this),this.achPaymentEventsController=new Wr(this),this.headlessSdkController=new jr(this)}set jsInitialized(e){this.requestUpdate(),this._jsInitialized=e}get jsInitialized(){return this._jsInitialized}get primerJS(){return this.headlessSdkController?.primerJSInstance??void 0}connectedCallback(){super.connectedCallback(),this.sdkContextController.setEventsController(this.primerEventsController),this._eventListenerController=new AbortController,document.addEventListener("primer:card-submit",this.handleExternalCardSubmit.bind(this),{signal:this._eventListenerController.signal}),document.addEventListener("primer:vault-submit",this.handleExternalVaultSubmit.bind(this),{signal:this._eventListenerController.signal}),document.addEventListener("primer:show-other-payments-toggle",this.handleExternalShowOtherPaymentsToggle.bind(this),{signal:this._eventListenerController.signal}),this._classObserver=new MutationObserver(()=>{this.requestUpdate()}),this._classObserver.observe(this,{attributes:!0,attributeFilter:["class"]})}attributeChangedCallback(e,a,i){e===wm.CUSTOM_STYLES?this.styleProcessingController.processCustomStyles(i):super.attributeChangedCallback(e,a,i)}disconnectedCallback(){this._loadingTimeoutId&&(window.clearTimeout(this._loadingTimeoutId),this._loadingTimeoutId=null),this.sdkStateController?.currentState.isLoading&&this.sdkStateController.forceCompleteLoading(),this._eventListenerController&&(this._eventListenerController.abort(),this._eventListenerController=null),this._classObserver&&(this._classObserver.disconnect(),this._classObserver=null),super.disconnectedCallback()}willUpdate(e){e.has("options")&&(this.options?.locale&&(Sn(this.options?.locale)?this.locale=na(this.options?.locale):P.warn("\u{1F30E}\u2757 Unsupported locale provided:",this.options?.locale,"- Falling back to system locale")),vn(this.locale))}updated(){let e=getComputedStyle(this);this.sdkContextController.setComputedStyles(e),this.checkLoadingStateChange()}handleExternalCardSubmit(e){this._eventListenerController?.signal.aborted||e.target!==this&&this.primerEventsController.dispatchEvent("primer:card-submit",e.detail)}handleExternalVaultSubmit(e){this._eventListenerController?.signal.aborted||e.target!==this&&this.primerEventsController.dispatchEvent("primer:vault-submit",e.detail)}handleExternalShowOtherPaymentsToggle(e){this._eventListenerController?.signal.aborted||e.target!==this&&this.primerEventsController.dispatchEvent("primer:show-other-payments-toggle",e.detail)}checkLoadingStateChange(){let e=this.sdkStateController?.currentState.isLoading||!1;if(this.previousLoadingState&&!e){this.jsInitialized=!0,X({eventName:"CHECKOUT_FLOW_STARTED"});let a=$e.getSdkInitStartTime(),i=a?Date.now()-a:void 0;ds(i)}this.previousLoadingState=e,e&&!this._loadingTimeoutId?this._loadingTimeoutId=window.setTimeout(()=>{this.sdkStateController?.currentState.isLoading&&(P.warn("Loading timeout in component, forcing completion"),this.sdkStateController.forceCompleteLoading(),this.jsInitialized=!0),this._loadingTimeoutId=null},1e4):!e&&this._loadingTimeoutId&&(window.clearTimeout(this._loadingTimeoutId),this._loadingTimeoutId=null)}render(){let e=this.sdkStateController.currentState,a=e.isLoading,i=e.primerJsError,n=!a&&!i;return p` ${R(a,()=>y)} ${R(i,()=>p`<primer-checkout-error></primer-checkout-error>`)} ${R(n,()=>p`<slot name="main" @slotchange=${this.onSlotChange}></slot>${R(this.hasAssignedContent,()=>y,()=>p`<primer-main></primer-main>`)} `,()=>y)} `}addEventListener(e,a,i){super.addEventListener(e,a,i)}removeEventListener(e,a,i){super.removeEventListener(e,a,i)}};Ne.styles=[I,Js],d([u({type:String,attribute:"custom-styles"})],Ne.prototype,"customStyles",2),d([u({type:String,attribute:"client-token"})],Ne.prototype,"clientToken",2),d([u({type:Object,attribute:!1,hasChanged:(e,a)=>!vr(e,a)})],Ne.prototype,"options",2),d([u({type:Boolean,attribute:"loader-disabled"})],Ne.prototype,"disableLoader",2),d([u({type:Boolean,reflect:!0,attribute:"js-initialized"})],Ne.prototype,"_jsInitialized",2),d([_e("slot")],Ne.prototype,"defaultSlot",2),d([N()],Ne.prototype,"previousLoadingState",2),Ne=d([D(),b("primer-checkout")],Ne);function Dm(r){return document.querySelector(`#${r}`)}function Om(r,t){let e=document.createElement("style");return e.textContent=r,e.id=t,e}function Ka(r,t,e=!0){if(!Yr||Dm(t))return;let i=Om(r,t);e&&document.head.firstChild?document.head.insertBefore(i,document.head.firstChild):document.head.appendChild(i)}var nl=`
|
|
146
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Vs=/'/g,Us=/"/g,zs=/^(?:script|style|textarea|title)$/i,Nn=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),p=Nn(1),Ke=Nn(2),Qv=Nn(3),Se=Symbol.for("lit-noChange"),y=Symbol.for("lit-nothing"),Hs=new WeakMap,Ft=Vt.createTreeWalker(Vt,129);function $s(r,t){if(!Pn(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return Gs!==void 0?Gs.createHTML(t):t}var js=(r,t)=>{let e=r.length-1,a=[],i,n=t===2?"<svg>":t===3?"<math>":"",o=xa;for(let s=0;s<e;s++){let l=r[s],c,m,g=-1,h=0;for(;h<l.length&&(o.lastIndex=h,m=o.exec(l),m!==null);)h=o.lastIndex,o===xa?m[1]==="!--"?o=Ks:m[1]!==void 0?o=Fs:m[2]!==void 0?(zs.test(m[2])&&(i=RegExp("</"+m[2],"g")),o=Kt):m[3]!==void 0&&(o=Kt):o===Kt?m[0]===">"?(o=i??xa,g=-1):m[1]===void 0?g=-2:(g=o.lastIndex-m[2].length,c=m[1],o=m[3]===void 0?Kt:m[3]==='"'?Us:Vs):o===Us||o===Vs?o=Kt:o===Ks||o===Fs?o=xa:(o=Kt,i=void 0);let T=o===Kt&&r[s+1].startsWith("/>")?" ":"";n+=o===xa?l+Tm:g>=0?(a.push(c),l.slice(0,g)+En+l.slice(g)+nt+T):l+nt+(g===-2?s:T)}return[$s(r,n+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),a]},Oa=class r{constructor({strings:t,_$litType$:e},a){let i;this.parts=[];let n=0,o=0,s=t.length-1,l=this.parts,[c,m]=js(t,e);if(this.el=r.createElement(c,a),Ft.currentNode=this.el.content,e===2||e===3){let g=this.el.content.firstChild;g.replaceWith(...g.childNodes)}for(;(i=Ft.nextNode())!==null&&l.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let g of i.getAttributeNames())if(g.endsWith(En)){let h=m[o++],T=i.getAttribute(g).split(nt),M=/([.?@])?(.*)/.exec(h);l.push({type:1,index:n,name:M[2],strings:T,ctor:M[1]==="."?Kr:M[1]==="?"?Fr:M[1]==="@"?Vr:Ht}),i.removeAttribute(g)}else g.startsWith(nt)&&(l.push({type:6,index:n}),i.removeAttribute(g));if(zs.test(i.tagName)){let g=i.textContent.split(nt),h=g.length-1;if(h>0){i.textContent=Br?Br.emptyScript:"";for(let T=0;T<h;T++)i.append(g[T],wa()),Ft.nextNode(),l.push({type:2,index:++n});i.append(g[h],wa())}}}else if(i.nodeType===8)if(i.data===Tn)l.push({type:2,index:n});else{let g=-1;for(;(g=i.data.indexOf(nt,g+1))!==-1;)l.push({type:7,index:n}),g+=nt.length-1}n++}}static createElement(t,e){let a=Vt.createElement("template");return a.innerHTML=t,a}};function Ut(r,t,e=r,a){if(t===Se)return t;let i=a!==void 0?e._$Co?.[a]:e._$Cl,n=Da(t)?void 0:t._$litDirective$;return i?.constructor!==n&&(i?._$AO?.(!1),n===void 0?i=void 0:(i=new n(r),i._$AT(r,e,a)),a!==void 0?(e._$Co??(e._$Co=[]))[a]=i:e._$Cl=i),i!==void 0&&(t=Ut(r,i._$AS(r,t.values),i,a)),t}var Gr=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:e},parts:a}=this._$AD,i=(t?.creationScope??Vt).importNode(e,!0);Ft.currentNode=i;let n=Ft.nextNode(),o=0,s=0,l=a[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new oa(n,n.nextSibling,this,t):l.type===1?c=new l.ctor(n,l.name,l.strings,this,t):l.type===6&&(c=new Ur(n,this,t)),this._$AV.push(c),l=a[++s]}o!==l?.index&&(n=Ft.nextNode(),o++)}return Ft.currentNode=Vt,i}p(t){let e=0;for(let a of this._$AV)a!==void 0&&(a.strings!==void 0?(a._$AI(t,a,e),e+=a.strings.length-2):a._$AI(t[e])),e++}},oa=class r{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,a,i){this.type=2,this._$AH=y,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=a,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Ut(this,t,e),Da(t)?t===y||t==null||t===""?(this._$AH!==y&&this._$AR(),this._$AH=y):t!==this._$AH&&t!==Se&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Ys(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==y&&Da(this._$AH)?this._$AA.nextSibling.data=t:this.T(Vt.createTextNode(t)),this._$AH=t}$(t){let{values:e,_$litType$:a}=t,i=typeof a=="number"?this._$AC(t):(a.el===void 0&&(a.el=Oa.createElement($s(a.h,a.h[0]),this.options)),a);if(this._$AH?._$AD===i)this._$AH.p(e);else{let n=new Gr(i,this),o=n.u(this.options);n.p(e),this.T(o),this._$AH=n}}_$AC(t){let e=Hs.get(t.strings);return e===void 0&&Hs.set(t.strings,e=new Oa(t)),e}k(t){Pn(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,a,i=0;for(let n of t)i===e.length?e.push(a=new r(this.O(wa()),this.O(wa()),this,this.options)):a=e[i],a._$AI(n),i++;i<e.length&&(this._$AR(a&&a._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){let a=t.nextSibling;t.remove(),t=a}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},Ht=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,a,i,n){this.type=1,this._$AH=y,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,a.length>2||a[0]!==""||a[1]!==""?(this._$AH=Array(a.length-1).fill(new String),this.strings=a):this._$AH=y}_$AI(t,e=this,a,i){let n=this.strings,o=!1;if(n===void 0)t=Ut(this,t,e,0),o=!Da(t)||t!==this._$AH&&t!==Se,o&&(this._$AH=t);else{let s=t,l,c;for(t=n[0],l=0;l<n.length-1;l++)c=Ut(this,s[a+l],e,l),c===Se&&(c=this._$AH[l]),o||(o=!Da(c)||c!==this._$AH[l]),c===y?t=y:t!==y&&(t+=(c??"")+n[l+1]),this._$AH[l]=c}o&&!i&&this.j(t)}j(t){t===y?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Kr=class extends Ht{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===y?void 0:t}},Fr=class extends Ht{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==y)}},Vr=class extends Ht{constructor(t,e,a,i,n){super(t,e,a,i,n),this.type=5}_$AI(t,e=this){if((t=Ut(this,t,e,0)??y)===Se)return;let a=this._$AH,i=t===y&&a!==y||t.capture!==a.capture||t.once!==a.once||t.passive!==a.passive,n=t!==y&&(a===y||i);i&&this.element.removeEventListener(this.name,this,a),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},Ur=class{constructor(t,e,a){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=a}get _$AU(){return this._$AM._$AU}_$AI(t){Ut(this,t)}},Ws={M:En,P:nt,A:Tn,C:1,L:js,R:Gr,D:Ys,V:Ut,I:oa,H:Ht,N:Fr,U:Vr,B:Kr,F:Ur},Pm=_a.litHtmlPolyfillSupport;Pm?.(Oa,oa),(_a.litHtmlVersions??(_a.litHtmlVersions=[])).push("3.3.0");var Zs=(r,t,e)=>{let a=e?.renderBefore??t,i=a._$litPart$;if(i===void 0){let n=e?.renderBefore??null;a._$litPart$=i=new oa(t.insertBefore(wa(),n),n,void 0,e??{})}return i._$AI(r),i};var Ba=globalThis,v=class extends it{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;let t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Zs(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Se}};v._$litElement$=!0,v.finalized=!0,Ba.litElementHydrateSupport?.({LitElement:v});var Nm=Ba.litElementPolyfillSupport;Nm?.({LitElement:v});(Ba.litElementVersions??(Ba.litElementVersions=[])).push("4.2.0");var b=r=>(t,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(r,t)})):customElements.define(r,t)};var Im={attribute:!0,type:String,converter:Ra,reflect:!1,hasChanged:Or},km=(r=Im,t,e)=>{let{kind:a,metadata:i}=e,n=globalThis.litPropertyMetadata.get(i);if(n===void 0&&globalThis.litPropertyMetadata.set(i,n=new Map),a==="setter"&&((r=Object.create(r)).wrapped=!0),n.set(e.name,r),a==="accessor"){let{name:o}=e;return{set(s){let l=t.get.call(this);t.set.call(this,s),this.requestUpdate(o,l,r)},init(s){return s!==void 0&&this.C(o,void 0,r,s),s}}}if(a==="setter"){let{name:o}=e;return function(s){let l=this[o];t.call(this,s),this.requestUpdate(o,l,r)}}throw Error("Unsupported decorator location: "+a)};function u(r){return(t,e)=>typeof e=="object"?km(r,t,e):((a,i,n)=>{let o=i.hasOwnProperty(n);return i.constructor.createProperty(n,a),o?Object.getOwnPropertyDescriptor(i,n):void 0})(r,t,e)}function N(r){return u({...r,state:!0,attribute:!1})}var Yt=(r,t,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(r,t,e),e);function _e(r,t){return(e,a,i)=>{let n=o=>o.renderRoot?.querySelector(r)??null;if(t){let{get:o,set:s}=typeof a=="object"?e:i??(()=>{let l=Symbol();return{get(){return this[l]},set(c){this[l]=c}}})();return Yt(e,a,{get(){let l=o.call(this);return l===void 0&&(l=n(this),(l!==null||this.hasUpdated)&&s.call(this,l)),l}})}return Yt(e,a,{get(){return n(this)}})}}function R(r,t,e){return r?t(r):e?.(r)}var I=f` * { box-sizing: border-box; } `,Js=f` :host { display: block; isolation: isolate; position: relative; width: 100%; //Keep the CSS loader in the same position - check css-loader-inline.ts min-height: 64px; } `;var qs="https://sdk.primer.io/web/v2-latest/Primer.min.js",he="20px";var Hr=class{constructor(t){this.paymentMethods=null;this.paymentManagers=null;this.vaultController=null;this.headlessInstance=t,this.vault={createCvvInput:e=>this.createCvvInputInternal(e),startPayment:(e,a)=>this.startVaultPaymentInternal(e,a),delete:e=>this.deleteVaultPaymentMethod(e)}}setPaymentMethods(t){this.paymentMethods=t}setPaymentManagers(t){this.paymentManagers=t}setVaultController(t){this.vaultController=t}async createCvvInputInternal(t){return this.vaultController?this.vaultController.createCvvInput(t):(P.warn("PrimerJS: Vault not available - createCvvInput cannot be called"),null)}async startVaultPaymentInternal(t,e){if(!this.vaultController)throw new Error("Vault manager not initialized");return this.vaultController.startVaultPaymentById(t,e)}async deleteVaultPaymentMethod(t){if(!this.vaultController)throw new Error("Vault manager not initialized");return this.vaultController.deleteVaultedPaymentMethod(t)}async createCvvInput(t){return this.vault.createCvvInput(t)}async startVaultPayment(t,e){return this.vault.startPayment(t,e)}async refreshSession(){if(!this.headlessInstance){P.errorWithDatadog("PrimerJS: Cannot refresh session: Headless instance not available");return}try{await this.headlessInstance.refreshClientSession()}catch(t){throw P.errorWithDatadog("PrimerJS: Error refreshing client session",{error:t}),t}}getPaymentMethods(){return this.paymentMethods?this.paymentMethods:(P.warn("PrimerJS: Payment methods not available"),[])}handlePaymentStart(){this.onPaymentStart&&this.onPaymentStart()}handleVaultedMethodsUpdate(t,e){if(this.onVaultedMethodsUpdate){let a=Math.floor(Date.now()/1e3);this.onVaultedMethodsUpdate({vaultedPayments:t,cvvRecapture:e,timestamp:a})}}setCardholderName(t){if(!this.paymentManagers){P.warn("PrimerJS: Payment managers not available - setCardholderName cannot be called yet");return}let e=this.paymentManagers.get("PAYMENT_CARD");if(!e||e.type!=="PAYMENT_CARD"){P.warn("PrimerJS: Card payment manager not available");return}try{e.manager.setCardholderName(t)}catch(a){P.errorWithDatadog("PrimerJS: Error setting cardholder name",{error:a})}}};var Yr=typeof window<"u"&&typeof window.document<"u";function Lm(r){return document.querySelector(`script[src^="${r}"]`)}function Rm(r,t){let e=document.createElement("script");return e.setAttribute("src",r),e.setAttribute("async",""),e.setAttribute("crossorigin","anonymous"),t&&e.setAttribute("type","module"),e}function Qs(r,t=!1){if(!Yr)throw new Error("Cannot load script in server environment");let e=Lm(r)??Rm(r,t);return new Promise((a,i)=>{e.onload=()=>{a()},e.onerror=()=>{i(new Error(`Failed to load script: ${r}`))},e.parentNode||document.head.appendChild(e)})}var Xs=f` :host { display: contents; } .cta-button { display: block; margin: auto; } `;var ie=class extends v{constructor(){super(...arguments);this.size="large";this.showCloseButton=!1;this.darkMode=!1;this.open=!1}openDialog(){this.open=!0}closeDialog(){let e=()=>{this.open=!1,this.removeEventListener("primer:dialog-close",e)};this.addEventListener("primer:dialog-close",e),this.dialog.startExitAnimation()}connectedCallback(){super.connectedCallback(),this.darkMode&&this.classList.add("primer-dark-theme"),this.open||this.openDialog()}updated(e){super.updated(e),e.has("darkMode")&&(this.darkMode?this.classList.add("primer-dark-theme"):this.classList.remove("primer-dark-theme")),e.has("open")&&this.open&&this.onOpen&&this.onOpen(),e.has("open")&&this.open&&this.onContentRendered&&this.updateComplete.then(()=>{requestAnimationFrame(()=>{this.onContentRendered?.()})})}render(){return this.open?p`<primer-dialog class="${this.darkMode?"primer-dark-theme":""}" .open=${this.open} size=${this.size} .showCloseButton=${this.showCloseButton} @primer:dialog-close="${()=>{this.open=!1}}" ><slot></slot>${this.cta?p`<primer-button @click=${this.cta.onClick} class="cta-button">${this.cta.icon?p`<primer-icon name="${this.cta.icon}" size="sm" color="var(--primer-color-background-outlined-default)" ></primer-icon>`:y} ${this.cta.label}</primer-button>`:y}</primer-dialog>`:y}};ie.styles=[I,Xs],d([u({type:String})],ie.prototype,"size",2),d([u({type:Boolean})],ie.prototype,"showCloseButton",2),d([u({type:Boolean})],ie.prototype,"darkMode",2),d([u({type:Object})],ie.prototype,"onOpen",2),d([u({type:Object})],ie.prototype,"onContentRendered",2),d([u({type:Object})],ie.prototype,"cta",2),d([N()],ie.prototype,"open",2),d([_e("primer-dialog")],ie.prototype,"dialog",2),ie=d([b("primer-portal-dialog"),D()],ie);var zr=class{constructor(){this.currentDialog=null;this.currentResolver=null}async show(t){return new Promise(e=>{let a=new ie;a.size=t.size??"large",a.showCloseButton=t.showCloseButton??!1;let i=document.querySelector("primer-checkout");a.darkMode=i?.classList.contains("primer-dark-theme")??!1,a.onContentRendered=t.onContentReady,a.cta=t.cta;let n=()=>{a.remove(),this.currentDialog=null,this.currentResolver=null,e({success:!1})};a.addEventListener("primer:dialog-close",n),this.currentDialog=a,this.currentResolver=e,document.body.appendChild(a),a.appendChild(t.htmlContent)})}close(){this.currentDialog&&this.currentResolver&&(this.currentDialog.closeDialog(),this.currentResolver({success:!0}),this.currentDialog.remove(),this.currentDialog=null,this.currentResolver=null)}};var xm=Za({"../../../localization/lit-localize/locales/ar.ts":()=>import("./chunks/ar.4ZFBST5B.js"),"../../../localization/lit-localize/locales/bg.ts":()=>import("./chunks/bg.A6DFGUKU.js"),"../../../localization/lit-localize/locales/ca.ts":()=>import("./chunks/ca.3MVWILFG.js"),"../../../localization/lit-localize/locales/cs.ts":()=>import("./chunks/cs.INYY7XZR.js"),"../../../localization/lit-localize/locales/da.ts":()=>import("./chunks/da.Y5IIDRC3.js"),"../../../localization/lit-localize/locales/de.ts":()=>import("./chunks/de.JZT46DAB.js"),"../../../localization/lit-localize/locales/el.ts":()=>import("./chunks/el.FJQOSK4N.js"),"../../../localization/lit-localize/locales/en-GB.ts":()=>import("./chunks/en-GB.TL522NMU.js"),"../../../localization/lit-localize/locales/en.ts":()=>import("./chunks/en.JFPWSECQ.js"),"../../../localization/lit-localize/locales/es-AR.ts":()=>import("./chunks/es-AR.GBZW2HPG.js"),"../../../localization/lit-localize/locales/es-MX.ts":()=>import("./chunks/es-MX.NFJ7HXSV.js"),"../../../localization/lit-localize/locales/es.ts":()=>import("./chunks/es.FX4YBDVU.js"),"../../../localization/lit-localize/locales/et-EE.ts":()=>import("./chunks/et-EE.JZD334EI.js"),"../../../localization/lit-localize/locales/fi-FI.ts":()=>import("./chunks/fi-FI.SHTM3UQK.js"),"../../../localization/lit-localize/locales/fr.ts":()=>import("./chunks/fr.MZYBSJWU.js"),"../../../localization/lit-localize/locales/he.ts":()=>import("./chunks/he.BQXGQQ4P.js"),"../../../localization/lit-localize/locales/hr.ts":()=>import("./chunks/hr.EK5WNO4N.js"),"../../../localization/lit-localize/locales/hu.ts":()=>import("./chunks/hu.N2BVXVWY.js"),"../../../localization/lit-localize/locales/id.ts":()=>import("./chunks/id.IJ37WK5P.js"),"../../../localization/lit-localize/locales/it.ts":()=>import("./chunks/it.2ZUPJDRP.js"),"../../../localization/lit-localize/locales/ja.ts":()=>import("./chunks/ja.BNLF6BZT.js"),"../../../localization/lit-localize/locales/ko.ts":()=>import("./chunks/ko.YJAZTBEF.js"),"../../../localization/lit-localize/locales/lt-LT.ts":()=>import("./chunks/lt-LT.GOVUI3KD.js"),"../../../localization/lit-localize/locales/lt.ts":()=>import("./chunks/lt.IPLRYI7A.js"),"../../../localization/lit-localize/locales/lv-LV.ts":()=>import("./chunks/lv-LV.EA76F4DL.js"),"../../../localization/lit-localize/locales/lv.ts":()=>import("./chunks/lv.I7E6LMWA.js"),"../../../localization/lit-localize/locales/ms.ts":()=>import("./chunks/ms.6I2BVK63.js"),"../../../localization/lit-localize/locales/nb.ts":()=>import("./chunks/nb.BYMLE7EQ.js"),"../../../localization/lit-localize/locales/nl.ts":()=>import("./chunks/nl.QOSIJQZE.js"),"../../../localization/lit-localize/locales/nl_NL.ts":()=>import("./chunks/nl_NL.DVZWMQJN.js"),"../../../localization/lit-localize/locales/pl.ts":()=>import("./chunks/pl.VK5CNTV3.js"),"../../../localization/lit-localize/locales/pt-BR.ts":()=>import("./chunks/pt-BR.22GYWGY5.js"),"../../../localization/lit-localize/locales/pt.ts":()=>import("./chunks/pt.L2PBSEBD.js"),"../../../localization/lit-localize/locales/ro.ts":()=>import("./chunks/ro.VFIM4IS3.js"),"../../../localization/lit-localize/locales/ru.ts":()=>import("./chunks/ru.VLLE4DKK.js"),"../../../localization/lit-localize/locales/sk.ts":()=>import("./chunks/sk.JALTDVLO.js"),"../../../localization/lit-localize/locales/sl.ts":()=>import("./chunks/sl.PQOCETM2.js"),"../../../localization/lit-localize/locales/sr-RS.ts":()=>import("./chunks/sr-RS.RGO57OCW.js"),"../../../localization/lit-localize/locales/sv.ts":()=>import("./chunks/sv.FQJP73FF.js"),"../../../localization/lit-localize/locales/th.ts":()=>import("./chunks/th.QYA26J2E.js"),"../../../localization/lit-localize/locales/tr.ts":()=>import("./chunks/tr.5ZDAANBV.js"),"../../../localization/lit-localize/locales/uk-UA.ts":()=>import("./chunks/uk-UA.FWQ7KVBB.js"),"../../../localization/lit-localize/locales/vi.ts":()=>import("./chunks/vi.GB6QZAMD.js"),"../../../localization/lit-localize/locales/zf.ts":()=>import("./chunks/zf.LNP32XVM.js"),"../../../localization/lit-localize/locales/zh-CN.ts":()=>import("./chunks/zh-CN.OEA7I6ZA.js"),"../../../localization/lit-localize/locales/zh-HK.ts":()=>import("./chunks/zh-HK.OUXNL5ZM.js"),"../../../localization/lit-localize/locales/zh-TW.ts":()=>import("./chunks/zh-TW.C5STTOCA.js")});var sa=null,In=null;async function el(r){if(In===r&&sa)return sa;try{return sa=(await xm(`../../../localization/lit-localize/locales/${r}.ts`)).templates,In=r,sa}catch{return r!=="en-GB"?el("en-GB"):(sa={},In=r,sa)}}async function tl(r){let t=await el(r);return(e,a)=>t[e]??a}var Ct={WORLDPAY_IDEAL:"WORLDPAY_IDEAL",AUTOMATED_CLEARING_HOUSE:"AUTOMATED_CLEARING_HOUSE",ADYEN_KLARNA:"ADYEN_KLARNA",ADYEN_BANCONTACT_CARD:"ADYEN_BANCONTACT_CARD",PAY_NL_KAARTDIRECT:"PAY_NL_KAARTDIRECT",ADYEN_EPS:"ADYEN_EPS",ADYEN_BANCONTACT_PAYCONIQ:"ADYEN_BANCONTACT_PAYCONIQ",OMISE_PROMPTPAY:"OMISE_PROMPTPAY",OMISE_TRUEMONEY:"OMISE_TRUEMONEY",ADYEN_MULTIBANCO:"ADYEN_MULTIBANCO",PACYPAY_WECHAT:"PACYPAY_WECHAT",PACYPAY_ALIPAY:"PACYPAY_ALIPAY",ADYEN_MBWAY:"ADYEN_MBWAY",XENDIT_DANA:"XENDIT_DANA",XENDIT_SHOPEEPAY:"XENDIT_SHOPEEPAY",ADYEN_PAYSHOP:"ADYEN_PAYSHOP",ADYEN_PAYTRAIL:"ADYEN_PAYTRAIL",CLEARPAY:"CLEARPAY",RAPYD_FAST:"RAPYD_FAST",RAPYD_PROMPTPAY:"RAPYD_PROMPTPAY",RAPYD_GCASH:"RAPYD_GCASH",RAPYD_POLI:"RAPYD_POLI",RAPYD_GRABPAY:"RAPYD_GRABPAY",PRIMER_PAYPAL:"PRIMER_PAYPAL",TWOC2P:"TWOC2P",NETS:"NETS",STRIPE_ACH:"STRIPE_ACH",STRIPE_GIROPAY:"STRIPE_GIROPAY",MOLLIE_GIROPAY:"MOLLIE_GIROPAY",MOLLIE_EPS:"MOLLIE_EPS",PAY_NL_EPS:"PAY_NL_EPS",PAY_NL_P24:"PAY_NL_P24",MOLLIE_P24:"MOLLIE_P24",MOLLIE_SOFORT:"MOLLIE_SOFORT",COINBASE:"COINBASE",OPENNODE:"OPENNODE",MOLLIE_GIFT_CARD:"MOLLIE_GIFTCARD",XFERS_PAYNOW:"XFERS_PAYNOW",CARD:"PAYMENT_CARD",APPLE_PAY:"APPLE_PAY",GOOGLE_PAY:"GOOGLE_PAY",PAYPAL:"PAYPAL_ORDER",PAYPAL_VAULTED:"PAYPAL_BILLING_AGREEMENT",GO_CARDLESS:"GOCARDLESS",PAY_NL_IDEAL:"PAY_NL_IDEAL",PAY_NL_SOFORT_BANKING:"PAY_NL_SOFORT_BANKING",PAY_NL_BANCONTACT:"PAY_NL_BANCONTACT",PAY_NL_PAYPAL:"PAY_NL_PAYPAL",PAY_NL_CREDIT_TRANSFER:"PAY_NL_CREDIT_TRANSFER",PAY_NL_DIRECT_DEBIT:"PAY_NL_DIRECT_DEBIT",PAY_NL_GIROPAY:"PAY_NL_GIROPAY",PAY_NL_PAYCONIQ:"PAY_NL_PAYCONIQ",PAY_NL_RIVERTY:"PAY_NL_RIVERTY",HOOLAH:"HOOLAH",ADYEN_BLIK:"ADYEN_BLIK",ADYEN_VIPPS:"ADYEN_VIPPS",ADYEN_GIROPAY:"ADYEN_GIROPAY",ADYEN_SOFORT:"ADYEN_SOFORT",ADYEN_IDEAL:"ADYEN_IDEAL",ADYEN_TRUSTLY:"ADYEN_TRUSTLY",ADYEN_ALIPAY:"ADYEN_ALIPAY",ADYEN_TWINT:"ADYEN_TWINT",ADYEN_MOBILEPAY:"ADYEN_MOBILEPAY",MOLLIE_BANCONTACT:"MOLLIE_BANCONTACT",MOLLIE_IDEAL:"MOLLIE_IDEAL",BUCKAROO_GIROPAY:"BUCKAROO_GIROPAY",BUCKAROO_EPS:"BUCKAROO_EPS",BUCKAROO_SOFORT:"BUCKAROO_SOFORT",BUCKAROO_BANCONTACT:"BUCKAROO_BANCONTACT",BUCKAROO_IDEAL:"BUCKAROO_IDEAL",ATOME:"ATOME",KLARNA_CUSTOMER_TOKEN:"KLARNA_CUSTOMER_TOKEN",DLOCAL_PIX:"DLOCAL_PIX",ALMA:"ALMA",ADYEN_CASHAPP:"ADYEN_CASHAPP",ADYEN_AFFIRM:"ADYEN_AFFIRM"},Ga={WORLDPAY_IDEAL:"WORLDPAY_IDEAL",STRIPE_ACH:"STRIPE_ACH",STRIPE_IDEAL:"STRIPE_IDEAL",ADYEN_KLARNA:"ADYEN_KLARNA",ADYEN_BANCONTACT_CARD:"ADYEN_BANCONTACT_CARD",PAY_NL_KAARTDIRECT:"PAY_NL_KAARTDIRECT",ADYEN_EPS:"ADYEN_EPS",ADYEN_BANCONTACT_PAYCONIQ:"ADYEN_BANCONTACT_PAYCONIQ",OMISE_PROMPTPAY:"OMISE_PROMPTPAY",OMISE_TRUEMONEY:"OMISE_TRUEMONEY",ADYEN_MULTIBANCO:"ADYEN_MULTIBANCO",PACYPAY_WECHAT:"PACYPAY_WECHAT",PACYPAY_ALIPAY:"PACYPAY_ALIPAY",ADYEN_MBWAY:"ADYEN_MBWAY",XENDIT_DANA:"XENDIT_DANA",XENDIT_SHOPEEPAY:"XENDIT_SHOPEEPAY",ADYEN_PAYSHOP:"ADYEN_PAYSHOP",ADYEN_PAYTRAIL:"ADYEN_PAYTRAIL",CLEARPAY:"CLEARPAY",RAPYD_FAST:"RAPYD_FAST",RAPYD_PROMPTPAY:"RAPYD_PROMPTPAY",RAPYD_GCASH:"RAPYD_GCASH",RAPYD_POLI:"RAPYD_POLI",RAPYD_GRABPAY:"RAPYD_GRABPAY",PRIMER_PAYPAL:"PRIMER_PAYPAL",TWOC2P:"TWOC2P",NETS:"NETS",STRIPE_GIROPAY:"STRIPE_GIROPAY",MOLLIE_GIROPAY:"MOLLIE_GIROPAY",MOLLIE_EPS:"MOLLIE_EPS",PAY_NL_EPS:"PAY_NL_EPS",PAY_NL_P24:"PAY_NL_P24",MOLLIE_P24:"MOLLIE_P24",MOLLIE_SOFORT:"MOLLIE_SOFORT",COINBASE:"COINBASE",OPENNODE:"OPENNODE",MOLLIE_GIFT_CARD:"MOLLIE_GIFTCARD",XFERS_PAYNOW:"XFERS_PAYNOW",PAYMENT_CARD:"PAYMENT_CARD",APPLE_PAY:"APPLE_PAY",GOOGLE_PAY:"GOOGLE_PAY",PAYPAL:"PAYPAL",GO_CARDLESS:"GOCARDLESS",KLARNA:"KLARNA",PAY_NL_IDEAL:"PAY_NL_IDEAL",PAY_NL_SOFORT_BANKING:"PAY_NL_SOFORT_BANKING",PAY_NL_BANCONTACT:"PAY_NL_BANCONTACT",PAY_NL_PAYPAL:"PAY_NL_PAYPAL",PAY_NL_CREDIT_TRANSFER:"PAY_NL_CREDIT_TRANSFER",PAY_NL_DIRECT_DEBIT:"PAY_NL_DIRECT_DEBIT",PAY_NL_GIROPAY:"PAY_NL_GIROPAY",PAY_NL_PAYCONIQ:"PAY_NL_PAYCONIQ",PAY_NL_RIVERTY:"PAY_NL_RIVERTY",HOOLAH:"HOOLAH",ADYEN_BLIK:"ADYEN_BLIK",ADYEN_MOBILEPAY:"ADYEN_MOBILEPAY",ADYEN_VIPPS:"ADYEN_VIPPS",ADYEN_GIROPAY:"ADYEN_GIROPAY",ADYEN_SOFORT:"ADYEN_SOFORT",ADYEN_IDEAL:"ADYEN_IDEAL",ADYEN_TRUSTLY:"ADYEN_TRUSTLY",ADYEN_ALIPAY:"ADYEN_ALIPAY",ADYEN_TWINT:"ADYEN_TWINT",ADYEN_BANK_TRANSFER:"ADYEN_BANK_TRANSFER",MOLLIE_BANCONTACT:"MOLLIE_BANCONTACT",MOLLIE_IDEAL:"MOLLIE_IDEAL",BUCKAROO_GIROPAY:"BUCKAROO_GIROPAY",BUCKAROO_EPS:"BUCKAROO_EPS",BUCKAROO_SOFORT:"BUCKAROO_SOFORT",BUCKAROO_BANCONTACT:"BUCKAROO_BANCONTACT",BUCKAROO_IDEAL:"BUCKAROO_IDEAL",ATOME:"ATOME",DLOCAL_PIX:"DLOCAL_PIX",ALMA:"ALMA",ADYEN_CASHAPP:"ADYEN_CASHAPP",ADYEN_AFFIRM:"ADYEN_AFFIRM"};var $r=class r extends Error{constructor(t,e){super(e.message),this.name="PrimerClientError",this.code=t,this.diagnosticsId=e.diagnosticsId||null,this.data=e.data,this.isFromDeveloper=e.isFromDeveloper||!1}static fromErrorCode(t,e){return new r(t,e)}};function al(r,t,e){return r.isDisconnected?!1:(r.host.sdkStateController.currentState.paymentFailure!==null&&X({eventName:"PAYMENT_REATTEMPTED",paymentMethod:t}),r.host.sdkStateController.startProcessing(),r.host.primerEventsController.dispatchPaymentStart(t,e))}function rl(r,t,e){if(!r.isDisconnected&&(P.info("Payment completed:",t),r.host.sdkStateController.completeProcessing(),r.host.primerEventsController.dispatchPaymentSuccess(t,e),X({eventName:"PAYMENT_SUCCESS",paymentId:t?.id,paymentMethod:e}),r.primerJS?.onPaymentSuccess)){let a=Math.floor(Date.now()/1e3);r.primerJS.onPaymentSuccess({payment:ta(t),paymentMethodType:e,timestamp:a})}}function il(r,t,e,a){if(r.isDisconnected)return;(s=>typeof s=="object"&&s!==null&&"response"in s&&typeof s.response=="object"&&s.response!==null&&"status"in s.response&&typeof s.response.status=="number")(t)&&t.response.status>=500?P.errorWithDatadog("Payment failed with server error",{error:t}):P.error("Payment failed:",t);let o=t instanceof $r?{code:t.code||"UNKNOWN_ERROR",message:t.message||"Unknown error occurred",diagnosticsId:t.diagnosticsId,data:t.data}:(()=>{let s=t,l=s instanceof Error&&"code"in s&&typeof s.code=="string"?s.code:"UNKNOWN_ERROR",c=s instanceof Error?s.message:"Unknown error occurred";return{code:l,message:c,data:{error:t}}})();if(r.host.sdkStateController.setPaymentFailure(o),r.host.primerEventsController.dispatchPaymentFailure({code:o.code,message:o.message,diagnosticsId:"diagnosticsId"in o?o.diagnosticsId??void 0:void 0,data:o.data},e,a),X({eventName:"PAYMENT_FAILURE",paymentId:a?.id,paymentMethod:e}),r.primerJS?.onPaymentFailure){let s=Math.floor(Date.now()/1e3);r.primerJS.onPaymentFailure({error:{code:o.code,message:o.message,diagnosticsId:"diagnosticsId"in o?o.diagnosticsId??void 0:void 0,data:o.data},payment:a?ta(a):void 0,paymentMethodType:e,timestamp:s})}}var kn="1.0.6",jr=class{constructor(t){this.createPaymentMethodManager=null;this._paymentsList=[];this.currentSdkInstance=null;this.primerJS=null;this.loadingTimeout=null;this.isDisconnected=!1;(this.host=t).addController(this),this.isDisconnected=!1,this.sdkInstanceTask=new O(t,{args:()=>[this.host.clientToken,this.host.options],task:this.initializeHeadless()}),new O(t,{args:()=>[this.sdkInstanceTask.value,this.paymentsList],task:this.initializeLitContext()})}set paymentsList(t){this._paymentsList=t,this.host.requestUpdate()}get paymentsList(){return this._paymentsList}get primerJSInstance(){return this.primerJS}hostConnected(){this.isDisconnected=!1,this.host.sdkStateController.startLoading(),this.setupLoadingTimeout()}hostDisconnected(){if(this.isDisconnected=!0,this.host.sdkContextController.getAnalyticsUtils()){let e=this.host.sdkStateController.currentState;(e.isProcessing||e.isLoading||this.currentSdkInstance)&&X({eventName:"PAYMENT_FLOW_EXITED"})}this.cleanupResources()}normalizeOptionsForLegacySdk(t){if(t.sdkCore!==!1)return{...t,sdkCore:!0};let e={...t};if(e.card?.cardholderName){let a={...e.card.cardholderName};a.visible===!1&&(a.required=!1),e.card={...e.card,cardholderName:a}}return e}setupLoadingTimeout(){this.clearLoadingTimeout(),this.loadingTimeout=setTimeout(()=>{this.host.sdkStateController.currentState.isLoading&&(P.warn("Loading timeout reached, resetting SDK state"),X({eventName:"PAYMENT_FLOW_EXITED",eventType:"timeout"}),this.cleanupResources(),this.host.sdkStateController.completeLoading())},1e4)}clearLoadingTimeout(){this.loadingTimeout!==null&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null)}cleanupResources(){if(this.clearLoadingTimeout(),this.currentSdkInstance)try{this.paymentsList=[],this.createPaymentMethodManager=null,this.host.sdkStateController.reset(),this.currentSdkInstance.teardown?.(),P.info("SDK instance cleaned up")}catch(t){P.errorWithDatadog("Error cleaning up SDK instance",{error:t})}As(),P.setClientToken(void 0),P.setSdkOptions(void 0),this.currentSdkInstance=null,this.primerJS=null}async _loadV2Sdk(t=qs){let e=window;if(e.Primer&&typeof e.Primer.preloadPrimer=="function"){P.info("SDK already loaded, skipping load script"),await e.Primer.preloadPrimer();return}await Qs(t),await e.Primer.preloadPrimer()}initializeHeadless(){return async([t,e])=>{if(this.isDisconnected)return P.warn("Component disconnected, aborting SDK initialization"),w;if(!t||!e)return w;this.cleanupResources();let a;try{let i;if(e.sdkCore!==!1){let l=new zr,c=na(e.locale||_r()),m=await tl(c);i={createHeadless:(h,T)=>rs(h,{...T,dialogProvider:l,translate:m,sdkVersion:kn,locale:c})}}else await this._loadV2Sdk(),i=window.Primer;this.primerJS=new Hr(null),this.primerJS.setVaultController(this.host.vaultManagerController);let n=this.normalizeOptionsForLegacySdk(e);P.setClientToken(t),P.setSdkOptions(n);let o=await i.createHeadless(t,{...n,onAvailablePaymentMethodsLoad:l=>{this.isDisconnected||(P.info("Configuration payment methods:",l),this.paymentsList=l)},onCheckoutComplete:({payment:l})=>{let c=l?.paymentMethodData?.paymentMethodType;rl({isDisconnected:this.isDisconnected,host:this.host,primerJS:this.primerJS},l,c)},onCheckoutFail:(l,c)=>{let m=c.payment?.paymentMethodData?.paymentMethodType;il({isDisconnected:this.isDisconnected,host:this.host,primerJS:this.primerJS},l,m,c.payment)},onBeforePaymentCreate:(l,c)=>{if(!l.paymentMethodType){P.error("Payment creation started without payment method type"),c?.abortPaymentCreation();return}if(!(al({isDisconnected:this.isDisconnected,host:this.host,primerJS:this.primerJS},l.paymentMethodType,c)||this.isDisconnected)){if(this.primerJS?.onPaymentPrepare){this.primerJS.onPaymentPrepare({paymentMethodType:l.paymentMethodType},c);return}c?.continuePaymentCreation()}},onPaymentMethodAction:(l,c)=>{this.isDisconnected||l==="PAYMENT_METHOD_UNSELECTED"&&(this.host.primerEventsController.dispatchPaymentCancel(c),this.host.sdkStateController.stopProcessing())},onPaymentCreationStart:()=>{this.isDisconnected||this.primerJS&&this.primerJS.handlePaymentStart()}});if(this.createPaymentMethodManager=o.createPaymentMethodManager.bind(o),this.currentSdkInstance=o,this.primerJS&&Object.defineProperty(this.primerJS,"headlessInstance",{value:o,writable:!1}),await o.start(),this.isDisconnected)return this.cleanupResources(),w;this.host.sdkContextController.setClientOptions(e),this.primerJS&&this.host.primerEventsController.dispatchCheckoutInitialized(this.primerJS);let s=o.getSDKUtilities();if(a=o.getAnalyticsUtils?.(),a&&(this.host.sdkContextController.setAnalyticsUtils({...a,sdkVersion:kn}),Ss({environment:a.environment,checkoutSessionId:a.checkoutSessionId,clientSessionId:a.clientSessionId||"",primerAccountId:a.primerAccountId||"",sdkVersion:kn,clientSessionToken:a.clientSessionToken,userAgent:typeof navigator<"u"?navigator.userAgent:""}),a.configurationFetchStartTime&&$e.setSdkInitStartTime(a.configurationFetchStartTime),X({eventName:"SDK_INIT_START"})),this.host.sdkContextController.setHeadlessUtils(s),e.sdkCore&&o.getConfiguration){let l=o.getConfiguration();this.host.sdkContextController.setConfiguration(l)}return this.host.vaultManagerController.initializeVaultManager(o.createVaultManager.bind(o),{vaultEnabled:e.vault?.enabled,captureVaultedCardCvv:!!s.getPaymentMethodConfiguration("PAYMENT_CARD")?.options?.captureVaultedCardCvv,showEmptyState:e.vault?.showEmptyState,headless:e.vault?.headless??!1}),o}catch(i){throw i instanceof Error&&(P.errorWithDatadog("SDK initialization error",{error:i,status:"error"}),this.host.sdkStateController.setPrimerJsError(i)),this.cleanupResources(),i}}}initializeLitContext(){return async([t,e])=>{if(this.isDisconnected)return w;if(!t||!e.length)return w;let a=new Map,i=new Map;try{for(let o of e){if(this.isDisconnected)break;let s=await this.initializePaymentMethodManager(o)();o&&s&&(a.set(o.type,o),i.set(o.type,s))}if(this.isDisconnected)return w;let n=Array.from(a.values());return this.host.sdkContextController.setPaymentManagers(i),this.host.sdkContextController.setPaymentMethods(n),this.primerJS&&(this.primerJS.setPaymentMethods(n),this.primerJS.setPaymentManagers(i)),this.host.primerEventsController.dispatchPaymentMethods(n),P.info("Initialized payment methods:",n),a}catch(n){if(n instanceof Error)throw this.host.sdkStateController.setPrimerJsError(n),n;return null}finally{this.clearLoadingTimeout(),this.isDisconnected||(this.host.sdkStateController.completeLoading(),X({eventName:"SDK_INIT_END"}))}}}initializePaymentMethodManager(t){let{type:e,managerType:a}=t;return async()=>{if(this.isDisconnected||!this.createPaymentMethodManager)return null;if(a==="KLARNA"){let i=await this.createPaymentMethodManager("KLARNA",{onPaymentMethodCategoriesChange:n=>{this.isDisconnected||this.host.sdkContextController.setKlarnaCategories({categories:n,isLoading:!1})}});return i?{type:e,manager:i}:null}try{if(a==="CARD"){let n=await this.createPaymentMethodManager("PAYMENT_CARD",{onBinDataAvailable:o=>{this.isDisconnected||this.host.primerEventsController.dispatchBinDataAvailable(o)},onCardNetworksChange:o=>{if(this.isDisconnected)return;let{detectedCardNetworks:s,selectableCardNetworks:l}=o;this.updateCardNetworksState({detectedCardNetwork:s.preferred??s.items[0],selectableCardNetworks:l?.items??[],isLoading:!1})},onBinDataLoadingChange:o=>{this.isDisconnected||(o?this.updateCardNetworksState({detectedCardNetwork:null,selectableCardNetworks:[],isLoading:!0}):this.host.sdkContextController.setCardNetworksLoadingFalse(),this.host.primerEventsController.dispatchBinDataLoadingChange(o))}});return n?{type:e,manager:n}:null}let i=await this.createPaymentMethodManager(e);return i?{type:e,manager:i}:null}catch(i){return P.errorWithDatadog(`Failed to initialize manager for ${e}`,{error:i}),null}}}updateCardNetworksState(t){this.host.primerEventsController.dispatchCardNetworkChange(t),this.host.sdkContextController.setCardNetworks(t)}};var Wr=class{constructor(t){this.host=t,t.addController(this)}_error(t){let{error:e}=t.detail;this.host.sdkStateController.setPaymentFailure({code:"UNKNOWN_ERROR",message:e.message})}_mandateConfirmed(){this.host.sdkStateController.completeProcessing()}_mandateDeclined(){this.host.sdkStateController.setPaymentFailure({code:"UNKNOWN_ERROR",message:"Mandate declined"})}hostConnected(){this.host.addEventListener("primer-ach-error",this._error.bind(this)),this.host.addEventListener("primer-ach-mandate-confirmed",this._mandateConfirmed.bind(this)),this.host.addEventListener("primer-ach-mandate-declined",this._mandateDeclined.bind(this))}hostDisconnected(){this.host.removeEventListener("primer-ach-error",this._error.bind(this)),this.host.removeEventListener("primer-ach-mandate-confirmed",this._mandateConfirmed.bind(this)),this.host.removeEventListener("primer-ach-mandate-declined",this._mandateDeclined.bind(this))}};var _m=Za({"../../localization/lit-localize/locales/ar.ts":()=>import("./chunks/ar.4ZFBST5B.js"),"../../localization/lit-localize/locales/bg.ts":()=>import("./chunks/bg.A6DFGUKU.js"),"../../localization/lit-localize/locales/ca.ts":()=>import("./chunks/ca.3MVWILFG.js"),"../../localization/lit-localize/locales/cs.ts":()=>import("./chunks/cs.INYY7XZR.js"),"../../localization/lit-localize/locales/da.ts":()=>import("./chunks/da.Y5IIDRC3.js"),"../../localization/lit-localize/locales/de.ts":()=>import("./chunks/de.JZT46DAB.js"),"../../localization/lit-localize/locales/el.ts":()=>import("./chunks/el.FJQOSK4N.js"),"../../localization/lit-localize/locales/en-GB.ts":()=>import("./chunks/en-GB.TL522NMU.js"),"../../localization/lit-localize/locales/en.ts":()=>import("./chunks/en.JFPWSECQ.js"),"../../localization/lit-localize/locales/es-AR.ts":()=>import("./chunks/es-AR.GBZW2HPG.js"),"../../localization/lit-localize/locales/es-MX.ts":()=>import("./chunks/es-MX.NFJ7HXSV.js"),"../../localization/lit-localize/locales/es.ts":()=>import("./chunks/es.FX4YBDVU.js"),"../../localization/lit-localize/locales/et-EE.ts":()=>import("./chunks/et-EE.JZD334EI.js"),"../../localization/lit-localize/locales/fi-FI.ts":()=>import("./chunks/fi-FI.SHTM3UQK.js"),"../../localization/lit-localize/locales/fr.ts":()=>import("./chunks/fr.MZYBSJWU.js"),"../../localization/lit-localize/locales/he.ts":()=>import("./chunks/he.BQXGQQ4P.js"),"../../localization/lit-localize/locales/hr.ts":()=>import("./chunks/hr.EK5WNO4N.js"),"../../localization/lit-localize/locales/hu.ts":()=>import("./chunks/hu.N2BVXVWY.js"),"../../localization/lit-localize/locales/id.ts":()=>import("./chunks/id.IJ37WK5P.js"),"../../localization/lit-localize/locales/it.ts":()=>import("./chunks/it.2ZUPJDRP.js"),"../../localization/lit-localize/locales/ja.ts":()=>import("./chunks/ja.BNLF6BZT.js"),"../../localization/lit-localize/locales/ko.ts":()=>import("./chunks/ko.YJAZTBEF.js"),"../../localization/lit-localize/locales/lt-LT.ts":()=>import("./chunks/lt-LT.GOVUI3KD.js"),"../../localization/lit-localize/locales/lt.ts":()=>import("./chunks/lt.IPLRYI7A.js"),"../../localization/lit-localize/locales/lv-LV.ts":()=>import("./chunks/lv-LV.EA76F4DL.js"),"../../localization/lit-localize/locales/lv.ts":()=>import("./chunks/lv.I7E6LMWA.js"),"../../localization/lit-localize/locales/ms.ts":()=>import("./chunks/ms.6I2BVK63.js"),"../../localization/lit-localize/locales/nb.ts":()=>import("./chunks/nb.BYMLE7EQ.js"),"../../localization/lit-localize/locales/nl.ts":()=>import("./chunks/nl.QOSIJQZE.js"),"../../localization/lit-localize/locales/nl_NL.ts":()=>import("./chunks/nl_NL.DVZWMQJN.js"),"../../localization/lit-localize/locales/pl.ts":()=>import("./chunks/pl.VK5CNTV3.js"),"../../localization/lit-localize/locales/pt-BR.ts":()=>import("./chunks/pt-BR.22GYWGY5.js"),"../../localization/lit-localize/locales/pt.ts":()=>import("./chunks/pt.L2PBSEBD.js"),"../../localization/lit-localize/locales/ro.ts":()=>import("./chunks/ro.VFIM4IS3.js"),"../../localization/lit-localize/locales/ru.ts":()=>import("./chunks/ru.VLLE4DKK.js"),"../../localization/lit-localize/locales/sk.ts":()=>import("./chunks/sk.JALTDVLO.js"),"../../localization/lit-localize/locales/sl.ts":()=>import("./chunks/sl.PQOCETM2.js"),"../../localization/lit-localize/locales/sr-RS.ts":()=>import("./chunks/sr-RS.RGO57OCW.js"),"../../localization/lit-localize/locales/sv.ts":()=>import("./chunks/sv.FQJP73FF.js"),"../../localization/lit-localize/locales/th.ts":()=>import("./chunks/th.QYA26J2E.js"),"../../localization/lit-localize/locales/tr.ts":()=>import("./chunks/tr.5ZDAANBV.js"),"../../localization/lit-localize/locales/uk-UA.ts":()=>import("./chunks/uk-UA.FWQ7KVBB.js"),"../../localization/lit-localize/locales/vi.ts":()=>import("./chunks/vi.GB6QZAMD.js"),"../../localization/lit-localize/locales/zf.ts":()=>import("./chunks/zf.LNP32XVM.js"),"../../localization/lit-localize/locales/zh-CN.ts":()=>import("./chunks/zh-CN.OEA7I6ZA.js"),"../../localization/lit-localize/locales/zh-HK.ts":()=>import("./chunks/zh-HK.OUXNL5ZM.js"),"../../localization/lit-localize/locales/zh-TW.ts":()=>import("./chunks/zh-TW.C5STTOCA.js")});fn(r=>_m(`../../localization/lit-localize/locales/${r}.ts`));var wm={LOADER_DISABLED:"loader-disabled",CUSTOM_STYLES:"custom-styles",CLIENT_TOKEN:"client-token",JS_INIT:"js-initialized"},Ne=class extends v{constructor(){super();this.customStyles="";this.clientToken="";this.options={};this.disableLoader=!1;this._jsInitialized=!1;this.previousLoadingState=!0;this.hasAssignedContent=!1;this._loadingTimeoutId=null;this._eventListenerController=null;this._classObserver=null;this.locale=na(_r());this.onSlotChange=e=>{let i=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=i.length>0,this.requestUpdate()};this.sdkContextController=new Sr(this),this.sdkStateController=new br(this),this.primerEventsController=new aa(this),this.styleProcessingController=new Ar(this),this.vaultManagerController=new Ea(this),this.achPaymentEventsController=new Wr(this),this.headlessSdkController=new jr(this)}set jsInitialized(e){this.requestUpdate(),this._jsInitialized=e}get jsInitialized(){return this._jsInitialized}get primerJS(){return this.headlessSdkController?.primerJSInstance??void 0}connectedCallback(){super.connectedCallback(),this.sdkContextController.setEventsController(this.primerEventsController),this._eventListenerController=new AbortController,document.addEventListener("primer:card-submit",this.handleExternalCardSubmit.bind(this),{signal:this._eventListenerController.signal}),document.addEventListener("primer:vault-submit",this.handleExternalVaultSubmit.bind(this),{signal:this._eventListenerController.signal}),document.addEventListener("primer:show-other-payments-toggle",this.handleExternalShowOtherPaymentsToggle.bind(this),{signal:this._eventListenerController.signal}),this._classObserver=new MutationObserver(()=>{this.requestUpdate()}),this._classObserver.observe(this,{attributes:!0,attributeFilter:["class"]})}attributeChangedCallback(e,a,i){e===wm.CUSTOM_STYLES?this.styleProcessingController.processCustomStyles(i):super.attributeChangedCallback(e,a,i)}disconnectedCallback(){this._loadingTimeoutId&&(window.clearTimeout(this._loadingTimeoutId),this._loadingTimeoutId=null),this.sdkStateController?.currentState.isLoading&&this.sdkStateController.forceCompleteLoading(),this._eventListenerController&&(this._eventListenerController.abort(),this._eventListenerController=null),this._classObserver&&(this._classObserver.disconnect(),this._classObserver=null),super.disconnectedCallback()}willUpdate(e){e.has("options")&&(this.options?.locale&&(Sn(this.options?.locale)?this.locale=na(this.options?.locale):P.warn("\u{1F30E}\u2757 Unsupported locale provided:",this.options?.locale,"- Falling back to system locale")),vn(this.locale))}updated(){let e=getComputedStyle(this);this.sdkContextController.setComputedStyles(e),this.checkLoadingStateChange()}handleExternalCardSubmit(e){this._eventListenerController?.signal.aborted||e.target!==this&&this.primerEventsController.dispatchEvent("primer:card-submit",e.detail)}handleExternalVaultSubmit(e){this._eventListenerController?.signal.aborted||e.target!==this&&this.primerEventsController.dispatchEvent("primer:vault-submit",e.detail)}handleExternalShowOtherPaymentsToggle(e){this._eventListenerController?.signal.aborted||e.target!==this&&this.primerEventsController.dispatchEvent("primer:show-other-payments-toggle",e.detail)}checkLoadingStateChange(){let e=this.sdkStateController?.currentState.isLoading||!1;if(this.previousLoadingState&&!e){this.jsInitialized=!0,X({eventName:"CHECKOUT_FLOW_STARTED"});let a=$e.getSdkInitStartTime(),i=a?Date.now()-a:void 0;ds(i)}this.previousLoadingState=e,e&&!this._loadingTimeoutId?this._loadingTimeoutId=window.setTimeout(()=>{this.sdkStateController?.currentState.isLoading&&(P.warn("Loading timeout in component, forcing completion"),this.sdkStateController.forceCompleteLoading(),this.jsInitialized=!0),this._loadingTimeoutId=null},1e4):!e&&this._loadingTimeoutId&&(window.clearTimeout(this._loadingTimeoutId),this._loadingTimeoutId=null)}render(){let e=this.sdkStateController.currentState,a=e.isLoading,i=e.primerJsError,n=!a&&!i;return p` ${R(a,()=>y)} ${R(i,()=>p`<primer-checkout-error></primer-checkout-error>`)} ${R(n,()=>p`<slot name="main" @slotchange=${this.onSlotChange}></slot>${R(this.hasAssignedContent,()=>y,()=>p`<primer-main></primer-main>`)} `,()=>y)} `}addEventListener(e,a,i){super.addEventListener(e,a,i)}removeEventListener(e,a,i){super.removeEventListener(e,a,i)}};Ne.styles=[I,Js],d([u({type:String,attribute:"custom-styles"})],Ne.prototype,"customStyles",2),d([u({type:String,attribute:"client-token"})],Ne.prototype,"clientToken",2),d([u({type:Object,attribute:!1,hasChanged:(e,a)=>!vr(e,a)})],Ne.prototype,"options",2),d([u({type:Boolean,attribute:"loader-disabled"})],Ne.prototype,"disableLoader",2),d([u({type:Boolean,reflect:!0,attribute:"js-initialized"})],Ne.prototype,"_jsInitialized",2),d([_e("slot")],Ne.prototype,"defaultSlot",2),d([N()],Ne.prototype,"previousLoadingState",2),Ne=d([D(),b("primer-checkout")],Ne);function Dm(r){return document.querySelector(`#${r}`)}function Om(r,t){let e=document.createElement("style");return e.textContent=r,e.id=t,e}function Ka(r,t,e=!0){if(!Yr||Dm(t))return;let i=Om(r,t);e&&document.head.firstChild?document.head.insertBefore(i,document.head.firstChild):document.head.appendChild(i)}var nl=`
|
|
147
147
|
@keyframes primer-css-spinner-rotate {
|
|
148
148
|
0% {
|
|
149
149
|
transform: rotate(0deg);
|
|
@@ -202,4 +202,4 @@ primer-checkout:not([js-initialized]):not([loader-disabled])::after {
|
|
|
202
202
|
input[data-custom-input]:focus {
|
|
203
203
|
outline: none;
|
|
204
204
|
}
|
|
205
|
-
`,t.shadowRoot?t.shadowRoot.appendChild(e):t.appendChild(e)}}function $d(r,t){return r.active!==t.active||r.dirty!==t.dirty||r.error!==t.error||r.errorCode!==t.errorCode||r.submitted!==t.submitted||r.touched!==t.touched||r.valid!==t.valid}var si=class{constructor(t,e){this._meta={active:!1,dirty:!1,error:null,errorCode:null,submitted:!1,touched:!1,valid:!1};this._hostedInput=null;this._standardInput=null;this.host=t,this.config=e,this.host.addController(this),this.setupTask=new O(this.host,{args:()=>[this.getHostedInput()],task:this.setupHostedInput.bind(this)}),this.host.addEventListener("wrapper-click",()=>{this.focusInput()})}focusInput(){this._hostedInput?this._hostedInput.focus():this._standardInput&&this._standardInput.focus()}notifyUserInteraction(){let t=this.host.cardFormContext;t?.onUserInteraction&&t.onUserInteraction()}getHostedInput(){let{type:t}=this.config,e=this.host.cardFormContext;return e?{cardNumber:e.cardNumberInput,cvv:e.cvvInput,expire:e.expiryInput,cardholderName:e.cardholderNameInput??"cardholderName"}[t]:void 0}async setupHostedInput([t]){if(!t)return w;await this.host.updateComplete;let e=this.getTargetContainer();return e?t==="cardholderName"?this.setupStandardInput(e):this.setupHostedIframeInput(t,e):w}getTargetContainer(){return this.host.renderRoot.querySelector(this.config.containerSelector)}setupStandardInput(t){let e=document.createElement("input");return e.type="text",e.placeholder=this.host.placeholder,Hn(e,this.host),(this.host.ariaLabel||this.host.label)&&e.setAttribute("aria-label",this.host.ariaLabel??this.host.label),this.setupInputEventListeners(e),t.innerHTML="",t.appendChild(e),this._standardInput=e,!0}setupInputEventListeners(t){t.addEventListener("input",e=>{let a=e.target,n=!!a.value.trim();this.notifyUserInteraction(),this._meta={...this._meta,dirty:n},this.config.onInput?.(a.value),this.host.requestUpdate()}),t.addEventListener("focus",()=>{this.notifyUserInteraction(),this._meta.active=!0,this.host.requestUpdate()}),t.addEventListener("blur",()=>{this._meta.active=!1,this._meta.touched=!1,this.host.requestUpdate()}),t.addEventListener("keydown",e=>{if(e.key==="Enter"){e.preventDefault();let a=this.host.closest("form");a&&a.requestSubmit()}})}async setupHostedIframeInput(t,e){await new Promise(n=>requestAnimationFrame(()=>n())),this._hostedInput=t;let a=Ua(this.host.computedStyles),i=a?{style:{input:{base:a}}}:void 0;return t.addEventListener("focus",()=>{this.notifyUserInteraction(),this._meta.active=!0,this.host.requestUpdate()}),t.addEventListener("blur",()=>{this._meta.active=!1,this.host.requestUpdate()}),t.addEventListener("change",n=>{let o=n;this.notifyUserInteraction(),$d(this._meta,o)&&(this._meta={...this._meta,...o},this.host.requestUpdate())}),t.addEventListener("enter",()=>{let n=this.host.closest("form");n&&n.requestSubmit()}),await t.render(e,{placeholder:this.host.placeholder,ariaLabel:this.host.ariaLabel,...i}),!0}get meta(){return this._meta}updateMetaFromValidation(t){this._meta={...this._meta,valid:!!t.valid,error:t.error||null,errorCode:t.errorCode||null},this.host.requestUpdate()}setSubmitted(t){this._meta={...this._meta,submitted:t,...t&&{touched:!0}},this.host.requestUpdate()}hostConnected(){this.registerWithContext()}hostDisconnected(){this.unregisterFromContext(),this._hostedInput=null,this._standardInput=null}hostUpdate(){if(this._hostedInput&&this.host.computedStyles){let t=Ua(this.host.computedStyles);t&&this._hostedInput.setOptions({style:{input:{base:t}}})}else this._standardInput&&this.host.computedStyles&&Hn(this._standardInput,this.host)}registerWithContext(){let t=this.host.cardFormContext;t?.registerInputController&&t.registerInputController(this.config.type,this)}unregisterFromContext(){let t=this.host.cardFormContext;t?.unregisterInputController&&t.unregisterInputController(this.config.type)}};var jd=f` :host { display: contents; } form { display: flex; flex-direction: column; gap: var(--primer-space-medium); width: 100%; } .card-form { display: flex; flex-direction: column; gap: var(--primer-space-medium); margin-bottom: var(--primer-space-medium); } .card-form-row { display: flex; gap: var(--primer-space-small); } `;var Wd={cardholderName:"cardholderName",cardNumber:"cardNumber",cardExpiryDate:"expire",expiryDate:"expire",cardSecurityCode:"cvv",cvv:"cvv"},oe=class extends v{constructor(){super(...arguments);this.hideLabels=!1;this.disabled=!1;this.hasAssignedContent=!1;this.selectedCardNetwork=null;this.formErrorMessage=null;this.paymentMethodSelectionSent=!1;this.paymentManagers=new Map;this.clientOptions=null;this.headlessUtils=null;this.analyticsUtils=null;this.contextEventsController=null;this.cardFormProvider=new W(this,{context:ua,initialValue:null});this.eventsController=new aa(this);this._contextCardSubmitListener=null;this._isHandlingContextEvent=!1;this.inputControllers=new Map;this.setupCardFormTask=new O(this,{task:([e])=>{if(!e?.manager)return w;let{manager:a}=e,i=a.createHostedInputs(),{cardNumberInput:n,expiryInput:o,cvvInput:s}=i;return this.cardFormProvider.setValue({cardholderNameInput:i.cardholderNameInput,cardNumberInput:n,expiryInput:o,cvvInput:s,setCardholderName:l=>{a.setCardholderName(l),this.shouldRequireCardholderName&&a.validate?.().then(c=>{let g=c?.validationErrors?.find(T=>T.name===Wd.cardholderName),h=this.inputControllers.get("cardholderName");h&&h.updateMetaFromValidation({valid:!1,error:g?.message||g?.error||null,errorCode:g?.message||g?.error||null})})},setCardNetwork:l=>{this.selectedCardNetwork=l},validate:()=>a.validate(),submit:l=>a.submit(l),hideLabels:this.hideLabels,disabled:this.disabled,setSubmissionState:l=>{this.inputControllers.forEach(c=>{c.setSubmitted(l)})},propagateValidationErrors:l=>{l&&l.forEach(c=>{let m=c.field||c.name,g=c.message||c.error,h=Wd[m];if(h){let T=this.inputControllers.get(h);if(T){let M={valid:!1,error:g,errorCode:g};T.updateMetaFromValidation(M)}}})},registerInputController:(l,c)=>{this.inputControllers.set(l,c)},unregisterInputController:l=>{this.inputControllers.delete(l)},onUserInteraction:()=>{this.sendPaymentMethodSelectionEvent(),this.checkAndSendPaymentDetailsEnteredEvent()}}),!0},args:()=>[this.paymentManagers.get("PAYMENT_CARD")]});this.paymentDetailsEnteredSent=!1;this.handleSlotButtonClick=e=>{let i=e.target.closest("button, primer-button");if(!i)return;let n=i;this.isSubmitButton(n)&&(e.preventDefault(),this.submitCardPayment())};this.handleDirectSubmit=e=>{e.stopPropagation(),this.submitCardPayment()};this.handleContextCardSubmit=e=>{if(!this._isHandlingContextEvent){this._isHandlingContextEvent=!0;try{e.target!==this&&(e.stopPropagation(),this.submitCardPayment())}finally{this._isHandlingContextEvent=!1}}};this.onSlotChange=e=>{let i=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=i.length>0};this.handleFormSubmit=e=>{e.preventDefault(),e.stopPropagation(),this.submitCardPayment()}}updated(e){if(super.updated(e),(e.has("hideLabels")||e.has("disabled"))&&this.cardFormProvider.value&&this.cardFormProvider.setValue({...this.cardFormProvider.value,hideLabels:this.hideLabels,disabled:this.disabled}),e.has("contextEventsController")){let a=e.get("contextEventsController");a?.host&&this._contextCardSubmitListener&&a.host.removeEventListener("primer:card-submit",this._contextCardSubmitListener),this.setupContextEventListeners()}}get shouldShowCardholderName(){let e=this.clientOptions?.card?.cardholderName;return typeof e?.visible=="boolean"?e.visible:!0}get shouldRequireCardholderName(){if(!this.shouldShowCardholderName)return!1;let e=this.clientOptions?.card?.cardholderName;return typeof e?.required=="boolean"?e.required:!0}sendPaymentMethodSelectionEvent(){this.paymentMethodSelectionSent||(this.paymentMethodSelectionSent=!0,X({eventName:"PAYMENT_METHOD_SELECTION",paymentMethod:"PAYMENT_CARD"}))}checkAndSendPaymentDetailsEnteredEvent(){if(this.paymentDetailsEnteredSent)return;let e=this.inputControllers.get("cardNumber"),a=this.inputControllers.get("expire"),i=this.inputControllers.get("cvv"),n=e?.meta?.dirty===!0,o=a?.meta?.dirty===!0,s=i?.meta?.dirty===!0,l=!0;this.shouldRequireCardholderName&&(l=this.inputControllers.get("cardholderName")?.meta?.dirty===!0),n&&o&&s&&l&&(this.sendPaymentDetailsEnteredEvent(),this.paymentDetailsEnteredSent=!0)}sendPaymentDetailsEnteredEvent(){X({eventName:"PAYMENT_DETAILS_ENTERED",paymentMethod:"PAYMENT_CARD"})}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.handleSlotButtonClick),this.addEventListener("primer:card-submit",this.handleDirectSubmit),this._contextCardSubmitListener=e=>{this.handleContextCardSubmit(e)},this.setupContextEventListeners()}disconnectedCallback(){this.removeEventListener("click",this.handleSlotButtonClick),this.removeEventListener("primer:card-submit",this.handleDirectSubmit),this.cleanupContextEventListeners(),super.disconnectedCallback()}setupContextEventListeners(){this.contextEventsController?.host&&this._contextCardSubmitListener&&this.contextEventsController.host.addEventListener("primer:card-submit",this._contextCardSubmitListener)}cleanupContextEventListeners(){this.contextEventsController?.host&&this._contextCardSubmitListener&&this.contextEventsController.host.removeEventListener("primer:card-submit",this._contextCardSubmitListener)}isSubmitButton(e){let a=e.tagName.toLowerCase(),i=a==="button",n=a==="primer-button";return i&&(e.getAttribute("type")==="submit"||e.hasAttribute("data-submit"))||n&&(e.getAttribute("type")==="submit"||e.hasAttribute("data-submit"))}async submitCardPayment(){let e=this.cardFormProvider.value;if(!e||this.disabled)return;this.formErrorMessage=null,e.setSubmissionState?.(!0);let a=this.querySelector("primer-billing-address")||this.renderRoot.querySelector("primer-billing-address"),i=!0;a&&(i=await a.validateForSubmission());let n=await e.validate?.();if(n?.valid&&i){if(a&&!await a.submitToSDK()){let c=S("tokenizationError",{id:"tokenizationError"});this.formErrorMessage=c,this.eventsController.dispatchFormSubmitErrors([{field:"billingAddress",name:"billingAddress",error:"BILLING_ADDRESS_SUBMISSION_FAILED",message:c}]);return}let o={success:!0};this.eventsController.dispatchFormSubmitSuccess(o);let s=this.selectedCardNetwork?{cardNetwork:this.selectedCardNetwork}:void 0;await e.submit?.(s)}else{let o=n?.validationErrors;e.propagateValidationErrors?.(o||[]),this.cardFormProvider.setValue({...e,errors:o}),this.eventsController.dispatchFormSubmitErrors(o)}}render(){return this.setupCardFormTask.status===St.ERROR||this.setupCardFormTask.status===St.INITIAL?y:p`<form @submit=${this.handleFormSubmit}><slot name="card-form-content" @slotchange=${this.onSlotChange}></slot>${this.setupCardFormTask.render({complete:()=>R(this.hasAssignedContent,()=>y,()=>p`<div class="card-form"><primer-input-card-number></primer-input-card-number><div class="card-form-row"><primer-input-card-expiry></primer-input-card-expiry><primer-input-cvv></primer-input-cvv></div>${R(this.shouldShowCardholderName,()=>p`<primer-input-card-holder-name></primer-input-card-holder-name>`,()=>y)}<primer-billing-address></primer-billing-address></div><primer-card-form-submit></primer-card-form-submit><primer-error-message message="${this.formErrorMessage||""}" ?visible="${!!this.formErrorMessage}" ></primer-error-message>`)})}</form>`}};oe.styles=[I,jd],d([u({type:Boolean,attribute:"hide-labels",reflect:!0})],oe.prototype,"hideLabels",2),d([u({type:Boolean,attribute:"disabled"})],oe.prototype,"disabled",2),d([N()],oe.prototype,"hasAssignedContent",2),d([N()],oe.prototype,"selectedCardNetwork",2),d([N()],oe.prototype,"formErrorMessage",2),d([A({context:Z,subscribe:!0}),u({type:Object})],oe.prototype,"paymentManagers",2),d([A({context:se}),u({attribute:!1})],oe.prototype,"clientOptions",2),d([A({context:z,subscribe:!0}),u({attribute:!1})],oe.prototype,"headlessUtils",2),d([A({context:ft,subscribe:!0}),u({attribute:!1})],oe.prototype,"analyticsUtils",2),d([A({context:Ye,subscribe:!0}),u({attribute:!1})],oe.prototype,"contextEventsController",2),oe=d([b("primer-card-form"),D()],oe);var ye=class extends v{constructor(){super();this._cardFormContext=null;this.computedStyles=null;this._userAssignedProps=new Set;this._internalLabel="";this._internalPlaceholder="";this._internalAriaLabel="";this.handleWrapperClick=()=>{this.hostedInputController.focusInput()};this.hostedInputController={}}get cardFormContext(){return this._cardFormContext}set cardFormContext(e){let a=this._cardFormContext;this._cardFormContext=e,!a&&e&&this.updateComplete.then(()=>{this.hostedInputController?.registerWithContext?.()}),this.requestUpdate("cardFormContext",a)}getTranslatedValue(e){return e?typeof e=="string"?e:S(e.id,{id:e.id}):""}get label(){return this._userAssignedProps.has("label")?this._internalLabel:this.getTranslatedValue(this.config.translations.label)}set label(e){let a=this.label;e!==""?(this._userAssignedProps.add("label"),this._internalLabel=e):(this._userAssignedProps.delete("label"),this._internalLabel=""),this.requestUpdate("label",a)}get placeholder(){return this._userAssignedProps.has("placeholder")?this._internalPlaceholder:this.getTranslatedValue(this.config.translations.placeholder)}set placeholder(e){let a=this.placeholder;this._userAssignedProps.add("placeholder"),this._internalPlaceholder=e,this.requestUpdate("placeholder",a)}get ariaLabel(){return this._userAssignedProps.has("ariaLabel")?this._internalAriaLabel:this.getTranslatedValue(this.config.translations.ariaLabel)||this.getTranslatedValue(this.config.translations.label)}set ariaLabel(e){let a=this.ariaLabel;e!==""?(this._userAssignedProps.add("ariaLabel"),this._internalAriaLabel=e):(this._userAssignedProps.delete("ariaLabel"),this._internalAriaLabel=""),this.requestUpdate("ariaLabel",a)}childUpdated(){Object.defineProperty(this,"hostedInputController",{value:new si(this,{type:this.config.inputType,containerSelector:this.config.containerSelector,onInput:this.config.onInput}),writable:!1,configurable:!1})}getError(){let e=this.hostedInputController.meta;return e.submitted||e.dirty&&e.touched?e.errorCode:null}renderInput(){if(this.hostedInputController.setupTask.status===St.ERROR)return y;let e=this.getError();return p`<primer-input-wrapper .focusWithin="${this.hostedInputController.meta.active}" .hasError=${!!e} @wrapper-click="${this.handleWrapperClick}" >${R(!this.cardFormContext?.hideLabels,()=>p`<primer-input-label slot="label" >${this.label}</primer-input-label >`,()=>y)}<div slot="input" class="card-input-slot" id="${this.config.containerSelector.substring(1)}" aria-label="${this.ariaLabel}" ></div>${R(e,()=>p`<primer-input-error slot="error">${S(e,{id:e})}</primer-input-error>`,()=>y)}</primer-input-wrapper>`}};d([A({context:ua,subscribe:!0})],ye.prototype,"cardFormContext",1),d([A({context:ia,subscribe:!0}),u()],ye.prototype,"computedStyles",2),d([u({type:String})],ye.prototype,"label",1),d([u({type:String})],ye.prototype,"placeholder",1),d([u({type:String,attribute:"aria-label"})],ye.prototype,"ariaLabel",1);var Zd=f` :host { display: contents; } .card-number-container { display: flex; align-items: center; width: 100%; position: relative; gap: var(--primer-space-small); } #cardNumber { flex: 1; display: flex; width: 100%; } .network-selector-container { display: flex; align-items: center; z-index: 2; } `;var It=f` .card-input-slot { display: flex; } `;var ct=class extends ye{constructor(){super();this.config={inputType:"cardNumber",containerSelector:"#cardNumber",errorName:"cardNumber-card",translations:{label:{id:"cardNumber",defaultMessage:"Card Number"},placeholder:"4111 1111 1111 1111",ariaLabel:{id:"cardNumber",defaultMessage:"Card Number"}}};this.handleNetworkSelected=e=>{let{network:a}=e.detail;this.cardFormContext&&this.cardFormContext.setCardNetwork(a)};this.childUpdated()}renderInput(){if(this.hostedInputController.setupTask.status===St.ERROR)return y;let e=this.getError();return p`<primer-input-wrapper .focusWithin="${this.hostedInputController.meta.active}" .hasError=${!!e} >${R(!this.cardFormContext?.hideLabels,()=>p`<primer-input-label slot="label" >${this.label}</primer-input-label >`,()=>y)}<div slot="input" class="card-number-container" aria-label="${this.ariaLabel}" ><div id="${this.config.containerSelector.substring(1)}"></div><div class="network-selector-container"><primer-card-network-selector @network-selected=${this.handleNetworkSelected} ></primer-card-network-selector></div></div>${R(e,a=>p`<primer-input-error slot="error">${S(a,{id:a})}</primer-input-error>`,()=>y)}</primer-input-wrapper>`}render(){return this.renderInput()}};ct.styles=[I,It,Zd],ct=d([b("primer-input-card-number"),D()],ct);var Jd=f` :host { display: contents; } `;var ut=class extends ye{constructor(){super();this.config={inputType:"cvv",containerSelector:"#cvv",errorName:"cvv-card",translations:{label:"CVV",placeholder:"123"}};this.childUpdated()}render(){return this.renderInput()}};ut.styles=[I,It,Jd],ut=d([b("primer-input-cvv"),D()],ut);var qd=f` :host { display: contents; } `;var pt=class extends ye{constructor(){super();this.config={inputType:"expire",containerSelector:"#expiry",errorName:"expiryDate-card",translations:{label:{id:"cardExpiry",defaultMessage:"Expiry Date"},placeholder:{id:"cardExpiryPlaceholder",defaultMessage:"MM/YY"},ariaLabel:{id:"cardExpiry",defaultMessage:"Expiry Date"}}};this.childUpdated()}render(){return this.renderInput()}};pt.styles=[I,It,qd],pt=d([b("primer-input-card-expiry"),D()],pt);var Qd=f` :host { display: contents; } `;var mt=class extends ye{constructor(){super();this.config={inputType:"cardholderName",containerSelector:"#cardFormName",errorName:"cardholderName",translations:{label:{id:"cardholderNameLabel",defaultMessage:"Cardholder Name"},placeholder:{id:"cardholderNamePlaceholder",defaultMessage:"Name on card"},ariaLabel:{id:"cardholderNameLabel",defaultMessage:"Cardholder Name"}},onInput:e=>this.handleInput(e)};this.childUpdated()}handleInput(e){this.cardFormContext?.setCardholderName?.(e)}render(){return this.renderInput()}};mt.styles=[I,It,Qd],mt=d([b("primer-input-card-holder-name"),D()],mt);var Xd=f` :host { display: contents; } `;var ae=class extends v{constructor(){super(...arguments);this._userAssignedProps=new Set;this._internalButtonText="";this.headlessUtils=null;this.clientOptions=null;this.sdkState=null;this.cardFormContext=null;this.analyticsUtils=null;this.contextEventsController=null;this.variant="primary";this.disabled=!1;this.handleClick=e=>{if(e.preventDefault(),this.disabled)return;X({eventName:"PAYMENT_SUBMITTED",paymentMethod:"PAYMENT_CARD"});let a=new CustomEvent("primer:card-submit",{bubbles:!0,composed:!0,detail:{source:"primer-card-form-submit"}});this.dispatchEvent(a)}}get buttonText(){return this._userAssignedProps.has("buttonText")?this._internalButtonText:S("pay",{id:"pay"})}set buttonText(e){let a=this.buttonText;e!==""?(this._userAssignedProps.add("buttonText"),this._internalButtonText=e):(this._userAssignedProps.delete("buttonText"),this._internalButtonText=""),this.requestUpdate("buttonText",a)}get submitButtonConfig(){return this.clientOptions?.submitButton??null}get shouldShowBuiltInButton(){return this.submitButtonConfig?.useBuiltInButton??!0}render(){if(!this.shouldShowBuiltInButton)return y;let e=this.submitButtonConfig?.amountVisible?this.headlessUtils?.getUIOrderAmount():null,a=e?` ${e}`:y,i=this.disabled||this.cardFormContext?.disabled||!1;return p`<primer-button type="submit" variant=${this.variant} ?disabled=${i} @click=${this.handleClick} .loading=${!!this.sdkState?.isProcessing} data-submit >${this.buttonText}${a}</primer-button>`}};ae.styles=[I,Xd],d([u({type:String})],ae.prototype,"buttonText",1),d([A({context:z,subscribe:!0}),u({type:Object})],ae.prototype,"headlessUtils",2),d([A({context:se,subscribe:!0}),u({type:Object})],ae.prototype,"clientOptions",2),d([A({context:J,subscribe:!0}),u()],ae.prototype,"sdkState",2),d([A({context:ua,subscribe:!0}),u()],ae.prototype,"cardFormContext",2),d([A({context:ft,subscribe:!0}),u({attribute:!1})],ae.prototype,"analyticsUtils",2),d([A({context:Ye,subscribe:!0}),u({attribute:!1})],ae.prototype,"contextEventsController",2),d([u({type:String})],ae.prototype,"variant",2),d([u({type:Boolean})],ae.prototype,"disabled",2),ae=d([b("primer-card-form-submit"),D()],ae);var ec=f` :host { display: flex; align-items: center; position: relative; height: var(--primer-typography-body-large-line-height); } .network-selector { display: flex; align-items: center; cursor: pointer; background: none; padding: unset; border: none; transition: opacity var(--primer-animation-duration) var(--primer-animation-easing); outline: none; gap: var(--primer-space-xsmall); } .network-selector:hover { opacity: 0.8; } .network-selector:focus-visible { outline: 2px solid var(--primer-color-focus); border-radius: var(--primer-radius-xsmall); } .network-selector-inline { display: flex; border: 1px solid var(--primer-color-border-outlined-default); border-radius: var(--primer-radius-small); padding: 1px; .network-icon-container { padding: var(--primer-space-xsmall); } .network-icon-container + .network-icon-container { border-left: 1px solid var(--primer-color-border-outlined-default); } } .network-icon { display: block; width: calc(var(--primer-size-medium) * 1.4); height: var(--primer-size-medium); object-fit: contain; margin: 0; svg { width: auto; height: 100%; } } .caret { margin-left: var(--primer-space-xsmall); transition: transform var(--primer-animation-duration) var(--primer-animation-easing); color: var(--primer-color-icon-primary); } .caret.open { transform: rotate(180deg); } .dropdown { position: absolute; top: 100%; right: 0; width: max-content; min-width: calc(var(--primer-size-xxxlarge) * 3); background: var(--primer-color-gray-000); border-radius: var(--primer-radius-small); box-shadow: 0 var(--primer-space-xxsmall) var(--primer-space-large) rgba(0, 0, 0, 0.15); z-index: 10; overflow: hidden; border: 1px solid var(--primer-color-border-outlined-default); } .dropdown:not(.open) { display: none; } .dropdown.open { display: block; max-height: calc(var(--primer-size-xxxlarge) * 4); overflow-y: auto; } .network-option { display: flex; align-items: center; padding: var(--primer-space-small) var(--primer-space-medium); cursor: pointer; transition: background-color var(--primer-animation-duration) var(--primer-animation-easing); position: relative; outline: none; background-color: transparent; } /* Only apply hover effect when not in keyboard navigation mode */ .network-option:hover { background-color: var(--primer-color-gray-100); } /* Apply focused style only when the focused class is present (keyboard navigation) */ .network-option.focused { background-color: var(--primer-color-gray-100); } .network-option:focus-visible { outline: 2px solid var(--primer-color-focus); outline-offset: -2px; } .network-option-icon { width: var(--primer-size-medium); height: var(--primer-size-small); margin-right: var(--primer-space-small); object-fit: contain; } .network-name { font-size: var(--primer-typography-body-medium-size); font-family: var(--primer-typography-body-medium-font); line-height: var(--primer-typography-body-medium-line-height); letter-spacing: var(--primer-typography-body-medium-letter-spacing); white-space: nowrap; color: var(--primer-color-text-primary); flex: 1; } .checkmark { margin-left: var(--primer-space-small); color: var(--primer-color-brand); width: var(--primer-size-small); height: var(--primer-size-small); } `;var Fg=Ti(Cc()),Vg=Ti(za());var Gg=Ti(za());var Ec=[["AMEX","american-express"],["CARTES_BANCAIRES"],["DANKORT"],["DINERS_CLUB","diners-club"],["DISCOVER","discover"],["ENROUTE"],["ELO","elo"],["EFTPOS"],["HIPER","hiper","hiper-pay"],["HIPERCARD","hipercard"],["INTERAC"],["JCB","jcb"],["MAESTRO","maestro"],["MASTERCARD","mastercard"],["MIR","mir","mir-pay"],["OTHER",void 0,"payment-card"],["UNIONPAY","unionpay"],["VISA","visa"]],UO=new Map(Ec.map(r=>[r[0],r])),HO=new Map(Ec.filter(r=>r[1]).map(r=>[r[1],r]));var Ug={cardNumber:"cardNumber",cardSecurityCode:"cardSecurityCode",cardExpiryDate:"cardExpiryDate",cardholderName:"cardholderName"};var t0=Object.values(Ug);var Hg=["EFTPOS"];function Tc(r){return!r.some(t=>Hg.includes(t))}var fe=class extends v{constructor(){super(...arguments);this.cardNetworks=null;this.headlessUtils=null;this.selectedCardNetwork=null;this.isDropdownOpen=!1;this.focusedNetworkIndex=0;this.isKeyboardNavigation=!1;this.buttonRef=zt();this.dropdownRef=zt();this.networkOptionRefs=[];this.toggleDropdown=e=>{this.isKeyboardNavigation=!1,e.stopPropagation(),this.getSelectableNetworks().length>1&&(this.isDropdownOpen=!this.isDropdownOpen,this.isDropdownOpen&&(this.focusedNetworkIndex=this.getSelectedNetworkIndex()))};this.handleClickOutside=e=>{this.isDropdownOpen&&(this.contains(e.target)||(this.isDropdownOpen=!1,this.isKeyboardNavigation=!1))};this.handleMouseMove=()=>{this.isKeyboardNavigation&&(this.isKeyboardNavigation=!1)};this.handleKeyDown=e=>{if(!(!(this.getSelectableNetworks().length>1)||!(this.contains(e.target)||this===e.target||this.isDropdownOpen&&e.target===document.body)))switch(this.isKeyboardNavigation=!0,e.key){case"ArrowDown":e.preventDefault(),this.isDropdownOpen?(this.focusedNetworkIndex=(this.focusedNetworkIndex+1)%this.getSelectableNetworks().length,this.focusNetworkOption()):(this.isDropdownOpen=!0,this.focusedNetworkIndex=this.getSelectedNetworkIndex());break;case"ArrowUp":e.preventDefault(),this.isDropdownOpen?(this.focusedNetworkIndex=(this.focusedNetworkIndex-1+this.getSelectableNetworks().length)%this.getSelectableNetworks().length,this.focusNetworkOption()):(this.isDropdownOpen=!0,this.focusedNetworkIndex=this.getSelectedNetworkIndex());break;case"Enter":case" ":this.isDropdownOpen&&this.focusedNetworkIndex>=0?(e.preventDefault(),this.selectNetwork(e,this.getSelectableNetworks()[this.focusedNetworkIndex])):!this.isDropdownOpen&&this.buttonRef.value===document.activeElement&&(e.preventDefault(),this.isDropdownOpen=!0,this.focusedNetworkIndex=this.getSelectedNetworkIndex());break;case"Escape":this.isDropdownOpen&&(e.preventDefault(),this.isDropdownOpen=!1,this.buttonRef.value?.focus());break;case"Tab":this.isDropdownOpen&&(this.isDropdownOpen=!1);break}};this.handleDocumentKeyDown=e=>{this.isDropdownOpen&&this.handleKeyDown(e)}}getNetworkIconUrl(e){return this.headlessUtils?.getCardNetworkAsset(e.network)?.cardUrl}renderDefaultCardIcon(){return p`<div class="network-icon">${Zr["payment-card"]}</div>`}getSelectableNetworks(){return this.cardNetworks?.selectableCardNetworks||[]}getDetectedNetwork(){return this.selectedCardNetwork??(this.cardNetworks?.detectedCardNetwork||null)}getSelectedNetworkIndex(){let e=this.getDetectedNetwork();if(!e)return 0;let a=this.getSelectableNetworks().findIndex(i=>i.network===e.network);return a>=0?a:0}selectNetwork(e,a){e.stopPropagation(),this.selectedCardNetwork=a,this.isDropdownOpen=!1,this.buttonRef.value?.focus(),this.cardNetworks&&this.dispatchEvent(new CustomEvent("network-selected",{detail:{network:a.network},bubbles:!0,composed:!0}))}focusNetworkOption(){requestAnimationFrame(()=>{this.networkOptionRefs[this.focusedNetworkIndex]&&this.networkOptionRefs[this.focusedNetworkIndex].focus()})}setNetworkOptionRef(e,a){this.networkOptionRefs[a]=e}connectedCallback(){super.connectedCallback(),setTimeout(()=>{document.addEventListener("click",this.handleClickOutside),document.addEventListener("mousemove",this.handleMouseMove),this.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keydown",this.handleDocumentKeyDown)},0)}disconnectedCallback(){document.removeEventListener("click",this.handleClickOutside),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousemove",this.handleMouseMove),this.removeEventListener("keydown",this.handleKeyDown),super.disconnectedCallback()}render(){if(this.cardNetworks?.isLoading)return p`<primer-spinner size="small" compact></primer-spinner>`;let e=this.getSelectableNetworks();if(!this.getDetectedNetwork()&&e.length===0)return this.renderDefaultCardIcon();let a=this.getDetectedNetwork()||(e.length>0?e[0]:null);if(!a)return this.renderDefaultCardIcon();let i=e.length>1;return i&&!Tc(e.map(o=>o.network))?p`<div class="network-selector-inline">${e.map(o=>p`<div class="network-icon-container"><img class="network-icon" src=${this.getNetworkIconUrl(o)} alt=${o.displayName} /></div>`)}</div>`:p`<button ${Pt(this.buttonRef)} class="network-selector" @click=${this.toggleDropdown} @keydown=${o=>{(o.key===" "||o.key==="Enter")&&i&&(o.preventDefault(),this.isDropdownOpen=!this.isDropdownOpen,this.isDropdownOpen&&(this.focusedNetworkIndex=this.getSelectedNetworkIndex()))}} aria-label=${i?`Selected card network: ${a.displayName}. Click to change.`:`Card network: ${a.displayName}`} aria-expanded=${i?this.isDropdownOpen:y} aria-haspopup=${i?"true":y} aria-controls=${i?"network-dropdown":y} ><img class="network-icon" src=${this.getNetworkIconUrl(a)} alt=${a.displayName} />${R(i,()=>p`<primer-icon class="caret ${this.isDropdownOpen?"open":""}" size="sm" name="chevron-down" ></primer-icon>`,()=>y)}</button>${R(this.isDropdownOpen,()=>p`<div ${Pt(this.dropdownRef)} id="network-dropdown" class="dropdown open" role="listbox" aria-label="Select card network" >${e.map((o,s)=>p`<div ${Pt(l=>this.setNetworkOptionRef(l,s))} class="network-option ${this.isKeyboardNavigation&&s===this.focusedNetworkIndex?"focused":""}" @click=${l=>this.selectNetwork(l,o)} @keydown=${l=>{(l.key==="Enter"||l.key===" ")&&this.selectNetwork(l,o)}} role="option" aria-selected=${o.network===a.network} tabindex="${s===this.focusedNetworkIndex?"0":"-1"}" ><img class="network-option-icon" src=${this.getNetworkIconUrl(o)} alt=${o.displayName} /><span class="network-name">${o.displayName}</span>${R(o.network===a.network,()=>p`<primer-icon class="checkmark" name="checkmark" size="sm" ></primer-icon>`,()=>y)}</div>`)}</div>`,()=>y)} `}};fe.styles=[I,ec],d([A({context:hr,subscribe:!0})],fe.prototype,"cardNetworks",2),d([A({context:z,subscribe:!0})],fe.prototype,"headlessUtils",2),d([N()],fe.prototype,"selectedCardNetwork",2),d([N()],fe.prototype,"isDropdownOpen",2),d([N()],fe.prototype,"focusedNetworkIndex",2),d([N()],fe.prototype,"isKeyboardNavigation",2),fe=d([b("primer-card-network-selector")],fe);var Pc=f` :host { display: block; margin-top: var(--primer-space-medium); margin-bottom: var(--primer-space-medium); } .other-payment-methods-container { width: 100%; } .other-payment-methods-content { padding: var(--primer-space-medium) 0; } .primer-loader { display: flex; justify-content: center; align-items: center; } /* Collapsable animation for slotted toggle button */ .collapsable-wrapper { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--primer-animation-duration) var(--primer-animation-easing); overflow: hidden; } .collapsable-wrapper.expanded { grid-template-rows: 1fr; } .collapsable-content { min-height: 0; } `;var Oe=class extends v{constructor(){super(...arguments);this.vaultManager=null;this.contextEventsController=null;this.hasSlottedToggle=!1;this.isExpanded=!1;this._isHandlingContextEvent=!1;this._contextToggleListener=null;this.handleToggleSlotChange=e=>{let i=e.target.assignedNodes({flatten:!0});this.hasSlottedToggle=i.length>0};this.handleSlotButtonClick=e=>{let i=e.target.closest("button, primer-button");if(!i)return;let n=i;this.isToggleButton(n)&&(e.preventDefault(),this.toggleAccordion())};this.handleDirectToggle=e=>{let a=e.detail?.action;a==="expand"?this.expand():a==="collapse"?this.collapse():this.toggleAccordion()};this.handleContextToggle=e=>{if(!this._isHandlingContextEvent){this._isHandlingContextEvent=!0;try{if(e.target!==this){e.stopPropagation();let a=e.detail?.action;a==="expand"?this.expand():a==="collapse"?this.collapse():this.toggleAccordion()}}finally{this._isHandlingContextEvent=!1}}}}isToggleButton(e){let a=this.shadowRoot?.querySelector('slot[name="show-other-payments-toggle-button"]');return a?a.assignedElements({flatten:!0}).some(n=>n===e||n.contains(e)):!1}toggleAccordion(){this.hasSlottedToggle?(this.isExpanded=!this.isExpanded,this.dispatchExpandedEvent(this.isExpanded)):this.collapsableElement&&(this.collapsableElement.isExpanded?this.collapsableElement.collapse():this.collapsableElement.expand())}dispatchExpandedEvent(e){this.dispatchEvent(new CustomEvent("primer:show-other-payments-toggled",{bubbles:!0,composed:!0,detail:{expanded:e}}))}expand(){this.hasSlottedToggle?this.isExpanded||(this.isExpanded=!0,this.dispatchExpandedEvent(!0)):this.collapsableElement?.expand()}collapse(){this.hasSlottedToggle?this.isExpanded&&(this.isExpanded=!1,this.dispatchExpandedEvent(!1)):this.collapsableElement?.collapse()}setupContextEventListeners(){this.contextEventsController?.host&&this._contextToggleListener&&this.contextEventsController.host.addEventListener("primer:show-other-payments-toggle",this._contextToggleListener)}cleanupContextEventListeners(){this.contextEventsController?.host&&this._contextToggleListener&&this.contextEventsController.host.removeEventListener("primer:show-other-payments-toggle",this._contextToggleListener)}connectedCallback(){super.connectedCallback(),this.isExpanded=this.vaultManager?.vaultedPaymentMethods.length===0,this.addEventListener("click",this.handleSlotButtonClick),this.addEventListener("primer:show-other-payments-toggle",this.handleDirectToggle),this._contextToggleListener=e=>{this.handleContextToggle(e)},this.setupContextEventListeners()}disconnectedCallback(){this.removeEventListener("click",this.handleSlotButtonClick),this.removeEventListener("primer:show-other-payments-toggle",this.handleDirectToggle),this.cleanupContextEventListeners(),super.disconnectedCallback()}render(){if(this.vaultManager?.isLoading)return y;let e=this.vaultManager?.showEmptyState||this.vaultManager?.vaultedPaymentMethods.length;return!this.vaultManager||!this.vaultManager.enabled||this.vaultManager.headless||!e?p`<slot name="other-payments"></slot>`:p`<div class="other-payment-methods-container"><slot name="show-other-payments-toggle-button" @slotchange=${this.handleToggleSlotChange} ></slot>${R(!this.hasSlottedToggle,()=>p`<primer-collapsable buttonVariant="secondary" .expanded="${this.vaultManager?.vaultedPaymentMethods.length===0}" .header="${S("navigateToPaymentMethods",{id:"navigateToPaymentMethods"})}" ><div class="other-payment-methods-content"><slot name="other-payments"></slot></div></primer-collapsable>`,()=>p`<div class="collapsable-wrapper ${this.isExpanded?"expanded":""}" role="region" aria-labelledby="custom-toggle-button" ><div class="collapsable-content"><div class="other-payment-methods-content"><slot name="other-payments"></slot></div></div></div>`)}</div>`}};Oe.styles=[Pc],d([A({context:be,subscribe:!0}),u({type:Object,attribute:!1})],Oe.prototype,"vaultManager",2),d([A({context:Ye,subscribe:!0}),u({attribute:!1})],Oe.prototype,"contextEventsController",2),d([_e("primer-collapsable")],Oe.prototype,"collapsableElement",2),d([N()],Oe.prototype,"hasSlottedToggle",2),d([N()],Oe.prototype,"isExpanded",2),Oe=d([b("primer-show-other-payments")],Oe);var ha=class extends v{render(){return p`<primer-checkout-state type="complete"></primer-checkout-state>`}};ha=d([b("primer-checkout-complete")],ha);var Wt=class extends v{constructor(){super(...arguments);this.sdkState=null}render(){return p`<primer-checkout-state type="failure" description=${this.sdkState?.primerJsError?.message||""} ></primer-checkout-state>`}};d([A({context:J,subscribe:!0}),u()],Wt.prototype,"sdkState",2),Wt=d([b("primer-checkout-error")],Wt);var Nc=f` :host { display: block; width: 100%; } `;var ht=class extends v{constructor(){super(...arguments);this.showProcessingErrors=!0}get shouldShowError(){return!this.sdkState||this.sdkState.isProcessing?!1:!!(this.sdkState.paymentFailure&&this.showProcessingErrors)}render(){return this.sdkState?p`<primer-error-message message="${S(this.sdkState.paymentFailure?.message??"",{id:"tokenizationError"})}" ?visible="${this.shouldShowError}" ></primer-error-message>`:y}};ht.styles=[Nc],d([A({context:J,subscribe:!0}),N()],ht.prototype,"sdkState",2),d([u({type:Boolean,attribute:"show-processing-errors"})],ht.prototype,"showProcessingErrors",2),ht=d([b("primer-error-message-container")],ht);var Ic=f` :host { display: contents; } .primer-main-list { display: flex; flex-direction: column; gap: var(--primer-space-small); } .primer-is-processing { opacity: 0.5; pointer-events: none; } primer-vault-manager { margin-bottom: var(--primer-space-xlarge); } `;var at=class extends v{constructor(){super(...arguments);this.hasAssignedContent=!1;this.onSlotChange=e=>{let i=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=i.length>0,this.requestUpdate()};this.paymentMethods=null;this.sdkState=null;this.clientOptions=null}render(){return this.sdkState?.isSuccessful?p`<slot name="checkout-complete"><primer-checkout-complete></primer-checkout-complete></slot>`:p`<slot name="payments" @slotchange=${this.onSlotChange}></slot>${R(this.hasAssignedContent,()=>y,()=>p`<div class=${le({"primer-is-processing":!!this.sdkState?.isProcessing})} ><primer-vault-manager></primer-vault-manager><primer-show-other-payments><div slot="other-payments" class="primer-main-list">${this.paymentMethods?.map(e=>p`<primer-payment-method type=${e.type} ?disabled=${this.clientOptions?.disabledPayments===!0} ></primer-payment-method>`)}</div></primer-show-other-payments><primer-error-message-container></primer-error-message-container></div>`)} `}};at.styles=[I,Ic],d([A({context:vt,subscribe:!0}),u()],at.prototype,"paymentMethods",2),d([A({context:J,subscribe:!0}),u()],at.prototype,"sdkState",2),d([A({context:se,subscribe:!0}),u()],at.prototype,"clientOptions",2),at=d([b("primer-main")],at);function dG(){dl(),cl()}export{Ie as AchPayment,Qe as ApplePay,ce as BillingAddress,Ee as Blik,Ae as Button,oe as CardForm,ut as CardFormCVV,fe as CardFormCardNetworkSelector,ct as CardFormCardNumber,st as CardFormError,pt as CardFormExpiry,mt as CardFormName,ae as CardFormSubmit,Me as Collapsable,Ve as Dialog,De as DynamicPayment,Je as ErrorMessage,ht as ErrorMessageContainer,qe as GooglePay,Y as Input,ot as InputLabel,We as InputWrapper,Xe as PayPal,Ue as PaymentMethod,we as PaymentMethodContainer,tt as PaymentMethodContentComponent,Et as Portal,ie as PortalDialog,ha as PrimerCheckoutComplete,Ne as PrimerCheckoutComponent,Wt as PrimerCheckoutFailure,lt as PrimerCheckoutState,Ze as PrimerIcon,de as PrimerKlarna,at as PrimerMain,ke as RedirectPayment,Ce as Select,Oe as ShowOtherPayments,je as Spinner,te as VaultCvvInput,Le as VaultDeleteConfirmation,dt as VaultEmptyState,et as VaultErrorMessage,ee as VaultManager,He as VaultManagerHeader,Te as VaultPaymentMethodItem,ne as VaultPaymentSubmit,Fm as injectDarkTheme,Km as injectLightTheme,dl as injectLoaderStyles,cl as injectThemeStyles,dG as loadPrimer};
|
|
205
|
+
`,t.shadowRoot?t.shadowRoot.appendChild(e):t.appendChild(e)}}function $d(r,t){return r.active!==t.active||r.dirty!==t.dirty||r.error!==t.error||r.errorCode!==t.errorCode||r.submitted!==t.submitted||r.touched!==t.touched||r.valid!==t.valid}var si=class{constructor(t,e){this._meta={active:!1,dirty:!1,error:null,errorCode:null,submitted:!1,touched:!1,valid:!1};this._hostedInput=null;this._standardInput=null;this.host=t,this.config=e,this.host.addController(this),this.setupTask=new O(this.host,{args:()=>[this.getHostedInput()],task:this.setupHostedInput.bind(this)}),this.host.addEventListener("wrapper-click",()=>{this.focusInput()})}focusInput(){this._hostedInput?this._hostedInput.focus():this._standardInput&&this._standardInput.focus()}notifyUserInteraction(){let t=this.host.cardFormContext;t?.onUserInteraction&&t.onUserInteraction()}getHostedInput(){let{type:t}=this.config,e=this.host.cardFormContext;return e?{cardNumber:e.cardNumberInput,cvv:e.cvvInput,expire:e.expiryInput,cardholderName:e.cardholderNameInput??"cardholderName"}[t]:void 0}async setupHostedInput([t]){if(!t)return w;await this.host.updateComplete;let e=this.getTargetContainer();return e?t==="cardholderName"?this.setupStandardInput(e):this.setupHostedIframeInput(t,e):w}getTargetContainer(){return this.host.renderRoot.querySelector(this.config.containerSelector)}setupStandardInput(t){let e=document.createElement("input");return e.type="text",e.placeholder=this.host.placeholder,Hn(e,this.host),(this.host.ariaLabel||this.host.label)&&e.setAttribute("aria-label",this.host.ariaLabel??this.host.label),this.setupInputEventListeners(e),t.innerHTML="",t.appendChild(e),this._standardInput=e,!0}setupInputEventListeners(t){t.addEventListener("input",e=>{let a=e.target,n=!!a.value.trim();this.notifyUserInteraction(),this._meta={...this._meta,dirty:n},this.config.onInput?.(a.value),this.host.requestUpdate()}),t.addEventListener("focus",()=>{this.notifyUserInteraction(),this._meta.active=!0,this.host.requestUpdate()}),t.addEventListener("blur",()=>{this._meta.active=!1,this._meta.touched=!1,this.host.requestUpdate()}),t.addEventListener("keydown",e=>{if(e.key==="Enter"){e.preventDefault();let a=this.host.closest("form");a&&a.requestSubmit()}})}async setupHostedIframeInput(t,e){await new Promise(n=>requestAnimationFrame(()=>n())),this._hostedInput=t;let a=Ua(this.host.computedStyles),i=a?{style:{input:{base:a}}}:void 0;return t.addEventListener("focus",()=>{this.notifyUserInteraction(),this._meta.active=!0,this.host.requestUpdate()}),t.addEventListener("blur",()=>{this._meta.active=!1,this.host.requestUpdate()}),t.addEventListener("change",n=>{let o=n;this.notifyUserInteraction(),$d(this._meta,o)&&(this._meta={...this._meta,...o},this.host.requestUpdate())}),t.addEventListener("enter",()=>{let n=this.host.closest("form");n&&n.requestSubmit()}),this.host.isConnected?(await t.render(e,{placeholder:this.host.placeholder,ariaLabel:this.host.ariaLabel,...i}),!0):!1}get meta(){return this._meta}updateMetaFromValidation(t){this._meta={...this._meta,valid:!!t.valid,error:t.error||null,errorCode:t.errorCode||null},this.host.requestUpdate()}setSubmitted(t){this._meta={...this._meta,submitted:t,...t&&{touched:!0}},this.host.requestUpdate()}hostConnected(){this.registerWithContext()}hostDisconnected(){this.unregisterFromContext(),this._hostedInput=null,this._standardInput=null}hostUpdate(){if(this._hostedInput&&this.host.computedStyles){let t=Ua(this.host.computedStyles);t&&this._hostedInput.setOptions({style:{input:{base:t}}})}else this._standardInput&&this.host.computedStyles&&Hn(this._standardInput,this.host)}registerWithContext(){let t=this.host.cardFormContext;t?.registerInputController&&t.registerInputController(this.config.type,this)}unregisterFromContext(){let t=this.host.cardFormContext;t?.unregisterInputController&&t.unregisterInputController(this.config.type)}};var jd=f` :host { display: contents; } form { display: flex; flex-direction: column; gap: var(--primer-space-medium); width: 100%; } .card-form { display: flex; flex-direction: column; gap: var(--primer-space-medium); margin-bottom: var(--primer-space-medium); } .card-form-row { display: flex; gap: var(--primer-space-small); } `;var Wd={cardholderName:"cardholderName",cardNumber:"cardNumber",cardExpiryDate:"expire",expiryDate:"expire",cardSecurityCode:"cvv",cvv:"cvv"},oe=class extends v{constructor(){super(...arguments);this.hideLabels=!1;this.disabled=!1;this.hasAssignedContent=!1;this.selectedCardNetwork=null;this.formErrorMessage=null;this.paymentMethodSelectionSent=!1;this.paymentManagers=new Map;this.clientOptions=null;this.headlessUtils=null;this.analyticsUtils=null;this.contextEventsController=null;this.cardFormProvider=new W(this,{context:ua,initialValue:null});this.eventsController=new aa(this);this._contextCardSubmitListener=null;this._isHandlingContextEvent=!1;this.inputControllers=new Map;this.setupCardFormTask=new O(this,{task:([e])=>{if(!e?.manager)return w;let{manager:a}=e,i=a.createHostedInputs(),{cardNumberInput:n,expiryInput:o,cvvInput:s}=i;return this.cardFormProvider.setValue({cardholderNameInput:i.cardholderNameInput,cardNumberInput:n,expiryInput:o,cvvInput:s,setCardholderName:l=>{a.setCardholderName(l),this.shouldRequireCardholderName&&a.validate?.().then(c=>{let g=c?.validationErrors?.find(T=>T.name===Wd.cardholderName),h=this.inputControllers.get("cardholderName");h&&h.updateMetaFromValidation({valid:!1,error:g?.message||g?.error||null,errorCode:g?.message||g?.error||null})})},setCardNetwork:l=>{this.selectedCardNetwork=l},validate:()=>a.validate(),submit:l=>a.submit(l),hideLabels:this.hideLabels,disabled:this.disabled,setSubmissionState:l=>{this.inputControllers.forEach(c=>{c.setSubmitted(l)})},propagateValidationErrors:l=>{l&&l.forEach(c=>{let m=c.field||c.name,g=c.message||c.error,h=Wd[m];if(h){let T=this.inputControllers.get(h);if(T){let M={valid:!1,error:g,errorCode:g};T.updateMetaFromValidation(M)}}})},registerInputController:(l,c)=>{this.inputControllers.set(l,c)},unregisterInputController:l=>{this.inputControllers.delete(l)},onUserInteraction:()=>{this.sendPaymentMethodSelectionEvent(),this.checkAndSendPaymentDetailsEnteredEvent()}}),!0},args:()=>[this.paymentManagers.get("PAYMENT_CARD")]});this.paymentDetailsEnteredSent=!1;this.handleSlotButtonClick=e=>{let i=e.target.closest("button, primer-button");if(!i)return;let n=i;this.isSubmitButton(n)&&(e.preventDefault(),this.submitCardPayment())};this.handleDirectSubmit=e=>{e.stopPropagation(),this.submitCardPayment()};this.handleContextCardSubmit=e=>{if(!this._isHandlingContextEvent){this._isHandlingContextEvent=!0;try{e.target!==this&&(e.stopPropagation(),this.submitCardPayment())}finally{this._isHandlingContextEvent=!1}}};this.onSlotChange=e=>{let i=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=i.length>0};this.handleFormSubmit=e=>{e.preventDefault(),e.stopPropagation(),this.submitCardPayment()}}updated(e){if(super.updated(e),(e.has("hideLabels")||e.has("disabled"))&&this.cardFormProvider.value&&this.cardFormProvider.setValue({...this.cardFormProvider.value,hideLabels:this.hideLabels,disabled:this.disabled}),e.has("contextEventsController")){let a=e.get("contextEventsController");a?.host&&this._contextCardSubmitListener&&a.host.removeEventListener("primer:card-submit",this._contextCardSubmitListener),this.setupContextEventListeners()}}get shouldShowCardholderName(){let e=this.clientOptions?.card?.cardholderName;return typeof e?.visible=="boolean"?e.visible:!0}get shouldRequireCardholderName(){if(!this.shouldShowCardholderName)return!1;let e=this.clientOptions?.card?.cardholderName;return typeof e?.required=="boolean"?e.required:!0}sendPaymentMethodSelectionEvent(){this.paymentMethodSelectionSent||(this.paymentMethodSelectionSent=!0,X({eventName:"PAYMENT_METHOD_SELECTION",paymentMethod:"PAYMENT_CARD"}))}checkAndSendPaymentDetailsEnteredEvent(){if(this.paymentDetailsEnteredSent)return;let e=this.inputControllers.get("cardNumber"),a=this.inputControllers.get("expire"),i=this.inputControllers.get("cvv"),n=e?.meta?.dirty===!0,o=a?.meta?.dirty===!0,s=i?.meta?.dirty===!0,l=!0;this.shouldRequireCardholderName&&(l=this.inputControllers.get("cardholderName")?.meta?.dirty===!0),n&&o&&s&&l&&(this.sendPaymentDetailsEnteredEvent(),this.paymentDetailsEnteredSent=!0)}sendPaymentDetailsEnteredEvent(){X({eventName:"PAYMENT_DETAILS_ENTERED",paymentMethod:"PAYMENT_CARD"})}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.handleSlotButtonClick),this.addEventListener("primer:card-submit",this.handleDirectSubmit),this._contextCardSubmitListener=e=>{this.handleContextCardSubmit(e)},this.setupContextEventListeners()}disconnectedCallback(){this.removeEventListener("click",this.handleSlotButtonClick),this.removeEventListener("primer:card-submit",this.handleDirectSubmit),this.cleanupContextEventListeners(),super.disconnectedCallback()}setupContextEventListeners(){this.contextEventsController?.host&&this._contextCardSubmitListener&&this.contextEventsController.host.addEventListener("primer:card-submit",this._contextCardSubmitListener)}cleanupContextEventListeners(){this.contextEventsController?.host&&this._contextCardSubmitListener&&this.contextEventsController.host.removeEventListener("primer:card-submit",this._contextCardSubmitListener)}isSubmitButton(e){let a=e.tagName.toLowerCase(),i=a==="button",n=a==="primer-button";return i&&(e.getAttribute("type")==="submit"||e.hasAttribute("data-submit"))||n&&(e.getAttribute("type")==="submit"||e.hasAttribute("data-submit"))}async submitCardPayment(){let e=this.cardFormProvider.value;if(!e||this.disabled)return;this.formErrorMessage=null,e.setSubmissionState?.(!0);let a=this.querySelector("primer-billing-address")||this.renderRoot.querySelector("primer-billing-address"),i=!0;a&&(i=await a.validateForSubmission());let n=await e.validate?.();if(n?.valid&&i){if(a&&!await a.submitToSDK()){let c=S("tokenizationError",{id:"tokenizationError"});this.formErrorMessage=c,this.eventsController.dispatchFormSubmitErrors([{field:"billingAddress",name:"billingAddress",error:"BILLING_ADDRESS_SUBMISSION_FAILED",message:c}]);return}let o={success:!0};this.eventsController.dispatchFormSubmitSuccess(o);let s=this.selectedCardNetwork?{cardNetwork:this.selectedCardNetwork}:void 0;await e.submit?.(s)}else{let o=n?.validationErrors;e.propagateValidationErrors?.(o||[]),this.cardFormProvider.setValue({...e,errors:o}),this.eventsController.dispatchFormSubmitErrors(o)}}render(){return this.setupCardFormTask.status===St.ERROR||this.setupCardFormTask.status===St.INITIAL?y:p`<form @submit=${this.handleFormSubmit}><slot name="card-form-content" @slotchange=${this.onSlotChange}></slot>${this.setupCardFormTask.render({complete:()=>R(this.hasAssignedContent,()=>y,()=>p`<div class="card-form"><primer-input-card-number></primer-input-card-number><div class="card-form-row"><primer-input-card-expiry></primer-input-card-expiry><primer-input-cvv></primer-input-cvv></div>${R(this.shouldShowCardholderName,()=>p`<primer-input-card-holder-name></primer-input-card-holder-name>`,()=>y)}<primer-billing-address></primer-billing-address></div><primer-card-form-submit></primer-card-form-submit><primer-error-message message="${this.formErrorMessage||""}" ?visible="${!!this.formErrorMessage}" ></primer-error-message>`)})}</form>`}};oe.styles=[I,jd],d([u({type:Boolean,attribute:"hide-labels",reflect:!0})],oe.prototype,"hideLabels",2),d([u({type:Boolean,attribute:"disabled"})],oe.prototype,"disabled",2),d([N()],oe.prototype,"hasAssignedContent",2),d([N()],oe.prototype,"selectedCardNetwork",2),d([N()],oe.prototype,"formErrorMessage",2),d([A({context:Z,subscribe:!0}),u({type:Object})],oe.prototype,"paymentManagers",2),d([A({context:se}),u({attribute:!1})],oe.prototype,"clientOptions",2),d([A({context:z,subscribe:!0}),u({attribute:!1})],oe.prototype,"headlessUtils",2),d([A({context:ft,subscribe:!0}),u({attribute:!1})],oe.prototype,"analyticsUtils",2),d([A({context:Ye,subscribe:!0}),u({attribute:!1})],oe.prototype,"contextEventsController",2),oe=d([b("primer-card-form"),D()],oe);var ye=class extends v{constructor(){super();this._cardFormContext=null;this.computedStyles=null;this._userAssignedProps=new Set;this._internalLabel="";this._internalPlaceholder="";this._internalAriaLabel="";this.handleWrapperClick=()=>{this.hostedInputController.focusInput()};this.hostedInputController={}}get cardFormContext(){return this._cardFormContext}set cardFormContext(e){let a=this._cardFormContext;this._cardFormContext=e,!a&&e&&this.updateComplete.then(()=>{this.hostedInputController?.registerWithContext?.()}),this.requestUpdate("cardFormContext",a)}getTranslatedValue(e){return e?typeof e=="string"?e:S(e.id,{id:e.id}):""}get label(){return this._userAssignedProps.has("label")?this._internalLabel:this.getTranslatedValue(this.config.translations.label)}set label(e){let a=this.label;e!==""?(this._userAssignedProps.add("label"),this._internalLabel=e):(this._userAssignedProps.delete("label"),this._internalLabel=""),this.requestUpdate("label",a)}get placeholder(){return this._userAssignedProps.has("placeholder")?this._internalPlaceholder:this.getTranslatedValue(this.config.translations.placeholder)}set placeholder(e){let a=this.placeholder;this._userAssignedProps.add("placeholder"),this._internalPlaceholder=e,this.requestUpdate("placeholder",a)}get ariaLabel(){return this._userAssignedProps.has("ariaLabel")?this._internalAriaLabel:this.getTranslatedValue(this.config.translations.ariaLabel)||this.getTranslatedValue(this.config.translations.label)}set ariaLabel(e){let a=this.ariaLabel;e!==""?(this._userAssignedProps.add("ariaLabel"),this._internalAriaLabel=e):(this._userAssignedProps.delete("ariaLabel"),this._internalAriaLabel=""),this.requestUpdate("ariaLabel",a)}childUpdated(){Object.defineProperty(this,"hostedInputController",{value:new si(this,{type:this.config.inputType,containerSelector:this.config.containerSelector,onInput:this.config.onInput}),writable:!1,configurable:!1})}getError(){let e=this.hostedInputController.meta;return e.submitted||e.dirty&&e.touched?e.errorCode:null}renderInput(){if(this.hostedInputController.setupTask.status===St.ERROR)return y;let e=this.getError();return p`<primer-input-wrapper .focusWithin="${this.hostedInputController.meta.active}" .hasError=${!!e} @wrapper-click="${this.handleWrapperClick}" >${R(!this.cardFormContext?.hideLabels,()=>p`<primer-input-label slot="label" >${this.label}</primer-input-label >`,()=>y)}<div slot="input" class="card-input-slot" id="${this.config.containerSelector.substring(1)}" aria-label="${this.ariaLabel}" ></div>${R(e,()=>p`<primer-input-error slot="error">${S(e,{id:e})}</primer-input-error>`,()=>y)}</primer-input-wrapper>`}};d([A({context:ua,subscribe:!0})],ye.prototype,"cardFormContext",1),d([A({context:ia,subscribe:!0}),u()],ye.prototype,"computedStyles",2),d([u({type:String})],ye.prototype,"label",1),d([u({type:String})],ye.prototype,"placeholder",1),d([u({type:String,attribute:"aria-label"})],ye.prototype,"ariaLabel",1);var Zd=f` :host { display: contents; } .card-number-container { display: flex; align-items: center; width: 100%; position: relative; gap: var(--primer-space-small); } #cardNumber { flex: 1; display: flex; width: 100%; } .network-selector-container { display: flex; align-items: center; z-index: 2; } `;var It=f` .card-input-slot { display: flex; } `;var ct=class extends ye{constructor(){super();this.config={inputType:"cardNumber",containerSelector:"#cardNumber",errorName:"cardNumber-card",translations:{label:{id:"cardNumber",defaultMessage:"Card Number"},placeholder:"4111 1111 1111 1111",ariaLabel:{id:"cardNumber",defaultMessage:"Card Number"}}};this.handleNetworkSelected=e=>{let{network:a}=e.detail;this.cardFormContext&&this.cardFormContext.setCardNetwork(a)};this.childUpdated()}renderInput(){if(this.hostedInputController.setupTask.status===St.ERROR)return y;let e=this.getError();return p`<primer-input-wrapper .focusWithin="${this.hostedInputController.meta.active}" .hasError=${!!e} >${R(!this.cardFormContext?.hideLabels,()=>p`<primer-input-label slot="label" >${this.label}</primer-input-label >`,()=>y)}<div slot="input" class="card-number-container" aria-label="${this.ariaLabel}" ><div id="${this.config.containerSelector.substring(1)}"></div><div class="network-selector-container"><primer-card-network-selector @network-selected=${this.handleNetworkSelected} ></primer-card-network-selector></div></div>${R(e,a=>p`<primer-input-error slot="error">${S(a,{id:a})}</primer-input-error>`,()=>y)}</primer-input-wrapper>`}render(){return this.renderInput()}};ct.styles=[I,It,Zd],ct=d([b("primer-input-card-number"),D()],ct);var Jd=f` :host { display: contents; } `;var ut=class extends ye{constructor(){super();this.config={inputType:"cvv",containerSelector:"#cvv",errorName:"cvv-card",translations:{label:"CVV",placeholder:"123"}};this.childUpdated()}render(){return this.renderInput()}};ut.styles=[I,It,Jd],ut=d([b("primer-input-cvv"),D()],ut);var qd=f` :host { display: contents; } `;var pt=class extends ye{constructor(){super();this.config={inputType:"expire",containerSelector:"#expiry",errorName:"expiryDate-card",translations:{label:{id:"cardExpiry",defaultMessage:"Expiry Date"},placeholder:{id:"cardExpiryPlaceholder",defaultMessage:"MM/YY"},ariaLabel:{id:"cardExpiry",defaultMessage:"Expiry Date"}}};this.childUpdated()}render(){return this.renderInput()}};pt.styles=[I,It,qd],pt=d([b("primer-input-card-expiry"),D()],pt);var Qd=f` :host { display: contents; } `;var mt=class extends ye{constructor(){super();this.config={inputType:"cardholderName",containerSelector:"#cardFormName",errorName:"cardholderName",translations:{label:{id:"cardholderNameLabel",defaultMessage:"Cardholder Name"},placeholder:{id:"cardholderNamePlaceholder",defaultMessage:"Name on card"},ariaLabel:{id:"cardholderNameLabel",defaultMessage:"Cardholder Name"}},onInput:e=>this.handleInput(e)};this.childUpdated()}handleInput(e){this.cardFormContext?.setCardholderName?.(e)}render(){return this.renderInput()}};mt.styles=[I,It,Qd],mt=d([b("primer-input-card-holder-name"),D()],mt);var Xd=f` :host { display: contents; } `;var ae=class extends v{constructor(){super(...arguments);this._userAssignedProps=new Set;this._internalButtonText="";this.headlessUtils=null;this.clientOptions=null;this.sdkState=null;this.cardFormContext=null;this.analyticsUtils=null;this.contextEventsController=null;this.variant="primary";this.disabled=!1;this.handleClick=e=>{if(e.preventDefault(),this.disabled)return;X({eventName:"PAYMENT_SUBMITTED",paymentMethod:"PAYMENT_CARD"});let a=new CustomEvent("primer:card-submit",{bubbles:!0,composed:!0,detail:{source:"primer-card-form-submit"}});this.dispatchEvent(a)}}get buttonText(){return this._userAssignedProps.has("buttonText")?this._internalButtonText:S("pay",{id:"pay"})}set buttonText(e){let a=this.buttonText;e!==""?(this._userAssignedProps.add("buttonText"),this._internalButtonText=e):(this._userAssignedProps.delete("buttonText"),this._internalButtonText=""),this.requestUpdate("buttonText",a)}get submitButtonConfig(){return this.clientOptions?.submitButton??null}get shouldShowBuiltInButton(){return this.submitButtonConfig?.useBuiltInButton??!0}render(){if(!this.shouldShowBuiltInButton)return y;let e=this.submitButtonConfig?.amountVisible?this.headlessUtils?.getUIOrderAmount():null,a=e?` ${e}`:y,i=this.disabled||this.cardFormContext?.disabled||!1;return p`<primer-button type="submit" variant=${this.variant} ?disabled=${i} @click=${this.handleClick} .loading=${!!this.sdkState?.isProcessing} data-submit >${this.buttonText}${a}</primer-button>`}};ae.styles=[I,Xd],d([u({type:String})],ae.prototype,"buttonText",1),d([A({context:z,subscribe:!0}),u({type:Object})],ae.prototype,"headlessUtils",2),d([A({context:se,subscribe:!0}),u({type:Object})],ae.prototype,"clientOptions",2),d([A({context:J,subscribe:!0}),u()],ae.prototype,"sdkState",2),d([A({context:ua,subscribe:!0}),u()],ae.prototype,"cardFormContext",2),d([A({context:ft,subscribe:!0}),u({attribute:!1})],ae.prototype,"analyticsUtils",2),d([A({context:Ye,subscribe:!0}),u({attribute:!1})],ae.prototype,"contextEventsController",2),d([u({type:String})],ae.prototype,"variant",2),d([u({type:Boolean})],ae.prototype,"disabled",2),ae=d([b("primer-card-form-submit"),D()],ae);var ec=f` :host { display: flex; align-items: center; position: relative; height: var(--primer-typography-body-large-line-height); } .network-selector { display: flex; align-items: center; cursor: pointer; background: none; padding: unset; border: none; transition: opacity var(--primer-animation-duration) var(--primer-animation-easing); outline: none; gap: var(--primer-space-xsmall); } .network-selector:hover { opacity: 0.8; } .network-selector:focus-visible { outline: 2px solid var(--primer-color-focus); border-radius: var(--primer-radius-xsmall); } .network-selector-inline { display: flex; border: 1px solid var(--primer-color-border-outlined-default); border-radius: var(--primer-radius-small); padding: 1px; .network-icon-container { padding: var(--primer-space-xsmall); } .network-icon-container + .network-icon-container { border-left: 1px solid var(--primer-color-border-outlined-default); } } .network-icon { display: block; width: calc(var(--primer-size-medium) * 1.4); height: var(--primer-size-medium); object-fit: contain; margin: 0; svg { width: auto; height: 100%; } } .caret { margin-left: var(--primer-space-xsmall); transition: transform var(--primer-animation-duration) var(--primer-animation-easing); color: var(--primer-color-icon-primary); } .caret.open { transform: rotate(180deg); } .dropdown { position: absolute; top: 100%; right: 0; width: max-content; min-width: calc(var(--primer-size-xxxlarge) * 3); background: var(--primer-color-gray-000); border-radius: var(--primer-radius-small); box-shadow: 0 var(--primer-space-xxsmall) var(--primer-space-large) rgba(0, 0, 0, 0.15); z-index: 10; overflow: hidden; border: 1px solid var(--primer-color-border-outlined-default); } .dropdown:not(.open) { display: none; } .dropdown.open { display: block; max-height: calc(var(--primer-size-xxxlarge) * 4); overflow-y: auto; } .network-option { display: flex; align-items: center; padding: var(--primer-space-small) var(--primer-space-medium); cursor: pointer; transition: background-color var(--primer-animation-duration) var(--primer-animation-easing); position: relative; outline: none; background-color: transparent; } /* Only apply hover effect when not in keyboard navigation mode */ .network-option:hover { background-color: var(--primer-color-gray-100); } /* Apply focused style only when the focused class is present (keyboard navigation) */ .network-option.focused { background-color: var(--primer-color-gray-100); } .network-option:focus-visible { outline: 2px solid var(--primer-color-focus); outline-offset: -2px; } .network-option-icon { width: var(--primer-size-medium); height: var(--primer-size-small); margin-right: var(--primer-space-small); object-fit: contain; } .network-name { font-size: var(--primer-typography-body-medium-size); font-family: var(--primer-typography-body-medium-font); line-height: var(--primer-typography-body-medium-line-height); letter-spacing: var(--primer-typography-body-medium-letter-spacing); white-space: nowrap; color: var(--primer-color-text-primary); flex: 1; } .checkmark { margin-left: var(--primer-space-small); color: var(--primer-color-brand); width: var(--primer-size-small); height: var(--primer-size-small); } `;var Fg=Ti(Cc()),Vg=Ti(za());var Gg=Ti(za());var Ec=[["AMEX","american-express"],["CARTES_BANCAIRES"],["DANKORT"],["DINERS_CLUB","diners-club"],["DISCOVER","discover"],["ENROUTE"],["ELO","elo"],["EFTPOS"],["HIPER","hiper","hiper-pay"],["HIPERCARD","hipercard"],["INTERAC"],["JCB","jcb"],["MAESTRO","maestro"],["MASTERCARD","mastercard"],["MIR","mir","mir-pay"],["OTHER",void 0,"payment-card"],["UNIONPAY","unionpay"],["VISA","visa"]],UO=new Map(Ec.map(r=>[r[0],r])),HO=new Map(Ec.filter(r=>r[1]).map(r=>[r[1],r]));var Ug={cardNumber:"cardNumber",cardSecurityCode:"cardSecurityCode",cardExpiryDate:"cardExpiryDate",cardholderName:"cardholderName"};var t0=Object.values(Ug);var Hg=["EFTPOS"];function Tc(r){return!r.some(t=>Hg.includes(t))}var fe=class extends v{constructor(){super(...arguments);this.cardNetworks=null;this.headlessUtils=null;this.selectedCardNetwork=null;this.isDropdownOpen=!1;this.focusedNetworkIndex=0;this.isKeyboardNavigation=!1;this.buttonRef=zt();this.dropdownRef=zt();this.networkOptionRefs=[];this.toggleDropdown=e=>{this.isKeyboardNavigation=!1,e.stopPropagation(),this.getSelectableNetworks().length>1&&(this.isDropdownOpen=!this.isDropdownOpen,this.isDropdownOpen&&(this.focusedNetworkIndex=this.getSelectedNetworkIndex()))};this.handleClickOutside=e=>{this.isDropdownOpen&&(this.contains(e.target)||(this.isDropdownOpen=!1,this.isKeyboardNavigation=!1))};this.handleMouseMove=()=>{this.isKeyboardNavigation&&(this.isKeyboardNavigation=!1)};this.handleKeyDown=e=>{if(!(!(this.getSelectableNetworks().length>1)||!(this.contains(e.target)||this===e.target||this.isDropdownOpen&&e.target===document.body)))switch(this.isKeyboardNavigation=!0,e.key){case"ArrowDown":e.preventDefault(),this.isDropdownOpen?(this.focusedNetworkIndex=(this.focusedNetworkIndex+1)%this.getSelectableNetworks().length,this.focusNetworkOption()):(this.isDropdownOpen=!0,this.focusedNetworkIndex=this.getSelectedNetworkIndex());break;case"ArrowUp":e.preventDefault(),this.isDropdownOpen?(this.focusedNetworkIndex=(this.focusedNetworkIndex-1+this.getSelectableNetworks().length)%this.getSelectableNetworks().length,this.focusNetworkOption()):(this.isDropdownOpen=!0,this.focusedNetworkIndex=this.getSelectedNetworkIndex());break;case"Enter":case" ":this.isDropdownOpen&&this.focusedNetworkIndex>=0?(e.preventDefault(),this.selectNetwork(e,this.getSelectableNetworks()[this.focusedNetworkIndex])):!this.isDropdownOpen&&this.buttonRef.value===document.activeElement&&(e.preventDefault(),this.isDropdownOpen=!0,this.focusedNetworkIndex=this.getSelectedNetworkIndex());break;case"Escape":this.isDropdownOpen&&(e.preventDefault(),this.isDropdownOpen=!1,this.buttonRef.value?.focus());break;case"Tab":this.isDropdownOpen&&(this.isDropdownOpen=!1);break}};this.handleDocumentKeyDown=e=>{this.isDropdownOpen&&this.handleKeyDown(e)}}getNetworkIconUrl(e){return this.headlessUtils?.getCardNetworkAsset(e.network)?.cardUrl}renderDefaultCardIcon(){return p`<div class="network-icon">${Zr["payment-card"]}</div>`}getSelectableNetworks(){return this.cardNetworks?.selectableCardNetworks||[]}getDetectedNetwork(){return this.selectedCardNetwork??(this.cardNetworks?.detectedCardNetwork||null)}getSelectedNetworkIndex(){let e=this.getDetectedNetwork();if(!e)return 0;let a=this.getSelectableNetworks().findIndex(i=>i.network===e.network);return a>=0?a:0}selectNetwork(e,a){e.stopPropagation(),this.selectedCardNetwork=a,this.isDropdownOpen=!1,this.buttonRef.value?.focus(),this.cardNetworks&&this.dispatchEvent(new CustomEvent("network-selected",{detail:{network:a.network},bubbles:!0,composed:!0}))}focusNetworkOption(){requestAnimationFrame(()=>{this.networkOptionRefs[this.focusedNetworkIndex]&&this.networkOptionRefs[this.focusedNetworkIndex].focus()})}setNetworkOptionRef(e,a){this.networkOptionRefs[a]=e}connectedCallback(){super.connectedCallback(),setTimeout(()=>{document.addEventListener("click",this.handleClickOutside),document.addEventListener("mousemove",this.handleMouseMove),this.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keydown",this.handleDocumentKeyDown)},0)}disconnectedCallback(){document.removeEventListener("click",this.handleClickOutside),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousemove",this.handleMouseMove),this.removeEventListener("keydown",this.handleKeyDown),super.disconnectedCallback()}render(){if(this.cardNetworks?.isLoading)return p`<primer-spinner size="small" compact></primer-spinner>`;let e=this.getSelectableNetworks();if(!this.getDetectedNetwork()&&e.length===0)return this.renderDefaultCardIcon();let a=this.getDetectedNetwork()||(e.length>0?e[0]:null);if(!a)return this.renderDefaultCardIcon();let i=e.length>1;return i&&!Tc(e.map(o=>o.network))?p`<div class="network-selector-inline">${e.map(o=>p`<div class="network-icon-container"><img class="network-icon" src=${this.getNetworkIconUrl(o)} alt=${o.displayName} /></div>`)}</div>`:p`<button ${Pt(this.buttonRef)} class="network-selector" @click=${this.toggleDropdown} @keydown=${o=>{(o.key===" "||o.key==="Enter")&&i&&(o.preventDefault(),this.isDropdownOpen=!this.isDropdownOpen,this.isDropdownOpen&&(this.focusedNetworkIndex=this.getSelectedNetworkIndex()))}} aria-label=${i?`Selected card network: ${a.displayName}. Click to change.`:`Card network: ${a.displayName}`} aria-expanded=${i?this.isDropdownOpen:y} aria-haspopup=${i?"true":y} aria-controls=${i?"network-dropdown":y} ><img class="network-icon" src=${this.getNetworkIconUrl(a)} alt=${a.displayName} />${R(i,()=>p`<primer-icon class="caret ${this.isDropdownOpen?"open":""}" size="sm" name="chevron-down" ></primer-icon>`,()=>y)}</button>${R(this.isDropdownOpen,()=>p`<div ${Pt(this.dropdownRef)} id="network-dropdown" class="dropdown open" role="listbox" aria-label="Select card network" >${e.map((o,s)=>p`<div ${Pt(l=>this.setNetworkOptionRef(l,s))} class="network-option ${this.isKeyboardNavigation&&s===this.focusedNetworkIndex?"focused":""}" @click=${l=>this.selectNetwork(l,o)} @keydown=${l=>{(l.key==="Enter"||l.key===" ")&&this.selectNetwork(l,o)}} role="option" aria-selected=${o.network===a.network} tabindex="${s===this.focusedNetworkIndex?"0":"-1"}" ><img class="network-option-icon" src=${this.getNetworkIconUrl(o)} alt=${o.displayName} /><span class="network-name">${o.displayName}</span>${R(o.network===a.network,()=>p`<primer-icon class="checkmark" name="checkmark" size="sm" ></primer-icon>`,()=>y)}</div>`)}</div>`,()=>y)} `}};fe.styles=[I,ec],d([A({context:hr,subscribe:!0})],fe.prototype,"cardNetworks",2),d([A({context:z,subscribe:!0})],fe.prototype,"headlessUtils",2),d([N()],fe.prototype,"selectedCardNetwork",2),d([N()],fe.prototype,"isDropdownOpen",2),d([N()],fe.prototype,"focusedNetworkIndex",2),d([N()],fe.prototype,"isKeyboardNavigation",2),fe=d([b("primer-card-network-selector")],fe);var Pc=f` :host { display: block; margin-top: var(--primer-space-medium); margin-bottom: var(--primer-space-medium); } .other-payment-methods-container { width: 100%; } .other-payment-methods-content { padding: var(--primer-space-medium) 0; } .primer-loader { display: flex; justify-content: center; align-items: center; } /* Collapsable animation for slotted toggle button */ .collapsable-wrapper { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--primer-animation-duration) var(--primer-animation-easing); overflow: hidden; } .collapsable-wrapper.expanded { grid-template-rows: 1fr; } .collapsable-content { min-height: 0; } `;var Oe=class extends v{constructor(){super(...arguments);this.vaultManager=null;this.contextEventsController=null;this.hasSlottedToggle=!1;this.isExpanded=!1;this._isHandlingContextEvent=!1;this._contextToggleListener=null;this.handleToggleSlotChange=e=>{let i=e.target.assignedNodes({flatten:!0});this.hasSlottedToggle=i.length>0};this.handleSlotButtonClick=e=>{let i=e.target.closest("button, primer-button");if(!i)return;let n=i;this.isToggleButton(n)&&(e.preventDefault(),this.toggleAccordion())};this.handleDirectToggle=e=>{let a=e.detail?.action;a==="expand"?this.expand():a==="collapse"?this.collapse():this.toggleAccordion()};this.handleContextToggle=e=>{if(!this._isHandlingContextEvent){this._isHandlingContextEvent=!0;try{if(e.target!==this){e.stopPropagation();let a=e.detail?.action;a==="expand"?this.expand():a==="collapse"?this.collapse():this.toggleAccordion()}}finally{this._isHandlingContextEvent=!1}}}}isToggleButton(e){let a=this.shadowRoot?.querySelector('slot[name="show-other-payments-toggle-button"]');return a?a.assignedElements({flatten:!0}).some(n=>n===e||n.contains(e)):!1}toggleAccordion(){this.hasSlottedToggle?(this.isExpanded=!this.isExpanded,this.dispatchExpandedEvent(this.isExpanded)):this.collapsableElement&&(this.collapsableElement.isExpanded?this.collapsableElement.collapse():this.collapsableElement.expand())}dispatchExpandedEvent(e){this.dispatchEvent(new CustomEvent("primer:show-other-payments-toggled",{bubbles:!0,composed:!0,detail:{expanded:e}}))}expand(){this.hasSlottedToggle?this.isExpanded||(this.isExpanded=!0,this.dispatchExpandedEvent(!0)):this.collapsableElement?.expand()}collapse(){this.hasSlottedToggle?this.isExpanded&&(this.isExpanded=!1,this.dispatchExpandedEvent(!1)):this.collapsableElement?.collapse()}setupContextEventListeners(){this.contextEventsController?.host&&this._contextToggleListener&&this.contextEventsController.host.addEventListener("primer:show-other-payments-toggle",this._contextToggleListener)}cleanupContextEventListeners(){this.contextEventsController?.host&&this._contextToggleListener&&this.contextEventsController.host.removeEventListener("primer:show-other-payments-toggle",this._contextToggleListener)}connectedCallback(){super.connectedCallback(),this.isExpanded=this.vaultManager?.vaultedPaymentMethods.length===0,this.addEventListener("click",this.handleSlotButtonClick),this.addEventListener("primer:show-other-payments-toggle",this.handleDirectToggle),this._contextToggleListener=e=>{this.handleContextToggle(e)},this.setupContextEventListeners()}disconnectedCallback(){this.removeEventListener("click",this.handleSlotButtonClick),this.removeEventListener("primer:show-other-payments-toggle",this.handleDirectToggle),this.cleanupContextEventListeners(),super.disconnectedCallback()}render(){if(this.vaultManager?.isLoading)return y;let e=this.vaultManager?.showEmptyState||this.vaultManager?.vaultedPaymentMethods.length;return!this.vaultManager||!this.vaultManager.enabled||this.vaultManager.headless||!e?p`<slot name="other-payments"></slot>`:p`<div class="other-payment-methods-container"><slot name="show-other-payments-toggle-button" @slotchange=${this.handleToggleSlotChange} ></slot>${R(!this.hasSlottedToggle,()=>p`<primer-collapsable buttonVariant="secondary" .expanded="${this.vaultManager?.vaultedPaymentMethods.length===0}" .header="${S("navigateToPaymentMethods",{id:"navigateToPaymentMethods"})}" ><div class="other-payment-methods-content"><slot name="other-payments"></slot></div></primer-collapsable>`,()=>p`<div class="collapsable-wrapper ${this.isExpanded?"expanded":""}" role="region" aria-labelledby="custom-toggle-button" ><div class="collapsable-content"><div class="other-payment-methods-content"><slot name="other-payments"></slot></div></div></div>`)}</div>`}};Oe.styles=[Pc],d([A({context:be,subscribe:!0}),u({type:Object,attribute:!1})],Oe.prototype,"vaultManager",2),d([A({context:Ye,subscribe:!0}),u({attribute:!1})],Oe.prototype,"contextEventsController",2),d([_e("primer-collapsable")],Oe.prototype,"collapsableElement",2),d([N()],Oe.prototype,"hasSlottedToggle",2),d([N()],Oe.prototype,"isExpanded",2),Oe=d([b("primer-show-other-payments")],Oe);var ha=class extends v{render(){return p`<primer-checkout-state type="complete"></primer-checkout-state>`}};ha=d([b("primer-checkout-complete")],ha);var Wt=class extends v{constructor(){super(...arguments);this.sdkState=null}render(){return p`<primer-checkout-state type="failure" description=${this.sdkState?.primerJsError?.message||""} ></primer-checkout-state>`}};d([A({context:J,subscribe:!0}),u()],Wt.prototype,"sdkState",2),Wt=d([b("primer-checkout-error")],Wt);var Nc=f` :host { display: block; width: 100%; } `;var ht=class extends v{constructor(){super(...arguments);this.showProcessingErrors=!0}get shouldShowError(){return!this.sdkState||this.sdkState.isProcessing?!1:!!(this.sdkState.paymentFailure&&this.showProcessingErrors)}render(){return this.sdkState?p`<primer-error-message message="${S(this.sdkState.paymentFailure?.message??"",{id:"tokenizationError"})}" ?visible="${this.shouldShowError}" ></primer-error-message>`:y}};ht.styles=[Nc],d([A({context:J,subscribe:!0}),N()],ht.prototype,"sdkState",2),d([u({type:Boolean,attribute:"show-processing-errors"})],ht.prototype,"showProcessingErrors",2),ht=d([b("primer-error-message-container")],ht);var Ic=f` :host { display: contents; } .primer-main-list { display: flex; flex-direction: column; gap: var(--primer-space-small); } .primer-is-processing { opacity: 0.5; pointer-events: none; } primer-vault-manager { margin-bottom: var(--primer-space-xlarge); } `;var at=class extends v{constructor(){super(...arguments);this.hasAssignedContent=!1;this.onSlotChange=e=>{let i=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=i.length>0,this.requestUpdate()};this.paymentMethods=null;this.sdkState=null;this.clientOptions=null}render(){return this.sdkState?.isSuccessful?p`<slot name="checkout-complete"><primer-checkout-complete></primer-checkout-complete></slot>`:p`<slot name="payments" @slotchange=${this.onSlotChange}></slot>${R(this.hasAssignedContent,()=>y,()=>p`<div class=${le({"primer-is-processing":!!this.sdkState?.isProcessing})} ><primer-vault-manager></primer-vault-manager><primer-show-other-payments><div slot="other-payments" class="primer-main-list">${this.paymentMethods?.map(e=>p`<primer-payment-method type=${e.type} ?disabled=${this.clientOptions?.disabledPayments===!0} ></primer-payment-method>`)}</div></primer-show-other-payments><primer-error-message-container></primer-error-message-container></div>`)} `}};at.styles=[I,Ic],d([A({context:vt,subscribe:!0}),u()],at.prototype,"paymentMethods",2),d([A({context:J,subscribe:!0}),u()],at.prototype,"sdkState",2),d([A({context:se,subscribe:!0}),u()],at.prototype,"clientOptions",2),at=d([b("primer-main")],at);function dG(){dl(),cl()}export{Ie as AchPayment,Qe as ApplePay,ce as BillingAddress,Ee as Blik,Ae as Button,oe as CardForm,ut as CardFormCVV,fe as CardFormCardNetworkSelector,ct as CardFormCardNumber,st as CardFormError,pt as CardFormExpiry,mt as CardFormName,ae as CardFormSubmit,Me as Collapsable,Ve as Dialog,De as DynamicPayment,Je as ErrorMessage,ht as ErrorMessageContainer,qe as GooglePay,Y as Input,ot as InputLabel,We as InputWrapper,Xe as PayPal,Ue as PaymentMethod,we as PaymentMethodContainer,tt as PaymentMethodContentComponent,Et as Portal,ie as PortalDialog,ha as PrimerCheckoutComplete,Ne as PrimerCheckoutComponent,Wt as PrimerCheckoutFailure,lt as PrimerCheckoutState,Ze as PrimerIcon,de as PrimerKlarna,at as PrimerMain,ke as RedirectPayment,Ce as Select,Oe as ShowOtherPayments,je as Spinner,te as VaultCvvInput,Le as VaultDeleteConfirmation,dt as VaultEmptyState,et as VaultErrorMessage,ee as VaultManager,He as VaultManagerHeader,Te as VaultPaymentMethodItem,ne as VaultPaymentSubmit,Fm as injectDarkTheme,Km as injectLightTheme,dl as injectLoaderStyles,cl as injectThemeStyles,dG as loadPrimer};
|
package/dist/web-types.json
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@primer-io/primer-js",
|
|
3
3
|
"description": "Primer Checkout is a web component-based SDK for building secure, customizable, and PCI-compliant checkout experiences. Designed with a modular architecture, it integrates seamlessly with any JavaScript framework and supports multiple payment methods.",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.6",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/primer-loader.js",
|
|
8
8
|
"types": "./dist/primer-loader.d.ts",
|