@bigcommerce/checkout-sdk 1.904.1 → 1.904.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/checkout-button.js +1 -1
- package/dist/cjs/checkout-sdk-essential.js +1 -1
- package/dist/cjs/checkout-sdk.js +1 -1
- package/dist/cjs/hosted-form-v2-iframe-host.js +1 -1
- package/dist/cjs/integrations/amazon-pay.js +1 -1
- package/dist/cjs/integrations/bigcommerce-payments.js +1 -1
- package/dist/cjs/integrations/braintree.js +1 -1
- package/dist/cjs/integrations/google-pay.js +1 -1
- package/dist/cjs/integrations/klarna.js +1 -1
- package/dist/cjs/integrations/paypal-commerce.js +1 -1
- package/dist/cjs/integrations/paypal-express.js +1 -1
- package/dist/cjs/integrations/zip.js +1 -1
- package/dist/esm/checkout-button.js +1 -1
- package/dist/esm/checkout-sdk-essential.js +1 -1
- package/dist/esm/checkout-sdk.js +1 -1
- package/dist/esm/hosted-form-v2-iframe-host.js +1 -1
- package/dist/esm/integrations/amazon-pay.js +1 -1
- package/dist/esm/integrations/bigcommerce-payments.js +1 -1
- package/dist/esm/integrations/braintree.js +1 -1
- package/dist/esm/integrations/google-pay.js +1 -1
- package/dist/esm/integrations/klarna.js +1 -1
- package/dist/esm/integrations/paypal-commerce.js +1 -1
- package/dist/esm/integrations/paypal-express.js +1 -1
- package/dist/esm/integrations/zip.js +1 -1
- package/dist/types/checkout-sdk.d.ts +1 -1
- package/dist/types/internal-mappers.d.ts +1 -1
- package/docs/interfaces/ShippingOption.md +1 -1
- package/package.json +1 -1
|
@@ -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 h 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 u;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 h;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"}(u||(u={}));class _ extends l{constructor(e){super(function(e){switch(e){case u.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case u.MissingCart:return"Unable to proceed because cart data is unavailable.";case u.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case u.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case u.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case u.MissingCheckoutConfig:case u.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case u.MissingOrder:return"Unable to proceed because order data is unavailable.";case u.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case u.MissingPayment:return"Unable to proceed because payment data is unavailable.";case u.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case u.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case u.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 m(){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 f=e=>"object"==typeof e&&null!==e&&"body"in e;class P extends l{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}var w;!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"}(w||(w={}));class v extends l{constructor(e){super(function(e){switch(e){case w.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case w.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case w.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case w.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 C extends l{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}function S(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 b{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 C("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 C("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 b(this._storeConfig.shopperCurrency),this._storeFormatter=new b(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?S(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,S(e.prototype,n,i))}),t}(e)}],I);const O=I;function A(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}function T(){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 M(e,t,n=!0){var i;return null!==(i=e[t])&&void 0!==i?i:n}var E,k,N,D,z,G,R,B,L;function x(e){return e in G}!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"}(k||(k={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(N||(N={})),function(e){e.pill="pill",e.rect="rect"}(D||(D={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(z||(z={})),function(e){e.AMEX="AMEX",e.DISCOVER="DISCOVER",e.INTERAC="INTERAC",e.JCB="JCB",e.MC="MASTERCARD",e.VISA="VISA"}(G||(G={})),function(e){e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION"}(R||(R={})),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"}(B||(B={})),function(e){e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER"}(L||(L={}));var j=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 _(u.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 j(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()?[R.OFFER,R.SHIPPING_ADDRESS,R.SHIPPING_OPTION]:[R.OFFER]}getCallbackTriggers(){return{availableTriggers:[L.INITIALIZE,L.SHIPPING_ADDRESS,L.SHIPPING_OPTION,L.OFFER],initializationTrigger:[L.INITIALIZE],addressChangeTriggers:[L.INITIALIZE,L.SHIPPING_ADDRESS],shippingOptionsChangeTriggers:[L.SHIPPING_OPTION],offerChangeTriggers:[L.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 _(u.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:z.ESTIMATED})}return Object.assign(Object.assign({},n&&{countryCode:n}),{currencyCode:e,totalPriceStatus:z.ESTIMATED,totalPrice:"0"})}isWebViewWithRestrictions(){return null!==this._isWebViewExperimentOn?this._isWebViewExperimentOn&&T():T()}setIsWebViewExperimentOn(e){this._isWebViewExperimentOn=e}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData().gatewayMerchantId;if(!e)throw new C("Unable to proceed, gatewayMerchantId is missing.");return{gateway:this._gatewayIdentifier,gatewayMerchantId:e}}getCardParameters(){return{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:this.getPaymentMethod().supportedCards.filter(x).map(e=>G[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 j(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)),h=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==h?void 0:h.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==h?void 0:h.id)||l[0].id)),{defaultSelectedOptionId:e,shippingOptions:l}}})}handleShippingOptionChange(e){return j(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=M(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 j(this,void 0,void 0,function*(){const{redemptionCodes:t=[]}=e,{offers:n}=this.getAppliedCoupons()||{};let i;return yield t.reduce((e,t)=>j(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)=>j(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 j(this,void 0,void 0,function*(){let t;try{yield this._paymentIntegrationService.applyCoupon(e)}catch(e){return e instanceof Error&&(t={reason:B.OFFER_INVALID,message:e.message,intent:L.OFFER}),t}})}setShouldRequestShipping(e){this._shouldRequestShipping=e}getGooglePayInitializationData(){return A(this.getPaymentMethod().initializationData,()=>new C("Missing initialization data."))}getPaymentMethod(){return A(this._getPaymentMethodFn,()=>new v(w.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=M(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:h,phoneNumber:u}=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:h,phone:u||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 A(this._currencyCode,()=>new C('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 _(u.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:m()})})}processAdditionalAction(e){return V(this,void 0,void 0,function*(){if(!f(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 P)})}_getAdyenClient(){if(!this._adyenClient)throw new v(w.PaymentNotInitialized);return this._adyenClient}}const W={"X-Checkout-SDK-Version":"1.904.1"};class H 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 q=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 K{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 q(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 q(this,void 0,void 0,function*(){yield this._buildWidgetPayloads(),yield this._determineReadinessToPay(),this._prefetchGooglePaymentData()})}getNonce(e){return this._gateway.getNonce(e)}extraPaymentData(){return q(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 q(this,void 0,void 0,function*(){const e=this._getPaymentDataRequest();return this._getPaymentsClient().loadPaymentData(e)})}setExternalCheckoutXhr(e,t){return q(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t)})}setExternalCheckoutForm(e,t,n){return q(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 q(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 q(this,void 0,void 0,function*(){return this._gateway.handleShippingAddressChange(e)})}handleShippingOptionChange(e){return q(this,void 0,void 0,function*(){yield this._gateway.handleShippingOptionChange(e)})}handleCoupons(e){return q(this,void 0,void 0,function*(){return this._gateway.handleCoupons(e)})}getTotalPrice(){return this._gateway.getTotalPrice()}_setExternalCheckout(e,t,n=!1,i){return q(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"},W),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 q(this,void 0,void 0,function*(){try{const{result:e}=yield this._getPaymentsClient().isReadyToPay(this._getIsReadyToPayRequest());if(!1===e)throw new H("Google Pay is not supported by the current device and browser, please try another payment method.")}catch(e){if(e instanceof H)throw e;throw new H}})}_buildButtonPayloads(){this._baseCardPaymentMethod={type:"CARD",parameters:this._gateway.getCardParameters()}}_buildWidgetPayloads(){return q(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 A(e,()=>new v(w.PaymentNotInitialized))}}class Y extends C{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 Z 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 J={size:70,color:"#d9d9d9",backgroundColor:"#ffffff"},Q={position:"fixed","background-color":"rgba(0, 0, 0, 0.4)","z-index":"1000"},X="embedded-checkout-loading-indicator-rotation";class ${constructor(e){this.styles=Object.assign(Object.assign({},J),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=`${X} 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(X))return;const t=document.createElement("style");t.id=X,null===(e=document.head)||void 0===e||e.appendChild(t),t.sheet instanceof CSSStyleSheet&&t.sheet.insertRule(`\n @keyframes ${X} {\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:Q})}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 C('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 C("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 Y(["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 Z)}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 C("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(),this._isDirectPayOnClickEnabled()?yield this._interactWithPaymentSheetAndPay():yield this._interactWithPaymentSheet()}catch(e){let n=e;if(this._toggleLoadingIndicator(!1),ee(e)){if("CANCELED"===e.statusCode)throw new P;n=new H(JSON.stringify(e))}throw null==t||t(new H("An error occurred while requesting your Google Pay payment details.")),n}finally{this._toggleBlockDeinitialization(!1)}null==e||e()})}_interactWithPaymentSheetAndPay(){return ie(this,void 0,void 0,function*(){const e=yield this._googlePayPaymentProcessor.showPaymentSheet();this._toggleBlockDeinitialization(!0),this._toggleLoadingIndicator(!0);const t=this._getMethodId(),n=this._paymentIntegrationService.getState(),{features:i}=n.getStoreConfigOrThrow().checkoutSettings,o=M(i,"PI-5031.google_pay_dont_override_address"),r=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(e);r&&!o&&(yield this._paymentIntegrationService.updateBillingAddress(r)),yield this._googlePayPaymentProcessor.setExternalCheckoutXhr(t,e),yield this._paymentIntegrationService.loadCheckout(),yield this._paymentIntegrationService.loadPaymentMethod(t);const a=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(t);yield this._googlePayPaymentProcessor.initialize(()=>a),yield this.execute({useStoreCredit:!1,payment:{methodId:t}}),this._completeCheckoutFlow()})}_completeCheckoutFlow(){window.location.replace("/checkout/order-confirmation"),this._toggleLoadingIndicator(!1),this._toggleBlockDeinitialization(!1)}_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=M(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 A(this._methodId,()=>new v(w.PaymentNotInitialized))}_getIsSignedInOrThrow(){return ie(this,void 0,void 0,function*(){try{return!!(yield this._googlePayPaymentProcessor.getNonce(this._getMethodId()))}catch(e){if(e instanceof _&&e.subtype===u.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 _&&(n=e.message)}if(t){const{newOfferInfo:t,error:n}=yield this._googlePayPaymentProcessor.handleCoupons(e);return{newOfferInfo:t,error:n}}return{error:{reason:B.OFFER_INVALID,message:n,intent:L.OFFER}}})}_getGooglePayClientOptions(e){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:({callbackTrigger:t,offerData:n})=>ie(this,void 0,void 0,function*(){if(t!==L.INITIALIZE&&t!==L.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:z.FINAL,totalPrice:c})},o&&{newOfferInfo:o}),a&&{error:a})})}}}_isDirectPayOnClickEnabled(){const{features:e}=this._paymentIntegrationService.getState().getStoreConfigOrThrow().checkoutSettings;return M(e,"PI-5111.google_pay_direct_pay_on_click")}_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 h;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 K(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 h;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 _(u.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(!f(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:m()})})}_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 P)})}_getAdyenClient(){if(!this._adyenClient)throw new v(w.PaymentNotInitialized);return this._adyenClient}}const he=g(o=>new oe(o,new K(ae(),new le(o,new ce(n(),i())),t(),e())),[{id:"googlepayadyenv3"}]);class ue 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 _(u.MissingPaymentMethod)}(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.paymentGatewayId}}}const ye=g(n=>new oe(n,new K(ae(),new ue(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 _e(e){if(!function(e){return"checkoutcomkey"in e}(e))throw new _(u.MissingPaymentMethod)}var me=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 fe extends F{constructor(e,t){super("checkoutltd",e),this._requestSender=t}processAdditionalAction(e){return new Promise((t,n)=>{if(f(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 me(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 C("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 _(u.MissingPaymentToken)}(i),n.nonce=yield this._tokenize(i),n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return _e(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.checkoutcomkey}}_tokenize(e){return me(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();_e(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 Pe=g(n=>{const i=t();return new oe(n,new K(ae(),new fe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]);class we 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 ve=g(n=>new oe(n,new K(ae(),new we(n),t(),e())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]);class Ce 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 Se=g(n=>new oe(n,new K(ae(),new Ce(n),t(),e())),[{id:"googlepayorbital"}]);var be,Ie,Oe,Ae,Te,Me,Ee,ke,Ne,De,ze,Ge;!function(e){e.SHIPPING="shipping",e.BILLING="billing"}(be||(be={})),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"}(Ae||(Ae={})),function(e){e.SUCCESS="success",e.ERROR="error"}(Te||(Te={})),function(e){e.CreditCard="card",e.ACH="us_bank_account",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"}(Me||(Me={})),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"}(ke||(ke={})),function(e){e.PAYMENT="payment",e.AUTHENTICATION="linkAuthentication",e.SHIPPING="address",e.EXPRESS_CHECKOUT="expressCheckout"}(Ne||(Ne={})),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"}(De||(De={})),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"}(ze||(ze={})),function(e){e.ON_SESSION="on_session",e.OFF_SESSION="off_session"}(Ge||(Ge={}));var Re=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 Be{constructor(e,t=window){this.scriptLoader=e,this.stripeWindow=t}getStripeClient(e,t,n,i,o){return Re(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 Re(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 Re(this,void 0,void 0,function*(){const t=this.stripeWindow.bcStripeElements;t&&(t.update(e),yield t.fetchUpdates())})}getStripeCheckout(e,t){return Re(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 Re(this,void 0,void 0,function*(){if(!this.stripeWindow.Stripe&&(yield this.scriptLoader.loadScript(this.getScriptUrl(e)),!this.stripeWindow.Stripe))throw new h;return this.stripeWindow.Stripe})}getScriptUrl(e){return e&&e!==ke.V3?`https://js.stripe.com/${e}/stripe.js`:"https://js.stripe.com/v3/"}getStoredStripeCheckout(e){return Re(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(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 Le={body:{},headers:{},status:0};class xe extends l{constructor(e,{message:t,errors:n}={}){const{body:i,headers:o,status:r}=e||Le;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 je=["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 _(u.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 C("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 _(u.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 Y(["payment"]);if(!f(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 P;throw new H}if(!(null==r?void 0:r.paymentIntent)&&!a)throw new xe;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,ke.CLOVER):this.scriptLoader.getStripeClient(e,n,ke.V3,je,"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 We=g(i=>new oe(i,new K(ae(),new Ue(i,new Be(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]);class He 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 qe=g(n=>new oe(n,new K(ae(),new He(n),t(),e())),[{id:"googlepayworldpayaccess"}]),Ke="3.128.0",Ye="3.123.2",Ze="3.106.0";class Je{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()||(M(t,"PAYPAL-5809.braintree_hosted_fields_fix_version")?Ke:M(t,"PAYPAL-5636.update_braintree_sdk_version")?Ye:Ze)}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 Qe extends l{constructor(e){super(e||"Unsupported browser error"),this.name="UnsupportedBrowserError",this.type="unsupported_browser"}}var Xe,$e,et,tt,nt,it,ot;!function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(Xe||(Xe={})),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 Qe;this.braintreeVenmo=i}return this.braintreeVenmo})}setClientToken(e){this.clientToken=e}getClientTokenOrThrow(){if(!this.clientToken)throw new v(w.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={[Ze]:{[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"},[Ye]:{[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"},[Ke]:{[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 ht=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 ut{constructor(e,t,n){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSDKVersionManager=n}loadClient(){return ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.Client,"client.min.js")})}loadFastlane(){return ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.Fastlane,"fastlane.min.js")})}loadPaypalCheckout(){return ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.PaypalCheckout,"paypal-checkout.min.js")})}loadPaypal(){return ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.Paypal,"paypal.min.js")})}loadLocalPayment(){return ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.LocalPayment,"local-payment.min.js")})}loadDataCollector(){return ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.DataCollector,"data-collector.min.js")})}loadUsBankAccount(){return ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.UsBankAccount,"us-bank-account.min.js")})}loadGooglePayment(){return ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.GooglePayment,"google-payment.min.js")})}load3DS(){return ht(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 ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.HostedFields,"hosted-fields.min.js")})}loadVisaCheckoutSdk(e){return ht(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 h;return this.braintreeHostWindow.V})})}loadBraintreeModuleOrThrow(e,t){return ht(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 h;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 _(u.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 _(u.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 C("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 _(u.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 _(u.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 _t=g(i=>{const o=t(),r=window,a=new Je(i),s=new dt(new ut(n(),r,a));return new oe(i,new K(ae(),new pt(i,s),o,e()))},[{id:"googlepaybraintree"}]),mt=["ar_BH","ar_DZ","ar_EG","ar_JO","ar_KW","ar_MA","ar_OM","ar_QA","ar_SA","ar_TN","ar_YE","ar_AE","bg_BG","cs_CZ","da_DK","da_FO","da_GL","de_AT","de_CH","de_DE","de_LU","el_GR","en_AD","en_AE","en_AG","en_AI","en_AL","en_AM","en_AN","en_AO","en_AT","en_AU","en_AW","en_AZ","en_BB","en_BE","en_BH","en_BJ","en_BM","en_BN","en_BS","en_BT","en_BW","en_BY","en_BZ","en_C2","en_CA","en_CD","en_CG","en_CH","en_CI","en_CK","en_CL","en_CM","en_CN","en_CO","en_CR","en_CV","en_CY","en_CZ","en_DE","en_DJ","en_DK","en_DM","en_DO","en_DZ","en_EC","en_EE","en_EG","en_ER","en_ES","en_ET","en_FI","en_FJ","en_FK","en_FM","en_FO","en_FR","en_GA","en_GB","en_GD","en_GE","en_GF","en_GI","en_GL","en_GM","en_GN","en_GP","en_GR","en_GT","en_GW","en_GY","en_HK","en_HN","en_HR","en_HU","en_ID","en_IE","en_IL","en_IN","en_IS","en_IT","en_JM","en_JO","en_JP","en_KE","en_KG","en_KH","en_KI","en_KM","en_KN","en_KR","en_KW","en_KY","en_KZ","en_LA","en_LC","en_LI","en_LK","en_LS","en_LT","en_LU","en_LV","en_MA","en_MC","en_MD","en_ME","en_MG","en_MH","en_MK","en_ML","en_MN","en_MQ","en_MR","en_MS","en_MT","en_MU","en_MV","en_MW","en_MY","en_MZ","en_NA","en_NC","en_NE","en_NF","en_NG","en_NI","en_NL","en_NO","en_NP","en_NR","en_NU","en_NZ","en_OM","en_PA","en_PE","en_PF","en_PG","en_PH","en_PL","en_PM","en_PN","en_PT","en_PW","en_PY","en_QA","en_RE","en_RO","en_RS","en_RU","en_RW","en_SA","en_SB","en_SC","en_SE","en_SG","en_SH","en_SI","en_SJ","en_SK","en_SL","en_SM","en_SN","en_SO","en_SR","en_ST","en_SV","en_SZ","en_TC","en_TD","en_TG","en_TH","en_TJ","en_TM","en_TN","en_TO","en_TR","en_TT","en_TV","en_TW","en_TZ","en_UA","en_UG","en_US","en_UY","en_VA","en_VC","en_VE","en_VG","en_VN","en_VU","en_WF","en_WS","en_YE","en_YT","en_ZA","en_ZM","en_ZW","es_AD","es_AI","es_AO","es_AR","es_AW","es_BB","es_BJ","es_BM","es_BO","es_BS","es_BZ","es_CD","es_CG","es_CK","es_CL","es_CO","es_CR","es_CV","es_DJ","es_DM","es_DO","es_DZ","es_EC","es_EG","es_ER","es_ES","es_ET","es_FJ","es_FK","es_FO","es_GA","es_GD","es_GE","es_GI","es_GL","es_GM","es_GN","es_GT","es_GW","es_GY","es_HN","es_IE","es_JM","es_JO","es_KE","es_KG","es_KI","es_KM","es_KN","es_KW","es_KY","es_KZ","es_LC","es_LI","es_LS","es_LU","es_MA","es_MG","es_MH","es_ML","es_MR","es_MS","es_MU","es_MW","es_MX","es_MZ","es_NA","es_NC","es_NE","es_NF","es_NI","es_NR","es_NU","es_NZ","es_OM","es_PA","es_PE","es_PF","es_PG","es_PM","es_PN","es_PW","es_PY","es_QA","es_RS","es_RW","es_SA","es_SB","es_SC","es_SH","es_SJ","es_SL","es_SM","es_SN","es_SO","es_SR","es_ST","es_SV","es_SZ","es_TC","es_TD","es_TG","es_TJ","es_TM","es_TN","es_TT","es_TV","es_UA","es_UG","es_US","es_UY","es_VA","es_VC","es_VE","es_VG","es_VU","es_WF","es_YE","es_ZM","et_EE","fi_FI","fr_AD","fr_AE","fr_AI","fr_AM","fr_AO","fr_AW","fr_AZ","fr_BB","fr_BE","fr_BF","fr_BI","fr_BJ","fr_BM","fr_BS","fr_BZ","fr_CA","fr_CD","fr_CG","fr_CH","fr_CI","fr_CK","fr_CM","fr_CV","fr_DJ","fr_DM","fr_DO","fr_DZ","fr_EC","fr_ER","fr_ET","fr_FJ","fr_FK","fr_FO","fr_FR","fr_GA","fr_GD","fr_GE","fr_GF","fr_GI","fr_GL","fr_GM","fr_GN","fr_GP","fr_GT","fr_GW","fr_GY","fr_HN","fr_IE","fr_JM","fr_JO","fr_KE","fr_KG","fr_KI","fr_KM","fr_KN","fr_KW","fr_KY","fr_KZ","fr_LC","fr_LI","fr_LS","fr_LU","fr_MA","fr_MC","fr_MG","fr_MH","fr_ML","fr_MQ","fr_MR","fr_MS","fr_MU","fr_MW","fr_MZ","fr_NA","fr_NC","fr_NE","fr_NF","fr_NI","fr_NR","fr_NU","fr_NZ","fr_OM","fr_PA","fr_PE","fr_PF","fr_PG","fr_PM","fr_PN","fr_PW","fr_QA","fr_RE","fr_RS","fr_RW","fr_SA","fr_SB","fr_SC","fr_SH","fr_SJ","fr_SL","fr_SM","fr_SN","fr_SO","fr_SR","fr_ST","fr_SV","fr_SZ","fr_TC","fr_TD","fr_TG","fr_TJ","fr_TM","fr_TN","fr_TT","fr_TV","fr_UA","fr_UG","fr_US","fr_UY","fr_VA","fr_VC","fr_VE","fr_VG","fr_VU","fr_WF","fr_YE","fr_YT","fr_ZA","fr_ZM","he_IL","hu_HU","id_ID","it_IT","ja_JP","ko_KR","lv_LV","lt_LT","ms_BN","ms_MY","nl_BE","nl_NL","pl_PL","pt_BR","pt_PT","ro_RO","ru_EE","ru_LT","ru_LV","ru_RU","ru_UA","si_LK","sk_SK","sl_SI","sq_AL","sv_SE","tl_PH","th_TH","tr_TR","vi_VN","zh_C2","zh_CN","zh_HK","zh_TW","zh_AD","zh_AE","zh_AI","zh_AO","zh_AW","zh_BB","zh_BH","zh_BJ","zh_BM","zh_BS","zh_BZ","zh_CD","zh_CG","zh_CK","zh_CL","zh_CO","zh_CV","zh_DJ","zh_DM","zh_DO","zh_DZ","zh_EC","zh_EG","zh_ER","zh_ET","zh_FJ","zh_FK","zh_FO","zh_GA","zh_GD","zh_GE","zh_GI","zh_GL","zh_GM","zh_GN","zh_GT","zh_GW","zh_GY","zh_HN","zh_IE","zh_JM","zh_JO","zh_KE","zh_KG","zh_KI","zh_KM","zh_KN","zh_KW","zh_KY","zh_KZ","zh_LC","zh_LI","zh_LS","zh_LT","zh_LU","zh_MA","zh_MG","zh_MH","zh_ML","zh_MR","zh_MS","zh_MU","zh_MW","zh_MZ","zh_NA","zh_NC","zh_NE","zh_NF","zh_NI","zh_NR","zh_NU","zh_NZ","zh_OM","zh_PA","zh_PE","zh_PF","zh_PG","zh_PM","zh_PN","zh_PW","zh_QA","zh_RS","zh_RW","zh_SA","zh_SB","zh_SC","zh_SH","zh_SJ","zh_SL","zh_SM","zh_SN","zh_SO","zh_SR","zh_ST","zh_SV","zh_SZ","zh_TC","zh_TD","zh_TG","zh_TJ","zh_TM","zh_TN","zh_TT","zh_TV","zh_UA","zh_UG","zh_US","zh_UY","zh_VA","zh_VC","zh_VE","zh_VG","zh_VU","zh_WF","zh_YE","zh_ZA","zh_ZM"];function ft(e){if(!e)return;let t;if(e.includes("-")){const[n,i]=e.split("-");t=`${n}_${i.toUpperCase()}`}else t=`${e}_${e.toUpperCase()}`;return mt.includes(t)?t:void 0}var Pt=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 wt{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n,i){return Pt(this,void 0,void 0,function*(){if(!this.window.paypalFastlaneSdk){const o=this.getPayPalFastlaneSdkConfiguration(e,t,n,i);if(yield this.loadPayPalSdk(o),!this.window.paypalFastlaneSdk)throw new h}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i,o){return Pt(this,void 0,void 0,function*(){if(!this.window.paypalGooglePay||o){const o=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i);yield this.loadPayPalSdk(o)}if(!this.window.paypalGooglePay)throw new h;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t,n){return Pt(this,void 0,void 0,function*(){if(!this.window.paypalApms){const i=this.getPayPalApmSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.paypalApms)throw new h}return this.window.paypalApms})}getPayPalMessages(e,t,n){return Pt(this,void 0,void 0,function*(){if(!this.window.paypalMessages){const i=this.getPayPalSdkMessagesConfiguration(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.paypalMessages)throw new h;return this.window.paypalMessages})}loadPayPalSdk({options:e,attributes:t}){return Pt(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,i){const{clientToken:o,initializationData:r}=e;if(!r||!r.clientId)throw new _(u.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:c,attributionId:d}=r,l=ft(i);return{options:Object.assign({"client-id":s,"merchant-id":c,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t,intent:a},l&&{locale:l}),attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":d,"data-sdk-client-token":o}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i=!0){const{clientToken:o,initializationData:r}=e;if(!r||!r.clientId)throw new _(u.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:c,buyerCountry:d,attributionId:l,isHostedCheckoutEnabled:h,isDeveloperModeApplicable:y}=r,g=h||i,p=ft(n);return{options:Object.assign(Object.assign({"client-id":s,"merchant-id":c,commit:g,components:["googlepay"],currency:t,intent:a},y&&{"buyer-country":d}),p&&{locale:p}),attributes:{"data-partner-attribution-id":l,"data-client-token":o,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new _(u.MissingPaymentMethod);const{intent:o,clientId:r,merchantId:a,buyerCountry:s,attributionId:c,isDeveloperModeApplicable:d,availableAlternativePaymentMethods:l=[],enabledAlternativePaymentMethods:h=[]}=i,y=h,g=l.filter(e=>!h.includes(e)),p=ft(n);return{options:Object.assign(Object.assign({"client-id":r,"merchant-id":a,"enable-funding":y.length>0?y:void 0,"disable-funding":g.length>0?g:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:o},d&&{"buyer-country":s}),p&&{locale:p}),attributes:{"data-partner-attribution-id":c,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new _(u.MissingPaymentMethod);const{clientId:o,merchantId:r,attributionId:a,isDeveloperModeApplicable:s,buyerCountry:c}=i,d=ft(n);return{options:Object.assign(Object.assign({"client-id":o,"merchant-id":r,components:["messages"],currency:t},s&&{"buyer-country":c}),d&&{locale:d}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}}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 vt(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 _(u.MissingPaymentMethod)}var 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 St 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 Ct(this,void 0,void 0,function*(){const d=this.service.getState(),l=null!==(r=null===(o=d.getStoreConfig())||void 0===o?void 0:o.currency.code)&&void 0!==r?r:n;if(!l)throw new _(u.MissingPaymentMethod);yield i.initialize.call(this,e,t,l);const h=i.getPaymentMethod.call(this);if(!h.initializationData)throw new _(u.MissingPaymentMethod);vt(h);const y=yield this.payPalCommerceSdk.getPayPalGooglePaySdk(h,l,d.getLocale());this.googlepayConfig=yield y.Googlepay().config();const{allowedPaymentMethods:g}=this.googlepayConfig;this.setGatewayIdentifier(null===(c=null===(s=null===(a=g[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 Ct(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 It,Ot;!function(e){e.Approved="APPROVED",e.PayerActionRequired="PAYER_ACTION_REQUIRED"}(It||(It={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(Ot||(Ot={}));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 extends oe{constructor(e,t,n,i){super(e,t),this._payPalCommerceSdk=n,this._requestSender=i}execute({payment:e}){return At(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId))throw new Y(["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 At(this,void 0,void 0,function*(){const n=this._paymentIntegrationService.getState(),i=n.getPaymentMethodOrThrow(this._getMethodId());if(!i.initializationData)throw new _(u.MissingPaymentMethod);const o=n.getCartOrThrow().currency.code,r=yield this._payPalCommerceSdk.getPayPalGooglePaySdk(i,o,n.getLocale(),!0),{status:a}=yield r.Googlepay().confirmOrder({orderId:e,paymentMethodData:t});if(a===It.PayerActionRequired)return yield r.Googlepay().initiatePayerAction({orderId:e}),Promise.resolve();if(a!==It.Approved)throw new C("Payment is not approved.");return Promise.resolve()})}getOrderId(e){return At(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},W),body:t});return n})}}const Mt=g(i=>{const o=new wt(n());return new Tt(i,new K(ae(),new St(i,o),t(),e()),o,t())},[{id:"googlepaypaypalcommerce"}]);var Et=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 kt{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n){return Et(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 h}return this.window.bigCommercePaymentsFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i){return Et(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 h;return this.window.bigCommercePaymentsGooglePay})}getPayPalApmsSdk(e,t){return Et(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 h}return this.window.bigCommercePaymentsApms})}getPayPalMessages(e,t){return Et(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 h;return this.window.bigCommercePaymentsMessages})}loadPayPalSdk({options:e,attributes:t}){return Et(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 _(u.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 _(u.MissingPaymentMethod);const{intent:r,clientId:a,merchantId:s,buyerCountry:c,attributionId:d,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:h}=o,y=l||n;return{options:Object.assign({"client-id":a,"merchant-id":s,commit:y,components:["googlepay"],currency:t,intent:r},h&&{"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 _(u.MissingPaymentMethod);const{intent:i,clientId:o,merchantId:r,buyerCountry:a,attributionId:s,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:d=[],enabledAlternativePaymentMethods:l=[]}=n,h=this.filterFundingOptions(l),y=this.filterFundingOptions(d.filter(e=>!l.includes(e)));return{options:Object.assign({"client-id":o,"merchant-id":r,"enable-funding":h.length>0?h: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 _(u.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 Nt,Dt,zt=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 Gt 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 zt(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 _(u.MissingPaymentMethod);yield i.initialize.call(this,e,t,d);const l=i.getPaymentMethod.call(this);if(!l.initializationData)throw new _(u.MissingPaymentMethod);vt(l);const h=yield this.payPalSdkHelper.getPayPalGooglePaySdk(l,d);this.googlepayConfig=yield h.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 zt(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"}(Nt||(Nt={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(Dt||(Dt={}));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 Bt 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 Y(["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 _(u.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===Nt.PayerActionRequired)return yield r.Googlepay().initiatePayerAction({orderId:e}),Promise.resolve();if(a!==Nt.Approved)throw new C("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},W),body:t});return n})}}const Lt=g(i=>{const o=new kt(n());return new Bt(i,new K(ae(),new Gt(i,o),t(),e()),o,t())},[{id:"googlepay_bigcommerce_payments"}]);var xt=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 jt extends F{constructor(e,t){super("worldlinena",e),this.formPoster=t}extraPaymentData(){return xt(this,void 0,void 0,function*(){return Promise.resolve({browser_info:m()})})}processAdditionalAction(e){return xt(this,void 0,void 0,function*(){if(!function(e){return f(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 Y(["formUrl","threeDSSessionData","creq"]);return new Promise(e=>{this.formPoster.postForm(n,{threeDSSessionData:i,creq:o},e,"_top")})})}}const Ft=g(n=>new oe(n,new K(ae(),new jt(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);class Vt extends l{constructor(e){super(e||"Not implemented."),this.name="NotImplementedError",this.type="not_implemented"}}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 Wt{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){var t,n;return Ut(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId)||!ne(e.methodId))throw new C('Unable to proceed because "methodId" is not a valid key.');this._methodId=e.methodId;const i=e[this._getMethodId()];if(!i)throw new C("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 Vt('In order to sign in via Google Pay, the shopper must click on "Google Pay" button.'))}signOut(){var e;return Ut(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})=>Ut(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:h}=c.includes(t)?yield this._googlePayPaymentProcessor.handleCoupons(o):{},u=h;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:z.FINAL,totalPrice:y})},d&&{newShippingOptionParameters:d}),l&&{newOfferInfo:l}),u&&{error:u})})}}}_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=>Ut(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 P;n=new H(JSON.stringify(t))}throw null==e||e(new H("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){return Ut(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 A(this._methodId,()=>new v(w.PaymentNotInitialized))}}const Ht=g(n=>{const i=t();return new Wt(n,new K(ae(),new F("adyen",n),i,e()))},[{id:"googlepayadyenv2"}]),qt=g(n=>{const i=t();return new Wt(n,new K(ae(),new F("adyen",n),i,e()))},[{id:"googlepayadyenv3"}]),Kt=g(n=>new Wt(n,new K(ae(),new ue(n),t(),e())),[{id:"googlepayauthorizenet"}]),Yt=g(n=>{const i=t();return new Wt(n,new K(ae(),new fe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]),Zt=g(n=>new Wt(n,new K(ae(),new we(n),t(),e())),[{id:"googlepaycybersourcev2"}]),Jt=g(n=>new Wt(n,new K(ae(),new we(n),t(),e())),[{id:"googlepaybnz"}]),Qt=g(n=>new Wt(n,new K(ae(),new Ce(n),t(),e())),[{id:"googlepayorbital"}]),Xt=g(i=>new Wt(i,new K(ae(),new Ue(i,new Be(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeocs"}]),$t=g(i=>new Wt(i,new K(ae(),new Ue(i,new Be(n())),t(),e())),[{id:"googlepaystripeupe"}]),en=g(n=>new Wt(n,new K(ae(),new He(n),t(),e())),[{id:"googlepayworldpayaccess"}]),tn=g(i=>{const o=t(),r=window,a=new Je(i),s=new dt(new ut(n(),r,a));return new Wt(i,new K(ae(),new pt(i,s),o,e()))},[{id:"googlepaybraintree"}]),nn=g(i=>new Wt(i,new K(ae(),new St(i,new wt(n())),t(),e())),[{id:"googlepaypaypalcommerce"}]),on=g(i=>new Wt(i,new K(ae(),new Gt(i,new kt(n())),t(),e())),[{id:"googlepay_bigcommerce_payments"}]),rn=g(n=>new Wt(n,new K(ae(),new jt(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);class an 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 sn=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 cn{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){var t,n,i;return sn(this,void 0,void 0,function*(){if(!e.methodId||!ne(e.methodId))throw new C('Unable to proceed because "methodId" is not a valid key.');if(this._methodId=e.methodId,!e.containerId)throw new C('Unable to proceed because "containerId" is not a valid key.');const o=e[this._getMethodOrThrow()];if(!o)throw new C("Unable to proceed without valid options.");const{buyNowInitializeOptions:r,currencyCode:a,buttonColor:s,buttonType:c,onError:d}=o;let l,h=this._paymentIntegrationService.getState();try{l=h.getPaymentMethodOrThrow(this._getMethodOrThrow())}catch(e){h=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodOrThrow()),l=h.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 C('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=>sn(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 P;n=new H(JSON.stringify(t))}throw null==e||e(new H("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){var e;return sn(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})=>sn(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):{},h=l;return this._buyNowInitializeOptions?this._getBuyNowTransactionInfo(c,d,h):this._getTransactionInfo(c,d,h)})}}}_createBuyNowCartOrThrow(e){return sn(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 an(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:z.FINAL})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})}_getTransactionInfo(e,t,n){return sn(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:z.FINAL,totalPrice:i})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})})}_getMethodOrThrow(){return A(this._methodId,()=>new v(w.PaymentNotInitialized))}_getCurrencyCodeOrThrow(){return A(this._currencyCode,()=>new C('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}}const dn=g(i=>{const o=t(),r=window,a=new Je(i),s=new dt(new ut(n(),r,a));return new cn(i,new K(ae(),new pt(i,s),o,e()))},[{id:"googlepaybraintree"}]),ln=g(i=>new cn(i,new K(ae(),new St(i,new wt(n())),t(),e())),[{id:"googlepaypaypalcommerce"}]),hn=g(i=>new cn(i,new K(ae(),new Gt(i,new kt(n())),t(),e())),[{id:"googlepay_bigcommerce_payments"}]),un=g(n=>{const i=t();return new cn(n,new K(ae(),new F("adyen",n),i,e()))},[{id:"googlepayadyenv2"}]),yn=g(n=>{const i=t();return new cn(n,new K(ae(),new F("adyen",n),i,e()))},[{id:"googlepayadyenv3"}]),gn=g(n=>new cn(n,new K(ae(),new ue(n),t(),e())),[{id:"googlepayauthorizenet"}]),pn=g(n=>{const i=t();return new cn(n,new K(ae(),new fe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]),_n=g(n=>new cn(n,new K(ae(),new we(n),t(),e())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]),mn=g(n=>new cn(n,new K(ae(),new Ce(n),t(),e())),[{id:"googlepayorbital"}]),fn=g(i=>new cn(i,new K(ae(),new Ue(i,new Be(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]),Pn=g(n=>new cn(n,new K(ae(),new He(n),t(),e())),[{id:"googlepayworldpayaccess"}]),wn=g(n=>new cn(n,new K(ae(),new jt(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);export{un as createGooglePayAdyenV2ButtonStrategy,Ht as createGooglePayAdyenV2CustomerStrategy,se as createGooglePayAdyenV2PaymentStrategy,yn as createGooglePayAdyenV3ButtonStrategy,qt as createGooglePayAdyenV3CustomerStrategy,he as createGooglePayAdyenV3PaymentStrategy,gn as createGooglePayAuthorizeDotNetButtonStrategy,Kt as createGooglePayAuthorizeDotNetCustomerStrategy,ye as createGooglePayAuthorizeNetPaymentStrategy,hn as createGooglePayBigCommercePaymentsButtonStrategy,on as createGooglePayBigCommercePaymentsCustomerStrategy,Lt as createGooglePayBigCommercePaymentsPaymentStrategy,Jt as createGooglePayBnzCustomerStrategy,dn as createGooglePayBraintreeButtonStrategy,tn as createGooglePayBraintreeCustomerStrategy,_t as createGooglePayBraintreePaymentStrategy,pn as createGooglePayCheckoutComButtonStrategy,Yt as createGooglePayCheckoutComCustomerStrategy,Pe as createGooglePayCheckoutComPaymentStrategy,_n as createGooglePayCybersourceButtonStrategy,Zt as createGooglePayCybersourceCustomerStrategy,ve as createGooglePayCybersourcePaymentStrategy,mn as createGooglePayOrbitalButtonStrategy,Qt as createGooglePayOrbitalCustomerStrategy,Se as createGooglePayOrbitalPaymentStrategy,Mt as createGooglePayPPCPPaymentStrategy,ln as createGooglePayPayPalCommerceButtonStrategy,nn as createGooglePayPayPalCommerceCustomerStrategy,fn as createGooglePayStripeButtonStrategy,Xt as createGooglePayStripeCustomerStrategy,We as createGooglePayStripePaymentStrategy,$t as createGooglePayStripeUpeCustomerStrategy,wn as createGooglePayTdOnlineMartButtonStrategy,rn as createGooglePayTdOnlineMartCustomerStrategy,Ft as createGooglePayTdOnlineMartPaymentStrategy,Pn as createGooglePayWorldpayAccessButtonStrategy,en as createGooglePayWorldpayAccessCustomerStrategy,qe 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 h 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 u;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 h;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"}(u||(u={}));class _ extends l{constructor(e){super(function(e){switch(e){case u.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case u.MissingCart:return"Unable to proceed because cart data is unavailable.";case u.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case u.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case u.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case u.MissingCheckoutConfig:case u.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case u.MissingOrder:return"Unable to proceed because order data is unavailable.";case u.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case u.MissingPayment:return"Unable to proceed because payment data is unavailable.";case u.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case u.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case u.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 m(){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 f=e=>"object"==typeof e&&null!==e&&"body"in e;class P extends l{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}var w;!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"}(w||(w={}));class v extends l{constructor(e){super(function(e){switch(e){case w.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case w.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case w.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case w.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 C extends l{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}function S(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 b{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 C("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 C("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 b(this._storeConfig.shopperCurrency),this._storeFormatter=new b(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?S(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,S(e.prototype,n,i))}),t}(e)}],I);const O=I;function A(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}function T(){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 M(e,t,n=!0){var i;return null!==(i=e[t])&&void 0!==i?i:n}var E,k,N,D,z,G,R,B,L;function x(e){return e in G}!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"}(k||(k={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(N||(N={})),function(e){e.pill="pill",e.rect="rect"}(D||(D={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(z||(z={})),function(e){e.AMEX="AMEX",e.DISCOVER="DISCOVER",e.INTERAC="INTERAC",e.JCB="JCB",e.MC="MASTERCARD",e.VISA="VISA"}(G||(G={})),function(e){e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION"}(R||(R={})),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"}(B||(B={})),function(e){e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER"}(L||(L={}));var j=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 _(u.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 j(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()?[R.OFFER,R.SHIPPING_ADDRESS,R.SHIPPING_OPTION]:[R.OFFER]}getCallbackTriggers(){return{availableTriggers:[L.INITIALIZE,L.SHIPPING_ADDRESS,L.SHIPPING_OPTION,L.OFFER],initializationTrigger:[L.INITIALIZE],addressChangeTriggers:[L.INITIALIZE,L.SHIPPING_ADDRESS],shippingOptionsChangeTriggers:[L.SHIPPING_OPTION],offerChangeTriggers:[L.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 _(u.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:z.ESTIMATED})}return Object.assign(Object.assign({},n&&{countryCode:n}),{currencyCode:e,totalPriceStatus:z.ESTIMATED,totalPrice:"0"})}isWebViewWithRestrictions(){return null!==this._isWebViewExperimentOn?this._isWebViewExperimentOn&&T():T()}setIsWebViewExperimentOn(e){this._isWebViewExperimentOn=e}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData().gatewayMerchantId;if(!e)throw new C("Unable to proceed, gatewayMerchantId is missing.");return{gateway:this._gatewayIdentifier,gatewayMerchantId:e}}getCardParameters(){return{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:this.getPaymentMethod().supportedCards.filter(x).map(e=>G[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 j(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)),h=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==h?void 0:h.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==h?void 0:h.id)||l[0].id)),{defaultSelectedOptionId:e,shippingOptions:l}}})}handleShippingOptionChange(e){return j(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=M(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 j(this,void 0,void 0,function*(){const{redemptionCodes:t=[]}=e,{offers:n}=this.getAppliedCoupons()||{};let i;return yield t.reduce((e,t)=>j(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)=>j(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 j(this,void 0,void 0,function*(){let t;try{yield this._paymentIntegrationService.applyCoupon(e)}catch(e){return e instanceof Error&&(t={reason:B.OFFER_INVALID,message:e.message,intent:L.OFFER}),t}})}setShouldRequestShipping(e){this._shouldRequestShipping=e}getGooglePayInitializationData(){return A(this.getPaymentMethod().initializationData,()=>new C("Missing initialization data."))}getPaymentMethod(){return A(this._getPaymentMethodFn,()=>new v(w.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=M(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:h,phoneNumber:u}=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:h,phone:u||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 A(this._currencyCode,()=>new C('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 _(u.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:m()})})}processAdditionalAction(e){return V(this,void 0,void 0,function*(){if(!f(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 P)})}_getAdyenClient(){if(!this._adyenClient)throw new v(w.PaymentNotInitialized);return this._adyenClient}}const W={"X-Checkout-SDK-Version":"1.904.2"};class H 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 q=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 K{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 q(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 q(this,void 0,void 0,function*(){yield this._buildWidgetPayloads(),yield this._determineReadinessToPay(),this._prefetchGooglePaymentData()})}getNonce(e){return this._gateway.getNonce(e)}extraPaymentData(){return q(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 q(this,void 0,void 0,function*(){const e=this._getPaymentDataRequest();return this._getPaymentsClient().loadPaymentData(e)})}setExternalCheckoutXhr(e,t){return q(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t)})}setExternalCheckoutForm(e,t,n){return q(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 q(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 q(this,void 0,void 0,function*(){return this._gateway.handleShippingAddressChange(e)})}handleShippingOptionChange(e){return q(this,void 0,void 0,function*(){yield this._gateway.handleShippingOptionChange(e)})}handleCoupons(e){return q(this,void 0,void 0,function*(){return this._gateway.handleCoupons(e)})}getTotalPrice(){return this._gateway.getTotalPrice()}_setExternalCheckout(e,t,n=!1,i){return q(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"},W),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 q(this,void 0,void 0,function*(){try{const{result:e}=yield this._getPaymentsClient().isReadyToPay(this._getIsReadyToPayRequest());if(!1===e)throw new H("Google Pay is not supported by the current device and browser, please try another payment method.")}catch(e){if(e instanceof H)throw e;throw new H}})}_buildButtonPayloads(){this._baseCardPaymentMethod={type:"CARD",parameters:this._gateway.getCardParameters()}}_buildWidgetPayloads(){return q(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 A(e,()=>new v(w.PaymentNotInitialized))}}class Y extends C{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 Z 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 J={size:70,color:"#d9d9d9",backgroundColor:"#ffffff"},Q={position:"fixed","background-color":"rgba(0, 0, 0, 0.4)","z-index":"1000"},X="embedded-checkout-loading-indicator-rotation";class ${constructor(e){this.styles=Object.assign(Object.assign({},J),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=`${X} 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(X))return;const t=document.createElement("style");t.id=X,null===(e=document.head)||void 0===e||e.appendChild(t),t.sheet instanceof CSSStyleSheet&&t.sheet.insertRule(`\n @keyframes ${X} {\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:Q})}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 C('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 C("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 Y(["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 Z)}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 C("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(),this._isDirectPayOnClickEnabled()?yield this._interactWithPaymentSheetAndPay():yield this._interactWithPaymentSheet()}catch(e){let n=e;if(this._toggleLoadingIndicator(!1),ee(e)){if("CANCELED"===e.statusCode)throw new P;n=new H(JSON.stringify(e))}throw null==t||t(new H("An error occurred while requesting your Google Pay payment details.")),n}finally{this._toggleBlockDeinitialization(!1)}null==e||e()})}_interactWithPaymentSheetAndPay(){return ie(this,void 0,void 0,function*(){const e=yield this._googlePayPaymentProcessor.showPaymentSheet();this._toggleBlockDeinitialization(!0),this._toggleLoadingIndicator(!0);const t=this._getMethodId(),n=this._paymentIntegrationService.getState(),{features:i}=n.getStoreConfigOrThrow().checkoutSettings,o=M(i,"PI-5031.google_pay_dont_override_address"),r=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(e);r&&!o&&(yield this._paymentIntegrationService.updateBillingAddress(r)),yield this._googlePayPaymentProcessor.setExternalCheckoutXhr(t,e),yield this._paymentIntegrationService.loadCheckout(),yield this._paymentIntegrationService.loadPaymentMethod(t);const a=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(t);yield this._googlePayPaymentProcessor.initialize(()=>a),yield this.execute({useStoreCredit:!1,payment:{methodId:t}}),this._completeCheckoutFlow()})}_completeCheckoutFlow(){window.location.replace("/checkout/order-confirmation"),this._toggleLoadingIndicator(!1),this._toggleBlockDeinitialization(!1)}_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=M(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 A(this._methodId,()=>new v(w.PaymentNotInitialized))}_getIsSignedInOrThrow(){return ie(this,void 0,void 0,function*(){try{return!!(yield this._googlePayPaymentProcessor.getNonce(this._getMethodId()))}catch(e){if(e instanceof _&&e.subtype===u.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 _&&(n=e.message)}if(t){const{newOfferInfo:t,error:n}=yield this._googlePayPaymentProcessor.handleCoupons(e);return{newOfferInfo:t,error:n}}return{error:{reason:B.OFFER_INVALID,message:n,intent:L.OFFER}}})}_getGooglePayClientOptions(e){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:({callbackTrigger:t,offerData:n})=>ie(this,void 0,void 0,function*(){if(t!==L.INITIALIZE&&t!==L.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:z.FINAL,totalPrice:c})},o&&{newOfferInfo:o}),a&&{error:a})})}}}_isDirectPayOnClickEnabled(){const{features:e}=this._paymentIntegrationService.getState().getStoreConfigOrThrow().checkoutSettings;return M(e,"PI-5111.google_pay_direct_pay_on_click")}_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 h;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 K(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 h;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 _(u.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(!f(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:m()})})}_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 P)})}_getAdyenClient(){if(!this._adyenClient)throw new v(w.PaymentNotInitialized);return this._adyenClient}}const he=g(o=>new oe(o,new K(ae(),new le(o,new ce(n(),i())),t(),e())),[{id:"googlepayadyenv3"}]);class ue 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 _(u.MissingPaymentMethod)}(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.paymentGatewayId}}}const ye=g(n=>new oe(n,new K(ae(),new ue(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 _e(e){if(!function(e){return"checkoutcomkey"in e}(e))throw new _(u.MissingPaymentMethod)}var me=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 fe extends F{constructor(e,t){super("checkoutltd",e),this._requestSender=t}processAdditionalAction(e){return new Promise((t,n)=>{if(f(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 me(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 C("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 _(u.MissingPaymentToken)}(i),n.nonce=yield this._tokenize(i),n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return _e(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.checkoutcomkey}}_tokenize(e){return me(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();_e(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 Pe=g(n=>{const i=t();return new oe(n,new K(ae(),new fe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]);class we 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 ve=g(n=>new oe(n,new K(ae(),new we(n),t(),e())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]);class Ce 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 Se=g(n=>new oe(n,new K(ae(),new Ce(n),t(),e())),[{id:"googlepayorbital"}]);var be,Ie,Oe,Ae,Te,Me,Ee,ke,Ne,De,ze,Ge;!function(e){e.SHIPPING="shipping",e.BILLING="billing"}(be||(be={})),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"}(Ae||(Ae={})),function(e){e.SUCCESS="success",e.ERROR="error"}(Te||(Te={})),function(e){e.CreditCard="card",e.ACH="us_bank_account",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"}(Me||(Me={})),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"}(ke||(ke={})),function(e){e.PAYMENT="payment",e.AUTHENTICATION="linkAuthentication",e.SHIPPING="address",e.EXPRESS_CHECKOUT="expressCheckout"}(Ne||(Ne={})),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"}(De||(De={})),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"}(ze||(ze={})),function(e){e.ON_SESSION="on_session",e.OFF_SESSION="off_session"}(Ge||(Ge={}));var Re=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 Be{constructor(e,t=window){this.scriptLoader=e,this.stripeWindow=t}getStripeClient(e,t,n,i,o){return Re(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 Re(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 Re(this,void 0,void 0,function*(){const t=this.stripeWindow.bcStripeElements;t&&(t.update(e),yield t.fetchUpdates())})}getStripeCheckout(e,t){return Re(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 Re(this,void 0,void 0,function*(){if(!this.stripeWindow.Stripe&&(yield this.scriptLoader.loadScript(this.getScriptUrl(e)),!this.stripeWindow.Stripe))throw new h;return this.stripeWindow.Stripe})}getScriptUrl(e){return e&&e!==ke.V3?`https://js.stripe.com/${e}/stripe.js`:"https://js.stripe.com/v3/"}getStoredStripeCheckout(e){return Re(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(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 Le={body:{},headers:{},status:0};class xe extends l{constructor(e,{message:t,errors:n}={}){const{body:i,headers:o,status:r}=e||Le;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 je=["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 _(u.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 C("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 _(u.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 Y(["payment"]);if(!f(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 P;throw new H}if(!(null==r?void 0:r.paymentIntent)&&!a)throw new xe;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,ke.CLOVER):this.scriptLoader.getStripeClient(e,n,ke.V3,je,"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 We=g(i=>new oe(i,new K(ae(),new Ue(i,new Be(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]);class He 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 qe=g(n=>new oe(n,new K(ae(),new He(n),t(),e())),[{id:"googlepayworldpayaccess"}]),Ke="3.128.0",Ye="3.123.2",Ze="3.106.0";class Je{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()||(M(t,"PAYPAL-5809.braintree_hosted_fields_fix_version")?Ke:M(t,"PAYPAL-5636.update_braintree_sdk_version")?Ye:Ze)}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 Qe extends l{constructor(e){super(e||"Unsupported browser error"),this.name="UnsupportedBrowserError",this.type="unsupported_browser"}}var Xe,$e,et,tt,nt,it,ot;!function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(Xe||(Xe={})),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 Qe;this.braintreeVenmo=i}return this.braintreeVenmo})}setClientToken(e){this.clientToken=e}getClientTokenOrThrow(){if(!this.clientToken)throw new v(w.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={[Ze]:{[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"},[Ye]:{[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"},[Ke]:{[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 ht=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 ut{constructor(e,t,n){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSDKVersionManager=n}loadClient(){return ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.Client,"client.min.js")})}loadFastlane(){return ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.Fastlane,"fastlane.min.js")})}loadPaypalCheckout(){return ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.PaypalCheckout,"paypal-checkout.min.js")})}loadPaypal(){return ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.Paypal,"paypal.min.js")})}loadLocalPayment(){return ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.LocalPayment,"local-payment.min.js")})}loadDataCollector(){return ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.DataCollector,"data-collector.min.js")})}loadUsBankAccount(){return ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.UsBankAccount,"us-bank-account.min.js")})}loadGooglePayment(){return ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.GooglePayment,"google-payment.min.js")})}load3DS(){return ht(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 ht(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(at.HostedFields,"hosted-fields.min.js")})}loadVisaCheckoutSdk(e){return ht(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 h;return this.braintreeHostWindow.V})})}loadBraintreeModuleOrThrow(e,t){return ht(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 h;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 _(u.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 _(u.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 C("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 _(u.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 _(u.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 _t=g(i=>{const o=t(),r=window,a=new Je(i),s=new dt(new ut(n(),r,a));return new oe(i,new K(ae(),new pt(i,s),o,e()))},[{id:"googlepaybraintree"}]),mt=["ar_BH","ar_DZ","ar_EG","ar_JO","ar_KW","ar_MA","ar_OM","ar_QA","ar_SA","ar_TN","ar_YE","ar_AE","bg_BG","cs_CZ","da_DK","da_FO","da_GL","de_AT","de_CH","de_DE","de_LU","el_GR","en_AD","en_AE","en_AG","en_AI","en_AL","en_AM","en_AN","en_AO","en_AT","en_AU","en_AW","en_AZ","en_BB","en_BE","en_BH","en_BJ","en_BM","en_BN","en_BS","en_BT","en_BW","en_BY","en_BZ","en_C2","en_CA","en_CD","en_CG","en_CH","en_CI","en_CK","en_CL","en_CM","en_CN","en_CO","en_CR","en_CV","en_CY","en_CZ","en_DE","en_DJ","en_DK","en_DM","en_DO","en_DZ","en_EC","en_EE","en_EG","en_ER","en_ES","en_ET","en_FI","en_FJ","en_FK","en_FM","en_FO","en_FR","en_GA","en_GB","en_GD","en_GE","en_GF","en_GI","en_GL","en_GM","en_GN","en_GP","en_GR","en_GT","en_GW","en_GY","en_HK","en_HN","en_HR","en_HU","en_ID","en_IE","en_IL","en_IN","en_IS","en_IT","en_JM","en_JO","en_JP","en_KE","en_KG","en_KH","en_KI","en_KM","en_KN","en_KR","en_KW","en_KY","en_KZ","en_LA","en_LC","en_LI","en_LK","en_LS","en_LT","en_LU","en_LV","en_MA","en_MC","en_MD","en_ME","en_MG","en_MH","en_MK","en_ML","en_MN","en_MQ","en_MR","en_MS","en_MT","en_MU","en_MV","en_MW","en_MY","en_MZ","en_NA","en_NC","en_NE","en_NF","en_NG","en_NI","en_NL","en_NO","en_NP","en_NR","en_NU","en_NZ","en_OM","en_PA","en_PE","en_PF","en_PG","en_PH","en_PL","en_PM","en_PN","en_PT","en_PW","en_PY","en_QA","en_RE","en_RO","en_RS","en_RU","en_RW","en_SA","en_SB","en_SC","en_SE","en_SG","en_SH","en_SI","en_SJ","en_SK","en_SL","en_SM","en_SN","en_SO","en_SR","en_ST","en_SV","en_SZ","en_TC","en_TD","en_TG","en_TH","en_TJ","en_TM","en_TN","en_TO","en_TR","en_TT","en_TV","en_TW","en_TZ","en_UA","en_UG","en_US","en_UY","en_VA","en_VC","en_VE","en_VG","en_VN","en_VU","en_WF","en_WS","en_YE","en_YT","en_ZA","en_ZM","en_ZW","es_AD","es_AI","es_AO","es_AR","es_AW","es_BB","es_BJ","es_BM","es_BO","es_BS","es_BZ","es_CD","es_CG","es_CK","es_CL","es_CO","es_CR","es_CV","es_DJ","es_DM","es_DO","es_DZ","es_EC","es_EG","es_ER","es_ES","es_ET","es_FJ","es_FK","es_FO","es_GA","es_GD","es_GE","es_GI","es_GL","es_GM","es_GN","es_GT","es_GW","es_GY","es_HN","es_IE","es_JM","es_JO","es_KE","es_KG","es_KI","es_KM","es_KN","es_KW","es_KY","es_KZ","es_LC","es_LI","es_LS","es_LU","es_MA","es_MG","es_MH","es_ML","es_MR","es_MS","es_MU","es_MW","es_MX","es_MZ","es_NA","es_NC","es_NE","es_NF","es_NI","es_NR","es_NU","es_NZ","es_OM","es_PA","es_PE","es_PF","es_PG","es_PM","es_PN","es_PW","es_PY","es_QA","es_RS","es_RW","es_SA","es_SB","es_SC","es_SH","es_SJ","es_SL","es_SM","es_SN","es_SO","es_SR","es_ST","es_SV","es_SZ","es_TC","es_TD","es_TG","es_TJ","es_TM","es_TN","es_TT","es_TV","es_UA","es_UG","es_US","es_UY","es_VA","es_VC","es_VE","es_VG","es_VU","es_WF","es_YE","es_ZM","et_EE","fi_FI","fr_AD","fr_AE","fr_AI","fr_AM","fr_AO","fr_AW","fr_AZ","fr_BB","fr_BE","fr_BF","fr_BI","fr_BJ","fr_BM","fr_BS","fr_BZ","fr_CA","fr_CD","fr_CG","fr_CH","fr_CI","fr_CK","fr_CM","fr_CV","fr_DJ","fr_DM","fr_DO","fr_DZ","fr_EC","fr_ER","fr_ET","fr_FJ","fr_FK","fr_FO","fr_FR","fr_GA","fr_GD","fr_GE","fr_GF","fr_GI","fr_GL","fr_GM","fr_GN","fr_GP","fr_GT","fr_GW","fr_GY","fr_HN","fr_IE","fr_JM","fr_JO","fr_KE","fr_KG","fr_KI","fr_KM","fr_KN","fr_KW","fr_KY","fr_KZ","fr_LC","fr_LI","fr_LS","fr_LU","fr_MA","fr_MC","fr_MG","fr_MH","fr_ML","fr_MQ","fr_MR","fr_MS","fr_MU","fr_MW","fr_MZ","fr_NA","fr_NC","fr_NE","fr_NF","fr_NI","fr_NR","fr_NU","fr_NZ","fr_OM","fr_PA","fr_PE","fr_PF","fr_PG","fr_PM","fr_PN","fr_PW","fr_QA","fr_RE","fr_RS","fr_RW","fr_SA","fr_SB","fr_SC","fr_SH","fr_SJ","fr_SL","fr_SM","fr_SN","fr_SO","fr_SR","fr_ST","fr_SV","fr_SZ","fr_TC","fr_TD","fr_TG","fr_TJ","fr_TM","fr_TN","fr_TT","fr_TV","fr_UA","fr_UG","fr_US","fr_UY","fr_VA","fr_VC","fr_VE","fr_VG","fr_VU","fr_WF","fr_YE","fr_YT","fr_ZA","fr_ZM","he_IL","hu_HU","id_ID","it_IT","ja_JP","ko_KR","lv_LV","lt_LT","ms_BN","ms_MY","nl_BE","nl_NL","pl_PL","pt_BR","pt_PT","ro_RO","ru_EE","ru_LT","ru_LV","ru_RU","ru_UA","si_LK","sk_SK","sl_SI","sq_AL","sv_SE","tl_PH","th_TH","tr_TR","vi_VN","zh_C2","zh_CN","zh_HK","zh_TW","zh_AD","zh_AE","zh_AI","zh_AO","zh_AW","zh_BB","zh_BH","zh_BJ","zh_BM","zh_BS","zh_BZ","zh_CD","zh_CG","zh_CK","zh_CL","zh_CO","zh_CV","zh_DJ","zh_DM","zh_DO","zh_DZ","zh_EC","zh_EG","zh_ER","zh_ET","zh_FJ","zh_FK","zh_FO","zh_GA","zh_GD","zh_GE","zh_GI","zh_GL","zh_GM","zh_GN","zh_GT","zh_GW","zh_GY","zh_HN","zh_IE","zh_JM","zh_JO","zh_KE","zh_KG","zh_KI","zh_KM","zh_KN","zh_KW","zh_KY","zh_KZ","zh_LC","zh_LI","zh_LS","zh_LT","zh_LU","zh_MA","zh_MG","zh_MH","zh_ML","zh_MR","zh_MS","zh_MU","zh_MW","zh_MZ","zh_NA","zh_NC","zh_NE","zh_NF","zh_NI","zh_NR","zh_NU","zh_NZ","zh_OM","zh_PA","zh_PE","zh_PF","zh_PG","zh_PM","zh_PN","zh_PW","zh_QA","zh_RS","zh_RW","zh_SA","zh_SB","zh_SC","zh_SH","zh_SJ","zh_SL","zh_SM","zh_SN","zh_SO","zh_SR","zh_ST","zh_SV","zh_SZ","zh_TC","zh_TD","zh_TG","zh_TJ","zh_TM","zh_TN","zh_TT","zh_TV","zh_UA","zh_UG","zh_US","zh_UY","zh_VA","zh_VC","zh_VE","zh_VG","zh_VU","zh_WF","zh_YE","zh_ZA","zh_ZM"];function ft(e){if(!e)return;let t;if(e.includes("-")){const[n,i]=e.split("-");t=`${n}_${i.toUpperCase()}`}else t=`${e}_${e.toUpperCase()}`;return mt.includes(t)?t:void 0}var Pt=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 wt{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n,i){return Pt(this,void 0,void 0,function*(){if(!this.window.paypalFastlaneSdk){const o=this.getPayPalFastlaneSdkConfiguration(e,t,n,i);if(yield this.loadPayPalSdk(o),!this.window.paypalFastlaneSdk)throw new h}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i,o){return Pt(this,void 0,void 0,function*(){if(!this.window.paypalGooglePay||o){const o=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i);yield this.loadPayPalSdk(o)}if(!this.window.paypalGooglePay)throw new h;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t,n){return Pt(this,void 0,void 0,function*(){if(!this.window.paypalApms){const i=this.getPayPalApmSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.paypalApms)throw new h}return this.window.paypalApms})}getPayPalMessages(e,t,n){return Pt(this,void 0,void 0,function*(){if(!this.window.paypalMessages){const i=this.getPayPalSdkMessagesConfiguration(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.paypalMessages)throw new h;return this.window.paypalMessages})}loadPayPalSdk({options:e,attributes:t}){return Pt(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,i){const{clientToken:o,initializationData:r}=e;if(!r||!r.clientId)throw new _(u.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:c,attributionId:d}=r,l=ft(i);return{options:Object.assign({"client-id":s,"merchant-id":c,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t,intent:a},l&&{locale:l}),attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":d,"data-sdk-client-token":o}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i=!0){const{clientToken:o,initializationData:r}=e;if(!r||!r.clientId)throw new _(u.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:c,buyerCountry:d,attributionId:l,isHostedCheckoutEnabled:h,isDeveloperModeApplicable:y}=r,g=h||i,p=ft(n);return{options:Object.assign(Object.assign({"client-id":s,"merchant-id":c,commit:g,components:["googlepay"],currency:t,intent:a},y&&{"buyer-country":d}),p&&{locale:p}),attributes:{"data-partner-attribution-id":l,"data-client-token":o,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new _(u.MissingPaymentMethod);const{intent:o,clientId:r,merchantId:a,buyerCountry:s,attributionId:c,isDeveloperModeApplicable:d,availableAlternativePaymentMethods:l=[],enabledAlternativePaymentMethods:h=[]}=i,y=h,g=l.filter(e=>!h.includes(e)),p=ft(n);return{options:Object.assign(Object.assign({"client-id":r,"merchant-id":a,"enable-funding":y.length>0?y:void 0,"disable-funding":g.length>0?g:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:o},d&&{"buyer-country":s}),p&&{locale:p}),attributes:{"data-partner-attribution-id":c,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new _(u.MissingPaymentMethod);const{clientId:o,merchantId:r,attributionId:a,isDeveloperModeApplicable:s,buyerCountry:c}=i,d=ft(n);return{options:Object.assign(Object.assign({"client-id":o,"merchant-id":r,components:["messages"],currency:t},s&&{"buyer-country":c}),d&&{locale:d}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}}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 vt(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 _(u.MissingPaymentMethod)}var 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 St 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 Ct(this,void 0,void 0,function*(){const d=this.service.getState(),l=null!==(r=null===(o=d.getStoreConfig())||void 0===o?void 0:o.currency.code)&&void 0!==r?r:n;if(!l)throw new _(u.MissingPaymentMethod);yield i.initialize.call(this,e,t,l);const h=i.getPaymentMethod.call(this);if(!h.initializationData)throw new _(u.MissingPaymentMethod);vt(h);const y=yield this.payPalCommerceSdk.getPayPalGooglePaySdk(h,l,d.getLocale());this.googlepayConfig=yield y.Googlepay().config();const{allowedPaymentMethods:g}=this.googlepayConfig;this.setGatewayIdentifier(null===(c=null===(s=null===(a=g[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 Ct(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 It,Ot;!function(e){e.Approved="APPROVED",e.PayerActionRequired="PAYER_ACTION_REQUIRED"}(It||(It={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(Ot||(Ot={}));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 extends oe{constructor(e,t,n,i){super(e,t),this._payPalCommerceSdk=n,this._requestSender=i}execute({payment:e}){return At(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId))throw new Y(["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 At(this,void 0,void 0,function*(){const n=this._paymentIntegrationService.getState(),i=n.getPaymentMethodOrThrow(this._getMethodId());if(!i.initializationData)throw new _(u.MissingPaymentMethod);const o=n.getCartOrThrow().currency.code,r=yield this._payPalCommerceSdk.getPayPalGooglePaySdk(i,o,n.getLocale(),!0),{status:a}=yield r.Googlepay().confirmOrder({orderId:e,paymentMethodData:t});if(a===It.PayerActionRequired)return yield r.Googlepay().initiatePayerAction({orderId:e}),Promise.resolve();if(a!==It.Approved)throw new C("Payment is not approved.");return Promise.resolve()})}getOrderId(e){return At(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},W),body:t});return n})}}const Mt=g(i=>{const o=new wt(n());return new Tt(i,new K(ae(),new St(i,o),t(),e()),o,t())},[{id:"googlepaypaypalcommerce"}]);var Et=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 kt{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n){return Et(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 h}return this.window.bigCommercePaymentsFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i){return Et(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 h;return this.window.bigCommercePaymentsGooglePay})}getPayPalApmsSdk(e,t){return Et(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 h}return this.window.bigCommercePaymentsApms})}getPayPalMessages(e,t){return Et(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 h;return this.window.bigCommercePaymentsMessages})}loadPayPalSdk({options:e,attributes:t}){return Et(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 _(u.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 _(u.MissingPaymentMethod);const{intent:r,clientId:a,merchantId:s,buyerCountry:c,attributionId:d,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:h}=o,y=l||n;return{options:Object.assign({"client-id":a,"merchant-id":s,commit:y,components:["googlepay"],currency:t,intent:r},h&&{"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 _(u.MissingPaymentMethod);const{intent:i,clientId:o,merchantId:r,buyerCountry:a,attributionId:s,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:d=[],enabledAlternativePaymentMethods:l=[]}=n,h=this.filterFundingOptions(l),y=this.filterFundingOptions(d.filter(e=>!l.includes(e)));return{options:Object.assign({"client-id":o,"merchant-id":r,"enable-funding":h.length>0?h: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 _(u.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 Nt,Dt,zt=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 Gt 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 zt(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 _(u.MissingPaymentMethod);yield i.initialize.call(this,e,t,d);const l=i.getPaymentMethod.call(this);if(!l.initializationData)throw new _(u.MissingPaymentMethod);vt(l);const h=yield this.payPalSdkHelper.getPayPalGooglePaySdk(l,d);this.googlepayConfig=yield h.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 zt(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"}(Nt||(Nt={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(Dt||(Dt={}));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 Bt 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 Y(["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 _(u.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===Nt.PayerActionRequired)return yield r.Googlepay().initiatePayerAction({orderId:e}),Promise.resolve();if(a!==Nt.Approved)throw new C("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},W),body:t});return n})}}const Lt=g(i=>{const o=new kt(n());return new Bt(i,new K(ae(),new Gt(i,o),t(),e()),o,t())},[{id:"googlepay_bigcommerce_payments"}]);var xt=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 jt extends F{constructor(e,t){super("worldlinena",e),this.formPoster=t}extraPaymentData(){return xt(this,void 0,void 0,function*(){return Promise.resolve({browser_info:m()})})}processAdditionalAction(e){return xt(this,void 0,void 0,function*(){if(!function(e){return f(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 Y(["formUrl","threeDSSessionData","creq"]);return new Promise(e=>{this.formPoster.postForm(n,{threeDSSessionData:i,creq:o},e,"_top")})})}}const Ft=g(n=>new oe(n,new K(ae(),new jt(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);class Vt extends l{constructor(e){super(e||"Not implemented."),this.name="NotImplementedError",this.type="not_implemented"}}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 Wt{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){var t,n;return Ut(this,void 0,void 0,function*(){if(!(null==e?void 0:e.methodId)||!ne(e.methodId))throw new C('Unable to proceed because "methodId" is not a valid key.');this._methodId=e.methodId;const i=e[this._getMethodId()];if(!i)throw new C("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 Vt('In order to sign in via Google Pay, the shopper must click on "Google Pay" button.'))}signOut(){var e;return Ut(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})=>Ut(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:h}=c.includes(t)?yield this._googlePayPaymentProcessor.handleCoupons(o):{},u=h;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:z.FINAL,totalPrice:y})},d&&{newShippingOptionParameters:d}),l&&{newOfferInfo:l}),u&&{error:u})})}}}_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=>Ut(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 P;n=new H(JSON.stringify(t))}throw null==e||e(new H("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){return Ut(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 A(this._methodId,()=>new v(w.PaymentNotInitialized))}}const Ht=g(n=>{const i=t();return new Wt(n,new K(ae(),new F("adyen",n),i,e()))},[{id:"googlepayadyenv2"}]),qt=g(n=>{const i=t();return new Wt(n,new K(ae(),new F("adyen",n),i,e()))},[{id:"googlepayadyenv3"}]),Kt=g(n=>new Wt(n,new K(ae(),new ue(n),t(),e())),[{id:"googlepayauthorizenet"}]),Yt=g(n=>{const i=t();return new Wt(n,new K(ae(),new fe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]),Zt=g(n=>new Wt(n,new K(ae(),new we(n),t(),e())),[{id:"googlepaycybersourcev2"}]),Jt=g(n=>new Wt(n,new K(ae(),new we(n),t(),e())),[{id:"googlepaybnz"}]),Qt=g(n=>new Wt(n,new K(ae(),new Ce(n),t(),e())),[{id:"googlepayorbital"}]),Xt=g(i=>new Wt(i,new K(ae(),new Ue(i,new Be(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeocs"}]),$t=g(i=>new Wt(i,new K(ae(),new Ue(i,new Be(n())),t(),e())),[{id:"googlepaystripeupe"}]),en=g(n=>new Wt(n,new K(ae(),new He(n),t(),e())),[{id:"googlepayworldpayaccess"}]),tn=g(i=>{const o=t(),r=window,a=new Je(i),s=new dt(new ut(n(),r,a));return new Wt(i,new K(ae(),new pt(i,s),o,e()))},[{id:"googlepaybraintree"}]),nn=g(i=>new Wt(i,new K(ae(),new St(i,new wt(n())),t(),e())),[{id:"googlepaypaypalcommerce"}]),on=g(i=>new Wt(i,new K(ae(),new Gt(i,new kt(n())),t(),e())),[{id:"googlepay_bigcommerce_payments"}]),rn=g(n=>new Wt(n,new K(ae(),new jt(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);class an 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 sn=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 cn{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){var t,n,i;return sn(this,void 0,void 0,function*(){if(!e.methodId||!ne(e.methodId))throw new C('Unable to proceed because "methodId" is not a valid key.');if(this._methodId=e.methodId,!e.containerId)throw new C('Unable to proceed because "containerId" is not a valid key.');const o=e[this._getMethodOrThrow()];if(!o)throw new C("Unable to proceed without valid options.");const{buyNowInitializeOptions:r,currencyCode:a,buttonColor:s,buttonType:c,onError:d}=o;let l,h=this._paymentIntegrationService.getState();try{l=h.getPaymentMethodOrThrow(this._getMethodOrThrow())}catch(e){h=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodOrThrow()),l=h.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 C('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=>sn(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 P;n=new H(JSON.stringify(t))}throw null==e||e(new H("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){var e;return sn(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})=>sn(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):{},h=l;return this._buyNowInitializeOptions?this._getBuyNowTransactionInfo(c,d,h):this._getTransactionInfo(c,d,h)})}}}_createBuyNowCartOrThrow(e){return sn(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 an(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:z.FINAL})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})}_getTransactionInfo(e,t,n){return sn(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:z.FINAL,totalPrice:i})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})})}_getMethodOrThrow(){return A(this._methodId,()=>new v(w.PaymentNotInitialized))}_getCurrencyCodeOrThrow(){return A(this._currencyCode,()=>new C('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}}const dn=g(i=>{const o=t(),r=window,a=new Je(i),s=new dt(new ut(n(),r,a));return new cn(i,new K(ae(),new pt(i,s),o,e()))},[{id:"googlepaybraintree"}]),ln=g(i=>new cn(i,new K(ae(),new St(i,new wt(n())),t(),e())),[{id:"googlepaypaypalcommerce"}]),hn=g(i=>new cn(i,new K(ae(),new Gt(i,new kt(n())),t(),e())),[{id:"googlepay_bigcommerce_payments"}]),un=g(n=>{const i=t();return new cn(n,new K(ae(),new F("adyen",n),i,e()))},[{id:"googlepayadyenv2"}]),yn=g(n=>{const i=t();return new cn(n,new K(ae(),new F("adyen",n),i,e()))},[{id:"googlepayadyenv3"}]),gn=g(n=>new cn(n,new K(ae(),new ue(n),t(),e())),[{id:"googlepayauthorizenet"}]),pn=g(n=>{const i=t();return new cn(n,new K(ae(),new fe(n,i),i,e()))},[{id:"googlepaycheckoutcom"}]),_n=g(n=>new cn(n,new K(ae(),new we(n),t(),e())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]),mn=g(n=>new cn(n,new K(ae(),new Ce(n),t(),e())),[{id:"googlepayorbital"}]),fn=g(i=>new cn(i,new K(ae(),new Ue(i,new Be(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]),Pn=g(n=>new cn(n,new K(ae(),new He(n),t(),e())),[{id:"googlepayworldpayaccess"}]),wn=g(n=>new cn(n,new K(ae(),new jt(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);export{un as createGooglePayAdyenV2ButtonStrategy,Ht as createGooglePayAdyenV2CustomerStrategy,se as createGooglePayAdyenV2PaymentStrategy,yn as createGooglePayAdyenV3ButtonStrategy,qt as createGooglePayAdyenV3CustomerStrategy,he as createGooglePayAdyenV3PaymentStrategy,gn as createGooglePayAuthorizeDotNetButtonStrategy,Kt as createGooglePayAuthorizeDotNetCustomerStrategy,ye as createGooglePayAuthorizeNetPaymentStrategy,hn as createGooglePayBigCommercePaymentsButtonStrategy,on as createGooglePayBigCommercePaymentsCustomerStrategy,Lt as createGooglePayBigCommercePaymentsPaymentStrategy,Jt as createGooglePayBnzCustomerStrategy,dn as createGooglePayBraintreeButtonStrategy,tn as createGooglePayBraintreeCustomerStrategy,_t as createGooglePayBraintreePaymentStrategy,pn as createGooglePayCheckoutComButtonStrategy,Yt as createGooglePayCheckoutComCustomerStrategy,Pe as createGooglePayCheckoutComPaymentStrategy,_n as createGooglePayCybersourceButtonStrategy,Zt as createGooglePayCybersourceCustomerStrategy,ve as createGooglePayCybersourcePaymentStrategy,mn as createGooglePayOrbitalButtonStrategy,Qt as createGooglePayOrbitalCustomerStrategy,Se as createGooglePayOrbitalPaymentStrategy,Mt as createGooglePayPPCPPaymentStrategy,ln as createGooglePayPayPalCommerceButtonStrategy,nn as createGooglePayPayPalCommerceCustomerStrategy,fn as createGooglePayStripeButtonStrategy,Xt as createGooglePayStripeCustomerStrategy,We as createGooglePayStripePaymentStrategy,$t as createGooglePayStripeUpeCustomerStrategy,wn as createGooglePayTdOnlineMartButtonStrategy,rn as createGooglePayTdOnlineMartCustomerStrategy,Ft as createGooglePayTdOnlineMartPaymentStrategy,Pn as createGooglePayWorldpayAccessButtonStrategy,en as createGooglePayWorldpayAccessCustomerStrategy,qe as createGooglePayWorldpayAccessPaymentStrategy};
|
|
2
2
|
//# sourceMappingURL=google-pay.js.map
|