@primer-io/primer-js 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/custom-elements.json +592 -263
- package/dist/jsx/index.d.ts +4 -0
- package/dist/primer-loader.d.ts +588 -36
- package/dist/primer-loader.js +10 -10
- package/dist/web-types.json +6 -1
- package/package.json +2 -1
package/dist/primer-loader.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import{a as jo,b as l,c as T}from"./chunks/chunk.DV3REKZU.js";var Ar=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 Ot=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})}handleExternalCardSubmit(t){this.dispatchCardSubmit(t.source)}};var nt=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 Dt=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 nt(this.context,this.host,this.t,this.subscribe))}};var xr=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 Li=class extends Event{constructor(t,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e}},z=class extends xr{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 nt(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 Li(this.context,this.host))}};function E({context:i,subscribe:t}){return(e,r)=>{typeof r=="object"?r.addInitializer((function(){new Dt(this,{context:i,callback:o=>{e.set.call(this,o)},subscribe:t})})):e.constructor.addInitializer((o=>{new Dt(o,{context:i,callback:a=>{o[r]=a},subscribe:t})}))}}var st=Symbol("analytics-context");var $t=Symbol("events-context");var Sr="cardNetworksContext";var me="clientOptionsContext";var Vt="computedStylesContext";var F="headlessInstanceContext";var Pr="configuration";var _r="klarnaCategoriesContext";var K="managerContext";var lt="paymentMethodsContext";var j="sdkStateContext";var ue="vaultManagerContext";var Oe="vaultManagerCvvContext";var Js={LOCAL:"https://analytics.dev.data.primer.io/v1/sdk-logs",DEV:"https://analytics.dev.data.primer.io/v1/sdk-logs",STAGING:"https://analytics.staging.data.primer.io/v1/sdk-logs",SANDBOX:"https://analytics.sandbox.data.primer.io/v1/sdk-logs",PRODUCTION:"https://analytics.production.data.primer.io/v1/sdk-logs"};function Go(i,t){let r={message:i instanceof Error?i.message:typeof i=="string"?i:JSON.stringify(i)};i instanceof Error&&i.stack&&(r.stack=i.stack),t?.clientSessionId&&(r.clientSessionId=t.clientSessionId),t?.metadata&&Object.assign(r,t.metadata),t.status&&Object.assign(r,{status:t.status});let o={message:JSON.stringify(r),hostname:typeof window<"u"?window.location.hostname:"unknown",service:"web-sdk",ddsource:"lambda",ddtags:`env:${t?.environment},version:${t?.sdkVersion}`};Zs(o,t)}function Zs(i,{environment:t,clientSessionToken:e}){if(t==="LOCAL"){A.debug("\u{1F436}\u{1F436}\u{1F436} [Datadog Log] \u{1F436}\u{1F436}\u{1F436}",i);return}let r=Js[t||"LOCAL"];if(!r){A.warn("No logging endpoint configured for current environment");return}fetch(r,{method:"POST",headers:{"Content-Type":"application/json",...e&&{Authorization:`Bearer ${e}`}},body:JSON.stringify(i)}).catch(o=>{A.error("Failed to send log event:",o)})}var $=class ${static log(t,...e){$.enabled}static info(t,...e){$.enabled}static warn(t,...e){$.enabled}static error(t,...e){$.enabled&&e.forEach(r=>{r instanceof Error&&r.toJSON})}static errorWithDatadog(t,e){let{error:r,status:o="error"}=e||{};if($.enabled){r instanceof Error&&r.toJSON;try{let a=r||t,n={environment:$.environment,sdkVersion:$.sdkVersion,clientSessionToken:$.clientSessionToken,clientSessionId:$.clientSessionId,status:o,metadata:{sdkOptions:$.sdkOptions,clientToken:$.clientToken}};Go(a,n)}catch{$.enabled}}}static debug(t,...e){$.enabled}static table(t,e){$.enabled}static time(t){$.enabled}static timeEnd(t){$.enabled}static setEnvironment(t){$.environment=t}static setSdkVersion(t){$.sdkVersion=t}static setClientSessionToken(t){$.clientSessionToken=t}static setClientSessionId(t){$.clientSessionId=t}static setSdkOptions(t){$.sdkOptions=t}static setClientToken(t){$.clientToken=t}};T($,"enabled",!0),T($,"environment"),T($,"sdkVersion"),T($,"clientSessionToken"),T($,"clientSessionId"),T($,"sdkOptions"),T($,"clientToken"),T($,"defaultFont","font-family: Consolas, monospace; font-size: 12px;"),T($,"brandTag","[PRIMER]"),T($,"brandStyle",`background: #24292e; color: #ffffff; padding: 2px 6px; border-radius: 3px; font-weight: bold; margin-right: 4px; ${$.defaultFont}`),T($,"styles",{log:`color: #4CAF50; ${$.defaultFont}`,info:`color: #2196F3; ${$.defaultFont}`,warn:`color: #FF9800; ${$.defaultFont}`,error:`color: #F44336; ${$.defaultFont}`,debug:`color: #9C27B0; ${$.defaultFont}`});var A=$;function Xs(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 qt(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 Et=class{constructor(t,e,r,o,a=()=>{this.host.requestUpdate()}){this.host=t;this.stateHandler=a;this.host.addController(this),this._dispatcher=Xs(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(){}},wr=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 Mr={isSuccessful:!1,isProcessing:!1,isLoading:!1,error:null,failure:null},Qs={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:()=>Mr,RESET_ERROR:i=>({...i,error:null,failure:null})},el=qt(Qs),Tr=class extends Et{constructor(t){super(t,Mr,el,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 kr=class{constructor(t){this.sdkStateProvider=null;this.paymentMethodsProvider=null;this.paymentManagerProvider=null;this.cardNetworksContext=null;this.vaultManagerCvvProvider=null;this.clientOptionsContext=null;this.headlessUtilsProvider=null;this.configurationProvider=null;this.klarnaCategoriesProvider=null;this.computedStylesProvider=null;this.analyticsProvider=null;this.eventsProvider=null;(this.host=t).addController(this),this.sdkStateProvider=new z(t,{context:j,initialValue:Mr}),this.paymentMethodsProvider=new z(t,{context:lt,initialValue:null}),this.paymentManagerProvider=new z(t,{context:K,initialValue:new Map}),this.cardNetworksContext=new z(t,{context:Sr,initialValue:null}),this.vaultManagerProvider=new z(t,{context:ue,initialValue:null}),this.vaultManagerCvvProvider=new z(t,{context:Oe,initialValue:null}),this.clientOptionsContext=new z(t,{context:me,initialValue:null}),this.klarnaCategoriesProvider=new z(t,{context:_r,initialValue:{categories:[],isLoading:!0}}),this.headlessUtilsProvider=new z(t,{context:F,initialValue:null}),this.configurationProvider=new z(t,{context:Pr,initialValue:null}),this.computedStylesProvider=new z(t,{context:Vt,initialValue:null}),this.analyticsProvider=new z(t,{context:st,initialValue:null}),this.eventsProvider=new z(t,{context:$t,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)}setConfiguration(t){this.configurationProvider?.setValue(t)}setAnalyticsUtils(t){this.analyticsProvider?.setValue(t)}getAnalyticsUtils(){return this.analyticsProvider?.value}setComputedStyles(t){this.computedStylesProvider?.setValue(t)}setVaultManagerCvv(t){this.vaultManagerCvvProvider?.setValue(t)}setEventsController(t){this.eventsProvider?.setValue(t)}};var At=class At{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=At.cssVarCache.get(t);return e||(e=`--${t.replace(/([A-Z])/g,(r,o)=>`-${o.toLowerCase()}`)}`,At.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 At.cssVarCache.keys()){let e=At.cssVarCache.get(t);e&&this.host.style.removeProperty(e)}}hostDisconnected(){}};At.cssVarCache=new Map;var Ir=At;var Nr=globalThis,Rr=Nr.ShadowRoot&&(Nr.ShadyCSS===void 0||Nr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,qo=Symbol(),Wo=new WeakMap,Lr=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==qo)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(Rr&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=Wo.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&Wo.set(e,t))}return t}toString(){return this.cssText}},Jo=i=>new Lr(typeof i=="string"?i:i+"",void 0,qo);var Ri=(i,t)=>{if(Rr)i.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of t){let r=document.createElement("style"),o=Nr.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=e.cssText,i.appendChild(r)}},Or=Rr?i=>i:i=>i instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return Jo(e)})(i):i;var{is:tl,defineProperty:rl,getOwnPropertyDescriptor:il,getOwnPropertyNames:ol,getOwnPropertySymbols:al,getPrototypeOf:nl}=Object,dt=globalThis,Zo=dt.trustedTypes,sl=Zo?Zo.emptyScript:"",ll=dt.reactiveElementPolyfillSupport,Jt=(i,t)=>i,Oi={toAttribute(i,t){switch(t){case Boolean:i=i?sl: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}},Dr=(i,t)=>!tl(i,t),Xo={attribute:!0,type:String,converter:Oi,reflect:!1,hasChanged:Dr};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),dt.litPropertyMetadata??(dt.litPropertyMetadata=new WeakMap);var xt=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=Xo){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&&rl(this.prototype,t,o)}}static getPropertyDescriptor(t,e,r){let{get:o,set:a}=il(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)??Xo}static _$Ei(){if(this.hasOwnProperty(Jt("elementProperties")))return;let t=nl(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Jt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Jt("properties"))){let e=this.properties,r=[...ol(e),...al(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(Or(o))}else t!==void 0&&e.push(Or(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 Ri(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:Oi).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:Oi;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??Dr)(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){}};xt.elementStyles=[],xt.shadowRootOptions={mode:"open"},xt[Jt("elementProperties")]=new Map,xt[Jt("finalized")]=new Map,ll?.({ReactiveElement:xt}),(dt.reactiveElementVersions??(dt.reactiveElementVersions=[])).push("2.0.4");var ct={INITIAL:0,PENDING:1,COMPLETE:2,ERROR:3},R=Symbol(),D=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??Qo,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===R)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)}}},Qo=(i,t)=>i===t||i.length===t.length&&i.every(((e,r)=>!Dr(e,t[r])));var dl={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:()=>ea},cl={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:()=>ta},pl=qt(dl),ml=qt(cl),ea={enabled:!1,isLoading:!1,isUpdating:!1,cvvRecapture:!1,showEmptyState:!0,vaultedPaymentMethods:[],createCvvInput:null,deleteVaultedPaymentMethod:()=>Promise.resolve(),startVaultedPaymentFlow:()=>Promise.resolve()},ta={cvvInput:null,formIsDirty:!1,setCvvInput:()=>{},selectedVaultedPaymentMethod:null,setSelectedVaultedPaymentMethod:()=>{}},Di=class extends Et{constructor(t,e){super(t,ea,pl,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"})}},$i=class extends Et{constructor(t,e){super(t,ta,ml,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"})}},Zt=class extends wr{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.errorWithDatadog("VaultManagerController: Error starting vaulted payment flow",{error: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 Di(e,{deleteVaultedPaymentMethod:this.deleteVaultedPaymentMethod.bind(this),startVaultedPaymentFlow:this.startVaultedPaymentFlow.bind(this),createCvvInput:this.createCvvInput}),this.itemController=new $i(e,{setCvvInput:this.setCvvInput.bind(this),setSelectedVaultedPaymentMethod:this.setSelectedVaultedPaymentMethod.bind(this)}),this.addController(this.coreController),this.addController(this.itemController),new D(this.host,{task:async([r,o])=>{if(!r||!o?.vaultEnabled)return this.coreController.disable(),R;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.errorWithDatadog("VaultManagerController: Failed to initialize vault",{error: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 ra=()=>ia.randomUUID?.()||ul(),ul=()=>("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,i=>(i^hl()>>i/4).toString(16)),hl=()=>(ia.getRandomValues?.(new Uint8Array(1))[0]??Math.random()*16)&15,ia=typeof crypto<"u"?crypto:{};var fl={LOCAL:"",DEV:"https://analytics.dev.data.primer.io/v1/sdk-analytic-events",STAGING:"https://analytics.staging.data.primer.io/v1/sdk-analytic-events",SANDBOX:"https://analytics.sandbox.data.primer.io/v1/sdk-analytic-events",PRODUCTION:"https://analytics.production.data.primer.io/v1/sdk-analytic-events"},Vi=class{constructor(){T(this,"sessionConfig",null)}initialize(t){this.sessionConfig=t}clear(){this.sessionConfig=null}getSessionConfig(){return this.sessionConfig}sendEvent(t){if(!this.sessionConfig){A.error("Analytics manager not initialized. Call initializeAnalytics() first.");return}let e={id:ra(),timestamp:Math.floor(Date.now()/1e3),sdkType:"WEB",eventName:t.eventName,checkoutSessionId:this.sessionConfig.checkoutSessionId,clientSessionId:this.sessionConfig.clientSessionId,primerAccountId:this.sessionConfig.primerAccountId,sdkVersion:this.sessionConfig.sdkVersion,userAgent:typeof navigator<"u"?navigator.userAgent:"",eventType:t.eventType,userLocale:t.userLocale,paymentMethod:t.paymentMethod,paymentId:t.paymentId,redirectDestinationUrl:t.redirectDestinationUrl,threedsProvider:t.threedsProvider,threedsResponse:t.threedsResponse};gl(e,this.sessionConfig)}},Ui=new Vi;function oa(i){Ui.initialize(i)}function q(i){Ui.sendEvent(i)}function aa(){Ui.clear()}async function gl(i,{environment:t,clientSessionToken:e}){if(t==="LOCAL"){A.debug(`Analytics event ${i.eventName}:`,i);return}let r=fl[t];return fetch(r,{method:"POST",headers:{"Content-Type":"application/json",...e&&{Authorization:`Bearer ${e}`}},body:JSON.stringify(i)}).catch(o=>{A.error("Failed to send analytics event:",o)})}var Xt="lit-localize-status";var na=i=>typeof i!="string"&&"strTag"in i,$r=(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 Qt=(i=>na(i)?$r(i.strings,i.values):i);var C=Qt,sa=!1;function Bi(i){if(sa)throw new Error("lit-localize can only be configured once");C=i,sa=!0}var Yi=class{constructor(t){this.__litLocalizeEventHandler=e=>{e.detail.status==="ready"&&this.host.requestUpdate()},this.host=t}hostConnected(){window.addEventListener(Xt,this.__litLocalizeEventHandler)}hostDisconnected(){window.removeEventListener(Xt,this.__litLocalizeEventHandler)}},yl=i=>i.addController(new Yi(i)),la=yl;var O=()=>(i,t)=>(i.addInitializer(la),i);var er=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 We=[];for(let i=0;i<256;i++)We[i]=(i>>4&15).toString(16)+(i&15).toString(16);function da(i){let t=0,e=8997,r=0,o=33826,a=0,n=40164,s=0,d=52210;for(let c=0;c<i.length;c++)e^=i.charCodeAt(c),t=e*435,r=o*435,a=n*435,s=d*435,a+=e<<8,s+=o<<8,r+=t>>>16,e=t&65535,a+=r>>>16,o=r&65535,d=s+(a>>>16)&65535,n=a&65535;return We[d>>8]+We[d&255]+We[n>>8]+We[n&255]+We[o>>8]+We[o&255]+We[e>>8]+We[e&255]}var vl="",bl="h",Cl="s";function ca(i,t){return(t?bl:Cl)+da(typeof i=="string"?i:i.join(vl))}var pa=new WeakMap,ma=new Map;function ua(i,t,e){if(i){let r=e?.id??El(t),o=i[r];if(o){if(typeof o=="string")return o;if("strTag"in o)return $r(o.strings,t.values,o.values);{let a=pa.get(o);return a===void 0&&(a=o.values,pa.set(o,a)),{...o,values:a.map(n=>t.values[n])}}}}return Qt(t)}function El(i){let t=typeof i=="string"?i:i.strings,e=ma.get(t);return e===void 0&&(e=ca(t,typeof i!="string"&&!("strTag"in i)),ma.set(t,e)),e}function Hi(i){window.dispatchEvent(new CustomEvent(Xt,{detail:i}))}var Ur="",Fi,ha,Br,zi,fa,St=new er;St.resolve();var Vr=0,ga=i=>(Bi(((t,e)=>ua(fa,t,e))),Ur=ha=i.sourceLocale,Br=new Set(i.targetLocales),Br.add(i.sourceLocale),zi=i.loadLocale,{getLocale:Al,setLocale:xl}),Al=()=>Ur,xl=i=>{if(i===(Fi??Ur))return St.promise;if(!Br||!zi)throw new Error("Internal error");if(!Br.has(i))throw new Error("Invalid locale code");Vr++;let t=Vr;return Fi=i,St.settled&&(St=new er),Hi({status:"loading",loadingLocale:i}),(i===ha?Promise.resolve({templates:void 0}):zi(i)).then(r=>{Vr===t&&(Ur=i,Fi=void 0,fa=r.templates,Hi({status:"ready",readyLocale:i}),St.resolve())},r=>{Vr===t&&(Hi({status:"error",errorLocale:i,errorMessage:r.toString()}),St.reject(r))}),St.promise};var Ki="en",ji=["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"],Gi="You must call `loadLocale` first to set up the localized template.",Yr,Hr,ya=i=>{let t=ga({sourceLocale:Ki,targetLocales:ji,loadLocale:i});Yr=t.getLocale,Hr=t.setLocale};var Wi=i=>{ya(i)},qi=i=>{if(!Hr)throw new Error(Gi);return Hr(i)},Ji=()=>{if(!Yr)throw new Error(Gi);return Yr()};var tr=new Set(ji);tr.add(Ki);var Zi=i=>{if(typeof i!="string")return!1;if(i==="en")return!0;let t=i.replace("_","-");if(tr.has(t))return!0;let e=t.split("-")[0];return!!tr.has(e)},Xi=i=>{if(i==="en")return"en-GB";let t=i.replace("_","-");if(tr.has(t))return t;let e=t.split("-")[0];return tr.has(e)?e:"en-GB"};var Fr=globalThis,zr=Fr.ShadowRoot&&(Fr.ShadyCSS===void 0||Fr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Qi=Symbol(),va=new WeakMap,rr=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==Qi)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(zr&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=va.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&va.set(e,t))}return t}toString(){return this.cssText}},he=i=>new rr(typeof i=="string"?i:i+"",void 0,Qi),y=(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 rr(e,i,Qi)},ba=(i,t)=>{if(zr)i.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of t){let r=document.createElement("style"),o=Fr.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=e.cssText,i.appendChild(r)}},eo=zr?i=>i:i=>i instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return he(e)})(i):i;var{is:Sl,defineProperty:Pl,getOwnPropertyDescriptor:_l,getOwnPropertyNames:wl,getOwnPropertySymbols:Tl,getPrototypeOf:Ml}=Object,pt=globalThis,Ca=pt.trustedTypes,kl=Ca?Ca.emptyScript:"",Il=pt.reactiveElementPolyfillSupport,ir=(i,t)=>i,or={toAttribute(i,t){switch(t){case Boolean:i=i?kl: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}},Kr=(i,t)=>!Sl(i,t),Ea={attribute:!0,type:String,converter:or,reflect:!1,useDefault:!1,hasChanged:Kr};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),pt.litPropertyMetadata??(pt.litPropertyMetadata=new WeakMap);var qe=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=Ea){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&&Pl(this.prototype,t,o)}}static getPropertyDescriptor(t,e,r){let{get:o,set:a}=_l(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)??Ea}static _$Ei(){if(this.hasOwnProperty(ir("elementProperties")))return;let t=Ml(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(ir("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ir("properties"))){let e=this.properties,r=[...wl(e),...Tl(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(eo(o))}else t!==void 0&&e.push(eo(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 ba(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:or).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:or;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??Kr)(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){}};qe.elementStyles=[],qe.shadowRootOptions={mode:"open"},qe[ir("elementProperties")]=new Map,qe[ir("finalized")]=new Map,Il?.({ReactiveElement:qe}),(pt.reactiveElementVersions??(pt.reactiveElementVersions=[])).push("2.1.0");var nr=globalThis,jr=nr.trustedTypes,Aa=jr?jr.createPolicy("lit-html",{createHTML:i=>i}):void 0,ro="$lit$",Je=`lit$${Math.random().toFixed(9).slice(2)}$`,io="?"+Je,Nl=`<${io}>`,wt=document,sr=()=>wt.createComment(""),lr=i=>i===null||typeof i!="object"&&typeof i!="function",oo=Array.isArray,Ta=i=>oo(i)||typeof i?.[Symbol.iterator]=="function",to=`[
|
|
2
|
-
\f\r]`,ar=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,xa=/-->/g,Sa=/>/g,Pt=RegExp(`>|${to}(?:([^\\s"'>=/]+)(${to}*=${to}*(?:[^
|
|
3
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Pa=/'/g,_a=/"/g,Ma=/^(?:script|style|textarea|title)$/i,ao=i=>(t,...e)=>({_$litType$:i,strings:t,values:e}),m=ao(1),De=ao(2),qu=ao(3),ee=Symbol.for("lit-noChange"),h=Symbol.for("lit-nothing"),wa=new WeakMap,_t=wt.createTreeWalker(wt,129);function ka(i,t){if(!oo(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return Aa!==void 0?Aa.createHTML(t):t}var Ia=(i,t)=>{let e=i.length-1,r=[],o,a=t===2?"<svg>":t===3?"<math>":"",n=ar;for(let s=0;s<e;s++){let d=i[s],c,u,g=-1,f=0;for(;f<d.length&&(n.lastIndex=f,u=n.exec(d),u!==null);)f=n.lastIndex,n===ar?u[1]==="!--"?n=xa:u[1]!==void 0?n=Sa:u[2]!==void 0?(Ma.test(u[2])&&(o=RegExp("</"+u[2],"g")),n=Pt):u[3]!==void 0&&(n=Pt):n===Pt?u[0]===">"?(n=o??ar,g=-1):u[1]===void 0?g=-2:(g=n.lastIndex-u[2].length,c=u[1],n=u[3]===void 0?Pt:u[3]==='"'?_a:Pa):n===_a||n===Pa?n=Pt:n===xa||n===Sa?n=ar:(n=Pt,o=void 0);let x=n===Pt&&i[s+1].startsWith("/>")?" ":"";a+=n===ar?d+Nl:g>=0?(r.push(c),d.slice(0,g)+ro+d.slice(g)+Je+x):d+Je+(g===-2?s:x)}return[ka(i,a+(i[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]},dr=class i{constructor({strings:t,_$litType$:e},r){let o;this.parts=[];let a=0,n=0,s=t.length-1,d=this.parts,[c,u]=Ia(t,e);if(this.el=i.createElement(c,r),_t.currentNode=this.el.content,e===2||e===3){let g=this.el.content.firstChild;g.replaceWith(...g.childNodes)}for(;(o=_t.nextNode())!==null&&d.length<s;){if(o.nodeType===1){if(o.hasAttributes())for(let g of o.getAttributeNames())if(g.endsWith(ro)){let f=u[n++],x=o.getAttribute(g).split(Je),I=/([.?@])?(.*)/.exec(f);d.push({type:1,index:a,name:I[2],strings:x,ctor:I[1]==="."?Wr:I[1]==="?"?qr:I[1]==="@"?Jr:Mt}),o.removeAttribute(g)}else g.startsWith(Je)&&(d.push({type:6,index:a}),o.removeAttribute(g));if(Ma.test(o.tagName)){let g=o.textContent.split(Je),f=g.length-1;if(f>0){o.textContent=jr?jr.emptyScript:"";for(let x=0;x<f;x++)o.append(g[x],sr()),_t.nextNode(),d.push({type:2,index:++a});o.append(g[f],sr())}}}else if(o.nodeType===8)if(o.data===io)d.push({type:2,index:a});else{let g=-1;for(;(g=o.data.indexOf(Je,g+1))!==-1;)d.push({type:7,index:a}),g+=Je.length-1}a++}}static createElement(t,e){let r=wt.createElement("template");return r.innerHTML=t,r}};function Tt(i,t,e=i,r){if(t===ee)return t;let o=r!==void 0?e._$Co?.[r]:e._$Cl,a=lr(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=Tt(i,o._$AS(i,t.values),o,r)),t}var Gr=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:e},parts:r}=this._$AD,o=(t?.creationScope??wt).importNode(e,!0);_t.currentNode=o;let a=_t.nextNode(),n=0,s=0,d=r[0];for(;d!==void 0;){if(n===d.index){let c;d.type===2?c=new Ut(a,a.nextSibling,this,t):d.type===1?c=new d.ctor(a,d.name,d.strings,this,t):d.type===6&&(c=new Zr(a,this,t)),this._$AV.push(c),d=r[++s]}n!==d?.index&&(a=_t.nextNode(),n++)}return _t.currentNode=wt,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++}},Ut=class i{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,r,o){this.type=2,this._$AH=h,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=Tt(this,t,e),lr(t)?t===h||t==null||t===""?(this._$AH!==h&&this._$AR(),this._$AH=h):t!==this._$AH&&t!==ee&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Ta(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!==h&&lr(this._$AH)?this._$AA.nextSibling.data=t:this.T(wt.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=dr.createElement(ka(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===o)this._$AH.p(e);else{let a=new Gr(o,this),n=a.u(this.options);a.p(e),this.T(n),this._$AH=a}}_$AC(t){let e=wa.get(t.strings);return e===void 0&&wa.set(t.strings,e=new dr(t)),e}k(t){oo(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(sr()),this.O(sr()),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))}},Mt=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,o,a){this.type=1,this._$AH=h,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=h}_$AI(t,e=this,r,o){let a=this.strings,n=!1;if(a===void 0)t=Tt(this,t,e,0),n=!lr(t)||t!==this._$AH&&t!==ee,n&&(this._$AH=t);else{let s=t,d,c;for(t=a[0],d=0;d<a.length-1;d++)c=Tt(this,s[r+d],e,d),c===ee&&(c=this._$AH[d]),n||(n=!lr(c)||c!==this._$AH[d]),c===h?t=h:t!==h&&(t+=(c??"")+a[d+1]),this._$AH[d]=c}n&&!o&&this.j(t)}j(t){t===h?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Wr=class extends Mt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===h?void 0:t}},qr=class extends Mt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==h)}},Jr=class extends Mt{constructor(t,e,r,o,a){super(t,e,r,o,a),this.type=5}_$AI(t,e=this){if((t=Tt(this,t,e,0)??h)===ee)return;let r=this._$AH,o=t===h&&r!==h||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,a=t!==h&&(r===h||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)}},Zr=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){Tt(this,t)}},Na={M:ro,P:Je,A:io,C:1,L:Ia,R:Gr,D:Ta,V:Tt,I:Ut,H:Mt,N:qr,U:Jr,B:Wr,F:Zr},Ll=nr.litHtmlPolyfillSupport;Ll?.(dr,Ut),(nr.litHtmlVersions??(nr.litHtmlVersions=[])).push("3.3.0");var La=(i,t,e)=>{let r=e?.renderBefore??t,o=r._$litPart$;if(o===void 0){let a=e?.renderBefore??null;r._$litPart$=o=new Ut(t.insertBefore(sr(),a),a,void 0,e??{})}return o._$AI(i),o};var cr=globalThis,v=class extends qe{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=La(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ee}};v._$litElement$=!0,v.finalized=!0,cr.litElementHydrateSupport?.({LitElement:v});var Rl=cr.litElementPolyfillSupport;Rl?.({LitElement:v});(cr.litElementVersions??(cr.litElementVersions=[])).push("4.2.0");var b=i=>(t,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(i,t)})):customElements.define(i,t)};var Ol={attribute:!0,type:String,converter:or,reflect:!1,hasChanged:Kr},Dl=(i=Ol,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 d=t.get.call(this);t.set.call(this,s),this.requestUpdate(n,d,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 d=this[n];t.call(this,s),this.requestUpdate(n,d,i)}}throw Error("Unsupported decorator location: "+r)};function p(i){return(t,e)=>typeof e=="object"?Dl(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 _(i){return p({...i,state:!0,attribute:!1})}var kt=(i,t,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(i,t,e),e);function mt(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 d=Symbol();return{get(){return this[d]},set(c){this[d]=c}}})();return kt(e,r,{get(){let d=n.call(this);return d===void 0&&(d=a(this),(d!==null||this.hasUpdated)&&s.call(this,d)),d}})}return kt(e,r,{get(){return a(this)}})}}function k(i,t,e){return i?t(i):e?.(i)}var P=y` * { box-sizing: border-box; } `,Ra=y` :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 Oa="https://sdk.primer.io/web/v2-latest/Primer.min.js",_e="20px";var Xr=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 Qr=class{constructor(t){this.paymentMethods=null;this.headlessInstance=t}setPaymentMethods(t){this.paymentMethods=t}async refreshSession(){if(!this.headlessInstance){A.errorWithDatadog("PrimerJS: Cannot refresh session: Headless instance not available");return}try{await this.headlessInstance.refreshClientSession()}catch(t){throw A.errorWithDatadog("PrimerJS: Error refreshing client session",{error: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 ei=typeof window<"u"&&typeof window.document<"u";function $l(i){return document.querySelector(`script[src^="${i}"]`)}function Vl(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 Da(i,t=!1){if(!ei)throw new Error("Cannot load script in server environment");let e=$l(i)??Vl(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 Ul={"../../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,d,c){return{card:s,isPotentiallyValid:d,isValid:c}}function n(s,d){d===void 0&&(d={});var c,u,g;if(typeof s!="string"&&typeof s!="number")return a(null,!1,!1);var f=String(s).replace(/-|\s/g,"");if(!/^\d*$/.test(f))return a(null,!1,!1);var x=o(f);if(x.length===0)return a(null,!1,!1);if(x.length!==1)return a(null,!0,!1);var I=x[0];if(d.maxLength&&f.length>d.maxLength)return a(I,!1,!1);u=d.skipLuhnValidation===!0||I.type===o.types.UNIONPAY&&d.luhnValidateUnionPay!==!0?!0:r(f),g=Math.max.apply(null,I.lengths),d.maxLength&&(g=Math.min(d.maxLength,g));for(var w=0;w<I.lengths.length;w++)if(I.lengths[w]===f.length)return c=f.length<g||u,a(I,c,u);return a(I,f.length<g,!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,d){for(var c=0;c<s.length;c++)if(d===s[c])return!0;return!1}function o(s){for(var d=e,c=0;c<s.length;c++)d=s[c]>d?s[c]:d;return d}function a(s,d){return{isValid:s,isPotentiallyValid:d}}function n(s,d){return d===void 0&&(d=e),d=d instanceof Array?d:[d],typeof s!="string"||!/^\d*$/.test(s)?a(!1,!1):r(d,s.length)?a(!0,!0):s.length<Math.min.apply(null,d)?a(!1,!0):s.length>o(d)?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 u,g=1,f=arguments.length;g<f;g++){u=arguments[g];for(var x in u)Object.prototype.hasOwnProperty.call(u,x)&&(c[x]=u[x])}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,u,g,f){return{isValid:c,isPotentiallyValid:u,month:g,year:f}}function d(c,u){var g;if(typeof c=="string")c=c.replace(/^(\d\d) (\d\d(\d\d)?)$/,"$1/$2"),g=(0,o.parseDate)(String(c));else{if(c===null||typeof c!="object")return s(!1,!1,null,null);var f=r({},c);g={month:String(f.month),year:String(f.year)}}var x=(0,a.expirationMonth)(g.month),I=(0,n.expirationYear)(g.year,u);if(x.isValid){if(I.isCurrentYear){var w=x.isValidForThisYear;return s(w,w,g.month,g.year)}if(I.isValid)return s(!0,!0,g.month,g.year)}return x.isPotentiallyValid&&I.isPotentiallyValid?s(!1,!0,null,null):s(!1,!1,null,null)}t.expirationDate=d},"../../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 d=a.length;if(d<2)return r(!1,!0);var c=new Date().getFullYear();if(d===3){var u=a.slice(0,2),g=String(c).slice(0,2);return r(!1,u===g)}if(d>4)return r(!1,!1);var f=parseInt(a,10),x=Number(String(c).substr(2,2)),I=!1;if(d===2){if(String(c).substr(0,2)===a)return r(!1,!0);s=x===f,I=f>=x&&f<=x+n}else d===4&&(s=c===f,I=f>=c&&f<=c+n);return r(I,I,s)}t.expirationYear=o},"../../node_modules/card-validator/dist/index.js":function(i,t,e){var r=this&&this.__createBinding||(Object.create?function(w,M,S,L){L===void 0&&(L=S);var U=Object.getOwnPropertyDescriptor(M,S);(!U||("get"in U?!M.__esModule:U.writable||U.configurable))&&(U={enumerable:!0,get:function(){return M[S]}}),Object.defineProperty(w,L,U)}:function(w,M,S,L){L===void 0&&(L=S),w[L]=M[S]}),o=this&&this.__setModuleDefault||(Object.create?function(w,M){Object.defineProperty(w,"default",{enumerable:!0,value:M})}:function(w,M){w.default=M}),a=this&&this.__importStar||function(w){if(w&&w.__esModule)return w;var M={};if(w!=null)for(var S in w)S!=="default"&&Object.prototype.hasOwnProperty.call(w,S)&&r(M,w,S);return o(M,w),M},n=a(e("../../node_modules/credit-card-type/dist/index.js")),s=e("../../node_modules/card-validator/dist/cardholder-name.js"),d=e("../../node_modules/card-validator/dist/card-number.js"),c=e("../../node_modules/card-validator/dist/expiration-date.js"),u=e("../../node_modules/card-validator/dist/expiration-month.js"),g=e("../../node_modules/card-validator/dist/expiration-year.js"),f=e("../../node_modules/card-validator/dist/cvv.js"),x=e("../../node_modules/card-validator/dist/postal-code.js"),I={creditCardType:n,cardholderName:s.cardholderName,number:d.cardNumber,expirationDate:c.expirationDate,expirationMonth:u.expirationMonth,expirationYear:g.expirationYear,cvv:f.cvv,postalCode:x.postalCode};i.exports=I},"../../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 d=Number(s[0]),c;return d===0?2:d>1||d===1&&Number(s[1])>2?1:d===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 d;if(/^\d{4}-\d{1,2}$/.test(s)?d=s.split("-").reverse():/\//.test(s)?d=s.split(/\s*\/\s*/g):/\s/.test(s)&&(d=s.split(/ +/g)),(0,o.isArray)(d))return{month:d[0]||"",year:d.slice(1).join()};var c=a(s),u=s.substr(0,c);return{month:u,year:s.substr(u.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 d=s.minLength||e;return typeof n!="string"?o(!1,!1):n.length<d||!r.test(n.trim().slice(0,d))?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 L,U=1,Pe=arguments.length;U<Pe;U++){L=arguments[U];for(var Ce in L)Object.prototype.hasOwnProperty.call(L,Ce)&&(S[Ce]=L[Ce])}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"),d=e("../../node_modules/credit-card-type/dist/lib/clone.js"),c={},u={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"},g=[u.VISA,u.MASTERCARD,u.AMERICAN_EXPRESS,u.DINERS_CLUB,u.DISCOVER,u.JCB,u.UNIONPAY,u.MAESTRO,u.ELO,u.MIR,u.HIPER,u.HIPERCARD],f=(0,d.clone)(g);function x(S){return c[S]||o[S]}function I(){return f.map(function(S){return(0,d.clone)(x(S))})}function w(S,L){L===void 0&&(L=!1);var U=f.indexOf(S);if(!L&&U===-1)throw new Error('"'+S+'" is not a supported card type.');return U}function M(S){var L=[];if(!(0,n.isValidInputType)(S))return L;if(S.length===0)return I();f.forEach(function(Pe){var Ce=x(Pe);(0,a.addMatchingCardsToResults)(S,Ce,L)});var U=(0,s.findBestMatch)(L);return U?[U]:L}M.getTypeInfo=function(S){return(0,d.clone)(x(S))},M.removeCard=function(S){var L=w(S);f.splice(L,1)},M.addCard=function(S){var L=w(S.type,!0);c[S.type]=S,L===-1&&f.push(S.type)},M.updateCard=function(S,L){var U=c[S]||o[S];if(!U)throw new Error('"'.concat(S,"\" is not a recognized type. Use `addCard` instead.'"));if(L.type&&U.type!==L.type)throw new Error("Cannot overwrite type parameter.");var Pe=(0,d.clone)(U);Pe=r(r({},Pe),L),c[Pe.type]=Pe},M.changeOrder=function(S,L){var U=w(S);f.splice(U,1),f.splice(L,0,S)},M.resetModifications=function(){f=(0,d.clone)(g),c={}},M.types=u,i.exports=M},"../../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,d){var c,u;for(c=0;c<s.patterns.length;c++){var g=s.patterns[c];if((0,o.matches)(n,g)){var f=(0,r.clone)(s);u=Array.isArray(g)?String(g[0]).length:String(g).length,n.length>=u&&(f.matchStrength=u),d.push(f);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 d=String(n).length,c=a.substr(0,d),u=parseInt(c,10);return n=parseInt(String(n).substr(0,c.length),10),s=parseInt(String(s).substr(0,c.length),10),u>=n&&u<=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}},$a={};function So(i){var t=$a[i];if(t!==void 0)return t.exports;var e=$a[i]={exports:{}};return Ul[i].call(e.exports,e,e.exports,So),e.exports}var Te=()=>an.randomUUID?.()||Bl(),Bl=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,i=>(i^Yl()>>i/4).toString(16)),Yl=()=>(an.getRandomValues?.(new Uint8Array(1))[0]??16*Math.random())&15,an=typeof crypto<"u"?crypto:{},Hl={LOCAL:"https://analytics.dev.data.primer.io/v1/sdk-logs",DEV:"https://analytics.dev.data.primer.io/v1/sdk-logs",STAGING:"https://analytics.staging.data.primer.io/v1/sdk-logs",SANDBOX:"https://analytics.sandbox.data.primer.io/v1/sdk-logs",PRODUCTION:"https://analytics.production.data.primer.io/v1/sdk-logs"};function Fl(i,t){let r={message:i instanceof Error?i.message:typeof i=="string"?i:JSON.stringify(i)};i instanceof Error&&i.stack&&(r.stack=i.stack),t?.clientSessionId&&(r.clientSessionId=t.clientSessionId),t?.metadata&&Object.assign(r,t.metadata),t.status&&Object.assign(r,{status:t.status});let o={message:JSON.stringify(r),hostname:typeof window<"u"?window.location.hostname:"unknown",service:"web-sdk",ddsource:"lambda",ddtags:`env:${t?.environment},version:${t?.sdkVersion}`};zl(o,t)}function zl(i,{environment:t,clientSessionToken:e}){if(t==="LOCAL")return void N.debug("\u{1F436}\u{1F436}\u{1F436} [Datadog Log] \u{1F436}\u{1F436}\u{1F436}",i);let r=Hl[t||"LOCAL"];if(!r)return void N.warn("No logging endpoint configured for current environment");fetch(r,{method:"POST",headers:{"Content-Type":"application/json",...e&&{Authorization:`Bearer ${e}`}},body:JSON.stringify(i)}).catch(o=>{N.error("Failed to send log event:",o)})}var V=class V{static log(t,...e){V.enabled}static info(t,...e){V.enabled}static warn(t,...e){V.enabled}static error(t,...e){V.enabled&&e.forEach(r=>{r instanceof Error&&r.toJSON})}static errorWithDatadog(t,e){let{error:r,status:o="error"}=e||{};if(V.enabled){r instanceof Error&&r.toJSON;try{let a=r||t,n={environment:V.environment,sdkVersion:V.sdkVersion,clientSessionToken:V.clientSessionToken,clientSessionId:V.clientSessionId,status:o,metadata:{sdkOptions:V.sdkOptions,clientToken:V.clientToken}};Fl(a,n)}catch{V.enabled}}}static debug(t,...e){V.enabled}static table(t,e){V.enabled}static time(t){V.enabled}static timeEnd(t){V.enabled}static setEnvironment(t){V.environment=t}static setSdkVersion(t){V.sdkVersion=t}static setClientSessionToken(t){V.clientSessionToken=t}static setClientSessionId(t){V.clientSessionId=t}static setSdkOptions(t){V.sdkOptions=t}static setClientToken(t){V.clientToken=t}};T(V,"enabled",!0),T(V,"environment"),T(V,"sdkVersion"),T(V,"clientSessionToken"),T(V,"clientSessionId"),T(V,"sdkOptions"),T(V,"clientToken"),T(V,"defaultFont","font-family: Consolas, monospace; font-size: 12px;"),T(V,"brandTag","[PRIMER]"),T(V,"brandStyle",`background: #24292e; color: #ffffff; padding: 2px 6px; border-radius: 3px; font-weight: bold; margin-right: 4px; ${V.defaultFont}`),T(V,"styles",{log:`color: #4CAF50; ${V.defaultFont}`,info:`color: #2196F3; ${V.defaultFont}`,warn:`color: #FF9800; ${V.defaultFont}`,error:`color: #F44336; ${V.defaultFont}`,debug:`color: #9C27B0; ${V.defaultFont}`});var N=V,Kl={LOCAL:"",DEV:"https://analytics.dev.data.primer.io/v1/sdk-analytic-events",STAGING:"https://analytics.staging.data.primer.io/v1/sdk-analytic-events",SANDBOX:"https://analytics.sandbox.data.primer.io/v1/sdk-analytic-events",PRODUCTION:"https://analytics.production.data.primer.io/v1/sdk-analytic-events"},co=class{constructor(){T(this,"sessionConfig",null)}initialize(t){this.sessionConfig=t}clear(){this.sessionConfig=null}getSessionConfig(){return this.sessionConfig}sendEvent(t){if(!this.sessionConfig)return void N.error("Analytics manager not initialized. Call initializeAnalytics() first.");let e={id:Te(),timestamp:Math.floor(Date.now()/1e3),sdkType:"WEB",eventName:t.eventName,checkoutSessionId:this.sessionConfig.checkoutSessionId,clientSessionId:this.sessionConfig.clientSessionId,primerAccountId:this.sessionConfig.primerAccountId,sdkVersion:this.sessionConfig.sdkVersion,userAgent:typeof navigator<"u"?navigator.userAgent:"",eventType:t.eventType,userLocale:t.userLocale,paymentMethod:t.paymentMethod,paymentId:t.paymentId,redirectDestinationUrl:t.redirectDestinationUrl,threedsProvider:t.threedsProvider,threedsResponse:t.threedsResponse};Gl(e,this.sessionConfig)}},nn=new co;function jl(i){nn.initialize(i)}function hi(i){nn.sendEvent(i)}async function Gl(i,{environment:t,clientSessionToken:e}){if(t==="LOCAL")return void N.debug(`Analytics event ${i.eventName}:`,i);let r=Kl[t];return fetch(r,{method:"POST",headers:{"Content-Type":"application/json",...e&&{Authorization:`Bearer ${e}`}},body:JSON.stringify(i)}).catch(o=>{N.error("Failed to send analytics event:",o)})}var no=(function(i){return i.CARD="CARD",i.NATIVE="NATIVE",i.REDIRECT="REDIRECT",i.KLARNA="KLARNA",i.ACH="ACH",i})({}),Va=So("../../node_modules/credit-card-type/dist/index.js");function Po(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 Wl(i){return Po(i).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1).toLowerCase()).join(" ")}function Ua(i){return Po(i).join("-").toLowerCase()}function Ba(i){return Po(i).join("_").toUpperCase()}var sn=[["AMEX","american-express"],["CARTES_BANCAIRES"],["DANKORT"],["DINERS_CLUB","diners-club"],["DISCOVER","discover"],["ENROUTE"],["ELO","elo"],["EFTPOS"],["HIPER","hiper","hiper-pay"],["HIPERCARD","hipercard"],["INTERAC"],["JCB","jcb"],["MAESTRO","maestro"],["MASTERCARD","mastercard"],["MIR","mir","mir-pay"],["OTHER",void 0,"payment-card"],["UNIONPAY","unionpay"],["VISA","visa"]],Ya=new Map(sn.map(i=>[i[0],i])),ql=new Map(sn.filter(i=>i[1]).map(i=>[i[1],i]));function _o(i){let{niceType:t,type:e}=(0,Va.getTypeInfo)(Ua(i))||(0,Va.getTypeInfo)(Ya.get(Ba(i))?.[1]||"")||{},[r,o,a]=ql.get(e)||Ya.get(Ba(i))||[];return{asset:a||Ua(o||i),backend:r,display:t||Wl(i),library:o}}var se={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"},ln="3.7.7",Jl=ln,Ft=typeof Buffer=="function",Ha=typeof TextDecoder=="function"?new TextDecoder:void 0,Fa=typeof TextEncoder=="function"?new TextEncoder:void 0,Zl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",pr=Array.prototype.slice.call(Zl),ti=(i=>{let t={};return i.forEach((e,r)=>t[e]=r),t})(pr),Xl=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,J=String.fromCharCode.bind(String),za=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):i=>new Uint8Array(Array.prototype.slice.call(i,0)),dn=i=>i.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),cn=i=>i.replace(/[^A-Za-z0-9\+\/]/g,""),pn=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+=pr[t>>18&63]+pr[t>>12&63]+pr[t>>6&63]+pr[63&t]}return n?a.slice(0,n-3)+"===".substring(n):a},wo=typeof btoa=="function"?i=>btoa(i):Ft?i=>Buffer.from(i,"binary").toString("base64"):pn,po=Ft?i=>Buffer.from(i).toString("base64"):i=>{let e=[];for(let r=0,o=i.length;r<o;r+=4096)e.push(J.apply(null,i.subarray(r,r+4096)));return wo(e.join(""))},oi=(i,t=!1)=>t?dn(po(i)):po(i),Ql=i=>{if(i.length<2){var t=i.charCodeAt(0);return t<128?i:t<2048?J(192|t>>>6)+J(128|63&t):J(224|t>>>12&15)+J(128|t>>>6&63)+J(128|63&t)}var t=65536+(i.charCodeAt(0)-55296)*1024+(i.charCodeAt(1)-56320);return J(240|t>>>18&7)+J(128|t>>>12&63)+J(128|t>>>6&63)+J(128|63&t)},ed=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,mn=i=>i.replace(ed,Ql),Ka=Ft?i=>Buffer.from(i,"utf8").toString("base64"):Fa?i=>po(Fa.encode(i)):i=>wo(mn(i)),Bt=(i,t=!1)=>t?dn(Ka(i)):Ka(i),ja=i=>Bt(i,!0),td=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,rd=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 J((e>>>10)+55296)+J((1023&e)+56320);case 3:return J((15&i.charCodeAt(0))<<12|(63&i.charCodeAt(1))<<6|63&i.charCodeAt(2));default:return J((31&i.charCodeAt(0))<<6|63&i.charCodeAt(1))}},un=i=>i.replace(td,rd),hn=i=>{if(i=i.replace(/\s+/g,""),!Xl.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=ti[i.charAt(a++)]<<18|ti[i.charAt(a++)]<<12|(r=ti[i.charAt(a++)])<<6|(o=ti[i.charAt(a++)]),e+=r===64?J(t>>16&255):o===64?J(t>>16&255,t>>8&255):J(t>>16&255,t>>8&255,255&t);return e},To=typeof atob=="function"?i=>atob(cn(i)):Ft?i=>Buffer.from(i,"base64").toString("binary"):hn,fn=Ft?i=>za(Buffer.from(i,"base64")):i=>za(To(i).split("").map(t=>t.charCodeAt(0))),gn=i=>fn(yn(i)),id=Ft?i=>Buffer.from(i,"base64").toString("utf8"):Ha?i=>Ha.decode(fn(i)):i=>un(To(i)),yn=i=>cn(i.replace(/[-_]/g,t=>t=="-"?"+":"/")),mo=i=>id(yn(i)),od=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)},vn=i=>({value:i,enumerable:!1,writable:!0,configurable:!0}),bn=function(){let i=(t,e)=>Object.defineProperty(String.prototype,t,vn(e));i("fromBase64",function(){return mo(this)}),i("toBase64",function(t){return Bt(this,t)}),i("toBase64URI",function(){return Bt(this,!0)}),i("toBase64URL",function(){return Bt(this,!0)}),i("toUint8Array",function(){return gn(this)})},Cn=function(){let i=(t,e)=>Object.defineProperty(Uint8Array.prototype,t,vn(e));i("toBase64",function(t){return oi(this,t)}),i("toBase64URI",function(){return oi(this,!0)}),i("toBase64URL",function(){return oi(this,!0)})},ad=()=>{bn(),Cn()},En={version:ln,VERSION:Jl,atob:To,atobPolyfill:hn,btoa:wo,btoaPolyfill:pn,fromBase64:mo,toBase64:Bt,encode:Bt,encodeURI:ja,encodeURL:ja,utob:mn,btou:un,decode:mo,isValid:od,fromUint8Array:oi,toUint8Array:gn,extendString:bn,extendUint8Array:Cn,extendBuiltins:ad},ai={encode:nd,decode:En.decode};function nd(i,t={}){let{urlSafe:e=!1}=t;return En.encode(i,e)}function sd(i,t){return!(i.intent!==`${t}_REDIRECTION`||!("statusUrl"in i)||!("redirectUrl"in i)||!i.redirectUrl||!i.statusUrl)}function Yt(i){let t=cd(i),e=1e3*t.exp;if(Date.now()>e)throw new Error(`${ld}. Expiration date: ${new Date(e).toISOString()}`);return t}var An="The provided `clientToken`",ld=`${An} has expired`,dd=`${An} is malformed`;function cd(i){try{let[t,e]=i.split("."),r=e||t;return JSON.parse(ai.decode(r))}catch{throw new Error(dd)}}var ni=class{constructor(t,e){T(this,"context");T(this,"dialogProvider");this.context=t,this.dialogProvider=e}};function Mo(){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 fr(i){return i?new Promise(t=>{setTimeout(t,i)}):Promise.resolve()}var uo=class extends ni{async handleRequiredAction(t){let e=t.requiredAction?.clientToken;if(!e)throw new Error("No client token provided");let r=Yt(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:Mo()});if(o||!a||!a.authentication)throw o??new Error("Unable to authenticate");let n=a.authentication,s=a;n.responseCode==="METHOD"&&(s=await this.handleMethod(r.tokenId,n),n=s.authentication),n.responseCode==="CHALLENGE"&&(s=await this.handleChallenge(r.tokenId,n));let d=await this.context.pciApi.postResumePayment(t.id,s.resumeToken);if(d.error||!d.data)throw d.error??new Error("Unable to resume payment");return d.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 d=document.createElement("iframe");d.style.display="none",d.id=o,d.name=o,s.appendChild(d);let c=document.createElement("form"),u=document.createElement("input");u.type="hidden",u.id=n,u.name=n,u.value=ai.encode(JSON.stringify({threeDSServerTransID:e.transactionId,threeDSMethodNotificationURL:e.notificationUrl}),{urlSafe:!0}).replace(/=+$/g,""),c.appendChild(u),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:g,error:f}=await this.pollStatus(e.statusUrl,"METHOD",1e3).promise;return s.remove(),f||!g?this.continueAuth(t):g}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 d=await this.context.pciApi.get3dsResumeStatus(t);if(d.error){clearTimeout(s),n(d);return}if(await fr(r),d.data&&d.data.authentication.responseCode!==e){clearTimeout(s),n(d);return}}}catch(d){clearTimeout(s),n({error:d,data:null})}}),abort:()=>{a=!1}}}async continueAuth(t){let{data:e,error:r}=await this.context.pciApi.post3dsContinue(t);return r||!e?{resumeToken:Te(),authentication:{responseCode:"SKIPPED",skippedReasonCode:"NEGOTIATION_ERROR",skippedReasonText:"Failed to negotiate with 3DS server"}}:e}async handleChallenge(t,e){let{container:r,formId:o}=this.createChallengeElements(e),a=()=>{let s=document.getElementById(o);s?s.submit():requestAnimationFrame(()=>{let d=document.getElementById(o);d&&d.submit()})},n=this.pollStatus(e.statusUrl,"CHALLENGE",2500,66e4);try{let s=this.dialogProvider.show({htmlContent:r.outerHTML,onContentReady:a});hi({eventName:"PAYMENT_THREEDS",threedsResponse:JSON.stringify(e)});let d=await Promise.race([n.promise,s.then(()=>null,c=>{throw n.abort(),c})]);return d&&d.data?(this.dialogProvider.close(),d.data):(this.dialogProvider.close(),this.continueAuth(t))}catch{return n.abort(),this.continueAuth(t)}}createChallengeElements(t){this.inject3DSChallengeCSS();let e=`3ds-challenge-iframe-${Te()}`,r=`3ds-challenge-form-${Te()}`,o=/^1/.test(t.protocolVersion),a=document.createElement("div");a.className="challenge-container";let n=document.createElement("form");if(n.id=r,n.className="challenge-form",n.action=t.acsChallengeUrl,n.target=e,n.method="post",o){let d=document.createElement("input");d.type="hidden",d.name="PaReq",d.id="PaReq",d.value=t.acsChallengeData||"",n.appendChild(d);let c=document.createElement("input");c.type="hidden",c.name="TermUrl",c.id="TermUrl",c.value=t.notificationUrl||"",n.appendChild(c)}else{let d=ai.encode(JSON.stringify({threeDSServerTransID:t.transactionId,acsTransID:t.acsTransactionId,messageVersion:t.protocolVersion,messageType:"CReq",challengeWindowSize:"05"}),{urlSafe:!0}),c=document.createElement("input");c.type="hidden",c.name="creq",c.id="creq",c.value=d,n.appendChild(c);let u=document.createElement("input");u.type="hidden",u.name="threeDSSessionData",u.id="threeDSSessionData",u.value="",n.appendChild(u)}let s=document.createElement("iframe");return s.id=e,s.name=e,s.className="challenge-iframe",s.setAttribute("frameborder","0"),s.title="3D Secure Challenge",a.appendChild(n),a.appendChild(s),{container:a,formId:r}}inject3DSChallengeCSS(){let t="primer-3ds-challenge-dialog-styles";if(document.getElementById(t))return;let e=`
|
|
1
|
+
import{a as Zo,b as d,c as N}from"./chunks/chunk.DV3REKZU.js";var Sr=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],n=r?.items??[];this.updateCardNetworksState({detectedCardNetwork:o,selectableCardNetworks:n,isLoading:!1})}};var nl={"../../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 n(s,l,c){return{card:s,isPotentiallyValid:l,isValid:c}}function a(s,l){l===void 0&&(l={});var c,u,f;if(typeof s!="string"&&typeof s!="number")return n(null,!1,!1);var h=String(s).replace(/-|\s/g,"");if(!/^\d*$/.test(h))return n(null,!1,!1);var A=o(h);if(A.length===0)return n(null,!1,!1);if(A.length!==1)return n(null,!0,!1);var x=A[0];if(l.maxLength&&h.length>l.maxLength)return n(x,!1,!1);u=l.skipLuhnValidation===!0||x.type===o.types.UNIONPAY&&l.luhnValidateUnionPay!==!0?!0:r(h),f=Math.max.apply(null,x.lengths),l.maxLength&&(f=Math.min(l.maxLength,f));for(var T=0;T<x.lengths.length;T++)if(x.lengths[T]===h.length)return c=h.length<f||u,n(x,c,u);return n(x,h.length<f,!1)}t.cardNumber=a},"../../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(a,s){return{isValid:a,isPotentiallyValid:s}}function n(a){return typeof a!="string"?o(!1,!1):a.length===0?o(!1,!0):a.length>r?o(!1,!1):e.test(a)?o(!1,!0):o(!0,!0)}t.cardholderName=n},"../../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 n(s,l){return{isValid:s,isPotentiallyValid:l}}function a(s,l){return l===void 0&&(l=e),l=l instanceof Array?l:[l],typeof s!="string"||!/^\d*$/.test(s)?n(!1,!1):r(l,s.length)?n(!0,!0):s.length<Math.min.apply(null,l)?n(!1,!0):s.length>o(l)?n(!1,!1):n(!0,!0)}t.cvv=a},"../../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 u,f=1,h=arguments.length;f<h;f++){u=arguments[f];for(var A in u)Object.prototype.hasOwnProperty.call(u,A)&&(c[A]=u[A])}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"),n=e("../../node_modules/card-validator/dist/expiration-month.js"),a=e("../../node_modules/card-validator/dist/expiration-year.js");function s(c,u,f,h){return{isValid:c,isPotentiallyValid:u,month:f,year:h}}function l(c,u){var f;if(typeof c=="string")c=c.replace(/^(\d\d) (\d\d(\d\d)?)$/,"$1/$2"),f=(0,o.parseDate)(String(c));else{if(c===null||typeof c!="object")return s(!1,!1,null,null);var h=r({},c);f={month:String(h.month),year:String(h.year)}}var A=(0,n.expirationMonth)(f.month),x=(0,a.expirationYear)(f.year,u);if(A.isValid){if(x.isCurrentYear){var T=A.isValidForThisYear;return s(T,T,f.month,f.year)}if(x.isValid)return s(!0,!0,f.month,f.year)}return A.isPotentiallyValid&&x.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,n,a){return{isValid:o,isPotentiallyValid:n,isValidForThisYear:a||!1}}function r(o){var n=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 a=parseInt(o,10);if(isNaN(Number(o)))return e(!1,!1);var s=a>0&&a<13;return e(s,s,s&&a>=n)}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(n,a,s){return{isValid:n,isPotentiallyValid:a,isCurrentYear:s||!1}}function o(n,a){a===void 0&&(a=e);var s;if(typeof n!="string")return r(!1,!1);if(n.replace(/\s/g,"")==="")return r(!1,!0);if(!/^\d*$/.test(n))return r(!1,!1);var l=n.length;if(l<2)return r(!1,!0);var c=new Date().getFullYear();if(l===3){var u=n.slice(0,2),f=String(c).slice(0,2);return r(!1,u===f)}if(l>4)return r(!1,!1);var h=parseInt(n,10),A=Number(String(c).substr(2,2)),x=!1;if(l===2){if(String(c).substr(0,2)===n)return r(!1,!0);s=A===h,x=h>=A&&h<=A+a}else l===4&&(s=c===h,x=h>=c&&h<=c+a);return r(x,x,s)}t.expirationYear=o},"../../node_modules/card-validator/dist/index.js":function(i,t,e){var r=this&&this.__createBinding||(Object.create?function(T,w,S,L){L===void 0&&(L=S);var $=Object.getOwnPropertyDescriptor(w,S);(!$||("get"in $?!w.__esModule:$.writable||$.configurable))&&($={enumerable:!0,get:function(){return w[S]}}),Object.defineProperty(T,L,$)}:function(T,w,S,L){L===void 0&&(L=S),T[L]=w[S]}),o=this&&this.__setModuleDefault||(Object.create?function(T,w){Object.defineProperty(T,"default",{enumerable:!0,value:w})}:function(T,w){T.default=w}),n=this&&this.__importStar||function(T){if(T&&T.__esModule)return T;var w={};if(T!=null)for(var S in T)S!=="default"&&Object.prototype.hasOwnProperty.call(T,S)&&r(w,T,S);return o(w,T),w},a=n(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"),u=e("../../node_modules/card-validator/dist/expiration-month.js"),f=e("../../node_modules/card-validator/dist/expiration-year.js"),h=e("../../node_modules/card-validator/dist/cvv.js"),A=e("../../node_modules/card-validator/dist/postal-code.js"),x={creditCardType:a,cardholderName:s.cardholderName,number:l.cardNumber,expirationDate:c.expirationDate,expirationMonth:u.expirationMonth,expirationYear:f.expirationYear,cvv:h.cvv,postalCode:A.postalCode};i.exports=x},"../../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 n(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 a(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=n(s),u=s.substr(0,c);return{month:u,year:s.substr(u.length)}}t.parseDate=a},"../../node_modules/card-validator/dist/luhn-10.js":function(i){function t(e){for(var r=0,o=!1,n=e.length-1,a;n>=0;)a=parseInt(e.charAt(n),10),o&&(a*=2,a>9&&(a=a%10+1)),o=!o,r+=a,n--;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(a,s){return{isValid:a,isPotentiallyValid:s}}function n(a,s){s===void 0&&(s={});var l=s.minLength||e;return typeof a!="string"?o(!1,!1):a.length<l||!r.test(a.trim().slice(0,l))?o(!1,!0):o(!0,!0)}t.postalCode=n},"../../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 L,$=1,xe=arguments.length;$<xe;$++){L=arguments[$];for(var Ee in L)Object.prototype.hasOwnProperty.call(L,Ee)&&(S[Ee]=L[Ee])}return S},r.apply(this,arguments)},o=e("../../node_modules/credit-card-type/dist/lib/card-types.js"),n=e("../../node_modules/credit-card-type/dist/lib/add-matching-cards-to-results.js"),a=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={},u={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"},f=[u.VISA,u.MASTERCARD,u.AMERICAN_EXPRESS,u.DINERS_CLUB,u.DISCOVER,u.JCB,u.UNIONPAY,u.MAESTRO,u.ELO,u.MIR,u.HIPER,u.HIPERCARD],h=(0,l.clone)(f);function A(S){return c[S]||o[S]}function x(){return h.map(function(S){return(0,l.clone)(A(S))})}function T(S,L){L===void 0&&(L=!1);var $=h.indexOf(S);if(!L&&$===-1)throw new Error('"'+S+'" is not a supported card type.');return $}function w(S){var L=[];if(!(0,a.isValidInputType)(S))return L;if(S.length===0)return x();h.forEach(function(xe){var Ee=A(xe);(0,n.addMatchingCardsToResults)(S,Ee,L)});var $=(0,s.findBestMatch)(L);return $?[$]:L}w.getTypeInfo=function(S){return(0,l.clone)(A(S))},w.removeCard=function(S){var L=T(S);h.splice(L,1)},w.addCard=function(S){var L=T(S.type,!0);c[S.type]=S,L===-1&&h.push(S.type)},w.updateCard=function(S,L){var $=c[S]||o[S];if(!$)throw new Error('"'.concat(S,"\" is not a recognized type. Use `addCard` instead.'"));if(L.type&&$.type!==L.type)throw new Error("Cannot overwrite type parameter.");var xe=(0,l.clone)($);xe=r(r({},xe),L),c[xe.type]=xe},w.changeOrder=function(S,L){var $=T(S);h.splice($,1),h.splice(L,0,S)},w.resetModifications=function(){h=(0,l.clone)(f),c={}},w.types=u,i.exports=w},"../../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 n(a,s,l){var c,u;for(c=0;c<s.patterns.length;c++){var f=s.patterns[c];if((0,o.matches)(a,f)){var h=(0,r.clone)(s);u=Array.isArray(f)?String(f[0]).length:String(f).length,a.length>=u&&(h.matchStrength=u),l.push(h);break}}}t.addMatchingCardsToResults=n},"../../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 n=o.filter(function(a){return a.matchStrength}).length;return n>0&&n===o.length}function r(o){return e(o)?o.reduce(function(n,a){return!n||Number(n.matchStrength)<Number(a.matchStrength)?a:n}):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(n,a,s){var l=String(a).length,c=n.substr(0,l),u=parseInt(c,10);return a=parseInt(String(a).substr(0,c.length),10),s=parseInt(String(s).substr(0,c.length),10),u>=a&&u<=s}function r(n,a){return a=String(a),a.substring(0,n.length)===n.substring(0,a.length)}function o(n,a){return Array.isArray(a)?e(n,a[0],a[1]):r(n,a)}t.matches=o}},Xo={};function Xi(i){var t=Xo[i];if(t!==void 0)return t.exports;var e=Xo[i]={exports:{}};return nl[i].call(e.exports,e,e.exports,Xi),e.exports}var Te=()=>Cn.randomUUID?.()||al(),al=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,i=>(i^sl()>>i/4).toString(16)),sl=()=>(Cn.getRandomValues?.(new Uint8Array(1))[0]??16*Math.random())&15,Cn=typeof crypto<"u"?crypto:{},$i=class{constructor(){N(this,"context",null)}initialize(t){this.context=t,I.debug("Session context initialized:",{checkoutSessionId:t.checkoutSessionId,clientSessionId:t.clientSessionId,primerAccountId:t.primerAccountId,environment:t.environment})}getContext(){return this.context}clear(){I.debug("Session context cleared"),this.context=null}isInitialized(){return this.context!==null}},Qi=new $i,ll={LOCAL:"https://analytics.dev.data.primer.io/v1/sdk-logs",DEV:"https://analytics.dev.data.primer.io/v1/sdk-logs",STAGING:"https://analytics.staging.data.primer.io/v1/sdk-logs",SANDBOX:"https://analytics.sandbox.data.primer.io/v1/sdk-logs",PRODUCTION:"https://analytics.production.data.primer.io/v1/sdk-logs"};function dl(i,t){let e=Qi.getContext(),o={message:i instanceof Error?i.message:typeof i=="string"?i:JSON.stringify(i)};i instanceof Error&&i.stack&&(o.stack=i.stack),e?(o.checkoutSessionId=e.checkoutSessionId,o.clientSessionId=e.clientSessionId,o.primerAccountId=e.primerAccountId,o.userAgent=e.userAgent):(t?.checkoutSessionId&&(o.checkoutSessionId=t.checkoutSessionId),t?.clientSessionId&&(o.clientSessionId=t.clientSessionId),t?.primerAccountId&&(o.primerAccountId=t.primerAccountId),t?.userAgent&&(o.userAgent=t.userAgent)),t?.metadata&&Object.assign(o,t.metadata),t.status&&Object.assign(o,{status:t.status});let n={message:JSON.stringify(o),hostname:typeof window<"u"?window.location.hostname:"unknown",service:"web-sdk",ddsource:"lambda",ddtags:`env:${e?.environment||t?.environment},version:${e?.sdkVersion||t?.sdkVersion}`};cl(n,{environment:e?.environment||t?.environment,clientSessionToken:e?.clientSessionToken||t?.clientSessionToken})}function cl(i,{environment:t,clientSessionToken:e}){if(t==="LOCAL")return void I.debug("\u{1F436}\u{1F436}\u{1F436} [Datadog Log] \u{1F436}\u{1F436}\u{1F436}",i);let r=ll[t||"LOCAL"];if(!r)return void I.warn("No logging endpoint configured for current environment");fetch(r,{method:"POST",headers:{"Content-Type":"application/json",...e&&{Authorization:`Bearer ${e}`}},body:JSON.stringify(i)}).catch(o=>{I.error("Failed to send log event:",o)})}var V=class V{static log(t,...e){V.enabled}static info(t,...e){V.enabled}static warn(t,...e){V.enabled}static error(t,...e){V.enabled&&e.forEach(r=>{r instanceof Error&&r.toJSON})}static errorWithDatadog(t,e){let{error:r,status:o="error"}=e||{};if(V.enabled){r instanceof Error&&r.toJSON;try{let n=r||t,a={status:o,metadata:{sdkOptions:V.sdkOptions,clientToken:V.clientToken}};dl(n,a)}catch{V.enabled}}}static debug(t,...e){V.enabled}static table(t,e){V.enabled}static time(t){V.enabled}static timeEnd(t){V.enabled}static setSdkOptions(t){V.sdkOptions=t}static setClientToken(t){V.clientToken=t}};N(V,"enabled",!0),N(V,"sdkOptions"),N(V,"clientToken"),N(V,"defaultFont","font-family: Consolas, monospace; font-size: 12px;"),N(V,"brandTag","[PRIMER]"),N(V,"brandStyle",`background: #24292e; color: #ffffff; padding: 2px 6px; border-radius: 3px; font-weight: bold; margin-right: 4px; ${V.defaultFont}`),N(V,"styles",{log:`color: #4CAF50; ${V.defaultFont}`,info:`color: #2196F3; ${V.defaultFont}`,warn:`color: #FF9800; ${V.defaultFont}`,error:`color: #F44336; ${V.defaultFont}`,debug:`color: #9C27B0; ${V.defaultFont}`});var I=V,pl={LOCAL:"",DEV:"https://analytics.dev.data.primer.io/v1/sdk-analytic-events",STAGING:"https://analytics.staging.data.primer.io/v1/sdk-analytic-events",SANDBOX:"https://analytics.sandbox.data.primer.io/v1/sdk-analytic-events",PRODUCTION:"https://analytics.production.data.primer.io/v1/sdk-analytic-events"},Vi=class{sendEvent(t){let e=Qi.getContext();if(!e)return void I.error("Session context not initialized. Call initializeAnalytics() first.");let r={id:Te(),timestamp:Math.floor(Date.now()/1e3),sdkType:"WEB",eventName:t.eventName,checkoutSessionId:e.checkoutSessionId,clientSessionId:e.clientSessionId,primerAccountId:e.primerAccountId,sdkVersion:e.sdkVersion,userAgent:e.userAgent,eventType:t.eventType,userLocale:t.userLocale,paymentMethod:t.paymentMethod,paymentId:t.paymentId,redirectDestinationUrl:t.redirectDestinationUrl,threedsProvider:t.threedsProvider,threedsResponse:t.threedsResponse};hl(r,e)}},ml=new Vi;function ul(i){let t={...i,userAgent:i.userAgent||(typeof navigator<"u"?navigator.userAgent:"")};Qi.initialize(t)}function $r(i){ml.sendEvent(i)}async function hl(i,{environment:t,clientSessionToken:e}){if(t==="LOCAL")return void I.debug(`Analytics event ${i.eventName}:`,i);let r=pl[t];return fetch(r,{method:"POST",headers:{"Content-Type":"application/json",...e&&{Authorization:`Bearer ${e}`}},body:JSON.stringify(i)}).catch(o=>{I.error("Failed to send analytics event:",o)})}var Ri=(function(i){return i.CARD="CARD",i.NATIVE="NATIVE",i.REDIRECT="REDIRECT",i.KLARNA="KLARNA",i.ACH="ACH",i})({}),Qo=Xi("../../node_modules/credit-card-type/dist/index.js");function eo(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 gl(i){return eo(i).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1).toLowerCase()).join(" ")}function en(i){return eo(i).join("-").toLowerCase()}function tn(i){return eo(i).join("_").toUpperCase()}var An=[["AMEX","american-express"],["CARTES_BANCAIRES"],["DANKORT"],["DINERS_CLUB","diners-club"],["DISCOVER","discover"],["ENROUTE"],["ELO","elo"],["EFTPOS"],["HIPER","hiper","hiper-pay"],["HIPERCARD","hipercard"],["INTERAC"],["JCB","jcb"],["MAESTRO","maestro"],["MASTERCARD","mastercard"],["MIR","mir","mir-pay"],["OTHER",void 0,"payment-card"],["UNIONPAY","unionpay"],["VISA","visa"]],rn=new Map(An.map(i=>[i[0],i])),fl=new Map(An.filter(i=>i[1]).map(i=>[i[1],i]));function to(i){let{niceType:t,type:e}=(0,Qo.getTypeInfo)(en(i))||(0,Qo.getTypeInfo)(rn.get(tn(i))?.[1]||"")||{},[r,o,n]=fl.get(e)||rn.get(tn(i))||[];return{asset:n||en(o||i),backend:r,display:t||gl(i),library:o}}var se={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"};var Sn="3.7.7",yl=Sn,Vt=typeof Buffer=="function",on=typeof TextDecoder=="function"?new TextDecoder:void 0,nn=typeof TextEncoder=="function"?new TextEncoder:void 0,vl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Zt=Array.prototype.slice.call(vl),Pr=(i=>{let t={};return i.forEach((e,r)=>t[e]=r),t})(Zt),bl=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,q=String.fromCharCode.bind(String),an=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):i=>new Uint8Array(Array.prototype.slice.call(i,0)),Pn=i=>i.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),xn=i=>i.replace(/[^A-Za-z0-9\+\/]/g,""),_n=i=>{let t,e,r,o,n="",a=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,n+=Zt[t>>18&63]+Zt[t>>12&63]+Zt[t>>6&63]+Zt[63&t]}return a?n.slice(0,a-3)+"===".substring(a):n},ro=typeof btoa=="function"?i=>btoa(i):Vt?i=>Buffer.from(i,"binary").toString("base64"):_n,Ui=Vt?i=>Buffer.from(i).toString("base64"):i=>{let e=[];for(let r=0,o=i.length;r<o;r+=4096)e.push(q.apply(null,i.subarray(r,r+4096)));return ro(e.join(""))},Tr=(i,t=!1)=>t?Pn(Ui(i)):Ui(i),El=i=>{if(i.length<2){var t=i.charCodeAt(0);return t<128?i:t<2048?q(192|t>>>6)+q(128|63&t):q(224|t>>>12&15)+q(128|t>>>6&63)+q(128|63&t)}var t=65536+(i.charCodeAt(0)-55296)*1024+(i.charCodeAt(1)-56320);return q(240|t>>>18&7)+q(128|t>>>12&63)+q(128|t>>>6&63)+q(128|63&t)},Cl=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Tn=i=>i.replace(Cl,El),sn=Vt?i=>Buffer.from(i,"utf8").toString("base64"):nn?i=>Ui(nn.encode(i)):i=>ro(Tn(i)),Ot=(i,t=!1)=>t?Pn(sn(i)):sn(i),ln=i=>Ot(i,!0),Al=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Sl=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 q((e>>>10)+55296)+q((1023&e)+56320);case 3:return q((15&i.charCodeAt(0))<<12|(63&i.charCodeAt(1))<<6|63&i.charCodeAt(2));default:return q((31&i.charCodeAt(0))<<6|63&i.charCodeAt(1))}},Mn=i=>i.replace(Al,Sl),wn=i=>{if(i=i.replace(/\s+/g,""),!bl.test(i))throw new TypeError("malformed base64.");i+="==".slice(2-(3&i.length));let t,e="",r,o;for(let n=0;n<i.length;)t=Pr[i.charAt(n++)]<<18|Pr[i.charAt(n++)]<<12|(r=Pr[i.charAt(n++)])<<6|(o=Pr[i.charAt(n++)]),e+=r===64?q(t>>16&255):o===64?q(t>>16&255,t>>8&255):q(t>>16&255,t>>8&255,255&t);return e},io=typeof atob=="function"?i=>atob(xn(i)):Vt?i=>Buffer.from(i,"base64").toString("binary"):wn,In=Vt?i=>an(Buffer.from(i,"base64")):i=>an(io(i).split("").map(t=>t.charCodeAt(0))),kn=i=>In(Nn(i)),Pl=Vt?i=>Buffer.from(i,"base64").toString("utf8"):on?i=>on.decode(In(i)):i=>Mn(io(i)),Nn=i=>xn(i.replace(/[-_]/g,t=>t=="-"?"+":"/")),Yi=i=>Pl(Nn(i)),xl=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)},Ln=i=>({value:i,enumerable:!1,writable:!0,configurable:!0}),Rn=function(){let i=(t,e)=>Object.defineProperty(String.prototype,t,Ln(e));i("fromBase64",function(){return Yi(this)}),i("toBase64",function(t){return Ot(this,t)}),i("toBase64URI",function(){return Ot(this,!0)}),i("toBase64URL",function(){return Ot(this,!0)}),i("toUint8Array",function(){return kn(this)})},On=function(){let i=(t,e)=>Object.defineProperty(Uint8Array.prototype,t,Ln(e));i("toBase64",function(t){return Tr(this,t)}),i("toBase64URI",function(){return Tr(this,!0)}),i("toBase64URL",function(){return Tr(this,!0)})},_l=()=>{Rn(),On()},Dn={version:Sn,VERSION:yl,atob:io,atobPolyfill:wn,btoa:ro,btoaPolyfill:_n,fromBase64:Yi,toBase64:Ot,encode:Ot,encodeURI:ln,encodeURL:ln,utob:Tn,btou:Mn,decode:Yi,isValid:xl,fromUint8Array:Tr,toUint8Array:kn,extendString:Rn,extendUint8Array:On,extendBuiltins:_l},Mr={encode:Tl,decode:Dn.decode};function Tl(i,t={}){let{urlSafe:e=!1}=t;return Dn.encode(i,e)}function Ml(i,t){return!(i.intent!==`${t}_REDIRECTION`||!("statusUrl"in i)||!("redirectUrl"in i)||!i.redirectUrl||!i.statusUrl)}function Dt(i){let t=kl(i),e=1e3*t.exp;if(Date.now()>e)throw new Error(`${wl}. Expiration date: ${new Date(e).toISOString()}`);return t}var $n="The provided `clientToken`",wl=`${$n} has expired`,Il=`${$n} is malformed`;function kl(i){try{let[t,e]=i.split("."),r=e||t;return JSON.parse(Mr.decode(r))}catch{throw new Error(Il)}}var wr=class{constructor(t,e){N(this,"context");N(this,"dialogProvider");this.context=t,this.dialogProvider=e}};function oo(){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 tr(i){return i?new Promise(t=>{setTimeout(t,i)}):Promise.resolve()}var Bi=class extends wr{async handleRequiredAction(t){let e=t.requiredAction?.clientToken;if(!e)throw new Error("No client token provided");let r=Dt(e);if(!("intent"in r)||r.intent!=="3DS_AUTHENTICATION")throw new Error("Invalid client token");let{error:o,data:n}=await this.context.pciApi.post3dsAuth(r.tokenId,{device:oo()});if(o||!n||!n.authentication)throw o??new Error("Unable to authenticate");let a=n.authentication,s=n;a.responseCode==="METHOD"&&(s=await this.handleMethod(r.tokenId,a),a=s.authentication),a.responseCode==="CHALLENGE"&&(s=await this.handleChallenge(r.tokenId,a));let l=await this.context.pciApi.postResumePayment(t.id,s.resumeToken);if(l.error||!l.data)throw l.error??new Error("Unable to resume payment");return l.data}async handleMethod(t,e){let r="primer-3ds-method-box",o="primer-3ds-method-iframe",n="primer-3ds-method-form",a="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"),u=document.createElement("input");u.type="hidden",u.id=a,u.name=a,u.value=Mr.encode(JSON.stringify({threeDSServerTransID:e.transactionId,threeDSMethodNotificationURL:e.notificationUrl}),{urlSafe:!0}).replace(/=+$/g,""),c.appendChild(u),c.id=n,c.name=n,c.action=e.acsMethodUrl,c.target=o,c.method="post",s.appendChild(c),document.body.appendChild(s),c.submit();let{data:f,error:h}=await this.pollStatus(e.statusUrl,"METHOD",1e3).promise;return s.remove(),h||!f?this.continueAuth(t):f}pollStatus(t,e="METHOD",r=1e3,o=66e4){let n=!0;return{promise:new Promise(async a=>{let s=setTimeout(()=>{n=!1,a({error:new Error("Operation timed out"),data:null})},o);try{for(;n;){let l=await this.context.pciApi.get3dsResumeStatus(t);if(l.error){clearTimeout(s),a(l);return}if(await tr(r),l.data&&l.data.authentication.responseCode!==e){clearTimeout(s),a(l);return}}}catch(l){clearTimeout(s),a({error:l,data:null})}}),abort:()=>{n=!1}}}async continueAuth(t){let{data:e,error:r}=await this.context.pciApi.post3dsContinue(t);return r||!e?{resumeToken:Te(),authentication:{responseCode:"SKIPPED",skippedReasonCode:"NEGOTIATION_ERROR",skippedReasonText:"Failed to negotiate with 3DS server"}}:e}async handleChallenge(t,e){let{container:r,formId:o}=this.createChallengeElements(e),n=()=>{let s=document.getElementById(o);s?s.submit():requestAnimationFrame(()=>{let l=document.getElementById(o);l&&l.submit()})},a=this.pollStatus(e.statusUrl,"CHALLENGE",2500,66e4);try{let s=this.dialogProvider.show({htmlContent:r.outerHTML,onContentReady:n});$r({eventName:"PAYMENT_THREEDS",threedsResponse:JSON.stringify(e)});let l=await Promise.race([a.promise,s.then(()=>null,c=>{throw a.abort(),c})]);return l&&l.data?(this.dialogProvider.close(),l.data):(this.dialogProvider.close(),this.continueAuth(t))}catch{return a.abort(),this.continueAuth(t)}}createChallengeElements(t){this.inject3DSChallengeCSS();let e=`3ds-challenge-iframe-${Te()}`,r=`3ds-challenge-form-${Te()}`,o=/^1/.test(t.protocolVersion),n=document.createElement("div");n.className="challenge-container";let a=document.createElement("form");if(a.id=r,a.className="challenge-form",a.action=t.acsChallengeUrl,a.target=e,a.method="post",o){let l=document.createElement("input");l.type="hidden",l.name="PaReq",l.id="PaReq",l.value=t.acsChallengeData||"",a.appendChild(l);let c=document.createElement("input");c.type="hidden",c.name="TermUrl",c.id="TermUrl",c.value=t.notificationUrl||"",a.appendChild(c)}else{let l=Mr.encode(JSON.stringify({threeDSServerTransID:t.transactionId,acsTransID:t.acsTransactionId,messageVersion:t.protocolVersion,messageType:"CReq",challengeWindowSize:"05"}),{urlSafe:!0}),c=document.createElement("input");c.type="hidden",c.name="creq",c.id="creq",c.value=l,a.appendChild(c);let u=document.createElement("input");u.type="hidden",u.name="threeDSSessionData",u.id="threeDSSessionData",u.value="",a.appendChild(u)}let s=document.createElement("iframe");return s.id=e,s.name=e,s.className="challenge-iframe",s.setAttribute("frameborder","0"),s.title="3D Secure Challenge",n.appendChild(a),n.appendChild(s),{container:n,formId:r}}inject3DSChallengeCSS(){let t="primer-3ds-challenge-dialog-styles";if(document.getElementById(t))return;let e=`
|
|
4
2
|
primer-dialog[size="large"] .challenge-container {
|
|
5
3
|
margin-top: 24px;
|
|
6
4
|
width: 100%;
|
|
@@ -19,7 +17,7 @@ import{a as jo,b as l,c as T}from"./chunks/chunk.DV3REKZU.js";var Ar=class{const
|
|
|
19
17
|
background-color: #ffffff;
|
|
20
18
|
flex: 1;
|
|
21
19
|
}
|
|
22
|
-
`,r=document.createElement("style");r.id=t,r.textContent=e,document.head.appendChild(r)}},
|
|
20
|
+
`,r=document.createElement("style");r.id=t,r.textContent=e,document.head.appendChild(r)}},Fi=class extends wr{async handleRequiredAction(t){let e=t.requiredAction?.clientToken;if(!e)throw new Error("No client token provided");let r=Dt(e);if(!("intent"in r)||r.intent!=="PROCESSOR_3DS")throw new Error("Invalid client token");let{statusUrl:o,redirectUrl:n}=r;if(!o||!n)throw new Error("Missing statusUrl or redirectUrl in client token");let a=await this.handleProcessor3DS(o,n);if(!a)throw new Error("Failed to get resume token from processor 3DS flow");let s=await this.context.pciApi.postResumePayment(t.id,a);if(s.error||!s.data)throw s.error??new Error("Unable to resume payment");return s.data}async handleProcessor3DS(t,e){let{container:r,setIframeSrc:o}=this.createIframeContainer(e),n=this.pollStatus(t);try{let a=this.dialogProvider.show({htmlContent:r.outerHTML,onContentReady:o}),s=await Promise.race([n.promise,a.then(()=>null,l=>{throw n.abort(),l})]);if($r({eventName:"PAYMENT_THREEDS",threedsResponse:JSON.stringify(s?.data)}),s&&s.data&&s.data.id)return this.dialogProvider.close(),s.data.id;throw this.dialogProvider.close(),new Error("Processor 3DS flow was cancelled or failed")}catch(a){throw n.abort(),this.dialogProvider.close(),a}}createIframeContainer(t){this.injectProcessor3DSCSS();let e=document.createElement("div");e.className="processor-3ds-container";let r=`processor-3ds-iframe-${Te()}`,o=document.createElement("iframe");return o.id=r,o.className="processor-3ds-iframe",o.setAttribute("frameborder","0"),o.setAttribute("allow","payment"),o.setAttribute("sandbox","allow-forms allow-scripts allow-same-origin allow-top-navigation"),o.title="Processor 3DS Authentication",e.appendChild(o),{container:e,setIframeSrc:()=>{let a=document.getElementById(r);a&&t&&(a.src=t)}}}pollStatus(t,e=100,r=72e5){let o=!0;return{promise:new Promise(async n=>{let a=setTimeout(()=>{o=!1,n({id:Te(),status:408,error:new Error("Processor 3DS operation timed out"),data:void 0,headers:{}})},r);try{for(;o;){let s=await this.context.pciApi.getResumeStatus(t);if(s.error){clearTimeout(a),n(s);return}if(s.data&&s.data.id){let l=s.data;if(l.status&&l.status!=="PENDING"){clearTimeout(a),n(s);return}}await tr(e)}}catch(s){clearTimeout(a),n({id:Te(),status:500,error:s instanceof Error?s:new Error("Unknown error"),data:void 0,headers:{}})}}),abort:()=>{o=!1}}}injectProcessor3DSCSS(){let t="primer-processor-3ds-dialog-styles";if(document.getElementById(t))return;let e=`
|
|
23
21
|
primer-dialog[size="large"] .processor-3ds-container {
|
|
24
22
|
margin-top: 24px;
|
|
25
23
|
width: 100%;
|
|
@@ -38,10 +36,10 @@ import{a as jo,b as l,c as T}from"./chunks/chunk.DV3REKZU.js";var Ar=class{const
|
|
|
38
36
|
background-color: #ffffff;
|
|
39
37
|
flex: 1;
|
|
40
38
|
}
|
|
41
|
-
`,r=document.createElement("style");r.id=t,r.textContent=e,document.head.appendChild(r)}},pd={CONTAINER_NOT_FOUND:"CONTAINER_NOT_FOUND"},si={MISSING_PARAMETER:"MISSING_PARAMETER",INVALID_PARAMETER:"INVALID_PARAMETER",INVALID_USAGE:"INVALID_USAGE"},we={UNAUTHORIZED:"UNAUTHORIZED",FORBIDDEN:"FORBIDDEN",NOT_FOUND:"NOT_FOUND",CONFLICT:"CONFLICT",REQUEST_TIMEOUT:"REQUEST_TIMEOUT",VALIDATION_ERROR:"REQUEST_VALIDATION_ERROR",SERVER_ERROR:"SERVER_ERROR",BAD_REQUEST:"BAD_REQUEST",REQUEST_ERROR:"REQUEST_ERROR",UNEXPECTED:"UNEXPECTED"},H={PAYMENT_CREATION_ABORTED:"PAYMENT_CREATION_ABORTED",PAYMENT_FAILED:"PAYMENT_FAILED",RESUME_FAILED:"RESUME_FAILED",TOKENIZATION_ERROR:"TOKENIZATION_ERROR"},li={MISSING_CLIENT_TOKEN:"MISSING_CLIENT_TOKEN",INVALID_CLIENT_TOKEN:"INVALID_CLIENT_TOKEN"},ri={VAULT_ERROR:"VAULT_ERROR",TOKENIZATION_ERROR:"TOKENIZATION_ERROR"},ko=(function(i){return i.REQUEST_ERROR="RequestError",i.TOKENIZATION_ERROR="TokenizationError",i.CLIENT_ERROR="ClientError",i.REQUEST_VALIDATION_ERROR="RequestValidationError",i.CONFIGURATION_ERROR="ConfigurationError",i.PCI_ERROR="PciError",i})({}),hr=class extends Error{constructor(e,r,o,a){super(r);T(this,"code");T(this,"error");this.name=e,this.code=o,this.error=a}toJSON(){return{name:this.name,message:this.message,code:this.code,stack:this.stack}}},It=class extends hr{constructor({message:e,error:r,response:o,code:a=we.REQUEST_ERROR}){let n=r??new Error(e);super(ko.REQUEST_ERROR,e,a,n);T(this,"response");this.response=o}toJSON(){return{name:this.name,message:this.message,response:this.response,code:this.code,stack:this.stack}}},te=class extends hr{constructor({message:e,error:r,code:o=we.UNEXPECTED,suggestion:a,paymentMethod:n}){let s=r??new Error(e);super(ko.TOKENIZATION_ERROR,e,o,s);T(this,"suggestion");T(this,"paymentMethod");this.suggestion=a,this.paymentMethod=n}toJSON(){return{name:this.name,message:this.message,code:this.code,paymentMethod:this.paymentMethod,suggestion:this.suggestion,stack:this.stack}}},B=class extends hr{constructor({message:e,error:r,code:o=we.UNEXPECTED,suggestion:a,paymentMethod:n}){let s=r??new Error(e);super(ko.CLIENT_ERROR,e,o,s);T(this,"suggestion");T(this,"paymentMethod");this.suggestion=a,this.paymentMethod=n}toJSON(){return{name:this.name,message:this.message,code:this.code,paymentMethod:this.paymentMethod,suggestion:this.suggestion,stack:this.stack}}},ut=class{constructor(t,e){T(this,"config");T(this,"context");this.config=Object.freeze(t),this.context=e}async tokenizeVaulted(t){let{error:e,data:r}=await this.context.pciApi.postPaymentInstrumentsExchange(t);if(e||!r)throw e??new B({code:H.TOKENIZATION_ERROR,message:"Unable to tokenize vaulted payment method",paymentMethod:this.config.type});return r}async setup(){return!0}async start(){}async render(t){N.warn(`Render not implemented for ${this.config.type}`)}async handleRequiredAction(t,e){return t.requiredAction?.name==="3DS_AUTHENTICATION"?new uo(this.context,e).handleRequiredAction(t):t.requiredAction?.name==="PROCESSOR_3DS"?new ho(this.context,e).handleRequiredAction(t):t}async createPayment(t){let{error:e,data:r}=await this.context.pciApi.postCreatePayment(t);if(e||!r)throw e??new B({code:H.PAYMENT_FAILED,message:"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 B({code:H.RESUME_FAILED,message:"Unable to resume payment"});return o}};function md(i){return i&&i.includes("_")?i.split("_").join("-"):i}var ud=JSON.parse('{"USD":{"b":2},"CAD":{"b":2},"EUR":{"b":2},"AED":{"b":2},"AFN":{"b":0},"ALL":{"b":0},"AMD":{"b":0},"ARS":{"b":2},"AUD":{"b":2},"AZN":{"b":2},"BAM":{"b":2},"BDT":{"b":2},"BGN":{"b":2},"BHD":{"b":3},"BIF":{"b":0},"BND":{"b":2},"BOB":{"b":2},"BRL":{"b":2},"BWP":{"b":2},"BYN":{"b":2},"BZD":{"b":2},"CDF":{"b":2},"CHF":{"b":2},"CLP":{"b":0},"CNY":{"b":2},"COP":{"b":2},"CRC":{"b":2},"CVE":{"b":2},"CZK":{"b":2},"DJF":{"b":0},"DKK":{"b":2},"DOP":{"b":2},"DZD":{"b":2},"EEK":{"b":2},"EGP":{"b":2},"ERN":{"b":2},"ETB":{"b":2},"GBP":{"b":2},"GEL":{"b":2},"GHS":{"b":2},"GNF":{"b":0},"GTQ":{"b":2},"HKD":{"b":2},"HNL":{"b":2},"HRK":{"b":2},"HUF":{"b":2},"IDR":{"b":2},"ILS":{"b":2},"INR":{"b":2},"IQD":{"b":0},"IRR":{"b":0},"ISK":{"b":0},"JMD":{"b":2},"JOD":{"b":3},"JPY":{"b":0},"KES":{"b":2},"KHR":{"b":2},"KMF":{"b":0},"KRW":{"b":0},"KWD":{"b":3},"KZT":{"b":2},"LBP":{"b":0},"LKR":{"b":2},"LTL":{"b":2},"LVL":{"b":2},"LYD":{"b":3},"MAD":{"b":2},"MDL":{"b":2},"MGA":{"b":0},"MKD":{"b":2},"MMK":{"b":0},"MOP":{"b":2},"MUR":{"b":0},"MXN":{"b":2},"MYR":{"b":2},"MZN":{"b":2},"NAD":{"b":2},"NGN":{"b":2},"NIO":{"b":2},"NOK":{"b":2},"NPR":{"b":2},"NZD":{"b":2},"OMR":{"b":3},"PAB":{"b":2},"PEN":{"b":2},"PHP":{"b":2},"PKR":{"b":0},"PLN":{"b":2},"PYG":{"b":0},"QAR":{"b":2},"RON":{"b":2},"RSD":{"b":2},"RUB":{"b":2},"RWF":{"b":0},"SAR":{"b":2},"SDG":{"b":2},"SEK":{"b":2},"SGD":{"b":2},"SOS":{"b":0},"SYP":{"b":0},"THB":{"b":2},"TND":{"b":3},"TOP":{"b":2},"TRY":{"b":2},"TTD":{"b":2},"TWD":{"b":2},"TZS":{"b":0},"UAH":{"b":2},"UGX":{"b":0},"UYU":{"b":2},"UZS":{"b":0},"VEF":{"b":2},"VND":{"b":0},"XAF":{"b":0},"XOF":{"b":0},"YER":{"b":0},"ZAR":{"b":2},"ZMK":{"b":0},"ZWL":{"b":0}}'),hd=2,fd=ud;function gd(i){if(!i)return null;let t=fd[i];return t?{decimalDigits:t.b}:null}function xn(i,t,e){let r=md(i),o=gd(e)?.decimalDigits??hd;function a(n){return new Intl.NumberFormat(r,{style:"currency",currency:e,currencyDisplay:n}).format(t/10**o)}try{return a("narrowSymbol")}catch{return a("symbol")}}function fo(i,t){return xn("en",i,t).replace(/[^0-9.]/g,"").replace(/(\..*)\./g,"$1")}var Ga=5,di=class extends ut{constructor(){super(...arguments);T(this,"applePaySession",null);T(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)return N.warn("Apple Pay is not available in this browser context"),!1;if(!ApplePaySession.supportsVersion(Ga))return N.warn("Apple Pay version not supported by this device"),!1;if(!ApplePaySession.canMakePayments())return N.warn("This device cannot make Apple Pay payments"),!1;let e=window.location.hostname;if(!(this.config.options.merchantDomains||[]).includes(e))return N.warn(`Apple Pay has not been configured for domain "${e}"`),!1}catch(e){return N.errorWithDatadog("Failed to initialize Apple Pay",{error:e}),!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(Ga,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(e){N.errorWithDatadog("Error initiating Apple Pay session",{error:e})}}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(r){N.warn("Apple Pay merchant validation failed:",r),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:fo(e??r,o),type:"final"}})}catch(e){N.errorWithDatadog("Error handling payment method selection",{error:e}),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,this.context.dialogProvider);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(r){N.errorWithDatadog("Error handling payment authorization",{error:r}),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=fo(o??a,r);return{countryCode:e,currencyCode:r,merchantCapabilities:["supports3DS"],supportedNetworks:n,total:{amount:s,label:this.config.options.merchantName,type:"pending"}}}},ci=class extends ut{constructor(){super(...arguments);T(this,"blikCode","")}setBlikCode(e){this.blikCode=e}getBlikCode(){return this.blikCode}clearBlikCode(){this.blikCode=""}async tokenize(){if(!/^\d{6}$/.test(this.blikCode))throw new te({message:"BLIK code must be exactly 6 digits",code:H.TOKENIZATION_ERROR,paymentMethod:this.config.type});let e=this.detectPlatform(),r={type:"OFF_SESSION_PAYMENT",paymentMethodType:this.config.type,paymentMethodConfigId:this.config.id,sessionInfo:{locale:this.context.locale||"en",platform:e,browserInfo:Mo(),blikCode:this.blikCode}};try{let{error:o,data:a}=await this.context.pciApi.postPaymentInstruments(r);if(this.clearBlikCode(),o||!a)throw o??new te({message:"Unable to tokenize BLIK payment method",code:H.TOKENIZATION_ERROR,paymentMethod:this.config.type});return a}catch(o){throw this.clearBlikCode(),o}}async handleRequiredAction(e,r){let o=await super.handleRequiredAction(e,r);if(o.id!==e.id)return o;let a=e.requiredAction?.clientToken;if(!a)throw new It({message:"No client token provided for BLIK payment",code:li.MISSING_CLIENT_TOKEN,response:{id:e.id,data:e}});let n=Yt(a);if(!this.isValidBlikClientToken(n))throw new It({message:"Invalid BLIK client token: missing statusUrl or incorrect intent",code:li.INVALID_CLIENT_TOKEN,response:{id:e.id,data:e}});let{promise:s,abort:d}=this.pollStatus(n.statusUrl),c=await s;if(d(),"error"in c)throw c.error;let u=c.id;if(!u){let g=await this.context.pciApi.getResumeStatus(n.statusUrl);if(g.error||!g.data?.id)throw g.error??new Error("Unable to get resume token");u=g.data.id}return await this.resumePayment(e.id,u)}pollStatus(e){let r=!0,o=1e3,a=864e5,n=Date.now();return{promise:new Promise(async s=>{for(;r;){if(Date.now()-n>=a)return void s({error:new Error("BLIK payment polling timed out after 24 hours")});let{data:d,error:c}=await this.context.pciApi.getResumeStatus(e);if(c)return void s({error:c instanceof Error?c:new Error(String(c))});if(d?.status==="COMPLETE")return void s({id:d.id});await fr(o)}}),abort:()=>{r=!1}}}detectPlatform(){let e=window.navigator.userAgent.toLowerCase();return["android","webos","iphone","ipad","ipod","blackberry","windows phone"].some(a=>e.includes(a))?"MOBILE_WEB":"WEB"}isValidBlikClientToken(e){if(typeof e!="object"||e===null)return!1;let r=e;return!(r.intent!=="ADYEN_BLIK_REDIRECTION"||!("statusUrl"in r)||typeof r.statusUrl!="string"||!r.statusUrl)}},Sn="https://sdk.primer.io/web/hosted-pages/v0.0.16",go=!1,yd=`${Sn}/api-controller.html`,vd=`${Sn}/hosted-input.html`,bd="https://goat-assets.production.core.primer.io";function Pn(i,t){return btoa(JSON.stringify({checkoutSessionId:i,name:t}))}So("../../node_modules/card-validator/dist/index.js");var ne={cardNumber:"cardNumber",cardSecurityCode:"cardSecurityCode",cardExpiryDate:"cardExpiryDate",cardholderName:"cardholderName"},Wa="cardSecurityCodeRecapture";Object.values(ne);function Cd(i){return{cardNumber:mr(i,ne.cardNumber),cardSecurityCode:mr(i,ne.cardSecurityCode),cardExpiryDate:mr(i,ne.cardExpiryDate),cardholderName:mr(i,ne.cardholderName)}}function mr(i,t){let e=document.createElement("iframe"),r=Pn(i,t);return e.src=`${vd}#${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 pi=class extends ut{constructor(e,r){super(e,r);T(this,"iframes");this.iframes=Cd(r.checkoutSessionId)}async tokenize(){let{error:e,data:r}=await this.context.pciApi.postPaymentInstruments("pci-card-form-data");if(e||!r)throw e??new te({code:H.TOKENIZATION_ERROR,message:"Unable to tokenize payment method",paymentMethod:se.PAYMENT_CARD});return r}};function Ed(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 qa=2,Ja=0,mi=class extends ut{constructor(){super(...arguments);T(this,"client");T(this,"callbacks",{onStart:()=>{},onError:()=>{},onSuccess:()=>{}});T(this,"allowedPaymentMethod",{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"]}})}setCallbacks(e){this.callbacks=e}async tokenize(){throw new te({code:H.TOKENIZATION_ERROR,message:"Google Pay does not support direct tokenization",paymentMethod:se.GOOGLE_PAY})}async setup(){try{await Ed("https://pay.google.com/gp/p/js/pay.js")}catch{return!1}if(!window.google||!window.google.payments)return N.error("Google Pay is not available in this browser context"),!1;if(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;if(!e)throw new B({code:si.MISSING_PARAMETER,message:"Cannot initialize Google Pay: missing country code",paymentMethod:se.GOOGLE_PAY});if(!r)throw new B({code:si.MISSING_PARAMETER,message:"Cannot initialize Google Pay: missing currency code",paymentMethod:se.GOOGLE_PAY});return!0}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:ai.encode(r.paymentMethodData.tokenizationData.token)});if(a||!o)throw a??new te({code:H.TOKENIZATION_ERROR,message:"Failed to tokenize payment data",paymentMethod:se.GOOGLE_PAY});let n=await this.createPayment(o.token);n.status==="SUCCESS"?this.callbacks.onSuccess(n):this.callbacks.onError()}catch(e){throw this.callbacks.onError(),N.errorWithDatadog("Google Pay error",{error:e}),e}}async handlePaymentDataChanged(e){return{}}buildIsReadyToPayRequest(){return{apiVersion:qa,apiVersionMinor:Ja,allowedPaymentMethods:[this.allowedPaymentMethod]}}buildPaymentDataRequest(){let{countryCode:e,currencyCode:r,merchantAmount:o,totalOrderAmount:a}=this.context.configuration.clientSession.order;return{apiVersion:qa,apiVersionMinor:Ja,transactionInfo:{countryCode:e,currencyCode:r,displayItems:[],totalPriceStatus:"FINAL",totalPrice:fo(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}}}]}}};function Ad(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 xd(i,t){var e=document.querySelector('script[src="'.concat(i,'"]'));if(e===null)return null;var r=_n(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 Sd(i){var t=i.url,e=i.attributes,r=i.onSuccess,o=i.onError,a=_n(t,e);a.onerror=o,a.onload=r,document.head.insertBefore(a,document.head.firstElementChild)}function Pd(i){var t=i.sdkBaseUrl,e=i.environment,r=Ad(i,["sdkBaseUrl","environment"]),o=t||Td(e),a=r,n=Object.keys(a).filter(function(c){return a[c]!==void 0&&a[c]!==null&&a[c]!==""}).reduce(function(c,u){var g=a[u].toString();return u=_d(u),u.substring(0,4)==="data"||u==="crossorigin"?c.attributes[u]=g:c.queryParams[u]=g,c},{queryParams:{},attributes:{}}),s=n.queryParams,d=n.attributes;return s["merchant-id"]&&s["merchant-id"].indexOf(",")!==-1&&(d["data-merchant-id"]=s["merchant-id"],s["merchant-id"]="*"),{url:"".concat(o,"?").concat(wd(s)),attributes:d}}function _d(i){var t=function(e,r){return(r?"-":"")+e.toLowerCase()};return i.replace(/[A-Z]+(?![a-z])|[A-Z]/g,t)}function wd(i){var t="";return Object.keys(i).forEach(function(e){t.length!==0&&(t+="&"),t+=e+"="+i[e]}),t}function Td(i){return i==="sandbox"?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js"}function _n(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 Md(i,t){if(t===void 0&&(t=Promise),wn(i,t),typeof document>"u")return t.resolve(null);var e=Pd(i),r=e.url,o=e.attributes,a=o["data-namespace"]||"paypal",n=Za(a);return o["data-js-sdk-library"]||(o["data-js-sdk-library"]="paypal-js"),xd(r,o)&&n?t.resolve(n):kd({url:r,attributes:o},t).then(function(){var s=Za(a);if(s)return s;throw new Error("The window.".concat(a," global variable is not available."))})}function kd(i,t){t===void 0&&(t=Promise),wn(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();Sd({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 Za(i){return window[i]}function wn(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 ii=new Map,Xa={getOrCreateNamespace(i){let t=ii.get(i);return t?t.namespace:Te()},getInstance(i){return ii.get(i)?.instance??null},storeInstance(i,t,e){ii.set(i,{instance:t,namespace:e})},hasInstance(i){return ii.has(i)}};async function Id({context:i,configId:t,paymentMethodType:e,callbacks:r}){try{r.onStart(),await i.clientSessionApi.selectPaymentMethod(e);let{data:o,error:a}=await i.coreApi.createPaypalBillingAgreement({paymentMethodConfigId:t});if(a||!o){let n=a?.message??"Failed to create billing agreement";throw new B({message:n,code:H.PAYMENT_FAILED,paymentMethod:e})}return o.tokenId}catch(o){throw N.errorWithDatadog("PayPal billing agreement creation failed:",{error:o}),r.onError(),o instanceof B||o instanceof te?o:new B({message:"Failed to create billing agreement",code:H.PAYMENT_FAILED,paymentMethod:e})}}async function Nd({context:i,configId:t,paymentMethodType:e,callbacks:r,createPayment:o,data:a,actions:n}){try{let s=a.billingToken;if(!s)throw new te({message:"Billing token not provided",code:H.TOKENIZATION_ERROR,paymentMethod:e});let{data:d,error:c}=await i.coreApi.confirmPaypalBillingAgreement({paymentMethodConfigId:t,tokenId:s});if(c||!d){let w=c?.message??"Failed to confirm billing agreement";throw new te({message:w,code:H.TOKENIZATION_ERROR,paymentMethod:e})}let u=d,g={paypalBillingAgreementId:u.billingAgreementId,shippingAddress:u.shippingAddress,externalPayerInfo:u.externalPayerInfo},{error:f,data:x}=await i.pciApi.postPaymentInstruments(g,{tokenType:"MULTI_USE",paymentFlow:"VAULT"});if(f||!x){let w=f?.message??"Unable to vault PayPal payment method";throw new te({message:w,code:H.TOKENIZATION_ERROR,paymentMethod:e})}let I=await o(x.token);r.onSuccess(I)}catch(s){throw N.errorWithDatadog("PayPal billing agreement approval failed:",{error:s}),r.onError(),s instanceof te||s instanceof B?s:new te({message:"Failed to approve billing agreement",code:H.TOKENIZATION_ERROR,paymentMethod:e})}}var Ld="gold",Rd="rect",Od="paypal",Dd="vertical",$d="horizontal";function Vd(i){return{color:i?.color??Ld,shape:i?.shape??Rd,label:i?.label??Od,layout:i?.layout??(i?.tagline?$d:Dd),tagline:i?.tagline??!1,...i?.height&&{height:i.height},...i?.borderRadius!==void 0&&{borderRadius:i.borderRadius},...i?.disableMaxWidth!==void 0&&{disableMaxWidth:i.disableMaxWidth}}}function Ud(i,t,e,r){let o={style:i,onInit:e.onInit,onClick:e.onClick,onCancel:e.onCancel,onError:e.onError};return t&&r?(o.createBillingAgreement=r.createBillingAgreement,o.onApprove=r.onApprove):o.onApprove=e.onApprove,o}function Bd(i){if(!i)return;let t={first_name:i.firstName,last_name:i.lastName,address_line_1:i.addressLine1??"",address_line_2:i.addressLine2,city:i.city??"",state:i.state,postal_code:i.postalCode??"",country_code:i.countryCode??""},{address_line_1:e,city:r,postal_code:o,country_code:a}=t;if(!(!e||!r||!o||!a))return t}function Yd(i){if(!i)return null;let t=i.purchase_units?.[0]?.shipping;if(!t?.address)return null;let e=t.address,r=t.name;return{firstName:r?.given_name,lastName:r?.surname,addressLine1:e.address_line_1,addressLine2:e.address_line_2,city:e.admin_area_2,state:e.admin_area_1,postalCode:e.postal_code,countryCode:e.country_code}}function Hd(i,t,e){let{order:{currencyCode:r,merchantAmount:o,totalOrderAmount:a,shipping:n,lineItems:s=[],fees:d=[]},customer:c}=i;if(!r)throw new B({message:"Currency code is not provided",code:si.MISSING_PARAMETER,paymentMethod:e});let u={amount:o??a,currencyCode:r,paymentMethodConfigId:t,amountBreakdown:{}},g=c?.shippingAddress,f=Bd(g);f&&(u.shipping_address=f);let x=!s.some(I=>!I.name&&!I.description);if(x&&(u.items=s.map(I=>{let{name:w,description:M,taxAmount:S,amount:L,quantity:U}=I,Pe=S?Math.floor(S/U):0;return{name:M||w||"",unit_amount:{value:L,currency_code:r},quantity:U.toString(),tax:{value:Pe,currency_code:r}}})),x&&s.length){let I=s.reduce((Ce,{amount:Ct,quantity:Ko})=>Ce+Ct*Ko,0),w=d?.reduce?.((Ce,{amount:Ct})=>Ce+(Ct??0),0),M=s?.reduce((Ce,{discountAmount:Ct})=>Ce+(Ct??0),0),S=s?.reduce((Ce,{taxAmount:Ct})=>Ce+(Ct??0),0),L=n?.amount??0,U=w??0,Pe=I+S+L+U-M;u.amountBreakdown={item_total:{value:I,currency_code:r},tax_total:{value:S,currency_code:r},handling:{value:U,currency_code:r},shipping:{value:L,currency_code:r},discount:{value:M,currency_code:r}},u.amount=Pe}return u}async function Fd({context:i,configId:t,paymentMethodType:e,callbacks:r}){try{r.onStart(),await i.clientSessionApi.selectPaymentMethod(e);let{data:o,error:a}=await i.coreApi.createPaypalOrder(Hd(i.configuration.clientSession,t,e));if(a||!o){let n=a?.message??"Unable to create PayPal order";throw new B({message:n,code:H.PAYMENT_FAILED,paymentMethod:e})}return o.orderId}catch(o){throw r.onError(),o}}async function zd({context:i,paymentMethodType:t,callbacks:e,createPayment:r,data:o,actions:a}){let n=null;try{n=await a?.order?.get()??null}catch(f){N.warn("Failed to get PayPal order details",f)}let s=Yd(n),d={external_payer_info:{email:n?.payer?.email_address,external_payer_id:o.payerID??void 0,first_name:n?.payer?.name?.given_name,last_name:n?.payer?.name?.surname},paypal_order_id:o.orderID,paypal_status:n?.status};s&&(d.shipping_address=s);let{error:c,data:u}=await i.pciApi.postPaymentInstruments(d);if(c||!u){let f=c?.message??"Unable to create payment instrument";throw new te({message:f,code:H.TOKENIZATION_ERROR,paymentMethod:t})}let g=await r(u.token);e.onSuccess(g)}var Kd=["buttons","funding-eligibility"],Qa=[],jd="authorize";function Gd(i,t,e){return(i??t==="PREFER_VAULT")&&e}function en({isVaultFlow:i,configIntent:t}){return i?"tokenize":t??jd}function Wd(i,t,e,r){let{clientId:o,intent:a}=t.options,n=i.configuration.clientSession.order.currencyCode,s=i.paymentMethodOptions?.paypal?.disableFunding??(Qa.length>0?Qa:void 0),d={dataNamespace:e,clientId:o,currency:n,components:Kd,...s&&s.length>0?{disableFunding:s}:{},enableFunding:i.paymentMethodOptions?.paypal?.enableFunding,integrationDate:i.paymentMethodOptions?.paypal?.integrationDate,debug:i.paymentMethodOptions?.paypal?.debug};return(go||i.decodedClientToken.env==="SANDBOX")&&(d.buyerCountry=i.paymentMethodOptions?.paypal?.buyerCountry),r?(d.vault="true",d.intent=en({isVaultFlow:!0,configIntent:a})):(d.vault="false",d.intent=en({isVaultFlow:!1,configIntent:a})),d}var ui=class extends ut{constructor(e,r){super(e,r);T(this,"paypalInstance");T(this,"dataNamespace");T(this,"callbacks",{onStart:()=>{},onError:()=>{},onSuccess:()=>{}});T(this,"isVaultFlow",!1);T(this,"isSetupComplete",!1);T(this,"setupPromise");this.dataNamespace=Xa.getOrCreateNamespace(e.id),this.context.onClientConfigurationUpdate(async()=>{N.info("PayPal: Client session updated, refreshing PayPal buttons");try{await this.setup()}catch(o){N.warn("PayPal: Failed to refresh on client session update:",o)}})}setCallbacks(e){this.callbacks=e}async tokenize(){throw new te({message:"PayPal does not support direct tokenization",code:H.TOKENIZATION_ERROR,paymentMethod:se.PAYPAL})}async setup(){let{clientId:e}=this.config.options;return this.setupPromise?(N.info("PayPal setup already in progress, waiting..."),this.setupPromise):this.isSetupComplete&&this.paypalInstance?.Buttons?(N.info("PayPal setup already completed, skipping"),!0):e?(this.setupPromise=(async()=>{try{let r=this.context.paymentMethodOptions?.paypal?.vault,o=this.context.paymentMethodOptions?.paypal?.paymentFlow,a=this.context.configuration.clientSession.paymentMethod?.vaultOnSuccess??!1;this.isVaultFlow=Gd(r,o,a);let n=Wd(this.context,this.config,this.dataNamespace,this.isVaultFlow);N.debug("%c PAYPAL %c Script Configuration ","background: #0070BA; color: #ffffff; font-weight: bold; padding: 4px 12px; border-radius: 3px 0 0 3px; font-size: 14px;","background: #003087; color: #ffffff; padding: 4px 12px; border-radius: 0 3px 3px 0; font-size: 14px;",n);let s=await Md(n);return s?(this.paypalInstance=s,Xa.storeInstance(this.config.id,s,this.dataNamespace),!0):(N.warn("Failed to load PayPal SDK"),!1)}catch(r){return N.errorWithDatadog("PayPal setup failed:",{error:r}),this.setupPromise=void 0,!1}})(),this.setupPromise):(N.warn("PayPal clientId is required"),!1)}async render(e){if(!this.paypalInstance.Buttons)throw new B({message:"PayPal Buttons component not available",code:si.INVALID_USAGE,paymentMethod:se.PAYPAL});let r=this.context.paymentMethodOptions?.paypal?.style,o=Vd(r),a=Ud(o,this.isVaultFlow,{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)},this.isVaultFlow?{createBillingAgreement:()=>Id({context:this.context,configId:this.config.id,paymentMethodType:this.config.type,callbacks:this.callbacks}),onApprove:(s,d)=>Nd({context:this.context,configId:this.config.id,paymentMethodType:this.config.type,callbacks:this.callbacks,createPayment:this.createPayment.bind(this),data:s,actions:d})}:void 0);this.isVaultFlow||(a.createOrder=this.handleCreateOrder.bind(this)),await this.paypalInstance.Buttons(a).render(e)}handleInit(e,r){let{clientSession:o}=this.context.configuration,a=!!o.order.currencyCode,n=!!o.order.totalOrderAmount||!!o.order.merchantAmount;if(!a||!n){N.warn("PayPal button disabled: missing currency or amount"),r.disable();return}r.enable()}handleClick(e,r){return hi({eventName:"PAYMENT_METHOD_SELECTION",paymentMethod:"PAYPAL"}),r.resolve()}async handleCreateOrder(){return Fd({context:this.context,configId:this.config.id,paymentMethodType:this.config.type,callbacks:this.callbacks})}async handleApprove(e,r){return zd({context:this.context,paymentMethodType:this.config.type,callbacks:this.callbacks,createPayment:this.createPayment.bind(this),data:e,actions:r})}handleCancel(){this.context.clientSessionApi.unselectPaymentMethod(),this.callbacks.onError()}handleError(e){N.errorWithDatadog("PayPal error:",e),this.callbacks.onError()}};async function qd(i,t,e){try{hi({eventName:"PAYMENT_PROCESSING_STARTED",paymentMethod:i.config.type}),e||await i.start();let r=e?await i.tokenizeVaulted(e.id):await i.tokenize(),o=await i.createPayment(r.token);return await i.handleRequiredAction(o,t)}catch(r){throw r}}var yo=(i,t,e)=>{let r=e;if(t?.status==="FAILED"&&(r=new B({code:H.PAYMENT_FAILED,message:`The payment "${t.id}" was created but failed to be processed. Check the payment id ${t.id} using the Payments API or search for the payment on your Dashboard for further explanations.`})),t?.checkoutOutcome==="CHECKOUT_FAILURE"&&(r=new B({code:H.PAYMENT_FAILED,message:`The payment "${t.id}" was created but failed to be processed. Check the payment id ${t.id} using the Payments API or search for the payment on your Dashboard for further explanations.`})),t?.status==="PENDING"&&!t.requiredAction?.clientToken&&(r=new B({code:H.PAYMENT_FAILED,message:`The payment "${t.id}" ended up in a "PENDING" state without any required action. The SDK does not know how to handle this state. Check the payment id ${t.id} using the Payments API or search for the payment on your Dashboard for further explanations.`})),t?.status==="SUCCESS"&&t.checkoutOutcome!=="CHECKOUT_FAILURE"||t?.status==="PENDING"&&t.showSuccessCheckoutOnPendingPayment||t?.checkoutOutcome==="CHECKOUT_COMPLETE")return void i.onCheckoutComplete?.({payment:t});i.onCheckoutFail?.(r||new B({code:H.PAYMENT_FAILED,message:`The payment${t?.id?` "${t.id}"`:""} is in an inconsistent state without any required action. The SDK does not know how to handle this state. Please contact Primer.`}),{payment:t??void 0})},Jd=async(i,t)=>{if(!i.onBeforePaymentCreate)return!0;let e=setTimeout(()=>{N.warn("onBeforePaymentCreate did not resolve within 10 seconds. Primer SDK will remain in a loading state until `continuePaymentCreation` or `abortPaymentCreation` is called.")},1e4);return new Promise(r=>{i.onBeforePaymentCreate({paymentMethodType:t},{continuePaymentCreation:()=>{clearTimeout(e),N.log(`Continuing payment creation for ${t}`),r(!0)},abortPaymentCreation:()=>{clearTimeout(e),N.log(`Aborting payment creation for ${t}`),r(!1)}})})};async function fi(i,t,e){if(!await Jd(i,t.config.type))return void i.onCheckoutFail?.(new B({message:"Payment creation aborted",code:H.PAYMENT_CREATION_ABORTED,paymentMethod:t.config.type}),{});i.onPaymentCreationStart?.();let o,a;try{a=await qd(t,t.context.dialogProvider,e)}catch(n){o=n}finally{yo(i,a,o)}}var tn=Symbol("PROXY_MARKER");function Io({namespace:i,onMessage:t,sendMessage:e}){function r(o,a){return new Proxy(o,{get(n,s,d){if(s==="then")return null;if(n[tn])return Reflect.get(n,s,d);let c=()=>{};return c[tn]=!0,r(c,[...a,s])},apply(n,s,d){return new Promise(async(c,u)=>{try{let g=[],f=d.map(M=>{if(typeof M!="function")return M;{let S=Te();return g.push(S),t(L=>{L.namespace===i&&L.sender===lo.PROVIDER&&L.type===so.CALLBACK&&L.id===S&&M(...L.data)}),S}}),x=Te(),I=t(M=>{M.namespace===i&&M.sender===lo.PROVIDER&&M.type===so.APPLY&&M.id===x&&(M.error?u(new Error(M.error)):c(M.data),I?.())}),w={type:so.APPLY,sender:lo.INJECTOR,id:x,path:a,args:f,callbackIds:g,timeStamp:Date.now(),namespace:i};e(w)}catch(g){u(g)}})}})}return r({},[])}var so={APPLY:"apply",CALLBACK:"callback"},lo={PROVIDER:"provider",INJECTOR:"injector"};function vo(i,t){let e=t?.input?.base?.height;e&&(i.style.height=typeof e=="number"?`${e}px`:e)}function Zd(i,t,e,r={}){let o=[],a="LOCAL",n={[ne.cardNumber]:void 0,[ne.cardExpiryDate]:void 0,[ne.cardSecurityCode]:void 0,[ne.cardholderName]:void 0},s=!1;t.subscribeToTeardown(()=>{s=!0});let d={createHostedInputs:()=>{let c=u=>{let g=new Map;return{getOptions:()=>{},setOptions:f=>{vo(e.iframes[u],f.style),n[u]?.setOptions(f)},render:(f,x)=>{let I=e.iframes[u];if(!I)return N.errorWithDatadog(`No iframe found for ${u}`),Promise.resolve();let w;return w=typeof f=="string"?document.getElementById(f):f,w?(vo(I,x.style),w.appendChild(I),new Promise(M=>{I.onload=()=>{if(s){N.warn(`Teardown was already called, aborting render for ${u}`),I.remove(),M();return}n[u]=Io({namespace:`${t.checkoutSessionId}-${u}`,onMessage:S=>{let L=U=>S(U.data);return window.addEventListener("message",L),()=>window.removeEventListener("message",L)},sendMessage:S=>{I.contentWindow.postMessage(S,"*")}}),n[u].setOptions({...x,orderedAllowedCardNetworks:t.configuration.clientSession.paymentMethod.orderedAllowedCardNetworks,cardholderName:i.cardholderName??i.card?.cardholderName}),n[u].setOnBlur(()=>{try{g.get("blur")?.()}catch(S){N.errorWithDatadog(`Blur listener error for ${u}`,{error:S})}}),n[u].setOnFocus(()=>{try{g.get("focus")?.()}catch(S){N.errorWithDatadog(`Focus listener error for ${u}`,{error:S})}}),n[u].setOnInput(S=>{let L={...S,errorCode:S.error,active:S.focused};try{g.get("input")?.(L),g.get("change")?.(L)}catch(U){N.errorWithDatadog(`Input listener error for ${u}`,{error:U})}}),n[u].setOnEnter(()=>{try{g.get("enter")?.()}catch(S){N.errorWithDatadog(`Enter listener error for ${u}`,{error:S})}}),u===ne.cardNumber&&(n[u].setBinDataApiConfig(t.configuration.binDataUrl,t.decodedClientToken.accessToken),n[u].setOnCardNetworksChange((S,L)=>{(L!==a||Xd(o,S))&&(o=S,a=L,r.onCardNetworksChange?.(Qd({networks:o,source:a},t.configuration.clientSession.paymentMethod.orderedAllowedCardNetworks)))}))},M()})):(N.error(`Container not found for ${u}:`,f),Promise.resolve())},addEventListener:(f,x)=>{g.set(f,x)},focus:()=>{let f=e.iframes[u];if(f&&f.contentWindow)try{n[u]?.focus()}catch(x){N.errorWithDatadog(`Focus send error for ${u}`,{error:x})}else N.warn(`Focus failed for ${u} - iframe not available`)},blur:()=>{let f=e.iframes[u];if(f&&f.contentWindow)try{n[u]?.blur()}catch(x){N.errorWithDatadog(`Blur send error for ${u}`,{error:x})}},setDisabled:f=>{n[u]?.setDisabled(f)},setCardholderName:f=>{n[u]?.setCardholderName(f)}}};return{cardNumberInput:c(ne.cardNumber),cardholderNameInput:c(ne.cardholderName),expiryInput:c(ne.cardExpiryDate),cvvInput:c(ne.cardSecurityCode)}},removeHostedInputs:()=>{s=!0,e.iframes.cardNumber.remove(),e.iframes.cardSecurityCode.remove(),e.iframes.cardExpiryDate.remove(),e.iframes.cardholderName.remove()},submit:async c=>{if((await d.validate()).valid)return await t.apiController.setPreferredNetwork(c?.cardNetwork),fi(i,e)},validate:async()=>{let c=(await Promise.all(Object.entries(n).map(([g,f])=>f?.getFieldState().then(x=>[g,x]).catch(()=>{})))).filter(g=>g!==void 0),u=[];for(let[g,f]of c)!f.valid&&f.error&&u.push({field:g,name:g,error:f.error,message:f.error});return{valid:u.length===0,validationErrors:u}},reset:()=>{Object.values(n).forEach(c=>{c?.reset()}),t.apiController.setPreferredNetwork(void 0)},setCardholderName:c=>{try{n[ne.cardholderName]?.setCardholderName(c)}catch(u){N.errorWithDatadog("SetCardholderName error",{error:u})}}};return d}function Xd(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 Qd({networks:i,source:t},e){let r=e,o=new Set(r.map(d=>_o(d).backend)),a=i.map(d=>({...d,allowed:o.has(d.network)})).sort((d,c)=>d.allowed?r.indexOf(d.network)-r.indexOf(c.network):1),n=a.filter(d=>d.allowed),s=t==="REMOTE"&&n.length>1;return{detectedCardNetworks:{items:a,preferred:n[0]},...s&&{selectableCardNetworks:{items:n,preferred:n[0]}},source:t}}function ec(i,t,e){return{createButton:()=>({render:async r=>{e.setCallbacks({onStart:()=>{i.onBeforePaymentCreate?.({paymentMethodType:e.config.type},{continuePaymentCreation:()=>{i.onPaymentCreationStart?.()},abortPaymentCreation:()=>{}})},onSuccess(a){yo(i,a)},onError(){yo(i)}});let o=typeof r=="string"?document.getElementById(r):r;if(!o)throw new B({code:pd.CONTAINER_NOT_FOUND,message:`Container with id "${r}" not found in the DOM.`});await e.render(o)}})}}function tc(i,t,e){return{start:()=>fi(i,e)}}function rc(i,t,e){return{start:async r=>(r?.blikCode&&e.setBlikCode(r.blikCode),fi(i,e))}}function ic(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"}}function rn(i,t,e="POST",r=""){let o=i.error,a=new Error(o?.description||o?.message||"Unexpected error"),n=oc(t),s=ac({summary:"Request failed for",method:e,path:r,details:JSON.stringify(i,null,2),code:n});return new It({message:s,code:n,error:a,response:i})}var oc=i=>i>=500?we.SERVER_ERROR:{400:we.BAD_REQUEST,401:we.UNAUTHORIZED,403:we.FORBIDDEN,404:we.NOT_FOUND,408:we.REQUEST_TIMEOUT,409:we.CONFLICT,422:we.VALIDATION_ERROR}[i]??we.REQUEST_ERROR,ac=({summary:i,method:t,path:e,code:r,details:o})=>`${i} ${t} ${e} with code ${r}"
|
|
39
|
+
`,r=document.createElement("style");r.id=t,r.textContent=e,document.head.appendChild(r)}},Nl={CONTAINER_NOT_FOUND:"CONTAINER_NOT_FOUND"},Ir={MISSING_PARAMETER:"MISSING_PARAMETER",INVALID_PARAMETER:"INVALID_PARAMETER",INVALID_USAGE:"INVALID_USAGE"},_e={UNAUTHORIZED:"UNAUTHORIZED",FORBIDDEN:"FORBIDDEN",NOT_FOUND:"NOT_FOUND",CONFLICT:"CONFLICT",REQUEST_TIMEOUT:"REQUEST_TIMEOUT",VALIDATION_ERROR:"REQUEST_VALIDATION_ERROR",SERVER_ERROR:"SERVER_ERROR",BAD_REQUEST:"BAD_REQUEST",REQUEST_ERROR:"REQUEST_ERROR",UNEXPECTED:"UNEXPECTED"},F={PAYMENT_CREATION_ABORTED:"PAYMENT_CREATION_ABORTED",PAYMENT_FAILED:"PAYMENT_FAILED",RESUME_FAILED:"RESUME_FAILED",TOKENIZATION_ERROR:"TOKENIZATION_ERROR"},kr={MISSING_CLIENT_TOKEN:"MISSING_CLIENT_TOKEN",INVALID_CLIENT_TOKEN:"INVALID_CLIENT_TOKEN"},xr={VAULT_ERROR:"VAULT_ERROR",TOKENIZATION_ERROR:"TOKENIZATION_ERROR"},no=(function(i){return i.REQUEST_ERROR="RequestError",i.TOKENIZATION_ERROR="TokenizationError",i.CLIENT_ERROR="ClientError",i.REQUEST_VALIDATION_ERROR="RequestValidationError",i.CONFIGURATION_ERROR="ConfigurationError",i.PCI_ERROR="PciError",i})({}),er=class extends Error{constructor(e,r,o,n){super(r);N(this,"code");N(this,"error");this.name=e,this.code=o,this.error=n}toJSON(){return{name:this.name,message:this.message,code:this.code,stack:this.stack}}},Ct=class extends er{constructor({message:e,error:r,response:o,code:n=_e.REQUEST_ERROR}){let a=r??new Error(e);super(no.REQUEST_ERROR,e,n,a);N(this,"response");this.response=o}toJSON(){return{name:this.name,message:this.message,response:this.response,code:this.code,stack:this.stack}}},ee=class extends er{constructor({message:e,error:r,code:o=_e.UNEXPECTED,suggestion:n,paymentMethod:a}){let s=r??new Error(e);super(no.TOKENIZATION_ERROR,e,o,s);N(this,"suggestion");N(this,"paymentMethod");this.suggestion=n,this.paymentMethod=a}toJSON(){return{name:this.name,message:this.message,code:this.code,paymentMethod:this.paymentMethod,suggestion:this.suggestion,stack:this.stack}}},Y=class extends er{constructor({message:e,error:r,code:o=_e.UNEXPECTED,suggestion:n,paymentMethod:a}){let s=r??new Error(e);super(no.CLIENT_ERROR,e,o,s);N(this,"suggestion");N(this,"paymentMethod");this.suggestion=n,this.paymentMethod=a}toJSON(){return{name:this.name,message:this.message,code:this.code,paymentMethod:this.paymentMethod,suggestion:this.suggestion,stack:this.stack}}},at=class{constructor(t,e){N(this,"config");N(this,"context");N(this,"lastToken",null);this.config=Object.freeze(t),this.context=e}getLastToken(){return this.lastToken}async tokenizeVaulted(t){let{error:e,data:r}=await this.context.pciApi.postPaymentInstrumentsExchange(t);if(e||!r)throw e??new Y({code:F.TOKENIZATION_ERROR,message:"Unable to tokenize vaulted payment method",paymentMethod:this.config.type});return r}async setup(){return!0}async start(){}async render(t){I.warn(`Render not implemented for ${this.config.type}`)}async handleRequiredAction(t,e){return t.requiredAction?.name==="3DS_AUTHENTICATION"?new Bi(this.context,e).handleRequiredAction(t):t.requiredAction?.name==="PROCESSOR_3DS"?new Fi(this.context,e).handleRequiredAction(t):t}async createPayment(t){this.lastToken=t;let{error:e,data:r}=await this.context.pciApi.postCreatePayment(t.token);if(e||!r)throw e??new Y({code:F.PAYMENT_FAILED,message:"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 Y({code:F.RESUME_FAILED,message:"Unable to resume payment"});return o}};function Ll(i){return i&&i.includes("_")?i.split("_").join("-"):i}var Rl=JSON.parse('{"USD":{"b":2},"CAD":{"b":2},"EUR":{"b":2},"AED":{"b":2},"AFN":{"b":0},"ALL":{"b":0},"AMD":{"b":0},"ARS":{"b":2},"AUD":{"b":2},"AZN":{"b":2},"BAM":{"b":2},"BDT":{"b":2},"BGN":{"b":2},"BHD":{"b":3},"BIF":{"b":0},"BND":{"b":2},"BOB":{"b":2},"BRL":{"b":2},"BWP":{"b":2},"BYN":{"b":2},"BZD":{"b":2},"CDF":{"b":2},"CHF":{"b":2},"CLP":{"b":0},"CNY":{"b":2},"COP":{"b":2},"CRC":{"b":2},"CVE":{"b":2},"CZK":{"b":2},"DJF":{"b":0},"DKK":{"b":2},"DOP":{"b":2},"DZD":{"b":2},"EEK":{"b":2},"EGP":{"b":2},"ERN":{"b":2},"ETB":{"b":2},"GBP":{"b":2},"GEL":{"b":2},"GHS":{"b":2},"GNF":{"b":0},"GTQ":{"b":2},"HKD":{"b":2},"HNL":{"b":2},"HRK":{"b":2},"HUF":{"b":2},"IDR":{"b":2},"ILS":{"b":2},"INR":{"b":2},"IQD":{"b":0},"IRR":{"b":0},"ISK":{"b":0},"JMD":{"b":2},"JOD":{"b":3},"JPY":{"b":0},"KES":{"b":2},"KHR":{"b":2},"KMF":{"b":0},"KRW":{"b":0},"KWD":{"b":3},"KZT":{"b":2},"LBP":{"b":0},"LKR":{"b":2},"LTL":{"b":2},"LVL":{"b":2},"LYD":{"b":3},"MAD":{"b":2},"MDL":{"b":2},"MGA":{"b":0},"MKD":{"b":2},"MMK":{"b":0},"MOP":{"b":2},"MUR":{"b":0},"MXN":{"b":2},"MYR":{"b":2},"MZN":{"b":2},"NAD":{"b":2},"NGN":{"b":2},"NIO":{"b":2},"NOK":{"b":2},"NPR":{"b":2},"NZD":{"b":2},"OMR":{"b":3},"PAB":{"b":2},"PEN":{"b":2},"PHP":{"b":2},"PKR":{"b":0},"PLN":{"b":2},"PYG":{"b":0},"QAR":{"b":2},"RON":{"b":2},"RSD":{"b":2},"RUB":{"b":2},"RWF":{"b":0},"SAR":{"b":2},"SDG":{"b":2},"SEK":{"b":2},"SGD":{"b":2},"SOS":{"b":0},"SYP":{"b":0},"THB":{"b":2},"TND":{"b":3},"TOP":{"b":2},"TRY":{"b":2},"TTD":{"b":2},"TWD":{"b":2},"TZS":{"b":0},"UAH":{"b":2},"UGX":{"b":0},"UYU":{"b":2},"UZS":{"b":0},"VEF":{"b":2},"VND":{"b":0},"XAF":{"b":0},"XOF":{"b":0},"YER":{"b":0},"ZAR":{"b":2},"ZMK":{"b":0},"ZWL":{"b":0}}'),Ol=2,Dl=Rl;function $l(i){if(!i)return null;let t=Dl[i];return t?{decimalDigits:t.b}:null}function Vn(i,t,e){let r=Ll(i),o=$l(e)?.decimalDigits??Ol;function n(a){return new Intl.NumberFormat(r,{style:"currency",currency:e,currencyDisplay:a}).format(t/10**o)}try{return n("narrowSymbol")}catch{return n("symbol")}}function Hi(i,t){return Vn("en",i,t).replace(/[^0-9.]/g,"").replace(/(\..*)\./g,"$1")}var dn=5,Nr=class extends at{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)return I.warn("Apple Pay is not available in this browser context"),!1;if(!ApplePaySession.supportsVersion(dn))return I.warn("Apple Pay version not supported by this device"),!1;if(!ApplePaySession.canMakePayments())return I.warn("This device cannot make Apple Pay payments"),!1;let e=window.location.hostname;if(!(this.config.options.merchantDomains||[]).includes(e))return I.warn(`Apple Pay has not been configured for domain "${e}"`),!1}catch(e){return I.errorWithDatadog("Failed to initialize Apple Pay",{error:e}),!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(dn,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(e){I.errorWithDatadog("Error initiating Apple Pay session",{error:e})}}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(r){I.warn("Apple Pay merchant validation failed:",r),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:Hi(e??r,o),type:"final"}})}catch(e){I.errorWithDatadog("Error handling payment method selection",{error:e}),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),n=await this.createPayment(o.data),a=await this.handleRequiredAction(n,this.context.dialogProvider);a.status==="SUCCESS"?(this.applePaySession.completePayment(ApplePaySession.STATUS_SUCCESS),this.callbacks.onSuccess(a)):(this.applePaySession.completePayment(ApplePaySession.STATUS_FAILURE),this.callbacks.onError()),this.applePaySession=null}catch(r){I.errorWithDatadog("Error handling payment authorization",{error:r}),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:n}=this.context.configuration.clientSession.order;if(!e||!r)throw new Error("Country code and currency code are required");let a=["visa","masterCard","amex"],s=Hi(o??n,r);return{countryCode:e,currencyCode:r,merchantCapabilities:["supports3DS"],supportedNetworks:a,total:{amount:s,label:this.config.options.merchantName,type:"pending"}}}},Lr=class extends at{constructor(){super(...arguments);N(this,"blikCode","")}setBlikCode(e){this.blikCode=e}getBlikCode(){return this.blikCode}clearBlikCode(){this.blikCode=""}async tokenize(){if(!/^\d{6}$/.test(this.blikCode))throw new ee({message:"BLIK code must be exactly 6 digits",code:F.TOKENIZATION_ERROR,paymentMethod:this.config.type});let e=this.detectPlatform(),r={type:"OFF_SESSION_PAYMENT",paymentMethodType:this.config.type,paymentMethodConfigId:this.config.id,sessionInfo:{locale:this.context.locale||"en",platform:e,browserInfo:oo(),blikCode:this.blikCode}};try{let{error:o,data:n}=await this.context.pciApi.postPaymentInstruments(r);if(this.clearBlikCode(),o||!n)throw o??new ee({message:"Unable to tokenize BLIK payment method",code:F.TOKENIZATION_ERROR,paymentMethod:this.config.type});return n}catch(o){throw this.clearBlikCode(),o}}async handleRequiredAction(e,r){let o=await super.handleRequiredAction(e,r);if(o.id!==e.id)return o;let n=e.requiredAction?.clientToken;if(!n)throw new Ct({message:"No client token provided for BLIK payment",code:kr.MISSING_CLIENT_TOKEN,response:{id:e.id,data:e}});let a=Dt(n);if(!this.isValidBlikClientToken(a))throw new Ct({message:"Invalid BLIK client token: missing statusUrl or incorrect intent",code:kr.INVALID_CLIENT_TOKEN,response:{id:e.id,data:e}});let{promise:s,abort:l}=this.pollStatus(a.statusUrl),c=await s;if(l(),"error"in c)throw c.error;let u=c.id;if(!u){let f=await this.context.pciApi.getResumeStatus(a.statusUrl);if(f.error||!f.data?.id)throw f.error??new Error("Unable to get resume token");u=f.data.id}return await this.resumePayment(e.id,u)}pollStatus(e){let r=!0,o=1e3,n=864e5,a=Date.now();return{promise:new Promise(async s=>{for(;r;){if(Date.now()-a>=n)return void s({error:new Error("BLIK payment polling timed out after 24 hours")});let{data:l,error:c}=await this.context.pciApi.getResumeStatus(e);if(c)return void s({error:c instanceof Error?c:new Error(String(c))});if(l?.status==="COMPLETE")return void s({id:l.id});await tr(o)}}),abort:()=>{r=!1}}}detectPlatform(){let e=window.navigator.userAgent.toLowerCase();return["android","webos","iphone","ipad","ipod","blackberry","windows phone"].some(n=>e.includes(n))?"MOBILE_WEB":"WEB"}isValidBlikClientToken(e){if(typeof e!="object"||e===null)return!1;let r=e;return!(r.intent!=="ADYEN_BLIK_REDIRECTION"||!("statusUrl"in r)||typeof r.statusUrl!="string"||!r.statusUrl)}},Un="https://sdk.primer.io/web/hosted-pages/v0.0.17",zi=!1,Vl=`${Un}/api-controller.html`,Ul=`${Un}/hosted-input.html`,Yl="https://goat-assets.production.core.primer.io";function Yn(i,t){return btoa(JSON.stringify({checkoutSessionId:i,name:t}))}Xi("../../node_modules/card-validator/dist/index.js");var ae={cardNumber:"cardNumber",cardSecurityCode:"cardSecurityCode",cardExpiryDate:"cardExpiryDate",cardholderName:"cardholderName"},cn="cardSecurityCodeRecapture";Object.values(ae);function Bl(i){return{cardNumber:Xt(i,ae.cardNumber),cardSecurityCode:Xt(i,ae.cardSecurityCode),cardExpiryDate:Xt(i,ae.cardExpiryDate),cardholderName:Xt(i,ae.cardholderName)}}function Xt(i,t){let e=document.createElement("iframe"),r=Yn(i,t);return e.src=`${Ul}#${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 Rr=class extends at{constructor(e,r){super(e,r);N(this,"iframes");this.iframes=Bl(r.checkoutSessionId)}async tokenize(){let{error:e,data:r}=await this.context.pciApi.postPaymentInstruments("pci-card-form-data");if(e||!r)throw e??new ee({code:F.TOKENIZATION_ERROR,message:"Unable to tokenize payment method",paymentMethod:se.PAYMENT_CARD});return r}};function Fl(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(([n,a])=>{o.setAttribute(n,a)}),o.onload=()=>{e()},o.onerror=()=>{r(new Error(`Failed to load script: ${i}`))},document.head.appendChild(o)})}var pn=2,mn=0,Or=class extends at{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 ee({code:F.TOKENIZATION_ERROR,message:"Google Pay does not support direct tokenization",paymentMethod:se.GOOGLE_PAY})}async setup(){try{await Fl("https://pay.google.com/gp/p/js/pay.js")}catch{return!1}if(!window.google||!window.google.payments)return I.error("Google Pay is not available in this browser context"),!1;if(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;if(!e)throw new Y({code:Ir.MISSING_PARAMETER,message:"Cannot initialize Google Pay: missing country code",paymentMethod:se.GOOGLE_PAY});if(!r)throw new Y({code:Ir.MISSING_PARAMETER,message:"Cannot initialize Google Pay: missing currency code",paymentMethod:se.GOOGLE_PAY});return!0}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:n}=await this.context.pciApi.postPaymentInstruments({flow:"GATEWAY",network:r.paymentMethodData.info?.cardNetwork??"OTHER",merchant_id:this.config.options.merchantId,encrypted_payload:Mr.encode(r.paymentMethodData.tokenizationData.token)});if(n||!o)throw n??new ee({code:F.TOKENIZATION_ERROR,message:"Failed to tokenize payment data",paymentMethod:se.GOOGLE_PAY});let a=await this.createPayment(o);a.status==="SUCCESS"?this.callbacks.onSuccess(a):this.callbacks.onError()}catch(e){throw this.callbacks.onError(),I.errorWithDatadog("Google Pay error",{error:e}),e}}async handlePaymentDataChanged(e){return{}}buildIsReadyToPayRequest(){return{apiVersion:pn,apiVersionMinor:mn,allowedPaymentMethods:[this.allowedPaymentMethod]}}buildPaymentDataRequest(){let{countryCode:e,currencyCode:r,merchantAmount:o,totalOrderAmount:n}=this.context.configuration.clientSession.order;return{apiVersion:pn,apiVersionMinor:mn,transactionInfo:{countryCode:e,currencyCode:r,displayItems:[],totalPriceStatus:"FINAL",totalPrice:Hi(o??n,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}}}]}}};function Hl(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 zl(i,t){var e=document.querySelector('script[src="'.concat(i,'"]'));if(e===null)return null;var r=Bn(i,t),o=e.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var n=!0;return Object.keys(o.dataset).forEach(function(a){o.dataset[a]!==r.dataset[a]&&(n=!1)}),n?e:null}function Kl(i){var t=i.url,e=i.attributes,r=i.onSuccess,o=i.onError,n=Bn(t,e);n.onerror=o,n.onload=r,document.head.insertBefore(n,document.head.firstElementChild)}function Gl(i){var t=i.sdkBaseUrl,e=i.environment,r=Hl(i,["sdkBaseUrl","environment"]),o=t||ql(e),n=r,a=Object.keys(n).filter(function(c){return n[c]!==void 0&&n[c]!==null&&n[c]!==""}).reduce(function(c,u){var f=n[u].toString();return u=jl(u),u.substring(0,4)==="data"||u==="crossorigin"?c.attributes[u]=f:c.queryParams[u]=f,c},{queryParams:{},attributes:{}}),s=a.queryParams,l=a.attributes;return s["merchant-id"]&&s["merchant-id"].indexOf(",")!==-1&&(l["data-merchant-id"]=s["merchant-id"],s["merchant-id"]="*"),{url:"".concat(o,"?").concat(Wl(s)),attributes:l}}function jl(i){var t=function(e,r){return(r?"-":"")+e.toLowerCase()};return i.replace(/[A-Z]+(?![a-z])|[A-Z]/g,t)}function Wl(i){var t="";return Object.keys(i).forEach(function(e){t.length!==0&&(t+="&"),t+=e+"="+i[e]}),t}function ql(i){return i==="sandbox"?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js"}function Bn(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 Jl(i,t){if(t===void 0&&(t=Promise),Fn(i,t),typeof document>"u")return t.resolve(null);var e=Gl(i),r=e.url,o=e.attributes,n=o["data-namespace"]||"paypal",a=un(n);return o["data-js-sdk-library"]||(o["data-js-sdk-library"]="paypal-js"),zl(r,o)&&a?t.resolve(a):Zl({url:r,attributes:o},t).then(function(){var s=un(n);if(s)return s;throw new Error("The window.".concat(n," global variable is not available."))})}function Zl(i,t){t===void 0&&(t=Promise),Fn(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,n){if(typeof document>"u")return o();Kl({url:e,attributes:r,onSuccess:function(){return o()},onError:function(){var a=new Error('The script "'.concat(e,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return n(a)}})})}function un(i){return window[i]}function Fn(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 _r=new Map,hn={getOrCreateNamespace(i){let t=_r.get(i);return t?t.namespace:Te()},getInstance(i){return _r.get(i)?.instance??null},storeInstance(i,t,e){_r.set(i,{instance:t,namespace:e})},hasInstance(i){return _r.has(i)}};async function Xl({context:i,configId:t,paymentMethodType:e,callbacks:r}){try{r.onStart(),await i.clientSessionApi.selectPaymentMethod(e);let{data:o,error:n}=await i.coreApi.createPaypalBillingAgreement({paymentMethodConfigId:t});if(n||!o){let a=n?.message??"Failed to create billing agreement";throw new Y({message:a,code:F.PAYMENT_FAILED,paymentMethod:e})}return o.tokenId}catch(o){throw I.errorWithDatadog("PayPal billing agreement creation failed:",{error:o}),r.onError(),o instanceof Y||o instanceof ee?o:new Y({message:"Failed to create billing agreement",code:F.PAYMENT_FAILED,paymentMethod:e})}}async function Ql({context:i,configId:t,paymentMethodType:e,callbacks:r,createPayment:o,data:n,actions:a}){try{let s=n.billingToken;if(!s)throw new ee({message:"Billing token not provided",code:F.TOKENIZATION_ERROR,paymentMethod:e});let{data:l,error:c}=await i.coreApi.confirmPaypalBillingAgreement({paymentMethodConfigId:t,tokenId:s});if(c||!l){let T=c?.message??"Failed to confirm billing agreement";throw new ee({message:T,code:F.TOKENIZATION_ERROR,paymentMethod:e})}let u=l,f={paypalBillingAgreementId:u.billingAgreementId,shippingAddress:u.shippingAddress,externalPayerInfo:u.externalPayerInfo},{error:h,data:A}=await i.pciApi.postPaymentInstruments(f,{tokenType:"MULTI_USE",paymentFlow:"VAULT"});if(h||!A){let T=h?.message??"Unable to vault PayPal payment method";throw new ee({message:T,code:F.TOKENIZATION_ERROR,paymentMethod:e})}let x=await o(A);r.onSuccess(x)}catch(s){throw I.errorWithDatadog("PayPal billing agreement approval failed:",{error:s}),r.onError(),s instanceof ee||s instanceof Y?s:new ee({message:"Failed to approve billing agreement",code:F.TOKENIZATION_ERROR,paymentMethod:e})}}var ed="gold",td="rect",rd="paypal",id="vertical",od="horizontal";function nd(i){return{color:i?.color??ed,shape:i?.shape??td,label:i?.label??rd,layout:i?.layout??(i?.tagline?od:id),tagline:i?.tagline??!1,...i?.height&&{height:i.height},...i?.borderRadius!==void 0&&{borderRadius:i.borderRadius},...i?.disableMaxWidth!==void 0&&{disableMaxWidth:i.disableMaxWidth}}}function ad(i,t,e,r){let o={style:i,onInit:e.onInit,onClick:e.onClick,onCancel:e.onCancel,onError:e.onError};return t&&r?(o.createBillingAgreement=r.createBillingAgreement,o.onApprove=r.onApprove):o.onApprove=e.onApprove,o}function sd(i){if(!i)return;let t={first_name:i.firstName,last_name:i.lastName,address_line_1:i.addressLine1??"",address_line_2:i.addressLine2,city:i.city??"",state:i.state,postal_code:i.postalCode??"",country_code:i.countryCode??""},{address_line_1:e,city:r,postal_code:o,country_code:n}=t;if(!(!e||!r||!o||!n))return t}function ld(i){if(!i)return null;let t=i.purchase_units?.[0]?.shipping;if(!t?.address)return null;let e=t.address,r=t.name;return{firstName:r?.given_name,lastName:r?.surname,addressLine1:e.address_line_1,addressLine2:e.address_line_2,city:e.admin_area_2,state:e.admin_area_1,postalCode:e.postal_code,countryCode:e.country_code}}function dd(i,t,e){let{order:{currencyCode:r,merchantAmount:o,totalOrderAmount:n,shipping:a,lineItems:s=[],fees:l=[]},customer:c}=i;if(!r)throw new Y({message:"Currency code is not provided",code:Ir.MISSING_PARAMETER,paymentMethod:e});let u={amount:o??n,currencyCode:r,paymentMethodConfigId:t,amountBreakdown:{}},f=c?.shippingAddress,h=sd(f);h&&(u.shipping_address=h);let A=!s.some(x=>!x.name&&!x.description);if(A&&(u.items=s.map(x=>{let{name:T,description:w,taxAmount:S,amount:L,quantity:$}=x,xe=S?Math.floor(S/$):0;return{name:w||T||"",unit_amount:{value:L,currency_code:r},quantity:$.toString(),tax:{value:xe,currency_code:r}}})),A&&s.length){let x=s.reduce((Ee,{amount:Et,quantity:Jo})=>Ee+Et*Jo,0),T=l?.reduce?.((Ee,{amount:Et})=>Ee+(Et??0),0),w=s?.reduce((Ee,{discountAmount:Et})=>Ee+(Et??0),0),S=s?.reduce((Ee,{taxAmount:Et})=>Ee+(Et??0),0),L=a?.amount??0,$=T??0,xe=x+S+L+$-w;u.amountBreakdown={item_total:{value:x,currency_code:r},tax_total:{value:S,currency_code:r},handling:{value:$,currency_code:r},shipping:{value:L,currency_code:r},discount:{value:w,currency_code:r}},u.amount=xe}return u}async function cd({context:i,configId:t,paymentMethodType:e,callbacks:r}){try{r.onStart(),await i.clientSessionApi.selectPaymentMethod(e);let{data:o,error:n}=await i.coreApi.createPaypalOrder(dd(i.configuration.clientSession,t,e));if(n||!o){let a=n?.message??"Unable to create PayPal order";throw new Y({message:a,code:F.PAYMENT_FAILED,paymentMethod:e})}return o.orderId}catch(o){throw r.onError(),o}}async function pd({context:i,paymentMethodType:t,callbacks:e,createPayment:r,data:o,actions:n}){let a=null;try{a=await n?.order?.get()??null}catch(h){I.warn("Failed to get PayPal order details",h)}let s=ld(a),l={external_payer_info:{email:a?.payer?.email_address,external_payer_id:o.payerID??void 0,first_name:a?.payer?.name?.given_name,last_name:a?.payer?.name?.surname},paypal_order_id:o.orderID,paypal_status:a?.status};s&&(l.shipping_address=s);let{error:c,data:u}=await i.pciApi.postPaymentInstruments(l);if(c||!u){let h=c?.message??"Unable to create payment instrument";throw new ee({message:h,code:F.TOKENIZATION_ERROR,paymentMethod:t})}let f=await r(u);e.onSuccess(f)}var md=["buttons","funding-eligibility"],gn=[],ud="authorize";function hd(i,t,e){return(i??t==="PREFER_VAULT")&&e}function fn({isVaultFlow:i,configIntent:t}){return i?"tokenize":t??ud}function gd(i,t,e,r){let{clientId:o,intent:n}=t.options,a=i.configuration.clientSession.order.currencyCode,s=i.paymentMethodOptions?.paypal?.disableFunding??(gn.length>0?gn:void 0),l={dataNamespace:e,clientId:o,currency:a,components:md,...s&&s.length>0?{disableFunding:s}:{},enableFunding:i.paymentMethodOptions?.paypal?.enableFunding,integrationDate:i.paymentMethodOptions?.paypal?.integrationDate,debug:i.paymentMethodOptions?.paypal?.debug};return(zi||i.decodedClientToken.env==="SANDBOX")&&(l.buyerCountry=i.paymentMethodOptions?.paypal?.buyerCountry),r?(l.vault="true",l.intent=fn({isVaultFlow:!0,configIntent:n})):(l.vault="false",l.intent=fn({isVaultFlow:!1,configIntent:n})),l}var Dr=class extends at{constructor(e,r){super(e,r);N(this,"paypalInstance");N(this,"dataNamespace");N(this,"callbacks",{onStart:()=>{},onError:()=>{},onSuccess:()=>{}});N(this,"isVaultFlow",!1);N(this,"isSetupComplete",!1);N(this,"setupPromise");this.dataNamespace=hn.getOrCreateNamespace(e.id),this.context.onClientConfigurationUpdate(async()=>{I.info("PayPal: Client session updated, refreshing PayPal buttons");try{await this.setup()}catch(o){I.warn("PayPal: Failed to refresh on client session update:",o)}})}setCallbacks(e){this.callbacks=e}async tokenize(){throw new ee({message:"PayPal does not support direct tokenization",code:F.TOKENIZATION_ERROR,paymentMethod:se.PAYPAL})}async setup(){let{clientId:e}=this.config.options;return this.setupPromise?(I.info("PayPal setup already in progress, waiting..."),this.setupPromise):this.isSetupComplete&&this.paypalInstance?.Buttons?(I.info("PayPal setup already completed, skipping"),!0):e?(this.setupPromise=(async()=>{try{let r=this.context.paymentMethodOptions?.paypal?.vault,o=this.context.paymentMethodOptions?.paypal?.paymentFlow,n=this.context.configuration.clientSession.paymentMethod?.vaultOnSuccess??!1;this.isVaultFlow=hd(r,o,n);let a=gd(this.context,this.config,this.dataNamespace,this.isVaultFlow);I.debug("%c PAYPAL %c Script Configuration ","background: #0070BA; color: #ffffff; font-weight: bold; padding: 4px 12px; border-radius: 3px 0 0 3px; font-size: 14px;","background: #003087; color: #ffffff; padding: 4px 12px; border-radius: 0 3px 3px 0; font-size: 14px;",a);let s=await Jl(a);return s?(this.paypalInstance=s,hn.storeInstance(this.config.id,s,this.dataNamespace),!0):(I.warn("Failed to load PayPal SDK"),!1)}catch(r){return I.errorWithDatadog("PayPal setup failed:",{error:r}),this.setupPromise=void 0,!1}})(),this.setupPromise):(I.warn("PayPal clientId is required"),!1)}async render(e){if(!this.paypalInstance.Buttons)throw new Y({message:"PayPal Buttons component not available",code:Ir.INVALID_USAGE,paymentMethod:se.PAYPAL});let r=this.context.paymentMethodOptions?.paypal?.style,o=nd(r),n=ad(o,this.isVaultFlow,{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)},this.isVaultFlow?{createBillingAgreement:()=>Xl({context:this.context,configId:this.config.id,paymentMethodType:this.config.type,callbacks:this.callbacks}),onApprove:(s,l)=>Ql({context:this.context,configId:this.config.id,paymentMethodType:this.config.type,callbacks:this.callbacks,createPayment:this.createPayment.bind(this),data:s,actions:l})}:void 0);this.isVaultFlow||(n.createOrder=this.handleCreateOrder.bind(this)),await this.paypalInstance.Buttons(n).render(e)}handleInit(e,r){let{clientSession:o}=this.context.configuration,n=!!o.order.currencyCode,a=!!o.order.totalOrderAmount||!!o.order.merchantAmount;if(!n||!a){I.warn("PayPal button disabled: missing currency or amount"),r.disable();return}r.enable()}handleClick(e,r){return $r({eventName:"PAYMENT_METHOD_SELECTION",paymentMethod:"PAYPAL"}),r.resolve()}async handleCreateOrder(){return cd({context:this.context,configId:this.config.id,paymentMethodType:this.config.type,callbacks:this.callbacks})}async handleApprove(e,r){return pd({context:this.context,paymentMethodType:this.config.type,callbacks:this.callbacks,createPayment:this.createPayment.bind(this),data:e,actions:r})}handleCancel(){this.context.clientSessionApi.unselectPaymentMethod(),this.callbacks.onError()}handleError(e){I.errorWithDatadog("PayPal error:",e),this.callbacks.onError()}};async function fd(i,t,e){try{$r({eventName:"PAYMENT_PROCESSING_STARTED",paymentMethod:i.config.type}),e||await i.start();let r=e?await i.tokenizeVaulted(e.id):await i.tokenize(),o=await i.createPayment(r);return await i.handleRequiredAction(o,t)}catch(r){throw r}}function yn(i,t,e){if(!i)return null;let r={id:i.id,orderId:i.orderId};return t?.paymentInstrumentData&&e&&(r.paymentMethodData={paymentMethodType:e,...t.paymentInstrumentData}),r}var Ki=(i,t,e,r,o)=>{let n=e;if(t?.status==="FAILED"&&(n=new Y({code:F.PAYMENT_FAILED,message:`The payment "${t.id}" was created but failed to be processed. Check the payment id ${t.id} using the Payments API or search for the payment on your Dashboard for further explanations.`})),t?.checkoutOutcome==="CHECKOUT_FAILURE"&&(n=new Y({code:F.PAYMENT_FAILED,message:`The payment "${t.id}" was created but failed to be processed. Check the payment id ${t.id} using the Payments API or search for the payment on your Dashboard for further explanations.`})),t?.status==="PENDING"&&!t.requiredAction?.clientToken&&(n=new Y({code:F.PAYMENT_FAILED,message:`The payment "${t.id}" ended up in a "PENDING" state without any required action. The SDK does not know how to handle this state. Check the payment id ${t.id} using the Payments API or search for the payment on your Dashboard for further explanations.`})),t?.status==="SUCCESS"&&t.checkoutOutcome!=="CHECKOUT_FAILURE"||t?.status==="PENDING"&&t.showSuccessCheckoutOnPendingPayment||t?.checkoutOutcome==="CHECKOUT_COMPLETE")return void i.onCheckoutComplete?.({payment:yn(t,r,o)});i.onCheckoutFail?.(n||new Y({code:F.PAYMENT_FAILED,message:`The payment${t?.id?` "${t.id}"`:""} is in an inconsistent state without any required action. The SDK does not know how to handle this state. Please contact Primer.`}),{payment:yn(t,r,o)??void 0})},yd=async(i,t)=>{if(!i.onBeforePaymentCreate)return!0;let e=setTimeout(()=>{I.warn("onBeforePaymentCreate did not resolve within 10 seconds. Primer SDK will remain in a loading state until `continuePaymentCreation` or `abortPaymentCreation` is called.")},1e4);return new Promise(r=>{i.onBeforePaymentCreate({paymentMethodType:t},{continuePaymentCreation:()=>{clearTimeout(e),I.log(`Continuing payment creation for ${t}`),r(!0)},abortPaymentCreation:()=>{clearTimeout(e),I.log(`Aborting payment creation for ${t}`),r(!1)}})})};async function Vr(i,t,e){if(!await yd(i,t.config.type))return void i.onCheckoutFail?.(new Y({message:"Payment creation aborted",code:F.PAYMENT_CREATION_ABORTED,paymentMethod:t.config.type}),{});i.onPaymentCreationStart?.();let o,n;try{n=await fd(t,t.context.dialogProvider,e)}catch(a){o=a}finally{Ki(i,n,o,t.getLastToken(),t.config.type)}}var vn=Symbol("PROXY_MARKER");function ao({namespace:i,onMessage:t,sendMessage:e}){function r(o,n){return new Proxy(o,{get(a,s,l){if(s==="then")return null;if(a[vn])return Reflect.get(a,s,l);let c=()=>{};return c[vn]=!0,r(c,[...n,s])},apply(a,s,l){return new Promise(async(c,u)=>{try{let f=[],h=l.map(w=>{if(typeof w!="function")return w;{let S=Te();return f.push(S),t(L=>{L.namespace===i&&L.sender===Di.PROVIDER&&L.type===Oi.CALLBACK&&L.id===S&&w(...L.data)}),S}}),A=Te(),x=t(w=>{w.namespace===i&&w.sender===Di.PROVIDER&&w.type===Oi.APPLY&&w.id===A&&(w.error?u(new Error(w.error)):c(w.data),x?.())}),T={type:Oi.APPLY,sender:Di.INJECTOR,id:A,path:n,args:h,callbackIds:f,timeStamp:Date.now(),namespace:i};e(T)}catch(f){u(f)}})}})}return r({},[])}var Oi={APPLY:"apply",CALLBACK:"callback"},Di={PROVIDER:"provider",INJECTOR:"injector"};function Gi(i,t){let e=t?.input?.base?.height;e&&(i.style.height=typeof e=="number"?`${e}px`:e)}function vd(i,t,e,r={}){let o=[],n="LOCAL",a={[ae.cardNumber]:void 0,[ae.cardExpiryDate]:void 0,[ae.cardSecurityCode]:void 0,[ae.cardholderName]:void 0},s=!1;t.subscribeToTeardown(()=>{s=!0});let l={createHostedInputs:()=>{let c=u=>{let f=new Map;return{getOptions:()=>{},setOptions:h=>{Gi(e.iframes[u],h.style),a[u]?.setOptions(h)},render:(h,A)=>{let x=e.iframes[u];if(!x)return I.errorWithDatadog(`No iframe found for ${u}`),Promise.resolve();let T;return T=typeof h=="string"?document.getElementById(h):h,T?(Gi(x,A.style),T.appendChild(x),new Promise(w=>{x.onload=()=>{if(s){I.warn(`Teardown was already called, aborting render for ${u}`),x.remove(),w();return}a[u]=ao({namespace:`${t.checkoutSessionId}-${u}`,onMessage:S=>{let L=$=>S($.data);return window.addEventListener("message",L),()=>window.removeEventListener("message",L)},sendMessage:S=>{x.contentWindow.postMessage(S,"*")}}),a[u].setOptions({...A,orderedAllowedCardNetworks:t.configuration.clientSession.paymentMethod.orderedAllowedCardNetworks,cardholderName:i.cardholderName??i.card?.cardholderName}),a[u].setOnBlur(()=>{try{f.get("blur")?.()}catch(S){I.errorWithDatadog(`Blur listener error for ${u}`,{error:S})}}),a[u].setOnFocus(()=>{try{f.get("focus")?.()}catch(S){I.errorWithDatadog(`Focus listener error for ${u}`,{error:S})}}),a[u].setOnInput(S=>{let L={...S,errorCode:S.error,active:S.focused};try{f.get("input")?.(L),f.get("change")?.(L)}catch($){I.errorWithDatadog(`Input listener error for ${u}`,{error:$})}}),a[u].setOnEnter(()=>{try{f.get("enter")?.()}catch(S){I.errorWithDatadog(`Enter listener error for ${u}`,{error:S})}}),u===ae.cardNumber&&(a[u].setBinDataApiConfig(t.configuration.binDataUrl,t.decodedClientToken.accessToken),a[u].setOnCardNetworksChange((S,L)=>{(L!==n||bd(o,S))&&(o=S,n=L,r.onCardNetworksChange?.(Ed({networks:o,source:n},t.configuration.clientSession.paymentMethod.orderedAllowedCardNetworks)))}))},w()})):(I.error(`Container not found for ${u}:`,h),Promise.resolve())},addEventListener:(h,A)=>{f.set(h,A)},focus:()=>{let h=e.iframes[u];if(h&&h.contentWindow)try{a[u]?.focus()}catch(A){I.errorWithDatadog(`Focus send error for ${u}`,{error:A})}else I.warn(`Focus failed for ${u} - iframe not available`)},blur:()=>{let h=e.iframes[u];if(h&&h.contentWindow)try{a[u]?.blur()}catch(A){I.errorWithDatadog(`Blur send error for ${u}`,{error:A})}},setDisabled:h=>{a[u]?.setDisabled(h)},setCardholderName:h=>{a[u]?.setCardholderName(h)}}};return{cardNumberInput:c(ae.cardNumber),cardholderNameInput:c(ae.cardholderName),expiryInput:c(ae.cardExpiryDate),cvvInput:c(ae.cardSecurityCode)}},removeHostedInputs:()=>{s=!0,e.iframes.cardNumber.remove(),e.iframes.cardSecurityCode.remove(),e.iframes.cardExpiryDate.remove(),e.iframes.cardholderName.remove()},submit:async c=>{if((await l.validate()).valid)return await t.apiController.setPreferredNetwork(c?.cardNetwork),Vr(i,e)},validate:async()=>{let c=(await Promise.all(Object.entries(a).map(([f,h])=>h?.getFieldState().then(A=>[f,A]).catch(()=>{})))).filter(f=>f!==void 0),u=[];for(let[f,h]of c)!h.valid&&h.error&&u.push({field:f,name:f,error:h.error,message:h.error});return{valid:u.length===0,validationErrors:u}},reset:()=>{Object.values(a).forEach(c=>{c?.reset()}),t.apiController.setPreferredNetwork(void 0)},setCardholderName:c=>{try{a[ae.cardholderName]?.setCardholderName(c)}catch(u){I.errorWithDatadog("SetCardholderName error",{error:u})}}};return l}function bd(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 Ed({networks:i,source:t},e){let r=e,o=new Set(r.map(l=>to(l).backend)),n=i.map(l=>({...l,allowed:o.has(l.network)})).sort((l,c)=>l.allowed?r.indexOf(l.network)-r.indexOf(c.network):1),a=n.filter(l=>l.allowed),s=t==="REMOTE"&&a.length>1;return{detectedCardNetworks:{items:n,preferred:a[0]},...s&&{selectableCardNetworks:{items:a,preferred:a[0]}},source:t}}function Cd(i,t,e){return{createButton:()=>({render:async r=>{e.setCallbacks({onStart:()=>{i.onBeforePaymentCreate?.({paymentMethodType:e.config.type},{continuePaymentCreation:()=>{i.onPaymentCreationStart?.()},abortPaymentCreation:()=>{}})},onSuccess(n){Ki(i,n,void 0,e.getLastToken(),e.config.type)},onError(){Ki(i,void 0,void 0,e.getLastToken())}});let o=typeof r=="string"?document.getElementById(r):r;if(!o)throw new Y({code:Nl.CONTAINER_NOT_FOUND,message:`Container with id "${r}" not found in the DOM.`});await e.render(o)}})}}function Ad(i,t,e){return{start:()=>Vr(i,e)}}function Sd(i,t,e){return{start:async r=>(r?.blikCode&&e.setBlikCode(r.blikCode),Vr(i,e))}}function Pd(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"}}function bn(i,t,e="POST",r=""){let o=i.error,n=new Error(o?.description||o?.message||"Unexpected error"),a=xd(t),s=_d({summary:"Request failed for",method:e,path:r,details:JSON.stringify(i,null,2),code:a});return new Ct({message:s,code:a,error:n,response:i})}var xd=i=>i>=500?_e.SERVER_ERROR:{400:_e.BAD_REQUEST,401:_e.UNAUTHORIZED,403:_e.FORBIDDEN,404:_e.NOT_FOUND,408:_e.REQUEST_TIMEOUT,409:_e.CONFLICT,422:_e.VALIDATION_ERROR}[i]??_e.REQUEST_ERROR,_d=({summary:i,method:t,path:e,code:r,details:o})=>`${i} ${t} ${e} with code ${r}"
|
|
42
40
|
|
|
43
41
|
Details:
|
|
44
|
-
${o}`;function nc(i,t,e){if(e?.status&&e.status>=400&&e.status<500)return!1;if(e?.status&&e.status>=500)return!0;if(i instanceof Error){let r=i.message.toLowerCase();return r.includes("network")||r.includes("timeout")||r.includes("connection")}return!1}function sc(i){let a=1e3*Math.pow(1.1,i),n=.1*a*(Math.random()-.5);return a=Math.max(0,a+n),Math.min(a,3e4)}var lc={attempts:3,retryCondition:nc,delayCalculator:sc,totalTimeout:3e5};async function dc(i,t,e){let r={...lc,...t.retry},o=[],a=Date.now();for(let d=0;d<=r.attempts;d++)try{let c=await i();if(!c.error)return{...c,retryHistory:o.length>0?o:void 0};if(d===r.attempts||!r.retryCondition(c.error,d,c))return{...c,retryHistory:o};let u=r.delayCalculator(d);if(o.push({attempt:d+1,delay:u,error:c.error,timestamp:Date.now()}),Date.now()-a+u>r.totalTimeout){let g=rn({...c,error:new Error("Retry total timeout exceeded")},408,t.method,e||"");return{...c,error:{...g,name:g.name,message:g.message,stack:g.stack,__sdkErrorType:g.name,__needsReconstruction:!0},retryHistory:o}}await fr(u)}catch(c){o.push({attempt:d+1,delay:0,error:c,timestamp:Date.now()})}let n=o[o.length-1]?.error,s;if(n){let d=rn({id:t.id,error:n},500,t.method,e||"");s={...d,name:d.name,message:d.message,stack:d.stack,__sdkErrorType:d.name,__needsReconstruction:!0}}return{id:t.id,error:s,retryHistory:o}}var Ht=class{constructor(t,e="",r={}){T(this,"fetch");T(this,"baseUrl");T(this,"defaultHeaders");this.fetch=t,this.baseUrl=e,this.defaultHeaders=Object.freeze({...r})}setDefaultHeader(t,e){this.defaultHeaders={...this.defaultHeaders,[t]:e}}async executeFetch(t,e){let r={...e,headers:{...this.defaultHeaders,...e?.headers},id:Te()};return e?.retry?dc(()=>this.fetch(t,{...r,retry:void 0}),r,t):this.fetch(t,r)}async get(t,e){return this.executeFetch(t,{...e,method:"GET"})}async post(t,e,r){return this.executeFetch(t,{...r,method:"POST",body:JSON.stringify(e)})}async delete(t,e){return this.executeFetch(t,{...e,method:"DELETE"})}},bo=class extends Ht{constructor(){super(...arguments);T(this,"configurationSubscribers",new Set);T(this,"_configuration")}async getConfiguration(){let e=await this.get(this.baseUrl);return e.data&&(this._configuration=e.data),e}subscribe(e){return this.configurationSubscribers.add(e),()=>{this.configurationSubscribers.delete(e)}}get configuration(){return this._configuration}set configuration(e){this._configuration=e,this.configurationSubscribers.forEach(r=>r(this._configuration))}},Co=class extends Ht{async getPaymentInstruments(){return this.get(`${this.baseUrl}/payment-instruments`)}async postPaymentInstruments(t,e){return this.post(`${this.baseUrl}/payment-instruments`,t==="pci-card-form-data"?t:{paymentInstrument:t,...e})}async postPaymentInstrumentsExchange(t){return this.post(`${this.baseUrl}/payment-instruments/${t}/exchange`,"payment-instrument-exchange")}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,{retry:{attempts:15}})}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)}};async function cc(i){return new Promise((t,e)=>{let r=Pn(i,"api"),o=`${yd}#${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 ur=class ur extends Ht{constructor(){super(...arguments);T(this,"onClientSessionUpdate")}setOnClientSessionUpdate(e){this.onClientSessionUpdate=e}async postClientSessionActions(e){if(e.length===0)return ur.noActionsResponse;let r=await this.post(`${this.baseUrl}/client-session/actions`,{actions:e}),{data:o}=r;return o&&this.onClientSessionUpdate?.(o),r}async selectPaymentMethod(e,r={}){return this.postClientSessionActions([{type:"SELECT_PAYMENT_METHOD",params:{...r,paymentMethodType:e}}])}async unselectPaymentMethod(){return this.postClientSessionActions([{type:"UNSELECT_PAYMENT_METHOD"}])}async selectCardNetwork(e){return this.selectPaymentMethod(se.PAYMENT_CARD,{binData:this.buildCardBinData(e)})}async setBillingAddress(e){let r=this.removeEmptyStringFromObject(e);return Object.values(r).length===0?ur.noActionsResponse:this.postClientSessionActions([{type:"SET_BILLING_ADDRESS",params:{billingAddress:r}}])}async setShippingAddress(e,r,o){let a=[];return e&&Object.keys(e).some(s=>!!e[s])&&a.push({type:"SET_SHIPPING_ADDRESS",params:{shippingAddress:e}}),r&&a.push({type:"SET_MOBILE_NUMBER",params:{mobileNumber:r}}),o&&a.push({type:"SET_EMAIL_ADDRESS",params:{emailAddress:o}}),this.postClientSessionActions(a)}async selectShippingMethod(e){return this.postClientSessionActions([{type:"SELECT_SHIPPING_METHOD",params:{shippingMethodId:e}}])}async setCustomerDetails({emailAddress:e,firstName:r,lastName:o}){let a=[];return e&&a.push({type:"SET_EMAIL_ADDRESS",params:{emailAddress:e}}),r&&a.push({type:"SET_CUSTOMER_FIRST_NAME",params:{firstName:r}}),o&&a.push({type:"SET_CUSTOMER_LAST_NAME",params:{lastName:o}}),this.postClientSessionActions(a)}buildCardBinData(e){let{backend:r}=_o(e);return{network:r,issuer_name:null,product_code:r,product_name:r,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"}}removeEmptyStringFromObject(e){let r={...e};for(let o in r)r[o]===""?delete r[o]:typeof r[o]=="object"&&r[o]!==null&&!Array.isArray(r[o])&&(r[o]=this.removeEmptyStringFromObject(r[o]));return r}};T(ur,"noActionsResponse",{data:{},error:void 0,headers:{},status:200,id:""});var Eo=ur,Ao=class extends Ht{async createPaypalOrder(t){return this.post(`${this.baseUrl}/paypal/orders/create`,t,{retry:{attempts:3}})}async createPaypalBillingAgreement(t){return this.post(`${this.baseUrl}/paypal/billing-agreements/create-agreement`,t,{retry:{attempts:3}})}async confirmPaypalBillingAgreement(t){return this.post(`${this.baseUrl}/paypal/billing-agreements/confirm-agreement`,t,{retry:{attempts:3}})}async createApplePaySession(t){return this.post(`${this.baseUrl}/apple-pay/sessions`,t)}};async function pc(i,{locale:t,dialogProvider:e,paymentMethodOptions:r}){let o=Te(),a=Yt(i),n=await cc(o),s=Io({namespace:`api-controller-${o}`,onMessage:w=>{let M=S=>w(S.data);return window.addEventListener("message",M),()=>window.removeEventListener("message",M)},sendMessage:w=>{n.contentWindow.postMessage(w,"*")}}),d=ic(a.accessToken,o),c=new bo(s.fetch,a.configurationUrl,d),{error:u}=await c.getConfiguration();if(u||!c.configuration)throw new Error(`Failed to fetch configuration: ${u}`);let g=new Co(s.fetch,c.configuration.pciUrl,d),f=new Ao(s.fetch,c.configuration.coreUrl,d),x=new Eo(s.fetch,c.configuration.pciUrl,d);x.setOnClientSessionUpdate(w=>{c.configuration=w});let I=new Set;return{get configuration(){return c.configuration},onClientConfigurationUpdate(w){return c.subscribe(w)},checkoutSessionId:o,apiController:s,configurationApi:c,pciApi:g,coreApi:f,clientSessionApi:x,dialogProvider:e,decodedClientToken:a,locale:t||navigator.language||navigator.languages[0]||"en",paymentMethodOptions:r,updateClientToken(w){try{let M=Yt(w);c.setDefaultHeader("primer-client-token",M.accessToken),g.setDefaultHeader("primer-client-token",M.accessToken),f.setDefaultHeader("primer-client-token",M.accessToken),x.setDefaultHeader("primer-client-token",M.accessToken)}catch{}},async refreshClientConfiguration(){let{data:w,error:M}=await c.getConfiguration();return M||!w?(N.warn("Failed to refresh client configuration:",M),!1):(c.configuration=w,!0)},subscribeToTeardown(w){return I.add(w),()=>{I.delete(w)}},teardown(){n.remove(),I.forEach(w=>w())}}}var mc=100;function uc({height:i,name:t,url:e="",width:r}){let o=new Set,a=window.open(e,t,fc({height:i,width:r}));if(!a)return;function n(){a?.close(),s()}function s(){o.forEach(d=>d()),o.clear(),window.removeEventListener("beforeunload",n)}return window.addEventListener("beforeunload",n),hc(a).then(s),{close:n,focus(){a.focus()},get isOpen(){return a?.closed===!1},onClose(d){return o.add(d),()=>{o.delete(d)}},setContent(d){a.document.write(d)},setUrl(d){a.location.replace(d)}}}var hc=i=>new Promise(t=>{let e=setInterval(()=>{i.closed&&(clearInterval(e),t())},mc)});function fc(i){let t=gc({parent:{left:window.screenLeft,top:window.screenTop,height:window.outerHeight,width:window.outerWidth},popup:i});return yc(t)}var gc=({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}),yc=i=>Object.entries(i).map(t=>t.join("=")).join(","),xo=class extends ut{constructor(){super(...arguments);T(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:Mo()}});if(e||!r)throw e??new te({message:"Unable to tokenize payment method",code:H.TOKENIZATION_ERROR});return r}async handleRequiredAction(e){let r=e.requiredAction?.clientToken;if(!r)throw new It({message:"No client token provided",code:li.MISSING_CLIENT_TOKEN,response:{id:e.id,data:e}});let o=Yt(r);if(!sd(o,this.config.type))throw new It({message:"Invalid client token",code:li.INVALID_CLIENT_TOKEN,response:{id:e.id,data:e}});this.popup?.setUrl(o.redirectUrl);let a=new Promise(u=>{this.popup?.onClose(()=>u({id:""}))}),{promise:n,abort:s}=this.pollStatus(o.statusUrl),d=await Promise.race([a,n]);if(s(),this.popup?.close(),"error"in d)throw d.error;let c=d.id;if(!c){let u=await this.context.pciApi.getResumeStatus(o.statusUrl);if(u.error||!u.data?.id)throw u.error??new Error("Unable to get resume token");c=u.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 fr(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=uc({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(vc({name:e,logoSrc:n,logoAlt:e,message:`Loading ${e}...`}))}},vc=({name:i,logoSrc:t,logoAlt:e,message:r})=>`<html>
|
|
42
|
+
${o}`;function Td(i,t,e){if(e?.status&&e.status>=400&&e.status<500)return!1;if(e?.status&&e.status>=500)return!0;if(i instanceof Error){let r=i.message.toLowerCase();return r.includes("network")||r.includes("timeout")||r.includes("connection")}return!1}function Md(i){let n=1e3*Math.pow(1.1,i),a=.1*n*(Math.random()-.5);return n=Math.max(0,n+a),Math.min(n,3e4)}var wd={attempts:3,retryCondition:Td,delayCalculator:Md,totalTimeout:3e5};async function Id(i,t,e){let r={...wd,...t.retry},o=[],n=Date.now();for(let l=0;l<=r.attempts;l++)try{let c=await i();if(!c.error)return{...c,retryHistory:o.length>0?o:void 0};if(l===r.attempts||!r.retryCondition(c.error,l,c))return{...c,retryHistory:o};let u=r.delayCalculator(l);if(o.push({attempt:l+1,delay:u,error:c.error,timestamp:Date.now()}),Date.now()-n+u>r.totalTimeout){let f=bn({...c,error:new Error("Retry total timeout exceeded")},408,t.method,e||"");return{...c,error:{...f,name:f.name,message:f.message,stack:f.stack,__sdkErrorType:f.name,__needsReconstruction:!0},retryHistory:o}}await tr(u)}catch(c){o.push({attempt:l+1,delay:0,error:c,timestamp:Date.now()})}let a=o[o.length-1]?.error,s;if(a){let l=bn({id:t.id,error:a},500,t.method,e||"");s={...l,name:l.name,message:l.message,stack:l.stack,__sdkErrorType:l.name,__needsReconstruction:!0}}return{id:t.id,error:s,retryHistory:o}}var $t=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 executeFetch(t,e){let r={...e,headers:{...this.defaultHeaders,...e?.headers},id:Te()};return e?.retry?Id(()=>this.fetch(t,{...r,retry:void 0}),r,t):this.fetch(t,r)}async get(t,e){return this.executeFetch(t,{...e,method:"GET"})}async post(t,e,r){return this.executeFetch(t,{...r,method:"POST",body:JSON.stringify(e)})}async delete(t,e){return this.executeFetch(t,{...e,method:"DELETE"})}},ji=class extends $t{constructor(){super(...arguments);N(this,"configurationSubscribers",new Set);N(this,"_configuration")}async getConfiguration(){let e=await this.get(this.baseUrl);return e.data&&(this._configuration=e.data),e}subscribe(e){return this.configurationSubscribers.add(e),()=>{this.configurationSubscribers.delete(e)}}get configuration(){return this._configuration}set configuration(e){this._configuration=e,this.configurationSubscribers.forEach(r=>r(this._configuration))}},Wi=class extends $t{async getPaymentInstruments(){return this.get(`${this.baseUrl}/payment-instruments`)}async postPaymentInstruments(t,e){return this.post(`${this.baseUrl}/payment-instruments`,t==="pci-card-form-data"?t:{paymentInstrument:t,...e})}async postPaymentInstrumentsExchange(t){return this.post(`${this.baseUrl}/payment-instruments/${t}/exchange`,"payment-instrument-exchange")}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,{retry:{attempts:15}})}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)}};async function kd(i){return new Promise((t,e)=>{let r=Yn(i,"api"),o=`${Vl}#${r}`,n=document.querySelector(`iframe[src="${o}"]`)??document.createElement("iframe");n.parentElement?t(n):(n.style.display="none",n.onload=()=>t(n),n.onerror=a=>{e(new Error(`Failed to initialize Primer SDK: ${a}`))},n.src=o,document.body.appendChild(n))})}var Qt=class Qt extends $t{constructor(){super(...arguments);N(this,"onClientSessionUpdate")}setOnClientSessionUpdate(e){this.onClientSessionUpdate=e}async postClientSessionActions(e){if(e.length===0)return Qt.noActionsResponse;let r=await this.post(`${this.baseUrl}/client-session/actions`,{actions:e}),{data:o}=r;return o&&this.onClientSessionUpdate?.(o),r}async selectPaymentMethod(e,r={}){return this.postClientSessionActions([{type:"SELECT_PAYMENT_METHOD",params:{...r,paymentMethodType:e}}])}async unselectPaymentMethod(){return this.postClientSessionActions([{type:"UNSELECT_PAYMENT_METHOD"}])}async selectCardNetwork(e){return this.selectPaymentMethod(se.PAYMENT_CARD,{binData:this.buildCardBinData(e)})}async setBillingAddress(e){let r=this.removeEmptyStringFromObject(e);return Object.values(r).length===0?Qt.noActionsResponse:this.postClientSessionActions([{type:"SET_BILLING_ADDRESS",params:{billingAddress:r}}])}async setShippingAddress(e,r,o){let n=[];return e&&Object.keys(e).some(s=>!!e[s])&&n.push({type:"SET_SHIPPING_ADDRESS",params:{shippingAddress:e}}),r&&n.push({type:"SET_MOBILE_NUMBER",params:{mobileNumber:r}}),o&&n.push({type:"SET_EMAIL_ADDRESS",params:{emailAddress:o}}),this.postClientSessionActions(n)}async selectShippingMethod(e){return this.postClientSessionActions([{type:"SELECT_SHIPPING_METHOD",params:{shippingMethodId:e}}])}async setCustomerDetails({emailAddress:e,firstName:r,lastName:o}){let n=[];return e&&n.push({type:"SET_EMAIL_ADDRESS",params:{emailAddress:e}}),r&&n.push({type:"SET_CUSTOMER_FIRST_NAME",params:{firstName:r}}),o&&n.push({type:"SET_CUSTOMER_LAST_NAME",params:{lastName:o}}),this.postClientSessionActions(n)}buildCardBinData(e){let{backend:r}=to(e);return{network:r,issuer_name:null,product_code:r,product_name:r,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"}}removeEmptyStringFromObject(e){let r={...e};for(let o in r)r[o]===""?delete r[o]:typeof r[o]=="object"&&r[o]!==null&&!Array.isArray(r[o])&&(r[o]=this.removeEmptyStringFromObject(r[o]));return r}};N(Qt,"noActionsResponse",{data:{},error:void 0,headers:{},status:200,id:""});var qi=Qt,Ji=class extends $t{async createPaypalOrder(t){return this.post(`${this.baseUrl}/paypal/orders/create`,t,{retry:{attempts:3}})}async createPaypalBillingAgreement(t){return this.post(`${this.baseUrl}/paypal/billing-agreements/create-agreement`,t,{retry:{attempts:3}})}async confirmPaypalBillingAgreement(t){return this.post(`${this.baseUrl}/paypal/billing-agreements/confirm-agreement`,t,{retry:{attempts:3}})}async createApplePaySession(t){return this.post(`${this.baseUrl}/apple-pay/sessions`,t)}};async function Nd(i,{locale:t,dialogProvider:e,paymentMethodOptions:r}){let o=Te(),n=Dt(i),a=await kd(o),s=ao({namespace:`api-controller-${o}`,onMessage:T=>{let w=S=>T(S.data);return window.addEventListener("message",w),()=>window.removeEventListener("message",w)},sendMessage:T=>{a.contentWindow.postMessage(T,"*")}}),l=Pd(n.accessToken,o),c=new ji(s.fetch,n.configurationUrl,l),{error:u}=await c.getConfiguration();if(u||!c.configuration)throw new Error(`Failed to fetch configuration: ${u}`);let f=new Wi(s.fetch,c.configuration.pciUrl,l),h=new Ji(s.fetch,c.configuration.coreUrl,l),A=new qi(s.fetch,c.configuration.pciUrl,l);A.setOnClientSessionUpdate(T=>{c.configuration=T});let x=new Set;return{get configuration(){return c.configuration},onClientConfigurationUpdate(T){return c.subscribe(T)},checkoutSessionId:o,apiController:s,configurationApi:c,pciApi:f,coreApi:h,clientSessionApi:A,dialogProvider:e,decodedClientToken:n,locale:t||navigator.language||navigator.languages[0]||"en",paymentMethodOptions:r,updateClientToken(T){try{let w=Dt(T);c.setDefaultHeader("primer-client-token",w.accessToken),f.setDefaultHeader("primer-client-token",w.accessToken),h.setDefaultHeader("primer-client-token",w.accessToken),A.setDefaultHeader("primer-client-token",w.accessToken)}catch{}},async refreshClientConfiguration(){let{data:T,error:w}=await c.getConfiguration();return w||!T?(I.warn("Failed to refresh client configuration:",w),!1):(c.configuration=T,!0)},subscribeToTeardown(T){return x.add(T),()=>{x.delete(T)}},teardown(){a.remove(),x.forEach(T=>T())}}}var Ld=100;function Rd({height:i,name:t,url:e="",width:r}){let o=new Set,n=window.open(e,t,Dd({height:i,width:r}));if(!n)return;function a(){n?.close(),s()}function s(){o.forEach(l=>l()),o.clear(),window.removeEventListener("beforeunload",a)}return window.addEventListener("beforeunload",a),Od(n).then(s),{close:a,focus(){n.focus()},get isOpen(){return n?.closed===!1},onClose(l){return o.add(l),()=>{o.delete(l)}},setContent(l){n.document.write(l)},setUrl(l){n.location.replace(l)}}}var Od=i=>new Promise(t=>{let e=setInterval(()=>{i.closed&&(clearInterval(e),t())},Ld)});function Dd(i){let t=$d({parent:{left:window.screenLeft,top:window.screenTop,height:window.outerHeight,width:window.outerWidth},popup:i});return Vd(t)}var $d=({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}),Vd=i=>Object.entries(i).map(t=>t.join("=")).join(","),Zi=class extends at{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:oo()}});if(e||!r)throw e??new ee({message:"Unable to tokenize payment method",code:F.TOKENIZATION_ERROR});return r}async handleRequiredAction(e){let r=e.requiredAction?.clientToken;if(!r)throw new Ct({message:"No client token provided",code:kr.MISSING_CLIENT_TOKEN,response:{id:e.id,data:e}});let o=Dt(r);if(!Ml(o,this.config.type))throw new Ct({message:"Invalid client token",code:kr.INVALID_CLIENT_TOKEN,response:{id:e.id,data:e}});this.popup?.setUrl(o.redirectUrl);let n=new Promise(u=>{this.popup?.onClose(()=>u({id:""}))}),{promise:a,abort:s}=this.pollStatus(o.statusUrl),l=await Promise.race([n,a]);if(s(),this.popup?.close(),"error"in l)throw l.error;let c=l.id;if(!c){let u=await this.context.pciApi.getResumeStatus(o.statusUrl);if(u.error||!u.data?.id)throw u.error??new Error("Unable to get resume token");c=u.data.id}return await this.resumePayment(e.id,c)}pollStatus(e){let r=!0;return{promise:new Promise(async o=>{for(;r;){let{data:n,error:a}=await this.context.pciApi.getResumeStatus(e);if(a)return void o({error:a});if(await tr(1e3),n?.status==="COMPLETE")return void o({id:n.id})}}),abort:()=>{r=!1}}}openPopup(){let{name:e,displayMetadata:{button:r,overlay:o,popup:n}}=this.config;this.popup=Rd({name:e,height:n?.height??500,width:n?.width??1e3});let a=o?.logo.colored||r?.iconUrl.colored||o?.logo.light||r?.iconUrl.light||o?.logo.dark||r?.iconUrl.dark;this.popup?.setContent(Ud({name:e,logoSrc:a,logoAlt:e,message:`Loading ${e}...`}))}},Ud=({name:i,logoSrc:t,logoAlt:e,message:r})=>`<html>
|
|
45
43
|
<head>
|
|
46
44
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
47
45
|
<style>
|
|
@@ -150,7 +148,9 @@ ${o}`;function nc(i,t,e){if(e?.status&&e.status>=400&&e.status<500)return!1;if(e
|
|
|
150
148
|
</div>
|
|
151
149
|
</body>
|
|
152
150
|
</html>
|
|
153
|
-
`;async function bc(i,t){let e=i.configuration.paymentMethods.map(o=>{if(!t.includes(o.type))return null;if(N.debug("Initializing payment method:",o.type),o.implementationType==="WEB_REDIRECT")return new xo(o,i);if(o.type===se.PAYMENT_CARD)return new pi(o,i);if(o.type===se.PAYPAL)return new ui(o,i);if(o.type===se.APPLE_PAY)return new di(o,i);if(o.type===se.GOOGLE_PAY)return new mi(o,i);if(o.type===se.ADYEN_BLIK)return new ci(o,i)}).map(async o=>{if(!o)return null;try{return await o.setup()?o:null}catch(a){return N.warn(`Failed to initialize payment method ${o.config.type}:`,a),null}});return(await Promise.all(e)).filter(o=>!!o)}function Cc(i,t,e){if(!t.configuration.clientSession.customer?.customerId)throw new B({message:"You must provide a `customerId` in the client session to use the Vault Manager."});let r=[];return{async fetchVaultedPaymentMethods(){let{data:o,error:a}=await t.pciApi.getPaymentInstruments();if(a)throw a;if(!o)throw new B({code:ri.VAULT_ERROR,message:"Missing vaulted payment methods data"});return r=o.data,r},async deleteVaultedPaymentMethod(o){if(!r.find(s=>s.id===o))throw new B({code:ri.VAULT_ERROR,message:"deleteVaultedPaymentMethod: the id provided doesn't match any vaulted payment method"});let{error:n}=await t.pciApi.deletePaymentInstrument(o);if(n)throw n;r=r.filter(s=>s.id!==o)},async startPaymentFlow(o){let a=r.find(s=>s.id===o);if(!a)throw new B({code:ri.VAULT_ERROR,message:"startPaymentFlow: the id provided doesn't match any vaulted payment method"});let n=e.find(s=>s.config.type===a.paymentMethodType);if(!n)throw new B({code:ri.TOKENIZATION_ERROR,message:`Payment instrument type ${a.paymentInstrumentType} is not recognized or not supported.`});await fi(i,n,a)},async createCvvInput(o){let a={blur:new Set,change:new Set,focus:new Set},n,s=mr(t.checkoutSessionId,Wa);await new Promise(f=>{s.onload=()=>{f()},(typeof o.container=="string"?document.querySelector(o.container):o.container)?.appendChild(s)}),vo(s,o.style);let d=Io({namespace:`${t.checkoutSessionId}-${Wa}`,onMessage:f=>{let x=I=>f(I.data);return window.addEventListener("message",x),()=>window.removeEventListener("message",x)},sendMessage:f=>{s.contentWindow.postMessage(f,"*")}});function c(f,x){f!=="metadata"&&a[f].add(x)}d.setOnFocus(()=>{a.focus.forEach(f=>f())}),d.setOnBlur(()=>{a.blur.forEach(f=>f())}),d.setOnInput(f=>{n=f,a.change.forEach(x=>x())}),d.setCardNetwork(o.cardNetwork??""),d.setOptions({placeholder:o.placeholder??"123",ariaLabel:o.ariaLabel??"CVV",style:o.style});function u(){s.parentNode&&s.remove()}let g=t.subscribeToTeardown(u);return{frame:s,remove:()=>{g(),u()},get metadata(){return{error:n?.error??"cvvRequired",errorCode:n?.error??"cvvRequired",valid:n?.valid??!1,active:n?.focused??!1,dirty:n?.dirty??!1,touched:n?.touched??!1,submitted:!0}},addEventListener:c,addListener:c,removeListener(f,x){f!=="metadata"&&a[f].delete(x)},blur(){d.blur()},focus(){d.focus()},validate(){d.getFieldState().then(f=>{n=f,a.change.forEach(x=>x(n))})}}}}}async function Tn(i,t){N.debug("createHeadless",t);let e=await pc(i,{locale:t.locale,dialogProvider:t.dialogProvider,paymentMethodOptions:{paypal:t.sdkCore?t.paypal:void 0}}),r=await bc(e,t.enabledPaymentMethods??[se.PAYMENT_CARD]);t.onClientSessionUpdate?.(e.configuration.clientSession),e.onClientConfigurationUpdate(async a=>{t.onClientSessionUpdate?.(a.clientSession)});let o={environment:go?"LOCAL":e.decodedClientToken.env,primerAccountId:e.configuration.primerAccountId,checkoutSessionId:e.checkoutSessionId,clientSessionId:e.configuration.clientSession?.clientSessionId,clientSessionToken:i,sdkVersion:t.sdkVersion};return jl({environment:go?"LOCAL":e.decodedClientToken.env,primerAccountId:o.primerAccountId||"",checkoutSessionId:o.checkoutSessionId,clientSessionId:o.clientSessionId||"",clientSessionToken:o.clientSessionToken,sdkVersion:o.sdkVersion||""}),t.onAvailablePaymentMethodsLoad?.(r.map(a=>({type:a.config.type,managerType:a.config.type===se.PAYMENT_CARD?no.CARD:a.config.implementationType==="NATIVE_SDK"?no.NATIVE:no.REDIRECT}))),{start:()=>Promise.resolve(),createPaymentMethodManager:async(a,n)=>{let s=r.find(({config:d})=>d.type===a);return s?s instanceof pi?Zd(t,e,s,n):s instanceof ui||s instanceof di||s instanceof mi?ec(t,e,s):s instanceof ci?rc(t,e,s):tc(t,e,s):(N.warn(`Payment method ${a} not found`),null)},getSDKUtilities:()=>({getCardNetworkAsset:on,getUIOrderAmount:()=>{let{merchantAmount:a,totalOrderAmount:n,currencyCode:s}=e.configuration.clientSession.order;return xn(e.locale,a??n,s)},getCDNAssets:async a=>{let n=r.find(({config:c})=>c.type===a);if(!n)return;let{backgroundColor:s,iconUrl:d}=n.config.displayMetadata?.button||{};return{assets:{icon:d?.colored||""},colors:{background:s?.colored||"",main:s?.colored||""},description:n.config.name||null,is_primer_app:!1,name:n.config.name,website:null,goatCdnUrl:""}},getPaymentMethodConfiguration:a=>r.find(({config:n})=>n.type===a)?.config,setBillingAddress:async a=>{let{error:n,data:s}=await e.clientSessionApi.setBillingAddress(a);if(n||!s)throw n||new B({message:"Failed to set billing address"})}}),getAnalyticsUtils:()=>o,createVaultManager(){return Cc(t,e,r)},getAssetsManager:()=>({getCardNetworkAsset:on,getPaymentMethodAsset:async a=>{let n=r.find(({config:u})=>u.type===a);if(!n)return null;let{backgroundColor:s,iconUrl:d,text:c}=n.config.displayMetadata?.button||{};return{backgroundColor:s,iconUrl:d,paymentMethodName:c,buttonText:c,displayName:n.config.name}}}),refreshClientSession:e.refreshClientConfiguration,getConfiguration:()=>e.configuration,teardown:()=>e.teardown()}}var on=i=>{let{asset:t,display:e}=_o(i);return{cardUrl:`${bd}/brand/card/${t}.svg`,displayName:e}};var Z={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Ee=i=>(...t)=>({_$litDirective$:i,values:t}),$e=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 gr=class extends $e{constructor(t){if(super(t),this.it=h,t.type!==Z.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===h||t==null)return this._t=void 0,this.it=t;if(t===ee)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;let e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};gr.directiveName="unsafeHTML",gr.resultType=1;var Mn=Ee(gr);var kn=Symbol.for("primer-sdk-core-dialog-access");function In(i){return{token:kn,content:i}}function No(i){return i!==void 0&&i.token===kn&&typeof i.content=="string"}var Nn=y` :host { display: block; } .content-container { width: 100%; height: 100%; display: flex; flex-direction: column; background-color: var(--primer-color-background-outlined-default); } .error { display: flex; align-items: center; justify-content: center; padding: var(--primer-space-large); color: var(--primer-color-text-danger); font-family: var(--primer-typography-body-medium-font); font-size: var(--primer-typography-body-medium-size); } `;var le=class extends v{constructor(){super(...arguments);this.size="large";this.showCloseButton=!1;this.open=!1}openDialog(){this.open=!0}closeDialog(){let e=document.querySelector("primer-dialog");if(e){e.startExitAnimation();let r=()=>{this.open=!1,this.removeEventListener("primer-dialog-close",r)};this.addEventListener("primer-dialog-close",r)}else this.open=!1}renderContent(){return m`<div class="content-container"><slot></slot>${this.renderSecureHtmlContent()}</div>`}renderSecureHtmlContent(){return this.secureHtmlContent?No(this.secureHtmlContent)?m`${Mn(this.secureHtmlContent.content)}`:(A.warn("PortalDialogComponent: Invalid access token provided for htmlContent. Content will not be rendered."),h):h}renderDialog(){return this.open?m`<primer-portal><primer-dialog .open=${this.open} size=${this.size} .showCloseButton=${!1} @primer-dialog-close="${()=>this.closeDialog()}" >${this.renderContent()}</primer-dialog></primer-portal>`:h}connectedCallback(){super.connectedCallback(),this.open||this.openDialog()}updated(e){if(super.updated(e),e.has("secureHtmlContent")){let r=this.secureHtmlContent;r&&!No(r)&&(A.errorWithDatadog("PortalDialogComponent: Invalid access token provided for htmlContent. Content will not be rendered."),this.secureHtmlContent=void 0)}e.has("open")&&this.open&&this.onOpen&&this.onOpen(),e.has("open")&&this.open&&this.onContentRendered&&this.updateComplete.then(()=>{requestAnimationFrame(()=>{this.onContentRendered?.()})})}render(){return m`${this.renderDialog()}`}};le.styles=[P,Nn],l([p({type:String})],le.prototype,"size",2),l([p({type:Boolean})],le.prototype,"showCloseButton",2),l([p({type:Object})],le.prototype,"onOpen",2),l([p({type:Object})],le.prototype,"onContentRendered",2),l([p({type:Object,converter:{fromAttribute:()=>{},toAttribute:()=>null}})],le.prototype,"secureHtmlContent",2),l([_()],le.prototype,"open",2),le=l([b("primer-portal-dialog"),O()],le);var gi=class{constructor(){this.currentDialog=null;this.currentResolver=null}async show(t){return new Promise(e=>{let r=In(t.htmlContent),o=new le;o.secureHtmlContent=r,o.size="large",o.showCloseButton=!1,o.onContentRendered=t.onContentReady;let a=()=>{this.currentDialog=null,this.currentResolver=null,e({success:!1})};o.addEventListener("primer-dialog-close",a),this.currentDialog=o,this.currentResolver=e,document.body.appendChild(o)})}close(){this.currentDialog&&this.currentResolver&&(this.currentDialog.closeDialog(),this.currentResolver({success:!0}),this.currentDialog.remove(),this.currentDialog=null,this.currentResolver=null)}};var yi="0.6.0",vi=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 D(t,{args:()=>[this.host.clientToken,this.host.options],task:this.initializeHeadless()}),new D(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(){if(this.isDisconnected=!0,this.host.sdkContextController.getAnalyticsUtils()){let e=this.host.sdkStateController.currentState;(e.isProcessing||e.isLoading||this.currentSdkInstance)&&q({eventName:"PAYMENT_FLOW_EXITED"})}this.cleanupResources()}normalizeOptionsForLegacySdk(t){if(t.sdkCore!==!1)return t.sdkCore=!0,t;let e={...t};if(e.card?.cardholderName){let r={...e.card.cardholderName};r.visible===!1&&(r.required=!1),e.card={...e.card,cardholderName:r}}return e}setupLoadingTimeout(){this.clearLoadingTimeout(),this.loadingTimeout=setTimeout(()=>{this.host.sdkStateController.currentState.isLoading&&(A.warn("Loading timeout reached, resetting SDK state"),q({eventName:"PAYMENT_FLOW_EXITED",eventType:"timeout"}),this.cleanupResources(),this.host.sdkStateController.completeLoading())},1e4)}clearLoadingTimeout(){this.loadingTimeout!==null&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null)}cleanupResources(){if(this.clearLoadingTimeout(),this.currentSdkInstance)try{this.paymentsList=[],this.createPaymentMethodManager=null,this.host.sdkStateController.reset(),this.currentSdkInstance.teardown?.(),A.info("SDK instance cleaned up")}catch(t){A.errorWithDatadog("Error cleaning up SDK instance",{error:t})}aa(),A.setEnvironment(void 0),A.setSdkVersion(void 0),A.setClientToken(void 0),A.setSdkOptions(void 0),A.setClientSessionId(void 0),this.currentSdkInstance=null,this.primerJS=null}async _loadV2Sdk(t=Oa){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 Da(t),await e.Primer.preloadPrimer()}initializeHeadless(){return async([t,e])=>{if(this.isDisconnected)return A.warn("Component disconnected, aborting SDK initialization"),R;if(!t||!e)return R;this.cleanupResources();let r;try{let o;if(e.sdkCore!==!1){let d=new gi;o={createHeadless:(u,g)=>Tn(u,{...g,dialogProvider:d,sdkVersion:yi})}}else await this._loadV2Sdk(),o=window.Primer;this.primerJS=new Qr(null);let a=this.normalizeOptionsForLegacySdk(e);A.setClientToken(t),A.setSdkOptions(a);let n=await o.createHeadless(t,{...a,onAvailablePaymentMethodsLoad:d=>{this.isDisconnected||(A.info("Configuration payment methods:",d),this.paymentsList=d)},onCheckoutComplete:({payment:d})=>{this.isDisconnected||(A.info("Payment completed:",d),this.host.sdkStateController.completeProcessing(),q({eventName:"PAYMENT_SUCCESS",paymentId:d?.id}),this.primerJS&&this.primerJS.handlePaymentComplete(d))},onCheckoutFail:(d,c)=>{if(this.isDisconnected)return;let u=d;u.response?.status&&u.response.status>=500?A.errorWithDatadog("Payment failed with server error",{error:d}):A.error("Payment failed:",d),this.host.sdkStateController.setFailure(d.code||"UNKNOWN_ERROR",d.message||"Unknown error occurred",{error:d}),q({eventName:"PAYMENT_FAILURE",paymentId:c.payment?.id}),this.primerJS&&this.primerJS.handlePaymentFailure(d,c.payment)},onBeforePaymentCreate:(d,c)=>{if(this.isDisconnected)return;this.host.sdkStateController.currentState.failure!==null&&q({eventName:"PAYMENT_REATTEMPTED",paymentMethod:d.paymentMethodType}),this.host.sdkStateController.startProcessing(),this.primerJS?this.primerJS.handleBeforePaymentCreate(d,c):c?.continuePaymentCreation()},onPaymentMethodAction:(d,c)=>{this.isDisconnected||d==="PAYMENT_METHOD_UNSELECTED"&&this.host.sdkStateController.stopProcessing()},onPaymentCreationStart:()=>{this.isDisconnected||(this.host.sdkStateController.resetError(),this.primerJS&&this.primerJS.handlePaymentStart())}});if(this.createPaymentMethodManager=n.createPaymentMethodManager.bind(n),this.currentSdkInstance=n,this.primerJS&&Object.defineProperty(this.primerJS,"headlessInstance",{value:n,writable:!1}),await n.start(),this.isDisconnected)return this.cleanupResources(),R;this.host.sdkContextController.setClientOptions(e),this.primerJS&&this.host.primerEventsController.dispatchCheckoutInitialized(this.primerJS);let s=n.getSDKUtilities();if(r=n.getAnalyticsUtils?.(),r&&(this.host.sdkContextController.setAnalyticsUtils({...r,sdkVersion:yi}),A.setEnvironment(r.environment),A.setSdkVersion(yi),A.setClientSessionToken(r.clientSessionToken),A.setClientSessionId(r.clientSessionId),oa({environment:r.environment,checkoutSessionId:r.checkoutSessionId,clientSessionId:r.clientSessionId||"",primerAccountId:r.primerAccountId||"",sdkVersion:yi,clientSessionToken:r.clientSessionToken}),q({eventName:"SDK_INIT_START"})),this.host.sdkContextController.setHeadlessUtils(s),e.sdkCore&&n.getConfiguration){let d=n.getConfiguration();this.host.sdkContextController.setConfiguration(d)}return this.host.vaultManagerController.initializeVaultManager(n.createVaultManager.bind(n),{vaultEnabled:e.vault?.enabled,captureVaultedCardCvv:!!s.getPaymentMethodConfiguration("PAYMENT_CARD")?.options?.captureVaultedCardCvv,showEmptyState:e.vault?.showEmptyState}),n}catch(o){throw o instanceof Error&&(A.errorWithDatadog("SDK initialization error",{error:o,status:"error"}),this.host.sdkStateController.setError(o)),this.cleanupResources(),o}}}initializeLitContext(){return async([t,e])=>{if(this.isDisconnected)return R;if(!t||!e.length)return R;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 R;let a=new Xr(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(),q({eventName:"SDK_INIT_END"}))}}}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.errorWithDatadog(`Failed to initialize manager for ${e}`,{error:o}),null}}}};var bi=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 Ec=jo({"../../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")});Wi(i=>Ec(`../../localization/lit-localize/locales/${i}.ts`));var Ac={LOADER_DISABLED:"loader-disabled",CUSTOM_STYLES:"custom-styles",CLIENT_TOKEN:"client-token",JS_INIT:"js-initialized"},Ae=class extends v{constructor(){super();this.customStyles="";this.clientToken="";this.options={};this.disableLoader=!1;this._jsInitialized=!1;this.previousLoadingState=!0;this.hasAssignedContent=!1;this._loadingTimeoutId=null;this._eventListenerController=null;this.locale="en-GB";this.onSlotChange=e=>{let o=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=o.length>0,this.requestUpdate()};this.sdkContextController=new kr(this),this.sdkStateController=new Tr(this),this.primerEventsController=new Ot(this),this.styleProcessingController=new Ir(this),this.vaultManagerController=new Zt(this),this.cardNetworkController=new Ar(this),this.achPaymentEventsController=new bi(this),new vi(this)}set jsInitialized(e){this.requestUpdate(),this._jsInitialized=e}get jsInitialized(){return this._jsInitialized}connectedCallback(){super.connectedCallback(),this.sdkContextController.setEventsController(this.primerEventsController),this._eventListenerController=new AbortController,document.addEventListener("primer:card-submit",this.handleExternalCardSubmit.bind(this),{signal:this._eventListenerController.signal})}attributeChangedCallback(e,r,o){e===Ac.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(),this._eventListenerController&&(this._eventListenerController.abort(),this._eventListenerController=null),super.disconnectedCallback()}willUpdate(e){e.has("options")&&(this.options?.locale&&(Zi(this.options?.locale)?this.locale=Xi(this.options?.locale):A.warn("\u{1F30E}\u2757 Unsupported locale provided:",this.options?.locale,"- Falling back to default locale `en-GB`")),qi(this.locale||"en-GB"))}updated(){let e=getComputedStyle(this);this.sdkContextController.setComputedStyles(e),this.checkLoadingStateChange()}handleExternalCardSubmit(e){this._eventListenerController?.signal.aborted||e.target!==this&&this.primerEventsController.dispatchEvent("primer:card-submit",e.detail)}checkLoadingStateChange(){let e=this.sdkStateController?.currentState.isLoading||!1;this.previousLoadingState&&!e&&(this.jsInitialized=!0,q({eventName:"CHECKOUT_FLOW_STARTED"})),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` ${k(r,()=>h)} ${k(o,()=>m`<primer-checkout-error></primer-checkout-error>`)} ${k(a,()=>m`<slot name="main" @slotchange=${this.onSlotChange}></slot>${k(this.hasAssignedContent,()=>h,()=>m`<primer-main></primer-main>`)} `,()=>h)} `}addEventListener(e,r,o){super.addEventListener(e,r,o)}removeEventListener(e,r,o){super.removeEventListener(e,r,o)}};Ae.styles=[P,Ra],l([p({type:String,attribute:"custom-styles"})],Ae.prototype,"customStyles",2),l([p({type:String,attribute:"client-token"})],Ae.prototype,"clientToken",2),l([p({type:Object})],Ae.prototype,"options",2),l([p({type:Boolean,attribute:"loader-disabled"})],Ae.prototype,"disableLoader",2),l([p({type:Boolean,reflect:!0,attribute:"js-initialized"})],Ae.prototype,"_jsInitialized",2),l([mt("slot")],Ae.prototype,"defaultSlot",2),l([_()],Ae.prototype,"previousLoadingState",2),Ae=l([O(),b("primer-checkout")],Ae);function xc(i){return document.querySelector(`#${i}`)}function Sc(i,t){let e=document.createElement("style");return e.textContent=i,e.id=t,e}function yr(i,t,e=!0){if(!ei||xc(t))return;let o=Sc(i,t);e&&document.head.firstChild?document.head.insertBefore(o,document.head.firstChild):document.head.appendChild(o)}var Ln=`
|
|
151
|
+
`;async function Yd(i,t){let e=i.configuration.paymentMethods.map(o=>{if(!t.includes(o.type))return null;if(I.debug("Initializing payment method:",o.type),o.implementationType==="WEB_REDIRECT")return new Zi(o,i);if(o.type===se.PAYMENT_CARD)return new Rr(o,i);if(o.type===se.PAYPAL)return new Dr(o,i);if(o.type===se.APPLE_PAY)return new Nr(o,i);if(o.type===se.GOOGLE_PAY)return new Or(o,i);if(o.type===se.ADYEN_BLIK)return new Lr(o,i)}).map(async o=>{if(!o)return null;try{return await o.setup()?o:null}catch(n){return I.warn(`Failed to initialize payment method ${o.config.type}:`,n),null}});return(await Promise.all(e)).filter(o=>!!o)}function Bd(i,t,e){if(!t.configuration.clientSession.customer?.customerId)throw new Y({message:"You must provide a `customerId` in the client session to use the Vault Manager."});let r=[];return{async fetchVaultedPaymentMethods(){let{data:o,error:n}=await t.pciApi.getPaymentInstruments();if(n)throw n;if(!o)throw new Y({code:xr.VAULT_ERROR,message:"Missing vaulted payment methods data"});return r=o.data,r},async deleteVaultedPaymentMethod(o){if(!r.find(s=>s.id===o))throw new Y({code:xr.VAULT_ERROR,message:"deleteVaultedPaymentMethod: the id provided doesn't match any vaulted payment method"});let{error:a}=await t.pciApi.deletePaymentInstrument(o);if(a)throw a;r=r.filter(s=>s.id!==o)},async startPaymentFlow(o){let n=r.find(s=>s.id===o);if(!n)throw new Y({code:xr.VAULT_ERROR,message:"startPaymentFlow: the id provided doesn't match any vaulted payment method"});let a=e.find(s=>s.config.type===n.paymentMethodType);if(!a)throw new Y({code:xr.TOKENIZATION_ERROR,message:`Payment instrument type ${n.paymentInstrumentType} is not recognized or not supported.`});await Vr(i,a,n)},async createCvvInput(o){let n={blur:new Set,change:new Set,focus:new Set},a,s=Xt(t.checkoutSessionId,cn);await new Promise(h=>{s.onload=()=>{h()},(typeof o.container=="string"?document.querySelector(o.container):o.container)?.appendChild(s)}),Gi(s,o.style);let l=ao({namespace:`${t.checkoutSessionId}-${cn}`,onMessage:h=>{let A=x=>h(x.data);return window.addEventListener("message",A),()=>window.removeEventListener("message",A)},sendMessage:h=>{s.contentWindow.postMessage(h,"*")}});function c(h,A){h!=="metadata"&&n[h].add(A)}l.setOnFocus(()=>{n.focus.forEach(h=>h())}),l.setOnBlur(()=>{n.blur.forEach(h=>h())}),l.setOnInput(h=>{a=h,n.change.forEach(A=>A())}),l.setCardNetwork(o.cardNetwork??""),l.setOptions({placeholder:o.placeholder??"123",ariaLabel:o.ariaLabel??"CVV",style:o.style});function u(){s.parentNode&&s.remove()}let f=t.subscribeToTeardown(u);return{frame:s,remove:()=>{f(),u()},get metadata(){return{error:a?.error??"cvvRequired",errorCode:a?.error??"cvvRequired",valid:a?.valid??!1,active:a?.focused??!1,dirty:a?.dirty??!1,touched:a?.touched??!1,submitted:!0}},addEventListener:c,addListener:c,removeListener(h,A){h!=="metadata"&&n[h].delete(A)},blur(){l.blur()},focus(){l.focus()},validate(){l.getFieldState().then(h=>{a=h,n.change.forEach(A=>A(a))})}}}}}async function Hn(i,t){I.debug("createHeadless",t);let e=await Nd(i,{locale:t.locale,dialogProvider:t.dialogProvider,paymentMethodOptions:{paypal:t.sdkCore?t.paypal:void 0}}),r=await Yd(e,t.enabledPaymentMethods??[se.PAYMENT_CARD]);t.onClientSessionUpdate?.(e.configuration.clientSession),e.onClientConfigurationUpdate(async n=>{t.onClientSessionUpdate?.(n.clientSession)});let o={environment:zi?"LOCAL":e.decodedClientToken.env,primerAccountId:e.configuration.primerAccountId,checkoutSessionId:e.checkoutSessionId,clientSessionId:e.configuration.clientSession?.clientSessionId,clientSessionToken:i,sdkVersion:t.sdkVersion};return ul({environment:zi?"LOCAL":e.decodedClientToken.env,primerAccountId:o.primerAccountId||"",checkoutSessionId:o.checkoutSessionId,clientSessionId:o.clientSessionId||"",clientSessionToken:o.clientSessionToken,sdkVersion:o.sdkVersion||"",userAgent:typeof navigator<"u"?navigator.userAgent:"unknown"}),t.onAvailablePaymentMethodsLoad?.(r.map(n=>({type:n.config.type,managerType:n.config.type===se.PAYMENT_CARD?Ri.CARD:n.config.implementationType==="NATIVE_SDK"?Ri.NATIVE:Ri.REDIRECT}))),{start:()=>Promise.resolve(),createPaymentMethodManager:async(n,a)=>{let s=r.find(({config:l})=>l.type===n);return s?s instanceof Rr?vd(t,e,s,a):s instanceof Dr||s instanceof Nr||s instanceof Or?Cd(t,e,s):s instanceof Lr?Sd(t,e,s):Ad(t,e,s):(I.warn(`Payment method ${n} not found`),null)},getSDKUtilities:()=>({getCardNetworkAsset:En,getUIOrderAmount:()=>{let{merchantAmount:n,totalOrderAmount:a,currencyCode:s}=e.configuration.clientSession.order;return Vn(e.locale,n??a,s)},getCDNAssets:async n=>{let a=r.find(({config:c})=>c.type===n);if(!a)return;let{backgroundColor:s,iconUrl:l}=a.config.displayMetadata?.button||{};return{assets:{icon:l?.colored||""},colors:{background:s?.colored||"",main:s?.colored||""},description:a.config.name||null,is_primer_app:!1,name:a.config.name,website:null,goatCdnUrl:""}},getPaymentMethodConfiguration:n=>r.find(({config:a})=>a.type===n)?.config,setBillingAddress:async n=>{let{error:a,data:s}=await e.clientSessionApi.setBillingAddress(n);if(a||!s)throw a||new Y({message:"Failed to set billing address"})}}),getAnalyticsUtils:()=>o,createVaultManager(){return Bd(t,e,r)},getAssetsManager:()=>({getCardNetworkAsset:En,getPaymentMethodAsset:async n=>{let a=r.find(({config:u})=>u.type===n);if(!a)return null;let{backgroundColor:s,iconUrl:l,text:c}=a.config.displayMetadata?.button||{};return{backgroundColor:s,iconUrl:l,paymentMethodName:c,buttonText:c,displayName:a.config.name}}}),refreshClientSession:e.refreshClientConfiguration,getConfiguration:()=>e.configuration,teardown:()=>e.teardown()}}var En=i=>{let{asset:t,display:e}=to(i);return{cardUrl:`${Yl}/brand/card/${t}.svg`,displayName:e}},Fd=new Set(["paymentMethodType","last4Digits","network","accountNumberLastFourDigits","bankName"]);function Ut(i){let{id:t,orderId:e,paymentMethodData:r}=i,o={id:t,orderId:e};if(!r||typeof r!="object")return o;let n={};for(let[a,s]of Object.entries(r))Fd.has(a)&&(n[a]=s);return o.paymentMethodData=n,o}var Hd=new Set(["last4Digits","network","accountNumberLastFourDigits","bankName","accountType","email"]);function zn(i){let{id:t,analyticsId:e,paymentMethodType:r,paymentInstrumentType:o,paymentInstrumentData:n,userDescription:a}=i,s={id:t,analyticsId:e,paymentMethodType:r,paymentInstrumentType:o};if(a&&(s.userDescription=a),!n||typeof n!="object")return s;let l={};for(let[c,u]of Object.entries(n))Hd.has(c)&&(l[c]=u);return Object.keys(l).length>0&&(s.paymentInstrumentData=l),s}var Yt=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})}handleExternalCardSubmit(t){this.dispatchCardSubmit(t.source)}dispatchPaymentStart(){this.dispatchEvent("primer:payment-start",void 0)}dispatchPaymentSuccess(t,e){let r=Ut(t),o=Math.floor(Date.now()/1e3);this.dispatchEvent("primer:payment-success",{paymentSummary:r,paymentMethodType:e,timestamp:o})}dispatchPaymentFailure(t,e,r){let o=Math.floor(Date.now()/1e3),n=r?Ut(r):void 0;this.dispatchEvent("primer:payment-failure",{error:t,paymentSummary:n,paymentMethodType:e,timestamp:o})}dispatchVaultMethodsUpdate(t){let e=Math.floor(Date.now()/1e3);this.dispatchEvent("primer:vault:methods-update",{vaultedPayments:t,timestamp:e})}};var st=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 Bt=class{constructor(t,e,r,o){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(n,a)=>{this.unsubscribe&&(this.unsubscribe!==a&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=n,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(n,a)),this.unsubscribe=a},this.host=t,e.context!==void 0){let n=e;this.context=n.context,this.callback=n.callback,this.subscribe=n.subscribe??!1}else this.context=e,this.callback=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 st(this.context,this.host,this.t,this.subscribe))}};var Ur=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 so=class extends Event{constructor(t,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e}},z=class extends Ur{constructor(t,e,r){super(e.context!==void 0?e.initialValue:r),this.onContextRequest=o=>{if(o.context!==this.context)return;let n=o.contextTarget??o.composedPath()[0];n!==this.host&&(o.stopPropagation(),this.addCallback(o.callback,n,o.subscribe))},this.onProviderRequest=o=>{if(o.context!==this.context||(o.contextTarget??o.composedPath()[0])===this.host)return;let n=new Set;for(let[a,{consumerHost:s}]of this.subscriptions)n.has(a)||(n.add(a),s.dispatchEvent(new st(this.context,s,a,!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 so(this.context,this.host))}};function C({context:i,subscribe:t}){return(e,r)=>{typeof r=="object"?r.addInitializer((function(){new Bt(this,{context:i,callback:o=>{e.set.call(this,o)},subscribe:t})})):e.constructor.addInitializer((o=>{new Bt(o,{context:i,callback:n=>{o[r]=n},subscribe:t})}))}}var lt=Symbol("analytics-context");var Ft=Symbol("events-context");var Yr="cardNetworksContext";var me="clientOptionsContext";var Ht="computedStylesContext";var H="headlessInstanceContext";var Br="configuration";var Fr="klarnaCategoriesContext";var K="managerContext";var dt="paymentMethodsContext";var G="sdkStateContext";var ue="vaultManagerContext";var Oe="vaultManagerCvvContext";function zd(i,t,e,r){let o=i,n=e;return{dispatch:a=>{let s=o,l=t(o,a,n);Kn(s,l)?o=l:(o=l,r(l))},getState:()=>Object.freeze({...o}),setCallbacks:a=>{n={...n,...a}}}}function Kn(i,t){if(i===t)return!0;if(i==null||t==null||typeof i!="object"||typeof t!="object")return!1;let e=Object.keys(i),r=Object.keys(t);if(e.length!==r.length)return!1;for(let o of e){if(!r.includes(o))return!1;let n=i[o],a=t[o];if(typeof n=="object"&&typeof a=="object"){if(!Kn(n,a))return!1}else if(n!==a)return!1}return!0}function lo(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 At=class{constructor(t,e,r,o,n=()=>{this.host.requestUpdate()}){this.host=t;this.stateHandler=n;this.host.addController(this),this._dispatcher=zd(e,r,o,a=>{this.stateHandler(a)})}get currentState(){return this._dispatcher.getState()}dispatch(t){this._dispatcher.dispatch(t)}setCallbacks(t){this._dispatcher.setCallbacks(t)}hostConnected(){}hostDisconnected(){}},Hr=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 Gn={isSuccessful:!1,isProcessing:!1,isLoading:!1,primerJsError:null,paymentFailure:null},jn=Gn;function Kd(i,t){switch(t.type){case"SET_LOADING":return{...i,isLoading:t.payload};case"SET_PROCESSING":return{...i,isProcessing:t.payload,...t.payload&&{primerJsError:null,paymentFailure:null}};case"SET_SUCCESS":return{...i,isSuccessful:t.payload};case"SET_PRIMER_JS_ERROR":return{...i,primerJsError:t.payload};case"SET_PAYMENT_FAILURE":return{...i,isProcessing:!1,paymentFailure:t.payload};case"COMPLETE_PROCESSING":return{...i,isProcessing:!1,isSuccessful:!0};case"RESET":return{isSuccessful:!1,isProcessing:!1,isLoading:!1,primerJsError:null,paymentFailure:null};default:return i}}var zr=class extends At{constructor(t){super(t,Gn,Kd,null,e=>{t.sdkContextController.setSdkState(e),t.primerEventsController.dispatchSdkState(e)})}setLoading(t){this.dispatch({type:"SET_LOADING",payload:t})}setProcessing(t){this.dispatch({type:"SET_PROCESSING",payload:t})}setSuccess(t){this.dispatch({type:"SET_SUCCESS",payload:t})}setPrimerJsError(t){this.dispatch({type:"SET_PRIMER_JS_ERROR",payload:t})}setPaymentFailure(t){this.dispatch({type:"SET_PAYMENT_FAILURE",payload:t})}completeProcessing(){this.dispatch({type:"COMPLETE_PROCESSING"})}reset(){this.dispatch({type:"RESET"})}startLoading(){this.setLoading(!0)}completeLoading(){this.setLoading(!1)}startProcessing(){this.setProcessing(!0)}stopProcessing(){this.setProcessing(!1)}resetError(){this.setPrimerJsError(null),this.setPaymentFailure(null)}forceCompleteLoading(){this.setLoading(!1)}};var Kr=class{constructor(t){this.sdkStateProvider=null;this.paymentMethodsProvider=null;this.paymentManagerProvider=null;this.cardNetworksContext=null;this.vaultManagerCvvProvider=null;this.clientOptionsContext=null;this.headlessUtilsProvider=null;this.configurationProvider=null;this.klarnaCategoriesProvider=null;this.computedStylesProvider=null;this.analyticsProvider=null;this.eventsProvider=null;(this.host=t).addController(this),this.sdkStateProvider=new z(t,{context:G,initialValue:jn}),this.paymentMethodsProvider=new z(t,{context:dt,initialValue:null}),this.paymentManagerProvider=new z(t,{context:K,initialValue:new Map}),this.cardNetworksContext=new z(t,{context:Yr,initialValue:null}),this.vaultManagerProvider=new z(t,{context:ue,initialValue:null}),this.vaultManagerCvvProvider=new z(t,{context:Oe,initialValue:null}),this.clientOptionsContext=new z(t,{context:me,initialValue:null}),this.klarnaCategoriesProvider=new z(t,{context:Fr,initialValue:{categories:[],isLoading:!0}}),this.headlessUtilsProvider=new z(t,{context:H,initialValue:null}),this.configurationProvider=new z(t,{context:Br,initialValue:null}),this.computedStylesProvider=new z(t,{context:Ht,initialValue:null}),this.analyticsProvider=new z(t,{context:lt,initialValue:null}),this.eventsProvider=new z(t,{context:Ft,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)}setConfiguration(t){this.configurationProvider?.setValue(t)}setAnalyticsUtils(t){this.analyticsProvider?.setValue(t)}getAnalyticsUtils(){return this.analyticsProvider?.value}setComputedStyles(t){this.computedStylesProvider?.setValue(t)}setVaultManagerCvv(t){this.vaultManagerCvvProvider?.setValue(t)}setEventsController(t){this.eventsProvider?.setValue(t)}};var co=class{constructor(){N(this,"context",null)}initialize(t){this.context=t,P.debug("Session context initialized:",{checkoutSessionId:t.checkoutSessionId,clientSessionId:t.clientSessionId,primerAccountId:t.primerAccountId,environment:t.environment})}getContext(){return this.context}clear(){P.debug("Session context cleared"),this.context=null}isInitialized(){return this.context!==null}},zt=new co;var Gd={LOCAL:"https://analytics.dev.data.primer.io/v1/sdk-logs",DEV:"https://analytics.dev.data.primer.io/v1/sdk-logs",STAGING:"https://analytics.staging.data.primer.io/v1/sdk-logs",SANDBOX:"https://analytics.sandbox.data.primer.io/v1/sdk-logs",PRODUCTION:"https://analytics.production.data.primer.io/v1/sdk-logs"};function Wn(i,t){let e=zt.getContext(),o={message:i instanceof Error?i.message:typeof i=="string"?i:JSON.stringify(i)};i instanceof Error&&i.stack&&(o.stack=i.stack),e?(o.checkoutSessionId=e.checkoutSessionId,o.clientSessionId=e.clientSessionId,o.primerAccountId=e.primerAccountId,o.userAgent=e.userAgent):(t?.checkoutSessionId&&(o.checkoutSessionId=t.checkoutSessionId),t?.clientSessionId&&(o.clientSessionId=t.clientSessionId),t?.primerAccountId&&(o.primerAccountId=t.primerAccountId),t?.userAgent&&(o.userAgent=t.userAgent)),t?.metadata&&Object.assign(o,t.metadata),t.status&&Object.assign(o,{status:t.status});let n={message:JSON.stringify(o),hostname:typeof window<"u"?window.location.hostname:"unknown",service:"web-sdk",ddsource:"lambda",ddtags:`env:${e?.environment||t?.environment},version:${e?.sdkVersion||t?.sdkVersion}`};jd(n,{environment:e?.environment||t?.environment,clientSessionToken:e?.clientSessionToken||t?.clientSessionToken})}function jd(i,{environment:t,clientSessionToken:e}){if(t==="LOCAL"){P.debug("\u{1F436}\u{1F436}\u{1F436} [Datadog Log] \u{1F436}\u{1F436}\u{1F436}",i);return}let r=Gd[t||"LOCAL"];if(!r){P.warn("No logging endpoint configured for current environment");return}fetch(r,{method:"POST",headers:{"Content-Type":"application/json",...e&&{Authorization:`Bearer ${e}`}},body:JSON.stringify(i)}).catch(o=>{P.error("Failed to send log event:",o)})}var U=class U{static log(t,...e){U.enabled}static info(t,...e){U.enabled}static warn(t,...e){U.enabled}static error(t,...e){U.enabled&&e.forEach(r=>{r instanceof Error&&r.toJSON})}static errorWithDatadog(t,e){let{error:r,status:o="error"}=e||{};if(U.enabled){r instanceof Error&&r.toJSON;try{let n=r||t,a={status:o,metadata:{sdkOptions:U.sdkOptions,clientToken:U.clientToken}};Wn(n,a)}catch{U.enabled}}}static debug(t,...e){U.enabled}static table(t,e){U.enabled}static time(t){U.enabled}static timeEnd(t){U.enabled}static setSdkOptions(t){U.sdkOptions=t}static setClientToken(t){U.clientToken=t}};N(U,"enabled",!0),N(U,"sdkOptions"),N(U,"clientToken"),N(U,"defaultFont","font-family: Consolas, monospace; font-size: 12px;"),N(U,"brandTag","[PRIMER]"),N(U,"brandStyle",`background: #24292e; color: #ffffff; padding: 2px 6px; border-radius: 3px; font-weight: bold; margin-right: 4px; ${U.defaultFont}`),N(U,"styles",{log:`color: #4CAF50; ${U.defaultFont}`,info:`color: #2196F3; ${U.defaultFont}`,warn:`color: #FF9800; ${U.defaultFont}`,error:`color: #F44336; ${U.defaultFont}`,debug:`color: #9C27B0; ${U.defaultFont}`});var P=U;var St=class St{constructor(t){(this.host=t).addController(this)}processCustomStyles(t){try{let e=JSON.parse(t);this.applyStyles(e)}catch(e){P.error("Error parsing customStyles property.",e instanceof Error?e:new Error(String(e)))}}isValidCssProperty(t){return/^[a-zA-Z][a-zA-Z0-9]*$/.test(t)}isValidCssValue(t){let r=/^[\w\s#.,%()\-+/!]+$/.test(t);return r||P.warn(`Rejected potentially unsafe CSS value: ${t}`),r}getCssVarName(t){let e=St.cssVarCache.get(t);return e||(e=`--${t.replace(/([A-Z])/g,(r,o)=>`-${o.toLowerCase()}`)}`,St.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)){P.warn(`Skipping invalid CSS property name: ${r}`);continue}if(!this.isValidCssValue(o))continue;let n=this.getCssVarName(r);e.push([n,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 St.cssVarCache.keys()){let e=St.cssVarCache.get(t);e&&this.host.style.removeProperty(e)}}hostDisconnected(){}};St.cssVarCache=new Map;var Gr=St;var jr=globalThis,qr=jr.ShadowRoot&&(jr.ShadyCSS===void 0||jr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Jn=Symbol(),qn=new WeakMap,Wr=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==Jn)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(qr&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=qn.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&qn.set(e,t))}return t}toString(){return this.cssText}},Zn=i=>new Wr(typeof i=="string"?i:i+"",void 0,Jn);var po=(i,t)=>{if(qr)i.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of t){let r=document.createElement("style"),o=jr.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=e.cssText,i.appendChild(r)}},Jr=qr?i=>i:i=>i instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return Zn(e)})(i):i;var{is:Wd,defineProperty:qd,getOwnPropertyDescriptor:Jd,getOwnPropertyNames:Zd,getOwnPropertySymbols:Xd,getPrototypeOf:Qd}=Object,ct=globalThis,Xn=ct.trustedTypes,ec=Xn?Xn.emptyScript:"",tc=ct.reactiveElementPolyfillSupport,rr=(i,t)=>i,mo={toAttribute(i,t){switch(t){case Boolean:i=i?ec: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}},Zr=(i,t)=>!Wd(i,t),Qn={attribute:!0,type:String,converter:mo,reflect:!1,hasChanged:Zr};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),ct.litPropertyMetadata??(ct.litPropertyMetadata=new WeakMap);var Pt=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=Qn){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&&qd(this.prototype,t,o)}}static getPropertyDescriptor(t,e,r){let{get:o,set:n}=Jd(this.prototype,t)??{get(){return this[e]},set(a){this[e]=a}};return{get(){return o?.call(this)},set(a){let s=o?.call(this);n.call(this,a),this.requestUpdate(t,s,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Qn}static _$Ei(){if(this.hasOwnProperty(rr("elementProperties")))return;let t=Qd(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(rr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(rr("properties"))){let e=this.properties,r=[...Zd(e),...Xd(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(Jr(o))}else t!==void 0&&e.push(Jr(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 po(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 n=(r.converter?.toAttribute!==void 0?r.converter:mo).toAttribute(e,r.type);this._$Em=t,n==null?this.removeAttribute(o):this.setAttribute(o,n),this._$Em=null}}_$AK(t,e){let r=this.constructor,o=r._$Eh.get(t);if(o!==void 0&&this._$Em!==o){let n=r.getPropertyOptions(o),a=typeof n.converter=="function"?{fromAttribute:n.converter}:n.converter?.fromAttribute!==void 0?n.converter:mo;this._$Em=o,this[o]=a.fromAttribute(e,n.type),this._$Em=null}}requestUpdate(t,e,r){if(t!==void 0){if(r??(r=this.constructor.getPropertyOptions(t)),!(r.hasChanged??Zr)(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,n]of this._$Ep)this[o]=n;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[o,n]of r)n.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.P(o,this[o],n)}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){}};Pt.elementStyles=[],Pt.shadowRootOptions={mode:"open"},Pt[rr("elementProperties")]=new Map,Pt[rr("finalized")]=new Map,tc?.({ReactiveElement:Pt}),(ct.reactiveElementVersions??(ct.reactiveElementVersions=[])).push("2.0.4");var pt={INITIAL:0,PENDING:1,COMPLETE:2,ERROR:3},R=Symbol(),D=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??ea,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 n=!1;try{e=await this.v(t,{signal:this.q.signal})}catch(a){n=!0,r=a}if(this.p===o){if(e===R)this.i=0;else{if(n===!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)}}},ea=(i,t)=>i===t||i.length===t.length&&i.every(((e,r)=>!Zr(e,t[r])));var Xr=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}},Qr=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 rc={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:()=>ta},ic={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:()=>ra},oc=lo(rc),nc=lo(ic),ta={enabled:!1,isLoading:!1,isUpdating:!1,cvvRecapture:!1,showEmptyState:!0,vaultedPaymentMethods:[],createCvvInput:null,deleteVaultedPaymentMethod:()=>Promise.resolve(),startVaultedPaymentFlow:()=>Promise.resolve()},ra={cvvInput:null,formIsDirty:!1,setCvvInput:()=>{},selectedVaultedPaymentMethod:null,setSelectedVaultedPaymentMethod:()=>{}},uo=class extends At{constructor(t,e){super(t,ta,oc,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"})}},ho=class extends At{constructor(t,e){super(t,ra,nc,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"})}},ir=class extends Hr{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){let o=r instanceof Error?r:new Error("Failed to delete payment method");throw this.coreController.setError(o),this.host.sdkStateController.setPrimerJsError(o),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(n){P.errorWithDatadog("VaultManagerController: Error starting vaulted payment flow",{error:n});let a=n instanceof Error?n:new Error("Failed to start vaulted payment flow");this.coreController.setError(a),this.host.sdkStateController.setPrimerJsError(a),this.host.sdkStateController.stopProcessing()}};this.setSelectedVaultedPaymentMethod=e=>{this.itemController.setSelectedPaymentMethod(e),this.itemController.setFormDirty(!1)};this.coreController=new uo(e,{deleteVaultedPaymentMethod:this.deleteVaultedPaymentMethod.bind(this),startVaultedPaymentFlow:this.startVaultedPaymentFlow.bind(this),createCvvInput:this.createCvvInput}),this.itemController=new ho(e,{setCvvInput:this.setCvvInput.bind(this),setSelectedVaultedPaymentMethod:this.setSelectedVaultedPaymentMethod.bind(this)}),this.addController(this.coreController),this.addController(this.itemController),new D(this.host,{task:async([r,o])=>{if(!r||!o?.vaultEnabled)return this.coreController.disable(),R;this.coreController.setLoading(!0);try{let n=r();this._vaultManager=n,this.coreController.initializeVaultManager(n,o.vaultEnabled,!!o.captureVaultedCardCvv,o.showEmptyState??!0),this.itemController.initializeCvv(n.createCvvInput),await this.fetchVaultedPaymentMethods(!0),P.log("VaultManagerController: Vault initialized successfully",{coreState:this.coreController.currentState,cvvState:this.itemController.currentState})}catch(n){P.errorWithDatadog("VaultManagerController: Failed to initialize vault",{error:n});let a=n instanceof Error?n:new Error("Unknown error");this.coreController.setError(a),this.host.sdkStateController.setPrimerJsError(a)}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()}createVaultedPaymentsWrapper(e){let r=new Map;for(let o of e){let n=zn(o);r.set(n.id,n)}return new Qr(r)}updatePaymentMethodsWithEvents(e){this.coreController.updatePaymentMethods(e);let r=this.createVaultedPaymentsWrapper(e);this.host.primerEventsController.dispatchVaultMethodsUpdate(r),this.host.primerJS?.handleVaultedMethodsUpdate(r),P.log("VaultManagerController: Dispatched vault methods update",{methodCount:e.length,filteredMethodCount:r.size()})}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 P.log("VaultManagerController: Fetched payment methods",r),this.updatePaymentMethodsWithEvents(r),r}catch(r){let o=r instanceof Error?r:new Error("Failed to fetch payment methods");throw this.coreController.setError(o),this.host.sdkStateController.setPrimerJsError(o),r}}};var ia=()=>oa.randomUUID?.()||ac(),ac=()=>("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,i=>(i^sc()>>i/4).toString(16)),sc=()=>(oa.getRandomValues?.(new Uint8Array(1))[0]??Math.random()*16)&15,oa=typeof crypto<"u"?crypto:{};var lc={LOCAL:"",DEV:"https://analytics.dev.data.primer.io/v1/sdk-analytic-events",STAGING:"https://analytics.staging.data.primer.io/v1/sdk-analytic-events",SANDBOX:"https://analytics.sandbox.data.primer.io/v1/sdk-analytic-events",PRODUCTION:"https://analytics.production.data.primer.io/v1/sdk-analytic-events"},go=class{sendEvent(t){let e=zt.getContext();if(!e){P.error("Session context not initialized. Call initializeAnalytics() first.");return}let r={id:ia(),timestamp:Math.floor(Date.now()/1e3),sdkType:"WEB",eventName:t.eventName,checkoutSessionId:e.checkoutSessionId,clientSessionId:e.clientSessionId,primerAccountId:e.primerAccountId,sdkVersion:e.sdkVersion,userAgent:e.userAgent,eventType:t.eventType,userLocale:t.userLocale,paymentMethod:t.paymentMethod,paymentId:t.paymentId,redirectDestinationUrl:t.redirectDestinationUrl,threedsProvider:t.threedsProvider,threedsResponse:t.threedsResponse};cc(r,e)}},dc=new go;function na(i){let t={...i,userAgent:i.userAgent||(typeof navigator<"u"?navigator.userAgent:"")};zt.initialize(t)}function J(i){dc.sendEvent(i)}function aa(){zt.clear()}async function cc(i,{environment:t,clientSessionToken:e}){if(t==="LOCAL"){P.debug(`Analytics event ${i.eventName}:`,i);return}let r=lc[t];return fetch(r,{method:"POST",headers:{"Content-Type":"application/json",...e&&{Authorization:`Bearer ${e}`}},body:JSON.stringify(i)}).catch(o=>{P.error("Failed to send analytics event:",o)})}var or="lit-localize-status";var sa=i=>typeof i!="string"&&"strTag"in i,ei=(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 nr=(i=>sa(i)?ei(i.strings,i.values):i);var E=nr,la=!1;function fo(i){if(la)throw new Error("lit-localize can only be configured once");E=i,la=!0}var yo=class{constructor(t){this.__litLocalizeEventHandler=e=>{e.detail.status==="ready"&&this.host.requestUpdate()},this.host=t}hostConnected(){window.addEventListener(or,this.__litLocalizeEventHandler)}hostDisconnected(){window.removeEventListener(or,this.__litLocalizeEventHandler)}},pc=i=>i.addController(new yo(i)),da=pc;var O=()=>(i,t)=>(i.addInitializer(da),i);var ar=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 We=[];for(let i=0;i<256;i++)We[i]=(i>>4&15).toString(16)+(i&15).toString(16);function ca(i){let t=0,e=8997,r=0,o=33826,n=0,a=40164,s=0,l=52210;for(let c=0;c<i.length;c++)e^=i.charCodeAt(c),t=e*435,r=o*435,n=a*435,s=l*435,n+=e<<8,s+=o<<8,r+=t>>>16,e=t&65535,n+=r>>>16,o=r&65535,l=s+(n>>>16)&65535,a=n&65535;return We[l>>8]+We[l&255]+We[a>>8]+We[a&255]+We[o>>8]+We[o&255]+We[e>>8]+We[e&255]}var mc="",uc="h",hc="s";function pa(i,t){return(t?uc:hc)+ca(typeof i=="string"?i:i.join(mc))}var ma=new WeakMap,ua=new Map;function ha(i,t,e){if(i){let r=e?.id??gc(t),o=i[r];if(o){if(typeof o=="string")return o;if("strTag"in o)return ei(o.strings,t.values,o.values);{let n=ma.get(o);return n===void 0&&(n=o.values,ma.set(o,n)),{...o,values:n.map(a=>t.values[a])}}}}return nr(t)}function gc(i){let t=typeof i=="string"?i:i.strings,e=ua.get(t);return e===void 0&&(e=pa(t,typeof i!="string"&&!("strTag"in i)),ua.set(t,e)),e}function vo(i){window.dispatchEvent(new CustomEvent(or,{detail:i}))}var ri="",bo,ga,ii,Eo,fa,xt=new ar;xt.resolve();var ti=0,ya=i=>(fo(((t,e)=>ha(fa,t,e))),ri=ga=i.sourceLocale,ii=new Set(i.targetLocales),ii.add(i.sourceLocale),Eo=i.loadLocale,{getLocale:fc,setLocale:yc}),fc=()=>ri,yc=i=>{if(i===(bo??ri))return xt.promise;if(!ii||!Eo)throw new Error("Internal error");if(!ii.has(i))throw new Error("Invalid locale code");ti++;let t=ti;return bo=i,xt.settled&&(xt=new ar),vo({status:"loading",loadingLocale:i}),(i===ga?Promise.resolve({templates:void 0}):Eo(i)).then(r=>{ti===t&&(ri=i,bo=void 0,fa=r.templates,vo({status:"ready",readyLocale:i}),xt.resolve())},r=>{ti===t&&(vo({status:"error",errorLocale:i,errorMessage:r.toString()}),xt.reject(r))}),xt.promise};var Co="en",Ao=["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"],So="You must call `loadLocale` first to set up the localized template.",oi,ni,va=i=>{let t=ya({sourceLocale:Co,targetLocales:Ao,loadLocale:i});oi=t.getLocale,ni=t.setLocale};var Po=i=>{va(i)},xo=i=>{if(!ni)throw new Error(So);return ni(i)},_o=()=>{if(!oi)throw new Error(So);return oi()};var sr=new Set(Ao);sr.add(Co);var To=i=>{if(typeof i!="string")return!1;if(i==="en")return!0;let t=i.replace("_","-");if(sr.has(t))return!0;let e=t.split("-")[0];return!!sr.has(e)},Mo=i=>{if(i==="en")return"en-GB";let t=i.replace("_","-");if(sr.has(t))return t;let e=t.split("-")[0];return sr.has(e)?e:"en-GB"};var ai=globalThis,si=ai.ShadowRoot&&(ai.ShadyCSS===void 0||ai.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,wo=Symbol(),ba=new WeakMap,lr=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==wo)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(si&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=ba.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&ba.set(e,t))}return t}toString(){return this.cssText}},he=i=>new lr(typeof i=="string"?i:i+"",void 0,wo),y=(i,...t)=>{let e=i.length===1?i[0]:t.reduce(((r,o,n)=>r+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+i[n+1]),i[0]);return new lr(e,i,wo)},Ea=(i,t)=>{if(si)i.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of t){let r=document.createElement("style"),o=ai.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=e.cssText,i.appendChild(r)}},Io=si?i=>i:i=>i instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return he(e)})(i):i;var{is:vc,defineProperty:bc,getOwnPropertyDescriptor:Ec,getOwnPropertyNames:Cc,getOwnPropertySymbols:Ac,getPrototypeOf:Sc}=Object,mt=globalThis,Ca=mt.trustedTypes,Pc=Ca?Ca.emptyScript:"",xc=mt.reactiveElementPolyfillSupport,dr=(i,t)=>i,cr={toAttribute(i,t){switch(t){case Boolean:i=i?Pc: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}},li=(i,t)=>!vc(i,t),Aa={attribute:!0,type:String,converter:cr,reflect:!1,useDefault:!1,hasChanged:li};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),mt.litPropertyMetadata??(mt.litPropertyMetadata=new WeakMap);var qe=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=Aa){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&&bc(this.prototype,t,o)}}static getPropertyDescriptor(t,e,r){let{get:o,set:n}=Ec(this.prototype,t)??{get(){return this[e]},set(a){this[e]=a}};return{get:o,set(a){let s=o?.call(this);n?.call(this,a),this.requestUpdate(t,s,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Aa}static _$Ei(){if(this.hasOwnProperty(dr("elementProperties")))return;let t=Sc(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(dr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(dr("properties"))){let e=this.properties,r=[...Cc(e),...Ac(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(Io(o))}else t!==void 0&&e.push(Io(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 Ea(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 n=(r.converter?.toAttribute!==void 0?r.converter:cr).toAttribute(e,r.type);this._$Em=t,n==null?this.removeAttribute(o):this.setAttribute(o,n),this._$Em=null}}_$AK(t,e){let r=this.constructor,o=r._$Eh.get(t);if(o!==void 0&&this._$Em!==o){let n=r.getPropertyOptions(o),a=typeof n.converter=="function"?{fromAttribute:n.converter}:n.converter?.fromAttribute!==void 0?n.converter:cr;this._$Em=o,this[o]=a.fromAttribute(e,n.type)??this._$Ej?.get(o)??null,this._$Em=null}}requestUpdate(t,e,r){if(t!==void 0){let o=this.constructor,n=this[t];if(r??(r=o.getPropertyOptions(t)),!((r.hasChanged??li)(n,e)||r.useDefault&&r.reflect&&n===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:n},a){r&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,a??e??this[t]),n!==!0||a!==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,n]of this._$Ep)this[o]=n;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[o,n]of r){let{wrapped:a}=n,s=this[o];a!==!0||this._$AL.has(o)||s===void 0||this.C(o,void 0,n,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){}};qe.elementStyles=[],qe.shadowRootOptions={mode:"open"},qe[dr("elementProperties")]=new Map,qe[dr("finalized")]=new Map,xc?.({ReactiveElement:qe}),(mt.reactiveElementVersions??(mt.reactiveElementVersions=[])).push("2.1.0");var mr=globalThis,di=mr.trustedTypes,Sa=di?di.createPolicy("lit-html",{createHTML:i=>i}):void 0,No="$lit$",Je=`lit$${Math.random().toFixed(9).slice(2)}$`,Lo="?"+Je,_c=`<${Lo}>`,Mt=document,ur=()=>Mt.createComment(""),hr=i=>i===null||typeof i!="object"&&typeof i!="function",Ro=Array.isArray,wa=i=>Ro(i)||typeof i?.[Symbol.iterator]=="function",ko=`[
|
|
152
|
+
\f\r]`,pr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Pa=/-->/g,xa=/>/g,_t=RegExp(`>|${ko}(?:([^\\s"'>=/]+)(${ko}*=${ko}*(?:[^
|
|
153
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),_a=/'/g,Ta=/"/g,Ia=/^(?:script|style|textarea|title)$/i,Oo=i=>(t,...e)=>({_$litType$:i,strings:t,values:e}),m=Oo(1),De=Oo(2),yh=Oo(3),te=Symbol.for("lit-noChange"),g=Symbol.for("lit-nothing"),Ma=new WeakMap,Tt=Mt.createTreeWalker(Mt,129);function ka(i,t){if(!Ro(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return Sa!==void 0?Sa.createHTML(t):t}var Na=(i,t)=>{let e=i.length-1,r=[],o,n=t===2?"<svg>":t===3?"<math>":"",a=pr;for(let s=0;s<e;s++){let l=i[s],c,u,f=-1,h=0;for(;h<l.length&&(a.lastIndex=h,u=a.exec(l),u!==null);)h=a.lastIndex,a===pr?u[1]==="!--"?a=Pa:u[1]!==void 0?a=xa:u[2]!==void 0?(Ia.test(u[2])&&(o=RegExp("</"+u[2],"g")),a=_t):u[3]!==void 0&&(a=_t):a===_t?u[0]===">"?(a=o??pr,f=-1):u[1]===void 0?f=-2:(f=a.lastIndex-u[2].length,c=u[1],a=u[3]===void 0?_t:u[3]==='"'?Ta:_a):a===Ta||a===_a?a=_t:a===Pa||a===xa?a=pr:(a=_t,o=void 0);let A=a===_t&&i[s+1].startsWith("/>")?" ":"";n+=a===pr?l+_c:f>=0?(r.push(c),l.slice(0,f)+No+l.slice(f)+Je+A):l+Je+(f===-2?s:A)}return[ka(i,n+(i[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]},gr=class i{constructor({strings:t,_$litType$:e},r){let o;this.parts=[];let n=0,a=0,s=t.length-1,l=this.parts,[c,u]=Na(t,e);if(this.el=i.createElement(c,r),Tt.currentNode=this.el.content,e===2||e===3){let f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(o=Tt.nextNode())!==null&&l.length<s;){if(o.nodeType===1){if(o.hasAttributes())for(let f of o.getAttributeNames())if(f.endsWith(No)){let h=u[a++],A=o.getAttribute(f).split(Je),x=/([.?@])?(.*)/.exec(h);l.push({type:1,index:n,name:x[2],strings:A,ctor:x[1]==="."?pi:x[1]==="?"?mi:x[1]==="@"?ui:It}),o.removeAttribute(f)}else f.startsWith(Je)&&(l.push({type:6,index:n}),o.removeAttribute(f));if(Ia.test(o.tagName)){let f=o.textContent.split(Je),h=f.length-1;if(h>0){o.textContent=di?di.emptyScript:"";for(let A=0;A<h;A++)o.append(f[A],ur()),Tt.nextNode(),l.push({type:2,index:++n});o.append(f[h],ur())}}}else if(o.nodeType===8)if(o.data===Lo)l.push({type:2,index:n});else{let f=-1;for(;(f=o.data.indexOf(Je,f+1))!==-1;)l.push({type:7,index:n}),f+=Je.length-1}n++}}static createElement(t,e){let r=Mt.createElement("template");return r.innerHTML=t,r}};function wt(i,t,e=i,r){if(t===te)return t;let o=r!==void 0?e._$Co?.[r]:e._$Cl,n=hr(t)?void 0:t._$litDirective$;return o?.constructor!==n&&(o?._$AO?.(!1),n===void 0?o=void 0:(o=new n(i),o._$AT(i,e,r)),r!==void 0?(e._$Co??(e._$Co=[]))[r]=o:e._$Cl=o),o!==void 0&&(t=wt(i,o._$AS(i,t.values),o,r)),t}var ci=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??Mt).importNode(e,!0);Tt.currentNode=o;let n=Tt.nextNode(),a=0,s=0,l=r[0];for(;l!==void 0;){if(a===l.index){let c;l.type===2?c=new Kt(n,n.nextSibling,this,t):l.type===1?c=new l.ctor(n,l.name,l.strings,this,t):l.type===6&&(c=new hi(n,this,t)),this._$AV.push(c),l=r[++s]}a!==l?.index&&(n=Tt.nextNode(),a++)}return Tt.currentNode=Mt,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++}},Kt=class i{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,r,o){this.type=2,this._$AH=g,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=wt(this,t,e),hr(t)?t===g||t==null||t===""?(this._$AH!==g&&this._$AR(),this._$AH=g):t!==this._$AH&&t!==te&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):wa(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!==g&&hr(this._$AH)?this._$AA.nextSibling.data=t:this.T(Mt.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=gr.createElement(ka(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===o)this._$AH.p(e);else{let n=new ci(o,this),a=n.u(this.options);n.p(e),this.T(a),this._$AH=n}}_$AC(t){let e=Ma.get(t.strings);return e===void 0&&Ma.set(t.strings,e=new gr(t)),e}k(t){Ro(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,r,o=0;for(let n of t)o===e.length?e.push(r=new i(this.O(ur()),this.O(ur()),this,this.options)):r=e[o],r._$AI(n),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))}},It=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,o,n){this.type=1,this._$AH=g,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=n,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=g}_$AI(t,e=this,r,o){let n=this.strings,a=!1;if(n===void 0)t=wt(this,t,e,0),a=!hr(t)||t!==this._$AH&&t!==te,a&&(this._$AH=t);else{let s=t,l,c;for(t=n[0],l=0;l<n.length-1;l++)c=wt(this,s[r+l],e,l),c===te&&(c=this._$AH[l]),a||(a=!hr(c)||c!==this._$AH[l]),c===g?t=g:t!==g&&(t+=(c??"")+n[l+1]),this._$AH[l]=c}a&&!o&&this.j(t)}j(t){t===g?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},pi=class extends It{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===g?void 0:t}},mi=class extends It{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==g)}},ui=class extends It{constructor(t,e,r,o,n){super(t,e,r,o,n),this.type=5}_$AI(t,e=this){if((t=wt(this,t,e,0)??g)===te)return;let r=this._$AH,o=t===g&&r!==g||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,n=t!==g&&(r===g||o);o&&this.element.removeEventListener(this.name,this,r),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},hi=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){wt(this,t)}},La={M:No,P:Je,A:Lo,C:1,L:Na,R:ci,D:wa,V:wt,I:Kt,H:It,N:mi,U:ui,B:pi,F:hi},Tc=mr.litHtmlPolyfillSupport;Tc?.(gr,Kt),(mr.litHtmlVersions??(mr.litHtmlVersions=[])).push("3.3.0");var Ra=(i,t,e)=>{let r=e?.renderBefore??t,o=r._$litPart$;if(o===void 0){let n=e?.renderBefore??null;r._$litPart$=o=new Kt(t.insertBefore(ur(),n),n,void 0,e??{})}return o._$AI(i),o};var fr=globalThis,v=class extends qe{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=Ra(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return te}};v._$litElement$=!0,v.finalized=!0,fr.litElementHydrateSupport?.({LitElement:v});var Mc=fr.litElementPolyfillSupport;Mc?.({LitElement:v});(fr.litElementVersions??(fr.litElementVersions=[])).push("4.2.0");var b=i=>(t,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(i,t)})):customElements.define(i,t)};var wc={attribute:!0,type:String,converter:cr,reflect:!1,hasChanged:li},Ic=(i=wc,t,e)=>{let{kind:r,metadata:o}=e,n=globalThis.litPropertyMetadata.get(o);if(n===void 0&&globalThis.litPropertyMetadata.set(o,n=new Map),r==="setter"&&((i=Object.create(i)).wrapped=!0),n.set(e.name,i),r==="accessor"){let{name:a}=e;return{set(s){let l=t.get.call(this);t.set.call(this,s),this.requestUpdate(a,l,i)},init(s){return s!==void 0&&this.C(a,void 0,i,s),s}}}if(r==="setter"){let{name:a}=e;return function(s){let l=this[a];t.call(this,s),this.requestUpdate(a,l,i)}}throw Error("Unsupported decorator location: "+r)};function p(i){return(t,e)=>typeof e=="object"?Ic(i,t,e):((r,o,n)=>{let a=o.hasOwnProperty(n);return o.constructor.createProperty(n,r),a?Object.getOwnPropertyDescriptor(o,n):void 0})(i,t,e)}function M(i){return p({...i,state:!0,attribute:!1})}var kt=(i,t,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(i,t,e),e);function ut(i,t){return(e,r,o)=>{let n=a=>a.renderRoot?.querySelector(i)??null;if(t){let{get:a,set:s}=typeof r=="object"?e:o??(()=>{let l=Symbol();return{get(){return this[l]},set(c){this[l]=c}}})();return kt(e,r,{get(){let l=a.call(this);return l===void 0&&(l=n(this),(l!==null||this.hasUpdated)&&s.call(this,l)),l}})}return kt(e,r,{get(){return n(this)}})}}function k(i,t,e){return i?t(i):e?.(i)}var _=y` * { box-sizing: border-box; } `,Oa=y` :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 Da="https://sdk.primer.io/web/v2-latest/Primer.min.js",Me="20px";var gi=class{constructor(t){this.paymentMethods=null;this.headlessInstance=t}setPaymentMethods(t){this.paymentMethods=t}async refreshSession(){if(!this.headlessInstance){P.errorWithDatadog("PrimerJS: Cannot refresh session: Headless instance not available");return}try{await this.headlessInstance.refreshClientSession()}catch(t){throw P.errorWithDatadog("PrimerJS: Error refreshing client session",{error:t}),t}}getPaymentMethods(){return this.paymentMethods?this.paymentMethods.toArray():(P.warn("PrimerJS: Payment methods not available"),[])}handlePaymentStart(){this.onPaymentStart&&this.onPaymentStart()}handleBeforePaymentCreate(t,e){if(this.onPaymentPrepare){let r={continuePaymentCreation:()=>{P.info("PrimerJS: Payment creation continuing"),e.continuePaymentCreation()},abortPaymentCreation:()=>{P.info("PrimerJS: Payment creation aborted"),e.abortPaymentCreation()}};this.onPaymentPrepare(t,r)}else P.info("PrimerJS: No payment prepare handler, continuing by default"),e.continuePaymentCreation()}handleVaultedMethodsUpdate(t){if(this.onVaultedMethodsUpdate){let e=Math.floor(Date.now()/1e3);this.onVaultedMethodsUpdate({vaultedPayments:t,timestamp:e})}}};var Nt={WORLDPAY_IDEAL:"WORLDPAY_IDEAL",AUTOMATED_CLEARING_HOUSE:"AUTOMATED_CLEARING_HOUSE",ADYEN_KLARNA:"ADYEN_KLARNA",ADYEN_BANCONTACT_CARD:"ADYEN_BANCONTACT_CARD",PAY_NL_KAARTDIRECT:"PAY_NL_KAARTDIRECT",ADYEN_EPS:"ADYEN_EPS",ADYEN_BANCONTACT_PAYCONIQ:"ADYEN_BANCONTACT_PAYCONIQ",OMISE_PROMPTPAY:"OMISE_PROMPTPAY",OMISE_TRUEMONEY:"OMISE_TRUEMONEY",ADYEN_MULTIBANCO:"ADYEN_MULTIBANCO",PACYPAY_WECHAT:"PACYPAY_WECHAT",PACYPAY_ALIPAY:"PACYPAY_ALIPAY",ADYEN_MBWAY:"ADYEN_MBWAY",XENDIT_DANA:"XENDIT_DANA",XENDIT_SHOPEEPAY:"XENDIT_SHOPEEPAY",ADYEN_PAYSHOP:"ADYEN_PAYSHOP",ADYEN_PAYTRAIL:"ADYEN_PAYTRAIL",CLEARPAY:"CLEARPAY",RAPYD_FAST:"RAPYD_FAST",RAPYD_PROMPTPAY:"RAPYD_PROMPTPAY",RAPYD_GCASH:"RAPYD_GCASH",RAPYD_POLI:"RAPYD_POLI",RAPYD_GRABPAY:"RAPYD_GRABPAY",PRIMER_PAYPAL:"PRIMER_PAYPAL",TWOC2P:"TWOC2P",NETS:"NETS",STRIPE_ACH:"STRIPE_ACH",STRIPE_GIROPAY:"STRIPE_GIROPAY",MOLLIE_GIROPAY:"MOLLIE_GIROPAY",MOLLIE_EPS:"MOLLIE_EPS",PAY_NL_EPS:"PAY_NL_EPS",PAY_NL_P24:"PAY_NL_P24",MOLLIE_P24:"MOLLIE_P24",MOLLIE_SOFORT:"MOLLIE_SOFORT",COINBASE:"COINBASE",OPENNODE:"OPENNODE",MOLLIE_GIFT_CARD:"MOLLIE_GIFTCARD",XFERS_PAYNOW:"XFERS_PAYNOW",CARD:"PAYMENT_CARD",APPLE_PAY:"APPLE_PAY",GOOGLE_PAY:"GOOGLE_PAY",PAYPAL:"PAYPAL_ORDER",PAYPAL_VAULTED:"PAYPAL_BILLING_AGREEMENT",GO_CARDLESS:"GOCARDLESS",PAY_NL_IDEAL:"PAY_NL_IDEAL",PAY_NL_SOFORT_BANKING:"PAY_NL_SOFORT_BANKING",PAY_NL_BANCONTACT:"PAY_NL_BANCONTACT",PAY_NL_PAYPAL:"PAY_NL_PAYPAL",PAY_NL_CREDIT_TRANSFER:"PAY_NL_CREDIT_TRANSFER",PAY_NL_DIRECT_DEBIT:"PAY_NL_DIRECT_DEBIT",PAY_NL_GIROPAY:"PAY_NL_GIROPAY",PAY_NL_PAYCONIQ:"PAY_NL_PAYCONIQ",PAY_NL_RIVERTY:"PAY_NL_RIVERTY",HOOLAH:"HOOLAH",ADYEN_BLIK:"ADYEN_BLIK",ADYEN_VIPPS:"ADYEN_VIPPS",ADYEN_GIROPAY:"ADYEN_GIROPAY",ADYEN_SOFORT:"ADYEN_SOFORT",ADYEN_IDEAL:"ADYEN_IDEAL",ADYEN_TRUSTLY:"ADYEN_TRUSTLY",ADYEN_ALIPAY:"ADYEN_ALIPAY",ADYEN_TWINT:"ADYEN_TWINT",ADYEN_MOBILEPAY:"ADYEN_MOBILEPAY",MOLLIE_BANCONTACT:"MOLLIE_BANCONTACT",MOLLIE_IDEAL:"MOLLIE_IDEAL",BUCKAROO_GIROPAY:"BUCKAROO_GIROPAY",BUCKAROO_EPS:"BUCKAROO_EPS",BUCKAROO_SOFORT:"BUCKAROO_SOFORT",BUCKAROO_BANCONTACT:"BUCKAROO_BANCONTACT",BUCKAROO_IDEAL:"BUCKAROO_IDEAL",ATOME:"ATOME",KLARNA_CUSTOMER_TOKEN:"KLARNA_CUSTOMER_TOKEN",DLOCAL_PIX:"DLOCAL_PIX",ALMA:"ALMA"},yr={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"};var fi=class i extends Error{constructor(t,e){super(e.message),this.name="PrimerClientError",this.code=t,this.diagnosticsId=e.diagnosticsId||null,this.data=e.data,this.isFromDeveloper=e.isFromDeveloper||!1}static fromErrorCode(t,e){return new i(t,e)}};var yi=typeof window<"u"&&typeof window.document<"u";function kc(i){return document.querySelector(`script[src^="${i}"]`)}function Nc(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 $a(i,t=!1){if(!yi)throw new Error("Cannot load script in server environment");let e=kc(i)??Nc(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 Z={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Ce=i=>(...t)=>({_$litDirective$:i,values:t}),$e=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 vr=class extends $e{constructor(t){if(super(t),this.it=g,t.type!==Z.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===g||t==null)return this._t=void 0,this.it=t;if(t===te)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;let e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};vr.directiveName="unsafeHTML",vr.resultType=1;var Va=Ce(vr);var Ua=Symbol.for("primer-sdk-core-dialog-access");function Ya(i){return{token:Ua,content:i}}function Do(i){return i!==void 0&&i.token===Ua&&typeof i.content=="string"}var Ba=y` :host { display: block; } .content-container { width: 100%; height: 100%; display: flex; flex-direction: column; background-color: var(--primer-color-background-outlined-default); } .error { display: flex; align-items: center; justify-content: center; padding: var(--primer-space-large); color: var(--primer-color-text-danger); font-family: var(--primer-typography-body-medium-font); font-size: var(--primer-typography-body-medium-size); } `;var le=class extends v{constructor(){super(...arguments);this.size="large";this.showCloseButton=!1;this.open=!1}openDialog(){this.open=!0}closeDialog(){let e=document.querySelector("primer-dialog");if(e){e.startExitAnimation();let r=()=>{this.open=!1,this.removeEventListener("primer-dialog-close",r)};this.addEventListener("primer-dialog-close",r)}else this.open=!1}renderContent(){return m`<div class="content-container"><slot></slot>${this.renderSecureHtmlContent()}</div>`}renderSecureHtmlContent(){return this.secureHtmlContent?Do(this.secureHtmlContent)?m`${Va(this.secureHtmlContent.content)}`:(P.warn("PortalDialogComponent: Invalid access token provided for htmlContent. Content will not be rendered."),g):g}renderDialog(){return this.open?m`<primer-portal><primer-dialog .open=${this.open} size=${this.size} .showCloseButton=${!1} @primer-dialog-close="${()=>this.closeDialog()}" >${this.renderContent()}</primer-dialog></primer-portal>`:g}connectedCallback(){super.connectedCallback(),this.open||this.openDialog()}updated(e){if(super.updated(e),e.has("secureHtmlContent")){let r=this.secureHtmlContent;r&&!Do(r)&&(P.errorWithDatadog("PortalDialogComponent: Invalid access token provided for htmlContent. Content will not be rendered."),this.secureHtmlContent=void 0)}e.has("open")&&this.open&&this.onOpen&&this.onOpen(),e.has("open")&&this.open&&this.onContentRendered&&this.updateComplete.then(()=>{requestAnimationFrame(()=>{this.onContentRendered?.()})})}render(){return m`${this.renderDialog()}`}};le.styles=[_,Ba],d([p({type:String})],le.prototype,"size",2),d([p({type:Boolean})],le.prototype,"showCloseButton",2),d([p({type:Object})],le.prototype,"onOpen",2),d([p({type:Object})],le.prototype,"onContentRendered",2),d([p({type:Object,converter:{fromAttribute:()=>{},toAttribute:()=>null}})],le.prototype,"secureHtmlContent",2),d([M()],le.prototype,"open",2),le=d([b("primer-portal-dialog"),O()],le);var vi=class{constructor(){this.currentDialog=null;this.currentResolver=null}async show(t){return new Promise(e=>{let r=Ya(t.htmlContent),o=new le;o.secureHtmlContent=r,o.size="large",o.showCloseButton=!1,o.onContentRendered=t.onContentReady;let n=()=>{this.currentDialog=null,this.currentResolver=null,e({success:!1})};o.addEventListener("primer-dialog-close",n),this.currentDialog=o,this.currentResolver=e,document.body.appendChild(o)})}close(){this.currentDialog&&this.currentResolver&&(this.currentDialog.closeDialog(),this.currentResolver({success:!0}),this.currentDialog.remove(),this.currentDialog=null,this.currentResolver=null)}};var $o="0.7.0",bi=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 D(t,{args:()=>[this.host.clientToken,this.host.options],task:this.initializeHeadless()}),new D(t,{args:()=>[this.sdkInstanceTask.value,this.paymentsList],task:this.initializeLitContext()})}set paymentsList(t){this._paymentsList=t,this.host.requestUpdate()}get paymentsList(){return this._paymentsList}get primerJSInstance(){return this.primerJS}hostConnected(){this.isDisconnected=!1,this.host.sdkStateController.startLoading(),this.setupLoadingTimeout()}hostDisconnected(){if(this.isDisconnected=!0,this.host.sdkContextController.getAnalyticsUtils()){let e=this.host.sdkStateController.currentState;(e.isProcessing||e.isLoading||this.currentSdkInstance)&&J({eventName:"PAYMENT_FLOW_EXITED"})}this.cleanupResources()}normalizeOptionsForLegacySdk(t){if(t.sdkCore!==!1)return t.sdkCore=!0,t;let e={...t};if(e.card?.cardholderName){let r={...e.card.cardholderName};r.visible===!1&&(r.required=!1),e.card={...e.card,cardholderName:r}}return e}setupLoadingTimeout(){this.clearLoadingTimeout(),this.loadingTimeout=setTimeout(()=>{this.host.sdkStateController.currentState.isLoading&&(P.warn("Loading timeout reached, resetting SDK state"),J({eventName:"PAYMENT_FLOW_EXITED",eventType:"timeout"}),this.cleanupResources(),this.host.sdkStateController.completeLoading())},1e4)}clearLoadingTimeout(){this.loadingTimeout!==null&&(clearTimeout(this.loadingTimeout),this.loadingTimeout=null)}cleanupResources(){if(this.clearLoadingTimeout(),this.currentSdkInstance)try{this.paymentsList=[],this.createPaymentMethodManager=null,this.host.sdkStateController.reset(),this.currentSdkInstance.teardown?.(),P.info("SDK instance cleaned up")}catch(t){P.errorWithDatadog("Error cleaning up SDK instance",{error:t})}aa(),P.setClientToken(void 0),P.setSdkOptions(void 0),this.currentSdkInstance=null,this.primerJS=null}async _loadV2Sdk(t=Da){let e=window;if(e.Primer&&typeof e.Primer.preloadPrimer=="function"){P.info("SDK already loaded, skipping load script"),await e.Primer.preloadPrimer();return}await $a(t),await e.Primer.preloadPrimer()}initializeHeadless(){return async([t,e])=>{if(this.isDisconnected)return P.warn("Component disconnected, aborting SDK initialization"),R;if(!t||!e)return R;this.cleanupResources();let r;try{let o;if(e.sdkCore!==!1){let l=new vi;o={createHeadless:(u,f)=>Hn(u,{...f,dialogProvider:l,sdkVersion:$o})}}else await this._loadV2Sdk(),o=window.Primer;this.primerJS=new gi(null);let n=this.normalizeOptionsForLegacySdk(e);P.setClientToken(t),P.setSdkOptions(n);let a=await o.createHeadless(t,{...n,onAvailablePaymentMethodsLoad:l=>{this.isDisconnected||(P.info("Configuration payment methods:",l),this.paymentsList=l)},onCheckoutComplete:({payment:l})=>{if(this.isDisconnected)return;P.info("Payment completed:",l);let c=l?.paymentMethodData?.paymentMethodType||"UNKNOWN";if(this.host.sdkStateController.completeProcessing(),l&&this.host.primerEventsController.dispatchPaymentSuccess(l,c),J({eventName:"PAYMENT_SUCCESS",paymentId:l?.id}),this.primerJS?.onPaymentSuccess&&l){let u=Math.floor(Date.now()/1e3);this.primerJS.onPaymentSuccess({payment:Ut(l),paymentMethodType:c,timestamp:u})}},onCheckoutFail:(l,c)=>{if(this.isDisconnected)return;(x=>typeof x=="object"&&x!==null&&"response"in x&&typeof x.response=="object"&&x.response!==null&&"status"in x.response&&typeof x.response.status=="number")(l)&&l.response.status>=500?P.errorWithDatadog("Payment failed with server error",{error:l}):P.error("Payment failed:",l);let h=c.payment?.paymentMethodData?.paymentMethodType||"UNKNOWN",A=l instanceof fi?{code:l.code||"UNKNOWN_ERROR",message:l.message||"Unknown error occurred",diagnosticsId:l.diagnosticsId,data:l.data}:(()=>{let x=l,T=x instanceof Error&&"code"in x&&typeof x.code=="string"?x.code:"UNKNOWN_ERROR",w=x instanceof Error?x.message:"Unknown error occurred";return{code:T,message:w,data:{error:l}}})();if(this.host.sdkStateController.setPaymentFailure(A),this.host.primerEventsController.dispatchPaymentFailure({code:A.code,message:A.message,diagnosticsId:"diagnosticsId"in A?A.diagnosticsId??void 0:void 0,data:A.data},h,c.payment),J({eventName:"PAYMENT_FAILURE",paymentId:c.payment?.id}),this.primerJS?.onPaymentFailure){let x=Math.floor(Date.now()/1e3);this.primerJS.onPaymentFailure({error:{code:A.code,message:A.message,diagnosticsId:"diagnosticsId"in A?A.diagnosticsId??void 0:void 0,data:A.data},payment:c.payment?Ut(c.payment):void 0,paymentMethodType:h,timestamp:x})}},onBeforePaymentCreate:(l,c)=>{if(this.isDisconnected)return;this.host.sdkStateController.currentState.paymentFailure!==null&&J({eventName:"PAYMENT_REATTEMPTED",paymentMethod:l.paymentMethodType}),this.host.sdkStateController.startProcessing(),this.primerJS?this.primerJS.handleBeforePaymentCreate(l,c):c?.continuePaymentCreation()},onPaymentMethodAction:(l,c)=>{this.isDisconnected||l==="PAYMENT_METHOD_UNSELECTED"&&this.host.sdkStateController.stopProcessing()},onPaymentCreationStart:()=>{this.isDisconnected||this.primerJS&&this.primerJS.handlePaymentStart()}});if(this.createPaymentMethodManager=a.createPaymentMethodManager.bind(a),this.currentSdkInstance=a,this.primerJS&&Object.defineProperty(this.primerJS,"headlessInstance",{value:a,writable:!1}),await a.start(),this.isDisconnected)return this.cleanupResources(),R;this.host.sdkContextController.setClientOptions(e),this.primerJS&&this.host.primerEventsController.dispatchCheckoutInitialized(this.primerJS);let s=a.getSDKUtilities();if(r=a.getAnalyticsUtils?.(),r&&(this.host.sdkContextController.setAnalyticsUtils({...r,sdkVersion:$o}),na({environment:r.environment,checkoutSessionId:r.checkoutSessionId,clientSessionId:r.clientSessionId||"",primerAccountId:r.primerAccountId||"",sdkVersion:$o,clientSessionToken:r.clientSessionToken,userAgent:typeof navigator<"u"?navigator.userAgent:""}),J({eventName:"SDK_INIT_START"})),this.host.sdkContextController.setHeadlessUtils(s),e.sdkCore&&a.getConfiguration){let l=a.getConfiguration();this.host.sdkContextController.setConfiguration(l)}return this.host.vaultManagerController.initializeVaultManager(a.createVaultManager.bind(a),{vaultEnabled:e.vault?.enabled,captureVaultedCardCvv:!!s.getPaymentMethodConfiguration("PAYMENT_CARD")?.options?.captureVaultedCardCvv,showEmptyState:e.vault?.showEmptyState}),a}catch(o){throw o instanceof Error&&(P.errorWithDatadog("SDK initialization error",{error:o,status:"error"}),this.host.sdkStateController.setPrimerJsError(o)),this.cleanupResources(),o}}}initializeLitContext(){return async([t,e])=>{if(this.isDisconnected)return R;if(!t||!e.length)return R;let r=new Map,o=new Map;try{for(let a of e){if(this.isDisconnected)break;let s=await this.initializePaymentMethodManager(a)();a&&s&&(r.set(a.type,a),o.set(a.type,s))}if(this.isDisconnected)return R;let n=new Xr(r);return this.host.sdkContextController.setPaymentManagers(o),this.host.sdkContextController.setPaymentMethods(n),this.primerJS&&this.primerJS.setPaymentMethods(n),this.host.primerEventsController.dispatchPaymentMethods(n),P.info("Initialized payment methods:",n.toArray()),r}catch(n){if(n instanceof Error)throw this.host.sdkStateController.setPrimerJsError(n),n;return null}finally{this.clearLoadingTimeout(),this.isDisconnected||(this.host.sdkStateController.completeLoading(),J({eventName:"SDK_INIT_END"}))}}}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:n=>{this.isDisconnected||this.host.sdkContextController.setKlarnaCategories({categories:n,isLoading:!1})}});return o?{type:e,manager:o}:null}try{if(r==="CARD"){let n=await this.createPaymentMethodManager(e,{onCardNetworksChange:a=>{this.isDisconnected||this.host.cardNetworkController.processCardNetworkChangeEvent(a)},onCardNetworksLoading:()=>{this.isDisconnected||this.host.cardNetworkController.setCardNetworksLoading()}});return n?{type:e,manager:n}:null}let o=await this.createPaymentMethodManager(e);return o?{type:e,manager:o}:null}catch(o){return P.errorWithDatadog(`Failed to initialize manager for ${e}`,{error:o}),null}}}};var Ei=class{constructor(t){this.host=t,t.addController(this)}_error(t){let{error:e}=t.detail;this.host.sdkStateController.setPaymentFailure({code:"UNKNOWN_ERROR",message:e.message})}_mandateConfirmed(){this.host.sdkStateController.completeProcessing()}_mandateDeclined(){this.host.sdkStateController.setPaymentFailure({code:"UNKNOWN_ERROR",message:"Mandate declined"})}hostConnected(){this.host.addEventListener("primer-ach-error",this._error.bind(this)),this.host.addEventListener("primer-ach-mandate-confirmed",this._mandateConfirmed.bind(this)),this.host.addEventListener("primer-ach-mandate-declined",this._mandateDeclined.bind(this))}hostDisconnected(){this.host.removeEventListener("primer-ach-error",this._error.bind(this)),this.host.removeEventListener("primer-ach-mandate-confirmed",this._mandateConfirmed.bind(this)),this.host.removeEventListener("primer-ach-mandate-declined",this._mandateDeclined.bind(this))}};var Lc=Zo({"../../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")});Po(i=>Lc(`../../localization/lit-localize/locales/${i}.ts`));var Rc={LOADER_DISABLED:"loader-disabled",CUSTOM_STYLES:"custom-styles",CLIENT_TOKEN:"client-token",JS_INIT:"js-initialized"},Ae=class extends v{constructor(){super();this.customStyles="";this.clientToken="";this.options={};this.disableLoader=!1;this._jsInitialized=!1;this.previousLoadingState=!0;this.hasAssignedContent=!1;this._loadingTimeoutId=null;this._eventListenerController=null;this.locale="en-GB";this.onSlotChange=e=>{let o=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=o.length>0,this.requestUpdate()};this.sdkContextController=new Kr(this),this.sdkStateController=new zr(this),this.primerEventsController=new Yt(this),this.styleProcessingController=new Gr(this),this.vaultManagerController=new ir(this),this.cardNetworkController=new Sr(this),this.achPaymentEventsController=new Ei(this),this.headlessSdkController=new bi(this)}set jsInitialized(e){this.requestUpdate(),this._jsInitialized=e}get jsInitialized(){return this._jsInitialized}get primerJS(){return this.headlessSdkController?.primerJSInstance??void 0}connectedCallback(){super.connectedCallback(),this.sdkContextController.setEventsController(this.primerEventsController),this._eventListenerController=new AbortController,document.addEventListener("primer:card-submit",this.handleExternalCardSubmit.bind(this),{signal:this._eventListenerController.signal})}attributeChangedCallback(e,r,o){e===Rc.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(),this._eventListenerController&&(this._eventListenerController.abort(),this._eventListenerController=null),super.disconnectedCallback()}willUpdate(e){e.has("options")&&(this.options?.locale&&(To(this.options?.locale)?this.locale=Mo(this.options?.locale):P.warn("\u{1F30E}\u2757 Unsupported locale provided:",this.options?.locale,"- Falling back to default locale `en-GB`")),xo(this.locale||"en-GB"))}updated(){let e=getComputedStyle(this);this.sdkContextController.setComputedStyles(e),this.checkLoadingStateChange()}handleExternalCardSubmit(e){this._eventListenerController?.signal.aborted||e.target!==this&&this.primerEventsController.dispatchEvent("primer:card-submit",e.detail)}checkLoadingStateChange(){let e=this.sdkStateController?.currentState.isLoading||!1;this.previousLoadingState&&!e&&(this.jsInitialized=!0,J({eventName:"CHECKOUT_FLOW_STARTED"})),this.previousLoadingState=e,e&&!this._loadingTimeoutId?this._loadingTimeoutId=window.setTimeout(()=>{this.sdkStateController?.currentState.isLoading&&(P.warn("Loading timeout in component, forcing completion"),this.sdkStateController.forceCompleteLoading(),this.jsInitialized=!0),this._loadingTimeoutId=null},1e4):!e&&this._loadingTimeoutId&&(window.clearTimeout(this._loadingTimeoutId),this._loadingTimeoutId=null)}render(){let e=this.sdkStateController.currentState,r=e.isLoading,o=e.primerJsError,n=!r&&!o;return m` ${k(r,()=>g)} ${k(o,()=>m`<primer-checkout-error></primer-checkout-error>`)} ${k(n,()=>m`<slot name="main" @slotchange=${this.onSlotChange}></slot>${k(this.hasAssignedContent,()=>g,()=>m`<primer-main></primer-main>`)} `,()=>g)} `}addEventListener(e,r,o){super.addEventListener(e,r,o)}removeEventListener(e,r,o){super.removeEventListener(e,r,o)}};Ae.styles=[_,Oa],d([p({type:String,attribute:"custom-styles"})],Ae.prototype,"customStyles",2),d([p({type:String,attribute:"client-token"})],Ae.prototype,"clientToken",2),d([p({type:Object})],Ae.prototype,"options",2),d([p({type:Boolean,attribute:"loader-disabled"})],Ae.prototype,"disableLoader",2),d([p({type:Boolean,reflect:!0,attribute:"js-initialized"})],Ae.prototype,"_jsInitialized",2),d([ut("slot")],Ae.prototype,"defaultSlot",2),d([M()],Ae.prototype,"previousLoadingState",2),Ae=d([O(),b("primer-checkout")],Ae);function Oc(i){return document.querySelector(`#${i}`)}function Dc(i,t){let e=document.createElement("style");return e.textContent=i,e.id=t,e}function br(i,t,e=!0){if(!yi||Oc(t))return;let o=Dc(i,t);e&&document.head.firstChild?document.head.insertBefore(o,document.head.firstChild):document.head.appendChild(o)}var Fa=`
|
|
154
154
|
@keyframes primer-css-spinner-rotate {
|
|
155
155
|
0% {
|
|
156
156
|
transform: rotate(0deg);
|
|
@@ -186,7 +186,7 @@ primer-checkout:not([js-initialized]):not([loader-disabled])::after {
|
|
|
186
186
|
animation: primer-css-spinner-rotate 1.2s linear infinite;
|
|
187
187
|
z-index: 9999;
|
|
188
188
|
}
|
|
189
|
-
`;var Rn=':root,primer-checkout{--primer-color-background-transparent-default:rgba(255,255,255,0);--primer-color-border-transparent-default:rgba(255,255,255,0);--primer-color-gray-100:#f5f5f5;--primer-color-gray-200:#eeeeee;--primer-color-gray-300:#e0e0e0;--primer-color-gray-400:#bdbdbd;--primer-color-gray-500:#9e9e9e;--primer-color-gray-600:#757575;--primer-color-gray-900:#212121;--primer-color-gray-000:#ffffff;--primer-color-brand:#2f98ff;--primer-color-red-100:#ffecec;--primer-color-red-500:#ff7279;--primer-color-red-900:#b4324b;--primer-color-blue-500:#399dff;--primer-color-blue-900:#2270f4;--primer-radius-base:4px;--primer-typography-brand:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;--primer-typography-title-xlarge-letter-spacing:-0.6px;--primer-typography-title-xlarge-weight:550;--primer-typography-title-xlarge-size:24px;--primer-typography-title-xlarge-line-height:32px;--primer-typography-title-large-letter-spacing:-0.2px;--primer-typography-title-large-weight:550;--primer-typography-title-large-size:16px;--primer-typography-title-large-line-height:20px;--primer-typography-body-large-letter-spacing:-0.2px;--primer-typography-body-large-weight:400;--primer-typography-body-large-size:16px;--primer-typography-body-large-line-height:20px;--primer-typography-body-medium-letter-spacing:0px;--primer-typography-body-medium-weight:400;--primer-typography-body-medium-size:14px;--primer-typography-body-medium-line-height:20px;--primer-typography-body-small-letter-spacing:0px;--primer-typography-body-small-weight:400;--primer-typography-body-small-size:12px;--primer-typography-body-small-line-height:16px;--primer-space-base:4px;--primer-size-base:4px;--primer-animation-duration:200ms;--primer-animation-easing:cubic-bezier(0.44,0,0.4,1);--primer-color-background-outlined-default:var(--primer-color-gray-000);--primer-color-background-outlined-disabled:var(--primer-color-gray-100);--primer-color-background-transparent-hover:var(--primer-color-gray-100);--primer-color-background-transparent-active:var(--primer-color-gray-200);--primer-color-background-transparent-loading:var(--primer-color-gray-100);--primer-color-background-transparent-focus:var(--primer-color-background-transparent-default);--primer-color-background-transparent-disabled:var(--primer-color-gray-100);--primer-color-background-transparent-selected:var(--primer-color-gray-100);--primer-color-text-primary:var(--primer-color-gray-900);--primer-color-text-placeholder:var(--primer-color-gray-500);--primer-color-text-disabled:var(--primer-color-gray-400);--primer-color-text-negative:var(--primer-color-red-900);--primer-color-text-link:var(--primer-color-blue-900);--primer-color-text-secondary:var(--primer-color-gray-600);--primer-color-border-outlined-default:var(--primer-color-gray-300);--primer-color-border-outlined-hover:var(--primer-color-gray-400);--primer-color-border-outlined-active:var(--primer-color-gray-500);--primer-color-border-outlined-disabled:var(--primer-color-gray-200);--primer-color-border-outlined-loading:var(--primer-color-gray-200);--primer-color-border-outlined-selected:var(--primer-color-brand);--primer-color-border-outlined-error:var(--primer-color-red-500);--primer-color-border-transparent-hover:var(--primer-color-border-transparent-default);--primer-color-border-transparent-active:var(--primer-color-border-transparent-default);--primer-color-border-transparent-disabled:var(--primer-color-border-transparent-default);--primer-color-border-transparent-selected:var(--primer-color-border-transparent-default);--primer-color-icon-primary:var(--primer-color-gray-900);--primer-color-icon-disabled:var(--primer-color-gray-400);--primer-color-icon-negative:var(--primer-color-red-500);--primer-color-focus:var(--primer-color-brand);--primer-color-loader:var(--primer-color-brand);--primer-radius-medium:8px;--primer-radius-small:4px;--primer-radius-large:12px;--primer-radius-xsmall:2px;--primer-typography-title-xlarge-font:var(--primer-typography-brand);--primer-typography-title-large-font:var(--primer-typography-brand);--primer-typography-body-large-font:var(--primer-typography-brand);--primer-typography-body-medium-font:var(--primer-typography-brand);--primer-typography-body-small-font:var(--primer-typography-brand);--primer-space-xxsmall:2px;--primer-space-xsmall:4px;--primer-space-small:8px;--primer-space-medium:12px;--primer-space-large:16px;--primer-space-xlarge:20px;--primer-size-small:16px;--primer-size-medium:20px;--primer-size-large:24px;--primer-size-xlarge:32px;--primer-size-xxlarge:40px;--primer-size-xxxlarge:56px;--primer-color-background-outlined-focus:var(--primer-color-background-outlined-default);--primer-color-background-outlined-loading:var(--primer-color-background-outlined-disabled);--primer-color-background-outlined-active:var(--primer-color-background-outlined-default);--primer-color-background-outlined-hover:var(--primer-color-background-outlined-default);--primer-color-background-outlined-selected:var(--primer-color-background-outlined-default);--primer-color-background-outlined-error:var(--primer-color-background-outlined-default);--primer-color-border-outlined-focus:var(--primer-color-focus);--primer-color-border-transparent-focus:var(--primer-color-focus);--primer-color-border-transparent-loading:var(--primer-color-border-transparent-disabled)}',On=":root,primer-checkout.primer-dark-theme{--primer-color-gray-100:#292929;--primer-color-gray-200:#424242;--primer-color-gray-300:#575757;--primer-color-gray-400:#858585;--primer-color-gray-500:#767577;--primer-color-gray-600:#c7c7c7;--primer-color-gray-900:#efefef;--primer-color-gray-000:#171619;--primer-color-brand:#2f98ff;--primer-color-red-100:#321c20;--primer-color-red-500:#e46d70;--primer-color-red-900:#f6bfbf;--primer-color-blue-500:#3f93e4;--primer-color-blue-900:#4aaeff}";var Pc="primer-light-theme-css",_c="primer-dark-theme-css";function Lo(){yr(Rn,Pc,!0)}function Ro(){yr(On,_c,!0)}function Dn(){Lo(),Ro()}function $n(){yr(Ln,"primer-css-loader-styles",!1)}function Vn(){Dn()}function wc(){Lo()}function Tc(){Ro()}var Un=y` :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 Oo={small:16,medium:24,large:32},Ve=class extends v{constructor(){super(...arguments);this.color="var(--primer-color-loader)";this.size="medium";this.compact=!1}getSize(){if(this.size in Oo)return Oo[this.size];let e=parseInt(this.size,10);return isNaN(e)?Oo.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>`}};Ve.styles=[Un],l([p({type:String})],Ve.prototype,"color",2),l([p({type:String})],Ve.prototype,"size",2),l([p({type:Boolean})],Ve.prototype,"compact",2),Ve=l([b("primer-spinner")],Ve);var re=Ee(class extends $e{constructor(i){if(super(i),i.type!==Z.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 ee}});var Bn=y` * { box-sizing: border-box; } :host { display: block; width: 100%; } .input-slot.focus-within { outline: 2px solid var(--primer-color-border-outlined-focus); outline-offset: -2px; } :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 Ue=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="${re(e)}" @click="${this.handleWrapperClick}"><slot name="input"></slot></div><slot name="error"></slot></div>`}};Ue.styles=[Bn],l([p({type:Boolean})],Ue.prototype,"focusWithin",2),l([p({type:Boolean,reflect:!0,attribute:"has-error"})],Ue.prototype,"hasError",2),l([mt('slot[name="input"]')],Ue.prototype,"inputSlot",2),Ue=l([b("primer-input-wrapper")],Ue);var Yn=y` :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 Ze=class extends v{constructor(){super(...arguments);this.for="";this.disabled=!1}render(){return m`<label for=${this.for}><slot></slot></label>`}};Ze.styles=[Yn],l([p({type:String,reflect:!0})],Ze.prototype,"for",2),l([p({type:Boolean,reflect:!0})],Ze.prototype,"disabled",2),Ze=l([b("primer-input-label")],Ze);var Hn=y` :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 fe=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?h:m`<primer-icon name="checkmark" size="sm" color="var(--primer-color-brand)" ></primer-icon>`}renderSpinner(){if(!this.loading)return h;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>`}};fe.styles=[P,Hn],l([p({type:String,reflect:!0})],fe.prototype,"variant",2),l([p({type:Boolean,reflect:!0})],fe.prototype,"disabled",2),l([p({type:Boolean,reflect:!0})],fe.prototype,"loading",2),l([p({type:String,attribute:"type"})],fe.prototype,"buttonType",2),l([p({type:String,reflect:!0})],fe.prototype,"selectionState",2),l([p({type:Boolean,reflect:!0})],fe.prototype,"selectable",2),l([p({type:Boolean,reflect:!0})],fe.prototype,"flex",2),fe=l([b("primer-button")],fe);var Fn=y` :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 Xe=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>`}};Xe.styles=[Fn],l([p({type:String,reflect:!0})],Xe.prototype,"for",2),l([p({type:Boolean,reflect:!0})],Xe.prototype,"active",2),Xe=l([b("primer-input-error")],Xe);var zn={trash:De`<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":De`<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":De`<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":De`<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":De`<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:De`<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:De`<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:De`<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:De`<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 Kn=y` :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 Be=class extends v{constructor(){super(...arguments);this.color="var(--primer-color-icon-primary)";this.size="lg"}render(){let e=this.name?zn[this.name]:null;return m`<div style="--internal-icon-color: ${this.color}">${e||m`<slot></slot>`}</div>`}};Be.styles=[Kn],l([p({type:String,reflect:!0})],Be.prototype,"color",2),l([p({type:String,reflect:!0})],Be.prototype,"size",2),l([p({reflect:!0})],Be.prototype,"name",2),Be=l([b("primer-icon")],Be);var jn=y` :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 Qe=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>`} `}};Qe.styles=[jn],l([p({type:String,reflect:!0})],Qe.prototype,"type",2),l([p({type:String,reflect:!0})],Qe.prototype,"description",2),Qe=l([b("primer-checkout-state")],Qe);var Gn=y` :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 Mc=["text","password","email","number","tel","url","search","date","time","datetime-local","month","week","color"];function kc(i){return Mc.includes(i)}var Y=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)}};Y.styles=[Gn],l([mt("input")],Y.prototype,"inputElement",2),l([p({type:String,reflect:!0})],Y.prototype,"value",2),l([p({type:String,reflect:!0})],Y.prototype,"placeholder",2),l([p({type:Boolean,reflect:!0})],Y.prototype,"disabled",2),l([p({type:String,reflect:!0})],Y.prototype,"name",2),l([p({type:String,reflect:!0,converter:{fromAttribute:e=>!e||!kc(e)?(e&&e!=="text"&&A.warn(`Invalid input type: ${e}. Defaulting to 'text'.`),"text"):e}})],Y.prototype,"type",2),l([p({type:Boolean,reflect:!0})],Y.prototype,"required",2),l([p({type:Boolean,reflect:!0})],Y.prototype,"readonly",2),l([p({type:String,reflect:!0})],Y.prototype,"pattern",2),l([p({type:Number,reflect:!0})],Y.prototype,"minlength",2),l([p({type:Number,reflect:!0})],Y.prototype,"maxlength",2),l([p({type:String,reflect:!0})],Y.prototype,"min",2),l([p({type:String,reflect:!0})],Y.prototype,"max",2),l([p({type:String,reflect:!0})],Y.prototype,"step",2),l([p({type:String,reflect:!0})],Y.prototype,"autocomplete",2),l([_()],Y.prototype,"hasFocus",2),l([_()],Y.prototype,"hasError",2),Y=l([b("primer-input")],Y);var{I:Gy}=Na;var Ci=i=>i.strings===void 0;var Ic={},Wn=(i,t=Ic)=>i._$AH=t;var qn=Ee(class extends $e{constructor(i){if(super(i),i.type!==Z.PROPERTY&&i.type!==Z.ATTRIBUTE&&i.type!==Z.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!Ci(i))throw Error("`live` bindings can only contain a single expression")}render(i){return i}update(i,[t]){if(t===ee||t===h)return t;let e=i.element,r=i.name;if(i.type===Z.PROPERTY){if(t===e[r])return ee}else if(i.type===Z.BOOLEAN_ATTRIBUTE){if(!!t===e.hasAttribute(r))return ee}else if(i.type===Z.ATTRIBUTE&&e.getAttribute(r)===t+"")return ee;return Wn(i),t}});var Jn=y` :host { display: contents; } select { width: 100%; padding: 0; padding-right: calc(var(--primer-space-medium) + 12px); 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; cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23212121' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0 center; } /* Placeholder state - when no value is selected */ select:invalid, select[value=''] { color: var(--primer-color-text-placeholder); } select:disabled { color: var(--primer-color-text-disabled); cursor: not-allowed; } /* Placeholder option styling */ select option:disabled { color: var(--primer-color-text-placeholder); } `;var ge=class extends v{constructor(){super(...arguments);this.name="";this.id="";this.value="";this.disabled=!1;this.hasError=!1;this.placeholder="";this.options=[]}handleChange(e){let r=e.target,o=this.value;this.value=r.value,this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0,composed:!0})),this.requestUpdate("value",o)}handleFocus(){this.dispatchEvent(new CustomEvent("focus",{bubbles:!0,composed:!0}))}handleBlur(){this.dispatchEvent(new CustomEvent("blur",{bubbles:!0,composed:!0}))}renderSelectOptions(){let e=[];for(let r of this.options)e.push(m`<option value=${r.value}>${r.label}</option>`);return e}render(){return m`<select id=${this.id} name=${this.name} .value=${qn(this.value)} ?disabled=${this.disabled} ?required=${!this.value} @change=${this.handleChange} @focus=${this.handleFocus} @blur=${this.handleBlur} aria-invalid=${this.hasError?"true":"false"} ><option value="" disabled ?selected=${!this.value}>${this.placeholder||"Select an option"}</option>${this.renderSelectOptions()}</select>`}};ge.styles=[P,Jn],l([p({type:String})],ge.prototype,"name",2),l([p({type:String})],ge.prototype,"id",2),l([p({type:String})],ge.prototype,"value",2),l([p({type:Boolean,reflect:!0})],ge.prototype,"disabled",2),l([p({type:Boolean,reflect:!0,attribute:"has-error"})],ge.prototype,"hasError",2),l([p({type:String})],ge.prototype,"placeholder",2),l([p({type:Array,attribute:!1})],ge.prototype,"options",2),ge=l([b("primer-select")],ge);var Zn=y` :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 ye=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>`}};ye.styles=[Zn],l([p({type:String})],ye.prototype,"header",2),l([p({type:Boolean})],ye.prototype,"expanded",2),l([p({type:String})],ye.prototype,"expandText",2),l([p({type:String})],ye.prototype,"collapseText",2),l([p({type:String})],ye.prototype,"ariaLabel",2),l([p({type:String})],ye.prototype,"buttonVariant",2),l([_()],ye.prototype,"isExpanded",2),ye=l([b("primer-collapsable")],ye);var Xn=y` :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 Ye=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 h;let e={"error-message":!0,hidden:!this.visible};return m`<div part="error-message" class=${re(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>`}};Ye.styles=[Xn],l([p({type:String})],Ye.prototype,"message",2),l([p({type:Boolean,reflect:!0})],Ye.prototype,"visible",2),l([_()],Ye.prototype,"showMessage",2),Ye=l([b("primer-error-message")],Ye);var Qn=y` :host { display: none; } `;var ht=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","primer-dialog-close"].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>`}};ht.styles=[Qn],l([_()],ht.prototype,"_id",2),ht=l([b("primer-portal")],ht);var es=y` :host { display: contents; } .backdrop { position: fixed; top: 0; left: 0; background-color: rgba(0, 0, 0, 0.2); z-index: 1000; display: flex; justify-content: center; align-items: center; width: 100vw; height: 100vh; /* Animation properties */ transition: all 500ms cubic-bezier(0.4, 0, 0.2, 1); opacity: 0; } .backdrop--entering { opacity: 0; } .backdrop--entered { opacity: 1; } .backdrop--exiting { opacity: 0; } .dialog { background-color: white; padding: var(--primer-space-medium); border-radius: var(--primer-radius-medium); max-width: 600px; box-shadow: 1px 1px 5px 3px rgba(0, 0, 0, 0.05); /* Animation properties */ transition: all 500ms cubic-bezier(0.4, 0, 0.2, 1); opacity: 0; transform: translateY(100vh); } .dialog--entering { opacity: 0; transform: translateY(100vh); } .dialog--entered { opacity: 1; transform: translateY(0); } .dialog--exiting { opacity: 0; transform: translateY(100vh); } .dialog.large { width: 500px; height: 640px; padding: 0; overflow: hidden; display: flex; flex-direction: column; } @media (max-width: 500px) { .dialog.large { width: calc(100vw - var(--primer-space-large, 32px)); height: calc(100vh - var(--primer-space-large, 32px)); max-width: none; max-height: none; } } .header { display: flex; justify-content: flex-end; flex-shrink: 0; } .content { flex: 1; overflow: auto; min-height: 0; } `;var Ne=class extends v{constructor(){super(...arguments);this.size="flex";this.showCloseButton=!0;this._animationState="entering";this._isVisible=!1;this._handleCloseClick=()=>{this._startExitAnimation()}}startExitAnimation(){this._startExitAnimation()}connectedCallback(){super.connectedCallback(),document.body.style.overflow="hidden",this._startEnterAnimation()}disconnectedCallback(){super.disconnectedCallback(),document.body.style.overflow="",this._animationTimeout&&clearTimeout(this._animationTimeout)}_startEnterAnimation(){this._animationState="entering",this._isVisible=!0,requestAnimationFrame(()=>{this._animationTimeout=window.setTimeout(()=>{this._animationState="entered"},500)})}_startExitAnimation(){this._animationTimeout&&clearTimeout(this._animationTimeout),this._animationState="exiting",this._animationTimeout=window.setTimeout(()=>{this._animationState="exited",this._isVisible=!1,this.dispatchEvent(new CustomEvent("primer-dialog-close",{bubbles:!0,composed:!0}))},500)}render(){return this._isVisible?m`<div class=${re({backdrop:!0,"backdrop--entering":this._animationState==="entering","backdrop--entered":this._animationState==="entered","backdrop--exiting":this._animationState==="exiting"})} @click=${e=>{e.preventDefault()}} ><div class=${re({dialog:!0,[this.size]:!0,"dialog--entering":this._animationState==="entering","dialog--entered":this._animationState==="entered","dialog--exiting":this._animationState==="exiting"})} ><div class="header">${this.showCloseButton?m`<primer-button variant="tertiary" @click=${this._handleCloseClick} ><primer-icon name="close"></primer-icon></primer-button>`:""}</div><div class="content"><slot></slot></div></div></div>`:m``}};Ne.styles=[es],l([p({type:String})],Ne.prototype,"size",2),l([p({type:Boolean})],Ne.prototype,"showCloseButton",2),l([_()],Ne.prototype,"_animationState",2),l([_()],Ne.prototype,"_isVisible",2),Ne=l([b("primer-dialog")],Ne);var ts=y` :host { display: contents; } .klarna-container { display: flex; flex-direction: column; width: 100%; transition: all var(--primer-animation-duration) var(--primer-animation-easing); } .klarna-container.expanded { border-radius: var(--primer-radius-medium); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); background-color: var(--primer-color-background-outlined-default); border: 1px solid var(--primer-color-border-outlined-default); padding: var(--primer-space-large); } .klarna-button-header { padding: 0; display: flex; align-items: center; justify-content: space-between; width: 100%; gap: var(--primer-space-small); } .klarna-accordion-icon { position: absolute; right: var(--primer-space-medium); font-size: var(--primer-typography-body-small-size); font-weight: var(--primer-typography-title-large-weight); color: var(--primer-color-text-secondary); transition: all var(--primer-animation-duration) var(--primer-animation-easing); display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; margin-left: var(--primer-space-small); } .klarna-accordion-icon.expanded { transform: rotate(180deg); } .klarna-expanded-content { width: 100%; display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--primer-animation-duration) var(--primer-animation-easing); } .klarna-expanded-content.visible { margin-top: var(--primer-space-large); border-top: 1px solid var(--primer-color-border-outlined-default); grid-template-rows: 1fr; } .klarna-accordion-content { overflow: hidden; } @keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } .category-selection { display: flex; flex-wrap: wrap; gap: var(--primer-space-small); margin: var(--primer-space-large) 0; } .category-button { padding: var(--primer-space-medium) var(--primer-space-large); border-radius: var(--primer-radius-base); background-color: var(--primer-color-background-outlined-loading); border: 1px solid var(--primer-color-border-outlined-default); font-size: var(--primer-typography-body-medium-size); cursor: pointer; transition: all var(--primer-animation-duration) var(--primer-animation-easing); flex: 1; min-width: 100px; text-align: center; } .category-button.selected { background-color: var(--primer-color-background-outlined-default); border-color: var(--primer-color-brand); color: var(--primer-color-brand); font-weight: var(--primer-typography-title-large-weight); } .category-button:hover:not(.selected):not(:disabled) { background-color: var(--primer-color-background-outlined-hover); } .category-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; } .klarna-category-container { min-height: 74px; width: 100%; border-radius: var(--primer-radius-small); border: 1px solid var(--primer-color-border-outlined-default); background-color: var(--primer-color-background-outlined-default); padding: var(--primer-space-medium); margin-bottom: var(--primer-space-large); transition: height var(--primer-animation-duration) var(--primer-animation-easing); overflow: hidden; } .klarna-button::part(button) { display: flex; flex: 1; gap: var(--primer-space-small); height: calc( ${he(_e)} + calc(2 * var(--primer-space-medium)) ); width: 100%; } .klarna-button primer-icon { margin-right: var(--primer-space-medium); } .klarna-button:hover { background-color: var(--primer-color-background-outlined-hover); border-color: var(--primer-color-border-outlined-hover); } .klarna-pay-button { padding: var(--primer-space-medium) var(--primer-space-large); display: flex; align-items: center; justify-content: center; border-radius: var(--primer-radius-small); background-color: var(--primer-color-brand); color: var(--primer-color-background-outlined-default); border: none; font-size: var(--primer-typography-body-medium-size); font-weight: var(--primer-typography-body-medium-weight); width: 100%; cursor: pointer; transition: all var(--primer-animation-duration) var(--primer-animation-easing); } .klarna-pay-button:hover:not(.disabled) { filter: brightness(105%); } .klarna-pay-button.loading { opacity: 0.7; pointer-events: none; } .klarna-pay-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 { text-align: center; font-size: var(--primer-typography-body-medium-size); color: var(--primer-color-text-secondary); padding: var(--primer-space-medium); } .error { color: var(--primer-color-text-negative); font-size: var(--primer-typography-body-medium-size); padding: var(--primer-space-medium); text-align: center; border: 1px solid var(--primer-color-border-outlined-error); background-color: var(--primer-color-background-outlined-default); border-radius: var(--primer-radius-small); } /* Overall disabled state for entire Klarna component */ :host([disabled]) { cursor: not-allowed; } :host([disabled]) .klarna-button { pointer-events: none; cursor: not-allowed; } :host([disabled]) .category-button { pointer-events: none; cursor: not-allowed; } :host([disabled]) .klarna-pay-button { pointer-events: none; cursor: not-allowed; } /* Ensure disabled state is visible on container when expanded */ :host([disabled]) .klarna-container.expanded { background-color: var(--primer-color-background-outlined-disabled); border-color: var(--primer-color-border-outlined-disabled); opacity: 0.7; } `;var ie=class extends v{constructor(){super(...arguments);this.paymentManagers=new Map;this.sdkState=null;this.headlessUtils=null;this.klarnaCategories=null;this.disabled=!1;this.selectedCategory=null;this.isExpanded=!1;this.headerAriaLabel=C("pay_with",{id:"pay_with"});this._paymentMethodManagerTask=new D(this,{task:async([e,r])=>{if(!e||!r)return R;let o=await r.getCDNAssets("KLARNA");return{manager:e.manager,klarnaIcon:o?.assets?.icon?`${o.goatCdnUrl}/${o.assets.icon}`:""}},args:()=>[this.paymentManagers.get("KLARNA"),this.headlessUtils]});this.toggleExpand=()=>{this.disabled||(this.isExpanded=!this.isExpanded,this.isExpanded||(this.selectedCategory=null))}}async startKlarnaPayment(){if(!(!this._paymentMethodManagerTask.value||!this.selectedCategory))try{await this._paymentMethodManagerTask.value.manager.start({paymentMethodCategoryId:this.selectedCategory})}catch(e){A.errorWithDatadog("Failed to start Klarna payment",{error:e})}}async renderSelectedCategory(){if(!(!this._paymentMethodManagerTask.value||!this.selectedCategory||!this.klarnaContainer))try{this.klarnaContainer.innerHTML="",await this._paymentMethodManagerTask.value.manager.renderCategory({containerId:this.klarnaContainer,paymentMethodCategoryId:this.selectedCategory,onHeightChange:e=>{e>0&&(this.klarnaContainer.style.height=`${e}px`)}})}catch(e){A.errorWithDatadog("Failed to render Klarna category",{error:e})}}selectCategory(e){this.disabled||(this.selectedCategory=e,this.renderSelectedCategory())}updated(e){e.has("selectedCategory")&&this.selectedCategory&&this.renderSelectedCategory()}renderCategorySelection(){let e=this.klarnaCategories?.categories||[];return this.klarnaCategories?.isLoading||!1?m`<div class="loading"><primer-spinner size="small"></primer-spinner></div>`:m`<div class="category-selection">${e.map(o=>m`<button class=${re({"category-button":!0,selected:o.id===this.selectedCategory})} @click=${()=>{this.selectCategory(o.id)}} ?disabled=${this.disabled} >${o.name}</button>`)}</div>`}renderExpandedContent(){return m` ${this.renderCategorySelection()} ${this.selectedCategory?m`<div id="klarna-category-container" class="klarna-category-container" ></div>`:h}<button class=${re({"klarna-pay-button":!0,loading:!!this.sdkState?.isProcessing,disabled:!this.selectedCategory||this.disabled})} ?disabled=${!this.selectedCategory||this.sdkState?.isProcessing||this.disabled} @click=${()=>this.startKlarnaPayment()} >${C("confirm",{id:"confirm"})}</button>`}render(){return this._paymentMethodManagerTask.render({error:e=>{let r=e instanceof Error?e.message:"Unknown error in Klarna";return m`<div class="error"> Error loading Klarna: ${r}</div>`},complete:({manager:e,klarnaIcon:r})=>e?m`<div class="klarna-container ${this.isExpanded?"expanded":""}"><div class="klarna-button-header"><primer-button buttonType="button" variant="secondary" class="klarna-button" @click=${this.toggleExpand} aria-expanded=${this.isExpanded} aria-controls="collapsable-content" aria-label=${this.headerAriaLabel} ?disabled=${this.disabled} ><img src=${r} alt="Klarna logo" /><span>${C("pay_with",{id:"pay_with"})} Klarna</span><span class="klarna-accordion-icon ${this.isExpanded?"expanded":""}" > ▼ </span></primer-button></div><div class="klarna-expanded-content ${this.isExpanded?"visible":""}" ><div class="klarna-accordion-content">${this.renderExpandedContent()}</div></div></div>`:h})}};ie.styles=[P,ts],l([E({context:K,subscribe:!0}),p()],ie.prototype,"paymentManagers",2),l([E({context:j,subscribe:!0}),p()],ie.prototype,"sdkState",2),l([E({context:F,subscribe:!0}),p({type:Object})],ie.prototype,"headlessUtils",2),l([E({context:_r,subscribe:!0}),p()],ie.prototype,"klarnaCategories",2),l([p({type:Boolean,attribute:"disabled"})],ie.prototype,"disabled",2),l([_()],ie.prototype,"selectedCategory",2),l([_()],ie.prototype,"isExpanded",2),l([_()],ie.prototype,"headerAriaLabel",2),l([mt("#klarna-category-container")],ie.prototype,"klarnaContainer",2),ie=l([b("primer-klarna"),O()],ie);var rs=y` :host { display: contents; } `;var Nt={WORLDPAY_IDEAL:"WORLDPAY_IDEAL",AUTOMATED_CLEARING_HOUSE:"AUTOMATED_CLEARING_HOUSE",ADYEN_KLARNA:"ADYEN_KLARNA",ADYEN_BANCONTACT_CARD:"ADYEN_BANCONTACT_CARD",PAY_NL_KAARTDIRECT:"PAY_NL_KAARTDIRECT",ADYEN_EPS:"ADYEN_EPS",ADYEN_BANCONTACT_PAYCONIQ:"ADYEN_BANCONTACT_PAYCONIQ",OMISE_PROMPTPAY:"OMISE_PROMPTPAY",OMISE_TRUEMONEY:"OMISE_TRUEMONEY",ADYEN_MULTIBANCO:"ADYEN_MULTIBANCO",PACYPAY_WECHAT:"PACYPAY_WECHAT",PACYPAY_ALIPAY:"PACYPAY_ALIPAY",ADYEN_MBWAY:"ADYEN_MBWAY",XENDIT_DANA:"XENDIT_DANA",XENDIT_SHOPEEPAY:"XENDIT_SHOPEEPAY",ADYEN_PAYSHOP:"ADYEN_PAYSHOP",ADYEN_PAYTRAIL:"ADYEN_PAYTRAIL",CLEARPAY:"CLEARPAY",RAPYD_FAST:"RAPYD_FAST",RAPYD_PROMPTPAY:"RAPYD_PROMPTPAY",RAPYD_GCASH:"RAPYD_GCASH",RAPYD_POLI:"RAPYD_POLI",RAPYD_GRABPAY:"RAPYD_GRABPAY",PRIMER_PAYPAL:"PRIMER_PAYPAL",TWOC2P:"TWOC2P",NETS:"NETS",STRIPE_ACH:"STRIPE_ACH",STRIPE_GIROPAY:"STRIPE_GIROPAY",MOLLIE_GIROPAY:"MOLLIE_GIROPAY",MOLLIE_EPS:"MOLLIE_EPS",PAY_NL_EPS:"PAY_NL_EPS",PAY_NL_P24:"PAY_NL_P24",MOLLIE_P24:"MOLLIE_P24",MOLLIE_SOFORT:"MOLLIE_SOFORT",COINBASE:"COINBASE",OPENNODE:"OPENNODE",MOLLIE_GIFT_CARD:"MOLLIE_GIFTCARD",XFERS_PAYNOW:"XFERS_PAYNOW",CARD:"PAYMENT_CARD",APPLE_PAY:"APPLE_PAY",GOOGLE_PAY:"GOOGLE_PAY",PAYPAL:"PAYPAL_ORDER",PAYPAL_VAULTED:"PAYPAL_BILLING_AGREEMENT",GO_CARDLESS:"GOCARDLESS",PAY_NL_IDEAL:"PAY_NL_IDEAL",PAY_NL_SOFORT_BANKING:"PAY_NL_SOFORT_BANKING",PAY_NL_BANCONTACT:"PAY_NL_BANCONTACT",PAY_NL_PAYPAL:"PAY_NL_PAYPAL",PAY_NL_CREDIT_TRANSFER:"PAY_NL_CREDIT_TRANSFER",PAY_NL_DIRECT_DEBIT:"PAY_NL_DIRECT_DEBIT",PAY_NL_GIROPAY:"PAY_NL_GIROPAY",PAY_NL_PAYCONIQ:"PAY_NL_PAYCONIQ",PAY_NL_RIVERTY:"PAY_NL_RIVERTY",HOOLAH:"HOOLAH",ADYEN_BLIK:"ADYEN_BLIK",ADYEN_VIPPS:"ADYEN_VIPPS",ADYEN_GIROPAY:"ADYEN_GIROPAY",ADYEN_SOFORT:"ADYEN_SOFORT",ADYEN_IDEAL:"ADYEN_IDEAL",ADYEN_TRUSTLY:"ADYEN_TRUSTLY",ADYEN_ALIPAY:"ADYEN_ALIPAY",ADYEN_TWINT:"ADYEN_TWINT",ADYEN_MOBILEPAY:"ADYEN_MOBILEPAY",MOLLIE_BANCONTACT:"MOLLIE_BANCONTACT",MOLLIE_IDEAL:"MOLLIE_IDEAL",BUCKAROO_GIROPAY:"BUCKAROO_GIROPAY",BUCKAROO_EPS:"BUCKAROO_EPS",BUCKAROO_SOFORT:"BUCKAROO_SOFORT",BUCKAROO_BANCONTACT:"BUCKAROO_BANCONTACT",BUCKAROO_IDEAL:"BUCKAROO_IDEAL",ATOME:"ATOME",KLARNA_CUSTOMER_TOKEN:"KLARNA_CUSTOMER_TOKEN",DLOCAL_PIX:"DLOCAL_PIX",ALMA:"ALMA"},vr={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"};var zt=y` :host { height: calc( ${he(_e)} + calc(2 * var(--primer-space-medium)) ); width: 100%; display: flex; } .native-button-container { width: 100%; height: 100%; flex: 1; position: relative; } /* Disabled state styling - handled via JavaScript overlay for iframe compatibility */ :host([disabled]) { cursor: not-allowed; } `;var is=y` ${zt} /* Google Pay renders to shadow root, no additional container styles needed */ :host { /* Ensure full width for Google Pay button */ width: 100%; } `;function os(){let i=document.createElement("div");return i.className="disabled-overlay",i.style.cssText=`
|
|
189
|
+
`;var Ha=':root,primer-checkout{--primer-color-background-transparent-default:rgba(255,255,255,0);--primer-color-border-transparent-default:rgba(255,255,255,0);--primer-color-gray-100:#f5f5f5;--primer-color-gray-200:#eeeeee;--primer-color-gray-300:#e0e0e0;--primer-color-gray-400:#bdbdbd;--primer-color-gray-500:#9e9e9e;--primer-color-gray-600:#757575;--primer-color-gray-900:#212121;--primer-color-gray-000:#ffffff;--primer-color-brand:#2f98ff;--primer-color-red-100:#ffecec;--primer-color-red-500:#ff7279;--primer-color-red-900:#b4324b;--primer-color-blue-500:#399dff;--primer-color-blue-900:#2270f4;--primer-radius-base:4px;--primer-typography-brand:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;--primer-typography-title-xlarge-letter-spacing:-0.6px;--primer-typography-title-xlarge-weight:550;--primer-typography-title-xlarge-size:24px;--primer-typography-title-xlarge-line-height:32px;--primer-typography-title-large-letter-spacing:-0.2px;--primer-typography-title-large-weight:550;--primer-typography-title-large-size:16px;--primer-typography-title-large-line-height:20px;--primer-typography-body-large-letter-spacing:-0.2px;--primer-typography-body-large-weight:400;--primer-typography-body-large-size:16px;--primer-typography-body-large-line-height:20px;--primer-typography-body-medium-letter-spacing:0px;--primer-typography-body-medium-weight:400;--primer-typography-body-medium-size:14px;--primer-typography-body-medium-line-height:20px;--primer-typography-body-small-letter-spacing:0px;--primer-typography-body-small-weight:400;--primer-typography-body-small-size:12px;--primer-typography-body-small-line-height:16px;--primer-space-base:4px;--primer-size-base:4px;--primer-animation-duration:200ms;--primer-animation-easing:cubic-bezier(0.44,0,0.4,1);--primer-color-background-outlined-default:var(--primer-color-gray-000);--primer-color-background-outlined-disabled:var(--primer-color-gray-100);--primer-color-background-transparent-hover:var(--primer-color-gray-100);--primer-color-background-transparent-active:var(--primer-color-gray-200);--primer-color-background-transparent-loading:var(--primer-color-gray-100);--primer-color-background-transparent-focus:var(--primer-color-background-transparent-default);--primer-color-background-transparent-disabled:var(--primer-color-gray-100);--primer-color-background-transparent-selected:var(--primer-color-gray-100);--primer-color-text-primary:var(--primer-color-gray-900);--primer-color-text-placeholder:var(--primer-color-gray-500);--primer-color-text-disabled:var(--primer-color-gray-400);--primer-color-text-negative:var(--primer-color-red-900);--primer-color-text-link:var(--primer-color-blue-900);--primer-color-text-secondary:var(--primer-color-gray-600);--primer-color-border-outlined-default:var(--primer-color-gray-300);--primer-color-border-outlined-hover:var(--primer-color-gray-400);--primer-color-border-outlined-active:var(--primer-color-gray-500);--primer-color-border-outlined-disabled:var(--primer-color-gray-200);--primer-color-border-outlined-loading:var(--primer-color-gray-200);--primer-color-border-outlined-selected:var(--primer-color-brand);--primer-color-border-outlined-error:var(--primer-color-red-500);--primer-color-border-transparent-hover:var(--primer-color-border-transparent-default);--primer-color-border-transparent-active:var(--primer-color-border-transparent-default);--primer-color-border-transparent-disabled:var(--primer-color-border-transparent-default);--primer-color-border-transparent-selected:var(--primer-color-border-transparent-default);--primer-color-icon-primary:var(--primer-color-gray-900);--primer-color-icon-disabled:var(--primer-color-gray-400);--primer-color-icon-negative:var(--primer-color-red-500);--primer-color-focus:var(--primer-color-brand);--primer-color-loader:var(--primer-color-brand);--primer-radius-medium:8px;--primer-radius-small:4px;--primer-radius-large:12px;--primer-radius-xsmall:2px;--primer-typography-title-xlarge-font:var(--primer-typography-brand);--primer-typography-title-large-font:var(--primer-typography-brand);--primer-typography-body-large-font:var(--primer-typography-brand);--primer-typography-body-medium-font:var(--primer-typography-brand);--primer-typography-body-small-font:var(--primer-typography-brand);--primer-space-xxsmall:2px;--primer-space-xsmall:4px;--primer-space-small:8px;--primer-space-medium:12px;--primer-space-large:16px;--primer-space-xlarge:20px;--primer-size-small:16px;--primer-size-medium:20px;--primer-size-large:24px;--primer-size-xlarge:32px;--primer-size-xxlarge:40px;--primer-size-xxxlarge:56px;--primer-color-background-outlined-focus:var(--primer-color-background-outlined-default);--primer-color-background-outlined-loading:var(--primer-color-background-outlined-disabled);--primer-color-background-outlined-active:var(--primer-color-background-outlined-default);--primer-color-background-outlined-hover:var(--primer-color-background-outlined-default);--primer-color-background-outlined-selected:var(--primer-color-background-outlined-default);--primer-color-background-outlined-error:var(--primer-color-background-outlined-default);--primer-color-border-outlined-focus:var(--primer-color-focus);--primer-color-border-transparent-focus:var(--primer-color-focus);--primer-color-border-transparent-loading:var(--primer-color-border-transparent-disabled)}',za=":root,primer-checkout.primer-dark-theme{--primer-color-gray-100:#292929;--primer-color-gray-200:#424242;--primer-color-gray-300:#575757;--primer-color-gray-400:#858585;--primer-color-gray-500:#767577;--primer-color-gray-600:#c7c7c7;--primer-color-gray-900:#efefef;--primer-color-gray-000:#171619;--primer-color-brand:#2f98ff;--primer-color-red-100:#321c20;--primer-color-red-500:#e46d70;--primer-color-red-900:#f6bfbf;--primer-color-blue-500:#3f93e4;--primer-color-blue-900:#4aaeff}";var $c="primer-light-theme-css",Vc="primer-dark-theme-css";function Vo(){br(Ha,$c,!0)}function Uo(){br(za,Vc,!0)}function Ka(){Vo(),Uo()}function Ga(){br(Fa,"primer-css-loader-styles",!1)}function ja(){Ka()}function Uc(){Vo()}function Yc(){Uo()}var Wa=y` :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 Yo={small:16,medium:24,large:32},Ve=class extends v{constructor(){super(...arguments);this.color="var(--primer-color-loader)";this.size="medium";this.compact=!1}getSize(){if(this.size in Yo)return Yo[this.size];let e=parseInt(this.size,10);return isNaN(e)?Yo.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>`}};Ve.styles=[Wa],d([p({type:String})],Ve.prototype,"color",2),d([p({type:String})],Ve.prototype,"size",2),d([p({type:Boolean})],Ve.prototype,"compact",2),Ve=d([b("primer-spinner")],Ve);var re=Ce(class extends $e{constructor(i){if(super(i),i.type!==Z.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 te}});var qa=y` * { box-sizing: border-box; } :host { display: block; width: 100%; } .input-slot.focus-within { outline: 2px solid var(--primer-color-border-outlined-focus); outline-offset: -2px; } :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 Ue=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 n=o.querySelector("primer-input");if(n)return n}return null}render(){let e={"input-slot":!0,"focus-within":this.focusWithin};return m`<div class="input-wrapper"><slot name="label"></slot><div class="${re(e)}" @click="${this.handleWrapperClick}"><slot name="input"></slot></div><slot name="error"></slot></div>`}};Ue.styles=[qa],d([p({type:Boolean})],Ue.prototype,"focusWithin",2),d([p({type:Boolean,reflect:!0,attribute:"has-error"})],Ue.prototype,"hasError",2),d([ut('slot[name="input"]')],Ue.prototype,"inputSlot",2),Ue=d([b("primer-input-wrapper")],Ue);var Ja=y` :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 Ze=class extends v{constructor(){super(...arguments);this.for="";this.disabled=!1}render(){return m`<label for=${this.for}><slot></slot></label>`}};Ze.styles=[Ja],d([p({type:String,reflect:!0})],Ze.prototype,"for",2),d([p({type:Boolean,reflect:!0})],Ze.prototype,"disabled",2),Ze=d([b("primer-input-label")],Ze);var Za=y` :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 ge=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?g:m`<primer-icon name="checkmark" size="sm" color="var(--primer-color-brand)" ></primer-icon>`}renderSpinner(){if(!this.loading)return g;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>`}};ge.styles=[_,Za],d([p({type:String,reflect:!0})],ge.prototype,"variant",2),d([p({type:Boolean,reflect:!0})],ge.prototype,"disabled",2),d([p({type:Boolean,reflect:!0})],ge.prototype,"loading",2),d([p({type:String,attribute:"type"})],ge.prototype,"buttonType",2),d([p({type:String,reflect:!0})],ge.prototype,"selectionState",2),d([p({type:Boolean,reflect:!0})],ge.prototype,"selectable",2),d([p({type:Boolean,reflect:!0})],ge.prototype,"flex",2),ge=d([b("primer-button")],ge);var Xa=y` :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 Xe=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>`}};Xe.styles=[Xa],d([p({type:String,reflect:!0})],Xe.prototype,"for",2),d([p({type:Boolean,reflect:!0})],Xe.prototype,"active",2),Xe=d([b("primer-input-error")],Xe);var Qa={trash:De`<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":De`<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":De`<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":De`<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":De`<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:De`<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:De`<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:De`<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:De`<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 es=y` :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 Ye=class extends v{constructor(){super(...arguments);this.color="var(--primer-color-icon-primary)";this.size="lg"}render(){let e=this.name?Qa[this.name]:null;return m`<div style="--internal-icon-color: ${this.color}">${e||m`<slot></slot>`}</div>`}};Ye.styles=[es],d([p({type:String,reflect:!0})],Ye.prototype,"color",2),d([p({type:String,reflect:!0})],Ye.prototype,"size",2),d([p({reflect:!0})],Ye.prototype,"name",2),Ye=d([b("primer-icon")],Ye);var ts=y` :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 Qe=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>`} `}};Qe.styles=[ts],d([p({type:String,reflect:!0})],Qe.prototype,"type",2),d([p({type:String,reflect:!0})],Qe.prototype,"description",2),Qe=d([b("primer-checkout-state")],Qe);var rs=y` :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 Bc=["text","password","email","number","tel","url","search","date","time","datetime-local","month","week","color"];function Fc(i){return Bc.includes(i)}var B=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)}};B.styles=[rs],d([ut("input")],B.prototype,"inputElement",2),d([p({type:String,reflect:!0})],B.prototype,"value",2),d([p({type:String,reflect:!0})],B.prototype,"placeholder",2),d([p({type:Boolean,reflect:!0})],B.prototype,"disabled",2),d([p({type:String,reflect:!0})],B.prototype,"name",2),d([p({type:String,reflect:!0,converter:{fromAttribute:e=>!e||!Fc(e)?(e&&e!=="text"&&P.warn(`Invalid input type: ${e}. Defaulting to 'text'.`),"text"):e}})],B.prototype,"type",2),d([p({type:Boolean,reflect:!0})],B.prototype,"required",2),d([p({type:Boolean,reflect:!0})],B.prototype,"readonly",2),d([p({type:String,reflect:!0})],B.prototype,"pattern",2),d([p({type:Number,reflect:!0})],B.prototype,"minlength",2),d([p({type:Number,reflect:!0})],B.prototype,"maxlength",2),d([p({type:String,reflect:!0})],B.prototype,"min",2),d([p({type:String,reflect:!0})],B.prototype,"max",2),d([p({type:String,reflect:!0})],B.prototype,"step",2),d([p({type:String,reflect:!0})],B.prototype,"autocomplete",2),d([M()],B.prototype,"hasFocus",2),d([M()],B.prototype,"hasError",2),B=d([b("primer-input")],B);var{I:gv}=La;var Ci=i=>i.strings===void 0;var Hc={},is=(i,t=Hc)=>i._$AH=t;var os=Ce(class extends $e{constructor(i){if(super(i),i.type!==Z.PROPERTY&&i.type!==Z.ATTRIBUTE&&i.type!==Z.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!Ci(i))throw Error("`live` bindings can only contain a single expression")}render(i){return i}update(i,[t]){if(t===te||t===g)return t;let e=i.element,r=i.name;if(i.type===Z.PROPERTY){if(t===e[r])return te}else if(i.type===Z.BOOLEAN_ATTRIBUTE){if(!!t===e.hasAttribute(r))return te}else if(i.type===Z.ATTRIBUTE&&e.getAttribute(r)===t+"")return te;return is(i),t}});var ns=y` :host { display: contents; } select { width: 100%; padding: 0; padding-right: calc(var(--primer-space-medium) + 12px); 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; cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23212121' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0 center; } /* Placeholder state - when no value is selected */ select:invalid, select[value=''] { color: var(--primer-color-text-placeholder); } select:disabled { color: var(--primer-color-text-disabled); cursor: not-allowed; } /* Placeholder option styling */ select option:disabled { color: var(--primer-color-text-placeholder); } `;var fe=class extends v{constructor(){super(...arguments);this.name="";this.id="";this.value="";this.disabled=!1;this.hasError=!1;this.placeholder="";this.options=[]}handleChange(e){let r=e.target,o=this.value;this.value=r.value,this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0,composed:!0})),this.requestUpdate("value",o)}handleFocus(){this.dispatchEvent(new CustomEvent("focus",{bubbles:!0,composed:!0}))}handleBlur(){this.dispatchEvent(new CustomEvent("blur",{bubbles:!0,composed:!0}))}renderSelectOptions(){let e=[];for(let r of this.options)e.push(m`<option value=${r.value}>${r.label}</option>`);return e}render(){return m`<select id=${this.id} name=${this.name} .value=${os(this.value)} ?disabled=${this.disabled} ?required=${!this.value} @change=${this.handleChange} @focus=${this.handleFocus} @blur=${this.handleBlur} aria-invalid=${this.hasError?"true":"false"} ><option value="" disabled ?selected=${!this.value}>${this.placeholder||"Select an option"}</option>${this.renderSelectOptions()}</select>`}};fe.styles=[_,ns],d([p({type:String})],fe.prototype,"name",2),d([p({type:String})],fe.prototype,"id",2),d([p({type:String})],fe.prototype,"value",2),d([p({type:Boolean,reflect:!0})],fe.prototype,"disabled",2),d([p({type:Boolean,reflect:!0,attribute:"has-error"})],fe.prototype,"hasError",2),d([p({type:String})],fe.prototype,"placeholder",2),d([p({type:Array,attribute:!1})],fe.prototype,"options",2),fe=d([b("primer-select")],fe);var as=y` :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 ye=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>`}};ye.styles=[as],d([p({type:String})],ye.prototype,"header",2),d([p({type:Boolean})],ye.prototype,"expanded",2),d([p({type:String})],ye.prototype,"expandText",2),d([p({type:String})],ye.prototype,"collapseText",2),d([p({type:String})],ye.prototype,"ariaLabel",2),d([p({type:String})],ye.prototype,"buttonVariant",2),d([M()],ye.prototype,"isExpanded",2),ye=d([b("primer-collapsable")],ye);var ss=y` :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 Be=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 g;let e={"error-message":!0,hidden:!this.visible};return m`<div part="error-message" class=${re(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>`}};Be.styles=[ss],d([p({type:String})],Be.prototype,"message",2),d([p({type:Boolean,reflect:!0})],Be.prototype,"visible",2),d([M()],Be.prototype,"showMessage",2),Be=d([b("primer-error-message")],Be);var ls=y` :host { display: none; } `;var ht=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 n=this.getContainer();o.forEach(a=>n.appendChild(a))}}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","primer-dialog-close"].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>`}};ht.styles=[ls],d([M()],ht.prototype,"_id",2),ht=d([b("primer-portal")],ht);var ds=y` :host { display: contents; } .backdrop { position: fixed; top: 0; left: 0; background-color: rgba(0, 0, 0, 0.2); z-index: 1000; display: flex; justify-content: center; align-items: center; width: 100vw; height: 100vh; /* Animation properties */ transition: all 500ms cubic-bezier(0.4, 0, 0.2, 1); opacity: 0; } .backdrop--entering { opacity: 0; } .backdrop--entered { opacity: 1; } .backdrop--exiting { opacity: 0; } .dialog { background-color: white; padding: var(--primer-space-medium); border-radius: var(--primer-radius-medium); max-width: 600px; box-shadow: 1px 1px 5px 3px rgba(0, 0, 0, 0.05); /* Animation properties */ transition: all 500ms cubic-bezier(0.4, 0, 0.2, 1); opacity: 0; transform: translateY(100vh); } .dialog--entering { opacity: 0; transform: translateY(100vh); } .dialog--entered { opacity: 1; transform: translateY(0); } .dialog--exiting { opacity: 0; transform: translateY(100vh); } .dialog.large { width: 500px; height: 640px; padding: 0; overflow: hidden; display: flex; flex-direction: column; } @media (max-width: 500px) { .dialog.large { width: calc(100vw - var(--primer-space-large, 32px)); height: calc(100vh - var(--primer-space-large, 32px)); max-width: none; max-height: none; } } .header { display: flex; justify-content: flex-end; flex-shrink: 0; } .content { flex: 1; overflow: auto; min-height: 0; } `;var Ne=class extends v{constructor(){super(...arguments);this.size="flex";this.showCloseButton=!0;this._animationState="entering";this._isVisible=!1;this._handleCloseClick=()=>{this._startExitAnimation()}}startExitAnimation(){this._startExitAnimation()}connectedCallback(){super.connectedCallback(),document.body.style.overflow="hidden",this._startEnterAnimation()}disconnectedCallback(){super.disconnectedCallback(),document.body.style.overflow="",this._animationTimeout&&clearTimeout(this._animationTimeout)}_startEnterAnimation(){this._animationState="entering",this._isVisible=!0,requestAnimationFrame(()=>{this._animationTimeout=window.setTimeout(()=>{this._animationState="entered"},500)})}_startExitAnimation(){this._animationTimeout&&clearTimeout(this._animationTimeout),this._animationState="exiting",this._animationTimeout=window.setTimeout(()=>{this._animationState="exited",this._isVisible=!1,this.dispatchEvent(new CustomEvent("primer-dialog-close",{bubbles:!0,composed:!0}))},500)}render(){return this._isVisible?m`<div class=${re({backdrop:!0,"backdrop--entering":this._animationState==="entering","backdrop--entered":this._animationState==="entered","backdrop--exiting":this._animationState==="exiting"})} @click=${e=>{e.preventDefault()}} ><div class=${re({dialog:!0,[this.size]:!0,"dialog--entering":this._animationState==="entering","dialog--entered":this._animationState==="entered","dialog--exiting":this._animationState==="exiting"})} ><div class="header">${this.showCloseButton?m`<primer-button variant="tertiary" @click=${this._handleCloseClick} ><primer-icon name="close"></primer-icon></primer-button>`:""}</div><div class="content"><slot></slot></div></div></div>`:m``}};Ne.styles=[ds],d([p({type:String})],Ne.prototype,"size",2),d([p({type:Boolean})],Ne.prototype,"showCloseButton",2),d([M()],Ne.prototype,"_animationState",2),d([M()],Ne.prototype,"_isVisible",2),Ne=d([b("primer-dialog")],Ne);var cs=y` :host { display: contents; } .klarna-container { display: flex; flex-direction: column; width: 100%; transition: all var(--primer-animation-duration) var(--primer-animation-easing); } .klarna-container.expanded { border-radius: var(--primer-radius-medium); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); background-color: var(--primer-color-background-outlined-default); border: 1px solid var(--primer-color-border-outlined-default); padding: var(--primer-space-large); } .klarna-button-header { padding: 0; display: flex; align-items: center; justify-content: space-between; width: 100%; gap: var(--primer-space-small); } .klarna-accordion-icon { position: absolute; right: var(--primer-space-medium); font-size: var(--primer-typography-body-small-size); font-weight: var(--primer-typography-title-large-weight); color: var(--primer-color-text-secondary); transition: all var(--primer-animation-duration) var(--primer-animation-easing); display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; margin-left: var(--primer-space-small); } .klarna-accordion-icon.expanded { transform: rotate(180deg); } .klarna-expanded-content { width: 100%; display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--primer-animation-duration) var(--primer-animation-easing); } .klarna-expanded-content.visible { margin-top: var(--primer-space-large); border-top: 1px solid var(--primer-color-border-outlined-default); grid-template-rows: 1fr; } .klarna-accordion-content { overflow: hidden; } @keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } .category-selection { display: flex; flex-wrap: wrap; gap: var(--primer-space-small); margin: var(--primer-space-large) 0; } .category-button { padding: var(--primer-space-medium) var(--primer-space-large); border-radius: var(--primer-radius-base); background-color: var(--primer-color-background-outlined-loading); border: 1px solid var(--primer-color-border-outlined-default); font-size: var(--primer-typography-body-medium-size); cursor: pointer; transition: all var(--primer-animation-duration) var(--primer-animation-easing); flex: 1; min-width: 100px; text-align: center; } .category-button.selected { background-color: var(--primer-color-background-outlined-default); border-color: var(--primer-color-brand); color: var(--primer-color-brand); font-weight: var(--primer-typography-title-large-weight); } .category-button:hover:not(.selected):not(:disabled) { background-color: var(--primer-color-background-outlined-hover); } .category-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; } .klarna-category-container { min-height: 74px; width: 100%; border-radius: var(--primer-radius-small); border: 1px solid var(--primer-color-border-outlined-default); background-color: var(--primer-color-background-outlined-default); padding: var(--primer-space-medium); margin-bottom: var(--primer-space-large); transition: height var(--primer-animation-duration) var(--primer-animation-easing); overflow: hidden; } .klarna-button::part(button) { display: flex; flex: 1; gap: var(--primer-space-small); height: calc( ${he(Me)} + calc(2 * var(--primer-space-medium)) ); width: 100%; } .klarna-button primer-icon { margin-right: var(--primer-space-medium); } .klarna-button:hover { background-color: var(--primer-color-background-outlined-hover); border-color: var(--primer-color-border-outlined-hover); } .klarna-pay-button { padding: var(--primer-space-medium) var(--primer-space-large); display: flex; align-items: center; justify-content: center; border-radius: var(--primer-radius-small); background-color: var(--primer-color-brand); color: var(--primer-color-background-outlined-default); border: none; font-size: var(--primer-typography-body-medium-size); font-weight: var(--primer-typography-body-medium-weight); width: 100%; cursor: pointer; transition: all var(--primer-animation-duration) var(--primer-animation-easing); } .klarna-pay-button:hover:not(.disabled) { filter: brightness(105%); } .klarna-pay-button.loading { opacity: 0.7; pointer-events: none; } .klarna-pay-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 { text-align: center; font-size: var(--primer-typography-body-medium-size); color: var(--primer-color-text-secondary); padding: var(--primer-space-medium); } .error { color: var(--primer-color-text-negative); font-size: var(--primer-typography-body-medium-size); padding: var(--primer-space-medium); text-align: center; border: 1px solid var(--primer-color-border-outlined-error); background-color: var(--primer-color-background-outlined-default); border-radius: var(--primer-radius-small); } /* Overall disabled state for entire Klarna component */ :host([disabled]) { cursor: not-allowed; } :host([disabled]) .klarna-button { pointer-events: none; cursor: not-allowed; } :host([disabled]) .category-button { pointer-events: none; cursor: not-allowed; } :host([disabled]) .klarna-pay-button { pointer-events: none; cursor: not-allowed; } /* Ensure disabled state is visible on container when expanded */ :host([disabled]) .klarna-container.expanded { background-color: var(--primer-color-background-outlined-disabled); border-color: var(--primer-color-border-outlined-disabled); opacity: 0.7; } `;var ie=class extends v{constructor(){super(...arguments);this.paymentManagers=new Map;this.sdkState=null;this.headlessUtils=null;this.klarnaCategories=null;this.disabled=!1;this.selectedCategory=null;this.isExpanded=!1;this.headerAriaLabel=E("pay_with",{id:"pay_with"});this._paymentMethodManagerTask=new D(this,{task:async([e,r])=>{if(!e||!r)return R;let o=await r.getCDNAssets("KLARNA");return{manager:e.manager,klarnaIcon:o?.assets?.icon?`${o.goatCdnUrl}/${o.assets.icon}`:""}},args:()=>[this.paymentManagers.get("KLARNA"),this.headlessUtils]});this.toggleExpand=()=>{this.disabled||(this.isExpanded=!this.isExpanded,this.isExpanded||(this.selectedCategory=null))}}async startKlarnaPayment(){if(!(!this._paymentMethodManagerTask.value||!this.selectedCategory))try{await this._paymentMethodManagerTask.value.manager.start({paymentMethodCategoryId:this.selectedCategory})}catch(e){P.errorWithDatadog("Failed to start Klarna payment",{error:e})}}async renderSelectedCategory(){if(!(!this._paymentMethodManagerTask.value||!this.selectedCategory||!this.klarnaContainer))try{this.klarnaContainer.innerHTML="",await this._paymentMethodManagerTask.value.manager.renderCategory({containerId:this.klarnaContainer,paymentMethodCategoryId:this.selectedCategory,onHeightChange:e=>{e>0&&(this.klarnaContainer.style.height=`${e}px`)}})}catch(e){P.errorWithDatadog("Failed to render Klarna category",{error:e})}}selectCategory(e){this.disabled||(this.selectedCategory=e,this.renderSelectedCategory())}updated(e){e.has("selectedCategory")&&this.selectedCategory&&this.renderSelectedCategory()}renderCategorySelection(){let e=this.klarnaCategories?.categories||[];return this.klarnaCategories?.isLoading||!1?m`<div class="loading"><primer-spinner size="small"></primer-spinner></div>`:m`<div class="category-selection">${e.map(o=>m`<button class=${re({"category-button":!0,selected:o.id===this.selectedCategory})} @click=${()=>{this.selectCategory(o.id)}} ?disabled=${this.disabled} >${o.name}</button>`)}</div>`}renderExpandedContent(){return m` ${this.renderCategorySelection()} ${this.selectedCategory?m`<div id="klarna-category-container" class="klarna-category-container" ></div>`:g}<button class=${re({"klarna-pay-button":!0,loading:!!this.sdkState?.isProcessing,disabled:!this.selectedCategory||this.disabled})} ?disabled=${!this.selectedCategory||this.sdkState?.isProcessing||this.disabled} @click=${()=>this.startKlarnaPayment()} >${E("confirm",{id:"confirm"})}</button>`}render(){return this._paymentMethodManagerTask.render({error:e=>{let r=e instanceof Error?e.message:"Unknown error in Klarna";return m`<div class="error"> Error loading Klarna: ${r}</div>`},complete:({manager:e,klarnaIcon:r})=>e?m`<div class="klarna-container ${this.isExpanded?"expanded":""}"><div class="klarna-button-header"><primer-button buttonType="button" variant="secondary" class="klarna-button" @click=${this.toggleExpand} aria-expanded=${this.isExpanded} aria-controls="collapsable-content" aria-label=${this.headerAriaLabel} ?disabled=${this.disabled} ><img src=${r} alt="Klarna logo" /><span>${E("pay_with",{id:"pay_with"})} Klarna</span><span class="klarna-accordion-icon ${this.isExpanded?"expanded":""}" > ▼ </span></primer-button></div><div class="klarna-expanded-content ${this.isExpanded?"visible":""}" ><div class="klarna-accordion-content">${this.renderExpandedContent()}</div></div></div>`:g})}};ie.styles=[_,cs],d([C({context:K,subscribe:!0}),p()],ie.prototype,"paymentManagers",2),d([C({context:G,subscribe:!0}),p()],ie.prototype,"sdkState",2),d([C({context:H,subscribe:!0}),p({type:Object})],ie.prototype,"headlessUtils",2),d([C({context:Fr,subscribe:!0}),p()],ie.prototype,"klarnaCategories",2),d([p({type:Boolean,attribute:"disabled"})],ie.prototype,"disabled",2),d([M()],ie.prototype,"selectedCategory",2),d([M()],ie.prototype,"isExpanded",2),d([M()],ie.prototype,"headerAriaLabel",2),d([ut("#klarna-category-container")],ie.prototype,"klarnaContainer",2),ie=d([b("primer-klarna"),O()],ie);var ps=y` :host { display: contents; } `;var Gt=y` :host { height: calc( ${he(Me)} + calc(2 * var(--primer-space-medium)) ); width: 100%; display: flex; } .native-button-container { width: 100%; height: 100%; flex: 1; position: relative; } /* Disabled state styling - handled via JavaScript overlay for iframe compatibility */ :host([disabled]) { cursor: not-allowed; } `;var ms=y` ${Gt} /* Google Pay renders to shadow root, no additional container styles needed */ :host { /* Ensure full width for Google Pay button */ width: 100%; } `;function us(){let i=document.createElement("div");return i.className="disabled-overlay",i.style.cssText=`
|
|
190
190
|
position: absolute;
|
|
191
191
|
top: 0;
|
|
192
192
|
left: 0;
|
|
@@ -198,7 +198,7 @@ primer-checkout:not([js-initialized]):not([loader-disabled])::after {
|
|
|
198
198
|
z-index: 1000;
|
|
199
199
|
pointer-events: all;
|
|
200
200
|
backdrop-filter: grayscale(100%);
|
|
201
|
-
`,i}function Kt(i,t){let e=t.value;if(!e)return;let r=e.querySelector(".disabled-overlay");if(r&&r.remove(),i){let o=os();e.appendChild(o)}}function Ei(i,t,e=5){let r=null;if(r=t.querySelector(".gpay-card-info-container-fill"),r||(r=document.querySelector(".gpay-card-info-container-fill")),!r){e>0&&setTimeout(()=>Ei(i,t,e-1),100);return}let o=r.querySelector(".disabled-overlay");if(o&&o.remove(),i){let a=os();r.style.position="relative",r.appendChild(a)}}var He=class extends v{constructor(){super();this.paymentManagers=new Map;this.disabled=!1;this.loadManagerTask=new D(this,{args:()=>[this.paymentMethod?.type],task:([e])=>{if(!e)return R;let r=this.paymentManagers.get(e);if(!r)throw new Error(`No manager found for payment method type ${e}`);if(r.type!=="GOOGLE_PAY")throw new Error("Invalid payment method type for Google Pay component");return r.manager}}),this.renderButtonTask=new D(this,{args:()=>[this.loadManagerTask.value],task:async([e])=>{if(!e)return R;await this.updateComplete;let r=e.createButton();return await r.render(this.shadowRoot?.getRootNode(),{style:{shadowRoot:!0}}),this.disabled&&await r.setDisabled(this.disabled),this.disabled&&this.shadowRoot&&(await this.updateComplete,Ei(this.disabled,this.shadowRoot)),r}})}attributeChangedCallback(e,r,o){if(super.attributeChangedCallback(e,r,o),e==="disabled"&&r!==o){let a=o!==null,n=this.renderButtonTask.value;n&&n.setDisabled(a)}}updated(e){e.has("disabled")&&this.shadowRoot&&Ei(this.disabled,this.shadowRoot)}render(){return h}};He.styles=[P,is],l([p({type:Object})],He.prototype,"paymentMethod",2),l([E({context:K,subscribe:!0}),p()],He.prototype,"paymentManagers",2),l([p({type:Boolean,attribute:"disabled"})],He.prototype,"disabled",2),He=l([b("primer-google-pay")],He);var br=(i,t)=>{let e=i._$AN;if(e===void 0)return!1;for(let r of e)r._$AO?.(t,!1),br(r,t);return!0},Ai=i=>{let t,e;do{if((t=i._$AM)===void 0)break;e=t._$AN,e.delete(i),i=t}while(e?.size===0)},as=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),Rc(t)}};function Nc(i){this._$AN!==void 0?(Ai(this),this._$AM=i,as(this)):this._$AM=i}function Lc(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++)br(r[a],!1),Ai(r[a]);else r!=null&&(br(r,!1),Ai(r));else br(this,i)}var Rc=i=>{i.type==Z.CHILD&&(i._$AP??(i._$AP=Lc),i._$AQ??(i._$AQ=Nc))},ft=class extends $e{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,r){super._$AT(t,e,r),as(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(br(this,t),Ai(this))}setValue(t){if(Ci(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 Lt=()=>new $o,$o=class{},Do=new WeakMap,gt=Ee(class extends ft{render(i){return h}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)),h}rt(i){if(this.isConnected||(i=void 0),typeof this.G=="function"){let t=this.ht??globalThis,e=Do.get(t);e===void 0&&(e=new WeakMap,Do.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"?Do.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 ns=y` ${zt} `;function xi(i){if(typeof window>"u"||!i.isConnected)return 0;let t=getComputedStyle(i),e=parseFloat(t.height),r=parseFloat(t.minHeight);return e<20&&r>0?r:e}function ss(i){return Math.max(25,Math.min(55,i))}var Fe=class extends v{constructor(){super();this.paymentManagers=new Map;this.disabled=!1;this.buttonContainerRef=Lt();this.loadManagerTask=new D(this,{args:()=>[this.paymentMethod?.type],task:([e])=>{if(!e)return R;let r=this.paymentManagers.get(e);if(!r)throw new Error(`No manager found for payment method type ${e}`);if(r.type!=="APPLE_PAY")throw new Error("Invalid payment method type for Apple Pay component");return r.manager}}),this.renderButtonTask=new D(this,{args:()=>[this.loadManagerTask.value],task:async([e])=>{if(!e)return R;await this.updateComplete;let r=this.buttonContainerRef.value;if(!r)throw new Error("Button container not found");let o=e.createButton(),a=xi(r);return await o.render(r,{style:{buttonHeight:a}}),this.disabled&&await o.setDisabled(this.disabled),this.disabled&&(await this.updateComplete,Kt(this.disabled,this.buttonContainerRef)),o}})}attributeChangedCallback(e,r,o){if(super.attributeChangedCallback(e,r,o),e==="disabled"&&r!==o){let a=o!==null,n=this.renderButtonTask.value;n&&n.setDisabled(a)}}updated(e){e.has("disabled")&&Kt(this.disabled,this.buttonContainerRef)}render(){return m`<div class="native-button-container" ${gt(this.buttonContainerRef)} ></div>`}};Fe.styles=[P,ns],l([p({type:Object})],Fe.prototype,"paymentMethod",2),l([E({context:K,subscribe:!0}),p()],Fe.prototype,"paymentManagers",2),l([p({type:Boolean,attribute:"disabled"})],Fe.prototype,"disabled",2),Fe=l([b("primer-apple-pay")],Fe);var ls=y` ${zt} /* Override base styles to use flexible height for multiple buttons */ :host { height: auto; min-height: calc( ${he(_e)} + calc(2 * var(--primer-space-medium)) ); /* PayPal SDK can show up to 6 buttons vertically (55px each + ~5px gap) */ max-height: 360px; } `;var ze=class extends v{constructor(){super();this.paymentManagers=new Map;this.disabled=!1;this.buttonContainerRef=Lt();this.loadManagerTask=new D(this,{args:()=>[this.paymentMethod?.type],task:([e])=>{if(!e)return R;let r=this.paymentManagers.get(e);if(!r)throw new Error(`No manager found for payment method type ${e}`);if(r.type!=="PAYPAL")throw new Error("Invalid payment method type for PayPal component");return r.manager}}),this.renderButtonTask=new D(this,{args:()=>[this.loadManagerTask.value],task:async([e])=>{if(!e)return R;await this.updateComplete;let r=this.buttonContainerRef.value;if(!r)throw new Error("Button container not found");let o=e.createButton(),a=xi(this),n=ss(a),s=55;return a>s&&A.warn(`PayPal button height (${a}px) exceeds maximum allowed height of ${s}px. Button will be capped at ${s}px. This is a PayPal SDK limitation.`),await o.render(r,{style:{buttonHeight:n}}),this.disabled&&await o.setDisabled(this.disabled),this.disabled&&(await this.updateComplete,Kt(this.disabled,this.buttonContainerRef)),o}})}attributeChangedCallback(e,r,o){if(super.attributeChangedCallback(e,r,o),e==="disabled"&&r!==o){let a=o!==null,n=this.renderButtonTask.value;n&&n.setDisabled(a)}}updated(e){e.has("disabled")&&Kt(this.disabled,this.buttonContainerRef)}render(){return m`<div class="native-button-container" ${gt(this.buttonContainerRef)} ></div>`}};ze.styles=[P,ls],l([p({type:Object})],ze.prototype,"paymentMethod",2),l([E({context:K,subscribe:!0}),p()],ze.prototype,"paymentManagers",2),l([p({type:Boolean,attribute:"disabled"})],ze.prototype,"disabled",2),ze=l([b("primer-paypal")],ze);var ds=y` :host { display: flex; width: 100%; } .blik-container { width: 100%; display: flex; flex-direction: column; transition: all var(--primer-animation-duration) var(--primer-animation-easing); } .blik-container.expanded { border-radius: var(--primer-radius-medium); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); background-color: var(--primer-color-background-outlined-default); border: 1px solid var(--primer-color-border-outlined-default); padding: var(--primer-space-large); } /* Button styles (collapsed state) */ primer-button.blik-button { width: 100%; } /* Override primer-button part styles for BLIK branding */ primer-button.blik-button::part(button) { /* BLIK brand requirement: Black background (#000000) with white logo */ background-color: #000000; border: none; color: var(--primer-color-text-primary); padding: 2px; display: flex; align-items: center; justify-content: center; gap: var(--primer-space-small); /* Fixed height for button - matches redirect payment method calculation */ height: calc( ${he(_e)} + calc(2 * var(--primer-space-medium)) ); flex-shrink: 0; /* Prevent button from shrinking when form appears */ } /* Image container for button logo */ .image-container { display: flex; justify-content: center; align-items: center; min-width: 100px; height: 100%; flex-shrink: 0; flex-grow: 1; } /* Button logo */ img { max-width: 100px; width: 100%; height: auto; object-fit: cover; max-height: 98%; } /* Expanded content (form, loading, error states) */ .blik-expanded-content { width: 100%; display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--primer-animation-duration) var(--primer-animation-easing); overflow: hidden; margin-top: var(--primer-space-medium); } .blik-container.expanded .blik-expanded-content { grid-template-rows: 1fr; } .blik-content-wrapper { overflow: hidden; } /* Input wrapper */ .blik-input-wrapper { display: flex; flex-direction: column; gap: var(--primer-space-small); } /* Input label */ .blik-label { 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); color: var(--primer-color-text-primary); } /* Input field */ .blik-input { width: 100%; padding: var(--primer-space-medium); font-family: var(--primer-typography-body-large-font); font-size: var(--primer-typography-body-large-size); font-weight: var(--primer-typography-body-large-weight); line-height: var(--primer-typography-body-large-line-height); /* Increase spacing between digits for better 6-digit code readability */ letter-spacing: 0.25em; text-align: center; color: var(--primer-color-text-primary); background-color: var(--primer-color-background-outlined-default); border: 1px solid var(--primer-color-border-outlined-default); border-radius: var(--primer-radius-medium); outline: none; transition: border-color var(--primer-animation-duration) var(--primer-animation-easing); } .blik-input::placeholder { color: var(--primer-color-text-secondary); /* Reduce placeholder visibility to emphasize user input */ opacity: 0.5; } .blik-input:focus { border-color: var(--primer-color-border-outlined-focus); } .blik-input: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 */ .blik-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--primer-space-large); padding: var(--primer-space-xlarge) var(--primer-space-medium); } /* Timeout warning */ .blik-timeout-warning { margin-top: var(--primer-space-medium); padding: var(--primer-space-small); font-size: var(--primer-typography-body-small-size); color: var(--primer-color-text-warning); text-align: center; border-radius: var(--primer-radius-small); background-color: var(--primer-color-surface-warning); } /* Error state */ .blik-error { display: flex; flex-direction: column; align-items: center; gap: var(--primer-space-medium); } .blik-error-message { 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); color: var(--primer-color-text-primary); text-align: center; } /* Retry button */ .blik-retry-button { padding: var(--primer-space-medium) var(--primer-space-large); font-family: var(--primer-typography-title-large-font); font-size: var(--primer-typography-title-large-size); font-weight: var(--primer-typography-title-large-weight); line-height: var(--primer-typography-title-large-line-height); color: var(--primer-color-background-outlined-default); background-color: var(--primer-color-brand); border: none; border-radius: var(--primer-radius-medium); cursor: pointer; outline: none; transition: filter var(--primer-animation-duration) var(--primer-animation-easing); } .blik-retry-button:hover:not(:disabled) { filter: brightness(105%); } .blik-retry-button:active:not(:disabled) { filter: brightness(98%); } .blik-retry-button:focus-visible { outline: 2px solid var(--primer-color-brand); outline-offset: 2px; } .blik-retry-button:disabled { background-color: var(--primer-color-background-outlined-disabled); color: var(--primer-color-text-disabled); cursor: not-allowed; } /* Disabled state styling */ :host([disabled]) { opacity: 0.6; cursor: not-allowed; } :host([disabled]) primer-button::part(button) { pointer-events: none; cursor: not-allowed; } :host([disabled]) img { filter: grayscale(100%); } /* Responsive typography for larger screens */ @media (min-width: 768px) { .blik-input { font-size: var(--primer-typography-title-large-size); } } `;var ve=class extends v{constructor(){super(...arguments);this.disabled=!1;this.paymentManagers=new Map;this.currentState="collapsed";this.blikCode="";this.errorMessage="";this.pollingDuration=0;this.pollingTimer=null;this.loadManagerTask=new D(this,{args:()=>[this.paymentMethod?.type],task:([e])=>{if(!e)return R;let r=this.paymentManagers.get(e);if(!r)throw new Error("BLIK payment method manager not initialized");if(r.type!=="ADYEN_BLIK")throw new Error("Invalid payment method type for BLIK component");return r.manager}});this.handleButtonClick=async()=>{if(this.disabled)return;if(this.currentState==="expanded-input"){this.handleCollapse();return}if(this.currentState!=="collapsed")return;let e=this.paymentMethod?.type;if(!e){this.errorMessage=C("something_went_wrong_error",{id:"something_went_wrong_error"}),this.currentState="error",A.error("Payment method type not available");return}let r=this.paymentManagers.get(e);if(!r||r.type!=="ADYEN_BLIK"){this.errorMessage=C("something_went_wrong_error",{id:"something_went_wrong_error"}),this.currentState="error",A.error("Manager not available when expanding BLIK form");return}this.currentState="expanded-input",await this.updateComplete,this.shadowRoot?.querySelector("#blik-code")?.focus()};this.handleCollapse=()=>{this.currentState="collapsed",this.blikCode="",this.errorMessage="",this.stopPollingTimer()};this.handleInput=e=>{let r=e.target,o=r.value,n=o.replace(/\D/g,"").slice(0,6);o!==n&&(r.value=n),this.blikCode=n,this.currentState==="error"&&(this.currentState="expanded-input",this.errorMessage=""),n.length===6&&this.submitBlikCode()};this.handleRetry=async()=>{this.currentState="expanded-input",this.errorMessage="",this.blikCode="",await this.updateComplete,this.shadowRoot?.querySelector("#blik-code")?.focus()}}startPollingTimer(){this.pollingDuration=0,this.pollingTimer=window.setInterval(()=>{this.pollingDuration+=1},1e3)}stopPollingTimer(){this.pollingTimer!==null&&(window.clearInterval(this.pollingTimer),this.pollingTimer=null),this.pollingDuration=0}async submitBlikCode(){if(this.blikCode.length!==6){this.errorMessage=C("sixDigitCodeErrorTooShort",{id:"sixDigitCodeErrorTooShort"}),this.currentState="error";return}let e=this.loadManagerTask.value;if(!e){this.errorMessage="BLIK payment method not initialized",this.currentState="error",A.error("BLIK manager not available via loadManagerTask");return}this.currentState="loading",this.errorMessage="",this.startPollingTimer();try{await e.start({blikCode:this.blikCode}),this.stopPollingTimer(),this.currentState="collapsed",this.blikCode=""}catch(r){this.stopPollingTimer(),this.currentState="error",this.errorMessage=r instanceof Error?r.message:C("tokenizationError",{id:"tokenizationError"}),A.errorWithDatadog("BLIK payment failed",{error:r instanceof Error?{message:r.message,name:r.name}:"Unknown error"})}}renderCollapsed(){return m`<primer-button class="blik-button" @click=${this.handleButtonClick} ?disabled=${this.disabled} aria-label="${C("pay_with",{id:"pay_with"})} BLIK" aria-expanded="${this.currentState!=="collapsed"}" title="BLIK" ><span class="image-container"><img src="https://goat-assets.production.core.primer.io/button/blik/inverted.png" alt="BLIK" /></span></primer-button>`}renderExpandedInput(){return m`<div class="blik-expanded-content"><div class="blik-content-wrapper"><div class="blik-input-wrapper"><label for="blik-code" class="blik-label">${C("getCodeFromBankingApp",{id:"getCodeFromBankingApp"})}</label><input id="blik-code" type="text" inputmode="numeric" pattern="[0-9]*" maxlength="6" class="blik-input" .value="${this.blikCode}" @input="${this.handleInput}" ?disabled="${this.disabled}" placeholder="000000" aria-label="${C("sixDigitCodeLabel",{id:"sixDigitCodeLabel"})}" autocomplete="off" spellcheck="false" /></div></div></div>`}renderLoading(){return m`<div class="blik-expanded-content"><div class="blik-content-wrapper"><div class="blik-loading"><primer-spinner size="medium"></primer-spinner>${this.pollingDuration>30?m`<div class="blik-timeout-warning"> This is taking longer than expected... </div>`:h}</div></div></div>`}renderError(){return m`<div class="blik-expanded-content"><div class="blik-content-wrapper"><div class="blik-error"><div class="blik-error-message" role="alert">${this.errorMessage||C("something_went_wrong_error",{id:"something_went_wrong_error"})}</div><button class="blik-retry-button" @click="${this.handleRetry}" ?disabled="${this.disabled}" >${C("retry_button",{id:"retry_button"})}</button></div></div></div>`}renderExpandedState(){switch(this.currentState){case"expanded-input":return this.renderExpandedInput();case"loading":return this.renderLoading();case"error":return this.renderError();default:return h}}disconnectedCallback(){super.disconnectedCallback(),this.stopPollingTimer()}render(){return m`<div class="blik-container ${this.currentState!=="collapsed"?"expanded":""}" >${this.renderCollapsed()} ${this.currentState!=="collapsed"?this.renderExpandedState():h}</div>`}};ve.styles=[P,ds],l([p({type:Object})],ve.prototype,"paymentMethod",2),l([p({type:Boolean,attribute:"disabled"})],ve.prototype,"disabled",2),l([E({context:K,subscribe:!0})],ve.prototype,"paymentManagers",2),l([_()],ve.prototype,"currentState",2),l([_()],ve.prototype,"blikCode",2),l([_()],ve.prototype,"errorMessage",2),l([_()],ve.prototype,"pollingDuration",2),ve=l([b("primer-blik"),O()],ve);var Le=class extends v{constructor(){super(...arguments);this.type=void 0;this.disabled=!1;this.paymentMethods=null;this.analyticsUtils=null;this.handleClick=()=>{this.paymentMethods?.get(this.type)?.managerType!=="CARD"&&this.sendPaymentMethodSelectionEvent()}}sendPaymentMethodSelectionEvent(){this.type&&q({eventName:"PAYMENT_METHOD_SELECTION",paymentMethod:this.type})}render(){if(!this.type)return h;let e=this.paymentMethods?.get(this.type);if(!e)return h;let r;switch(e?.managerType){case"CARD":r=m`<primer-card-form ?disabled=${this.disabled} ></primer-card-form>`;break;case"NATIVE":{let o=e.type;o===vr.GOOGLE_PAY?r=m`<primer-google-pay .paymentMethod=${e} ?disabled=${this.disabled} ></primer-google-pay>`:o===vr.APPLE_PAY?r=m`<primer-apple-pay .paymentMethod=${e} ?disabled=${this.disabled} ></primer-apple-pay>`:o===vr.PAYPAL?r=m`<primer-paypal .paymentMethod=${e} ?disabled=${this.disabled} ></primer-paypal>`:o===vr.ADYEN_BLIK&&(r=m`<primer-blik .paymentMethod=${e} ?disabled=${this.disabled} ></primer-blik>`);break}case"REDIRECT":r=m`<primer-redirect-payment .paymentMethod=${e} ?disabled=${this.disabled} ></primer-redirect-payment>`;break;case"KLARNA":r=m`<primer-klarna ?disabled=${this.disabled} ></primer-klarna>`;break;case"ACH":r=m`<primer-dynamic-payment .paymentMethod=${e} ></primer-dynamic-payment>`;break;default:return h}return m`<div @click=${this.handleClick}>${r}</div>`}};Le.styles=[rs],l([p({type:String})],Le.prototype,"type",2),l([p({type:Boolean,attribute:"disabled"})],Le.prototype,"disabled",2),l([E({context:lt,subscribe:!0}),p()],Le.prototype,"paymentMethods",2),l([E({context:st,subscribe:!0}),p({attribute:!1})],Le.prototype,"analyticsUtils",2),Le=l([b("primer-payment-method")],Le);var cs=y` :host { display: block; width: 100%; } .payment-methods-container { display: flex; flex-direction: column; gap: var(--primer-space-small); } :host([disabled]) .payment-methods-container { opacity: 0.5; pointer-events: none; } `;var Me=class extends v{constructor(){super(...arguments);this.disabled=!1;this.paymentMethods=null;this.clientOptions=null}getFilteredMethods(){if(!this.paymentMethods)return[];let e=this.paymentMethods.toArray();if(this.include){let r=this.include.split(",").map(o=>o.trim());e=e.filter(o=>r.includes(o.type))}if(this.exclude){let r=this.exclude.split(",").map(o=>o.trim());e=e.filter(o=>!r.includes(o.type))}return e}render(){let e=this.getFilteredMethods();return e.length===0?h:m`<div class="payment-methods-container">${e.map(r=>m`<primer-payment-method type="${r.type}" ?disabled="${this.disabled||this.clientOptions?.disabledPayments===!0}" ></primer-payment-method>`)}</div>`}};Me.styles=[P,cs],l([p({type:String})],Me.prototype,"include",2),l([p({type:String})],Me.prototype,"exclude",2),l([p({type:Boolean,attribute:"disabled"})],Me.prototype,"disabled",2),l([E({context:lt,subscribe:!0}),p()],Me.prototype,"paymentMethods",2),l([E({context:me,subscribe:!0}),p()],Me.prototype,"clientOptions",2),Me=l([b("primer-payment-method-container")],Me);var ps=y` :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 ms(){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 Si=class{constructor(t,e){this.formState=ms();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=ms(),this.host.requestUpdate()}isValidFieldName(t){return!!t&&["firstName","lastName","emailAddress"].includes(t)}hostConnected(){}hostDisconnected(){}};var xe=class extends v{constructor(){super(...arguments);this.formController=new Si(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 D(this,{task:([e])=>e!=="STRIPE_ACH"?R: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>${C("payWithAch",{id:"payWithAch"})}</h2><p>${C("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">${C("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:h}</primer-input-error></primer-input-wrapper><primer-input-wrapper .hasError=${this.formController.hasError.lastName} ><primer-input-label slot="label">${C("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:h}</primer-input-error></primer-input-wrapper></div><primer-input-wrapper .hasError=${this.formController.hasError.emailAddress} ><primer-input-label slot="label">${C("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:h}</primer-input-error></primer-input-wrapper><p>${C("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} >${C("stripe_ach_user_details_collection_continue_button",{id:"stripe_ach_user_details_collection_continue_button"})}</primer-button></form>`}renderMandate(){return m`<h2>${C("payWithAch",{id:"payWithAch"})}</h2><p>${this.clientOptions?.stripe?.mandateData.fullMandateText??C("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} >${C("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} >${C("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():h})}};xe.styles=[P,ps],l([p({type:Object})],xe.prototype,"paymentMethod",2),l([E({context:K,subscribe:!0}),p({attribute:!1})],xe.prototype,"paymentManagers",2),l([E({context:j,subscribe:!0}),p({attribute:!1})],xe.prototype,"sdkState",2),l([E({context:me,subscribe:!0}),p({attribute:!1})],xe.prototype,"clientOptions",2),l([_()],xe.prototype,"screen",2),l([_()],xe.prototype,"isSubmitting",2),xe=l([b("primer-ach-payment"),O()],xe);var us=y` :host { height: calc( ${he(_e)} + calc(2 * var(--primer-space-medium)) ); display: flex; /* Default value for the background color CSS variable */ --dynamic-payment-button-bg-color: var( --primer-color-background-outlined-default ); } primer-button { width: 100%; height: 100%; } primer-button::part(button) { background-color: var(--dynamic-payment-button-bg-color); border: 1px solid var(--primer-color-border-outlined-default); color: var(--primer-color-text-primary); flex: 1; padding: 1px; } .image-container { display: flex; justify-content: center; height: 100%; } /* Target the img specifically inside our component */ img { height: 100%; } `;function Cr(i){return i.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g,(t,e)=>e.toUpperCase())}var ke=class extends v{constructor(){super(...arguments);this.paymentManagers=new Map;this.sdkState=null;this.headlessUtils=null;this.open=!1;this._paymentMethodManagerTask=new D(this,{task:([e,r])=>!e||!r?R:r.get(e)?.manager,args:()=>[this.paymentMethod?.type,this.paymentManagers]});this._getAssetsTask=new D(this,{task:([e,r])=>{if(!e||!r)return R;let o=r.getPaymentMethodConfiguration(e);return o?{backgroundColor:o.displayMetadata.button.backgroundColor.colored,name:o.name,displayName:this._legacyGetButtonLabel(o.displayMetadata.button.text),iconUrl:o.displayMetadata.button.iconUrl.colored||o.displayMetadata.button.iconUrl.light||o.displayMetadata.button.iconUrl.dark}:R},args:()=>[this.paymentMethod?.type,this.headlessUtils]});this._setupTasks=new D(this,{task:([e,r])=>!e||!r?R:{paymentMethodManager:e,assetsConfig:r},args:()=>[this._paymentMethodManagerTask.value,this._getAssetsTask.value]})}_legacyGetButtonLabel(e){if(!e)return;let r=e?Cr(e):"";return r==="payWith"&&(r="pay_with"),C(r,{id:r})}start(){this._paymentMethodManagerTask.value&&(this.open=!0)}renderDialog(){return this.open?m`<primer-portal><primer-dialog @primer-dialog-close="${()=>this.open=!1}"><primer-ach-payment .paymentMethod=${this.paymentMethod} @primer-ach-error=${()=>this.open=!1} @primer-ach-mandate-confirmed=${()=>this.open=!1} @primer-ach-mandate-declined=${()=>this.open=!1} ></primer-ach-payment></primer-dialog></primer-portal>`:h}render(){return this._setupTasks.render({error:()=>h,complete:({assetsConfig:e})=>(this.style.setProperty("--dynamic-payment-button-bg-color",e.backgroundColor),m`<primer-button @click="${()=>this.start()}" class=${re({loading:!!this.sdkState?.isProcessing,reverse:!0})} title="${C("pay_with",{id:"pay_with"})} ${e.name}" ><span class="image-container"><img src="${e.iconUrl}" alt="${e.name}" /></span>${e.displayName}</primer-button>${this.renderDialog()} `)})}};ke.styles=[P,us],l([p({type:Object})],ke.prototype,"paymentMethod",2),l([E({context:K,subscribe:!0})],ke.prototype,"paymentManagers",2),l([E({context:j,subscribe:!0})],ke.prototype,"sdkState",2),l([E({context:F,subscribe:!0})],ke.prototype,"headlessUtils",2),l([_()],ke.prototype,"open",2),ke=l([b("primer-dynamic-payment"),O()],ke);var hs=y` :host { height: calc( ${he(_e)} + calc(2 * var(--primer-space-medium)) ); display: flex; /* Default value for the background color CSS variable */ --redirect-payment-button-bg-color: var( --primer-color-background-outlined-default ); } primer-button { width: 100%; height: 100%; } primer-button::part(button) { background-color: var(--redirect-payment-button-bg-color); border: 1px solid var(--primer-color-border-outlined-default); color: var(--primer-color-text-primary); flex: 1; padding: var(--primer-space-small); display: flex; align-items: center; justify-content: center; gap: var(--primer-space-small); } /* Default layout: icon on the left (START) */ primer-button { display: flex; flex-direction: row; } /* When icon position is END */ primer-button.icon-end { flex-direction: row-reverse; } .image-container { display: flex; justify-content: center; align-items: center; min-width: 100px; height: 100%; } .button-text { font-family: var(--primer-typography-font-family); font-size: var(--primer-typography-title-small-font-size); font-weight: var(--primer-typography-title-small-font-weight); line-height: var(--primer-typography-title-small-line-height); letter-spacing: var(--primer-typography-title-small-letter-spacing); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* Target the img specifically inside our component */ img { max-width: 100px; width: 100%; height: auto; object-fit: cover; max-height: 100%; } /* For image container sizing */ .image-container { flex-shrink: 0; flex-grow: 1; } /* Disabled state styling - subtle visual feedback */ :host([disabled]) { opacity: 0.6; cursor: not-allowed; } :host([disabled]) primer-button::part(button) { pointer-events: none; cursor: not-allowed; } :host([disabled]) img { filter: grayscale(100%); } `;var Ie=class extends v{constructor(){super(...arguments);this.disabled=!1;this.paymentManagers=new Map;this.sdkState=null;this.headlessUtils=null;this._paymentMethodManagerTask=new D(this,{task:([e,r])=>!e||!r?R:r.get(e)?.manager,args:()=>[this.paymentMethod?.type,this.paymentManagers]});this._getAssetsTask=new D(this,{task:([e,r])=>{if(!e||!r)return R;let o=r.getPaymentMethodConfiguration(e);if(!o)return R;let a=o.displayMetadata.button.backgroundColor.colored??o.displayMetadata.button.backgroundColor.light,n=o.displayMetadata.button.iconPositionRelativeToText||"START";return{backgroundColor:a,name:o.name,displayName:this._legacyGetButtonLabel(o.displayMetadata.button.text),iconUrl:o.displayMetadata.button.iconUrl.colored??o.displayMetadata.button.iconUrl.light,iconPosition:n}},args:()=>[this.paymentMethod?.type,this.headlessUtils]});this._setupTasks=new D(this,{task:([e,r])=>!e||!r?R:{paymentMethodManager:e,assetsConfig:r},args:()=>[this._paymentMethodManagerTask.value,this._getAssetsTask.value]})}_legacyGetButtonLabel(e){if(!e)return;let r=e?Cr(e):"";return r==="payWith"&&(r="pay_with"),C(r,{id:r})}startRedirectPayment(){this.disabled||this._paymentMethodManagerTask.value&&this._paymentMethodManagerTask.value.start()}render(){return this._setupTasks.render({error:()=>h,complete:({assetsConfig:e})=>{this.style.setProperty("--redirect-payment-button-bg-color",e.backgroundColor);let r={loading:!!this.sdkState?.isProcessing,"icon-end":e.iconPosition==="END","image-only":!e.displayName},o=e.displayName?m`<span class="image-container"><img src="${e.iconUrl}" alt="${e.name}" /></span><span class="button-text">${e.displayName}</span>`:m`<span class="image-container"><img src="${e.iconUrl}" alt="${e.name}" /></span>`;return m`<primer-button @click="${()=>this.startRedirectPayment()}" class=${re(r)} title="${C("pay_with",{id:"pay_with"})} ${e.name}" ?disabled=${this.disabled} >${o}</primer-button>`}})}};Ie.styles=[P,hs],l([p({type:Object})],Ie.prototype,"paymentMethod",2),l([p({type:Boolean,attribute:"disabled"})],Ie.prototype,"disabled",2),l([E({context:K,subscribe:!0})],Ie.prototype,"paymentManagers",2),l([E({context:j,subscribe:!0})],Ie.prototype,"sdkState",2),l([E({context:F,subscribe:!0})],Ie.prototype,"headlessUtils",2),Ie=l([b("primer-redirect-payment"),O()],Ie);var fs=y` :host { display: block; } :host([hidden]) { display: none; } .billing-address-form { display: flex; flex-direction: column; gap: var(--primer-space-medium); } .billing-address-title { margin-top: var(--primer-space-large); margin-bottom: var(--primer-space-small); font-family: var(--primer-typography-body-medium-font); font-size: var(--primer-typography-body-large-size); font-weight: var(--primer-typography-body-large-weight); line-height: var(--primer-typography-body-large-line-height); color: var(--primer-color-text-primary); } .billing-address-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--primer-space-medium); } @media (max-width: 640px) { .billing-address-row { grid-template-columns: 1fr; } } `;var Vo={locale:"en",countries:{AF:"Afghanistan",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia",BA:"Bosnia and Herzegovina",BW:"Botswana",BV:"Bouvet Island",BR:"Brazil",IO:"British Indian Ocean Territory",BN:"Brunei Darussalam",BG:"Bulgaria",BF:"Burkina Faso",BI:"Burundi",KH:"Cambodia",CM:"Cameroon",CA:"Canada",CV:"Cape Verde",KY:"Cayman Islands",CF:"Central African Republic",TD:"Chad",CL:"Chile",CN:["People's Republic of China","China"],CX:"Christmas Island",CC:"Cocos (Keeling) Islands",CO:"Colombia",KM:"Comoros",CG:["Republic of the Congo","Congo"],CD:["Democratic Republic of the Congo","Congo"],CK:"Cook Islands",CR:"Costa Rica",CI:["Cote d'Ivoire","C\xF4te d'Ivoire","Ivory Coast"],HR:"Croatia",CU:"Cuba",CY:"Cyprus",CZ:["Czech Republic","Czechia"],DK:"Denmark",DJ:"Djibouti",DM:"Dominica",DO:"Dominican Republic",EC:"Ecuador",EG:"Egypt",SV:"El Salvador",GQ:"Equatorial Guinea",ER:"Eritrea",EE:"Estonia",ET:"Ethiopia",FK:"Falkland Islands (Malvinas)",FO:"Faroe Islands",FJ:"Fiji",FI:"Finland",FR:"France",GF:"French Guiana",PF:"French Polynesia",TF:"French Southern Territories",GA:"Gabon",GM:["Republic of The Gambia","The Gambia","Gambia"],GE:"Georgia",DE:"Germany",GH:"Ghana",GI:"Gibraltar",GR:"Greece",GL:"Greenland",GD:"Grenada",GP:"Guadeloupe",GU:"Guam",GT:"Guatemala",GN:"Guinea",GW:"Guinea-Bissau",GY:"Guyana",HT:"Haiti",HM:"Heard Island and McDonald Islands",VA:"Holy See (Vatican City State)",HN:"Honduras",HK:"Hong Kong",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:["Islamic Republic of Iran","Iran"],IQ:"Iraq",IE:"Ireland",IL:"Israel",IT:"Italy",JM:"Jamaica",JP:"Japan",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KI:"Kiribati",KP:"North Korea",KR:["South Korea","Korea, Republic of","Republic of Korea"],KW:"Kuwait",KG:"Kyrgyzstan",LA:"Lao People's Democratic Republic",LV:"Latvia",LB:"Lebanon",LS:"Lesotho",LR:"Liberia",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MO:"Macao",MG:"Madagascar",MW:"Malawi",MY:"Malaysia",MV:"Maldives",ML:"Mali",MT:"Malta",MH:"Marshall Islands",MQ:"Martinique",MR:"Mauritania",MU:"Mauritius",YT:"Mayotte",MX:"Mexico",FM:"Micronesia, Federated States of",MD:"Moldova, Republic of",MC:"Monaco",MN:"Mongolia",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NR:"Nauru",NP:"Nepal",NL:["Netherlands","The Netherlands","Netherlands (Kingdom of the)"],NC:"New Caledonia",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NU:"Niue",NF:"Norfolk Island",MK:["The Republic of North Macedonia","North Macedonia"],MP:"Northern Mariana Islands",NO:"Norway",OM:"Oman",PK:"Pakistan",PW:"Palau",PS:["State of Palestine","Palestine"],PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PN:["Pitcairn","Pitcairn Islands"],PL:"Poland",PT:"Portugal",PR:"Puerto Rico",QA:"Qatar",RE:"Reunion",RO:"Romania",RU:["Russian Federation","Russia"],RW:"Rwanda",SH:"Saint Helena",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SK:"Slovakia",SI:"Slovenia",SB:"Solomon Islands",SO:"Somalia",ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Eswatini",SE:"Sweden",CH:"Switzerland",SY:"Syrian Arab Republic",TW:["Taiwan, Province of China","Taiwan"],TJ:"Tajikistan",TZ:["United Republic of Tanzania","Tanzania"],TH:"Thailand",TL:"Timor-Leste",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:["T\xFCrkiye","Turkey"],TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",UG:"Uganda",UA:"Ukraine",AE:["United Arab Emirates","UAE"],GB:["United Kingdom","UK","Great Britain"],US:["United States of America","United States","USA","U.S.A.","US","U.S."],UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela",VN:"Vietnam",VG:"Virgin Islands, British",VI:"Virgin Islands, U.S.",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe",AX:["\xC5land Islands","Aland Islands"],BQ:"Bonaire, Sint Eustatius and Saba",CW:"Cura\xE7ao",GG:"Guernsey",IM:"Isle of Man",JE:"Jersey",ME:"Montenegro",BL:"Saint Barth\xE9lemy",MF:"Saint Martin (French part)",RS:"Serbia",SX:"Sint Maarten (Dutch part)",SS:"South Sudan",XK:"Kosovo"}};var Uo=i=>i.split("-")[0],Er={en:Vo},Dc=Object.keys(Vo.countries).sort((i,t)=>i.localeCompare(t));function $c(i,t){let e=Uo(t),r=Er[t]?.countries??Er[e]?.countries;if(!r)return"";let o=r[i];return o?Array.isArray(o)?o[1]:o:""}function Vc(){return Dc}function Bo(i){let t=Uo(i);return Vc().map(e=>[e,$c(e,i)]).sort(([,e],[,r])=>e.localeCompare(r,t))}async function gs(i){let t=Uo(i);if(Er[i]||Er[t])return!0;try{let e=await import(`i18n-iso-countries/langs/${t}.json`);return Er[t]=e.default||e,!0}catch{return!1}}var Yo={firstName:"firstName",lastName:"lastName",addressLine1:"addressLine1",addressLine2:"addressLine2",city:"city",postalCode:"postalCode",state:"state",countryCode:"countryCode"},oe=class extends v{constructor(){super(...arguments);this.configuration=null;this.headlessUtils=null;this.formData={};this.errors={};this.touchedFields=new Set;this.dirtyFields=new Set;this.focusedField=null;this.submitted=!1;this.countryOptions=[];this._initializationTask=new D(this,{task:async([e,r])=>{if(!e||!r)return R;let o=this.extractFieldConfig(e);return await this.initializeCountryOptions(),o},args:()=>[this.configuration,this.headlessUtils]})}connectedCallback(){super.connectedCallback(),this._initializationTask.value}extractFieldConfig(e){if(e?.checkoutModules){let r=e.checkoutModules.find(o=>o.type==="BILLING_ADDRESS");if(r?.options){let o=r.options;return Object.keys(Yo).reduce((a,n)=>({...a,[n]:o[n]??!1}),{})}}return this.defaultFieldConfig}async initializeCountryOptions(){try{let e=Bo("en");this.countryOptions=[...e.map(([a,n])=>({value:a,label:n}))],this.requestUpdate("countryOptions");let r=Ji();if(r==="en"||r==="en-GB"||r.startsWith("en-"))return;if(await gs(r)){let a=Bo(r);this.countryOptions=[...a.map(([n,s])=>({value:n,label:s}))],this.requestUpdate("countryOptions")}}catch(e){A.errorWithDatadog("Failed to load country locale",{error:e})}}get fieldConfig(){return this.extractFieldConfig(this.configuration)}get defaultFieldConfig(){return Object.keys(Yo).reduce((e,r)=>({...e,[r]:!1}),{})}get shouldShowForm(){return this.fieldConfig.postalCode}handleInput(e,r){this.formData={...this.formData,[e]:r},this.dirtyFields.add(e),(this.submitted||this.dirtyFields.has(e)&&this.touchedFields.has(e))&&this.validateField(e),this.dispatchEvent(new CustomEvent("primer-billing-address-change",{detail:this.formData,bubbles:!0,composed:!0}))}handleFocus(e){this.focusedField=e}handleBlur(e){this.focusedField=null,this.touchedFields.add(e),this.validateField(e)}validateField(e){let r=this.formData[e],o=this.fieldConfig[e];if(!o){delete this.errors[e];return}if(o&&(!r||r.trim()==="")){let a=`${e}ErrorRequired`;this.errors={...this.errors,[e]:C("This field is required",{id:a})}}else{let a={...this.errors};delete a[e],this.errors=a}}validateForm(){return Object.keys(Yo).forEach(e=>{let r=e;this.fieldConfig[r]&&this.validateField(r)}),Object.keys(this.errors).length===0}async validateForSubmission(){if(!this.shouldShowForm)return!0;this.submitted=!0,Object.keys(this.fieldConfig).forEach(r=>{this.fieldConfig[r]&&this.touchedFields.add(r)});let e=this.validateForm();return this.requestUpdate(),await this.updateComplete,e}async submitToSDK(){if(this.headlessUtils?.setBillingAddress)try{return await this.headlessUtils.setBillingAddress(this.formData),this.dispatchEvent(new CustomEvent("primer-billing-address-submit",{detail:this.formData,bubbles:!0,composed:!0})),!0}catch(e){return A.errorWithDatadog("Failed to set billing address",{error:e}),!1}return!0}shouldShowError(e){let r=!!this.errors[e],o=this.dirtyFields.has(e),a=this.touchedFields.has(e);return r&&(this.submitted||o&&a)}render(){return this._initializationTask.render({pending:()=>h,error:()=>h,complete:()=>this.shouldShowForm?(this.removeAttribute("hidden"),m`<div class="billing-address-form"><div class="billing-address-title">${C("Billing address",{id:"billingAddressLabel"})}</div>${k(this.fieldConfig.countryCode,()=>m`<primer-input-wrapper .focusWithin=${this.focusedField==="countryCode"} .hasError=${this.shouldShowError("countryCode")} ><primer-input-label slot="label">${C("Country code",{id:"countryCodeLabel"})}</primer-input-label><primer-select slot="input" id="countryCode" name="countryCode" .value=${this.formData.countryCode||""} .options=${this.countryOptions} .hasError=${this.shouldShowError("countryCode")} placeholder=${C("Select a country",{id:"countrySelectPlaceholder"})} @input=${e=>this.handleInput("countryCode",e.detail)} @focus=${()=>this.handleFocus("countryCode")} @blur=${()=>this.handleBlur("countryCode")} ></primer-select>${k(this.shouldShowError("countryCode"),()=>m`<primer-input-error slot="error">${this.errors.countryCode}</primer-input-error>`)}</primer-input-wrapper>`)} ${k(this.fieldConfig.firstName||this.fieldConfig.lastName,()=>m`<div class="billing-address-row">${k(this.fieldConfig.firstName,()=>m`<primer-input-wrapper .focusWithin=${this.focusedField==="firstName"} .hasError=${this.shouldShowError("firstName")} ><primer-input-label slot="label">${C("First name",{id:"firstNameLabel"})}</primer-input-label><primer-input slot="input" id="firstName" name="firstName" type="text" .value=${this.formData.firstName||""} placeholder=${C("First name",{id:"firstNamePlaceholder"})} @input=${e=>this.handleInput("firstName",e.detail)} @focus=${()=>this.handleFocus("firstName")} @blur=${()=>this.handleBlur("firstName")} ></primer-input>${k(this.shouldShowError("firstName"),()=>m`<primer-input-error slot="error">${this.errors.firstName}</primer-input-error>`)}</primer-input-wrapper>`)} ${k(this.fieldConfig.lastName,()=>m`<primer-input-wrapper .focusWithin=${this.focusedField==="lastName"} .hasError=${this.shouldShowError("lastName")} ><primer-input-label slot="label">${C("Last name",{id:"lastNameLabel"})}</primer-input-label><primer-input slot="input" id="lastName" name="lastName" type="text" .value=${this.formData.lastName||""} placeholder=${C("Last name",{id:"lastNamePlaceholder"})} @input=${e=>this.handleInput("lastName",e.detail)} @focus=${()=>this.handleFocus("lastName")} @blur=${()=>this.handleBlur("lastName")} ></primer-input>${k(this.shouldShowError("lastName"),()=>m`<primer-input-error slot="error">${this.errors.lastName}</primer-input-error>`)}</primer-input-wrapper>`)}</div>`)} ${k(this.fieldConfig.addressLine1,()=>m`<primer-input-wrapper .focusWithin=${this.focusedField==="addressLine1"} .hasError=${this.shouldShowError("addressLine1")} ><primer-input-label slot="label">${C("Address line 1",{id:"addressLine1"})}</primer-input-label><primer-input slot="input" id="addressLine1" name="addressLine1" type="text" .value=${this.formData.addressLine1||""} placeholder=${C("Address line 1",{id:"addressLine1Placeholder"})} @input=${e=>this.handleInput("addressLine1",e.detail)} @focus=${()=>this.handleFocus("addressLine1")} @blur=${()=>this.handleBlur("addressLine1")} ></primer-input>${k(this.shouldShowError("addressLine1"),()=>m`<primer-input-error slot="error">${this.errors.addressLine1}</primer-input-error>`)}</primer-input-wrapper>`)} ${k(this.fieldConfig.addressLine2,()=>m`<primer-input-wrapper .focusWithin=${this.focusedField==="addressLine2"} .hasError=${this.shouldShowError("addressLine2")} ><primer-input-label slot="label">${C("Address line 2",{id:"addressLine2"})}</primer-input-label><primer-input slot="input" id="addressLine2" name="addressLine2" type="text" .value=${this.formData.addressLine2||""} placeholder=${C("Address line 2",{id:"addressLine2Placeholder"})} @input=${e=>this.handleInput("addressLine2",e.detail)} @focus=${()=>this.handleFocus("addressLine2")} @blur=${()=>this.handleBlur("addressLine2")} ></primer-input>${k(this.shouldShowError("addressLine2"),()=>m`<primer-input-error slot="error">${this.errors.addressLine2}</primer-input-error>`)}</primer-input-wrapper>`)} ${k(this.fieldConfig.postalCode||this.fieldConfig.city,()=>m`<div class="billing-address-row">${k(this.fieldConfig.postalCode,()=>m`<primer-input-wrapper .focusWithin=${this.focusedField==="postalCode"} .hasError=${this.shouldShowError("postalCode")} ><primer-input-label slot="label">${C("Postal code",{id:"postalCodeLabel"})}</primer-input-label><primer-input slot="input" id="postalCode" name="postalCode" type="text" .value=${this.formData.postalCode||""} placeholder=${C("90210",{id:"postalCodePlaceholder"})} @input=${e=>this.handleInput("postalCode",e.detail)} @focus=${()=>this.handleFocus("postalCode")} @blur=${()=>this.handleBlur("postalCode")} ></primer-input>${k(this.shouldShowError("postalCode"),()=>m`<primer-input-error slot="error">${this.errors.postalCode}</primer-input-error>`)}</primer-input-wrapper>`)} ${k(this.fieldConfig.city,()=>m`<primer-input-wrapper .focusWithin=${this.focusedField==="city"} .hasError=${this.shouldShowError("city")} ><primer-input-label slot="label">${C("City",{id:"cityLabel"})}</primer-input-label><primer-input slot="input" id="city" name="city" type="text" .value=${this.formData.city||""} placeholder=${C("Cape Town",{id:"cityPlaceholder"})} @input=${e=>this.handleInput("city",e.detail)} @focus=${()=>this.handleFocus("city")} @blur=${()=>this.handleBlur("city")} ></primer-input>${k(this.shouldShowError("city"),()=>m`<primer-input-error slot="error">${this.errors.city}</primer-input-error>`)}</primer-input-wrapper>`)}</div>`)} ${k(this.fieldConfig.state,()=>m`<primer-input-wrapper .focusWithin=${this.focusedField==="state"} .hasError=${this.shouldShowError("state")} ><primer-input-label slot="label">${C("State / Region / County",{id:"stateLabel"})}</primer-input-label><primer-input slot="input" id="state" name="state" type="text" .value=${this.formData.state||""} placeholder=${C("State / Region / County",{id:"statePlaceholder"})} @input=${e=>this.handleInput("state",e.detail)} @focus=${()=>this.handleFocus("state")} @blur=${()=>this.handleBlur("state")} ></primer-input>${k(this.shouldShowError("state"),()=>m`<primer-input-error slot="error">${this.errors.state}</primer-input-error>`)}</primer-input-wrapper>`)}</div>`):(this.setAttribute("hidden",""),h)})}};oe.styles=[P,fs],l([E({context:Pr,subscribe:!0}),p({attribute:!1})],oe.prototype,"configuration",2),l([E({context:F,subscribe:!0}),p({attribute:!1})],oe.prototype,"headlessUtils",2),l([_()],oe.prototype,"formData",2),l([_()],oe.prototype,"errors",2),l([_()],oe.prototype,"touchedFields",2),l([_()],oe.prototype,"dirtyFields",2),l([_()],oe.prototype,"focusedField",2),l([_()],oe.prototype,"submitted",2),l([_()],oe.prototype,"countryOptions",2),oe=l([b("primer-billing-address"),O()],oe);function ys(i){return i.paymentInstrumentType===Nt.CARD}async function Pi(i,t,e){if(!i||!t||!e)return{icon:"",shouldShowCVV:!1,type:"other",description:""};let r="";if(ys(i))r=t.getCardNetworkAsset(i.paymentInstrumentData.network).cardUrl;else{let n=await t.getCDNAssets(i.paymentMethodType);n&&n.assets?.icon&&(r=n.assets.icon)}let o=e.cvvRecapture,a=Ho(i);return{icon:r,shouldShowCVV:o,...a}}function vs(i){return i.charAt(0).toUpperCase()+i.slice(1).toLowerCase()}function Uc(i){return i?i===i.toUpperCase()?vs(i):i:""}function bs(i,t){return[i,t].filter(Boolean).join(" ")}function Bc(i,t){return!i||!t?"":`Expires ${i}/${t.slice(-2)}`}function Cs(i){return i?`\u2022\u2022\u2022\u2022 ${i}`:""}function Yc(i){let t=i.paymentInstrumentData,e=t.cardholderName,r=t.last4Digits,o=Bc(t.expirationMonth,t.expirationYear),a=Uc(t.network),n=`${i.paymentInstrumentData.cardholderName?i.paymentInstrumentData.cardholderName:""}${(r?` ${a} ${Cs(r)}`:a)||" Card"}`;return{type:"card",cardholderName:e,last4:r,expiresDate:o,network:a,description:n}}function Hc(i){let t=i.paymentInstrumentData,e=t.externalPayerInfo?.email||"",r=t.externalPayerInfo?.firstName||"",o=t.externalPayerInfo?.lastName||"",a=i.userDescription||e||"PayPal Account";return{type:"paypal",fullName:bs(r,o),email:e,paymentMethodType:"PayPal",description:a}}function Fc(i){let t=i.paymentInstrumentData,e=t.sessionData?.billingAddress?.email||"",r=t.sessionData?.billingAddress?.firstName||"",o=t.sessionData?.billingAddress?.lastName||"",a=i.userDescription||(e?`Klarna - ${e}`:"Klarna Account");return{type:"other",fullName:bs(r,o),email:e,paymentMethodType:"Klarna",description:a}}function zc(i){let t=i.paymentInstrumentData,e=t.accountNumberLastFourDigits||"",r=t.bankName||"",o=t.accountType||"",a=i.userDescription;return a||(r&&e?a=`${r} ${Cs(e)}`:r?a=r:a="Bank Account"),{type:"other",fullName:"",bankName:r,last4:e,accountType:o,paymentMethodType:"ACH",description:a}}function Kc(i){let t=i.paymentInstrumentType,e=vs(t.replace(/_/g," "));return{type:"other",description:i.userDescription||e}}var jc={[Nt.CARD]:Yc,[Nt.PAYPAL_VAULTED]:Hc,[Nt.KLARNA_CUSTOMER_TOKEN]:Fc,[Nt.AUTOMATED_CLEARING_HOUSE]:zc};function Ho(i){try{let t=jc[i.paymentInstrumentType];return t?t(i):Kc(i)}catch(t){return A.errorWithDatadog(`FormatUtils: Error formatting payment method ${i.id}`,{error:t}),{type:"other",description:i.userDescription||i.id||"Payment Method"}}}var Es=y` :host { display: block; width: 100%; position: relative; } .vault-manager { display: flex; flex-direction: column; position: relative; } .vault-manager-content { display: flex; flex-direction: column; width: 100%; position: relative; } /* Content container using CSS Grid for height animation */ .content-container { display: grid; grid-template-rows: 1fr; transition: grid-template-rows var(--primer-animation-duration) var(--primer-animation-easing); width: 100%; position: relative; } /* Required to make grid animation work - ensures content can expand/collapse properly */ .content-container > * { min-height: 0; overflow: hidden; } /* Submit button container */ .submit-button-container { display: grid; grid-template-rows: 1fr; transition: grid-template-rows var(--primer-animation-duration) var(--primer-animation-easing); overflow: hidden; margin-top: var(--primer-space-small); width: 100%; } /* Ensure the submit button has full width */ .submit-button { width: 100%; } /* Make sure pay button inside the submit component is full width */ primer-vault-payment-submit::part(button), ::slotted(primer-button) { width: 100%; } /* Payment methods list */ .payment-methods-list { display: flex; flex-direction: column; gap: var(--primer-space-small); width: 100%; position: relative; } /* Delete confirmation container */ .delete-confirmation-container { width: 100%; position: relative; display: flex; flex-direction: column; gap: var(--primer-space-small); } /* Loading overlay styles */ .loading-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background-color: rgba(255, 255, 255, 0.7); z-index: 10; border-radius: var(--primer-radius-medium); backdrop-filter: blur(2px); opacity: 0; /* Start invisible */ } /* Add styles for when updating is active */ .is-updating { pointer-events: none; /* Prevent interaction when updating */ } /* * Component-specific styles to ensure smooth animations * These components need display:block to work with the grid layout */ primer-vault-payment-method-item, primer-vault-empty-state, primer-vault-delete-confirmation { display: block; width: 100%; } /* Disable animations for reduced motion preference */ @media (prefers-reduced-motion: reduce) { .content-container, .submit-button-container, primer-vault-payment-method-item, primer-vault-payment-submit, primer-vault-empty-state, primer-vault-delete-confirmation { transition: none; } } primer-button::part(button) { align-items: center; width: 100%; justify-content: flex-start; display: flex; text-align: left; padding: var(--primer-space-medium); } `;var _i=new WeakMap,jt=class{constructor(t,e){this.startPaused=!1,this.disabled=!1,this.clients=new Set,this.pendingComplete=!1,this.host=t,this.defaultOptions=e.defaultOptions||{},this.startPaused=!!e.startPaused,this.disabled=!!e.disabled,this.onComplete=e.onComplete,_i.set(this.host,this)}async add(t){this.clients.add(t),this.startPaused&&t.webAnimation?.pause(),this.pendingComplete=!0,await t.finished,this.pendingComplete&&!this.isAnimating&&(this.pendingComplete=!1,this.onComplete?.())}remove(t){this.clients.delete(t)}pause(){this.clients.forEach((t=>t.webAnimation?.pause()))}play(){this.clients.forEach((t=>t.webAnimation?.play()))}cancel(){this.clients.forEach((t=>t.webAnimation?.cancel())),this.clients.clear()}finish(){this.clients.forEach((t=>t.webAnimation?.finish())),this.clients.clear()}togglePlay(){this.isPlaying?this.pause():this.play()}get isAnimating(){return this.clients.size>0}get isPlaying(){return Array.from(this.clients).some((t=>t.webAnimation?.playState==="running"))}async finished(){await Promise.all(Array.from(this.clients).map((t=>t.finished)))}};var As=0,Fo=new Map,xs=new WeakSet,zo=()=>new Promise((i=>requestAnimationFrame(i)));var Ss=(i,t)=>{let e=i-t;return e===0?void 0:e},Ps=(i,t)=>{let e=i/t;return e===1?void 0:e},wi={left:(i,t)=>{let e=Ss(i,t);return{value:e,transform:e==null||isNaN(e)?void 0:`translateX(${e}px)`}},top:(i,t)=>{let e=Ss(i,t);return{value:e,transform:e==null||isNaN(e)?void 0:`translateY(${e}px)`}},width:(i,t)=>{let e;t===0&&(t=1,e={width:"1px"});let r=Ps(i,t);return{value:r,overrideFrom:e,transform:r==null||isNaN(r)?void 0:`scaleX(${r})`}},height:(i,t)=>{let e;t===0&&(t=1,e={height:"1px"});let r=Ps(i,t);return{value:r,overrideFrom:e,transform:r==null||isNaN(r)?void 0:`scaleY(${r})`}}},ws={duration:333,easing:"ease-in-out"},Ts=["left","top","width","height","opacity","color","background"],_s=new WeakMap,Ti=class extends ft{constructor(t){if(super(t),this.t=!1,this.i=null,this.o=null,this.h=!0,this.shouldLog=!1,t.type===Z.CHILD)throw Error("The `animate` directive must be used in attribute position.");this.createFinished()}createFinished(){this.resolveFinished?.(),this.finished=new Promise((t=>{this.l=t}))}async resolveFinished(){this.l?.(),this.l=void 0}render(t){return h}getController(){return _i.get(this.u)}isDisabled(){return this.options.disabled||this.getController()?.disabled}update(t,[e]){let r=this.u===void 0;return r&&(this.u=t.options?.host,this.u.addController(this),this.u.updateComplete.then((o=>this.t=!0)),this.element=t.element,_s.set(this.element,this)),this.optionsOrCallback=e,(r||typeof e!="function")&&this.p(e),this.render(e)}p(t){t=t??{};let e=this.getController();e!==void 0&&((t={...e.defaultOptions,...t}).keyframeOptions={...e.defaultOptions.keyframeOptions,...t.keyframeOptions}),t.properties??(t.properties=Ts),this.options=t}m(){let t={},e=this.element.getBoundingClientRect(),r=getComputedStyle(this.element);return this.options.properties.forEach((o=>{let a=e[o]??(wi[o]?void 0:r[o]),n=Number(a);t[o]=isNaN(n)?a+"":n})),t}v(){let t,e=!0;return this.options.guard&&(t=this.options.guard(),e=((r,o)=>{if(Array.isArray(r)){if(Array.isArray(o)&&o.length===r.length&&r.every(((a,n)=>a===o[n])))return!1}else if(o===r)return!1;return!0})(t,this._)),this.h=this.t&&!this.isDisabled()&&!this.isAnimating()&&e&&this.element.isConnected,this.h&&(this._=Array.isArray(t)?Array.from(t):t),this.h}hostUpdate(){typeof this.optionsOrCallback=="function"&&this.p(this.optionsOrCallback()),this.v()&&(this.A=this.m(),this.i=this.i??this.element.parentNode,this.o=this.element.nextSibling)}async hostUpdated(){if(!this.h||!this.element.isConnected||this.options.skipInitial&&!this.isHostRendered)return;let t;this.prepare(),await zo;let e=this.O(),r=this.j(this.options.keyframeOptions,e),o=this.m();if(this.A!==void 0){let{from:a,to:n}=this.N(this.A,o,e);this.log("measured",[this.A,o,a,n]),t=this.calculateKeyframes(a,n)}else{let a=Fo.get(this.options.inId);if(a){Fo.delete(this.options.inId);let{from:n,to:s}=this.N(a,o,e);t=this.calculateKeyframes(n,s),t=this.options.in?[{...this.options.in[0],...t[0]},...this.options.in.slice(1),t[1]]:t,As++,t.forEach((d=>d.zIndex=As))}else this.options.in&&(t=[...this.options.in,{}])}this.animate(t,r)}resetStyles(){this.P!==void 0&&(this.element.setAttribute("style",this.P??""),this.P=void 0)}commitStyles(){this.P=this.element.getAttribute("style"),this.webAnimation?.commitStyles(),this.webAnimation?.cancel()}reconnected(){}async disconnected(){if(!this.h||(this.options.id!==void 0&&Fo.set(this.options.id,this.A),this.options.out===void 0))return;if(this.prepare(),await zo(),this.i?.isConnected){let e=this.o&&this.o.parentNode===this.i?this.o:null;if(this.i.insertBefore(this.element,e),this.options.stabilizeOut){let r=this.m();this.log("stabilizing out");let o=this.A.left-r.left,a=this.A.top-r.top;getComputedStyle(this.element).position!=="static"||o===0&&a===0||(this.element.style.position="relative"),o!==0&&(this.element.style.left=o+"px"),a!==0&&(this.element.style.top=a+"px")}}let t=this.j(this.options.keyframeOptions);await this.animate(this.options.out,t),this.element.remove()}prepare(){this.createFinished()}start(){this.options.onStart?.(this)}didFinish(t){t&&this.options.onComplete?.(this),this.A=void 0,this.animatingProperties=void 0,this.frames=void 0,this.resolveFinished()}O(){let t=[];for(let e=this.element.parentNode;e;e=e?.parentNode){let r=_s.get(e);r&&!r.isDisabled()&&r&&t.push(r)}return t}get isHostRendered(){let t=xs.has(this.u);return t||this.u.updateComplete.then((()=>{xs.add(this.u)})),t}j(t,e=this.O()){let r={...ws};return e.forEach((o=>Object.assign(r,o.options.keyframeOptions))),Object.assign(r,t),r}N(t,e,r){t={...t},e={...e};let o=r.map((s=>s.animatingProperties)).filter((s=>s!==void 0)),a=1,n=1;return o.length>0&&(o.forEach((s=>{s.width&&(a/=s.width),s.height&&(n/=s.height)})),t.left!==void 0&&e.left!==void 0&&(t.left=a*t.left,e.left=a*e.left),t.top!==void 0&&e.top!==void 0&&(t.top=n*t.top,e.top=n*e.top)),{from:t,to:e}}calculateKeyframes(t,e,r=!1){let o={},a={},n=!1,s={};for(let d in e){let c=t[d],u=e[d];if(d in wi){let g=wi[d];if(c===void 0||u===void 0)continue;let f=g(c,u);f.transform!==void 0&&(s[d]=f.value,n=!0,o.transform=`${o.transform??""} ${f.transform}`,f.overrideFrom!==void 0&&Object.assign(o,f.overrideFrom))}else c!==u&&c!==void 0&&u!==void 0&&(n=!0,o[d]=c,a[d]=u)}return o.transformOrigin=a.transformOrigin=r?"center center":"top left",this.animatingProperties=s,n?[o,a]:void 0}async animate(t,e=this.options.keyframeOptions){this.start(),this.frames=t;let r=!1;if(!this.isAnimating()&&!this.isDisabled()&&(this.options.onFrames&&(this.frames=t=this.options.onFrames(this),this.log("modified frames",t)),t!==void 0)){this.log("animate",[t,e]),r=!0,this.webAnimation=this.element.animate(t,e);let o=this.getController();o?.add(this);try{await this.webAnimation.finished}catch{}o?.remove(this)}return this.didFinish(r),r}isAnimating(){return this.webAnimation?.playState==="running"||this.webAnimation?.pending}log(t,e){this.shouldLog&&this.isDisabled()}},yt=Ee(Ti);var Gc=["top","right","bottom","left"],Mi=class extends ft{constructor(t){if(super(t),t.type!==Z.ELEMENT)throw Error("The `position` directive must be used in attribute position.")}render(t,e){return h}update(t,[e,r]){return this.u===void 0&&(this.u=t.options?.host,this.u.addController(this)),this.S=t.element,this.C=e,this.F=r??["left","top","width","height"],this.render(e,r)}hostUpdated(){this.$()}$(){let t=typeof this.C=="function"?this.C():this.C?.value,e=t.offsetParent;if(t===void 0||!e)return;let r=t.getBoundingClientRect(),o=e.getBoundingClientRect();this.F?.forEach((a=>{let n=Gc.includes(a)?r[a]-o[a]:r[a];this.S.style[a]=n+"px"}))}},Wc=Ee(Mi);var ae=class extends v{constructor(){super();this.vaultManagerContext=null;this.vaultItemContext=null;this.headlessUtils=null;this.isEditMode=!1;this.deletePaymentMethodId=null;this.isDeleting=!1;this.errorMessage="";this.animationDuration=300;this.deleteAssetConfig=null;this.handleToggleEditMode=e=>{this.isEditMode=e.detail,this.deletePaymentMethodId=null,this.isEditMode&&this.vaultItemContext&&this.vaultItemContext.setSelectedVaultedPaymentMethod(null)};this.handleDeletePaymentMethod=async e=>{if(this.deletePaymentMethodId=e.detail,this.deletePaymentMethodId&&this.vaultManagerContext&&this.headlessUtils){let r=this.vaultManagerContext.vaultedPaymentMethods.find(o=>o.id===this.deletePaymentMethodId);r&&(this.deleteAssetConfig=await Pi(r,this.headlessUtils,this.vaultManagerContext))}};this.handleCancelDelete=()=>{this.deletePaymentMethodId=null,this.deleteAssetConfig=null};this.handleConfirmDelete=async()=>{if(!this.vaultManagerContext?.deleteVaultedPaymentMethod||!this.deletePaymentMethodId){this.errorMessage=C("something_went_wrong_error",{id:"something_went_wrong_error"});return}try{this.isDeleting=!0,await this.vaultManagerContext.deleteVaultedPaymentMethod(this.deletePaymentMethodId),this.deletePaymentMethodId=null,this.deleteAssetConfig=null}catch(e){this.errorMessage=e instanceof Error?e.message:C("something_went_wrong_error",{id:"something_went_wrong_error"})}finally{this.isDeleting=!1}};this.handlePaymentError=e=>{let r=e.detail?.error;this.errorMessage=r instanceof Error?r.message:C("payment_processing_error",{id:"payment_processing_error"})};this.handleCloseError=()=>{this.errorMessage=""};new jt(this,{defaultOptions:{keyframeOptions:{duration:Number(getComputedStyle(document.documentElement).getPropertyValue("--primer-animation-duration").trim().replace("ms","")),easing:getComputedStyle(document.documentElement).getPropertyValue("--primer-animation-easing").trim()}}})}getAnimationConfig(){return{keyframeOptions:{duration:this.animationDuration,easing:getComputedStyle(document.documentElement).getPropertyValue("--primer-animation-easing").trim(),fill:"both"}}}getPaymentMethodName(e){if(!this.vaultManagerContext)return"";let r=this.vaultManagerContext.vaultedPaymentMethods.find(o=>o.id===e);if(!r)return"";try{return Ho(r).description||""}catch{return""}}renderLoadingOverlay(){return m`<div class="loading-overlay" ${yt({...this.getAnimationConfig(),properties:["opacity"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ><primer-spinner size="medium" color="var(--primer-color-loader)" ></primer-spinner></div>`}renderDeleteConfirmation(){if(!this.deletePaymentMethodId||!this.deleteAssetConfig)return h;let e=this.getPaymentMethodName(this.deletePaymentMethodId);return m`<div class="delete-confirmation-container"><primer-button disabled variant="secondary"><primer-payment-method-content .assetConfig=${this.deleteAssetConfig} ></primer-payment-method-content></primer-button><primer-vault-delete-confirmation .isDeleting=${this.isDeleting} .paymentMethodId=${this.deletePaymentMethodId} .paymentMethodName=${e} @confirm-delete=${this.handleConfirmDelete} @cancel-delete=${this.handleCancelDelete} ${yt({...this.getAnimationConfig(),properties:["opacity"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ></primer-vault-delete-confirmation></div>`}renderPaymentMethodItem(e){return this.deletePaymentMethodId===e.id?h:m`<primer-vault-payment-method-item .paymentMethod=${e} .isEditMode=${this.isEditMode} @delete-payment-method=${this.handleDeletePaymentMethod} ${yt({...this.getAnimationConfig(),properties:["opacity"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ></primer-vault-payment-method-item>`}renderPaymentMethodList(){let e=this.vaultManagerContext?.vaultedPaymentMethods||[],r=!this.isEditMode&&e.length>0&&!this.deletePaymentMethodId;return m`<div class="payment-methods-list">${e.map(o=>this.renderPaymentMethodItem(o))} ${k(r,()=>m`<div class="submit-button-container"><primer-vault-payment-submit class="submit-button" @primer-vault-payment-error=${this.handlePaymentError} ${yt({...this.getAnimationConfig(),properties:["opacity"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ></primer-vault-payment-submit></div>`,()=>h)}</div>`}render(){if(!this.vaultManagerContext?.enabled)return h;let e=this.vaultManagerContext.vaultedPaymentMethods.length>0,r=this.vaultManagerContext.isLoading,o=this.vaultManagerContext.isUpdating;return m` ${k(!this.vaultManagerContext?.showEmptyState&&!e,()=>h,()=>m`<slot name="vault-empty-state"><div class="vault-manager ${o?"is-updating":""}"><primer-vault-manager-header .isEditMode=${this.isEditMode} .hasPaymentMethods=${e} @toggle-edit-mode=${this.handleToggleEditMode} ></primer-vault-manager-header>${k(this.errorMessage,()=>m`<primer-vault-error-message .errorMessage=${this.errorMessage} @close-error=${this.handleCloseError} ${yt({...this.getAnimationConfig(),properties:["opacity"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ></primer-vault-error-message>`,()=>h)}<div class="vault-manager-content">${k(!r&&!e,()=>m`<div class="content-container"><primer-vault-empty-state ${yt({...this.getAnimationConfig(),properties:["opacity"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ></primer-vault-empty-state></div>`,()=>h)} ${k(!r&&e,()=>m`<div class="content-container">${k(this.deletePaymentMethodId,()=>this.renderDeleteConfirmation(),()=>this.renderPaymentMethodList())}</div>`,()=>h)}</div>${k(o,()=>this.renderLoadingOverlay(),()=>h)}</div></slot>`)} `}};ae.styles=[P,Es],l([E({context:ue,subscribe:!0}),p({type:Object,attribute:!1})],ae.prototype,"vaultManagerContext",2),l([E({context:Oe,subscribe:!0}),p({type:Object,attribute:!1})],ae.prototype,"vaultItemContext",2),l([E({context:F,subscribe:!0}),p({type:Object,attribute:!1})],ae.prototype,"headlessUtils",2),l([_()],ae.prototype,"isEditMode",2),l([_()],ae.prototype,"deletePaymentMethodId",2),l([_()],ae.prototype,"isDeleting",2),l([_()],ae.prototype,"errorMessage",2),l([p({type:Number})],ae.prototype,"animationDuration",2),l([_()],ae.prototype,"deleteAssetConfig",2),ae=l([b("primer-vault-manager"),O()],ae);var Ms=y` :host { display: flex; width: 100%; flex-direction: column; } .payment-method-wrapper { display: flex; flex-direction: column; width: 100%; } .payment-method-container { display: flex; width: 100%; align-items: center; gap: var(--primer-space-small); } /* Target the button part from primer-button with 'with-cvv' class using ::part selector */ primer-button::part(button) { align-items: center; width: 100%; justify-content: flex-start; display: flex; text-align: left; padding: var(--primer-space-medium); } /* render checkmark icon on baseline (on the top) */ primer-button.with-cvv::part(button) { align-items: baseline; } /* Card icons */ .payment-method-icon { height: var(--primer-space-xlarge); object-fit: contain; flex-shrink: 0; transition: transform var(--primer-animation-duration) var(--primer-animation-easing); } .payment-method-icon-generic { display: flex; align-items: center; justify-content: center; color: var(--primer-color-gray-500); height: var(--primer-space-xlarge); flex-shrink: 0; } .payment-method-details { flex: 1; display: flex; gap: var(--primer-space-xsmall); align-items: flex-start; transition: transform var(--primer-animation-duration) var(--primer-animation-easing); margin-left: var(--primer-space-small); } .payment-method-card { flex: 1; width: 100%; display: flex; flex-direction: column; gap: var(--primer-space-xsmall); transition: transform var(--primer-animation-duration) var(--primer-animation-easing); } .payment-method-description { font-weight: var(--primer-typography-title-large-weight); color: var(--primer-color-text-primary); transition: color var(--primer-animation-duration) var(--primer-animation-easing); } .payment-method-secondary-description { font-size: var(--primer-typography-body-small-size); color: var(--primer-color-text-secondary); transition: color var(--primer-animation-duration) var(--primer-animation-easing); } .payment-method-row { display: grid; grid-template-columns: 200px 100px; justify-content: space-between; align-items: center; } .cell-2 { grid-column: 2; display: flex; justify-content: flex-end; align-items: center; } .mt-2 { margin-top: var(--primer-space-medium); } .payment-method-header { font-weight: var(--primer-typography-body-large-weight); font-size: var(--primer-typography-body-large-size); line-height: var(--primer-typography-body-large-line-height); color: var(--primer-color-text-primary); letter-spacing: var(--primer-typography-body-large-letter-spacing); } .payment-method-subtitle { color: var(--primer-color-text-secondary); font-size: var(--primer-typography-body-small-size); line-height: var(--primer-typography-body-small-line-height); font-weight: var(--primer-typography-body-small-weight); letter-spacing: var(--primer-typography-body-small-letter-spacing); } .payment-method-button { flex: 1; } .flex { display: flex; align-items: flex-end; gap: var(--primer-space-xsmall); } .flex-center { display: flex; align-items: center; justify-content: center; gap: var(--primer-space-small); } /* Delete button - for edit mode */ .delete-button { display: flex; align-items: center; justify-content: center; } .delete-button:active { transform: scale(0.95); } `;var be=class extends v{constructor(){super(...arguments);this.vaultManagerContext=null;this.vaultItemContext=null;this.headlessUtils=null;this.paymentMethod=null;this.isEditMode=!1;this._getAssetsTask=new D(this,{task:async([e,r,o])=>await Pi(e,r,o),args:()=>[this.paymentMethod,this.headlessUtils,this.vaultManagerContext]});this.handleClick=()=>{this.isEditMode||!this.vaultManagerContext||!this.paymentMethod||(this.isSelected()?this.vaultItemContext?.setSelectedVaultedPaymentMethod(null):this.vaultItemContext?.setSelectedVaultedPaymentMethod(this.paymentMethod))};this.handleDeleteClick=e=>{e.stopPropagation(),this.dispatchEvent(new CustomEvent("delete-payment-method",{detail:this.paymentMethod?.id,bubbles:!0,composed:!0}))}}isSelected(){if(!this.vaultManagerContext||!this.paymentMethod)return!1;let e=this.vaultItemContext?.selectedVaultedPaymentMethod;return!!e&&e.id===this.paymentMethod.id}render(){return this._getAssetsTask.render({error:()=>h,complete:e=>{let r=this.isSelected()?"checked":"default",o=!1,a=e?.description;return m`<div class="payment-method-wrapper"><div class="payment-method-container"><primer-button variant="secondary" class="payment-method-button ${e.shouldShowCVV?"with-cvv":""}" selectable ?disabled=${this.isEditMode} selectionState=${r} .flex=${o} @click=${this.handleClick} ><primer-payment-method-content .assetConfig=${e} ></primer-payment-method-content>${k(e.shouldShowCVV&&this.isSelected()&&!this.isEditMode,()=>m`<div class="payment-method-row mt-2"><span class="flex-center"><primer-icon name="lock" size="sm"></primer-icon><span class="payment-method-subtitle"> Input the card CVV for a secure payment</span ></span><span class="cell-2"><primer-vault-cvv-input .paymentMethod="${this.paymentMethod}" ><span slot="label"></span></primer-vault-cvv-input></span></div>`,()=>h)}</primer-button>${this.isEditMode?m`<primer-button variant="tertiary" class="delete-button" @click=${this.handleDeleteClick} aria-label=${`${C("delete",{id:"delete"})} ${a}`} ><primer-icon name="close" size="sm"></primer-icon></primer-button>`:h}</div></div>`}})}};be.styles=[P,Ms],l([E({context:ue,subscribe:!0}),p({type:Object,attribute:!1,hasChanged(e,r){return e?.cvvRecapture!==r?.cvvRecapture}})],be.prototype,"vaultManagerContext",2),l([E({context:Oe,subscribe:!0}),p({type:Object,attribute:!1,hasChanged(e,r){return e?.selectedVaultedPaymentMethod?.id!==r?.selectedVaultedPaymentMethod?.id}})],be.prototype,"vaultItemContext",2),l([E({context:F,subscribe:!0}),p({type:Object})],be.prototype,"headlessUtils",2),l([p({type:Object,attribute:!1})],be.prototype,"paymentMethod",2),l([p({type:Boolean,reflect:!0})],be.prototype,"isEditMode",2),be=l([b("primer-vault-payment-method-item"),O()],be);var ks=y` :host { display: block; width: 100%; } .vault-manager-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--primer-space-medium); } .vault-manager-header h3 { font-size: var(--primer-typography-title-large-size); font-weight: var(--primer-typography-title-large-weight); font-family: var(--primer-typography-title-large-font); color: var(--primer-color-text-primary); margin: 0; } .edit-button { display: flex; align-items: center; justify-content: center; } `;var Re=class extends v{constructor(){super(...arguments);this.isEditMode=!1;this.hasPaymentMethods=!1;this.toggleEditMode=()=>{this.dispatchEvent(new CustomEvent("toggle-edit-mode",{detail:!this.isEditMode,bubbles:!0,composed:!0}))}}render(){return m`<div class="vault-manager-header"><h3>${C("previouslyUsed",{id:"previouslyUsed"})}</h3>${this.hasPaymentMethods?m`<primer-button variant="tertiary" class="edit-button ${this.isEditMode?"active":""}" @click=${this.toggleEditMode} aria-label=${this.isEditMode?C("confirm",{id:"confirm"}):C("editPaymentMethods",{id:"editPaymentMethods"})} >${this.isEditMode?m`<primer-icon name="checkmark" size="sm"></primer-icon>`:m`<primer-icon name="edit" size="sm"></primer-icon>`}</primer-button>`:h}</div>`}};Re.styles=[P,ks],l([p({type:Boolean})],Re.prototype,"isEditMode",2),l([p({type:Boolean})],Re.prototype,"hasPaymentMethods",2),Re=l([b("primer-vault-manager-header"),O()],Re);var Is=y` :host { display: block; width: 100%; } .delete-confirmation-text { color: var(--primer-color-text-secondary); font-size: var(--primer-typography-body-small-size); font-weight: var(--primer-typography-body-small-weight); line-height: var(--primer-typography-body-small-line-height); letter-spacing: var(--primer-typography-body-small-letter-spacing); } .delete-confirmation { margin-top: var(--primer-space-medium); background-color: var(--primer-color-gray-000); } .delete-message { margin-bottom: var(--primer-space-medium); } .delete-text { margin: 0; color: var(--primer-color-text-secondary); font-size: var(--primer-typography-body-medium-size); } .delete-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--primer-space-small); } .delete-confirm { background-color: var(--primer-color-red-500); color: var(--primer-color-gray-000); border: none; padding: var(--primer-space-small) var(--primer-space-medium); border-radius: var(--primer-radius-small); font-weight: var(--primer-typography-body-medium-weight); cursor: pointer; transition: background-color var(--primer-animation-duration) var(--primer-animation-easing); } .delete-confirm:hover:not(:disabled) { background-color: var(--primer-color-red-900); } .delete-confirm:disabled { opacity: 0.7; cursor: not-allowed; } .delete-cancel { background-color: transparent; border: 1px solid var(--primer-color-border-outlined-default); padding: var(--primer-space-small) var(--primer-space-medium); border-radius: var(--primer-radius-small); color: var(--primer-color-text-primary); font-weight: var(--primer-typography-body-medium-weight); cursor: pointer; transition: background-color var(--primer-animation-duration) var(--primer-animation-easing); } .delete-cancel:hover:not(:disabled) { background-color: var(--primer-color-gray-100); } .delete-cancel:disabled { opacity: 0.7; cursor: not-allowed; } `;var Se=class extends v{constructor(){super(...arguments);this.isDeleting=!1;this.paymentMethodId="";this.paymentMethodName="";this.vaultManager=null;this.handleConfirmClick=()=>{this.dispatchEvent(new CustomEvent("confirm-delete",{bubbles:!0,composed:!0}))};this.handleCancelClick=()=>{this.dispatchEvent(new CustomEvent("cancel-delete",{bubbles:!0,composed:!0}))}}render(){return m`<div class="delete-confirmation"><p class="delete-confirmation-text"> Are you sure you want to delete this payment method? </p><div class="delete-actions"><primer-button variant="secondary" @click=${this.handleCancelClick} ?disabled=${this.isDeleting} >${C("cancel",{id:"cancel"})}</primer-button><primer-button @click=${this.handleConfirmClick} ?disabled=${this.isDeleting} >${this.isDeleting?C("deleting",{id:"deleting"}):C("confirmVaultedPaymentMethodDeletion",{id:"confirmVaultedPaymentMethodDeletion"})}</primer-button></div></div>`}};Se.styles=[P,Is],l([p({type:Boolean})],Se.prototype,"isDeleting",2),l([p({type:String})],Se.prototype,"paymentMethodId",2),l([p({type:String})],Se.prototype,"paymentMethodName",2),l([E({context:ue,subscribe:!0})],Se.prototype,"vaultManager",2),Se=l([b("primer-vault-delete-confirmation"),O()],Se);var Ns=y` :host { display: block; width: 100%; } .empty-state { padding: var(--primer-space-xlarge) 0; text-align: center; color: var(--primer-color-text-secondary); } .empty-state p { margin: 0; } `;var et=class extends v{render(){return m`<div class="empty-state"><p>${C("savedPaymentMethodsEmpty",{id:"savedPaymentMethodsEmpty"})}</p></div>`}};et.styles=[P,Ns],et=l([b("primer-vault-empty-state"),O()],et);var Ls=y` :host { display: block; width: 100%; } .error-message { display: flex; background-color: var(--primer-color-red-100); padding: var(--primer-space-medium); border-radius: var(--primer-radius-small); margin-bottom: var(--primer-space-medium); justify-content: space-between; align-items: center; border: 1px solid var(--primer-color-red-500); } .error-content { display: flex; align-items: center; gap: var(--primer-space-small); } .error-message p { margin: 0; color: var(--primer-color-text-negative); font-size: var(--primer-typography-body-medium-size); } .error-message button { background: transparent; border: none; color: var(--primer-color-text-negative); cursor: pointer; padding: var(--primer-space-xsmall); display: flex; align-items: center; justify-content: center; border-radius: var(--primer-radius-small); transition: background-color var(--primer-animation-duration) var(--primer-animation-easing); } .error-message button:hover { background-color: rgba(0, 0, 0, 0.05); } `;var Ke=class extends v{constructor(){super(...arguments);this.errorMessage="";this.handleDismiss=()=>{this.dispatchEvent(new CustomEvent("close-error",{bubbles:!0,composed:!0}))}}render(){return m`<div class="error-message"><div class="error-content"><primer-icon name="warning" size="sm" color="var(--primer-color-red-500)" ></primer-icon><p>${this.errorMessage}</p></div><button @click=${this.handleDismiss} aria-label=${C("closeErrorMessage",{id:"closeErrorMessage"})} ><primer-icon name="close" size="sm"></primer-icon></button></div>`}};Ke.styles=[P,Ls],l([p({type:String})],Ke.prototype,"errorMessage",2),Ke=l([b("primer-vault-error-message"),O()],Ke);var Rs=y` :host { display: contents; } `;var X=class extends v{constructor(){super(...arguments);this._userAssignedProps=new Set;this._internalButtonText="";this.headlessInstance=null;this.sdkState=null;this.vaultItemContext=null;this.vaultManager=null;this.clientOptions=null;this.variant="primary";this.disabled=!1;this.handleClick=async e=>{if(e.preventDefault(),!this.isButtonDisabled)try{await this.vaultManager?.startVaultedPaymentFlow()}catch(r){let o=new CustomEvent("primer-vault-payment-error",{bubbles:!0,composed:!0,detail:{error:r}});this.dispatchEvent(o)}}}get buttonText(){return this._userAssignedProps.has("buttonText")?this._internalButtonText:C("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)}get isButtonDisabled(){return!!(this.disabled||!this.vaultItemContext?.selectedVaultedPaymentMethod||this.vaultManager?.isLoading)}render(){let e=this.clientOptions?.submitButton?.amountVisible?this.headlessInstance?.getUIOrderAmount():null,r=e?` ${e}`:h;return m`<primer-button buttonType="submit" variant=${this.variant} @click=${this.handleClick} .disabled=${this.isButtonDisabled} .loading=${this.sdkState?.isProcessing} data-submit >${this.buttonText}${r}</primer-button>`}};X.styles=[P,Rs],l([p({type:String})],X.prototype,"buttonText",1),l([E({context:F,subscribe:!0}),p({type:Object})],X.prototype,"headlessInstance",2),l([E({context:j,subscribe:!0}),p()],X.prototype,"sdkState",2),l([E({context:Oe,subscribe:!0}),p({type:Object,attribute:!1,hasChanged(e,r){return e?.selectedVaultedPaymentMethod?.id!==r?.selectedVaultedPaymentMethod?.id}})],X.prototype,"vaultItemContext",2),l([E({context:ue,subscribe:!0}),p({type:Object,attribute:!1})],X.prototype,"vaultManager",2),l([E({context:me,subscribe:!0}),p({type:Object,attribute:!1,hasChanged(e,r){return e?.submitButton?.amountVisible!==r?.submitButton?.amountVisible}})],X.prototype,"clientOptions",2),l([p({type:String})],X.prototype,"variant",2),l([p({type:Boolean})],X.prototype,"disabled",2),X=l([b("primer-vault-payment-submit"),O()],X);function ki(i){return i?{paddingHorizontal:0,placeholder:{color:i.getPropertyValue("--primer-color-text-placeholder").trim(),fontSize:i.getPropertyValue("--primer-typography-body-large-size").trim(),fontFamily:i.getPropertyValue("--primer-typography-body-large-font").trim()},height:i.getPropertyValue("--primer-typography-body-large-line-height").trim(),fontSize:i.getPropertyValue("--primer-typography-body-large-size").trim(),fontFamily:i.getPropertyValue("--primer-typography-body-large-font").trim(),color:i.getPropertyValue("--primer-color-text-primary").trim()}:null}var Os=y` :host { display: block; margin-top: var(--primer-space-medium); } .cvv-input-container { margin-bottom: var(--primer-space-medium); } `;var G=class extends v{constructor(){super();this.vaultManagerFormContext=null;this.vaultManagerCvvContext=null;this.computedStyles=null;this.paymentMethod=null;this.cvvError=null;this.cvvInputIsDirty=!1;this.cvvInputIsBlurred=!1;this.cvvInput=null;this.isFocused=!1;this._setupCVVIframe=new D(this,{task:([e,r])=>!e||!r||e.paymentMethodType!=="PAYMENT_CARD"||!e.paymentInstrumentData?.network||r.createCvvInput===null?R:{network:e.paymentInstrumentData.network,createCvvInput:r.createCvvInput},args:()=>[this.paymentMethod,this.vaultManagerFormContext]});this.cvvContainerId=`cvv-container-${Math.random().toString(36).substring(2,9)}`,new D(this,{task:async([e])=>{if(!e)return R;await this.updateComplete;let r=this.renderRoot.querySelector(`#${this.cvvContainerId}`);if(!r)return;let o=ki(this.computedStyles),a=o?{input:{base:o}}:void 0,n={cardNetwork:e.network,container:r,name:"cvv",placeholder:"123",style:a};this.cvvInput=await e.createCvvInput?.(n)??null,this.cvvInput&&(this.cvvInput.focus(),this.cvvError=this.cvvInput.metadata.errorCode||null,this.vaultManagerCvvContext?.setCvvInput(this.cvvInput),this.cvvInput.addListener("change",()=>{this.onCvvInputChange()}),this.cvvInput.addListener("blur",()=>{this.onBlur()}),this.cvvInput.addListener("focus",()=>{this.onFocus()}))},args:()=>[this._setupCVVIframe.value]})}disconnectedCallback(){super.disconnectedCallback(),this.cvvInput&&(this.cvvInput.remove(),this.cvvInput=null,this.cvvError=null,this.vaultManagerCvvContext?.setCvvInput(null))}onCvvInputChange(){!this.cvvInput||!this.vaultManagerCvvContext||(this.cvvInputIsDirty=!0,this.cvvError=this.cvvInput.metadata.errorCode||null)}onBlur(){this.cvvInput&&(this.cvvInputIsBlurred=!0,this.cvvError=this.cvvInput.metadata.errorCode||null,this.isFocused=!1)}onFocus(){this.isFocused=!0}render(){return this._setupCVVIframe.render({error:()=>h,complete:()=>m`<div class="cvv-input-container"><primer-input-wrapper .focusWithin=${this.isFocused} .hasError=${!!this.cvvError&&(this.vaultManagerCvvContext?.formIsDirty||this.cvvInputIsDirty&&this.cvvInputIsBlurred)} ><slot name="label" slot="label"><primer-input-label>CVV</primer-input-label></slot><div slot="input" id="${this.cvvContainerId}"></div>${k(this.cvvError&&(this.vaultManagerCvvContext?.formIsDirty||this.cvvInputIsDirty&&this.cvvInputIsBlurred),()=>m`<primer-input-error slot="error">${C(this.cvvError,{id:this.cvvError})}</primer-input-error>`)}</primer-input-wrapper></div>`})}};G.styles=[P,Os],l([E({context:ue,subscribe:!0}),p({type:Object,attribute:!1,hasChanged(e,r){return e?.createCvvInput!==r?.createCvvInput}})],G.prototype,"vaultManagerFormContext",2),l([E({context:Oe,subscribe:!0}),p({type:Object,attribute:!1})],G.prototype,"vaultManagerCvvContext",2),l([E({context:Vt,subscribe:!0}),p()],G.prototype,"computedStyles",2),l([p({type:Object})],G.prototype,"paymentMethod",2),l([_()],G.prototype,"cvvError",2),l([_()],G.prototype,"cvvInputIsDirty",2),l([_()],G.prototype,"cvvInputIsBlurred",2),l([_()],G.prototype,"cvvInput",2),l([_()],G.prototype,"isFocused",2),G=l([b("primer-vault-cvv-input"),O()],G);var Ds=y` :host { display: flex; width: 100%; align-items: center; } /* Card icons */ .payment-method-icon { height: var(--primer-space-xlarge); object-fit: contain; flex-shrink: 0; transition: transform var(--primer-animation-duration) var(--primer-animation-easing); } .payment-method-icon-generic { display: flex; align-items: center; justify-content: center; color: var(--primer-color-gray-500); height: var(--primer-space-xlarge); flex-shrink: 0; } .payment-method-details { flex: 1; display: flex; flex-direction: column; gap: var(--primer-space-xsmall); align-items: flex-start; transition: transform var(--primer-animation-duration) var(--primer-animation-easing); margin-left: var(--primer-space-small); } .payment-method-card { flex: 1; width: 100%; display: flex; flex-direction: column; gap: var(--primer-space-xsmall); transition: transform var(--primer-animation-duration) var(--primer-animation-easing); } .payment-method-description { font-weight: var(--primer-typography-title-large-weight); color: var(--primer-color-text-primary); transition: color var(--primer-animation-duration) var(--primer-animation-easing); } .payment-method-secondary-description { font-size: var(--primer-typography-body-small-size); color: var(--primer-color-text-secondary); transition: color var(--primer-animation-duration) var(--primer-animation-easing); } .payment-method-row { display: grid; grid-template-columns: 200px 100px; justify-content: space-between; align-items: center; } .cell-2 { grid-column: 2; display: flex; justify-content: flex-end; align-items: center; } .payment-method-header { font-weight: var(--primer-typography-body-large-weight); font-size: var(--primer-typography-body-large-size); line-height: var(--primer-typography-body-large-line-height); color: var(--primer-color-text-primary); letter-spacing: var(--primer-typography-body-large-letter-spacing); } .payment-method-subtitle { color: var(--primer-color-text-secondary); font-size: var(--primer-typography-body-small-size); line-height: var(--primer-typography-body-small-line-height); font-weight: var(--primer-typography-body-small-weight); letter-spacing: var(--primer-typography-body-small-letter-spacing); } .flex { display: flex; align-items: flex-end; gap: var(--primer-space-xsmall); } .payment-method-card-other { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: var(--primer-space-medium); align-items: center; justify-content: space-between; } .payment-method-right-column-text { 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 je=class extends v{constructor(){super(...arguments);this.assetConfig=null}render(){if(!this.assetConfig)return h;let e=this.assetConfig.description,r=this.assetConfig.icon,o=k(this.assetConfig.icon,()=>m`<img class="payment-method-icon" src=${r} alt=${e} />`,()=>m`<div class="payment-method-icon payment-method-icon-generic"><primer-icon name="payment-card" size="sm"></primer-icon></div>`);return this.assetConfig.type==="paypal"?m`<span class="payment-method-card"><div class="payment-method-row"><span class="payment-method-header" >${this.assetConfig.fullName}</span ></div><div class="payment-method-row"><span class="flex">${o}<span class="payment-method-subtitle" >${this.assetConfig.paymentMethodType}</span ></span></div></span>`:this.assetConfig.type==="other"&&this.assetConfig.paymentMethodType!=="ACH"?m`<div class="payment-method-card-other"><div class="left-column"><div class="payment-method-header">${this.assetConfig.fullName}</div><div class="flex">${o}<span class="payment-method-subtitle" >${this.assetConfig.paymentMethodType}</span ></div></div><div class="payment-method-right-column-text">${this.assetConfig.email||`\u2022\u2022\u2022\u2022 ${this.assetConfig.last4}`}</div></div>`:this.assetConfig.type==="other"&&this.assetConfig.paymentMethodType==="ACH"?m`<span class="payment-method-card"><div class="payment-method-row"><span class="payment-method-header" >${this.assetConfig.fullName}</span ><span class="payment-method-header cell-2" >•••• ${this.assetConfig.last4}</span ></div><div class="payment-method-row"><span class="flex">${o}<span class="payment-method-subtitle" >${this.assetConfig.bankName}</span ></span><span class="payment-method-subtitle cell-2" >${this.assetConfig.accountType}</span ></div></span>`:this.assetConfig.type==="card"?m`<span class="payment-method-card"><div class="payment-method-row"><span class="payment-method-header" >${this.assetConfig.cardholderName}</span ><span class="payment-method-header cell-2" >•••• ${this.assetConfig.last4}</span ></div><div class="payment-method-row"><span class="flex">${o}<span class="payment-method-subtitle" >${this.assetConfig.network}</span ></span><span class="payment-method-subtitle cell-2" >${this.assetConfig.expiresDate}</span ></div></span>`:h}};je.styles=[P,Ds],l([p({type:Object,attribute:!1})],je.prototype,"assetConfig",2),je=l([b("primer-payment-method-content")],je);var Gt="card-form-context";function $s(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=`
|
|
201
|
+
`,i}function jt(i,t){let e=t.value;if(!e)return;let r=e.querySelector(".disabled-overlay");if(r&&r.remove(),i){let o=us();e.appendChild(o)}}function Ai(i,t,e=5){let r=null;if(r=t.querySelector(".gpay-card-info-container-fill"),r||(r=document.querySelector(".gpay-card-info-container-fill")),!r){e>0&&setTimeout(()=>Ai(i,t,e-1),100);return}let o=r.querySelector(".disabled-overlay");if(o&&o.remove(),i){let n=us();r.style.position="relative",r.appendChild(n)}}var Fe=class extends v{constructor(){super();this.paymentManagers=new Map;this.disabled=!1;this.loadManagerTask=new D(this,{args:()=>[this.paymentMethod?.type],task:([e])=>{if(!e)return R;let r=this.paymentManagers.get(e);if(!r)throw new Error(`No manager found for payment method type ${e}`);if(r.type!=="GOOGLE_PAY")throw new Error("Invalid payment method type for Google Pay component");return r.manager}}),this.renderButtonTask=new D(this,{args:()=>[this.loadManagerTask.value],task:async([e])=>{if(!e)return R;await this.updateComplete;let r=e.createButton();return await r.render(this.shadowRoot?.getRootNode(),{style:{shadowRoot:!0}}),this.disabled&&await r.setDisabled(this.disabled),this.disabled&&this.shadowRoot&&(await this.updateComplete,Ai(this.disabled,this.shadowRoot)),r}})}attributeChangedCallback(e,r,o){if(super.attributeChangedCallback(e,r,o),e==="disabled"&&r!==o){let n=o!==null,a=this.renderButtonTask.value;a&&a.setDisabled(n)}}updated(e){e.has("disabled")&&this.shadowRoot&&Ai(this.disabled,this.shadowRoot)}render(){return g}};Fe.styles=[_,ms],d([p({type:Object})],Fe.prototype,"paymentMethod",2),d([C({context:K,subscribe:!0}),p()],Fe.prototype,"paymentManagers",2),d([p({type:Boolean,attribute:"disabled"})],Fe.prototype,"disabled",2),Fe=d([b("primer-google-pay")],Fe);var Er=(i,t)=>{let e=i._$AN;if(e===void 0)return!1;for(let r of e)r._$AO?.(t,!1),Er(r,t);return!0},Si=i=>{let t,e;do{if((t=i._$AM)===void 0)break;e=t._$AN,e.delete(i),i=t}while(e?.size===0)},hs=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),Gc(t)}};function zc(i){this._$AN!==void 0?(Si(this),this._$AM=i,hs(this)):this._$AM=i}function Kc(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 n=e;n<r.length;n++)Er(r[n],!1),Si(r[n]);else r!=null&&(Er(r,!1),Si(r));else Er(this,i)}var Gc=i=>{i.type==Z.CHILD&&(i._$AP??(i._$AP=Kc),i._$AQ??(i._$AQ=zc))},gt=class extends $e{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,r){super._$AT(t,e,r),hs(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(Er(this,t),Si(this))}setValue(t){if(Ci(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 Lt=()=>new Fo,Fo=class{},Bo=new WeakMap,ft=Ce(class extends gt{render(i){return g}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)),g}rt(i){if(this.isConnected||(i=void 0),typeof this.G=="function"){let t=this.ht??globalThis,e=Bo.get(t);e===void 0&&(e=new WeakMap,Bo.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"?Bo.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 gs=y` ${Gt} `;function Pi(i){if(typeof window>"u"||!i.isConnected)return 0;let t=getComputedStyle(i),e=parseFloat(t.height),r=parseFloat(t.minHeight);return e<20&&r>0?r:e}function fs(i){return Math.max(25,Math.min(55,i))}var He=class extends v{constructor(){super();this.paymentManagers=new Map;this.disabled=!1;this.buttonContainerRef=Lt();this.loadManagerTask=new D(this,{args:()=>[this.paymentMethod?.type],task:([e])=>{if(!e)return R;let r=this.paymentManagers.get(e);if(!r)throw new Error(`No manager found for payment method type ${e}`);if(r.type!=="APPLE_PAY")throw new Error("Invalid payment method type for Apple Pay component");return r.manager}}),this.renderButtonTask=new D(this,{args:()=>[this.loadManagerTask.value],task:async([e])=>{if(!e)return R;await this.updateComplete;let r=this.buttonContainerRef.value;if(!r)throw new Error("Button container not found");let o=e.createButton(),n=Pi(r);return await o.render(r,{style:{buttonHeight:n}}),this.disabled&&await o.setDisabled(this.disabled),this.disabled&&(await this.updateComplete,jt(this.disabled,this.buttonContainerRef)),o}})}attributeChangedCallback(e,r,o){if(super.attributeChangedCallback(e,r,o),e==="disabled"&&r!==o){let n=o!==null,a=this.renderButtonTask.value;a&&a.setDisabled(n)}}updated(e){e.has("disabled")&&jt(this.disabled,this.buttonContainerRef)}render(){return m`<div class="native-button-container" ${ft(this.buttonContainerRef)} ></div>`}};He.styles=[_,gs],d([p({type:Object})],He.prototype,"paymentMethod",2),d([C({context:K,subscribe:!0}),p()],He.prototype,"paymentManagers",2),d([p({type:Boolean,attribute:"disabled"})],He.prototype,"disabled",2),He=d([b("primer-apple-pay")],He);var ys=y` ${Gt} /* Override base styles to use flexible height for multiple buttons */ :host { height: auto; min-height: calc( ${he(Me)} + calc(2 * var(--primer-space-medium)) ); /* PayPal SDK can show up to 6 buttons vertically (55px each + ~5px gap) */ max-height: 360px; } `;var ze=class extends v{constructor(){super();this.paymentManagers=new Map;this.disabled=!1;this.buttonContainerRef=Lt();this.loadManagerTask=new D(this,{args:()=>[this.paymentMethod?.type],task:([e])=>{if(!e)return R;let r=this.paymentManagers.get(e);if(!r)throw new Error(`No manager found for payment method type ${e}`);if(r.type!=="PAYPAL")throw new Error("Invalid payment method type for PayPal component");return r.manager}}),this.renderButtonTask=new D(this,{args:()=>[this.loadManagerTask.value],task:async([e])=>{if(!e)return R;await this.updateComplete;let r=this.buttonContainerRef.value;if(!r)throw new Error("Button container not found");let o=e.createButton(),n=Pi(this),a=fs(n),s=55;return n>s&&P.warn(`PayPal button height (${n}px) exceeds maximum allowed height of ${s}px. Button will be capped at ${s}px. This is a PayPal SDK limitation.`),await o.render(r,{style:{buttonHeight:a}}),this.disabled&&await o.setDisabled(this.disabled),this.disabled&&(await this.updateComplete,jt(this.disabled,this.buttonContainerRef)),o}})}attributeChangedCallback(e,r,o){if(super.attributeChangedCallback(e,r,o),e==="disabled"&&r!==o){let n=o!==null,a=this.renderButtonTask.value;a&&a.setDisabled(n)}}updated(e){e.has("disabled")&&jt(this.disabled,this.buttonContainerRef)}render(){return m`<div class="native-button-container" ${ft(this.buttonContainerRef)} ></div>`}};ze.styles=[_,ys],d([p({type:Object})],ze.prototype,"paymentMethod",2),d([C({context:K,subscribe:!0}),p()],ze.prototype,"paymentManagers",2),d([p({type:Boolean,attribute:"disabled"})],ze.prototype,"disabled",2),ze=d([b("primer-paypal")],ze);var vs=y` :host { display: flex; width: 100%; } .blik-container { width: 100%; display: flex; flex-direction: column; transition: all var(--primer-animation-duration) var(--primer-animation-easing); } .blik-container.expanded { border-radius: var(--primer-radius-medium); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); background-color: var(--primer-color-background-outlined-default); border: 1px solid var(--primer-color-border-outlined-default); padding: var(--primer-space-large); } /* Button styles (collapsed state) */ primer-button.blik-button { width: 100%; } /* Override primer-button part styles for BLIK branding */ primer-button.blik-button::part(button) { /* BLIK brand requirement: Black background (#000000) with white logo */ background-color: #000000; border: none; color: var(--primer-color-text-primary); padding: 2px; display: flex; align-items: center; justify-content: center; gap: var(--primer-space-small); /* Fixed height for button - matches redirect payment method calculation */ height: calc( ${he(Me)} + calc(2 * var(--primer-space-medium)) ); flex-shrink: 0; /* Prevent button from shrinking when form appears */ } /* Image container for button logo */ .image-container { display: flex; justify-content: center; align-items: center; min-width: 100px; height: 100%; flex-shrink: 0; flex-grow: 1; } /* Button logo */ img { max-width: 100px; width: 100%; height: auto; object-fit: cover; max-height: 98%; } /* Expanded content (form, loading, error states) */ .blik-expanded-content { width: 100%; display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--primer-animation-duration) var(--primer-animation-easing); overflow: hidden; margin-top: var(--primer-space-medium); } .blik-container.expanded .blik-expanded-content { grid-template-rows: 1fr; } .blik-content-wrapper { overflow: hidden; } /* Input wrapper */ .blik-input-wrapper { display: flex; flex-direction: column; gap: var(--primer-space-small); } /* Input label */ .blik-label { 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); color: var(--primer-color-text-primary); } /* Input field */ .blik-input { width: 100%; padding: var(--primer-space-medium); font-family: var(--primer-typography-body-large-font); font-size: var(--primer-typography-body-large-size); font-weight: var(--primer-typography-body-large-weight); line-height: var(--primer-typography-body-large-line-height); /* Increase spacing between digits for better 6-digit code readability */ letter-spacing: 0.25em; text-align: center; color: var(--primer-color-text-primary); background-color: var(--primer-color-background-outlined-default); border: 1px solid var(--primer-color-border-outlined-default); border-radius: var(--primer-radius-medium); outline: none; transition: border-color var(--primer-animation-duration) var(--primer-animation-easing); } .blik-input::placeholder { color: var(--primer-color-text-secondary); /* Reduce placeholder visibility to emphasize user input */ opacity: 0.5; } .blik-input:focus { border-color: var(--primer-color-border-outlined-focus); } .blik-input: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 */ .blik-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--primer-space-large); padding: var(--primer-space-xlarge) var(--primer-space-medium); } /* Timeout warning */ .blik-timeout-warning { margin-top: var(--primer-space-medium); padding: var(--primer-space-small); font-size: var(--primer-typography-body-small-size); color: var(--primer-color-text-warning); text-align: center; border-radius: var(--primer-radius-small); background-color: var(--primer-color-surface-warning); } /* Error state */ .blik-error { display: flex; flex-direction: column; align-items: center; gap: var(--primer-space-medium); } .blik-error-message { 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); color: var(--primer-color-text-primary); text-align: center; } /* Retry button */ .blik-retry-button { padding: var(--primer-space-medium) var(--primer-space-large); font-family: var(--primer-typography-title-large-font); font-size: var(--primer-typography-title-large-size); font-weight: var(--primer-typography-title-large-weight); line-height: var(--primer-typography-title-large-line-height); color: var(--primer-color-background-outlined-default); background-color: var(--primer-color-brand); border: none; border-radius: var(--primer-radius-medium); cursor: pointer; outline: none; transition: filter var(--primer-animation-duration) var(--primer-animation-easing); } .blik-retry-button:hover:not(:disabled) { filter: brightness(105%); } .blik-retry-button:active:not(:disabled) { filter: brightness(98%); } .blik-retry-button:focus-visible { outline: 2px solid var(--primer-color-brand); outline-offset: 2px; } .blik-retry-button:disabled { background-color: var(--primer-color-background-outlined-disabled); color: var(--primer-color-text-disabled); cursor: not-allowed; } /* Disabled state styling */ :host([disabled]) { opacity: 0.6; cursor: not-allowed; } :host([disabled]) primer-button::part(button) { pointer-events: none; cursor: not-allowed; } :host([disabled]) img { filter: grayscale(100%); } /* Responsive typography for larger screens */ @media (min-width: 768px) { .blik-input { font-size: var(--primer-typography-title-large-size); } } `;var ve=class extends v{constructor(){super(...arguments);this.disabled=!1;this.paymentManagers=new Map;this.currentState="collapsed";this.blikCode="";this.errorMessage="";this.pollingDuration=0;this.pollingTimer=null;this.loadManagerTask=new D(this,{args:()=>[this.paymentMethod?.type],task:([e])=>{if(!e)return R;let r=this.paymentManagers.get(e);if(!r)throw new Error("BLIK payment method manager not initialized");if(r.type!=="ADYEN_BLIK")throw new Error("Invalid payment method type for BLIK component");return r.manager}});this.handleButtonClick=async()=>{if(this.disabled)return;if(this.currentState==="expanded-input"){this.handleCollapse();return}if(this.currentState!=="collapsed")return;let e=this.paymentMethod?.type;if(!e){this.errorMessage=E("something_went_wrong_error",{id:"something_went_wrong_error"}),this.currentState="error",P.error("Payment method type not available");return}let r=this.paymentManagers.get(e);if(!r||r.type!=="ADYEN_BLIK"){this.errorMessage=E("something_went_wrong_error",{id:"something_went_wrong_error"}),this.currentState="error",P.error("Manager not available when expanding BLIK form");return}this.currentState="expanded-input",await this.updateComplete,this.shadowRoot?.querySelector("#blik-code")?.focus()};this.handleCollapse=()=>{this.currentState="collapsed",this.blikCode="",this.errorMessage="",this.stopPollingTimer()};this.handleInput=e=>{let r=e.target,o=r.value,a=o.replace(/\D/g,"").slice(0,6);o!==a&&(r.value=a),this.blikCode=a,this.currentState==="error"&&(this.currentState="expanded-input",this.errorMessage=""),a.length===6&&this.submitBlikCode()};this.handleRetry=async()=>{this.currentState="expanded-input",this.errorMessage="",this.blikCode="",await this.updateComplete,this.shadowRoot?.querySelector("#blik-code")?.focus()}}startPollingTimer(){this.pollingDuration=0,this.pollingTimer=window.setInterval(()=>{this.pollingDuration+=1},1e3)}stopPollingTimer(){this.pollingTimer!==null&&(window.clearInterval(this.pollingTimer),this.pollingTimer=null),this.pollingDuration=0}async submitBlikCode(){if(this.blikCode.length!==6){this.errorMessage=E("sixDigitCodeErrorTooShort",{id:"sixDigitCodeErrorTooShort"}),this.currentState="error";return}let e=this.loadManagerTask.value;if(!e){this.errorMessage="BLIK payment method not initialized",this.currentState="error",P.error("BLIK manager not available via loadManagerTask");return}this.currentState="loading",this.errorMessage="",this.startPollingTimer();try{await e.start({blikCode:this.blikCode}),this.stopPollingTimer(),this.currentState="collapsed",this.blikCode=""}catch(r){this.stopPollingTimer(),this.currentState="error",this.errorMessage=r instanceof Error?r.message:E("tokenizationError",{id:"tokenizationError"}),P.errorWithDatadog("BLIK payment failed",{error:r instanceof Error?{message:r.message,name:r.name}:"Unknown error"})}}renderCollapsed(){return m`<primer-button class="blik-button" @click=${this.handleButtonClick} ?disabled=${this.disabled} aria-label="${E("pay_with",{id:"pay_with"})} BLIK" aria-expanded="${this.currentState!=="collapsed"}" title="BLIK" ><span class="image-container"><img src="https://goat-assets.production.core.primer.io/button/blik/inverted.png" alt="BLIK" /></span></primer-button>`}renderExpandedInput(){return m`<div class="blik-expanded-content"><div class="blik-content-wrapper"><div class="blik-input-wrapper"><label for="blik-code" class="blik-label">${E("getCodeFromBankingApp",{id:"getCodeFromBankingApp"})}</label><input id="blik-code" type="text" inputmode="numeric" pattern="[0-9]*" maxlength="6" class="blik-input" .value="${this.blikCode}" @input="${this.handleInput}" ?disabled="${this.disabled}" placeholder="000000" aria-label="${E("sixDigitCodeLabel",{id:"sixDigitCodeLabel"})}" autocomplete="off" spellcheck="false" /></div></div></div>`}renderLoading(){return m`<div class="blik-expanded-content"><div class="blik-content-wrapper"><div class="blik-loading"><primer-spinner size="medium"></primer-spinner>${this.pollingDuration>30?m`<div class="blik-timeout-warning"> This is taking longer than expected... </div>`:g}</div></div></div>`}renderError(){return m`<div class="blik-expanded-content"><div class="blik-content-wrapper"><div class="blik-error"><div class="blik-error-message" role="alert">${this.errorMessage||E("something_went_wrong_error",{id:"something_went_wrong_error"})}</div><button class="blik-retry-button" @click="${this.handleRetry}" ?disabled="${this.disabled}" >${E("retry_button",{id:"retry_button"})}</button></div></div></div>`}renderExpandedState(){switch(this.currentState){case"expanded-input":return this.renderExpandedInput();case"loading":return this.renderLoading();case"error":return this.renderError();default:return g}}disconnectedCallback(){super.disconnectedCallback(),this.stopPollingTimer()}render(){return m`<div class="blik-container ${this.currentState!=="collapsed"?"expanded":""}" >${this.renderCollapsed()} ${this.currentState!=="collapsed"?this.renderExpandedState():g}</div>`}};ve.styles=[_,vs],d([p({type:Object})],ve.prototype,"paymentMethod",2),d([p({type:Boolean,attribute:"disabled"})],ve.prototype,"disabled",2),d([C({context:K,subscribe:!0})],ve.prototype,"paymentManagers",2),d([M()],ve.prototype,"currentState",2),d([M()],ve.prototype,"blikCode",2),d([M()],ve.prototype,"errorMessage",2),d([M()],ve.prototype,"pollingDuration",2),ve=d([b("primer-blik"),O()],ve);var Le=class extends v{constructor(){super(...arguments);this.type=void 0;this.disabled=!1;this.paymentMethods=null;this.analyticsUtils=null;this.handleClick=()=>{this.paymentMethods?.get(this.type)?.managerType!=="CARD"&&this.sendPaymentMethodSelectionEvent()}}sendPaymentMethodSelectionEvent(){this.type&&J({eventName:"PAYMENT_METHOD_SELECTION",paymentMethod:this.type})}render(){if(!this.type)return g;let e=this.paymentMethods?.get(this.type);if(!e)return g;let r;switch(e?.managerType){case"CARD":r=m`<primer-card-form ?disabled=${this.disabled} ></primer-card-form>`;break;case"NATIVE":{let o=e.type;o===yr.GOOGLE_PAY?r=m`<primer-google-pay .paymentMethod=${e} ?disabled=${this.disabled} ></primer-google-pay>`:o===yr.APPLE_PAY?r=m`<primer-apple-pay .paymentMethod=${e} ?disabled=${this.disabled} ></primer-apple-pay>`:o===yr.PAYPAL?r=m`<primer-paypal .paymentMethod=${e} ?disabled=${this.disabled} ></primer-paypal>`:o===yr.ADYEN_BLIK&&(r=m`<primer-blik .paymentMethod=${e} ?disabled=${this.disabled} ></primer-blik>`);break}case"REDIRECT":r=m`<primer-redirect-payment .paymentMethod=${e} ?disabled=${this.disabled} ></primer-redirect-payment>`;break;case"KLARNA":r=m`<primer-klarna ?disabled=${this.disabled} ></primer-klarna>`;break;case"ACH":r=m`<primer-dynamic-payment .paymentMethod=${e} ></primer-dynamic-payment>`;break;default:return g}return m`<div @click=${this.handleClick}>${r}</div>`}};Le.styles=[ps],d([p({type:String})],Le.prototype,"type",2),d([p({type:Boolean,attribute:"disabled"})],Le.prototype,"disabled",2),d([C({context:dt,subscribe:!0}),p()],Le.prototype,"paymentMethods",2),d([C({context:lt,subscribe:!0}),p({attribute:!1})],Le.prototype,"analyticsUtils",2),Le=d([b("primer-payment-method")],Le);var bs=y` :host { display: block; width: 100%; } .payment-methods-container { display: flex; flex-direction: column; gap: var(--primer-space-small); } :host([disabled]) .payment-methods-container { opacity: 0.5; pointer-events: none; } `;var we=class extends v{constructor(){super(...arguments);this.disabled=!1;this.paymentMethods=null;this.clientOptions=null}getFilteredMethods(){if(!this.paymentMethods)return[];let e=this.paymentMethods.toArray();if(this.include){let r=this.include.split(",").map(o=>o.trim());e=e.filter(o=>r.includes(o.type))}if(this.exclude){let r=this.exclude.split(",").map(o=>o.trim());e=e.filter(o=>!r.includes(o.type))}return e}render(){let e=this.getFilteredMethods();return e.length===0?g:m`<div class="payment-methods-container">${e.map(r=>m`<primer-payment-method type="${r.type}" ?disabled="${this.disabled||this.clientOptions?.disabledPayments===!0}" ></primer-payment-method>`)}</div>`}};we.styles=[_,bs],d([p({type:String})],we.prototype,"include",2),d([p({type:String})],we.prototype,"exclude",2),d([p({type:Boolean,attribute:"disabled"})],we.prototype,"disabled",2),d([C({context:dt,subscribe:!0}),p()],we.prototype,"paymentMethods",2),d([C({context:me,subscribe:!0}),p()],we.prototype,"clientOptions",2),we=d([b("primer-payment-method-container")],we);var Es=y` :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 Cs(){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 xi=class{constructor(t,e){this.formState=Cs();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=Cs(),this.host.requestUpdate()}isValidFieldName(t){return!!t&&["firstName","lastName","emailAddress"].includes(t)}hostConnected(){}hostDisconnected(){}};var Se=class extends v{constructor(){super(...arguments);this.formController=new xi(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 D(this,{task:([e])=>e!=="STRIPE_ACH"?R: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>${E("payWithAch",{id:"payWithAch"})}</h2><p>${E("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">${E("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:g}</primer-input-error></primer-input-wrapper><primer-input-wrapper .hasError=${this.formController.hasError.lastName} ><primer-input-label slot="label">${E("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:g}</primer-input-error></primer-input-wrapper></div><primer-input-wrapper .hasError=${this.formController.hasError.emailAddress} ><primer-input-label slot="label">${E("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:g}</primer-input-error></primer-input-wrapper><p>${E("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} >${E("stripe_ach_user_details_collection_continue_button",{id:"stripe_ach_user_details_collection_continue_button"})}</primer-button></form>`}renderMandate(){return m`<h2>${E("payWithAch",{id:"payWithAch"})}</h2><p>${this.clientOptions?.stripe?.mandateData.fullMandateText??E("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} >${E("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} >${E("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():g})}};Se.styles=[_,Es],d([p({type:Object})],Se.prototype,"paymentMethod",2),d([C({context:K,subscribe:!0}),p({attribute:!1})],Se.prototype,"paymentManagers",2),d([C({context:G,subscribe:!0}),p({attribute:!1})],Se.prototype,"sdkState",2),d([C({context:me,subscribe:!0}),p({attribute:!1})],Se.prototype,"clientOptions",2),d([M()],Se.prototype,"screen",2),d([M()],Se.prototype,"isSubmitting",2),Se=d([b("primer-ach-payment"),O()],Se);var As=y` :host { height: calc( ${he(Me)} + calc(2 * var(--primer-space-medium)) ); display: flex; /* Default value for the background color CSS variable */ --dynamic-payment-button-bg-color: var( --primer-color-background-outlined-default ); } primer-button { width: 100%; height: 100%; } primer-button::part(button) { background-color: var(--dynamic-payment-button-bg-color); border: 1px solid var(--primer-color-border-outlined-default); color: var(--primer-color-text-primary); flex: 1; padding: 1px; } .image-container { display: flex; justify-content: center; height: 100%; } /* Target the img specifically inside our component */ img { height: 100%; } `;function Cr(i){return i.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g,(t,e)=>e.toUpperCase())}var Ie=class extends v{constructor(){super(...arguments);this.paymentManagers=new Map;this.sdkState=null;this.headlessUtils=null;this.open=!1;this._paymentMethodManagerTask=new D(this,{task:([e,r])=>!e||!r?R:r.get(e)?.manager,args:()=>[this.paymentMethod?.type,this.paymentManagers]});this._getAssetsTask=new D(this,{task:([e,r])=>{if(!e||!r)return R;let o=r.getPaymentMethodConfiguration(e);return o?{backgroundColor:o.displayMetadata.button.backgroundColor.colored,name:o.name,displayName:this._legacyGetButtonLabel(o.displayMetadata.button.text),iconUrl:o.displayMetadata.button.iconUrl.colored||o.displayMetadata.button.iconUrl.light||o.displayMetadata.button.iconUrl.dark}:R},args:()=>[this.paymentMethod?.type,this.headlessUtils]});this._setupTasks=new D(this,{task:([e,r])=>!e||!r?R:{paymentMethodManager:e,assetsConfig:r},args:()=>[this._paymentMethodManagerTask.value,this._getAssetsTask.value]})}_legacyGetButtonLabel(e){if(!e)return;let r=e?Cr(e):"";return r==="payWith"&&(r="pay_with"),E(r,{id:r})}start(){this._paymentMethodManagerTask.value&&(this.open=!0)}renderDialog(){return this.open?m`<primer-portal><primer-dialog @primer-dialog-close="${()=>this.open=!1}"><primer-ach-payment .paymentMethod=${this.paymentMethod} @primer-ach-error=${()=>this.open=!1} @primer-ach-mandate-confirmed=${()=>this.open=!1} @primer-ach-mandate-declined=${()=>this.open=!1} ></primer-ach-payment></primer-dialog></primer-portal>`:g}render(){return this._setupTasks.render({error:()=>g,complete:({assetsConfig:e})=>(this.style.setProperty("--dynamic-payment-button-bg-color",e.backgroundColor),m`<primer-button @click="${()=>this.start()}" class=${re({loading:!!this.sdkState?.isProcessing,reverse:!0})} title="${E("pay_with",{id:"pay_with"})} ${e.name}" ><span class="image-container"><img src="${e.iconUrl}" alt="${e.name}" /></span>${e.displayName}</primer-button>${this.renderDialog()} `)})}};Ie.styles=[_,As],d([p({type:Object})],Ie.prototype,"paymentMethod",2),d([C({context:K,subscribe:!0})],Ie.prototype,"paymentManagers",2),d([C({context:G,subscribe:!0})],Ie.prototype,"sdkState",2),d([C({context:H,subscribe:!0})],Ie.prototype,"headlessUtils",2),d([M()],Ie.prototype,"open",2),Ie=d([b("primer-dynamic-payment"),O()],Ie);var Ss=y` :host { height: calc( ${he(Me)} + calc(2 * var(--primer-space-medium)) ); display: flex; /* Default value for the background color CSS variable */ --redirect-payment-button-bg-color: var( --primer-color-background-outlined-default ); } primer-button { width: 100%; height: 100%; } primer-button::part(button) { background-color: var(--redirect-payment-button-bg-color); border: 1px solid var(--primer-color-border-outlined-default); color: var(--primer-color-text-primary); flex: 1; padding: var(--primer-space-small); display: flex; align-items: center; justify-content: center; gap: var(--primer-space-small); } /* Default layout: icon on the left (START) */ primer-button { display: flex; flex-direction: row; } /* When icon position is END */ primer-button.icon-end { flex-direction: row-reverse; } .image-container { display: flex; justify-content: center; align-items: center; min-width: 100px; height: 100%; } .button-text { font-family: var(--primer-typography-font-family); font-size: var(--primer-typography-title-small-font-size); font-weight: var(--primer-typography-title-small-font-weight); line-height: var(--primer-typography-title-small-line-height); letter-spacing: var(--primer-typography-title-small-letter-spacing); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* Target the img specifically inside our component */ img { max-width: 100px; width: 100%; height: auto; object-fit: cover; max-height: 100%; } /* For image container sizing */ .image-container { flex-shrink: 0; flex-grow: 1; } /* Disabled state styling - subtle visual feedback */ :host([disabled]) { opacity: 0.6; cursor: not-allowed; } :host([disabled]) primer-button::part(button) { pointer-events: none; cursor: not-allowed; } :host([disabled]) img { filter: grayscale(100%); } `;var ke=class extends v{constructor(){super(...arguments);this.disabled=!1;this.paymentManagers=new Map;this.sdkState=null;this.headlessUtils=null;this._paymentMethodManagerTask=new D(this,{task:([e,r])=>!e||!r?R:r.get(e)?.manager,args:()=>[this.paymentMethod?.type,this.paymentManagers]});this._getAssetsTask=new D(this,{task:([e,r])=>{if(!e||!r)return R;let o=r.getPaymentMethodConfiguration(e);if(!o)return R;let n=o.displayMetadata.button.backgroundColor.colored??o.displayMetadata.button.backgroundColor.light,a=o.displayMetadata.button.iconPositionRelativeToText||"START";return{backgroundColor:n,name:o.name,displayName:this._legacyGetButtonLabel(o.displayMetadata.button.text),iconUrl:o.displayMetadata.button.iconUrl.colored??o.displayMetadata.button.iconUrl.light,iconPosition:a}},args:()=>[this.paymentMethod?.type,this.headlessUtils]});this._setupTasks=new D(this,{task:([e,r])=>!e||!r?R:{paymentMethodManager:e,assetsConfig:r},args:()=>[this._paymentMethodManagerTask.value,this._getAssetsTask.value]})}_legacyGetButtonLabel(e){if(!e)return;let r=e?Cr(e):"";return r==="payWith"&&(r="pay_with"),E(r,{id:r})}startRedirectPayment(){this.disabled||this._paymentMethodManagerTask.value&&this._paymentMethodManagerTask.value.start()}render(){return this._setupTasks.render({error:()=>g,complete:({assetsConfig:e})=>{this.style.setProperty("--redirect-payment-button-bg-color",e.backgroundColor);let r={loading:!!this.sdkState?.isProcessing,"icon-end":e.iconPosition==="END","image-only":!e.displayName},o=e.displayName?m`<span class="image-container"><img src="${e.iconUrl}" alt="${e.name}" /></span><span class="button-text">${e.displayName}</span>`:m`<span class="image-container"><img src="${e.iconUrl}" alt="${e.name}" /></span>`;return m`<primer-button @click="${()=>this.startRedirectPayment()}" class=${re(r)} title="${E("pay_with",{id:"pay_with"})} ${e.name}" ?disabled=${this.disabled} >${o}</primer-button>`}})}};ke.styles=[_,Ss],d([p({type:Object})],ke.prototype,"paymentMethod",2),d([p({type:Boolean,attribute:"disabled"})],ke.prototype,"disabled",2),d([C({context:K,subscribe:!0})],ke.prototype,"paymentManagers",2),d([C({context:G,subscribe:!0})],ke.prototype,"sdkState",2),d([C({context:H,subscribe:!0})],ke.prototype,"headlessUtils",2),ke=d([b("primer-redirect-payment"),O()],ke);var Ps=y` :host { display: block; } :host([hidden]) { display: none; } .billing-address-form { display: flex; flex-direction: column; gap: var(--primer-space-medium); } .billing-address-title { margin-top: var(--primer-space-large); margin-bottom: var(--primer-space-small); font-family: var(--primer-typography-body-medium-font); font-size: var(--primer-typography-body-large-size); font-weight: var(--primer-typography-body-large-weight); line-height: var(--primer-typography-body-large-line-height); color: var(--primer-color-text-primary); } .billing-address-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--primer-space-medium); } @media (max-width: 640px) { .billing-address-row { grid-template-columns: 1fr; } } `;var Ho={locale:"en",countries:{AF:"Afghanistan",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia",BA:"Bosnia and Herzegovina",BW:"Botswana",BV:"Bouvet Island",BR:"Brazil",IO:"British Indian Ocean Territory",BN:"Brunei Darussalam",BG:"Bulgaria",BF:"Burkina Faso",BI:"Burundi",KH:"Cambodia",CM:"Cameroon",CA:"Canada",CV:"Cape Verde",KY:"Cayman Islands",CF:"Central African Republic",TD:"Chad",CL:"Chile",CN:["People's Republic of China","China"],CX:"Christmas Island",CC:"Cocos (Keeling) Islands",CO:"Colombia",KM:"Comoros",CG:["Republic of the Congo","Congo"],CD:["Democratic Republic of the Congo","Congo"],CK:"Cook Islands",CR:"Costa Rica",CI:["Cote d'Ivoire","C\xF4te d'Ivoire","Ivory Coast"],HR:"Croatia",CU:"Cuba",CY:"Cyprus",CZ:["Czech Republic","Czechia"],DK:"Denmark",DJ:"Djibouti",DM:"Dominica",DO:"Dominican Republic",EC:"Ecuador",EG:"Egypt",SV:"El Salvador",GQ:"Equatorial Guinea",ER:"Eritrea",EE:"Estonia",ET:"Ethiopia",FK:"Falkland Islands (Malvinas)",FO:"Faroe Islands",FJ:"Fiji",FI:"Finland",FR:"France",GF:"French Guiana",PF:"French Polynesia",TF:"French Southern Territories",GA:"Gabon",GM:["Republic of The Gambia","The Gambia","Gambia"],GE:"Georgia",DE:"Germany",GH:"Ghana",GI:"Gibraltar",GR:"Greece",GL:"Greenland",GD:"Grenada",GP:"Guadeloupe",GU:"Guam",GT:"Guatemala",GN:"Guinea",GW:"Guinea-Bissau",GY:"Guyana",HT:"Haiti",HM:"Heard Island and McDonald Islands",VA:"Holy See (Vatican City State)",HN:"Honduras",HK:"Hong Kong",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:["Islamic Republic of Iran","Iran"],IQ:"Iraq",IE:"Ireland",IL:"Israel",IT:"Italy",JM:"Jamaica",JP:"Japan",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KI:"Kiribati",KP:"North Korea",KR:["South Korea","Korea, Republic of","Republic of Korea"],KW:"Kuwait",KG:"Kyrgyzstan",LA:"Lao People's Democratic Republic",LV:"Latvia",LB:"Lebanon",LS:"Lesotho",LR:"Liberia",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MO:"Macao",MG:"Madagascar",MW:"Malawi",MY:"Malaysia",MV:"Maldives",ML:"Mali",MT:"Malta",MH:"Marshall Islands",MQ:"Martinique",MR:"Mauritania",MU:"Mauritius",YT:"Mayotte",MX:"Mexico",FM:"Micronesia, Federated States of",MD:"Moldova, Republic of",MC:"Monaco",MN:"Mongolia",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NR:"Nauru",NP:"Nepal",NL:["Netherlands","The Netherlands","Netherlands (Kingdom of the)"],NC:"New Caledonia",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NU:"Niue",NF:"Norfolk Island",MK:["The Republic of North Macedonia","North Macedonia"],MP:"Northern Mariana Islands",NO:"Norway",OM:"Oman",PK:"Pakistan",PW:"Palau",PS:["State of Palestine","Palestine"],PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PN:["Pitcairn","Pitcairn Islands"],PL:"Poland",PT:"Portugal",PR:"Puerto Rico",QA:"Qatar",RE:"Reunion",RO:"Romania",RU:["Russian Federation","Russia"],RW:"Rwanda",SH:"Saint Helena",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SK:"Slovakia",SI:"Slovenia",SB:"Solomon Islands",SO:"Somalia",ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Eswatini",SE:"Sweden",CH:"Switzerland",SY:"Syrian Arab Republic",TW:["Taiwan, Province of China","Taiwan"],TJ:"Tajikistan",TZ:["United Republic of Tanzania","Tanzania"],TH:"Thailand",TL:"Timor-Leste",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:["T\xFCrkiye","Turkey"],TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",UG:"Uganda",UA:"Ukraine",AE:["United Arab Emirates","UAE"],GB:["United Kingdom","UK","Great Britain"],US:["United States of America","United States","USA","U.S.A.","US","U.S."],UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela",VN:"Vietnam",VG:"Virgin Islands, British",VI:"Virgin Islands, U.S.",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe",AX:["\xC5land Islands","Aland Islands"],BQ:"Bonaire, Sint Eustatius and Saba",CW:"Cura\xE7ao",GG:"Guernsey",IM:"Isle of Man",JE:"Jersey",ME:"Montenegro",BL:"Saint Barth\xE9lemy",MF:"Saint Martin (French part)",RS:"Serbia",SX:"Sint Maarten (Dutch part)",SS:"South Sudan",XK:"Kosovo"}};var zo=i=>i.split("-")[0],Ar={en:Ho},Wc=Object.keys(Ho.countries).sort((i,t)=>i.localeCompare(t));function qc(i,t){let e=zo(t),r=Ar[t]?.countries??Ar[e]?.countries;if(!r)return"";let o=r[i];return o?Array.isArray(o)?o[1]:o:""}function Jc(){return Wc}function Ko(i){let t=zo(i);return Jc().map(e=>[e,qc(e,i)]).sort(([,e],[,r])=>e.localeCompare(r,t))}async function xs(i){let t=zo(i);if(Ar[i]||Ar[t])return!0;try{let e=await import(`i18n-iso-countries/langs/${t}.json`);return Ar[t]=e.default||e,!0}catch{return!1}}var Go={firstName:"firstName",lastName:"lastName",addressLine1:"addressLine1",addressLine2:"addressLine2",city:"city",postalCode:"postalCode",state:"state",countryCode:"countryCode"},oe=class extends v{constructor(){super(...arguments);this.configuration=null;this.headlessUtils=null;this.formData={};this.errors={};this.touchedFields=new Set;this.dirtyFields=new Set;this.focusedField=null;this.submitted=!1;this.countryOptions=[];this._initializationTask=new D(this,{task:async([e,r])=>{if(!e||!r)return R;let o=this.extractFieldConfig(e);return await this.initializeCountryOptions(),o},args:()=>[this.configuration,this.headlessUtils]})}connectedCallback(){super.connectedCallback(),this._initializationTask.value}extractFieldConfig(e){if(e?.checkoutModules){let r=e.checkoutModules.find(o=>o.type==="BILLING_ADDRESS");if(r?.options){let o=r.options;return Object.keys(Go).reduce((n,a)=>({...n,[a]:o[a]??!1}),{})}}return this.defaultFieldConfig}async initializeCountryOptions(){try{let e=Ko("en");this.countryOptions=[...e.map(([n,a])=>({value:n,label:a}))],this.requestUpdate("countryOptions");let r=_o();if(r==="en"||r==="en-GB"||r.startsWith("en-"))return;if(await xs(r)){let n=Ko(r);this.countryOptions=[...n.map(([a,s])=>({value:a,label:s}))],this.requestUpdate("countryOptions")}}catch(e){P.errorWithDatadog("Failed to load country locale",{error:e})}}get fieldConfig(){return this.extractFieldConfig(this.configuration)}get defaultFieldConfig(){return Object.keys(Go).reduce((e,r)=>({...e,[r]:!1}),{})}get shouldShowForm(){return this.fieldConfig.postalCode}handleInput(e,r){this.formData={...this.formData,[e]:r},this.dirtyFields.add(e),(this.submitted||this.dirtyFields.has(e)&&this.touchedFields.has(e))&&this.validateField(e),this.dispatchEvent(new CustomEvent("primer-billing-address-change",{detail:this.formData,bubbles:!0,composed:!0}))}handleFocus(e){this.focusedField=e}handleBlur(e){this.focusedField=null,this.touchedFields.add(e),this.validateField(e)}validateField(e){let r=this.formData[e],o=this.fieldConfig[e];if(!o){delete this.errors[e];return}if(o&&(!r||r.trim()==="")){let n=`${e}ErrorRequired`;this.errors={...this.errors,[e]:E("This field is required",{id:n})}}else{let n={...this.errors};delete n[e],this.errors=n}}validateForm(){return Object.keys(Go).forEach(e=>{let r=e;this.fieldConfig[r]&&this.validateField(r)}),Object.keys(this.errors).length===0}async validateForSubmission(){if(!this.shouldShowForm)return!0;this.submitted=!0,Object.keys(this.fieldConfig).forEach(r=>{this.fieldConfig[r]&&this.touchedFields.add(r)});let e=this.validateForm();return this.requestUpdate(),await this.updateComplete,e}async submitToSDK(){if(this.headlessUtils?.setBillingAddress)try{return await this.headlessUtils.setBillingAddress(this.formData),this.dispatchEvent(new CustomEvent("primer-billing-address-submit",{detail:this.formData,bubbles:!0,composed:!0})),!0}catch(e){return P.errorWithDatadog("Failed to set billing address",{error:e}),!1}return!0}shouldShowError(e){let r=!!this.errors[e],o=this.dirtyFields.has(e),n=this.touchedFields.has(e);return r&&(this.submitted||o&&n)}render(){return this._initializationTask.render({pending:()=>g,error:()=>g,complete:()=>this.shouldShowForm?(this.removeAttribute("hidden"),m`<div class="billing-address-form"><div class="billing-address-title">${E("Billing address",{id:"billingAddressLabel"})}</div>${k(this.fieldConfig.countryCode,()=>m`<primer-input-wrapper .focusWithin=${this.focusedField==="countryCode"} .hasError=${this.shouldShowError("countryCode")} ><primer-input-label slot="label">${E("Country code",{id:"countryCodeLabel"})}</primer-input-label><primer-select slot="input" id="countryCode" name="countryCode" .value=${this.formData.countryCode||""} .options=${this.countryOptions} .hasError=${this.shouldShowError("countryCode")} placeholder=${E("Select a country",{id:"countrySelectPlaceholder"})} @input=${e=>this.handleInput("countryCode",e.detail)} @focus=${()=>this.handleFocus("countryCode")} @blur=${()=>this.handleBlur("countryCode")} ></primer-select>${k(this.shouldShowError("countryCode"),()=>m`<primer-input-error slot="error">${this.errors.countryCode}</primer-input-error>`)}</primer-input-wrapper>`)} ${k(this.fieldConfig.firstName||this.fieldConfig.lastName,()=>m`<div class="billing-address-row">${k(this.fieldConfig.firstName,()=>m`<primer-input-wrapper .focusWithin=${this.focusedField==="firstName"} .hasError=${this.shouldShowError("firstName")} ><primer-input-label slot="label">${E("First name",{id:"firstNameLabel"})}</primer-input-label><primer-input slot="input" id="firstName" name="firstName" type="text" .value=${this.formData.firstName||""} placeholder=${E("First name",{id:"firstNamePlaceholder"})} @input=${e=>this.handleInput("firstName",e.detail)} @focus=${()=>this.handleFocus("firstName")} @blur=${()=>this.handleBlur("firstName")} ></primer-input>${k(this.shouldShowError("firstName"),()=>m`<primer-input-error slot="error">${this.errors.firstName}</primer-input-error>`)}</primer-input-wrapper>`)} ${k(this.fieldConfig.lastName,()=>m`<primer-input-wrapper .focusWithin=${this.focusedField==="lastName"} .hasError=${this.shouldShowError("lastName")} ><primer-input-label slot="label">${E("Last name",{id:"lastNameLabel"})}</primer-input-label><primer-input slot="input" id="lastName" name="lastName" type="text" .value=${this.formData.lastName||""} placeholder=${E("Last name",{id:"lastNamePlaceholder"})} @input=${e=>this.handleInput("lastName",e.detail)} @focus=${()=>this.handleFocus("lastName")} @blur=${()=>this.handleBlur("lastName")} ></primer-input>${k(this.shouldShowError("lastName"),()=>m`<primer-input-error slot="error">${this.errors.lastName}</primer-input-error>`)}</primer-input-wrapper>`)}</div>`)} ${k(this.fieldConfig.addressLine1,()=>m`<primer-input-wrapper .focusWithin=${this.focusedField==="addressLine1"} .hasError=${this.shouldShowError("addressLine1")} ><primer-input-label slot="label">${E("Address line 1",{id:"addressLine1"})}</primer-input-label><primer-input slot="input" id="addressLine1" name="addressLine1" type="text" .value=${this.formData.addressLine1||""} placeholder=${E("Address line 1",{id:"addressLine1Placeholder"})} @input=${e=>this.handleInput("addressLine1",e.detail)} @focus=${()=>this.handleFocus("addressLine1")} @blur=${()=>this.handleBlur("addressLine1")} ></primer-input>${k(this.shouldShowError("addressLine1"),()=>m`<primer-input-error slot="error">${this.errors.addressLine1}</primer-input-error>`)}</primer-input-wrapper>`)} ${k(this.fieldConfig.addressLine2,()=>m`<primer-input-wrapper .focusWithin=${this.focusedField==="addressLine2"} .hasError=${this.shouldShowError("addressLine2")} ><primer-input-label slot="label">${E("Address line 2",{id:"addressLine2"})}</primer-input-label><primer-input slot="input" id="addressLine2" name="addressLine2" type="text" .value=${this.formData.addressLine2||""} placeholder=${E("Address line 2",{id:"addressLine2Placeholder"})} @input=${e=>this.handleInput("addressLine2",e.detail)} @focus=${()=>this.handleFocus("addressLine2")} @blur=${()=>this.handleBlur("addressLine2")} ></primer-input>${k(this.shouldShowError("addressLine2"),()=>m`<primer-input-error slot="error">${this.errors.addressLine2}</primer-input-error>`)}</primer-input-wrapper>`)} ${k(this.fieldConfig.postalCode||this.fieldConfig.city,()=>m`<div class="billing-address-row">${k(this.fieldConfig.postalCode,()=>m`<primer-input-wrapper .focusWithin=${this.focusedField==="postalCode"} .hasError=${this.shouldShowError("postalCode")} ><primer-input-label slot="label">${E("Postal code",{id:"postalCodeLabel"})}</primer-input-label><primer-input slot="input" id="postalCode" name="postalCode" type="text" .value=${this.formData.postalCode||""} placeholder=${E("90210",{id:"postalCodePlaceholder"})} @input=${e=>this.handleInput("postalCode",e.detail)} @focus=${()=>this.handleFocus("postalCode")} @blur=${()=>this.handleBlur("postalCode")} ></primer-input>${k(this.shouldShowError("postalCode"),()=>m`<primer-input-error slot="error">${this.errors.postalCode}</primer-input-error>`)}</primer-input-wrapper>`)} ${k(this.fieldConfig.city,()=>m`<primer-input-wrapper .focusWithin=${this.focusedField==="city"} .hasError=${this.shouldShowError("city")} ><primer-input-label slot="label">${E("City",{id:"cityLabel"})}</primer-input-label><primer-input slot="input" id="city" name="city" type="text" .value=${this.formData.city||""} placeholder=${E("Cape Town",{id:"cityPlaceholder"})} @input=${e=>this.handleInput("city",e.detail)} @focus=${()=>this.handleFocus("city")} @blur=${()=>this.handleBlur("city")} ></primer-input>${k(this.shouldShowError("city"),()=>m`<primer-input-error slot="error">${this.errors.city}</primer-input-error>`)}</primer-input-wrapper>`)}</div>`)} ${k(this.fieldConfig.state,()=>m`<primer-input-wrapper .focusWithin=${this.focusedField==="state"} .hasError=${this.shouldShowError("state")} ><primer-input-label slot="label">${E("State / Region / County",{id:"stateLabel"})}</primer-input-label><primer-input slot="input" id="state" name="state" type="text" .value=${this.formData.state||""} placeholder=${E("State / Region / County",{id:"statePlaceholder"})} @input=${e=>this.handleInput("state",e.detail)} @focus=${()=>this.handleFocus("state")} @blur=${()=>this.handleBlur("state")} ></primer-input>${k(this.shouldShowError("state"),()=>m`<primer-input-error slot="error">${this.errors.state}</primer-input-error>`)}</primer-input-wrapper>`)}</div>`):(this.setAttribute("hidden",""),g)})}};oe.styles=[_,Ps],d([C({context:Br,subscribe:!0}),p({attribute:!1})],oe.prototype,"configuration",2),d([C({context:H,subscribe:!0}),p({attribute:!1})],oe.prototype,"headlessUtils",2),d([M()],oe.prototype,"formData",2),d([M()],oe.prototype,"errors",2),d([M()],oe.prototype,"touchedFields",2),d([M()],oe.prototype,"dirtyFields",2),d([M()],oe.prototype,"focusedField",2),d([M()],oe.prototype,"submitted",2),d([M()],oe.prototype,"countryOptions",2),oe=d([b("primer-billing-address"),O()],oe);function _s(i){return i.paymentInstrumentType===Nt.CARD}async function _i(i,t,e){if(!i||!t||!e)return{icon:"",shouldShowCVV:!1,type:"other",description:""};let r="";if(_s(i))r=t.getCardNetworkAsset(i.paymentInstrumentData.network).cardUrl;else{let a=await t.getCDNAssets(i.paymentMethodType);a&&a.assets?.icon&&(r=a.assets.icon)}let o=e.cvvRecapture,n=jo(i);return{icon:r,shouldShowCVV:o,...n}}function Ts(i){return i.charAt(0).toUpperCase()+i.slice(1).toLowerCase()}function Zc(i){return i?i===i.toUpperCase()?Ts(i):i:""}function Ms(i,t){return[i,t].filter(Boolean).join(" ")}function Xc(i,t){return!i||!t?"":`Expires ${i}/${t.slice(-2)}`}function ws(i){return i?`\u2022\u2022\u2022\u2022 ${i}`:""}function Qc(i){let t=i.paymentInstrumentData,e=t.cardholderName,r=t.last4Digits,o=Xc(t.expirationMonth,t.expirationYear),n=Zc(t.network),a=`${i.paymentInstrumentData.cardholderName?i.paymentInstrumentData.cardholderName:""}${(r?` ${n} ${ws(r)}`:n)||" Card"}`;return{type:"card",cardholderName:e,last4:r,expiresDate:o,network:n,description:a}}function ep(i){let t=i.paymentInstrumentData,e=t.externalPayerInfo?.email||"",r=t.externalPayerInfo?.firstName||"",o=t.externalPayerInfo?.lastName||"",n=i.userDescription||e||"PayPal Account";return{type:"paypal",fullName:Ms(r,o),email:e,paymentMethodType:"PayPal",description:n}}function tp(i){let t=i.paymentInstrumentData,e=t.sessionData?.billingAddress?.email||"",r=t.sessionData?.billingAddress?.firstName||"",o=t.sessionData?.billingAddress?.lastName||"",n=i.userDescription||(e?`Klarna - ${e}`:"Klarna Account");return{type:"other",fullName:Ms(r,o),email:e,paymentMethodType:"Klarna",description:n}}function rp(i){let t=i.paymentInstrumentData,e=t.accountNumberLastFourDigits||"",r=t.bankName||"",o=t.accountType||"",n=i.userDescription;return n||(r&&e?n=`${r} ${ws(e)}`:r?n=r:n="Bank Account"),{type:"other",fullName:"",bankName:r,last4:e,accountType:o,paymentMethodType:"ACH",description:n}}function ip(i){let t=i.paymentInstrumentType,e=Ts(t.replace(/_/g," "));return{type:"other",description:i.userDescription||e}}var op={[Nt.CARD]:Qc,[Nt.PAYPAL_VAULTED]:ep,[Nt.KLARNA_CUSTOMER_TOKEN]:tp,[Nt.AUTOMATED_CLEARING_HOUSE]:rp};function jo(i){try{let t=op[i.paymentInstrumentType];return t?t(i):ip(i)}catch(t){return P.errorWithDatadog(`FormatUtils: Error formatting payment method ${i.id}`,{error:t}),{type:"other",description:i.userDescription||i.id||"Payment Method"}}}var Is=y` :host { display: block; width: 100%; position: relative; } .vault-manager { display: flex; flex-direction: column; position: relative; } .vault-manager-content { display: flex; flex-direction: column; width: 100%; position: relative; } /* Content container using CSS Grid for height animation */ .content-container { display: grid; grid-template-rows: 1fr; transition: grid-template-rows var(--primer-animation-duration) var(--primer-animation-easing); width: 100%; position: relative; } /* Required to make grid animation work - ensures content can expand/collapse properly */ .content-container > * { min-height: 0; overflow: hidden; } /* Submit button container */ .submit-button-container { display: grid; grid-template-rows: 1fr; transition: grid-template-rows var(--primer-animation-duration) var(--primer-animation-easing); overflow: hidden; margin-top: var(--primer-space-small); width: 100%; } /* Ensure the submit button has full width */ .submit-button { width: 100%; } /* Make sure pay button inside the submit component is full width */ primer-vault-payment-submit::part(button), ::slotted(primer-button) { width: 100%; } /* Payment methods list */ .payment-methods-list { display: flex; flex-direction: column; gap: var(--primer-space-small); width: 100%; position: relative; } /* Delete confirmation container */ .delete-confirmation-container { width: 100%; position: relative; display: flex; flex-direction: column; gap: var(--primer-space-small); } /* Loading overlay styles */ .loading-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background-color: rgba(255, 255, 255, 0.7); z-index: 10; border-radius: var(--primer-radius-medium); backdrop-filter: blur(2px); opacity: 0; /* Start invisible */ } /* Add styles for when updating is active */ .is-updating { pointer-events: none; /* Prevent interaction when updating */ } /* * Component-specific styles to ensure smooth animations * These components need display:block to work with the grid layout */ primer-vault-payment-method-item, primer-vault-empty-state, primer-vault-delete-confirmation { display: block; width: 100%; } /* Disable animations for reduced motion preference */ @media (prefers-reduced-motion: reduce) { .content-container, .submit-button-container, primer-vault-payment-method-item, primer-vault-payment-submit, primer-vault-empty-state, primer-vault-delete-confirmation { transition: none; } } primer-button::part(button) { align-items: center; width: 100%; justify-content: flex-start; display: flex; text-align: left; padding: var(--primer-space-medium); } `;var Ti=new WeakMap,Wt=class{constructor(t,e){this.startPaused=!1,this.disabled=!1,this.clients=new Set,this.pendingComplete=!1,this.host=t,this.defaultOptions=e.defaultOptions||{},this.startPaused=!!e.startPaused,this.disabled=!!e.disabled,this.onComplete=e.onComplete,Ti.set(this.host,this)}async add(t){this.clients.add(t),this.startPaused&&t.webAnimation?.pause(),this.pendingComplete=!0,await t.finished,this.pendingComplete&&!this.isAnimating&&(this.pendingComplete=!1,this.onComplete?.())}remove(t){this.clients.delete(t)}pause(){this.clients.forEach((t=>t.webAnimation?.pause()))}play(){this.clients.forEach((t=>t.webAnimation?.play()))}cancel(){this.clients.forEach((t=>t.webAnimation?.cancel())),this.clients.clear()}finish(){this.clients.forEach((t=>t.webAnimation?.finish())),this.clients.clear()}togglePlay(){this.isPlaying?this.pause():this.play()}get isAnimating(){return this.clients.size>0}get isPlaying(){return Array.from(this.clients).some((t=>t.webAnimation?.playState==="running"))}async finished(){await Promise.all(Array.from(this.clients).map((t=>t.finished)))}};var ks=0,Wo=new Map,Ns=new WeakSet,qo=()=>new Promise((i=>requestAnimationFrame(i)));var Ls=(i,t)=>{let e=i-t;return e===0?void 0:e},Rs=(i,t)=>{let e=i/t;return e===1?void 0:e},Mi={left:(i,t)=>{let e=Ls(i,t);return{value:e,transform:e==null||isNaN(e)?void 0:`translateX(${e}px)`}},top:(i,t)=>{let e=Ls(i,t);return{value:e,transform:e==null||isNaN(e)?void 0:`translateY(${e}px)`}},width:(i,t)=>{let e;t===0&&(t=1,e={width:"1px"});let r=Rs(i,t);return{value:r,overrideFrom:e,transform:r==null||isNaN(r)?void 0:`scaleX(${r})`}},height:(i,t)=>{let e;t===0&&(t=1,e={height:"1px"});let r=Rs(i,t);return{value:r,overrideFrom:e,transform:r==null||isNaN(r)?void 0:`scaleY(${r})`}}},Ds={duration:333,easing:"ease-in-out"},$s=["left","top","width","height","opacity","color","background"],Os=new WeakMap,wi=class extends gt{constructor(t){if(super(t),this.t=!1,this.i=null,this.o=null,this.h=!0,this.shouldLog=!1,t.type===Z.CHILD)throw Error("The `animate` directive must be used in attribute position.");this.createFinished()}createFinished(){this.resolveFinished?.(),this.finished=new Promise((t=>{this.l=t}))}async resolveFinished(){this.l?.(),this.l=void 0}render(t){return g}getController(){return Ti.get(this.u)}isDisabled(){return this.options.disabled||this.getController()?.disabled}update(t,[e]){let r=this.u===void 0;return r&&(this.u=t.options?.host,this.u.addController(this),this.u.updateComplete.then((o=>this.t=!0)),this.element=t.element,Os.set(this.element,this)),this.optionsOrCallback=e,(r||typeof e!="function")&&this.p(e),this.render(e)}p(t){t=t??{};let e=this.getController();e!==void 0&&((t={...e.defaultOptions,...t}).keyframeOptions={...e.defaultOptions.keyframeOptions,...t.keyframeOptions}),t.properties??(t.properties=$s),this.options=t}m(){let t={},e=this.element.getBoundingClientRect(),r=getComputedStyle(this.element);return this.options.properties.forEach((o=>{let n=e[o]??(Mi[o]?void 0:r[o]),a=Number(n);t[o]=isNaN(a)?n+"":a})),t}v(){let t,e=!0;return this.options.guard&&(t=this.options.guard(),e=((r,o)=>{if(Array.isArray(r)){if(Array.isArray(o)&&o.length===r.length&&r.every(((n,a)=>n===o[a])))return!1}else if(o===r)return!1;return!0})(t,this._)),this.h=this.t&&!this.isDisabled()&&!this.isAnimating()&&e&&this.element.isConnected,this.h&&(this._=Array.isArray(t)?Array.from(t):t),this.h}hostUpdate(){typeof this.optionsOrCallback=="function"&&this.p(this.optionsOrCallback()),this.v()&&(this.A=this.m(),this.i=this.i??this.element.parentNode,this.o=this.element.nextSibling)}async hostUpdated(){if(!this.h||!this.element.isConnected||this.options.skipInitial&&!this.isHostRendered)return;let t;this.prepare(),await qo;let e=this.O(),r=this.j(this.options.keyframeOptions,e),o=this.m();if(this.A!==void 0){let{from:n,to:a}=this.N(this.A,o,e);this.log("measured",[this.A,o,n,a]),t=this.calculateKeyframes(n,a)}else{let n=Wo.get(this.options.inId);if(n){Wo.delete(this.options.inId);let{from:a,to:s}=this.N(n,o,e);t=this.calculateKeyframes(a,s),t=this.options.in?[{...this.options.in[0],...t[0]},...this.options.in.slice(1),t[1]]:t,ks++,t.forEach((l=>l.zIndex=ks))}else this.options.in&&(t=[...this.options.in,{}])}this.animate(t,r)}resetStyles(){this.P!==void 0&&(this.element.setAttribute("style",this.P??""),this.P=void 0)}commitStyles(){this.P=this.element.getAttribute("style"),this.webAnimation?.commitStyles(),this.webAnimation?.cancel()}reconnected(){}async disconnected(){if(!this.h||(this.options.id!==void 0&&Wo.set(this.options.id,this.A),this.options.out===void 0))return;if(this.prepare(),await qo(),this.i?.isConnected){let e=this.o&&this.o.parentNode===this.i?this.o:null;if(this.i.insertBefore(this.element,e),this.options.stabilizeOut){let r=this.m();this.log("stabilizing out");let o=this.A.left-r.left,n=this.A.top-r.top;getComputedStyle(this.element).position!=="static"||o===0&&n===0||(this.element.style.position="relative"),o!==0&&(this.element.style.left=o+"px"),n!==0&&(this.element.style.top=n+"px")}}let t=this.j(this.options.keyframeOptions);await this.animate(this.options.out,t),this.element.remove()}prepare(){this.createFinished()}start(){this.options.onStart?.(this)}didFinish(t){t&&this.options.onComplete?.(this),this.A=void 0,this.animatingProperties=void 0,this.frames=void 0,this.resolveFinished()}O(){let t=[];for(let e=this.element.parentNode;e;e=e?.parentNode){let r=Os.get(e);r&&!r.isDisabled()&&r&&t.push(r)}return t}get isHostRendered(){let t=Ns.has(this.u);return t||this.u.updateComplete.then((()=>{Ns.add(this.u)})),t}j(t,e=this.O()){let r={...Ds};return e.forEach((o=>Object.assign(r,o.options.keyframeOptions))),Object.assign(r,t),r}N(t,e,r){t={...t},e={...e};let o=r.map((s=>s.animatingProperties)).filter((s=>s!==void 0)),n=1,a=1;return o.length>0&&(o.forEach((s=>{s.width&&(n/=s.width),s.height&&(a/=s.height)})),t.left!==void 0&&e.left!==void 0&&(t.left=n*t.left,e.left=n*e.left),t.top!==void 0&&e.top!==void 0&&(t.top=a*t.top,e.top=a*e.top)),{from:t,to:e}}calculateKeyframes(t,e,r=!1){let o={},n={},a=!1,s={};for(let l in e){let c=t[l],u=e[l];if(l in Mi){let f=Mi[l];if(c===void 0||u===void 0)continue;let h=f(c,u);h.transform!==void 0&&(s[l]=h.value,a=!0,o.transform=`${o.transform??""} ${h.transform}`,h.overrideFrom!==void 0&&Object.assign(o,h.overrideFrom))}else c!==u&&c!==void 0&&u!==void 0&&(a=!0,o[l]=c,n[l]=u)}return o.transformOrigin=n.transformOrigin=r?"center center":"top left",this.animatingProperties=s,a?[o,n]:void 0}async animate(t,e=this.options.keyframeOptions){this.start(),this.frames=t;let r=!1;if(!this.isAnimating()&&!this.isDisabled()&&(this.options.onFrames&&(this.frames=t=this.options.onFrames(this),this.log("modified frames",t)),t!==void 0)){this.log("animate",[t,e]),r=!0,this.webAnimation=this.element.animate(t,e);let o=this.getController();o?.add(this);try{await this.webAnimation.finished}catch{}o?.remove(this)}return this.didFinish(r),r}isAnimating(){return this.webAnimation?.playState==="running"||this.webAnimation?.pending}log(t,e){this.shouldLog&&this.isDisabled()}},yt=Ce(wi);var np=["top","right","bottom","left"],Ii=class extends gt{constructor(t){if(super(t),t.type!==Z.ELEMENT)throw Error("The `position` directive must be used in attribute position.")}render(t,e){return g}update(t,[e,r]){return this.u===void 0&&(this.u=t.options?.host,this.u.addController(this)),this.S=t.element,this.C=e,this.F=r??["left","top","width","height"],this.render(e,r)}hostUpdated(){this.$()}$(){let t=typeof this.C=="function"?this.C():this.C?.value,e=t.offsetParent;if(t===void 0||!e)return;let r=t.getBoundingClientRect(),o=e.getBoundingClientRect();this.F?.forEach((n=>{let a=np.includes(n)?r[n]-o[n]:r[n];this.S.style[n]=a+"px"}))}},ap=Ce(Ii);var ne=class extends v{constructor(){super();this.vaultManagerContext=null;this.vaultItemContext=null;this.headlessUtils=null;this.isEditMode=!1;this.deletePaymentMethodId=null;this.isDeleting=!1;this.errorMessage="";this.animationDuration=300;this.deleteAssetConfig=null;this.handleToggleEditMode=e=>{this.isEditMode=e.detail,this.deletePaymentMethodId=null,this.isEditMode&&this.vaultItemContext&&this.vaultItemContext.setSelectedVaultedPaymentMethod(null)};this.handleDeletePaymentMethod=async e=>{if(this.deletePaymentMethodId=e.detail,this.deletePaymentMethodId&&this.vaultManagerContext&&this.headlessUtils){let r=this.vaultManagerContext.vaultedPaymentMethods.find(o=>o.id===this.deletePaymentMethodId);r&&(this.deleteAssetConfig=await _i(r,this.headlessUtils,this.vaultManagerContext))}};this.handleCancelDelete=()=>{this.deletePaymentMethodId=null,this.deleteAssetConfig=null};this.handleConfirmDelete=async()=>{if(!this.vaultManagerContext?.deleteVaultedPaymentMethod||!this.deletePaymentMethodId){this.errorMessage=E("something_went_wrong_error",{id:"something_went_wrong_error"});return}try{this.isDeleting=!0,await this.vaultManagerContext.deleteVaultedPaymentMethod(this.deletePaymentMethodId),this.deletePaymentMethodId=null,this.deleteAssetConfig=null}catch(e){this.errorMessage=e instanceof Error?e.message:E("something_went_wrong_error",{id:"something_went_wrong_error"})}finally{this.isDeleting=!1}};this.handlePaymentError=e=>{let r=e.detail?.error;this.errorMessage=r instanceof Error?r.message:E("payment_processing_error",{id:"payment_processing_error"})};this.handleCloseError=()=>{this.errorMessage=""};new Wt(this,{defaultOptions:{keyframeOptions:{duration:Number(getComputedStyle(document.documentElement).getPropertyValue("--primer-animation-duration").trim().replace("ms","")),easing:getComputedStyle(document.documentElement).getPropertyValue("--primer-animation-easing").trim()}}})}getAnimationConfig(){return{keyframeOptions:{duration:this.animationDuration,easing:getComputedStyle(document.documentElement).getPropertyValue("--primer-animation-easing").trim(),fill:"both"}}}getPaymentMethodName(e){if(!this.vaultManagerContext)return"";let r=this.vaultManagerContext.vaultedPaymentMethods.find(o=>o.id===e);if(!r)return"";try{return jo(r).description||""}catch{return""}}renderLoadingOverlay(){return m`<div class="loading-overlay" ${yt({...this.getAnimationConfig(),properties:["opacity"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ><primer-spinner size="medium" color="var(--primer-color-loader)" ></primer-spinner></div>`}renderDeleteConfirmation(){if(!this.deletePaymentMethodId||!this.deleteAssetConfig)return g;let e=this.getPaymentMethodName(this.deletePaymentMethodId);return m`<div class="delete-confirmation-container"><primer-button disabled variant="secondary"><primer-payment-method-content .assetConfig=${this.deleteAssetConfig} ></primer-payment-method-content></primer-button><primer-vault-delete-confirmation .isDeleting=${this.isDeleting} .paymentMethodId=${this.deletePaymentMethodId} .paymentMethodName=${e} @confirm-delete=${this.handleConfirmDelete} @cancel-delete=${this.handleCancelDelete} ${yt({...this.getAnimationConfig(),properties:["opacity"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ></primer-vault-delete-confirmation></div>`}renderPaymentMethodItem(e){return this.deletePaymentMethodId===e.id?g:m`<primer-vault-payment-method-item .paymentMethod=${e} .isEditMode=${this.isEditMode} @delete-payment-method=${this.handleDeletePaymentMethod} ${yt({...this.getAnimationConfig(),properties:["opacity"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ></primer-vault-payment-method-item>`}renderPaymentMethodList(){let e=this.vaultManagerContext?.vaultedPaymentMethods||[],r=!this.isEditMode&&e.length>0&&!this.deletePaymentMethodId;return m`<div class="payment-methods-list">${e.map(o=>this.renderPaymentMethodItem(o))} ${k(r,()=>m`<div class="submit-button-container"><primer-vault-payment-submit class="submit-button" @primer-vault-payment-error=${this.handlePaymentError} ${yt({...this.getAnimationConfig(),properties:["opacity"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ></primer-vault-payment-submit></div>`,()=>g)}</div>`}render(){if(!this.vaultManagerContext?.enabled)return g;let e=this.vaultManagerContext.vaultedPaymentMethods.length>0,r=this.vaultManagerContext.isLoading,o=this.vaultManagerContext.isUpdating;return m` ${k(!this.vaultManagerContext?.showEmptyState&&!e,()=>g,()=>m`<slot name="vault-empty-state"><div class="vault-manager ${o?"is-updating":""}"><primer-vault-manager-header .isEditMode=${this.isEditMode} .hasPaymentMethods=${e} @toggle-edit-mode=${this.handleToggleEditMode} ></primer-vault-manager-header>${k(this.errorMessage,()=>m`<primer-vault-error-message .errorMessage=${this.errorMessage} @close-error=${this.handleCloseError} ${yt({...this.getAnimationConfig(),properties:["opacity"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ></primer-vault-error-message>`,()=>g)}<div class="vault-manager-content">${k(!r&&!e,()=>m`<div class="content-container"><primer-vault-empty-state ${yt({...this.getAnimationConfig(),properties:["opacity"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ></primer-vault-empty-state></div>`,()=>g)} ${k(!r&&e,()=>m`<div class="content-container">${k(this.deletePaymentMethodId,()=>this.renderDeleteConfirmation(),()=>this.renderPaymentMethodList())}</div>`,()=>g)}</div>${k(o,()=>this.renderLoadingOverlay(),()=>g)}</div></slot>`)} `}};ne.styles=[_,Is],d([C({context:ue,subscribe:!0}),p({type:Object,attribute:!1})],ne.prototype,"vaultManagerContext",2),d([C({context:Oe,subscribe:!0}),p({type:Object,attribute:!1})],ne.prototype,"vaultItemContext",2),d([C({context:H,subscribe:!0}),p({type:Object,attribute:!1})],ne.prototype,"headlessUtils",2),d([M()],ne.prototype,"isEditMode",2),d([M()],ne.prototype,"deletePaymentMethodId",2),d([M()],ne.prototype,"isDeleting",2),d([M()],ne.prototype,"errorMessage",2),d([p({type:Number})],ne.prototype,"animationDuration",2),d([M()],ne.prototype,"deleteAssetConfig",2),ne=d([b("primer-vault-manager"),O()],ne);var Vs=y` :host { display: flex; width: 100%; flex-direction: column; } .payment-method-wrapper { display: flex; flex-direction: column; width: 100%; } .payment-method-container { display: flex; width: 100%; align-items: center; gap: var(--primer-space-small); } /* Target the button part from primer-button with 'with-cvv' class using ::part selector */ primer-button::part(button) { align-items: center; width: 100%; justify-content: flex-start; display: flex; text-align: left; padding: var(--primer-space-medium); } /* render checkmark icon on baseline (on the top) */ primer-button.with-cvv::part(button) { align-items: baseline; } /* Card icons */ .payment-method-icon { height: var(--primer-space-xlarge); object-fit: contain; flex-shrink: 0; transition: transform var(--primer-animation-duration) var(--primer-animation-easing); } .payment-method-icon-generic { display: flex; align-items: center; justify-content: center; color: var(--primer-color-gray-500); height: var(--primer-space-xlarge); flex-shrink: 0; } .payment-method-details { flex: 1; display: flex; gap: var(--primer-space-xsmall); align-items: flex-start; transition: transform var(--primer-animation-duration) var(--primer-animation-easing); margin-left: var(--primer-space-small); } .payment-method-card { flex: 1; width: 100%; display: flex; flex-direction: column; gap: var(--primer-space-xsmall); transition: transform var(--primer-animation-duration) var(--primer-animation-easing); } .payment-method-description { font-weight: var(--primer-typography-title-large-weight); color: var(--primer-color-text-primary); transition: color var(--primer-animation-duration) var(--primer-animation-easing); } .payment-method-secondary-description { font-size: var(--primer-typography-body-small-size); color: var(--primer-color-text-secondary); transition: color var(--primer-animation-duration) var(--primer-animation-easing); } .payment-method-row { display: grid; grid-template-columns: 200px 100px; justify-content: space-between; align-items: center; } .cell-2 { grid-column: 2; display: flex; justify-content: flex-end; align-items: center; } .mt-2 { margin-top: var(--primer-space-medium); } .payment-method-header { font-weight: var(--primer-typography-body-large-weight); font-size: var(--primer-typography-body-large-size); line-height: var(--primer-typography-body-large-line-height); color: var(--primer-color-text-primary); letter-spacing: var(--primer-typography-body-large-letter-spacing); } .payment-method-subtitle { color: var(--primer-color-text-secondary); font-size: var(--primer-typography-body-small-size); line-height: var(--primer-typography-body-small-line-height); font-weight: var(--primer-typography-body-small-weight); letter-spacing: var(--primer-typography-body-small-letter-spacing); } .payment-method-button { flex: 1; } .flex { display: flex; align-items: flex-end; gap: var(--primer-space-xsmall); } .flex-center { display: flex; align-items: center; justify-content: center; gap: var(--primer-space-small); } /* Delete button - for edit mode */ .delete-button { display: flex; align-items: center; justify-content: center; } .delete-button:active { transform: scale(0.95); } `;var be=class extends v{constructor(){super(...arguments);this.vaultManagerContext=null;this.vaultItemContext=null;this.headlessUtils=null;this.paymentMethod=null;this.isEditMode=!1;this._getAssetsTask=new D(this,{task:async([e,r,o])=>await _i(e,r,o),args:()=>[this.paymentMethod,this.headlessUtils,this.vaultManagerContext]});this.handleClick=()=>{this.isEditMode||!this.vaultManagerContext||!this.paymentMethod||(this.isSelected()?this.vaultItemContext?.setSelectedVaultedPaymentMethod(null):this.vaultItemContext?.setSelectedVaultedPaymentMethod(this.paymentMethod))};this.handleDeleteClick=e=>{e.stopPropagation(),this.dispatchEvent(new CustomEvent("delete-payment-method",{detail:this.paymentMethod?.id,bubbles:!0,composed:!0}))}}isSelected(){if(!this.vaultManagerContext||!this.paymentMethod)return!1;let e=this.vaultItemContext?.selectedVaultedPaymentMethod;return!!e&&e.id===this.paymentMethod.id}render(){return this._getAssetsTask.render({error:()=>g,complete:e=>{let r=this.isSelected()?"checked":"default",o=!1,n=e?.description;return m`<div class="payment-method-wrapper"><div class="payment-method-container"><primer-button variant="secondary" class="payment-method-button ${e.shouldShowCVV?"with-cvv":""}" selectable ?disabled=${this.isEditMode} selectionState=${r} .flex=${o} @click=${this.handleClick} ><primer-payment-method-content .assetConfig=${e} ></primer-payment-method-content>${k(e.shouldShowCVV&&this.isSelected()&&!this.isEditMode,()=>m`<div class="payment-method-row mt-2"><span class="flex-center"><primer-icon name="lock" size="sm"></primer-icon><span class="payment-method-subtitle"> Input the card CVV for a secure payment</span ></span><span class="cell-2"><primer-vault-cvv-input .paymentMethod="${this.paymentMethod}" ><span slot="label"></span></primer-vault-cvv-input></span></div>`,()=>g)}</primer-button>${this.isEditMode?m`<primer-button variant="tertiary" class="delete-button" @click=${this.handleDeleteClick} aria-label=${`${E("delete",{id:"delete"})} ${n}`} ><primer-icon name="close" size="sm"></primer-icon></primer-button>`:g}</div></div>`}})}};be.styles=[_,Vs],d([C({context:ue,subscribe:!0}),p({type:Object,attribute:!1,hasChanged(e,r){return e?.cvvRecapture!==r?.cvvRecapture}})],be.prototype,"vaultManagerContext",2),d([C({context:Oe,subscribe:!0}),p({type:Object,attribute:!1,hasChanged(e,r){return e?.selectedVaultedPaymentMethod?.id!==r?.selectedVaultedPaymentMethod?.id}})],be.prototype,"vaultItemContext",2),d([C({context:H,subscribe:!0}),p({type:Object})],be.prototype,"headlessUtils",2),d([p({type:Object,attribute:!1})],be.prototype,"paymentMethod",2),d([p({type:Boolean,reflect:!0})],be.prototype,"isEditMode",2),be=d([b("primer-vault-payment-method-item"),O()],be);var Us=y` :host { display: block; width: 100%; } .vault-manager-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--primer-space-medium); } .vault-manager-header h3 { font-size: var(--primer-typography-title-large-size); font-weight: var(--primer-typography-title-large-weight); font-family: var(--primer-typography-title-large-font); color: var(--primer-color-text-primary); margin: 0; } .edit-button { display: flex; align-items: center; justify-content: center; } `;var Re=class extends v{constructor(){super(...arguments);this.isEditMode=!1;this.hasPaymentMethods=!1;this.toggleEditMode=()=>{this.dispatchEvent(new CustomEvent("toggle-edit-mode",{detail:!this.isEditMode,bubbles:!0,composed:!0}))}}render(){return m`<div class="vault-manager-header"><h3>${E("previouslyUsed",{id:"previouslyUsed"})}</h3>${this.hasPaymentMethods?m`<primer-button variant="tertiary" class="edit-button ${this.isEditMode?"active":""}" @click=${this.toggleEditMode} aria-label=${this.isEditMode?E("confirm",{id:"confirm"}):E("editPaymentMethods",{id:"editPaymentMethods"})} >${this.isEditMode?m`<primer-icon name="checkmark" size="sm"></primer-icon>`:m`<primer-icon name="edit" size="sm"></primer-icon>`}</primer-button>`:g}</div>`}};Re.styles=[_,Us],d([p({type:Boolean})],Re.prototype,"isEditMode",2),d([p({type:Boolean})],Re.prototype,"hasPaymentMethods",2),Re=d([b("primer-vault-manager-header"),O()],Re);var Ys=y` :host { display: block; width: 100%; } .delete-confirmation-text { color: var(--primer-color-text-secondary); font-size: var(--primer-typography-body-small-size); font-weight: var(--primer-typography-body-small-weight); line-height: var(--primer-typography-body-small-line-height); letter-spacing: var(--primer-typography-body-small-letter-spacing); } .delete-confirmation { margin-top: var(--primer-space-medium); background-color: var(--primer-color-gray-000); } .delete-message { margin-bottom: var(--primer-space-medium); } .delete-text { margin: 0; color: var(--primer-color-text-secondary); font-size: var(--primer-typography-body-medium-size); } .delete-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--primer-space-small); } .delete-confirm { background-color: var(--primer-color-red-500); color: var(--primer-color-gray-000); border: none; padding: var(--primer-space-small) var(--primer-space-medium); border-radius: var(--primer-radius-small); font-weight: var(--primer-typography-body-medium-weight); cursor: pointer; transition: background-color var(--primer-animation-duration) var(--primer-animation-easing); } .delete-confirm:hover:not(:disabled) { background-color: var(--primer-color-red-900); } .delete-confirm:disabled { opacity: 0.7; cursor: not-allowed; } .delete-cancel { background-color: transparent; border: 1px solid var(--primer-color-border-outlined-default); padding: var(--primer-space-small) var(--primer-space-medium); border-radius: var(--primer-radius-small); color: var(--primer-color-text-primary); font-weight: var(--primer-typography-body-medium-weight); cursor: pointer; transition: background-color var(--primer-animation-duration) var(--primer-animation-easing); } .delete-cancel:hover:not(:disabled) { background-color: var(--primer-color-gray-100); } .delete-cancel:disabled { opacity: 0.7; cursor: not-allowed; } `;var Pe=class extends v{constructor(){super(...arguments);this.isDeleting=!1;this.paymentMethodId="";this.paymentMethodName="";this.vaultManager=null;this.handleConfirmClick=()=>{this.dispatchEvent(new CustomEvent("confirm-delete",{bubbles:!0,composed:!0}))};this.handleCancelClick=()=>{this.dispatchEvent(new CustomEvent("cancel-delete",{bubbles:!0,composed:!0}))}}render(){return m`<div class="delete-confirmation"><p class="delete-confirmation-text"> Are you sure you want to delete this payment method? </p><div class="delete-actions"><primer-button variant="secondary" @click=${this.handleCancelClick} ?disabled=${this.isDeleting} >${E("cancel",{id:"cancel"})}</primer-button><primer-button @click=${this.handleConfirmClick} ?disabled=${this.isDeleting} >${this.isDeleting?E("deleting",{id:"deleting"}):E("confirmVaultedPaymentMethodDeletion",{id:"confirmVaultedPaymentMethodDeletion"})}</primer-button></div></div>`}};Pe.styles=[_,Ys],d([p({type:Boolean})],Pe.prototype,"isDeleting",2),d([p({type:String})],Pe.prototype,"paymentMethodId",2),d([p({type:String})],Pe.prototype,"paymentMethodName",2),d([C({context:ue,subscribe:!0})],Pe.prototype,"vaultManager",2),Pe=d([b("primer-vault-delete-confirmation"),O()],Pe);var Bs=y` :host { display: block; width: 100%; } .empty-state { padding: var(--primer-space-xlarge) 0; text-align: center; color: var(--primer-color-text-secondary); } .empty-state p { margin: 0; } `;var et=class extends v{render(){return m`<div class="empty-state"><p>${E("savedPaymentMethodsEmpty",{id:"savedPaymentMethodsEmpty"})}</p></div>`}};et.styles=[_,Bs],et=d([b("primer-vault-empty-state"),O()],et);var Fs=y` :host { display: block; width: 100%; } .error-message { display: flex; background-color: var(--primer-color-red-100); padding: var(--primer-space-medium); border-radius: var(--primer-radius-small); margin-bottom: var(--primer-space-medium); justify-content: space-between; align-items: center; border: 1px solid var(--primer-color-red-500); } .error-content { display: flex; align-items: center; gap: var(--primer-space-small); } .error-message p { margin: 0; color: var(--primer-color-text-negative); font-size: var(--primer-typography-body-medium-size); } .error-message button { background: transparent; border: none; color: var(--primer-color-text-negative); cursor: pointer; padding: var(--primer-space-xsmall); display: flex; align-items: center; justify-content: center; border-radius: var(--primer-radius-small); transition: background-color var(--primer-animation-duration) var(--primer-animation-easing); } .error-message button:hover { background-color: rgba(0, 0, 0, 0.05); } `;var Ke=class extends v{constructor(){super(...arguments);this.errorMessage="";this.handleDismiss=()=>{this.dispatchEvent(new CustomEvent("close-error",{bubbles:!0,composed:!0}))}}render(){return m`<div class="error-message"><div class="error-content"><primer-icon name="warning" size="sm" color="var(--primer-color-red-500)" ></primer-icon><p>${this.errorMessage}</p></div><button @click=${this.handleDismiss} aria-label=${E("closeErrorMessage",{id:"closeErrorMessage"})} ><primer-icon name="close" size="sm"></primer-icon></button></div>`}};Ke.styles=[_,Fs],d([p({type:String})],Ke.prototype,"errorMessage",2),Ke=d([b("primer-vault-error-message"),O()],Ke);var Hs=y` :host { display: contents; } `;var X=class extends v{constructor(){super(...arguments);this._userAssignedProps=new Set;this._internalButtonText="";this.headlessInstance=null;this.sdkState=null;this.vaultItemContext=null;this.vaultManager=null;this.clientOptions=null;this.variant="primary";this.disabled=!1;this.handleClick=async e=>{if(e.preventDefault(),!this.isButtonDisabled)try{await this.vaultManager?.startVaultedPaymentFlow()}catch(r){let o=new CustomEvent("primer-vault-payment-error",{bubbles:!0,composed:!0,detail:{error:r}});this.dispatchEvent(o)}}}get buttonText(){return this._userAssignedProps.has("buttonText")?this._internalButtonText:E("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)}get isButtonDisabled(){return!!(this.disabled||!this.vaultItemContext?.selectedVaultedPaymentMethod||this.vaultManager?.isLoading)}render(){let e=this.clientOptions?.submitButton?.amountVisible?this.headlessInstance?.getUIOrderAmount():null,r=e?` ${e}`:g;return m`<primer-button buttonType="submit" variant=${this.variant} @click=${this.handleClick} .disabled=${this.isButtonDisabled} .loading=${this.sdkState?.isProcessing} data-submit >${this.buttonText}${r}</primer-button>`}};X.styles=[_,Hs],d([p({type:String})],X.prototype,"buttonText",1),d([C({context:H,subscribe:!0}),p({type:Object})],X.prototype,"headlessInstance",2),d([C({context:G,subscribe:!0}),p()],X.prototype,"sdkState",2),d([C({context:Oe,subscribe:!0}),p({type:Object,attribute:!1,hasChanged(e,r){return e?.selectedVaultedPaymentMethod?.id!==r?.selectedVaultedPaymentMethod?.id}})],X.prototype,"vaultItemContext",2),d([C({context:ue,subscribe:!0}),p({type:Object,attribute:!1})],X.prototype,"vaultManager",2),d([C({context:me,subscribe:!0}),p({type:Object,attribute:!1,hasChanged(e,r){return e?.submitButton?.amountVisible!==r?.submitButton?.amountVisible}})],X.prototype,"clientOptions",2),d([p({type:String})],X.prototype,"variant",2),d([p({type:Boolean})],X.prototype,"disabled",2),X=d([b("primer-vault-payment-submit"),O()],X);function ki(i){return i?{paddingHorizontal:0,placeholder:{color:i.getPropertyValue("--primer-color-text-placeholder").trim(),fontSize:i.getPropertyValue("--primer-typography-body-large-size").trim(),fontFamily:i.getPropertyValue("--primer-typography-body-large-font").trim()},height:i.getPropertyValue("--primer-typography-body-large-line-height").trim(),fontSize:i.getPropertyValue("--primer-typography-body-large-size").trim(),fontFamily:i.getPropertyValue("--primer-typography-body-large-font").trim(),color:i.getPropertyValue("--primer-color-text-primary").trim()}:null}var zs=y` :host { display: block; margin-top: var(--primer-space-medium); } .cvv-input-container { margin-bottom: var(--primer-space-medium); } `;var j=class extends v{constructor(){super();this.vaultManagerFormContext=null;this.vaultManagerCvvContext=null;this.computedStyles=null;this.paymentMethod=null;this.cvvError=null;this.cvvInputIsDirty=!1;this.cvvInputIsBlurred=!1;this.cvvInput=null;this.isFocused=!1;this._setupCVVIframe=new D(this,{task:([e,r])=>!e||!r||e.paymentMethodType!=="PAYMENT_CARD"||!e.paymentInstrumentData?.network||r.createCvvInput===null?R:{network:e.paymentInstrumentData.network,createCvvInput:r.createCvvInput},args:()=>[this.paymentMethod,this.vaultManagerFormContext]});this.cvvContainerId=`cvv-container-${Math.random().toString(36).substring(2,9)}`,new D(this,{task:async([e])=>{if(!e)return R;await this.updateComplete;let r=this.renderRoot.querySelector(`#${this.cvvContainerId}`);if(!r)return;let o=ki(this.computedStyles),n=o?{input:{base:o}}:void 0,a={cardNetwork:e.network,container:r,name:"cvv",placeholder:"123",style:n};this.cvvInput=await e.createCvvInput?.(a)??null,this.cvvInput&&(this.cvvInput.focus(),this.cvvError=this.cvvInput.metadata.errorCode||null,this.vaultManagerCvvContext?.setCvvInput(this.cvvInput),this.cvvInput.addListener("change",()=>{this.onCvvInputChange()}),this.cvvInput.addListener("blur",()=>{this.onBlur()}),this.cvvInput.addListener("focus",()=>{this.onFocus()}))},args:()=>[this._setupCVVIframe.value]})}disconnectedCallback(){super.disconnectedCallback(),this.cvvInput&&(this.cvvInput.remove(),this.cvvInput=null,this.cvvError=null,this.vaultManagerCvvContext?.setCvvInput(null))}onCvvInputChange(){!this.cvvInput||!this.vaultManagerCvvContext||(this.cvvInputIsDirty=!0,this.cvvError=this.cvvInput.metadata.errorCode||null)}onBlur(){this.cvvInput&&(this.cvvInputIsBlurred=!0,this.cvvError=this.cvvInput.metadata.errorCode||null,this.isFocused=!1)}onFocus(){this.isFocused=!0}render(){return this._setupCVVIframe.render({error:()=>g,complete:()=>m`<div class="cvv-input-container"><primer-input-wrapper .focusWithin=${this.isFocused} .hasError=${!!this.cvvError&&(this.vaultManagerCvvContext?.formIsDirty||this.cvvInputIsDirty&&this.cvvInputIsBlurred)} ><slot name="label" slot="label"><primer-input-label>CVV</primer-input-label></slot><div slot="input" id="${this.cvvContainerId}"></div>${k(this.cvvError&&(this.vaultManagerCvvContext?.formIsDirty||this.cvvInputIsDirty&&this.cvvInputIsBlurred),()=>m`<primer-input-error slot="error">${E(this.cvvError,{id:this.cvvError})}</primer-input-error>`)}</primer-input-wrapper></div>`})}};j.styles=[_,zs],d([C({context:ue,subscribe:!0}),p({type:Object,attribute:!1,hasChanged(e,r){return e?.createCvvInput!==r?.createCvvInput}})],j.prototype,"vaultManagerFormContext",2),d([C({context:Oe,subscribe:!0}),p({type:Object,attribute:!1})],j.prototype,"vaultManagerCvvContext",2),d([C({context:Ht,subscribe:!0}),p()],j.prototype,"computedStyles",2),d([p({type:Object})],j.prototype,"paymentMethod",2),d([M()],j.prototype,"cvvError",2),d([M()],j.prototype,"cvvInputIsDirty",2),d([M()],j.prototype,"cvvInputIsBlurred",2),d([M()],j.prototype,"cvvInput",2),d([M()],j.prototype,"isFocused",2),j=d([b("primer-vault-cvv-input"),O()],j);var Ks=y` :host { display: flex; width: 100%; align-items: center; } /* Card icons */ .payment-method-icon { height: var(--primer-space-xlarge); object-fit: contain; flex-shrink: 0; transition: transform var(--primer-animation-duration) var(--primer-animation-easing); } .payment-method-icon-generic { display: flex; align-items: center; justify-content: center; color: var(--primer-color-gray-500); height: var(--primer-space-xlarge); flex-shrink: 0; } .payment-method-details { flex: 1; display: flex; flex-direction: column; gap: var(--primer-space-xsmall); align-items: flex-start; transition: transform var(--primer-animation-duration) var(--primer-animation-easing); margin-left: var(--primer-space-small); } .payment-method-card { flex: 1; width: 100%; display: flex; flex-direction: column; gap: var(--primer-space-xsmall); transition: transform var(--primer-animation-duration) var(--primer-animation-easing); } .payment-method-description { font-weight: var(--primer-typography-title-large-weight); color: var(--primer-color-text-primary); transition: color var(--primer-animation-duration) var(--primer-animation-easing); } .payment-method-secondary-description { font-size: var(--primer-typography-body-small-size); color: var(--primer-color-text-secondary); transition: color var(--primer-animation-duration) var(--primer-animation-easing); } .payment-method-row { display: grid; grid-template-columns: 200px 100px; justify-content: space-between; align-items: center; } .cell-2 { grid-column: 2; display: flex; justify-content: flex-end; align-items: center; } .payment-method-header { font-weight: var(--primer-typography-body-large-weight); font-size: var(--primer-typography-body-large-size); line-height: var(--primer-typography-body-large-line-height); color: var(--primer-color-text-primary); letter-spacing: var(--primer-typography-body-large-letter-spacing); } .payment-method-subtitle { color: var(--primer-color-text-secondary); font-size: var(--primer-typography-body-small-size); line-height: var(--primer-typography-body-small-line-height); font-weight: var(--primer-typography-body-small-weight); letter-spacing: var(--primer-typography-body-small-letter-spacing); } .flex { display: flex; align-items: flex-end; gap: var(--primer-space-xsmall); } .payment-method-card-other { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: var(--primer-space-medium); align-items: center; justify-content: space-between; } .payment-method-right-column-text { 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 Ge=class extends v{constructor(){super(...arguments);this.assetConfig=null}render(){if(!this.assetConfig)return g;let e=this.assetConfig.description,r=this.assetConfig.icon,o=k(this.assetConfig.icon,()=>m`<img class="payment-method-icon" src=${r} alt=${e} />`,()=>m`<div class="payment-method-icon payment-method-icon-generic"><primer-icon name="payment-card" size="sm"></primer-icon></div>`);return this.assetConfig.type==="paypal"?m`<span class="payment-method-card"><div class="payment-method-row"><span class="payment-method-header" >${this.assetConfig.fullName}</span ></div><div class="payment-method-row"><span class="flex">${o}<span class="payment-method-subtitle" >${this.assetConfig.paymentMethodType}</span ></span></div></span>`:this.assetConfig.type==="other"&&this.assetConfig.paymentMethodType!=="ACH"?m`<div class="payment-method-card-other"><div class="left-column"><div class="payment-method-header">${this.assetConfig.fullName}</div><div class="flex">${o}<span class="payment-method-subtitle" >${this.assetConfig.paymentMethodType}</span ></div></div><div class="payment-method-right-column-text">${this.assetConfig.email||`\u2022\u2022\u2022\u2022 ${this.assetConfig.last4}`}</div></div>`:this.assetConfig.type==="other"&&this.assetConfig.paymentMethodType==="ACH"?m`<span class="payment-method-card"><div class="payment-method-row"><span class="payment-method-header" >${this.assetConfig.fullName}</span ><span class="payment-method-header cell-2" >•••• ${this.assetConfig.last4}</span ></div><div class="payment-method-row"><span class="flex">${o}<span class="payment-method-subtitle" >${this.assetConfig.bankName}</span ></span><span class="payment-method-subtitle cell-2" >${this.assetConfig.accountType}</span ></div></span>`:this.assetConfig.type==="card"?m`<span class="payment-method-card"><div class="payment-method-row"><span class="payment-method-header" >${this.assetConfig.cardholderName}</span ><span class="payment-method-header cell-2" >•••• ${this.assetConfig.last4}</span ></div><div class="payment-method-row"><span class="flex">${o}<span class="payment-method-subtitle" >${this.assetConfig.network}</span ></span><span class="payment-method-subtitle cell-2" >${this.assetConfig.expiresDate}</span ></div></span>`:g}};Ge.styles=[_,Ks],d([p({type:Object,attribute:!1})],Ge.prototype,"assetConfig",2),Ge=d([b("primer-payment-method-content")],Ge);var qt="card-form-context";function Gs(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=`
|
|
202
202
|
input[data-custom-input]::placeholder {
|
|
203
203
|
color: var(--primer-color-text-placeholder);
|
|
204
204
|
font-size: var(--primer-typography-body-large-size);
|
|
@@ -207,4 +207,4 @@ primer-checkout:not([js-initialized]):not([loader-disabled])::after {
|
|
|
207
207
|
input[data-custom-input]:focus {
|
|
208
208
|
outline: none;
|
|
209
209
|
}
|
|
210
|
-
`,t.shadowRoot?t.shadowRoot.appendChild(e):t.appendChild(e)}}function Vs(i,t){return i.active!==t.active||i.dirty!==t.dirty||i.error!==t.error||i.errorCode!==t.errorCode||i.submitted!==t.submitted||i.touched!==t.touched||i.valid!==t.valid}var Ii=class{constructor(t,e){this._meta={active:!1,dirty:!1,error:null,errorCode:null,submitted:!1,touched:!1,valid:!1};this._hostedInput=null;this._standardInput=null;this.host=t,this.config=e,this.host.addController(this),this.setupTask=new D(this.host,{args:()=>[this.getHostedInput()],task:this.setupHostedInput.bind(this)}),this.host.addEventListener("wrapper-click",()=>{this.focusInput()})}focusInput(){this._hostedInput?this._hostedInput.focus():this._standardInput&&this._standardInput.focus()}notifyUserInteraction(){let t=this.host.cardFormContext;t?.onUserInteraction&&t.onUserInteraction()}getHostedInput(){let{type:t}=this.config,e=this.host.cardFormContext;return e?{cardNumber:e.cardNumberInput,cvv:e.cvvInput,expire:e.expiryInput,cardholderName:e.cardholderNameInput??"cardholderName"}[t]:void 0}async setupHostedInput([t]){if(!t)return R;await this.host.updateComplete;let e=this.getTargetContainer();return e?t==="cardholderName"?this.setupStandardInput(e):this.setupHostedIframeInput(t,e):R}getTargetContainer(){return this.host.renderRoot.querySelector(this.config.containerSelector)}setupStandardInput(t){let e=document.createElement("input");return e.type="text",e.placeholder=this.host.placeholder,$s(e,this.host),(this.host.ariaLabel||this.host.label)&&e.setAttribute("aria-label",this.host.ariaLabel??this.host.label),this.setupInputEventListeners(e),t.innerHTML="",t.appendChild(e),this._standardInput=e,!0}setupInputEventListeners(t){t.addEventListener("input",e=>{let r=e.target,a=!!r.value.trim();this.notifyUserInteraction(),this._meta={...this._meta,dirty:a},this.config.onInput?.(r.value),this.host.requestUpdate()}),t.addEventListener("focus",()=>{this.notifyUserInteraction(),this._meta.active=!0,this.host.requestUpdate()}),t.addEventListener("blur",()=>{this._meta.active=!1,this._meta.touched=!1,this.host.requestUpdate()}),t.addEventListener("keydown",e=>{if(e.key==="Enter"){e.preventDefault();let r=this.host.closest("form");r&&r.requestSubmit()}})}async setupHostedIframeInput(t,e){await new Promise(a=>requestAnimationFrame(()=>a())),this._hostedInput=t;let r=ki(this.host.computedStyles),o=r?{style:{input:{base:r}}}:void 0;return t.addEventListener("focus",()=>{this.notifyUserInteraction(),this._meta.active=!0,this.host.requestUpdate()}),t.addEventListener("blur",()=>{this._meta.active=!1,this.host.requestUpdate()}),t.addEventListener("change",a=>{let n=a;this.notifyUserInteraction(),Vs(this._meta,n)&&(this._meta={...this._meta,...n},this.host.requestUpdate())}),t.addEventListener("enter",()=>{let a=this.host.closest("form");a&&a.requestSubmit()}),await t.render(e,{placeholder:this.host.placeholder,ariaLabel:this.host.ariaLabel,...o}),!0}get meta(){return this._meta}updateMetaFromValidation(t){this._meta={...this._meta,valid:!!t.valid,error:t.error||null,errorCode:t.errorCode||null},this.host.requestUpdate()}setSubmitted(t){this._meta={...this._meta,submitted:t,...t&&{touched:!0}},this.host.requestUpdate()}hostConnected(){this.registerWithContext()}hostDisconnected(){this.unregisterFromContext(),this._hostedInput=null,this._standardInput=null}registerWithContext(){let t=this.host.cardFormContext;t?.registerInputController&&t.registerInputController(this.config.type,this)}unregisterFromContext(){let t=this.host.cardFormContext;t?.unregisterInputController&&t.unregisterInputController(this.config.type)}};var Us=y` :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 Bs={cardholderName:"cardholderName",cardNumber:"cardNumber",cardExpiryDate:"expire",expiryDate:"expire",cardSecurityCode:"cvv",cvv:"cvv"},Q=class extends v{constructor(){super(...arguments);this.hideLabels=!1;this.disabled=!1;this.hasAssignedContent=!1;this.selectedCardNetwork=null;this.formErrorMessage=null;this.paymentMethodSelectionSent=!1;this.paymentManagers=new Map;this.clientOptions=null;this.headlessUtils=null;this.analyticsUtils=null;this.contextEventsController=null;this.cardFormProvider=new z(this,{context:Gt,initialValue:null});this.eventsController=new Ot(this);this._contextCardSubmitListener=null;this._isHandlingContextEvent=!1;this.inputControllers=new Map;this.setupCardFormTask=new D(this,{task:([e])=>{if(!e?.manager)return R;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:d=>{r.setCardholderName(d),this.shouldRequireCardholderName&&r.validate?.().then(c=>{let g=c?.validationErrors?.find(x=>x.name===Bs.cardholderName),f=this.inputControllers.get("cardholderName");f&&f.updateMetaFromValidation({valid:!1,error:g?.message||g?.error||null,errorCode:g?.message||g?.error||null})})},setCardNetwork:d=>{this.selectedCardNetwork=d},validate:()=>r.validate(),submit:d=>r.submit(d),hideLabels:this.hideLabels,disabled:this.disabled,setSubmissionState:d=>{this.inputControllers.forEach(c=>{c.setSubmitted(d)})},propagateValidationErrors:d=>{d&&d.forEach(c=>{let u=c.field||c.name,g=c.message||c.error,f=Bs[u];if(f){let x=this.inputControllers.get(f);if(x){let I={valid:!1,error:g,errorCode:g};x.updateMetaFromValidation(I)}}})},registerInputController:(d,c)=>{this.inputControllers.set(d,c)},unregisterInputController:d=>{this.inputControllers.delete(d)},onUserInteraction:()=>{this.sendPaymentMethodSelectionEvent(),this.checkAndSendPaymentDetailsEnteredEvent()}}),!0},args:()=>[this.paymentManagers.get("PAYMENT_CARD")]});this.paymentDetailsEnteredSent=!1;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.handleContextCardSubmit=e=>{if(!this._isHandlingContextEvent){this._isHandlingContextEvent=!0;try{e.target!==this&&(e.stopPropagation(),this.submitCardPayment())}finally{this._isHandlingContextEvent=!1}}};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){if(super.updated(e),(e.has("hideLabels")||e.has("disabled"))&&this.cardFormProvider.value&&this.cardFormProvider.setValue({...this.cardFormProvider.value,hideLabels:this.hideLabels,disabled:this.disabled}),e.has("contextEventsController")){let r=e.get("contextEventsController");r?.host&&this._contextCardSubmitListener&&r.host.removeEventListener("primer:card-submit",this._contextCardSubmitListener),this.setupContextEventListeners()}}get shouldShowCardholderName(){let e=this.clientOptions?.card?.cardholderName;return typeof e?.visible=="boolean"?e.visible:!0}get shouldRequireCardholderName(){if(!this.shouldShowCardholderName)return!1;let e=this.clientOptions?.card?.cardholderName;return typeof e?.required=="boolean"?e.required:!0}sendPaymentMethodSelectionEvent(){this.paymentMethodSelectionSent||(this.paymentMethodSelectionSent=!0,q({eventName:"PAYMENT_METHOD_SELECTION",paymentMethod:"PAYMENT_CARD"}))}checkAndSendPaymentDetailsEnteredEvent(){if(this.paymentDetailsEnteredSent)return;let e=this.inputControllers.get("cardNumber"),r=this.inputControllers.get("expire"),o=this.inputControllers.get("cvv"),a=e?.meta?.dirty===!0,n=r?.meta?.dirty===!0,s=o?.meta?.dirty===!0,d=!0;this.shouldRequireCardholderName&&(d=this.inputControllers.get("cardholderName")?.meta?.dirty===!0),a&&n&&s&&d&&(this.sendPaymentDetailsEnteredEvent(),this.paymentDetailsEnteredSent=!0)}sendPaymentDetailsEnteredEvent(){q({eventName:"PAYMENT_DETAILS_ENTERED",paymentMethod:"PAYMENT_CARD"})}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.handleSlotButtonClick),this.addEventListener("primer:card-submit",this.handleDirectSubmit),this._contextCardSubmitListener=e=>{this.handleContextCardSubmit(e)},this.setupContextEventListeners()}disconnectedCallback(){this.removeEventListener("click",this.handleSlotButtonClick),this.removeEventListener("primer:card-submit",this.handleDirectSubmit),this.cleanupContextEventListeners(),super.disconnectedCallback()}setupContextEventListeners(){this.contextEventsController?.host&&this._contextCardSubmitListener&&this.contextEventsController.host.addEventListener("primer:card-submit",this._contextCardSubmitListener)}cleanupContextEventListeners(){this.contextEventsController?.host&&this._contextCardSubmitListener&&this.contextEventsController.host.removeEventListener("primer:card-submit",this._contextCardSubmitListener)}isSubmitButton(e){let 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;this.formErrorMessage=null,e.setSubmissionState?.(!0);let r=this.querySelector("primer-billing-address")||this.renderRoot.querySelector("primer-billing-address"),o=!0;r&&(o=await r.validateForSubmission());let a=await e.validate?.();if(a?.valid&&o){if(r&&!await r.submitToSDK()){let c=C("tokenizationError",{id:"tokenizationError"});this.formErrorMessage=c,this.eventsController.dispatchFormSubmitErrors([{field:"billingAddress",name:"billingAddress",error:"BILLING_ADDRESS_SUBMISSION_FAILED",message:c}]);return}let n=this.selectedCardNetwork?{cardNetwork:this.selectedCardNetwork}:void 0;await e.submit?.(n);let s={success:!0};this.eventsController.dispatchFormSubmitSuccess(s)}else{let n=a?.validationErrors;e.propagateValidationErrors?.(n||[]),this.cardFormProvider.setValue({...e,errors:n}),this.eventsController.dispatchFormSubmitErrors(n)}}render(){return this.setupCardFormTask.status===ct.ERROR||this.setupCardFormTask.status===ct.INITIAL?h:m`<form @submit=${this.handleFormSubmit}><slot name="card-form-content" @slotchange=${this.onSlotChange}></slot>${this.setupCardFormTask.render({complete:()=>k(this.hasAssignedContent,()=>h,()=>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>${k(this.shouldShowCardholderName,()=>m`<primer-input-card-holder-name></primer-input-card-holder-name>`,()=>h)}<primer-billing-address></primer-billing-address></div><primer-card-form-submit></primer-card-form-submit><primer-error-message message="${this.formErrorMessage||""}" ?visible="${!!this.formErrorMessage}" ></primer-error-message>`)})}</form>`}};Q.styles=[P,Us],l([p({type:Boolean,attribute:"hide-labels",reflect:!0})],Q.prototype,"hideLabels",2),l([p({type:Boolean,attribute:"disabled"})],Q.prototype,"disabled",2),l([_()],Q.prototype,"hasAssignedContent",2),l([_()],Q.prototype,"selectedCardNetwork",2),l([_()],Q.prototype,"formErrorMessage",2),l([E({context:K,subscribe:!0}),p({type:Object})],Q.prototype,"paymentManagers",2),l([E({context:me}),p({attribute:!1})],Q.prototype,"clientOptions",2),l([E({context:F,subscribe:!0}),p({attribute:!1})],Q.prototype,"headlessUtils",2),l([E({context:st,subscribe:!0}),p({attribute:!1})],Q.prototype,"analyticsUtils",2),l([E({context:$t,subscribe:!0}),p({attribute:!1})],Q.prototype,"contextEventsController",2),Q=l([b("primer-card-form"),O()],Q);var de=class extends v{constructor(){super();this._cardFormContext=null;this.computedStyles=null;this._userAssignedProps=new Set;this._internalLabel="";this._internalPlaceholder="";this._internalAriaLabel="";this.handleWrapperClick=()=>{this.hostedInputController.focusInput()};this.hostedInputController={}}get cardFormContext(){return this._cardFormContext}set cardFormContext(e){let r=this._cardFormContext;this._cardFormContext=e,!r&&e&&this.updateComplete.then(()=>{this.hostedInputController?.registerWithContext?.()}),this.requestUpdate("cardFormContext",r)}getTranslatedValue(e){return e?typeof e=="string"?e:C(e.id,{id:e.id}):""}get label(){return this._userAssignedProps.has("label")?this._internalLabel:this.getTranslatedValue(this.config.translations.label)}set label(e){let r=this.label;e!==""?(this._userAssignedProps.add("label"),this._internalLabel=e):(this._userAssignedProps.delete("label"),this._internalLabel=""),this.requestUpdate("label",r)}get placeholder(){return this._userAssignedProps.has("placeholder")?this._internalPlaceholder:this.getTranslatedValue(this.config.translations.placeholder)}set placeholder(e){let r=this.placeholder;this._userAssignedProps.add("placeholder"),this._internalPlaceholder=e,this.requestUpdate("placeholder",r)}get ariaLabel(){return this._userAssignedProps.has("ariaLabel")?this._internalAriaLabel:this.getTranslatedValue(this.config.translations.ariaLabel)||this.getTranslatedValue(this.config.translations.label)}set ariaLabel(e){let r=this.ariaLabel;e!==""?(this._userAssignedProps.add("ariaLabel"),this._internalAriaLabel=e):(this._userAssignedProps.delete("ariaLabel"),this._internalAriaLabel=""),this.requestUpdate("ariaLabel",r)}childUpdated(){Object.defineProperty(this,"hostedInputController",{value:new Ii(this,{type:this.config.inputType,containerSelector:this.config.containerSelector,onInput:this.config.onInput}),writable:!1,configurable:!1})}getError(){let e=this.hostedInputController.meta;return e.submitted||e.dirty&&e.touched?e.errorCode:null}renderInput(){if(this.hostedInputController.setupTask.status===ct.ERROR)return h;let e=this.getError();return m`<primer-input-wrapper .focusWithin="${this.hostedInputController.meta.active}" .hasError=${!!e} @wrapper-click="${this.handleWrapperClick}" >${k(!this.cardFormContext?.hideLabels,()=>m`<primer-input-label slot="label" >${this.label}</primer-input-label >`,()=>h)}<div slot="input" class="card-input-slot" id="${this.config.containerSelector.substring(1)}" aria-label="${this.ariaLabel}" ></div>${k(e,()=>m`<primer-input-error slot="error">${C(e,{id:e})}</primer-input-error>`,()=>h)}</primer-input-wrapper>`}};l([E({context:Gt,subscribe:!0})],de.prototype,"cardFormContext",1),l([E({context:Vt,subscribe:!0}),p()],de.prototype,"computedStyles",2),l([p({type:String})],de.prototype,"label",1),l([p({type:String})],de.prototype,"placeholder",1),l([p({type:String,attribute:"aria-label"})],de.prototype,"ariaLabel",1);var Ys=y` :host { display: contents; } .card-number-container { display: flex; align-items: center; width: 100%; position: relative; gap: var(--primer-space-small); } #cardNumber { flex: 1; display: flex; width: 100%; } .network-selector-container { display: flex; align-items: center; z-index: 2; } `;var vt=y` .card-input-slot { display: flex; } `;var tt=class extends de{constructor(){super();this.config={inputType:"cardNumber",containerSelector:"#cardNumber",errorName:"cardNumber-card",translations:{label:{id:"cardNumber",defaultMessage:"Card Number"},placeholder:"4111 1111 1111 1111",ariaLabel:{id:"cardNumber",defaultMessage:"Card Number"}}};this.handleNetworkSelected=e=>{let{network:r}=e.detail;this.cardFormContext&&this.cardFormContext.setCardNetwork(r)};this.childUpdated()}renderInput(){if(this.hostedInputController.setupTask.status===ct.ERROR)return h;let e=this.getError();return m`<primer-input-wrapper .focusWithin="${this.hostedInputController.meta.active}" .hasError=${!!e} >${k(!this.cardFormContext?.hideLabels,()=>m`<primer-input-label slot="label" >${this.label}</primer-input-label >`,()=>h)}<div slot="input" class="card-number-container" aria-label="${this.ariaLabel}" ><div id="${this.config.containerSelector.substring(1)}"></div><div class="network-selector-container"><primer-card-network-selector @network-selected=${this.handleNetworkSelected} ></primer-card-network-selector></div></div>${k(e,r=>m`<primer-input-error slot="error">${C(r,{id:r})}</primer-input-error>`,()=>h)}</primer-input-wrapper>`}render(){return this.renderInput()}};tt.styles=[P,vt,Ys],tt=l([b("primer-input-card-number"),O()],tt);var Hs=y` :host { display: contents; } `;var rt=class extends de{constructor(){super();this.config={inputType:"cvv",containerSelector:"#cvv",errorName:"cvv-card",translations:{label:"CVV",placeholder:"123"}};this.childUpdated()}render(){return this.renderInput()}};rt.styles=[P,vt,Hs],rt=l([b("primer-input-cvv"),O()],rt);var Fs=y` :host { display: contents; } `;var it=class extends de{constructor(){super();this.config={inputType:"expire",containerSelector:"#expiry",errorName:"expiryDate-card",translations:{label:{id:"cardExpiry",defaultMessage:"Expiry Date"},placeholder:{id:"cardExpiryPlaceholder",defaultMessage:"MM/YY"},ariaLabel:{id:"cardExpiry",defaultMessage:"Expiry Date"}}};this.childUpdated()}render(){return this.renderInput()}};it.styles=[P,vt,Fs],it=l([b("primer-input-card-expiry"),O()],it);var zs=y` :host { display: contents; } `;var ot=class extends de{constructor(){super();this.config={inputType:"cardholderName",containerSelector:"#cardFormName",errorName:"cardholderName",translations:{label:{id:"cardholderNameLabel",defaultMessage:"Cardholder Name"},placeholder:{id:"cardholderNamePlaceholder",defaultMessage:"Name on card"},ariaLabel:{id:"cardholderNameLabel",defaultMessage:"Cardholder Name"}},onInput:e=>this.handleInput(e)};this.childUpdated()}handleInput(e){this.cardFormContext?.setCardholderName?.(e)}render(){return this.renderInput()}};ot.styles=[P,vt,zs],ot=l([b("primer-input-card-holder-name"),O()],ot);var Ks=y` :host { display: contents; } `;var W=class extends v{constructor(){super(...arguments);this._userAssignedProps=new Set;this._internalButtonText="";this.headlessUtils=null;this.clientOptions=null;this.sdkState=null;this.cardFormContext=null;this.analyticsUtils=null;this.contextEventsController=null;this.variant="primary";this.disabled=!1;this.handleClick=e=>{if(e.preventDefault(),this.disabled)return;q({eventName:"PAYMENT_SUBMITTED",paymentMethod:"PAYMENT_CARD"});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:C("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)}get submitButtonConfig(){return this.clientOptions?.submitButton??null}get shouldShowBuiltInButton(){return this.submitButtonConfig?.useBuiltInButton??!0}render(){if(!this.shouldShowBuiltInButton)return h;let e=this.submitButtonConfig?.amountVisible?this.headlessUtils?.getUIOrderAmount():null,r=e?` ${e}`:h,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>`}};W.styles=[P,Ks],l([p({type:String})],W.prototype,"buttonText",1),l([E({context:F,subscribe:!0}),p({type:Object})],W.prototype,"headlessUtils",2),l([E({context:me,subscribe:!0}),p({type:Object})],W.prototype,"clientOptions",2),l([E({context:j,subscribe:!0}),p()],W.prototype,"sdkState",2),l([E({context:Gt,subscribe:!0}),p()],W.prototype,"cardFormContext",2),l([E({context:st,subscribe:!0}),p({attribute:!1})],W.prototype,"analyticsUtils",2),l([E({context:$t,subscribe:!0}),p({attribute:!1})],W.prototype,"contextEventsController",2),l([p({type:String})],W.prototype,"variant",2),l([p({type:Boolean})],W.prototype,"disabled",2),W=l([b("primer-card-form-submit"),O()],W);var js=y` :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 ce=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=Lt();this.dropdownRef=Lt();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 ${gt(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:h} aria-haspopup=${o?"true":h} aria-controls=${o?"network-dropdown":h} ><img class="network-icon" src=${this.getNetworkIconUrl(r)} alt=${r.displayName} />${k(o,()=>m`<primer-icon class="caret ${this.isDropdownOpen?"open":""}" size="sm" name="chevron-down" ></primer-icon>`,()=>h)}</button>${k(this.isDropdownOpen,()=>m`<div ${gt(this.dropdownRef)} id="network-dropdown" class="dropdown open" role="listbox" aria-label="Select card network" >${e.map((a,n)=>m`<div ${gt(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>${k(a.network===r.network,()=>m`<primer-icon class="checkmark" name="checkmark" size="sm" ></primer-icon>`,()=>h)}</div>`)}</div>`,()=>h)} `}};ce.styles=[P,js],l([E({context:Sr,subscribe:!0})],ce.prototype,"cardNetworks",2),l([E({context:F,subscribe:!0})],ce.prototype,"headlessUtils",2),l([_()],ce.prototype,"selectedCardNetwork",2),l([_()],ce.prototype,"isDropdownOpen",2),l([_()],ce.prototype,"focusedNetworkIndex",2),l([_()],ce.prototype,"isKeyboardNavigation",2),ce=l([b("primer-card-network-selector")],ce);var Gs=y` :host { display: block; margin-top: var(--primer-space-medium); margin-bottom: var(--primer-space-medium); } .other-payment-methods-container { width: 100%; } .other-payment-methods-content { padding: var(--primer-space-medium) 0; } .primer-loader { display: flex; justify-content: center; align-items: center; } `;var bt=class extends v{constructor(){super(...arguments);this.vaultManager=null}render(){if(this.vaultManager?.isLoading)return h;let e=this.vaultManager?.showEmptyState&&this.vaultManager?.vaultedPaymentMethods.length;return!this.vaultManager||!this.vaultManager.enabled||!e?m`<slot name="other-payments"></slot>`:m`<div class="other-payment-methods-container"><primer-collapsable buttonVariant="secondary" .expanded="${this.vaultManager?.vaultedPaymentMethods.length===0}" .header="${C("navigateToPaymentMethods",{id:"navigateToPaymentMethods"})}" ><div class="other-payment-methods-content"><slot name="other-payments"></slot></div></primer-collapsable></div>`}};bt.styles=[Gs],l([E({context:ue,subscribe:!0}),p({type:Object,attribute:!1})],bt.prototype,"vaultManager",2),bt=l([b("primer-show-other-payments")],bt);var Wt=class extends v{render(){return m`<primer-checkout-state type="complete"></primer-checkout-state>`}};Wt=l([b("primer-checkout-complete")],Wt);var Rt=class extends v{constructor(){super(...arguments);this.sdkState=null}render(){return m`<primer-checkout-state type="failure" description=${this.sdkState?.error?.message||""} ></primer-checkout-state>`}};l([E({context:j,subscribe:!0}),p()],Rt.prototype,"sdkState",2),Rt=l([b("primer-checkout-error")],Rt);var Ws=y` :host { display: block; width: 100%; } `;var at=class extends v{constructor(){super(...arguments);this.showProcessingErrors=!0}get shouldShowError(){return!this.sdkState||this.sdkState.isProcessing?!1:!!(this.sdkState.failure&&this.showProcessingErrors)}render(){return this.sdkState?m`<primer-error-message message="${C(this.sdkState.failure?.message??"",{id:"tokenizationError"})}" ?visible="${this.shouldShowError}" ></primer-error-message>`:h}};at.styles=[Ws],l([E({context:j,subscribe:!0}),_()],at.prototype,"sdkState",2),l([p({type:Boolean,attribute:"show-processing-errors"})],at.prototype,"showProcessingErrors",2),at=l([b("primer-error-message-container")],at);var qs=y` :host { display: contents; } .primer-main-list { display: flex; flex-direction: column; gap: var(--primer-space-small); } .primer-is-processing { opacity: 0.5; pointer-events: none; } primer-vault-manager { margin-bottom: var(--primer-space-xlarge); } `;var Ge=class extends v{constructor(){super(...arguments);this.hasAssignedContent=!1;this.onSlotChange=e=>{let o=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=o.length>0,this.requestUpdate()};this.paymentMethods=null;this.sdkState=null;this.clientOptions=null}render(){return this.sdkState?.isSuccessful?m`<slot name="checkout-complete"><primer-checkout-complete></primer-checkout-complete></slot>`:m`<slot name="payments" @slotchange=${this.onSlotChange}></slot>${k(this.hasAssignedContent,()=>h,()=>m`<div class=${re({"primer-is-processing":!!this.sdkState?.isProcessing})} ><primer-vault-manager></primer-vault-manager><primer-show-other-payments><div slot="other-payments" class="primer-main-list">${this.paymentMethods?.toArray().map(e=>m`<primer-payment-method type=${e.type} ?disabled=${this.clientOptions?.disabledPayments===!0} ></primer-payment-method>`)}</div></primer-show-other-payments><primer-error-message-container></primer-error-message-container></div>`)} `}};Ge.styles=[P,qs],l([E({context:lt,subscribe:!0}),p()],Ge.prototype,"paymentMethods",2),l([E({context:j,subscribe:!0}),p()],Ge.prototype,"sdkState",2),l([E({context:me,subscribe:!0}),p()],Ge.prototype,"clientOptions",2),Ge=l([b("primer-main")],Ge);function $k(){$n(),Vn()}export{xe as AchPayment,Fe as ApplePay,oe as BillingAddress,ve as Blik,fe as Button,Q as CardForm,rt as CardFormCVV,ce as CardFormCardNetworkSelector,tt as CardFormCardNumber,Xe as CardFormError,it as CardFormExpiry,ot as CardFormName,W as CardFormSubmit,ye as Collapsable,Ne as Dialog,ke as DynamicPayment,Ye as ErrorMessage,at as ErrorMessageContainer,He as GooglePay,Xr as InitializedPayments,Y as Input,Ze as InputLabel,Ue as InputWrapper,ze as PayPal,Le as PaymentMethod,Me as PaymentMethodContainer,je as PaymentMethodContentComponent,ht as Portal,le as PortalDialog,Wt as PrimerCheckoutComplete,Ae as PrimerCheckoutComponent,Rt as PrimerCheckoutFailure,Qe as PrimerCheckoutState,Be as PrimerIcon,ie as PrimerKlarna,Ge as PrimerMain,Ie as RedirectPayment,ge as Select,bt as ShowOtherPayments,Ve as Spinner,G as VaultCvvInput,Se as VaultDeleteConfirmation,et as VaultEmptyState,Ke as VaultErrorMessage,ae as VaultManager,Re as VaultManagerHeader,be as VaultPaymentMethodItem,X as VaultPaymentSubmit,Tc as injectDarkTheme,wc as injectLightTheme,$n as injectLoaderStyles,Vn as injectThemeStyles,$k as loadPrimer};
|
|
210
|
+
`,t.shadowRoot?t.shadowRoot.appendChild(e):t.appendChild(e)}}function js(i,t){return i.active!==t.active||i.dirty!==t.dirty||i.error!==t.error||i.errorCode!==t.errorCode||i.submitted!==t.submitted||i.touched!==t.touched||i.valid!==t.valid}var Ni=class{constructor(t,e){this._meta={active:!1,dirty:!1,error:null,errorCode:null,submitted:!1,touched:!1,valid:!1};this._hostedInput=null;this._standardInput=null;this.host=t,this.config=e,this.host.addController(this),this.setupTask=new D(this.host,{args:()=>[this.getHostedInput()],task:this.setupHostedInput.bind(this)}),this.host.addEventListener("wrapper-click",()=>{this.focusInput()})}focusInput(){this._hostedInput?this._hostedInput.focus():this._standardInput&&this._standardInput.focus()}notifyUserInteraction(){let t=this.host.cardFormContext;t?.onUserInteraction&&t.onUserInteraction()}getHostedInput(){let{type:t}=this.config,e=this.host.cardFormContext;return e?{cardNumber:e.cardNumberInput,cvv:e.cvvInput,expire:e.expiryInput,cardholderName:e.cardholderNameInput??"cardholderName"}[t]:void 0}async setupHostedInput([t]){if(!t)return R;await this.host.updateComplete;let e=this.getTargetContainer();return e?t==="cardholderName"?this.setupStandardInput(e):this.setupHostedIframeInput(t,e):R}getTargetContainer(){return this.host.renderRoot.querySelector(this.config.containerSelector)}setupStandardInput(t){let e=document.createElement("input");return e.type="text",e.placeholder=this.host.placeholder,Gs(e,this.host),(this.host.ariaLabel||this.host.label)&&e.setAttribute("aria-label",this.host.ariaLabel??this.host.label),this.setupInputEventListeners(e),t.innerHTML="",t.appendChild(e),this._standardInput=e,!0}setupInputEventListeners(t){t.addEventListener("input",e=>{let r=e.target,n=!!r.value.trim();this.notifyUserInteraction(),this._meta={...this._meta,dirty:n},this.config.onInput?.(r.value),this.host.requestUpdate()}),t.addEventListener("focus",()=>{this.notifyUserInteraction(),this._meta.active=!0,this.host.requestUpdate()}),t.addEventListener("blur",()=>{this._meta.active=!1,this._meta.touched=!1,this.host.requestUpdate()}),t.addEventListener("keydown",e=>{if(e.key==="Enter"){e.preventDefault();let r=this.host.closest("form");r&&r.requestSubmit()}})}async setupHostedIframeInput(t,e){await new Promise(n=>requestAnimationFrame(()=>n())),this._hostedInput=t;let r=ki(this.host.computedStyles),o=r?{style:{input:{base:r}}}:void 0;return t.addEventListener("focus",()=>{this.notifyUserInteraction(),this._meta.active=!0,this.host.requestUpdate()}),t.addEventListener("blur",()=>{this._meta.active=!1,this.host.requestUpdate()}),t.addEventListener("change",n=>{let a=n;this.notifyUserInteraction(),js(this._meta,a)&&(this._meta={...this._meta,...a},this.host.requestUpdate())}),t.addEventListener("enter",()=>{let n=this.host.closest("form");n&&n.requestSubmit()}),await t.render(e,{placeholder:this.host.placeholder,ariaLabel:this.host.ariaLabel,...o}),!0}get meta(){return this._meta}updateMetaFromValidation(t){this._meta={...this._meta,valid:!!t.valid,error:t.error||null,errorCode:t.errorCode||null},this.host.requestUpdate()}setSubmitted(t){this._meta={...this._meta,submitted:t,...t&&{touched:!0}},this.host.requestUpdate()}hostConnected(){this.registerWithContext()}hostDisconnected(){this.unregisterFromContext(),this._hostedInput=null,this._standardInput=null}registerWithContext(){let t=this.host.cardFormContext;t?.registerInputController&&t.registerInputController(this.config.type,this)}unregisterFromContext(){let t=this.host.cardFormContext;t?.unregisterInputController&&t.unregisterInputController(this.config.type)}};var Ws=y` :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 qs={cardholderName:"cardholderName",cardNumber:"cardNumber",cardExpiryDate:"expire",expiryDate:"expire",cardSecurityCode:"cvv",cvv:"cvv"},Q=class extends v{constructor(){super(...arguments);this.hideLabels=!1;this.disabled=!1;this.hasAssignedContent=!1;this.selectedCardNetwork=null;this.formErrorMessage=null;this.paymentMethodSelectionSent=!1;this.paymentManagers=new Map;this.clientOptions=null;this.headlessUtils=null;this.analyticsUtils=null;this.contextEventsController=null;this.cardFormProvider=new z(this,{context:qt,initialValue:null});this.eventsController=new Yt(this);this._contextCardSubmitListener=null;this._isHandlingContextEvent=!1;this.inputControllers=new Map;this.setupCardFormTask=new D(this,{task:([e])=>{if(!e?.manager)return R;let{manager:r}=e,o=r.createHostedInputs(),{cardNumberInput:n,expiryInput:a,cvvInput:s}=o;return this.cardFormProvider.setValue({cardholderNameInput:o.cardholderNameInput,cardNumberInput:n,expiryInput:a,cvvInput:s,setCardholderName:l=>{r.setCardholderName(l),this.shouldRequireCardholderName&&r.validate?.().then(c=>{let f=c?.validationErrors?.find(A=>A.name===qs.cardholderName),h=this.inputControllers.get("cardholderName");h&&h.updateMetaFromValidation({valid:!1,error:f?.message||f?.error||null,errorCode:f?.message||f?.error||null})})},setCardNetwork:l=>{this.selectedCardNetwork=l},validate:()=>r.validate(),submit:l=>r.submit(l),hideLabels:this.hideLabels,disabled:this.disabled,setSubmissionState:l=>{this.inputControllers.forEach(c=>{c.setSubmitted(l)})},propagateValidationErrors:l=>{l&&l.forEach(c=>{let u=c.field||c.name,f=c.message||c.error,h=qs[u];if(h){let A=this.inputControllers.get(h);if(A){let x={valid:!1,error:f,errorCode:f};A.updateMetaFromValidation(x)}}})},registerInputController:(l,c)=>{this.inputControllers.set(l,c)},unregisterInputController:l=>{this.inputControllers.delete(l)},onUserInteraction:()=>{this.sendPaymentMethodSelectionEvent(),this.checkAndSendPaymentDetailsEnteredEvent()}}),!0},args:()=>[this.paymentManagers.get("PAYMENT_CARD")]});this.paymentDetailsEnteredSent=!1;this.handleSlotButtonClick=e=>{let o=e.target.closest("button, primer-button");if(!o)return;let n=o;this.isSubmitButton(n)&&(e.preventDefault(),this.submitCardPayment())};this.handleDirectSubmit=e=>{e.stopPropagation(),this.submitCardPayment()};this.handleContextCardSubmit=e=>{if(!this._isHandlingContextEvent){this._isHandlingContextEvent=!0;try{e.target!==this&&(e.stopPropagation(),this.submitCardPayment())}finally{this._isHandlingContextEvent=!1}}};this.onSlotChange=e=>{let o=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=o.length>0};this.handleFormSubmit=e=>{e.preventDefault(),e.stopPropagation(),this.submitCardPayment()}}updated(e){if(super.updated(e),(e.has("hideLabels")||e.has("disabled"))&&this.cardFormProvider.value&&this.cardFormProvider.setValue({...this.cardFormProvider.value,hideLabels:this.hideLabels,disabled:this.disabled}),e.has("contextEventsController")){let r=e.get("contextEventsController");r?.host&&this._contextCardSubmitListener&&r.host.removeEventListener("primer:card-submit",this._contextCardSubmitListener),this.setupContextEventListeners()}}get shouldShowCardholderName(){let e=this.clientOptions?.card?.cardholderName;return typeof e?.visible=="boolean"?e.visible:!0}get shouldRequireCardholderName(){if(!this.shouldShowCardholderName)return!1;let e=this.clientOptions?.card?.cardholderName;return typeof e?.required=="boolean"?e.required:!0}sendPaymentMethodSelectionEvent(){this.paymentMethodSelectionSent||(this.paymentMethodSelectionSent=!0,J({eventName:"PAYMENT_METHOD_SELECTION",paymentMethod:"PAYMENT_CARD"}))}checkAndSendPaymentDetailsEnteredEvent(){if(this.paymentDetailsEnteredSent)return;let e=this.inputControllers.get("cardNumber"),r=this.inputControllers.get("expire"),o=this.inputControllers.get("cvv"),n=e?.meta?.dirty===!0,a=r?.meta?.dirty===!0,s=o?.meta?.dirty===!0,l=!0;this.shouldRequireCardholderName&&(l=this.inputControllers.get("cardholderName")?.meta?.dirty===!0),n&&a&&s&&l&&(this.sendPaymentDetailsEnteredEvent(),this.paymentDetailsEnteredSent=!0)}sendPaymentDetailsEnteredEvent(){J({eventName:"PAYMENT_DETAILS_ENTERED",paymentMethod:"PAYMENT_CARD"})}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.handleSlotButtonClick),this.addEventListener("primer:card-submit",this.handleDirectSubmit),this._contextCardSubmitListener=e=>{this.handleContextCardSubmit(e)},this.setupContextEventListeners()}disconnectedCallback(){this.removeEventListener("click",this.handleSlotButtonClick),this.removeEventListener("primer:card-submit",this.handleDirectSubmit),this.cleanupContextEventListeners(),super.disconnectedCallback()}setupContextEventListeners(){this.contextEventsController?.host&&this._contextCardSubmitListener&&this.contextEventsController.host.addEventListener("primer:card-submit",this._contextCardSubmitListener)}cleanupContextEventListeners(){this.contextEventsController?.host&&this._contextCardSubmitListener&&this.contextEventsController.host.removeEventListener("primer:card-submit",this._contextCardSubmitListener)}isSubmitButton(e){let r=e.tagName.toLowerCase(),o=r==="button",n=r==="primer-button";return o&&(e.getAttribute("type")==="submit"||e.hasAttribute("data-submit"))||n&&(e.getAttribute("type")==="submit"||e.hasAttribute("data-submit"))}async submitCardPayment(){let e=this.cardFormProvider.value;if(!e||this.disabled)return;this.formErrorMessage=null,e.setSubmissionState?.(!0);let r=this.querySelector("primer-billing-address")||this.renderRoot.querySelector("primer-billing-address"),o=!0;r&&(o=await r.validateForSubmission());let n=await e.validate?.();if(n?.valid&&o){if(r&&!await r.submitToSDK()){let c=E("tokenizationError",{id:"tokenizationError"});this.formErrorMessage=c,this.eventsController.dispatchFormSubmitErrors([{field:"billingAddress",name:"billingAddress",error:"BILLING_ADDRESS_SUBMISSION_FAILED",message:c}]);return}let a=this.selectedCardNetwork?{cardNetwork:this.selectedCardNetwork}:void 0;await e.submit?.(a);let s={success:!0};this.eventsController.dispatchFormSubmitSuccess(s)}else{let a=n?.validationErrors;e.propagateValidationErrors?.(a||[]),this.cardFormProvider.setValue({...e,errors:a}),this.eventsController.dispatchFormSubmitErrors(a)}}render(){return this.setupCardFormTask.status===pt.ERROR||this.setupCardFormTask.status===pt.INITIAL?g:m`<form @submit=${this.handleFormSubmit}><slot name="card-form-content" @slotchange=${this.onSlotChange}></slot>${this.setupCardFormTask.render({complete:()=>k(this.hasAssignedContent,()=>g,()=>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>${k(this.shouldShowCardholderName,()=>m`<primer-input-card-holder-name></primer-input-card-holder-name>`,()=>g)}<primer-billing-address></primer-billing-address></div><primer-card-form-submit></primer-card-form-submit><primer-error-message message="${this.formErrorMessage||""}" ?visible="${!!this.formErrorMessage}" ></primer-error-message>`)})}</form>`}};Q.styles=[_,Ws],d([p({type:Boolean,attribute:"hide-labels",reflect:!0})],Q.prototype,"hideLabels",2),d([p({type:Boolean,attribute:"disabled"})],Q.prototype,"disabled",2),d([M()],Q.prototype,"hasAssignedContent",2),d([M()],Q.prototype,"selectedCardNetwork",2),d([M()],Q.prototype,"formErrorMessage",2),d([C({context:K,subscribe:!0}),p({type:Object})],Q.prototype,"paymentManagers",2),d([C({context:me}),p({attribute:!1})],Q.prototype,"clientOptions",2),d([C({context:H,subscribe:!0}),p({attribute:!1})],Q.prototype,"headlessUtils",2),d([C({context:lt,subscribe:!0}),p({attribute:!1})],Q.prototype,"analyticsUtils",2),d([C({context:Ft,subscribe:!0}),p({attribute:!1})],Q.prototype,"contextEventsController",2),Q=d([b("primer-card-form"),O()],Q);var de=class extends v{constructor(){super();this._cardFormContext=null;this.computedStyles=null;this._userAssignedProps=new Set;this._internalLabel="";this._internalPlaceholder="";this._internalAriaLabel="";this.handleWrapperClick=()=>{this.hostedInputController.focusInput()};this.hostedInputController={}}get cardFormContext(){return this._cardFormContext}set cardFormContext(e){let r=this._cardFormContext;this._cardFormContext=e,!r&&e&&this.updateComplete.then(()=>{this.hostedInputController?.registerWithContext?.()}),this.requestUpdate("cardFormContext",r)}getTranslatedValue(e){return e?typeof e=="string"?e:E(e.id,{id:e.id}):""}get label(){return this._userAssignedProps.has("label")?this._internalLabel:this.getTranslatedValue(this.config.translations.label)}set label(e){let r=this.label;e!==""?(this._userAssignedProps.add("label"),this._internalLabel=e):(this._userAssignedProps.delete("label"),this._internalLabel=""),this.requestUpdate("label",r)}get placeholder(){return this._userAssignedProps.has("placeholder")?this._internalPlaceholder:this.getTranslatedValue(this.config.translations.placeholder)}set placeholder(e){let r=this.placeholder;this._userAssignedProps.add("placeholder"),this._internalPlaceholder=e,this.requestUpdate("placeholder",r)}get ariaLabel(){return this._userAssignedProps.has("ariaLabel")?this._internalAriaLabel:this.getTranslatedValue(this.config.translations.ariaLabel)||this.getTranslatedValue(this.config.translations.label)}set ariaLabel(e){let r=this.ariaLabel;e!==""?(this._userAssignedProps.add("ariaLabel"),this._internalAriaLabel=e):(this._userAssignedProps.delete("ariaLabel"),this._internalAriaLabel=""),this.requestUpdate("ariaLabel",r)}childUpdated(){Object.defineProperty(this,"hostedInputController",{value:new Ni(this,{type:this.config.inputType,containerSelector:this.config.containerSelector,onInput:this.config.onInput}),writable:!1,configurable:!1})}getError(){let e=this.hostedInputController.meta;return e.submitted||e.dirty&&e.touched?e.errorCode:null}renderInput(){if(this.hostedInputController.setupTask.status===pt.ERROR)return g;let e=this.getError();return m`<primer-input-wrapper .focusWithin="${this.hostedInputController.meta.active}" .hasError=${!!e} @wrapper-click="${this.handleWrapperClick}" >${k(!this.cardFormContext?.hideLabels,()=>m`<primer-input-label slot="label" >${this.label}</primer-input-label >`,()=>g)}<div slot="input" class="card-input-slot" id="${this.config.containerSelector.substring(1)}" aria-label="${this.ariaLabel}" ></div>${k(e,()=>m`<primer-input-error slot="error">${E(e,{id:e})}</primer-input-error>`,()=>g)}</primer-input-wrapper>`}};d([C({context:qt,subscribe:!0})],de.prototype,"cardFormContext",1),d([C({context:Ht,subscribe:!0}),p()],de.prototype,"computedStyles",2),d([p({type:String})],de.prototype,"label",1),d([p({type:String})],de.prototype,"placeholder",1),d([p({type:String,attribute:"aria-label"})],de.prototype,"ariaLabel",1);var Js=y` :host { display: contents; } .card-number-container { display: flex; align-items: center; width: 100%; position: relative; gap: var(--primer-space-small); } #cardNumber { flex: 1; display: flex; width: 100%; } .network-selector-container { display: flex; align-items: center; z-index: 2; } `;var vt=y` .card-input-slot { display: flex; } `;var tt=class extends de{constructor(){super();this.config={inputType:"cardNumber",containerSelector:"#cardNumber",errorName:"cardNumber-card",translations:{label:{id:"cardNumber",defaultMessage:"Card Number"},placeholder:"4111 1111 1111 1111",ariaLabel:{id:"cardNumber",defaultMessage:"Card Number"}}};this.handleNetworkSelected=e=>{let{network:r}=e.detail;this.cardFormContext&&this.cardFormContext.setCardNetwork(r)};this.childUpdated()}renderInput(){if(this.hostedInputController.setupTask.status===pt.ERROR)return g;let e=this.getError();return m`<primer-input-wrapper .focusWithin="${this.hostedInputController.meta.active}" .hasError=${!!e} >${k(!this.cardFormContext?.hideLabels,()=>m`<primer-input-label slot="label" >${this.label}</primer-input-label >`,()=>g)}<div slot="input" class="card-number-container" aria-label="${this.ariaLabel}" ><div id="${this.config.containerSelector.substring(1)}"></div><div class="network-selector-container"><primer-card-network-selector @network-selected=${this.handleNetworkSelected} ></primer-card-network-selector></div></div>${k(e,r=>m`<primer-input-error slot="error">${E(r,{id:r})}</primer-input-error>`,()=>g)}</primer-input-wrapper>`}render(){return this.renderInput()}};tt.styles=[_,vt,Js],tt=d([b("primer-input-card-number"),O()],tt);var Zs=y` :host { display: contents; } `;var rt=class extends de{constructor(){super();this.config={inputType:"cvv",containerSelector:"#cvv",errorName:"cvv-card",translations:{label:"CVV",placeholder:"123"}};this.childUpdated()}render(){return this.renderInput()}};rt.styles=[_,vt,Zs],rt=d([b("primer-input-cvv"),O()],rt);var Xs=y` :host { display: contents; } `;var it=class extends de{constructor(){super();this.config={inputType:"expire",containerSelector:"#expiry",errorName:"expiryDate-card",translations:{label:{id:"cardExpiry",defaultMessage:"Expiry Date"},placeholder:{id:"cardExpiryPlaceholder",defaultMessage:"MM/YY"},ariaLabel:{id:"cardExpiry",defaultMessage:"Expiry Date"}}};this.childUpdated()}render(){return this.renderInput()}};it.styles=[_,vt,Xs],it=d([b("primer-input-card-expiry"),O()],it);var Qs=y` :host { display: contents; } `;var ot=class extends de{constructor(){super();this.config={inputType:"cardholderName",containerSelector:"#cardFormName",errorName:"cardholderName",translations:{label:{id:"cardholderNameLabel",defaultMessage:"Cardholder Name"},placeholder:{id:"cardholderNamePlaceholder",defaultMessage:"Name on card"},ariaLabel:{id:"cardholderNameLabel",defaultMessage:"Cardholder Name"}},onInput:e=>this.handleInput(e)};this.childUpdated()}handleInput(e){this.cardFormContext?.setCardholderName?.(e)}render(){return this.renderInput()}};ot.styles=[_,vt,Qs],ot=d([b("primer-input-card-holder-name"),O()],ot);var el=y` :host { display: contents; } `;var W=class extends v{constructor(){super(...arguments);this._userAssignedProps=new Set;this._internalButtonText="";this.headlessUtils=null;this.clientOptions=null;this.sdkState=null;this.cardFormContext=null;this.analyticsUtils=null;this.contextEventsController=null;this.variant="primary";this.disabled=!1;this.handleClick=e=>{if(e.preventDefault(),this.disabled)return;J({eventName:"PAYMENT_SUBMITTED",paymentMethod:"PAYMENT_CARD"});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:E("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)}get submitButtonConfig(){return this.clientOptions?.submitButton??null}get shouldShowBuiltInButton(){return this.submitButtonConfig?.useBuiltInButton??!0}render(){if(!this.shouldShowBuiltInButton)return g;let e=this.submitButtonConfig?.amountVisible?this.headlessUtils?.getUIOrderAmount():null,r=e?` ${e}`:g,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>`}};W.styles=[_,el],d([p({type:String})],W.prototype,"buttonText",1),d([C({context:H,subscribe:!0}),p({type:Object})],W.prototype,"headlessUtils",2),d([C({context:me,subscribe:!0}),p({type:Object})],W.prototype,"clientOptions",2),d([C({context:G,subscribe:!0}),p()],W.prototype,"sdkState",2),d([C({context:qt,subscribe:!0}),p()],W.prototype,"cardFormContext",2),d([C({context:lt,subscribe:!0}),p({attribute:!1})],W.prototype,"analyticsUtils",2),d([C({context:Ft,subscribe:!0}),p({attribute:!1})],W.prototype,"contextEventsController",2),d([p({type:String})],W.prototype,"variant",2),d([p({type:Boolean})],W.prototype,"disabled",2),W=d([b("primer-card-form-submit"),O()],W);var tl=y` :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 ce=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=Lt();this.dropdownRef=Lt();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 ${ft(this.buttonRef)} class="network-selector" @click=${this.toggleDropdown} @keydown=${n=>{(n.key===" "||n.key==="Enter")&&o&&(n.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:g} aria-haspopup=${o?"true":g} aria-controls=${o?"network-dropdown":g} ><img class="network-icon" src=${this.getNetworkIconUrl(r)} alt=${r.displayName} />${k(o,()=>m`<primer-icon class="caret ${this.isDropdownOpen?"open":""}" size="sm" name="chevron-down" ></primer-icon>`,()=>g)}</button>${k(this.isDropdownOpen,()=>m`<div ${ft(this.dropdownRef)} id="network-dropdown" class="dropdown open" role="listbox" aria-label="Select card network" >${e.map((n,a)=>m`<div ${ft(s=>this.setNetworkOptionRef(s,a))} class="network-option ${this.isKeyboardNavigation&&a===this.focusedNetworkIndex?"focused":""}" @click=${s=>this.selectNetwork(s,n)} @keydown=${s=>{(s.key==="Enter"||s.key===" ")&&this.selectNetwork(s,n)}} role="option" aria-selected=${n.network===r.network} tabindex="${a===this.focusedNetworkIndex?"0":"-1"}" ><img class="network-option-icon" src=${this.getNetworkIconUrl(n)} alt=${n.displayName} /><span class="network-name">${n.displayName}</span>${k(n.network===r.network,()=>m`<primer-icon class="checkmark" name="checkmark" size="sm" ></primer-icon>`,()=>g)}</div>`)}</div>`,()=>g)} `}};ce.styles=[_,tl],d([C({context:Yr,subscribe:!0})],ce.prototype,"cardNetworks",2),d([C({context:H,subscribe:!0})],ce.prototype,"headlessUtils",2),d([M()],ce.prototype,"selectedCardNetwork",2),d([M()],ce.prototype,"isDropdownOpen",2),d([M()],ce.prototype,"focusedNetworkIndex",2),d([M()],ce.prototype,"isKeyboardNavigation",2),ce=d([b("primer-card-network-selector")],ce);var rl=y` :host { display: block; margin-top: var(--primer-space-medium); margin-bottom: var(--primer-space-medium); } .other-payment-methods-container { width: 100%; } .other-payment-methods-content { padding: var(--primer-space-medium) 0; } .primer-loader { display: flex; justify-content: center; align-items: center; } `;var bt=class extends v{constructor(){super(...arguments);this.vaultManager=null}render(){if(this.vaultManager?.isLoading)return g;let e=this.vaultManager?.showEmptyState&&this.vaultManager?.vaultedPaymentMethods.length;return!this.vaultManager||!this.vaultManager.enabled||!e?m`<slot name="other-payments"></slot>`:m`<div class="other-payment-methods-container"><primer-collapsable buttonVariant="secondary" .expanded="${this.vaultManager?.vaultedPaymentMethods.length===0}" .header="${E("navigateToPaymentMethods",{id:"navigateToPaymentMethods"})}" ><div class="other-payment-methods-content"><slot name="other-payments"></slot></div></primer-collapsable></div>`}};bt.styles=[rl],d([C({context:ue,subscribe:!0}),p({type:Object,attribute:!1})],bt.prototype,"vaultManager",2),bt=d([b("primer-show-other-payments")],bt);var Jt=class extends v{render(){return m`<primer-checkout-state type="complete"></primer-checkout-state>`}};Jt=d([b("primer-checkout-complete")],Jt);var Rt=class extends v{constructor(){super(...arguments);this.sdkState=null}render(){return m`<primer-checkout-state type="failure" description=${this.sdkState?.primerJsError?.message||""} ></primer-checkout-state>`}};d([C({context:G,subscribe:!0}),p()],Rt.prototype,"sdkState",2),Rt=d([b("primer-checkout-error")],Rt);var il=y` :host { display: block; width: 100%; } `;var nt=class extends v{constructor(){super(...arguments);this.showProcessingErrors=!0}get shouldShowError(){return!this.sdkState||this.sdkState.isProcessing?!1:!!(this.sdkState.paymentFailure&&this.showProcessingErrors)}render(){return this.sdkState?m`<primer-error-message message="${E(this.sdkState.paymentFailure?.message??"",{id:"tokenizationError"})}" ?visible="${this.shouldShowError}" ></primer-error-message>`:g}};nt.styles=[il],d([C({context:G,subscribe:!0}),M()],nt.prototype,"sdkState",2),d([p({type:Boolean,attribute:"show-processing-errors"})],nt.prototype,"showProcessingErrors",2),nt=d([b("primer-error-message-container")],nt);var ol=y` :host { display: contents; } .primer-main-list { display: flex; flex-direction: column; gap: var(--primer-space-small); } .primer-is-processing { opacity: 0.5; pointer-events: none; } primer-vault-manager { margin-bottom: var(--primer-space-xlarge); } `;var je=class extends v{constructor(){super(...arguments);this.hasAssignedContent=!1;this.onSlotChange=e=>{let o=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=o.length>0,this.requestUpdate()};this.paymentMethods=null;this.sdkState=null;this.clientOptions=null}render(){return this.sdkState?.isSuccessful?m`<slot name="checkout-complete"><primer-checkout-complete></primer-checkout-complete></slot>`:m`<slot name="payments" @slotchange=${this.onSlotChange}></slot>${k(this.hasAssignedContent,()=>g,()=>m`<div class=${re({"primer-is-processing":!!this.sdkState?.isProcessing})} ><primer-vault-manager></primer-vault-manager><primer-show-other-payments><div slot="other-payments" class="primer-main-list">${this.paymentMethods?.toArray().map(e=>m`<primer-payment-method type=${e.type} ?disabled=${this.clientOptions?.disabledPayments===!0} ></primer-payment-method>`)}</div></primer-show-other-payments><primer-error-message-container></primer-error-message-container></div>`)} `}};je.styles=[_,ol],d([C({context:dt,subscribe:!0}),p()],je.prototype,"paymentMethods",2),d([C({context:G,subscribe:!0}),p()],je.prototype,"sdkState",2),d([C({context:me,subscribe:!0}),p()],je.prototype,"clientOptions",2),je=d([b("primer-main")],je);function ok(){Ga(),ja()}export{Se as AchPayment,He as ApplePay,oe as BillingAddress,ve as Blik,ge as Button,Q as CardForm,rt as CardFormCVV,ce as CardFormCardNetworkSelector,tt as CardFormCardNumber,Xe as CardFormError,it as CardFormExpiry,ot as CardFormName,W as CardFormSubmit,ye as Collapsable,Ne as Dialog,Ie as DynamicPayment,Be as ErrorMessage,nt as ErrorMessageContainer,Fe as GooglePay,Xr as InitializedPayments,Qr as InitializedVaultedPayments,B as Input,Ze as InputLabel,Ue as InputWrapper,ze as PayPal,Le as PaymentMethod,we as PaymentMethodContainer,Ge as PaymentMethodContentComponent,ht as Portal,le as PortalDialog,Jt as PrimerCheckoutComplete,Ae as PrimerCheckoutComponent,Rt as PrimerCheckoutFailure,Qe as PrimerCheckoutState,Ye as PrimerIcon,ie as PrimerKlarna,je as PrimerMain,ke as RedirectPayment,fe as Select,bt as ShowOtherPayments,Ve as Spinner,j as VaultCvvInput,Pe as VaultDeleteConfirmation,et as VaultEmptyState,Ke as VaultErrorMessage,ne as VaultManager,Re as VaultManagerHeader,be as VaultPaymentMethodItem,X as VaultPaymentSubmit,Yc as injectDarkTheme,Uc as injectLightTheme,Ga as injectLoaderStyles,ja as injectThemeStyles,ok as loadPrimer};
|