@bigcommerce/checkout-sdk 1.889.0 → 1.889.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.
@@ -1,2 +1,2 @@
1
- import{createFormPoster as e}from"@bigcommerce/form-poster";import{createRequestSender as t}from"@bigcommerce/request-sender";import{getScriptLoader as n,getStylesheetLoader as i}from"@bigcommerce/script-loader";import{find as o,includes as r,isArray as a,isObject as s,round as c,some as d}from"lodash";class l extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}class u extends l{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}var h;class y{constructor(e,t,n=window){this._scriptLoader=e,this._stylesheetLoader=t,this._window=n}load(e){var t,n,i,o,r,a;return i=this,o=void 0,a=function*(){if(yield Promise.all([this._stylesheetLoader.loadStylesheet(`https://checkoutshopper-${null!==(t=e.environment)&&void 0!==t?t:""}.adyen.com/checkoutshopper/sdk/3.10.1/adyen.css`,{prepend:!1,attributes:{integrity:"sha384-8ofgICZZ/k5cC5N7xegqFZOA73H9RQ7H13439JfAZW8Gj3qjuKL2isaTD3GMIhDE",crossorigin:"anonymous"}}),this._scriptLoader.loadScript(`https://checkoutshopper-${null!==(n=e.environment)&&void 0!==n?n:""}.adyen.com/checkoutshopper/sdk/3.10.1/adyen.js`,{async:!0,attributes:{integrity:"sha384-wG2z9zSQo61EIvyXmiFCo+zB3y0ZB4hsrXVcANmpP8HLthjoQJQPBh7tZKJSV8jA",crossorigin:"anonymous"}})]),!this._window.AdyenCheckout)throw new u;return new this._window.AdyenCheckout(e)},new((r=void 0)||(r=Promise))(function(e,t){function n(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof r?i:new r(function(e){e(i)})).then(n,s)}c((a=a.apply(i,o||[])).next())})}}function g(e,t){return Object.assign(e,{resolveIds:t})}function p(e){return"object"==typeof e&&null!==e&&"errors"in e&&Array.isArray(e.errors)&&"code"in e.errors[0]&&"string"==typeof e.errors[0].code&&"provider_data"in e&&"object"==typeof e.provider_data}!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(h||(h={}));class m extends l{constructor(e){super(function(e){switch(e){case h.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case h.MissingCart:return"Unable to proceed because cart data is unavailable.";case h.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case h.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case h.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case h.MissingCheckoutConfig:case h.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case h.MissingOrder:return"Unable to proceed because order data is unavailable.";case h.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case h.MissingPayment:return"Unable to proceed because payment data is unavailable.";case h.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case h.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case h.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}function f(){const{navigator:e}=window;let t;return t=e.language?e.language:e.userLanguage,{color_depth:window.screen.colorDepth||24,java_enabled:"function"==typeof e.javaEnabled&&e.javaEnabled(),language:t,screen_height:window.screen.height,screen_width:window.screen.width,time_zone_offset:(new Date).getTimezoneOffset().toString()}}const P=e=>"object"==typeof e&&null!==e&&"body"in e;class w extends l{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}var v;!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(v||(v={}));class _ extends l{constructor(e){super(function(e){switch(e){case v.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case v.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case v.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case v.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}class b extends l{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}function C(e,t,n){if("function"!=typeof n.value)return n;let i=n.value;return{get(){const e=i.bind(this);return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e},set(e){i=e}}}class S{constructor(e){if(!e)throw new Error("Currency settings missing");const{decimalPlaces:t,symbolLocation:n,symbol:i,thousandsSeparator:o,decimalSeparator:r}=e;if("string"!=typeof n||"string"!=typeof i||"string"!=typeof o||"string"!=typeof r||"string"!=typeof t)throw new b("Invalid currency settings provided");this._decimalPlaces=parseInt(t,10),this._symbolLocation=n,this._symbol=i,this._thousandsSeparator=o,this._decimalSeparator=r}format(e){if("number"!=typeof e)throw new b("Invalid amount provided");const t=this._formatNumber(e),n=this._formatCurrency(t);return e<0?`-${n}`:n}_formatNumber(e){const t=Math.abs(e),[n,i=""]=this._toFixed(t,this._decimalPlaces).split("."),o=n.replace(/\B(?=(\d{3})+(?!\d))/g,this._thousandsSeparator);return this._decimalPlaces<1?o:[o,i].join(this._decimalSeparator)}_formatCurrency(e){return"left"===this._symbolLocation.toLowerCase()?`${this._symbol}${e}`:`${e}${this._symbol}`}_toFixed(e,t){return(+`${Math.round(+`${e}e${t}`)}e${-t}`).toFixed(t)}}let I=class{constructor(e){this._storeConfig=e,this._customerFormatter=new S(this._storeConfig.shopperCurrency),this._storeFormatter=new S(this._storeConfig.currency)}toCustomerCurrency(e){const t=this._storeConfig.shopperCurrency.exchangeRate;return this._customerFormatter.format(e*t)}toStoreCurrency(e){return this._storeFormatter.format(e)}};I=function(e,t,n,i){var o,r=arguments.length,a=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(t,n,a):o(t,n))||a);return r>3&&a&&Object.defineProperty(t,n,a),a}([function(e,t,n){return t&&n?C(0,t,n):function(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&"constructor"!==n&&Object.defineProperty(t.prototype,n,C(e.prototype,n,i))}),t}(e)}],I);const O=I;function k(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}function A(){if("undefined"==typeof window)return!1;if(function(e){return"ReactNativeWebView"in e}(window))return!0;const e=navigator.userAgent||navigator.vendor||(function(e){return"opera"in e}(window)?window.opera:""),t=/android.+; wv/i.test(e),n=/iPhone|iPod|iPad/i.test(e)&&/AppleWebKit/i.test(e)&&!/Safari/i.test(e);return t||n}function T(e,t,n=!0){var i;return null!==(i=e[t])&&void 0!==i?i:n}var E,M,D,N,R,x,z,G,B;function j(e){return e in x}!function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(E||(E={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(M||(M={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(D||(D={})),function(e){e.pill="pill",e.rect="rect"}(N||(N={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(R||(R={})),function(e){e.AMEX="AMEX",e.DISCOVER="DISCOVER",e.INTERAC="INTERAC",e.JCB="JCB",e.MC="MASTERCARD",e.VISA="VISA"}(x||(x={})),function(e){e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION"}(z||(z={})),function(e){e.OFFER_INVALID="OFFER_INVALID",e.PAYMENT_DATA_INVALID="PAYMENT_DATA_INVALID",e.SHIPPING_ADDRESS_INVALID="SHIPPING_ADDRESS_INVALID",e.SHIPPING_ADDRESS_UNSERVICEABLE="SHIPPING_ADDRESS_UNSERVICEABLE",e.SHIPPING_OPTION_INVALID="SHIPPING_OPTION_INVALID",e.OTHER_ERROR="OTHER_ERROR"}(G||(G={})),function(e){e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER"}(B||(B={}));var L=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class F{constructor(e,t){this._gatewayIdentifier=e,this._paymentIntegrationService=t,this._isBuyNowFlow=!1,this._shouldRequestShipping=!0,this._isWebViewExperimentOn=null}mapToShippingAddressRequestBody({shippingAddress:e}){if(!e)return;const{company:t="",phone:n=""}=this._paymentIntegrationService.getState().getShippingAddress()||{};return this._mapToAddressRequestBody(e,t,n)}mapToBillingAddressRequestBody(e){const{billingAddress:t}=e.paymentMethodData.info;if(!t)return;const{company:n="",phone:i="",email:o,customFields:r=[]}=this._paymentIntegrationService.getState().getBillingAddress()||{};return Object.assign(Object.assign({},this._mapToAddressRequestBody(t,n,i,r)),{email:o||e.email})}mapToExternalCheckoutData(e){var t;const{paymentMethodData:{tokenizationData:{token:n},info:{cardNetwork:i,cardDetails:o}}}=e;if(!n)throw new m(h.MissingPaymentToken);return Promise.resolve(Object.assign({nonce:n,card_information:{type:i,number:o}},this._isBuyNowFlow&&{cart_id:null===(t=this._paymentIntegrationService.getState().getCart())||void 0===t?void 0:t.id}))}getRequiredData(){var e;return L(this,void 0,void 0,function*(){const t={emailRequired:!0};if(!this._isShippingAddressRequired())return t;const n=yield this._paymentIntegrationService.loadShippingCountries(),i=null===(e=n.getShippingCountries())||void 0===e?void 0:e.map(e=>e.code);return Object.assign(Object.assign({},t),{shippingAddressRequired:!0,shippingAddressParameters:Object.assign({phoneNumberRequired:!0},i&&{allowedCountryCodes:i}),shippingOptionRequired:!0})})}getCallbackIntents(){return this._isShippingAddressRequired()?[z.OFFER,z.SHIPPING_ADDRESS,z.SHIPPING_OPTION]:[z.OFFER]}getCallbackTriggers(){return{availableTriggers:[B.INITIALIZE,B.SHIPPING_ADDRESS,B.SHIPPING_OPTION,B.OFFER],initializationTrigger:[B.INITIALIZE],addressChangeTriggers:[B.INITIALIZE,B.SHIPPING_ADDRESS],shippingOptionsChangeTriggers:[B.SHIPPING_OPTION],offerChangeTriggers:[B.OFFER]}}getNonce(e){var t;const n=null===(t=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(e).initializationData)||void 0===t?void 0:t.nonce;if(!n)throw new m(h.MissingPaymentToken);return Promise.resolve(n)}extraPaymentData(){return Promise.resolve(void 0)}getMerchantInfo(){const{googleMerchantName:e,googleMerchantId:t,platformToken:n}=this.getGooglePayInitializationData();return{merchantName:e,merchantId:t,authJwt:n}}getTransactionInfo(){let e;const{getCartOrThrow:t}=this._paymentIntegrationService.getState();e=this._isBuyNowFlow?this._getCurrencyCodeOrThrow():t().currency.code;const n=this.getGooglePayInitializationData().storeCountry;if(this.isWebViewWithRestrictions()){const t=this.getTotalPrice();return Object.assign(Object.assign({},n&&{countryCode:n}),{currencyCode:e,totalPrice:t,totalPriceStatus:R.ESTIMATED})}return Object.assign(Object.assign({},n&&{countryCode:n}),{currencyCode:e,totalPriceStatus:R.ESTIMATED,totalPrice:"0"})}isWebViewWithRestrictions(){return null!==this._isWebViewExperimentOn?this._isWebViewExperimentOn&&A():A()}setIsWebViewExperimentOn(e){this._isWebViewExperimentOn=e}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData().gatewayMerchantId;if(!e)throw new b("Unable to proceed, gatewayMerchantId is missing.");return{gateway:this._gatewayIdentifier,gatewayMerchantId:e}}getCardParameters(){return{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:this.getPaymentMethod().supportedCards.filter(j).map(e=>x[e]),billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}}initialize(e,t,n){return this._getPaymentMethodFn=e,this._isBuyNowFlow=Boolean(t),this._currencyCode=n,this._isBuyNowFlow&&this._getCurrencyCodeOrThrow(),Promise.resolve()}handleShippingAddressChange(e){var t,n,i,o;return L(this,void 0,void 0,function*(){e&&(e.name=e.name||"",e.address1=e.address1||"");const r=this.mapToShippingAddressRequestBody({shippingAddress:e});r&&(yield this._paymentIntegrationService.updateShippingAddress(r));const a=this._paymentIntegrationService.getState(),s=a.getConsignments();if(!(null==s?void 0:s[0]))return;const c=s[0],d=a.getStoreConfigOrThrow();this._currencyService||(this._currencyService=new O(d));const l=(c.availableShippingOptions||[]).map(this._getGooglePayShippingOption.bind(this)),u=null===(t=c.availableShippingOptions)||void 0===t?void 0:t.find(e=>e.isRecommended);if(l.length){const e=(null===(n=c.selectedShippingOption)||void 0===n?void 0:n.id)||(null==u?void 0:u.id)||(null===(i=l[0])||void 0===i?void 0:i.id);return!(null===(o=c.selectedShippingOption)||void 0===o?void 0:o.id)&&l[0]&&(yield this.handleShippingOptionChange((null==u?void 0:u.id)||l[0].id)),{defaultSelectedOptionId:e,shippingOptions:l}}})}handleShippingOptionChange(e){return L(this,void 0,void 0,function*(){if("shipping_option_unselected"!==e)return this._paymentIntegrationService.selectShippingOption(e)})}getTotalPrice(){const{getCheckoutOrThrow:e,getCartOrThrow:t,getStoreConfigOrThrow:n}=this._paymentIntegrationService.getState(),{decimalPlaces:i}=t().currency,o=T(n().checkoutSettings.features,"PI-5075.google_pay_round_total_price_to_max_2_decimal_places")?Math.min(i,2):i;return c(e().outstandingBalance,o).toFixed(o)}handleCoupons(e){return L(this,void 0,void 0,function*(){const{redemptionCodes:t=[]}=e,{offers:n}=this.getAppliedCoupons()||{};let i;return yield t.reduce((e,t)=>L(this,void 0,void 0,function*(){if(yield e,(n||[]).some(({redemptionCode:e})=>e===t))return;const o=yield this.applyCoupon(t);o&&(i=o)}),Promise.resolve()),yield(n||[]).reduce((e,n)=>L(this,void 0,void 0,function*(){yield e,t.includes(n.redemptionCode)||(yield this._paymentIntegrationService.removeCoupon(n.redemptionCode))}),Promise.resolve()),{newOfferInfo:this.getAppliedCoupons(),error:i}})}getAppliedCoupons(){const e=this._paymentIntegrationService.getState(),{coupons:t}=e.getCheckout()||{};return{offers:(t||[]).map(e=>{const{displayName:t,code:n}=e;return{redemptionCode:n,description:t}})}}applyCoupon(e){return L(this,void 0,void 0,function*(){let t;try{yield this._paymentIntegrationService.applyCoupon(e)}catch(e){return e instanceof Error&&(t={reason:G.OFFER_INVALID,message:e.message,intent:B.OFFER}),t}})}setShouldRequestShipping(e){this._shouldRequestShipping=e}getGooglePayInitializationData(){return k(this.getPaymentMethod().initializationData,()=>new b("Missing initialization data."))}getPaymentMethod(){return k(this._getPaymentMethodFn,()=>new _(v.PaymentNotInitialized))()}getGatewayIdentifier(){return this._gatewayIdentifier}setGatewayIdentifier(e){this._gatewayIdentifier=e||this.getGatewayIdentifier()}_isShippingAddressRequired(){const{getCartOrThrow:e,getStoreConfigOrThrow:t,getShippingAddress:n}=this._paymentIntegrationService.getState(),i=t();let o;return o=T(i.checkoutSettings.features,"PI-4290.google_pay_require_shipping_address")?this._shouldRequestShipping:void 0===n(),o&&(r=e(),a=i,!!r&&(!!r.lineItems.physicalItems.some(e=>e.isShippingRequired)||!(!a||!r.lineItems.customItems)&&r.lineItems.customItems.length>0));var r,a}_mapToAddressRequestBody(e,t,n,i){const{name:o,address1:r,address2:a,address3:s,locality:c,administrativeArea:d,countryCode:l,postalCode:u,phoneNumber:h}=e,[y,g]=this._getFirstAndLastName(o);return{firstName:y,lastName:g,company:t,address1:r,address2:`${a} ${s}`.trim(),city:c||d,stateOrProvince:d,stateOrProvinceCode:d,countryCode:l,postalCode:u,phone:h||n,customFields:i||[]}}_getFirstAndLastName(e){const t=e.split(" ");return 1===t.length?[e,""]:[t.slice(0,-1).join(" "),t[t.length-1]]}_getCurrencyCodeOrThrow(){return k(this._currencyCode,()=>new b('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}_getGooglePayShippingOption({id:e,cost:t,description:n,additionalDescription:i}){var o;return{id:e,label:`${(null===(o=this._currencyService)||void 0===o?void 0:o.toCustomerCurrency(t))||t} ${n}`,description:i}}}var V=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class U extends F{constructor(e,t){super("adyen",e),this._scriptLoader=t,this._service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return V(this,void 0,void 0,function*(){yield i.initialize.call(this,e,t,n);const o=i.getPaymentMethod.call(this),r=this._service.getState().getStoreConfig();if(!r)throw new m(h.MissingCheckoutConfig);return this._adyenClient=yield this._scriptLoader.load({environment:o.config.testMode?"test":"live",locale:r.storeProfile.storeLanguage}),Promise.resolve()})}getNonce(e){const t=Object.create(null,{getNonce:{get:()=>super.getNonce},getPaymentMethod:{get:()=>super.getPaymentMethod}});return V(this,void 0,void 0,function*(){const n=yield t.getNonce.call(this,e),i=t.getPaymentMethod.call(this);return JSON.stringify({type:i.method,googlePayToken:n,browser_info:f()})})}processAdditionalAction(e){return V(this,void 0,void 0,function*(){if(!P(e)||!p(e.body))throw e;const t=yield this._handleAction(e.body.provider_data);try{return yield this._service.submitPayment(t)}catch(e){return this.processAdditionalAction(e)}})}_handleAction(e){return new Promise((t,n)=>{const i=JSON.parse(e.action);this._getAdyenClient().createFromAction(i,{onAdditionalDetails:e=>{const n={methodId:i.paymentMethodType,paymentData:{nonce:JSON.stringify(e.data)}};t(n)},size:"05",onError:e=>n(e)}).mount("body"),n(new w)})}_getAdyenClient(){if(!this._adyenClient)throw new _(v.PaymentNotInitialized);return this._adyenClient}}const q={"X-Checkout-SDK-Version":"1.889.0"};class W extends l{constructor(e){super(e||"Unable to proceed because the client library of a payment method has thrown an unexpected error."),this.name="PaymentMethodFailedError",this.type="payment_method_client_invalid"}}var H=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Y{constructor(e,t,n,i){this._scriptLoader=e,this._gateway=t,this._requestSender=n,this._formPoster=i,this._baseRequest={apiVersion:2,apiVersionMinor:0}}initialize(e,t,n,i){return H(this,void 0,void 0,function*(){this._paymentsClient=yield this._scriptLoader.getGooglePaymentsClient(e().config.testMode,t),yield this._gateway.initialize(e,n,i),this._buildButtonPayloads()})}initializeWidget(){return H(this,void 0,void 0,function*(){yield this._buildWidgetPayloads(),yield this._determineReadinessToPay(),this._prefetchGooglePaymentData()})}getNonce(e){return this._gateway.getNonce(e)}extraPaymentData(){return H(this,void 0,void 0,function*(){return this._gateway.extraPaymentData()})}addPaymentButton(e,t){const n=document.querySelector(`#${e}`);if(!n)return;const i=this._getPaymentsClient().createButton(Object.assign(Object.assign({},t),{allowedPaymentMethods:[this._getBaseCardPaymentMethod()]}));return n.appendChild(i)}showPaymentSheet(){return H(this,void 0,void 0,function*(){const e=this._getPaymentDataRequest();return this._getPaymentsClient().loadPaymentData(e)})}setExternalCheckoutXhr(e,t){return H(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t)})}setExternalCheckoutForm(e,t,n){return H(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t,!0,n)})}mapToBillingAddressRequestBody(e){return this._gateway.mapToBillingAddressRequestBody(e)}mapToShippingAddressRequestBody(e){return this._gateway.mapToShippingAddressRequestBody(e)}processAdditionalAction(e,t){return"processAdditionalAction"in this._gateway?this._gateway.processAdditionalAction(e,t):Promise.reject(e)}signOut(e){return H(this,void 0,void 0,function*(){yield this._requestSender.get(`/remote-checkout/${e}/signout`)})}getCallbackTriggers(){return this._gateway.getCallbackTriggers()}setShouldRequestShipping(e){return this._gateway.setShouldRequestShipping(e)}handleShippingAddressChange(e){return H(this,void 0,void 0,function*(){return this._gateway.handleShippingAddressChange(e)})}handleShippingOptionChange(e){return H(this,void 0,void 0,function*(){yield this._gateway.handleShippingOptionChange(e)})}handleCoupons(e){return H(this,void 0,void 0,function*(){return this._gateway.handleCoupons(e)})}getTotalPrice(){return this._gateway.getTotalPrice()}_setExternalCheckout(e,t,n=!1,i){return H(this,void 0,void 0,function*(){const o="/checkout.php",r=Object.assign({action:"set_external_checkout",provider:e},yield this._gateway.mapToExternalCheckoutData(t));if(n)return new Promise(e=>{this._formPoster.postForm(i?`${i}/checkout`:o,Object.assign(Object.assign({},r),{card_information:JSON.stringify(r.card_information)}),e)});yield this._requestSender.post(o,{headers:Object.assign({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},q),body:r})})}isWebViewWithRestrictions(){return this._gateway.isWebViewWithRestrictions()}setIsWebViewExperimentOn(e){return this._gateway.setIsWebViewExperimentOn(e)}_prefetchGooglePaymentData(){const e=this._getPaymentDataRequest();e.transactionInfo=this._gateway.getTransactionInfo(),this._getPaymentsClient().prefetchPaymentData(e)}_determineReadinessToPay(){return H(this,void 0,void 0,function*(){try{const{result:e}=yield this._getPaymentsClient().isReadyToPay(this._getIsReadyToPayRequest());if(!1===e)throw new W("Google Pay is not supported by the current device and browser, please try another payment method.")}catch(e){if(e instanceof W)throw e;throw new W}})}_buildButtonPayloads(){this._baseCardPaymentMethod={type:"CARD",parameters:this._gateway.getCardParameters()}}_buildWidgetPayloads(){return H(this,void 0,void 0,function*(){const e=this._getBaseCardPaymentMethod();this._cardPaymentMethod=Object.assign(Object.assign({},e),{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:yield this._gateway.getPaymentGatewayParameters()}});const t=this._gateway.isWebViewWithRestrictions()?{shippingOptionRequired:!1}:{callbackIntents:this._gateway.getCallbackIntents(),offerInfo:this._gateway.getAppliedCoupons()};this._paymentDataRequest=Object.assign(Object.assign(Object.assign(Object.assign({},this._baseRequest),{allowedPaymentMethods:[this._cardPaymentMethod],transactionInfo:this._gateway.getTransactionInfo(),merchantInfo:this._gateway.getMerchantInfo()}),yield this._gateway.getRequiredData()),t),this._isReadyToPayRequest=Object.assign(Object.assign({},this._baseRequest),{allowedPaymentMethods:[e]})})}_getBaseCardPaymentMethod(){return this._getOrThrow(this._baseCardPaymentMethod)}_getPaymentDataRequest(){return this._getOrThrow(this._paymentDataRequest)}_getIsReadyToPayRequest(){return this._getOrThrow(this._isReadyToPayRequest)}_getPaymentsClient(){return this._getOrThrow(this._paymentsClient)}_getOrThrow(e){return k(e,()=>new _(v.PaymentNotInitialized))}}class J extends b{constructor(e){let t="Unable to submit payment for the order because the payload is invalid.";e&&(t=`${t} Make sure the following fields are provided correctly: ${e.join(", ")}.`),super(t),this.name="PaymentArgumentInvalidError"}}class K extends l{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}const Z={size:70,color:"#d9d9d9",backgroundColor:"#ffffff"},X={position:"fixed","background-color":"rgba(0, 0, 0, 0.4)","z-index":"1000"},Q="embedded-checkout-loading-indicator-rotation";class ${constructor(e){this.styles=Object.assign(Object.assign({},Z),e&&e.styles),this.containerStyles=Object.assign({},e&&e.containerStyles),this.defineAnimation(),this.container=this.buildContainer(),this.indicator=this.buildIndicator(),this.container.appendChild(this.indicator)}show(e){if(e){const t=document.getElementById(e);if(!t)throw new Error("Unable to attach the loading indicator because the parent ID is not valid.");t.appendChild(this.container)}this.container.style.visibility="visible",this.container.style.opacity="1"}hide(){const e=()=>{this.container.style.visibility="hidden",this.container.removeEventListener("transitionend",e)};this.container.addEventListener("transitionend",e),this.container.style.opacity="0"}buildContainer(){const e=document.createElement("div");return e.style.display="block",e.style.bottom="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.position="absolute",e.style.right="0",e.style.top="0",e.style.transition="all 250ms ease-out",e.style.opacity="0",this.setStyleAttribute(e,this.containerStyles),e}buildIndicator(){const e=document.createElement("div");return e.style.display="block",e.style.width=`${this.styles.size}px`,e.style.height=`${this.styles.size}px`,e.style.borderRadius=`${this.styles.size}px`,e.style.border="solid 1px",e.style.borderColor=`${this.styles.backgroundColor} ${this.styles.backgroundColor} ${this.styles.color} ${this.styles.color}`,e.style.margin="0 auto",e.style.position="absolute",e.style.left="0",e.style.right="0",e.style.top="50%",e.style.transform="translateY(-50%) rotate(0deg)",e.style.transformStyle="preserve-3d",e.style.animation=`${Q} 500ms infinite cubic-bezier(0.69, 0.31, 0.56, 0.83)`,e}setStyleAttribute(e,t){Object.keys(t).forEach(n=>{e.style.setProperty(n,t[n])})}defineAnimation(){var e;if(document.getElementById(Q))return;const t=document.createElement("style");t.id=Q,null===(e=document.head)||void 0===e||e.appendChild(t),t.sheet instanceof CSSStyleSheet&&t.sheet.insertRule(`\n @keyframes ${Q} {\n 0% { transform: translateY(-50%) rotate(0deg); }\n 100% { transform: translateY(-50%) rotate(360deg); }\n }\n `,0)}}function ee(e){return"object"==typeof e&&null!==e&&"statusCode"in e}var te;function ne(e){return Object.values(te).includes(e)}!function(e){e.ADYEN_V2="googlepayadyenv2",e.ADYEN_V3="googlepayadyenv3",e.AUTHORIZE_NET="googlepayauthorizenet",e.BNZ="googlepaybnz",e.BRAINTREE="googlepaybraintree",e.PAYPAL_COMMERCE="googlepaypaypalcommerce",e.BIGCOMMERCE_PAYMENTS="googlepay_bigcommerce_payments",e.CHECKOUT_COM="googlepaycheckoutcom",e.CYBERSOURCE_V2="googlepaycybersourcev2",e.ORBITAL="googlepayorbital",e.STRIPE="googlepaystripe",e.STRIPE_UPE="googlepaystripeupe",e.STRIPE_OCS="googlepaystripeocs",e.WORLDPAY_ACCESS="googlepayworldpayaccess",e.TD_ONLINE_MART="googlepaytdonlinemart"}(te||(te={}));var ie=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class oe{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t,this._isDeinitializationBlocked=!1,this._loadingIndicator=new $({containerStyles:X})}initialize(e){var t,n;return ie(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId)||!ne(e.methodId))throw new b('Unable to proceed because "methodId" is not a valid key.');this._methodId=e.methodId;const i=e[this._getMethodId()];if(!(null==i?void 0:i.walletButton))throw new b("Unable to proceed without valid options.");const{walletButton:o,loadingContainerId:r}=i,a=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}(i,["walletButton","loadingContainerId"]);this._loadingIndicatorContainer=r,yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodId());const s=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(this._getMethodId());this._googlePayPaymentProcessor.setIsWebViewExperimentOn(!!(null===(t=s.initializationData)||void 0===t?void 0:t.isWebViewExperimentOn)),yield this._googlePayPaymentProcessor.initialize(()=>s,this._getGooglePayClientOptions(null===(n=s.initializationData)||void 0===n?void 0:n.storeCountry)),this._addPaymentButton(o,a)})}execute({payment:e}){return ie(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId))throw new J(["payment"]);yield this._paymentIntegrationService.submitOrder();const t=yield this._googlePayPaymentProcessor.getNonce(e.methodId),n=yield this._googlePayPaymentProcessor.extraPaymentData();try{yield this._paymentIntegrationService.submitPayment(Object.assign(Object.assign({},e),{paymentData:Object.assign({nonce:t},n)}))}catch(t){yield this._googlePayPaymentProcessor.processAdditionalAction(t,e.methodId)}})}finalize(){return Promise.reject(new K)}deinitialize(){var e;return this._isDeinitializationBlocked||(this._clickListener&&(null===(e=this._paymentButton)||void 0===e||e.removeEventListener("click",this._clickListener)),this._paymentButton=void 0,this._clickListener=void 0,this._methodId=void 0),Promise.resolve()}_addPaymentButton(e,t){if(this._paymentButton)return;const n=document.getElementById(e);if(!n)throw new b("Unable to proceed without a walletButton.");this._paymentButton=n,this._clickListener=this._handleClick(t),this._paymentButton.addEventListener("click",this._clickListener)}_handleClick({onPaymentSelect:e,onError:t}){return n=>ie(this,void 0,void 0,function*(){n.preventDefault();try{this._googlePayPaymentProcessor.setShouldRequestShipping(!1),yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(e){let n=e;if(this._toggleLoadingIndicator(!1),ee(e)){if("CANCELED"===e.statusCode)throw new w;n=new W(JSON.stringify(e))}throw null==t||t(new W("An error occurred while requesting your Google Pay payment details.")),n}finally{this._toggleBlockDeinitialization(!1)}null==e||e()})}_interactWithPaymentSheet(){return ie(this,void 0,void 0,function*(){const e=yield this._googlePayPaymentProcessor.showPaymentSheet(),t=this._paymentIntegrationService.getState(),{features:n}=t.getStoreConfigOrThrow().checkoutSettings,i=T(n,"PI-5031.google_pay_dont_override_address");this._toggleBlockDeinitialization(!0),this._toggleLoadingIndicator(!0);const o=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(e);o&&!i&&(yield this._paymentIntegrationService.updateBillingAddress(o)),yield this._googlePayPaymentProcessor.setExternalCheckoutXhr(this._getMethodId(),e),yield this._paymentIntegrationService.loadCheckout(),yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodId()),this._toggleLoadingIndicator(!1),this._toggleBlockDeinitialization(!1)})}_getMethodId(){return k(this._methodId,()=>new _(v.PaymentNotInitialized))}_getIsSignedInOrThrow(){return ie(this,void 0,void 0,function*(){try{return!!(yield this._googlePayPaymentProcessor.getNonce(this._getMethodId()))}catch(e){if(e instanceof m&&e.subtype===h.MissingPaymentToken)return!1;throw e}})}_handleOfferTrigger(e){return ie(this,void 0,void 0,function*(){let t=!1,n="Sign in to Google Pay first to apply or remove promo codes.";try{t=yield this._getIsSignedInOrThrow()}catch(e){e instanceof m&&(n=e.message)}if(t){const{newOfferInfo:t,error:n}=yield this._googlePayPaymentProcessor.handleCoupons(e);return{newOfferInfo:t,error:n}}return{error:{reason:G.OFFER_INVALID,message:n,intent:B.OFFER}}})}_getGooglePayClientOptions(e){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:({callbackTrigger:t,offerData:n})=>ie(this,void 0,void 0,function*(){if(t!==B.INITIALIZE&&t!==B.OFFER)return;const{offerChangeTriggers:i}=this._googlePayPaymentProcessor.getCallbackTriggers(),{newOfferInfo:o,error:r}=i.includes(t)?yield this._handleOfferTrigger(n):{},a=r;yield this._paymentIntegrationService.loadCheckout();const{code:s}=this._paymentIntegrationService.getState().getCartOrThrow().currency,c=this._googlePayPaymentProcessor.getTotalPrice();return Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},e&&{countryCode:e}),{currencyCode:s,totalPriceStatus:R.FINAL,totalPrice:c})},o&&{newOfferInfo:o}),a&&{error:a})})}}}_toggleBlockDeinitialization(e){this._isDeinitializationBlocked=e}_toggleLoadingIndicator(e){e&&this._loadingIndicatorContainer?this._loadingIndicator.show(this._loadingIndicatorContainer):this._loadingIndicator.hide()}}class re{constructor(e){this._scriptLoader=e,this._window=window}getGooglePaymentsClient(e=!1,t){return n=this,i=void 0,r=function*(){if(yield this._scriptLoader.loadScript("https://pay.google.com/gp/p/js/pay.js"),!this._window.google)throw new u;return void 0===this._paymentsClient&&(this._paymentsClient=new this._window.google.payments.api.PaymentsClient(Object.assign({environment:e?"TEST":"PRODUCTION"},null!=t?t:{}))),this._paymentsClient},new((o=void 0)||(o=Promise))(function(e,t){function a(e){try{c(r.next(e))}catch(e){t(e)}}function s(e){try{c(r.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(a,s)}c((r=r.apply(n,i||[])).next())});var n,i,o,r}}function ae(){return new re(n())}const se=g(o=>new oe(o,new Y(ae(),new U(o,new y(n(),i())),t(),e())),[{id:"googlepayadyenv2"}]);class ce{constructor(e,t,n=window){this._scriptLoader=e,this._stylesheetLoader=t,this._window=n}load(e){var t,n,i,o,r,a;return i=this,o=void 0,a=function*(){if(yield Promise.all([this._stylesheetLoader.loadStylesheet(`https://checkoutshopper-${null!==(t=e.environment)&&void 0!==t?t:""}.adyen.com/checkoutshopper/sdk/5.71.1/adyen.css`,{prepend:!1,attributes:{integrity:"sha384-5MvB4RnzvviA3VBT4KYABZ4HXNZG5LRqREEgd41xt/pf/QvKmsj2O9GuNuywRXx9",crossorigin:"anonymous"}}),this._scriptLoader.loadScript(`https://checkoutshopper-${null!==(n=e.environment)&&void 0!==n?n:""}.adyen.com/checkoutshopper/sdk/5.71.1/adyen.js`,{async:!0,attributes:{integrity:"sha384-yvY2yFNR4WqIjPqP9MzjI+gJimmaJnAvj4rLHKvgJbgFD5fMuf8zIJrFJOW8Lhhf",crossorigin:"anonymous"}})]),!this._window.AdyenCheckout)throw new u;return yield this._window.AdyenCheckout(e)},new((r=void 0)||(r=Promise))(function(e,t){function n(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof r?i:new r(function(e){e(i)})).then(n,s)}c((a=a.apply(i,o||[])).next())})}}var de=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class le extends F{constructor(e,t){super("adyen",e),this._scriptLoader=t,this._service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return de(this,void 0,void 0,function*(){yield i.initialize.call(this,e,t,n);const o=i.getPaymentMethod.call(this),r=this._service.getState().getStoreConfig();if(!r)throw new m(h.MissingCheckoutConfig);return this._adyenClient=yield this._scriptLoader.load({environment:o.config.testMode?"test":"live",locale:r.storeProfile.storeLanguage}),Promise.resolve()})}processAdditionalAction(e){return de(this,void 0,void 0,function*(){if(!P(e)||!p(e.body))throw e;const t=yield this._handleAction(e.body.provider_data);try{return yield this._service.submitPayment(t)}catch(e){return this.processAdditionalAction(e)}})}getNonce(e){const t=Object.create(null,{getNonce:{get:()=>super.getNonce},getPaymentMethod:{get:()=>super.getPaymentMethod}});return de(this,void 0,void 0,function*(){const n=yield t.getNonce.call(this,e),i=t.getPaymentMethod.call(this);return JSON.stringify({type:i.method,googlePayToken:n,browser_info:f()})})}_handleAction(e){return new Promise((t,n)=>{const i=JSON.parse(e.action);this._getAdyenClient().createFromAction(i,{onAdditionalDetails:e=>{const n={methodId:i.paymentMethodType,paymentData:{nonce:JSON.stringify(e.data)}};t(n)},size:"05",onError:e=>n(e)}).mount("body"),n(new w)})}_getAdyenClient(){if(!this._adyenClient)throw new _(v.PaymentNotInitialized);return this._adyenClient}}const ue=g(o=>new oe(o,new Y(ae(),new le(o,new ce(n(),i())),t(),e())),[{id:"googlepayadyenv3"}]);class he extends F{constructor(e){super("authorizenet",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,r=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((o=void 0)||(o=Promise))(function(e,t){function a(e){try{c(r.next(e))}catch(e){t(e)}}function s(e){try{c(r.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(a,s)}c((r=r.apply(n,i||[])).next())});var n,i,o,r}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return function(e){if(!function(e){return"paymentGatewayId"in e}(e))throw new m(h.MissingPaymentMethod)}(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.paymentGatewayId}}}const ye=g(n=>new oe(n,new Y(ae(),new he(n),t(),e())),[{id:"googlepayauthorizenet"}]);var ge;!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(ge||(ge={}));const pe=ge;function me(e){if(!function(e){return"checkoutcomkey"in e}(e))throw new m(h.MissingPaymentMethod)}var fe=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Pe extends F{constructor(e,t){super("checkoutltd",e),this._requestSender=t}processAdditionalAction(e){return new Promise((t,n)=>{if(P(e)&&function(e){var t;if("object"!=typeof e||null===e)return!1;const n=e;return"string"==typeof(null===(t=n.three_ds_result)||void 0===t?void 0:t.acs_url)&&"string"==typeof n.three_ds_result.code}(e.body)&&"three_d_secure_required"===e.body.three_ds_result.code)return window.location.assign(e.body.three_ds_result.acs_url);n(e)})}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return fe(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new b("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"protocolVersion"in e&&"signature"in e&&"signedMessage"in e}(e))throw new m(h.MissingPaymentToken)}(i),n.nonce=yield this._tokenize(i),n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return me(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.checkoutcomkey}}_tokenize(e){return fe(this,void 0,void 0,function*(){const t=this.getPaymentMethod().config.testMode?"https://api.sandbox.checkout.com/tokens":"https://api.checkout.com/tokens",n=this.getGooglePayInitializationData();me(n);const{body:i}=yield this._requestSender.post(t,{credentials:!1,body:{type:"googlepay",token_data:e},headers:{Authorization:n.checkoutcomkey,"Content-Type":pe.Json,"X-XSRF-TOKEN":null}});return i.token})}}const we=g(n=>{const i=t();return new oe(n,new Y(ae(),new Pe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]);class ve extends F{constructor(e){super("cybersource",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,r=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((o=void 0)||(o=Promise))(function(e,t){function a(e){try{c(r.next(e))}catch(e){t(e)}}function s(e){try{c(r.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(a,s)}c((r=r.apply(n,i||[])).next())});var n,i,o,r}}const _e=g(n=>new oe(n,new Y(ae(),new ve(n),t(),e())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]);class be extends F{constructor(e){super("chase",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,r=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((o=void 0)||(o=Promise))(function(e,t){function a(e){try{c(r.next(e))}catch(e){t(e)}}function s(e){try{c(r.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(a,s)}c((r=r.apply(n,i||[])).next())});var n,i,o,r}}const Ce=g(n=>new oe(n,new Y(ae(),new be(n),t(),e())),[{id:"googlepayorbital"}]);var Se,Ie,Oe,ke,Ae,Te,Ee,Me,De,Ne,Re,xe;!function(e){e.SHIPPING="shipping",e.BILLING="billing"}(Se||(Se={})),function(e){e.SPLIT="split",e.FULL="full",e.ORGANIZATION="organization"}(Ie||(Ie={})),function(e){e.Open="open",e.Expired="expired",e.Complete="complete"}(Oe||(Oe={})),function(e){e.Paid="paid",e.UnPaid="unpaid",e.NoPaymentRequired="no_payment_required"}(ke||(ke={})),function(e){e.SUCCESS="success",e.ERROR="error"}(Ae||(Ae={})),function(e){e.CreditCard="card",e.Link="link",e.EPS="eps",e.GRABPAY="grabpay",e.BANCONTACT="bancontact",e.IDEAL="ideal",e.ALIPAY="alipay",e.KLARNA="klarna",e.OCS="optimized_checkout",e.CHECKOUT_SESSION="checkout_session"}(Te||(Te={})),function(e){e.NEVER="never",e.AUTO="auto",e.ALWAYS="always",e.PAYMENT="payment",e.IF_REQUIRED="if_required"}(Ee||(Ee={})),function(e){e.V3="v3",e.ACACIA="acacia",e.BASIL="basil",e.CLOVER="clover"}(Me||(Me={})),function(e){e.PAYMENT="payment",e.AUTHENTICATION="linkAuthentication",e.SHIPPING="address",e.EXPRESS_CHECKOUT="expressCheckout"}(De||(De={})),function(e){e.REQUIRES_PAYMENT_METHOD="requires_payment_method",e.REQUIRES_CONFIRMATION="requires_confirmation",e.REQUIRES_ACTION="requires_action",e.PROCESSING="processing",e.SUCCEEDED="succeeded",e.CANCELED="canceled"}(Ne||(Ne={})),function(e){e.CLICK="click",e.CHANGE="change",e.READY="ready",e.SHIPPING_ADDRESS_CHANGE="shippingaddresschange",e.SHIPPING_RATE_CHANGE="shippingratechange",e.CONFIRM="confirm",e.CANCEL="cancel",e.LOADER_START="loaderstart"}(Re||(Re={})),function(e){e.ON_SESSION="on_session",e.OFF_SESSION="off_session"}(xe||(xe={}));var ze=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Ge{constructor(e,t=window){this.scriptLoader=e,this.stripeWindow=t}getStripeClient(e,t,n,i,o){return ze(this,void 0,void 0,function*(){if(this.stripeWindow.bcStripeClient)return this.stripeWindow.bcStripeClient;const r=yield this.load(n),{stripePublishableKey:a,stripeConnectedAccount:s}=e,c=r(a,Object.assign(Object.assign(Object.assign(Object.assign({},s?{stripeAccount:s}:{}),t?{locale:t}:{}),i?{betas:i}:{}),o?{apiVersion:o}:{}));return Object.assign(this.stripeWindow,{bcStripeClient:c}),c})}getElements(e,t){return ze(this,void 0,void 0,function*(){let n=this.stripeWindow.bcStripeElements;return n?yield this.updateStripeElements(t):(n=e.elements(t),Object.assign(this.stripeWindow,{bcStripeElements:n})),n})}updateStripeElements(e){return ze(this,void 0,void 0,function*(){const t=this.stripeWindow.bcStripeElements;t&&(t.update(e),yield t.fetchUpdates())})}getStripeCheckout(e,t){return ze(this,void 0,void 0,function*(){let n=yield this.getStoredStripeCheckout(t);return n||(n=yield e.initCheckout(t),Object.assign(this.stripeWindow,{bcStripeCheckout:n})),n})}load(e){return ze(this,void 0,void 0,function*(){if(!this.stripeWindow.Stripe&&(yield this.scriptLoader.loadScript(this.getScriptUrl(e)),!this.stripeWindow.Stripe))throw new u;return this.stripeWindow.Stripe})}getScriptUrl(e){return e&&e!==Me.V3?`https://js.stripe.com/${e}/stripe.js`:"https://js.stripe.com/v3/"}getStoredStripeCheckout(e){return ze(this,void 0,void 0,function*(){const t=this.stripeWindow.bcStripeCheckout;if(t)try{const{actions:n,error:i}=yield t.loadActions();if(i||!n)return void this.logErrorToConsole(i);const o=yield n.getSession(),r=e.clientSecret.split("_secret_")[0];if((null==o?void 0:o.id)===r)return t}catch(e){return void this.logErrorToConsole(e)}})}logErrorToConsole(e){e?console.error(e):console.error("No stripe checkout actions available on loadActions().")}}const Be={body:{},headers:{},status:0};class je extends l{constructor(e,{message:t,errors:n}={}){const{body:i,headers:o,status:r}=e||Be;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=i,this.headers=o,this.status=r,this.errors=n||[]}}const Le=["payment_element_beta_2","alipay_pm_beta_1","link_default_integration_beta_1","shipping_address_element_beta_1","address_element_beta_1"];function Fe(e){if(!function(e){return"stripeConnectedAccount"in e&&"stripePublishableKey"in e&&"stripeVersion"in e}(e))throw new m(h.MissingPaymentMethod)}var Ve=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Ue extends F{constructor(e,t){super("stripe",e),this.paymentIntegrationService=e,this.scriptLoader=t}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return Ve(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new b("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"id"in e}(e))throw new m(h.MissingPaymentToken)}(i),n.nonce=i.id,n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();Fe(e);const{stripeVersion:t,stripePublishableKey:n,stripeConnectedAccount:i}=e;return{gateway:this.getGatewayIdentifier(),"stripe:version":t,"stripe:publishableKey":`${n}/${i}`}}processAdditionalAction(e,t){var n;return Ve(this,void 0,void 0,function*(){if(!t)throw new J(["payment"]);if(!P(e)||("object"!=typeof(i=e.body)||null===i||!("three_ds_result"in i)||!("errors"in i)))throw e;var i;if(d(e.body.errors,{code:"three_d_secure_required"})){const i=this.getGooglePayInitializationData();Fe(i),this.stripeUPEClient=yield this.loadStripeJs(i,t);const o=e.body.three_ds_result.token;let r,a=!1;try{r=yield this.stripeUPEClient.confirmCardPayment(o)}catch(e){try{r=yield this.stripeUPEClient.retrievePaymentIntent(o)}catch(e){a=!0}}if(null==r?void 0:r.error){if(this._throwDisplayableStripeError(r.error),this._isCancellationError(r.error))throw new w;throw new W}if(!(null==r?void 0:r.paymentIntent)&&!a)throw new je;return this.paymentIntegrationService.submitPayment({methodId:t,paymentData:{nonce:(null===(n=null==r?void 0:r.paymentIntent)||void 0===n?void 0:n.id)||o}})}throw e})}loadStripeJs(e,t){return Ve(this,void 0,void 0,function*(){if(this.stripeUPEClient)return this.stripeUPEClient;const n=this.paymentIntegrationService.getState().getCartLocale();return"googlepaystripeocs"===t&&e.useNewStripeJsVersion?this.scriptLoader.getStripeClient(e,n,Me.CLOVER):this.scriptLoader.getStripeClient(e,n,Me.V3,Le,"2020-03-02;alipay_beta=v1;link_beta=v1")})}_isCancellationError(e){var t,n;return e&&-1!==(null===(n=null===(t=e.payment_intent.last_payment_error)||void 0===t?void 0:t.message)||void 0===n?void 0:n.indexOf("canceled"))}_throwDisplayableStripeError(e){if(r(["card_error","invalid_request_error","validation_error"],e.type))throw new Error(e.message)}}const qe=g(i=>new oe(i,new Y(ae(),new Ue(i,new Ge(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]);class We extends F{constructor(e){super("worldpay",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,r=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((o=void 0)||(o=Promise))(function(e,t){function a(e){try{c(r.next(e))}catch(e){t(e)}}function s(e){try{c(r.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(a,s)}c((r=r.apply(n,i||[])).next())});var n,i,o,r}}const He=g(n=>new oe(n,new Y(ae(),new We(n),t(),e())),[{id:"googlepayworldpayaccess"}]),Ye="3.128.0",Je="3.123.2",Ke="3.106.0";class Ze{constructor(e){this.paymentIntegrationService=e,this.braintreeWindow=window}getSDKVersion(){const e=this.paymentIntegrationService.getState().getStoreConfig(),t=(null==e?void 0:e.checkoutSettings.features)||{};return this.getPreloadedSDKVersion()||(T(t,"PAYPAL-5809.braintree_hosted_fields_fix_version")?Ye:T(t,"PAYPAL-5636.update_braintree_sdk_version")?Je:Ke)}getPreloadedSDKVersion(){const e=this.braintreeWindow.braintree;if(e){const t=o(Object.values(e),e=>!!e.VERSION);return null==t?void 0:t.VERSION}}}class Xe extends l{constructor(e){super(e||"Unsupported browser error"),this.name="UnsupportedBrowserError",this.type="unsupported_browser"}}var Qe,$e,et,tt,nt,it,ot;!function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(Qe||(Qe={})),function(e){e.Completed="COMPLETED",e.Pending="PENDING",e.Failed="FAILED"}($e||($e={})),function(e){e.TRUSTLY="trustly"}(et||(et={})),function(e){e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="cancelled",e.UNRECOGNIZED="unrecognized"}(tt||(tt={})),function(e){e.Customer="CUSTOMER",e.Merchant="MERCHANT",e.Network="NETWORK",e.Internal="INTERNAL",e.Unknown="UNKNOWN"}(nt||(nt={})),function(e){e.KountNotEnabled="DATA_COLLECTOR_KOUNT_NOT_ENABLED"}(it||(it={})),function(e){e.Visa="visa",e.Mastercard="mastercard",e.AmericanExpress="american-express",e.DinersClub="diners-club",e.Discover="discover",e.Jcb="jcb",e.UnionPay="union-pay",e.Maestro="maestro",e.Elo="elo",e.Mir="mir",e.Hiper="hiper",e.Hipercard="hipercard"}(ot||(ot={}));var rt,at,st,ct=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class dt{constructor(e){this.braintreeScriptLoader=e}initialize(e){this.setClientToken(e)}deinitialize(){return ct(this,void 0,void 0,function*(){yield this.teardownModule(this.dataCollector),this.dataCollector=void 0})}getClient(){return ct(this,void 0,void 0,function*(){if(!this.client){const e=this.getClientTokenOrThrow(),t=yield this.braintreeScriptLoader.loadClient();this.client=yield t.create({authorization:e})}return this.client})}getDataCollectorOrThrow(e){return ct(this,void 0,void 0,function*(){const t={deviceData:void 0,teardown:()=>Promise.resolve()};if(!this.dataCollector)try{const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadDataCollector(),i=Object.assign({client:t,kount:!0},e);this.dataCollector=yield n.create(i)}catch(e){if(function(e){return Boolean("object"==typeof e&&null!==e&&("type"in e||"message"in e||"code"in e))}(e)&&e.code===it.KountNotEnabled)return t;throw e}return this.dataCollector})}getBraintreeGooglePayment(){return ct(this,void 0,void 0,function*(){if(!this.googlePayment){const[e,t]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadGooglePayment()]);this.googlePayment=yield t.create({client:e})}return this.googlePayment})}getBraintreeThreeDS(){return ct(this,void 0,void 0,function*(){if(!this.threeDS){const[e,t]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()]);this.threeDS=yield t.create({client:e,version:2})}return this.threeDS})}getBraintreeLocalPayment(e){return ct(this,void 0,void 0,function*(){if(!this.braintreeLocalPayment){const[t,n]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadLocalPayment()]);this.braintreeLocalPayment=yield new Promise((i,o)=>{n.create({client:t,merchantAccountId:e},(e,t)=>{e&&o(e),i(t)})})}return this.braintreeLocalPayment})}getUsBankAccount(){return ct(this,void 0,void 0,function*(){if(!this.usBankAccount){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadUsBankAccount();this.usBankAccount=yield t.create({client:e})}return this.usBankAccount})}getBraintreeVisaCheckout(){return this.visaCheckout||(this.visaCheckout=Promise.all([this.getClient(),this.braintreeScriptLoader.loadVisaCheckout()]).then(([e,t])=>t.create({client:e}))),this.visaCheckout}getVisaCheckoutSdk(e){return ct(this,void 0,void 0,function*(){return this.visaCheckoutSDK||(this.visaCheckoutSDK=yield this.braintreeScriptLoader.loadVisaCheckoutSdk(e)),this.visaCheckoutSDK})}getVenmoCheckoutOrThrow(){return ct(this,void 0,void 0,function*(){if(!this.braintreeVenmo){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadVenmoCheckout(),n={client:e,allowDesktop:!0,paymentMethodUsage:"multi_use"},i=yield t.create(n);if(!i.isBrowserSupported())throw new Xe;this.braintreeVenmo=i}return this.braintreeVenmo})}setClientToken(e){this.clientToken=e}getClientTokenOrThrow(){if(!this.clientToken)throw new _(v.PaymentNotInitialized);return this.clientToken}teardownModule(e){return e?e.teardown():Promise.resolve()}}!function(e){e.Sandbox="sandbox",e.Production="production"}(rt||(rt={})),function(e){e.Client="client",e.DataCollector="dataCollector",e.Fastlane="fastlane",e.GooglePayment="googlePayment",e.HostedFields="hostedFields",e.LocalPayment="localPayment",e.Paypal="paypal",e.PaypalCheckout="paypalCheckout",e.ThreeDSecure="threeDSecure",e.UsBankAccount="usBankAccount",e.Venmo="venmo",e.VisaCheckout="visaCheckout"}(at||(at={})),function(e){e.CardCode="cardCode",e.CardCodeVerification="cardCodeVerification",e.CardExpiry="cardExpiry",e.CardName="cardName",e.CardNumber="cardNumber",e.CardNumberVerification="cardNumberVerification"}(st||(st={}));const lt={[Ke]:{[at.Client]:"sha384-26BXDNnJI23JYRyFBj4xe4sVNrUSSiSSu11kxVXNM/vEPONm4LuL00w6ZaTgQewt",[at.PaypalCheckout]:"sha384-B+vzbZwnQtzWBthpkT4TXKUibO65tyeK7eCxSvpblgprTep2+IAXB2Cxxjrn710O",[at.Paypal]:"sha384-uyAGL1/3+XJAHnGoNy4eCoXdzJ4f7Ilzp+6w9PNnEjs6DCCz9WMyJjMN1gzc78U+",[at.LocalPayment]:"sha384-LIvOEMkIVEwVuYBdVOQc1AC5YbGGlwyfUheS0ACK218D2STuVYQlZ4FyEPowAEfT",[at.DataCollector]:"sha384-1bo9JDz+Kscthc085cCKWur8CLwUoBpoNyxsDi7932mCl0zFq3A5mv+FQLw9GHpV",[at.UsBankAccount]:"sha384-xmHBVaU+w74V+OebD3AaPONFxHUGMf+QRs8G/JxVPXNNP7MDa2jL0ICWHIe2tTfJ",[at.GooglePayment]:"sha384-WKDJl8mqoP82qZpMGH6AbZxnvXnSW8ILV4M64CyMLiugGMwu7LyP89wjCkHqsiBe",[at.ThreeDSecure]:"sha384-VQUlpGHzsGvs5XeiGFip7EXRsvoHWEXDVmgCacfbyieZI9mdBOqq3NSoyo28OCOB",[at.VisaCheckout]:"sha384-yx7mADfzTN0T43Q6rlH49LIg1EJ0iUZgBp/EczX9LXsUGkySgxrD+nWHQRBkyfoT",[at.Venmo]:"sha384-QX4rPjoj1ZDhuG0aSyKs56lEKDqTMTcjYxUHY1SzO5VZDsqIE2NTkqot7KNSCyov",[at.HostedFields]:"sha384-VvYBACfSu0Cr/J32uKmxG7AXcNOJE1AzIIL3kbikyS7YKp5fz5Is+NzNP/lyauNy",[at.Fastlane]:"sha384-9oGsZMRZwpGtDEDYa/dFt76dECqj1xAni9gIKgc3KfMIiRnR73nEeeUDLiBzxhFa"},[Je]:{[at.Client]:"sha384-o+nbQGcwNNxIBeXeu3+XmbSq+Cg8R3EN3N0l5hXCgMMU2RGY0t1z0LroSEIAbfAO",[at.PaypalCheckout]:"sha384-WrfbWPBS4mH86GAoycPSgiH8hQ8KH7A67C93Hjhunv/xhNk2YpBn3wbFA4Fhg9U/",[at.Paypal]:"sha384-VF389nvvrRUgDsTXMxTYORDtVegB9IQa3Cxr//DyJnLYnz8/X8VCzEvck2c+Megt",[at.LocalPayment]:"sha384-tZKx2rEQbfmZpoPSY5VPmJEhaq4X75dLvwHMs3VE9U+C8lPyw+hWTIL1+GPvWCIH",[at.DataCollector]:"sha384-E6k3wOpP7syCDDwaRDLF06942Y00NkbwJvWi2OQXwwKzGwG5fd3E7RFUvCCecfvO",[at.UsBankAccount]:"sha384-258FON8LZGG0W9Qaz4Jij83pZHu30YnKjJA7gNulLBh6CclkucgF+tHDQuYFRYfW",[at.GooglePayment]:"sha384-taJ2p/0+n0VH328POAoBiuEbL3tnHUTE9S42hK1V+Txs3X+QYjZOyKW35JgHRFfO",[at.ThreeDSecure]:"sha384-+NSZH4Zj3sO5bdWvPKhU5N16QDxeueTVTnUVeleeESkhLSaz4Ob1hh/5myecc9Ym",[at.VisaCheckout]:"sha384-66DiBjghxk1OmBj8aksN8gbQ+CwoQcx1vPfiXUN08g1iQVM+BwewF0p7toM3i7SS",[at.Venmo]:"sha384-B5UwY42kE4RoLoWbQ7YpqosUlUad2/DlGWiw0HhoZbSPk30CQAaSA10ohyLDTkDU",[at.HostedFields]:"sha384-Aw9EesSaUeWxe36PqEHiOyOyOq8M6CIb1gw7/yHNVPRzGtFXXcd2OQ8qXrIlOj2P",[at.Fastlane]:"sha384-rhBL1hpZ71JqG+2TsT0Dih47mbjx8cjJCpeZjk9tw3df1gFMKfCTmMyZunhr7H4Y"},[Ye]:{[at.Client]:"sha384-0WNxksIpRP+fYZiIdr12g6DBUQfLDzYCQJZtR/C8KkcwSGhPHfcFp3tTaGcMyFTq",[at.PaypalCheckout]:"sha384-lWM1jk4BOxoDNV6Kop7tVNvQgINlmEVz0c/OwM+HNHK3QC8xqwd54Ovrt2QRDTjh",[at.Paypal]:"sha384-fXUmVxC2EMZBDXZ7eTHSTL/LFBrHej/MSXT/vTBXvra4lzgLNGvREAp+x0GYObuH",[at.LocalPayment]:"sha384-pha1xGuGSkmZH5x9aqHvRaO4xLea7rmQ/79PFj9zxNzxuFcOWZg7gOP7FibygOEC",[at.DataCollector]:"sha384-Q6PI2F9eekWbAxhroybl+aEcvqhdowN/EQlGwBUyJOzPFn9982u9xl6SU6XfGKzc",[at.UsBankAccount]:"sha384-W3RLQSKJL1tQ3+Y7mP6tmkamtZ8bV4Yw/XxL9Jj5JtXHraD8loMF8hAIG5m2zK7F",[at.GooglePayment]:"sha384-TITQMsFWA3elDNGP2mWz2oKBo4qjt+TlqzovcaPoeBiAh/wPBi6nae50ADdgU1/i",[at.ThreeDSecure]:"sha384-YiycYN89ZlL/Evcaq4y1ajW1mhd7JYfZBDuOwHtIn4/Jnm20GL+/XCM+zYAwWD8D",[at.VisaCheckout]:"sha384-/OdaTv9qrkKzjObtUe6yzfDhHozFW/+uXlrSl736sOZRJpjGQETvpYXqMFFg69xv",[at.Venmo]:"sha384-dA+ojdW9vbJS4JavcXyOs9d5uZHJg5dNtYupoPSH2zsXIiYDVS5amLb/u8qmQ6oz",[at.HostedFields]:"sha384-31ZkS58+iaWsW06ftW52zzVZFp43WPd7pNYRiddYynSNg6Oh7WGbSFGorAUH6T1z",[at.Fastlane]:"sha384-jlbrwNvL3HvLAUCtLSmrnQ2GH1udCUrRS/bVmReAS5fuIVvcW8Pko/Gkg82tlgtr"}};var ut=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class ht{constructor(e,t,n){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSDKVersionManager=n}loadClient(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.Client,"client.min.js")})}loadFastlane(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.Fastlane,"fastlane.min.js")})}loadPaypalCheckout(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.PaypalCheckout,"paypal-checkout.min.js")})}loadPaypal(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.Paypal,"paypal.min.js")})}loadLocalPayment(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.LocalPayment,"local-payment.min.js")})}loadDataCollector(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.DataCollector,"data-collector.min.js")})}loadUsBankAccount(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.UsBankAccount,"us-bank-account.min.js")})}loadGooglePayment(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.GooglePayment,"google-payment.min.js")})}load3DS(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.ThreeDSecure,"three-d-secure.min.js")})}loadVisaCheckout(){return this.loadBraintreeModuleOrThrow(at.VisaCheckout,"visa-checkout.min.js")}loadVenmoCheckout(){return this.loadBraintreeModuleOrThrow(at.Venmo,"venmo.min.js")}loadHostedFields(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.HostedFields,"hosted-fields.min.js")})}loadVisaCheckoutSdk(e){return ut(this,void 0,void 0,function*(){if(this.braintreeHostWindow.V)return this.braintreeHostWindow.V;const t=e?"sha384-0eu1s1GtqzXlL9DtLgmwzC5WWlEH/ADRM0n38cVQkvtT+W/gey96rcb1LwuUOPDm":"sha384-1f1csvP3ZFxg4dILH1GaY4LHlZ0oX7Rk83rxmLlwbnIi4TM0NYzXoev1VoEiVDS6";return this.scriptLoader.loadScript(`//${e?"sandbox-":""}assets.secure.checkout.visa.com/checkout-widget/resources/js/integration/v1/sdk.js`,{async:!0,attributes:{integrity:t,crossorigin:"anonymous"}}).then(()=>{if(!this.braintreeHostWindow.V)throw new u;return this.braintreeHostWindow.V})})}loadBraintreeModuleOrThrow(e,t){return ut(this,void 0,void 0,function*(){let n=this.getBraintreeModule(e);if(n)return n;const i=this.braintreeSDKVersionManager.getSDKVersion(),o=`//js.braintreegateway.com/web/${i}/js/${t}`,r=i in lt?this.getIntegrityValuesByModuleName(e,i):void 0;if(yield this.scriptLoader.loadScript(o,r?{async:!0,attributes:{integrity:r,crossorigin:"anonymous"}}:void 0),n=this.getBraintreeModule(e),!n)throw new u;return n})}getBraintreeModule(e){var t;return null===(t=this.braintreeHostWindow.braintree)||void 0===t?void 0:t[e]}getIntegrityValuesByModuleName(e,t){const n=lt[t][e];if(!n)throw new Error("Unexpected fileName value");return n}}class yt{constructor(e){const t=new Promise((e,t)=>{this.cancel=t});this.promise=Promise.race([e,t])}}var gt=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class pt extends F{constructor(e,t){super("braintree",e),this._braintreeSdk=t,this._methodId=te.BRAINTREE,this._service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return gt(this,void 0,void 0,function*(){yield i.initialize.call(this,e,t,n);let o=i.getPaymentMethod.call(this);if(o.clientToken||(o=(yield this._service.loadPaymentMethod(this._methodId)).getPaymentMethodOrThrow(this._methodId)),!o.clientToken||!o.initializationData)throw new m(h.MissingPaymentMethod);return this._braintreeSdk.initialize(o.clientToken),this._braintreeGooglePayment=yield this._braintreeSdk.getBraintreeGooglePayment(),Promise.resolve()})}getNonce(e){const t=Object.create(null,{getNonce:{get:()=>super.getNonce},getPaymentMethod:{get:()=>super.getPaymentMethod}});var n;return gt(this,void 0,void 0,function*(){const i=yield t.getNonce.call(this,e),{clientToken:o,initializationData:r}=t.getPaymentMethod.call(this);if(!o||!r||!(null===(n=r.card_information)||void 0===n?void 0:n.bin))throw new m(h.MissingPaymentMethod);const{isThreeDSecureEnabled:a,card_information:{bin:s,isNetworkTokenized:c}}=r;if(a&&!c){const e=yield this._braintreeSdk.getBraintreeThreeDS(),{orderAmount:t}=this._service.getState().getOrderOrThrow();return(yield this._braintreePresent3DSChallenge(e,t,i,s)).nonce}return i})}extraPaymentData(){return gt(this,void 0,void 0,function*(){return{deviceSessionId:yield this._getBraintreeDeviceData()}})}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return gt(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new b("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"androidPayCards"in e}(e))throw new m(h.MissingPaymentToken)}(i),n.nonce=i.androidPayCards[0].nonce,n.card_information.bin=i.androidPayCards[0].details.bin,n.card_information.isNetworkTokenized=i.androidPayCards[0].details.isNetworkTokenized,n})}getCardParameters(){return super.getCardParameters()}getPaymentGatewayParameters(){const e=Object.create(null,{getMerchantInfo:{get:()=>super.getMerchantInfo},getTransactionInfo:{get:()=>super.getTransactionInfo},getRequiredData:{get:()=>super.getRequiredData}});return gt(this,void 0,void 0,function*(){return this.getBraintreeGooglePayment().createPaymentDataRequest(Object.assign({merchantInfo:e.getMerchantInfo.call(this),transactionInfo:e.getTransactionInfo.call(this),cardRequirements:{billingAddressRequired:!0,billingAddressFormat:"FULL"}},yield e.getRequiredData.call(this))).paymentMethodTokenizationParameters.parameters})}getBraintreeGooglePayment(){if(!this._braintreeGooglePayment)throw new m(h.MissingPaymentMethod);return this._braintreeGooglePayment}_getBraintreeDeviceData(){return gt(this,void 0,void 0,function*(){const{deviceData:e}=yield this._braintreeSdk.getDataCollectorOrThrow();return e})}_braintreePresent3DSChallenge(e,t,n,i){return new yt(e.verifyCard({amount:t,bin:i,nonce:n,onLookupComplete:(e,t)=>{t()}})).promise}}const mt=g(i=>{const o=t(),r=window,a=new Ze(i),s=new dt(new ht(n(),r,a));return new oe(i,new Y(ae(),new pt(i,s),o,e()))},[{id:"googlepaybraintree"}]);var ft=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Pt{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n){return ft(this,void 0,void 0,function*(){if(!this.window.paypalFastlaneSdk){const i=this.getPayPalFastlaneSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.paypalFastlaneSdk)throw new u}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i){return ft(this,void 0,void 0,function*(){if(!this.window.paypalGooglePay||i){const i=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.paypalGooglePay)throw new u;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t){return ft(this,void 0,void 0,function*(){if(!this.window.paypalApms){const n=this.getPayPalApmSdkConfiguration(e,t);if(yield this.loadPayPalSdk(n),!this.window.paypalApms)throw new u}return this.window.paypalApms})}getPayPalMessages(e,t){return ft(this,void 0,void 0,function*(){if(!this.window.paypalMessages){const n=this.getPayPalSdkMessagesConfiguration(e,t);yield this.loadPayPalSdk(n)}if(!this.window.paypalMessages)throw new u;return this.window.paypalMessages})}loadPayPalSdk({options:e,attributes:t}){return ft(this,void 0,void 0,function*(){const n=this.transformConfig(e),i=this.transformConfig(t),o=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(o,{async:!0,attributes:i})})}getPayPalFastlaneSdkConfiguration(e,t,n){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new m(h.MissingPaymentMethod);const{intent:r,clientId:a,merchantId:s,attributionId:c}=o;return{options:{"client-id":a,"merchant-id":s,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t,intent:r},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":i}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n=!0){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new m(h.MissingPaymentMethod);const{intent:r,clientId:a,merchantId:s,buyerCountry:c,attributionId:d,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:u}=o,y=l||n;return{options:Object.assign({"client-id":a,"merchant-id":s,commit:y,components:["googlepay"],currency:t,intent:r},u&&{"buyer-country":c}),attributes:{"data-partner-attribution-id":d,"data-client-token":i,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new m(h.MissingPaymentMethod);const{intent:i,clientId:o,merchantId:r,buyerCountry:a,attributionId:s,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:d=[],enabledAlternativePaymentMethods:l=[]}=n,u=l,y=d.filter(e=>!l.includes(e));return{options:Object.assign({"client-id":o,"merchant-id":r,"enable-funding":u.length>0?u:void 0,"disable-funding":y.length>0?y:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:i},c&&{"buyer-country":a}),attributes:{"data-partner-attribution-id":s,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new m(h.MissingPaymentMethod);const{clientId:i,merchantId:o,attributionId:r,isDeveloperModeApplicable:a,buyerCountry:s}=n;return{options:Object.assign({"client-id":i,"merchant-id":o,components:["messages"],currency:t},a&&{"buyer-country":s}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":r}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}function wt(e){if(!function(e){return!!e.initializationData&&"attributionId"in e.initializationData&&"isVenmoEnabled"in e.initializationData&&"isGooglePayEnabled"in e.initializationData&&"isPayPalCreditAvailable"in e.initializationData}(e))throw new m(h.MissingPaymentMethod)}var vt=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class _t extends F{constructor(e,t){super("paypalsb",e),this.payPalCommerceSdk=t,this.service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});var o,r,a,s,c;return vt(this,void 0,void 0,function*(){const d=null!==(r=null===(o=this.service.getState().getStoreConfig())||void 0===o?void 0:o.currency.code)&&void 0!==r?r:n;if(!d)throw new m(h.MissingPaymentMethod);yield i.initialize.call(this,e,t,d);const l=i.getPaymentMethod.call(this);if(!l.initializationData)throw new m(h.MissingPaymentMethod);wt(l);const u=yield this.payPalCommerceSdk.getPayPalGooglePaySdk(l,d);this.googlepayConfig=yield u.Googlepay().config();const{allowedPaymentMethods:y}=this.googlepayConfig;this.setGatewayIdentifier(null===(c=null===(s=null===(a=y[0])||void 0===a?void 0:a.tokenizationSpecification)||void 0===s?void 0:s.parameters)||void 0===c?void 0:c.gateway)})}getPaymentGatewayParameters(){if(this.googlepayConfig){const{allowedPaymentMethods:e}=this.googlepayConfig,{gatewayMerchantId:t}=e[0].tokenizationSpecification.parameters;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:t}}return{gateway:this.getGatewayIdentifier()}}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return vt(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n})}}const bt="This API endpoint is for internal use only and may change in the future";var Ct,St;!function(e){e.Approved="APPROVED",e.PayerActionRequired="PAYER_ACTION_REQUIRED"}(Ct||(Ct={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(St||(St={}));var It=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Ot extends oe{constructor(e,t,n,i){super(e,t),this._payPalCommerceSdk=n,this._requestSender=i}execute({payment:e}){return It(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId))throw new J(["payment"]);const t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow().id,{initializationData:i}=t.getPaymentMethodOrThrow(this._getMethodId()),{orderId:o}=yield this.getOrderId(n),{card_information:r}=i||{},a=yield this._googlePayPaymentProcessor.getNonce(e.methodId),s={tokenizationData:{type:"PAYMENT_GATEWAY",token:atob(a)},info:{cardNetwork:(null==r?void 0:r.type)||"",cardDetails:(null==r?void 0:r.number)||""},type:"CARD"};yield this.confirmOrder(o,s),yield this._paymentIntegrationService.submitOrder();try{const t={formattedPayload:{method_id:e.methodId,paypal_account:{order_id:o}}};yield this._paymentIntegrationService.submitPayment({methodId:e.methodId,paymentData:t})}catch(e){yield this._googlePayPaymentProcessor.processAdditionalAction(e)}})}confirmOrder(e,t){return It(this,void 0,void 0,function*(){const n=this._paymentIntegrationService.getState(),i=n.getPaymentMethodOrThrow(this._getMethodId());if(!i.initializationData)throw new m(h.MissingPaymentMethod);const o=n.getCartOrThrow().currency.code,r=yield this._payPalCommerceSdk.getPayPalGooglePaySdk(i,o,!0),{status:a}=yield r.Googlepay().confirmOrder({orderId:e,paymentMethodData:t});if(a===Ct.PayerActionRequired)return yield r.Googlepay().initiatePayerAction({orderId:e}),Promise.resolve();if(a!==Ct.Approved)throw new b("Payment is not approved.");return Promise.resolve()})}getOrderId(e){return It(this,void 0,void 0,function*(){const t={cartId:e,shouldSaveInstrument:!1},{body:n}=yield this._requestSender.post("/api/storefront/payments/googlepaypaypalcommercecheckout",{headers:Object.assign({"X-API-INTERNAL":bt,"Content-Type":pe.Json},q),body:t});return n})}}const kt=g(i=>{const o=new Pt(n());return new Ot(i,new Y(ae(),new _t(i,o),t(),e()),o,t())},[{id:"googlepaypaypalcommerce"}]);var At=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Tt{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n){return At(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsFastlaneSdk){const i=this.getPayPalFastlaneSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.bigCommercePaymentsFastlaneSdk)throw new u}return this.window.bigCommercePaymentsFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i){return At(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsGooglePay||i){const i=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.bigCommercePaymentsGooglePay)throw new u;return this.window.bigCommercePaymentsGooglePay})}getPayPalApmsSdk(e,t){return At(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsApms){const n=this.getPayPalApmSdkConfiguration(e,t);if(yield this.loadPayPalSdk(n),!this.window.bigCommercePaymentsApms)throw new u}return this.window.bigCommercePaymentsApms})}getPayPalMessages(e,t){return At(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsMessages){const n=this.getPayPalSdkMessagesConfiguration(e,t);yield this.loadPayPalSdk(n)}if(!this.window.bigCommercePaymentsMessages)throw new u;return this.window.bigCommercePaymentsMessages})}loadPayPalSdk({options:e,attributes:t}){return At(this,void 0,void 0,function*(){const n=this.transformConfig(e),i=this.transformConfig(t),o=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(o,{async:!0,attributes:i})})}getPayPalFastlaneSdkConfiguration(e,t,n){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new m(h.MissingPaymentMethod);const{intent:r,clientId:a,merchantId:s,attributionId:c}=o;return{options:{"client-id":a,"merchant-id":s,commit:!0,components:["fastlane","three-domain-secure"],currency:t,intent:r},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"bigCommercePaymentsFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":i}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n=!0){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new m(h.MissingPaymentMethod);const{intent:r,clientId:a,merchantId:s,buyerCountry:c,attributionId:d,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:u}=o,y=l||n;return{options:Object.assign({"client-id":a,"merchant-id":s,commit:y,components:["googlepay"],currency:t,intent:r},u&&{"buyer-country":c}),attributes:{"data-partner-attribution-id":d,"data-client-token":i,"data-namespace":"bigCommercePaymentsGooglePay"}}}getPayPalApmSdkConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new m(h.MissingPaymentMethod);const{intent:i,clientId:o,merchantId:r,buyerCountry:a,attributionId:s,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:d=[],enabledAlternativePaymentMethods:l=[]}=n,u=this.filterFundingOptions(l),y=this.filterFundingOptions(d.filter(e=>!l.includes(e)));return{options:Object.assign({"client-id":o,"merchant-id":r,"enable-funding":u.length>0?u:void 0,"disable-funding":y.length>0?y:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:i},c&&{"buyer-country":a}),attributes:{"data-partner-attribution-id":s,"data-namespace":"bigCommercePaymentsApms"}}}getPayPalSdkMessagesConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new m(h.MissingPaymentMethod);const{clientId:i,merchantId:o,attributionId:r,isDeveloperModeApplicable:a,buyerCountry:s}=n;return{options:Object.assign({"client-id":i,"merchant-id":o,components:["messages"],currency:t},a&&{"buyer-country":s}),attributes:{"data-namespace":"bigCommercePaymentsMessages","data-partner-attribution-id":r}}}filterFundingOptions(e){const t=["klarna","afterpay"];return e?e.filter(e=>!t.includes(e)):[]}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}var Et,Mt,Dt=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Nt extends F{constructor(e,t){super("googlepay_bigcommerce_payments",e),this.payPalSdkHelper=t,this.service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});var o,r,a,s,c;return Dt(this,void 0,void 0,function*(){const d=null!==(r=null===(o=this.service.getState().getStoreConfig())||void 0===o?void 0:o.currency.code)&&void 0!==r?r:n;if(!d)throw new m(h.MissingPaymentMethod);yield i.initialize.call(this,e,t,d);const l=i.getPaymentMethod.call(this);if(!l.initializationData)throw new m(h.MissingPaymentMethod);wt(l);const u=yield this.payPalSdkHelper.getPayPalGooglePaySdk(l,d);this.googlepayConfig=yield u.Googlepay().config();const{allowedPaymentMethods:y}=this.googlepayConfig;this.setGatewayIdentifier(null===(c=null===(s=null===(a=y[0])||void 0===a?void 0:a.tokenizationSpecification)||void 0===s?void 0:s.parameters)||void 0===c?void 0:c.gateway)})}getPaymentGatewayParameters(){if(this.googlepayConfig){const{allowedPaymentMethods:e}=this.googlepayConfig,{gatewayMerchantId:t}=e[0].tokenizationSpecification.parameters;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:t}}return{gateway:this.getGatewayIdentifier()}}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return Dt(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n})}}!function(e){e.Approved="APPROVED",e.PayerActionRequired="PAYER_ACTION_REQUIRED"}(Et||(Et={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(Mt||(Mt={}));var Rt=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class xt extends oe{constructor(e,t,n,i){super(e,t),this._payPalSdkHelper=n,this._requestSender=i}execute({payment:e}){return Rt(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId))throw new J(["payment"]);const t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow().id,{initializationData:i}=t.getPaymentMethodOrThrow(this._getMethodId()),{orderId:o}=yield this.getOrderId(n),{card_information:r}=i||{},a=yield this._googlePayPaymentProcessor.getNonce(e.methodId),s={tokenizationData:{type:"PAYMENT_GATEWAY",token:atob(a)},info:{cardNetwork:(null==r?void 0:r.type)||"",cardDetails:(null==r?void 0:r.number)||""},type:"CARD"};yield this.confirmOrder(o,s),yield this._paymentIntegrationService.submitOrder();try{const t={formattedPayload:{method_id:e.methodId,paypal_account:{order_id:o}}};yield this._paymentIntegrationService.submitPayment({methodId:e.methodId,paymentData:t})}catch(e){yield this._googlePayPaymentProcessor.processAdditionalAction(e)}})}confirmOrder(e,t){return Rt(this,void 0,void 0,function*(){const n=this._paymentIntegrationService.getState(),i=n.getPaymentMethodOrThrow(this._getMethodId());if(!i.initializationData)throw new m(h.MissingPaymentMethod);const o=n.getCartOrThrow().currency.code,r=yield this._payPalSdkHelper.getPayPalGooglePaySdk(i,o,!0),{status:a}=yield r.Googlepay().confirmOrder({orderId:e,paymentMethodData:t});if(a===Et.PayerActionRequired)return yield r.Googlepay().initiatePayerAction({orderId:e}),Promise.resolve();if(a!==Et.Approved)throw new b("Payment is not approved.");return Promise.resolve()})}getOrderId(e){return Rt(this,void 0,void 0,function*(){const t={cartId:e,shouldSaveInstrument:!1},{body:n}=yield this._requestSender.post("/api/storefront/payments/googlepay_bigcommerce_paymentscheckout",{headers:Object.assign({"X-API-INTERNAL":bt,"Content-Type":pe.Json},q),body:t});return n})}}const zt=g(i=>{const o=new Tt(n());return new xt(i,new Y(ae(),new Nt(i,o),t(),e()),o,t())},[{id:"googlepay_bigcommerce_payments"}]);var Gt=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Bt extends F{constructor(e,t){super("worldlinena",e),this.formPoster=t}extraPaymentData(){return Gt(this,void 0,void 0,function*(){return Promise.resolve({browser_info:f()})})}processAdditionalAction(e){return Gt(this,void 0,void 0,function*(){if(!function(e){return P(e)&&(t=e.body,s(t)&&"object"==typeof t&&"errors"in t&&"three_ds_result"in t&&a(t.errors)&&d(t.errors,{code:"three_d_secure_required"}));var t}(e))throw e;const{three_ds_result:t}=e.body,{acs_url:n,payer_auth_request:i,merchant_data:o}=t||{};if(!n||!i||!o)throw new J(["formUrl","threeDSSessionData","creq"]);return new Promise(e=>{this.formPoster.postForm(n,{threeDSSessionData:i,creq:o},e,"_top")})})}}const jt=g(n=>new oe(n,new Y(ae(),new Bt(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);class Lt extends l{constructor(e){super(e||"Not implemented."),this.name="NotImplementedError",this.type="not_implemented"}}var Ft=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Vt{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){var t,n;return Ft(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId)||!ne(e.methodId))throw new b('Unable to proceed because "methodId" is not a valid key.');this._methodId=e.methodId;const i=e[this._getMethodId()];if(!i)throw new b("Unable to proceed without valid options.");let o,r=this._paymentIntegrationService.getState();try{o=r.getPaymentMethodOrThrow(this._getMethodId())}catch(e){r=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodId()),o=r.getPaymentMethodOrThrow(this._getMethodId())}try{this._googlePayPaymentProcessor.setIsWebViewExperimentOn(!!(null===(t=o.initializationData)||void 0===t?void 0:t.isWebViewExperimentOn)),yield this._googlePayPaymentProcessor.initialize(()=>o,this._getGooglePayClientOptions(null===(n=o.initializationData)||void 0===n?void 0:n.storeCountry))}catch(e){return}this._addPaymentButton(i)})}signIn(){return Promise.reject(new Lt('In order to sign in via Google Pay, the shopper must click on "Google Pay" button.'))}signOut(){var e;return Ft(this,void 0,void 0,function*(){const t=null===(e=this._paymentIntegrationService.getState().getPaymentId())||void 0===e?void 0:e.providerId;t&&(yield this._googlePayPaymentProcessor.signOut(t))})}executePaymentMethodCheckout(e){var t;return null===(t=null==e?void 0:e.continueWithCheckoutCallback)||void 0===t||t.call(e),Promise.resolve()}deinitialize(){var e;return null===(e=this._paymentButton)||void 0===e||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()}_getGooglePayClientOptions(e){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:({callbackTrigger:t,shippingAddress:n,shippingOptionData:i,offerData:o})=>Ft(this,void 0,void 0,function*(){const{availableTriggers:r,addressChangeTriggers:a,shippingOptionsChangeTriggers:s,offerChangeTriggers:c}=this._googlePayPaymentProcessor.getCallbackTriggers();if(!r.includes(t))return;const d=a.includes(t)?yield this._googlePayPaymentProcessor.handleShippingAddressChange(n):void 0;s.includes(t)&&(yield this._googlePayPaymentProcessor.handleShippingOptionChange(i.id));const{newOfferInfo:l,error:u}=c.includes(t)?yield this._googlePayPaymentProcessor.handleCoupons(o):{},h=u;yield this._paymentIntegrationService.loadCheckout();const y=this._googlePayPaymentProcessor.getTotalPrice(),{code:g}=this._paymentIntegrationService.getState().getCartOrThrow().currency;return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},e&&{countryCode:e}),{currencyCode:g,totalPriceStatus:R.FINAL,totalPrice:y})},d&&{newShippingOptionParameters:d}),l&&{newOfferInfo:l}),h&&{error:h})})}}}_addPaymentButton({container:e,buttonColor:t,buttonType:n,onClick:i,onError:o}){var r;this._paymentButton=null!==(r=this._paymentButton)&&void 0!==r?r:this._googlePayPaymentProcessor.addPaymentButton(e,{buttonColor:null!=t?t:"default",buttonType:null!=n?n:"plain",onClick:this._handleClick(o,i)})}_handleClick(e,t){return n=>Ft(this,void 0,void 0,function*(){n.preventDefault(),t&&"function"==typeof t&&t();try{yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(t){let n=t;if(ee(t)){if("CANCELED"===t.statusCode)throw new w;n=new W(JSON.stringify(t))}throw null==e||e(new W("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){return Ft(this,void 0,void 0,function*(){const e=yield this._googlePayPaymentProcessor.showPaymentSheet(),t=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(e),n=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(e),i="/embedded-checkout"===window.location.pathname?this._paymentIntegrationService.getState().getStoreConfigOrThrow().links.siteLink:void 0;t&&(yield this._paymentIntegrationService.updateBillingAddress(t)),n&&(yield this._paymentIntegrationService.updateShippingAddress(n)),yield this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodId(),e,i)})}_getMethodId(){return k(this._methodId,()=>new _(v.PaymentNotInitialized))}}const Ut=g(n=>{const i=t();return new Vt(n,new Y(ae(),new F("adyen",n),i,e()))},[{id:"googlepayadyenv2"}]),qt=g(n=>{const i=t();return new Vt(n,new Y(ae(),new F("adyen",n),i,e()))},[{id:"googlepayadyenv3"}]),Wt=g(n=>new Vt(n,new Y(ae(),new he(n),t(),e())),[{id:"googlepayauthorizenet"}]),Ht=g(n=>{const i=t();return new Vt(n,new Y(ae(),new Pe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]),Yt=g(n=>new Vt(n,new Y(ae(),new ve(n),t(),e())),[{id:"googlepaycybersourcev2"}]),Jt=g(n=>new Vt(n,new Y(ae(),new ve(n),t(),e())),[{id:"googlepaybnz"}]),Kt=g(n=>new Vt(n,new Y(ae(),new be(n),t(),e())),[{id:"googlepayorbital"}]),Zt=g(i=>new Vt(i,new Y(ae(),new Ue(i,new Ge(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeocs"}]),Xt=g(i=>new Vt(i,new Y(ae(),new Ue(i,new Ge(n())),t(),e())),[{id:"googlepaystripeupe"}]),Qt=g(n=>new Vt(n,new Y(ae(),new We(n),t(),e())),[{id:"googlepayworldpayaccess"}]),$t=g(i=>{const o=t(),r=window,a=new Ze(i),s=new dt(new ht(n(),r,a));return new Vt(i,new Y(ae(),new pt(i,s),o,e()))},[{id:"googlepaybraintree"}]),en=g(i=>new Vt(i,new Y(ae(),new _t(i,new Pt(n())),t(),e())),[{id:"googlepaypaypalcommerce"}]),tn=g(i=>new Vt(i,new Y(ae(),new Nt(i,new Tt(n())),t(),e())),[{id:"googlepay_bigcommerce_payments"}]),nn=g(n=>new Vt(n,new Y(ae(),new Bt(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);class on extends l{constructor(e){super(e||"An unexpected error has occurred during buy now cart creation process. Please try again later."),this.name="BuyNowCartCreationError",this.type="buy_now_cart_creation_error"}}var rn=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class an{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){var t,n,i;return rn(this,void 0,void 0,function*(){if(!e.methodId||!ne(e.methodId))throw new b('Unable to proceed because "methodId" is not a valid key.');if(this._methodId=e.methodId,!e.containerId)throw new b('Unable to proceed because "containerId" is not a valid key.');const o=e[this._getMethodOrThrow()];if(!o)throw new b("Unable to proceed without valid options.");const{buyNowInitializeOptions:r,currencyCode:a,buttonColor:s,buttonType:c,onError:d}=o;let l,u=this._paymentIntegrationService.getState();try{l=u.getPaymentMethodOrThrow(this._getMethodOrThrow())}catch(e){u=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodOrThrow()),l=u.getPaymentMethodOrThrow(this._getMethodOrThrow())}if(this._countryCode=null===(t=l.initializationData)||void 0===t?void 0:t.storeCountry,this._googlePayPaymentProcessor.setIsWebViewExperimentOn(!!(null===(n=l.initializationData)||void 0===n?void 0:n.isWebViewExperimentOn)),r){if(!a)throw new b('Unable to initialize payment because "options.currencyCode" argument is not provided.');this._currencyCode=a,this._buyNowInitializeOptions=r,yield this._googlePayPaymentProcessor.initialize(()=>l,this._getGooglePayClientOptions(),!!r,a)}else yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initialize(()=>l,this._getGooglePayClientOptions());this._paymentButton=null!==(i=this._paymentButton)&&void 0!==i?i:this._googlePayPaymentProcessor.addPaymentButton(e.containerId,{buttonColor:null!=s?s:"default",buttonType:null!=c?c:"plain",onClick:this._handleClick(d)})})}deinitialize(){var e;return null===(e=this._paymentButton)||void 0===e||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()}_handleClick(e){return t=>rn(this,void 0,void 0,function*(){t.preventDefault();try{this._buyNowInitializeOptions?yield this._createBuyNowCartOrThrow(this._buyNowInitializeOptions):yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(t){let n=t;if(ee(t)){if("CANCELED"===t.statusCode)throw new w;n=new W(JSON.stringify(t))}throw null==e||e(new W("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){var e;return rn(this,void 0,void 0,function*(){const t=yield this._googlePayPaymentProcessor.showPaymentSheet(),n=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(t),i=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(t),o="/embedded-checkout"===window.location.pathname?this._paymentIntegrationService.getState().getStoreConfigOrThrow().links.siteLink:void 0;n&&(yield this._paymentIntegrationService.updateBillingAddress(n)),i&&!(null===(e=this._buyNowCart)||void 0===e?void 0:e.lineItems.digitalItems.length)&&(yield this._paymentIntegrationService.updateShippingAddress(i)),yield this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodOrThrow(),t,o)})}_getGooglePayClientOptions(){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:({callbackTrigger:e,shippingAddress:t,shippingOptionData:n,offerData:i})=>rn(this,void 0,void 0,function*(){const{availableTriggers:o,addressChangeTriggers:r,shippingOptionsChangeTriggers:a,offerChangeTriggers:s}=this._googlePayPaymentProcessor.getCallbackTriggers();if(!o.includes(e))return;const c=r.includes(e)?yield this._googlePayPaymentProcessor.handleShippingAddressChange(t):void 0;a.includes(e)&&(yield this._googlePayPaymentProcessor.handleShippingOptionChange(n.id));const{newOfferInfo:d,error:l}=s.includes(e)?yield this._googlePayPaymentProcessor.handleCoupons(i):{},u=l;return this._buyNowInitializeOptions?this._getBuyNowTransactionInfo(c,d,u):this._getTransactionInfo(c,d,u)})}}}_createBuyNowCartOrThrow(e){return rn(this,void 0,void 0,function*(){if("function"==typeof(null==e?void 0:e.getBuyNowCartRequestBody)){const t=e.getBuyNowCartRequestBody();try{this._buyNowCart=yield this._paymentIntegrationService.createBuyNowCart(t),yield this._paymentIntegrationService.loadCheckout(this._buyNowCart.id)}catch(e){if("string"==typeof e)throw new on(e);throw e}}})}_getBuyNowTransactionInfo(e,t,n){if(!this._buyNowCart)return;const{cartAmount:i}=this._buyNowCart,o=this._googlePayPaymentProcessor.getTotalPrice();return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:this._getCurrencyCodeOrThrow(),totalPrice:o||String(i),totalPriceStatus:R.FINAL})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})}_getTransactionInfo(e,t,n){return rn(this,void 0,void 0,function*(){yield this._paymentIntegrationService.loadCheckout();const i=this._googlePayPaymentProcessor.getTotalPrice(),{code:o}=this._paymentIntegrationService.getState().getCartOrThrow().currency;return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:o,totalPriceStatus:R.FINAL,totalPrice:i})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})})}_getMethodOrThrow(){return k(this._methodId,()=>new _(v.PaymentNotInitialized))}_getCurrencyCodeOrThrow(){return k(this._currencyCode,()=>new b('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}}const sn=g(i=>{const o=t(),r=window,a=new Ze(i),s=new dt(new ht(n(),r,a));return new an(i,new Y(ae(),new pt(i,s),o,e()))},[{id:"googlepaybraintree"}]),cn=g(i=>new an(i,new Y(ae(),new _t(i,new Pt(n())),t(),e())),[{id:"googlepaypaypalcommerce"}]),dn=g(i=>new an(i,new Y(ae(),new Nt(i,new Tt(n())),t(),e())),[{id:"googlepay_bigcommerce_payments"}]),ln=g(n=>{const i=t();return new an(n,new Y(ae(),new F("adyen",n),i,e()))},[{id:"googlepayadyenv2"}]),un=g(n=>{const i=t();return new an(n,new Y(ae(),new F("adyen",n),i,e()))},[{id:"googlepayadyenv3"}]),hn=g(n=>new an(n,new Y(ae(),new he(n),t(),e())),[{id:"googlepayauthorizenet"}]),yn=g(n=>{const i=t();return new an(n,new Y(ae(),new Pe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]),gn=g(n=>new an(n,new Y(ae(),new ve(n),t(),e())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]),pn=g(n=>new an(n,new Y(ae(),new be(n),t(),e())),[{id:"googlepayorbital"}]),mn=g(i=>new an(i,new Y(ae(),new Ue(i,new Ge(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]),fn=g(n=>new an(n,new Y(ae(),new We(n),t(),e())),[{id:"googlepayworldpayaccess"}]),Pn=g(n=>new an(n,new Y(ae(),new Bt(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);export{ln as createGooglePayAdyenV2ButtonStrategy,Ut as createGooglePayAdyenV2CustomerStrategy,se as createGooglePayAdyenV2PaymentStrategy,un as createGooglePayAdyenV3ButtonStrategy,qt as createGooglePayAdyenV3CustomerStrategy,ue as createGooglePayAdyenV3PaymentStrategy,hn as createGooglePayAuthorizeDotNetButtonStrategy,Wt as createGooglePayAuthorizeDotNetCustomerStrategy,ye as createGooglePayAuthorizeNetPaymentStrategy,dn as createGooglePayBigCommercePaymentsButtonStrategy,tn as createGooglePayBigCommercePaymentsCustomerStrategy,zt as createGooglePayBigCommercePaymentsPaymentStrategy,Jt as createGooglePayBnzCustomerStrategy,sn as createGooglePayBraintreeButtonStrategy,$t as createGooglePayBraintreeCustomerStrategy,mt as createGooglePayBraintreePaymentStrategy,yn as createGooglePayCheckoutComButtonStrategy,Ht as createGooglePayCheckoutComCustomerStrategy,we as createGooglePayCheckoutComPaymentStrategy,gn as createGooglePayCybersourceButtonStrategy,Yt as createGooglePayCybersourceCustomerStrategy,_e as createGooglePayCybersourcePaymentStrategy,pn as createGooglePayOrbitalButtonStrategy,Kt as createGooglePayOrbitalCustomerStrategy,Ce as createGooglePayOrbitalPaymentStrategy,kt as createGooglePayPPCPPaymentStrategy,cn as createGooglePayPayPalCommerceButtonStrategy,en as createGooglePayPayPalCommerceCustomerStrategy,mn as createGooglePayStripeButtonStrategy,Zt as createGooglePayStripeCustomerStrategy,qe as createGooglePayStripePaymentStrategy,Xt as createGooglePayStripeUpeCustomerStrategy,Pn as createGooglePayTdOnlineMartButtonStrategy,nn as createGooglePayTdOnlineMartCustomerStrategy,jt as createGooglePayTdOnlineMartPaymentStrategy,fn as createGooglePayWorldpayAccessButtonStrategy,Qt as createGooglePayWorldpayAccessCustomerStrategy,He as createGooglePayWorldpayAccessPaymentStrategy};
1
+ import{createFormPoster as e}from"@bigcommerce/form-poster";import{createRequestSender as t}from"@bigcommerce/request-sender";import{getScriptLoader as n,getStylesheetLoader as i}from"@bigcommerce/script-loader";import{find as o,includes as r,isArray as a,isObject as s,round as c,some as d}from"lodash";class l extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}class u extends l{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}var h;class y{constructor(e,t,n=window){this._scriptLoader=e,this._stylesheetLoader=t,this._window=n}load(e){var t,n,i,o,r,a;return i=this,o=void 0,a=function*(){if(yield Promise.all([this._stylesheetLoader.loadStylesheet(`https://checkoutshopper-${null!==(t=e.environment)&&void 0!==t?t:""}.adyen.com/checkoutshopper/sdk/3.10.1/adyen.css`,{prepend:!1,attributes:{integrity:"sha384-8ofgICZZ/k5cC5N7xegqFZOA73H9RQ7H13439JfAZW8Gj3qjuKL2isaTD3GMIhDE",crossorigin:"anonymous"}}),this._scriptLoader.loadScript(`https://checkoutshopper-${null!==(n=e.environment)&&void 0!==n?n:""}.adyen.com/checkoutshopper/sdk/3.10.1/adyen.js`,{async:!0,attributes:{integrity:"sha384-wG2z9zSQo61EIvyXmiFCo+zB3y0ZB4hsrXVcANmpP8HLthjoQJQPBh7tZKJSV8jA",crossorigin:"anonymous"}})]),!this._window.AdyenCheckout)throw new u;return new this._window.AdyenCheckout(e)},new((r=void 0)||(r=Promise))(function(e,t){function n(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof r?i:new r(function(e){e(i)})).then(n,s)}c((a=a.apply(i,o||[])).next())})}}function g(e,t){return Object.assign(e,{resolveIds:t})}function p(e){return"object"==typeof e&&null!==e&&"errors"in e&&Array.isArray(e.errors)&&"code"in e.errors[0]&&"string"==typeof e.errors[0].code&&"provider_data"in e&&"object"==typeof e.provider_data}!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(h||(h={}));class m extends l{constructor(e){super(function(e){switch(e){case h.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case h.MissingCart:return"Unable to proceed because cart data is unavailable.";case h.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case h.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case h.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case h.MissingCheckoutConfig:case h.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case h.MissingOrder:return"Unable to proceed because order data is unavailable.";case h.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case h.MissingPayment:return"Unable to proceed because payment data is unavailable.";case h.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case h.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case h.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}function f(){const{navigator:e}=window;let t;return t=e.language?e.language:e.userLanguage,{color_depth:window.screen.colorDepth||24,java_enabled:"function"==typeof e.javaEnabled&&e.javaEnabled(),language:t,screen_height:window.screen.height,screen_width:window.screen.width,time_zone_offset:(new Date).getTimezoneOffset().toString()}}const P=e=>"object"==typeof e&&null!==e&&"body"in e;class w extends l{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}var v;!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(v||(v={}));class _ extends l{constructor(e){super(function(e){switch(e){case v.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case v.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case v.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case v.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}class b extends l{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}function C(e,t,n){if("function"!=typeof n.value)return n;let i=n.value;return{get(){const e=i.bind(this);return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e},set(e){i=e}}}class S{constructor(e){if(!e)throw new Error("Currency settings missing");const{decimalPlaces:t,symbolLocation:n,symbol:i,thousandsSeparator:o,decimalSeparator:r}=e;if("string"!=typeof n||"string"!=typeof i||"string"!=typeof o||"string"!=typeof r||"string"!=typeof t)throw new b("Invalid currency settings provided");this._decimalPlaces=parseInt(t,10),this._symbolLocation=n,this._symbol=i,this._thousandsSeparator=o,this._decimalSeparator=r}format(e){if("number"!=typeof e)throw new b("Invalid amount provided");const t=this._formatNumber(e),n=this._formatCurrency(t);return e<0?`-${n}`:n}_formatNumber(e){const t=Math.abs(e),[n,i=""]=this._toFixed(t,this._decimalPlaces).split("."),o=n.replace(/\B(?=(\d{3})+(?!\d))/g,this._thousandsSeparator);return this._decimalPlaces<1?o:[o,i].join(this._decimalSeparator)}_formatCurrency(e){return"left"===this._symbolLocation.toLowerCase()?`${this._symbol}${e}`:`${e}${this._symbol}`}_toFixed(e,t){return(+`${Math.round(+`${e}e${t}`)}e${-t}`).toFixed(t)}}let I=class{constructor(e){this._storeConfig=e,this._customerFormatter=new S(this._storeConfig.shopperCurrency),this._storeFormatter=new S(this._storeConfig.currency)}toCustomerCurrency(e){const t=this._storeConfig.shopperCurrency.exchangeRate;return this._customerFormatter.format(e*t)}toStoreCurrency(e){return this._storeFormatter.format(e)}};I=function(e,t,n,i){var o,r=arguments.length,a=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(t,n,a):o(t,n))||a);return r>3&&a&&Object.defineProperty(t,n,a),a}([function(e,t,n){return t&&n?C(0,t,n):function(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&"constructor"!==n&&Object.defineProperty(t.prototype,n,C(e.prototype,n,i))}),t}(e)}],I);const O=I;function k(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}function A(){if("undefined"==typeof window)return!1;if(function(e){return"ReactNativeWebView"in e}(window))return!0;const e=navigator.userAgent||navigator.vendor||(function(e){return"opera"in e}(window)?window.opera:""),t=/android.+; wv/i.test(e),n=/iPhone|iPod|iPad/i.test(e)&&/AppleWebKit/i.test(e)&&!/Safari/i.test(e);return t||n}function T(e,t,n=!0){var i;return null!==(i=e[t])&&void 0!==i?i:n}var E,M,D,N,R,x,z,G,B;function j(e){return e in x}!function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(E||(E={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(M||(M={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(D||(D={})),function(e){e.pill="pill",e.rect="rect"}(N||(N={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(R||(R={})),function(e){e.AMEX="AMEX",e.DISCOVER="DISCOVER",e.INTERAC="INTERAC",e.JCB="JCB",e.MC="MASTERCARD",e.VISA="VISA"}(x||(x={})),function(e){e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION"}(z||(z={})),function(e){e.OFFER_INVALID="OFFER_INVALID",e.PAYMENT_DATA_INVALID="PAYMENT_DATA_INVALID",e.SHIPPING_ADDRESS_INVALID="SHIPPING_ADDRESS_INVALID",e.SHIPPING_ADDRESS_UNSERVICEABLE="SHIPPING_ADDRESS_UNSERVICEABLE",e.SHIPPING_OPTION_INVALID="SHIPPING_OPTION_INVALID",e.OTHER_ERROR="OTHER_ERROR"}(G||(G={})),function(e){e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER"}(B||(B={}));var L=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class F{constructor(e,t){this._gatewayIdentifier=e,this._paymentIntegrationService=t,this._isBuyNowFlow=!1,this._shouldRequestShipping=!0,this._isWebViewExperimentOn=null}mapToShippingAddressRequestBody({shippingAddress:e}){if(!e)return;const{company:t="",phone:n=""}=this._paymentIntegrationService.getState().getShippingAddress()||{};return this._mapToAddressRequestBody(e,t,n)}mapToBillingAddressRequestBody(e){const{billingAddress:t}=e.paymentMethodData.info;if(!t)return;const{company:n="",phone:i="",email:o,customFields:r=[]}=this._paymentIntegrationService.getState().getBillingAddress()||{};return Object.assign(Object.assign({},this._mapToAddressRequestBody(t,n,i,r)),{email:o||e.email})}mapToExternalCheckoutData(e){var t;const{paymentMethodData:{tokenizationData:{token:n},info:{cardNetwork:i,cardDetails:o}}}=e;if(!n)throw new m(h.MissingPaymentToken);return Promise.resolve(Object.assign({nonce:n,card_information:{type:i,number:o}},this._isBuyNowFlow&&{cart_id:null===(t=this._paymentIntegrationService.getState().getCart())||void 0===t?void 0:t.id}))}getRequiredData(){var e;return L(this,void 0,void 0,function*(){const t={emailRequired:!0};if(!this._isShippingAddressRequired())return t;const n=yield this._paymentIntegrationService.loadShippingCountries(),i=null===(e=n.getShippingCountries())||void 0===e?void 0:e.map(e=>e.code);return Object.assign(Object.assign({},t),{shippingAddressRequired:!0,shippingAddressParameters:Object.assign({phoneNumberRequired:!0},i&&{allowedCountryCodes:i}),shippingOptionRequired:!0})})}getCallbackIntents(){return this._isShippingAddressRequired()?[z.OFFER,z.SHIPPING_ADDRESS,z.SHIPPING_OPTION]:[z.OFFER]}getCallbackTriggers(){return{availableTriggers:[B.INITIALIZE,B.SHIPPING_ADDRESS,B.SHIPPING_OPTION,B.OFFER],initializationTrigger:[B.INITIALIZE],addressChangeTriggers:[B.INITIALIZE,B.SHIPPING_ADDRESS],shippingOptionsChangeTriggers:[B.SHIPPING_OPTION],offerChangeTriggers:[B.OFFER]}}getNonce(e){var t;const n=null===(t=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(e).initializationData)||void 0===t?void 0:t.nonce;if(!n)throw new m(h.MissingPaymentToken);return Promise.resolve(n)}extraPaymentData(){return Promise.resolve(void 0)}getMerchantInfo(){const{googleMerchantName:e,googleMerchantId:t,platformToken:n}=this.getGooglePayInitializationData();return{merchantName:e,merchantId:t,authJwt:n}}getTransactionInfo(){let e;const{getCartOrThrow:t}=this._paymentIntegrationService.getState();e=this._isBuyNowFlow?this._getCurrencyCodeOrThrow():t().currency.code;const n=this.getGooglePayInitializationData().storeCountry;if(this.isWebViewWithRestrictions()){const t=this.getTotalPrice();return Object.assign(Object.assign({},n&&{countryCode:n}),{currencyCode:e,totalPrice:t,totalPriceStatus:R.ESTIMATED})}return Object.assign(Object.assign({},n&&{countryCode:n}),{currencyCode:e,totalPriceStatus:R.ESTIMATED,totalPrice:"0"})}isWebViewWithRestrictions(){return null!==this._isWebViewExperimentOn?this._isWebViewExperimentOn&&A():A()}setIsWebViewExperimentOn(e){this._isWebViewExperimentOn=e}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData().gatewayMerchantId;if(!e)throw new b("Unable to proceed, gatewayMerchantId is missing.");return{gateway:this._gatewayIdentifier,gatewayMerchantId:e}}getCardParameters(){return{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:this.getPaymentMethod().supportedCards.filter(j).map(e=>x[e]),billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}}initialize(e,t,n){return this._getPaymentMethodFn=e,this._isBuyNowFlow=Boolean(t),this._currencyCode=n,this._isBuyNowFlow&&this._getCurrencyCodeOrThrow(),Promise.resolve()}handleShippingAddressChange(e){var t,n,i,o;return L(this,void 0,void 0,function*(){e&&(e.name=e.name||"",e.address1=e.address1||"");const r=this.mapToShippingAddressRequestBody({shippingAddress:e});r&&(yield this._paymentIntegrationService.updateShippingAddress(r));const a=this._paymentIntegrationService.getState(),s=a.getConsignments();if(!(null==s?void 0:s[0]))return;const c=s[0],d=a.getStoreConfigOrThrow();this._currencyService||(this._currencyService=new O(d));const l=(c.availableShippingOptions||[]).map(this._getGooglePayShippingOption.bind(this)),u=null===(t=c.availableShippingOptions)||void 0===t?void 0:t.find(e=>e.isRecommended);if(l.length){const e=(null===(n=c.selectedShippingOption)||void 0===n?void 0:n.id)||(null==u?void 0:u.id)||(null===(i=l[0])||void 0===i?void 0:i.id);return!(null===(o=c.selectedShippingOption)||void 0===o?void 0:o.id)&&l[0]&&(yield this.handleShippingOptionChange((null==u?void 0:u.id)||l[0].id)),{defaultSelectedOptionId:e,shippingOptions:l}}})}handleShippingOptionChange(e){return L(this,void 0,void 0,function*(){if("shipping_option_unselected"!==e)return this._paymentIntegrationService.selectShippingOption(e)})}getTotalPrice(){const{getCheckoutOrThrow:e,getCartOrThrow:t,getStoreConfigOrThrow:n}=this._paymentIntegrationService.getState(),{decimalPlaces:i}=t().currency,o=T(n().checkoutSettings.features,"PI-5075.google_pay_round_total_price_to_max_2_decimal_places")?Math.min(i,2):i;return c(e().outstandingBalance,o).toFixed(o)}handleCoupons(e){return L(this,void 0,void 0,function*(){const{redemptionCodes:t=[]}=e,{offers:n}=this.getAppliedCoupons()||{};let i;return yield t.reduce((e,t)=>L(this,void 0,void 0,function*(){if(yield e,(n||[]).some(({redemptionCode:e})=>e===t))return;const o=yield this.applyCoupon(t);o&&(i=o)}),Promise.resolve()),yield(n||[]).reduce((e,n)=>L(this,void 0,void 0,function*(){yield e,t.includes(n.redemptionCode)||(yield this._paymentIntegrationService.removeCoupon(n.redemptionCode))}),Promise.resolve()),{newOfferInfo:this.getAppliedCoupons(),error:i}})}getAppliedCoupons(){const e=this._paymentIntegrationService.getState(),{coupons:t}=e.getCheckout()||{};return{offers:(t||[]).map(e=>{const{displayName:t,code:n}=e;return{redemptionCode:n,description:t}})}}applyCoupon(e){return L(this,void 0,void 0,function*(){let t;try{yield this._paymentIntegrationService.applyCoupon(e)}catch(e){return e instanceof Error&&(t={reason:G.OFFER_INVALID,message:e.message,intent:B.OFFER}),t}})}setShouldRequestShipping(e){this._shouldRequestShipping=e}getGooglePayInitializationData(){return k(this.getPaymentMethod().initializationData,()=>new b("Missing initialization data."))}getPaymentMethod(){return k(this._getPaymentMethodFn,()=>new _(v.PaymentNotInitialized))()}getGatewayIdentifier(){return this._gatewayIdentifier}setGatewayIdentifier(e){this._gatewayIdentifier=e||this.getGatewayIdentifier()}_isShippingAddressRequired(){const{getCartOrThrow:e,getStoreConfigOrThrow:t,getShippingAddress:n}=this._paymentIntegrationService.getState(),i=t();let o;return o=T(i.checkoutSettings.features,"PI-4290.google_pay_require_shipping_address")?this._shouldRequestShipping:void 0===n(),o&&(r=e(),a=i,!!r&&(!!r.lineItems.physicalItems.some(e=>e.isShippingRequired)||!(!a||!r.lineItems.customItems)&&r.lineItems.customItems.length>0));var r,a}_mapToAddressRequestBody(e,t,n,i){const{name:o,address1:r,address2:a,address3:s,locality:c,administrativeArea:d,countryCode:l,postalCode:u,phoneNumber:h}=e,[y,g]=this._getFirstAndLastName(o);return{firstName:y,lastName:g,company:t,address1:r,address2:`${a} ${s}`.trim(),city:c||d,stateOrProvince:d,stateOrProvinceCode:d,countryCode:l,postalCode:u,phone:h||n,customFields:i||[]}}_getFirstAndLastName(e){const t=e.split(" ");return 1===t.length?[e,""]:[t.slice(0,-1).join(" "),t[t.length-1]]}_getCurrencyCodeOrThrow(){return k(this._currencyCode,()=>new b('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}_getGooglePayShippingOption({id:e,cost:t,description:n,additionalDescription:i}){var o;return{id:e,label:`${(null===(o=this._currencyService)||void 0===o?void 0:o.toCustomerCurrency(t))||t} ${n}`,description:i}}}var V=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class U extends F{constructor(e,t){super("adyen",e),this._scriptLoader=t,this._service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return V(this,void 0,void 0,function*(){yield i.initialize.call(this,e,t,n);const o=i.getPaymentMethod.call(this),r=this._service.getState().getStoreConfig();if(!r)throw new m(h.MissingCheckoutConfig);return this._adyenClient=yield this._scriptLoader.load({environment:o.config.testMode?"test":"live",locale:r.storeProfile.storeLanguage}),Promise.resolve()})}getNonce(e){const t=Object.create(null,{getNonce:{get:()=>super.getNonce},getPaymentMethod:{get:()=>super.getPaymentMethod}});return V(this,void 0,void 0,function*(){const n=yield t.getNonce.call(this,e),i=t.getPaymentMethod.call(this);return JSON.stringify({type:i.method,googlePayToken:n,browser_info:f()})})}processAdditionalAction(e){return V(this,void 0,void 0,function*(){if(!P(e)||!p(e.body))throw e;const t=yield this._handleAction(e.body.provider_data);try{return yield this._service.submitPayment(t)}catch(e){return this.processAdditionalAction(e)}})}_handleAction(e){return new Promise((t,n)=>{const i=JSON.parse(e.action);this._getAdyenClient().createFromAction(i,{onAdditionalDetails:e=>{const n={methodId:i.paymentMethodType,paymentData:{nonce:JSON.stringify(e.data)}};t(n)},size:"05",onError:e=>n(e)}).mount("body"),n(new w)})}_getAdyenClient(){if(!this._adyenClient)throw new _(v.PaymentNotInitialized);return this._adyenClient}}const q={"X-Checkout-SDK-Version":"1.889.1"};class W extends l{constructor(e){super(e||"Unable to proceed because the client library of a payment method has thrown an unexpected error."),this.name="PaymentMethodFailedError",this.type="payment_method_client_invalid"}}var H=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Y{constructor(e,t,n,i){this._scriptLoader=e,this._gateway=t,this._requestSender=n,this._formPoster=i,this._baseRequest={apiVersion:2,apiVersionMinor:0}}initialize(e,t,n,i){return H(this,void 0,void 0,function*(){this._paymentsClient=yield this._scriptLoader.getGooglePaymentsClient(e().config.testMode,t),yield this._gateway.initialize(e,n,i),this._buildButtonPayloads()})}initializeWidget(){return H(this,void 0,void 0,function*(){yield this._buildWidgetPayloads(),yield this._determineReadinessToPay(),this._prefetchGooglePaymentData()})}getNonce(e){return this._gateway.getNonce(e)}extraPaymentData(){return H(this,void 0,void 0,function*(){return this._gateway.extraPaymentData()})}addPaymentButton(e,t){const n=document.querySelector(`#${e}`);if(!n)return;const i=this._getPaymentsClient().createButton(Object.assign(Object.assign({},t),{allowedPaymentMethods:[this._getBaseCardPaymentMethod()]}));return n.appendChild(i)}showPaymentSheet(){return H(this,void 0,void 0,function*(){const e=this._getPaymentDataRequest();return this._getPaymentsClient().loadPaymentData(e)})}setExternalCheckoutXhr(e,t){return H(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t)})}setExternalCheckoutForm(e,t,n){return H(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t,!0,n)})}mapToBillingAddressRequestBody(e){return this._gateway.mapToBillingAddressRequestBody(e)}mapToShippingAddressRequestBody(e){return this._gateway.mapToShippingAddressRequestBody(e)}processAdditionalAction(e,t){return"processAdditionalAction"in this._gateway?this._gateway.processAdditionalAction(e,t):Promise.reject(e)}signOut(e){return H(this,void 0,void 0,function*(){yield this._requestSender.get(`/remote-checkout/${e}/signout`)})}getCallbackTriggers(){return this._gateway.getCallbackTriggers()}setShouldRequestShipping(e){return this._gateway.setShouldRequestShipping(e)}handleShippingAddressChange(e){return H(this,void 0,void 0,function*(){return this._gateway.handleShippingAddressChange(e)})}handleShippingOptionChange(e){return H(this,void 0,void 0,function*(){yield this._gateway.handleShippingOptionChange(e)})}handleCoupons(e){return H(this,void 0,void 0,function*(){return this._gateway.handleCoupons(e)})}getTotalPrice(){return this._gateway.getTotalPrice()}_setExternalCheckout(e,t,n=!1,i){return H(this,void 0,void 0,function*(){const o="/checkout.php",r=Object.assign({action:"set_external_checkout",provider:e},yield this._gateway.mapToExternalCheckoutData(t));if(n)return new Promise(e=>{this._formPoster.postForm(i?`${i}/checkout`:o,Object.assign(Object.assign({},r),{card_information:JSON.stringify(r.card_information)}),e)});yield this._requestSender.post(o,{headers:Object.assign({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},q),body:r})})}isWebViewWithRestrictions(){return this._gateway.isWebViewWithRestrictions()}setIsWebViewExperimentOn(e){return this._gateway.setIsWebViewExperimentOn(e)}_prefetchGooglePaymentData(){const e=this._getPaymentDataRequest();e.transactionInfo=this._gateway.getTransactionInfo(),this._getPaymentsClient().prefetchPaymentData(e)}_determineReadinessToPay(){return H(this,void 0,void 0,function*(){try{const{result:e}=yield this._getPaymentsClient().isReadyToPay(this._getIsReadyToPayRequest());if(!1===e)throw new W("Google Pay is not supported by the current device and browser, please try another payment method.")}catch(e){if(e instanceof W)throw e;throw new W}})}_buildButtonPayloads(){this._baseCardPaymentMethod={type:"CARD",parameters:this._gateway.getCardParameters()}}_buildWidgetPayloads(){return H(this,void 0,void 0,function*(){const e=this._getBaseCardPaymentMethod();this._cardPaymentMethod=Object.assign(Object.assign({},e),{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:yield this._gateway.getPaymentGatewayParameters()}});const t=this._gateway.isWebViewWithRestrictions()?{shippingOptionRequired:!1}:{callbackIntents:this._gateway.getCallbackIntents(),offerInfo:this._gateway.getAppliedCoupons()};this._paymentDataRequest=Object.assign(Object.assign(Object.assign(Object.assign({},this._baseRequest),{allowedPaymentMethods:[this._cardPaymentMethod],transactionInfo:this._gateway.getTransactionInfo(),merchantInfo:this._gateway.getMerchantInfo()}),yield this._gateway.getRequiredData()),t),this._isReadyToPayRequest=Object.assign(Object.assign({},this._baseRequest),{allowedPaymentMethods:[e]})})}_getBaseCardPaymentMethod(){return this._getOrThrow(this._baseCardPaymentMethod)}_getPaymentDataRequest(){return this._getOrThrow(this._paymentDataRequest)}_getIsReadyToPayRequest(){return this._getOrThrow(this._isReadyToPayRequest)}_getPaymentsClient(){return this._getOrThrow(this._paymentsClient)}_getOrThrow(e){return k(e,()=>new _(v.PaymentNotInitialized))}}class J extends b{constructor(e){let t="Unable to submit payment for the order because the payload is invalid.";e&&(t=`${t} Make sure the following fields are provided correctly: ${e.join(", ")}.`),super(t),this.name="PaymentArgumentInvalidError"}}class K extends l{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}const Z={size:70,color:"#d9d9d9",backgroundColor:"#ffffff"},X={position:"fixed","background-color":"rgba(0, 0, 0, 0.4)","z-index":"1000"},Q="embedded-checkout-loading-indicator-rotation";class ${constructor(e){this.styles=Object.assign(Object.assign({},Z),e&&e.styles),this.containerStyles=Object.assign({},e&&e.containerStyles),this.defineAnimation(),this.container=this.buildContainer(),this.indicator=this.buildIndicator(),this.container.appendChild(this.indicator)}show(e){if(e){const t=document.getElementById(e);if(!t)throw new Error("Unable to attach the loading indicator because the parent ID is not valid.");t.appendChild(this.container)}this.container.style.visibility="visible",this.container.style.opacity="1"}hide(){const e=()=>{this.container.style.visibility="hidden",this.container.removeEventListener("transitionend",e)};this.container.addEventListener("transitionend",e),this.container.style.opacity="0"}buildContainer(){const e=document.createElement("div");return e.style.display="block",e.style.bottom="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.position="absolute",e.style.right="0",e.style.top="0",e.style.transition="all 250ms ease-out",e.style.opacity="0",this.setStyleAttribute(e,this.containerStyles),e}buildIndicator(){const e=document.createElement("div");return e.style.display="block",e.style.width=`${this.styles.size}px`,e.style.height=`${this.styles.size}px`,e.style.borderRadius=`${this.styles.size}px`,e.style.border="solid 1px",e.style.borderColor=`${this.styles.backgroundColor} ${this.styles.backgroundColor} ${this.styles.color} ${this.styles.color}`,e.style.margin="0 auto",e.style.position="absolute",e.style.left="0",e.style.right="0",e.style.top="50%",e.style.transform="translateY(-50%) rotate(0deg)",e.style.transformStyle="preserve-3d",e.style.animation=`${Q} 500ms infinite cubic-bezier(0.69, 0.31, 0.56, 0.83)`,e}setStyleAttribute(e,t){Object.keys(t).forEach(n=>{e.style.setProperty(n,t[n])})}defineAnimation(){var e;if(document.getElementById(Q))return;const t=document.createElement("style");t.id=Q,null===(e=document.head)||void 0===e||e.appendChild(t),t.sheet instanceof CSSStyleSheet&&t.sheet.insertRule(`\n @keyframes ${Q} {\n 0% { transform: translateY(-50%) rotate(0deg); }\n 100% { transform: translateY(-50%) rotate(360deg); }\n }\n `,0)}}function ee(e){return"object"==typeof e&&null!==e&&"statusCode"in e}var te;function ne(e){return Object.values(te).includes(e)}!function(e){e.ADYEN_V2="googlepayadyenv2",e.ADYEN_V3="googlepayadyenv3",e.AUTHORIZE_NET="googlepayauthorizenet",e.BNZ="googlepaybnz",e.BRAINTREE="googlepaybraintree",e.PAYPAL_COMMERCE="googlepaypaypalcommerce",e.BIGCOMMERCE_PAYMENTS="googlepay_bigcommerce_payments",e.CHECKOUT_COM="googlepaycheckoutcom",e.CYBERSOURCE_V2="googlepaycybersourcev2",e.ORBITAL="googlepayorbital",e.STRIPE="googlepaystripe",e.STRIPE_UPE="googlepaystripeupe",e.STRIPE_OCS="googlepaystripeocs",e.WORLDPAY_ACCESS="googlepayworldpayaccess",e.TD_ONLINE_MART="googlepaytdonlinemart"}(te||(te={}));var ie=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class oe{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t,this._isDeinitializationBlocked=!1,this._loadingIndicator=new $({containerStyles:X})}initialize(e){var t,n;return ie(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId)||!ne(e.methodId))throw new b('Unable to proceed because "methodId" is not a valid key.');this._methodId=e.methodId;const i=e[this._getMethodId()];if(!(null==i?void 0:i.walletButton))throw new b("Unable to proceed without valid options.");const{walletButton:o,loadingContainerId:r}=i,a=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}(i,["walletButton","loadingContainerId"]);this._loadingIndicatorContainer=r,yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodId());const s=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(this._getMethodId());this._googlePayPaymentProcessor.setIsWebViewExperimentOn(!!(null===(t=s.initializationData)||void 0===t?void 0:t.isWebViewExperimentOn)),yield this._googlePayPaymentProcessor.initialize(()=>s,this._getGooglePayClientOptions(null===(n=s.initializationData)||void 0===n?void 0:n.storeCountry)),this._addPaymentButton(o,a)})}execute({payment:e}){return ie(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId))throw new J(["payment"]);yield this._paymentIntegrationService.submitOrder();const t=yield this._googlePayPaymentProcessor.getNonce(e.methodId),n=yield this._googlePayPaymentProcessor.extraPaymentData();try{yield this._paymentIntegrationService.submitPayment(Object.assign(Object.assign({},e),{paymentData:Object.assign({nonce:t},n)}))}catch(t){yield this._googlePayPaymentProcessor.processAdditionalAction(t,e.methodId)}})}finalize(){return Promise.reject(new K)}deinitialize(){var e;return this._isDeinitializationBlocked||(this._clickListener&&(null===(e=this._paymentButton)||void 0===e||e.removeEventListener("click",this._clickListener)),this._paymentButton=void 0,this._clickListener=void 0,this._methodId=void 0),Promise.resolve()}_addPaymentButton(e,t){if(this._paymentButton)return;const n=document.getElementById(e);if(!n)throw new b("Unable to proceed without a walletButton.");this._paymentButton=n,this._clickListener=this._handleClick(t),this._paymentButton.addEventListener("click",this._clickListener)}_handleClick({onPaymentSelect:e,onError:t}){return n=>ie(this,void 0,void 0,function*(){n.preventDefault();try{this._googlePayPaymentProcessor.setShouldRequestShipping(!1),yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(e){let n=e;if(this._toggleLoadingIndicator(!1),ee(e)){if("CANCELED"===e.statusCode)throw new w;n=new W(JSON.stringify(e))}throw null==t||t(new W("An error occurred while requesting your Google Pay payment details.")),n}finally{this._toggleBlockDeinitialization(!1)}null==e||e()})}_interactWithPaymentSheet(){return ie(this,void 0,void 0,function*(){const e=yield this._googlePayPaymentProcessor.showPaymentSheet(),t=this._paymentIntegrationService.getState(),{features:n}=t.getStoreConfigOrThrow().checkoutSettings,i=T(n,"PI-5031.google_pay_dont_override_address");this._toggleBlockDeinitialization(!0),this._toggleLoadingIndicator(!0);const o=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(e);o&&!i&&(yield this._paymentIntegrationService.updateBillingAddress(o)),yield this._googlePayPaymentProcessor.setExternalCheckoutXhr(this._getMethodId(),e),yield this._paymentIntegrationService.loadCheckout(),yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodId()),this._toggleLoadingIndicator(!1),this._toggleBlockDeinitialization(!1)})}_getMethodId(){return k(this._methodId,()=>new _(v.PaymentNotInitialized))}_getIsSignedInOrThrow(){return ie(this,void 0,void 0,function*(){try{return!!(yield this._googlePayPaymentProcessor.getNonce(this._getMethodId()))}catch(e){if(e instanceof m&&e.subtype===h.MissingPaymentToken)return!1;throw e}})}_handleOfferTrigger(e){return ie(this,void 0,void 0,function*(){let t=!1,n="Sign in to Google Pay first to apply or remove promo codes.";try{t=yield this._getIsSignedInOrThrow()}catch(e){e instanceof m&&(n=e.message)}if(t){const{newOfferInfo:t,error:n}=yield this._googlePayPaymentProcessor.handleCoupons(e);return{newOfferInfo:t,error:n}}return{error:{reason:G.OFFER_INVALID,message:n,intent:B.OFFER}}})}_getGooglePayClientOptions(e){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:({callbackTrigger:t,offerData:n})=>ie(this,void 0,void 0,function*(){if(t!==B.INITIALIZE&&t!==B.OFFER)return;const{offerChangeTriggers:i}=this._googlePayPaymentProcessor.getCallbackTriggers(),{newOfferInfo:o,error:r}=i.includes(t)?yield this._handleOfferTrigger(n):{},a=r;yield this._paymentIntegrationService.loadCheckout();const{code:s}=this._paymentIntegrationService.getState().getCartOrThrow().currency,c=this._googlePayPaymentProcessor.getTotalPrice();return Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},e&&{countryCode:e}),{currencyCode:s,totalPriceStatus:R.FINAL,totalPrice:c})},o&&{newOfferInfo:o}),a&&{error:a})})}}}_toggleBlockDeinitialization(e){this._isDeinitializationBlocked=e}_toggleLoadingIndicator(e){e&&this._loadingIndicatorContainer?this._loadingIndicator.show(this._loadingIndicatorContainer):this._loadingIndicator.hide()}}class re{constructor(e){this._scriptLoader=e,this._window=window}getGooglePaymentsClient(e=!1,t){return n=this,i=void 0,r=function*(){if(yield this._scriptLoader.loadScript("https://pay.google.com/gp/p/js/pay.js"),!this._window.google)throw new u;return void 0===this._paymentsClient&&(this._paymentsClient=new this._window.google.payments.api.PaymentsClient(Object.assign({environment:e?"TEST":"PRODUCTION"},null!=t?t:{}))),this._paymentsClient},new((o=void 0)||(o=Promise))(function(e,t){function a(e){try{c(r.next(e))}catch(e){t(e)}}function s(e){try{c(r.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(a,s)}c((r=r.apply(n,i||[])).next())});var n,i,o,r}}function ae(){return new re(n())}const se=g(o=>new oe(o,new Y(ae(),new U(o,new y(n(),i())),t(),e())),[{id:"googlepayadyenv2"}]);class ce{constructor(e,t,n=window){this._scriptLoader=e,this._stylesheetLoader=t,this._window=n}load(e){var t,n,i,o,r,a;return i=this,o=void 0,a=function*(){if(yield Promise.all([this._stylesheetLoader.loadStylesheet(`https://checkoutshopper-${null!==(t=e.environment)&&void 0!==t?t:""}.adyen.com/checkoutshopper/sdk/5.71.1/adyen.css`,{prepend:!1,attributes:{integrity:"sha384-5MvB4RnzvviA3VBT4KYABZ4HXNZG5LRqREEgd41xt/pf/QvKmsj2O9GuNuywRXx9",crossorigin:"anonymous"}}),this._scriptLoader.loadScript(`https://checkoutshopper-${null!==(n=e.environment)&&void 0!==n?n:""}.adyen.com/checkoutshopper/sdk/5.71.1/adyen.js`,{async:!0,attributes:{integrity:"sha384-yvY2yFNR4WqIjPqP9MzjI+gJimmaJnAvj4rLHKvgJbgFD5fMuf8zIJrFJOW8Lhhf",crossorigin:"anonymous"}})]),!this._window.AdyenCheckout)throw new u;return yield this._window.AdyenCheckout(e)},new((r=void 0)||(r=Promise))(function(e,t){function n(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof r?i:new r(function(e){e(i)})).then(n,s)}c((a=a.apply(i,o||[])).next())})}}var de=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class le extends F{constructor(e,t){super("adyen",e),this._scriptLoader=t,this._service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return de(this,void 0,void 0,function*(){yield i.initialize.call(this,e,t,n);const o=i.getPaymentMethod.call(this),r=this._service.getState().getStoreConfig();if(!r)throw new m(h.MissingCheckoutConfig);return this._adyenClient=yield this._scriptLoader.load({environment:o.config.testMode?"test":"live",locale:r.storeProfile.storeLanguage}),Promise.resolve()})}processAdditionalAction(e){return de(this,void 0,void 0,function*(){if(!P(e)||!p(e.body))throw e;const t=yield this._handleAction(e.body.provider_data);try{return yield this._service.submitPayment(t)}catch(e){return this.processAdditionalAction(e)}})}getNonce(e){const t=Object.create(null,{getNonce:{get:()=>super.getNonce},getPaymentMethod:{get:()=>super.getPaymentMethod}});return de(this,void 0,void 0,function*(){const n=yield t.getNonce.call(this,e),i=t.getPaymentMethod.call(this);return JSON.stringify({type:i.method,googlePayToken:n,browser_info:f()})})}_handleAction(e){return new Promise((t,n)=>{const i=JSON.parse(e.action);this._getAdyenClient().createFromAction(i,{onAdditionalDetails:e=>{const n={methodId:i.paymentMethodType,paymentData:{nonce:JSON.stringify(e.data)}};t(n)},size:"05",onError:e=>n(e)}).mount("body"),n(new w)})}_getAdyenClient(){if(!this._adyenClient)throw new _(v.PaymentNotInitialized);return this._adyenClient}}const ue=g(o=>new oe(o,new Y(ae(),new le(o,new ce(n(),i())),t(),e())),[{id:"googlepayadyenv3"}]);class he extends F{constructor(e){super("authorizenet",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,r=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((o=void 0)||(o=Promise))(function(e,t){function a(e){try{c(r.next(e))}catch(e){t(e)}}function s(e){try{c(r.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(a,s)}c((r=r.apply(n,i||[])).next())});var n,i,o,r}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return function(e){if(!function(e){return"paymentGatewayId"in e}(e))throw new m(h.MissingPaymentMethod)}(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.paymentGatewayId}}}const ye=g(n=>new oe(n,new Y(ae(),new he(n),t(),e())),[{id:"googlepayauthorizenet"}]);var ge;!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(ge||(ge={}));const pe=ge;function me(e){if(!function(e){return"checkoutcomkey"in e}(e))throw new m(h.MissingPaymentMethod)}var fe=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Pe extends F{constructor(e,t){super("checkoutltd",e),this._requestSender=t}processAdditionalAction(e){return new Promise((t,n)=>{if(P(e)&&function(e){var t;if("object"!=typeof e||null===e)return!1;const n=e;return"string"==typeof(null===(t=n.three_ds_result)||void 0===t?void 0:t.acs_url)&&"string"==typeof n.three_ds_result.code}(e.body)&&"three_d_secure_required"===e.body.three_ds_result.code)return window.location.assign(e.body.three_ds_result.acs_url);n(e)})}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return fe(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new b("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"protocolVersion"in e&&"signature"in e&&"signedMessage"in e}(e))throw new m(h.MissingPaymentToken)}(i),n.nonce=yield this._tokenize(i),n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return me(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.checkoutcomkey}}_tokenize(e){return fe(this,void 0,void 0,function*(){const t=this.getPaymentMethod().config.testMode?"https://api.sandbox.checkout.com/tokens":"https://api.checkout.com/tokens",n=this.getGooglePayInitializationData();me(n);const{body:i}=yield this._requestSender.post(t,{credentials:!1,body:{type:"googlepay",token_data:e},headers:{Authorization:n.checkoutcomkey,"Content-Type":pe.Json,"X-XSRF-TOKEN":null}});return i.token})}}const we=g(n=>{const i=t();return new oe(n,new Y(ae(),new Pe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]);class ve extends F{constructor(e){super("cybersource",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,r=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((o=void 0)||(o=Promise))(function(e,t){function a(e){try{c(r.next(e))}catch(e){t(e)}}function s(e){try{c(r.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(a,s)}c((r=r.apply(n,i||[])).next())});var n,i,o,r}}const _e=g(n=>new oe(n,new Y(ae(),new ve(n),t(),e())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]);class be extends F{constructor(e){super("chase",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,r=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((o=void 0)||(o=Promise))(function(e,t){function a(e){try{c(r.next(e))}catch(e){t(e)}}function s(e){try{c(r.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(a,s)}c((r=r.apply(n,i||[])).next())});var n,i,o,r}}const Ce=g(n=>new oe(n,new Y(ae(),new be(n),t(),e())),[{id:"googlepayorbital"}]);var Se,Ie,Oe,ke,Ae,Te,Ee,Me,De,Ne,Re,xe;!function(e){e.SHIPPING="shipping",e.BILLING="billing"}(Se||(Se={})),function(e){e.SPLIT="split",e.FULL="full",e.ORGANIZATION="organization"}(Ie||(Ie={})),function(e){e.Open="open",e.Expired="expired",e.Complete="complete"}(Oe||(Oe={})),function(e){e.Paid="paid",e.UnPaid="unpaid",e.NoPaymentRequired="no_payment_required"}(ke||(ke={})),function(e){e.SUCCESS="success",e.ERROR="error"}(Ae||(Ae={})),function(e){e.CreditCard="card",e.Link="link",e.EPS="eps",e.GRABPAY="grabpay",e.BANCONTACT="bancontact",e.IDEAL="ideal",e.ALIPAY="alipay",e.KLARNA="klarna",e.OCS="optimized_checkout",e.CHECKOUT_SESSION="checkout_session"}(Te||(Te={})),function(e){e.NEVER="never",e.AUTO="auto",e.ALWAYS="always",e.PAYMENT="payment",e.IF_REQUIRED="if_required"}(Ee||(Ee={})),function(e){e.V3="v3",e.ACACIA="acacia",e.BASIL="basil",e.CLOVER="clover"}(Me||(Me={})),function(e){e.PAYMENT="payment",e.AUTHENTICATION="linkAuthentication",e.SHIPPING="address",e.EXPRESS_CHECKOUT="expressCheckout"}(De||(De={})),function(e){e.REQUIRES_PAYMENT_METHOD="requires_payment_method",e.REQUIRES_CONFIRMATION="requires_confirmation",e.REQUIRES_ACTION="requires_action",e.PROCESSING="processing",e.SUCCEEDED="succeeded",e.CANCELED="canceled"}(Ne||(Ne={})),function(e){e.CLICK="click",e.CHANGE="change",e.READY="ready",e.SHIPPING_ADDRESS_CHANGE="shippingaddresschange",e.SHIPPING_RATE_CHANGE="shippingratechange",e.CONFIRM="confirm",e.CANCEL="cancel",e.LOADER_START="loaderstart"}(Re||(Re={})),function(e){e.ON_SESSION="on_session",e.OFF_SESSION="off_session"}(xe||(xe={}));var ze=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Ge{constructor(e,t=window){this.scriptLoader=e,this.stripeWindow=t}getStripeClient(e,t,n,i,o){return ze(this,void 0,void 0,function*(){if(this.stripeWindow.bcStripeClient)return this.stripeWindow.bcStripeClient;const r=yield this.load(n),{stripePublishableKey:a,stripeConnectedAccount:s}=e,c=r(a,Object.assign(Object.assign(Object.assign(Object.assign({},s?{stripeAccount:s}:{}),t?{locale:t}:{}),i?{betas:i}:{}),o?{apiVersion:o}:{}));return Object.assign(this.stripeWindow,{bcStripeClient:c}),c})}getElements(e,t){return ze(this,void 0,void 0,function*(){let n=this.stripeWindow.bcStripeElements;return n?yield this.updateStripeElements(t):(n=e.elements(t),Object.assign(this.stripeWindow,{bcStripeElements:n})),n})}updateStripeElements(e){return ze(this,void 0,void 0,function*(){const t=this.stripeWindow.bcStripeElements;t&&(t.update(e),yield t.fetchUpdates())})}getStripeCheckout(e,t){return ze(this,void 0,void 0,function*(){let n=yield this.getStoredStripeCheckout(t);return n||(n=yield e.initCheckout(t),Object.assign(this.stripeWindow,{bcStripeCheckout:n})),n})}load(e){return ze(this,void 0,void 0,function*(){if(!this.stripeWindow.Stripe&&(yield this.scriptLoader.loadScript(this.getScriptUrl(e)),!this.stripeWindow.Stripe))throw new u;return this.stripeWindow.Stripe})}getScriptUrl(e){return e&&e!==Me.V3?`https://js.stripe.com/${e}/stripe.js`:"https://js.stripe.com/v3/"}getStoredStripeCheckout(e){return ze(this,void 0,void 0,function*(){const t=this.stripeWindow.bcStripeCheckout;if(t)try{const{actions:n,error:i}=yield t.loadActions();if(i||!n)return void this.logErrorToConsole(i);const o=yield n.getSession(),r=e.clientSecret.split("_secret_")[0];if((null==o?void 0:o.id)===r)return t}catch(e){return void this.logErrorToConsole(e)}})}logErrorToConsole(e){e?console.error(e):console.error("No stripe checkout actions available on loadActions().")}}const Be={body:{},headers:{},status:0};class je extends l{constructor(e,{message:t,errors:n}={}){const{body:i,headers:o,status:r}=e||Be;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=i,this.headers=o,this.status=r,this.errors=n||[]}}const Le=["payment_element_beta_2","alipay_pm_beta_1","link_default_integration_beta_1","shipping_address_element_beta_1","address_element_beta_1"];function Fe(e){if(!function(e){return"stripeConnectedAccount"in e&&"stripePublishableKey"in e&&"stripeVersion"in e}(e))throw new m(h.MissingPaymentMethod)}var Ve=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Ue extends F{constructor(e,t){super("stripe",e),this.paymentIntegrationService=e,this.scriptLoader=t}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return Ve(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new b("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"id"in e}(e))throw new m(h.MissingPaymentToken)}(i),n.nonce=i.id,n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();Fe(e);const{stripeVersion:t,stripePublishableKey:n,stripeConnectedAccount:i}=e;return{gateway:this.getGatewayIdentifier(),"stripe:version":t,"stripe:publishableKey":`${n}/${i}`}}processAdditionalAction(e,t){var n;return Ve(this,void 0,void 0,function*(){if(!t)throw new J(["payment"]);if(!P(e)||("object"!=typeof(i=e.body)||null===i||!("three_ds_result"in i)||!("errors"in i)))throw e;var i;if(d(e.body.errors,{code:"three_d_secure_required"})){const i=this.getGooglePayInitializationData();Fe(i),this.stripeUPEClient=yield this.loadStripeJs(i,t);const o=e.body.three_ds_result.token;let r,a=!1;try{r=yield this.stripeUPEClient.confirmCardPayment(o)}catch(e){try{r=yield this.stripeUPEClient.retrievePaymentIntent(o)}catch(e){a=!0}}if(null==r?void 0:r.error){if(this._throwDisplayableStripeError(r.error),this._isCancellationError(r.error))throw new w;throw new W}if(!(null==r?void 0:r.paymentIntent)&&!a)throw new je;return this.paymentIntegrationService.submitPayment({methodId:t,paymentData:{nonce:(null===(n=null==r?void 0:r.paymentIntent)||void 0===n?void 0:n.id)||o}})}throw e})}loadStripeJs(e,t){return Ve(this,void 0,void 0,function*(){if(this.stripeUPEClient)return this.stripeUPEClient;const n=this.paymentIntegrationService.getState().getCartLocale();return"googlepaystripeocs"===t&&e.useNewStripeJsVersion?this.scriptLoader.getStripeClient(e,n,Me.CLOVER):this.scriptLoader.getStripeClient(e,n,Me.V3,Le,"2020-03-02;alipay_beta=v1;link_beta=v1")})}_isCancellationError(e){var t,n;return e&&-1!==(null===(n=null===(t=e.payment_intent.last_payment_error)||void 0===t?void 0:t.message)||void 0===n?void 0:n.indexOf("canceled"))}_throwDisplayableStripeError(e){if(r(["card_error","invalid_request_error","validation_error"],e.type))throw new Error(e.message)}}const qe=g(i=>new oe(i,new Y(ae(),new Ue(i,new Ge(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]);class We extends F{constructor(e){super("worldpay",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,r=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((o=void 0)||(o=Promise))(function(e,t){function a(e){try{c(r.next(e))}catch(e){t(e)}}function s(e){try{c(r.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o(function(e){e(n)})).then(a,s)}c((r=r.apply(n,i||[])).next())});var n,i,o,r}}const He=g(n=>new oe(n,new Y(ae(),new We(n),t(),e())),[{id:"googlepayworldpayaccess"}]),Ye="3.128.0",Je="3.123.2",Ke="3.106.0";class Ze{constructor(e){this.paymentIntegrationService=e,this.braintreeWindow=window}getSDKVersion(){const e=this.paymentIntegrationService.getState().getStoreConfig(),t=(null==e?void 0:e.checkoutSettings.features)||{};return this.getPreloadedSDKVersion()||(T(t,"PAYPAL-5809.braintree_hosted_fields_fix_version")?Ye:T(t,"PAYPAL-5636.update_braintree_sdk_version")?Je:Ke)}getPreloadedSDKVersion(){const e=this.braintreeWindow.braintree;if(e){const t=o(Object.values(e),e=>!!e.VERSION);return null==t?void 0:t.VERSION}}}class Xe extends l{constructor(e){super(e||"Unsupported browser error"),this.name="UnsupportedBrowserError",this.type="unsupported_browser"}}var Qe,$e,et,tt,nt,it,ot;!function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(Qe||(Qe={})),function(e){e.Completed="COMPLETED",e.Pending="PENDING",e.Failed="FAILED"}($e||($e={})),function(e){e.TRUSTLY="trustly"}(et||(et={})),function(e){e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="cancelled",e.UNRECOGNIZED="unrecognized"}(tt||(tt={})),function(e){e.Customer="CUSTOMER",e.Merchant="MERCHANT",e.Network="NETWORK",e.Internal="INTERNAL",e.Unknown="UNKNOWN"}(nt||(nt={})),function(e){e.KountNotEnabled="DATA_COLLECTOR_KOUNT_NOT_ENABLED"}(it||(it={})),function(e){e.Visa="visa",e.Mastercard="mastercard",e.AmericanExpress="american-express",e.DinersClub="diners-club",e.Discover="discover",e.Jcb="jcb",e.UnionPay="union-pay",e.Maestro="maestro",e.Elo="elo",e.Mir="mir",e.Hiper="hiper",e.Hipercard="hipercard"}(ot||(ot={}));var rt,at,st,ct=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class dt{constructor(e){this.braintreeScriptLoader=e}initialize(e){this.setClientToken(e)}deinitialize(){return ct(this,void 0,void 0,function*(){yield this.teardownModule(this.dataCollector),this.dataCollector=void 0})}getClient(){return ct(this,void 0,void 0,function*(){if(!this.client){const e=this.getClientTokenOrThrow(),t=yield this.braintreeScriptLoader.loadClient();this.client=yield t.create({authorization:e})}return this.client})}getDataCollectorOrThrow(e){return ct(this,void 0,void 0,function*(){const t={deviceData:void 0,teardown:()=>Promise.resolve()};if(!this.dataCollector)try{const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadDataCollector(),i=Object.assign({client:t,kount:!0},e);this.dataCollector=yield n.create(i)}catch(e){if(function(e){return Boolean("object"==typeof e&&null!==e&&("type"in e||"message"in e||"code"in e))}(e)&&e.code===it.KountNotEnabled)return t;throw e}return this.dataCollector})}getBraintreeGooglePayment(){return ct(this,void 0,void 0,function*(){if(!this.googlePayment){const[e,t]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadGooglePayment()]);this.googlePayment=yield t.create({client:e})}return this.googlePayment})}getBraintreeThreeDS(){return ct(this,void 0,void 0,function*(){if(!this.threeDS){const[e,t]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()]);this.threeDS=yield t.create({client:e,version:2})}return this.threeDS})}getBraintreeLocalPayment(e){return ct(this,void 0,void 0,function*(){if(!this.braintreeLocalPayment){const[t,n]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadLocalPayment()]);this.braintreeLocalPayment=yield new Promise((i,o)=>{n.create({client:t,merchantAccountId:e},(e,t)=>{e&&o(e),i(t)})})}return this.braintreeLocalPayment})}getUsBankAccount(){return ct(this,void 0,void 0,function*(){if(!this.usBankAccount){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadUsBankAccount();this.usBankAccount=yield t.create({client:e})}return this.usBankAccount})}getBraintreeVisaCheckout(){return this.visaCheckout||(this.visaCheckout=Promise.all([this.getClient(),this.braintreeScriptLoader.loadVisaCheckout()]).then(([e,t])=>t.create({client:e}))),this.visaCheckout}getVisaCheckoutSdk(e){return ct(this,void 0,void 0,function*(){return this.visaCheckoutSDK||(this.visaCheckoutSDK=yield this.braintreeScriptLoader.loadVisaCheckoutSdk(e)),this.visaCheckoutSDK})}getVenmoCheckoutOrThrow(){return ct(this,void 0,void 0,function*(){if(!this.braintreeVenmo){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadVenmoCheckout(),n={client:e,allowDesktop:!0,paymentMethodUsage:"multi_use"},i=yield t.create(n);if(!i.isBrowserSupported())throw new Xe;this.braintreeVenmo=i}return this.braintreeVenmo})}setClientToken(e){this.clientToken=e}getClientTokenOrThrow(){if(!this.clientToken)throw new _(v.PaymentNotInitialized);return this.clientToken}teardownModule(e){return e?e.teardown():Promise.resolve()}}!function(e){e.Sandbox="sandbox",e.Production="production"}(rt||(rt={})),function(e){e.Client="client",e.DataCollector="dataCollector",e.Fastlane="fastlane",e.GooglePayment="googlePayment",e.HostedFields="hostedFields",e.LocalPayment="localPayment",e.Paypal="paypal",e.PaypalCheckout="paypalCheckout",e.ThreeDSecure="threeDSecure",e.UsBankAccount="usBankAccount",e.Venmo="venmo",e.VisaCheckout="visaCheckout"}(at||(at={})),function(e){e.CardCode="cardCode",e.CardCodeVerification="cardCodeVerification",e.CardExpiry="cardExpiry",e.CardName="cardName",e.CardNumber="cardNumber",e.CardNumberVerification="cardNumberVerification"}(st||(st={}));const lt={[Ke]:{[at.Client]:"sha384-26BXDNnJI23JYRyFBj4xe4sVNrUSSiSSu11kxVXNM/vEPONm4LuL00w6ZaTgQewt",[at.PaypalCheckout]:"sha384-B+vzbZwnQtzWBthpkT4TXKUibO65tyeK7eCxSvpblgprTep2+IAXB2Cxxjrn710O",[at.Paypal]:"sha384-uyAGL1/3+XJAHnGoNy4eCoXdzJ4f7Ilzp+6w9PNnEjs6DCCz9WMyJjMN1gzc78U+",[at.LocalPayment]:"sha384-LIvOEMkIVEwVuYBdVOQc1AC5YbGGlwyfUheS0ACK218D2STuVYQlZ4FyEPowAEfT",[at.DataCollector]:"sha384-1bo9JDz+Kscthc085cCKWur8CLwUoBpoNyxsDi7932mCl0zFq3A5mv+FQLw9GHpV",[at.UsBankAccount]:"sha384-xmHBVaU+w74V+OebD3AaPONFxHUGMf+QRs8G/JxVPXNNP7MDa2jL0ICWHIe2tTfJ",[at.GooglePayment]:"sha384-WKDJl8mqoP82qZpMGH6AbZxnvXnSW8ILV4M64CyMLiugGMwu7LyP89wjCkHqsiBe",[at.ThreeDSecure]:"sha384-VQUlpGHzsGvs5XeiGFip7EXRsvoHWEXDVmgCacfbyieZI9mdBOqq3NSoyo28OCOB",[at.VisaCheckout]:"sha384-yx7mADfzTN0T43Q6rlH49LIg1EJ0iUZgBp/EczX9LXsUGkySgxrD+nWHQRBkyfoT",[at.Venmo]:"sha384-QX4rPjoj1ZDhuG0aSyKs56lEKDqTMTcjYxUHY1SzO5VZDsqIE2NTkqot7KNSCyov",[at.HostedFields]:"sha384-VvYBACfSu0Cr/J32uKmxG7AXcNOJE1AzIIL3kbikyS7YKp5fz5Is+NzNP/lyauNy",[at.Fastlane]:"sha384-9oGsZMRZwpGtDEDYa/dFt76dECqj1xAni9gIKgc3KfMIiRnR73nEeeUDLiBzxhFa"},[Je]:{[at.Client]:"sha384-o+nbQGcwNNxIBeXeu3+XmbSq+Cg8R3EN3N0l5hXCgMMU2RGY0t1z0LroSEIAbfAO",[at.PaypalCheckout]:"sha384-WrfbWPBS4mH86GAoycPSgiH8hQ8KH7A67C93Hjhunv/xhNk2YpBn3wbFA4Fhg9U/",[at.Paypal]:"sha384-VF389nvvrRUgDsTXMxTYORDtVegB9IQa3Cxr//DyJnLYnz8/X8VCzEvck2c+Megt",[at.LocalPayment]:"sha384-tZKx2rEQbfmZpoPSY5VPmJEhaq4X75dLvwHMs3VE9U+C8lPyw+hWTIL1+GPvWCIH",[at.DataCollector]:"sha384-E6k3wOpP7syCDDwaRDLF06942Y00NkbwJvWi2OQXwwKzGwG5fd3E7RFUvCCecfvO",[at.UsBankAccount]:"sha384-258FON8LZGG0W9Qaz4Jij83pZHu30YnKjJA7gNulLBh6CclkucgF+tHDQuYFRYfW",[at.GooglePayment]:"sha384-taJ2p/0+n0VH328POAoBiuEbL3tnHUTE9S42hK1V+Txs3X+QYjZOyKW35JgHRFfO",[at.ThreeDSecure]:"sha384-+NSZH4Zj3sO5bdWvPKhU5N16QDxeueTVTnUVeleeESkhLSaz4Ob1hh/5myecc9Ym",[at.VisaCheckout]:"sha384-66DiBjghxk1OmBj8aksN8gbQ+CwoQcx1vPfiXUN08g1iQVM+BwewF0p7toM3i7SS",[at.Venmo]:"sha384-B5UwY42kE4RoLoWbQ7YpqosUlUad2/DlGWiw0HhoZbSPk30CQAaSA10ohyLDTkDU",[at.HostedFields]:"sha384-Aw9EesSaUeWxe36PqEHiOyOyOq8M6CIb1gw7/yHNVPRzGtFXXcd2OQ8qXrIlOj2P",[at.Fastlane]:"sha384-rhBL1hpZ71JqG+2TsT0Dih47mbjx8cjJCpeZjk9tw3df1gFMKfCTmMyZunhr7H4Y"},[Ye]:{[at.Client]:"sha384-0WNxksIpRP+fYZiIdr12g6DBUQfLDzYCQJZtR/C8KkcwSGhPHfcFp3tTaGcMyFTq",[at.PaypalCheckout]:"sha384-lWM1jk4BOxoDNV6Kop7tVNvQgINlmEVz0c/OwM+HNHK3QC8xqwd54Ovrt2QRDTjh",[at.Paypal]:"sha384-fXUmVxC2EMZBDXZ7eTHSTL/LFBrHej/MSXT/vTBXvra4lzgLNGvREAp+x0GYObuH",[at.LocalPayment]:"sha384-pha1xGuGSkmZH5x9aqHvRaO4xLea7rmQ/79PFj9zxNzxuFcOWZg7gOP7FibygOEC",[at.DataCollector]:"sha384-Q6PI2F9eekWbAxhroybl+aEcvqhdowN/EQlGwBUyJOzPFn9982u9xl6SU6XfGKzc",[at.UsBankAccount]:"sha384-W3RLQSKJL1tQ3+Y7mP6tmkamtZ8bV4Yw/XxL9Jj5JtXHraD8loMF8hAIG5m2zK7F",[at.GooglePayment]:"sha384-TITQMsFWA3elDNGP2mWz2oKBo4qjt+TlqzovcaPoeBiAh/wPBi6nae50ADdgU1/i",[at.ThreeDSecure]:"sha384-YiycYN89ZlL/Evcaq4y1ajW1mhd7JYfZBDuOwHtIn4/Jnm20GL+/XCM+zYAwWD8D",[at.VisaCheckout]:"sha384-/OdaTv9qrkKzjObtUe6yzfDhHozFW/+uXlrSl736sOZRJpjGQETvpYXqMFFg69xv",[at.Venmo]:"sha384-dA+ojdW9vbJS4JavcXyOs9d5uZHJg5dNtYupoPSH2zsXIiYDVS5amLb/u8qmQ6oz",[at.HostedFields]:"sha384-31ZkS58+iaWsW06ftW52zzVZFp43WPd7pNYRiddYynSNg6Oh7WGbSFGorAUH6T1z",[at.Fastlane]:"sha384-jlbrwNvL3HvLAUCtLSmrnQ2GH1udCUrRS/bVmReAS5fuIVvcW8Pko/Gkg82tlgtr"}};var ut=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class ht{constructor(e,t,n){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSDKVersionManager=n}loadClient(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.Client,"client.min.js")})}loadFastlane(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.Fastlane,"fastlane.min.js")})}loadPaypalCheckout(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.PaypalCheckout,"paypal-checkout.min.js")})}loadPaypal(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.Paypal,"paypal.min.js")})}loadLocalPayment(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.LocalPayment,"local-payment.min.js")})}loadDataCollector(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.DataCollector,"data-collector.min.js")})}loadUsBankAccount(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.UsBankAccount,"us-bank-account.min.js")})}loadGooglePayment(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.GooglePayment,"google-payment.min.js")})}load3DS(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.ThreeDSecure,"three-d-secure.min.js")})}loadVisaCheckout(){return this.loadBraintreeModuleOrThrow(at.VisaCheckout,"visa-checkout.min.js")}loadVenmoCheckout(){return this.loadBraintreeModuleOrThrow(at.Venmo,"venmo.min.js")}loadHostedFields(){return ut(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.HostedFields,"hosted-fields.min.js")})}loadVisaCheckoutSdk(e){return ut(this,void 0,void 0,function*(){if(this.braintreeHostWindow.V)return this.braintreeHostWindow.V;const t=e?"sha384-0eu1s1GtqzXlL9DtLgmwzC5WWlEH/ADRM0n38cVQkvtT+W/gey96rcb1LwuUOPDm":"sha384-1f1csvP3ZFxg4dILH1GaY4LHlZ0oX7Rk83rxmLlwbnIi4TM0NYzXoev1VoEiVDS6";return this.scriptLoader.loadScript(`//${e?"sandbox-":""}assets.secure.checkout.visa.com/checkout-widget/resources/js/integration/v1/sdk.js`,{async:!0,attributes:{integrity:t,crossorigin:"anonymous"}}).then(()=>{if(!this.braintreeHostWindow.V)throw new u;return this.braintreeHostWindow.V})})}loadBraintreeModuleOrThrow(e,t){return ut(this,void 0,void 0,function*(){let n=this.getBraintreeModule(e);if(n)return n;const i=this.braintreeSDKVersionManager.getSDKVersion(),o=`//js.braintreegateway.com/web/${i}/js/${t}`,r=i in lt?this.getIntegrityValuesByModuleName(e,i):void 0;if(yield this.scriptLoader.loadScript(o,r?{async:!0,attributes:{integrity:r,crossorigin:"anonymous"}}:void 0),n=this.getBraintreeModule(e),!n)throw new u;return n})}getBraintreeModule(e){var t;return null===(t=this.braintreeHostWindow.braintree)||void 0===t?void 0:t[e]}getIntegrityValuesByModuleName(e,t){const n=lt[t][e];if(!n)throw new Error("Unexpected fileName value");return n}}class yt{constructor(e){const t=new Promise((e,t)=>{this.cancel=t});this.promise=Promise.race([e,t])}}var gt=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class pt extends F{constructor(e,t){super("braintree",e),this._braintreeSdk=t,this._methodId=te.BRAINTREE,this._service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return gt(this,void 0,void 0,function*(){yield i.initialize.call(this,e,t,n);let o=i.getPaymentMethod.call(this);if(o.clientToken||(o=(yield this._service.loadPaymentMethod(this._methodId)).getPaymentMethodOrThrow(this._methodId)),!o.clientToken||!o.initializationData)throw new m(h.MissingPaymentMethod);return this._braintreeSdk.initialize(o.clientToken),this._braintreeGooglePayment=yield this._braintreeSdk.getBraintreeGooglePayment(),Promise.resolve()})}getNonce(e){const t=Object.create(null,{getNonce:{get:()=>super.getNonce},getPaymentMethod:{get:()=>super.getPaymentMethod}});var n;return gt(this,void 0,void 0,function*(){const i=yield t.getNonce.call(this,e),{clientToken:o,initializationData:r}=t.getPaymentMethod.call(this);if(!o||!r||!(null===(n=r.card_information)||void 0===n?void 0:n.bin))throw new m(h.MissingPaymentMethod);const{isThreeDSecureEnabled:a,card_information:{bin:s,isNetworkTokenized:c}}=r;if(a&&!c){const e=yield this._braintreeSdk.getBraintreeThreeDS(),{orderAmount:t}=this._service.getState().getOrderOrThrow();return(yield this._braintreePresent3DSChallenge(e,t,i,s)).nonce}return i})}extraPaymentData(){return gt(this,void 0,void 0,function*(){return{deviceSessionId:yield this._getBraintreeDeviceData()}})}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return gt(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new b("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"androidPayCards"in e}(e))throw new m(h.MissingPaymentToken)}(i),n.nonce=i.androidPayCards[0].nonce,n.card_information.bin=i.androidPayCards[0].details.bin,n.card_information.isNetworkTokenized=i.androidPayCards[0].details.isNetworkTokenized,n})}getCardParameters(){return super.getCardParameters()}getPaymentGatewayParameters(){const e=Object.create(null,{getMerchantInfo:{get:()=>super.getMerchantInfo},getTransactionInfo:{get:()=>super.getTransactionInfo},getRequiredData:{get:()=>super.getRequiredData}});return gt(this,void 0,void 0,function*(){return this.getBraintreeGooglePayment().createPaymentDataRequest(Object.assign({merchantInfo:e.getMerchantInfo.call(this),transactionInfo:e.getTransactionInfo.call(this),cardRequirements:{billingAddressRequired:!0,billingAddressFormat:"FULL"}},yield e.getRequiredData.call(this))).paymentMethodTokenizationParameters.parameters})}getBraintreeGooglePayment(){if(!this._braintreeGooglePayment)throw new m(h.MissingPaymentMethod);return this._braintreeGooglePayment}_getBraintreeDeviceData(){return gt(this,void 0,void 0,function*(){const{deviceData:e}=yield this._braintreeSdk.getDataCollectorOrThrow();return e})}_braintreePresent3DSChallenge(e,t,n,i){return new yt(e.verifyCard({amount:t,bin:i,nonce:n,onLookupComplete:(e,t)=>{t()}})).promise}}const mt=g(i=>{const o=t(),r=window,a=new Ze(i),s=new dt(new ht(n(),r,a));return new oe(i,new Y(ae(),new pt(i,s),o,e()))},[{id:"googlepaybraintree"}]);var ft=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Pt{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n){return ft(this,void 0,void 0,function*(){if(!this.window.paypalFastlaneSdk){const i=this.getPayPalFastlaneSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.paypalFastlaneSdk)throw new u}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i){return ft(this,void 0,void 0,function*(){if(!this.window.paypalGooglePay||i){const i=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.paypalGooglePay)throw new u;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t){return ft(this,void 0,void 0,function*(){if(!this.window.paypalApms){const n=this.getPayPalApmSdkConfiguration(e,t);if(yield this.loadPayPalSdk(n),!this.window.paypalApms)throw new u}return this.window.paypalApms})}getPayPalMessages(e,t){return ft(this,void 0,void 0,function*(){if(!this.window.paypalMessages){const n=this.getPayPalSdkMessagesConfiguration(e,t);yield this.loadPayPalSdk(n)}if(!this.window.paypalMessages)throw new u;return this.window.paypalMessages})}loadPayPalSdk({options:e,attributes:t}){return ft(this,void 0,void 0,function*(){const n=this.transformConfig(e),i=this.transformConfig(t),o=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(o,{async:!0,attributes:i})})}getPayPalFastlaneSdkConfiguration(e,t,n){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new m(h.MissingPaymentMethod);const{intent:r,clientId:a,merchantId:s,attributionId:c}=o;return{options:{"client-id":a,"merchant-id":s,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t,intent:r},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":i}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n=!0){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new m(h.MissingPaymentMethod);const{intent:r,clientId:a,merchantId:s,buyerCountry:c,attributionId:d,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:u}=o,y=l||n;return{options:Object.assign({"client-id":a,"merchant-id":s,commit:y,components:["googlepay"],currency:t,intent:r},u&&{"buyer-country":c}),attributes:{"data-partner-attribution-id":d,"data-client-token":i,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new m(h.MissingPaymentMethod);const{intent:i,clientId:o,merchantId:r,buyerCountry:a,attributionId:s,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:d=[],enabledAlternativePaymentMethods:l=[]}=n,u=l,y=d.filter(e=>!l.includes(e));return{options:Object.assign({"client-id":o,"merchant-id":r,"enable-funding":u.length>0?u:void 0,"disable-funding":y.length>0?y:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:i},c&&{"buyer-country":a}),attributes:{"data-partner-attribution-id":s,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new m(h.MissingPaymentMethod);const{clientId:i,merchantId:o,attributionId:r,isDeveloperModeApplicable:a,buyerCountry:s}=n;return{options:Object.assign({"client-id":i,"merchant-id":o,components:["messages"],currency:t},a&&{"buyer-country":s}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":r}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}function wt(e){if(!function(e){return!!e.initializationData&&"attributionId"in e.initializationData&&"isVenmoEnabled"in e.initializationData&&"isGooglePayEnabled"in e.initializationData&&"isPayPalCreditAvailable"in e.initializationData}(e))throw new m(h.MissingPaymentMethod)}var vt=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class _t extends F{constructor(e,t){super("paypalsb",e),this.payPalCommerceSdk=t,this.service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});var o,r,a,s,c;return vt(this,void 0,void 0,function*(){const d=null!==(r=null===(o=this.service.getState().getStoreConfig())||void 0===o?void 0:o.currency.code)&&void 0!==r?r:n;if(!d)throw new m(h.MissingPaymentMethod);yield i.initialize.call(this,e,t,d);const l=i.getPaymentMethod.call(this);if(!l.initializationData)throw new m(h.MissingPaymentMethod);wt(l);const u=yield this.payPalCommerceSdk.getPayPalGooglePaySdk(l,d);this.googlepayConfig=yield u.Googlepay().config();const{allowedPaymentMethods:y}=this.googlepayConfig;this.setGatewayIdentifier(null===(c=null===(s=null===(a=y[0])||void 0===a?void 0:a.tokenizationSpecification)||void 0===s?void 0:s.parameters)||void 0===c?void 0:c.gateway)})}getPaymentGatewayParameters(){if(this.googlepayConfig){const{allowedPaymentMethods:e}=this.googlepayConfig,{gatewayMerchantId:t}=e[0].tokenizationSpecification.parameters;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:t}}return{gateway:this.getGatewayIdentifier()}}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return vt(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n})}}const bt="This API endpoint is for internal use only and may change in the future";var Ct,St;!function(e){e.Approved="APPROVED",e.PayerActionRequired="PAYER_ACTION_REQUIRED"}(Ct||(Ct={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(St||(St={}));var It=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Ot extends oe{constructor(e,t,n,i){super(e,t),this._payPalCommerceSdk=n,this._requestSender=i}execute({payment:e}){return It(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId))throw new J(["payment"]);const t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow().id,{initializationData:i}=t.getPaymentMethodOrThrow(this._getMethodId()),{orderId:o}=yield this.getOrderId(n),{card_information:r}=i||{},a=yield this._googlePayPaymentProcessor.getNonce(e.methodId),s={tokenizationData:{type:"PAYMENT_GATEWAY",token:atob(a)},info:{cardNetwork:(null==r?void 0:r.type)||"",cardDetails:(null==r?void 0:r.number)||""},type:"CARD"};yield this.confirmOrder(o,s),yield this._paymentIntegrationService.submitOrder();try{const t={formattedPayload:{method_id:e.methodId,paypal_account:{order_id:o}}};yield this._paymentIntegrationService.submitPayment({methodId:e.methodId,paymentData:t})}catch(e){yield this._googlePayPaymentProcessor.processAdditionalAction(e)}})}confirmOrder(e,t){return It(this,void 0,void 0,function*(){const n=this._paymentIntegrationService.getState(),i=n.getPaymentMethodOrThrow(this._getMethodId());if(!i.initializationData)throw new m(h.MissingPaymentMethod);const o=n.getCartOrThrow().currency.code,r=yield this._payPalCommerceSdk.getPayPalGooglePaySdk(i,o,!0),{status:a}=yield r.Googlepay().confirmOrder({orderId:e,paymentMethodData:t});if(a===Ct.PayerActionRequired)return yield r.Googlepay().initiatePayerAction({orderId:e}),Promise.resolve();if(a!==Ct.Approved)throw new b("Payment is not approved.");return Promise.resolve()})}getOrderId(e){return It(this,void 0,void 0,function*(){const t={cartId:e,shouldSaveInstrument:!1},{body:n}=yield this._requestSender.post("/api/storefront/payments/googlepaypaypalcommercecheckout",{headers:Object.assign({"X-API-INTERNAL":bt,"Content-Type":pe.Json},q),body:t});return n})}}const kt=g(i=>{const o=new Pt(n());return new Ot(i,new Y(ae(),new _t(i,o),t(),e()),o,t())},[{id:"googlepaypaypalcommerce"}]);var At=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Tt{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n){return At(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsFastlaneSdk){const i=this.getPayPalFastlaneSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.bigCommercePaymentsFastlaneSdk)throw new u}return this.window.bigCommercePaymentsFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i){return At(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsGooglePay||i){const i=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.bigCommercePaymentsGooglePay)throw new u;return this.window.bigCommercePaymentsGooglePay})}getPayPalApmsSdk(e,t){return At(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsApms){const n=this.getPayPalApmSdkConfiguration(e,t);if(yield this.loadPayPalSdk(n),!this.window.bigCommercePaymentsApms)throw new u}return this.window.bigCommercePaymentsApms})}getPayPalMessages(e,t){return At(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsMessages){const n=this.getPayPalSdkMessagesConfiguration(e,t);yield this.loadPayPalSdk(n)}if(!this.window.bigCommercePaymentsMessages)throw new u;return this.window.bigCommercePaymentsMessages})}loadPayPalSdk({options:e,attributes:t}){return At(this,void 0,void 0,function*(){const n=this.transformConfig(e),i=this.transformConfig(t),o=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(o,{async:!0,attributes:i})})}getPayPalFastlaneSdkConfiguration(e,t,n){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new m(h.MissingPaymentMethod);const{intent:r,clientId:a,merchantId:s,attributionId:c}=o;return{options:{"client-id":a,"merchant-id":s,commit:!0,components:["fastlane","three-domain-secure"],currency:t,intent:r},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"bigCommercePaymentsFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":i}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n=!0){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new m(h.MissingPaymentMethod);const{intent:r,clientId:a,merchantId:s,buyerCountry:c,attributionId:d,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:u}=o,y=l||n;return{options:Object.assign({"client-id":a,"merchant-id":s,commit:y,components:["googlepay"],currency:t,intent:r},u&&{"buyer-country":c}),attributes:{"data-partner-attribution-id":d,"data-client-token":i,"data-namespace":"bigCommercePaymentsGooglePay"}}}getPayPalApmSdkConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new m(h.MissingPaymentMethod);const{intent:i,clientId:o,merchantId:r,buyerCountry:a,attributionId:s,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:d=[],enabledAlternativePaymentMethods:l=[]}=n,u=this.filterFundingOptions(l),y=this.filterFundingOptions(d.filter(e=>!l.includes(e)));return{options:Object.assign({"client-id":o,"merchant-id":r,"enable-funding":u.length>0?u:void 0,"disable-funding":y.length>0?y:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:i},c&&{"buyer-country":a}),attributes:{"data-partner-attribution-id":s,"data-namespace":"bigCommercePaymentsApms"}}}getPayPalSdkMessagesConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new m(h.MissingPaymentMethod);const{clientId:i,merchantId:o,attributionId:r,isDeveloperModeApplicable:a,buyerCountry:s}=n;return{options:Object.assign({"client-id":i,"merchant-id":o,components:["messages"],currency:t},a&&{"buyer-country":s}),attributes:{"data-namespace":"bigCommercePaymentsMessages","data-partner-attribution-id":r}}}filterFundingOptions(e){const t=["klarna","afterpay"];return e?e.filter(e=>!t.includes(e)):[]}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}var Et,Mt,Dt=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Nt extends F{constructor(e,t){super("googlepay_bigcommerce_payments",e),this.payPalSdkHelper=t,this.service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});var o,r,a,s,c;return Dt(this,void 0,void 0,function*(){const d=null!==(r=null===(o=this.service.getState().getStoreConfig())||void 0===o?void 0:o.currency.code)&&void 0!==r?r:n;if(!d)throw new m(h.MissingPaymentMethod);yield i.initialize.call(this,e,t,d);const l=i.getPaymentMethod.call(this);if(!l.initializationData)throw new m(h.MissingPaymentMethod);wt(l);const u=yield this.payPalSdkHelper.getPayPalGooglePaySdk(l,d);this.googlepayConfig=yield u.Googlepay().config();const{allowedPaymentMethods:y}=this.googlepayConfig;this.setGatewayIdentifier(null===(c=null===(s=null===(a=y[0])||void 0===a?void 0:a.tokenizationSpecification)||void 0===s?void 0:s.parameters)||void 0===c?void 0:c.gateway)})}getPaymentGatewayParameters(){if(this.googlepayConfig){const{allowedPaymentMethods:e}=this.googlepayConfig,{gatewayMerchantId:t}=e[0].tokenizationSpecification.parameters;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:t}}return{gateway:this.getGatewayIdentifier()}}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return Dt(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n})}}!function(e){e.Approved="APPROVED",e.PayerActionRequired="PAYER_ACTION_REQUIRED"}(Et||(Et={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(Mt||(Mt={}));var Rt=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class xt extends oe{constructor(e,t,n,i){super(e,t),this._payPalSdkHelper=n,this._requestSender=i}execute({payment:e}){return Rt(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId))throw new J(["payment"]);const t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow().id,{initializationData:i}=t.getPaymentMethodOrThrow(this._getMethodId()),{orderId:o}=yield this.getOrderId(n),{card_information:r}=i||{},a=yield this._googlePayPaymentProcessor.getNonce(e.methodId),s={tokenizationData:{type:"PAYMENT_GATEWAY",token:atob(a)},info:{cardNetwork:(null==r?void 0:r.type)||"",cardDetails:(null==r?void 0:r.number)||""},type:"CARD"};yield this.confirmOrder(o,s),yield this._paymentIntegrationService.submitOrder();try{const t={formattedPayload:{method_id:e.methodId,paypal_account:{order_id:o}}};yield this._paymentIntegrationService.submitPayment({methodId:e.methodId,paymentData:t})}catch(e){yield this._googlePayPaymentProcessor.processAdditionalAction(e)}})}confirmOrder(e,t){return Rt(this,void 0,void 0,function*(){const n=this._paymentIntegrationService.getState(),i=n.getPaymentMethodOrThrow(this._getMethodId());if(!i.initializationData)throw new m(h.MissingPaymentMethod);const o=n.getCartOrThrow().currency.code,r=yield this._payPalSdkHelper.getPayPalGooglePaySdk(i,o,!0),{status:a}=yield r.Googlepay().confirmOrder({orderId:e,paymentMethodData:t});if(a===Et.PayerActionRequired)return yield r.Googlepay().initiatePayerAction({orderId:e}),Promise.resolve();if(a!==Et.Approved)throw new b("Payment is not approved.");return Promise.resolve()})}getOrderId(e){return Rt(this,void 0,void 0,function*(){const t={cartId:e,shouldSaveInstrument:!1},{body:n}=yield this._requestSender.post("/api/storefront/payments/googlepay_bigcommerce_paymentscheckout",{headers:Object.assign({"X-API-INTERNAL":bt,"Content-Type":pe.Json},q),body:t});return n})}}const zt=g(i=>{const o=new Tt(n());return new xt(i,new Y(ae(),new Nt(i,o),t(),e()),o,t())},[{id:"googlepay_bigcommerce_payments"}]);var Gt=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Bt extends F{constructor(e,t){super("worldlinena",e),this.formPoster=t}extraPaymentData(){return Gt(this,void 0,void 0,function*(){return Promise.resolve({browser_info:f()})})}processAdditionalAction(e){return Gt(this,void 0,void 0,function*(){if(!function(e){return P(e)&&(t=e.body,s(t)&&"object"==typeof t&&"errors"in t&&"three_ds_result"in t&&a(t.errors)&&d(t.errors,{code:"three_d_secure_required"}));var t}(e))throw e;const{three_ds_result:t}=e.body,{acs_url:n,payer_auth_request:i,merchant_data:o}=t||{};if(!n||!i||!o)throw new J(["formUrl","threeDSSessionData","creq"]);return new Promise(e=>{this.formPoster.postForm(n,{threeDSSessionData:i,creq:o},e,"_top")})})}}const jt=g(n=>new oe(n,new Y(ae(),new Bt(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);class Lt extends l{constructor(e){super(e||"Not implemented."),this.name="NotImplementedError",this.type="not_implemented"}}var Ft=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Vt{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){var t,n;return Ft(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId)||!ne(e.methodId))throw new b('Unable to proceed because "methodId" is not a valid key.');this._methodId=e.methodId;const i=e[this._getMethodId()];if(!i)throw new b("Unable to proceed without valid options.");let o,r=this._paymentIntegrationService.getState();try{o=r.getPaymentMethodOrThrow(this._getMethodId())}catch(e){r=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodId()),o=r.getPaymentMethodOrThrow(this._getMethodId())}try{this._googlePayPaymentProcessor.setIsWebViewExperimentOn(!!(null===(t=o.initializationData)||void 0===t?void 0:t.isWebViewExperimentOn)),yield this._googlePayPaymentProcessor.initialize(()=>o,this._getGooglePayClientOptions(null===(n=o.initializationData)||void 0===n?void 0:n.storeCountry))}catch(e){return}this._addPaymentButton(i)})}signIn(){return Promise.reject(new Lt('In order to sign in via Google Pay, the shopper must click on "Google Pay" button.'))}signOut(){var e;return Ft(this,void 0,void 0,function*(){const t=null===(e=this._paymentIntegrationService.getState().getPaymentId())||void 0===e?void 0:e.providerId;t&&(yield this._googlePayPaymentProcessor.signOut(t))})}executePaymentMethodCheckout(e){var t;return null===(t=null==e?void 0:e.continueWithCheckoutCallback)||void 0===t||t.call(e),Promise.resolve()}deinitialize(){var e;return null===(e=this._paymentButton)||void 0===e||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()}_getGooglePayClientOptions(e){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:({callbackTrigger:t,shippingAddress:n,shippingOptionData:i,offerData:o})=>Ft(this,void 0,void 0,function*(){const{availableTriggers:r,addressChangeTriggers:a,shippingOptionsChangeTriggers:s,offerChangeTriggers:c}=this._googlePayPaymentProcessor.getCallbackTriggers();if(!r.includes(t))return;const d=a.includes(t)?yield this._googlePayPaymentProcessor.handleShippingAddressChange(n):void 0;s.includes(t)&&(yield this._googlePayPaymentProcessor.handleShippingOptionChange(i.id));const{newOfferInfo:l,error:u}=c.includes(t)?yield this._googlePayPaymentProcessor.handleCoupons(o):{},h=u;yield this._paymentIntegrationService.loadCheckout();const y=this._googlePayPaymentProcessor.getTotalPrice(),{code:g}=this._paymentIntegrationService.getState().getCartOrThrow().currency;return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},e&&{countryCode:e}),{currencyCode:g,totalPriceStatus:R.FINAL,totalPrice:y})},d&&{newShippingOptionParameters:d}),l&&{newOfferInfo:l}),h&&{error:h})})}}}_addPaymentButton({container:e,buttonColor:t,buttonType:n,onClick:i,onError:o}){var r;this._paymentButton=null!==(r=this._paymentButton)&&void 0!==r?r:this._googlePayPaymentProcessor.addPaymentButton(e,{buttonColor:null!=t?t:"default",buttonType:null!=n?n:"plain",onClick:this._handleClick(o,i)})}_handleClick(e,t){return n=>Ft(this,void 0,void 0,function*(){n.preventDefault(),t&&"function"==typeof t&&t();try{yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(t){let n=t;if(ee(t)){if("CANCELED"===t.statusCode)throw new w;n=new W(JSON.stringify(t))}throw null==e||e(new W("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){return Ft(this,void 0,void 0,function*(){const e=yield this._googlePayPaymentProcessor.showPaymentSheet(),t=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(e),n=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(e),i="/embedded-checkout"===window.location.pathname?this._paymentIntegrationService.getState().getStoreConfigOrThrow().links.siteLink:void 0;t&&(yield this._paymentIntegrationService.updateBillingAddress(t)),n&&(yield this._paymentIntegrationService.updateShippingAddress(n)),yield this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodId(),e,i)})}_getMethodId(){return k(this._methodId,()=>new _(v.PaymentNotInitialized))}}const Ut=g(n=>{const i=t();return new Vt(n,new Y(ae(),new F("adyen",n),i,e()))},[{id:"googlepayadyenv2"}]),qt=g(n=>{const i=t();return new Vt(n,new Y(ae(),new F("adyen",n),i,e()))},[{id:"googlepayadyenv3"}]),Wt=g(n=>new Vt(n,new Y(ae(),new he(n),t(),e())),[{id:"googlepayauthorizenet"}]),Ht=g(n=>{const i=t();return new Vt(n,new Y(ae(),new Pe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]),Yt=g(n=>new Vt(n,new Y(ae(),new ve(n),t(),e())),[{id:"googlepaycybersourcev2"}]),Jt=g(n=>new Vt(n,new Y(ae(),new ve(n),t(),e())),[{id:"googlepaybnz"}]),Kt=g(n=>new Vt(n,new Y(ae(),new be(n),t(),e())),[{id:"googlepayorbital"}]),Zt=g(i=>new Vt(i,new Y(ae(),new Ue(i,new Ge(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeocs"}]),Xt=g(i=>new Vt(i,new Y(ae(),new Ue(i,new Ge(n())),t(),e())),[{id:"googlepaystripeupe"}]),Qt=g(n=>new Vt(n,new Y(ae(),new We(n),t(),e())),[{id:"googlepayworldpayaccess"}]),$t=g(i=>{const o=t(),r=window,a=new Ze(i),s=new dt(new ht(n(),r,a));return new Vt(i,new Y(ae(),new pt(i,s),o,e()))},[{id:"googlepaybraintree"}]),en=g(i=>new Vt(i,new Y(ae(),new _t(i,new Pt(n())),t(),e())),[{id:"googlepaypaypalcommerce"}]),tn=g(i=>new Vt(i,new Y(ae(),new Nt(i,new Tt(n())),t(),e())),[{id:"googlepay_bigcommerce_payments"}]),nn=g(n=>new Vt(n,new Y(ae(),new Bt(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);class on extends l{constructor(e){super(e||"An unexpected error has occurred during buy now cart creation process. Please try again later."),this.name="BuyNowCartCreationError",this.type="buy_now_cart_creation_error"}}var rn=function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function s(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class an{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){var t,n,i;return rn(this,void 0,void 0,function*(){if(!e.methodId||!ne(e.methodId))throw new b('Unable to proceed because "methodId" is not a valid key.');if(this._methodId=e.methodId,!e.containerId)throw new b('Unable to proceed because "containerId" is not a valid key.');const o=e[this._getMethodOrThrow()];if(!o)throw new b("Unable to proceed without valid options.");const{buyNowInitializeOptions:r,currencyCode:a,buttonColor:s,buttonType:c,onError:d}=o;let l,u=this._paymentIntegrationService.getState();try{l=u.getPaymentMethodOrThrow(this._getMethodOrThrow())}catch(e){u=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodOrThrow()),l=u.getPaymentMethodOrThrow(this._getMethodOrThrow())}if(this._countryCode=null===(t=l.initializationData)||void 0===t?void 0:t.storeCountry,this._googlePayPaymentProcessor.setIsWebViewExperimentOn(!!(null===(n=l.initializationData)||void 0===n?void 0:n.isWebViewExperimentOn)),r){if(!a)throw new b('Unable to initialize payment because "options.currencyCode" argument is not provided.');this._currencyCode=a,this._buyNowInitializeOptions=r,yield this._googlePayPaymentProcessor.initialize(()=>l,this._getGooglePayClientOptions(),!!r,a)}else yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initialize(()=>l,this._getGooglePayClientOptions());this._paymentButton=null!==(i=this._paymentButton)&&void 0!==i?i:this._googlePayPaymentProcessor.addPaymentButton(e.containerId,{buttonColor:null!=s?s:"default",buttonType:null!=c?c:"plain",onClick:this._handleClick(d)})})}deinitialize(){var e;return null===(e=this._paymentButton)||void 0===e||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()}_handleClick(e){return t=>rn(this,void 0,void 0,function*(){t.preventDefault();try{this._buyNowInitializeOptions?yield this._createBuyNowCartOrThrow(this._buyNowInitializeOptions):yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(t){let n=t;if(ee(t)){if("CANCELED"===t.statusCode)throw new w;n=new W(JSON.stringify(t))}throw null==e||e(new W("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){var e;return rn(this,void 0,void 0,function*(){const t=yield this._googlePayPaymentProcessor.showPaymentSheet(),n=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(t),i=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(t),o="/embedded-checkout"===window.location.pathname?this._paymentIntegrationService.getState().getStoreConfigOrThrow().links.siteLink:void 0;n&&(yield this._paymentIntegrationService.updateBillingAddress(n)),i&&!(null===(e=this._buyNowCart)||void 0===e?void 0:e.lineItems.digitalItems.length)&&(yield this._paymentIntegrationService.updateShippingAddress(i)),yield this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodOrThrow(),t,o)})}_getGooglePayClientOptions(){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:({callbackTrigger:e,shippingAddress:t,shippingOptionData:n,offerData:i})=>rn(this,void 0,void 0,function*(){const{availableTriggers:o,addressChangeTriggers:r,shippingOptionsChangeTriggers:a,offerChangeTriggers:s}=this._googlePayPaymentProcessor.getCallbackTriggers();if(!o.includes(e))return;const c=r.includes(e)?yield this._googlePayPaymentProcessor.handleShippingAddressChange(t):void 0;a.includes(e)&&(yield this._googlePayPaymentProcessor.handleShippingOptionChange(n.id));const{newOfferInfo:d,error:l}=s.includes(e)?yield this._googlePayPaymentProcessor.handleCoupons(i):{},u=l;return this._buyNowInitializeOptions?this._getBuyNowTransactionInfo(c,d,u):this._getTransactionInfo(c,d,u)})}}}_createBuyNowCartOrThrow(e){return rn(this,void 0,void 0,function*(){if("function"==typeof(null==e?void 0:e.getBuyNowCartRequestBody)){const t=e.getBuyNowCartRequestBody();try{this._buyNowCart=yield this._paymentIntegrationService.createBuyNowCart(t),yield this._paymentIntegrationService.loadCheckout(this._buyNowCart.id)}catch(e){if("string"==typeof e)throw new on(e);throw e}}})}_getBuyNowTransactionInfo(e,t,n){if(!this._buyNowCart)return;const{cartAmount:i}=this._buyNowCart,o=this._googlePayPaymentProcessor.getTotalPrice();return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:this._getCurrencyCodeOrThrow(),totalPrice:o||String(i),totalPriceStatus:R.FINAL})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})}_getTransactionInfo(e,t,n){return rn(this,void 0,void 0,function*(){yield this._paymentIntegrationService.loadCheckout();const i=this._googlePayPaymentProcessor.getTotalPrice(),{code:o}=this._paymentIntegrationService.getState().getCartOrThrow().currency;return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:o,totalPriceStatus:R.FINAL,totalPrice:i})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})})}_getMethodOrThrow(){return k(this._methodId,()=>new _(v.PaymentNotInitialized))}_getCurrencyCodeOrThrow(){return k(this._currencyCode,()=>new b('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}}const sn=g(i=>{const o=t(),r=window,a=new Ze(i),s=new dt(new ht(n(),r,a));return new an(i,new Y(ae(),new pt(i,s),o,e()))},[{id:"googlepaybraintree"}]),cn=g(i=>new an(i,new Y(ae(),new _t(i,new Pt(n())),t(),e())),[{id:"googlepaypaypalcommerce"}]),dn=g(i=>new an(i,new Y(ae(),new Nt(i,new Tt(n())),t(),e())),[{id:"googlepay_bigcommerce_payments"}]),ln=g(n=>{const i=t();return new an(n,new Y(ae(),new F("adyen",n),i,e()))},[{id:"googlepayadyenv2"}]),un=g(n=>{const i=t();return new an(n,new Y(ae(),new F("adyen",n),i,e()))},[{id:"googlepayadyenv3"}]),hn=g(n=>new an(n,new Y(ae(),new he(n),t(),e())),[{id:"googlepayauthorizenet"}]),yn=g(n=>{const i=t();return new an(n,new Y(ae(),new Pe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]),gn=g(n=>new an(n,new Y(ae(),new ve(n),t(),e())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]),pn=g(n=>new an(n,new Y(ae(),new be(n),t(),e())),[{id:"googlepayorbital"}]),mn=g(i=>new an(i,new Y(ae(),new Ue(i,new Ge(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]),fn=g(n=>new an(n,new Y(ae(),new We(n),t(),e())),[{id:"googlepayworldpayaccess"}]),Pn=g(n=>new an(n,new Y(ae(),new Bt(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);export{ln as createGooglePayAdyenV2ButtonStrategy,Ut as createGooglePayAdyenV2CustomerStrategy,se as createGooglePayAdyenV2PaymentStrategy,un as createGooglePayAdyenV3ButtonStrategy,qt as createGooglePayAdyenV3CustomerStrategy,ue as createGooglePayAdyenV3PaymentStrategy,hn as createGooglePayAuthorizeDotNetButtonStrategy,Wt as createGooglePayAuthorizeDotNetCustomerStrategy,ye as createGooglePayAuthorizeNetPaymentStrategy,dn as createGooglePayBigCommercePaymentsButtonStrategy,tn as createGooglePayBigCommercePaymentsCustomerStrategy,zt as createGooglePayBigCommercePaymentsPaymentStrategy,Jt as createGooglePayBnzCustomerStrategy,sn as createGooglePayBraintreeButtonStrategy,$t as createGooglePayBraintreeCustomerStrategy,mt as createGooglePayBraintreePaymentStrategy,yn as createGooglePayCheckoutComButtonStrategy,Ht as createGooglePayCheckoutComCustomerStrategy,we as createGooglePayCheckoutComPaymentStrategy,gn as createGooglePayCybersourceButtonStrategy,Yt as createGooglePayCybersourceCustomerStrategy,_e as createGooglePayCybersourcePaymentStrategy,pn as createGooglePayOrbitalButtonStrategy,Kt as createGooglePayOrbitalCustomerStrategy,Ce as createGooglePayOrbitalPaymentStrategy,kt as createGooglePayPPCPPaymentStrategy,cn as createGooglePayPayPalCommerceButtonStrategy,en as createGooglePayPayPalCommerceCustomerStrategy,mn as createGooglePayStripeButtonStrategy,Zt as createGooglePayStripeCustomerStrategy,qe as createGooglePayStripePaymentStrategy,Xt as createGooglePayStripeUpeCustomerStrategy,Pn as createGooglePayTdOnlineMartButtonStrategy,nn as createGooglePayTdOnlineMartCustomerStrategy,jt as createGooglePayTdOnlineMartPaymentStrategy,fn as createGooglePayWorldpayAccessButtonStrategy,Qt as createGooglePayWorldpayAccessCustomerStrategy,He as createGooglePayWorldpayAccessPaymentStrategy};
2
2
  //# sourceMappingURL=google-pay.js.map
@@ -1,2 +1,2 @@
1
- import{getScriptLoader as e}from"@bigcommerce/script-loader";import{includes as t}from"lodash";import{createRequestSender as n}from"@bigcommerce/request-sender";var i,a,r={};function o(e,t){return Object.assign(e,{resolveIds:t})}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);class s extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}class d extends s{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class c extends s{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(i||(i={}));class l extends s{constructor(e){super(function(e){switch(e){case i.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case i.MissingCart:return"Unable to proceed because cart data is unavailable.";case i.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case i.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case i.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case i.MissingCheckoutConfig:case i.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case i.MissingOrder:return"Unable to proceed because order data is unavailable.";case i.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case i.MissingPayment:return"Unable to proceed because payment data is unavailable.";case i.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case i.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case i.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(a||(a={}));class u extends s{constructor(e){super(function(e){switch(e){case a.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case a.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case a.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case a.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}class h extends s{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}const p={body:{},headers:{},status:0};class m extends s{constructor(e,{message:t,errors:n}={}){const{body:i,headers:a,status:r}=e||p;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=i,this.headers=a,this.status=r,this.errors=n||[]}}class y extends m{constructor(e){super(e,{message:"There is a problem processing your payment. Please try again later."}),this.name="PaymentMethodInvalidError",this.type="payment_method_invalid"}}const g=["AT","BE","CA","CH","CZ","DE","DK","ES","FI","FR","GB","GR","IE","IT","NL","NO","NZ","PL","PT","SE"],b=["AU"];var v=function(e,t,n,i){return new(n||(n=Promise))(function(a,r){function o(e){try{d(i.next(e))}catch(e){r(e)}}function s(e){try{d(i.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,s)}d((i=i.apply(e,t||[])).next())})};class f{constructor(e,t){this.paymentIntegrationService=e,this.klarnaScriptLoader=t}initialize(e){return v(this,void 0,void 0,function*(){this.klarnaCredit=yield this.klarnaScriptLoader.load(),this.unsubscribe=this.paymentIntegrationService.subscribe(t=>{t.isPaymentMethodInitialized({methodId:e.methodId,gatewayId:e.gatewayId})&&this.loadWidget(e)},e=>{const t=e.getCheckout();return t&&t.outstandingBalance},e=>{const t=e.getCheckout();return t&&t.coupons}),yield this.loadWidget(e)})}deinitialize(){return this.unsubscribe&&this.unsubscribe(),Promise.resolve()}execute(e,t){return v(this,void 0,void 0,function*(){if(!e.payment)throw new d('Unable to proceed because "payload.payment" argument is not provided.');const n=e.payment,{paymentData:i}=n,a=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(n[i[a]]=e[i[a]])}return n}(n,["paymentData"]),{authorization_token:r}=yield this.authorize();yield this.paymentIntegrationService.initializePayment(a.methodId,{authorizationToken:r}),yield this.paymentIntegrationService.submitOrder(Object.assign(Object.assign({},e),{payment:a,useStoreCredit:e.useStoreCredit}),t)})}finalize(){return Promise.reject(new c)}loadWidget(e){return v(this,void 0,void 0,function*(){if(!e.klarna)throw new d('Unable to load widget because "options.klarna" argument is not provided.');const{methodId:t,klarna:{container:n,onLoad:r}}=e;return yield this.paymentIntegrationService.loadPaymentMethod(t),new Promise(e=>{const o=this.paymentIntegrationService.getState().getPaymentMethod(t);if(!o)throw new l(i.MissingPaymentMethod);if(!this.klarnaCredit||!o.clientToken)throw new u(a.PaymentNotInitialized);this.klarnaCredit.init({client_token:o.clientToken}),this.klarnaCredit.load({container:n},t=>{r&&r(t),e(t)})})})}getUpdateSessionData(e,n){if(!t([...g,...b],e.countryCode))return{};const i={billing_address:this.mapToKlarnaAddress(e,e.email)};return n&&(i.shipping_address=this.mapToKlarnaAddress(n,e.email)),i}needsStateCode(e){return t(b,e)}mapToKlarnaAddress(e,t){const n={street_address:e.address1,city:e.city,country:e.countryCode,given_name:e.firstName,family_name:e.lastName,postal_code:e.postalCode,region:this.needsStateCode(e.countryCode)?e.stateOrProvinceCode:e.stateOrProvince,email:t};return e.address2&&(n.street_address2=e.address2),e.phone&&(n.phone=e.phone),n}authorize(){return new Promise((e,t)=>{const n=this.paymentIntegrationService.getState(),r=n.getBillingAddress(),o=n.getShippingAddress();if(!r)throw new l(i.MissingBillingAddress);if(!this.klarnaCredit)throw new u(a.PaymentNotInitialized);const s=this.getUpdateSessionData(r,o);this.klarnaCredit.authorize(s,n=>n.approved?e(n):n.show_form?t(new h):void t(new y))})}}class w extends s{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}class P{constructor(e,t=window){this.scriptLoader=e,this.klarnaWindow=t}load(){var e,t,n,i,a,r;return n=this,i=void 0,r=function*(){if((null===(e=this.klarnaWindow.Klarna)||void 0===e?void 0:e.Credit)||(yield this.scriptLoader.loadScript("//credit.klarnacdn.net/lib/v1/api.js")),!(null===(t=this.klarnaWindow.Klarna)||void 0===t?void 0:t.Credit))throw new w;return this.klarnaWindow.Klarna.Credit},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{d(r.next(e))}catch(e){t(e)}}function s(e){try{d(r.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a(function(e){e(n)})).then(o,s)}d((r=r.apply(n,i||[])).next())})}}const k=o(t=>new f(t,new P(e())),[{id:"klarna"}]);var I=function(e,t,n,i){return new(n||(n=Promise))(function(a,r){function o(e){try{d(i.next(e))}catch(e){r(e)}}function s(e){try{d(i.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,s)}d((i=i.apply(e,t||[])).next())})};class M{constructor(e,t,n){this.paymentIntegrationService=e,this.klarnav2ScriptLoader=t,this.klarnav2TokenUpdater=n}initialize(e){return I(this,void 0,void 0,function*(){this.klarnaPayments=yield this.klarnav2ScriptLoader.load(),this.unsubscribe=this.paymentIntegrationService.subscribe(t=>{t.isPaymentMethodInitialized({methodId:e.methodId,gatewayId:e.gatewayId})&&this.loadPaymentsWidget(e)},e=>{const t=e.getCheckout();return t&&t.outstandingBalance},e=>{const t=e.getCheckout();return t&&t.coupons}),yield this.loadPaymentsWidget(e)})}deinitialize(){return this.unsubscribe&&this.unsubscribe(),Promise.resolve()}execute(e,t){return I(this,void 0,void 0,function*(){if(!e.payment)throw new d('Unable to proceed because "payload.payment" argument is not provided.');const n=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(n[i[a]]=e[i[a]])}return n}(e.payment,[]),{gatewayId:i,methodId:a}=n;if(!i)throw new d('Unable to proceed because "payload.payment.gatewayId" argument is not provided.');const r=this.paymentIntegrationService.getState(),{id:o}=r.getCartOrThrow(),{clientToken:s,initializationData:c}=r.getPaymentMethodOrThrow(a),{klarnaMultipleRadioButton:l}=c||{};yield this.klarnav2TokenUpdater.klarnaOrderInitialization(o,s);const u=this.isKlarnaMultipleRadioButtonEnabled(l,i,a),{authorization_token:h}=yield this.authorizeOrThrow(u,a);yield this.paymentIntegrationService.initializePayment(i,{authorizationToken:h}),yield this.paymentIntegrationService.submitOrder(Object.assign(Object.assign({},e),{payment:n,useStoreCredit:e.useStoreCredit}),t)})}finalize(){return Promise.reject(new c)}loadPaymentsWidget(e){return I(this,void 0,void 0,function*(){if(!e.klarnav2)throw new d('Unable to load widget because "options.klarnav2" argument is not provided.');const{methodId:t,gatewayId:n,klarnav2:{container:r,onLoad:o}}=e;if(!n)throw new d('Unable to proceed because "payload.payment.gatewayId" argument is not provided.');const s=this.paymentIntegrationService.getState(),c={params:s.getCartOrThrow().id};return yield this.klarnav2TokenUpdater.updateClientToken(n,{params:c}).catch(()=>{throw new l(i.MissingPaymentMethod)}),new Promise(e=>{const i=s.getPaymentMethodOrThrow(t),{klarnaMultipleRadioButton:d}=i.initializationData||{};if(!this.klarnaPayments||!i.clientToken)throw new u(a.PaymentNotInitialized);this.klarnaPayments.init({client_token:i.clientToken}),this.klarnaPayments.load({container:r,payment_method_category:this.isKlarnaMultipleRadioButtonEnabled(d,n,t)},t=>{o&&o(t),e(t)})})})}getUpdateSessionData(e,n,i){if(!t([...g,...b],n.countryCode))return{};const a={billing_address:this.mapToKlarnaAddress(e,n,n.email)};return i&&(a.shipping_address=this.mapToKlarnaAddress(e,i,n.email)),a}needsStateCode(e){return t(b,e)}isKlarnaMultipleRadioButtonEnabled(e,t,n){return e?n:t}mapToKlarnaAddress(e,t,n){const i=this.paymentIntegrationService.getState(),{checkoutSettings:a}=i.getStoreConfigOrThrow(),r=i.getPaymentMethodOrThrow(e),{enableBillie:o}=r.initializationData||{},s={street_address:t.address1,city:t.city,country:t.countryCode,given_name:t.firstName,family_name:t.lastName,postal_code:t.postalCode,region:this.needsStateCode(t.countryCode)?t.stateOrProvinceCode:t.stateOrProvince,email:n};return t.address2&&(s.street_address2=t.address2),t.phone&&(s.phone=t.phone),t.company&&o&&function(e,t,n=!0){var i;return null!==(i=e["PI-3915.b2b_payment_session_for_klarna"])&&void 0!==i?i:n}(a.features)&&(s.organization_name=t.company),s}authorizeOrThrow(e,t){return I(this,void 0,void 0,function*(){yield this.paymentIntegrationService.loadCheckout();const n=this.paymentIntegrationService.getState(),i=n.getBillingAddressOrThrow(),r=n.getShippingAddress(),o=this.getUpdateSessionData(t,i,r);return new Promise((t,n)=>{if(!this.klarnaPayments)return n(new u(a.PaymentNotInitialized));this.klarnaPayments.authorize({payment_method_category:e},o,e=>e.approved?t(e):e.show_form?n(new h):void n(new y))})})}}var S;class C{constructor(e,t=window){this.scriptLoader=e,this.klarnaWindow=t}load(){var e,t,n,i,a,r;return n=this,i=void 0,r=function*(){if((null===(e=this.klarnaWindow.Klarna)||void 0===e?void 0:e.Payments)||(yield this.scriptLoader.loadScript("https://x.klarnacdn.net/kp/lib/v1/api.js")),!(null===(t=this.klarnaWindow.Klarna)||void 0===t?void 0:t.Payments))throw new w;return this.klarnaWindow.Klarna.Payments},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{d(r.next(e))}catch(e){t(e)}}function s(e){try{d(r.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a(function(e){e(n)})).then(o,s)}d((r=r.apply(n,i||[])).next())})}}!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(S||(S={}));const O=S,z="This API endpoint is for internal use only and may change in the future",_={"X-Checkout-SDK-Version":"1.889.0"};class T{constructor(e){this.requestSender=e}updateClientToken(e,{timeout:t,params:n}={}){const i=`/api/storefront/payments/${e}`;return this.requestSender.get(i,{timeout:t,headers:Object.assign({Accept:O.JsonV1,"X-API-INTERNAL":z},_),params:n})}klarnaOrderInitialization(e,t){return n=this,i=void 0,r=function*(){const n={headers:Object.assign({Accept:O.JsonV1,"X-API-INTERNAL":z},_),body:{cartId:e,clientToken:t}};yield this.requestSender.put("/api/storefront/initialization/klarna",n)},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{d(r.next(e))}catch(e){t(e)}}function s(e){try{d(r.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a(function(e){e(n)})).then(o,s)}d((r=r.apply(n,i||[])).next())});var n,i,a,r}}const U=o(t=>{const{getHost:i}=t.getState(),a=n({host:i()});return new M(t,new C(e()),new T(a))},[{gateway:"klarna"}]);export{k as createKlarnaPaymentStrategy,U as createKlarnaV2PaymentStrategy};
1
+ import{getScriptLoader as e}from"@bigcommerce/script-loader";import{includes as t}from"lodash";import{createRequestSender as n}from"@bigcommerce/request-sender";var i,a,r={};function o(e,t){return Object.assign(e,{resolveIds:t})}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);class s extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}class d extends s{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class c extends s{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(i||(i={}));class l extends s{constructor(e){super(function(e){switch(e){case i.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case i.MissingCart:return"Unable to proceed because cart data is unavailable.";case i.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case i.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case i.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case i.MissingCheckoutConfig:case i.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case i.MissingOrder:return"Unable to proceed because order data is unavailable.";case i.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case i.MissingPayment:return"Unable to proceed because payment data is unavailable.";case i.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case i.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case i.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(a||(a={}));class u extends s{constructor(e){super(function(e){switch(e){case a.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case a.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case a.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case a.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}class h extends s{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}const p={body:{},headers:{},status:0};class m extends s{constructor(e,{message:t,errors:n}={}){const{body:i,headers:a,status:r}=e||p;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=i,this.headers=a,this.status=r,this.errors=n||[]}}class y extends m{constructor(e){super(e,{message:"There is a problem processing your payment. Please try again later."}),this.name="PaymentMethodInvalidError",this.type="payment_method_invalid"}}const g=["AT","BE","CA","CH","CZ","DE","DK","ES","FI","FR","GB","GR","IE","IT","NL","NO","NZ","PL","PT","SE"],b=["AU"];var v=function(e,t,n,i){return new(n||(n=Promise))(function(a,r){function o(e){try{d(i.next(e))}catch(e){r(e)}}function s(e){try{d(i.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,s)}d((i=i.apply(e,t||[])).next())})};class f{constructor(e,t){this.paymentIntegrationService=e,this.klarnaScriptLoader=t}initialize(e){return v(this,void 0,void 0,function*(){this.klarnaCredit=yield this.klarnaScriptLoader.load(),this.unsubscribe=this.paymentIntegrationService.subscribe(t=>{t.isPaymentMethodInitialized({methodId:e.methodId,gatewayId:e.gatewayId})&&this.loadWidget(e)},e=>{const t=e.getCheckout();return t&&t.outstandingBalance},e=>{const t=e.getCheckout();return t&&t.coupons}),yield this.loadWidget(e)})}deinitialize(){return this.unsubscribe&&this.unsubscribe(),Promise.resolve()}execute(e,t){return v(this,void 0,void 0,function*(){if(!e.payment)throw new d('Unable to proceed because "payload.payment" argument is not provided.');const n=e.payment,{paymentData:i}=n,a=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(n[i[a]]=e[i[a]])}return n}(n,["paymentData"]),{authorization_token:r}=yield this.authorize();yield this.paymentIntegrationService.initializePayment(a.methodId,{authorizationToken:r}),yield this.paymentIntegrationService.submitOrder(Object.assign(Object.assign({},e),{payment:a,useStoreCredit:e.useStoreCredit}),t)})}finalize(){return Promise.reject(new c)}loadWidget(e){return v(this,void 0,void 0,function*(){if(!e.klarna)throw new d('Unable to load widget because "options.klarna" argument is not provided.');const{methodId:t,klarna:{container:n,onLoad:r}}=e;return yield this.paymentIntegrationService.loadPaymentMethod(t),new Promise(e=>{const o=this.paymentIntegrationService.getState().getPaymentMethod(t);if(!o)throw new l(i.MissingPaymentMethod);if(!this.klarnaCredit||!o.clientToken)throw new u(a.PaymentNotInitialized);this.klarnaCredit.init({client_token:o.clientToken}),this.klarnaCredit.load({container:n},t=>{r&&r(t),e(t)})})})}getUpdateSessionData(e,n){if(!t([...g,...b],e.countryCode))return{};const i={billing_address:this.mapToKlarnaAddress(e,e.email)};return n&&(i.shipping_address=this.mapToKlarnaAddress(n,e.email)),i}needsStateCode(e){return t(b,e)}mapToKlarnaAddress(e,t){const n={street_address:e.address1,city:e.city,country:e.countryCode,given_name:e.firstName,family_name:e.lastName,postal_code:e.postalCode,region:this.needsStateCode(e.countryCode)?e.stateOrProvinceCode:e.stateOrProvince,email:t};return e.address2&&(n.street_address2=e.address2),e.phone&&(n.phone=e.phone),n}authorize(){return new Promise((e,t)=>{const n=this.paymentIntegrationService.getState(),r=n.getBillingAddress(),o=n.getShippingAddress();if(!r)throw new l(i.MissingBillingAddress);if(!this.klarnaCredit)throw new u(a.PaymentNotInitialized);const s=this.getUpdateSessionData(r,o);this.klarnaCredit.authorize(s,n=>n.approved?e(n):n.show_form?t(new h):void t(new y))})}}class w extends s{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}class P{constructor(e,t=window){this.scriptLoader=e,this.klarnaWindow=t}load(){var e,t,n,i,a,r;return n=this,i=void 0,r=function*(){if((null===(e=this.klarnaWindow.Klarna)||void 0===e?void 0:e.Credit)||(yield this.scriptLoader.loadScript("//credit.klarnacdn.net/lib/v1/api.js")),!(null===(t=this.klarnaWindow.Klarna)||void 0===t?void 0:t.Credit))throw new w;return this.klarnaWindow.Klarna.Credit},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{d(r.next(e))}catch(e){t(e)}}function s(e){try{d(r.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a(function(e){e(n)})).then(o,s)}d((r=r.apply(n,i||[])).next())})}}const k=o(t=>new f(t,new P(e())),[{id:"klarna"}]);var I=function(e,t,n,i){return new(n||(n=Promise))(function(a,r){function o(e){try{d(i.next(e))}catch(e){r(e)}}function s(e){try{d(i.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,s)}d((i=i.apply(e,t||[])).next())})};class M{constructor(e,t,n){this.paymentIntegrationService=e,this.klarnav2ScriptLoader=t,this.klarnav2TokenUpdater=n}initialize(e){return I(this,void 0,void 0,function*(){this.klarnaPayments=yield this.klarnav2ScriptLoader.load(),this.unsubscribe=this.paymentIntegrationService.subscribe(t=>{t.isPaymentMethodInitialized({methodId:e.methodId,gatewayId:e.gatewayId})&&this.loadPaymentsWidget(e)},e=>{const t=e.getCheckout();return t&&t.outstandingBalance},e=>{const t=e.getCheckout();return t&&t.coupons}),yield this.loadPaymentsWidget(e)})}deinitialize(){return this.unsubscribe&&this.unsubscribe(),Promise.resolve()}execute(e,t){return I(this,void 0,void 0,function*(){if(!e.payment)throw new d('Unable to proceed because "payload.payment" argument is not provided.');const n=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(n[i[a]]=e[i[a]])}return n}(e.payment,[]),{gatewayId:i,methodId:a}=n;if(!i)throw new d('Unable to proceed because "payload.payment.gatewayId" argument is not provided.');const r=this.paymentIntegrationService.getState(),{id:o}=r.getCartOrThrow(),{clientToken:s,initializationData:c}=r.getPaymentMethodOrThrow(a),{klarnaMultipleRadioButton:l}=c||{};yield this.klarnav2TokenUpdater.klarnaOrderInitialization(o,s);const u=this.isKlarnaMultipleRadioButtonEnabled(l,i,a),{authorization_token:h}=yield this.authorizeOrThrow(u,a);yield this.paymentIntegrationService.initializePayment(i,{authorizationToken:h}),yield this.paymentIntegrationService.submitOrder(Object.assign(Object.assign({},e),{payment:n,useStoreCredit:e.useStoreCredit}),t)})}finalize(){return Promise.reject(new c)}loadPaymentsWidget(e){return I(this,void 0,void 0,function*(){if(!e.klarnav2)throw new d('Unable to load widget because "options.klarnav2" argument is not provided.');const{methodId:t,gatewayId:n,klarnav2:{container:r,onLoad:o}}=e;if(!n)throw new d('Unable to proceed because "payload.payment.gatewayId" argument is not provided.');const s=this.paymentIntegrationService.getState(),c={params:s.getCartOrThrow().id};return yield this.klarnav2TokenUpdater.updateClientToken(n,{params:c}).catch(()=>{throw new l(i.MissingPaymentMethod)}),new Promise(e=>{const i=s.getPaymentMethodOrThrow(t),{klarnaMultipleRadioButton:d}=i.initializationData||{};if(!this.klarnaPayments||!i.clientToken)throw new u(a.PaymentNotInitialized);this.klarnaPayments.init({client_token:i.clientToken}),this.klarnaPayments.load({container:r,payment_method_category:this.isKlarnaMultipleRadioButtonEnabled(d,n,t)},t=>{o&&o(t),e(t)})})})}getUpdateSessionData(e,n,i){if(!t([...g,...b],n.countryCode))return{};const a={billing_address:this.mapToKlarnaAddress(e,n,n.email)};return i&&(a.shipping_address=this.mapToKlarnaAddress(e,i,n.email)),a}needsStateCode(e){return t(b,e)}isKlarnaMultipleRadioButtonEnabled(e,t,n){return e?n:t}mapToKlarnaAddress(e,t,n){const i=this.paymentIntegrationService.getState(),{checkoutSettings:a}=i.getStoreConfigOrThrow(),r=i.getPaymentMethodOrThrow(e),{enableBillie:o}=r.initializationData||{},s={street_address:t.address1,city:t.city,country:t.countryCode,given_name:t.firstName,family_name:t.lastName,postal_code:t.postalCode,region:this.needsStateCode(t.countryCode)?t.stateOrProvinceCode:t.stateOrProvince,email:n};return t.address2&&(s.street_address2=t.address2),t.phone&&(s.phone=t.phone),t.company&&o&&function(e,t,n=!0){var i;return null!==(i=e["PI-3915.b2b_payment_session_for_klarna"])&&void 0!==i?i:n}(a.features)&&(s.organization_name=t.company),s}authorizeOrThrow(e,t){return I(this,void 0,void 0,function*(){yield this.paymentIntegrationService.loadCheckout();const n=this.paymentIntegrationService.getState(),i=n.getBillingAddressOrThrow(),r=n.getShippingAddress(),o=this.getUpdateSessionData(t,i,r);return new Promise((t,n)=>{if(!this.klarnaPayments)return n(new u(a.PaymentNotInitialized));this.klarnaPayments.authorize({payment_method_category:e},o,e=>e.approved?t(e):e.show_form?n(new h):void n(new y))})})}}var S;class C{constructor(e,t=window){this.scriptLoader=e,this.klarnaWindow=t}load(){var e,t,n,i,a,r;return n=this,i=void 0,r=function*(){if((null===(e=this.klarnaWindow.Klarna)||void 0===e?void 0:e.Payments)||(yield this.scriptLoader.loadScript("https://x.klarnacdn.net/kp/lib/v1/api.js")),!(null===(t=this.klarnaWindow.Klarna)||void 0===t?void 0:t.Payments))throw new w;return this.klarnaWindow.Klarna.Payments},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{d(r.next(e))}catch(e){t(e)}}function s(e){try{d(r.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a(function(e){e(n)})).then(o,s)}d((r=r.apply(n,i||[])).next())})}}!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(S||(S={}));const O=S,z="This API endpoint is for internal use only and may change in the future",_={"X-Checkout-SDK-Version":"1.889.1"};class T{constructor(e){this.requestSender=e}updateClientToken(e,{timeout:t,params:n}={}){const i=`/api/storefront/payments/${e}`;return this.requestSender.get(i,{timeout:t,headers:Object.assign({Accept:O.JsonV1,"X-API-INTERNAL":z},_),params:n})}klarnaOrderInitialization(e,t){return n=this,i=void 0,r=function*(){const n={headers:Object.assign({Accept:O.JsonV1,"X-API-INTERNAL":z},_),body:{cartId:e,clientToken:t}};yield this.requestSender.put("/api/storefront/initialization/klarna",n)},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{d(r.next(e))}catch(e){t(e)}}function s(e){try{d(r.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a(function(e){e(n)})).then(o,s)}d((r=r.apply(n,i||[])).next())});var n,i,a,r}}const U=o(t=>{const{getHost:i}=t.getState(),a=n({host:i()});return new M(t,new C(e()),new T(a))},[{gateway:"klarna"}]);export{k as createKlarnaPaymentStrategy,U as createKlarnaV2PaymentStrategy};
2
2
  //# sourceMappingURL=klarna.js.map