!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Hexea=t():e.Hexea=t()}(self,()=>(()=>{"use strict";var e={d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),p:"https://js.connexpointstage.com/"},t={};e.d(t,{default:()=>z});const n="validation_error";const i=class{constructor(e,t=null,i=null,a=null){this.type=n,this.message=e,this.modelState=a,this.errors=i,this.responseCode=t}},a="configuration_error";const o=class{constructor(e){this.type=a,this.message=e}},s="internal_server_error";const r=class{constructor(e,t=null,n=null,i=null){this.type=s,this.message=e,this.responseCode=t,this.errors=n,this.detailed_error_message=i}};const l=class{constructor(e,t="*"){var n,i,a;this.startSession=this.startSession.bind(this),this.invoke=this.invoke.bind(this),this.message=this.message.bind(this),this.ready=this.ready.bind(this),this.frameCallback=this.frameCallback.bind(this),this.frameCallbackError=this.frameCallbackError.bind(this),this.frameReady=this.frameReady.bind(this),this.isAlive=this.isAlive.bind(this),this.sendMessage=this.sendMessage.bind(this),this.processMessage=this.processMessage.bind(this),this.rpcID=0,this.target=e,this.host=t,this.promises={},this.readyQueue=[],this.readyStatus=!1,this.methods={},n=window,i="message",a=this.message,n.addEventListener?n.addEventListener(i,a,!1):n.attachEvent(`on${i}`,a)}startSession(){return this.sendMessage("frameReady"),this.frameReady()}unbind(){var e,t,n;e=window,t="message",n=this.message,e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent(`on${t}`,n)}invoke(e,...t){return this.ready(()=>this.sendMessage(e,t))}message(e){let t=!1;try{t=e.source===this.target&&("*"===this.host||e.origin===this.host)}catch(e){}t&&this.processMessage(e.data)}ready(e){return this.readyStatus?e():new Promise(t=>{this.readyQueue.push(()=>{t(e())})})}frameCallback(e,t){this.promises[e]&&this.promises[e].resolve(t),delete this.promises[e]}frameCallbackError(e,t){this.promises[e]&&this.promises[e].reject(t),delete this.promises[e]}frameReady(){return this.readyStatus=!0,this.readyQueue.forEach(e=>{e()}),!1}isAlive(){return!0}sendMessage(e,t=[]){const n=++this.rpcID;return new Promise((i,a)=>{this.promises[n]={resolve:i,reject:a};const o=JSON.stringify({method:e,args:t,id:n});if(null==(null!=this.target?this.target.postMessage:null)){const e=new Error("Unable to communicate. Please contact support if the problem persists.");if(null==this.methods.rpcError)throw e;return void this.methods.rpcError(e)}this.target.postMessage(o,this.host)})}processMessage(e){let t,l;try{l=JSON.parse(e)}catch(e){return}if(-1!==["frameReady","frameCallback","frameCallbackError","isAlive"].indexOf(l.method)){t=null;const e=this[l.method];null!=e&&(t=e.apply(this,l.args))}else t="function"==typeof this.methods[l.method]?this.methods[l.method](...l.args):void 0;"frameCallback"!==l.method&&"frameCallbackError"!==l.method&&(Promise.resolve(t)===t?t.then(e=>this.invoke("frameCallback",l.id,e)).catch(e=>{return this.invoke("frameCallbackError",l.id,(t=e).type===n?new i(t.message):t.type===a?new o(t.message):t.type===s?new r(t.message):t);var t}):this.invoke("frameCallback",l.id,t))}},c="client_error",h=e.p+"cardNumber.80a1dadd955aa7447c5a..html",d=e.p+"cardExpiration.8839d8d40296ff238973..html",p=e.p+"cardSwipe.51c14c179fcdfa06e466..html",m=e.p+"cardVerificationValue.8d591974a46b650de2a4..html";const y=class{constructor(e,t,n,i={}){this.paymentMethod=e,this.type=t,this.element=n,this.options=i,this.rpc=null,this.onChange=this.onChange.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.callbacks={},this.initialize()}initialize(){this.createElement(),this.createRPC(),this.findLabel()}blur(){this.rpc.invoke("blur")}clear(){this.rpc.invoke("clear")}focus(){this.rpc.invoke("focus")}on(e,t){if("function"!=typeof t)throw new Error("callback must be a function");this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t)}emit(e,...t){(this.callbacks[e]||[]).forEach(e=>{e(...t)})}onChange(e){this.emit("change",e)}onFocus(){this.emit("focus")}onBlur(){this.emit("blur")}createElement(){const e=document.createElement("div");e.style.cssText="border: none !important;\nmargin: 0px !important;\npadding: 0px !important;\ndisplay: block !important;\nbackground: transparent !important;\nposition: relative !important;\nopacity: 1 !important;\n";const t=document.createElement("iframe");switch(t.setAttribute("frameBorder","0"),t.setAttribute("allowtransparency","true"),t.setAttribute("scrolling","no"),t.name=this.getFrameID(),t.title="Secure payment method input frame",t.style.cssText="border: none !important;\nmargin: 0px !important;\npadding: 0px !important;\nwidth: 1px !important;\nmin-width: 100% !important;\noverflow: hidden !important;\ndisplay: block !important;\nheight: 20px;\nvisibility: hidden\n",t.addEventListener("load",()=>{t.style.visibility="visible"}),e.appendChild(t),this.type){case"cardNumber":t.src=h;break;case"cardExpiration":t.src=d;break;case"cardSwipe":t.src=p;break;case"cardVerificationValue":t.src=m;break;default:throw new Error(`${this.type} is not a valid field type. Try cardNumber, cardExpiration, or cardSwipe, or cvv  instead`)}this.element.appendChild(e),this.component=e,this.frame=t}createRPC(){const{frame:e,paymentMethod:t,options:n}=this,i=new l(e.contentWindow);i.methods.change=this.onChange,i.methods.focus=this.onFocus,i.methods.blur=this.onBlur,this.rpc=i,i.invoke("setOptions",n).then(({height:n})=>{t.registerFrame(this),e.style.height=`${n}px`,e.style.minHeight=`${n}px !important`,this.emit("ready")}),i.invoke("setMerchantInfo",t.merchantInfo)}updateMerchantInfo(e){this.rpc.invoke("setMerchantInfo",e)}findLabel(){const e=e=>{e.addEventListener("click",e=>{e.preventDefault(),this.focus()})};const{id:t}=this.element;if(t){const n=document.querySelector(`label[for="${t}"]`);n&&e(n)}!function t(n){n&&("LABEL"===n.tagName?e(n):t(n.parentNode))}(this.element.parentNode)}getFrameID(){return this.options.frameID}createPublicApi(){return{on:this.on.bind(this),blur:this.blur.bind(this),clear:this.clear.bind(this),focus:this.focus.bind(this)}}};class u{static configCache=new Map;static getConfigValue(e,t=null){return 0===u.configCache.size&&u.initializeCache(),u.configCache.has(e)?u.configCache.get(e):t}static initializeCache(){let e={};if(u.isRunningLocally()){const t=process.env.ENV_CONFIG;"string"==typeof t?e=JSON.parse(t||"{}"):"object"==typeof t&&null!==t&&(e=t)}Object.entries(e).forEach(([e,t])=>{u.configCache.set(e,t)})}static isRunningLocally(){return!1}}const g=u,f=["amex","discover","masterCard","visa"];class w{constructor(e){this.walletButton=e,this.paymentMethod=e.paymentMethod,this.options=e.options,this.style=this.options.wallets.applePay.style,this.futurePaymentOptions=this.options.wallets.applePay.futurePaymentOptions,this.supportedNetworks=f.filter(t=>e.supportedNetworks.filter(e=>e.toLowerCase()===t.toLowerCase()).length>0),this.applePaySDKUrl=g.getConfigValue("APPLEPAY_SDKURL","https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js"),this.tokenNotificationURL=g.getConfigValue("TOKENURLNOTIFICATION",""),this.applePaySettings={merchantIdApplePay:this.paymentMethod.merchantInfo.applePayPSPEnabled?this.paymentMethod.client.pcct:g.getConfigValue("APPLEPAY_MERCHANTID","merchant.com.vancopayments.stage"),currencyCode:"USD",countryCode:"US",merchantCapabilities:["supports3DS"]},this.options.debitCardOnly&&this.applePaySettings.merchantCapabilities.push("supportsDebit"),this.applePayStyle=`\n    /*\n    Apple Pay Style\n    */\n    apple-pay-button {\n    --apple-pay-button-width: ${this.style.width};\n    --apple-pay-button-height: ${this.style.height};\n    --apple-pay-button-border-radius: ${this.style.borderRadius};\n    --apple-pay-button-padding: 0px 0px;\n    --apple-pay-button-box-sizing: border-box;\n    }\n    `}logTrace(e,t={}){this.walletButton.logTrace(e,{pcct:this.paymentMethod.client.pcct,...t})}logException(e,t={}){this.walletButton.logException(e,{pcct:this.paymentMethod.client.pcct,...t})}startApplePaySession(e){const t=new ApplePaySession(10,e);this.handleApplePayEvents(t),t.begin()}handleApplePayEvents(e){const t={startDate:"",endDate:"",frequency:"",type:""},n={nameOnCard:"",paymentData:"",paymentMethod:"",transactionIdentifier:"",appleRecurrenceData:t},i={addressLine1:"",isSaved:this.options.isSaved,postalCode:"",countryCode:"USA",applePay:n,idType:this.options.idType,id:this.options.id,debitCardOnly:this.options.debitCardOnly};e.onvalidatemerchant=t=>{const n={appleUrl:t.validationURL,body:{merchantIdentifier:this.applePaySettings.merchantIdApplePay,domainName:this.options.merchantDomain??window.location.hostname,displayName:this.walletButton.customerName}};this.logTrace("Create apple pay session",{applePaySession:n,message:"Apple pay session"}),this.paymentMethod.client.controllerRPC.invoke("getApplePaySession",this.paymentMethod.client.pcct,n).then(t=>{e.completeMerchantValidation(JSON.parse(t))}).catch(e=>{this.logException(e,{applePaySession:n,message:"Error occured in apple pay session endpoint"})})},e.onpaymentauthorized=a=>{if(n.paymentData=a.payment.token.paymentData,n.paymentMethod=a.payment.token.paymentMethod,n.transactionIdentifier=a.payment.token.transactionIdentifier,n.nameOnCard=`${a.payment.billingContact.givenName} ${a.payment.billingContact.familyName}`,i.addressLine1=a.payment.billingContact.addressLines[0],i.postalCode=a.payment.billingContact.postalCode,i.deferredUse=this.options.deferredUse,i.isSaved=this.options.deferredUse?this.options.deferredUse:this.options.isSaved,this.options.deferredUse){t.startDate=this.futurePaymentOptions.recurringPaymentStartDate,t.endDate=this.futurePaymentOptions.recurringPaymentEndDate,t.frequency=this.futurePaymentOptions.frequency,t.type="onetime"===this.futurePaymentOptions.type?"oneTime":this.futurePaymentOptions.type;Object.values(t).some(e=>null!=e&&""!==e)||(n.appleRecurrenceData=null)}else n.appleRecurrenceData=null;this.logTrace("Apple pay tokenize"),this.paymentMethod.client.controllerRPC.invoke("tokenizeCardData",this.paymentMethod.client.pcct,i).then(t=>{t&&t.error?(e.completePayment(ApplePaySession.STATUS_FAILURE),this.walletButton.onPaymentMethod({error:t.error})):(this.walletButton.onPaymentMethod({paymentData:{paymentMethodToken:t.paymentMethodToken,isTest:t.isTest,paymentMethodType:t.paymentMethodType,nameOnCard:t.nameOnCard,bin:t.bin,last4:t.last4,expireMonth:t.expireMonth,expireYear:t.expireYear,addressLine1:t.addressLine1,postalCode:t.postalCode,brand:t.brand,countryCode:t.countryCode,isSaved:t.isSaved,deferredUse:t.deferredUse,quickCheckout:t.quickCheckout,isSwiped:t.isSwiped,isApplePay:"ApplePay"===t.digitalWallet,amount:this.options.amount,digitalWallet:t.digitalWallet,phone:a.payment.shippingContact?.phoneNumber||null,email:a.payment.shippingContact?.email||null,address:{addressLine1:a.payment.billingContact.addressLines[0],addressLine2:a.payment.billingContact.addressLines[1]??null,postalCode:a.payment.billingContact.postalCode,country:a.payment.billingContact.countryCode,city:a.payment.billingContact.locality,state:a.payment.billingContact.administrativeArea}},success:!0}),e.completePayment(ApplePaySession.STATUS_SUCCESS),this.logTrace("Apple pay tokenize success"))}).catch(t=>{e.completePayment(ApplePaySession.STATUS_FAILURE),this.walletButton.onPaymentMethod({error:t}),this.logException(t,{message:"Apple pay tokenize failed"})})},e.oncancel=e=>{const t={event:e,message:"Error occured in apple pay session endpoint"};this.logTrace("Apple pay session canceled ",t)}}loadApplePayScript(e=5e3,t=100){if(!document.querySelector(`script[src="${this.applePaySDKUrl}"]`)){const e=document.createElement("script");e.async=!0,e.src=this.applePaySDKUrl,e.crossOrigin="anonymous",e.onerror=e=>{this.logException(e,{message:"Error loading the Apple Pay SDK."})},document.body.appendChild(e)}let n=0;const i=(a,o)=>{window.ApplePaySession&&window.ApplePaySession.applePayCapabilities?a():(n+=t,n>=e&&o(new Error(`Apple Pay SDK unable to load within ${e}ms`)),setTimeout(()=>i(a,o),t))};return new Promise(i)}async checkApplePayAvailability(){try{if(await this.loadApplePayScript(),!window.ApplePaySession)return!1;if(!window.ApplePaySession.applePayCapabilities)return!!window.ApplePaySession.canMakePayments&&window.ApplePaySession.canMakePayments();try{const e=await window.ApplePaySession.applePayCapabilities(this.applePaySettings.merchantIdApplePay);return"paymentCredentialsAvailable"===e.paymentCredentialStatus||"paymentCredentialsUnavailable"===e.paymentCredentialStatus}catch(e){return this.logException(e,{message:"Apple Pay applePayCapabilities failed"}),!1}}catch(e){return this.logException(e,{message:"Apple Pay checkApplePayAvailability failed"}),!1}}static getIntervalValues(e){const t={daily:["day",1],weekly:["day",7],everyotherweek:["day",14],monthly:["month",1],quarterly:["month",3],annually:["year",1]},n=e?.toLowerCase();if(t[n])return t[n];throw new Error(`Invalid frequency: "${e}"`)}static validateDates(e,t){const n=new Date(e),i=t?new Date(t):null;if(Number.isNaN(n.getTime()))throw new Error("Start date is invalid");if(n<new Date)throw new Error("Start date is less than current date");if(i){if(Number.isNaN(i.getTime()))throw new Error("End date is invalid");if(n>i)throw new Error("Start date is greater than end date")}return!0}static getPaymentType(e){const t=e?.toLowerCase();return"recurring"===t?"recurring":"onetime"===t?"deferred":null}buildDeferredPaymentModel(e){return{deferredPaymentRequest:{paymentDescription:this.futurePaymentOptions.paymentDescription,deferredBilling:{label:"Deferred",amount:this.options.amount,paymentTiming:e,deferredPaymentDate:this.futurePaymentOptions.recurringPaymentStartDate},billingAgreement:"",managementURL:this.futurePaymentOptions.managementURL,tokenNotificationURL:this.tokenNotificationURL}}}buildRecurringPaymentModel(e){let t,n;try{[t,n]=w.getIntervalValues(this.futurePaymentOptions.frequency),w.validateDates(this.futurePaymentOptions.recurringPaymentStartDate,this.futurePaymentOptions.recurringPaymentEndDate)}catch(e){throw this.logException(e,{message:"Invalid Apple Pay recurring setup"}),e}return{recurringPaymentRequest:{paymentDescription:this.futurePaymentOptions.paymentDescription,regularBilling:{label:"Recurring",amount:this.options.amount,paymentTiming:e,recurringPaymentStartDate:this.futurePaymentOptions.recurringPaymentStartDate,recurringPaymentEndDate:this.futurePaymentOptions.recurringPaymentEndDate,recurringPaymentIntervalUnit:t,recurringPaymentIntervalCount:n},billingAgreement:"",managementURL:this.futurePaymentOptions.managementURL,tokenNotificationURL:this.tokenNotificationURL}}}buildApplePayModel(){const e={currencyCode:this.applePaySettings.currencyCode,countryCode:this.applePaySettings.countryCode,merchantCapabilities:this.applePaySettings.merchantCapabilities,supportedNetworks:this.supportedNetworks,requiredBillingContactFields:["name","phone","email","postalAddress"],total:{label:this.walletButton.customerName,amount:this.options.amount,type:"final"}};if(!0===this.options.deferredUse){const t=w.getPaymentType(this.futurePaymentOptions.type);"deferred"===t?Object.assign(e,this.buildDeferredPaymentModel(t)):"recurring"===t?Object.assign(e,this.buildRecurringPaymentModel(t)):this.logTrace("Invalid Apple Pay type for deferred use!")}return e}render(e){this.checkApplePayAvailability().then(t=>{if(!t)return;const n=this.buildApplePayModel();if(!n)return;const i=(this.paymentMethod.merchantInfo.acceptDonations??!1)&&"NP"===this.paymentMethod.merchantInfo.customerType,a="donate"===this.style.buttonType?.toLowerCase()&&i?this.style.buttonType??"plain":"plain",o=document.createElement("apple-pay-button");o.setAttribute("buttonstyle",this.style.color),o.setAttribute("type",a),o.setAttribute("locale","en-US");const s=document.createElement("style");s.innerHTML=this.applePayStyle;const r=document.querySelector("script");r.parentNode.insertBefore(s,r),o.addEventListener("click",()=>{this.startApplePaySession(n)}),e.appendChild(o),this.logTrace("Apple pay initialized",{options:this.options})})}}const b={apiVersion:2,apiVersionMinor:0},P=["AMEX","DISCOVER","MASTERCARD","VISA"],C=["PAN_ONLY","CRYPTOGRAM_3DS"];class E{constructor(e){this.walletButton=e,this.paymentMethod=e.paymentMethod,this.controllerRPC=this.paymentMethod.client.controllerRPC,this.supportedNetworks=e.supportedNetworks,this.style=e.options.wallets.googlePay.style,this.options=e.options,this.googlePayEnvironment=g.getConfigValue("GOOGLEPAY_ENVIRONMENT","TEST");const t="https://pay.google.com/gp/p/js/pay.js";if(document.querySelector(`script[src="${t}"]`))this.logTrace("[GooglePay] Found existing script:",{scriptUrl:t}),this.configureGooglePayClient();else{const e=document.createElement("script");e.async=!0,e.onload=()=>this.configureGooglePayClient(),e.src=t,document.body.appendChild(e)}}logTrace(e,t={}){this.walletButton.logTrace(e,{pcct:this.paymentMethod.client.pcct,...t})}logException(e,t={}){this.walletButton.logException(e,{pcct:this.paymentMethod.client.pcct,...t})}configureGooglePayClient(){const e={type:"PAYMENT_GATEWAY",parameters:{gateway:"vanco",gatewayMerchantId:this.paymentMethod.client.pcct}},t=!0===this.options.debitCardOnly;this.baseCardPaymentMethod={type:"CARD",parameters:{allowedAuthMethods:C,allowedCardNetworks:P.filter(e=>this.supportedNetworks.filter(t=>t.toLowerCase()===e.toLowerCase()).length>0),allowCreditCards:!t,allowPrepaidCards:!0,billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}},tokenizationSpecification:e},this.logTrace("Create Google Pay session",{googlePay:this.baseCardPaymentMethod}),this.paymentsClient=new google.payments.api.PaymentsClient({environment:this.googlePayEnvironment,paymentDataCallbacks:{onPaymentAuthorized:e=>this.onPaymentAuthorized(e)}})}onPaymentAuthorized(e){return new Promise(t=>{this.logTrace("Google Pay tokenize");const n={addressLine1:e.paymentMethodData.info.billingAddress.address1,isSaved:this.options.isSaved,deferredUse:this.options.deferredUse,postalCode:e.paymentMethodData.info.billingAddress.postalCode,countryCode:"USA",googlePay:{nameOnCard:e.paymentMethodData.info.billingAddress.name,billingAddress:{addressLine1:e.paymentMethodData.info.billingAddress.address1,addressLine2:e.paymentMethodData.info.billingAddress.address2,addressLine3:e.paymentMethodData.info.billingAddress.address3,city:e.paymentMethodData.info.billingAddress.locality,state:e.paymentMethodData.info.billingAddress.administrativeArea,postalCode:e.paymentMethodData.info.billingAddress.postalCode},paymentData:JSON.parse(e.paymentMethodData.tokenizationData.token),cardBrand:e.paymentMethodData.info.cardNetwork,last4:e.paymentMethodData.info.cardDetails},idType:this.options.idType,id:this.options.id,debitCardOnly:this.options.debitCardOnly};this.controllerRPC.invoke("tokenizeCardData",this.paymentMethod.client.pcct,n).then(n=>{n&&n.error?(t({transactionState:"ERROR"}),this.walletButton.onPaymentMethod({error:n.error})):(this.walletButton.onPaymentMethod({paymentData:{paymentMethodToken:n.paymentMethodToken,isTest:n.isTest,paymentMethodType:n.paymentMethodType,nameOnCard:n.nameOnCard,bin:n.bin,last4:n.last4,expireMonth:n.expireMonth,expireYear:n.expireYear,brand:n.brand,isSaved:n.isSaved,deferredUse:n.deferredUse,quickCheckout:n.quickCheckout,isSwiped:n.isSwiped,isApplePay:"ApplePay"===n.digitalWallet,amount:this.options.amount,digitalWallet:n.digitalWallet,phone:e.paymentMethodData.info.billingAddress.phoneNumber,email:e.email,address:{addressLine1:e.paymentMethodData.info.billingAddress.address1,addressLine2:e.paymentMethodData.info.billingAddress.address2,postalCode:e.paymentMethodData.info.billingAddress.postalCode,country:e.paymentMethodData.info.billingAddress.countryCode,city:e.paymentMethodData.info.billingAddress.locality,state:e.paymentMethodData.info.billingAddress.administrativeArea}},success:!0}),t({transactionState:"SUCCESS"}),this.logTrace("Google Pay tokenize success"))}).catch(e=>{t({transactionState:"ERROR"}),this.walletButton.onPaymentMethod({error:e}),this.logException(e,{message:"Google Pay tokenize failed"})})})}waitForPaymentsClient(e=5e3,t=100){const n=Date.now(),i=(a,o)=>{this.paymentsClient?a():Date.now()-n>=e?o(new Error("[GooglePay] PaymentsClient initialization timeout")):setTimeout(()=>i(a,o),t)};return new Promise(i)}async render(e){if(!this.paymentsClient)try{await this.waitForPaymentsClient(),this.logTrace("[GooglePay] PaymentsClient now available, proceeding with render")}catch(e){return void this.logException(e,{message:"Timeout waiting for Google Pay SDK"})}const t={...b,allowedPaymentMethods:[{...this.baseCardPaymentMethod}]};this.paymentsClient.isReadyToPay(t).then(t=>{if(t.result){const t={...b,merchantInfo:{merchantId:E.getFirstNonEmpty(this.options.wallets.googlePay?.merchantId,this.paymentMethod.merchantInfo.googleMerchantID),merchantName:this.walletButton.customerName},callbackIntents:["PAYMENT_AUTHORIZATION"],transactionInfo:{countryCode:"US",currencyCode:"USD",totalPriceStatus:"FINAL",totalPrice:this.options.amount.toString()},emailRequired:!0,allowedPaymentMethods:[this.baseCardPaymentMethod]};this.logTrace("Google Pay client fetch data",{paymentDataRequest:t}),this.paymentsClient.prefetchPaymentData(t);const n=document.createElement("div");this.style.width&&(n.style.width=this.style.width),this.style.height&&(n.style.height=this.style.height);let i="default";if(this.style.color)switch(this.style.color.toLowerCase()){case"black":i="black";break;case"white":case"white-outline":i="white";break;default:i="default"}const a=this.paymentsClient.createButton({buttonType:this.style.buttonType??"short",buttonColor:i,buttonRadius:parseInt(this.style.borderRadius,10),buttonSizeMode:"fill",onClick:()=>{try{this.paymentsClient.loadPaymentData(t).then(()=>{}).catch(e=>{this.logException(e,{message:"Google Pay loadPaymentData"})})}catch(e){this.logException(e,{message:"Google Pay onClick"})}},allowedPaymentMethods:[this.baseCardPaymentMethod]});n.appendChild(a),e.appendChild(n)}}).catch(e=>{this.logException(e,{message:"Google Pay isReadyToPay"})})}static getFirstNonEmpty(...e){return e.find(e=>null!=e&&""!==e)}}class S{constructor(e,t,n){this.paymentMethod=e,this.element=t,this.options=n,this.supportedNetworks=[],this.appleButtonEnabled=!1,this.samsungButtonEnabled=!1,this.googleButtonEnabled=!1,this.onPaymentMethod=this.onPaymentMethod.bind(this),this.callbacks={},this.customerName="",e.merchantInfo&&this.updateMerchantInfo(e.merchantInfo)}on(e,t){if("function"!=typeof t)throw new Error("callback must be a function");this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t)}emit(e,...t){(this.callbacks[e]||[]).forEach(e=>{e(...t)})}onPaymentMethod(e){e&&e.error?this.emit("paymentmethod",S.normalizeError(e.error)):this.emit("paymentmethod",e)}static normalizeError(e){return e&&e.type?{error:e}:{error:{type:"unknown_error",message:e?.message??"An error has occurred. Please try again.",errors:[]}}}logTrace(e,t={}){const n={pcct:this.paymentMethod.client.pcct,href:window.location.href};this.paymentMethod.client.logTrace(e,{...n,...t})}logException(e,t={}){this.paymentMethod.client.logException(e,{pcct:this.paymentMethod.client.pcct,...t})}updateMerchantInfo(e){this.logTrace("MerchantInfo for digital wallet",{merchantInfo:e});let t=[];if(e.amexAllowed&&(t=[...t,"amex"]),e.discoverAllowed&&(t=[...t,"discover"]),e.mastercardAllowed&&(t=[...t,"mastercard"]),e.visaAllowed&&(t=[...t,"visa"]),this.options.cardBrandsAllowed.length>0){const e=this.options.cardBrandsAllowed.map(e=>e.toLowerCase());t=t.filter(t=>e.includes(t.toLowerCase()))}this.supportedNetworks=t,e.applePayAllowed&&(this.appleButtonEnabled=e.applePayAllowed),e.samsungPayAllowed&&(this.samsungButtonEnabled=e.samsungPayAllowed),e.googlePayAllowed&&(this.googleButtonEnabled=e.googlePayAllowed),e.customerName&&(this.customerName=e.customerName),this.createElement()}createElement(){this.appleButtonEnabled&&(this.createApplePayButton(),this.logTrace("Element created for apple pay")),this.googleButtonEnabled&&(this.createGooglePayButton(),this.logTrace("Element created for google pay")),this.walletContainer()}createApplePayButton(){new w(this).render(this.element)}createGooglePayButton(){const e=this.paymentMethod.merchantInfo.googleMerchantID,t=this.options.wallets?.googlePay?.merchantId;if(!e&&!t){const e="merchantId is required for Google Pay transactions.";throw this.logTrace(e,this.options),new Error(e)}new E(this).render(this.element)}walletContainer(){if(0===(this.appleButtonEnabled?1:0)+(this.googleButtonEnabled?1:0)+(this.samsungButtonEnabled?1:0))return;const{layoutDirection:e,gap:t}=this.options.containerStyle,n=this.options.wallets?.applePay?.style?.width||this.options.wallets?.googlePay?.style?.width||this.options.wallets?.samsungPay?.style?.width;let i="";i="column"===e?["display: flex","flex-direction: column","width: 100%","align-items: "+(n?"center":"stretch"),`gap: ${t}`].join("; "):n?["display: flex","flex-direction: row","width: 100%","align-items: center",`gap: ${t}`].join("; "):["display: grid","width: 100%","grid-auto-flow: column","grid-auto-columns: 1fr","align-items: center",`gap: ${t}`].join("; "),this.element.setAttribute("style",i)}createPublicApi(){return{on:this.on.bind(this)}}}const A=S;class v{static transposeOptions(e,t){const n=JSON.parse(JSON.stringify(e));return n.version||n.amount?v.normalizeNewStructure(n,t):v.normalizeOldStructure(n,t)}static normalizeNewStructure(e,t){const n={...e};return n.version=e.version??"1.0",n.isSaved=e.isSaved??!1,n.deferredUse=e.deferredUse??!1,n.id=e.id??null,n.idType=e.idType??null,n.cardBrandsAllowed=e.cardBrandsAllowed??[],n.debitCardOnly=e.debitCardOnly??!1,n.containerStyle={gap:n.containerStyle?.gap||"10px",layoutDirection:n.containerStyle?.layoutDirection||"row"},n.wallets=n.wallets||{},n.wallets.applePay=v.normalizeWalletConfig(t,e.wallets?.applePay,{futurePaymentOptions:e.wallets?.applePay?.futurePaymentOptions||{}}),n.wallets.googlePay=v.normalizeWalletConfig(t,e.wallets?.googlePay,{merchantId:e.wallets?.googlePay?.merchantId}),n.wallets.samsungPay=v.normalizeWalletConfig(t,e.wallets?.samsungPay),n}static normalizeOldStructure(e,t){const n=v.normalizeStyle(t,e.style);return{version:"1.0",amount:e.total?.amount,merchantDomain:null,containerStyle:{layoutDirection:"row",gap:"10px"},isSaved:e.isSaved??!1,deferredUse:e.deferredUse??!1,id:e.id??null,idType:e.idType??null,cardBrandsAllowed:[],debitCardOnly:!1,wallets:{applePay:{style:n,futurePaymentOptions:e.deferredUse?{type:e.type,paymentDescription:e.paymentDescription,recurringPaymentStartDate:e.recurringPaymentStartDate,recurringPaymentEndDate:e.recurringPaymentEndDate,frequency:e.frequency,managementURL:e.managementURL}:{}},googlePay:{merchantId:e.merchantId,style:n},samsungPay:{style:n}}}}static normalizeWalletConfig(e,t,n={}){return{...t||{},style:v.normalizeStyle(e,t?.style||{}),...n}}static normalizeStyle(e,t={}){return{color:t.color||"black",height:`${Math.max(parseInt(t.height,10)||0,40)}px`,...t.width&&v.calculateWidth(t.width),borderRadius:v.calculateRadius(t.borderRadius,e),buttonType:t.buttonType}}static calculateWidth(e){if("string"==typeof e&&e.trim().endsWith("%"))return{width:e};const t=parseInt(e,10)||0;return{width:`${Math.max(t,100)}px`}}static calculateRadius(e,t){if("string"==typeof e&&e.trim().endsWith("em")){return parseFloat(e)*(parseFloat(window.getComputedStyle(t).fontSize)||16)+"px"}return"string"==typeof e&&e.trim().endsWith("px")?e:`${parseInt(e,10)||0}px`}}const M=v;let I=0;const D="card",k="echeck",T=[D,k,"wallet"];const x=class{constructor(e,t){if(-1===T.indexOf(t))throw new Error(`Payment method type "${t}" is not supported. Supported types: ${T.join(", ")}`);I+=1,this.name=`pm${I}`,this.client=e,this.type=t,this.fields=[],this.walletButton=void 0,this.submitting=!1,this.merchantInfo=null}field(e,t,n={}){const i=this.client.createFrameId(),a=new y(this,e,t,{...n,frameID:i,controllerFrameID:this.client.controllerFrameID});return this.fields.push(a),a.createPublicApi()}button(e,t,n={}){if("string"!=typeof e)throw new Error("Invalid button type.");const i=M.transposeOptions(n,t),a=new A(this,t,{...i});return this.walletButton=a,a.createPublicApi()}buttons(e,t={}){const n=M.transposeOptions(t,e),i=new A(this,e,{...n});return this.walletButton=i,i.createPublicApi()}updateMerchantInfo(e){this.merchantInfo=e,this.walletButton&&this.walletButton.updateMerchantInfo(e),this.fields.forEach(t=>{t.updateMerchantInfo(e)})}async tokenize(e={},t,n){if(this.submitting)return Promise.reject();this.submitting=!0;try{let i=null;return this.type===D?i=await this.client.controllerRPC.invoke("submit",this.name,e,t,n):this.type===k&&(i=await this.client.controllerRPC.invoke("submitEcheck",e,t,n)),i}catch(e){throw e}finally{this.submitting=!1}}registerFrame(e){this.client.registerPaymentMethodFrame(this.name,{name:e.getFrameID(),type:e.type})}createPublicApi(){return{name:this.name,field:this.field.bind(this),button:this.button.bind(this),buttons:this.buttons.bind(this)}}isValidIdType(e){return"idsId"===e||"partnerPayerRef"===e}isValidString(e){return"string"==typeof e&&""!==e.trim()}logTrace(e,t={}){this.client.logTrace(e,{pcct:this.client.pcct,...t})}logException(e,t={}){this.client.logException(e,{pcct:this.client.pcct,...t})}},N=e.p+"controller.b15640d660c536386ca1..html";const R=class{constructor(e){this.rpc=e}async logTrace(e,t={}){try{this.rpc&&await this.rpc.invoke("logTrace",e,t)}catch(e){}}async logException(e,t={}){try{if(this.rpc){let n;n=e instanceof Error?{message:e.message,stack:e.stack}:e,await this.rpc.invoke("logException",n,t)}}catch(e){}}async logEvent(e,t={}){try{this.rpc&&await this.rpc.invoke("logEvent",e,t)}catch(e){}}};const O=class{constructor(e,t,n={}){this.logger=e,this.fieldName=t,this.setConfig(n),this.isInitializing=!1}async start(e,t){if(!this.isInitializing){if(!this.config){const n=new Error("[TransactionMonitor] Configuration missing. Call setConfig() first.");return void this.logException(n,{sessionKey:e,pcct:t})}if(e&&"unknown"!==e&&t&&"unknown"!==t)try{this.isInitializing=!0,await this.loadSDK(e,t)}catch(n){this.logException(n,{sessionKey:e,pcct:t,message:"[TransactionMonitor] Error starting session"})}else this.logException(new Error("[TransactionMonitor] Invalid session key or pcct provided"),{fieldName:this.fieldName,sessionKey:e,pcct:t})}}async loadSDK(e,t){const n=document.querySelector(`script[src*="${this.config.apiSubdomain}/assets/loader.min.js"]`);return n?(this.logTrace("[TransactionMonitor] Found existing script:",{scriptSrc:n.src}),await this.waitAndCreateContext(e,t),Promise.resolve(!0)):new Promise(n=>{const i=document.createElement("script");i.type="text/javascript",i.async=!0,i.src=`https://${this.config.apiSubdomain}/assets/loader.min.js`,i.onload=async()=>{await this.waitAndCreateContext(e,t),n(!0)},i.onerror=a=>{this.logException(a,{sessionKey:e,pcct:t,message:"[TransactionMonitor] Error loading SDK."}),i.parentNode&&i.parentNode.removeChild(i),n(!1)};const a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(i,a)})}async waitAndCreateContext(e,t){try{if(!await this.waitForSDK())return;this.createContext(e,t)}catch(n){this.logException(n,{sessionKey:e,pcct:t,message:"[TransactionMonitor] Error creating context"})}}waitForSDK(e=3e3,t=50){const n=Date.now(),i=a=>{const o=window[this.config.sdkGlobalName];if(o&&"function"==typeof o.createContext)a(!0);else{if(Date.now()-n>=e){const e=new Error("[TransactionMonitor] SDK initialization timeout");return this.logException(e,{message:"[TransactionMonitor] SDK timeout"}),void a(!1)}setTimeout(()=>i(a),t)}};return new Promise(i)}createContext(e,t){const n={clientId:this.config.clientId,sessionKey:e,flow:this.config.flow,environment:this.config.environment,parentElement:this.config.parentElement,partnerId:t,apiSubdomain:this.config.apiSubdomain,pixelSubdomain:this.config.pixelSubdomain,onDeviceResponse:n=>this.handleDeviceResponse(n,t,e)},i=window[this.config.sdkGlobalName].createContext(n);this.logTrace("[TransactionMonitor] Context created successfully:",{config:i.config,sessionKey:e,pcct:t})}handleDeviceResponse(e,t,n){if(this.logTrace("[TransactionMonitor] Device response received:",{data:e,pcct:t,sessionKey:n}),this.config.onDeviceResponseCallback)try{this.config.onDeviceResponseCallback(e,t,n)}catch(e){this.logException(e,{sessionKey:n,pcct:t,message:"[TransactionMonitor] Error in onDeviceResponse callback"})}}setConfig(e={}){this.config={clientId:e.clientId||g.getConfigValue("MONITORINGCLIENTID","78b751f9-f431-4ce9-a57a-97b3280a4a59"),environment:e.environment||g.getConfigValue("MONITORINGENVIRONMENT","sandbox"),apiSubdomain:e.apiSubdomain||g.getConfigValue("APISUBDOMAIN","mrmistoffelees.connexpointtest.com"),pixelSubdomain:e.pixelSubdomain||g.getConfigValue("PIXELSUBDOMAIN","pspsps.connexpointtest.com"),flow:e.flow||this.fieldName,parentElement:e.parentElement||document.body,sdkGlobalName:e.sdkGlobalName||"_Sardine"},"function"==typeof e.onDeviceResponse&&(this.config.onDeviceResponseCallback=e.onDeviceResponse)}logTrace(e,t={}){this.logger&&this.logger.logTrace&&this.logger.logTrace(e,t)}logException(e,t={}){this.logger&&this.logger.logException&&this.logger.logException(e,t)}};let L="";class B{constructor(e){if("string"!=typeof e||!e.trim())throw new Error("PCCT is required");this.pcct=e,this.paymentMethods={},this.controllerFrame=null,this.controllerFrameID=null,this.controllerRPC=null,this.logger=null,this.merchantInfo=null,this.frameCount=0,this.envHelper=g,this.siteKeyValue=this.envHelper.getConfigValue("SiteKey","6LcUK18iAAAAAAFSbv0aH6bZN0e5h0mtd2qbc-Wm"),this.createControllerFrame()}deconstructor(){this.controllerFrame=null,document.removeChild("iframe")}paymentMethod(e){const t=new x(this,e);return this.paymentMethods[t.name]=t,this.fetchAndPassOnMerchantInfo(t),t.createPublicApi()}async validateIFrame(){let e=!1;const t=document.querySelectorAll('iframe[name^="hexeaSecureFrame"]');for(let n=0;n<t.length;n++){const i=document.getElementsByName(t[n].name)[0];if(null!==i){const t=i.contentWindow.document.getElementById("USBHID");if(null!=t){e=!0;break}}}return e}waitForMerchantInfo(e=5e3,t=100){const n=Date.now(),i=(a,o)=>{this.merchantInfo?a():Date.now()-n>=e?o(new Error("Failed to get merchant info within the allowed time.")):setTimeout(()=>i(a,o),t)};return new Promise(i)}async tokenize(e,t){if(!this.merchantInfo)try{await this.waitForMerchantInfo()}catch(e){throw this.logException(e,{message:"Error waiting for merchant info",pcct:this.pcct}),e}const n=this.paymentMethods[e.name];if(L="","captchaEnabled"in this.merchantInfo&&0!==this.merchantInfo.captchaEnabled&&"card"===n.type){const e=await this.getAdminDomainInfo();if(!0===e.isAdminPage)L=e.token;else{await this.loadGrecaptchaDocument(this.merchantInfo.captchaEnabled),setTimeout(()=>{const e=document.getElementById("hexeaCardUIBody");if(e){const t=e.querySelectorAll("div"),n=t[t.length-3];n&&(n.style.zIndex="999999",n.style.transform="scale(0.88)",n.style.transformorigin="top",n.style.top="0px")}},1e3);const e=6e4,t=Date.now();for(;""===L&&Date.now()-t<e;)await new Promise(e=>setTimeout(e,100));""===L&&this.logTrace("Captcha token not received within timeout period.")}}if(!n)throw new o("The payment method provided to Tokenize was not created by this instance of Hexea()");const i=t?{...t}:{};return i.ReferrerURL=document.location.href,this.logTrace(`[Hexea] tokenize pm method called for pcct:${this.pcct}`,{pcct:this.pcct,captcha_Token:L,billing:i}),n.tokenize(i,this.pcct,L)}applyStyle(e,t){null!=e&&Object.keys(t).forEach(n=>e.style[n]=t[n])}async loadGrecaptchaDocument(e=1){const t=document.createElement("script");t.innerHTML=`var onloadCallback = function() {widgetId = grecaptcha.render('html_element', { 'sitekey': '${this.siteKeyValue}' ,'callback':'myCallBackFunction','size':'normal' });};`,document.head.appendChild(t),document.addEventListener("submit",function(){grecaptcha.reset(undefined)});const n=document.createElement("div");n.id="divCaptchaContainer",this.applyStyle(n,{margin:"15px 0","z-index":"inherit"});const i=document.createElement("div");i.id="divCaptcha",i.innerHTML="<div id='html_element' style='z-index:99999;'></div>",n.appendChild(i);const a=document.getElementById("g-recaptcha");if(this.applyStyle(i,{display:"flex",justifyContent:"center","z-index":9999}),2===e&&null!==a){const e=document.getElementById("iFrameResizer0");this.applyStyle(e,{height:"500px!important"}),a.parentNode.insertBefore(n,a)}else this.applyStyle(n,{margin:"0 0"}),this.applyStyle(i,{position:"fixed",left:0,top:0,width:"100%",height:"100%","align-items":"center","align-content":"stretch",background:"rgba(0,0,0,0.5)"}),document.body.appendChild(n);const o=document.createElement("script");return o.setAttribute("src","https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"),o.setAttribute("async","true"),o.setAttribute("defer","true"),document.body.appendChild(o),window.myCallBackFunction=async function(e){const t=e,i=document.createTextNode('Please check "I\'m not a robot"');if(""!==t)return L=t,n.parentElement.removeChild(n),!0;newCaptchaDiv.appendChild(i)},!1}async getAdminDomainInfo(){const e=B.getDeviceType();return this.controllerRPC.invoke("checkIfIsAdminDomain",this.pcct,e)}static getDeviceType(){const e=window.navigator.standalone,t=window.navigator.userAgent.toLowerCase();return/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(window.navigator.userAgent)&&!e||t.includes("wv")?"mobileDevice":window.location.href}fetchAndPassOnMerchantInfo(e){const t="card"===e.type&&this.merchantInfo&&this.merchantInfo.sardineEnabled;!this.merchantInfo||t&&!this.merchantInfo.sessionKey?this.merchantInfo&&t&&!this.merchantInfo.sessionKey?this.addSessionData(e):this.merchantInfo||this.controllerRPC.invoke("fetchMerchantInfo",[this.pcct]).then(t=>{this.merchantInfo=t,this.addSessionData(e)}).catch(e=>{throw e&&e.type?e.type===c?new Error("PCCT is not recognized"):new Error("Failed to get merchant info"):e}):e.updateMerchantInfo(this.merchantInfo)}addSessionData(e){this.merchantInfo.sardineEnabled&&"card"===e.type?this.controllerRPC.invoke("getSessionKey").then(t=>{this.merchantInfo=Object.assign(this.merchantInfo,{sessionKey:t,pcct:this.pcct}),e.updateMerchantInfo(this.merchantInfo),this.startTransactionMonitor(t,this.pcct)}).catch(e=>{throw new Error("Failed to get session info")}):e.updateMerchantInfo(this.merchantInfo)}startTransactionMonitor(e,t){const n=window.location.pathname,i=n.length>15?n.slice(0,15):n;new O(this.logger,`Main:${i}`).start(e,t)}createFrameId(){return this.frameCount+=1,`hexeaSecureFrame${this.frameCount}`}createControllerFrame(){this.controllerFrameID=this.createFrameId();const e=document.createElement("iframe");e.title="Secure payment method input frame",e.style.visibility="hidden",e.style.width="0px",e.style.height="0px",e.src=N,e.name=this.controllerFrameID,document.body.appendChild(e),this.controllerFrame=e,this.controllerRPC=new l(e.contentWindow),this.logger=new R(this.controllerRPC),this.logTrace("[Hexea] controller iFrame created",{domain:window.location.hostname,href:window.location.href})}registerPaymentMethodFrame(...e){return this.controllerRPC.invoke("registerPaymentMethodFrame",...e)}logTrace(e,t={}){this.logger&&this.logger.logTrace&&this.logger.logTrace(e,t)}logException(e,t={}){this.logger&&this.logger.logException&&this.logger.logException(e,t)}createPublicApi(){return{paymentMethod:this.paymentMethod.bind(this),tokenize:this.tokenize.bind(this)}}}const U=B;const z=function(...e){return new U(...e).createPublicApi()};return t=t.default})());