@primer-io/primer-js 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/custom-elements.json +0 -9
- package/dist/primer-loader.d.ts +0 -1
- package/dist/primer-loader.js +2 -2
- package/dist/web-types.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4938,15 +4938,6 @@
|
|
|
4938
4938
|
}
|
|
4939
4939
|
]
|
|
4940
4940
|
},
|
|
4941
|
-
{
|
|
4942
|
-
"kind": "method",
|
|
4943
|
-
"name": "getConfiguration",
|
|
4944
|
-
"return": {
|
|
4945
|
-
"type": {
|
|
4946
|
-
"text": "ConfigurationContextType | undefined"
|
|
4947
|
-
}
|
|
4948
|
-
}
|
|
4949
|
-
},
|
|
4950
4941
|
{
|
|
4951
4942
|
"kind": "method",
|
|
4952
4943
|
"name": "setAnalyticsUtils",
|
package/dist/primer-loader.d.ts
CHANGED
|
@@ -1728,7 +1728,6 @@ declare class SDKContextController implements ReactiveController {
|
|
|
1728
1728
|
setClientOptions(value: PrimerCheckoutOptions | null): void;
|
|
1729
1729
|
setHeadlessUtils(value: HeadlessUtilsContextType): void;
|
|
1730
1730
|
setConfiguration(value: ConfigurationContextType): void;
|
|
1731
|
-
getConfiguration(): ConfigurationContextType | undefined;
|
|
1732
1731
|
setAnalyticsUtils(value: AnalyticsContextType): void;
|
|
1733
1732
|
getAnalyticsUtils(): AnalyticsContextType | undefined;
|
|
1734
1733
|
setComputedStyles(value: CSSStyleDeclaration): void;
|
package/dist/primer-loader.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Yo,b as s,c as T}from"./chunks/chunk.DV3REKZU.js";var Cr=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 Lt=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 at=class extends Event{constructor(t,e,r,o){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e,this.callback=r,this.subscribe=o??!1}};var Rt=class{constructor(t,e,r,o){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(a,n)=>{this.unsubscribe&&(this.unsubscribe!==n&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=a,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(a,n)),this.unsubscribe=n},this.host=t,e.context!==void 0){let a=e;this.context=a.context,this.callback=a.callback,this.subscribe=a.subscribe??!1}else this.context=e,this.callback=r,this.subscribe=o??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new at(this.context,this.host,this.t,this.subscribe))}};var Er=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 ki=class extends Event{constructor(t,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e}},F=class extends Er{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:l}]of this.subscriptions)a.has(n)||(a.add(n),l.dispatchEvent(new at(this.context,l,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 ki(this.context,this.host))}};function E({context:i,subscribe:t}){return(e,r)=>{typeof r=="object"?r.addInitializer((function(){new Rt(this,{context:i,callback:o=>{e.set.call(this,o)},subscribe:t})})):e.constructor.addInitializer((o=>{new Rt(o,{context:i,callback:a=>{o[r]=a},subscribe:t})}))}}var nt=Symbol("analytics-context");var Ot=Symbol("events-context");var xr="cardNetworksContext";var pe="clientOptionsContext";var Dt="computedStylesContext";var Y="headlessInstanceContext";var Ar="configuration";var Sr="klarnaCategoriesContext";var z="managerContext";var st="paymentMethodsContext";var K="sdkStateContext";var me="vaultManagerContext";var Ie="vaultManagerCvvContext";var Fs={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 Ho(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"){x.debug("\u{1F436}\u{1F436}\u{1F436} [Datadog Log] \u{1F436}\u{1F436}\u{1F436}",i);return}let r=Fs[t||"LOCAL"];if(!r){x.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=>{x.error("Failed to send log event:",o)})}var D=class D{static log(t,...e){D.enabled}static info(t,...e){D.enabled}static warn(t,...e){D.enabled}static error(t,...e){D.enabled&&e.forEach(r=>{r instanceof Error&&r.toJSON})}static errorWithDatadog(t,e){let{error:r,status:o="error"}=e||{};if(D.enabled){r instanceof Error&&r.toJSON;try{let a=r||t,n={environment:D.environment,sdkVersion:D.sdkVersion,clientSessionToken:D.clientSessionToken,clientSessionId:D.clientSessionId,status:o,metadata:{sdkOptions:D.sdkOptions,clientToken:D.clientToken}};Ho(a,n)}catch{D.enabled}}}static debug(t,...e){D.enabled}static table(t,e){D.enabled}static time(t){D.enabled}static timeEnd(t){D.enabled}static setEnvironment(t){D.environment=t}static setSdkVersion(t){D.sdkVersion=t}static setClientSessionToken(t){D.clientSessionToken=t}static setClientSessionId(t){D.clientSessionId=t}static setSdkOptions(t){D.sdkOptions=t}static setClientToken(t){D.clientToken=t}};T(D,"enabled",!0),T(D,"environment"),T(D,"sdkVersion"),T(D,"clientSessionToken"),T(D,"clientSessionId"),T(D,"sdkOptions"),T(D,"clientToken"),T(D,"defaultFont","font-family: Consolas, monospace; font-size: 12px;"),T(D,"brandTag","[PRIMER]"),T(D,"brandStyle",`background: #24292e; color: #ffffff; padding: 2px 6px; border-radius: 3px; font-weight: bold; margin-right: 4px; ${D.defaultFont}`),T(D,"styles",{log:`color: #4CAF50; ${D.defaultFont}`,info:`color: #2196F3; ${D.defaultFont}`,warn:`color: #FF9800; ${D.defaultFont}`,error:`color: #F44336; ${D.defaultFont}`,debug:`color: #9C27B0; ${D.defaultFont}`});var x=D;function Ks(i,t,e,r){let o=i,a=e;return{dispatch:n=>{let l=t(o,n,a);o=l,r(l)},getState:()=>Object.freeze({...o}),setCallbacks:n=>{a={...a,...n}}}}function Wt(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 bt=class{constructor(t,e,r,o,a=()=>{this.host.requestUpdate()}){this.host=t;this.stateHandler=a;this.host.addController(this),this._dispatcher=Ks(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(){}},_r=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 wr={isSuccessful:!1,isProcessing:!1,isLoading:!1,error:null,failure:null},js={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)=>(x.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:()=>wr,RESET_ERROR:i=>({...i,error:null,failure:null})},Gs=Wt(js),Pr=class extends bt{constructor(t){super(t,wr,Gs,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&&(x.warn("Force completing loading state"),this.completeLoading())}};var Tr=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 F(t,{context:K,initialValue:wr}),this.paymentMethodsProvider=new F(t,{context:st,initialValue:null}),this.paymentManagerProvider=new F(t,{context:z,initialValue:new Map}),this.cardNetworksContext=new F(t,{context:xr,initialValue:null}),this.vaultManagerProvider=new F(t,{context:me,initialValue:null}),this.vaultManagerCvvProvider=new F(t,{context:Ie,initialValue:null}),this.clientOptionsContext=new F(t,{context:pe,initialValue:null}),this.klarnaCategoriesProvider=new F(t,{context:Sr,initialValue:{categories:[],isLoading:!0}}),this.headlessUtilsProvider=new F(t,{context:Y,initialValue:null}),this.configurationProvider=new F(t,{context:Ar,initialValue:null}),this.computedStylesProvider=new F(t,{context:Dt,initialValue:null}),this.analyticsProvider=new F(t,{context:nt,initialValue:null}),this.eventsProvider=new F(t,{context:Ot,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)}getConfiguration(){return this.configurationProvider?.value}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 Ct=class Ct{constructor(t){(this.host=t).addController(this)}processCustomStyles(t){try{let e=JSON.parse(t);this.applyStyles(e)}catch(e){x.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||x.warn(`Rejected potentially unsafe CSS value: ${t}`),r}getCssVarName(t){let e=Ct.cssVarCache.get(t);return e||(e=`--${t.replace(/([A-Z])/g,(r,o)=>`-${o.toLowerCase()}`)}`,Ct.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)){x.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 Ct.cssVarCache.keys()){let e=Ct.cssVarCache.get(t);e&&this.host.style.removeProperty(e)}}hostDisconnected(){}};Ct.cssVarCache=new Map;var Mr=Ct;var kr=globalThis,Nr=kr.ShadowRoot&&(kr.ShadyCSS===void 0||kr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,zo=Symbol(),Fo=new WeakMap,Ir=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==zo)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(Nr&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=Fo.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&Fo.set(e,t))}return t}toString(){return this.cssText}},Ko=i=>new Ir(typeof i=="string"?i:i+"",void 0,zo);var Ii=(i,t)=>{if(Nr)i.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of t){let r=document.createElement("style"),o=kr.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=e.cssText,i.appendChild(r)}},Lr=Nr?i=>i:i=>i instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return Ko(e)})(i):i;var{is:Ws,defineProperty:qs,getOwnPropertyDescriptor:Js,getOwnPropertyNames:Zs,getOwnPropertySymbols:Xs,getPrototypeOf:Qs}=Object,lt=globalThis,jo=lt.trustedTypes,el=jo?jo.emptyScript:"",tl=lt.reactiveElementPolyfillSupport,qt=(i,t)=>i,Ni={toAttribute(i,t){switch(t){case Boolean:i=i?el: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}},Rr=(i,t)=>!Ws(i,t),Go={attribute:!0,type:String,converter:Ni,reflect:!1,hasChanged:Rr};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),lt.litPropertyMetadata??(lt.litPropertyMetadata=new WeakMap);var Et=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=Go){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&&qs(this.prototype,t,o)}}static getPropertyDescriptor(t,e,r){let{get:o,set:a}=Js(this.prototype,t)??{get(){return this[e]},set(n){this[e]=n}};return{get(){return o?.call(this)},set(n){let l=o?.call(this);a.call(this,n),this.requestUpdate(t,l,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Go}static _$Ei(){if(this.hasOwnProperty(qt("elementProperties")))return;let t=Qs(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(qt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(qt("properties"))){let e=this.properties,r=[...Zs(e),...Xs(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(Lr(o))}else t!==void 0&&e.push(Lr(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 Ii(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:Ni).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:Ni;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??Rr)(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){}};Et.elementStyles=[],Et.shadowRootOptions={mode:"open"},Et[qt("elementProperties")]=new Map,Et[qt("finalized")]=new Map,tl?.({ReactiveElement:Et}),(lt.reactiveElementVersions??(lt.reactiveElementVersions=[])).push("2.0.4");var dt={INITIAL:0,PENDING:1,COMPLETE:2,ERROR:3},N=Symbol(),O=class{get taskComplete(){return this.t||(this.i===1?this.t=new Promise(((t,e)=>{this.o=t,this.h=e})):this.i===3?this.t=Promise.reject(this.l):this.t=Promise.resolve(this.u)),this.t}constructor(t,e,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??Wo,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===N)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)}}},Wo=(i,t)=>i===t||i.length===t.length&&i.every(((e,r)=>!Rr(e,t[r])));var rl={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:()=>qo},il={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:()=>Jo},ol=Wt(rl),al=Wt(il),qo={enabled:!1,isLoading:!1,isUpdating:!1,cvvRecapture:!1,showEmptyState:!0,vaultedPaymentMethods:[],createCvvInput:null,deleteVaultedPaymentMethod:()=>Promise.resolve(),startVaultedPaymentFlow:()=>Promise.resolve()},Jo={cvvInput:null,formIsDirty:!1,setCvvInput:()=>{},selectedVaultedPaymentMethod:null,setSelectedVaultedPaymentMethod:()=>{}},Li=class extends bt{constructor(t,e){super(t,qo,ol,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"})}},Ri=class extends bt{constructor(t,e){super(t,Jo,al,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"})}},Jt=class extends _r{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){x.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 Li(e,{deleteVaultedPaymentMethod:this.deleteVaultedPaymentMethod.bind(this),startVaultedPaymentFlow:this.startVaultedPaymentFlow.bind(this),createCvvInput:this.createCvvInput}),this.itemController=new Ri(e,{setCvvInput:this.setCvvInput.bind(this),setSelectedVaultedPaymentMethod:this.setSelectedVaultedPaymentMethod.bind(this)}),this.addController(this.coreController),this.addController(this.itemController),new O(this.host,{task:async([r,o])=>{if(!r||!o?.vaultEnabled)return this.coreController.disable(),N;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),x.log("VaultManagerController: Vault initialized successfully",{coreState:this.coreController.currentState,cvvState:this.itemController.currentState})}catch(a){x.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 x.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 Zo=()=>Xo.randomUUID?.()||nl(),nl=()=>("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,i=>(i^sl()>>i/4).toString(16)),sl=()=>(Xo.getRandomValues?.(new Uint8Array(1))[0]??Math.random()*16)&15,Xo=typeof crypto<"u"?crypto:{};var ll={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"},Oi=class{constructor(){T(this,"sessionConfig",null)}initialize(t){this.sessionConfig=t}clear(){this.sessionConfig=null}getSessionConfig(){return this.sessionConfig}sendEvent(t){if(!this.sessionConfig){x.error("Analytics manager not initialized. Call initializeAnalytics() first.");return}let e={id:Zo(),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};dl(e,this.sessionConfig)}},Di=new Oi;function Qo(i){Di.initialize(i)}function q(i){Di.sendEvent(i)}function ea(){Di.clear()}async function dl(i,{environment:t,clientSessionToken:e}){if(t==="LOCAL"){x.debug(`Analytics event ${i.eventName}:`,i);return}let r=ll[t];return fetch(r,{method:"POST",headers:{"Content-Type":"application/json",...e&&{Authorization:`Bearer ${e}`}},body:JSON.stringify(i)}).catch(o=>{x.error("Failed to send analytics event:",o)})}var Zt="lit-localize-status";var ta=i=>typeof i!="string"&&"strTag"in i,Or=(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 Xt=(i=>ta(i)?Or(i.strings,i.values):i);var C=Xt,ra=!1;function $i(i){if(ra)throw new Error("lit-localize can only be configured once");C=i,ra=!0}var Vi=class{constructor(t){this.__litLocalizeEventHandler=e=>{e.detail.status==="ready"&&this.host.requestUpdate()},this.host=t}hostConnected(){window.addEventListener(Zt,this.__litLocalizeEventHandler)}hostDisconnected(){window.removeEventListener(Zt,this.__litLocalizeEventHandler)}},cl=i=>i.addController(new Vi(i)),ia=cl;var R=()=>(i,t)=>(i.addInitializer(ia),i);var Qt=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 je=[];for(let i=0;i<256;i++)je[i]=(i>>4&15).toString(16)+(i&15).toString(16);function oa(i){let t=0,e=8997,r=0,o=33826,a=0,n=40164,l=0,d=52210;for(let c=0;c<i.length;c++)e^=i.charCodeAt(c),t=e*435,r=o*435,a=n*435,l=d*435,a+=e<<8,l+=o<<8,r+=t>>>16,e=t&65535,a+=r>>>16,o=r&65535,d=l+(a>>>16)&65535,n=a&65535;return je[d>>8]+je[d&255]+je[n>>8]+je[n&255]+je[o>>8]+je[o&255]+je[e>>8]+je[e&255]}var pl="",ml="h",ul="s";function aa(i,t){return(t?ml:ul)+oa(typeof i=="string"?i:i.join(pl))}var na=new WeakMap,sa=new Map;function la(i,t,e){if(i){let r=e?.id??hl(t),o=i[r];if(o){if(typeof o=="string")return o;if("strTag"in o)return Or(o.strings,t.values,o.values);{let a=na.get(o);return a===void 0&&(a=o.values,na.set(o,a)),{...o,values:a.map(n=>t.values[n])}}}}return Xt(t)}function hl(i){let t=typeof i=="string"?i:i.strings,e=sa.get(t);return e===void 0&&(e=aa(t,typeof i!="string"&&!("strTag"in i)),sa.set(t,e)),e}function Ui(i){window.dispatchEvent(new CustomEvent(Zt,{detail:i}))}var $r="",Bi,da,Vr,Yi,ca,xt=new Qt;xt.resolve();var Dr=0,pa=i=>($i(((t,e)=>la(ca,t,e))),$r=da=i.sourceLocale,Vr=new Set(i.targetLocales),Vr.add(i.sourceLocale),Yi=i.loadLocale,{getLocale:fl,setLocale:gl}),fl=()=>$r,gl=i=>{if(i===(Bi??$r))return xt.promise;if(!Vr||!Yi)throw new Error("Internal error");if(!Vr.has(i))throw new Error("Invalid locale code");Dr++;let t=Dr;return Bi=i,xt.settled&&(xt=new Qt),Ui({status:"loading",loadingLocale:i}),(i===da?Promise.resolve({templates:void 0}):Yi(i)).then(r=>{Dr===t&&($r=i,Bi=void 0,ca=r.templates,Ui({status:"ready",readyLocale:i}),xt.resolve())},r=>{Dr===t&&(Ui({status:"error",errorLocale:i,errorMessage:r.toString()}),xt.reject(r))}),xt.promise};var Hi="en",Fi=["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"],zi="You must call `loadLocale` first to set up the localized template.",Ur,Br,ma=i=>{let t=pa({sourceLocale:Hi,targetLocales:Fi,loadLocale:i});Ur=t.getLocale,Br=t.setLocale};var Ki=i=>{ma(i)},ji=i=>{if(!Br)throw new Error(zi);return Br(i)},Gi=()=>{if(!Ur)throw new Error(zi);return Ur()};var er=new Set(Fi);er.add(Hi);var Wi=i=>{if(typeof i!="string")return!1;if(i==="en")return!0;let t=i.replace("_","-");if(er.has(t))return!0;let e=t.split("-")[0];return!!er.has(e)},qi=i=>{if(i==="en")return"en-GB";let t=i.replace("_","-");if(er.has(t))return t;let e=t.split("-")[0];return er.has(e)?e:"en-GB"};var Yr=globalThis,Hr=Yr.ShadowRoot&&(Yr.ShadyCSS===void 0||Yr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ji=Symbol(),ua=new WeakMap,tr=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==Ji)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(Hr&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=ua.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&ua.set(e,t))}return t}toString(){return this.cssText}},xe=i=>new tr(typeof i=="string"?i:i+"",void 0,Ji),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 tr(e,i,Ji)},ha=(i,t)=>{if(Hr)i.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of t){let r=document.createElement("style"),o=Yr.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=e.cssText,i.appendChild(r)}},Zi=Hr?i=>i:i=>i instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return xe(e)})(i):i;var{is:yl,defineProperty:vl,getOwnPropertyDescriptor:bl,getOwnPropertyNames:Cl,getOwnPropertySymbols:El,getPrototypeOf:xl}=Object,ct=globalThis,fa=ct.trustedTypes,Al=fa?fa.emptyScript:"",Sl=ct.reactiveElementPolyfillSupport,rr=(i,t)=>i,ir={toAttribute(i,t){switch(t){case Boolean:i=i?Al: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}},Fr=(i,t)=>!yl(i,t),ga={attribute:!0,type:String,converter:ir,reflect:!1,useDefault:!1,hasChanged:Fr};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),ct.litPropertyMetadata??(ct.litPropertyMetadata=new WeakMap);var Ge=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=ga){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&&vl(this.prototype,t,o)}}static getPropertyDescriptor(t,e,r){let{get:o,set:a}=bl(this.prototype,t)??{get(){return this[e]},set(n){this[e]=n}};return{get:o,set(n){let l=o?.call(this);a?.call(this,n),this.requestUpdate(t,l,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??ga}static _$Ei(){if(this.hasOwnProperty(rr("elementProperties")))return;let t=xl(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=[...Cl(e),...El(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(Zi(o))}else t!==void 0&&e.push(Zi(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 ha(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:ir).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:ir;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??Fr)(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,l=this[o];n!==!0||this._$AL.has(o)||l===void 0||this.C(o,void 0,a,l)}}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){}};Ge.elementStyles=[],Ge.shadowRootOptions={mode:"open"},Ge[rr("elementProperties")]=new Map,Ge[rr("finalized")]=new Map,Sl?.({ReactiveElement:Ge}),(ct.reactiveElementVersions??(ct.reactiveElementVersions=[])).push("2.1.0");var ar=globalThis,zr=ar.trustedTypes,ya=zr?zr.createPolicy("lit-html",{createHTML:i=>i}):void 0,Qi="$lit$",We=`lit$${Math.random().toFixed(9).slice(2)}$`,eo="?"+We,_l=`<${eo}>`,_t=document,nr=()=>_t.createComment(""),sr=i=>i===null||typeof i!="object"&&typeof i!="function",to=Array.isArray,Aa=i=>to(i)||typeof i?.[Symbol.iterator]=="function",Xi=`[
|
|
1
|
+
import{a as Yo,b as s,c as T}from"./chunks/chunk.DV3REKZU.js";var Cr=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 Lt=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 at=class extends Event{constructor(t,e,r,o){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e,this.callback=r,this.subscribe=o??!1}};var Rt=class{constructor(t,e,r,o){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(a,n)=>{this.unsubscribe&&(this.unsubscribe!==n&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=a,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(a,n)),this.unsubscribe=n},this.host=t,e.context!==void 0){let a=e;this.context=a.context,this.callback=a.callback,this.subscribe=a.subscribe??!1}else this.context=e,this.callback=r,this.subscribe=o??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new at(this.context,this.host,this.t,this.subscribe))}};var Er=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 ki=class extends Event{constructor(t,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e}},F=class extends Er{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:l}]of this.subscriptions)a.has(n)||(a.add(n),l.dispatchEvent(new at(this.context,l,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 ki(this.context,this.host))}};function E({context:i,subscribe:t}){return(e,r)=>{typeof r=="object"?r.addInitializer((function(){new Rt(this,{context:i,callback:o=>{e.set.call(this,o)},subscribe:t})})):e.constructor.addInitializer((o=>{new Rt(o,{context:i,callback:a=>{o[r]=a},subscribe:t})}))}}var nt=Symbol("analytics-context");var Ot=Symbol("events-context");var xr="cardNetworksContext";var pe="clientOptionsContext";var Dt="computedStylesContext";var Y="headlessInstanceContext";var Ar="configuration";var Sr="klarnaCategoriesContext";var z="managerContext";var st="paymentMethodsContext";var K="sdkStateContext";var me="vaultManagerContext";var Ie="vaultManagerCvvContext";var Fs={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 Ho(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"){x.debug("\u{1F436}\u{1F436}\u{1F436} [Datadog Log] \u{1F436}\u{1F436}\u{1F436}",i);return}let r=Fs[t||"LOCAL"];if(!r){x.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=>{x.error("Failed to send log event:",o)})}var D=class D{static log(t,...e){D.enabled}static info(t,...e){D.enabled}static warn(t,...e){D.enabled}static error(t,...e){D.enabled&&e.forEach(r=>{r instanceof Error&&r.toJSON})}static errorWithDatadog(t,e){let{error:r,status:o="error"}=e||{};if(D.enabled){r instanceof Error&&r.toJSON;try{let a=r||t,n={environment:D.environment,sdkVersion:D.sdkVersion,clientSessionToken:D.clientSessionToken,clientSessionId:D.clientSessionId,status:o,metadata:{sdkOptions:D.sdkOptions,clientToken:D.clientToken}};Ho(a,n)}catch{D.enabled}}}static debug(t,...e){D.enabled}static table(t,e){D.enabled}static time(t){D.enabled}static timeEnd(t){D.enabled}static setEnvironment(t){D.environment=t}static setSdkVersion(t){D.sdkVersion=t}static setClientSessionToken(t){D.clientSessionToken=t}static setClientSessionId(t){D.clientSessionId=t}static setSdkOptions(t){D.sdkOptions=t}static setClientToken(t){D.clientToken=t}};T(D,"enabled",!0),T(D,"environment"),T(D,"sdkVersion"),T(D,"clientSessionToken"),T(D,"clientSessionId"),T(D,"sdkOptions"),T(D,"clientToken"),T(D,"defaultFont","font-family: Consolas, monospace; font-size: 12px;"),T(D,"brandTag","[PRIMER]"),T(D,"brandStyle",`background: #24292e; color: #ffffff; padding: 2px 6px; border-radius: 3px; font-weight: bold; margin-right: 4px; ${D.defaultFont}`),T(D,"styles",{log:`color: #4CAF50; ${D.defaultFont}`,info:`color: #2196F3; ${D.defaultFont}`,warn:`color: #FF9800; ${D.defaultFont}`,error:`color: #F44336; ${D.defaultFont}`,debug:`color: #9C27B0; ${D.defaultFont}`});var x=D;function Ks(i,t,e,r){let o=i,a=e;return{dispatch:n=>{let l=t(o,n,a);o=l,r(l)},getState:()=>Object.freeze({...o}),setCallbacks:n=>{a={...a,...n}}}}function Wt(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 bt=class{constructor(t,e,r,o,a=()=>{this.host.requestUpdate()}){this.host=t;this.stateHandler=a;this.host.addController(this),this._dispatcher=Ks(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(){}},_r=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 wr={isSuccessful:!1,isProcessing:!1,isLoading:!1,error:null,failure:null},js={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)=>(x.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:()=>wr,RESET_ERROR:i=>({...i,error:null,failure:null})},Gs=Wt(js),Pr=class extends bt{constructor(t){super(t,wr,Gs,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&&(x.warn("Force completing loading state"),this.completeLoading())}};var Tr=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 F(t,{context:K,initialValue:wr}),this.paymentMethodsProvider=new F(t,{context:st,initialValue:null}),this.paymentManagerProvider=new F(t,{context:z,initialValue:new Map}),this.cardNetworksContext=new F(t,{context:xr,initialValue:null}),this.vaultManagerProvider=new F(t,{context:me,initialValue:null}),this.vaultManagerCvvProvider=new F(t,{context:Ie,initialValue:null}),this.clientOptionsContext=new F(t,{context:pe,initialValue:null}),this.klarnaCategoriesProvider=new F(t,{context:Sr,initialValue:{categories:[],isLoading:!0}}),this.headlessUtilsProvider=new F(t,{context:Y,initialValue:null}),this.configurationProvider=new F(t,{context:Ar,initialValue:null}),this.computedStylesProvider=new F(t,{context:Dt,initialValue:null}),this.analyticsProvider=new F(t,{context:nt,initialValue:null}),this.eventsProvider=new F(t,{context:Ot,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 Ct=class Ct{constructor(t){(this.host=t).addController(this)}processCustomStyles(t){try{let e=JSON.parse(t);this.applyStyles(e)}catch(e){x.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||x.warn(`Rejected potentially unsafe CSS value: ${t}`),r}getCssVarName(t){let e=Ct.cssVarCache.get(t);return e||(e=`--${t.replace(/([A-Z])/g,(r,o)=>`-${o.toLowerCase()}`)}`,Ct.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)){x.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 Ct.cssVarCache.keys()){let e=Ct.cssVarCache.get(t);e&&this.host.style.removeProperty(e)}}hostDisconnected(){}};Ct.cssVarCache=new Map;var Mr=Ct;var kr=globalThis,Nr=kr.ShadowRoot&&(kr.ShadyCSS===void 0||kr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,zo=Symbol(),Fo=new WeakMap,Ir=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==zo)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(Nr&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=Fo.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&Fo.set(e,t))}return t}toString(){return this.cssText}},Ko=i=>new Ir(typeof i=="string"?i:i+"",void 0,zo);var Ii=(i,t)=>{if(Nr)i.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of t){let r=document.createElement("style"),o=kr.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=e.cssText,i.appendChild(r)}},Lr=Nr?i=>i:i=>i instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return Ko(e)})(i):i;var{is:Ws,defineProperty:qs,getOwnPropertyDescriptor:Js,getOwnPropertyNames:Zs,getOwnPropertySymbols:Xs,getPrototypeOf:Qs}=Object,lt=globalThis,jo=lt.trustedTypes,el=jo?jo.emptyScript:"",tl=lt.reactiveElementPolyfillSupport,qt=(i,t)=>i,Ni={toAttribute(i,t){switch(t){case Boolean:i=i?el: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}},Rr=(i,t)=>!Ws(i,t),Go={attribute:!0,type:String,converter:Ni,reflect:!1,hasChanged:Rr};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),lt.litPropertyMetadata??(lt.litPropertyMetadata=new WeakMap);var Et=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=Go){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&&qs(this.prototype,t,o)}}static getPropertyDescriptor(t,e,r){let{get:o,set:a}=Js(this.prototype,t)??{get(){return this[e]},set(n){this[e]=n}};return{get(){return o?.call(this)},set(n){let l=o?.call(this);a.call(this,n),this.requestUpdate(t,l,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Go}static _$Ei(){if(this.hasOwnProperty(qt("elementProperties")))return;let t=Qs(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(qt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(qt("properties"))){let e=this.properties,r=[...Zs(e),...Xs(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(Lr(o))}else t!==void 0&&e.push(Lr(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 Ii(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:Ni).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:Ni;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??Rr)(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){}};Et.elementStyles=[],Et.shadowRootOptions={mode:"open"},Et[qt("elementProperties")]=new Map,Et[qt("finalized")]=new Map,tl?.({ReactiveElement:Et}),(lt.reactiveElementVersions??(lt.reactiveElementVersions=[])).push("2.0.4");var dt={INITIAL:0,PENDING:1,COMPLETE:2,ERROR:3},N=Symbol(),O=class{get taskComplete(){return this.t||(this.i===1?this.t=new Promise(((t,e)=>{this.o=t,this.h=e})):this.i===3?this.t=Promise.reject(this.l):this.t=Promise.resolve(this.u)),this.t}constructor(t,e,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??Wo,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===N)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)}}},Wo=(i,t)=>i===t||i.length===t.length&&i.every(((e,r)=>!Rr(e,t[r])));var rl={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:()=>qo},il={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:()=>Jo},ol=Wt(rl),al=Wt(il),qo={enabled:!1,isLoading:!1,isUpdating:!1,cvvRecapture:!1,showEmptyState:!0,vaultedPaymentMethods:[],createCvvInput:null,deleteVaultedPaymentMethod:()=>Promise.resolve(),startVaultedPaymentFlow:()=>Promise.resolve()},Jo={cvvInput:null,formIsDirty:!1,setCvvInput:()=>{},selectedVaultedPaymentMethod:null,setSelectedVaultedPaymentMethod:()=>{}},Li=class extends bt{constructor(t,e){super(t,qo,ol,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"})}},Ri=class extends bt{constructor(t,e){super(t,Jo,al,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"})}},Jt=class extends _r{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){x.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 Li(e,{deleteVaultedPaymentMethod:this.deleteVaultedPaymentMethod.bind(this),startVaultedPaymentFlow:this.startVaultedPaymentFlow.bind(this),createCvvInput:this.createCvvInput}),this.itemController=new Ri(e,{setCvvInput:this.setCvvInput.bind(this),setSelectedVaultedPaymentMethod:this.setSelectedVaultedPaymentMethod.bind(this)}),this.addController(this.coreController),this.addController(this.itemController),new O(this.host,{task:async([r,o])=>{if(!r||!o?.vaultEnabled)return this.coreController.disable(),N;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),x.log("VaultManagerController: Vault initialized successfully",{coreState:this.coreController.currentState,cvvState:this.itemController.currentState})}catch(a){x.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 x.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 Zo=()=>Xo.randomUUID?.()||nl(),nl=()=>("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,i=>(i^sl()>>i/4).toString(16)),sl=()=>(Xo.getRandomValues?.(new Uint8Array(1))[0]??Math.random()*16)&15,Xo=typeof crypto<"u"?crypto:{};var ll={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"},Oi=class{constructor(){T(this,"sessionConfig",null)}initialize(t){this.sessionConfig=t}clear(){this.sessionConfig=null}getSessionConfig(){return this.sessionConfig}sendEvent(t){if(!this.sessionConfig){x.error("Analytics manager not initialized. Call initializeAnalytics() first.");return}let e={id:Zo(),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};dl(e,this.sessionConfig)}},Di=new Oi;function Qo(i){Di.initialize(i)}function q(i){Di.sendEvent(i)}function ea(){Di.clear()}async function dl(i,{environment:t,clientSessionToken:e}){if(t==="LOCAL"){x.debug(`Analytics event ${i.eventName}:`,i);return}let r=ll[t];return fetch(r,{method:"POST",headers:{"Content-Type":"application/json",...e&&{Authorization:`Bearer ${e}`}},body:JSON.stringify(i)}).catch(o=>{x.error("Failed to send analytics event:",o)})}var Zt="lit-localize-status";var ta=i=>typeof i!="string"&&"strTag"in i,Or=(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 Xt=(i=>ta(i)?Or(i.strings,i.values):i);var C=Xt,ra=!1;function $i(i){if(ra)throw new Error("lit-localize can only be configured once");C=i,ra=!0}var Vi=class{constructor(t){this.__litLocalizeEventHandler=e=>{e.detail.status==="ready"&&this.host.requestUpdate()},this.host=t}hostConnected(){window.addEventListener(Zt,this.__litLocalizeEventHandler)}hostDisconnected(){window.removeEventListener(Zt,this.__litLocalizeEventHandler)}},cl=i=>i.addController(new Vi(i)),ia=cl;var R=()=>(i,t)=>(i.addInitializer(ia),i);var Qt=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 je=[];for(let i=0;i<256;i++)je[i]=(i>>4&15).toString(16)+(i&15).toString(16);function oa(i){let t=0,e=8997,r=0,o=33826,a=0,n=40164,l=0,d=52210;for(let c=0;c<i.length;c++)e^=i.charCodeAt(c),t=e*435,r=o*435,a=n*435,l=d*435,a+=e<<8,l+=o<<8,r+=t>>>16,e=t&65535,a+=r>>>16,o=r&65535,d=l+(a>>>16)&65535,n=a&65535;return je[d>>8]+je[d&255]+je[n>>8]+je[n&255]+je[o>>8]+je[o&255]+je[e>>8]+je[e&255]}var pl="",ml="h",ul="s";function aa(i,t){return(t?ml:ul)+oa(typeof i=="string"?i:i.join(pl))}var na=new WeakMap,sa=new Map;function la(i,t,e){if(i){let r=e?.id??hl(t),o=i[r];if(o){if(typeof o=="string")return o;if("strTag"in o)return Or(o.strings,t.values,o.values);{let a=na.get(o);return a===void 0&&(a=o.values,na.set(o,a)),{...o,values:a.map(n=>t.values[n])}}}}return Xt(t)}function hl(i){let t=typeof i=="string"?i:i.strings,e=sa.get(t);return e===void 0&&(e=aa(t,typeof i!="string"&&!("strTag"in i)),sa.set(t,e)),e}function Ui(i){window.dispatchEvent(new CustomEvent(Zt,{detail:i}))}var $r="",Bi,da,Vr,Yi,ca,xt=new Qt;xt.resolve();var Dr=0,pa=i=>($i(((t,e)=>la(ca,t,e))),$r=da=i.sourceLocale,Vr=new Set(i.targetLocales),Vr.add(i.sourceLocale),Yi=i.loadLocale,{getLocale:fl,setLocale:gl}),fl=()=>$r,gl=i=>{if(i===(Bi??$r))return xt.promise;if(!Vr||!Yi)throw new Error("Internal error");if(!Vr.has(i))throw new Error("Invalid locale code");Dr++;let t=Dr;return Bi=i,xt.settled&&(xt=new Qt),Ui({status:"loading",loadingLocale:i}),(i===da?Promise.resolve({templates:void 0}):Yi(i)).then(r=>{Dr===t&&($r=i,Bi=void 0,ca=r.templates,Ui({status:"ready",readyLocale:i}),xt.resolve())},r=>{Dr===t&&(Ui({status:"error",errorLocale:i,errorMessage:r.toString()}),xt.reject(r))}),xt.promise};var Hi="en",Fi=["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"],zi="You must call `loadLocale` first to set up the localized template.",Ur,Br,ma=i=>{let t=pa({sourceLocale:Hi,targetLocales:Fi,loadLocale:i});Ur=t.getLocale,Br=t.setLocale};var Ki=i=>{ma(i)},ji=i=>{if(!Br)throw new Error(zi);return Br(i)},Gi=()=>{if(!Ur)throw new Error(zi);return Ur()};var er=new Set(Fi);er.add(Hi);var Wi=i=>{if(typeof i!="string")return!1;if(i==="en")return!0;let t=i.replace("_","-");if(er.has(t))return!0;let e=t.split("-")[0];return!!er.has(e)},qi=i=>{if(i==="en")return"en-GB";let t=i.replace("_","-");if(er.has(t))return t;let e=t.split("-")[0];return er.has(e)?e:"en-GB"};var Yr=globalThis,Hr=Yr.ShadowRoot&&(Yr.ShadyCSS===void 0||Yr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ji=Symbol(),ua=new WeakMap,tr=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==Ji)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(Hr&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=ua.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&ua.set(e,t))}return t}toString(){return this.cssText}},xe=i=>new tr(typeof i=="string"?i:i+"",void 0,Ji),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 tr(e,i,Ji)},ha=(i,t)=>{if(Hr)i.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of t){let r=document.createElement("style"),o=Yr.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=e.cssText,i.appendChild(r)}},Zi=Hr?i=>i:i=>i instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return xe(e)})(i):i;var{is:yl,defineProperty:vl,getOwnPropertyDescriptor:bl,getOwnPropertyNames:Cl,getOwnPropertySymbols:El,getPrototypeOf:xl}=Object,ct=globalThis,fa=ct.trustedTypes,Al=fa?fa.emptyScript:"",Sl=ct.reactiveElementPolyfillSupport,rr=(i,t)=>i,ir={toAttribute(i,t){switch(t){case Boolean:i=i?Al: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}},Fr=(i,t)=>!yl(i,t),ga={attribute:!0,type:String,converter:ir,reflect:!1,useDefault:!1,hasChanged:Fr};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),ct.litPropertyMetadata??(ct.litPropertyMetadata=new WeakMap);var Ge=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=ga){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&&vl(this.prototype,t,o)}}static getPropertyDescriptor(t,e,r){let{get:o,set:a}=bl(this.prototype,t)??{get(){return this[e]},set(n){this[e]=n}};return{get:o,set(n){let l=o?.call(this);a?.call(this,n),this.requestUpdate(t,l,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??ga}static _$Ei(){if(this.hasOwnProperty(rr("elementProperties")))return;let t=xl(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=[...Cl(e),...El(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(Zi(o))}else t!==void 0&&e.push(Zi(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 ha(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:ir).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:ir;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??Fr)(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,l=this[o];n!==!0||this._$AL.has(o)||l===void 0||this.C(o,void 0,a,l)}}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){}};Ge.elementStyles=[],Ge.shadowRootOptions={mode:"open"},Ge[rr("elementProperties")]=new Map,Ge[rr("finalized")]=new Map,Sl?.({ReactiveElement:Ge}),(ct.reactiveElementVersions??(ct.reactiveElementVersions=[])).push("2.1.0");var ar=globalThis,zr=ar.trustedTypes,ya=zr?zr.createPolicy("lit-html",{createHTML:i=>i}):void 0,Qi="$lit$",We=`lit$${Math.random().toFixed(9).slice(2)}$`,eo="?"+We,_l=`<${eo}>`,_t=document,nr=()=>_t.createComment(""),sr=i=>i===null||typeof i!="object"&&typeof i!="function",to=Array.isArray,Aa=i=>to(i)||typeof i?.[Symbol.iterator]=="function",Xi=`[
|
|
2
2
|
\f\r]`,or=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,va=/-->/g,ba=/>/g,At=RegExp(`>|${Xi}(?:([^\\s"'>=/]+)(${Xi}*=${Xi}*(?:[^
|
|
3
3
|
\f\r"'\`<>=]|("|')|))|$)`,"g"),Ca=/'/g,Ea=/"/g,Sa=/^(?:script|style|textarea|title)$/i,ro=i=>(t,...e)=>({_$litType$:i,strings:t,values:e}),m=ro(1),Ne=ro(2),Su=ro(3),te=Symbol.for("lit-noChange"),h=Symbol.for("lit-nothing"),xa=new WeakMap,St=_t.createTreeWalker(_t,129);function _a(i,t){if(!to(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return ya!==void 0?ya.createHTML(t):t}var Pa=(i,t)=>{let e=i.length-1,r=[],o,a=t===2?"<svg>":t===3?"<math>":"",n=or;for(let l=0;l<e;l++){let d=i[l],c,u,f=-1,g=0;for(;g<d.length&&(n.lastIndex=g,u=n.exec(d),u!==null);)g=n.lastIndex,n===or?u[1]==="!--"?n=va:u[1]!==void 0?n=ba:u[2]!==void 0?(Sa.test(u[2])&&(o=RegExp("</"+u[2],"g")),n=At):u[3]!==void 0&&(n=At):n===At?u[0]===">"?(n=o??or,f=-1):u[1]===void 0?f=-2:(f=n.lastIndex-u[2].length,c=u[1],n=u[3]===void 0?At:u[3]==='"'?Ea:Ca):n===Ea||n===Ca?n=At:n===va||n===ba?n=or:(n=At,o=void 0);let A=n===At&&i[l+1].startsWith("/>")?" ":"";a+=n===or?d+_l:f>=0?(r.push(c),d.slice(0,f)+Qi+d.slice(f)+We+A):d+We+(f===-2?l:A)}return[_a(i,a+(i[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]},lr=class i{constructor({strings:t,_$litType$:e},r){let o;this.parts=[];let a=0,n=0,l=t.length-1,d=this.parts,[c,u]=Pa(t,e);if(this.el=i.createElement(c,r),St.currentNode=this.el.content,e===2||e===3){let f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(o=St.nextNode())!==null&&d.length<l;){if(o.nodeType===1){if(o.hasAttributes())for(let f of o.getAttributeNames())if(f.endsWith(Qi)){let g=u[n++],A=o.getAttribute(f).split(We),S=/([.?@])?(.*)/.exec(g);d.push({type:1,index:a,name:S[2],strings:A,ctor:S[1]==="."?jr:S[1]==="?"?Gr:S[1]==="@"?Wr:wt}),o.removeAttribute(f)}else f.startsWith(We)&&(d.push({type:6,index:a}),o.removeAttribute(f));if(Sa.test(o.tagName)){let f=o.textContent.split(We),g=f.length-1;if(g>0){o.textContent=zr?zr.emptyScript:"";for(let A=0;A<g;A++)o.append(f[A],nr()),St.nextNode(),d.push({type:2,index:++a});o.append(f[g],nr())}}}else if(o.nodeType===8)if(o.data===eo)d.push({type:2,index:a});else{let f=-1;for(;(f=o.data.indexOf(We,f+1))!==-1;)d.push({type:7,index:a}),f+=We.length-1}a++}}static createElement(t,e){let r=_t.createElement("template");return r.innerHTML=t,r}};function Pt(i,t,e=i,r){if(t===te)return t;let o=r!==void 0?e._$Co?.[r]:e._$Cl,a=sr(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=Pt(i,o._$AS(i,t.values),o,r)),t}var Kr=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??_t).importNode(e,!0);St.currentNode=o;let a=St.nextNode(),n=0,l=0,d=r[0];for(;d!==void 0;){if(n===d.index){let c;d.type===2?c=new $t(a,a.nextSibling,this,t):d.type===1?c=new d.ctor(a,d.name,d.strings,this,t):d.type===6&&(c=new qr(a,this,t)),this._$AV.push(c),d=r[++l]}n!==d?.index&&(a=St.nextNode(),n++)}return St.currentNode=_t,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++}},$t=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=Pt(this,t,e),sr(t)?t===h||t==null||t===""?(this._$AH!==h&&this._$AR(),this._$AH=h):t!==this._$AH&&t!==te&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Aa(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&&sr(this._$AH)?this._$AA.nextSibling.data=t:this.T(_t.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=lr.createElement(_a(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===o)this._$AH.p(e);else{let a=new Kr(o,this),n=a.u(this.options);a.p(e),this.T(n),this._$AH=a}}_$AC(t){let e=xa.get(t.strings);return e===void 0&&xa.set(t.strings,e=new lr(t)),e}k(t){to(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(nr()),this.O(nr()),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))}},wt=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=Pt(this,t,e,0),n=!sr(t)||t!==this._$AH&&t!==te,n&&(this._$AH=t);else{let l=t,d,c;for(t=a[0],d=0;d<a.length-1;d++)c=Pt(this,l[r+d],e,d),c===te&&(c=this._$AH[d]),n||(n=!sr(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??"")}},jr=class extends wt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===h?void 0:t}},Gr=class extends wt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==h)}},Wr=class extends wt{constructor(t,e,r,o,a){super(t,e,r,o,a),this.type=5}_$AI(t,e=this){if((t=Pt(this,t,e,0)??h)===te)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)}},qr=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){Pt(this,t)}},wa={M:Qi,P:We,A:eo,C:1,L:Pa,R:Kr,D:Aa,V:Pt,I:$t,H:wt,N:Gr,U:Wr,B:jr,F:qr},Pl=ar.litHtmlPolyfillSupport;Pl?.(lr,$t),(ar.litHtmlVersions??(ar.litHtmlVersions=[])).push("3.3.0");var Ta=(i,t,e)=>{let r=e?.renderBefore??t,o=r._$litPart$;if(o===void 0){let a=e?.renderBefore??null;r._$litPart$=o=new $t(t.insertBefore(nr(),a),a,void 0,e??{})}return o._$AI(i),o};var dr=globalThis,v=class extends Ge{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=Ta(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,dr.litElementHydrateSupport?.({LitElement:v});var wl=dr.litElementPolyfillSupport;wl?.({LitElement:v});(dr.litElementVersions??(dr.litElementVersions=[])).push("4.2.0");var b=i=>(t,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(i,t)})):customElements.define(i,t)};var Tl={attribute:!0,type:String,converter:ir,reflect:!1,hasChanged:Fr},Ml=(i=Tl,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(l){let d=t.get.call(this);t.set.call(this,l),this.requestUpdate(n,d,i)},init(l){return l!==void 0&&this.C(n,void 0,i,l),l}}}if(r==="setter"){let{name:n}=e;return function(l){let d=this[n];t.call(this,l),this.requestUpdate(n,d,i)}}throw Error("Unsupported decorator location: "+r)};function p(i){return(t,e)=>typeof e=="object"?Ml(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 w(i){return p({...i,state:!0,attribute:!1})}var Tt=(i,t,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(i,t,e),e);function pt(i,t){return(e,r,o)=>{let a=n=>n.renderRoot?.querySelector(i)??null;if(t){let{get:n,set:l}=typeof r=="object"?e:o??(()=>{let d=Symbol();return{get(){return this[d]},set(c){this[d]=c}}})();return Tt(e,r,{get(){let d=n.call(this);return d===void 0&&(d=a(this),(d!==null||this.hasUpdated)&&l.call(this,d)),d}})}return Tt(e,r,{get(){return a(this)}})}}function k(i,t,e){return i?t(i):e?.(i)}var P=y` * { box-sizing: border-box; } `,Ma=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 ka="https://sdk.primer.io/web/v2-latest/Primer.min.js",Le="20px";var Jr=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 Zr=class{constructor(t){this.paymentMethods=null;this.headlessInstance=t}setPaymentMethods(t){this.paymentMethods=t}async refreshSession(){if(!this.headlessInstance){x.errorWithDatadog("PrimerJS: Cannot refresh session: Headless instance not available");return}try{await this.headlessInstance.refreshClientSession()}catch(t){throw x.errorWithDatadog("PrimerJS: Error refreshing client session",{error:t}),t}}getPaymentMethods(){return this.paymentMethods?this.paymentMethods.toArray():(x.warn("PrimerJS: Payment methods not available"),[])}handlePaymentStart(){this.onPaymentStart&&this.onPaymentStart()}handleBeforePaymentCreate(t,e){if(this.onPaymentPrepare){let r={continuePaymentCreation:()=>{x.info("PrimerJS: Payment creation continuing"),e.continuePaymentCreation()},abortPaymentCreation:()=>{x.info("PrimerJS: Payment creation aborted"),e.abortPaymentCreation()}};this.onPaymentPrepare(t,r)}else x.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 Xr=typeof window<"u"&&typeof window.document<"u";function kl(i){return document.querySelector(`script[src^="${i}"]`)}function Il(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 Ia(i,t=!1){if(!Xr)throw new Error("Cannot load script in server environment");let e=kl(i)??Il(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 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 a(l,d,c){return{card:l,isPotentiallyValid:d,isValid:c}}function n(l,d){d===void 0&&(d={});var c,u,f;if(typeof l!="string"&&typeof l!="number")return a(null,!1,!1);var g=String(l).replace(/-|\s/g,"");if(!/^\d*$/.test(g))return a(null,!1,!1);var A=o(g);if(A.length===0)return a(null,!1,!1);if(A.length!==1)return a(null,!0,!1);var S=A[0];if(d.maxLength&&g.length>d.maxLength)return a(S,!1,!1);u=d.skipLuhnValidation===!0||S.type===o.types.UNIONPAY&&d.luhnValidateUnionPay!==!0?!0:r(g),f=Math.max.apply(null,S.lengths),d.maxLength&&(f=Math.min(d.maxLength,f));for(var M=0;M<S.lengths.length;M++)if(S.lengths[M]===g.length)return c=g.length<f||u,a(S,c,u);return a(S,g.length<f,!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,l){return{isValid:n,isPotentiallyValid:l}}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(l,d){for(var c=0;c<l.length;c++)if(d===l[c])return!0;return!1}function o(l){for(var d=e,c=0;c<l.length;c++)d=l[c]>d?l[c]:d;return d}function a(l,d){return{isValid:l,isPotentiallyValid:d}}function n(l,d){return d===void 0&&(d=e),d=d instanceof Array?d:[d],typeof l!="string"||!/^\d*$/.test(l)?a(!1,!1):r(d,l.length)?a(!0,!0):l.length<Math.min.apply(null,d)?a(!1,!0):l.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,f=1,g=arguments.length;f<g;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"),a=e("../../node_modules/card-validator/dist/expiration-month.js"),n=e("../../node_modules/card-validator/dist/expiration-year.js");function l(c,u,f,g){return{isValid:c,isPotentiallyValid:u,month:f,year:g}}function d(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 l(!1,!1,null,null);var g=r({},c);f={month:String(g.month),year:String(g.year)}}var A=(0,a.expirationMonth)(f.month),S=(0,n.expirationYear)(f.year,u);if(A.isValid){if(S.isCurrentYear){var M=A.isValidForThisYear;return l(M,M,f.month,f.year)}if(S.isValid)return l(!0,!0,f.month,f.year)}return A.isPotentiallyValid&&S.isPotentiallyValid?l(!1,!0,null,null):l(!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 l=n>0&&n<13;return e(l,l,l&&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,l){return{isValid:a,isPotentiallyValid:n,isCurrentYear:l||!1}}function o(a,n){n===void 0&&(n=e);var l;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),f=String(c).slice(0,2);return r(!1,u===f)}if(d>4)return r(!1,!1);var g=parseInt(a,10),A=Number(String(c).substr(2,2)),S=!1;if(d===2){if(String(c).substr(0,2)===a)return r(!1,!0);l=A===g,S=g>=A&&g<=A+n}else d===4&&(l=c===g,S=g>=c&&g<=c+n);return r(S,S,l)}t.expirationYear=o},"../../node_modules/card-validator/dist/index.js":function(i,t,e){var r=this&&this.__createBinding||(Object.create?function(M,L,_,I){I===void 0&&(I=_);var U=Object.getOwnPropertyDescriptor(L,_);(!U||("get"in U?!L.__esModule:U.writable||U.configurable))&&(U={enumerable:!0,get:function(){return L[_]}}),Object.defineProperty(M,I,U)}:function(M,L,_,I){I===void 0&&(I=_),M[I]=L[_]}),o=this&&this.__setModuleDefault||(Object.create?function(M,L){Object.defineProperty(M,"default",{enumerable:!0,value:L})}:function(M,L){M.default=L}),a=this&&this.__importStar||function(M){if(M&&M.__esModule)return M;var L={};if(M!=null)for(var _ in M)_!=="default"&&Object.prototype.hasOwnProperty.call(M,_)&&r(L,M,_);return o(L,M),L},n=a(e("../../node_modules/credit-card-type/dist/index.js")),l=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"),f=e("../../node_modules/card-validator/dist/expiration-year.js"),g=e("../../node_modules/card-validator/dist/cvv.js"),A=e("../../node_modules/card-validator/dist/postal-code.js"),S={creditCardType:n,cardholderName:l.cardholderName,number:d.cardNumber,expirationDate:c.expirationDate,expirationMonth:u.expirationMonth,expirationYear:f.expirationYear,cvv:g.cvv,postalCode:A.postalCode};i.exports=S},"../../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(l){var d=Number(l[0]),c;return d===0?2:d>1||d===1&&Number(l[1])>2?1:d===1?(c=l.substr(1),(0,r.expirationYear)(c).isPotentiallyValid?1:2):l.length===5?1:l.length>5?2:1}function n(l){var d;if(/^\d{4}-\d{1,2}$/.test(l)?d=l.split("-").reverse():/\//.test(l)?d=l.split(/\s*\/\s*/g):/\s/.test(l)&&(d=l.split(/ +/g)),(0,o.isArray)(d))return{month:d[0]||"",year:d.slice(1).join()};var c=a(l),u=l.substr(0,c);return{month:u,year:l.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,l){return{isValid:n,isPotentiallyValid:l}}function a(n,l){l===void 0&&(l={});var d=l.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(_){for(var I,U=1,ot=arguments.length;U<ot;U++){I=arguments[U];for(var Gt in I)Object.prototype.hasOwnProperty.call(I,Gt)&&(_[Gt]=I[Gt])}return _},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"),l=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"},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],g=(0,d.clone)(f);function A(_){return c[_]||o[_]}function S(){return g.map(function(_){return(0,d.clone)(A(_))})}function M(_,I){I===void 0&&(I=!1);var U=g.indexOf(_);if(!I&&U===-1)throw new Error('"'+_+'" is not a supported card type.');return U}function L(_){var I=[];if(!(0,n.isValidInputType)(_))return I;if(_.length===0)return S();g.forEach(function(ot){var Gt=A(ot);(0,a.addMatchingCardsToResults)(_,Gt,I)});var U=(0,l.findBestMatch)(I);return U?[U]:I}L.getTypeInfo=function(_){return(0,d.clone)(A(_))},L.removeCard=function(_){var I=M(_);g.splice(I,1)},L.addCard=function(_){var I=M(_.type,!0);c[_.type]=_,I===-1&&g.push(_.type)},L.updateCard=function(_,I){var U=c[_]||o[_];if(!U)throw new Error('"'.concat(_,"\" is not a recognized type. Use `addCard` instead.'"));if(I.type&&U.type!==I.type)throw new Error("Cannot overwrite type parameter.");var ot=(0,d.clone)(U);ot=r(r({},ot),I),c[ot.type]=ot},L.changeOrder=function(_,I){var U=M(_);g.splice(U,1),g.splice(I,0,_)},L.resetModifications=function(){g=(0,d.clone)(f),c={}},L.types=u,i.exports=L},"../../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,l,d){var c,u;for(c=0;c<l.patterns.length;c++){var f=l.patterns[c];if((0,o.matches)(n,f)){var g=(0,r.clone)(l);u=Array.isArray(f)?String(f[0]).length:String(f).length,n.length>=u&&(g.matchStrength=u),d.push(g);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,l){var d=String(n).length,c=a.substr(0,d),u=parseInt(c,10);return n=parseInt(String(n).substr(0,c.length),10),l=parseInt(String(l).substr(0,c.length),10),u>=n&&u<=l}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}},Na={};function Co(i){var t=Na[i];if(t!==void 0)return t.exports;var e=Na[i]={exports:{}};return Nl[i].call(e.exports,e,e.exports,Co),e.exports}var Se=()=>Za.randomUUID?.()||Ll(),Ll=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,i=>(i^Rl()>>i/4).toString(16)),Rl=()=>(Za.getRandomValues?.(new Uint8Array(1))[0]??16*Math.random())&15,Za=typeof crypto<"u"?crypto:{},Ol={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 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}`};$l(o,t)}function $l(i,{environment:t,clientSessionToken:e}){if(t==="LOCAL")return void V.debug("\u{1F436}\u{1F436}\u{1F436} [Datadog Log] \u{1F436}\u{1F436}\u{1F436}",i);let r=Ol[t||"LOCAL"];if(!r)return void V.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=>{V.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}};Dl(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 V=$,Vl={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"},no=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 V.error("Analytics manager not initialized. Call initializeAnalytics() first.");let e={id:Se(),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};Bl(e,this.sessionConfig)}},Xa=new no;function Ul(i){Xa.initialize(i)}function pi(i){Xa.sendEvent(i)}async function Bl(i,{environment:t,clientSessionToken:e}){if(t==="LOCAL")return void V.debug(`Analytics event ${i.eventName}:`,i);let r=Vl[t];return fetch(r,{method:"POST",headers:{"Content-Type":"application/json",...e&&{Authorization:`Bearer ${e}`}},body:JSON.stringify(i)}).catch(o=>{V.error("Failed to send analytics event:",o)})}var io=(function(i){return i.CARD="CARD",i.NATIVE="NATIVE",i.REDIRECT="REDIRECT",i.KLARNA="KLARNA",i.ACH="ACH",i})({}),La=Co("../../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 Yl(i){return Eo(i).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1).toLowerCase()).join(" ")}function Ra(i){return Eo(i).join("-").toLowerCase()}function Oa(i){return Eo(i).join("_").toUpperCase()}var Qa=[["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"]],Da=new Map(Qa.map(i=>[i[0],i])),Hl=new Map(Qa.filter(i=>i[1]).map(i=>[i[1],i]));function xo(i){let{niceType:t,type:e}=(0,La.getTypeInfo)(Ra(i))||(0,La.getTypeInfo)(Da.get(Oa(i))?.[1]||"")||{},[r,o,a]=Hl.get(e)||Da.get(Oa(i))||[];return{asset:a||Ra(o||i),backend:r,display:t||Yl(i),library:o}}var j={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"},en="3.7.7",Fl=en,Yt=typeof Buffer=="function",$a=typeof TextDecoder=="function"?new TextDecoder:void 0,Va=typeof TextEncoder=="function"?new TextEncoder:void 0,zl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",cr=Array.prototype.slice.call(zl),Qr=(i=>{let t={};return i.forEach((e,r)=>t[e]=r),t})(cr),Kl=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,J=String.fromCharCode.bind(String),Ua=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):i=>new Uint8Array(Array.prototype.slice.call(i,0)),tn=i=>i.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),rn=i=>i.replace(/[^A-Za-z0-9\+\/]/g,""),on=i=>{let t,e,r,o,a="",n=i.length%3;for(let l=0;l<i.length;){if((e=i.charCodeAt(l++))>255||(r=i.charCodeAt(l++))>255||(o=i.charCodeAt(l++))>255)throw new TypeError("invalid character found");t=e<<16|r<<8|o,a+=cr[t>>18&63]+cr[t>>12&63]+cr[t>>6&63]+cr[63&t]}return n?a.slice(0,n-3)+"===".substring(n):a},Ao=typeof btoa=="function"?i=>btoa(i):Yt?i=>Buffer.from(i,"binary").toString("base64"):on,so=Yt?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 Ao(e.join(""))},ti=(i,t=!1)=>t?tn(so(i)):so(i),jl=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)},Gl=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,an=i=>i.replace(Gl,jl),Ba=Yt?i=>Buffer.from(i,"utf8").toString("base64"):Va?i=>so(Va.encode(i)):i=>Ao(an(i)),Vt=(i,t=!1)=>t?tn(Ba(i)):Ba(i),Ya=i=>Vt(i,!0),Wl=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,ql=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))}},nn=i=>i.replace(Wl,ql),sn=i=>{if(i=i.replace(/\s+/g,""),!Kl.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=Qr[i.charAt(a++)]<<18|Qr[i.charAt(a++)]<<12|(r=Qr[i.charAt(a++)])<<6|(o=Qr[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},So=typeof atob=="function"?i=>atob(rn(i)):Yt?i=>Buffer.from(i,"base64").toString("binary"):sn,ln=Yt?i=>Ua(Buffer.from(i,"base64")):i=>Ua(So(i).split("").map(t=>t.charCodeAt(0))),dn=i=>ln(cn(i)),Jl=Yt?i=>Buffer.from(i,"base64").toString("utf8"):$a?i=>$a.decode(ln(i)):i=>nn(So(i)),cn=i=>rn(i.replace(/[-_]/g,t=>t=="-"?"+":"/")),lo=i=>Jl(cn(i)),Zl=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)},pn=i=>({value:i,enumerable:!1,writable:!0,configurable:!0}),mn=function(){let i=(t,e)=>Object.defineProperty(String.prototype,t,pn(e));i("fromBase64",function(){return lo(this)}),i("toBase64",function(t){return Vt(this,t)}),i("toBase64URI",function(){return Vt(this,!0)}),i("toBase64URL",function(){return Vt(this,!0)}),i("toUint8Array",function(){return dn(this)})},un=function(){let i=(t,e)=>Object.defineProperty(Uint8Array.prototype,t,pn(e));i("toBase64",function(t){return ti(this,t)}),i("toBase64URI",function(){return ti(this,!0)}),i("toBase64URL",function(){return ti(this,!0)})},Xl=()=>{mn(),un()},hn={version:en,VERSION:Fl,atob:So,atobPolyfill:sn,btoa:Ao,btoaPolyfill:on,fromBase64:lo,toBase64:Vt,encode:Vt,encodeURI:Ya,encodeURL:Ya,utob:an,btou:nn,decode:lo,isValid:Zl,fromUint8Array:ti,toUint8Array:dn,extendString:mn,extendUint8Array:un,extendBuiltins:Xl},ri={encode:Ql,decode:hn.decode};function Ql(i,t={}){let{urlSafe:e=!1}=t;return hn.encode(i,e)}function ed(i,t){return!(i.intent!==`${t}_REDIRECTION`||!("statusUrl"in i)||!("redirectUrl"in i)||!i.redirectUrl||!i.statusUrl)}function Ut(i){let t=id(i),e=1e3*t.exp;if(Date.now()>e)throw new Error(`${td}. Expiration date: ${new Date(e).toISOString()}`);return t}var fn="The provided `clientToken`",td=`${fn} has expired`,rd=`${fn} is malformed`;function id(i){try{let[t,e]=i.split("."),r=e||t;return JSON.parse(ri.decode(r))}catch{throw new Error(rd)}}var ii=class{constructor(t,e){T(this,"context");T(this,"dialogProvider");this.context=t,this.dialogProvider=e}};function _o(){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 ur(i){return i?new Promise(t=>{setTimeout(t,i)}):Promise.resolve()}var co=class extends ii{async handleRequiredAction(t){let e=t.requiredAction?.clientToken;if(!e)throw new Error("No client token provided");let r=Ut(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:_o()});if(o||!a||!a.authentication)throw o??new Error("Unable to authenticate");let n=a.authentication,l=a;n.responseCode==="METHOD"&&(l=await this.handleMethod(r.tokenId,n),n=l.authentication),n.responseCode==="CHALLENGE"&&(l=await this.handleChallenge(r.tokenId,n));let d=await this.context.pciApi.postResumePayment(t.id,l.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",l=document.createElement("div");l.id=r,l.style.position="absolute",l.style.width="2px",l.style.height="2px",l.style.left="-10000px";let d=document.createElement("iframe");d.style.display="none",d.id=o,d.name=o,l.appendChild(d);let c=document.createElement("form"),u=document.createElement("input");u.type="hidden",u.id=n,u.name=n,u.value=ri.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",l.appendChild(c),document.body.appendChild(l),c.submit();let{data:f,error:g}=await this.pollStatus(e.statusUrl,"METHOD",1e3).promise;return l.remove(),g||!f?this.continueAuth(t):f}pollStatus(t,e="METHOD",r=1e3,o=66e4){let a=!0;return{promise:new Promise(async n=>{let l=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(l),n(d);return}if(await ur(r),d.data&&d.data.authentication.responseCode!==e){clearTimeout(l),n(d);return}}}catch(d){clearTimeout(l),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:Se(),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 l=document.getElementById(o);l?l.submit():requestAnimationFrame(()=>{let d=document.getElementById(o);d&&d.submit()})},n=this.pollStatus(e.statusUrl,"CHALLENGE",2500,66e4);try{let l=this.dialogProvider.show({htmlContent:r.outerHTML,onContentReady:a});pi({eventName:"PAYMENT_THREEDS",threedsResponse:JSON.stringify(e)});let d=await Promise.race([n.promise,l.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-${Se()}`,r=`3ds-challenge-form-${Se()}`,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=ri.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 l=document.createElement("iframe");return l.id=e,l.name=e,l.className="challenge-iframe",l.setAttribute("frameborder","0"),l.title="3D Secure Challenge",a.appendChild(n),a.appendChild(l),{container:a,formId:r}}inject3DSChallengeCSS(){let t="primer-3ds-challenge-dialog-styles";if(document.getElementById(t))return;let e=`
|
|
4
4
|
primer-dialog[size="large"] .challenge-container {
|
|
@@ -150,7 +150,7 @@ ${o}`;function Od(i,t,e){if(e?.status&&e.status>=400&&e.status<500)return!1;if(e
|
|
|
150
150
|
</div>
|
|
151
151
|
</body>
|
|
152
152
|
</html>
|
|
153
|
-
`;async function Wd(i,t){let e=i.configuration.paymentMethods.map(o=>{if(!t.includes(o.type))return null;if(V.debug("Initializing payment method:",o.type),o.implementationType==="WEB_REDIRECT")return new bo(o,i);if(o.type===j.PAYMENT_CARD)return new li(o,i);if(o.type===j.PAYPAL)return new ci(o,i);if(o.type===j.APPLE_PAY)return new ni(o,i);if(o.type===j.GOOGLE_PAY)return new di(o,i);if(o.type===j.ADYEN_BLIK)return new si(o,i)}).map(async o=>{if(!o)return null;try{return await o.setup()?o:null}catch(a){return V.warn(`Failed to initialize payment method ${o.config.type}:`,a),null}});return(await Promise.all(e)).filter(o=>!!o)}function qd(i,t,e){if(!t.configuration.clientSession.customer?.customerId)throw new H({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 H({code:ei.VAULT_ERROR,message:"Missing vaulted payment methods data"});return r=o.data,r},async deleteVaultedPaymentMethod(o){if(!r.find(l=>l.id===o))throw new H({code:ei.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(l=>l.id!==o)},async startPaymentFlow(o){let a=r.find(l=>l.id===o);if(!a)throw new H({code:ei.VAULT_ERROR,message:"startPaymentFlow: the id provided doesn't match any vaulted payment method"});let n=e.find(l=>l.config.type===a.paymentMethodType);if(!n)throw new H({code:ei.TOKENIZATION_ERROR,message:`Payment instrument type ${a.paymentInstrumentType} is not recognized or not supported.`});await mi(i,n,a)},async createCvvInput(o){let a={blur:new Set,change:new Set,focus:new Set},n,l=pr(t.checkoutSessionId,za);await new Promise(g=>{l.onload=()=>{g()},(typeof o.container=="string"?document.querySelector(o.container):o.container)?.appendChild(l)}),ho(l,o.style);let d=wo({namespace:`${t.checkoutSessionId}-${za}`,onMessage:g=>{let A=S=>g(S.data);return window.addEventListener("message",A),()=>window.removeEventListener("message",A)},sendMessage:g=>{l.contentWindow.postMessage(g,"*")}});function c(g,A){g!=="metadata"&&a[g].add(A)}d.setOnFocus(()=>{a.focus.forEach(g=>g())}),d.setOnBlur(()=>{a.blur.forEach(g=>g())}),d.setOnInput(g=>{n=g,a.change.forEach(A=>A())}),d.setCardNetwork(o.cardNetwork??""),d.setOptions({placeholder:o.placeholder??"123",ariaLabel:o.ariaLabel??"CVV",style:o.style});function u(){l.parentNode&&l.remove()}let f=t.subscribeToTeardown(u);return{frame:l,remove:()=>{f(),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(g,A){g!=="metadata"&&a[g].delete(A)},blur(){d.blur()},focus(){d.focus()},validate(){d.getFieldState().then(g=>{n=g,a.change.forEach(A=>A(n))})}}}}}async function En(i,t){V.debug("createHeadless",t);let e=await Bd(i,{locale:t.locale,dialogProvider:t.dialogProvider}),r=await Wd(e,t.enabledPaymentMethods??[j.PAYMENT_CARD]);t.onClientSessionUpdate?.(e.configuration.clientSession),e.onClientConfigurationUpdate(a=>{t.onClientSessionUpdate?.(a.clientSession)});let o={environment:Fa?"LOCAL":e.decodedClientToken.env,primerAccountId:e.configuration.primerAccountId,checkoutSessionId:e.checkoutSessionId,clientSessionId:e.configuration.clientSession?.clientSessionId,clientSessionToken:i,sdkVersion:t.sdkVersion};return Ul({environment:Fa?"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===j.PAYMENT_CARD?io.CARD:a.config.implementationType==="NATIVE_SDK"?io.NATIVE:io.REDIRECT}))),{start:()=>Promise.resolve(),createPaymentMethodManager:async(a,n)=>{let l=r.find(({config:d})=>d.type===a);return l?l instanceof li?Pd(t,e,l,n):l instanceof ci||l instanceof ni||l instanceof di?Md(t,e,l):l instanceof si?Id(t,e,l):kd(t,e,l):(V.warn(`Payment method ${a} not found`),null)},getSDKUtilities:()=>({getCardNetworkAsset:Ja,getUIOrderAmount:()=>{let{merchantAmount:a,totalOrderAmount:n,currencyCode:l}=e.configuration.clientSession.order;return gn(e.locale,a??n,l)},getCDNAssets:async a=>{let n=r.find(({config:c})=>c.type===a);if(!n)return;let{backgroundColor:l,iconUrl:d}=n.config.displayMetadata?.button||{};return{assets:{icon:d?.colored||""},colors:{background:l?.colored||"",main:l?.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:l}=await e.clientSessionApi.setBillingAddress(a);if(n||!l)throw n||new H({message:"Failed to set billing address"})}}),getAnalyticsUtils:()=>o,createVaultManager(){return qd(t,e,r)},getAssetsManager:()=>({getCardNetworkAsset:Ja,getPaymentMethodAsset:async a=>{let n=r.find(({config:u})=>u.type===a);if(!n)return null;let{backgroundColor:l,iconUrl:d,text:c}=n.config.displayMetadata?.button||{};return{backgroundColor:l,iconUrl:d,paymentMethodName:c,buttonText:c,displayName:n.config.name}}}),refreshClientSession:e.refreshClientConfiguration,getConfiguration:()=>e.configuration,teardown:()=>e.teardown()}}var Ja=i=>{let{asset:t,display:e}=xo(i);return{cardUrl:`${md}/brand/card/${t}.svg`,displayName:e}};var X={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},ve=i=>(...t)=>({_$litDirective$:i,values:t}),Oe=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 hr=class extends Oe{constructor(t){if(super(t),this.it=h,t.type!==X.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===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:[]}}};hr.directiveName="unsafeHTML",hr.resultType=1;var xn=ve(hr);var An=Symbol.for("primer-sdk-core-dialog-access");function Sn(i){return{token:An,content:i}}function To(i){return i!==void 0&&i.token===An&&typeof i.content=="string"}var _n=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 se=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?To(this.secureHtmlContent)?m`${xn(this.secureHtmlContent.content)}`:(x.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&&!To(r)&&(x.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()}`}};se.styles=[P,_n],s([p({type:String})],se.prototype,"size",2),s([p({type:Boolean})],se.prototype,"showCloseButton",2),s([p({type:Object})],se.prototype,"onOpen",2),s([p({type:Object})],se.prototype,"onContentRendered",2),s([p({type:Object,converter:{fromAttribute:()=>{},toAttribute:()=>null}})],se.prototype,"secureHtmlContent",2),s([w()],se.prototype,"open",2),se=s([b("primer-portal-dialog"),R()],se);var ui=class{constructor(){this.currentDialog=null;this.currentResolver=null}async show(t){return new Promise(e=>{let r=Sn(t.htmlContent),o=new se;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 hi="0.5.0",fi=class{constructor(t){this.createPaymentMethodManager=null;this._paymentsList=[];this.currentSdkInstance=null;this.primerJS=null;this.loadingTimeout=null;this.isDisconnected=!1;(this.host=t).addController(this),this.isDisconnected=!1,this.sdkInstanceTask=new O(t,{args:()=>[this.host.clientToken,this.host.options],task:this.initializeHeadless()}),new O(t,{args:()=>[this.sdkInstanceTask.value,this.paymentsList],task:this.initializeLitContext()})}set paymentsList(t){this._paymentsList=t,this.host.requestUpdate()}get paymentsList(){return this._paymentsList}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;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&&(x.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?.(),x.info("SDK instance cleaned up")}catch(t){x.errorWithDatadog("Error cleaning up SDK instance",{error:t})}ea(),x.setEnvironment(void 0),x.setSdkVersion(void 0),x.setClientToken(void 0),x.setSdkOptions(void 0),x.setClientSessionId(void 0),this.currentSdkInstance=null,this.primerJS=null}async _loadV2Sdk(t=ka){let e=window;if(e.Primer&&typeof e.Primer.preloadPrimer=="function"){x.info("SDK already loaded, skipping load script"),await e.Primer.preloadPrimer();return}await Ia(t),await e.Primer.preloadPrimer()}initializeHeadless(){return async([t,e])=>{if(this.isDisconnected)return x.warn("Component disconnected, aborting SDK initialization"),N;if(!t||!e)return N;this.cleanupResources();let r;try{let o;if(e.sdkCore!==!1){let d=new ui;o={createHeadless:(u,f)=>En(u,{...f,dialogProvider:d,sdkVersion:hi})}}else await this._loadV2Sdk(),o=window.Primer;this.primerJS=new Zr(null);let a=this.normalizeOptionsForLegacySdk(e);x.setClientToken(t),x.setSdkOptions(a);let n=await o.createHeadless(t,{...a,onAvailablePaymentMethodsLoad:d=>{this.isDisconnected||(x.info("Configuration payment methods:",d),this.paymentsList=d)},onCheckoutComplete:({payment:d})=>{this.isDisconnected||(x.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?x.errorWithDatadog("Payment failed with server error",{error:d}):x.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(),N;this.host.sdkContextController.setClientOptions(e),this.primerJS&&this.host.primerEventsController.dispatchCheckoutInitialized(this.primerJS);let l=n.getSDKUtilities();if(r=n.getAnalyticsUtils?.(),r&&(this.host.sdkContextController.setAnalyticsUtils({...r,sdkVersion:hi}),x.setEnvironment(r.environment),x.setSdkVersion(hi),x.setClientSessionToken(r.clientSessionToken),x.setClientSessionId(r.clientSessionId),Qo({environment:r.environment,checkoutSessionId:r.checkoutSessionId,clientSessionId:r.clientSessionId||"",primerAccountId:r.primerAccountId||"",sdkVersion:hi,clientSessionToken:r.clientSessionToken}),q({eventName:"SDK_INIT_START"})),this.host.sdkContextController.setHeadlessUtils(l),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:!!l.getPaymentMethodConfiguration("PAYMENT_CARD")?.options?.captureVaultedCardCvv,showEmptyState:e.vault?.showEmptyState}),n}catch(o){throw o instanceof Error&&(x.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 N;if(!t||!e.length)return N;let r=new Map,o=new Map;try{for(let n of e){if(this.isDisconnected)break;let l=await this.initializePaymentMethodManager(n)();n&&l&&(r.set(n.type,n),o.set(n.type,l))}if(this.isDisconnected)return N;let a=new Jr(r);return this.host.sdkContextController.setPaymentManagers(o),this.host.sdkContextController.setPaymentMethods(a),this.primerJS&&this.primerJS.setPaymentMethods(a),this.host.primerEventsController.dispatchPaymentMethods(a),x.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 x.errorWithDatadog(`Failed to initialize manager for ${e}`,{error:o}),null}}}};var gi=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 Jd=Yo({"../../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")});Ki(i=>Jd(`../../localization/lit-localize/locales/${i}.ts`));var Zd={LOADER_DISABLED:"loader-disabled",CUSTOM_STYLES:"custom-styles",CLIENT_TOKEN:"client-token",JS_INIT:"js-initialized"},be=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 Tr(this),this.sdkStateController=new Pr(this),this.primerEventsController=new Lt(this),this.styleProcessingController=new Mr(this),this.vaultManagerController=new Jt(this),this.cardNetworkController=new Cr(this),this.achPaymentEventsController=new gi(this),new fi(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===Zd.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&&(Wi(this.options?.locale)?this.locale=qi(this.options?.locale):x.warn("\u{1F30E}\u2757 Unsupported locale provided:",this.options?.locale,"- Falling back to default locale `en-GB`")),ji(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&&(x.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)}};be.styles=[P,Ma],s([p({type:String,attribute:"custom-styles"})],be.prototype,"customStyles",2),s([p({type:String,attribute:"client-token"})],be.prototype,"clientToken",2),s([p({type:Object})],be.prototype,"options",2),s([p({type:Boolean,attribute:"loader-disabled"})],be.prototype,"disableLoader",2),s([p({type:Boolean,reflect:!0,attribute:"js-initialized"})],be.prototype,"_jsInitialized",2),s([pt("slot")],be.prototype,"defaultSlot",2),s([w()],be.prototype,"previousLoadingState",2),be=s([R(),b("primer-checkout")],be);function Xd(i){return document.querySelector(`#${i}`)}function Qd(i,t){let e=document.createElement("style");return e.textContent=i,e.id=t,e}function fr(i,t,e=!0){if(!Xr||Xd(t))return;let o=Qd(i,t);e&&document.head.firstChild?document.head.insertBefore(o,document.head.firstChild):document.head.appendChild(o)}var Pn=`
|
|
153
|
+
`;async function Wd(i,t){let e=i.configuration.paymentMethods.map(o=>{if(!t.includes(o.type))return null;if(V.debug("Initializing payment method:",o.type),o.implementationType==="WEB_REDIRECT")return new bo(o,i);if(o.type===j.PAYMENT_CARD)return new li(o,i);if(o.type===j.PAYPAL)return new ci(o,i);if(o.type===j.APPLE_PAY)return new ni(o,i);if(o.type===j.GOOGLE_PAY)return new di(o,i);if(o.type===j.ADYEN_BLIK)return new si(o,i)}).map(async o=>{if(!o)return null;try{return await o.setup()?o:null}catch(a){return V.warn(`Failed to initialize payment method ${o.config.type}:`,a),null}});return(await Promise.all(e)).filter(o=>!!o)}function qd(i,t,e){if(!t.configuration.clientSession.customer?.customerId)throw new H({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 H({code:ei.VAULT_ERROR,message:"Missing vaulted payment methods data"});return r=o.data,r},async deleteVaultedPaymentMethod(o){if(!r.find(l=>l.id===o))throw new H({code:ei.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(l=>l.id!==o)},async startPaymentFlow(o){let a=r.find(l=>l.id===o);if(!a)throw new H({code:ei.VAULT_ERROR,message:"startPaymentFlow: the id provided doesn't match any vaulted payment method"});let n=e.find(l=>l.config.type===a.paymentMethodType);if(!n)throw new H({code:ei.TOKENIZATION_ERROR,message:`Payment instrument type ${a.paymentInstrumentType} is not recognized or not supported.`});await mi(i,n,a)},async createCvvInput(o){let a={blur:new Set,change:new Set,focus:new Set},n,l=pr(t.checkoutSessionId,za);await new Promise(g=>{l.onload=()=>{g()},(typeof o.container=="string"?document.querySelector(o.container):o.container)?.appendChild(l)}),ho(l,o.style);let d=wo({namespace:`${t.checkoutSessionId}-${za}`,onMessage:g=>{let A=S=>g(S.data);return window.addEventListener("message",A),()=>window.removeEventListener("message",A)},sendMessage:g=>{l.contentWindow.postMessage(g,"*")}});function c(g,A){g!=="metadata"&&a[g].add(A)}d.setOnFocus(()=>{a.focus.forEach(g=>g())}),d.setOnBlur(()=>{a.blur.forEach(g=>g())}),d.setOnInput(g=>{n=g,a.change.forEach(A=>A())}),d.setCardNetwork(o.cardNetwork??""),d.setOptions({placeholder:o.placeholder??"123",ariaLabel:o.ariaLabel??"CVV",style:o.style});function u(){l.parentNode&&l.remove()}let f=t.subscribeToTeardown(u);return{frame:l,remove:()=>{f(),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(g,A){g!=="metadata"&&a[g].delete(A)},blur(){d.blur()},focus(){d.focus()},validate(){d.getFieldState().then(g=>{n=g,a.change.forEach(A=>A(n))})}}}}}async function En(i,t){V.debug("createHeadless",t);let e=await Bd(i,{locale:t.locale,dialogProvider:t.dialogProvider}),r=await Wd(e,t.enabledPaymentMethods??[j.PAYMENT_CARD]);t.onClientSessionUpdate?.(e.configuration.clientSession),e.onClientConfigurationUpdate(a=>{t.onClientSessionUpdate?.(a.clientSession)});let o={environment:Fa?"LOCAL":e.decodedClientToken.env,primerAccountId:e.configuration.primerAccountId,checkoutSessionId:e.checkoutSessionId,clientSessionId:e.configuration.clientSession?.clientSessionId,clientSessionToken:i,sdkVersion:t.sdkVersion};return Ul({environment:Fa?"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===j.PAYMENT_CARD?io.CARD:a.config.implementationType==="NATIVE_SDK"?io.NATIVE:io.REDIRECT}))),{start:()=>Promise.resolve(),createPaymentMethodManager:async(a,n)=>{let l=r.find(({config:d})=>d.type===a);return l?l instanceof li?Pd(t,e,l,n):l instanceof ci||l instanceof ni||l instanceof di?Md(t,e,l):l instanceof si?Id(t,e,l):kd(t,e,l):(V.warn(`Payment method ${a} not found`),null)},getSDKUtilities:()=>({getCardNetworkAsset:Ja,getUIOrderAmount:()=>{let{merchantAmount:a,totalOrderAmount:n,currencyCode:l}=e.configuration.clientSession.order;return gn(e.locale,a??n,l)},getCDNAssets:async a=>{let n=r.find(({config:c})=>c.type===a);if(!n)return;let{backgroundColor:l,iconUrl:d}=n.config.displayMetadata?.button||{};return{assets:{icon:d?.colored||""},colors:{background:l?.colored||"",main:l?.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:l}=await e.clientSessionApi.setBillingAddress(a);if(n||!l)throw n||new H({message:"Failed to set billing address"})}}),getAnalyticsUtils:()=>o,createVaultManager(){return qd(t,e,r)},getAssetsManager:()=>({getCardNetworkAsset:Ja,getPaymentMethodAsset:async a=>{let n=r.find(({config:u})=>u.type===a);if(!n)return null;let{backgroundColor:l,iconUrl:d,text:c}=n.config.displayMetadata?.button||{};return{backgroundColor:l,iconUrl:d,paymentMethodName:c,buttonText:c,displayName:n.config.name}}}),refreshClientSession:e.refreshClientConfiguration,getConfiguration:()=>e.configuration,teardown:()=>e.teardown()}}var Ja=i=>{let{asset:t,display:e}=xo(i);return{cardUrl:`${md}/brand/card/${t}.svg`,displayName:e}};var X={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},ve=i=>(...t)=>({_$litDirective$:i,values:t}),Oe=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 hr=class extends Oe{constructor(t){if(super(t),this.it=h,t.type!==X.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===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:[]}}};hr.directiveName="unsafeHTML",hr.resultType=1;var xn=ve(hr);var An=Symbol.for("primer-sdk-core-dialog-access");function Sn(i){return{token:An,content:i}}function To(i){return i!==void 0&&i.token===An&&typeof i.content=="string"}var _n=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 se=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?To(this.secureHtmlContent)?m`${xn(this.secureHtmlContent.content)}`:(x.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&&!To(r)&&(x.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()}`}};se.styles=[P,_n],s([p({type:String})],se.prototype,"size",2),s([p({type:Boolean})],se.prototype,"showCloseButton",2),s([p({type:Object})],se.prototype,"onOpen",2),s([p({type:Object})],se.prototype,"onContentRendered",2),s([p({type:Object,converter:{fromAttribute:()=>{},toAttribute:()=>null}})],se.prototype,"secureHtmlContent",2),s([w()],se.prototype,"open",2),se=s([b("primer-portal-dialog"),R()],se);var ui=class{constructor(){this.currentDialog=null;this.currentResolver=null}async show(t){return new Promise(e=>{let r=Sn(t.htmlContent),o=new se;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 hi="0.5.1",fi=class{constructor(t){this.createPaymentMethodManager=null;this._paymentsList=[];this.currentSdkInstance=null;this.primerJS=null;this.loadingTimeout=null;this.isDisconnected=!1;(this.host=t).addController(this),this.isDisconnected=!1,this.sdkInstanceTask=new O(t,{args:()=>[this.host.clientToken,this.host.options],task:this.initializeHeadless()}),new O(t,{args:()=>[this.sdkInstanceTask.value,this.paymentsList],task:this.initializeLitContext()})}set paymentsList(t){this._paymentsList=t,this.host.requestUpdate()}get paymentsList(){return this._paymentsList}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&&(x.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?.(),x.info("SDK instance cleaned up")}catch(t){x.errorWithDatadog("Error cleaning up SDK instance",{error:t})}ea(),x.setEnvironment(void 0),x.setSdkVersion(void 0),x.setClientToken(void 0),x.setSdkOptions(void 0),x.setClientSessionId(void 0),this.currentSdkInstance=null,this.primerJS=null}async _loadV2Sdk(t=ka){let e=window;if(e.Primer&&typeof e.Primer.preloadPrimer=="function"){x.info("SDK already loaded, skipping load script"),await e.Primer.preloadPrimer();return}await Ia(t),await e.Primer.preloadPrimer()}initializeHeadless(){return async([t,e])=>{if(this.isDisconnected)return x.warn("Component disconnected, aborting SDK initialization"),N;if(!t||!e)return N;this.cleanupResources();let r;try{let o;if(e.sdkCore!==!1){let d=new ui;o={createHeadless:(u,f)=>En(u,{...f,dialogProvider:d,sdkVersion:hi})}}else await this._loadV2Sdk(),o=window.Primer;this.primerJS=new Zr(null);let a=this.normalizeOptionsForLegacySdk(e);x.setClientToken(t),x.setSdkOptions(a);let n=await o.createHeadless(t,{...a,onAvailablePaymentMethodsLoad:d=>{this.isDisconnected||(x.info("Configuration payment methods:",d),this.paymentsList=d)},onCheckoutComplete:({payment:d})=>{this.isDisconnected||(x.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?x.errorWithDatadog("Payment failed with server error",{error:d}):x.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(),N;this.host.sdkContextController.setClientOptions(e),this.primerJS&&this.host.primerEventsController.dispatchCheckoutInitialized(this.primerJS);let l=n.getSDKUtilities();if(r=n.getAnalyticsUtils?.(),r&&(this.host.sdkContextController.setAnalyticsUtils({...r,sdkVersion:hi}),x.setEnvironment(r.environment),x.setSdkVersion(hi),x.setClientSessionToken(r.clientSessionToken),x.setClientSessionId(r.clientSessionId),Qo({environment:r.environment,checkoutSessionId:r.checkoutSessionId,clientSessionId:r.clientSessionId||"",primerAccountId:r.primerAccountId||"",sdkVersion:hi,clientSessionToken:r.clientSessionToken}),q({eventName:"SDK_INIT_START"})),this.host.sdkContextController.setHeadlessUtils(l),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:!!l.getPaymentMethodConfiguration("PAYMENT_CARD")?.options?.captureVaultedCardCvv,showEmptyState:e.vault?.showEmptyState}),n}catch(o){throw o instanceof Error&&(x.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 N;if(!t||!e.length)return N;let r=new Map,o=new Map;try{for(let n of e){if(this.isDisconnected)break;let l=await this.initializePaymentMethodManager(n)();n&&l&&(r.set(n.type,n),o.set(n.type,l))}if(this.isDisconnected)return N;let a=new Jr(r);return this.host.sdkContextController.setPaymentManagers(o),this.host.sdkContextController.setPaymentMethods(a),this.primerJS&&this.primerJS.setPaymentMethods(a),this.host.primerEventsController.dispatchPaymentMethods(a),x.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 x.errorWithDatadog(`Failed to initialize manager for ${e}`,{error:o}),null}}}};var gi=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 Jd=Yo({"../../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")});Ki(i=>Jd(`../../localization/lit-localize/locales/${i}.ts`));var Zd={LOADER_DISABLED:"loader-disabled",CUSTOM_STYLES:"custom-styles",CLIENT_TOKEN:"client-token",JS_INIT:"js-initialized"},be=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 Tr(this),this.sdkStateController=new Pr(this),this.primerEventsController=new Lt(this),this.styleProcessingController=new Mr(this),this.vaultManagerController=new Jt(this),this.cardNetworkController=new Cr(this),this.achPaymentEventsController=new gi(this),new fi(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===Zd.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&&(Wi(this.options?.locale)?this.locale=qi(this.options?.locale):x.warn("\u{1F30E}\u2757 Unsupported locale provided:",this.options?.locale,"- Falling back to default locale `en-GB`")),ji(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&&(x.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)}};be.styles=[P,Ma],s([p({type:String,attribute:"custom-styles"})],be.prototype,"customStyles",2),s([p({type:String,attribute:"client-token"})],be.prototype,"clientToken",2),s([p({type:Object})],be.prototype,"options",2),s([p({type:Boolean,attribute:"loader-disabled"})],be.prototype,"disableLoader",2),s([p({type:Boolean,reflect:!0,attribute:"js-initialized"})],be.prototype,"_jsInitialized",2),s([pt("slot")],be.prototype,"defaultSlot",2),s([w()],be.prototype,"previousLoadingState",2),be=s([R(),b("primer-checkout")],be);function Xd(i){return document.querySelector(`#${i}`)}function Qd(i,t){let e=document.createElement("style");return e.textContent=i,e.id=t,e}function fr(i,t,e=!0){if(!Xr||Xd(t))return;let o=Qd(i,t);e&&document.head.firstChild?document.head.insertBefore(o,document.head.firstChild):document.head.appendChild(o)}var Pn=`
|
|
154
154
|
@keyframes primer-css-spinner-rotate {
|
|
155
155
|
0% {
|
|
156
156
|
transform: rotate(0deg);
|
package/dist/web-types.json
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@primer-io/primer-js",
|
|
3
3
|
"description": "Primer Checkout is a web component-based SDK for building secure, customizable, and PCI-compliant checkout experiences. Designed with a modular architecture, it integrates seamlessly with any JavaScript framework and supports multiple payment methods.",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
|
-
"version": "0.5.
|
|
5
|
+
"version": "0.5.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/primer-loader.js",
|
|
8
8
|
"types": "./dist/primer-loader.d.ts",
|