@primer-io/primer-js 0.3.2 → 0.3.3

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.
@@ -1,4 +1,4 @@
1
- import{a as xi,b as d,c as N}from"./chunks/chunk.DV3REKZU.js";import{createComponent as Us}from"@lit/react";import Hs from"react";var $t=class{constructor(t){(this.host=t).addController(this)}hostConnected(){}setCardNetworksLoading(){let t={detectedCardNetwork:null,selectableCardNetworks:[],isLoading:!0};this.updateCardNetworksState(t)}updateCardNetworksState(t){this.host.primerEventsController.dispatchCardNetworkChange(t),this.host.sdkContextController.setCardNetworks(t)}processCardNetworkChangeEvent(t){let{detectedCardNetworks:e,selectableCardNetworks:r}=t,o=e.preferred??e.items[0],a=r?.items??[];this.updateCardNetworksState({detectedCardNetwork:o,selectableCardNetworks:a,isLoading:!1})}};var tt=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)}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})}};var xe=class extends Event{constructor(t,e,r,o){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e,this.callback=r,this.subscribe=o??!1}};var rt=class{constructor(t,e,r,o){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(a,n)=>{this.unsubscribe&&(this.unsubscribe!==n&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=a,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(a,n)),this.unsubscribe=n},this.host=t,e.context!==void 0){let a=e;this.context=a.context,this.callback=a.callback,this.subscribe=a.subscribe??!1}else this.context=e,this.callback=r,this.subscribe=o??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new xe(this.context,this.host,this.t,this.subscribe))}};var Yt=class{get value(){return this.o}set value(t){this.setValue(t)}setValue(t,e=!1){let r=e||!Object.is(t,this.o);this.o=t,r&&this.updateObservers()}constructor(t){this.subscriptions=new Map,this.updateObservers=()=>{for(let[e,{disposer:r}]of this.subscriptions)e(this.o,r)},t!==void 0&&(this.value=t)}addCallback(t,e,r){if(!r)return void t(this.value);this.subscriptions.has(t)||this.subscriptions.set(t,{disposer:()=>{this.subscriptions.delete(t)},consumerHost:e});let{disposer:o}=this.subscriptions.get(t);t(this.value,o)}clearCallbacks(){this.subscriptions.clear()}};var Dr=class extends Event{constructor(t,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e}},U=class extends Yt{constructor(t,e,r){super(e.context!==void 0?e.initialValue:r),this.onContextRequest=o=>{if(o.context!==this.context)return;let a=o.contextTarget??o.composedPath()[0];a!==this.host&&(o.stopPropagation(),this.addCallback(o.callback,a,o.subscribe))},this.onProviderRequest=o=>{if(o.context!==this.context||(o.contextTarget??o.composedPath()[0])===this.host)return;let a=new Set;for(let[n,{consumerHost:s}]of this.subscriptions)a.has(n)||(a.add(n),s.dispatchEvent(new xe(this.context,s,n,!0)));o.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 Dr(this.context,this.host))}};function C({context:i,subscribe:t}){return(e,r)=>{typeof r=="object"?r.addInitializer(function(){new rt(this,{context:i,callback:o=>{e.set.call(this,o)},subscribe:t})}):e.constructor.addInitializer(o=>{new rt(o,{context:i,callback:a=>{o[r]=a},subscribe:t})})}}var Vt="cardNetworksContext";var Pe="clientOptionsContext";var it="computedStylesContext";var K="headlessInstanceContext";var Ut="klarnaCategoriesContext";var G="managerContext";var ot="paymentMethodsContext";var V="sdkStateContext";var at="vaultManagerContext";var Ht="vaultManagerCvvContext";var Y=class Y{static log(t,...e){Y.enabled}static info(t,...e){Y.enabled}static warn(t,...e){Y.enabled}static error(t,...e){Y.enabled}static debug(t,...e){Y.enabled}static table(t,e){Y.enabled}static time(t){Y.enabled}static timeEnd(t){Y.enabled}};Y.enabled=!0,Y.defaultFont="font-family: Consolas, monospace; font-size: 12px;",Y.brandTag="[PRIMER]",Y.brandStyle=`background: #24292e; color: #ffffff; padding: 2px 6px; border-radius: 3px; font-weight: bold; margin-right: 4px; ${Y.defaultFont}`,Y.styles={log:`color: #4CAF50; ${Y.defaultFont}`,info:`color: #2196F3; ${Y.defaultFont}`,warn:`color: #FF9800; ${Y.defaultFont}`,error:`color: #F44336; ${Y.defaultFont}`,debug:`color: #9C27B0; ${Y.defaultFont}`};var A=Y;function Wa(i,t,e,r){let o=i,a=e;return{dispatch:n=>{let s=t(o,n,a);o=s,r(s)},getState:()=>Object.freeze({...o}),setCallbacks:n=>{a={...a,...n}}}}function gt(i){return(t,e,r)=>{let o=i[e.type];if(!o)throw new Error(`No handler for action type: ${e.type}`);return o(t,e,r)}}var $e=class{constructor(t,e,r,o,a=()=>{this.host.requestUpdate()}){this.host=t;this.stateHandler=a;this.host.addController(this),this._dispatcher=Wa(e,r,o,n=>{this.stateHandler(n)})}get currentState(){return this._dispatcher.getState()}dispatch(t){this._dispatcher.dispatch(t)}setCallbacks(t){this._dispatcher.setCallbacks(t)}hostConnected(){}hostDisconnected(){}},Bt=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 Ft={isSuccessful:!1,isProcessing:!1,isLoading:!1,error:null,failure:null},Ja={START_LOADING:i=>({...i,isLoading:!0}),START_PROCESSING:i=>({...i,failure:null,isProcessing:!0}),STOP_PROCESSING:i=>({...i,isProcessing:!1}),COMPLETE_PROCESSING:i=>({...i,isProcessing:!1,isSuccessful:!0}),SET_ERROR:(i,t)=>(A.error(t.payload.message),{...i,isProcessing:!1,error:t.payload}),SET_FAILURE:(i,t)=>({...i,isProcessing:!1,failure:t.payload}),COMPLETE_LOADING:i=>({...i,isLoading:!1}),RESET:()=>Ft,RESET_ERROR:i=>({...i,error:null,failure:null})},Za=gt(Ja),zt=class extends $e{constructor(t){super(t,Ft,Za,null,e=>{t.sdkContextController.setSdkState(e),t.primerEventsController.dispatchSdkState(e)})}startLoading(){this.dispatch({type:"START_LOADING"})}startProcessing(){this.dispatch({type:"START_PROCESSING"})}stopProcessing(){this.dispatch({type:"STOP_PROCESSING"})}completeProcessing(){this.dispatch({type:"COMPLETE_PROCESSING"})}completeLoading(){this.dispatch({type:"COMPLETE_LOADING"})}setError(t){this.dispatch({type:"SET_ERROR",payload:t})}setFailure(t,e,r){this.dispatch({type:"SET_FAILURE",payload:{code:t,message:e,details:r}})}reset(){this.dispatch({type:"RESET"})}resetError(){this.dispatch({type:"RESET_ERROR"})}forceCompleteLoading(){this.currentState.isLoading&&(A.warn("Force completing loading state"),this.completeLoading())}};var jt=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.klarnaCategoriesProvider=null;this.computedStylesProvider=null;(this.host=t).addController(this),this.sdkStateProvider=new U(t,{context:V,initialValue:Ft}),this.paymentMethodsProvider=new U(t,{context:ot,initialValue:null}),this.paymentManagerProvider=new U(t,{context:G,initialValue:new Map}),this.cardNetworksContext=new U(t,{context:Vt,initialValue:null}),this.vaultManagerProvider=new U(t,{context:at,initialValue:null}),this.vaultManagerCvvProvider=new U(t,{context:Ht,initialValue:null}),this.clientOptionsContext=new U(t,{context:Pe,initialValue:null}),this.klarnaCategoriesProvider=new U(t,{context:Ut,initialValue:{categories:[],isLoading:!0}}),this.headlessUtilsProvider=new U(t,{context:K,initialValue:null}),this.computedStylesProvider=new U(t,{context:it,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)}setVaultManager(t){this.vaultManagerProvider?.setValue(t)}setKlarnaCategories(t){this.klarnaCategoriesProvider?.setValue(t)}setClientOptions(t){this.clientOptionsContext?.setValue(t)}setHeadlessUtils(t){this.headlessUtilsProvider?.setValue(t)}setComputedStyles(t){this.computedStylesProvider?.setValue(t)}setVaultManagerCvv(t){this.vaultManagerCvvProvider?.setValue(t)}};var Ye=class Ye{constructor(t){(this.host=t).addController(this)}processCustomStyles(t){try{let e=JSON.parse(t);this.applyStyles(e)}catch(e){A.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 r=/^[\w\s#.,%()\-+/!]+$/.test(t);return r||A.warn(`Rejected potentially unsafe CSS value: ${t}`),r}getCssVarName(t){let e=Ye.cssVarCache.get(t);return e||(e=`--${t.replace(/([A-Z])/g,(r,o)=>`-${o.toLowerCase()}`)}`,Ye.cssVarCache.set(t,e)),e}applyStyles(t){let e=[];for(let r of Object.keys(t)){let o=t[r];if(!o)continue;if(!this.isValidCssProperty(r)){A.warn(`Skipping invalid CSS property name: ${r}`);continue}if(!this.isValidCssValue(o))continue;let a=this.getCssVarName(r);e.push([a,o])}if(e.length>0)for(let[r,o]of e)this.host.style.setProperty(r,o)}removeStyle(t){let e=this.getCssVarName(t);this.host.style.removeProperty(e)}clearAllStyles(){for(let t of Ye.cssVarCache.keys()){let e=Ye.cssVarCache.get(t);e&&this.host.style.removeProperty(e)}}hostDisconnected(){}};Ye.cssVarCache=new Map;var Kt=Ye;var Gt=globalThis,Wt=Gt.ShadowRoot&&(Gt.ShadyCSS===void 0||Gt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,wi=Symbol(),Pi=new WeakMap,qt=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==wi)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(Wt&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=Pi.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&Pi.set(e,t))}return t}toString(){return this.cssText}},Mi=i=>new qt(typeof i=="string"?i:i+"",void 0,wi);var $r=(i,t)=>{if(Wt)i.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of t){let r=document.createElement("style"),o=Gt.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=e.cssText,i.appendChild(r)}},Jt=Wt?i=>i:i=>i instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return Mi(e)})(i):i;var{is:Xa,defineProperty:Qa,getOwnPropertyDescriptor:en,getOwnPropertyNames:tn,getOwnPropertySymbols:rn,getPrototypeOf:on}=Object,we=globalThis,Ti=we.trustedTypes,an=Ti?Ti.emptyScript:"",nn=we.reactiveElementPolyfillSupport,vt=(i,t)=>i,Yr={toAttribute(i,t){switch(t){case Boolean:i=i?an:null;break;case Object:case Array:i=i==null?i:JSON.stringify(i)}return i},fromAttribute(i,t){let e=i;switch(t){case Boolean:e=i!==null;break;case Number:e=i===null?null:Number(i);break;case Object:case Array:try{e=JSON.parse(i)}catch{e=null}}return e}},Zt=(i,t)=>!Xa(i,t),ki={attribute:!0,type:String,converter:Yr,reflect:!1,hasChanged:Zt};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),we.litPropertyMetadata??(we.litPropertyMetadata=new WeakMap);var Ve=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=ki){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){let r=Symbol(),o=this.getPropertyDescriptor(t,r,e);o!==void 0&&Qa(this.prototype,t,o)}}static getPropertyDescriptor(t,e,r){let{get:o,set:a}=en(this.prototype,t)??{get(){return this[e]},set(n){this[e]=n}};return{get(){return o?.call(this)},set(n){let s=o?.call(this);a.call(this,n),this.requestUpdate(t,s,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??ki}static _$Ei(){if(this.hasOwnProperty(vt("elementProperties")))return;let t=on(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(vt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(vt("properties"))){let e=this.properties,r=[...tn(e),...rn(e)];for(let o of r)this.createProperty(o,e[o])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[r,o]of e)this.elementProperties.set(r,o)}this._$Eh=new Map;for(let[e,r]of this.elementProperties){let o=this._$Eu(e,r);o!==void 0&&this._$Eh.set(o,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let o of r)e.unshift(Jt(o))}else t!==void 0&&e.push(Jt(t));return e}static _$Eu(t,e){let r=e.attribute;return r===!1?void 0:typeof r=="string"?r: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 r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return $r(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,r){this._$AK(t,r)}_$EC(t,e){let r=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,r);if(o!==void 0&&r.reflect===!0){let a=(r.converter?.toAttribute!==void 0?r.converter:Yr).toAttribute(e,r.type);this._$Em=t,a==null?this.removeAttribute(o):this.setAttribute(o,a),this._$Em=null}}_$AK(t,e){let r=this.constructor,o=r._$Eh.get(t);if(o!==void 0&&this._$Em!==o){let a=r.getPropertyOptions(o),n=typeof a.converter=="function"?{fromAttribute:a.converter}:a.converter?.fromAttribute!==void 0?a.converter:Yr;this._$Em=o,this[o]=n.fromAttribute(e,a.type),this._$Em=null}}requestUpdate(t,e,r){if(t!==void 0){if(r??(r=this.constructor.getPropertyOptions(t)),!(r.hasChanged??Zt)(this[t],e))return;this.P(t,e,r)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,r){this._$AL.has(t)||this._$AL.set(t,e),r.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[o,a]of this._$Ep)this[o]=a;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[o,a]of r)a.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.P(o,this[o],a)}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(e)):this._$EU()}catch(r){throw t=!1,this._$EU(),r}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){}};Ve.elementStyles=[],Ve.shadowRootOptions={mode:"open"},Ve[vt("elementProperties")]=new Map,Ve[vt("finalized")]=new Map,nn?.({ReactiveElement:Ve}),(we.reactiveElementVersions??(we.reactiveElementVersions=[])).push("2.0.4");var Me={INITIAL:0,PENDING:1,COMPLETE:2,ERROR:3},M=Symbol(),L=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,r){this.p=0,this.i=0,(this._=t).addController(this);let o=typeof e=="object"?e:{task:e,args:r};this.v=o.task,this.j=o.args,this.m=o.argsEqual??Ii,this.k=o.onComplete,this.A=o.onError,this.autoRun=o.autoRun??!0,"initialValue"in o&&(this.u=o.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,r;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 o=++this.p;this.q=new AbortController;let a=!1;try{e=await this.v(t,{signal:this.q.signal})}catch(n){a=!0,r=n}if(this.p===o){if(e===M)this.i=0;else{if(a===!1){try{this.k?.(e)}catch{}this.i=2,this.o?.(e)}else{try{this.A?.(r)}catch{}this.i=3,this.h?.(r)}this.u=e,this.l=r}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)}}},Ii=(i,t)=>i===t||i.length===t.length&&i.every((e,r)=>!Zt(e,t[r]));var sn={SET_LOADING:(i,t)=>({...i,isLoading:t.payload}),SET_UPDATING:(i,t)=>({...i,isUpdating:t.payload}),INITIALIZE_VAULT_MANAGER:(i,t,e)=>({...i,enabled:t.vaultEnabled,cvvRecapture:t.cvvRecapture,showEmptyState:t.showEmptyState,deleteVaultedPaymentMethod:e.deleteVaultedPaymentMethod,startVaultedPaymentFlow:e.startVaultedPaymentFlow,createCvvInput:e.createCvvInput}),UPDATE_PAYMENT_METHODS:(i,t)=>({...i,vaultedPaymentMethods:t.payload,isLoading:!1,isUpdating:!1}),SET_ERROR:i=>({...i,isLoading:!1,isUpdating:!1}),DISABLE:i=>({...i,enabled:!1}),RESET:()=>Ni},ln={INITIALIZE_CVV:(i,t,e)=>({...i,setCvvInput:e.setCvvInput,setSelectedVaultedPaymentMethod:e.setSelectedVaultedPaymentMethod}),SET_FORM_DIRTY:(i,t)=>({...i,formIsDirty:t.payload}),SET_CVV_INPUT:(i,t)=>({...i,cvvInput:t.payload}),SET_SELECTED_VAULTED_PAYMENT_METHOD:(i,t)=>({...i,selectedVaultedPaymentMethod:t.payload}),RESET_CVV:()=>Li},dn=gt(sn),cn=gt(ln),Ni={enabled:!1,isLoading:!1,isUpdating:!1,cvvRecapture:!1,showEmptyState:!0,vaultedPaymentMethods:[],createCvvInput:null,deleteVaultedPaymentMethod:()=>Promise.resolve(),startVaultedPaymentFlow:()=>Promise.resolve()},Li={cvvInput:null,formIsDirty:!1,setCvvInput:()=>{},selectedVaultedPaymentMethod:null,setSelectedVaultedPaymentMethod:()=>{}},Vr=class extends $e{constructor(t,e){super(t,Ni,dn,e,r=>{t.sdkContextController.setVaultManager(r)})}setLoading(t){this.dispatch({type:"SET_LOADING",payload:t})}setUpdating(t){this.dispatch({type:"SET_UPDATING",payload:t})}initializeVaultManager(t,e,r,o){this.dispatch({type:"INITIALIZE_VAULT_MANAGER",payload:t,vaultEnabled:e,cvvRecapture:r,showEmptyState:o})}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"})}},Ur=class extends $e{constructor(t,e){super(t,Li,cn,e,r=>{t.sdkContextController.setVaultManagerCvv(r)})}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"})}},bt=class extends Bt{constructor(e){super(e);this._vaultManager=null;this._options=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(r){throw this.coreController.setError(r instanceof Error?r:new Error("Failed to delete payment method")),r}};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,r=this.vaultManagerState.cvvRecapture,o=this.vaultItemState.cvvInput;if(!e||r&&(!o||o.metadata.error)){this.itemController.setFormDirty(!0);return}this.host.sdkStateController.startProcessing();try{await this._vaultManager.startPaymentFlow(e.id,r?{cvv:o.valueToken}:void 0)}catch(a){A.error("VaultManagerController: Error starting vaulted payment flow",a),this.coreController.setError(a instanceof Error?a:new Error("Failed to start vaulted payment flow")),this.host.sdkStateController.stopProcessing()}};this.setSelectedVaultedPaymentMethod=e=>{this.itemController.setSelectedPaymentMethod(e),this.itemController.setFormDirty(!1)};this.coreController=new Vr(e,{deleteVaultedPaymentMethod:this.deleteVaultedPaymentMethod.bind(this),startVaultedPaymentFlow:this.startVaultedPaymentFlow.bind(this),createCvvInput:this.createCvvInput}),this.itemController=new Ur(e,{setCvvInput:this.setCvvInput.bind(this),setSelectedVaultedPaymentMethod:this.setSelectedVaultedPaymentMethod.bind(this)}),this.addController(this.coreController),this.addController(this.itemController),new L(this.host,{task:async([r,o])=>{if(!r||!o?.vaultEnabled)return this.coreController.disable(),M;this.coreController.setLoading(!0);try{this.coreController.initializeVaultManager(r,o.vaultEnabled,!!o.captureVaultedCardCvv,o.showEmptyState??!0),this.itemController.initializeCvv(r.createCvvInput),await this.fetchVaultedPaymentMethods(!0),A.log("VaultManagerController: Vault initialized successfully",{coreState:this.coreController.currentState,cvvState:this.itemController.currentState})}catch(a){A.error("VaultManagerController: Failed to initialize vault",a),this.coreController.setError(a instanceof Error?a:new Error("Unknown error"))}return this._vaultManager},args:()=>[this.vaultManager,this.options]})}initializeVaultManager(e,r){this.vaultManager=e,this.options=r??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()}async fetchVaultedPaymentMethods(e){if(!this._vaultManager)throw new Error("Vault manager not initialized");try{e||this.coreController.setUpdating(!0);let r=await this._vaultManager.fetchVaultedPaymentMethods();return A.log("VaultManagerController: Fetched payment methods",r),this.coreController.updatePaymentMethods(r),r}catch(r){throw this.coreController.setError(r instanceof Error?r:new Error("Failed to fetch payment methods")),r}}};var Ct="lit-localize-status";var Oi=i=>typeof i!="string"&&"strTag"in i,Xt=(i,t,e)=>{let r=i[0];for(let o=1;o<i.length;o++)r+=t[e?e[o-1]:o-1],r+=i[o];return r};var Et=i=>Oi(i)?Xt(i.strings,i.values):i;var x=Et,Ri=!1;function Hr(i){if(Ri)throw new Error("lit-localize can only be configured once");x=i,Ri=!0}var Br=class{constructor(t){this.__litLocalizeEventHandler=e=>{e.detail.status==="ready"&&this.host.requestUpdate()},this.host=t}hostConnected(){window.addEventListener(Ct,this.__litLocalizeEventHandler)}hostDisconnected(){window.removeEventListener(Ct,this.__litLocalizeEventHandler)}},pn=i=>i.addController(new Br(i)),Di=pn;var R=()=>(i,t)=>(i.addInitializer(Di),i);var At=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 fe=[];for(let i=0;i<256;i++)fe[i]=(i>>4&15).toString(16)+(i&15).toString(16);function $i(i){let t=0,e=8997,r=0,o=33826,a=0,n=40164,s=0,l=52210;for(let c=0;c<i.length;c++)e^=i.charCodeAt(c),t=e*435,r=o*435,a=n*435,s=l*435,a+=e<<8,s+=o<<8,r+=t>>>16,e=t&65535,a+=r>>>16,o=r&65535,l=s+(a>>>16)&65535,n=a&65535;return fe[l>>8]+fe[l&255]+fe[n>>8]+fe[n&255]+fe[o>>8]+fe[o&255]+fe[e>>8]+fe[e&255]}var un="",mn="h",hn="s";function Yi(i,t){return(t?mn:hn)+$i(typeof i=="string"?i:i.join(un))}var Vi=new WeakMap,Ui=new Map;function Hi(i,t,e){if(i){let r=e?.id??fn(t),o=i[r];if(o){if(typeof o=="string")return o;if("strTag"in o)return Xt(o.strings,t.values,o.values);{let a=Vi.get(o);return a===void 0&&(a=o.values,Vi.set(o,a)),{...o,values:a.map(n=>t.values[n])}}}}return Et(t)}function fn(i){let t=typeof i=="string"?i:i.strings,e=Ui.get(t);return e===void 0&&(e=Yi(t,typeof i!="string"&&!("strTag"in i)),Ui.set(t,e)),e}function zr(i){window.dispatchEvent(new CustomEvent(Ct,{detail:i}))}var er="",Fr,Bi,tr,jr,zi,Ue=new At;Ue.resolve();var Qt=0,Fi=i=>(Hr((t,e)=>Hi(zi,t,e)),er=Bi=i.sourceLocale,tr=new Set(i.targetLocales),tr.add(i.sourceLocale),jr=i.loadLocale,{getLocale:yn,setLocale:gn}),yn=()=>er,gn=i=>{if(i===(Fr??er))return Ue.promise;if(!tr||!jr)throw new Error("Internal error");if(!tr.has(i))throw new Error("Invalid locale code");Qt++;let t=Qt;return Fr=i,Ue.settled&&(Ue=new At),zr({status:"loading",loadingLocale:i}),(i===Bi?Promise.resolve({templates:void 0}):jr(i)).then(r=>{Qt===t&&(er=i,Fr=void 0,zi=r.templates,zr({status:"ready",readyLocale:i}),Ue.resolve())},r=>{Qt===t&&(zr({status:"error",errorLocale:i,errorMessage:r.toString()}),Ue.reject(r))}),Ue.promise};var Kr="en",Gr=["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"],ji="You must call `loadLocale` first to set up the localized template.",Ki,rr,Gi=i=>{let t=Fi({sourceLocale:Kr,targetLocales:Gr,loadLocale:i});Ki=t.getLocale,rr=t.setLocale};var qr=i=>{Gi(i)},Wr=i=>{if(!rr)throw new Error(ji);return rr(i)};var _t=new Set(Gr);_t.add(Kr);var Jr=i=>{if(typeof i!="string")return!1;if(i==="en")return!0;let t=i.replace("_","-");if(_t.has(t))return!0;let e=t.split("-")[0];return!!_t.has(e)},Zr=i=>{if(i==="en")return"en-GB";let t=i.replace("_","-");if(_t.has(t))return t;let e=t.split("-")[0];return _t.has(e)?e:"en-GB"};var ir=globalThis,or=ir.ShadowRoot&&(ir.ShadyCSS===void 0||ir.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Xr=Symbol(),qi=new WeakMap,St=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==Xr)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(or&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=qi.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&qi.set(e,t))}return t}toString(){return this.cssText}},ae=i=>new St(typeof i=="string"?i:i+"",void 0,Xr),g=(i,...t)=>{let e=i.length===1?i[0]:t.reduce((r,o,a)=>r+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+i[a+1],i[0]);return new St(e,i,Xr)},Wi=(i,t)=>{if(or)i.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of t){let r=document.createElement("style"),o=ir.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=e.cssText,i.appendChild(r)}},Qr=or?i=>i:i=>i instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return ae(e)})(i):i;var{is:vn,defineProperty:bn,getOwnPropertyDescriptor:Cn,getOwnPropertyNames:En,getOwnPropertySymbols:An,getPrototypeOf:_n}=Object,Te=globalThis,Ji=Te.trustedTypes,Sn=Ji?Ji.emptyScript:"",xn=Te.reactiveElementPolyfillSupport,xt=(i,t)=>i,Pt={toAttribute(i,t){switch(t){case Boolean:i=i?Sn:null;break;case Object:case Array:i=i==null?i:JSON.stringify(i)}return i},fromAttribute(i,t){let e=i;switch(t){case Boolean:e=i!==null;break;case Number:e=i===null?null:Number(i);break;case Object:case Array:try{e=JSON.parse(i)}catch{e=null}}return e}},ar=(i,t)=>!vn(i,t),Zi={attribute:!0,type:String,converter:Pt,reflect:!1,useDefault:!1,hasChanged:ar};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Te.litPropertyMetadata??(Te.litPropertyMetadata=new WeakMap);var ye=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=Zi){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 r=Symbol(),o=this.getPropertyDescriptor(t,r,e);o!==void 0&&bn(this.prototype,t,o)}}static getPropertyDescriptor(t,e,r){let{get:o,set:a}=Cn(this.prototype,t)??{get(){return this[e]},set(n){this[e]=n}};return{get:o,set(n){let s=o?.call(this);a?.call(this,n),this.requestUpdate(t,s,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Zi}static _$Ei(){if(this.hasOwnProperty(xt("elementProperties")))return;let t=_n(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(xt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(xt("properties"))){let e=this.properties,r=[...En(e),...An(e)];for(let o of r)this.createProperty(o,e[o])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[r,o]of e)this.elementProperties.set(r,o)}this._$Eh=new Map;for(let[e,r]of this.elementProperties){let o=this._$Eu(e,r);o!==void 0&&this._$Eh.set(o,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let o of r)e.unshift(Qr(o))}else t!==void 0&&e.push(Qr(t));return e}static _$Eu(t,e){let r=e.attribute;return r===!1?void 0:typeof r=="string"?r: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 r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Wi(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,r){this._$AK(t,r)}_$ET(t,e){let r=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,r);if(o!==void 0&&r.reflect===!0){let a=(r.converter?.toAttribute!==void 0?r.converter:Pt).toAttribute(e,r.type);this._$Em=t,a==null?this.removeAttribute(o):this.setAttribute(o,a),this._$Em=null}}_$AK(t,e){let r=this.constructor,o=r._$Eh.get(t);if(o!==void 0&&this._$Em!==o){let a=r.getPropertyOptions(o),n=typeof a.converter=="function"?{fromAttribute:a.converter}:a.converter?.fromAttribute!==void 0?a.converter:Pt;this._$Em=o,this[o]=n.fromAttribute(e,a.type)??this._$Ej?.get(o)??null,this._$Em=null}}requestUpdate(t,e,r){if(t!==void 0){let o=this.constructor,a=this[t];if(r??(r=o.getPropertyOptions(t)),!((r.hasChanged??ar)(a,e)||r.useDefault&&r.reflect&&a===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,r))))return;this.C(t,e,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:r,reflect:o,wrapped:a},n){r&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,n??e??this[t]),a!==!0||n!==void 0)||(this._$AL.has(t)||(this.hasUpdated||r||(e=void 0),this._$AL.set(t,e)),o===!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[o,a]of this._$Ep)this[o]=a;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[o,a]of r){let{wrapped:n}=a,s=this[o];n!==!0||this._$AL.has(o)||s===void 0||this.C(o,void 0,a,s)}}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(e)):this._$EM()}catch(r){throw t=!1,this._$EM(),r}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){}};ye.elementStyles=[],ye.shadowRootOptions={mode:"open"},ye[xt("elementProperties")]=new Map,ye[xt("finalized")]=new Map,xn?.({ReactiveElement:ye}),(Te.reactiveElementVersions??(Te.reactiveElementVersions=[])).push("2.1.0");var Mt=globalThis,nr=Mt.trustedTypes,Xi=nr?nr.createPolicy("lit-html",{createHTML:i=>i}):void 0,ti="$lit$",ge=`lit$${Math.random().toFixed(9).slice(2)}$`,ri="?"+ge,Pn=`<${ri}>`,ze=document,Tt=()=>ze.createComment(""),kt=i=>i===null||typeof i!="object"&&typeof i!="function",ii=Array.isArray,oo=i=>ii(i)||typeof i?.[Symbol.iterator]=="function",ei=`[
1
+ import{a as xi,b as d,c as N}from"./chunks/chunk.DV3REKZU.js";import{createComponent as Us}from"@lit/react";import Hs from"react";var $t=class{constructor(t){(this.host=t).addController(this)}hostConnected(){}setCardNetworksLoading(){let t={detectedCardNetwork:null,selectableCardNetworks:[],isLoading:!0};this.updateCardNetworksState(t)}updateCardNetworksState(t){this.host.primerEventsController.dispatchCardNetworkChange(t),this.host.sdkContextController.setCardNetworks(t)}processCardNetworkChangeEvent(t){let{detectedCardNetworks:e,selectableCardNetworks:r}=t,o=e.preferred??e.items[0],a=r?.items??[];this.updateCardNetworksState({detectedCardNetwork:o,selectableCardNetworks:a,isLoading:!1})}};var tt=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)}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})}};var xe=class extends Event{constructor(t,e,r,o){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e,this.callback=r,this.subscribe=o??!1}};var rt=class{constructor(t,e,r,o){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(a,n)=>{this.unsubscribe&&(this.unsubscribe!==n&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=a,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(a,n)),this.unsubscribe=n},this.host=t,e.context!==void 0){let a=e;this.context=a.context,this.callback=a.callback,this.subscribe=a.subscribe??!1}else this.context=e,this.callback=r,this.subscribe=o??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new xe(this.context,this.host,this.t,this.subscribe))}};var Yt=class{get value(){return this.o}set value(t){this.setValue(t)}setValue(t,e=!1){let r=e||!Object.is(t,this.o);this.o=t,r&&this.updateObservers()}constructor(t){this.subscriptions=new Map,this.updateObservers=()=>{for(let[e,{disposer:r}]of this.subscriptions)e(this.o,r)},t!==void 0&&(this.value=t)}addCallback(t,e,r){if(!r)return void t(this.value);this.subscriptions.has(t)||this.subscriptions.set(t,{disposer:()=>{this.subscriptions.delete(t)},consumerHost:e});let{disposer:o}=this.subscriptions.get(t);t(this.value,o)}clearCallbacks(){this.subscriptions.clear()}};var Dr=class extends Event{constructor(t,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e}},U=class extends Yt{constructor(t,e,r){super(e.context!==void 0?e.initialValue:r),this.onContextRequest=o=>{if(o.context!==this.context)return;let a=o.contextTarget??o.composedPath()[0];a!==this.host&&(o.stopPropagation(),this.addCallback(o.callback,a,o.subscribe))},this.onProviderRequest=o=>{if(o.context!==this.context||(o.contextTarget??o.composedPath()[0])===this.host)return;let a=new Set;for(let[n,{consumerHost:s}]of this.subscriptions)a.has(n)||(a.add(n),s.dispatchEvent(new xe(this.context,s,n,!0)));o.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 Dr(this.context,this.host))}};function C({context:i,subscribe:t}){return(e,r)=>{typeof r=="object"?r.addInitializer(function(){new rt(this,{context:i,callback:o=>{e.set.call(this,o)},subscribe:t})}):e.constructor.addInitializer(o=>{new rt(o,{context:i,callback:a=>{o[r]=a},subscribe:t})})}}var Vt="cardNetworksContext";var Pe="clientOptionsContext";var it="computedStylesContext";var K="headlessInstanceContext";var Ut="klarnaCategoriesContext";var G="managerContext";var ot="paymentMethodsContext";var V="sdkStateContext";var at="vaultManagerContext";var Ht="vaultManagerCvvContext";var Y=class Y{static log(t,...e){Y.enabled}static info(t,...e){Y.enabled}static warn(t,...e){Y.enabled}static error(t,...e){Y.enabled}static debug(t,...e){Y.enabled}static table(t,e){Y.enabled}static time(t){Y.enabled}static timeEnd(t){Y.enabled}};Y.enabled=!0,Y.defaultFont="font-family: Consolas, monospace; font-size: 12px;",Y.brandTag="[PRIMER]",Y.brandStyle=`background: #24292e; color: #ffffff; padding: 2px 6px; border-radius: 3px; font-weight: bold; margin-right: 4px; ${Y.defaultFont}`,Y.styles={log:`color: #4CAF50; ${Y.defaultFont}`,info:`color: #2196F3; ${Y.defaultFont}`,warn:`color: #FF9800; ${Y.defaultFont}`,error:`color: #F44336; ${Y.defaultFont}`,debug:`color: #9C27B0; ${Y.defaultFont}`};var A=Y;function Wa(i,t,e,r){let o=i,a=e;return{dispatch:n=>{let s=t(o,n,a);o=s,r(s)},getState:()=>Object.freeze({...o}),setCallbacks:n=>{a={...a,...n}}}}function gt(i){return(t,e,r)=>{let o=i[e.type];if(!o)throw new Error(`No handler for action type: ${e.type}`);return o(t,e,r)}}var $e=class{constructor(t,e,r,o,a=()=>{this.host.requestUpdate()}){this.host=t;this.stateHandler=a;this.host.addController(this),this._dispatcher=Wa(e,r,o,n=>{this.stateHandler(n)})}get currentState(){return this._dispatcher.getState()}dispatch(t){this._dispatcher.dispatch(t)}setCallbacks(t){this._dispatcher.setCallbacks(t)}hostConnected(){}hostDisconnected(){}},Bt=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 Ft={isSuccessful:!1,isProcessing:!1,isLoading:!1,error:null,failure:null},Ja={START_LOADING:i=>({...i,isLoading:!0}),START_PROCESSING:i=>({...i,failure:null,isProcessing:!0}),STOP_PROCESSING:i=>({...i,isProcessing:!1}),COMPLETE_PROCESSING:i=>({...i,isProcessing:!1,isSuccessful:!0}),SET_ERROR:(i,t)=>(A.error(t.payload.message),{...i,isProcessing:!1,error:t.payload}),SET_FAILURE:(i,t)=>({...i,isProcessing:!1,failure:t.payload}),COMPLETE_LOADING:i=>({...i,isLoading:!1}),RESET:()=>Ft,RESET_ERROR:i=>({...i,error:null,failure:null})},Za=gt(Ja),zt=class extends $e{constructor(t){super(t,Ft,Za,null,e=>{t.sdkContextController.setSdkState(e),t.primerEventsController.dispatchSdkState(e)})}startLoading(){this.dispatch({type:"START_LOADING"})}startProcessing(){this.dispatch({type:"START_PROCESSING"})}stopProcessing(){this.dispatch({type:"STOP_PROCESSING"})}completeProcessing(){this.dispatch({type:"COMPLETE_PROCESSING"})}completeLoading(){this.dispatch({type:"COMPLETE_LOADING"})}setError(t){this.dispatch({type:"SET_ERROR",payload:t})}setFailure(t,e,r){this.dispatch({type:"SET_FAILURE",payload:{code:t,message:e,details:r}})}reset(){this.dispatch({type:"RESET"})}resetError(){this.dispatch({type:"RESET_ERROR"})}forceCompleteLoading(){this.currentState.isLoading&&(A.warn("Force completing loading state"),this.completeLoading())}};var jt=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.klarnaCategoriesProvider=null;this.computedStylesProvider=null;(this.host=t).addController(this),this.sdkStateProvider=new U(t,{context:V,initialValue:Ft}),this.paymentMethodsProvider=new U(t,{context:ot,initialValue:null}),this.paymentManagerProvider=new U(t,{context:G,initialValue:new Map}),this.cardNetworksContext=new U(t,{context:Vt,initialValue:null}),this.vaultManagerProvider=new U(t,{context:at,initialValue:null}),this.vaultManagerCvvProvider=new U(t,{context:Ht,initialValue:null}),this.clientOptionsContext=new U(t,{context:Pe,initialValue:null}),this.klarnaCategoriesProvider=new U(t,{context:Ut,initialValue:{categories:[],isLoading:!0}}),this.headlessUtilsProvider=new U(t,{context:K,initialValue:null}),this.computedStylesProvider=new U(t,{context:it,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)}setVaultManager(t){this.vaultManagerProvider?.setValue(t)}setKlarnaCategories(t){this.klarnaCategoriesProvider?.setValue(t)}setClientOptions(t){this.clientOptionsContext?.setValue(t)}setHeadlessUtils(t){this.headlessUtilsProvider?.setValue(t)}setComputedStyles(t){this.computedStylesProvider?.setValue(t)}setVaultManagerCvv(t){this.vaultManagerCvvProvider?.setValue(t)}};var Ye=class Ye{constructor(t){(this.host=t).addController(this)}processCustomStyles(t){try{let e=JSON.parse(t);this.applyStyles(e)}catch(e){A.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 r=/^[\w\s#.,%()\-+/!]+$/.test(t);return r||A.warn(`Rejected potentially unsafe CSS value: ${t}`),r}getCssVarName(t){let e=Ye.cssVarCache.get(t);return e||(e=`--${t.replace(/([A-Z])/g,(r,o)=>`-${o.toLowerCase()}`)}`,Ye.cssVarCache.set(t,e)),e}applyStyles(t){let e=[];for(let r of Object.keys(t)){let o=t[r];if(!o)continue;if(!this.isValidCssProperty(r)){A.warn(`Skipping invalid CSS property name: ${r}`);continue}if(!this.isValidCssValue(o))continue;let a=this.getCssVarName(r);e.push([a,o])}if(e.length>0)for(let[r,o]of e)this.host.style.setProperty(r,o)}removeStyle(t){let e=this.getCssVarName(t);this.host.style.removeProperty(e)}clearAllStyles(){for(let t of Ye.cssVarCache.keys()){let e=Ye.cssVarCache.get(t);e&&this.host.style.removeProperty(e)}}hostDisconnected(){}};Ye.cssVarCache=new Map;var Kt=Ye;var Gt=globalThis,Wt=Gt.ShadowRoot&&(Gt.ShadyCSS===void 0||Gt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,wi=Symbol(),Pi=new WeakMap,qt=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==wi)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(Wt&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=Pi.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&Pi.set(e,t))}return t}toString(){return this.cssText}},Mi=i=>new qt(typeof i=="string"?i:i+"",void 0,wi);var $r=(i,t)=>{if(Wt)i.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of t){let r=document.createElement("style"),o=Gt.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=e.cssText,i.appendChild(r)}},Jt=Wt?i=>i:i=>i instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return Mi(e)})(i):i;var{is:Xa,defineProperty:Qa,getOwnPropertyDescriptor:en,getOwnPropertyNames:tn,getOwnPropertySymbols:rn,getPrototypeOf:on}=Object,we=globalThis,Ti=we.trustedTypes,an=Ti?Ti.emptyScript:"",nn=we.reactiveElementPolyfillSupport,vt=(i,t)=>i,Yr={toAttribute(i,t){switch(t){case Boolean:i=i?an:null;break;case Object:case Array:i=i==null?i:JSON.stringify(i)}return i},fromAttribute(i,t){let e=i;switch(t){case Boolean:e=i!==null;break;case Number:e=i===null?null:Number(i);break;case Object:case Array:try{e=JSON.parse(i)}catch{e=null}}return e}},Zt=(i,t)=>!Xa(i,t),ki={attribute:!0,type:String,converter:Yr,reflect:!1,hasChanged:Zt};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),we.litPropertyMetadata??(we.litPropertyMetadata=new WeakMap);var Ve=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=ki){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){let r=Symbol(),o=this.getPropertyDescriptor(t,r,e);o!==void 0&&Qa(this.prototype,t,o)}}static getPropertyDescriptor(t,e,r){let{get:o,set:a}=en(this.prototype,t)??{get(){return this[e]},set(n){this[e]=n}};return{get(){return o?.call(this)},set(n){let s=o?.call(this);a.call(this,n),this.requestUpdate(t,s,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??ki}static _$Ei(){if(this.hasOwnProperty(vt("elementProperties")))return;let t=on(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(vt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(vt("properties"))){let e=this.properties,r=[...tn(e),...rn(e)];for(let o of r)this.createProperty(o,e[o])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[r,o]of e)this.elementProperties.set(r,o)}this._$Eh=new Map;for(let[e,r]of this.elementProperties){let o=this._$Eu(e,r);o!==void 0&&this._$Eh.set(o,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let o of r)e.unshift(Jt(o))}else t!==void 0&&e.push(Jt(t));return e}static _$Eu(t,e){let r=e.attribute;return r===!1?void 0:typeof r=="string"?r: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 r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return $r(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,r){this._$AK(t,r)}_$EC(t,e){let r=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,r);if(o!==void 0&&r.reflect===!0){let a=(r.converter?.toAttribute!==void 0?r.converter:Yr).toAttribute(e,r.type);this._$Em=t,a==null?this.removeAttribute(o):this.setAttribute(o,a),this._$Em=null}}_$AK(t,e){let r=this.constructor,o=r._$Eh.get(t);if(o!==void 0&&this._$Em!==o){let a=r.getPropertyOptions(o),n=typeof a.converter=="function"?{fromAttribute:a.converter}:a.converter?.fromAttribute!==void 0?a.converter:Yr;this._$Em=o,this[o]=n.fromAttribute(e,a.type),this._$Em=null}}requestUpdate(t,e,r){if(t!==void 0){if(r??(r=this.constructor.getPropertyOptions(t)),!(r.hasChanged??Zt)(this[t],e))return;this.P(t,e,r)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,r){this._$AL.has(t)||this._$AL.set(t,e),r.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[o,a]of this._$Ep)this[o]=a;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[o,a]of r)a.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.P(o,this[o],a)}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(e)):this._$EU()}catch(r){throw t=!1,this._$EU(),r}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){}};Ve.elementStyles=[],Ve.shadowRootOptions={mode:"open"},Ve[vt("elementProperties")]=new Map,Ve[vt("finalized")]=new Map,nn?.({ReactiveElement:Ve}),(we.reactiveElementVersions??(we.reactiveElementVersions=[])).push("2.0.4");var Me={INITIAL:0,PENDING:1,COMPLETE:2,ERROR:3},M=Symbol(),L=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,r){this.p=0,this.i=0,(this._=t).addController(this);let o=typeof e=="object"?e:{task:e,args:r};this.v=o.task,this.j=o.args,this.m=o.argsEqual??Ii,this.k=o.onComplete,this.A=o.onError,this.autoRun=o.autoRun??!0,"initialValue"in o&&(this.u=o.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,r;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 o=++this.p;this.q=new AbortController;let a=!1;try{e=await this.v(t,{signal:this.q.signal})}catch(n){a=!0,r=n}if(this.p===o){if(e===M)this.i=0;else{if(a===!1){try{this.k?.(e)}catch{}this.i=2,this.o?.(e)}else{try{this.A?.(r)}catch{}this.i=3,this.h?.(r)}this.u=e,this.l=r}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)}}},Ii=(i,t)=>i===t||i.length===t.length&&i.every((e,r)=>!Zt(e,t[r]));var sn={SET_LOADING:(i,t)=>({...i,isLoading:t.payload}),SET_UPDATING:(i,t)=>({...i,isUpdating:t.payload}),INITIALIZE_VAULT_MANAGER:(i,t,e)=>({...i,enabled:t.vaultEnabled,cvvRecapture:t.cvvRecapture,showEmptyState:t.showEmptyState,deleteVaultedPaymentMethod:e.deleteVaultedPaymentMethod,startVaultedPaymentFlow:e.startVaultedPaymentFlow,createCvvInput:e.createCvvInput}),UPDATE_PAYMENT_METHODS:(i,t)=>({...i,vaultedPaymentMethods:t.payload,isLoading:!1,isUpdating:!1}),SET_ERROR:i=>({...i,isLoading:!1,isUpdating:!1}),DISABLE:i=>({...i,enabled:!1}),RESET:()=>Ni},ln={INITIALIZE_CVV:(i,t,e)=>({...i,setCvvInput:e.setCvvInput,setSelectedVaultedPaymentMethod:e.setSelectedVaultedPaymentMethod}),SET_FORM_DIRTY:(i,t)=>({...i,formIsDirty:t.payload}),SET_CVV_INPUT:(i,t)=>({...i,cvvInput:t.payload}),SET_SELECTED_VAULTED_PAYMENT_METHOD:(i,t)=>({...i,selectedVaultedPaymentMethod:t.payload}),RESET_CVV:()=>Li},dn=gt(sn),cn=gt(ln),Ni={enabled:!1,isLoading:!1,isUpdating:!1,cvvRecapture:!1,showEmptyState:!0,vaultedPaymentMethods:[],createCvvInput:null,deleteVaultedPaymentMethod:()=>Promise.resolve(),startVaultedPaymentFlow:()=>Promise.resolve()},Li={cvvInput:null,formIsDirty:!1,setCvvInput:()=>{},selectedVaultedPaymentMethod:null,setSelectedVaultedPaymentMethod:()=>{}},Vr=class extends $e{constructor(t,e){super(t,Ni,dn,e,r=>{t.sdkContextController.setVaultManager(r)})}setLoading(t){this.dispatch({type:"SET_LOADING",payload:t})}setUpdating(t){this.dispatch({type:"SET_UPDATING",payload:t})}initializeVaultManager(t,e,r,o){this.dispatch({type:"INITIALIZE_VAULT_MANAGER",payload:t,vaultEnabled:e,cvvRecapture:r,showEmptyState:o})}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"})}},Ur=class extends $e{constructor(t,e){super(t,Li,cn,e,r=>{t.sdkContextController.setVaultManagerCvv(r)})}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"})}},bt=class extends Bt{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(r){throw this.coreController.setError(r instanceof Error?r:new Error("Failed to delete payment method")),r}};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,r=this.vaultManagerState.cvvRecapture,o=this.vaultItemState.cvvInput;if(!e||r&&(!o||o.metadata.error)){this.itemController.setFormDirty(!0);return}this.host.sdkStateController.startProcessing();try{await this._vaultManager.startPaymentFlow(e.id,r?{cvv:o.valueToken}:void 0)}catch(a){A.error("VaultManagerController: Error starting vaulted payment flow",a),this.coreController.setError(a instanceof Error?a:new Error("Failed to start vaulted payment flow")),this.host.sdkStateController.stopProcessing()}};this.setSelectedVaultedPaymentMethod=e=>{this.itemController.setSelectedPaymentMethod(e),this.itemController.setFormDirty(!1)};this.coreController=new Vr(e,{deleteVaultedPaymentMethod:this.deleteVaultedPaymentMethod.bind(this),startVaultedPaymentFlow:this.startVaultedPaymentFlow.bind(this),createCvvInput:this.createCvvInput}),this.itemController=new Ur(e,{setCvvInput:this.setCvvInput.bind(this),setSelectedVaultedPaymentMethod:this.setSelectedVaultedPaymentMethod.bind(this)}),this.addController(this.coreController),this.addController(this.itemController),new L(this.host,{task:async([r,o])=>{if(!r||!o?.vaultEnabled)return this.coreController.disable(),M;this.coreController.setLoading(!0);try{let a=r();this._vaultManager=a,this.coreController.initializeVaultManager(a,o.vaultEnabled,!!o.captureVaultedCardCvv,o.showEmptyState??!0),this.itemController.initializeCvv(a.createCvvInput),await this.fetchVaultedPaymentMethods(!0),A.log("VaultManagerController: Vault initialized successfully",{coreState:this.coreController.currentState,cvvState:this.itemController.currentState})}catch(a){A.error("VaultManagerController: Failed to initialize vault",a),this.coreController.setError(a instanceof Error?a:new Error("Unknown error"))}return this._vaultManager},args:()=>[this.createVaultManagerFn,this.options]})}initializeVaultManager(e,r){this.createVaultManagerFn=e,this.options=r??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()}async fetchVaultedPaymentMethods(e){if(!this._vaultManager)throw new Error("Vault manager not initialized");try{e||this.coreController.setUpdating(!0);let r=await this._vaultManager.fetchVaultedPaymentMethods();return A.log("VaultManagerController: Fetched payment methods",r),this.coreController.updatePaymentMethods(r),r}catch(r){throw this.coreController.setError(r instanceof Error?r:new Error("Failed to fetch payment methods")),r}}};var Ct="lit-localize-status";var Oi=i=>typeof i!="string"&&"strTag"in i,Xt=(i,t,e)=>{let r=i[0];for(let o=1;o<i.length;o++)r+=t[e?e[o-1]:o-1],r+=i[o];return r};var Et=i=>Oi(i)?Xt(i.strings,i.values):i;var x=Et,Ri=!1;function Hr(i){if(Ri)throw new Error("lit-localize can only be configured once");x=i,Ri=!0}var Br=class{constructor(t){this.__litLocalizeEventHandler=e=>{e.detail.status==="ready"&&this.host.requestUpdate()},this.host=t}hostConnected(){window.addEventListener(Ct,this.__litLocalizeEventHandler)}hostDisconnected(){window.removeEventListener(Ct,this.__litLocalizeEventHandler)}},pn=i=>i.addController(new Br(i)),Di=pn;var R=()=>(i,t)=>(i.addInitializer(Di),i);var At=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 fe=[];for(let i=0;i<256;i++)fe[i]=(i>>4&15).toString(16)+(i&15).toString(16);function $i(i){let t=0,e=8997,r=0,o=33826,a=0,n=40164,s=0,l=52210;for(let c=0;c<i.length;c++)e^=i.charCodeAt(c),t=e*435,r=o*435,a=n*435,s=l*435,a+=e<<8,s+=o<<8,r+=t>>>16,e=t&65535,a+=r>>>16,o=r&65535,l=s+(a>>>16)&65535,n=a&65535;return fe[l>>8]+fe[l&255]+fe[n>>8]+fe[n&255]+fe[o>>8]+fe[o&255]+fe[e>>8]+fe[e&255]}var un="",mn="h",hn="s";function Yi(i,t){return(t?mn:hn)+$i(typeof i=="string"?i:i.join(un))}var Vi=new WeakMap,Ui=new Map;function Hi(i,t,e){if(i){let r=e?.id??fn(t),o=i[r];if(o){if(typeof o=="string")return o;if("strTag"in o)return Xt(o.strings,t.values,o.values);{let a=Vi.get(o);return a===void 0&&(a=o.values,Vi.set(o,a)),{...o,values:a.map(n=>t.values[n])}}}}return Et(t)}function fn(i){let t=typeof i=="string"?i:i.strings,e=Ui.get(t);return e===void 0&&(e=Yi(t,typeof i!="string"&&!("strTag"in i)),Ui.set(t,e)),e}function zr(i){window.dispatchEvent(new CustomEvent(Ct,{detail:i}))}var er="",Fr,Bi,tr,jr,zi,Ue=new At;Ue.resolve();var Qt=0,Fi=i=>(Hr((t,e)=>Hi(zi,t,e)),er=Bi=i.sourceLocale,tr=new Set(i.targetLocales),tr.add(i.sourceLocale),jr=i.loadLocale,{getLocale:yn,setLocale:gn}),yn=()=>er,gn=i=>{if(i===(Fr??er))return Ue.promise;if(!tr||!jr)throw new Error("Internal error");if(!tr.has(i))throw new Error("Invalid locale code");Qt++;let t=Qt;return Fr=i,Ue.settled&&(Ue=new At),zr({status:"loading",loadingLocale:i}),(i===Bi?Promise.resolve({templates:void 0}):jr(i)).then(r=>{Qt===t&&(er=i,Fr=void 0,zi=r.templates,zr({status:"ready",readyLocale:i}),Ue.resolve())},r=>{Qt===t&&(zr({status:"error",errorLocale:i,errorMessage:r.toString()}),Ue.reject(r))}),Ue.promise};var Kr="en",Gr=["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"],ji="You must call `loadLocale` first to set up the localized template.",Ki,rr,Gi=i=>{let t=Fi({sourceLocale:Kr,targetLocales:Gr,loadLocale:i});Ki=t.getLocale,rr=t.setLocale};var qr=i=>{Gi(i)},Wr=i=>{if(!rr)throw new Error(ji);return rr(i)};var _t=new Set(Gr);_t.add(Kr);var Jr=i=>{if(typeof i!="string")return!1;if(i==="en")return!0;let t=i.replace("_","-");if(_t.has(t))return!0;let e=t.split("-")[0];return!!_t.has(e)},Zr=i=>{if(i==="en")return"en-GB";let t=i.replace("_","-");if(_t.has(t))return t;let e=t.split("-")[0];return _t.has(e)?e:"en-GB"};var ir=globalThis,or=ir.ShadowRoot&&(ir.ShadyCSS===void 0||ir.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Xr=Symbol(),qi=new WeakMap,St=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==Xr)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(or&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=qi.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&qi.set(e,t))}return t}toString(){return this.cssText}},ae=i=>new St(typeof i=="string"?i:i+"",void 0,Xr),g=(i,...t)=>{let e=i.length===1?i[0]:t.reduce((r,o,a)=>r+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+i[a+1],i[0]);return new St(e,i,Xr)},Wi=(i,t)=>{if(or)i.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of t){let r=document.createElement("style"),o=ir.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=e.cssText,i.appendChild(r)}},Qr=or?i=>i:i=>i instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return ae(e)})(i):i;var{is:vn,defineProperty:bn,getOwnPropertyDescriptor:Cn,getOwnPropertyNames:En,getOwnPropertySymbols:An,getPrototypeOf:_n}=Object,Te=globalThis,Ji=Te.trustedTypes,Sn=Ji?Ji.emptyScript:"",xn=Te.reactiveElementPolyfillSupport,xt=(i,t)=>i,Pt={toAttribute(i,t){switch(t){case Boolean:i=i?Sn:null;break;case Object:case Array:i=i==null?i:JSON.stringify(i)}return i},fromAttribute(i,t){let e=i;switch(t){case Boolean:e=i!==null;break;case Number:e=i===null?null:Number(i);break;case Object:case Array:try{e=JSON.parse(i)}catch{e=null}}return e}},ar=(i,t)=>!vn(i,t),Zi={attribute:!0,type:String,converter:Pt,reflect:!1,useDefault:!1,hasChanged:ar};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Te.litPropertyMetadata??(Te.litPropertyMetadata=new WeakMap);var ye=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=Zi){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 r=Symbol(),o=this.getPropertyDescriptor(t,r,e);o!==void 0&&bn(this.prototype,t,o)}}static getPropertyDescriptor(t,e,r){let{get:o,set:a}=Cn(this.prototype,t)??{get(){return this[e]},set(n){this[e]=n}};return{get:o,set(n){let s=o?.call(this);a?.call(this,n),this.requestUpdate(t,s,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Zi}static _$Ei(){if(this.hasOwnProperty(xt("elementProperties")))return;let t=_n(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(xt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(xt("properties"))){let e=this.properties,r=[...En(e),...An(e)];for(let o of r)this.createProperty(o,e[o])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[r,o]of e)this.elementProperties.set(r,o)}this._$Eh=new Map;for(let[e,r]of this.elementProperties){let o=this._$Eu(e,r);o!==void 0&&this._$Eh.set(o,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let o of r)e.unshift(Qr(o))}else t!==void 0&&e.push(Qr(t));return e}static _$Eu(t,e){let r=e.attribute;return r===!1?void 0:typeof r=="string"?r: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 r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Wi(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,r){this._$AK(t,r)}_$ET(t,e){let r=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,r);if(o!==void 0&&r.reflect===!0){let a=(r.converter?.toAttribute!==void 0?r.converter:Pt).toAttribute(e,r.type);this._$Em=t,a==null?this.removeAttribute(o):this.setAttribute(o,a),this._$Em=null}}_$AK(t,e){let r=this.constructor,o=r._$Eh.get(t);if(o!==void 0&&this._$Em!==o){let a=r.getPropertyOptions(o),n=typeof a.converter=="function"?{fromAttribute:a.converter}:a.converter?.fromAttribute!==void 0?a.converter:Pt;this._$Em=o,this[o]=n.fromAttribute(e,a.type)??this._$Ej?.get(o)??null,this._$Em=null}}requestUpdate(t,e,r){if(t!==void 0){let o=this.constructor,a=this[t];if(r??(r=o.getPropertyOptions(t)),!((r.hasChanged??ar)(a,e)||r.useDefault&&r.reflect&&a===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,r))))return;this.C(t,e,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:r,reflect:o,wrapped:a},n){r&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,n??e??this[t]),a!==!0||n!==void 0)||(this._$AL.has(t)||(this.hasUpdated||r||(e=void 0),this._$AL.set(t,e)),o===!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[o,a]of this._$Ep)this[o]=a;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[o,a]of r){let{wrapped:n}=a,s=this[o];n!==!0||this._$AL.has(o)||s===void 0||this.C(o,void 0,a,s)}}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(e)):this._$EM()}catch(r){throw t=!1,this._$EM(),r}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){}};ye.elementStyles=[],ye.shadowRootOptions={mode:"open"},ye[xt("elementProperties")]=new Map,ye[xt("finalized")]=new Map,xn?.({ReactiveElement:ye}),(Te.reactiveElementVersions??(Te.reactiveElementVersions=[])).push("2.1.0");var Mt=globalThis,nr=Mt.trustedTypes,Xi=nr?nr.createPolicy("lit-html",{createHTML:i=>i}):void 0,ti="$lit$",ge=`lit$${Math.random().toFixed(9).slice(2)}$`,ri="?"+ge,Pn=`<${ri}>`,ze=document,Tt=()=>ze.createComment(""),kt=i=>i===null||typeof i!="object"&&typeof i!="function",ii=Array.isArray,oo=i=>ii(i)||typeof i?.[Symbol.iterator]=="function",ei=`[
2
2
  \f\r]`,wt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Qi=/-->/g,eo=/>/g,He=RegExp(`>|${ei}(?:([^\\s"'>=/]+)(${ei}*=${ei}*(?:[^
3
3
  \f\r"'\`<>=]|("|')|))|$)`,"g"),to=/'/g,ro=/"/g,ao=/^(?:script|style|textarea|title)$/i,oi=i=>(t,...e)=>({_$litType$:i,strings:t,values:e}),m=oi(1),ne=oi(2),Eu=oi(3),ve=Symbol.for("lit-noChange"),f=Symbol.for("lit-nothing"),io=new WeakMap,Be=ze.createTreeWalker(ze,129);function no(i,t){if(!ii(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return Xi!==void 0?Xi.createHTML(t):t}var so=(i,t)=>{let e=i.length-1,r=[],o,a=t===2?"<svg>":t===3?"<math>":"",n=wt;for(let s=0;s<e;s++){let l=i[s],c,h,u=-1,y=0;for(;y<l.length&&(n.lastIndex=y,h=n.exec(l),h!==null);)y=n.lastIndex,n===wt?h[1]==="!--"?n=Qi:h[1]!==void 0?n=eo:h[2]!==void 0?(ao.test(h[2])&&(o=RegExp("</"+h[2],"g")),n=He):h[3]!==void 0&&(n=He):n===He?h[0]===">"?(n=o??wt,u=-1):h[1]===void 0?u=-2:(u=n.lastIndex-h[2].length,c=h[1],n=h[3]===void 0?He:h[3]==='"'?ro:to):n===ro||n===to?n=He:n===Qi||n===eo?n=wt:(n=He,o=void 0);let _=n===He&&i[s+1].startsWith("/>")?" ":"";a+=n===wt?l+Pn:u>=0?(r.push(c),l.slice(0,u)+ti+l.slice(u)+ge+_):l+ge+(u===-2?s:_)}return[no(i,a+(i[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]},It=class i{constructor({strings:t,_$litType$:e},r){let o;this.parts=[];let a=0,n=0,s=t.length-1,l=this.parts,[c,h]=so(t,e);if(this.el=i.createElement(c,r),Be.currentNode=this.el.content,e===2||e===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(o=Be.nextNode())!==null&&l.length<s;){if(o.nodeType===1){if(o.hasAttributes())for(let u of o.getAttributeNames())if(u.endsWith(ti)){let y=h[n++],_=o.getAttribute(u).split(ge),E=/([.?@])?(.*)/.exec(y);l.push({type:1,index:a,name:E[2],strings:_,ctor:E[1]==="."?lr:E[1]==="?"?dr:E[1]==="@"?cr:je}),o.removeAttribute(u)}else u.startsWith(ge)&&(l.push({type:6,index:a}),o.removeAttribute(u));if(ao.test(o.tagName)){let u=o.textContent.split(ge),y=u.length-1;if(y>0){o.textContent=nr?nr.emptyScript:"";for(let _=0;_<y;_++)o.append(u[_],Tt()),Be.nextNode(),l.push({type:2,index:++a});o.append(u[y],Tt())}}}else if(o.nodeType===8)if(o.data===ri)l.push({type:2,index:a});else{let u=-1;for(;(u=o.data.indexOf(ge,u+1))!==-1;)l.push({type:7,index:a}),u+=ge.length-1}a++}}static createElement(t,e){let r=ze.createElement("template");return r.innerHTML=t,r}};function Fe(i,t,e=i,r){if(t===ve)return t;let o=r!==void 0?e._$Co?.[r]:e._$Cl,a=kt(t)?void 0:t._$litDirective$;return o?.constructor!==a&&(o?._$AO?.(!1),a===void 0?o=void 0:(o=new a(i),o._$AT(i,e,r)),r!==void 0?(e._$Co??(e._$Co=[]))[r]=o:e._$Cl=o),o!==void 0&&(t=Fe(i,o._$AS(i,t.values),o,r)),t}var sr=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:r}=this._$AD,o=(t?.creationScope??ze).importNode(e,!0);Be.currentNode=o;let a=Be.nextNode(),n=0,s=0,l=r[0];for(;l!==void 0;){if(n===l.index){let c;l.type===2?c=new nt(a,a.nextSibling,this,t):l.type===1?c=new l.ctor(a,l.name,l.strings,this,t):l.type===6&&(c=new pr(a,this,t)),this._$AV.push(c),l=r[++s]}n!==l?.index&&(a=Be.nextNode(),n++)}return Be.currentNode=ze,o}p(t){let e=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}},nt=class i{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,r,o){this.type=2,this._$AH=f,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=o,this._$Cv=o?.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=Fe(this,t,e),kt(t)?t===f||t==null||t===""?(this._$AH!==f&&this._$AR(),this._$AH=f):t!==this._$AH&&t!==ve&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):oo(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!==f&&kt(this._$AH)?this._$AA.nextSibling.data=t:this.T(ze.createTextNode(t)),this._$AH=t}$(t){let{values:e,_$litType$:r}=t,o=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=It.createElement(no(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===o)this._$AH.p(e);else{let a=new sr(o,this),n=a.u(this.options);a.p(e),this.T(n),this._$AH=a}}_$AC(t){let e=io.get(t.strings);return e===void 0&&io.set(t.strings,e=new It(t)),e}k(t){ii(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,r,o=0;for(let a of t)o===e.length?e.push(r=new i(this.O(Tt()),this.O(Tt()),this,this.options)):r=e[o],r._$AI(a),o++;o<e.length&&(this._$AR(r&&r._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){let r=t.nextSibling;t.remove(),t=r}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},je=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,o,a){this.type=1,this._$AH=f,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=a,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=f}_$AI(t,e=this,r,o){let a=this.strings,n=!1;if(a===void 0)t=Fe(this,t,e,0),n=!kt(t)||t!==this._$AH&&t!==ve,n&&(this._$AH=t);else{let s=t,l,c;for(t=a[0],l=0;l<a.length-1;l++)c=Fe(this,s[r+l],e,l),c===ve&&(c=this._$AH[l]),n||(n=!kt(c)||c!==this._$AH[l]),c===f?t=f:t!==f&&(t+=(c??"")+a[l+1]),this._$AH[l]=c}n&&!o&&this.j(t)}j(t){t===f?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},lr=class extends je{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===f?void 0:t}},dr=class extends je{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==f)}},cr=class extends je{constructor(t,e,r,o,a){super(t,e,r,o,a),this.type=5}_$AI(t,e=this){if((t=Fe(this,t,e,0)??f)===ve)return;let r=this._$AH,o=t===f&&r!==f||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,a=t!==f&&(r===f||o);o&&this.element.removeEventListener(this.name,this,r),a&&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)}},pr=class{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){Fe(this,t)}},lo={M:ti,P:ge,A:ri,C:1,L:so,R:sr,D:oo,V:Fe,I:nt,H:je,N:dr,U:cr,B:lr,F:pr},wn=Mt.litHtmlPolyfillSupport;wn?.(It,nt),(Mt.litHtmlVersions??(Mt.litHtmlVersions=[])).push("3.3.0");var co=(i,t,e)=>{let r=e?.renderBefore??t,o=r._$litPart$;if(o===void 0){let a=e?.renderBefore??null;r._$litPart$=o=new nt(t.insertBefore(Tt(),a),a,void 0,e??{})}return o._$AI(i),o};var Nt=globalThis,v=class extends ye{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=co(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ve}};v._$litElement$=!0,v.finalized=!0,Nt.litElementHydrateSupport?.({LitElement:v});var Mn=Nt.litElementPolyfillSupport;Mn?.({LitElement:v});(Nt.litElementVersions??(Nt.litElementVersions=[])).push("4.2.0");var b=i=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(i,t)}):customElements.define(i,t)};var Tn={attribute:!0,type:String,converter:Pt,reflect:!1,hasChanged:ar},kn=(i=Tn,t,e)=>{let{kind:r,metadata:o}=e,a=globalThis.litPropertyMetadata.get(o);if(a===void 0&&globalThis.litPropertyMetadata.set(o,a=new Map),r==="setter"&&((i=Object.create(i)).wrapped=!0),a.set(e.name,i),r==="accessor"){let{name:n}=e;return{set(s){let l=t.get.call(this);t.set.call(this,s),this.requestUpdate(n,l,i)},init(s){return s!==void 0&&this.C(n,void 0,i,s),s}}}if(r==="setter"){let{name:n}=e;return function(s){let l=this[n];t.call(this,s),this.requestUpdate(n,l,i)}}throw Error("Unsupported decorator location: "+r)};function p(i){return(t,e)=>typeof e=="object"?kn(i,t,e):((r,o,a)=>{let n=o.hasOwnProperty(a);return o.constructor.createProperty(a,r),n?Object.getOwnPropertyDescriptor(o,a):void 0})(i,t,e)}function P(i){return p({...i,state:!0,attribute:!1})}var Ke=(i,t,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(i,t,e),e);function ke(i,t){return(e,r,o)=>{let a=n=>n.renderRoot?.querySelector(i)??null;if(t){let{get:n,set:s}=typeof r=="object"?e:o??(()=>{let l=Symbol();return{get(){return this[l]},set(c){this[l]=c}}})();return Ke(e,r,{get(){let l=n.call(this);return l===void 0&&(l=a(this),(l!==null||this.hasUpdated)&&s.call(this,l)),l}})}return Ke(e,r,{get(){return a(this)}})}}function O(i,t,e){return i?t(i):e?.(i)}var T=g` * { box-sizing: border-box; } `,po=g` :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 uo="https://sdk.primer.io/web/v2-latest/Primer.min.js",se="20px";var ur=class{constructor(t){this._methods=t}get(t){return this._methods.get(t)}toArray(){return Array.from(this._methods.values())}size(){return this._methods.size}};var mr=class{constructor(t){this.paymentMethods=null;this.headlessInstance=t}setPaymentMethods(t){this.paymentMethods=t}async refreshSession(){if(!this.headlessInstance){A.error("PrimerJS: Cannot refresh session: Headless instance not available");return}try{await this.headlessInstance.refreshClientSession()}catch(t){throw A.error("PrimerJS: Error refreshing client session:",t),t}}getPaymentMethods(){return this.paymentMethods?this.paymentMethods.toArray():(A.warn("PrimerJS: Payment methods not available"),[])}handlePaymentStart(){this.onPaymentStart&&this.onPaymentStart()}handleBeforePaymentCreate(t,e){if(this.onPaymentPrepare){let r={continuePaymentCreation:()=>{A.info("PrimerJS: Payment creation continuing"),e.continuePaymentCreation()},abortPaymentCreation:()=>{A.info("PrimerJS: Payment creation aborted"),e.abortPaymentCreation()}};this.onPaymentPrepare(t,r)}else A.info("PrimerJS: No payment prepare handler, continuing by default"),e.continuePaymentCreation()}handlePaymentComplete(t){this.onPaymentComplete&&this.onPaymentComplete({payment:t,status:"success"})}handlePaymentFailure(t,e){this.onPaymentComplete&&this.onPaymentComplete({payment:e||null,status:"error",error:t})}};var mo=typeof window<"u"&&typeof window.document<"u";function In(i){return document.querySelector(`script[src^="${i}"]`)}function Nn(i,t){let e=document.createElement("script");return e.setAttribute("src",i),e.setAttribute("async",""),e.setAttribute("crossorigin","anonymous"),t&&e.setAttribute("type","module"),e}function ho(i,t=!1){if(!mo)throw new Error("Cannot load script in server environment");let e=In(i)??Nn(i,t);return new Promise((r,o)=>{e.onload=()=>{r()},e.onerror=()=>{o(new Error(`Failed to load script: ${i}`))},e.parentNode||document.head.appendChild(e)})}var Ln={"../../node_modules/card-validator/dist/card-number.js":function(i,t,e){Object.defineProperty(t,"__esModule",{value:!0}),t.cardNumber=void 0;var r=e("../../node_modules/card-validator/dist/luhn-10.js"),o=e("../../node_modules/credit-card-type/dist/index.js");function a(s,l,c){return{card:s,isPotentiallyValid:l,isValid:c}}function n(s,l){l===void 0&&(l={});var c,h,u;if(typeof s!="string"&&typeof s!="number")return a(null,!1,!1);var y=String(s).replace(/-|\s/g,"");if(!/^\d*$/.test(y))return a(null,!1,!1);var _=o(y);if(_.length===0)return a(null,!1,!1);if(_.length!==1)return a(null,!0,!1);var E=_[0];if(l.maxLength&&y.length>l.maxLength)return a(E,!1,!1);h=l.skipLuhnValidation===!0||E.type===o.types.UNIONPAY&&l.luhnValidateUnionPay!==!0?!0:r(y),u=Math.max.apply(null,E.lengths),l.maxLength&&(u=Math.min(l.maxLength,u));for(var w=0;w<E.lengths.length;w++)if(E.lengths[w]===y.length)return c=y.length<u||h,a(E,c,h);return a(E,y.length<u,!1)}t.cardNumber=n},"../../node_modules/card-validator/dist/cardholder-name.js":function(i,t){Object.defineProperty(t,"__esModule",{value:!0}),t.cardholderName=void 0;var e=/^[\d\s-]*$/,r=255;function o(n,s){return{isValid:n,isPotentiallyValid:s}}function a(n){return typeof n!="string"?o(!1,!1):n.length===0?o(!1,!0):n.length>r?o(!1,!1):e.test(n)?o(!1,!0):o(!0,!0)}t.cardholderName=a},"../../node_modules/card-validator/dist/cvv.js":function(i,t){Object.defineProperty(t,"__esModule",{value:!0}),t.cvv=void 0;var e=3;function r(s,l){for(var c=0;c<s.length;c++)if(l===s[c])return!0;return!1}function o(s){for(var l=e,c=0;c<s.length;c++)l=s[c]>l?s[c]:l;return l}function a(s,l){return{isValid:s,isPotentiallyValid:l}}function n(s,l){return l===void 0&&(l=e),l=l instanceof Array?l:[l],typeof s!="string"||!/^\d*$/.test(s)?a(!1,!1):r(l,s.length)?a(!0,!0):s.length<Math.min.apply(null,l)?a(!1,!0):s.length>o(l)?a(!1,!1):a(!0,!0)}t.cvv=n},"../../node_modules/card-validator/dist/expiration-date.js":function(i,t,e){var r=this&&this.__assign||function(){return r=Object.assign||function(c){for(var h,u=1,y=arguments.length;u<y;u++){h=arguments[u];for(var _ in h)Object.prototype.hasOwnProperty.call(h,_)&&(c[_]=h[_])}return c},r.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.expirationDate=void 0;var o=e("../../node_modules/card-validator/dist/lib/parse-date.js"),a=e("../../node_modules/card-validator/dist/expiration-month.js"),n=e("../../node_modules/card-validator/dist/expiration-year.js");function s(c,h,u,y){return{isValid:c,isPotentiallyValid:h,month:u,year:y}}function l(c,h){var u;if(typeof c=="string")c=c.replace(/^(\d\d) (\d\d(\d\d)?)$/,"$1/$2"),u=(0,o.parseDate)(String(c));else{if(c===null||typeof c!="object")return s(!1,!1,null,null);var y=r({},c);u={month:String(y.month),year:String(y.year)}}var _=(0,a.expirationMonth)(u.month),E=(0,n.expirationYear)(u.year,h);if(_.isValid){if(E.isCurrentYear){var w=_.isValidForThisYear;return s(w,w,u.month,u.year)}if(E.isValid)return s(!0,!0,u.month,u.year)}return _.isPotentiallyValid&&E.isPotentiallyValid?s(!1,!0,null,null):s(!1,!1,null,null)}t.expirationDate=l},"../../node_modules/card-validator/dist/expiration-month.js":function(i,t){Object.defineProperty(t,"__esModule",{value:!0}),t.expirationMonth=void 0;function e(o,a,n){return{isValid:o,isPotentiallyValid:a,isValidForThisYear:n||!1}}function r(o){var a=new Date().getMonth()+1;if(typeof o!="string")return e(!1,!1);if(o.replace(/\s/g,"")===""||o==="0")return e(!1,!0);if(!/^\d*$/.test(o))return e(!1,!1);var n=parseInt(o,10);if(isNaN(Number(o)))return e(!1,!1);var s=n>0&&n<13;return e(s,s,s&&n>=a)}t.expirationMonth=r},"../../node_modules/card-validator/dist/expiration-year.js":function(i,t){Object.defineProperty(t,"__esModule",{value:!0}),t.expirationYear=void 0;var e=19;function r(a,n,s){return{isValid:a,isPotentiallyValid:n,isCurrentYear:s||!1}}function o(a,n){n===void 0&&(n=e);var s;if(typeof a!="string")return r(!1,!1);if(a.replace(/\s/g,"")==="")return r(!1,!0);if(!/^\d*$/.test(a))return r(!1,!1);var l=a.length;if(l<2)return r(!1,!0);var c=new Date().getFullYear();if(l===3){var h=a.slice(0,2),u=String(c).slice(0,2);return r(!1,h===u)}if(l>4)return r(!1,!1);var y=parseInt(a,10),_=Number(String(c).substr(2,2)),E=!1;if(l===2){if(String(c).substr(0,2)===a)return r(!1,!0);s=_===y,E=y>=_&&y<=_+n}else l===4&&(s=c===y,E=y>=c&&y<=c+n);return r(E,E,s)}t.expirationYear=o},"../../node_modules/card-validator/dist/index.js":function(i,t,e){var r=this&&this.__createBinding||(Object.create?function(w,I,S,k){k===void 0&&(k=S);var $=Object.getOwnPropertyDescriptor(I,S);(!$||("get"in $?!I.__esModule:$.writable||$.configurable))&&($={enumerable:!0,get:function(){return I[S]}}),Object.defineProperty(w,k,$)}:function(w,I,S,k){k===void 0&&(k=S),w[k]=I[S]}),o=this&&this.__setModuleDefault||(Object.create?function(w,I){Object.defineProperty(w,"default",{enumerable:!0,value:I})}:function(w,I){w.default=I}),a=this&&this.__importStar||function(w){if(w&&w.__esModule)return w;var I={};if(w!=null)for(var S in w)S!=="default"&&Object.prototype.hasOwnProperty.call(w,S)&&r(I,w,S);return o(I,w),I},n=a(e("../../node_modules/credit-card-type/dist/index.js")),s=e("../../node_modules/card-validator/dist/cardholder-name.js"),l=e("../../node_modules/card-validator/dist/card-number.js"),c=e("../../node_modules/card-validator/dist/expiration-date.js"),h=e("../../node_modules/card-validator/dist/expiration-month.js"),u=e("../../node_modules/card-validator/dist/expiration-year.js"),y=e("../../node_modules/card-validator/dist/cvv.js"),_=e("../../node_modules/card-validator/dist/postal-code.js"),E={creditCardType:n,cardholderName:s.cardholderName,number:l.cardNumber,expirationDate:c.expirationDate,expirationMonth:h.expirationMonth,expirationYear:u.expirationYear,cvv:y.cvv,postalCode:_.postalCode};i.exports=E},"../../node_modules/card-validator/dist/lib/is-array.js":function(i,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isArray=void 0,t.isArray=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"}},"../../node_modules/card-validator/dist/lib/parse-date.js":function(i,t,e){Object.defineProperty(t,"__esModule",{value:!0}),t.parseDate=void 0;var r=e("../../node_modules/card-validator/dist/expiration-year.js"),o=e("../../node_modules/card-validator/dist/lib/is-array.js");function a(s){var l=Number(s[0]),c;return l===0?2:l>1||l===1&&Number(s[1])>2?1:l===1?(c=s.substr(1),(0,r.expirationYear)(c).isPotentiallyValid?1:2):s.length===5?1:s.length>5?2:1}function n(s){var l;if(/^\d{4}-\d{1,2}$/.test(s)?l=s.split("-").reverse():/\//.test(s)?l=s.split(/\s*\/\s*/g):/\s/.test(s)&&(l=s.split(/ +/g)),(0,o.isArray)(l))return{month:l[0]||"",year:l.slice(1).join()};var c=a(s),h=s.substr(0,c);return{month:h,year:s.substr(h.length)}}t.parseDate=n},"../../node_modules/card-validator/dist/luhn-10.js":function(i){function t(e){for(var r=0,o=!1,a=e.length-1,n;a>=0;)n=parseInt(e.charAt(a),10),o&&(n*=2,n>9&&(n=n%10+1)),o=!o,r+=n,a--;return r%10===0}i.exports=t},"../../node_modules/card-validator/dist/postal-code.js":function(i,t){Object.defineProperty(t,"__esModule",{value:!0}),t.postalCode=void 0;var e=3,r=new RegExp(/^[a-z0-9]+$/i);function o(n,s){return{isValid:n,isPotentiallyValid:s}}function a(n,s){s===void 0&&(s={});var l=s.minLength||e;return typeof n!="string"?o(!1,!1):n.length<l||!r.test(n.trim().slice(0,l))?o(!1,!0):o(!0,!0)}t.postalCode=a},"../../node_modules/credit-card-type/dist/index.js":function(i,t,e){var r=this&&this.__assign||function(){return r=Object.assign||function(S){for(var k,$=1,Se=arguments.length;$<Se;$++){k=arguments[$];for(var yt in k)Object.prototype.hasOwnProperty.call(k,yt)&&(S[yt]=k[yt])}return S},r.apply(this,arguments)},o=e("../../node_modules/credit-card-type/dist/lib/card-types.js"),a=e("../../node_modules/credit-card-type/dist/lib/add-matching-cards-to-results.js"),n=e("../../node_modules/credit-card-type/dist/lib/is-valid-input-type.js"),s=e("../../node_modules/credit-card-type/dist/lib/find-best-match.js"),l=e("../../node_modules/credit-card-type/dist/lib/clone.js"),c={},h={VISA:"visa",MASTERCARD:"mastercard",AMERICAN_EXPRESS:"american-express",DINERS_CLUB:"diners-club",DISCOVER:"discover",JCB:"jcb",UNIONPAY:"unionpay",MAESTRO:"maestro",ELO:"elo",MIR:"mir",HIPER:"hiper",HIPERCARD:"hipercard"},u=[h.VISA,h.MASTERCARD,h.AMERICAN_EXPRESS,h.DINERS_CLUB,h.DISCOVER,h.JCB,h.UNIONPAY,h.MAESTRO,h.ELO,h.MIR,h.HIPER,h.HIPERCARD],y=(0,l.clone)(u);function _(S){return c[S]||o[S]}function E(){return y.map(function(S){return(0,l.clone)(_(S))})}function w(S,k){k===void 0&&(k=!1);var $=y.indexOf(S);if(!k&&$===-1)throw new Error('"'+S+'" is not a supported card type.');return $}function I(S){var k=[];if(!(0,n.isValidInputType)(S))return k;if(S.length===0)return E();y.forEach(function(Se){var yt=_(Se);(0,a.addMatchingCardsToResults)(S,yt,k)});var $=(0,s.findBestMatch)(k);return $?[$]:k}I.getTypeInfo=function(S){return(0,l.clone)(_(S))},I.removeCard=function(S){var k=w(S);y.splice(k,1)},I.addCard=function(S){var k=w(S.type,!0);c[S.type]=S,k===-1&&y.push(S.type)},I.updateCard=function(S,k){var $=c[S]||o[S];if(!$)throw new Error('"'.concat(S,"\" is not a recognized type. Use `addCard` instead.'"));if(k.type&&$.type!==k.type)throw new Error("Cannot overwrite type parameter.");var Se=(0,l.clone)($);Se=r(r({},Se),k),c[Se.type]=Se},I.changeOrder=function(S,k){var $=w(S);y.splice($,1),y.splice(k,0,S)},I.resetModifications=function(){y=(0,l.clone)(u),c={}},I.types=h,i.exports=I},"../../node_modules/credit-card-type/dist/lib/add-matching-cards-to-results.js":function(i,t,e){Object.defineProperty(t,"__esModule",{value:!0}),t.addMatchingCardsToResults=void 0;var r=e("../../node_modules/credit-card-type/dist/lib/clone.js"),o=e("../../node_modules/credit-card-type/dist/lib/matches.js");function a(n,s,l){var c,h;for(c=0;c<s.patterns.length;c++){var u=s.patterns[c];if((0,o.matches)(n,u)){var y=(0,r.clone)(s);h=Array.isArray(u)?String(u[0]).length:String(u).length,n.length>=h&&(y.matchStrength=h),l.push(y);break}}}t.addMatchingCardsToResults=a},"../../node_modules/credit-card-type/dist/lib/card-types.js":function(i){var t={visa:{niceType:"Visa",type:"visa",patterns:[4],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}},mastercard:{niceType:"Mastercard",type:"mastercard",patterns:[[51,55],[2221,2229],[223,229],[23,26],[270,271],2720],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},"american-express":{niceType:"American Express",type:"american-express",patterns:[34,37],gaps:[4,10],lengths:[15],code:{name:"CID",size:4}},"diners-club":{niceType:"Diners Club",type:"diners-club",patterns:[[300,305],36,38,39],gaps:[4,10],lengths:[14,16,19],code:{name:"CVV",size:3}},discover:{niceType:"Discover",type:"discover",patterns:[6011,[644,649],65],gaps:[4,8,12],lengths:[16,19],code:{name:"CID",size:3}},jcb:{niceType:"JCB",type:"jcb",patterns:[2131,1800,[3528,3589]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVV",size:3}},unionpay:{niceType:"UnionPay",type:"unionpay",patterns:[620,[62100,62182],[62184,62187],[62185,62197],[62200,62205],[622010,622999],622018,[62207,62209],[623,626],6270,6272,6276,[627700,627779],[627781,627799],[6282,6289],6291,6292,810,[8110,8131],[8132,8151],[8152,8163],[8164,8171]],gaps:[4,8,12],lengths:[14,15,16,17,18,19],code:{name:"CVN",size:3}},maestro:{niceType:"Maestro",type:"maestro",patterns:[493698,[5e5,504174],[504176,506698],[506779,508999],[56,59],63,67,6],gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:"CVC",size:3}},elo:{niceType:"Elo",type:"elo",patterns:[401178,401179,438935,457631,457632,431274,451416,457393,504175,[506699,506778],[509e3,509999],627780,636297,636368,[650031,650033],[650035,650051],[650405,650439],[650485,650538],[650541,650598],[650700,650718],[650720,650727],[650901,650978],[651652,651679],[655e3,655019],[655021,655058]],gaps:[4,8,12],lengths:[16],code:{name:"CVE",size:3}},mir:{niceType:"Mir",type:"mir",patterns:[[2200,2204]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVP2",size:3}},hiper:{niceType:"Hiper",type:"hiper",patterns:[637095,63737423,63743358,637568,637599,637609,637612],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},hipercard:{niceType:"Hipercard",type:"hipercard",patterns:[606282],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}}};i.exports=t},"../../node_modules/credit-card-type/dist/lib/clone.js":function(i,t){Object.defineProperty(t,"__esModule",{value:!0}),t.clone=void 0;function e(r){return r?JSON.parse(JSON.stringify(r)):null}t.clone=e},"../../node_modules/credit-card-type/dist/lib/find-best-match.js":function(i,t){Object.defineProperty(t,"__esModule",{value:!0}),t.findBestMatch=void 0;function e(o){var a=o.filter(function(n){return n.matchStrength}).length;return a>0&&a===o.length}function r(o){return e(o)?o.reduce(function(a,n){return!a||Number(a.matchStrength)<Number(n.matchStrength)?n:a}):null}t.findBestMatch=r},"../../node_modules/credit-card-type/dist/lib/is-valid-input-type.js":function(i,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isValidInputType=void 0;function e(r){return typeof r=="string"||r instanceof String}t.isValidInputType=e},"../../node_modules/credit-card-type/dist/lib/matches.js":function(i,t){Object.defineProperty(t,"__esModule",{value:!0}),t.matches=void 0;function e(a,n,s){var l=String(n).length,c=a.substr(0,l),h=parseInt(c,10);return n=parseInt(String(n).substr(0,c.length),10),s=parseInt(String(s).substr(0,c.length),10),h>=n&&h<=s}function r(a,n){return n=String(n),n.substring(0,a.length)===a.substring(0,n.length)}function o(a,n){return Array.isArray(n)?e(a,n[0],n[1]):r(a,n)}t.matches=o}},fo={};function le(i){var t=fo[i];if(t!==void 0)return t.exports;var e=fo[i]={exports:{}};return Ln[i].call(e.exports,e,e.exports,le),e.exports}le.n=i=>{var t=i&&i.__esModule?()=>i.default:()=>i;return le.d(t,{a:t}),t};le.d=(i,t)=>{for(var e in t)le.o(t,e)&&!le.o(i,e)&&Object.defineProperty(i,e,{enumerable:!0,get:t[e]})};le.o=(i,t)=>Object.prototype.hasOwnProperty.call(i,t);var yo=le("../../node_modules/credit-card-type/dist/index.js");function fi(i){return i.replace(/[-_]/g," ").replace(/[^\s\w]/g,"").replace(/([A-Z][a-z]+|[0-9]+)/g," $1").replace(/([A-Z]{2,})/g," $1").trim().split(/\s+/g)}function On(i){return fi(i).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1).toLowerCase()).join(" ")}function go(i){return fi(i).join("-").toLowerCase()}function vo(i){return fi(i).join("_").toUpperCase()}var To=[["AMEX","american-express"],["CARTES_BANCAIRES"],["DANKORT"],["DINERS_CLUB","diners-club"],["DISCOVER","discover"],["ENROUTE"],["ELO","elo"],["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"]],bo=new Map(To.map(i=>[i[0],i])),Rn=new Map(To.filter(i=>i[1]).map(i=>[i[1],i]));function ko(i){let{niceType:t,type:e}=(0,yo.getTypeInfo)(go(i))||(0,yo.getTypeInfo)(bo.get(vo(i))?.[1]||"")||{},[r,o,a]=Rn.get(e)||bo.get(vo(i))||[];return{asset:a||go(o||i),backend:r,display:t||On(i),library:o}}var st={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"};function Dn(i,t){return{"Content-Type":"application/json","primer-client-token":i,"primer-sdk-client":"WEB","primer-sdk-version":"0.0.0-local","primer-sdk-checkout-session-id":t,"x-api-version":"2.4"}}var Ot=()=>Io.randomUUID?.()||$n(),$n=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,i=>(i^Yn()>>i/4).toString(16)),Yn=()=>(Io.getRandomValues?.(new Uint8Array(1))[0]??16*Math.random())&15,Io=typeof crypto<"u"?crypto:{};function Vn(i,t){return async(e,r)=>new Promise(o=>{let a=Ot(),n={id:t,type:"http-request",url:e,init:r,requestId:a};i.contentWindow?.postMessage(n,"*");let s=l=>{l.data.type==="http-response"&&l.data.requestId===a&&(window.removeEventListener("message",s),o(l.data))};window.addEventListener("message",s)})}var ct=class{constructor(t,e="",r={}){N(this,"fetch");N(this,"baseUrl");N(this,"defaultHeaders");this.fetch=t,this.baseUrl=e,this.defaultHeaders=Object.freeze({...r})}setDefaultHeader(t,e){this.defaultHeaders={...this.defaultHeaders,[t]:e}}async get(t,e){return this.fetch(t,{...e,method:"GET",headers:{...this.defaultHeaders,...e?.headers}})}async post(t,e,r){return this.fetch(t,{...r,method:"POST",body:JSON.stringify(e),headers:{...this.defaultHeaders,...r?.headers}})}async delete(t,e){return this.fetch(t,{...e,method:"DELETE",headers:{...this.defaultHeaders,...e?.headers}})}},ai=class extends ct{async getConfiguration(){return this.get(this.baseUrl)}},ni=class extends ct{async getPaymentInstruments(){return this.get(`${this.baseUrl}/payment-instruments`)}async postPaymentInstruments(t){return this.post(`${this.baseUrl}/payment-instruments`,t==="pci-card-form-data"?t:{paymentInstrument:t})}async postCreatePayment(t){return this.post(`${this.baseUrl}/payments`,{paymentMethodToken:t})}async postResumePayment(t,e){return this.post(`${this.baseUrl}/payments/${t}/resume`,{resumeToken:e})}async post3dsAuth(t,e){return this.post(`${this.baseUrl}/3ds/${t}/auth`,e)}async post3dsContinue(t){return this.post(`${this.baseUrl}/3ds/${t}/continue`,{platform:"WEB",status:"FAILURE"})}async get3dsResumeStatus(t){return this.get(t)}async deletePaymentInstrument(t){return this.delete(`${this.baseUrl}/payment-instruments/${t}/vault`)}async postClientSessionActions(t){return this.post(`${this.baseUrl}/client-session/actions`,{actions:t})}async getResumeStatus(t){return this.get(t)}},No="3.7.7",Un=No,pt=typeof Buffer=="function",Co=typeof TextDecoder=="function"?new TextDecoder:void 0,Eo=typeof TextEncoder=="function"?new TextEncoder:void 0,Hn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Lt=Array.prototype.slice.call(Hn),hr=(i=>{let t={};return i.forEach((e,r)=>t[e]=r),t})(Lt),Bn=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,H=String.fromCharCode.bind(String),Ao=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):i=>new Uint8Array(Array.prototype.slice.call(i,0)),Lo=i=>i.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),Oo=i=>i.replace(/[^A-Za-z0-9\+\/]/g,""),Ro=i=>{let t,e,r,o,a="",n=i.length%3;for(let s=0;s<i.length;){if((e=i.charCodeAt(s++))>255||(r=i.charCodeAt(s++))>255||(o=i.charCodeAt(s++))>255)throw new TypeError("invalid character found");t=e<<16|r<<8|o,a+=Lt[t>>18&63]+Lt[t>>12&63]+Lt[t>>6&63]+Lt[63&t]}return n?a.slice(0,n-3)+"===".substring(n):a},yi=typeof btoa=="function"?i=>btoa(i):pt?i=>Buffer.from(i,"binary").toString("base64"):Ro,si=pt?i=>Buffer.from(i).toString("base64"):i=>{let e=[];for(let r=0,o=i.length;r<o;r+=4096)e.push(H.apply(null,i.subarray(r,r+4096)));return yi(e.join(""))},gr=(i,t=!1)=>t?Lo(si(i)):si(i),zn=i=>{if(i.length<2){var t=i.charCodeAt(0);return t<128?i:t<2048?H(192|t>>>6)+H(128|63&t):H(224|t>>>12&15)+H(128|t>>>6&63)+H(128|63&t)}var t=65536+(i.charCodeAt(0)-55296)*1024+(i.charCodeAt(1)-56320);return H(240|t>>>18&7)+H(128|t>>>12&63)+H(128|t>>>6&63)+H(128|63&t)},Fn=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Do=i=>i.replace(Fn,zn),_o=pt?i=>Buffer.from(i,"utf8").toString("base64"):Eo?i=>si(Eo.encode(i)):i=>yi(Do(i)),lt=(i,t=!1)=>t?Lo(_o(i)):_o(i),So=i=>lt(i,!0),jn=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Kn=i=>{switch(i.length){case 4:var t=(7&i.charCodeAt(0))<<18|(63&i.charCodeAt(1))<<12|(63&i.charCodeAt(2))<<6|63&i.charCodeAt(3),e=t-65536;return H((e>>>10)+55296)+H((1023&e)+56320);case 3:return H((15&i.charCodeAt(0))<<12|(63&i.charCodeAt(1))<<6|63&i.charCodeAt(2));default:return H((31&i.charCodeAt(0))<<6|63&i.charCodeAt(1))}},$o=i=>i.replace(jn,Kn),Yo=i=>{if(i=i.replace(/\s+/g,""),!Bn.test(i))throw new TypeError("malformed base64.");i+="==".slice(2-(3&i.length));let t,e="",r,o;for(let a=0;a<i.length;)t=hr[i.charAt(a++)]<<18|hr[i.charAt(a++)]<<12|(r=hr[i.charAt(a++)])<<6|(o=hr[i.charAt(a++)]),e+=r===64?H(t>>16&255):o===64?H(t>>16&255,t>>8&255):H(t>>16&255,t>>8&255,255&t);return e},gi=typeof atob=="function"?i=>atob(Oo(i)):pt?i=>Buffer.from(i,"base64").toString("binary"):Yo,Vo=pt?i=>Ao(Buffer.from(i,"base64")):i=>Ao(gi(i).split("").map(t=>t.charCodeAt(0))),Uo=i=>Vo(Ho(i)),Gn=pt?i=>Buffer.from(i,"base64").toString("utf8"):Co?i=>Co.decode(Vo(i)):i=>$o(gi(i)),Ho=i=>Oo(i.replace(/[-_]/g,t=>t=="-"?"+":"/")),li=i=>Gn(Ho(i)),qn=i=>{if(typeof i!="string")return!1;let t=i.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},Bo=i=>({value:i,enumerable:!1,writable:!0,configurable:!0}),zo=function(){let i=(t,e)=>Object.defineProperty(String.prototype,t,Bo(e));i("fromBase64",function(){return li(this)}),i("toBase64",function(t){return lt(this,t)}),i("toBase64URI",function(){return lt(this,!0)}),i("toBase64URL",function(){return lt(this,!0)}),i("toUint8Array",function(){return Uo(this)})},Fo=function(){let i=(t,e)=>Object.defineProperty(Uint8Array.prototype,t,Bo(e));i("toBase64",function(t){return gr(this,t)}),i("toBase64URI",function(){return gr(this,!0)}),i("toBase64URL",function(){return gr(this,!0)})},Wn=()=>{zo(),Fo()},jo={version:No,VERSION:Un,atob:gi,atobPolyfill:Yo,btoa:yi,btoaPolyfill:Ro,fromBase64:li,toBase64:lt,encode:lt,encodeURI:So,encodeURL:So,utob:Do,btou:$o,decode:li,isValid:qn,fromUint8Array:gr,toUint8Array:Uo,extendString:zo,extendUint8Array:Fo,extendBuiltins:Wn},vr={encode:Jn,decode:jo.decode};function Jn(i,t={}){let{urlSafe:e=!1}=t;return jo.encode(i,e)}function Zn(i,t){return!(i.intent!==`${t}_REDIRECTION`||!("statusUrl"in i)||!("redirectUrl"in i)||!i.redirectUrl||!i.statusUrl)}function br(i){let t=es(i),e=1e3*t.exp;if(Date.now()>e)throw new Error(`${Xn}. Expiration date: ${new Date(e).toISOString()}`);return t}var Ko="The provided `clientToken`",Xn=`${Ko} has expired`,Qn=`${Ko} is malformed`;function es(i){try{let[t,e]=i.split("."),r=e||t;return JSON.parse(vr.decode(r))}catch{throw new Error(Qn)}}var Go="https://sdk.primer.io/web/hosted-pages/v0-latest",ts=`${Go}/api-controller.html`,rs=`${Go}/hosted-input.html`,is="https://goat-assets.production.core.primer.io";function qo(i,t){return btoa(JSON.stringify({checkoutSessionId:i,name:t}))}async function os(i){return new Promise((t,e)=>{let r=qo(i,"api"),o=`${ts}#${r}`,a=document.querySelector(`iframe[src="${o}"]`)??document.createElement("iframe");a.parentElement?t(a):(a.style.display="none",a.onload=()=>t(a),a.onerror=n=>{e(new Error(`Failed to initialize Primer SDK: ${n}`))},a.src=o,document.body.appendChild(a))})}var di=class extends ct{async postClientSessionActions(t){return t.length===0?Promise.resolve({data:void 0,headers:{},status:200,id:"",requestId:"",type:"http-response"}):this.post(`${this.baseUrl}/client-session/actions`,{actions:t})}async selectPaymentMethod(t,e={}){return this.postClientSessionActions([{type:"SELECT_PAYMENT_METHOD",params:{...e,paymentMethodType:t}}])}async unselectPaymentMethod(){return this.postClientSessionActions([{type:"UNSELECT_PAYMENT_METHOD"}])}async selectCardNetwork(t){return this.selectPaymentMethod(st.PAYMENT_CARD,{binData:this.buildCardBinData(t)})}async setBillingAddress(t){let e=this.removeEmptyStringFromObject(t);return this.postClientSessionActions([{type:"SET_BILLING_ADDRESS",params:{billingAddress:e}}])}async setShippingAddress(t,e,r){let o=[];return t&&Object.keys(t).some(n=>!!t[n])&&o.push({type:"SET_SHIPPING_ADDRESS",params:{shippingAddress:t}}),e&&o.push({type:"SET_MOBILE_NUMBER",params:{mobileNumber:e}}),r&&o.push({type:"SET_EMAIL_ADDRESS",params:{emailAddress:r}}),this.postClientSessionActions(o)}async selectShippingMethod(t){return this.postClientSessionActions([{type:"SELECT_SHIPPING_METHOD",params:{shippingMethodId:t}}])}async setCustomerDetails({emailAddress:t,firstName:e,lastName:r}){let o=[];return t&&o.push({type:"SET_EMAIL_ADDRESS",params:{emailAddress:t}}),e&&o.push({type:"SET_CUSTOMER_FIRST_NAME",params:{firstName:e}}),r&&o.push({type:"SET_CUSTOMER_LAST_NAME",params:{lastName:r}}),this.postClientSessionActions(o)}buildCardBinData(t){let e=this.getCardNetworkName(t);return{network:e,issuer_name:null,product_code:e,product_name:e,product_usage_type:"UNKNOWN",account_number_type:"UNKNOWN",issuer_country_code:null,account_funding_type:"UNKNOWN",issuer_currency_code:null,regional_restriction:"UNKNOWN",prepaid_reloadable_indicator:"NOT_APPLICABLE"}}getCardNetworkName(t){return{visa:"VISA",mastercard:"MASTERCARD",amex:"AMERICAN_EXPRESS",discover:"DISCOVER"}[t.toLowerCase()]||t}removeEmptyStringFromObject(t){let e={...t};for(let r in e)e[r]===""?delete e[r]:typeof e[r]=="object"&&e[r]!==null&&!Array.isArray(e[r])&&(e[r]=this.removeEmptyStringFromObject(e[r]));return e}},ci=class extends ct{async createPaypalOrder(t){return this.post(`${this.baseUrl}/paypal/orders/create`,t)}async createApplePaySession(t){return this.post(`${this.baseUrl}/apple-pay/sessions`,t)}},pi=class{constructor(t){N(this,"listeners",new Set);N(this,"state");N(this,"initialState");this.initialState=t,this.state=Object.freeze(structuredClone(t))}reset(){this.setState(structuredClone(this.initialState))}getState(){return this.state}setState(t){this.state=Object.freeze({...this.state,...t}),this.notify()}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notify(){this.listeners.forEach(t=>t(this.state))}},dt=class extends pi{constructor(e,r){super(e);N(this,"options");N(this,"channel");N(this,"key");this.key=r.id+r.name,this.options=r,this.channel=new BroadcastChannel(this.key),this.channel.addEventListener("message",this.onMessage.bind(this)),this.options.crossOriginTarget&&window.addEventListener("message",this.onMessage.bind(this)),this.requestInitialState()}requestInitialState(){this.options.main||this.postMessage({key:this.key,type:"request-initial-state"})}sendInitialState(){this.options.main&&this.postMessage({type:"post-state",key:this.key,state:super.getState()})}setState(e){this.internalSetState(e)}onMessage(e){if(e.data.key===this.key){if(e.data.type==="request-initial-state")return void this.sendInitialState();this.internalSetState(e.data.state,e.data.type)}}internalSetState(e,r){this.options.main?this.setMainState(e):this.setNonMainState(e,r)}setMainState(e){super.setState(e),this.postMessage({type:"post-state",key:this.key,state:super.getState()})}setNonMainState(e,r){if(r!=="patch-state"){if(r==="post-state")return void super.setState(e);this.postMessage({type:"patch-state",key:this.key,state:e})}}postMessage(e){this.channel.postMessage(e),this.options.crossOriginTarget?.postMessage(e,"*")}};function as(i,t,e=!1){return new dt({accessToken:"",binDataUrl:"",orderedAllowedCardNetworks:[]},{main:e,id:i,name:"checkout-config-store",crossOriginTarget:t})}var ns=le("../../node_modules/card-validator/dist/index.js"),ss=le.n(ns);function ls(i){let t=ss().number(i);return{isValid:t.isValid||!1,card:{type:t.card?.type||null,code:t.card?.code||{name:"CVV",size:4},lengths:t.card?.lengths||[16],gaps:t.card?.gaps||[4,8,12]}}}var fr={placeholder:"",ariaLabel:"",style:{}};function ds(i,t,e=!1){return{pciStore:new dt({cardNumber:"",cardSecurityCode:"",cardExpiryDate:"",cardHolderName:""},{main:e,id:i,name:"card-form-pci"}),publicStore:new dt({cardNumber:{valid:!1,dirty:!1,touched:!1,focused:!1,disabled:!1,error:""},cardSecurityCode:{valid:!1,dirty:!1,touched:!1,focused:!1,disabled:!1,error:""},cardExpiryDate:{valid:!1,dirty:!1,touched:!1,focused:!1,disabled:!1,error:""},cardHolderName:{valid:!1,dirty:!1,touched:!1,focused:!1,disabled:!1,error:""},type:ls(""),networks:[],networksSource:"LOCAL",preferredNetwork:void 0},{main:e,id:i,name:"card-form-public",crossOriginTarget:t}),optionsStore:new dt({cardNumber:structuredClone(fr),cardSecurityCode:structuredClone(fr),cardExpiryDate:structuredClone(fr),cardHolderName:structuredClone(fr)},{main:e,id:i,name:"card-form-options",crossOriginTarget:t})}}async function cs(i){let t=Ot(),e=br(i),r=await os(t),o=Vn(r,t),a=Dn(e.accessToken,t),n=as(t,r.contentWindow);n.setState({accessToken:e.accessToken});let s=new ai(o,e.configurationUrl,a),{data:l,error:c}=await s.getConfiguration();if(c||!l)throw new Error(`Failed to fetch configuration: ${c}`);n.setState({binDataUrl:l.binDataUrl,orderedAllowedCardNetworks:l.clientSession.paymentMethod.orderedAllowedCardNetworks});let h=new ni(o,l.pciUrl,a),u=new ci(o,l.coreUrl,a),y=new di(o,l.pciUrl,a);return{apiControllerIframe:r,configuration:l,checkoutSessionId:t,configurationApi:s,pciApi:h,coreApi:u,clientSessionApi:y,updateClientToken:_=>{try{let E=br(_);s.setDefaultHeader("primer-client-token",E.accessToken),h.setDefaultHeader("primer-client-token",E.accessToken),u.setDefaultHeader("primer-client-token",E.accessToken),y.setDefaultHeader("primer-client-token",E.accessToken),n.setState({accessToken:E.accessToken})}catch{}}}}var ui=class{constructor(t){N(this,"context");this.context=t}};function Wo(){return{javaEnabled:typeof window.navigator.javaEnabled=="function"?window.navigator.javaEnabled():!1,language:window.navigator.language,colorDepth:window.screen.colorDepth,screenHeight:window.screen.height,screenWidth:window.screen.width,timezoneOffset:new Date().getTimezoneOffset(),userAgent:window.navigator.userAgent}}function Jo(i){return i?new Promise(t=>{setTimeout(t,i)}):Promise.resolve()}var mi=class extends ui{async handleRequiredAction(t){let e=t.requiredAction?.clientToken;if(!e)throw new Error("No client token provided");let r=br(e);if(!("intent"in r)||r.intent!=="3DS_AUTHENTICATION")throw new Error("Invalid client token");let{error:o,data:a}=await this.context.pciApi.post3dsAuth(r.tokenId,{device:Wo()});if(o||!a||!a.authentication)throw o??new Error("Unable to authenticate");let n=a;a.authentication.responseCode==="METHOD"?n=await this.handleMethod(r.tokenId,a.authentication):a.authentication.responseCode==="CHALLENGE"&&(n=await this.handleChallenge(r.tokenId,a.authentication));let s=await this.context.pciApi.postResumePayment(t.id,n.resumeToken);if(s.error||!s.data)throw s.error??new Error("Unable to resume payment");return s.data}async handleMethod(t,e){let r="primer-3ds-method-box",o="primer-3ds-method-iframe",a="primer-3ds-method-form",n="threeDSMethodData",s=document.createElement("div");s.id=r,s.style.position="absolute",s.style.width="2px",s.style.height="2px",s.style.left="-10000px";let l=document.createElement("iframe");l.style.display="none",l.id=o,l.name=o,s.appendChild(l);let c=document.createElement("form"),h=document.createElement("input");h.type="hidden",h.id=n,h.name=n,h.value=vr.encode(JSON.stringify({threeDSServerTransID:e.transactionId,threeDSMethodNotificationURL:e.notificationUrl}),{urlSafe:!0}).replace(/=+$/g,""),c.appendChild(h),c.id=a,c.name=a,c.action=e.acsMethodUrl,c.target=o,c.method="post",s.appendChild(c),document.body.appendChild(s),c.submit();let{data:u,error:y}=await this.pollStatus(e.statusUrl,"METHOD",1e3).promise;return s.remove(),y||!u?this.continueAuth(t):u}pollStatus(t,e="METHOD",r=1e3,o=66e4){let a=!0;return{promise:new Promise(async n=>{let s=setTimeout(()=>{a=!1,n({error:new Error("Operation timed out"),data:null})},o);try{for(;a;){let l=await this.context.pciApi.get3dsResumeStatus(t);if(l.error){clearTimeout(s),n(l);return}if(await Jo(r),l.data&&l.data.authentication.responseCode!==e){clearTimeout(s),n(l);return}}}catch(l){clearTimeout(s),n({error:l,data:null})}}),abort:()=>{a=!1}}}async continueAuth(t){let{data:e,error:r}=await this.context.pciApi.post3dsContinue(t);return r||!e?{resumeToken:Ot(),authentication:{responseCode:"SKIPPED",skippedReasonCode:"NEGOTIATION_ERROR",skippedReasonText:"Failed to negotiate with 3DS server"}}:e}async handleChallenge(t,e){let r=`3ds-challenge-iframe-${Ot()}`,o=document.createElement("div");o.style.position="fixed",o.style.top="0",o.style.left="0",o.style.width="100%",o.style.height="100%",o.style.backgroundColor="rgba(0, 0, 0, 0.5)";let a=document.createElement("div");a.style.height="min(calc(100vh - 16px), 600px)",a.style.width="min(calc(100vw - 16px), 500px)",a.style.display="grid",a.style.placeContent="center",a.style.backgroundColor="#ffffff",a.style.borderRadius="3px",a.style.position="relative",a.style.boxShadow="1px 1px 5px 3px rgba(0, 0, 0, 0.05)",a.style.overflow="hidden",o.appendChild(a);let n=document.createElement("iframe");n.id=r,n.name=r,n.width="100%",n.height="100%",n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("frameBorder","0"),n.setAttribute("border","0"),n.style.position="absolute",n.style.top="0",n.style.left="0";let s=document.createElement("form");if(s.style.width="1px",s.style.height="1px",s.style.position="absolute",s.style.left="-10000px",s.action=e.acsChallengeUrl,s.target=r,s.method="post",/^1/.test(e.protocolVersion)){let u=document.createElement("input"),y=document.createElement("input");u.type="hidden",u.name="PaReq",u.id="PaReq",u.value=e.acsChallengeData??"",y.type="hidden",y.name="TermUrl",y.id="TermUrl",y.value=e.notificationUrl??"",s.appendChild(u),s.appendChild(y)}else{let u=document.createElement("input"),y=document.createElement("input");u.type="hidden",u.name="creq",u.id="creq",u.value=vr.encode(JSON.stringify({threeDSServerTransID:e.transactionId,acsTransID:e.acsTransactionId,messageVersion:e.protocolVersion,messageType:"CReq",challengeWindowSize:"05"}),{urlSafe:!0}),y.type="hidden",y.name="threeDSSessionData",y.id="threeDSSessionData",s.appendChild(u),s.appendChild(y)}a.appendChild(s),a.appendChild(n),document.body.appendChild(o),s.submit();let h=await this.pollStatus(e.statusUrl,"CHALLENGE",2500,66e4).promise;return o.remove(),h.error||!h.data?this.continueAuth(t):h.data}},Ge=class{constructor(t,e){N(this,"config");N(this,"context");this.config=Object.freeze(t),this.context=e}async setup(){return!0}async start(){}async render(t){}async handleRequiredAction(t){return t.requiredAction?.name==="3DS_AUTHENTICATION"?new mi(this.context).handleRequiredAction(t):t}async createPayment(t){let{error:e,data:r}=await this.context.pciApi.postCreatePayment(t);if(e||!r)throw e??new Error("Unable to create payment");return r.requiredAction?.clientToken&&this.context.updateClientToken(r.requiredAction.clientToken),r}async resumePayment(t,e){let{error:r,data:o}=await this.context.pciApi.postResumePayment(t,e);if(r||!o)throw r??new Error("Unable to resume payment");return o}};function ps(i){return{cardNumber:yr(i,"cardNumber"),cardSecurityCode:yr(i,"cardSecurityCode"),cardExpiryDate:yr(i,"cardExpiryDate"),cardHolderName:yr(i,"cardHolderName")}}function yr(i,t){let e=document.createElement("iframe"),r=qo(i,t);return e.src=`${rs}#${r}`,e.setAttribute("tabindex","0"),e.setAttribute("frameBorder","0"),e.style.border="none",e.style.boxSizing="border-box",e.style.height="20px",e.style.width="100%",e.style.colorScheme="auto",e}var Cr=class extends Ge{constructor(e,r){super(e,r);N(this,"iframes");N(this,"store");this.store=ds(r.checkoutSessionId,r.apiControllerIframe.contentWindow),this.iframes=ps(r.checkoutSessionId)}async tokenize(){let{error:e,data:r}=await this.context.pciApi.postPaymentInstruments("pci-card-form-data");if(e||!r)throw e??new Error("Unable to tokenize payment method");return r}},us=100;function ms({height:i,name:t,url:e="",width:r}){let o=new Set,a=window.open(e,t,fs({height:i,width:r}));if(!a)return;function n(){a?.close(),s()}function s(){o.forEach(l=>l()),o.clear(),window.removeEventListener("beforeunload",n)}return window.addEventListener("beforeunload",n),hs(a).then(s),{close:n,focus(){a.focus()},get isOpen(){return a?.closed===!1},onClose(l){return o.add(l),()=>{o.delete(l)}},setContent(l){a.document.write(l)},setUrl(l){a.location.replace(l)}}}var hs=i=>new Promise(t=>{let e=setInterval(()=>{i.closed&&(clearInterval(e),t())},us)});function fs(i){let t=ys({parent:{left:window.screenLeft,top:window.screenTop,height:window.outerHeight,width:window.outerWidth},popup:i});return gs(t)}var ys=({parent:i,popup:t})=>({left:i.left+(i.width-t.width)/2,top:i.top+(i.height-t.height)/2,height:t.height,width:t.width}),gs=i=>Object.entries(i).map(t=>t.join("=")).join(","),hi=class extends Ge{constructor(){super(...arguments);N(this,"popup")}async start(){this.openPopup()}async tokenize(){let{error:e,data:r}=await this.context.pciApi.postPaymentInstruments({type:"OFF_SESSION_PAYMENT",paymentMethodType:this.config.type,paymentMethodConfigId:this.config.id,sessionInfo:{locale:"en",platform:"WEB",browserInfo:Wo()}});if(e||!r)throw e??new Error("Unable to tokenize payment method");return r}async handleRequiredAction(e){let r=e.requiredAction?.clientToken;if(!r)throw new Error("No client token provided");let o=br(r);if(!Zn(o,this.config.type))throw new Error("Invalid client token");this.popup?.setUrl(o.redirectUrl);let a=new Promise(h=>{this.popup?.onClose(()=>h({id:""}))}),{promise:n,abort:s}=this.pollStatus(o.statusUrl),l=await Promise.race([a,n]);if(s(),this.popup?.close(),"error"in l)throw l.error;let c=l.id;if(!c){let h=await this.context.pciApi.getResumeStatus(o.statusUrl);if(h.error||!h.data?.id)throw h.error??new Error("Unable to get resume token");c=h.data.id}return await this.resumePayment(e.id,c)}pollStatus(e){let r=!0;return{promise:new Promise(async o=>{for(;r;){let{data:a,error:n}=await this.context.pciApi.getResumeStatus(e);if(n)return void o({error:n});if(await Jo(1e3),a?.status==="COMPLETE")return void o({id:a.id})}}),abort:()=>{r=!1}}}openPopup(){let{name:e,displayMetadata:{button:r,overlay:o,popup:a}}=this.config;this.popup=ms({name:e,height:a?.height??500,width:a?.width??1e3});let n=o?.logo.colored||r?.iconUrl.colored||o?.logo.light||r?.iconUrl.light||o?.logo.dark||r?.iconUrl.dark;this.popup?.setContent(vs({name:e,logoSrc:n,logoAlt:e,message:`Loading ${e}...`}))}},vs=({name:i,logoSrc:t,logoAlt:e,message:r})=>`<html>
4
4
  <head>
@@ -109,7 +109,7 @@ import{a as xi,b as d,c as N}from"./chunks/chunk.DV3REKZU.js";import{createCompo
109
109
  </div>
110
110
  </body>
111
111
  </html>
112
- `;function bs(i,t){var e={};for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&t.indexOf(r)<0&&(e[r]=i[r]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(i);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(i,r[o])&&(e[r[o]]=i[r[o]]);return e}function Cs(i,t){var e=document.querySelector('script[src="'.concat(i,'"]'));if(e===null)return null;var r=Zo(i,t),o=e.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var a=!0;return Object.keys(o.dataset).forEach(function(n){o.dataset[n]!==r.dataset[n]&&(a=!1)}),a?e:null}function Es(i){var t=i.url,e=i.attributes,r=i.onSuccess,o=i.onError,a=Zo(t,e);a.onerror=o,a.onload=r,document.head.insertBefore(a,document.head.firstElementChild)}function As(i){var t=i.sdkBaseUrl,e=i.environment,r=bs(i,["sdkBaseUrl","environment"]),o=t||xs(e),a=r,n=Object.keys(a).filter(function(c){return a[c]!==void 0&&a[c]!==null&&a[c]!==""}).reduce(function(c,h){var u=a[h].toString();return h=_s(h),h.substring(0,4)==="data"||h==="crossorigin"?c.attributes[h]=u:c.queryParams[h]=u,c},{queryParams:{},attributes:{}}),s=n.queryParams,l=n.attributes;return s["merchant-id"]&&s["merchant-id"].indexOf(",")!==-1&&(l["data-merchant-id"]=s["merchant-id"],s["merchant-id"]="*"),{url:"".concat(o,"?").concat(Ss(s)),attributes:l}}function _s(i){var t=function(e,r){return(r?"-":"")+e.toLowerCase()};return i.replace(/[A-Z]+(?![a-z])|[A-Z]/g,t)}function Ss(i){var t="";return Object.keys(i).forEach(function(e){t.length!==0&&(t+="&"),t+=e+"="+i[e]}),t}function xs(i){return i==="sandbox"?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js"}function Zo(i,t){t===void 0&&(t={});var e=document.createElement("script");return e.src=i,Object.keys(t).forEach(function(r){e.setAttribute(r,t[r]),r==="data-csp-nonce"&&e.setAttribute("nonce",t["data-csp-nonce"])}),e}function Ps(i,t){if(t===void 0&&(t=Promise),Xo(i,t),typeof document>"u")return t.resolve(null);var e=As(i),r=e.url,o=e.attributes,a=o["data-namespace"]||"paypal",n=xo(a);return o["data-js-sdk-library"]||(o["data-js-sdk-library"]="paypal-js"),Cs(r,o)&&n?t.resolve(n):ws({url:r,attributes:o},t).then(function(){var s=xo(a);if(s)return s;throw new Error("The window.".concat(a," global variable is not available."))})}function ws(i,t){t===void 0&&(t=Promise),Xo(i,t);var e=i.url,r=i.attributes;if(typeof e!="string"||e.length===0)throw new Error("Invalid url.");if(r!==void 0&&typeof r!="object")throw new Error("Expected attributes to be an object.");return new t(function(o,a){if(typeof document>"u")return o();Es({url:e,attributes:r,onSuccess:function(){return o()},onError:function(){var n=new Error('The script "'.concat(e,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return a(n)}})})}function xo(i){return window[i]}function Xo(i,t){if(typeof i!="object"||i===null)throw new Error("Expected an options object.");var e=i.environment;if(e&&e!=="production"&&e!=="sandbox")throw new Error('The `environment` option must be either "production" or "sandbox".');if(t!==void 0&&typeof t!="function")throw new Error("Expected PromisePonyfill to be a function.")}var Er=class extends Ge{constructor(){super(...arguments);N(this,"paypalInstance");N(this,"dataNamespace",Ot());N(this,"callbacks",{onStart:()=>{},onError:()=>{},onSuccess:()=>{}})}setCallbacks(e){this.callbacks=e}async tokenize(){throw new Error("PayPal does not support direct tokenization")}async setup(){let{clientId:e,intent:r}=this.config.options;if(!e||!r)return!1;try{let o=await Ps({dataNamespace:this.dataNamespace,clientId:e,currency:this.context.configuration.clientSession.order.currencyCode,components:["buttons","funding-eligibility"],disableFunding:["bancontact","card","credit"],intent:r??"authorize"});return o?(this.paypalInstance=o,!0):!1}catch{return!1}}async render(e){if(!this.paypalInstance.Buttons)return;let r=this.paypalInstance.Buttons({style:{color:"gold",shape:"rect",label:"paypal",tagline:!1},createOrder:this.handleCreateOrder.bind(this),onInit:this.handleInit.bind(this),onClick:this.handleClick.bind(this),onApprove:this.handleApprove.bind(this),onCancel:this.handleCancel.bind(this),onError:this.handleError.bind(this)});if(!r.isEligible())throw new Error("PayPal Buttons are not eligible for rendering");await r.render(e)}handleInit(e,r){}handleClick(e,r){return r.resolve()}async handleCreateOrder(){this.callbacks.onStart(),await this.context.clientSessionApi.selectPaymentMethod(this.config.type);let{data:e,error:r}=await this.context.coreApi.createPaypalOrder(this.buildCreateOrderRequestBody());if(r||!e)throw r??new Error("Unable to create PayPal order");return e.orderId}async handleApprove(e,r){let o=null;try{o=await r?.order?.get()??null}catch{}let{error:a,data:n}=await this.context.pciApi.postPaymentInstruments({external_payer_info:{email:o?.payment_source?.paypal?.email_address,external_payer_id:e.payerID??void 0},paypal_order_id:e.orderID,paypal_status:o?.status});if(a||!n)throw a??new Error("Unable to create payment instrument");let s=await this.createPayment(n.token);this.callbacks.onSuccess(s)}handleCancel(){this.context.clientSessionApi.unselectPaymentMethod()}handleError(e){}buildCreateOrderRequestBody(){let{order:{currencyCode:e,merchantAmount:r,totalOrderAmount:o,shipping:a,lineItems:n=[],fees:s=[]}}=this.context.configuration.clientSession;if(!e)throw new Error("Currency code is not provided");let l={amount:r??o,currencyCode:e,paymentMethodConfigId:this.config.id,amountBreakdown:{}},c=!n.some(({description:h})=>!h);if(c&&(l.items=n.map(({description:h,taxAmount:u,amount:y,quantity:_})=>{let E=u?Math.floor(u/_):0;return{name:h,unit_amount:{value:y,currency_code:e},quantity:_.toString(),tax:{value:E,currency_code:e}}})),c&&n.length){let h=n.reduce((E,{amount:w,quantity:I})=>E+w*I,0),u=s?.reduce?.((E,{amount:w})=>E+(w??0),0),y=n?.reduce((E,{discountAmount:w})=>E+(w??0),0),_=n?.reduce((E,{taxAmount:w,quantity:I})=>E+(w??0*I),0);l.amountBreakdown={item_total:{value:h,currency_code:e},tax_total:{value:_,currency_code:e},handling:{value:u??0,currency_code:e},shipping:{value:a?.amount??0,currency_code:e},discount:{value:y,currency_code:e}}}return l}};function Ar(i,t){return(i/100).toFixed(2)}var Po=5,_r=class extends Ge{constructor(){super(...arguments);N(this,"applePaySession",null);N(this,"callbacks",{onStart:()=>{},onError:()=>{},onSuccess:()=>{}})}setCallbacks(e){this.callbacks=e}async tokenize(){throw new Error("ApplePay does not support direct tokenization")}async setup(){try{if(!ApplePaySession||!ApplePaySession.supportsVersion(Po)||!ApplePaySession.canMakePayments())return!1;let e=window.location.hostname;if(!(this.config.options.merchantDomains||[]).includes(e))return!1}catch{return!1}return!0}async render(e){let r=document.createElement("button");r.setAttribute("style","display: inline-block;width: 100%;cursor: pointer;height: 40px;-webkit-appearance: -apple-pay-button;-apple-pay-button-type: plain;-apple-pay-button-style: black"),r.setAttribute("type","button"),r.classList.add("primer-apple-pay-button"),r.addEventListener("click",this.handleButtonClick.bind(this)),e.appendChild(r)}async handleButtonClick(){try{this.callbacks.onStart(),this.applePaySession=new ApplePaySession(Po,this.createPaymentRequest()),this.applePaySession.onvalidatemerchant=this.handleValidateMerchant.bind(this),this.applePaySession.onpaymentauthorized=this.handlePaymentAuthorized.bind(this),this.applePaySession.onpaymentmethodselected=this.handlePaymentMethodSelected.bind(this),this.applePaySession.oncancel=this.handleCancel.bind(this),this.applePaySession.begin()}catch{}}async handleValidateMerchant({validationURL:e}){if(this.applePaySession)try{let{data:r,error:o}=await this.context.coreApi.createApplePaySession({validationUrl:e,paymentMethodConfigId:this.config.id,merchantDomain:window.location.hostname});if(o||!r||!this.applePaySession)throw o??new Error("Failed to validate merchant");this.applePaySession.completeMerchantValidation(r)}catch{this.abort()}}async handlePaymentMethodSelected(){if(this.applePaySession)try{let{merchantAmount:e,totalOrderAmount:r,currencyCode:o}=this.context.configuration.clientSession.order;this.applePaySession.completePaymentMethodSelection({newTotal:{label:this.config.options.merchantName,amount:Ar(e??r,o),type:"final"}})}catch{this.abort()}}async handlePaymentAuthorized({payment:e}){if(this.applePaySession)try{let r={paymentMethodConfigId:this.config.id,token:e.token},o=await this.context.pciApi.postPaymentInstruments(r),a=await this.createPayment(o.data.token),n=await this.handleRequiredAction(a);n.status==="SUCCESS"?(this.applePaySession.completePayment(ApplePaySession.STATUS_SUCCESS),this.callbacks.onSuccess(n)):(this.applePaySession.completePayment(ApplePaySession.STATUS_FAILURE),this.callbacks.onError()),this.applePaySession=null}catch{this.applePaySession&&(this.applePaySession.completePayment(ApplePaySession.STATUS_FAILURE),this.applePaySession=null),this.callbacks.onError()}}handleCancel(){this.applePaySession=null,this.callbacks.onError()}abort(){this.applePaySession?.abort(),this.applePaySession=null,this.callbacks.onError()}createPaymentRequest(){let{countryCode:e,currencyCode:r,merchantAmount:o,totalOrderAmount:a}=this.context.configuration.clientSession.order;if(!e||!r)throw new Error("Country code and currency code are required");let n=["visa","masterCard","amex"],s=Ar(o??a,r);return{countryCode:e,currencyCode:r,merchantCapabilities:["supports3DS"],supportedNetworks:n,total:{amount:s,label:this.config.options.merchantName,type:"pending"}}}};function Ms(i,t={}){return new Promise((e,r)=>{if(document.querySelector(`script[src="${i}"]`))return void e();let o=document.createElement("script");o.src=i,Object.entries(t).forEach(([a,n])=>{o.setAttribute(a,n)}),o.onload=()=>{e()},o.onerror=()=>{r(new Error(`Failed to load script: ${i}`))},document.head.appendChild(o)})}var wo=2,Mo=0,Sr=class extends Ge{constructor(){super(...arguments);N(this,"client");N(this,"callbacks",{onStart:()=>{},onError:()=>{},onSuccess:()=>{}});N(this,"allowedPaymentMethod",{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"]}})}setCallbacks(e){this.callbacks=e}async tokenize(){throw new Error("Google Pay does not support direct tokenization")}async setup(){try{await Ms("https://pay.google.com/gp/p/js/pay.js")}catch{return!1}if(!window.google||!window.google.payments||(this.client=new google.payments.api.PaymentsClient({environment:"TEST"}),!this.client.isReadyToPay(this.buildIsReadyToPayRequest())))return!1;let{countryCode:e,currencyCode:r}=this.context.configuration.clientSession.order;return!(!e||!r)}async render(e){let r=this.client.createButton({buttonType:"buy",buttonColor:"black",buttonSizeMode:"fill",buttonRootNode:e instanceof ShadowRoot?e:void 0,onClick:this.handleButtonClick.bind(this)});e.appendChild(r)}async handleButtonClick(){this.callbacks.onStart();try{let e=this.buildPaymentDataRequest(),r=await this.client.loadPaymentData(e),{data:o,error:a}=await this.context.pciApi.postPaymentInstruments({flow:"GATEWAY",network:r.paymentMethodData.info?.cardNetwork??"OTHER",merchant_id:this.config.options.merchantId,encrypted_payload:vr.encode(r.paymentMethodData.tokenizationData.token)});if(a||!o)throw a??new Error("Failed to tokenize payment data");let n=await this.createPayment(o.token);n.status==="SUCCESS"?this.callbacks.onSuccess(n):this.callbacks.onError()}catch(e){throw this.callbacks.onError(),e}}async handlePaymentDataChanged(e){return{}}buildIsReadyToPayRequest(){return{apiVersion:wo,apiVersionMinor:Mo,allowedPaymentMethods:[this.allowedPaymentMethod]}}buildPaymentDataRequest(){let{countryCode:e,currencyCode:r,merchantAmount:o,totalOrderAmount:a}=this.context.configuration.clientSession.order;return{apiVersion:wo,apiVersionMinor:Mo,transactionInfo:{countryCode:e,currencyCode:r,displayItems:[],totalPriceStatus:"FINAL",totalPrice:Ar(o??a,r),totalPriceLabel:"Total"},merchantInfo:{merchantId:this.config.options.merchantId,merchantName:this.config.options.merchantName},allowedPaymentMethods:[{...this.allowedPaymentMethod,tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"primer",gatewayMerchantId:this.config.options.merchantId}}}]}}};async function Ts(i){let t=i.configuration.paymentMethods.map(r=>{if(r.implementationType==="WEB_REDIRECT")return new hi(r,i);if(r.type===st.PAYMENT_CARD)return new Cr(r,i);if(r.type===st.PAYPAL)return new Er(r,i);if(r.type===st.APPLE_PAY)return new _r(r,i);if(r.type===st.GOOGLE_PAY)return new Sr(r,i)}).map(r=>r?.setup().then(o=>o?r:null));return(await Promise.all(t)).filter(r=>!!r)}async function ks(i){let t=await cs(i),e=await Ts(t);return{context:t,paymentMethods:e}}var xr=class i{constructor(t,e=window.parent){N(this,"sessionId");N(this,"targetWindow");N(this,"messageHandlers",new Set);this.sessionId=t,this.targetWindow=e}send(t,e,r){let o={sessionId:this.sessionId,type:t,...r&&{target:r},...e&&{data:e}};this.targetWindow.postMessage(o,"*")}listen(t){let e=r=>{let o=r.data;if(o?.sessionId===this.sessionId){let{sessionId:a,...n}=o;t(n)}};return this.messageHandlers.add(e),window.addEventListener("message",e),()=>{window.removeEventListener("message",e),this.messageHandlers.delete(e)}}forIframe(t){if(!t.contentWindow)throw new Error("Iframe contentWindow is not available");return new i(this.sessionId,t.contentWindow)}cleanup(){this.messageHandlers.forEach(t=>{window.removeEventListener("message",t)}),this.messageHandlers.clear()}};async function Is(i){try{await i.start();let t=await i.tokenize(),e=await i.createPayment(t.token);return await i.handleRequiredAction(e)}catch(t){throw t}}var Ns=async(i,t)=>{if(!i.onBeforePaymentCreate)return!0;let e=setTimeout(()=>{},1e4);return new Promise(r=>{i.onBeforePaymentCreate({paymentMethodType:t},{continuePaymentCreation:()=>{clearTimeout(e),r(!0)},abortPaymentCreation:()=>{clearTimeout(e),r(!1)}})})};async function Qo(i,t){if(!await Ns(i,t.config.type)){i.onCheckoutFail?.(new Error("Payment creation aborted"),{});return}i.onPaymentCreationStart?.();let r=null,o=null;try{o=await Is(t)}catch(a){r=a}finally{if(r||!o){i.onCheckoutFail?.(new Error("Payment creation failed"),{});return}if(o.status==="FAILED")return void i.onCheckoutFail?.(new Error("Payment failed"),{payment:o??{}});i.onCheckoutComplete?.({payment:o})}}function Ls(i,t,e,r={}){let o=[],a="LOCAL";return e.store.publicStore.subscribe(({networks:n,networksSource:s})=>{s==="LOCAL"&&a!=="LOCAL"&&r.onCardNetworksLoading?.(),(s!==a||Os(o,n))&&(o=n,a=s,r.onCardNetworksChange?.(Rs({networks:o,source:a},t.configuration.clientSession.paymentMethod.orderedAllowedCardNetworks)))}),{createHostedInputs:()=>{let n=new xr(t.checkoutSessionId),s=l=>{let c=new Map,h=n.listen(u=>{u.target===l&&(u.type==="focus"?c.get("focus")?.():u.type==="blur"?c.get("blur")?.():u.type==="input"&&(c.get("input")?.(u.data),c.get("change")?.(u.data)))});return{cleanup:()=>{h()},getOptions:()=>e.store.optionsStore.getState()[l]||{placeholder:"",ariaLabel:"",style:{}},setOptions:u=>{e.store.optionsStore.setState({[l]:{...e.store.optionsStore.getState()[l],...u}})},render:(u,y)=>{let _=e.iframes[l];if(!_)return Promise.resolve();let E;return E=typeof u=="string"?document.querySelector(u):u,E&&(E.appendChild(_),_.onload=()=>{e.store.optionsStore.setState({[l]:y})}),Promise.resolve()},addEventListener:(u,y)=>{c.set(u,y)},focus:()=>{let u=e.iframes[l];u&&u.contentWindow&&n.forIframe(u).send("focus",void 0,l)},blur:()=>{let u=e.iframes[l];u&&u.contentWindow&&n.forIframe(u).send("blur",void 0,l)},setDisabled:u=>{let y=e.store.publicStore.getState();e.store.publicStore.setState({...y,[l]:{...y[l],disabled:u}})}}};return{cardNumberInput:s("cardNumber"),cardHolderNameInput:s("cardHolderName"),expiryInput:s("cardExpiryDate"),cvvInput:s("cardSecurityCode")}},removeHostedInputs:()=>{e.iframes.cardNumber.remove(),e.iframes.cardSecurityCode.remove(),e.iframes.cardExpiryDate.remove(),e.iframes.cardHolderName.remove()},submit:n=>{if(n?.cardNetwork){let s=e.store.publicStore.getState();e.store.publicStore.setState({...s,preferredNetwork:n.cardNetwork})}return Qo(i,e)},validate:()=>{let n=e.store.publicStore.getState(),s=[],l=["cardNumber","cardSecurityCode","cardExpiryDate","cardHolderName"];for(let c of l){let h=n[c];!h.valid&&h.error&&s.push({field:c,name:c,error:h.error,message:h.error})}return Promise.resolve({valid:s.length===0,validationErrors:s})},reset:()=>{t.apiControllerIframe?.contentWindow&&new xr(t.checkoutSessionId).forIframe(t.apiControllerIframe).send("reset-card-form")}}}function Os(i,t){if(i.length!==t.length)return!0;let e=t.map(({network:r})=>r);return!i.every(({network:r})=>e.includes(r))}function Rs({networks:i,source:t},e){let r=e,o=new Set(r.map(l=>ko(l).backend)),a=i.map(l=>({...l,allowed:o.has(l.network)})).sort((l,c)=>l.allowed?r.indexOf(l.network)-r.indexOf(c.network):1),n=a.filter(l=>l.allowed),s=t==="REMOTE"&&n.length>1;return{detectedCardNetworks:{items:a,preferred:n[0]},...s&&{selectableCardNetworks:{items:n,preferred:n[0]}},source:t}}function Ds(i,t,e){return{createButton:()=>({render:async r=>{e.setCallbacks({onStart:()=>{i.onBeforePaymentCreate?.({paymentMethodType:e.config.type},{continuePaymentCreation:()=>{i.onPaymentCreationStart?.()},abortPaymentCreation:()=>{}})},onSuccess(o){i.onCheckoutComplete?.({payment:o})},onError(){i.onCheckoutFail?.(new Error("Payment creation failed"),{})}}),await e.render(r)}})}}function $s(i,t,e){return{start:()=>Qo(i,e)}}async function ea(i,t){let{paymentMethods:e,context:r}=await ks(i);return t.onAvailablePaymentMethodsLoad?.(e.map(o=>({type:o.config.type,managerType:o.config.type===st.PAYMENT_CARD?"CARD":o.config.implementationType==="NATIVE_SDK"?"NATIVE":"REDIRECT"}))),{start:()=>Promise.resolve(),createPaymentMethodManager:async(o,a)=>{let n=e.find(({config:s})=>s.type===o);return n?n instanceof Cr?Ls(t,r,n,a):n instanceof Er||n instanceof _r||n instanceof Sr?Ds(t,r,n):$s(t,r,n):null},getSDKUtilities:()=>({getCardNetworkAsset:o=>{let{asset:a,display:n}=ko(o);return{cardUrl:`${is}/brand/card/${a}.svg`,displayName:n}},getUIOrderAmount:()=>{let{merchantAmount:o,totalOrderAmount:a,currencyCode:n}=r.configuration.clientSession.order;return Ar(o??a,n)},getCDNAssets:o=>{let a=e.find(({config:c})=>c.type===o);if(!a)return null;let{backgroundColor:n,iconUrl:s,text:l}=a.config.displayMetadata?.button||{};return{backgroundColor:n,iconUrl:s,paymentMethodName:l,displayName:a.config.name}},getPaymentMethodConfiguration:o=>e.find(({config:a})=>a.type===o)?.config}),createVaultManager:()=>({})}}var Pr=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 L(t,{args:()=>[this.host.clientToken,this.host.options],task:this.initializeHeadless()}),new L(t,{args:()=>[this.sdkInstanceTask.value,this.paymentsList],task:this.initializeLitContext()})}set paymentsList(t){this._paymentsList=t,this.host.requestUpdate()}get paymentsList(){return this._paymentsList}hostConnected(){this.isDisconnected=!1,this.host.sdkStateController.startLoading(),this.setupLoadingTimeout()}hostDisconnected(){this.isDisconnected=!0,this.cleanupResources()}setupLoadingTimeout(){this.clearLoadingTimeout(),this.loadingTimeout=setTimeout(()=>{this.host.sdkStateController.currentState.isLoading&&(A.warn("Loading timeout reached, resetting SDK state"),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(),A.info("SDK instance cleaned up")}catch(t){A.error("Error cleaning up SDK instance:",t)}this.currentSdkInstance=null,this.primerJS=null}async _loadV2Sdk(t=uo){let e=window;if(e.Primer&&typeof e.Primer.preloadPrimer=="function"){A.info("SDK already loaded, skipping load script"),await e.Primer.preloadPrimer();return}await ho(t),await e.Primer.preloadPrimer()}initializeHeadless(){return async([t,e])=>{if(this.isDisconnected)return A.warn("Component disconnected, aborting SDK initialization"),M;if(!t||!e)return M;this.cleanupResources();try{let r;e.sdkCore?r={createHeadless:(s,l)=>ea(s,l)}:(await this._loadV2Sdk(),r=window.Primer),this.primerJS=new mr(null);let o=await r.createHeadless(t,{...e,onAvailablePaymentMethodsLoad:n=>{this.isDisconnected||(A.info("Configuration payment methods:",n),this.paymentsList=n)},onCheckoutComplete:({payment:n})=>{this.isDisconnected||(A.info("Payment completed:",n),this.host.sdkStateController.completeProcessing(),this.primerJS&&this.primerJS.handlePaymentComplete(n))},onCheckoutFail:(n,s)=>{this.isDisconnected||(A.error("Payment failed:",n),this.host.sdkStateController.setFailure(n.code||"UNKNOWN_ERROR",n.message||"Unknown error occurred"),this.primerJS&&this.primerJS.handlePaymentFailure(n,s.payment))},onBeforePaymentCreate:(n,s)=>{this.isDisconnected||(this.host.sdkStateController.startProcessing(),this.primerJS?this.primerJS.handleBeforePaymentCreate(n,s):s?.continuePaymentCreation())},onPaymentMethodAction:(n,s)=>{this.isDisconnected||n==="PAYMENT_METHOD_UNSELECTED"&&this.host.sdkStateController.stopProcessing()},onPaymentCreationStart:()=>{this.isDisconnected||(this.host.sdkStateController.resetError(),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(),M;this.host.sdkContextController.setClientOptions(e),this.primerJS&&this.host.primerEventsController.dispatchCheckoutInitialized(this.primerJS);let a=o.getSDKUtilities();return this.host.sdkContextController.setHeadlessUtils(a),this.host.vaultManagerController.initializeVaultManager(o.createVaultManager(),{vaultEnabled:e.vault?.enabled,captureVaultedCardCvv:!!a.getPaymentMethodConfiguration("PAYMENT_CARD")?.options?.captureVaultedCardCvv,showEmptyState:e.vault?.showEmptyState}),o}catch(r){throw r instanceof Error&&(A.error("SDK initialization error:",r),this.host.sdkStateController.setError(r)),this.cleanupResources(),r}}}initializeLitContext(){return async([t,e])=>{if(this.isDisconnected)return M;if(!t||!e.length)return M;let r=new Map,o=new Map;try{for(let n of e){if(this.isDisconnected)break;let s=await this.initializePaymentMethodManager(n)();n&&s&&(r.set(n.type,n),o.set(n.type,s))}if(this.isDisconnected)return M;let a=new ur(r);return this.host.sdkContextController.setPaymentManagers(o),this.host.sdkContextController.setPaymentMethods(a),this.primerJS&&this.primerJS.setPaymentMethods(a),this.host.primerEventsController.dispatchPaymentMethods(a),A.info("Initialized payment methods:",a.toArray()),r}catch(a){if(a instanceof Error)throw this.host.sdkStateController.setError(a),a;return null}finally{this.clearLoadingTimeout(),this.isDisconnected||this.host.sdkStateController.completeLoading()}}}initializePaymentMethodManager(t){let{type:e,managerType:r}=t;return async()=>{if(this.isDisconnected||!this.createPaymentMethodManager)return null;if(r==="KLARNA"){let o=await this.createPaymentMethodManager("KLARNA",{onPaymentMethodCategoriesChange:a=>{this.isDisconnected||this.host.sdkContextController.setKlarnaCategories({categories:a,isLoading:!1})}});return o?{type:e,manager:o}:null}try{if(r==="CARD"){let a=await this.createPaymentMethodManager(e,{onCardNetworksChange:n=>{this.isDisconnected||this.host.cardNetworkController.processCardNetworkChangeEvent(n)},onCardNetworksLoading:()=>{this.isDisconnected||this.host.cardNetworkController.setCardNetworksLoading()}});return a?{type:e,manager:a}:null}let o=await this.createPaymentMethodManager(e);return o?{type:e,manager:o}:null}catch(o){return A.error(`Failed to initialize manager for ${e}:`,o),null}}}};var wr=class{constructor(t){this.host=t,t.addController(this)}_error(t){let{error:e}=t.detail;this.host.sdkStateController.setFailure("UNKNOWN_ERROR",e.message)}_mandateConfirmed(){this.host.sdkStateController.completeProcessing()}_mandateDeclined(){this.host.sdkStateController.setFailure("UNKNOWN_ERROR","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 Ys=xi({"../../localization/lit-localize/locales/ar.ts":()=>import("./chunks/ar.KRXB3WQO.js"),"../../localization/lit-localize/locales/bg.ts":()=>import("./chunks/bg.6SKJRXIR.js"),"../../localization/lit-localize/locales/ca.ts":()=>import("./chunks/ca.SANDLFEK.js"),"../../localization/lit-localize/locales/cs.ts":()=>import("./chunks/cs.FC4I5M3C.js"),"../../localization/lit-localize/locales/da.ts":()=>import("./chunks/da.YI32NZ7B.js"),"../../localization/lit-localize/locales/de.ts":()=>import("./chunks/de.7M7UFQB7.js"),"../../localization/lit-localize/locales/el.ts":()=>import("./chunks/el.XSGTYDZR.js"),"../../localization/lit-localize/locales/en-GB.ts":()=>import("./chunks/en-GB.VO4GDE3X.js"),"../../localization/lit-localize/locales/en.ts":()=>import("./chunks/en.MNFLVOE3.js"),"../../localization/lit-localize/locales/es-AR.ts":()=>import("./chunks/es-AR.TBWVUZEF.js"),"../../localization/lit-localize/locales/es-MX.ts":()=>import("./chunks/es-MX.6EMWUABR.js"),"../../localization/lit-localize/locales/es.ts":()=>import("./chunks/es.XZLDFHYI.js"),"../../localization/lit-localize/locales/et-EE.ts":()=>import("./chunks/et-EE.JBSFMKZ2.js"),"../../localization/lit-localize/locales/fi-FI.ts":()=>import("./chunks/fi-FI.I75VK2ID.js"),"../../localization/lit-localize/locales/fr.ts":()=>import("./chunks/fr.JBNP6RXT.js"),"../../localization/lit-localize/locales/he.ts":()=>import("./chunks/he.PW253QAL.js"),"../../localization/lit-localize/locales/hr.ts":()=>import("./chunks/hr.LM4RITYJ.js"),"../../localization/lit-localize/locales/hu.ts":()=>import("./chunks/hu.JGCKQA6J.js"),"../../localization/lit-localize/locales/id.ts":()=>import("./chunks/id.VBXULDDY.js"),"../../localization/lit-localize/locales/it.ts":()=>import("./chunks/it.7Q6BFLDK.js"),"../../localization/lit-localize/locales/ja.ts":()=>import("./chunks/ja.QOC76SSC.js"),"../../localization/lit-localize/locales/ko.ts":()=>import("./chunks/ko.BANZIFNH.js"),"../../localization/lit-localize/locales/lt-LT.ts":()=>import("./chunks/lt-LT.Q2SRJOKH.js"),"../../localization/lit-localize/locales/lt.ts":()=>import("./chunks/lt.XMNFEN5T.js"),"../../localization/lit-localize/locales/lv-LV.ts":()=>import("./chunks/lv-LV.3AJDTMU5.js"),"../../localization/lit-localize/locales/lv.ts":()=>import("./chunks/lv.TFPDXNEV.js"),"../../localization/lit-localize/locales/ms.ts":()=>import("./chunks/ms.FPTX4NM4.js"),"../../localization/lit-localize/locales/nb.ts":()=>import("./chunks/nb.CAFSKRQ2.js"),"../../localization/lit-localize/locales/nl.ts":()=>import("./chunks/nl.7BPSDYTC.js"),"../../localization/lit-localize/locales/nl_NL.ts":()=>import("./chunks/nl_NL.6ZVCFPVW.js"),"../../localization/lit-localize/locales/pl.ts":()=>import("./chunks/pl.RF34QM23.js"),"../../localization/lit-localize/locales/pt-BR.ts":()=>import("./chunks/pt-BR.AKDHLRUA.js"),"../../localization/lit-localize/locales/pt.ts":()=>import("./chunks/pt.VBALOWHZ.js"),"../../localization/lit-localize/locales/ro.ts":()=>import("./chunks/ro.WN7VCF27.js"),"../../localization/lit-localize/locales/ru.ts":()=>import("./chunks/ru.ICXGVGRR.js"),"../../localization/lit-localize/locales/sk.ts":()=>import("./chunks/sk.SIP5JIOX.js"),"../../localization/lit-localize/locales/sl.ts":()=>import("./chunks/sl.R77UEKCA.js"),"../../localization/lit-localize/locales/sr-RS.ts":()=>import("./chunks/sr-RS.6M2YSTDX.js"),"../../localization/lit-localize/locales/sv.ts":()=>import("./chunks/sv.33ZY4CDS.js"),"../../localization/lit-localize/locales/th.ts":()=>import("./chunks/th.M27YUIZC.js"),"../../localization/lit-localize/locales/tr.ts":()=>import("./chunks/tr.Q2SIY6NA.js"),"../../localization/lit-localize/locales/uk-UA.ts":()=>import("./chunks/uk-UA.EJZOGSJR.js"),"../../localization/lit-localize/locales/vi.ts":()=>import("./chunks/vi.3RROGLXM.js"),"../../localization/lit-localize/locales/zf.ts":()=>import("./chunks/zf.GGWFQ3Y7.js"),"../../localization/lit-localize/locales/zh-CN.ts":()=>import("./chunks/zh-CN.MQHNRMN4.js"),"../../localization/lit-localize/locales/zh-HK.ts":()=>import("./chunks/zh-HK.WNR7XUSX.js"),"../../localization/lit-localize/locales/zh-TW.ts":()=>import("./chunks/zh-TW.GNCY2PNY.js")});qr(i=>Ys(`../../localization/lit-localize/locales/${i}.ts`));var Vs={LOADER_DISABLED:"loader-disabled",CUSTOM_STYLES:"custom-styles",CLIENT_TOKEN:"client-token",JS_INIT:"js-initialized"},q=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.locale="en-GB";this.onSlotChange=e=>{let o=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=o.length>0,this.requestUpdate()};this.sdkContextController=new jt(this),this.sdkStateController=new zt(this),this.primerEventsController=new tt(this),this.styleProcessingController=new Kt(this),this.vaultManagerController=new bt(this),this.cardNetworkController=new $t(this),this.achPaymentEventsController=new wr(this),new Pr(this)}set jsInitialized(e){this.requestUpdate(),this._jsInitialized=e}get jsInitialized(){return this._jsInitialized}attributeChangedCallback(e,r,o){e===Vs.CUSTOM_STYLES?this.styleProcessingController.processCustomStyles(o):super.attributeChangedCallback(e,r,o)}disconnectedCallback(){this._loadingTimeoutId&&(window.clearTimeout(this._loadingTimeoutId),this._loadingTimeoutId=null),this.sdkStateController?.currentState.isLoading&&this.sdkStateController.forceCompleteLoading(),super.disconnectedCallback()}willUpdate(e){e.has("options")&&(this.options?.locale&&(Jr(this.options?.locale)?this.locale=Zr(this.options?.locale):A.warn("\u{1F30E}\u2757 Unsupported locale provided:",this.options?.locale,"- Falling back to default locale `en-GB`")),Wr(this.locale||"en-GB"))}updated(){let e=getComputedStyle(this);this.sdkContextController.setComputedStyles(e),this.checkLoadingStateChange()}checkLoadingStateChange(){let e=this.sdkStateController?.currentState.isLoading||!1;this.previousLoadingState&&!e&&(this.jsInitialized=!0),this.previousLoadingState=e,e&&!this._loadingTimeoutId?this._loadingTimeoutId=window.setTimeout(()=>{this.sdkStateController?.currentState.isLoading&&(A.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,r=e.isLoading,o=e.error,a=!r&&!o;return m` ${O(r,()=>f)} ${O(o,()=>m`<primer-checkout-error></primer-checkout-error>`)} ${O(a,()=>m`<slot name="main" @slotchange=${this.onSlotChange}></slot>${O(this.hasAssignedContent,()=>f,()=>m`<primer-main></primer-main>`)} `,()=>f)} `}addEventListener(e,r,o){super.addEventListener(e,r,o)}removeEventListener(e,r,o){super.removeEventListener(e,r,o)}};q.styles=[T,po],d([p({type:String,attribute:"custom-styles"})],q.prototype,"customStyles",2),d([p({type:String,attribute:"client-token"})],q.prototype,"clientToken",2),d([p({type:Object})],q.prototype,"options",2),d([p({type:Boolean,attribute:"loader-disabled"})],q.prototype,"disableLoader",2),d([p({type:Boolean,reflect:!0,attribute:"js-initialized"})],q.prototype,"_jsInitialized",2),d([ke("slot")],q.prototype,"defaultSlot",2),d([P()],q.prototype,"previousLoadingState",2),q=d([R(),b("primer-checkout")],q);var Bs=Us({tagName:"primer-checkout",elementClass:q,react:Hs});import{createComponent as zs}from"@lit/react";import Fs from"react";var ta=g` :host { display: flex; flex-direction: column; align-items: center; gap: var(--primer-space-xsmall); } p { margin: 0; color: var(--primer-color-text-primary); text-align: center; font-size: var(--primer-typography-body-large-size); font-family: var(--primer-typography-body-large-font); font-weight: var(--primer-typography-body-large-weight); line-height: var(--primer-typography-body-large-line-height); letter-spacing: var(--primer-typography-body-large-letter-spacing); } p.secondary { color: var(--primer-color-text-secondary); text-align: center; font-family: var(--primer-typography-body-medium-font, Inter); font-size: var(--primer-typography-body-medium-size); font-weight: var(--primer-typography-body-medium-weight); line-height: var(--primer-typography-body-medium-line-height); letter-spacing: var(--primer-typography-body-medium-letter-spacing); } `;var be=class extends v{constructor(){super(...arguments);this.type="complete"}render(){return this.type==="complete"?m`<primer-icon size="lg" name="successful-check" color="var(--primer-color-icon-positive)" ></primer-icon><p>Checkout complete!</p><p class="secondary"> You'll be redirected to the order confirmation page soon. </p>`:m`<primer-icon size="lg" name="failure-icon" color="var(--primer-color-icon-negative)" ></primer-icon><p>Payment failed</p>${this.description?m`<p class="secondary">${this.description}</p>`:m`<p class="secondary">Something went wrong.</p>`} `}};be.styles=[ta],d([p({type:String,reflect:!0})],be.prototype,"type",2),d([p({type:String,reflect:!0})],be.prototype,"description",2),be=d([b("primer-checkout-state")],be);var js=zs({tagName:"primer-checkout-state",elementClass:be,react:Fs});import{createComponent as Ks}from"@lit/react";import Gs from"react";var ra=g` :host { display: block; } .collapsable { width: 100%; } /* Make the button display with full width */ primer-button::part(button) { width: 100%; } .collapsable-wrapper { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--primer-animation-duration) var(--primer-animation-easing); overflow: hidden; border-top: none; margin-top: -1px; } .collapsable-wrapper.expanded { grid-template-rows: 1fr; } .collapsable-content { min-height: 0; overflow: hidden; padding: var(--primer-space-medium, 12px) 0; } .icon-container { display: flex; align-items: center; justify-content: center; transition: transform var(--primer-animation-duration) var(--primer-animation-easing); font-size: 0.75em; } .icon-container.expanded { transform: rotate(180deg); } /* Disable animation for users who prefer reduced motion */ @media (prefers-reduced-motion: reduce) { .collapsable-wrapper, .icon-container { transition: none; } } `;var W=class extends v{constructor(){super(...arguments);this.header="";this.expanded=!1;this.expandText="Expand";this.collapseText="Collapse";this.ariaLabel="";this.buttonVariant="primary";this.isExpanded=!1;this.toggleExpanded=()=>{this.isExpanded=!this.isExpanded,this.dispatchExpandedChangedEvent(this.isExpanded)}}connectedCallback(){super.connectedCallback(),this.isExpanded=this.expanded}dispatchExpandedChangedEvent(e){this.dispatchEvent(new CustomEvent("expanded-changed",{bubbles:!0,composed:!0,detail:{expanded:e}}))}expand(){this.isExpanded||(this.isExpanded=!0,this.dispatchExpandedChangedEvent(!0))}collapse(){this.isExpanded&&(this.isExpanded=!1,this.dispatchExpandedChangedEvent(!1))}render(){let e=this.isExpanded?this.collapseText:this.expandText,r=this.ariaLabel||this.header||e,o=this.header||e;return m`<div class="collapsable"><primer-button variant=${this.buttonVariant} buttonType="button" @click=${this.toggleExpanded} aria-expanded=${this.isExpanded} aria-controls="collapsable-content" aria-label=${r} ><span>${o}</span></primer-button><div class="collapsable-wrapper ${this.isExpanded?"expanded":""}" id="collapsable-content" role="region" aria-labelledby="collapsable-header" ><div class="collapsable-content"><slot></slot></div></div></div>`}};W.styles=[ra],d([p({type:String})],W.prototype,"header",2),d([p({type:Boolean})],W.prototype,"expanded",2),d([p({type:String})],W.prototype,"expandText",2),d([p({type:String})],W.prototype,"collapseText",2),d([p({type:String})],W.prototype,"ariaLabel",2),d([p({type:String})],W.prototype,"buttonVariant",2),d([P()],W.prototype,"isExpanded",2),W=d([b("primer-collapsable")],W);var qs=Ks({tagName:"primer-collapsable",elementClass:W,react:Gs});import{createComponent as Ws}from"@lit/react";import Js from"react";var ia=g` :host { display: contents; } .backdrop { position: absolute; top: 0; left: 0; background-color: rgba(0, 0, 0, 0.5); z-index: 1000; display: flex; justify-content: center; align-items: center; width: 100vw; height: 100vh; } .dialog { background-color: white; padding: var(--primer-space-medium); border-radius: var(--primer-radius-medium); max-width: 600px; } .header { display: flex; justify-content: flex-end; } `;var Ie={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Ce=i=>(...t)=>({_$litDirective$:i,values:t}),ut=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,r){this._$Ct=t,this._$AM=e,this._$Ci=r}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};var F=Ce(class extends ut{constructor(i){if(super(i),i.type!==Ie.ATTRIBUTE||i.name!=="class"||i.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(i){return" "+Object.keys(i).filter(t=>i[t]).join(" ")+" "}update(i,[t]){if(this.st===void 0){this.st=new Set,i.strings!==void 0&&(this.nt=new Set(i.strings.join(" ").split(/\s/).filter(r=>r!=="")));for(let r in t)t[r]&&!this.nt?.has(r)&&this.st.add(r);return this.render(t)}let e=i.element.classList;for(let r of this.st)r in t||(e.remove(r),this.st.delete(r));for(let r in t){let o=!!t[r];o===this.st.has(r)||this.nt?.has(r)||(o?(e.add(r),this.st.add(r)):(e.remove(r),this.st.delete(r)))}return ve}});var qe=class extends v{constructor(){super(...arguments);this._handleCloseClick=()=>{this.dispatchEvent(new CustomEvent("primer-dialog-close",{bubbles:!0,composed:!0}))}}render(){return m`<div class=${F({backdrop:!0})} @click=${e=>{e.preventDefault()}} ><div class="dialog"><div class="header"><primer-button variant="tertiary" @click=${this._handleCloseClick}><primer-icon name="close"></primer-icon></primer-button></div><div class="content"><slot></slot></div></div></div>`}};qe.styles=[ia],qe=d([b("primer-dialog")],qe);var Zs=Ws({tagName:"primer-dialog",elementClass:qe,react:Js});import{createComponent as Xs}from"@lit/react";import Qs from"react";var oa=g` :host { display: block; width: 100%; box-sizing: border-box; } .error-message { display: flex; align-items: flex-start; padding: var(--primer-space-medium); background-color: var(--primer-color-red-100); border-radius: var(--primer-radius-medium); border: 1px solid var(--primer-color-border-outlined-error); margin-top: var(--primer-space-small); box-sizing: border-box; width: 100%; /* Add animation properties */ opacity: 1; transform: translateY(0); transition: opacity var(--primer-animation-duration) var(--primer-animation-easing), transform var(--primer-animation-duration) var(--primer-animation-easing); } .error-message.hidden { opacity: 0; transform: translateY(-var(--primer-space-medium)); pointer-events: none; } .error-icon { flex-shrink: 0; margin-right: var(--primer-space-medium); color: var(--primer-color-icon-negative); } .error-content { flex: 1; font-family: var(--primer-typography-body-medium-font); font-size: var(--primer-typography-body-medium-size); font-weight: var(--primer-typography-body-medium-weight); line-height: var(--primer-typography-body-medium-line-height); letter-spacing: var(--primer-typography-body-medium-letter-spacing); color: var(--primer-color-text-negative); } /* Respect user's preference for reduced motion */ @media (prefers-reduced-motion: reduce) { .error-message { transition: opacity var(--primer-animation-duration) var(--primer-animation-easing); transform: none; } .error-message.hidden { transform: none; } } `;var de=class extends v{constructor(){super();this.message="";this.visible=!1;this._role="alert";this.showMessage=!1;this.role="alert"}get role(){return this._role}set role(e){this._role=e,this.setAttribute("role",e)}updated(e){e.has("visible")&&this.handleVisibilityChange()}handleVisibilityChange(){this.visible?(this.showMessage=!0,this.setAttribute("aria-hidden","false")):setTimeout(()=>{this.showMessage=!1,this.setAttribute("aria-hidden","true")},200)}render(){if(!this.showMessage&&!this.visible)return f;let e={"error-message":!0,hidden:!this.visible};return m`<div part="error-message" class=${F(e)} aria-live="assertive" aria-atomic="true" ><div part="error-icon" class="error-icon"><primer-icon name="failure-icon" size="sm" color="var(--primer-color-icon-negative)" ></primer-icon></div><div part="error-content" class="error-content">${this.message}</div></div>`}};de.styles=[oa],d([p({type:String})],de.prototype,"message",2),d([p({type:Boolean,reflect:!0})],de.prototype,"visible",2),d([P()],de.prototype,"showMessage",2),de=d([b("primer-error-message")],de);var el=Xs({tagName:"primer-error-message",elementClass:de,react:Qs});import{createComponent as tl}from"@lit/react";import rl from"react";var aa={trash:ne`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13.8333 2.99992H11.5V2.49992C11.5 2.05789 11.3244 1.63397 11.0118 1.32141C10.6993 1.00885 10.2754 0.833252 9.83333 0.833252H6.16667C5.72464 0.833252 5.30072 1.00885 4.98816 1.32141C4.67559 1.63397 4.5 2.05789 4.5 2.49992V2.99992H2.16667C1.98986 2.99992 1.82029 3.07015 1.69526 3.19518C1.57024 3.32021 1.5 3.48978 1.5 3.66659C1.5 3.8434 1.57024 4.01297 1.69526 4.138C1.82029 4.26302 1.98986 4.33326 2.16667 4.33326H2.83333V12.4999C2.83333 12.942 3.00893 13.3659 3.32149 13.6784C3.63405 13.991 4.05797 14.1666 4.5 14.1666H11.5C11.942 14.1666 12.3659 13.991 12.6785 13.6784C12.9911 13.3659 13.1667 12.942 13.1667 12.4999V4.33326H13.8333C14.0101 4.33326 14.1797 4.26302 14.3047 4.138C14.4298 4.01297 14.5 3.8434 14.5 3.66659C14.5 3.48978 14.4298 3.32021 14.3047 3.19518C14.1797 3.07015 14.0101 2.99992 13.8333 2.99992ZM5.83333 2.49992C5.83333 2.32311 5.90357 2.15354 6.0286 2.02851C6.15362 1.90349 6.32319 1.83325 6.5 1.83325H9.5C9.67681 1.83325 9.84638 1.90349 9.9714 2.02851C10.0964 2.15354 10.1667 2.32311 10.1667 2.49992V2.99992H5.83333V2.49992ZM11.8333 12.4999C11.8333 12.6767 11.7631 12.8463 11.6381 12.9713C11.513 13.0964 11.3435 13.1666 11.1667 13.1666H4.83333C4.65652 13.1666 4.48695 13.0964 4.36193 12.9713C4.2369 12.8463 4.16667 12.6767 4.16667 12.4999V4.33326H11.8333V12.4999Z" fill="currentColor"/><path d="M6.5 10.9999C6.67681 10.9999 6.84638 10.9297 6.9714 10.8047C7.09643 10.6796 7.16667 10.5101 7.16667 10.3333V7.33325C7.16667 7.15644 7.09643 6.98687 6.9714 6.86184C6.84638 6.73682 6.67681 6.66658 6.5 6.66658C6.32319 6.66658 6.15362 6.73682 6.0286 6.86184C5.90357 6.98687 5.83333 7.15644 5.83333 7.33325V10.3333C5.83333 10.5101 5.90357 10.6796 6.0286 10.8047C6.15362 10.9297 6.32319 10.9999 6.5 10.9999Z" fill="currentColor"/><path d="M9.5 10.9999C9.67681 10.9999 9.84638 10.9297 9.9714 10.8047C10.0964 10.6796 10.1667 10.5101 10.1667 10.3333V7.33325C10.1667 7.15644 10.0964 6.98687 9.9714 6.86184C9.84638 6.73682 9.67681 6.66658 9.5 6.66658C9.32319 6.66658 9.15362 6.73682 9.0286 6.86184C8.90357 6.98687 8.83333 7.15644 8.83333 7.33325V10.3333C8.83333 10.5101 8.90357 10.6796 9.0286 10.8047C9.15362 10.9297 9.32319 10.9999 9.5 10.9999Z" fill="currentColor"/></svg>`,"successful-check":ne`<svg viewBox="0 0 56 56" fill="none" xmlns="http://www.w3.org/2000/svg" ><g id="icon/check-circle-large"><path id="vector" fill-rule="evenodd" clip-rule="evenodd" d="M20.1762 29.5746L24.8429 34.2413C25.295 34.7007 26.0387 34.7007 26.4908 34.2413L35.8241 24.9079C36.2835 24.4559 36.2835 23.7121 35.8241 23.26C35.372 22.8007 34.6283 22.8007 34.1762 23.26L25.6668 31.7694L21.8241 27.9267C21.372 27.4673 20.6283 27.4673 20.1762 27.9267C19.7168 28.3788 19.7168 29.1225 20.1762 29.5746ZM28.0002 47.4173C38.3106 47.4173 46.6668 39.0611 46.6668 28.7507C46.6668 18.4402 38.3106 10.084 28.0002 10.084C17.6897 10.084 9.3335 18.4402 9.3335 28.7507C9.3335 39.0611 17.6897 47.4173 28.0002 47.4173Z" /></g></svg>`,"failure-icon":ne`<svg viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg" ><path fill-rule="evenodd" clip-rule="evenodd" d="M20.0008 23.3333C20.4614 23.3333 20.7873 22.9606 20.7873 22.5V15C20.7873 14.5394 20.4146 14.1666 20.0008 14.1666C19.587 14.1666 19.1675 14.5416 19.1675 15V22.5C19.1675 22.9583 19.5425 23.3333 20.0008 23.3333ZM32.9331 27.3594L22.5269 9.75935C22.0008 8.86821 21.0529 8.33488 20.0008 8.33331C18.9487 8.33331 18.006 8.8656 17.4748 9.75831L7.06331 27.3625C6.53987 28.2463 6.53206 29.3073 7.04134 30.201C7.568 31.1198 8.51904 31.6666 9.58935 31.6666H30.4175C31.4857 31.6666 32.4357 31.1182 32.9597 30.1995C33.4696 29.3073 33.4591 28.2448 32.9331 27.3594ZM18.7977 26.6666C18.7977 25.976 19.3107 25.4166 20.0008 25.4166C20.6935 25.4166 21.2508 25.9739 21.2039 26.6666C21.2039 27.3568 20.6909 27.9166 20.0008 27.9166C19.3576 27.9166 18.7977 27.3568 18.7977 26.6666Z" /></svg>`,"payment-card":ne`<svg width="28" height="21" viewBox="0 0 28 21" fill="none" xmlns="http://www.w3.org/2000/svg"><rect y="0.748047" width="28" height="20" rx="2" fill="#E0E0E0"/><rect y="6.74805" width="28" height="4" fill="#212121"/><rect x="19" y="13.748" width="6" height="4" rx="0.933333" fill="white"/></svg>`,"chevron-down":ne`<svg width="8" height="6" viewBox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.41978 4.90118C4.32079 5.02361 4.16188 5.08353 4.00037 5.08353C3.83887 5.08353 3.67996 5.02361 3.55753 4.90118L0.63995 1.9836C0.395733 1.73939 0.395733 1.34382 0.63995 1.09947C0.884167 0.855124 1.27973 0.855254 1.52408 1.09947L4.00037 3.57524L6.47589 1.09973C6.72011 0.855515 7.11567 0.855515 7.36002 1.09973C7.60437 1.34395 7.60424 1.73952 7.36002 1.98386L4.41978 4.90118Z" fill="#212121"/></svg>`,checkmark:ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15.6326 6.12193C15.8983 6.3668 15.8983 6.76276 15.6326 6.98418L8.75546 13.8613C8.53404 14.127 8.13808 14.127 7.89321 13.8613L4.35119 10.3186C4.10706 10.0971 4.10706 9.70118 4.35119 9.45631C4.59531 9.21404 4.99126 9.21404 5.23535 9.45631L8.33606 12.5588L14.7704 6.12193C15.0152 5.87863 15.4112 5.87863 15.6326 6.12193Z" /></svg>`,close:ne`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none"><path d="M14.7551 13.734C15.0479 14.0269 15.0479 14.502 14.7551 14.7949C14.4622 15.0879 13.987 15.0878 13.6941 14.7949L10.0005 11.0738L6.28054 14.7937C5.98767 15.0866 5.51249 15.0866 5.21959 14.7937C4.92668 14.5008 4.92671 14.0256 5.21959 13.7327L8.94075 10.0141L5.21856 6.26604C4.92568 5.97316 4.92568 5.49798 5.21856 5.20508C5.51143 4.91217 5.98661 4.91221 6.27951 5.20508L10.0005 8.95438L13.7204 5.23446C14.0132 4.94159 14.4884 4.94159 14.7813 5.23446C15.0742 5.52734 15.0742 6.00252 14.7813 6.29542L11.0602 10.0141L14.7551 13.734Z" fill="#212121" /></svg>`,edit:ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10.9355 3.19972C11.7814 2.35335 13.1541 2.35335 13.9999 3.19972L14.3642 3.56456C15.21 4.41103 15.21 5.78338 14.3642 6.62925L8.42804 12.5684C8.16615 12.8272 7.84406 13.0169 7.48886 13.1192L4.47866 13.9802C4.2258 14.0524 3.95489 13.9802 3.76825 13.7694C3.58463 13.6099 3.51239 13.339 3.58463 13.0861L4.44555 10.0759C4.5479 9.72072 4.73754 9.39863 4.99642 9.13674L10.9355 3.19972ZM12.9524 4.22139C12.6965 3.93933 12.239 3.93933 11.956 4.22139L11.08 5.09705L12.4677 6.48476L13.3437 5.5817C13.6267 5.32583 13.6267 4.86828 13.3437 4.58622L12.9524 4.22139ZM5.83626 10.4733L5.33055 12.2342L7.09151 11.7285C7.21192 11.6954 7.31728 11.6322 7.40458 11.5449L11.4473 7.50521L10.0596 6.11751L6.01988 10.1602C5.93259 10.2475 5.86937 10.3529 5.83626 10.4733Z" fill="#212121"/><path d="M3.5 16.7126C3.5 16.3138 3.82335 15.9904 4.22222 15.9904H15.7778C16.1767 15.9904 16.5 16.3138 16.5 16.7126C16.5 17.1115 16.1767 17.4349 15.7778 17.4349H4.22222C3.82335 17.4349 3.5 17.1115 3.5 16.7126Z" fill="#212121"/></svg>`,lock:ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7.91621 7.08223V8.33262H12.0842V7.08223C12.0842 5.93082 11.1516 4.99824 10.0002 4.99824C8.84879 4.99824 7.91621 5.93082 7.91621 7.08223ZM6.24902 8.33262V7.08223C6.24902 5.01127 7.92924 3.33105 10.0002 3.33105C12.0712 3.33105 13.7514 5.01127 13.7514 7.08223V8.33262H14.1682C15.0877 8.33262 15.8354 9.08025 15.8354 9.9998V15.0014C15.8354 15.9209 15.0877 16.6686 14.1682 16.6686H5.83223C4.91267 16.6686 4.16504 15.9209 4.16504 15.0014V9.9998C4.16504 9.08025 4.91267 8.33262 5.83223 8.33262H6.24902Z" fill="#212121" fill-opacity="0.62"/></svg>`};var na=g` :host { display: inline-block; line-height: 0; /* so you don’t get extra space around the icon */ } /* Styling svgs rendered by passing *name* attribute - from our library file */ :host([size='sm']) svg { width: 20px; height: 20px; } :host([size='md']) svg { width: 42px; height: 42px; } :host([size='lg']) svg { width: 56px; height: 56px; } svg { /* --internal used for abstracting away the icon component */ fill: var(--internal-icon-color, currentColor); } /* For slotted icons */ :host([size='sm']) ::slotted(svg) { width: 20px; height: 20px; } :host([size='lg']) ::slotted(svg) { width: 56px; height: 56px; } ::slotted(svg) { /* --internal used for abstracting away the icon component */ fill: var(--internal-icon-color, currentColor); } `;var ce=class extends v{constructor(){super(...arguments);this.color="var(--primer-color-icon-primary)";this.size="lg"}render(){let e=this.name?aa[this.name]:null;return m`<div style="--internal-icon-color: ${this.color}">${e||m`<slot></slot>`}</div>`}};ce.styles=[na],d([p({type:String,reflect:!0})],ce.prototype,"color",2),d([p({type:String,reflect:!0})],ce.prototype,"size",2),d([p({reflect:!0})],ce.prototype,"name",2),ce=d([b("primer-icon")],ce);var il=tl({tagName:"primer-icon",elementClass:ce,react:rl});import{createComponent as nl}from"@lit/react";import sl from"react";var sa=g` :host { display: contents; } input { width: 100%; padding: 0; border: none; height: var(--primer-typography-body-large-line-height); font-size: var(--primer-typography-body-large-size); font-family: var(--primer-typography-body-large-font); color: var(--primer-color-text-primary); background-color: transparent; outline: none; } input::placeholder { color: var(--primer-color-text-placeholder); font-size: var(--primer-typography-body-large-size); font-family: var(--primer-typography-body-large-font); } :host([disabled]) input { color: var(--primer-color-text-disabled); cursor: not-allowed; } :host([disabled]) input::placeholder { color: var(--primer-color-text-disabled); } `;var ol=["text","password","email","number","tel","url","search","date","time","datetime-local","month","week","color"];function al(i){return ol.includes(i)}var D=class extends v{constructor(){super(...arguments);this.value="";this.placeholder="";this.disabled=!1;this.name="";this.type="text";this.required=!1;this.readonly=!1;this.pattern="";this.min="";this.max="";this.step="";this.autocomplete="";this._id="";this.hasFocus=!1;this.hasError=!1;this.handleInput=e=>{e.stopPropagation();let r=e.target;this.value=r.value;let o=new CustomEvent("input",{detail:this.value,bubbles:!0,composed:!0});this.dispatchEvent(o)};this.handleChange=e=>{e.stopPropagation();let r=e.target;this.value=r.value;let o=new CustomEvent("change",{detail:this.value,bubbles:!0,composed:!0});this.dispatchEvent(o)};this.handleFocus=()=>{this.hasFocus=!0,this.dispatchEvent(new FocusEvent("focus",{bubbles:!0,composed:!0}))};this.handleBlur=()=>{this.hasFocus=!1,this.dispatchEvent(new FocusEvent("blur",{bubbles:!0,composed:!0}))};this.handleInvalid=e=>{e.stopPropagation(),this.hasError=!0,this.dispatchEvent(new Event("invalid",{bubbles:!0,composed:!0}))}}get id(){return this._id}set id(e){this._id=e,this.setAttribute("id",e)}focus(e){this.inputElement?.focus(e)}blur(){this.inputElement?.blur()}select(){this.inputElement?.select()}setSelectionRange(e,r,o){this.inputElement?.setSelectionRange(e,r,o)}get validity(){return this.inputElement?.validity||{}}get validationMessage(){return this.inputElement?.validationMessage||""}checkValidity(){return this.inputElement?.checkValidity()||!1}reportValidity(){return this.inputElement?.reportValidity()||!1}render(){let e={input:!0,"input--focused":this.hasFocus,"input--disabled":this.disabled,"input--error":this.hasError,"input--readonly":this.readonly},r=Object.entries(e).filter(([,o])=>o).map(([o])=>o).join(" ");return m`<input part="input" class=${r} .value=${this.value} .type=${this.type} ?disabled=${this.disabled} ?required=${this.required} ?readonly=${this.readonly} placeholder=${this.placeholder} pattern=${this.pattern} minlength=${this.minlength??""} maxlength=${this.maxlength??""} min=${this.min} max=${this.max} step=${this.step} autocomplete=${this.autocomplete} name=${this.name} id=${this.id} @input=${this.handleInput} @change=${this.handleChange} @focus=${this.handleFocus} @blur=${this.handleBlur} @invalid=${this.handleInvalid} />`}addEventListener(e,r,o){super.addEventListener(e,r,o)}removeEventListener(e,r,o){super.removeEventListener(e,r,o)}};D.styles=[sa],d([ke("input")],D.prototype,"inputElement",2),d([p({type:String,reflect:!0})],D.prototype,"value",2),d([p({type:String,reflect:!0})],D.prototype,"placeholder",2),d([p({type:Boolean,reflect:!0})],D.prototype,"disabled",2),d([p({type:String,reflect:!0})],D.prototype,"name",2),d([p({type:String,reflect:!0,converter:{fromAttribute:e=>!e||!al(e)?(e&&e!=="text"&&A.warn(`Invalid input type: ${e}. Defaulting to 'text'.`),"text"):e}})],D.prototype,"type",2),d([p({type:Boolean,reflect:!0})],D.prototype,"required",2),d([p({type:Boolean,reflect:!0})],D.prototype,"readonly",2),d([p({type:String,reflect:!0})],D.prototype,"pattern",2),d([p({type:Number,reflect:!0})],D.prototype,"minlength",2),d([p({type:Number,reflect:!0})],D.prototype,"maxlength",2),d([p({type:String,reflect:!0})],D.prototype,"min",2),d([p({type:String,reflect:!0})],D.prototype,"max",2),d([p({type:String,reflect:!0})],D.prototype,"step",2),d([p({type:String,reflect:!0})],D.prototype,"autocomplete",2),d([P()],D.prototype,"hasFocus",2),d([P()],D.prototype,"hasError",2),D=d([b("primer-input")],D);var ll=nl({tagName:"primer-input",elementClass:D,react:sl});import{createComponent as dl}from"@lit/react";import cl from"react";var la=g` :host { display: contents; } :host(:not([active])) { display: none; } .error { color: var(--primer-color-text-negative); font-size: var(--primer-typography-body-small-size); line-height: var(--primer-typography-body-small-line-height); display: block; font-family: var(--primer-typography-body-small-font); } `;var Ee=class extends v{constructor(){super(...arguments);this.for="";this.active=!0}render(){return m`<span class="error" role="alert" aria-live="polite" id="${this.for||""}" ><slot></slot></span>`}};Ee.styles=[la],d([p({type:String,reflect:!0})],Ee.prototype,"for",2),d([p({type:Boolean,reflect:!0})],Ee.prototype,"active",2),Ee=d([b("primer-input-error")],Ee);var pl=dl({tagName:"primer-input-error",elementClass:Ee,react:cl});import{createComponent as ul}from"@lit/react";import ml from"react";var da=g` :host { display: inline-block; font-weight: var(--primer-typography-body-small-weight); font-size: var(--primer-typography-body-small-size); letter-spacing: var(--primer-typography-body-small-letter-spacing); line-height: var(--primer-typography-body-small-line-height); color: var(--primer-color-text-primary); font-family: var(--primer-typography-body-small-font); } :host([disabled]) { color: var(--primer-color-text-disabled); } `;var Ae=class extends v{constructor(){super(...arguments);this.for="";this.disabled=!1}render(){return m`<label for=${this.for}><slot></slot></label>`}};Ae.styles=[da],d([p({type:String,reflect:!0})],Ae.prototype,"for",2),d([p({type:Boolean,reflect:!0})],Ae.prototype,"disabled",2),Ae=d([b("primer-input-label")],Ae);var hl=ul({tagName:"primer-input-label",elementClass:Ae,react:ml});import{createComponent as fl}from"@lit/react";import yl from"react";var ca=g` * { box-sizing: border-box; } :host { display: block; width: 100%; } .input-slot.focus-within, .input-slot:focus-within { outline: 2px solid var(--primer-color-border-outlined-focus); outline-offset: -2px; } :host([has-error]) .input-slot.focus-within, :host([has-error]) .input-slot:focus-within { outline: 2px solid var(--primer-color-border-outlined-error); background-color: var(--primer-color-background-outlined-error); } :host([has-error]) .input-slot { border-color: var(--primer-color-border-outlined-error); background-color: var(--primer-color-background-outlined-error); } .input-wrapper { display: flex; flex-direction: column; gap: var(--primer-space-xsmall); } .input-slot { padding: var(--primer-space-medium) var(--primer-space-medium); border: 1px solid var(--primer-color-border-outlined-default); border-radius: var(--primer-radius-small); background-color: var(--primer-color-background-outlined-default); height: calc( var(--primer-typography-body-large-line-height) + var(--primer-space-medium) + var(--primer-space-medium) + 2px ); display: flex; cursor: text; /* Indicate text input interactivity */ /* 2px is the border width */ } .input-slot ::slotted(*) { width: 100%; } .input-slot:hover { border-color: var(--primer-color-border-outlined-hover); background-color: var(--primer-color-background-outlined-hover); } .input-slot:active { border-color: var(--primer-color-border-outlined-active); background-color: var(--primer-color-background-outlined-active); } .input-slot:disabled { background-color: var(--primer-color-background-outlined-disabled); border-color: var(--primer-color-border-outlined-disabled); cursor: not-allowed; } `;var pe=class extends v{constructor(){super(...arguments);this.focusWithin=!1;this.hasError=!1;this.handleWrapperClick=e=>{if(e.target!==e.currentTarget)return;let r=this.findSlottedPrimerInput();r?r.focus():this.dispatchEvent(new CustomEvent("wrapper-click",{bubbles:!0,composed:!0}))}}findSlottedPrimerInput(){if(!this.inputSlot)return null;let e=this.inputSlot.assignedElements({flatten:!0}),r=e.find(o=>o.tagName.toLowerCase()==="primer-input");if(r)return r;for(let o of e){let a=o.querySelector("primer-input");if(a)return a}return null}render(){let e={"input-slot":!0,"focus-within":this.focusWithin};return m`<div class="input-wrapper"><slot name="label"></slot><div class="${F(e)}" @click="${this.handleWrapperClick}"><slot name="input"></slot></div><slot name="error"></slot></div>`}};pe.styles=[ca],d([p({type:Boolean})],pe.prototype,"focusWithin",2),d([p({type:Boolean,reflect:!0,attribute:"has-error"})],pe.prototype,"hasError",2),d([ke('slot[name="input"]')],pe.prototype,"inputSlot",2),pe=d([b("primer-input-wrapper")],pe);var gl=fl({tagName:"primer-input-wrapper",elementClass:pe,react:yl});import{createComponent as vl}from"@lit/react";import bl from"react";var pa=g` :host { display: none; } `;var Ne=class extends v{constructor(){super(...arguments);this._id=`d${Math.random().toString(36).substring(7)}`;this._handleSlotChange=e=>{let o=e.target.assignedNodes();if(!o.length)return;let a=this.getContainer();o.forEach(n=>a.appendChild(n))}}get id(){return this._id}getContainer(){let e=document.querySelector(`#${this._id}`);return e||(e=document.createElement("div"),e.id=this._id,document.body.appendChild(e),this._setupEventListeners(e)),e}_setupEventListeners(e){["primer-ach-error","primer-ach-bank-details-collected","primer-ach-mandate-confirmed","primer-ach-mandate-declined"].forEach(r=>{e.addEventListener(r,o=>{o.stopPropagation(),this.dispatchEvent(new CustomEvent(r,{bubbles:!0,composed:!0,detail:o.detail}))})})}disconnectedCallback(){super.disconnectedCallback(),this.getContainer().remove()}render(){return m`<slot @slotchange=${this._handleSlotChange}></slot>`}};Ne.styles=[pa],d([P()],Ne.prototype,"_id",2),Ne=d([b("primer-portal")],Ne);var Cl=vl({tagName:"primer-portal",elementClass:Ne,react:bl});import{createComponent as El}from"@lit/react";import Al from"react";var ua=g` :host { display: inline-flex; align-items: center; justify-content: center; } .spinner-container { display: flex; align-items: center; justify-content: center; width: var(--spinner-size, var(--primer-size-medium)); height: var(--spinner-size, var(--primer-size-medium)); } .spinner-container:not(.compact) { margin: var(--primer-space-small) 0; } .spinner-container.compact { margin: 0; } .spinner { animation: spinner-rotate 1.2s linear infinite; width: 100%; height: 100%; color: var(--spinner-color, var(--primer-color-loader)); } .path { fill: currentColor; transform-origin: center; transition: fill var(--primer-animation-duration, 200ms) var(--primer-animation-easing, ease); } @keyframes spinner-rotate { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } `;var vi={small:16,medium:24,large:32},ue=class extends v{constructor(){super(...arguments);this.color="var(--primer-color-loader)";this.size="medium";this.compact=!1}getSize(){if(this.size in vi)return vi[this.size];let e=parseInt(this.size,10);return isNaN(e)?vi.medium:e}render(){let e=this.getSize(),r=20,o=`0 0 ${r} ${r}`;return this.style.setProperty("--spinner-color",this.color),this.style.setProperty("--spinner-size",`${e}px`),m`<div class="spinner-container ${this.compact?"compact":""}"><svg class="spinner" width="${e}" height="${e}" viewBox="${o}" fill="none" xmlns="http://www.w3.org/2000/svg" role="status" aria-label="Loading" ><path d="M4.27827 10.002C4.27827 6.84166 6.84019 4.27973 10.0005 4.27973C10.7676 4.27973 11.3894 3.6579 11.3894 2.89084C11.3894 2.12378 10.7676 1.50195 10.0005 1.50195C5.30607 1.50195 1.50049 5.30753 1.50049 10.002C1.50049 14.6964 5.30607 18.502 10.0005 18.502C14.6949 18.502 18.5005 14.6964 18.5005 10.002C18.5005 9.23489 17.8787 8.61306 17.1116 8.61306C16.3445 8.61306 15.7227 9.23489 15.7227 10.002C15.7227 13.1622 13.1608 15.7242 10.0005 15.7242C6.84019 15.7242 4.27827 13.1622 4.27827 10.002Z" fill="currentColor" class="path" /></svg></div>`}};ue.styles=[ua],d([p({type:String})],ue.prototype,"color",2),d([p({type:String})],ue.prototype,"size",2),d([p({type:Boolean})],ue.prototype,"compact",2),ue=d([b("primer-spinner")],ue);var _l=El({tagName:"primer-spinner",elementClass:ue,react:Al});import{createComponent as Sl}from"@lit/react";import xl from"react";var ma=g` :host { display: contents; } button { align-items: center; border-radius: var(--primer-radius-medium); border: none; cursor: pointer; display: flex; font-family: var(--primer-typography-title-large-font); font-size: var(--primer-typography-title-large-size); font-weight: var(--primer-typography-title-large-weight); gap: var(--primer-space-small); justify-content: center; letter-spacing: var(--primer-typography-title-large-letter-spacing); line-height: var(--primer-typography-title-large-line-height); outline: none; padding: var(--primer-space-medium) var(--primer-space-medium); position: relative; } .button-content { display: flex; height: 100%; width: 100%; align-items: center; gap: var(--primer-space-small); justify-content: center; transition: opacity var(--primer-animation-duration) var(--primer-animation-easing); } .button-content-base { width: 100%; height: 100%; gap: var(--primer-space-small); transition: opacity var(--primer-animation-duration) var(--primer-animation-easing); } /* Reduce opacity of text during loading for better focus on the spinner */ .button-content.loading { opacity: 0.65; } :host([selectable]) button { justify-content: space-between; } /* Primary variant */ :host([variant='primary']) button { background-color: var(--primer-color-brand); /* This is correct (color-background for color) because Button is kind of a special component */ color: var(--primer-color-background-outlined-default); } :host([variant='primary']:not([disabled]):not([loading])) button:hover { filter: brightness(105%); } :host([variant='primary']:not([disabled]):not([loading])) button:active { filter: brightness(98%); } :host([variant='primary']) button:focus-visible { outline: 2px solid var(--primer-color-brand); outline-offset: 2px; } /* Disabled state for primary button */ :host([variant='primary'][disabled]:not([loading])) button, :host([variant='primary']:not([loading])) button:disabled { color: var(--primer-color-text-disabled); background-color: var(--primer-color-background-outlined-disabled); cursor: not-allowed; } /* Loading state for primary button - OVERRIDES disabled styles with higher specificity */ :host([variant='primary'][loading]) button { background-color: var(--primer-color-brand); opacity: 0.8; color: var(--primer-color-background-outlined-default); cursor: wait; } /* Secondary variant */ :host([variant='secondary']) button { background-color: var(--primer-color-background-outlined-default); color: var(--primer-color-text-primary); border: 1px solid var(--primer-color-border-outlined-default); } :host([variant='secondary']:not([disabled]):not([loading])) button:hover { background-color: var(--primer-color-background-outlined-hover); } :host([variant='secondary']:not([disabled]):not([loading])) button:active { background-color: var(--primer-color-background-outlined-active); } :host([variant='secondary']) button:focus-visible { outline: 2px solid var(--primer-color-border-outlined-focus); outline-offset: 2px; } /* Disabled state for secondary button */ :host([variant='secondary'][disabled]:not([loading])) button, :host([variant='secondary']:not([loading])) button:disabled { background-color: var(--primer-color-background-outlined-disabled); border-color: var(--primer-color-border-outlined-disabled); color: var(--primer-color-text-disabled); cursor: not-allowed; } /* Loading state for secondary button - OVERRIDES disabled styles */ :host([variant='secondary'][loading]) button { background-color: var(--primer-color-gray-100); border-color: var(--primer-color-gray-300); color: var(--primer-color-gray-600); cursor: wait; } /* Tertiary variant */ :host([variant='tertiary']) button { background-color: var(--primer-color-background-transparent-default); border: 1px solid var(--primer-color-border-transparent-default); color: var(--primer-color-text-primary); border-radius: var(--primer-radius-small); padding: var(--primer-space-xxsmall) var(--primer-space-xxsmall); } :host([variant='tertiary']:not([disabled]):not([loading])) button:hover { border-radius: var(--primer-radius-small); background-color: var(--primer-color-background-transparent-hover); border: 1px solid var(--primer-color-border-transparent-hover); color: var(--primer-color-text-primary); } :host([variant='tertiary']:not([disabled]):not([loading])) button:active { background-color: var(--primer-color-background-transparent-active); border-color: var(--primer-color-border-transparent-active); border-radius: var(--primer-radius-small); color: var(--primer-color-text-primary); } :host([variant='tertiary']) button:focus-visible { border-radius: var(--primer-radius-small); background-color: var(--primer-color-background-transparent-focus); outline: 2px solid var(--primer-color-border-transparent-focus); outline-offset: 2px; } /* Disabled state for tertiary button */ :host([variant='tertiary'][disabled]:not([loading])) button, :host([variant='tertiary']:not([loading])) button:disabled { background-color: var(--primer-color-border-transparent-disabled); color: var(--primer-color-text-disabled); cursor: not-allowed; } /* Loading state for tertiary button - OVERRIDES disabled styles */ :host([variant='tertiary'][loading]) button { background-color: var(--primer-color-gray-100); color: var(--primer-color-gray-600); cursor: wait; } /* Checked state styling */ :host([selectionState='checked']) button { border: 2px solid var(--primer-color-brand); background-color: var(--primer-color-gray-100); } /* Loading state - center spinner with content */ :host([loading]) primer-spinner { margin-right: var(--primer-space-xsmall); } /* Special case for tertiary variant loading state spinner size */ :host([variant='tertiary'][loading]) primer-spinner { transform: scale(0.85); } `;var J=class extends v{constructor(){super(...arguments);this.variant="primary";this.disabled=!1;this.loading=!1;this.buttonType="button";this.selectionState="default";this.selectable=!1;this.flex=!0;this.handleClick=()=>{!this.selectable||this.disabled||this.loading||(this.selectionState=this.selectionState==="default"?"checked":"default",this.dispatchEvent(new CustomEvent("selection-change",{bubbles:!0,composed:!0,detail:{state:this.selectionState}})))}}renderCheckmark(){return!this.selectable||this.selectionState!=="checked"||this.loading?f:m`<primer-icon name="checkmark" size="sm" color="var(--primer-color-brand)" ></primer-icon>`}renderSpinner(){if(!this.loading)return f;let e;return this.variant==="primary"?e="var(--primer-color-background-outlined-default)":(this.variant==="secondary"||this.variant==="tertiary")&&(e="var(--primer-color-gray-900)"),m`<primer-spinner size="small" color="${e}" compact ></primer-spinner>`}render(){return m`<button type=${this.buttonType} ?disabled=${this.disabled||this.loading} @click=${this.handleClick} part="button" aria-checked=${this.selectionState==="checked"} aria-busy=${this.loading} >${this.renderSpinner()} ${this.flex?m`<span class="button-content ${this.loading?"loading":""}"><slot></slot></span>`:m`<span class="button-content-base ${this.loading?"loading":""}" ><slot></slot></span>`} ${this.renderCheckmark()}</button>`}};J.styles=[T,ma],d([p({type:String,reflect:!0})],J.prototype,"variant",2),d([p({type:Boolean,reflect:!0})],J.prototype,"disabled",2),d([p({type:Boolean,reflect:!0})],J.prototype,"loading",2),d([p({type:String,attribute:"type"})],J.prototype,"buttonType",2),d([p({type:String,reflect:!0})],J.prototype,"selectionState",2),d([p({type:Boolean,reflect:!0})],J.prototype,"selectable",2),d([p({type:Boolean,reflect:!0})],J.prototype,"flex",2),J=d([b("primer-button")],J);var Pl=Sl({tagName:"primer-button",elementClass:J,react:xl});import{createComponent as wl}from"@lit/react";import Ml from"react";var ha=g` :host { display: flex; flex-direction: column; gap: var(--primer-space-medium); width: 100%; } h2 { margin: 0; padding: 0; border-radius: var(--primer-radius-medium); font-weight: var(--primer-typography-title-xlarge-weight); font-size: var(--primer-typography-title-xlarge-size); letter-spacing: var(--primer-typography-title-xlarge-letter-spacing); line-height: var(--primer-typography-title-xlarge-line-height); font-family: var(--primer-typography-title-xlarge-font); } p { margin: 0; padding: 0; border-radius: var(--primer-radius-medium); font-weight: var(--primer-typography-body-medium-weight); font-size: var(--primer-typography-body-medium-size); letter-spacing: var(--primer-typography-body-medium-letter-spacing); line-height: var(--primer-typography-body-medium-line-height); font-family: var(--primer-typography-body-medium-font); } form { display: flex; flex-direction: column; gap: var(--primer-space-medium); width: 100%; } .form-row { display: flex; gap: var(--primer-space-small); width: 100%; } .form-row primer-input-wrapper { flex: 1; } .error-message { color: var(--primer-color-text-negative); background-color: var(--primer-color-red-100); padding: var(--primer-space-small); border-radius: var(--primer-radius-small); font-weight: var(--primer-typography-body-medium-weight); font-size: var(--primer-typography-body-medium-size); letter-spacing: var(--primer-typography-body-medium-letter-spacing); line-height: var(--primer-typography-body-medium-line-height); font-family: var(--primer-typography-body-medium-font); } .loading-container { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--primer-space-medium); padding: var(--primer-space-large); } .button-group { display: flex; gap: var(--primer-space-small); margin-top: var(--primer-space-medium); } /* Apply responsive styles for small screens */ @media (max-width: 600px) { .form-row { flex-direction: column; gap: var(--primer-space-medium); } .button-group { flex-direction: column; } } `;function fa(){return{firstName:{value:"",error:"",pristine:!0,touched:!1,dirty:!1,valid:!1},lastName:{value:"",error:"",pristine:!0,touched:!1,dirty:!1,valid:!1},emailAddress:{value:"",error:"",pristine:!0,touched:!1,dirty:!1,valid:!1}}}var Mr=class{constructor(t,e){this.formState=fa();this.host=t,this.validate=e,t.addController(this)}get hasError(){return{firstName:this.formState.firstName.dirty&&this.formState.firstName.touched&&!!this.formState.firstName.error,lastName:this.formState.lastName.dirty&&this.formState.lastName.touched&&!!this.formState.lastName.error,emailAddress:this.formState.emailAddress.dirty&&this.formState.emailAddress.touched&&!!this.formState.emailAddress.error}}get formData(){return{firstName:this.formState.firstName.value,lastName:this.formState.lastName.value,emailAddress:this.formState.emailAddress.value}}async setFieldValue(t,e){let r=this.formState[t];r.value=e,r.dirty=!0,r.error="",r.valid=!0;let o=await this.validate(this.formData);this.setValidation(o)}setValidation(t,e=!1){e&&(this.formState.firstName.touched=!0,this.formState.lastName.touched=!0,this.formState.emailAddress.touched=!0,this.formState.firstName.dirty=!0,this.formState.lastName.dirty=!0,this.formState.emailAddress.dirty=!0),t.validationErrors.forEach(r=>{this.isValidFieldName(r.field)&&(this.formState[r.field].error=r.message,this.formState[r.field].valid=r.message==="")}),this.host.dispatchEvent(new CustomEvent("primer-ach-validation",{bubbles:!0,composed:!0,detail:{validation:t}})),this.host.requestUpdate()}setFieldTouched(t){this.formState[t].touched||(this.formState[t].touched=!0,this.host.requestUpdate())}resetForm(){this.formState=fa(),this.host.requestUpdate()}isValidFieldName(t){return!!t&&["firstName","lastName","emailAddress"].includes(t)}hostConnected(){}hostDisconnected(){}};var X=class extends v{constructor(){super(...arguments);this.formController=new Mr(this,e=>this._paymentMethodManagerTask.value.setAndValidate(e));this.paymentManagers=new Map;this.sdkState=void 0;this.clientOptions=void 0;this.screen="form";this.isSubmitting=!1;this._paymentMethodManagerTask=new L(this,{task:([e])=>e!=="STRIPE_ACH"?M:this.paymentManagers.get(e)?.manager,args:()=>[this.paymentMethod?.type]})}_handleInput(e,r){let o=e.target;this.formController.setFieldValue(r,o.value)}_handleBlur(e){this.formController.setFieldTouched(e)}_handleError(e){this.dispatchEvent(new CustomEvent("primer-ach-error",{bubbles:!0,composed:!0,detail:{error:e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error occurred")}}))}async _handleSubmitButtonClick(e){if(!this.isSubmitting){this.isSubmitting=!0;try{let r=await e.start(this.formController.formData);if(!r||r.valid)return await this._handleCollectBankAccountDetails(e);r&&this.formController.setValidation(r,!0)}catch(r){this._handleError(r)}finally{this.isSubmitting=!1}}}async _handleCollectBankAccountDetails(e){try{await e.collectBankAccountDetails(),this.screen="mandate",this.dispatchEvent(new CustomEvent("primer-ach-bank-details-collected",{bubbles:!0,composed:!0}))}catch(r){this._handleError(r)}}async _handleConfirmMandate(){if(this._paymentMethodManagerTask.value){this.isSubmitting=!0;try{await this._paymentMethodManagerTask.value.confirmMandate(),this.dispatchEvent(new CustomEvent("primer-ach-mandate-confirmed",{bubbles:!0,composed:!0}))}catch(e){this._handleError(e)}finally{this.isSubmitting=!1}}}async _handleDeclineMandate(){if(this._paymentMethodManagerTask.value){this.isSubmitting=!0;try{await this._paymentMethodManagerTask.value.declineMandate(),this.dispatchEvent(new CustomEvent("primer-ach-mandate-declined",{bubbles:!0,composed:!0}))}catch(e){this._handleError(e)}finally{this.isSubmitting=!1}}}renderForm(e){return m`<h2>${x("payWithAch",{id:"payWithAch"})}</h2><p>${x("stripe_ach_user_details_collection_subtitle_label",{id:"stripe_ach_user_details_collection_subtitle_label"})}</p><form @submit=${r=>r.preventDefault()}><div class="form-row"><primer-input-wrapper .hasError=${this.formController.hasError.firstName} ><primer-input-label slot="label">${x("stripe_ach_user_details_collection_first_name_label",{id:"stripe_ach_user_details_collection_first_name_label"})}</primer-input-label><primer-input slot="input" .value=${this.formController.formState.firstName.value} @input=${r=>this._handleInput(r,"firstName")} @blur=${()=>this._handleBlur("firstName")} ?disabled=${this.isSubmitting} ></primer-input><primer-input-error slot="error">${this.formController.hasError.firstName?this.formController.formState.firstName.error:f}</primer-input-error></primer-input-wrapper><primer-input-wrapper .hasError=${this.formController.hasError.lastName} ><primer-input-label slot="label">${x("stripe_ach_user_details_collection_last_name_label",{id:"stripe_ach_user_details_collection_last_name_label"})}</primer-input-label><primer-input slot="input" .value=${this.formController.formState.lastName.value} @input=${r=>this._handleInput(r,"lastName")} @blur=${()=>this._handleBlur("lastName")} ?disabled=${this.isSubmitting} ></primer-input><primer-input-error slot="error">${this.formController.hasError.lastName?this.formController.formState.lastName.error:f}</primer-input-error></primer-input-wrapper></div><primer-input-wrapper .hasError=${this.formController.hasError.emailAddress} ><primer-input-label slot="label">${x("stripe_ach_user_details_collection_email_address_label",{id:"stripe_ach_user_details_collection_email_address_label"})}</primer-input-label><primer-input slot="input" type="email" .value=${this.formController.formState.emailAddress.value} @input=${r=>this._handleInput(r,"emailAddress")} @blur=${()=>this._handleBlur("emailAddress")} ?disabled=${this.isSubmitting} ></primer-input><primer-input-error slot="error">${this.formController.hasError.emailAddress?this.formController.formState.emailAddress.error:f}</primer-input-error></primer-input-wrapper><p>${x("stripe_ach_user_details_collection_data_usage_label",{id:"stripe_ach_user_details_collection_data_usage_label"})}</p><primer-button buttonType="submit" variant="primary" @click=${()=>this._handleSubmitButtonClick(e)} ?disabled=${this.isSubmitting} ?loading=${this.isSubmitting} >${x("stripe_ach_user_details_collection_continue_button",{id:"stripe_ach_user_details_collection_continue_button"})}</primer-button></form>`}renderMandate(){return m`<h2>${x("payWithAch",{id:"payWithAch"})}</h2><p>${this.clientOptions?.stripe?.mandateData.fullMandateText??x("stripe_ach_mandate_template_web",{id:"stripe_ach_mandate_template_web"}).replace(/\{merchantName\}/g,this.clientOptions?.stripe?.mandateData.merchantName??"Merchant")}</p><div class="button-group"><primer-button variant="primary" @click=${this._handleConfirmMandate.bind(this)} ?disabled=${this.isSubmitting} ?loading=${this.isSubmitting} >${x("stripe_ach_mandate_accept_button",{id:"stripe_ach_mandate_accept_button"})}</primer-button><primer-button variant="tertiary" @click=${this._handleDeclineMandate.bind(this)} ?disabled=${this.isSubmitting} >${x("stripe_ach_mandate_cancel_payment_button",{id:"stripe_ach_mandate_cancel_payment_button"})}</primer-button></div>`}render(){return this._paymentMethodManagerTask.render({complete:e=>e?this.screen==="form"?this.renderForm(e):this.renderMandate():f})}};X.styles=[T,ha],d([p({type:Object})],X.prototype,"paymentMethod",2),d([C({context:G,subscribe:!0}),p({attribute:!1})],X.prototype,"paymentManagers",2),d([C({context:V,subscribe:!0}),p({attribute:!1})],X.prototype,"sdkState",2),d([C({context:Pe,subscribe:!0}),p({attribute:!1})],X.prototype,"clientOptions",2),d([P()],X.prototype,"screen",2),d([P()],X.prototype,"isSubmitting",2),X=d([b("primer-ach-payment"),R()],X);var Tl=wl({tagName:"primer-ach-payment",elementClass:X,react:Ml});import{createComponent as kl}from"@lit/react";import Il from"react";var mt="card-form-context";var ya=g` :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 ee=class extends v{constructor(){super(...arguments);this.hideLabels=!1;this.disabled=!1;this.hasAssignedContent=!1;this.selectedCardNetwork=null;this.paymentManagers=new Map;this.cardFormProvider=new U(this,{context:mt,initialValue:null});this.eventsController=new tt(this);this.setupCardFormTask=new L(this,{task:([e])=>{if(!e?.manager)return M;let{manager:r}=e,o=r.createHostedInputs(),{cardNumberInput:a,expiryInput:n,cvvInput:s}=o;return this.cardFormProvider.setValue({cardHolderNameInput:o.cardHolderNameInput,cardNumberInput:a,expiryInput:n,cvvInput:s,setCardholderName:l=>r.setCardholderName(l),setCardNetwork:l=>{this.selectedCardNetwork=l},validate:()=>r.validate(),submit:l=>r.submit(l),hideLabels:this.hideLabels,disabled:this.disabled}),!0},args:()=>[this.paymentManagers.get("PAYMENT_CARD")]});this.handleSlotButtonClick=e=>{let o=e.target.closest("button, primer-button");if(!o)return;let a=o;this.isSubmitButton(a)&&(e.preventDefault(),this.submitCardPayment())};this.handleDirectSubmit=e=>{e.stopPropagation(),this.submitCardPayment()};this.onSlotChange=e=>{let o=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=o.length>0};this.handleFormSubmit=e=>{e.preventDefault(),e.stopPropagation(),this.submitCardPayment()}}updated(e){super.updated(e),(e.has("hideLabels")||e.has("disabled"))&&this.cardFormProvider.value&&this.cardFormProvider.setValue({...this.cardFormProvider.value,hideLabels:this.hideLabels,disabled:this.disabled})}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.handleSlotButtonClick),this.addEventListener("primer:card-submit",this.handleDirectSubmit)}disconnectedCallback(){this.removeEventListener("click",this.handleSlotButtonClick),this.removeEventListener("primer:card-submit",this.handleDirectSubmit),super.disconnectedCallback()}isSubmitButton(e){let r=e.tagName.toLowerCase(),o=r==="button",a=r==="primer-button";return o&&(e.getAttribute("type")==="submit"||e.hasAttribute("data-submit"))||a&&(e.getAttribute("type")==="submit"||e.hasAttribute("data-submit"))}async submitCardPayment(){let e=this.cardFormProvider.value;if(!e||this.disabled)return;let r=await e.validate?.();if(r?.valid){let o=await e.submit?.(this.selectedCardNetwork?{cardNetwork:this.selectedCardNetwork}:void 0);this.eventsController.dispatchFormSubmitSuccess(o)}else{let o=r?.validationErrors;this.cardFormProvider.setValue({...e,errors:o}),this.eventsController.dispatchFormSubmitErrors(o)}}render(){return this.setupCardFormTask.status===Me.ERROR||this.setupCardFormTask.status===Me.INITIAL?f:m`<form @submit=${this.handleFormSubmit}><slot name="card-form-content" @slotchange=${this.onSlotChange}></slot>${this.setupCardFormTask.render({complete:()=>O(this.hasAssignedContent,()=>f,()=>m`<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><primer-input-card-holder-name></primer-input-card-holder-name></div><primer-card-form-submit></primer-card-form-submit>`)})}</form>`}};ee.styles=[T,ya],d([p({type:Boolean,attribute:"hide-labels",reflect:!0})],ee.prototype,"hideLabels",2),d([p({type:Boolean,attribute:"disabled"})],ee.prototype,"disabled",2),d([P()],ee.prototype,"hasAssignedContent",2),d([P()],ee.prototype,"selectedCardNetwork",2),d([C({context:G,subscribe:!0}),p({type:Object})],ee.prototype,"paymentManagers",2),ee=d([b("primer-card-form"),R()],ee);var Nl=kl({tagName:"primer-card-form",elementClass:ee,react:Il});import{createComponent as Ll}from"@lit/react";import Ol from"react";var ga=g` :host { display: contents; } `;var Z=class extends v{constructor(){super(...arguments);this._userAssignedProps=new Set;this._internalButtonText="";this.headlessInstance=null;this.clientOptions=null;this.sdkState=null;this.cardFormContext=null;this.variant="primary";this.disabled=!1;this.handleClick=e=>{if(e.preventDefault(),this.disabled)return;let r=new CustomEvent("primer:card-submit",{bubbles:!0,composed:!0,detail:{source:"primer-card-form-submit"}});this.dispatchEvent(r)}}get buttonText(){return this._userAssignedProps.has("buttonText")?this._internalButtonText:x("pay",{id:"pay"})}set buttonText(e){let r=this.buttonText;e!==""?(this._userAssignedProps.add("buttonText"),this._internalButtonText=e):(this._userAssignedProps.delete("buttonText"),this._internalButtonText=""),this.requestUpdate("buttonText",r)}render(){let e=this.clientOptions?.submitButton?.amountVisible?this.headlessInstance?.getUIOrderAmount():null,r=e?` ${e}`:f,o=this.disabled||this.cardFormContext?.disabled||!1;return m`<primer-button type="submit" variant=${this.variant} ?disabled=${o} @click=${this.handleClick} .loading=${!!this.sdkState?.isProcessing} data-submit >${this.buttonText}${r}</primer-button>`}};Z.styles=[T,ga],d([p({type:String})],Z.prototype,"buttonText",1),d([C({context:K,subscribe:!0}),p({type:Object})],Z.prototype,"headlessInstance",2),d([C({context:Pe,subscribe:!0}),p({type:Object})],Z.prototype,"clientOptions",2),d([C({context:V,subscribe:!0}),p()],Z.prototype,"sdkState",2),d([C({context:mt,subscribe:!0}),p()],Z.prototype,"cardFormContext",2),d([p({type:String})],Z.prototype,"variant",2),d([p({type:Boolean})],Z.prototype,"disabled",2),Z=d([b("primer-card-form-submit"),R()],Z);var Rl=Ll({tagName:"primer-card-form-submit",elementClass:Z,react:Ol});import{createComponent as Vl}from"@lit/react";import Ul from"react";var{I:sv}=lo;var va=i=>i.strings===void 0;var Rt=(i,t)=>{let e=i._$AN;if(e===void 0)return!1;for(let r of e)r._$AO?.(t,!1),Rt(r,t);return!0},Tr=i=>{let t,e;do{if((t=i._$AM)===void 0)break;e=t._$AN,e.delete(i),i=t}while(e?.size===0)},ba=i=>{for(let t;t=i._$AM;i=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(i))break;e.add(i),Yl(t)}};function Dl(i){this._$AN!==void 0?(Tr(this),this._$AM=i,ba(this)):this._$AM=i}function $l(i,t=!1,e=0){let r=this._$AH,o=this._$AN;if(o!==void 0&&o.size!==0)if(t)if(Array.isArray(r))for(let a=e;a<r.length;a++)Rt(r[a],!1),Tr(r[a]);else r!=null&&(Rt(r,!1),Tr(r));else Rt(this,i)}var Yl=i=>{i.type==Ie.CHILD&&(i._$AP??(i._$AP=$l),i._$AQ??(i._$AQ=Dl))},Le=class extends ut{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,r){super._$AT(t,e,r),ba(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(Rt(this,t),Tr(this))}setValue(t){if(va(this._$Ct))this._$Ct._$AI(t,this);else{let e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};var Ei=()=>new Ci,Ci=class{},bi=new WeakMap,kr=Ce(class extends Le{render(i){return f}update(i,[t]){let e=t!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=t,this.ht=i.options?.host,this.rt(this.ct=i.element)),f}rt(i){if(this.isConnected||(i=void 0),typeof this.G=="function"){let t=this.ht??globalThis,e=bi.get(t);e===void 0&&(e=new WeakMap,bi.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,i),i!==void 0&&this.G.call(this.ht,i)}else this.G.value=i}get lt(){return typeof this.G=="function"?bi.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Ca=g` :host { display: flex; align-items: center; position: relative; } .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-icon { width: var(--primer-size-large); height: var( --primer-size-medium ); /* Added explicit height to maintain aspect ratio */ object-fit: contain; } .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 Q=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=Ei();this.dropdownRef=Ei();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}getSelectableNetworks(){return this.cardNetworks?.selectableCardNetworks||[]}getDetectedNetwork(){return this.selectedCardNetwork??(this.cardNetworks?.detectedCardNetwork||null)}getSelectedNetworkIndex(){let e=this.getDetectedNetwork();if(!e)return 0;let r=this.getSelectableNetworks().findIndex(o=>o.network===e.network);return r>=0?r:0}selectNetwork(e,r){e.stopPropagation(),this.selectedCardNetwork=r,this.isDropdownOpen=!1,this.buttonRef.value?.focus(),this.cardNetworks&&this.dispatchEvent(new CustomEvent("network-selected",{detail:{network:r.network},bubbles:!0,composed:!0}))}focusNetworkOption(){requestAnimationFrame(()=>{this.networkOptionRefs[this.focusedNetworkIndex]&&this.networkOptionRefs[this.focusedNetworkIndex].focus()})}setNetworkOptionRef(e,r){this.networkOptionRefs[r]=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 m`<primer-spinner size="small" compact></primer-spinner>`;let e=this.getSelectableNetworks();if(!this.getDetectedNetwork()&&e.length===0)return m`<primer-icon name="payment-card" size="sm"></primer-icon>`;let r=this.getDetectedNetwork()||(e.length>0?e[0]:null);if(!r)return m`<primer-icon name="payment-card" size="sm"></primer-icon>`;let o=e.length>1;return m`<button ${kr(this.buttonRef)} class="network-selector" @click=${this.toggleDropdown} @keydown=${a=>{(a.key===" "||a.key==="Enter")&&o&&(a.preventDefault(),this.isDropdownOpen=!this.isDropdownOpen,this.isDropdownOpen&&(this.focusedNetworkIndex=this.getSelectedNetworkIndex()))}} aria-label=${o?`Selected card network: ${r.displayName}. Click to change.`:`Card network: ${r.displayName}`} aria-expanded=${o?this.isDropdownOpen:f} aria-haspopup=${o?"true":f} aria-controls=${o?"network-dropdown":f} ><img class="network-icon" src=${this.getNetworkIconUrl(r)} alt=${r.displayName} />${O(o,()=>m`<primer-icon class="caret ${this.isDropdownOpen?"open":""}" size="sm" name="chevron-down" ></primer-icon>`,()=>f)}</button>${O(this.isDropdownOpen,()=>m`<div ${kr(this.dropdownRef)} id="network-dropdown" class="dropdown open" role="listbox" aria-label="Select card network" >${e.map((a,n)=>m`<div ${kr(s=>this.setNetworkOptionRef(s,n))} class="network-option ${this.isKeyboardNavigation&&n===this.focusedNetworkIndex?"focused":""}" @click=${s=>this.selectNetwork(s,a)} @keydown=${s=>{(s.key==="Enter"||s.key===" ")&&this.selectNetwork(s,a)}} role="option" aria-selected=${a.network===r.network} tabindex="${n===this.focusedNetworkIndex?"0":"-1"}" ><img class="network-option-icon" src=${this.getNetworkIconUrl(a)} alt=${a.displayName} /><span class="network-name">${a.displayName}</span>${O(a.network===r.network,()=>m`<primer-icon class="checkmark" name="checkmark" size="sm" ></primer-icon>`,()=>f)}</div>`)}</div>`,()=>f)} `}};Q.styles=[T,Ca],d([C({context:Vt,subscribe:!0})],Q.prototype,"cardNetworks",2),d([C({context:K,subscribe:!0})],Q.prototype,"headlessUtils",2),d([P()],Q.prototype,"selectedCardNetwork",2),d([P()],Q.prototype,"isDropdownOpen",2),d([P()],Q.prototype,"focusedNetworkIndex",2),d([P()],Q.prototype,"isKeyboardNavigation",2),Q=d([b("primer-card-network-selector")],Q);var Hl=Vl({tagName:"primer-card-network-selector",elementClass:Q,react:Ul});import{createComponent as Bl}from"@lit/react";import zl from"react";function Ea(i,t){if(i.style.cssText="width: 100%; flex:1; padding: 0; border: none; height: var(--primer-typography-body-large-line-height); font-size: var(--primer-typography-body-large-size); font-family: var(--primer-typography-body-large-font); color: var(--primer-color-text-primary); background-color: transparent; outline: none;",i.setAttribute("data-custom-input",""),!t.shadowRoot?.querySelector("style[data-custom-input-style]")){let e=document.createElement("style");e.setAttribute("data-custom-input-style",""),e.textContent=`
112
+ `;function bs(i,t){var e={};for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&t.indexOf(r)<0&&(e[r]=i[r]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(i);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(i,r[o])&&(e[r[o]]=i[r[o]]);return e}function Cs(i,t){var e=document.querySelector('script[src="'.concat(i,'"]'));if(e===null)return null;var r=Zo(i,t),o=e.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var a=!0;return Object.keys(o.dataset).forEach(function(n){o.dataset[n]!==r.dataset[n]&&(a=!1)}),a?e:null}function Es(i){var t=i.url,e=i.attributes,r=i.onSuccess,o=i.onError,a=Zo(t,e);a.onerror=o,a.onload=r,document.head.insertBefore(a,document.head.firstElementChild)}function As(i){var t=i.sdkBaseUrl,e=i.environment,r=bs(i,["sdkBaseUrl","environment"]),o=t||xs(e),a=r,n=Object.keys(a).filter(function(c){return a[c]!==void 0&&a[c]!==null&&a[c]!==""}).reduce(function(c,h){var u=a[h].toString();return h=_s(h),h.substring(0,4)==="data"||h==="crossorigin"?c.attributes[h]=u:c.queryParams[h]=u,c},{queryParams:{},attributes:{}}),s=n.queryParams,l=n.attributes;return s["merchant-id"]&&s["merchant-id"].indexOf(",")!==-1&&(l["data-merchant-id"]=s["merchant-id"],s["merchant-id"]="*"),{url:"".concat(o,"?").concat(Ss(s)),attributes:l}}function _s(i){var t=function(e,r){return(r?"-":"")+e.toLowerCase()};return i.replace(/[A-Z]+(?![a-z])|[A-Z]/g,t)}function Ss(i){var t="";return Object.keys(i).forEach(function(e){t.length!==0&&(t+="&"),t+=e+"="+i[e]}),t}function xs(i){return i==="sandbox"?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js"}function Zo(i,t){t===void 0&&(t={});var e=document.createElement("script");return e.src=i,Object.keys(t).forEach(function(r){e.setAttribute(r,t[r]),r==="data-csp-nonce"&&e.setAttribute("nonce",t["data-csp-nonce"])}),e}function Ps(i,t){if(t===void 0&&(t=Promise),Xo(i,t),typeof document>"u")return t.resolve(null);var e=As(i),r=e.url,o=e.attributes,a=o["data-namespace"]||"paypal",n=xo(a);return o["data-js-sdk-library"]||(o["data-js-sdk-library"]="paypal-js"),Cs(r,o)&&n?t.resolve(n):ws({url:r,attributes:o},t).then(function(){var s=xo(a);if(s)return s;throw new Error("The window.".concat(a," global variable is not available."))})}function ws(i,t){t===void 0&&(t=Promise),Xo(i,t);var e=i.url,r=i.attributes;if(typeof e!="string"||e.length===0)throw new Error("Invalid url.");if(r!==void 0&&typeof r!="object")throw new Error("Expected attributes to be an object.");return new t(function(o,a){if(typeof document>"u")return o();Es({url:e,attributes:r,onSuccess:function(){return o()},onError:function(){var n=new Error('The script "'.concat(e,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return a(n)}})})}function xo(i){return window[i]}function Xo(i,t){if(typeof i!="object"||i===null)throw new Error("Expected an options object.");var e=i.environment;if(e&&e!=="production"&&e!=="sandbox")throw new Error('The `environment` option must be either "production" or "sandbox".');if(t!==void 0&&typeof t!="function")throw new Error("Expected PromisePonyfill to be a function.")}var Er=class extends Ge{constructor(){super(...arguments);N(this,"paypalInstance");N(this,"dataNamespace",Ot());N(this,"callbacks",{onStart:()=>{},onError:()=>{},onSuccess:()=>{}})}setCallbacks(e){this.callbacks=e}async tokenize(){throw new Error("PayPal does not support direct tokenization")}async setup(){let{clientId:e,intent:r}=this.config.options;if(!e||!r)return!1;try{let o=await Ps({dataNamespace:this.dataNamespace,clientId:e,currency:this.context.configuration.clientSession.order.currencyCode,components:["buttons","funding-eligibility"],disableFunding:["bancontact","card","credit"],intent:r??"authorize"});return o?(this.paypalInstance=o,!0):!1}catch{return!1}}async render(e){if(!this.paypalInstance.Buttons)return;let r=this.paypalInstance.Buttons({style:{color:"gold",shape:"rect",label:"paypal",tagline:!1},createOrder:this.handleCreateOrder.bind(this),onInit:this.handleInit.bind(this),onClick:this.handleClick.bind(this),onApprove:this.handleApprove.bind(this),onCancel:this.handleCancel.bind(this),onError:this.handleError.bind(this)});if(!r.isEligible())throw new Error("PayPal Buttons are not eligible for rendering");await r.render(e)}handleInit(e,r){}handleClick(e,r){return r.resolve()}async handleCreateOrder(){this.callbacks.onStart(),await this.context.clientSessionApi.selectPaymentMethod(this.config.type);let{data:e,error:r}=await this.context.coreApi.createPaypalOrder(this.buildCreateOrderRequestBody());if(r||!e)throw r??new Error("Unable to create PayPal order");return e.orderId}async handleApprove(e,r){let o=null;try{o=await r?.order?.get()??null}catch{}let{error:a,data:n}=await this.context.pciApi.postPaymentInstruments({external_payer_info:{email:o?.payment_source?.paypal?.email_address,external_payer_id:e.payerID??void 0},paypal_order_id:e.orderID,paypal_status:o?.status});if(a||!n)throw a??new Error("Unable to create payment instrument");let s=await this.createPayment(n.token);this.callbacks.onSuccess(s)}handleCancel(){this.context.clientSessionApi.unselectPaymentMethod()}handleError(e){}buildCreateOrderRequestBody(){let{order:{currencyCode:e,merchantAmount:r,totalOrderAmount:o,shipping:a,lineItems:n=[],fees:s=[]}}=this.context.configuration.clientSession;if(!e)throw new Error("Currency code is not provided");let l={amount:r??o,currencyCode:e,paymentMethodConfigId:this.config.id,amountBreakdown:{}},c=!n.some(({description:h})=>!h);if(c&&(l.items=n.map(({description:h,taxAmount:u,amount:y,quantity:_})=>{let E=u?Math.floor(u/_):0;return{name:h,unit_amount:{value:y,currency_code:e},quantity:_.toString(),tax:{value:E,currency_code:e}}})),c&&n.length){let h=n.reduce((E,{amount:w,quantity:I})=>E+w*I,0),u=s?.reduce?.((E,{amount:w})=>E+(w??0),0),y=n?.reduce((E,{discountAmount:w})=>E+(w??0),0),_=n?.reduce((E,{taxAmount:w,quantity:I})=>E+(w??0*I),0);l.amountBreakdown={item_total:{value:h,currency_code:e},tax_total:{value:_,currency_code:e},handling:{value:u??0,currency_code:e},shipping:{value:a?.amount??0,currency_code:e},discount:{value:y,currency_code:e}}}return l}};function Ar(i,t){return(i/100).toFixed(2)}var Po=5,_r=class extends Ge{constructor(){super(...arguments);N(this,"applePaySession",null);N(this,"callbacks",{onStart:()=>{},onError:()=>{},onSuccess:()=>{}})}setCallbacks(e){this.callbacks=e}async tokenize(){throw new Error("ApplePay does not support direct tokenization")}async setup(){try{if(!ApplePaySession||!ApplePaySession.supportsVersion(Po)||!ApplePaySession.canMakePayments())return!1;let e=window.location.hostname;if(!(this.config.options.merchantDomains||[]).includes(e))return!1}catch{return!1}return!0}async render(e){let r=document.createElement("button");r.setAttribute("style","display: inline-block;width: 100%;cursor: pointer;height: 40px;-webkit-appearance: -apple-pay-button;-apple-pay-button-type: plain;-apple-pay-button-style: black"),r.setAttribute("type","button"),r.classList.add("primer-apple-pay-button"),r.addEventListener("click",this.handleButtonClick.bind(this)),e.appendChild(r)}async handleButtonClick(){try{this.callbacks.onStart(),this.applePaySession=new ApplePaySession(Po,this.createPaymentRequest()),this.applePaySession.onvalidatemerchant=this.handleValidateMerchant.bind(this),this.applePaySession.onpaymentauthorized=this.handlePaymentAuthorized.bind(this),this.applePaySession.onpaymentmethodselected=this.handlePaymentMethodSelected.bind(this),this.applePaySession.oncancel=this.handleCancel.bind(this),this.applePaySession.begin()}catch{}}async handleValidateMerchant({validationURL:e}){if(this.applePaySession)try{let{data:r,error:o}=await this.context.coreApi.createApplePaySession({validationUrl:e,paymentMethodConfigId:this.config.id,merchantDomain:window.location.hostname});if(o||!r||!this.applePaySession)throw o??new Error("Failed to validate merchant");this.applePaySession.completeMerchantValidation(r)}catch{this.abort()}}async handlePaymentMethodSelected(){if(this.applePaySession)try{let{merchantAmount:e,totalOrderAmount:r,currencyCode:o}=this.context.configuration.clientSession.order;this.applePaySession.completePaymentMethodSelection({newTotal:{label:this.config.options.merchantName,amount:Ar(e??r,o),type:"final"}})}catch{this.abort()}}async handlePaymentAuthorized({payment:e}){if(this.applePaySession)try{let r={paymentMethodConfigId:this.config.id,token:e.token},o=await this.context.pciApi.postPaymentInstruments(r),a=await this.createPayment(o.data.token),n=await this.handleRequiredAction(a);n.status==="SUCCESS"?(this.applePaySession.completePayment(ApplePaySession.STATUS_SUCCESS),this.callbacks.onSuccess(n)):(this.applePaySession.completePayment(ApplePaySession.STATUS_FAILURE),this.callbacks.onError()),this.applePaySession=null}catch{this.applePaySession&&(this.applePaySession.completePayment(ApplePaySession.STATUS_FAILURE),this.applePaySession=null),this.callbacks.onError()}}handleCancel(){this.applePaySession=null,this.callbacks.onError()}abort(){this.applePaySession?.abort(),this.applePaySession=null,this.callbacks.onError()}createPaymentRequest(){let{countryCode:e,currencyCode:r,merchantAmount:o,totalOrderAmount:a}=this.context.configuration.clientSession.order;if(!e||!r)throw new Error("Country code and currency code are required");let n=["visa","masterCard","amex"],s=Ar(o??a,r);return{countryCode:e,currencyCode:r,merchantCapabilities:["supports3DS"],supportedNetworks:n,total:{amount:s,label:this.config.options.merchantName,type:"pending"}}}};function Ms(i,t={}){return new Promise((e,r)=>{if(document.querySelector(`script[src="${i}"]`))return void e();let o=document.createElement("script");o.src=i,Object.entries(t).forEach(([a,n])=>{o.setAttribute(a,n)}),o.onload=()=>{e()},o.onerror=()=>{r(new Error(`Failed to load script: ${i}`))},document.head.appendChild(o)})}var wo=2,Mo=0,Sr=class extends Ge{constructor(){super(...arguments);N(this,"client");N(this,"callbacks",{onStart:()=>{},onError:()=>{},onSuccess:()=>{}});N(this,"allowedPaymentMethod",{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"]}})}setCallbacks(e){this.callbacks=e}async tokenize(){throw new Error("Google Pay does not support direct tokenization")}async setup(){try{await Ms("https://pay.google.com/gp/p/js/pay.js")}catch{return!1}if(!window.google||!window.google.payments||(this.client=new google.payments.api.PaymentsClient({environment:"TEST"}),!this.client.isReadyToPay(this.buildIsReadyToPayRequest())))return!1;let{countryCode:e,currencyCode:r}=this.context.configuration.clientSession.order;return!(!e||!r)}async render(e){let r=this.client.createButton({buttonType:"buy",buttonColor:"black",buttonSizeMode:"fill",buttonRootNode:e instanceof ShadowRoot?e:void 0,onClick:this.handleButtonClick.bind(this)});e.appendChild(r)}async handleButtonClick(){this.callbacks.onStart();try{let e=this.buildPaymentDataRequest(),r=await this.client.loadPaymentData(e),{data:o,error:a}=await this.context.pciApi.postPaymentInstruments({flow:"GATEWAY",network:r.paymentMethodData.info?.cardNetwork??"OTHER",merchant_id:this.config.options.merchantId,encrypted_payload:vr.encode(r.paymentMethodData.tokenizationData.token)});if(a||!o)throw a??new Error("Failed to tokenize payment data");let n=await this.createPayment(o.token);n.status==="SUCCESS"?this.callbacks.onSuccess(n):this.callbacks.onError()}catch(e){throw this.callbacks.onError(),e}}async handlePaymentDataChanged(e){return{}}buildIsReadyToPayRequest(){return{apiVersion:wo,apiVersionMinor:Mo,allowedPaymentMethods:[this.allowedPaymentMethod]}}buildPaymentDataRequest(){let{countryCode:e,currencyCode:r,merchantAmount:o,totalOrderAmount:a}=this.context.configuration.clientSession.order;return{apiVersion:wo,apiVersionMinor:Mo,transactionInfo:{countryCode:e,currencyCode:r,displayItems:[],totalPriceStatus:"FINAL",totalPrice:Ar(o??a,r),totalPriceLabel:"Total"},merchantInfo:{merchantId:this.config.options.merchantId,merchantName:this.config.options.merchantName},allowedPaymentMethods:[{...this.allowedPaymentMethod,tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"primer",gatewayMerchantId:this.config.options.merchantId}}}]}}};async function Ts(i){let t=i.configuration.paymentMethods.map(r=>{if(r.implementationType==="WEB_REDIRECT")return new hi(r,i);if(r.type===st.PAYMENT_CARD)return new Cr(r,i);if(r.type===st.PAYPAL)return new Er(r,i);if(r.type===st.APPLE_PAY)return new _r(r,i);if(r.type===st.GOOGLE_PAY)return new Sr(r,i)}).map(r=>r?.setup().then(o=>o?r:null));return(await Promise.all(t)).filter(r=>!!r)}async function ks(i){let t=await cs(i),e=await Ts(t);return{context:t,paymentMethods:e}}var xr=class i{constructor(t,e=window.parent){N(this,"sessionId");N(this,"targetWindow");N(this,"messageHandlers",new Set);this.sessionId=t,this.targetWindow=e}send(t,e,r){let o={sessionId:this.sessionId,type:t,...r&&{target:r},...e&&{data:e}};this.targetWindow.postMessage(o,"*")}listen(t){let e=r=>{let o=r.data;if(o?.sessionId===this.sessionId){let{sessionId:a,...n}=o;t(n)}};return this.messageHandlers.add(e),window.addEventListener("message",e),()=>{window.removeEventListener("message",e),this.messageHandlers.delete(e)}}forIframe(t){if(!t.contentWindow)throw new Error("Iframe contentWindow is not available");return new i(this.sessionId,t.contentWindow)}cleanup(){this.messageHandlers.forEach(t=>{window.removeEventListener("message",t)}),this.messageHandlers.clear()}};async function Is(i){try{await i.start();let t=await i.tokenize(),e=await i.createPayment(t.token);return await i.handleRequiredAction(e)}catch(t){throw t}}var Ns=async(i,t)=>{if(!i.onBeforePaymentCreate)return!0;let e=setTimeout(()=>{},1e4);return new Promise(r=>{i.onBeforePaymentCreate({paymentMethodType:t},{continuePaymentCreation:()=>{clearTimeout(e),r(!0)},abortPaymentCreation:()=>{clearTimeout(e),r(!1)}})})};async function Qo(i,t){if(!await Ns(i,t.config.type)){i.onCheckoutFail?.(new Error("Payment creation aborted"),{});return}i.onPaymentCreationStart?.();let r=null,o=null;try{o=await Is(t)}catch(a){r=a}finally{if(r||!o){i.onCheckoutFail?.(new Error("Payment creation failed"),{});return}if(o.status==="FAILED")return void i.onCheckoutFail?.(new Error("Payment failed"),{payment:o??{}});i.onCheckoutComplete?.({payment:o})}}function Ls(i,t,e,r={}){let o=[],a="LOCAL";return e.store.publicStore.subscribe(({networks:n,networksSource:s})=>{s==="LOCAL"&&a!=="LOCAL"&&r.onCardNetworksLoading?.(),(s!==a||Os(o,n))&&(o=n,a=s,r.onCardNetworksChange?.(Rs({networks:o,source:a},t.configuration.clientSession.paymentMethod.orderedAllowedCardNetworks)))}),{createHostedInputs:()=>{let n=new xr(t.checkoutSessionId),s=l=>{let c=new Map,h=n.listen(u=>{u.target===l&&(u.type==="focus"?c.get("focus")?.():u.type==="blur"?c.get("blur")?.():u.type==="input"&&(c.get("input")?.(u.data),c.get("change")?.(u.data)))});return{cleanup:()=>{h()},getOptions:()=>e.store.optionsStore.getState()[l]||{placeholder:"",ariaLabel:"",style:{}},setOptions:u=>{e.store.optionsStore.setState({[l]:{...e.store.optionsStore.getState()[l],...u}})},render:(u,y)=>{let _=e.iframes[l];if(!_)return Promise.resolve();let E;return E=typeof u=="string"?document.querySelector(u):u,E&&(E.appendChild(_),_.onload=()=>{e.store.optionsStore.setState({[l]:y})}),Promise.resolve()},addEventListener:(u,y)=>{c.set(u,y)},focus:()=>{let u=e.iframes[l];u&&u.contentWindow&&n.forIframe(u).send("focus",void 0,l)},blur:()=>{let u=e.iframes[l];u&&u.contentWindow&&n.forIframe(u).send("blur",void 0,l)},setDisabled:u=>{let y=e.store.publicStore.getState();e.store.publicStore.setState({...y,[l]:{...y[l],disabled:u}})}}};return{cardNumberInput:s("cardNumber"),cardHolderNameInput:s("cardHolderName"),expiryInput:s("cardExpiryDate"),cvvInput:s("cardSecurityCode")}},removeHostedInputs:()=>{e.iframes.cardNumber.remove(),e.iframes.cardSecurityCode.remove(),e.iframes.cardExpiryDate.remove(),e.iframes.cardHolderName.remove()},submit:n=>{if(n?.cardNetwork){let s=e.store.publicStore.getState();e.store.publicStore.setState({...s,preferredNetwork:n.cardNetwork})}return Qo(i,e)},validate:()=>{let n=e.store.publicStore.getState(),s=[],l=["cardNumber","cardSecurityCode","cardExpiryDate","cardHolderName"];for(let c of l){let h=n[c];!h.valid&&h.error&&s.push({field:c,name:c,error:h.error,message:h.error})}return Promise.resolve({valid:s.length===0,validationErrors:s})},reset:()=>{t.apiControllerIframe?.contentWindow&&new xr(t.checkoutSessionId).forIframe(t.apiControllerIframe).send("reset-card-form")}}}function Os(i,t){if(i.length!==t.length)return!0;let e=t.map(({network:r})=>r);return!i.every(({network:r})=>e.includes(r))}function Rs({networks:i,source:t},e){let r=e,o=new Set(r.map(l=>ko(l).backend)),a=i.map(l=>({...l,allowed:o.has(l.network)})).sort((l,c)=>l.allowed?r.indexOf(l.network)-r.indexOf(c.network):1),n=a.filter(l=>l.allowed),s=t==="REMOTE"&&n.length>1;return{detectedCardNetworks:{items:a,preferred:n[0]},...s&&{selectableCardNetworks:{items:n,preferred:n[0]}},source:t}}function Ds(i,t,e){return{createButton:()=>({render:async r=>{e.setCallbacks({onStart:()=>{i.onBeforePaymentCreate?.({paymentMethodType:e.config.type},{continuePaymentCreation:()=>{i.onPaymentCreationStart?.()},abortPaymentCreation:()=>{}})},onSuccess(o){i.onCheckoutComplete?.({payment:o})},onError(){i.onCheckoutFail?.(new Error("Payment creation failed"),{})}}),await e.render(r)}})}}function $s(i,t,e){return{start:()=>Qo(i,e)}}async function ea(i,t){let{paymentMethods:e,context:r}=await ks(i);return t.onAvailablePaymentMethodsLoad?.(e.map(o=>({type:o.config.type,managerType:o.config.type===st.PAYMENT_CARD?"CARD":o.config.implementationType==="NATIVE_SDK"?"NATIVE":"REDIRECT"}))),{start:()=>Promise.resolve(),createPaymentMethodManager:async(o,a)=>{let n=e.find(({config:s})=>s.type===o);return n?n instanceof Cr?Ls(t,r,n,a):n instanceof Er||n instanceof _r||n instanceof Sr?Ds(t,r,n):$s(t,r,n):null},getSDKUtilities:()=>({getCardNetworkAsset:o=>{let{asset:a,display:n}=ko(o);return{cardUrl:`${is}/brand/card/${a}.svg`,displayName:n}},getUIOrderAmount:()=>{let{merchantAmount:o,totalOrderAmount:a,currencyCode:n}=r.configuration.clientSession.order;return Ar(o??a,n)},getCDNAssets:o=>{let a=e.find(({config:c})=>c.type===o);if(!a)return null;let{backgroundColor:n,iconUrl:s,text:l}=a.config.displayMetadata?.button||{};return{backgroundColor:n,iconUrl:s,paymentMethodName:l,displayName:a.config.name}},getPaymentMethodConfiguration:o=>e.find(({config:a})=>a.type===o)?.config}),createVaultManager:()=>({})}}var Pr=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 L(t,{args:()=>[this.host.clientToken,this.host.options],task:this.initializeHeadless()}),new L(t,{args:()=>[this.sdkInstanceTask.value,this.paymentsList],task:this.initializeLitContext()})}set paymentsList(t){this._paymentsList=t,this.host.requestUpdate()}get paymentsList(){return this._paymentsList}hostConnected(){this.isDisconnected=!1,this.host.sdkStateController.startLoading(),this.setupLoadingTimeout()}hostDisconnected(){this.isDisconnected=!0,this.cleanupResources()}setupLoadingTimeout(){this.clearLoadingTimeout(),this.loadingTimeout=setTimeout(()=>{this.host.sdkStateController.currentState.isLoading&&(A.warn("Loading timeout reached, resetting SDK state"),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(),A.info("SDK instance cleaned up")}catch(t){A.error("Error cleaning up SDK instance:",t)}this.currentSdkInstance=null,this.primerJS=null}async _loadV2Sdk(t=uo){let e=window;if(e.Primer&&typeof e.Primer.preloadPrimer=="function"){A.info("SDK already loaded, skipping load script"),await e.Primer.preloadPrimer();return}await ho(t),await e.Primer.preloadPrimer()}initializeHeadless(){return async([t,e])=>{if(this.isDisconnected)return A.warn("Component disconnected, aborting SDK initialization"),M;if(!t||!e)return M;this.cleanupResources();try{let r;e.sdkCore?r={createHeadless:(s,l)=>ea(s,l)}:(await this._loadV2Sdk(),r=window.Primer),this.primerJS=new mr(null);let o=await r.createHeadless(t,{...e,onAvailablePaymentMethodsLoad:n=>{this.isDisconnected||(A.info("Configuration payment methods:",n),this.paymentsList=n)},onCheckoutComplete:({payment:n})=>{this.isDisconnected||(A.info("Payment completed:",n),this.host.sdkStateController.completeProcessing(),this.primerJS&&this.primerJS.handlePaymentComplete(n))},onCheckoutFail:(n,s)=>{this.isDisconnected||(A.error("Payment failed:",n),this.host.sdkStateController.setFailure(n.code||"UNKNOWN_ERROR",n.message||"Unknown error occurred"),this.primerJS&&this.primerJS.handlePaymentFailure(n,s.payment))},onBeforePaymentCreate:(n,s)=>{this.isDisconnected||(this.host.sdkStateController.startProcessing(),this.primerJS?this.primerJS.handleBeforePaymentCreate(n,s):s?.continuePaymentCreation())},onPaymentMethodAction:(n,s)=>{this.isDisconnected||n==="PAYMENT_METHOD_UNSELECTED"&&this.host.sdkStateController.stopProcessing()},onPaymentCreationStart:()=>{this.isDisconnected||(this.host.sdkStateController.resetError(),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(),M;this.host.sdkContextController.setClientOptions(e),this.primerJS&&this.host.primerEventsController.dispatchCheckoutInitialized(this.primerJS);let a=o.getSDKUtilities();return this.host.sdkContextController.setHeadlessUtils(a),this.host.vaultManagerController.initializeVaultManager(o.createVaultManager.bind(o),{vaultEnabled:e.vault?.enabled,captureVaultedCardCvv:!!a.getPaymentMethodConfiguration("PAYMENT_CARD")?.options?.captureVaultedCardCvv,showEmptyState:e.vault?.showEmptyState}),o}catch(r){throw r instanceof Error&&(A.error("SDK initialization error:",r),this.host.sdkStateController.setError(r)),this.cleanupResources(),r}}}initializeLitContext(){return async([t,e])=>{if(this.isDisconnected)return M;if(!t||!e.length)return M;let r=new Map,o=new Map;try{for(let n of e){if(this.isDisconnected)break;let s=await this.initializePaymentMethodManager(n)();n&&s&&(r.set(n.type,n),o.set(n.type,s))}if(this.isDisconnected)return M;let a=new ur(r);return this.host.sdkContextController.setPaymentManagers(o),this.host.sdkContextController.setPaymentMethods(a),this.primerJS&&this.primerJS.setPaymentMethods(a),this.host.primerEventsController.dispatchPaymentMethods(a),A.info("Initialized payment methods:",a.toArray()),r}catch(a){if(a instanceof Error)throw this.host.sdkStateController.setError(a),a;return null}finally{this.clearLoadingTimeout(),this.isDisconnected||this.host.sdkStateController.completeLoading()}}}initializePaymentMethodManager(t){let{type:e,managerType:r}=t;return async()=>{if(this.isDisconnected||!this.createPaymentMethodManager)return null;if(r==="KLARNA"){let o=await this.createPaymentMethodManager("KLARNA",{onPaymentMethodCategoriesChange:a=>{this.isDisconnected||this.host.sdkContextController.setKlarnaCategories({categories:a,isLoading:!1})}});return o?{type:e,manager:o}:null}try{if(r==="CARD"){let a=await this.createPaymentMethodManager(e,{onCardNetworksChange:n=>{this.isDisconnected||this.host.cardNetworkController.processCardNetworkChangeEvent(n)},onCardNetworksLoading:()=>{this.isDisconnected||this.host.cardNetworkController.setCardNetworksLoading()}});return a?{type:e,manager:a}:null}let o=await this.createPaymentMethodManager(e);return o?{type:e,manager:o}:null}catch(o){return A.error(`Failed to initialize manager for ${e}:`,o),null}}}};var wr=class{constructor(t){this.host=t,t.addController(this)}_error(t){let{error:e}=t.detail;this.host.sdkStateController.setFailure("UNKNOWN_ERROR",e.message)}_mandateConfirmed(){this.host.sdkStateController.completeProcessing()}_mandateDeclined(){this.host.sdkStateController.setFailure("UNKNOWN_ERROR","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 Ys=xi({"../../localization/lit-localize/locales/ar.ts":()=>import("./chunks/ar.KRXB3WQO.js"),"../../localization/lit-localize/locales/bg.ts":()=>import("./chunks/bg.6SKJRXIR.js"),"../../localization/lit-localize/locales/ca.ts":()=>import("./chunks/ca.SANDLFEK.js"),"../../localization/lit-localize/locales/cs.ts":()=>import("./chunks/cs.FC4I5M3C.js"),"../../localization/lit-localize/locales/da.ts":()=>import("./chunks/da.YI32NZ7B.js"),"../../localization/lit-localize/locales/de.ts":()=>import("./chunks/de.7M7UFQB7.js"),"../../localization/lit-localize/locales/el.ts":()=>import("./chunks/el.XSGTYDZR.js"),"../../localization/lit-localize/locales/en-GB.ts":()=>import("./chunks/en-GB.VO4GDE3X.js"),"../../localization/lit-localize/locales/en.ts":()=>import("./chunks/en.MNFLVOE3.js"),"../../localization/lit-localize/locales/es-AR.ts":()=>import("./chunks/es-AR.TBWVUZEF.js"),"../../localization/lit-localize/locales/es-MX.ts":()=>import("./chunks/es-MX.6EMWUABR.js"),"../../localization/lit-localize/locales/es.ts":()=>import("./chunks/es.XZLDFHYI.js"),"../../localization/lit-localize/locales/et-EE.ts":()=>import("./chunks/et-EE.JBSFMKZ2.js"),"../../localization/lit-localize/locales/fi-FI.ts":()=>import("./chunks/fi-FI.I75VK2ID.js"),"../../localization/lit-localize/locales/fr.ts":()=>import("./chunks/fr.JBNP6RXT.js"),"../../localization/lit-localize/locales/he.ts":()=>import("./chunks/he.PW253QAL.js"),"../../localization/lit-localize/locales/hr.ts":()=>import("./chunks/hr.LM4RITYJ.js"),"../../localization/lit-localize/locales/hu.ts":()=>import("./chunks/hu.JGCKQA6J.js"),"../../localization/lit-localize/locales/id.ts":()=>import("./chunks/id.VBXULDDY.js"),"../../localization/lit-localize/locales/it.ts":()=>import("./chunks/it.7Q6BFLDK.js"),"../../localization/lit-localize/locales/ja.ts":()=>import("./chunks/ja.QOC76SSC.js"),"../../localization/lit-localize/locales/ko.ts":()=>import("./chunks/ko.BANZIFNH.js"),"../../localization/lit-localize/locales/lt-LT.ts":()=>import("./chunks/lt-LT.Q2SRJOKH.js"),"../../localization/lit-localize/locales/lt.ts":()=>import("./chunks/lt.XMNFEN5T.js"),"../../localization/lit-localize/locales/lv-LV.ts":()=>import("./chunks/lv-LV.3AJDTMU5.js"),"../../localization/lit-localize/locales/lv.ts":()=>import("./chunks/lv.TFPDXNEV.js"),"../../localization/lit-localize/locales/ms.ts":()=>import("./chunks/ms.FPTX4NM4.js"),"../../localization/lit-localize/locales/nb.ts":()=>import("./chunks/nb.CAFSKRQ2.js"),"../../localization/lit-localize/locales/nl.ts":()=>import("./chunks/nl.7BPSDYTC.js"),"../../localization/lit-localize/locales/nl_NL.ts":()=>import("./chunks/nl_NL.6ZVCFPVW.js"),"../../localization/lit-localize/locales/pl.ts":()=>import("./chunks/pl.RF34QM23.js"),"../../localization/lit-localize/locales/pt-BR.ts":()=>import("./chunks/pt-BR.AKDHLRUA.js"),"../../localization/lit-localize/locales/pt.ts":()=>import("./chunks/pt.VBALOWHZ.js"),"../../localization/lit-localize/locales/ro.ts":()=>import("./chunks/ro.WN7VCF27.js"),"../../localization/lit-localize/locales/ru.ts":()=>import("./chunks/ru.ICXGVGRR.js"),"../../localization/lit-localize/locales/sk.ts":()=>import("./chunks/sk.SIP5JIOX.js"),"../../localization/lit-localize/locales/sl.ts":()=>import("./chunks/sl.R77UEKCA.js"),"../../localization/lit-localize/locales/sr-RS.ts":()=>import("./chunks/sr-RS.6M2YSTDX.js"),"../../localization/lit-localize/locales/sv.ts":()=>import("./chunks/sv.33ZY4CDS.js"),"../../localization/lit-localize/locales/th.ts":()=>import("./chunks/th.M27YUIZC.js"),"../../localization/lit-localize/locales/tr.ts":()=>import("./chunks/tr.Q2SIY6NA.js"),"../../localization/lit-localize/locales/uk-UA.ts":()=>import("./chunks/uk-UA.EJZOGSJR.js"),"../../localization/lit-localize/locales/vi.ts":()=>import("./chunks/vi.3RROGLXM.js"),"../../localization/lit-localize/locales/zf.ts":()=>import("./chunks/zf.GGWFQ3Y7.js"),"../../localization/lit-localize/locales/zh-CN.ts":()=>import("./chunks/zh-CN.MQHNRMN4.js"),"../../localization/lit-localize/locales/zh-HK.ts":()=>import("./chunks/zh-HK.WNR7XUSX.js"),"../../localization/lit-localize/locales/zh-TW.ts":()=>import("./chunks/zh-TW.GNCY2PNY.js")});qr(i=>Ys(`../../localization/lit-localize/locales/${i}.ts`));var Vs={LOADER_DISABLED:"loader-disabled",CUSTOM_STYLES:"custom-styles",CLIENT_TOKEN:"client-token",JS_INIT:"js-initialized"},q=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.locale="en-GB";this.onSlotChange=e=>{let o=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=o.length>0,this.requestUpdate()};this.sdkContextController=new jt(this),this.sdkStateController=new zt(this),this.primerEventsController=new tt(this),this.styleProcessingController=new Kt(this),this.vaultManagerController=new bt(this),this.cardNetworkController=new $t(this),this.achPaymentEventsController=new wr(this),new Pr(this)}set jsInitialized(e){this.requestUpdate(),this._jsInitialized=e}get jsInitialized(){return this._jsInitialized}attributeChangedCallback(e,r,o){e===Vs.CUSTOM_STYLES?this.styleProcessingController.processCustomStyles(o):super.attributeChangedCallback(e,r,o)}disconnectedCallback(){this._loadingTimeoutId&&(window.clearTimeout(this._loadingTimeoutId),this._loadingTimeoutId=null),this.sdkStateController?.currentState.isLoading&&this.sdkStateController.forceCompleteLoading(),super.disconnectedCallback()}willUpdate(e){e.has("options")&&(this.options?.locale&&(Jr(this.options?.locale)?this.locale=Zr(this.options?.locale):A.warn("\u{1F30E}\u2757 Unsupported locale provided:",this.options?.locale,"- Falling back to default locale `en-GB`")),Wr(this.locale||"en-GB"))}updated(){let e=getComputedStyle(this);this.sdkContextController.setComputedStyles(e),this.checkLoadingStateChange()}checkLoadingStateChange(){let e=this.sdkStateController?.currentState.isLoading||!1;this.previousLoadingState&&!e&&(this.jsInitialized=!0),this.previousLoadingState=e,e&&!this._loadingTimeoutId?this._loadingTimeoutId=window.setTimeout(()=>{this.sdkStateController?.currentState.isLoading&&(A.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,r=e.isLoading,o=e.error,a=!r&&!o;return m` ${O(r,()=>f)} ${O(o,()=>m`<primer-checkout-error></primer-checkout-error>`)} ${O(a,()=>m`<slot name="main" @slotchange=${this.onSlotChange}></slot>${O(this.hasAssignedContent,()=>f,()=>m`<primer-main></primer-main>`)} `,()=>f)} `}addEventListener(e,r,o){super.addEventListener(e,r,o)}removeEventListener(e,r,o){super.removeEventListener(e,r,o)}};q.styles=[T,po],d([p({type:String,attribute:"custom-styles"})],q.prototype,"customStyles",2),d([p({type:String,attribute:"client-token"})],q.prototype,"clientToken",2),d([p({type:Object})],q.prototype,"options",2),d([p({type:Boolean,attribute:"loader-disabled"})],q.prototype,"disableLoader",2),d([p({type:Boolean,reflect:!0,attribute:"js-initialized"})],q.prototype,"_jsInitialized",2),d([ke("slot")],q.prototype,"defaultSlot",2),d([P()],q.prototype,"previousLoadingState",2),q=d([R(),b("primer-checkout")],q);var Bs=Us({tagName:"primer-checkout",elementClass:q,react:Hs});import{createComponent as zs}from"@lit/react";import Fs from"react";var ta=g` :host { display: flex; flex-direction: column; align-items: center; gap: var(--primer-space-xsmall); } p { margin: 0; color: var(--primer-color-text-primary); text-align: center; font-size: var(--primer-typography-body-large-size); font-family: var(--primer-typography-body-large-font); font-weight: var(--primer-typography-body-large-weight); line-height: var(--primer-typography-body-large-line-height); letter-spacing: var(--primer-typography-body-large-letter-spacing); } p.secondary { color: var(--primer-color-text-secondary); text-align: center; font-family: var(--primer-typography-body-medium-font, Inter); font-size: var(--primer-typography-body-medium-size); font-weight: var(--primer-typography-body-medium-weight); line-height: var(--primer-typography-body-medium-line-height); letter-spacing: var(--primer-typography-body-medium-letter-spacing); } `;var be=class extends v{constructor(){super(...arguments);this.type="complete"}render(){return this.type==="complete"?m`<primer-icon size="lg" name="successful-check" color="var(--primer-color-icon-positive)" ></primer-icon><p>Checkout complete!</p><p class="secondary"> You'll be redirected to the order confirmation page soon. </p>`:m`<primer-icon size="lg" name="failure-icon" color="var(--primer-color-icon-negative)" ></primer-icon><p>Payment failed</p>${this.description?m`<p class="secondary">${this.description}</p>`:m`<p class="secondary">Something went wrong.</p>`} `}};be.styles=[ta],d([p({type:String,reflect:!0})],be.prototype,"type",2),d([p({type:String,reflect:!0})],be.prototype,"description",2),be=d([b("primer-checkout-state")],be);var js=zs({tagName:"primer-checkout-state",elementClass:be,react:Fs});import{createComponent as Ks}from"@lit/react";import Gs from"react";var ra=g` :host { display: block; } .collapsable { width: 100%; } /* Make the button display with full width */ primer-button::part(button) { width: 100%; } .collapsable-wrapper { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--primer-animation-duration) var(--primer-animation-easing); overflow: hidden; border-top: none; margin-top: -1px; } .collapsable-wrapper.expanded { grid-template-rows: 1fr; } .collapsable-content { min-height: 0; overflow: hidden; padding: var(--primer-space-medium, 12px) 0; } .icon-container { display: flex; align-items: center; justify-content: center; transition: transform var(--primer-animation-duration) var(--primer-animation-easing); font-size: 0.75em; } .icon-container.expanded { transform: rotate(180deg); } /* Disable animation for users who prefer reduced motion */ @media (prefers-reduced-motion: reduce) { .collapsable-wrapper, .icon-container { transition: none; } } `;var W=class extends v{constructor(){super(...arguments);this.header="";this.expanded=!1;this.expandText="Expand";this.collapseText="Collapse";this.ariaLabel="";this.buttonVariant="primary";this.isExpanded=!1;this.toggleExpanded=()=>{this.isExpanded=!this.isExpanded,this.dispatchExpandedChangedEvent(this.isExpanded)}}connectedCallback(){super.connectedCallback(),this.isExpanded=this.expanded}dispatchExpandedChangedEvent(e){this.dispatchEvent(new CustomEvent("expanded-changed",{bubbles:!0,composed:!0,detail:{expanded:e}}))}expand(){this.isExpanded||(this.isExpanded=!0,this.dispatchExpandedChangedEvent(!0))}collapse(){this.isExpanded&&(this.isExpanded=!1,this.dispatchExpandedChangedEvent(!1))}render(){let e=this.isExpanded?this.collapseText:this.expandText,r=this.ariaLabel||this.header||e,o=this.header||e;return m`<div class="collapsable"><primer-button variant=${this.buttonVariant} buttonType="button" @click=${this.toggleExpanded} aria-expanded=${this.isExpanded} aria-controls="collapsable-content" aria-label=${r} ><span>${o}</span></primer-button><div class="collapsable-wrapper ${this.isExpanded?"expanded":""}" id="collapsable-content" role="region" aria-labelledby="collapsable-header" ><div class="collapsable-content"><slot></slot></div></div></div>`}};W.styles=[ra],d([p({type:String})],W.prototype,"header",2),d([p({type:Boolean})],W.prototype,"expanded",2),d([p({type:String})],W.prototype,"expandText",2),d([p({type:String})],W.prototype,"collapseText",2),d([p({type:String})],W.prototype,"ariaLabel",2),d([p({type:String})],W.prototype,"buttonVariant",2),d([P()],W.prototype,"isExpanded",2),W=d([b("primer-collapsable")],W);var qs=Ks({tagName:"primer-collapsable",elementClass:W,react:Gs});import{createComponent as Ws}from"@lit/react";import Js from"react";var ia=g` :host { display: contents; } .backdrop { position: absolute; top: 0; left: 0; background-color: rgba(0, 0, 0, 0.5); z-index: 1000; display: flex; justify-content: center; align-items: center; width: 100vw; height: 100vh; } .dialog { background-color: white; padding: var(--primer-space-medium); border-radius: var(--primer-radius-medium); max-width: 600px; } .header { display: flex; justify-content: flex-end; } `;var Ie={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Ce=i=>(...t)=>({_$litDirective$:i,values:t}),ut=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,r){this._$Ct=t,this._$AM=e,this._$Ci=r}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};var F=Ce(class extends ut{constructor(i){if(super(i),i.type!==Ie.ATTRIBUTE||i.name!=="class"||i.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(i){return" "+Object.keys(i).filter(t=>i[t]).join(" ")+" "}update(i,[t]){if(this.st===void 0){this.st=new Set,i.strings!==void 0&&(this.nt=new Set(i.strings.join(" ").split(/\s/).filter(r=>r!=="")));for(let r in t)t[r]&&!this.nt?.has(r)&&this.st.add(r);return this.render(t)}let e=i.element.classList;for(let r of this.st)r in t||(e.remove(r),this.st.delete(r));for(let r in t){let o=!!t[r];o===this.st.has(r)||this.nt?.has(r)||(o?(e.add(r),this.st.add(r)):(e.remove(r),this.st.delete(r)))}return ve}});var qe=class extends v{constructor(){super(...arguments);this._handleCloseClick=()=>{this.dispatchEvent(new CustomEvent("primer-dialog-close",{bubbles:!0,composed:!0}))}}render(){return m`<div class=${F({backdrop:!0})} @click=${e=>{e.preventDefault()}} ><div class="dialog"><div class="header"><primer-button variant="tertiary" @click=${this._handleCloseClick}><primer-icon name="close"></primer-icon></primer-button></div><div class="content"><slot></slot></div></div></div>`}};qe.styles=[ia],qe=d([b("primer-dialog")],qe);var Zs=Ws({tagName:"primer-dialog",elementClass:qe,react:Js});import{createComponent as Xs}from"@lit/react";import Qs from"react";var oa=g` :host { display: block; width: 100%; box-sizing: border-box; } .error-message { display: flex; align-items: flex-start; padding: var(--primer-space-medium); background-color: var(--primer-color-red-100); border-radius: var(--primer-radius-medium); border: 1px solid var(--primer-color-border-outlined-error); margin-top: var(--primer-space-small); box-sizing: border-box; width: 100%; /* Add animation properties */ opacity: 1; transform: translateY(0); transition: opacity var(--primer-animation-duration) var(--primer-animation-easing), transform var(--primer-animation-duration) var(--primer-animation-easing); } .error-message.hidden { opacity: 0; transform: translateY(-var(--primer-space-medium)); pointer-events: none; } .error-icon { flex-shrink: 0; margin-right: var(--primer-space-medium); color: var(--primer-color-icon-negative); } .error-content { flex: 1; font-family: var(--primer-typography-body-medium-font); font-size: var(--primer-typography-body-medium-size); font-weight: var(--primer-typography-body-medium-weight); line-height: var(--primer-typography-body-medium-line-height); letter-spacing: var(--primer-typography-body-medium-letter-spacing); color: var(--primer-color-text-negative); } /* Respect user's preference for reduced motion */ @media (prefers-reduced-motion: reduce) { .error-message { transition: opacity var(--primer-animation-duration) var(--primer-animation-easing); transform: none; } .error-message.hidden { transform: none; } } `;var de=class extends v{constructor(){super();this.message="";this.visible=!1;this._role="alert";this.showMessage=!1;this.role="alert"}get role(){return this._role}set role(e){this._role=e,this.setAttribute("role",e)}updated(e){e.has("visible")&&this.handleVisibilityChange()}handleVisibilityChange(){this.visible?(this.showMessage=!0,this.setAttribute("aria-hidden","false")):setTimeout(()=>{this.showMessage=!1,this.setAttribute("aria-hidden","true")},200)}render(){if(!this.showMessage&&!this.visible)return f;let e={"error-message":!0,hidden:!this.visible};return m`<div part="error-message" class=${F(e)} aria-live="assertive" aria-atomic="true" ><div part="error-icon" class="error-icon"><primer-icon name="failure-icon" size="sm" color="var(--primer-color-icon-negative)" ></primer-icon></div><div part="error-content" class="error-content">${this.message}</div></div>`}};de.styles=[oa],d([p({type:String})],de.prototype,"message",2),d([p({type:Boolean,reflect:!0})],de.prototype,"visible",2),d([P()],de.prototype,"showMessage",2),de=d([b("primer-error-message")],de);var el=Xs({tagName:"primer-error-message",elementClass:de,react:Qs});import{createComponent as tl}from"@lit/react";import rl from"react";var aa={trash:ne`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13.8333 2.99992H11.5V2.49992C11.5 2.05789 11.3244 1.63397 11.0118 1.32141C10.6993 1.00885 10.2754 0.833252 9.83333 0.833252H6.16667C5.72464 0.833252 5.30072 1.00885 4.98816 1.32141C4.67559 1.63397 4.5 2.05789 4.5 2.49992V2.99992H2.16667C1.98986 2.99992 1.82029 3.07015 1.69526 3.19518C1.57024 3.32021 1.5 3.48978 1.5 3.66659C1.5 3.8434 1.57024 4.01297 1.69526 4.138C1.82029 4.26302 1.98986 4.33326 2.16667 4.33326H2.83333V12.4999C2.83333 12.942 3.00893 13.3659 3.32149 13.6784C3.63405 13.991 4.05797 14.1666 4.5 14.1666H11.5C11.942 14.1666 12.3659 13.991 12.6785 13.6784C12.9911 13.3659 13.1667 12.942 13.1667 12.4999V4.33326H13.8333C14.0101 4.33326 14.1797 4.26302 14.3047 4.138C14.4298 4.01297 14.5 3.8434 14.5 3.66659C14.5 3.48978 14.4298 3.32021 14.3047 3.19518C14.1797 3.07015 14.0101 2.99992 13.8333 2.99992ZM5.83333 2.49992C5.83333 2.32311 5.90357 2.15354 6.0286 2.02851C6.15362 1.90349 6.32319 1.83325 6.5 1.83325H9.5C9.67681 1.83325 9.84638 1.90349 9.9714 2.02851C10.0964 2.15354 10.1667 2.32311 10.1667 2.49992V2.99992H5.83333V2.49992ZM11.8333 12.4999C11.8333 12.6767 11.7631 12.8463 11.6381 12.9713C11.513 13.0964 11.3435 13.1666 11.1667 13.1666H4.83333C4.65652 13.1666 4.48695 13.0964 4.36193 12.9713C4.2369 12.8463 4.16667 12.6767 4.16667 12.4999V4.33326H11.8333V12.4999Z" fill="currentColor"/><path d="M6.5 10.9999C6.67681 10.9999 6.84638 10.9297 6.9714 10.8047C7.09643 10.6796 7.16667 10.5101 7.16667 10.3333V7.33325C7.16667 7.15644 7.09643 6.98687 6.9714 6.86184C6.84638 6.73682 6.67681 6.66658 6.5 6.66658C6.32319 6.66658 6.15362 6.73682 6.0286 6.86184C5.90357 6.98687 5.83333 7.15644 5.83333 7.33325V10.3333C5.83333 10.5101 5.90357 10.6796 6.0286 10.8047C6.15362 10.9297 6.32319 10.9999 6.5 10.9999Z" fill="currentColor"/><path d="M9.5 10.9999C9.67681 10.9999 9.84638 10.9297 9.9714 10.8047C10.0964 10.6796 10.1667 10.5101 10.1667 10.3333V7.33325C10.1667 7.15644 10.0964 6.98687 9.9714 6.86184C9.84638 6.73682 9.67681 6.66658 9.5 6.66658C9.32319 6.66658 9.15362 6.73682 9.0286 6.86184C8.90357 6.98687 8.83333 7.15644 8.83333 7.33325V10.3333C8.83333 10.5101 8.90357 10.6796 9.0286 10.8047C9.15362 10.9297 9.32319 10.9999 9.5 10.9999Z" fill="currentColor"/></svg>`,"successful-check":ne`<svg viewBox="0 0 56 56" fill="none" xmlns="http://www.w3.org/2000/svg" ><g id="icon/check-circle-large"><path id="vector" fill-rule="evenodd" clip-rule="evenodd" d="M20.1762 29.5746L24.8429 34.2413C25.295 34.7007 26.0387 34.7007 26.4908 34.2413L35.8241 24.9079C36.2835 24.4559 36.2835 23.7121 35.8241 23.26C35.372 22.8007 34.6283 22.8007 34.1762 23.26L25.6668 31.7694L21.8241 27.9267C21.372 27.4673 20.6283 27.4673 20.1762 27.9267C19.7168 28.3788 19.7168 29.1225 20.1762 29.5746ZM28.0002 47.4173C38.3106 47.4173 46.6668 39.0611 46.6668 28.7507C46.6668 18.4402 38.3106 10.084 28.0002 10.084C17.6897 10.084 9.3335 18.4402 9.3335 28.7507C9.3335 39.0611 17.6897 47.4173 28.0002 47.4173Z" /></g></svg>`,"failure-icon":ne`<svg viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg" ><path fill-rule="evenodd" clip-rule="evenodd" d="M20.0008 23.3333C20.4614 23.3333 20.7873 22.9606 20.7873 22.5V15C20.7873 14.5394 20.4146 14.1666 20.0008 14.1666C19.587 14.1666 19.1675 14.5416 19.1675 15V22.5C19.1675 22.9583 19.5425 23.3333 20.0008 23.3333ZM32.9331 27.3594L22.5269 9.75935C22.0008 8.86821 21.0529 8.33488 20.0008 8.33331C18.9487 8.33331 18.006 8.8656 17.4748 9.75831L7.06331 27.3625C6.53987 28.2463 6.53206 29.3073 7.04134 30.201C7.568 31.1198 8.51904 31.6666 9.58935 31.6666H30.4175C31.4857 31.6666 32.4357 31.1182 32.9597 30.1995C33.4696 29.3073 33.4591 28.2448 32.9331 27.3594ZM18.7977 26.6666C18.7977 25.976 19.3107 25.4166 20.0008 25.4166C20.6935 25.4166 21.2508 25.9739 21.2039 26.6666C21.2039 27.3568 20.6909 27.9166 20.0008 27.9166C19.3576 27.9166 18.7977 27.3568 18.7977 26.6666Z" /></svg>`,"payment-card":ne`<svg width="28" height="21" viewBox="0 0 28 21" fill="none" xmlns="http://www.w3.org/2000/svg"><rect y="0.748047" width="28" height="20" rx="2" fill="#E0E0E0"/><rect y="6.74805" width="28" height="4" fill="#212121"/><rect x="19" y="13.748" width="6" height="4" rx="0.933333" fill="white"/></svg>`,"chevron-down":ne`<svg width="8" height="6" viewBox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.41978 4.90118C4.32079 5.02361 4.16188 5.08353 4.00037 5.08353C3.83887 5.08353 3.67996 5.02361 3.55753 4.90118L0.63995 1.9836C0.395733 1.73939 0.395733 1.34382 0.63995 1.09947C0.884167 0.855124 1.27973 0.855254 1.52408 1.09947L4.00037 3.57524L6.47589 1.09973C6.72011 0.855515 7.11567 0.855515 7.36002 1.09973C7.60437 1.34395 7.60424 1.73952 7.36002 1.98386L4.41978 4.90118Z" fill="#212121"/></svg>`,checkmark:ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15.6326 6.12193C15.8983 6.3668 15.8983 6.76276 15.6326 6.98418L8.75546 13.8613C8.53404 14.127 8.13808 14.127 7.89321 13.8613L4.35119 10.3186C4.10706 10.0971 4.10706 9.70118 4.35119 9.45631C4.59531 9.21404 4.99126 9.21404 5.23535 9.45631L8.33606 12.5588L14.7704 6.12193C15.0152 5.87863 15.4112 5.87863 15.6326 6.12193Z" /></svg>`,close:ne`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none"><path d="M14.7551 13.734C15.0479 14.0269 15.0479 14.502 14.7551 14.7949C14.4622 15.0879 13.987 15.0878 13.6941 14.7949L10.0005 11.0738L6.28054 14.7937C5.98767 15.0866 5.51249 15.0866 5.21959 14.7937C4.92668 14.5008 4.92671 14.0256 5.21959 13.7327L8.94075 10.0141L5.21856 6.26604C4.92568 5.97316 4.92568 5.49798 5.21856 5.20508C5.51143 4.91217 5.98661 4.91221 6.27951 5.20508L10.0005 8.95438L13.7204 5.23446C14.0132 4.94159 14.4884 4.94159 14.7813 5.23446C15.0742 5.52734 15.0742 6.00252 14.7813 6.29542L11.0602 10.0141L14.7551 13.734Z" fill="#212121" /></svg>`,edit:ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10.9355 3.19972C11.7814 2.35335 13.1541 2.35335 13.9999 3.19972L14.3642 3.56456C15.21 4.41103 15.21 5.78338 14.3642 6.62925L8.42804 12.5684C8.16615 12.8272 7.84406 13.0169 7.48886 13.1192L4.47866 13.9802C4.2258 14.0524 3.95489 13.9802 3.76825 13.7694C3.58463 13.6099 3.51239 13.339 3.58463 13.0861L4.44555 10.0759C4.5479 9.72072 4.73754 9.39863 4.99642 9.13674L10.9355 3.19972ZM12.9524 4.22139C12.6965 3.93933 12.239 3.93933 11.956 4.22139L11.08 5.09705L12.4677 6.48476L13.3437 5.5817C13.6267 5.32583 13.6267 4.86828 13.3437 4.58622L12.9524 4.22139ZM5.83626 10.4733L5.33055 12.2342L7.09151 11.7285C7.21192 11.6954 7.31728 11.6322 7.40458 11.5449L11.4473 7.50521L10.0596 6.11751L6.01988 10.1602C5.93259 10.2475 5.86937 10.3529 5.83626 10.4733Z" fill="#212121"/><path d="M3.5 16.7126C3.5 16.3138 3.82335 15.9904 4.22222 15.9904H15.7778C16.1767 15.9904 16.5 16.3138 16.5 16.7126C16.5 17.1115 16.1767 17.4349 15.7778 17.4349H4.22222C3.82335 17.4349 3.5 17.1115 3.5 16.7126Z" fill="#212121"/></svg>`,lock:ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7.91621 7.08223V8.33262H12.0842V7.08223C12.0842 5.93082 11.1516 4.99824 10.0002 4.99824C8.84879 4.99824 7.91621 5.93082 7.91621 7.08223ZM6.24902 8.33262V7.08223C6.24902 5.01127 7.92924 3.33105 10.0002 3.33105C12.0712 3.33105 13.7514 5.01127 13.7514 7.08223V8.33262H14.1682C15.0877 8.33262 15.8354 9.08025 15.8354 9.9998V15.0014C15.8354 15.9209 15.0877 16.6686 14.1682 16.6686H5.83223C4.91267 16.6686 4.16504 15.9209 4.16504 15.0014V9.9998C4.16504 9.08025 4.91267 8.33262 5.83223 8.33262H6.24902Z" fill="#212121" fill-opacity="0.62"/></svg>`};var na=g` :host { display: inline-block; line-height: 0; /* so you don’t get extra space around the icon */ } /* Styling svgs rendered by passing *name* attribute - from our library file */ :host([size='sm']) svg { width: 20px; height: 20px; } :host([size='md']) svg { width: 42px; height: 42px; } :host([size='lg']) svg { width: 56px; height: 56px; } svg { /* --internal used for abstracting away the icon component */ fill: var(--internal-icon-color, currentColor); } /* For slotted icons */ :host([size='sm']) ::slotted(svg) { width: 20px; height: 20px; } :host([size='lg']) ::slotted(svg) { width: 56px; height: 56px; } ::slotted(svg) { /* --internal used for abstracting away the icon component */ fill: var(--internal-icon-color, currentColor); } `;var ce=class extends v{constructor(){super(...arguments);this.color="var(--primer-color-icon-primary)";this.size="lg"}render(){let e=this.name?aa[this.name]:null;return m`<div style="--internal-icon-color: ${this.color}">${e||m`<slot></slot>`}</div>`}};ce.styles=[na],d([p({type:String,reflect:!0})],ce.prototype,"color",2),d([p({type:String,reflect:!0})],ce.prototype,"size",2),d([p({reflect:!0})],ce.prototype,"name",2),ce=d([b("primer-icon")],ce);var il=tl({tagName:"primer-icon",elementClass:ce,react:rl});import{createComponent as nl}from"@lit/react";import sl from"react";var sa=g` :host { display: contents; } input { width: 100%; padding: 0; border: none; height: var(--primer-typography-body-large-line-height); font-size: var(--primer-typography-body-large-size); font-family: var(--primer-typography-body-large-font); color: var(--primer-color-text-primary); background-color: transparent; outline: none; } input::placeholder { color: var(--primer-color-text-placeholder); font-size: var(--primer-typography-body-large-size); font-family: var(--primer-typography-body-large-font); } :host([disabled]) input { color: var(--primer-color-text-disabled); cursor: not-allowed; } :host([disabled]) input::placeholder { color: var(--primer-color-text-disabled); } `;var ol=["text","password","email","number","tel","url","search","date","time","datetime-local","month","week","color"];function al(i){return ol.includes(i)}var D=class extends v{constructor(){super(...arguments);this.value="";this.placeholder="";this.disabled=!1;this.name="";this.type="text";this.required=!1;this.readonly=!1;this.pattern="";this.min="";this.max="";this.step="";this.autocomplete="";this._id="";this.hasFocus=!1;this.hasError=!1;this.handleInput=e=>{e.stopPropagation();let r=e.target;this.value=r.value;let o=new CustomEvent("input",{detail:this.value,bubbles:!0,composed:!0});this.dispatchEvent(o)};this.handleChange=e=>{e.stopPropagation();let r=e.target;this.value=r.value;let o=new CustomEvent("change",{detail:this.value,bubbles:!0,composed:!0});this.dispatchEvent(o)};this.handleFocus=()=>{this.hasFocus=!0,this.dispatchEvent(new FocusEvent("focus",{bubbles:!0,composed:!0}))};this.handleBlur=()=>{this.hasFocus=!1,this.dispatchEvent(new FocusEvent("blur",{bubbles:!0,composed:!0}))};this.handleInvalid=e=>{e.stopPropagation(),this.hasError=!0,this.dispatchEvent(new Event("invalid",{bubbles:!0,composed:!0}))}}get id(){return this._id}set id(e){this._id=e,this.setAttribute("id",e)}focus(e){this.inputElement?.focus(e)}blur(){this.inputElement?.blur()}select(){this.inputElement?.select()}setSelectionRange(e,r,o){this.inputElement?.setSelectionRange(e,r,o)}get validity(){return this.inputElement?.validity||{}}get validationMessage(){return this.inputElement?.validationMessage||""}checkValidity(){return this.inputElement?.checkValidity()||!1}reportValidity(){return this.inputElement?.reportValidity()||!1}render(){let e={input:!0,"input--focused":this.hasFocus,"input--disabled":this.disabled,"input--error":this.hasError,"input--readonly":this.readonly},r=Object.entries(e).filter(([,o])=>o).map(([o])=>o).join(" ");return m`<input part="input" class=${r} .value=${this.value} .type=${this.type} ?disabled=${this.disabled} ?required=${this.required} ?readonly=${this.readonly} placeholder=${this.placeholder} pattern=${this.pattern} minlength=${this.minlength??""} maxlength=${this.maxlength??""} min=${this.min} max=${this.max} step=${this.step} autocomplete=${this.autocomplete} name=${this.name} id=${this.id} @input=${this.handleInput} @change=${this.handleChange} @focus=${this.handleFocus} @blur=${this.handleBlur} @invalid=${this.handleInvalid} />`}addEventListener(e,r,o){super.addEventListener(e,r,o)}removeEventListener(e,r,o){super.removeEventListener(e,r,o)}};D.styles=[sa],d([ke("input")],D.prototype,"inputElement",2),d([p({type:String,reflect:!0})],D.prototype,"value",2),d([p({type:String,reflect:!0})],D.prototype,"placeholder",2),d([p({type:Boolean,reflect:!0})],D.prototype,"disabled",2),d([p({type:String,reflect:!0})],D.prototype,"name",2),d([p({type:String,reflect:!0,converter:{fromAttribute:e=>!e||!al(e)?(e&&e!=="text"&&A.warn(`Invalid input type: ${e}. Defaulting to 'text'.`),"text"):e}})],D.prototype,"type",2),d([p({type:Boolean,reflect:!0})],D.prototype,"required",2),d([p({type:Boolean,reflect:!0})],D.prototype,"readonly",2),d([p({type:String,reflect:!0})],D.prototype,"pattern",2),d([p({type:Number,reflect:!0})],D.prototype,"minlength",2),d([p({type:Number,reflect:!0})],D.prototype,"maxlength",2),d([p({type:String,reflect:!0})],D.prototype,"min",2),d([p({type:String,reflect:!0})],D.prototype,"max",2),d([p({type:String,reflect:!0})],D.prototype,"step",2),d([p({type:String,reflect:!0})],D.prototype,"autocomplete",2),d([P()],D.prototype,"hasFocus",2),d([P()],D.prototype,"hasError",2),D=d([b("primer-input")],D);var ll=nl({tagName:"primer-input",elementClass:D,react:sl});import{createComponent as dl}from"@lit/react";import cl from"react";var la=g` :host { display: contents; } :host(:not([active])) { display: none; } .error { color: var(--primer-color-text-negative); font-size: var(--primer-typography-body-small-size); line-height: var(--primer-typography-body-small-line-height); display: block; font-family: var(--primer-typography-body-small-font); } `;var Ee=class extends v{constructor(){super(...arguments);this.for="";this.active=!0}render(){return m`<span class="error" role="alert" aria-live="polite" id="${this.for||""}" ><slot></slot></span>`}};Ee.styles=[la],d([p({type:String,reflect:!0})],Ee.prototype,"for",2),d([p({type:Boolean,reflect:!0})],Ee.prototype,"active",2),Ee=d([b("primer-input-error")],Ee);var pl=dl({tagName:"primer-input-error",elementClass:Ee,react:cl});import{createComponent as ul}from"@lit/react";import ml from"react";var da=g` :host { display: inline-block; font-weight: var(--primer-typography-body-small-weight); font-size: var(--primer-typography-body-small-size); letter-spacing: var(--primer-typography-body-small-letter-spacing); line-height: var(--primer-typography-body-small-line-height); color: var(--primer-color-text-primary); font-family: var(--primer-typography-body-small-font); } :host([disabled]) { color: var(--primer-color-text-disabled); } `;var Ae=class extends v{constructor(){super(...arguments);this.for="";this.disabled=!1}render(){return m`<label for=${this.for}><slot></slot></label>`}};Ae.styles=[da],d([p({type:String,reflect:!0})],Ae.prototype,"for",2),d([p({type:Boolean,reflect:!0})],Ae.prototype,"disabled",2),Ae=d([b("primer-input-label")],Ae);var hl=ul({tagName:"primer-input-label",elementClass:Ae,react:ml});import{createComponent as fl}from"@lit/react";import yl from"react";var ca=g` * { box-sizing: border-box; } :host { display: block; width: 100%; } .input-slot.focus-within, .input-slot:focus-within { outline: 2px solid var(--primer-color-border-outlined-focus); outline-offset: -2px; } :host([has-error]) .input-slot.focus-within, :host([has-error]) .input-slot:focus-within { outline: 2px solid var(--primer-color-border-outlined-error); background-color: var(--primer-color-background-outlined-error); } :host([has-error]) .input-slot { border-color: var(--primer-color-border-outlined-error); background-color: var(--primer-color-background-outlined-error); } .input-wrapper { display: flex; flex-direction: column; gap: var(--primer-space-xsmall); } .input-slot { padding: var(--primer-space-medium) var(--primer-space-medium); border: 1px solid var(--primer-color-border-outlined-default); border-radius: var(--primer-radius-small); background-color: var(--primer-color-background-outlined-default); height: calc( var(--primer-typography-body-large-line-height) + var(--primer-space-medium) + var(--primer-space-medium) + 2px ); display: flex; cursor: text; /* Indicate text input interactivity */ /* 2px is the border width */ } .input-slot ::slotted(*) { width: 100%; } .input-slot:hover { border-color: var(--primer-color-border-outlined-hover); background-color: var(--primer-color-background-outlined-hover); } .input-slot:active { border-color: var(--primer-color-border-outlined-active); background-color: var(--primer-color-background-outlined-active); } .input-slot:disabled { background-color: var(--primer-color-background-outlined-disabled); border-color: var(--primer-color-border-outlined-disabled); cursor: not-allowed; } `;var pe=class extends v{constructor(){super(...arguments);this.focusWithin=!1;this.hasError=!1;this.handleWrapperClick=e=>{if(e.target!==e.currentTarget)return;let r=this.findSlottedPrimerInput();r?r.focus():this.dispatchEvent(new CustomEvent("wrapper-click",{bubbles:!0,composed:!0}))}}findSlottedPrimerInput(){if(!this.inputSlot)return null;let e=this.inputSlot.assignedElements({flatten:!0}),r=e.find(o=>o.tagName.toLowerCase()==="primer-input");if(r)return r;for(let o of e){let a=o.querySelector("primer-input");if(a)return a}return null}render(){let e={"input-slot":!0,"focus-within":this.focusWithin};return m`<div class="input-wrapper"><slot name="label"></slot><div class="${F(e)}" @click="${this.handleWrapperClick}"><slot name="input"></slot></div><slot name="error"></slot></div>`}};pe.styles=[ca],d([p({type:Boolean})],pe.prototype,"focusWithin",2),d([p({type:Boolean,reflect:!0,attribute:"has-error"})],pe.prototype,"hasError",2),d([ke('slot[name="input"]')],pe.prototype,"inputSlot",2),pe=d([b("primer-input-wrapper")],pe);var gl=fl({tagName:"primer-input-wrapper",elementClass:pe,react:yl});import{createComponent as vl}from"@lit/react";import bl from"react";var pa=g` :host { display: none; } `;var Ne=class extends v{constructor(){super(...arguments);this._id=`d${Math.random().toString(36).substring(7)}`;this._handleSlotChange=e=>{let o=e.target.assignedNodes();if(!o.length)return;let a=this.getContainer();o.forEach(n=>a.appendChild(n))}}get id(){return this._id}getContainer(){let e=document.querySelector(`#${this._id}`);return e||(e=document.createElement("div"),e.id=this._id,document.body.appendChild(e),this._setupEventListeners(e)),e}_setupEventListeners(e){["primer-ach-error","primer-ach-bank-details-collected","primer-ach-mandate-confirmed","primer-ach-mandate-declined"].forEach(r=>{e.addEventListener(r,o=>{o.stopPropagation(),this.dispatchEvent(new CustomEvent(r,{bubbles:!0,composed:!0,detail:o.detail}))})})}disconnectedCallback(){super.disconnectedCallback(),this.getContainer().remove()}render(){return m`<slot @slotchange=${this._handleSlotChange}></slot>`}};Ne.styles=[pa],d([P()],Ne.prototype,"_id",2),Ne=d([b("primer-portal")],Ne);var Cl=vl({tagName:"primer-portal",elementClass:Ne,react:bl});import{createComponent as El}from"@lit/react";import Al from"react";var ua=g` :host { display: inline-flex; align-items: center; justify-content: center; } .spinner-container { display: flex; align-items: center; justify-content: center; width: var(--spinner-size, var(--primer-size-medium)); height: var(--spinner-size, var(--primer-size-medium)); } .spinner-container:not(.compact) { margin: var(--primer-space-small) 0; } .spinner-container.compact { margin: 0; } .spinner { animation: spinner-rotate 1.2s linear infinite; width: 100%; height: 100%; color: var(--spinner-color, var(--primer-color-loader)); } .path { fill: currentColor; transform-origin: center; transition: fill var(--primer-animation-duration, 200ms) var(--primer-animation-easing, ease); } @keyframes spinner-rotate { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } `;var vi={small:16,medium:24,large:32},ue=class extends v{constructor(){super(...arguments);this.color="var(--primer-color-loader)";this.size="medium";this.compact=!1}getSize(){if(this.size in vi)return vi[this.size];let e=parseInt(this.size,10);return isNaN(e)?vi.medium:e}render(){let e=this.getSize(),r=20,o=`0 0 ${r} ${r}`;return this.style.setProperty("--spinner-color",this.color),this.style.setProperty("--spinner-size",`${e}px`),m`<div class="spinner-container ${this.compact?"compact":""}"><svg class="spinner" width="${e}" height="${e}" viewBox="${o}" fill="none" xmlns="http://www.w3.org/2000/svg" role="status" aria-label="Loading" ><path d="M4.27827 10.002C4.27827 6.84166 6.84019 4.27973 10.0005 4.27973C10.7676 4.27973 11.3894 3.6579 11.3894 2.89084C11.3894 2.12378 10.7676 1.50195 10.0005 1.50195C5.30607 1.50195 1.50049 5.30753 1.50049 10.002C1.50049 14.6964 5.30607 18.502 10.0005 18.502C14.6949 18.502 18.5005 14.6964 18.5005 10.002C18.5005 9.23489 17.8787 8.61306 17.1116 8.61306C16.3445 8.61306 15.7227 9.23489 15.7227 10.002C15.7227 13.1622 13.1608 15.7242 10.0005 15.7242C6.84019 15.7242 4.27827 13.1622 4.27827 10.002Z" fill="currentColor" class="path" /></svg></div>`}};ue.styles=[ua],d([p({type:String})],ue.prototype,"color",2),d([p({type:String})],ue.prototype,"size",2),d([p({type:Boolean})],ue.prototype,"compact",2),ue=d([b("primer-spinner")],ue);var _l=El({tagName:"primer-spinner",elementClass:ue,react:Al});import{createComponent as Sl}from"@lit/react";import xl from"react";var ma=g` :host { display: contents; } button { align-items: center; border-radius: var(--primer-radius-medium); border: none; cursor: pointer; display: flex; font-family: var(--primer-typography-title-large-font); font-size: var(--primer-typography-title-large-size); font-weight: var(--primer-typography-title-large-weight); gap: var(--primer-space-small); justify-content: center; letter-spacing: var(--primer-typography-title-large-letter-spacing); line-height: var(--primer-typography-title-large-line-height); outline: none; padding: var(--primer-space-medium) var(--primer-space-medium); position: relative; } .button-content { display: flex; height: 100%; width: 100%; align-items: center; gap: var(--primer-space-small); justify-content: center; transition: opacity var(--primer-animation-duration) var(--primer-animation-easing); } .button-content-base { width: 100%; height: 100%; gap: var(--primer-space-small); transition: opacity var(--primer-animation-duration) var(--primer-animation-easing); } /* Reduce opacity of text during loading for better focus on the spinner */ .button-content.loading { opacity: 0.65; } :host([selectable]) button { justify-content: space-between; } /* Primary variant */ :host([variant='primary']) button { background-color: var(--primer-color-brand); /* This is correct (color-background for color) because Button is kind of a special component */ color: var(--primer-color-background-outlined-default); } :host([variant='primary']:not([disabled]):not([loading])) button:hover { filter: brightness(105%); } :host([variant='primary']:not([disabled]):not([loading])) button:active { filter: brightness(98%); } :host([variant='primary']) button:focus-visible { outline: 2px solid var(--primer-color-brand); outline-offset: 2px; } /* Disabled state for primary button */ :host([variant='primary'][disabled]:not([loading])) button, :host([variant='primary']:not([loading])) button:disabled { color: var(--primer-color-text-disabled); background-color: var(--primer-color-background-outlined-disabled); cursor: not-allowed; } /* Loading state for primary button - OVERRIDES disabled styles with higher specificity */ :host([variant='primary'][loading]) button { background-color: var(--primer-color-brand); opacity: 0.8; color: var(--primer-color-background-outlined-default); cursor: wait; } /* Secondary variant */ :host([variant='secondary']) button { background-color: var(--primer-color-background-outlined-default); color: var(--primer-color-text-primary); border: 1px solid var(--primer-color-border-outlined-default); } :host([variant='secondary']:not([disabled]):not([loading])) button:hover { background-color: var(--primer-color-background-outlined-hover); } :host([variant='secondary']:not([disabled]):not([loading])) button:active { background-color: var(--primer-color-background-outlined-active); } :host([variant='secondary']) button:focus-visible { outline: 2px solid var(--primer-color-border-outlined-focus); outline-offset: 2px; } /* Disabled state for secondary button */ :host([variant='secondary'][disabled]:not([loading])) button, :host([variant='secondary']:not([loading])) button:disabled { background-color: var(--primer-color-background-outlined-disabled); border-color: var(--primer-color-border-outlined-disabled); color: var(--primer-color-text-disabled); cursor: not-allowed; } /* Loading state for secondary button - OVERRIDES disabled styles */ :host([variant='secondary'][loading]) button { background-color: var(--primer-color-gray-100); border-color: var(--primer-color-gray-300); color: var(--primer-color-gray-600); cursor: wait; } /* Tertiary variant */ :host([variant='tertiary']) button { background-color: var(--primer-color-background-transparent-default); border: 1px solid var(--primer-color-border-transparent-default); color: var(--primer-color-text-primary); border-radius: var(--primer-radius-small); padding: var(--primer-space-xxsmall) var(--primer-space-xxsmall); } :host([variant='tertiary']:not([disabled]):not([loading])) button:hover { border-radius: var(--primer-radius-small); background-color: var(--primer-color-background-transparent-hover); border: 1px solid var(--primer-color-border-transparent-hover); color: var(--primer-color-text-primary); } :host([variant='tertiary']:not([disabled]):not([loading])) button:active { background-color: var(--primer-color-background-transparent-active); border-color: var(--primer-color-border-transparent-active); border-radius: var(--primer-radius-small); color: var(--primer-color-text-primary); } :host([variant='tertiary']) button:focus-visible { border-radius: var(--primer-radius-small); background-color: var(--primer-color-background-transparent-focus); outline: 2px solid var(--primer-color-border-transparent-focus); outline-offset: 2px; } /* Disabled state for tertiary button */ :host([variant='tertiary'][disabled]:not([loading])) button, :host([variant='tertiary']:not([loading])) button:disabled { background-color: var(--primer-color-border-transparent-disabled); color: var(--primer-color-text-disabled); cursor: not-allowed; } /* Loading state for tertiary button - OVERRIDES disabled styles */ :host([variant='tertiary'][loading]) button { background-color: var(--primer-color-gray-100); color: var(--primer-color-gray-600); cursor: wait; } /* Checked state styling */ :host([selectionState='checked']) button { border: 2px solid var(--primer-color-brand); background-color: var(--primer-color-gray-100); } /* Loading state - center spinner with content */ :host([loading]) primer-spinner { margin-right: var(--primer-space-xsmall); } /* Special case for tertiary variant loading state spinner size */ :host([variant='tertiary'][loading]) primer-spinner { transform: scale(0.85); } `;var J=class extends v{constructor(){super(...arguments);this.variant="primary";this.disabled=!1;this.loading=!1;this.buttonType="button";this.selectionState="default";this.selectable=!1;this.flex=!0;this.handleClick=()=>{!this.selectable||this.disabled||this.loading||(this.selectionState=this.selectionState==="default"?"checked":"default",this.dispatchEvent(new CustomEvent("selection-change",{bubbles:!0,composed:!0,detail:{state:this.selectionState}})))}}renderCheckmark(){return!this.selectable||this.selectionState!=="checked"||this.loading?f:m`<primer-icon name="checkmark" size="sm" color="var(--primer-color-brand)" ></primer-icon>`}renderSpinner(){if(!this.loading)return f;let e;return this.variant==="primary"?e="var(--primer-color-background-outlined-default)":(this.variant==="secondary"||this.variant==="tertiary")&&(e="var(--primer-color-gray-900)"),m`<primer-spinner size="small" color="${e}" compact ></primer-spinner>`}render(){return m`<button type=${this.buttonType} ?disabled=${this.disabled||this.loading} @click=${this.handleClick} part="button" aria-checked=${this.selectionState==="checked"} aria-busy=${this.loading} >${this.renderSpinner()} ${this.flex?m`<span class="button-content ${this.loading?"loading":""}"><slot></slot></span>`:m`<span class="button-content-base ${this.loading?"loading":""}" ><slot></slot></span>`} ${this.renderCheckmark()}</button>`}};J.styles=[T,ma],d([p({type:String,reflect:!0})],J.prototype,"variant",2),d([p({type:Boolean,reflect:!0})],J.prototype,"disabled",2),d([p({type:Boolean,reflect:!0})],J.prototype,"loading",2),d([p({type:String,attribute:"type"})],J.prototype,"buttonType",2),d([p({type:String,reflect:!0})],J.prototype,"selectionState",2),d([p({type:Boolean,reflect:!0})],J.prototype,"selectable",2),d([p({type:Boolean,reflect:!0})],J.prototype,"flex",2),J=d([b("primer-button")],J);var Pl=Sl({tagName:"primer-button",elementClass:J,react:xl});import{createComponent as wl}from"@lit/react";import Ml from"react";var ha=g` :host { display: flex; flex-direction: column; gap: var(--primer-space-medium); width: 100%; } h2 { margin: 0; padding: 0; border-radius: var(--primer-radius-medium); font-weight: var(--primer-typography-title-xlarge-weight); font-size: var(--primer-typography-title-xlarge-size); letter-spacing: var(--primer-typography-title-xlarge-letter-spacing); line-height: var(--primer-typography-title-xlarge-line-height); font-family: var(--primer-typography-title-xlarge-font); } p { margin: 0; padding: 0; border-radius: var(--primer-radius-medium); font-weight: var(--primer-typography-body-medium-weight); font-size: var(--primer-typography-body-medium-size); letter-spacing: var(--primer-typography-body-medium-letter-spacing); line-height: var(--primer-typography-body-medium-line-height); font-family: var(--primer-typography-body-medium-font); } form { display: flex; flex-direction: column; gap: var(--primer-space-medium); width: 100%; } .form-row { display: flex; gap: var(--primer-space-small); width: 100%; } .form-row primer-input-wrapper { flex: 1; } .error-message { color: var(--primer-color-text-negative); background-color: var(--primer-color-red-100); padding: var(--primer-space-small); border-radius: var(--primer-radius-small); font-weight: var(--primer-typography-body-medium-weight); font-size: var(--primer-typography-body-medium-size); letter-spacing: var(--primer-typography-body-medium-letter-spacing); line-height: var(--primer-typography-body-medium-line-height); font-family: var(--primer-typography-body-medium-font); } .loading-container { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--primer-space-medium); padding: var(--primer-space-large); } .button-group { display: flex; gap: var(--primer-space-small); margin-top: var(--primer-space-medium); } /* Apply responsive styles for small screens */ @media (max-width: 600px) { .form-row { flex-direction: column; gap: var(--primer-space-medium); } .button-group { flex-direction: column; } } `;function fa(){return{firstName:{value:"",error:"",pristine:!0,touched:!1,dirty:!1,valid:!1},lastName:{value:"",error:"",pristine:!0,touched:!1,dirty:!1,valid:!1},emailAddress:{value:"",error:"",pristine:!0,touched:!1,dirty:!1,valid:!1}}}var Mr=class{constructor(t,e){this.formState=fa();this.host=t,this.validate=e,t.addController(this)}get hasError(){return{firstName:this.formState.firstName.dirty&&this.formState.firstName.touched&&!!this.formState.firstName.error,lastName:this.formState.lastName.dirty&&this.formState.lastName.touched&&!!this.formState.lastName.error,emailAddress:this.formState.emailAddress.dirty&&this.formState.emailAddress.touched&&!!this.formState.emailAddress.error}}get formData(){return{firstName:this.formState.firstName.value,lastName:this.formState.lastName.value,emailAddress:this.formState.emailAddress.value}}async setFieldValue(t,e){let r=this.formState[t];r.value=e,r.dirty=!0,r.error="",r.valid=!0;let o=await this.validate(this.formData);this.setValidation(o)}setValidation(t,e=!1){e&&(this.formState.firstName.touched=!0,this.formState.lastName.touched=!0,this.formState.emailAddress.touched=!0,this.formState.firstName.dirty=!0,this.formState.lastName.dirty=!0,this.formState.emailAddress.dirty=!0),t.validationErrors.forEach(r=>{this.isValidFieldName(r.field)&&(this.formState[r.field].error=r.message,this.formState[r.field].valid=r.message==="")}),this.host.dispatchEvent(new CustomEvent("primer-ach-validation",{bubbles:!0,composed:!0,detail:{validation:t}})),this.host.requestUpdate()}setFieldTouched(t){this.formState[t].touched||(this.formState[t].touched=!0,this.host.requestUpdate())}resetForm(){this.formState=fa(),this.host.requestUpdate()}isValidFieldName(t){return!!t&&["firstName","lastName","emailAddress"].includes(t)}hostConnected(){}hostDisconnected(){}};var X=class extends v{constructor(){super(...arguments);this.formController=new Mr(this,e=>this._paymentMethodManagerTask.value.setAndValidate(e));this.paymentManagers=new Map;this.sdkState=void 0;this.clientOptions=void 0;this.screen="form";this.isSubmitting=!1;this._paymentMethodManagerTask=new L(this,{task:([e])=>e!=="STRIPE_ACH"?M:this.paymentManagers.get(e)?.manager,args:()=>[this.paymentMethod?.type]})}_handleInput(e,r){let o=e.target;this.formController.setFieldValue(r,o.value)}_handleBlur(e){this.formController.setFieldTouched(e)}_handleError(e){this.dispatchEvent(new CustomEvent("primer-ach-error",{bubbles:!0,composed:!0,detail:{error:e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error occurred")}}))}async _handleSubmitButtonClick(e){if(!this.isSubmitting){this.isSubmitting=!0;try{let r=await e.start(this.formController.formData);if(!r||r.valid)return await this._handleCollectBankAccountDetails(e);r&&this.formController.setValidation(r,!0)}catch(r){this._handleError(r)}finally{this.isSubmitting=!1}}}async _handleCollectBankAccountDetails(e){try{await e.collectBankAccountDetails(),this.screen="mandate",this.dispatchEvent(new CustomEvent("primer-ach-bank-details-collected",{bubbles:!0,composed:!0}))}catch(r){this._handleError(r)}}async _handleConfirmMandate(){if(this._paymentMethodManagerTask.value){this.isSubmitting=!0;try{await this._paymentMethodManagerTask.value.confirmMandate(),this.dispatchEvent(new CustomEvent("primer-ach-mandate-confirmed",{bubbles:!0,composed:!0}))}catch(e){this._handleError(e)}finally{this.isSubmitting=!1}}}async _handleDeclineMandate(){if(this._paymentMethodManagerTask.value){this.isSubmitting=!0;try{await this._paymentMethodManagerTask.value.declineMandate(),this.dispatchEvent(new CustomEvent("primer-ach-mandate-declined",{bubbles:!0,composed:!0}))}catch(e){this._handleError(e)}finally{this.isSubmitting=!1}}}renderForm(e){return m`<h2>${x("payWithAch",{id:"payWithAch"})}</h2><p>${x("stripe_ach_user_details_collection_subtitle_label",{id:"stripe_ach_user_details_collection_subtitle_label"})}</p><form @submit=${r=>r.preventDefault()}><div class="form-row"><primer-input-wrapper .hasError=${this.formController.hasError.firstName} ><primer-input-label slot="label">${x("stripe_ach_user_details_collection_first_name_label",{id:"stripe_ach_user_details_collection_first_name_label"})}</primer-input-label><primer-input slot="input" .value=${this.formController.formState.firstName.value} @input=${r=>this._handleInput(r,"firstName")} @blur=${()=>this._handleBlur("firstName")} ?disabled=${this.isSubmitting} ></primer-input><primer-input-error slot="error">${this.formController.hasError.firstName?this.formController.formState.firstName.error:f}</primer-input-error></primer-input-wrapper><primer-input-wrapper .hasError=${this.formController.hasError.lastName} ><primer-input-label slot="label">${x("stripe_ach_user_details_collection_last_name_label",{id:"stripe_ach_user_details_collection_last_name_label"})}</primer-input-label><primer-input slot="input" .value=${this.formController.formState.lastName.value} @input=${r=>this._handleInput(r,"lastName")} @blur=${()=>this._handleBlur("lastName")} ?disabled=${this.isSubmitting} ></primer-input><primer-input-error slot="error">${this.formController.hasError.lastName?this.formController.formState.lastName.error:f}</primer-input-error></primer-input-wrapper></div><primer-input-wrapper .hasError=${this.formController.hasError.emailAddress} ><primer-input-label slot="label">${x("stripe_ach_user_details_collection_email_address_label",{id:"stripe_ach_user_details_collection_email_address_label"})}</primer-input-label><primer-input slot="input" type="email" .value=${this.formController.formState.emailAddress.value} @input=${r=>this._handleInput(r,"emailAddress")} @blur=${()=>this._handleBlur("emailAddress")} ?disabled=${this.isSubmitting} ></primer-input><primer-input-error slot="error">${this.formController.hasError.emailAddress?this.formController.formState.emailAddress.error:f}</primer-input-error></primer-input-wrapper><p>${x("stripe_ach_user_details_collection_data_usage_label",{id:"stripe_ach_user_details_collection_data_usage_label"})}</p><primer-button buttonType="submit" variant="primary" @click=${()=>this._handleSubmitButtonClick(e)} ?disabled=${this.isSubmitting} ?loading=${this.isSubmitting} >${x("stripe_ach_user_details_collection_continue_button",{id:"stripe_ach_user_details_collection_continue_button"})}</primer-button></form>`}renderMandate(){return m`<h2>${x("payWithAch",{id:"payWithAch"})}</h2><p>${this.clientOptions?.stripe?.mandateData.fullMandateText??x("stripe_ach_mandate_template_web",{id:"stripe_ach_mandate_template_web"}).replace(/\{merchantName\}/g,this.clientOptions?.stripe?.mandateData.merchantName??"Merchant")}</p><div class="button-group"><primer-button variant="primary" @click=${this._handleConfirmMandate.bind(this)} ?disabled=${this.isSubmitting} ?loading=${this.isSubmitting} >${x("stripe_ach_mandate_accept_button",{id:"stripe_ach_mandate_accept_button"})}</primer-button><primer-button variant="tertiary" @click=${this._handleDeclineMandate.bind(this)} ?disabled=${this.isSubmitting} >${x("stripe_ach_mandate_cancel_payment_button",{id:"stripe_ach_mandate_cancel_payment_button"})}</primer-button></div>`}render(){return this._paymentMethodManagerTask.render({complete:e=>e?this.screen==="form"?this.renderForm(e):this.renderMandate():f})}};X.styles=[T,ha],d([p({type:Object})],X.prototype,"paymentMethod",2),d([C({context:G,subscribe:!0}),p({attribute:!1})],X.prototype,"paymentManagers",2),d([C({context:V,subscribe:!0}),p({attribute:!1})],X.prototype,"sdkState",2),d([C({context:Pe,subscribe:!0}),p({attribute:!1})],X.prototype,"clientOptions",2),d([P()],X.prototype,"screen",2),d([P()],X.prototype,"isSubmitting",2),X=d([b("primer-ach-payment"),R()],X);var Tl=wl({tagName:"primer-ach-payment",elementClass:X,react:Ml});import{createComponent as kl}from"@lit/react";import Il from"react";var mt="card-form-context";var ya=g` :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 ee=class extends v{constructor(){super(...arguments);this.hideLabels=!1;this.disabled=!1;this.hasAssignedContent=!1;this.selectedCardNetwork=null;this.paymentManagers=new Map;this.cardFormProvider=new U(this,{context:mt,initialValue:null});this.eventsController=new tt(this);this.setupCardFormTask=new L(this,{task:([e])=>{if(!e?.manager)return M;let{manager:r}=e,o=r.createHostedInputs(),{cardNumberInput:a,expiryInput:n,cvvInput:s}=o;return this.cardFormProvider.setValue({cardHolderNameInput:o.cardHolderNameInput,cardNumberInput:a,expiryInput:n,cvvInput:s,setCardholderName:l=>r.setCardholderName(l),setCardNetwork:l=>{this.selectedCardNetwork=l},validate:()=>r.validate(),submit:l=>r.submit(l),hideLabels:this.hideLabels,disabled:this.disabled}),!0},args:()=>[this.paymentManagers.get("PAYMENT_CARD")]});this.handleSlotButtonClick=e=>{let o=e.target.closest("button, primer-button");if(!o)return;let a=o;this.isSubmitButton(a)&&(e.preventDefault(),this.submitCardPayment())};this.handleDirectSubmit=e=>{e.stopPropagation(),this.submitCardPayment()};this.onSlotChange=e=>{let o=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=o.length>0};this.handleFormSubmit=e=>{e.preventDefault(),e.stopPropagation(),this.submitCardPayment()}}updated(e){super.updated(e),(e.has("hideLabels")||e.has("disabled"))&&this.cardFormProvider.value&&this.cardFormProvider.setValue({...this.cardFormProvider.value,hideLabels:this.hideLabels,disabled:this.disabled})}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.handleSlotButtonClick),this.addEventListener("primer:card-submit",this.handleDirectSubmit)}disconnectedCallback(){this.removeEventListener("click",this.handleSlotButtonClick),this.removeEventListener("primer:card-submit",this.handleDirectSubmit),super.disconnectedCallback()}isSubmitButton(e){let r=e.tagName.toLowerCase(),o=r==="button",a=r==="primer-button";return o&&(e.getAttribute("type")==="submit"||e.hasAttribute("data-submit"))||a&&(e.getAttribute("type")==="submit"||e.hasAttribute("data-submit"))}async submitCardPayment(){let e=this.cardFormProvider.value;if(!e||this.disabled)return;let r=await e.validate?.();if(r?.valid){let o=await e.submit?.(this.selectedCardNetwork?{cardNetwork:this.selectedCardNetwork}:void 0);this.eventsController.dispatchFormSubmitSuccess(o)}else{let o=r?.validationErrors;this.cardFormProvider.setValue({...e,errors:o}),this.eventsController.dispatchFormSubmitErrors(o)}}render(){return this.setupCardFormTask.status===Me.ERROR||this.setupCardFormTask.status===Me.INITIAL?f:m`<form @submit=${this.handleFormSubmit}><slot name="card-form-content" @slotchange=${this.onSlotChange}></slot>${this.setupCardFormTask.render({complete:()=>O(this.hasAssignedContent,()=>f,()=>m`<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><primer-input-card-holder-name></primer-input-card-holder-name></div><primer-card-form-submit></primer-card-form-submit>`)})}</form>`}};ee.styles=[T,ya],d([p({type:Boolean,attribute:"hide-labels",reflect:!0})],ee.prototype,"hideLabels",2),d([p({type:Boolean,attribute:"disabled"})],ee.prototype,"disabled",2),d([P()],ee.prototype,"hasAssignedContent",2),d([P()],ee.prototype,"selectedCardNetwork",2),d([C({context:G,subscribe:!0}),p({type:Object})],ee.prototype,"paymentManagers",2),ee=d([b("primer-card-form"),R()],ee);var Nl=kl({tagName:"primer-card-form",elementClass:ee,react:Il});import{createComponent as Ll}from"@lit/react";import Ol from"react";var ga=g` :host { display: contents; } `;var Z=class extends v{constructor(){super(...arguments);this._userAssignedProps=new Set;this._internalButtonText="";this.headlessInstance=null;this.clientOptions=null;this.sdkState=null;this.cardFormContext=null;this.variant="primary";this.disabled=!1;this.handleClick=e=>{if(e.preventDefault(),this.disabled)return;let r=new CustomEvent("primer:card-submit",{bubbles:!0,composed:!0,detail:{source:"primer-card-form-submit"}});this.dispatchEvent(r)}}get buttonText(){return this._userAssignedProps.has("buttonText")?this._internalButtonText:x("pay",{id:"pay"})}set buttonText(e){let r=this.buttonText;e!==""?(this._userAssignedProps.add("buttonText"),this._internalButtonText=e):(this._userAssignedProps.delete("buttonText"),this._internalButtonText=""),this.requestUpdate("buttonText",r)}render(){let e=this.clientOptions?.submitButton?.amountVisible?this.headlessInstance?.getUIOrderAmount():null,r=e?` ${e}`:f,o=this.disabled||this.cardFormContext?.disabled||!1;return m`<primer-button type="submit" variant=${this.variant} ?disabled=${o} @click=${this.handleClick} .loading=${!!this.sdkState?.isProcessing} data-submit >${this.buttonText}${r}</primer-button>`}};Z.styles=[T,ga],d([p({type:String})],Z.prototype,"buttonText",1),d([C({context:K,subscribe:!0}),p({type:Object})],Z.prototype,"headlessInstance",2),d([C({context:Pe,subscribe:!0}),p({type:Object})],Z.prototype,"clientOptions",2),d([C({context:V,subscribe:!0}),p()],Z.prototype,"sdkState",2),d([C({context:mt,subscribe:!0}),p()],Z.prototype,"cardFormContext",2),d([p({type:String})],Z.prototype,"variant",2),d([p({type:Boolean})],Z.prototype,"disabled",2),Z=d([b("primer-card-form-submit"),R()],Z);var Rl=Ll({tagName:"primer-card-form-submit",elementClass:Z,react:Ol});import{createComponent as Vl}from"@lit/react";import Ul from"react";var{I:sv}=lo;var va=i=>i.strings===void 0;var Rt=(i,t)=>{let e=i._$AN;if(e===void 0)return!1;for(let r of e)r._$AO?.(t,!1),Rt(r,t);return!0},Tr=i=>{let t,e;do{if((t=i._$AM)===void 0)break;e=t._$AN,e.delete(i),i=t}while(e?.size===0)},ba=i=>{for(let t;t=i._$AM;i=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(i))break;e.add(i),Yl(t)}};function Dl(i){this._$AN!==void 0?(Tr(this),this._$AM=i,ba(this)):this._$AM=i}function $l(i,t=!1,e=0){let r=this._$AH,o=this._$AN;if(o!==void 0&&o.size!==0)if(t)if(Array.isArray(r))for(let a=e;a<r.length;a++)Rt(r[a],!1),Tr(r[a]);else r!=null&&(Rt(r,!1),Tr(r));else Rt(this,i)}var Yl=i=>{i.type==Ie.CHILD&&(i._$AP??(i._$AP=$l),i._$AQ??(i._$AQ=Dl))},Le=class extends ut{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,r){super._$AT(t,e,r),ba(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(Rt(this,t),Tr(this))}setValue(t){if(va(this._$Ct))this._$Ct._$AI(t,this);else{let e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};var Ei=()=>new Ci,Ci=class{},bi=new WeakMap,kr=Ce(class extends Le{render(i){return f}update(i,[t]){let e=t!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=t,this.ht=i.options?.host,this.rt(this.ct=i.element)),f}rt(i){if(this.isConnected||(i=void 0),typeof this.G=="function"){let t=this.ht??globalThis,e=bi.get(t);e===void 0&&(e=new WeakMap,bi.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,i),i!==void 0&&this.G.call(this.ht,i)}else this.G.value=i}get lt(){return typeof this.G=="function"?bi.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Ca=g` :host { display: flex; align-items: center; position: relative; } .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-icon { width: var(--primer-size-large); height: var( --primer-size-medium ); /* Added explicit height to maintain aspect ratio */ object-fit: contain; } .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 Q=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=Ei();this.dropdownRef=Ei();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}getSelectableNetworks(){return this.cardNetworks?.selectableCardNetworks||[]}getDetectedNetwork(){return this.selectedCardNetwork??(this.cardNetworks?.detectedCardNetwork||null)}getSelectedNetworkIndex(){let e=this.getDetectedNetwork();if(!e)return 0;let r=this.getSelectableNetworks().findIndex(o=>o.network===e.network);return r>=0?r:0}selectNetwork(e,r){e.stopPropagation(),this.selectedCardNetwork=r,this.isDropdownOpen=!1,this.buttonRef.value?.focus(),this.cardNetworks&&this.dispatchEvent(new CustomEvent("network-selected",{detail:{network:r.network},bubbles:!0,composed:!0}))}focusNetworkOption(){requestAnimationFrame(()=>{this.networkOptionRefs[this.focusedNetworkIndex]&&this.networkOptionRefs[this.focusedNetworkIndex].focus()})}setNetworkOptionRef(e,r){this.networkOptionRefs[r]=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 m`<primer-spinner size="small" compact></primer-spinner>`;let e=this.getSelectableNetworks();if(!this.getDetectedNetwork()&&e.length===0)return m`<primer-icon name="payment-card" size="sm"></primer-icon>`;let r=this.getDetectedNetwork()||(e.length>0?e[0]:null);if(!r)return m`<primer-icon name="payment-card" size="sm"></primer-icon>`;let o=e.length>1;return m`<button ${kr(this.buttonRef)} class="network-selector" @click=${this.toggleDropdown} @keydown=${a=>{(a.key===" "||a.key==="Enter")&&o&&(a.preventDefault(),this.isDropdownOpen=!this.isDropdownOpen,this.isDropdownOpen&&(this.focusedNetworkIndex=this.getSelectedNetworkIndex()))}} aria-label=${o?`Selected card network: ${r.displayName}. Click to change.`:`Card network: ${r.displayName}`} aria-expanded=${o?this.isDropdownOpen:f} aria-haspopup=${o?"true":f} aria-controls=${o?"network-dropdown":f} ><img class="network-icon" src=${this.getNetworkIconUrl(r)} alt=${r.displayName} />${O(o,()=>m`<primer-icon class="caret ${this.isDropdownOpen?"open":""}" size="sm" name="chevron-down" ></primer-icon>`,()=>f)}</button>${O(this.isDropdownOpen,()=>m`<div ${kr(this.dropdownRef)} id="network-dropdown" class="dropdown open" role="listbox" aria-label="Select card network" >${e.map((a,n)=>m`<div ${kr(s=>this.setNetworkOptionRef(s,n))} class="network-option ${this.isKeyboardNavigation&&n===this.focusedNetworkIndex?"focused":""}" @click=${s=>this.selectNetwork(s,a)} @keydown=${s=>{(s.key==="Enter"||s.key===" ")&&this.selectNetwork(s,a)}} role="option" aria-selected=${a.network===r.network} tabindex="${n===this.focusedNetworkIndex?"0":"-1"}" ><img class="network-option-icon" src=${this.getNetworkIconUrl(a)} alt=${a.displayName} /><span class="network-name">${a.displayName}</span>${O(a.network===r.network,()=>m`<primer-icon class="checkmark" name="checkmark" size="sm" ></primer-icon>`,()=>f)}</div>`)}</div>`,()=>f)} `}};Q.styles=[T,Ca],d([C({context:Vt,subscribe:!0})],Q.prototype,"cardNetworks",2),d([C({context:K,subscribe:!0})],Q.prototype,"headlessUtils",2),d([P()],Q.prototype,"selectedCardNetwork",2),d([P()],Q.prototype,"isDropdownOpen",2),d([P()],Q.prototype,"focusedNetworkIndex",2),d([P()],Q.prototype,"isKeyboardNavigation",2),Q=d([b("primer-card-network-selector")],Q);var Hl=Vl({tagName:"primer-card-network-selector",elementClass:Q,react:Ul});import{createComponent as Bl}from"@lit/react";import zl from"react";function Ea(i,t){if(i.style.cssText="width: 100%; flex:1; padding: 0; border: none; height: var(--primer-typography-body-large-line-height); font-size: var(--primer-typography-body-large-size); font-family: var(--primer-typography-body-large-font); color: var(--primer-color-text-primary); background-color: transparent; outline: none;",i.setAttribute("data-custom-input",""),!t.shadowRoot?.querySelector("style[data-custom-input-style]")){let e=document.createElement("style");e.setAttribute("data-custom-input-style",""),e.textContent=`
113
113
  input[data-custom-input]::placeholder {
114
114
  color: var(--primer-color-text-placeholder);
115
115
  font-size: var(--primer-typography-body-large-size);