@bigcommerce/checkout-sdk 1.979.0 → 1.979.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/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 r}from"@bigcommerce/script-loader";import{find as i,includes as o,isArray as a,isObject as s,round as l,some as c}from"lodash";class d 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 d{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}class u{constructor(e,t,n=window){this._scriptLoader=e,this._stylesheetLoader=t,this._window=n}load(e){return t=this,n=function*(){var t,n;if(yield Promise.all([this._stylesheetLoader.loadStylesheet(`https://checkoutshopper-${null!=(t=e.environment)?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)?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 Promise((e,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},o=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,o);a((n=n.apply(t,null)).next())});var t,n}}function y(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}var g=(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",e))(g||{});class _ extends d{constructor(e){super(function(e){switch(e){case 0:return"Unable to proceed because billing address data is unavailable.";case 1:return"Unable to proceed because cart data is unavailable.";case 3:return"Unable to proceed because consignments data is unavailable.";case 2:return"Unable to proceed because checkout data is unavailable.";case 4:return"Unable to proceed because customer data is unavailable.";case 5:case 7:return"Unable to proceed because configuration data is unavailable.";case 6:return"Unable to proceed because order data is unavailable.";case 8:return"Unable to proceed because order ID is unavailable or not generated yet.";case 9:return"Unable to proceed because payment data is unavailable.";case 15:return"Unable to proceed because the token required to submit a payment is missing.";case 12:return"Unable to proceed because payment method data is unavailable or not properly configured.";case 16: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 P=e=>"object"==typeof e&&null!==e&&"body"in e;class f extends d{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}var w=(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",e))(w||{});class b extends d{constructor(e){super(function(e){switch(e){case 1:return"Unable to proceed because the customer step of checkout has not been initialized.";case 2:return"Unable to proceed because the payment step of checkout has not been initialized.";case 3:return"Unable to proceed because the shipping step of checkout has not been initialized.";case 4: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 S extends d{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}var C=Object.defineProperty,v=Object.defineProperties,I=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,A=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,M=(e,t,n)=>t in e?C(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function k(e,t,n){if("function"!=typeof n.value)return n;let r=n.value;return{get(){const e=r.bind(this);var i;return Object.defineProperty(this,t,(i=((e,t)=>{for(var n in t||(t={}))A.call(t,n)&&M(e,n,t[n]);if(O)for(var n of O(t))T.call(t,n)&&M(e,n,t[n]);return e})({},n),v(i,I({value:e})))),e},set(e){r=e}}}class E{constructor(e){if(!e)throw new Error("Currency settings missing");const{decimalPlaces:t,symbolLocation:n,symbol:r,thousandsSeparator:i,decimalSeparator:o}=e;if("string"!=typeof n||"string"!=typeof r||"string"!=typeof i||"string"!=typeof o||"string"!=typeof t)throw new S("Invalid currency settings provided");this._decimalPlaces=parseInt(t,10),this._symbolLocation=n,this._symbol=r,this._thousandsSeparator=i,this._decimalSeparator=o}format(e){if("number"!=typeof e)throw new S("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,r=""]=this._toFixed(t,this._decimalPlaces).split("."),i=n.replace(/\B(?=(\d{3})+(?!\d))/g,this._thousandsSeparator);return this._decimalPlaces<1?i:[i,r].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)}}Object.defineProperty,Object.getOwnPropertyDescriptor;let D=class{constructor(e){this._storeConfig=e,this._customerFormatter=new E(this._storeConfig.shopperCurrency),this._storeFormatter=new E(this._storeConfig.currency)}toCustomerCurrency(e){const t=this._storeConfig.shopperCurrency.exchangeRate;return this._customerFormatter.format(e*t)}toStoreCurrency(e){return this._storeFormatter.format(e)}};function z(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}D=((e,t)=>{for(var n,r=t,i=e.length-1;i>=0;i--)(n=e[i])&&(r=n(r)||r);return r})([function(e,t,n){return t&&n?k(0,t,n):function(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const r=Object.getOwnPropertyDescriptor(e.prototype,n);r&&"constructor"!==n&&Object.defineProperty(t.prototype,n,k(e.prototype,n,r))}),t}(e)}],D);function N(){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 G(e,t,n=!0){var r;return null!=(r=e[t])?r:n}var R=(e=>(e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN",e))(R||{}),B=(e=>(e.AMEX="AMEX",e.DISCOVER="DISCOVER",e.INTERAC="INTERAC",e.JCB="JCB",e.MC="MASTERCARD",e.VISA="VISA",e))(B||{}),L=(e=>(e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION",e))(L||{}),x=(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",e))(x||{}),j=(e=>(e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER",e))(j||{});function F(e){return e in B}var V=Object.defineProperty,U=Object.defineProperties,W=Object.getOwnPropertyDescriptors,H=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,J=(e,t,n)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Y=(e,t)=>{for(var n in t||(t={}))q.call(t,n)&&J(e,n,t[n]);if(H)for(var n of H(t))K.call(t,n)&&J(e,n,t[n]);return e},Z=(e,t)=>U(e,W(t)),X=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class Q{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:r="",email:i,customFields:o=[]}=this._paymentIntegrationService.getState().getBillingAddress()||{};return Z(Y({},this._mapToAddressRequestBody(t,n,r,o)),{email:i||e.email})}mapToExternalCheckoutData(e){var t;const{paymentMethodData:{tokenizationData:{token:n},info:{cardNetwork:r,cardDetails:i}}}=e;if(!n)throw new _(g.MissingPaymentToken);return Promise.resolve(Y({nonce:n,card_information:{type:r,number:i}},this._isBuyNowFlow&&{cart_id:null==(t=this._paymentIntegrationService.getState().getCart())?void 0:t.id}))}getRequiredData(){return X(this,null,function*(){var e;const t={emailRequired:!0};if(!this._isShippingAddressRequired())return t;const n=null==(e=(yield this._paymentIntegrationService.loadShippingCountries()).getShippingCountries())?void 0:e.map(e=>e.code);return Z(Y({},t),{shippingAddressRequired:!0,shippingAddressParameters:Y({phoneNumberRequired:!0},n&&{allowedCountryCodes:n}),shippingOptionRequired:!0})})}getCallbackIntents(){return this._isShippingAddressRequired()?[L.OFFER,L.SHIPPING_ADDRESS,L.SHIPPING_OPTION]:[L.OFFER]}getCallbackTriggers(){return{availableTriggers:[j.INITIALIZE,j.SHIPPING_ADDRESS,j.SHIPPING_OPTION,j.OFFER],initializationTrigger:[j.INITIALIZE],addressChangeTriggers:[j.INITIALIZE,j.SHIPPING_ADDRESS],shippingOptionsChangeTriggers:[j.SHIPPING_OPTION],offerChangeTriggers:[j.OFFER]}}getNonce(e){var t;const n=null==(t=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(e).initializationData)?void 0:t.nonce;if(!n)throw new _(g.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 Z(Y({},n&&{countryCode:n}),{currencyCode:e,totalPrice:t,totalPriceStatus:R.ESTIMATED})}return Z(Y({},n&&{countryCode:n}),{currencyCode:e,totalPriceStatus:R.ESTIMATED,totalPrice:"0"})}isWebViewWithRestrictions(){return null!==this._isWebViewExperimentOn?this._isWebViewExperimentOn&&N():N()}setIsWebViewExperimentOn(e){this._isWebViewExperimentOn=e}setFilterAvailableShippingOptions(e){this._filterAvailableShippingOptions=e}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData().gatewayMerchantId;if(!e)throw new S("Unable to proceed, gatewayMerchantId is missing.");return{gateway:this._gatewayIdentifier,gatewayMerchantId:e}}getCardParameters(){return{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:this.getPaymentMethod().supportedCards.filter(F).map(e=>B[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){return X(this,null,function*(){var t,n;e&&(e.name=e.name||"",e.address1=e.address1||"");const r=this.mapToShippingAddressRequestBody({shippingAddress:e});r&&(yield this._paymentIntegrationService.updateShippingAddress(r));const i=this._paymentIntegrationService.getState(),o=i.getConsignments();if(!(null==o?void 0:o[0]))return;const a=o[0],s=i.getStoreConfigOrThrow();this._currencyService||(this._currencyService=new D(s));let l=a.availableShippingOptions||[];if("function"==typeof this._filterAvailableShippingOptions)try{l=yield this._filterAvailableShippingOptions(l)}catch(e){console.error("Failed to filter available shipping options:",e)}const c=l.map(this._getGooglePayShippingOption.bind(this)),d=l.find(e=>e.isRecommended),h=l.some(e=>{var t;return e.id===(null==(t=a.selectedShippingOption)?void 0:t.id)})?null==(t=a.selectedShippingOption)?void 0:t.id:void 0;if(c.length){const e=h||(null==d?void 0:d.id)||(null==(n=c[0])?void 0:n.id);return!h&&c[0]&&(yield this.handleShippingOptionChange((null==d?void 0:d.id)||c[0].id)),{defaultSelectedOptionId:e,shippingOptions:c}}})}handleShippingOptionChange(e){return X(this,null,function*(){if("shipping_option_unselected"!==e)return this._paymentIntegrationService.selectShippingOption(e)})}getTotalPrice(){const{getCheckoutOrThrow:e,getCartOrThrow:t,getStoreConfigOrThrow:n}=this._paymentIntegrationService.getState(),{decimalPlaces:r}=t().currency,i=G(n().checkoutSettings.features,"PI-5075.google_pay_round_total_price_to_max_2_decimal_places")?Math.min(r,2):r;return l(e().outstandingBalance,i).toFixed(i)}handleCoupons(e){return X(this,null,function*(){const{redemptionCodes:t=[]}=e,{offers:n}=this.getAppliedCoupons()||{};let r;return yield t.reduce((e,t)=>X(this,null,function*(){if(yield e,(n||[]).some(({redemptionCode:e})=>e===t))return;const i=yield this.applyCoupon(t);i&&(r=i)}),Promise.resolve()),yield(n||[]).reduce((e,n)=>X(this,null,function*(){yield e,t.includes(n.redemptionCode)||(yield this._paymentIntegrationService.removeCoupon(n.redemptionCode))}),Promise.resolve()),{newOfferInfo:this.getAppliedCoupons(),error:r}})}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 X(this,null,function*(){let t;try{yield this._paymentIntegrationService.applyCoupon(e)}catch(e){return e instanceof Error&&(t={reason:x.OFFER_INVALID,message:e.message,intent:j.OFFER}),t}})}setShouldRequestShipping(e){this._shouldRequestShipping=e}getGooglePayInitializationData(){return z(this.getPaymentMethod().initializationData,()=>new S("Missing initialization data."))}getPaymentMethod(){return z(this._getPaymentMethodFn,()=>new b(w.PaymentNotInitialized))()}getGatewayIdentifier(){return this._gatewayIdentifier}setGatewayIdentifier(e){this._gatewayIdentifier=e||this.getGatewayIdentifier()}_isShippingAddressRequired(){const{getCartOrThrow:e,getStoreConfigOrThrow:t,getShippingAddress:n}=this._paymentIntegrationService.getState(),r=t();let i;return i=G(r.checkoutSettings.features,"PI-4290.google_pay_require_shipping_address")?this._shouldRequestShipping:void 0===n(),i&&(o=e(),a=r,!!o&&(!!o.lineItems.physicalItems.some(e=>e.isShippingRequired)||!(!a||!o.lineItems.customItems)&&o.lineItems.customItems.length>0));var o,a}_mapToAddressRequestBody(e,t,n,r){const{name:i,address1:o,address2:a,address3:s,locality:l,administrativeArea:c,countryCode:d,postalCode:h,phoneNumber:u}=e,[y,p]=this._getFirstAndLastName(i);return{firstName:y,lastName:p,company:t,address1:o,address2:`${a} ${s}`.trim(),city:l||c,stateOrProvince:c,stateOrProvinceCode:c,countryCode:d,postalCode:h,phone:u||n,customFields:r||[]}}_getFirstAndLastName(e){const t=e.split(" ");return 1===t.length?[e,""]:[t.slice(0,-1).join(" "),t[t.length-1]]}_getCurrencyCodeOrThrow(){return z(this._currencyCode,()=>new S('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}_getGooglePayShippingOption({id:e,cost:t,description:n,additionalDescription:r}){var i;return{id:e,label:`${(null==(i=this._currencyService)?void 0:i.toCustomerCurrency(t))||t} ${n}`,description:r}}}var $=Object.getPrototypeOf,ee=Reflect.get,te=(e,t,n)=>ee($(e),n,t),ne=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class re extends Q{constructor(e,t){super("adyen",e),this._scriptLoader=t,this._service=e}initialize(e,t,n){return ne(this,null,function*(){yield te(re.prototype,this,"initialize").call(this,e,t,n);const r=te(re.prototype,this,"getPaymentMethod").call(this),i=this._service.getState().getStoreConfig();if(!i)throw new _(g.MissingCheckoutConfig);return this._adyenClient=yield this._scriptLoader.load({environment:r.config.testMode?"test":"live",locale:i.storeProfile.storeLanguage}),Promise.resolve()})}getNonce(e){return ne(this,null,function*(){const t=yield te(re.prototype,this,"getNonce").call(this,e),n=te(re.prototype,this,"getPaymentMethod").call(this);return JSON.stringify({type:n.method,googlePayToken:t,browser_info:m()})})}processAdditionalAction(e){return ne(this,null,function*(){if(!P(e)||!p(e.body))throw e;const t=yield this._handleAction(e.body.provider_data);try{return yield this._service.submitPayment(t)}catch(e){return this.processAdditionalAction(e)}})}_handleAction(e){return new Promise((t,n)=>{const r=JSON.parse(e.action);this._getAdyenClient().createFromAction(r,{onAdditionalDetails:e=>{const n={methodId:r.paymentMethodType,paymentData:{nonce:JSON.stringify(e.data)}};t(n)},size:"05",onError:e=>n(e)}).mount("body"),n(new f)})}_getAdyenClient(){if(!this._adyenClient)throw new b(w.PaymentNotInitialized);return this._adyenClient}}const ie={"X-Checkout-SDK-Version":"1.979.0"};class oe extends d{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 ae=Object.defineProperty,se=Object.defineProperties,le=Object.getOwnPropertyDescriptors,ce=Object.getOwnPropertySymbols,de=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable,ue=(e,t,n)=>t in e?ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ye=(e,t)=>{for(var n in t||(t={}))de.call(t,n)&&ue(e,n,t[n]);if(ce)for(var n of ce(t))he.call(t,n)&&ue(e,n,t[n]);return e},pe=(e,t)=>se(e,le(t)),ge=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class _e{constructor(e,t,n,r){this._scriptLoader=e,this._gateway=t,this._requestSender=n,this._formPoster=r,this._baseRequest={apiVersion:2,apiVersionMinor:0}}initialize(e,t,n,r){return ge(this,null,function*(){this._paymentsClient=yield this._scriptLoader.getGooglePaymentsClient(e().config.testMode,t),yield this._gateway.initialize(e,n,r),this._buildButtonPayloads()})}initializeWidget(){return ge(this,null,function*(){yield this._buildWidgetPayloads(),yield this._determineReadinessToPay(),this._prefetchGooglePaymentData()})}getNonce(e){return this._gateway.getNonce(e)}extraPaymentData(){return ge(this,null,function*(){return this._gateway.extraPaymentData()})}addPaymentButton(e,t){const n=document.querySelector(`#${e}`);if(!n)return;const r=this._getPaymentsClient().createButton(pe(ye({},t),{allowedPaymentMethods:[this._getBaseCardPaymentMethod()]}));return n.appendChild(r)}showPaymentSheet(){return ge(this,null,function*(){const e=this._getPaymentDataRequest();return this._getPaymentsClient().loadPaymentData(e)})}setExternalCheckoutXhr(e,t){return ge(this,null,function*(){return this._setExternalCheckout(e,t)})}setExternalCheckoutForm(e,t,n){return ge(this,null,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 ge(this,null,function*(){yield this._requestSender.get(`/remote-checkout/${e}/signout`)})}getCallbackTriggers(){return this._gateway.getCallbackTriggers()}setShouldRequestShipping(e){return this._gateway.setShouldRequestShipping(e)}handleShippingAddressChange(e){return ge(this,null,function*(){return this._gateway.handleShippingAddressChange(e)})}handleShippingOptionChange(e){return ge(this,null,function*(){yield this._gateway.handleShippingOptionChange(e)})}handleCoupons(e){return ge(this,null,function*(){return this._gateway.handleCoupons(e)})}getTotalPrice(){return this._gateway.getTotalPrice()}_setExternalCheckout(e,t,n=!1,r){return ge(this,null,function*(){const i="/checkout.php",o=ye({action:"set_external_checkout",provider:e},yield this._gateway.mapToExternalCheckoutData(t));if(n)return new Promise(e=>{this._formPoster.postForm(r?`${r}/checkout`:i,pe(ye({},o),{card_information:JSON.stringify(o.card_information)}),e)});yield this._requestSender.post(i,{headers:ye({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},ie),body:o})})}isWebViewWithRestrictions(){return this._gateway.isWebViewWithRestrictions()}setIsWebViewExperimentOn(e){return this._gateway.setIsWebViewExperimentOn(e)}setFilterAvailableShippingOptions(e){return this._gateway.setFilterAvailableShippingOptions(e)}_prefetchGooglePaymentData(){const e=this._getPaymentDataRequest();e.transactionInfo=this._gateway.getTransactionInfo(),this._getPaymentsClient().prefetchPaymentData(e)}_determineReadinessToPay(){return ge(this,null,function*(){try{const{result:e}=yield this._getPaymentsClient().isReadyToPay(this._getIsReadyToPayRequest());if(!1===e)throw new oe("Google Pay is not supported by the current device and browser, please try another payment method.")}catch(e){if(e instanceof oe)throw e;throw new oe}})}_buildButtonPayloads(){this._baseCardPaymentMethod={type:"CARD",parameters:this._gateway.getCardParameters()}}_buildWidgetPayloads(){return ge(this,null,function*(){const e=this._getBaseCardPaymentMethod();this._cardPaymentMethod=pe(ye({},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=ye(ye(pe(ye({},this._baseRequest),{allowedPaymentMethods:[this._cardPaymentMethod],transactionInfo:this._gateway.getTransactionInfo(),merchantInfo:this._gateway.getMerchantInfo()}),yield this._gateway.getRequiredData()),t),this._isReadyToPayRequest=pe(ye({},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 z(e,()=>new b(w.PaymentNotInitialized))}}class me extends S{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 Pe extends d{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}var fe=Object.defineProperty,we=Object.getOwnPropertySymbols,be=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable,Ce=(e,t,n)=>t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ve=(e,t)=>{for(var n in t||(t={}))be.call(t,n)&&Ce(e,n,t[n]);if(we)for(var n of we(t))Se.call(t,n)&&Ce(e,n,t[n]);return e};const Ie={size:70,color:"#d9d9d9",backgroundColor:"#ffffff"},Oe={position:"fixed","background-color":"rgba(0, 0, 0, 0.4)","z-index":"1000"},Ae="embedded-checkout-loading-indicator-rotation";class Te{constructor(e){this.styles=ve(ve({},Ie),e&&e.styles),this.containerStyles=ve({},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=`${Ae} 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(Ae))return;const t=document.createElement("style");t.id=Ae,null==(e=document.head)||e.appendChild(t),t.sheet instanceof CSSStyleSheet&&t.sheet.insertRule(`\n @keyframes ${Ae} {\n 0% { transform: translateY(-50%) rotate(0deg); }\n 100% { transform: translateY(-50%) rotate(360deg); }\n }\n `,0)}}function Me(e){return"object"==typeof e&&null!==e&&"statusCode"in e}var ke=(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",e))(ke||{});function Ee(e){return Object.values(ke).includes(e)}var De=Object.defineProperty,ze=Object.defineProperties,Ne=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertySymbols,Re=Object.prototype.hasOwnProperty,Be=Object.prototype.propertyIsEnumerable,Le=(e,t,n)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xe=(e,t)=>{for(var n in t||(t={}))Re.call(t,n)&&Le(e,n,t[n]);if(Ge)for(var n of Ge(t))Be.call(t,n)&&Le(e,n,t[n]);return e},je=(e,t)=>ze(e,Ne(t)),Fe=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class Ve{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t,this._isDeinitializationBlocked=!1,this._isContainerMode=!1,this._loadingIndicator=new Te({containerStyles:Oe})}initialize(e){return Fe(this,null,function*(){var t,n;if(!(null==e?void 0:e.methodId)||!Ee(e.methodId))throw new S('Unable to proceed because "methodId" is not a valid key.');this._methodId=e.methodId;const r=e[this._getMethodId()];if(!(null==r?void 0:r.walletButton)&&!(null==r?void 0:r.container))throw new S("Unable to proceed without valid options.");const i=r,{walletButton:o,loadingContainerId:a,container:s,buttonColor:l,buttonSizeMode:c,buttonType:d,onInit:h}=i,u=((e,t)=>{var n={};for(var r in e)Re.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&Ge)for(var r of Ge(e))t.indexOf(r)<0&&Be.call(e,r)&&(n[r]=e[r]);return n})(i,["walletButton","loadingContainerId","container","buttonColor","buttonSizeMode","buttonType","onInit"]);this._loadingIndicatorContainer=a,yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodId());const y=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(this._getMethodId());if(this._googlePayPaymentProcessor.setIsWebViewExperimentOn(!!(null==(t=y.initializationData)?void 0:t.isWebViewExperimentOn)),yield this._googlePayPaymentProcessor.initialize(()=>y,this._getGooglePayClientOptions(null==(n=y.initializationData)?void 0:n.storeCountry)),s){this._isContainerMode=!0;const e=()=>this._addPaymentButtonToContainer(r);h?h(e):e()}else this._addPaymentButton(o,u)})}execute(e){return Fe(this,arguments,function*({payment:e}){if(!(null==e?void 0:e.methodId))throw new me(["payment"]);yield this._paymentIntegrationService.submitOrder();const t=yield this._googlePayPaymentProcessor.getNonce(e.methodId),n=yield this._googlePayPaymentProcessor.extraPaymentData();try{yield this._paymentIntegrationService.submitPayment(je(xe({},e),{paymentData:xe({nonce:t},n)}))}catch(t){yield this._googlePayPaymentProcessor.processAdditionalAction(t,e.methodId)}})}finalize(){return Promise.reject(new Pe)}deinitialize(){var e,t;return this._isDeinitializationBlocked||(this._isContainerMode?null==(e=this._paymentButton)||e.remove():this._clickListener&&(null==(t=this._paymentButton)||t.removeEventListener("click",this._clickListener)),this._paymentButton=void 0,this._clickListener=void 0,this._methodId=void 0,this._isContainerMode=!1),Promise.resolve()}_addPaymentButton(e,t){if(this._paymentButton)return;const n=document.getElementById(e);if(!n)throw new S("Unable to proceed without a walletButton.");this._paymentButton=n,this._clickListener=this._handleClick(t),this._paymentButton.addEventListener("click",this._clickListener)}_addPaymentButtonToContainer(e){if(this._paymentButton)return;const{container:t,buttonColor:n,buttonSizeMode:r,buttonType:i,onError:o}=e;if(!t)throw new S("Unable to proceed: container ID is not valid.");const a=this._googlePayPaymentProcessor.addPaymentButton(t,{buttonColor:null!=n?n:"default",buttonSizeMode:null!=r?r:"fill",buttonType:null!=i?i:"pay",onClick:this._handleContainerButtonClick(o)});if(!a)throw new S(`Unable to proceed: container element "#${t}" not found in the DOM.`);this._paymentButton=a}_handleContainerButtonClick(e){return t=>Fe(this,null,function*(){t.preventDefault(),yield this._runGooglePayWidgetInteractionWithErrorHandling(e,()=>Fe(this,null,function*(){this._googlePayPaymentProcessor.setShouldRequestShipping(!1),yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheetAndPay()}))})}_handleClick({onPaymentSelect:e,onError:t}){return n=>Fe(this,null,function*(){n.preventDefault(),yield this._runGooglePayWidgetInteractionWithErrorHandling(t,()=>Fe(this,null,function*(){this._googlePayPaymentProcessor.setShouldRequestShipping(!1),yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheetAndPay()})),null==e||e()})}_interactWithPaymentSheetAndPay(){return Fe(this,null,function*(){const e=yield this._googlePayPaymentProcessor.showPaymentSheet();this._toggleBlockDeinitialization(!0),this._toggleLoadingIndicator(!0);const t=this._getMethodId(),n=this._paymentIntegrationService.getState(),{features:r}=n.getStoreConfigOrThrow().checkoutSettings,i=G(r,"PI-5031.google_pay_dont_override_address"),o=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(e);o&&!i&&(yield this._paymentIntegrationService.updateBillingAddress(o)),yield this._googlePayPaymentProcessor.setExternalCheckoutXhr(t,e),yield this._paymentIntegrationService.loadPaymentMethod(t);const a=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(t);yield this._googlePayPaymentProcessor.initialize(()=>a);try{yield this.execute({useStoreCredit:!1,payment:{methodId:t}}),this._completeCheckoutFlow()}catch(e){throw yield this._paymentIntegrationService.loadCheckout(),e}})}_completeCheckoutFlow(){window.location.replace("/checkout/order-confirmation"),this._toggleLoadingIndicator(!1),this._toggleBlockDeinitialization(!1)}_getMethodId(){return z(this._methodId,()=>new b(w.PaymentNotInitialized))}_getIsSignedInOrThrow(){return Fe(this,null,function*(){try{return!!(yield this._googlePayPaymentProcessor.getNonce(this._getMethodId()))}catch(e){if(e instanceof _&&e.subtype===g.MissingPaymentToken)return!1;throw e}})}_handleOfferTrigger(e){return Fe(this,null,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:x.OFFER_INVALID,message:n,intent:j.OFFER}}})}_getGooglePayClientOptions(e){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:t=>Fe(this,[t],function*({callbackTrigger:t,offerData:n}){if(t!==j.INITIALIZE&&t!==j.OFFER)return;const{offerChangeTriggers:r}=this._googlePayPaymentProcessor.getCallbackTriggers(),{newOfferInfo:i,error:o}=r.includes(t)?yield this._handleOfferTrigger(n):{},a=o;yield this._paymentIntegrationService.loadCheckout();const{code:s}=this._paymentIntegrationService.getState().getCartOrThrow().currency,l=this._googlePayPaymentProcessor.getTotalPrice();return xe(xe({newTransactionInfo:je(xe({},e&&{countryCode:e}),{currencyCode:s,totalPriceStatus:R.FINAL,totalPrice:l})},i&&{newOfferInfo:i}),a&&{error:a})})}}}_runGooglePayWidgetInteractionWithErrorHandling(e,t){return Fe(this,null,function*(){try{yield t()}catch(t){let n=t;if(this._toggleLoadingIndicator(!1),Me(t)){if("CANCELED"===t.statusCode)throw new f;n=new oe(JSON.stringify(t))}throw null==e||e(new oe("An error occurred while requesting your Google Pay payment details.")),n}finally{this._toggleBlockDeinitialization(!1)}})}_toggleBlockDeinitialization(e){this._isDeinitializationBlocked=e}_toggleLoadingIndicator(e){e&&this._loadingIndicatorContainer?this._loadingIndicator.show(this._loadingIndicatorContainer):this._loadingIndicator.hide()}}var Ue=Object.defineProperty,We=Object.getOwnPropertySymbols,He=Object.prototype.hasOwnProperty,qe=Object.prototype.propertyIsEnumerable,Ke=(e,t,n)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class Je{constructor(e){this._scriptLoader=e,this._window=window}getGooglePaymentsClient(e=!1,t){return n=this,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(((e,t)=>{for(var n in t||(t={}))He.call(t,n)&&Ke(e,n,t[n]);if(We)for(var n of We(t))qe.call(t,n)&&Ke(e,n,t[n]);return e})({environment:e?"TEST":"PRODUCTION"},null!=t?t:{}))),this._paymentsClient},new Promise((e,t)=>{var i=e=>{try{a(r.next(e))}catch(e){t(e)}},o=e=>{try{a(r.throw(e))}catch(e){t(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,o);a((r=r.apply(n,null)).next())});var n,r}}function Ye(){return new Je(n())}const Ze=y(i=>new Ve(i,new _e(Ye(),new re(i,new u(n(),r())),t(),e())),[{id:"googlepayadyenv2"}]);class Xe{constructor(e,t,n=window){this._scriptLoader=e,this._stylesheetLoader=t,this._window=n}load(e){return t=this,n=function*(){var t,n;if(yield Promise.all([this._stylesheetLoader.loadStylesheet(`https://checkoutshopper-${null!=(t=e.environment)?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)?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 Promise((e,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},o=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,o);a((n=n.apply(t,null)).next())});var t,n}}var Qe=Object.getPrototypeOf,$e=Reflect.get,et=(e,t,n)=>$e(Qe(e),n,t),tt=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class nt extends Q{constructor(e,t){super("adyen",e),this._scriptLoader=t,this._service=e}initialize(e,t,n){return tt(this,null,function*(){yield et(nt.prototype,this,"initialize").call(this,e,t,n);const r=et(nt.prototype,this,"getPaymentMethod").call(this),i=this._service.getState().getStoreConfig();if(!i)throw new _(g.MissingCheckoutConfig);return this._adyenClient=yield this._scriptLoader.load({environment:r.config.testMode?"test":"live",locale:i.storeProfile.storeLanguage}),Promise.resolve()})}processAdditionalAction(e){return tt(this,null,function*(){if(!P(e)||!p(e.body))throw e;const t=yield this._handleAction(e.body.provider_data);try{return yield this._service.submitPayment(t)}catch(e){return this.processAdditionalAction(e)}})}getNonce(e){return tt(this,null,function*(){const t=yield et(nt.prototype,this,"getNonce").call(this,e),n=et(nt.prototype,this,"getPaymentMethod").call(this);return JSON.stringify({type:n.method,googlePayToken:t,browser_info:m()})})}_handleAction(e){return new Promise((t,n)=>{const r=JSON.parse(e.action);this._getAdyenClient().createFromAction(r,{onAdditionalDetails:e=>{const n={methodId:r.paymentMethodType,paymentData:{nonce:JSON.stringify(e.data)}};t(n)},size:"05",onError:e=>n(e)}).mount("body"),n(new f)})}_getAdyenClient(){if(!this._adyenClient)throw new b(w.PaymentNotInitialized);return this._adyenClient}}const rt=y(i=>new Ve(i,new _e(Ye(),new nt(i,new Xe(n(),r())),t(),e())),[{id:"googlepayadyenv3"}]);var it=Object.getPrototypeOf,ot=Reflect.get;class at extends Q{constructor(e){super("authorizenet",e)}mapToExternalCheckoutData(e){return t=this,n=function*(){const t=yield(n=at.prototype,ot(it(n),"mapToExternalCheckoutData",this)).call(this,e);var n;return t.nonce=btoa(t.nonce),t},new Promise((e,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},o=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,o);a((n=n.apply(t,null)).next())});var t,n}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return function(e){if(!function(e){return"paymentGatewayId"in e}(e))throw new _(g.MissingPaymentMethod)}(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.paymentGatewayId}}}const st=y(n=>new Ve(n,new _e(Ye(),new at(n),t(),e())),[{id:"googlepayauthorizenet"}]);var lt=(e=>(e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json",e))(lt||{});const ct=lt;function dt(e){if(!function(e){return"checkoutcomkey"in e}(e))throw new _(g.MissingPaymentMethod)}var ht=Object.getPrototypeOf,ut=Reflect.get,yt=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class pt extends Q{constructor(e,t){super("checkoutltd",e),this._requestSender=t}processAdditionalAction(e){return new Promise((t,n)=>{if(P(e)&&function(e){var t;if("object"!=typeof e||null===e)return!1;const n=e;return"string"==typeof(null==(t=n.three_ds_result)?void 0:t.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){return yt(this,null,function*(){const t=yield(n=pt.prototype,ut(ht(n),"mapToExternalCheckoutData",this)).call(this,e);var n;let r;try{r=JSON.parse(t.nonce)}catch(e){throw new S("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 _(g.MissingPaymentToken)}(r),t.nonce=yield this._tokenize(r),t})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return dt(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.checkoutcomkey}}_tokenize(e){return yt(this,null,function*(){const t=this.getPaymentMethod().config.testMode?"https://api.sandbox.checkout.com/tokens":"https://api.checkout.com/tokens",n=this.getGooglePayInitializationData();dt(n);const{body:r}=yield this._requestSender.post(t,{credentials:!1,body:{type:"googlepay",token_data:e},headers:{Authorization:n.checkoutcomkey,"Content-Type":ct.Json,"X-XSRF-TOKEN":null}});return r.token})}}const gt=y(n=>{const r=t();return new Ve(n,new _e(Ye(),new pt(n,r),r,e()))},[{id:"googlepaycheckoutcom"}]);var _t=Object.getPrototypeOf,mt=Reflect.get;class Pt extends Q{constructor(e){super("cybersource",e)}mapToExternalCheckoutData(e){return t=this,n=function*(){const t=yield(n=Pt.prototype,mt(_t(n),"mapToExternalCheckoutData",this)).call(this,e);var n;return t.nonce=btoa(t.nonce),t},new Promise((e,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},o=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,o);a((n=n.apply(t,null)).next())});var t,n}}const ft=y(n=>new Ve(n,new _e(Ye(),new Pt(n),t(),e())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]);var wt=Object.getPrototypeOf,bt=Reflect.get;class St extends Q{constructor(e){super("chase",e)}mapToExternalCheckoutData(e){return t=this,n=function*(){const t=yield(n=St.prototype,bt(wt(n),"mapToExternalCheckoutData",this)).call(this,e);var n;return t.nonce=btoa(t.nonce),t},new Promise((e,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},o=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,o);a((n=n.apply(t,null)).next())});var t,n}}const Ct=y(n=>new Ve(n,new _e(Ye(),new St(n),t(),e())),[{id:"googlepayorbital"}]);var vt=(e=>(e.V3="v3",e.ACACIA="acacia",e.BASIL="basil",e.CLOVER="clover",e))(vt||{}),It=Object.defineProperty,Ot=Object.getOwnPropertySymbols,At=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable,Mt=(e,t,n)=>t in e?It(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,kt=(e,t)=>{for(var n in t||(t={}))At.call(t,n)&&Mt(e,n,t[n]);if(Ot)for(var n of Ot(t))Tt.call(t,n)&&Mt(e,n,t[n]);return e},Et=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class Dt{constructor(e,t=window){this.scriptLoader=e,this.stripeWindow=t}getStripeClient(e,t,n,r,i){return Et(this,null,function*(){if(this.stripeWindow.bcStripeClient)return this.stripeWindow.bcStripeClient;const o=yield this.load(n),{stripePublishableKey:a,stripeConnectedAccount:s}=e,l=o(a,kt(kt(kt(kt({},s?{stripeAccount:s}:{}),t?{locale:t}:{}),r?{betas:r}:{}),i?{apiVersion:i}:{}));return Object.assign(this.stripeWindow,{bcStripeClient:l}),l})}getElements(e,t){return Et(this,null,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 Et(this,null,function*(){const t=this.stripeWindow.bcStripeElements;t&&(t.update(e),yield t.fetchUpdates())})}getStripeCheckout(e,t){return Et(this,null,function*(){let n=yield this.getStoredStripeCheckout(t);if(n){const{actions:e}=yield n.loadActions();yield null==e?void 0:e.runServerUpdate(()=>Promise.resolve())}else n=yield e.initCheckout(t),Object.assign(this.stripeWindow,{bcStripeCheckout:n});return n})}load(e){return Et(this,null,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!==vt.V3?`https://js.stripe.com/${e}/stripe.js`:"https://js.stripe.com/v3/"}getStoredStripeCheckout(e){return Et(this,null,function*(){const t=this.stripeWindow.bcStripeCheckout;if(t)try{const{actions:n,error:r}=yield t.loadActions();if(r||!n)return void this.logErrorToConsole(r);const i=yield n.getSession(),o=e.clientSecret.split("_secret_")[0];if(i.id===o)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 zt={body:{},headers:{},status:0};class Nt extends d{constructor(e,{message:t,errors:n}={}){const{body:r,headers:i,status:o}=e||zt;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=r,this.headers=i,this.status=o,this.errors=n||[]}}const Gt=["payment_element_beta_2","alipay_pm_beta_1","link_default_integration_beta_1","shipping_address_element_beta_1","address_element_beta_1"];function Rt(e){if(!function(e){return"stripeConnectedAccount"in e&&"stripePublishableKey"in e&&"stripeVersion"in e}(e))throw new _(g.MissingPaymentMethod)}var Bt=Object.getPrototypeOf,Lt=Reflect.get,xt=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class jt extends Q{constructor(e,t){super("stripe",e),this.paymentIntegrationService=e,this.scriptLoader=t}mapToExternalCheckoutData(e){return xt(this,null,function*(){const t=yield(n=jt.prototype,Lt(Bt(n),"mapToExternalCheckoutData",this)).call(this,e);var n;let r;try{r=JSON.parse(t.nonce)}catch(e){throw new S("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 _(g.MissingPaymentToken)}(r),t.nonce=r.id,t})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();Rt(e);const{stripeVersion:t,stripePublishableKey:n,stripeConnectedAccount:r}=e;return{gateway:this.getGatewayIdentifier(),"stripe:version":t,"stripe:publishableKey":`${n}/${r}`}}processAdditionalAction(e,t){return xt(this,null,function*(){var n,r;if(!t)throw new me(["payment"]);if(!P(e)||("object"!=typeof(r=e.body)||null===r||!("three_ds_result"in r)||!("errors"in r)))throw e;if(c(e.body.errors,{code:"three_d_secure_required"})){const r=this.getGooglePayInitializationData();Rt(r),this.stripeUPEClient=yield this.loadStripeJs(r,t);const i=e.body.three_ds_result.token;let o,a=!1;try{o=yield this.stripeUPEClient.confirmCardPayment(i)}catch(e){try{o=yield this.stripeUPEClient.retrievePaymentIntent(i)}catch(e){a=!0}}if(null==o?void 0:o.error){if(this._throwDisplayableStripeError(o.error),this._isCancellationError(o.error))throw new f;throw new oe}if(!(null==o?void 0:o.paymentIntent)&&!a)throw new Nt;return this.paymentIntegrationService.submitPayment({methodId:t,paymentData:{nonce:(null==(n=null==o?void 0:o.paymentIntent)?void 0:n.id)||i}})}throw e})}loadStripeJs(e,t){return xt(this,null,function*(){if(this.stripeUPEClient)return this.stripeUPEClient;const n=this.paymentIntegrationService.getState().getCartLocale();return"googlepaystripeocs"===t?this.scriptLoader.getStripeClient(e,n,vt.CLOVER):this.scriptLoader.getStripeClient(e,n,vt.V3,Gt,"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.message)?void 0:n.indexOf("canceled"))}_throwDisplayableStripeError(e){if(o(["card_error","invalid_request_error","validation_error"],e.type))throw new Error(e.message)}}const Ft=y(r=>new Ve(r,new _e(Ye(),new jt(r,new Dt(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]);var Vt=Object.getPrototypeOf,Ut=Reflect.get;class Wt extends Q{constructor(e){super("worldpay",e)}mapToExternalCheckoutData(e){return t=this,n=function*(){const t=yield(n=Wt.prototype,Ut(Vt(n),"mapToExternalCheckoutData",this)).call(this,e);var n;return t.nonce=btoa(t.nonce),t},new Promise((e,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},o=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,o);a((n=n.apply(t,null)).next())});var t,n}}const Ht=y(n=>new Ve(n,new _e(Ye(),new Wt(n),t(),e())),[{id:"googlepayworldpayaccess"}]),qt="3.128.0",Kt="3.123.2",Jt="3.106.0";class Yt{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()||(G(t,"PAYPAL-5809.braintree_hosted_fields_fix_version")?qt:G(t,"PAYPAL-5636.update_braintree_sdk_version")?Kt:Jt)}getPreloadedSDKVersion(){const e=this.braintreeWindow.braintree;if(e){const t=i(Object.values(e),e=>!!e.VERSION);return null==t?void 0:t.VERSION}}}class Zt extends d{constructor(e){super(e||"Unsupported browser error"),this.name="UnsupportedBrowserError",this.type="unsupported_browser"}}var Xt=(e=>(e.KountNotEnabled="DATA_COLLECTOR_KOUNT_NOT_ENABLED",e))(Xt||{}),Qt=Object.defineProperty,$t=Object.getOwnPropertySymbols,en=Object.prototype.hasOwnProperty,tn=Object.prototype.propertyIsEnumerable,nn=(e,t,n)=>t in e?Qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rn=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class on{constructor(e){this.braintreeScriptLoader=e}initialize(e){this.setClientToken(e)}deinitialize(){return rn(this,null,function*(){yield this.teardownModule(this.dataCollector),this.dataCollector=void 0})}getClient(){return rn(this,null,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 rn(this,null,function*(){const t={deviceData:void 0,teardown:()=>Promise.resolve()};if(!this.dataCollector)try{const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadDataCollector(),r=((e,t)=>{for(var n in t||(t={}))en.call(t,n)&&nn(e,n,t[n]);if($t)for(var n of $t(t))tn.call(t,n)&&nn(e,n,t[n]);return e})({client:t,kount:!0},e);this.dataCollector=yield n.create(r)}catch(e){if(function(e){return Boolean("object"==typeof e&&null!==e&&("type"in e||"message"in e||"code"in e))}(e)&&e.code===Xt.KountNotEnabled)return t;throw e}return this.dataCollector})}getBraintreeGooglePayment(){return rn(this,null,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 rn(this,null,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 rn(this,null,function*(){if(!this.braintreeLocalPayment){const[t,n]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadLocalPayment()]);this.braintreeLocalPayment=yield new Promise((r,i)=>{n.create({client:t,merchantAccountId:e},(e,t)=>{e&&i(e),r(t)})})}return this.braintreeLocalPayment})}getUsBankAccount(){return rn(this,null,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 rn(this,null,function*(){return this.visaCheckoutSDK||(this.visaCheckoutSDK=yield this.braintreeScriptLoader.loadVisaCheckoutSdk(e)),this.visaCheckoutSDK})}getVenmoCheckoutOrThrow(){return rn(this,null,function*(){if(!this.braintreeVenmo){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadVenmoCheckout(),n={client:e,allowDesktop:!0,paymentMethodUsage:"multi_use"},r=yield t.create(n);if(!r.isBrowserSupported())throw new Zt;this.braintreeVenmo=r}return this.braintreeVenmo})}setClientToken(e){this.clientToken=e}getClientTokenOrThrow(){if(!this.clientToken)throw new b(w.PaymentNotInitialized);return this.clientToken}teardownModule(e){return e?e.teardown():Promise.resolve()}}var an=(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",e))(an||{});const sn={[Jt]:{[an.Client]:"sha384-26BXDNnJI23JYRyFBj4xe4sVNrUSSiSSu11kxVXNM/vEPONm4LuL00w6ZaTgQewt",[an.PaypalCheckout]:"sha384-B+vzbZwnQtzWBthpkT4TXKUibO65tyeK7eCxSvpblgprTep2+IAXB2Cxxjrn710O",[an.Paypal]:"sha384-uyAGL1/3+XJAHnGoNy4eCoXdzJ4f7Ilzp+6w9PNnEjs6DCCz9WMyJjMN1gzc78U+",[an.LocalPayment]:"sha384-LIvOEMkIVEwVuYBdVOQc1AC5YbGGlwyfUheS0ACK218D2STuVYQlZ4FyEPowAEfT",[an.DataCollector]:"sha384-1bo9JDz+Kscthc085cCKWur8CLwUoBpoNyxsDi7932mCl0zFq3A5mv+FQLw9GHpV",[an.UsBankAccount]:"sha384-xmHBVaU+w74V+OebD3AaPONFxHUGMf+QRs8G/JxVPXNNP7MDa2jL0ICWHIe2tTfJ",[an.GooglePayment]:"sha384-WKDJl8mqoP82qZpMGH6AbZxnvXnSW8ILV4M64CyMLiugGMwu7LyP89wjCkHqsiBe",[an.ThreeDSecure]:"sha384-VQUlpGHzsGvs5XeiGFip7EXRsvoHWEXDVmgCacfbyieZI9mdBOqq3NSoyo28OCOB",[an.VisaCheckout]:"sha384-yx7mADfzTN0T43Q6rlH49LIg1EJ0iUZgBp/EczX9LXsUGkySgxrD+nWHQRBkyfoT",[an.Venmo]:"sha384-QX4rPjoj1ZDhuG0aSyKs56lEKDqTMTcjYxUHY1SzO5VZDsqIE2NTkqot7KNSCyov",[an.HostedFields]:"sha384-VvYBACfSu0Cr/J32uKmxG7AXcNOJE1AzIIL3kbikyS7YKp5fz5Is+NzNP/lyauNy",[an.Fastlane]:"sha384-9oGsZMRZwpGtDEDYa/dFt76dECqj1xAni9gIKgc3KfMIiRnR73nEeeUDLiBzxhFa"},[Kt]:{[an.Client]:"sha384-o+nbQGcwNNxIBeXeu3+XmbSq+Cg8R3EN3N0l5hXCgMMU2RGY0t1z0LroSEIAbfAO",[an.PaypalCheckout]:"sha384-WrfbWPBS4mH86GAoycPSgiH8hQ8KH7A67C93Hjhunv/xhNk2YpBn3wbFA4Fhg9U/",[an.Paypal]:"sha384-VF389nvvrRUgDsTXMxTYORDtVegB9IQa3Cxr//DyJnLYnz8/X8VCzEvck2c+Megt",[an.LocalPayment]:"sha384-tZKx2rEQbfmZpoPSY5VPmJEhaq4X75dLvwHMs3VE9U+C8lPyw+hWTIL1+GPvWCIH",[an.DataCollector]:"sha384-E6k3wOpP7syCDDwaRDLF06942Y00NkbwJvWi2OQXwwKzGwG5fd3E7RFUvCCecfvO",[an.UsBankAccount]:"sha384-258FON8LZGG0W9Qaz4Jij83pZHu30YnKjJA7gNulLBh6CclkucgF+tHDQuYFRYfW",[an.GooglePayment]:"sha384-taJ2p/0+n0VH328POAoBiuEbL3tnHUTE9S42hK1V+Txs3X+QYjZOyKW35JgHRFfO",[an.ThreeDSecure]:"sha384-+NSZH4Zj3sO5bdWvPKhU5N16QDxeueTVTnUVeleeESkhLSaz4Ob1hh/5myecc9Ym",[an.VisaCheckout]:"sha384-66DiBjghxk1OmBj8aksN8gbQ+CwoQcx1vPfiXUN08g1iQVM+BwewF0p7toM3i7SS",[an.Venmo]:"sha384-B5UwY42kE4RoLoWbQ7YpqosUlUad2/DlGWiw0HhoZbSPk30CQAaSA10ohyLDTkDU",[an.HostedFields]:"sha384-Aw9EesSaUeWxe36PqEHiOyOyOq8M6CIb1gw7/yHNVPRzGtFXXcd2OQ8qXrIlOj2P",[an.Fastlane]:"sha384-rhBL1hpZ71JqG+2TsT0Dih47mbjx8cjJCpeZjk9tw3df1gFMKfCTmMyZunhr7H4Y"},[qt]:{[an.Client]:"sha384-0WNxksIpRP+fYZiIdr12g6DBUQfLDzYCQJZtR/C8KkcwSGhPHfcFp3tTaGcMyFTq",[an.PaypalCheckout]:"sha384-lWM1jk4BOxoDNV6Kop7tVNvQgINlmEVz0c/OwM+HNHK3QC8xqwd54Ovrt2QRDTjh",[an.Paypal]:"sha384-fXUmVxC2EMZBDXZ7eTHSTL/LFBrHej/MSXT/vTBXvra4lzgLNGvREAp+x0GYObuH",[an.LocalPayment]:"sha384-pha1xGuGSkmZH5x9aqHvRaO4xLea7rmQ/79PFj9zxNzxuFcOWZg7gOP7FibygOEC",[an.DataCollector]:"sha384-Q6PI2F9eekWbAxhroybl+aEcvqhdowN/EQlGwBUyJOzPFn9982u9xl6SU6XfGKzc",[an.UsBankAccount]:"sha384-W3RLQSKJL1tQ3+Y7mP6tmkamtZ8bV4Yw/XxL9Jj5JtXHraD8loMF8hAIG5m2zK7F",[an.GooglePayment]:"sha384-TITQMsFWA3elDNGP2mWz2oKBo4qjt+TlqzovcaPoeBiAh/wPBi6nae50ADdgU1/i",[an.ThreeDSecure]:"sha384-YiycYN89ZlL/Evcaq4y1ajW1mhd7JYfZBDuOwHtIn4/Jnm20GL+/XCM+zYAwWD8D",[an.VisaCheckout]:"sha384-/OdaTv9qrkKzjObtUe6yzfDhHozFW/+uXlrSl736sOZRJpjGQETvpYXqMFFg69xv",[an.Venmo]:"sha384-dA+ojdW9vbJS4JavcXyOs9d5uZHJg5dNtYupoPSH2zsXIiYDVS5amLb/u8qmQ6oz",[an.HostedFields]:"sha384-31ZkS58+iaWsW06ftW52zzVZFp43WPd7pNYRiddYynSNg6Oh7WGbSFGorAUH6T1z",[an.Fastlane]:"sha384-jlbrwNvL3HvLAUCtLSmrnQ2GH1udCUrRS/bVmReAS5fuIVvcW8Pko/Gkg82tlgtr"}};var ln=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class cn{constructor(e,t,n){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSDKVersionManager=n}loadClient(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.Client,"client.min.js")})}loadFastlane(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.Fastlane,"fastlane.min.js")})}loadPaypalCheckout(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.PaypalCheckout,"paypal-checkout.min.js")})}loadPaypal(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.Paypal,"paypal.min.js")})}loadLocalPayment(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.LocalPayment,"local-payment.min.js")})}loadDataCollector(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.DataCollector,"data-collector.min.js")})}loadUsBankAccount(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.UsBankAccount,"us-bank-account.min.js")})}loadGooglePayment(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.GooglePayment,"google-payment.min.js")})}load3DS(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.ThreeDSecure,"three-d-secure.min.js")})}loadVisaCheckout(){return this.loadBraintreeModuleOrThrow(an.VisaCheckout,"visa-checkout.min.js")}loadVenmoCheckout(){return this.loadBraintreeModuleOrThrow(an.Venmo,"venmo.min.js")}loadHostedFields(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.HostedFields,"hosted-fields.min.js")})}loadVisaCheckoutSdk(e){return ln(this,null,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 ln(this,null,function*(){let n=this.getBraintreeModule(e);if(n)return n;const r=this.braintreeSDKVersionManager.getSDKVersion(),i=`//js.braintreegateway.com/web/${r}/js/${t}`,o=r in sn?this.getIntegrityValuesByModuleName(e,r):void 0;if(yield this.scriptLoader.loadScript(i,o?{async:!0,attributes:{integrity:o,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[e]}getIntegrityValuesByModuleName(e,t){const n=sn[t][e];if(!n)throw new Error("Unexpected fileName value");return n}}class dn{constructor(e){const t=new Promise((e,t)=>{this.cancel=t});this.promise=Promise.race([e,t])}}var hn=Object.defineProperty,un=Object.getOwnPropertySymbols,yn=Object.getPrototypeOf,pn=Object.prototype.hasOwnProperty,gn=Object.prototype.propertyIsEnumerable,_n=Reflect.get,mn=(e,t,n)=>t in e?hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pn=(e,t,n)=>_n(yn(e),n,t),fn=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class wn extends Q{constructor(e,t){super("braintree",e),this._braintreeSdk=t,this._methodId=ke.BRAINTREE,this._verificationsInProgress=0,this._service=e}initialize(e,t,n){return fn(this,null,function*(){yield Pn(wn.prototype,this,"initialize").call(this,e,t,n);let r=Pn(wn.prototype,this,"getPaymentMethod").call(this);if(r.clientToken||(r=(yield this._service.loadPaymentMethod(this._methodId)).getPaymentMethodOrThrow(this._methodId)),!r.clientToken||!r.initializationData)throw new _(g.MissingPaymentMethod);return this._braintreeSdk.initialize(r.clientToken),this._braintreeGooglePayment=yield this._braintreeSdk.getBraintreeGooglePayment(),Promise.resolve()})}getNonce(e){return fn(this,null,function*(){var t;const n=yield Pn(wn.prototype,this,"getNonce").call(this,e),{clientToken:r,initializationData:i}=Pn(wn.prototype,this,"getPaymentMethod").call(this);if(!r||!i||!(null==(t=i.card_information)?void 0:t.bin))throw new _(g.MissingPaymentMethod);const{isThreeDSecureEnabled:o,card_information:{bin:a,isNetworkTokenized:s}}=i;if(o&&!s){const e=yield this._braintreeSdk.getBraintreeThreeDS(),{orderAmount:t}=this._service.getState().getOrderOrThrow();return(yield this._braintreePresent3DSChallenge(e,t,n,a)).nonce}return n})}extraPaymentData(){return fn(this,null,function*(){return{deviceSessionId:yield this._getBraintreeDeviceData()}})}mapToExternalCheckoutData(e){return fn(this,null,function*(){const t=yield Pn(wn.prototype,this,"mapToExternalCheckoutData").call(this,e);let n;try{n=JSON.parse(t.nonce)}catch(e){throw new S("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 _(g.MissingPaymentToken)}(n),t.nonce=n.androidPayCards[0].nonce,t.card_information.bin=n.androidPayCards[0].details.bin,t.card_information.isNetworkTokenized=n.androidPayCards[0].details.isNetworkTokenized,t})}getCardParameters(){return super.getCardParameters()}getPaymentGatewayParameters(){return fn(this,null,function*(){return this.getBraintreeGooglePayment().createPaymentDataRequest(((e,t)=>{for(var n in t||(t={}))pn.call(t,n)&&mn(e,n,t[n]);if(un)for(var n of un(t))gn.call(t,n)&&mn(e,n,t[n]);return e})({merchantInfo:Pn(wn.prototype,this,"getMerchantInfo").call(this),transactionInfo:Pn(wn.prototype,this,"getTransactionInfo").call(this),cardRequirements:{billingAddressRequired:!0,billingAddressFormat:"FULL"}},yield Pn(wn.prototype,this,"getRequiredData").call(this))).paymentMethodTokenizationParameters.parameters})}getBraintreeGooglePayment(){if(!this._braintreeGooglePayment)throw new _(g.MissingPaymentMethod);return this._braintreeGooglePayment}_getBraintreeDeviceData(){return fn(this,null,function*(){const{deviceData:e}=yield this._braintreeSdk.getDataCollectorOrThrow();return e})}_braintreePresent3DSChallenge(e,t,n,r){return fn(this,null,function*(){this._verificationsInProgress>0&&(yield this._cancelBraintree3DSVerification(e)),this._verificationsInProgress+=1;const i=new dn(e.verifyCard({amount:t,bin:r,nonce:n,onLookupComplete:(e,t)=>{t()}}));try{return yield i.promise}finally{this._verificationsInProgress-=1}})}_cancelBraintree3DSVerification(e){return fn(this,null,function*(){try{yield e.cancelVerifyCard()}catch(e){}})}}const bn=y(r=>{const i=t(),o=window,a=new Yt(r),s=new on(new cn(n(),o,a));return new Ve(r,new _e(Ye(),new wn(r,s),i,e()))},[{id:"googlepaybraintree"}]),Sn=["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 Cn(e){if(!e)return;let t;if(e.includes("-")){const[n,r]=e.split("-");t=`${n}_${r.toUpperCase()}`}else t=`${e}_${e.toUpperCase()}`;return Sn.includes(t)?t:void 0}var vn=Object.defineProperty,In=Object.defineProperties,On=Object.getOwnPropertyDescriptors,An=Object.getOwnPropertySymbols,Tn=Object.prototype.hasOwnProperty,Mn=Object.prototype.propertyIsEnumerable,kn=(e,t,n)=>t in e?vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,En=(e,t)=>{for(var n in t||(t={}))Tn.call(t,n)&&kn(e,n,t[n]);if(An)for(var n of An(t))Mn.call(t,n)&&kn(e,n,t[n]);return e},Dn=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class zn{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n,r){return Dn(this,null,function*(){if(!this.window.paypalFastlaneSdk){const i=this.getPayPalFastlaneSdkConfiguration(e,t,n,r);if(yield this.loadPayPalSdk(i),!this.window.paypalFastlaneSdk)throw new h}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,r,i){return Dn(this,null,function*(){if(!this.window.paypalGooglePay||i){const i=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,r);yield this.loadPayPalSdk(i)}if(!this.window.paypalGooglePay)throw new h;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t,n){return Dn(this,null,function*(){if(!this.window.paypalApms){const r=this.getPayPalApmSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(r),!this.window.paypalApms)throw new h}return this.window.paypalApms})}getPayPalMessages(e,t,n){return Dn(this,null,function*(){if(!this.window.paypalMessages){const r=this.getPayPalSdkMessagesConfiguration(e,t,n);yield this.loadPayPalSdk(r)}if(!this.window.paypalMessages)throw new h;return this.window.paypalMessages})}loadPayPalSdk(e){return Dn(this,arguments,function*({options:e,attributes:t}){const n=this.transformConfig(e),r=this.transformConfig(t),i=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(i,{async:!0,attributes:r})})}getPayPalFastlaneSdkConfiguration(e,t,n,r){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new _(g.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:l,attributionId:c}=o,d=Cn(r);return{options:En({"client-id":s,"merchant-id":l,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t,intent:a},d&&{locale:d}),attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":i}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,r=!0){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new _(g.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:l,buyerCountry:c,attributionId:d,isHostedCheckoutEnabled:h,isDeveloperModeApplicable:u}=o,y=h||r,p=Cn(n);return{options:En(En({"client-id":s,"merchant-id":l,commit:y,components:["googlepay"],currency:t,intent:a},u&&{"buyer-country":c}),p&&{locale:p}),attributes:{"data-partner-attribution-id":d,"data-client-token":i,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t,n){const{initializationData:r}=e;if(!r||!r.clientId)throw new _(g.MissingPaymentMethod);const{intent:i,clientId:o,merchantId:a,buyerCountry:s,attributionId:l,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:d=[],enabledAlternativePaymentMethods:h=[]}=r,u=h,y=d.filter(e=>!h.includes(e)),p=Cn(n);return{options:En(En({"client-id":o,"merchant-id":a,"enable-funding":u.length>0?u:void 0,"disable-funding":y.length>0?y:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:i},c&&{"buyer-country":s}),p&&{locale:p}),attributes:{"data-partner-attribution-id":l,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t,n){const{initializationData:r}=e;if(!r||!r.clientId)throw new _(g.MissingPaymentMethod);const{clientId:i,merchantId:o,attributionId:a,isDeveloperModeApplicable:s,buyerCountry:l}=r,c=Cn(n);return{options:En(En({"client-id":i,"merchant-id":o,components:["messages"],currency:t},s&&{"buyer-country":l}),c&&{locale:c}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const r=e[n];var i,o;null==r||""===r||Array.isArray(r)&&0===r.length||(i=En({},t),o={[n]:Array.isArray(r)?r.join(","):r},t=In(i,On(o)))}),t}}function Nn(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 _(g.MissingPaymentMethod)}var Gn=Object.getPrototypeOf,Rn=Reflect.get,Bn=(e,t,n)=>Rn(Gn(e),n,t),Ln=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class xn extends Q{constructor(e,t){super("paypalsb",e),this.payPalCommerceSdk=t,this.service=e}initialize(e,t,n){return Ln(this,null,function*(){var r,i,o,a,s;const l=this.service.getState(),c=null!=(i=null==(r=l.getStoreConfig())?void 0:r.currency.code)?i:n;if(!c)throw new _(g.MissingPaymentMethod);yield Bn(xn.prototype,this,"initialize").call(this,e,t,c);const d=Bn(xn.prototype,this,"getPaymentMethod").call(this);if(!d.initializationData)throw new _(g.MissingPaymentMethod);Nn(d);const h=yield this.payPalCommerceSdk.getPayPalGooglePaySdk(d,c,l.getLocale());this.googlepayConfig=yield h.Googlepay().config();const{allowedPaymentMethods:u}=this.googlepayConfig;this.setGatewayIdentifier(null==(s=null==(a=null==(o=u[0])?void 0:o.tokenizationSpecification)?void 0:a.parameters)?void 0:s.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){return Ln(this,null,function*(){const t=yield Bn(xn.prototype,this,"mapToExternalCheckoutData").call(this,e);return t.nonce=btoa(t.nonce),t})}}const jn="This API endpoint is for internal use only and may change in the future";var Fn=(e=>(e.Approved="APPROVED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e))(Fn||{}),Vn=Object.defineProperty,Un=Object.getOwnPropertySymbols,Wn=Object.prototype.hasOwnProperty,Hn=Object.prototype.propertyIsEnumerable,qn=(e,t,n)=>t in e?Vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Kn=(e,t)=>{for(var n in t||(t={}))Wn.call(t,n)&&qn(e,n,t[n]);if(Un)for(var n of Un(t))Hn.call(t,n)&&qn(e,n,t[n]);return e},Jn=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class Yn extends Ve{constructor(e,t,n,r){super(e,t),this._payPalCommerceSdk=n,this._requestSender=r}execute(e){return Jn(this,arguments,function*({payment:e}){if(!(null==e?void 0:e.methodId))throw new me(["payment"]);const t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow().id,{initializationData:r}=t.getPaymentMethodOrThrow(this._getMethodId()),{orderId:i}=yield this.getOrderId(n),{card_information:o}=r||{},a=yield this._googlePayPaymentProcessor.getNonce(e.methodId),s={tokenizationData:{type:"PAYMENT_GATEWAY",token:atob(a)},info:{cardNetwork:(null==o?void 0:o.type)||"",cardDetails:(null==o?void 0:o.number)||""},type:"CARD"};yield this.confirmOrder(i,s),yield this._paymentIntegrationService.submitOrder();try{const t={formattedPayload:{method_id:e.methodId,paypal_account:{order_id:i}}};yield this._paymentIntegrationService.submitPayment({methodId:e.methodId,paymentData:t})}catch(e){yield this._googlePayPaymentProcessor.processAdditionalAction(e)}})}confirmOrder(e,t){return Jn(this,null,function*(){const n=this._paymentIntegrationService.getState(),r=n.getPaymentMethodOrThrow(this._getMethodId());if(!r.initializationData)throw new _(g.MissingPaymentMethod);const i=n.getCartOrThrow().currency.code,o=yield this._payPalCommerceSdk.getPayPalGooglePaySdk(r,i,n.getLocale(),!0),{status:a}=yield o.Googlepay().confirmOrder({orderId:e,paymentMethodData:t});if(a===Fn.PayerActionRequired)return yield o.Googlepay().initiatePayerAction({orderId:e}),Promise.resolve();if(a!==Fn.Approved)throw new S("Payment is not approved.");return Promise.resolve()})}getOrderId(e){return Jn(this,null,function*(){const t={cartId:e,shouldSaveInstrument:!1},{body:n}=yield this._requestSender.post("/api/storefront/payments/googlepaypaypalcommercecheckout",{headers:Kn({"X-API-INTERNAL":jn,"Content-Type":ct.Json},ie),body:t});return n})}}const Zn=y(r=>{const i=new zn(n());return new Yn(r,new _e(Ye(),new xn(r,i),t(),e()),i,t())},[{id:"googlepaypaypalcommerce"}]);var Xn=Object.defineProperty,Qn=Object.defineProperties,$n=Object.getOwnPropertyDescriptors,er=Object.getOwnPropertySymbols,tr=Object.prototype.hasOwnProperty,nr=Object.prototype.propertyIsEnumerable,rr=(e,t,n)=>t in e?Xn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ir=(e,t)=>{for(var n in t||(t={}))tr.call(t,n)&&rr(e,n,t[n]);if(er)for(var n of er(t))nr.call(t,n)&&rr(e,n,t[n]);return e},or=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class ar{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n){return or(this,null,function*(){if(!this.window.bigCommercePaymentsFastlaneSdk){const r=this.getPayPalFastlaneSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(r),!this.window.bigCommercePaymentsFastlaneSdk)throw new h}return this.window.bigCommercePaymentsFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,r){return or(this,null,function*(){if(!this.window.bigCommercePaymentsGooglePay||r){const r=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n);yield this.loadPayPalSdk(r)}if(!this.window.bigCommercePaymentsGooglePay)throw new h;return this.window.bigCommercePaymentsGooglePay})}getPayPalApmsSdk(e,t){return or(this,null,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 or(this,null,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(e){return or(this,arguments,function*({options:e,attributes:t}){const n=this.transformConfig(e),r=this.transformConfig(t),i=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(i,{async:!0,attributes:r})})}getPayPalFastlaneSdkConfiguration(e,t,n){const{clientToken:r,initializationData:i}=e;if(!i||!i.clientId)throw new _(g.MissingPaymentMethod);const{intent:o,clientId:a,merchantId:s,attributionId:l}=i;return{options:{"client-id":a,"merchant-id":s,commit:!0,components:["fastlane","three-domain-secure"],currency:t,intent:o},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"bigCommercePaymentsFastlaneSdk","data-partner-attribution-id":l,"data-sdk-client-token":r}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n=!0){const{clientToken:r,initializationData:i}=e;if(!i||!i.clientId)throw new _(g.MissingPaymentMethod);const{intent:o,clientId:a,merchantId:s,buyerCountry:l,attributionId:c,isHostedCheckoutEnabled:d,isDeveloperModeApplicable:h}=i;return{options:ir({"client-id":a,"merchant-id":s,commit:d||n,components:["googlepay"],currency:t,intent:o},h&&{"buyer-country":l}),attributes:{"data-partner-attribution-id":c,"data-client-token":r,"data-namespace":"bigCommercePaymentsGooglePay"}}}getPayPalApmSdkConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new _(g.MissingPaymentMethod);const{intent:r,clientId:i,merchantId:o,buyerCountry:a,attributionId:s,isDeveloperModeApplicable:l,availableAlternativePaymentMethods:c=[],enabledAlternativePaymentMethods:d=[]}=n,h=this.filterFundingOptions(d),u=this.filterFundingOptions(c.filter(e=>!d.includes(e)));return{options:ir({"client-id":i,"merchant-id":o,"enable-funding":h.length>0?h:void 0,"disable-funding":u.length>0?u:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:r},l&&{"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 _(g.MissingPaymentMethod);const{clientId:r,merchantId:i,attributionId:o,isDeveloperModeApplicable:a,buyerCountry:s}=n;return{options:ir({"client-id":r,"merchant-id":i,components:["messages"],currency:t},a&&{"buyer-country":s}),attributes:{"data-namespace":"bigCommercePaymentsMessages","data-partner-attribution-id":o}}}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 r=e[n];var i,o;null==r||""===r||Array.isArray(r)&&0===r.length||(i=ir({},t),o={[n]:Array.isArray(r)?r.join(","):r},t=Qn(i,$n(o)))}),t}}var sr=Object.getPrototypeOf,lr=Reflect.get,cr=(e,t,n)=>lr(sr(e),n,t),dr=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class hr extends Q{constructor(e,t){super("googlepay_bigcommerce_payments",e),this.payPalSdkHelper=t,this.service=e}initialize(e,t,n){return dr(this,null,function*(){var r,i,o,a,s;const l=null!=(i=null==(r=this.service.getState().getStoreConfig())?void 0:r.currency.code)?i:n;if(!l)throw new _(g.MissingPaymentMethod);yield cr(hr.prototype,this,"initialize").call(this,e,t,l);const c=cr(hr.prototype,this,"getPaymentMethod").call(this);if(!c.initializationData)throw new _(g.MissingPaymentMethod);Nn(c);const d=yield this.payPalSdkHelper.getPayPalGooglePaySdk(c,l);this.googlepayConfig=yield d.Googlepay().config();const{allowedPaymentMethods:h}=this.googlepayConfig;this.setGatewayIdentifier(null==(s=null==(a=null==(o=h[0])?void 0:o.tokenizationSpecification)?void 0:a.parameters)?void 0:s.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){return dr(this,null,function*(){const t=yield cr(hr.prototype,this,"mapToExternalCheckoutData").call(this,e);return t.nonce=btoa(t.nonce),t})}}var ur=(e=>(e.Approved="APPROVED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e))(ur||{}),yr=Object.defineProperty,pr=Object.getOwnPropertySymbols,gr=Object.prototype.hasOwnProperty,_r=Object.prototype.propertyIsEnumerable,mr=(e,t,n)=>t in e?yr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pr=(e,t)=>{for(var n in t||(t={}))gr.call(t,n)&&mr(e,n,t[n]);if(pr)for(var n of pr(t))_r.call(t,n)&&mr(e,n,t[n]);return e},fr=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class wr extends Ve{constructor(e,t,n,r){super(e,t),this._payPalSdkHelper=n,this._requestSender=r}execute(e){return fr(this,arguments,function*({payment:e}){if(!(null==e?void 0:e.methodId))throw new me(["payment"]);const t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow().id,{initializationData:r}=t.getPaymentMethodOrThrow(this._getMethodId()),{orderId:i}=yield this.getOrderId(n),{card_information:o}=r||{},a=yield this._googlePayPaymentProcessor.getNonce(e.methodId),s={tokenizationData:{type:"PAYMENT_GATEWAY",token:atob(a)},info:{cardNetwork:(null==o?void 0:o.type)||"",cardDetails:(null==o?void 0:o.number)||""},type:"CARD"};yield this.confirmOrder(i,s),yield this._paymentIntegrationService.submitOrder();try{const t={formattedPayload:{method_id:e.methodId,paypal_account:{order_id:i}}};yield this._paymentIntegrationService.submitPayment({methodId:e.methodId,paymentData:t})}catch(e){yield this._googlePayPaymentProcessor.processAdditionalAction(e)}})}confirmOrder(e,t){return fr(this,null,function*(){const n=this._paymentIntegrationService.getState(),r=n.getPaymentMethodOrThrow(this._getMethodId());if(!r.initializationData)throw new _(g.MissingPaymentMethod);const i=n.getCartOrThrow().currency.code,o=yield this._payPalSdkHelper.getPayPalGooglePaySdk(r,i,!0),{status:a}=yield o.Googlepay().confirmOrder({orderId:e,paymentMethodData:t});if(a===ur.PayerActionRequired)return yield o.Googlepay().initiatePayerAction({orderId:e}),Promise.resolve();if(a!==ur.Approved)throw new S("Payment is not approved.");return Promise.resolve()})}getOrderId(e){return fr(this,null,function*(){const t={cartId:e,shouldSaveInstrument:!1},{body:n}=yield this._requestSender.post("/api/storefront/payments/googlepay_bigcommerce_paymentscheckout",{headers:Pr({"X-API-INTERNAL":jn,"Content-Type":ct.Json},ie),body:t});return n})}}const br=y(r=>{const i=new ar(n());return new wr(r,new _e(Ye(),new hr(r,i),t(),e()),i,t())},[{id:"googlepay_bigcommerce_payments"}]);var Sr=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class Cr extends Q{constructor(e,t){super("worldlinena",e),this.formPoster=t}extraPaymentData(){return Sr(this,null,function*(){return Promise.resolve({browser_info:m()})})}processAdditionalAction(e){return Sr(this,null,function*(){if(!function(e){return P(e)&&(t=e.body,s(t)&&"object"==typeof t&&"errors"in t&&"three_ds_result"in t&&a(t.errors)&&c(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:r,merchant_data:i}=t||{};if(!n||!r||!i)throw new me(["formUrl","threeDSSessionData","creq"]);return new Promise(e=>{this.formPoster.postForm(n,{threeDSSessionData:r,creq:i},e,"_top")})})}}const vr=y(n=>new Ve(n,new _e(Ye(),new Cr(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);class Ir extends d{constructor(e){super(e||"Not implemented."),this.name="NotImplementedError",this.type="not_implemented"}}var Or=Object.defineProperty,Ar=Object.defineProperties,Tr=Object.getOwnPropertyDescriptors,Mr=Object.getOwnPropertySymbols,kr=Object.prototype.hasOwnProperty,Er=Object.prototype.propertyIsEnumerable,Dr=(e,t,n)=>t in e?Or(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zr=(e,t)=>{for(var n in t||(t={}))kr.call(t,n)&&Dr(e,n,t[n]);if(Mr)for(var n of Mr(t))Er.call(t,n)&&Dr(e,n,t[n]);return e},Nr=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class Gr{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){return Nr(this,null,function*(){var t,n;if(!(null==e?void 0:e.methodId)||!Ee(e.methodId))throw new S('Unable to proceed because "methodId" is not a valid key.');this._methodId=e.methodId;const r=e[this._getMethodId()];if(!r)throw new S("Unable to proceed without valid options.");let i,o=this._paymentIntegrationService.getState();try{i=o.getPaymentMethodOrThrow(this._getMethodId())}catch(e){o=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodId()),i=o.getPaymentMethodOrThrow(this._getMethodId())}try{this._googlePayPaymentProcessor.setIsWebViewExperimentOn(!!(null==(t=i.initializationData)?void 0:t.isWebViewExperimentOn)),this._googlePayPaymentProcessor.setFilterAvailableShippingOptions(r.filterAvailableShippingOptions),yield this._googlePayPaymentProcessor.initialize(()=>i,this._getGooglePayClientOptions(null==(n=i.initializationData)?void 0:n.storeCountry))}catch(e){return}this._addPaymentButton(r)})}signIn(){return Promise.reject(new Ir('In order to sign in via Google Pay, the shopper must click on "Google Pay" button.'))}signOut(){return Nr(this,null,function*(){var e;const t=null==(e=this._paymentIntegrationService.getState().getPaymentId())?void 0:e.providerId;t&&(yield this._googlePayPaymentProcessor.signOut(t))})}executePaymentMethodCheckout(e){var t;return null==(t=null==e?void 0:e.continueWithCheckoutCallback)||t.call(e),Promise.resolve()}deinitialize(){var e;return null==(e=this._paymentButton)||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()}_getGooglePayClientOptions(e){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:t=>Nr(this,[t],function*({callbackTrigger:t,shippingAddress:n,shippingOptionData:r,offerData:i}){const{availableTriggers:o,addressChangeTriggers:a,shippingOptionsChangeTriggers:s,offerChangeTriggers:l}=this._googlePayPaymentProcessor.getCallbackTriggers();if(!o.includes(t))return;const c=a.includes(t)?yield this._googlePayPaymentProcessor.handleShippingAddressChange(n):void 0;s.includes(t)&&(yield this._googlePayPaymentProcessor.handleShippingOptionChange(r.id));const{newOfferInfo:d,error:h}=l.includes(t)?yield this._googlePayPaymentProcessor.handleCoupons(i):{},u=h;yield this._paymentIntegrationService.loadCheckout();const y=this._googlePayPaymentProcessor.getTotalPrice(),{code:p}=this._paymentIntegrationService.getState().getCartOrThrow().currency;return zr(zr(zr({newTransactionInfo:(g=zr({},e&&{countryCode:e}),_={currencyCode:p,totalPriceStatus:R.FINAL,totalPrice:y},Ar(g,Tr(_)))},c&&{newShippingOptionParameters:c}),d&&{newOfferInfo:d}),u&&{error:u});var g,_})}}}_addPaymentButton({container:e,buttonColor:t,buttonType:n,onClick:r,onError:i}){var o;this._paymentButton=null!=(o=this._paymentButton)?o:this._googlePayPaymentProcessor.addPaymentButton(e,{buttonColor:null!=t?t:"default",buttonType:null!=n?n:"plain",onClick:this._handleClick(i,r)})}_handleClick(e,t){return n=>Nr(this,null,function*(){n.preventDefault(),t&&"function"==typeof t&&t();try{yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(t){let n=t;if(Me(t)){if("CANCELED"===t.statusCode)throw new f;n=new oe(JSON.stringify(t))}throw null==e||e(new oe("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){return Nr(this,null,function*(){const e=yield this._googlePayPaymentProcessor.showPaymentSheet(),t=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(e),n=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(e),r="/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,r)})}_getMethodId(){return z(this._methodId,()=>new b(w.PaymentNotInitialized))}}const Rr=y(n=>{const r=t();return new Gr(n,new _e(Ye(),new Q("adyen",n),r,e()))},[{id:"googlepayadyenv2"}]),Br=y(n=>{const r=t();return new Gr(n,new _e(Ye(),new Q("adyen",n),r,e()))},[{id:"googlepayadyenv3"}]),Lr=y(n=>new Gr(n,new _e(Ye(),new at(n),t(),e())),[{id:"googlepayauthorizenet"}]),xr=y(n=>{const r=t();return new Gr(n,new _e(Ye(),new pt(n,r),r,e()))},[{id:"googlepaycheckoutcom"}]),jr=y(n=>new Gr(n,new _e(Ye(),new Pt(n),t(),e())),[{id:"googlepaycybersourcev2"}]),Fr=y(n=>new Gr(n,new _e(Ye(),new Pt(n),t(),e())),[{id:"googlepaybnz"}]),Vr=y(n=>new Gr(n,new _e(Ye(),new St(n),t(),e())),[{id:"googlepayorbital"}]),Ur=y(r=>new Gr(r,new _e(Ye(),new jt(r,new Dt(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeocs"}]),Wr=y(r=>new Gr(r,new _e(Ye(),new jt(r,new Dt(n())),t(),e())),[{id:"googlepaystripeupe"}]),Hr=y(n=>new Gr(n,new _e(Ye(),new Wt(n),t(),e())),[{id:"googlepayworldpayaccess"}]),qr=y(r=>{const i=t(),o=window,a=new Yt(r),s=new on(new cn(n(),o,a));return new Gr(r,new _e(Ye(),new wn(r,s),i,e()))},[{id:"googlepaybraintree"}]),Kr=y(r=>new Gr(r,new _e(Ye(),new xn(r,new zn(n())),t(),e())),[{id:"googlepaypaypalcommerce"}]),Jr=y(r=>new Gr(r,new _e(Ye(),new hr(r,new ar(n())),t(),e())),[{id:"googlepay_bigcommerce_payments"}]),Yr=y(n=>new Gr(n,new _e(Ye(),new Cr(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);class Zr extends d{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 Xr=Object.defineProperty,Qr=Object.defineProperties,$r=Object.getOwnPropertyDescriptors,ei=Object.getOwnPropertySymbols,ti=Object.prototype.hasOwnProperty,ni=Object.prototype.propertyIsEnumerable,ri=(e,t,n)=>t in e?Xr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ii=(e,t)=>{for(var n in t||(t={}))ti.call(t,n)&&ri(e,n,t[n]);if(ei)for(var n of ei(t))ni.call(t,n)&&ri(e,n,t[n]);return e},oi=(e,t)=>Qr(e,$r(t)),ai=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class si{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){return ai(this,null,function*(){var t,n,r;if(!e.methodId||!Ee(e.methodId))throw new S('Unable to proceed because "methodId" is not a valid key.');if(this._methodId=e.methodId,!e.containerId)throw new S('Unable to proceed because "containerId" is not a valid key.');const i=e[this._getMethodOrThrow()];if(!i)throw new S("Unable to proceed without valid options.");const{buyNowInitializeOptions:o,currencyCode:a,buttonColor:s,buttonType:l,onError:c,filterAvailableShippingOptions:d}=i;let h,u=this._paymentIntegrationService.getState();try{h=u.getPaymentMethodOrThrow(this._getMethodOrThrow())}catch(e){u=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodOrThrow()),h=u.getPaymentMethodOrThrow(this._getMethodOrThrow())}if(this._countryCode=null==(t=h.initializationData)?void 0:t.storeCountry,this._googlePayPaymentProcessor.setIsWebViewExperimentOn(!!(null==(n=h.initializationData)?void 0:n.isWebViewExperimentOn)),this._googlePayPaymentProcessor.setFilterAvailableShippingOptions(d),o){if(!a)throw new S('Unable to initialize payment because "options.currencyCode" argument is not provided.');this._currencyCode=a,this._buyNowInitializeOptions=o,yield this._googlePayPaymentProcessor.initialize(()=>h,this._getGooglePayClientOptions(),!!o,a)}else yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initialize(()=>h,this._getGooglePayClientOptions());this._paymentButton=null!=(r=this._paymentButton)?r:this._googlePayPaymentProcessor.addPaymentButton(e.containerId,{buttonColor:null!=s?s:"default",buttonType:null!=l?l:"plain",onClick:this._handleClick(c)})})}deinitialize(){var e;return null==(e=this._paymentButton)||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()}_handleClick(e){return t=>ai(this,null,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(Me(t)){if("CANCELED"===t.statusCode)throw new f;n=new oe(JSON.stringify(t))}throw null==e||e(new oe("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){return ai(this,null,function*(){var e;const t=yield this._googlePayPaymentProcessor.showPaymentSheet(),n=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(t),r=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(t),i="/embedded-checkout"===window.location.pathname?this._paymentIntegrationService.getState().getStoreConfigOrThrow().links.siteLink:void 0;n&&(yield this._paymentIntegrationService.updateBillingAddress(n)),r&&!(null==(e=this._buyNowCart)?void 0:e.lineItems.digitalItems.length)&&(yield this._paymentIntegrationService.updateShippingAddress(r)),yield this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodOrThrow(),t,i)})}_getGooglePayClientOptions(){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:e=>ai(this,[e],function*({callbackTrigger:e,shippingAddress:t,shippingOptionData:n,offerData:r}){const{availableTriggers:i,addressChangeTriggers:o,shippingOptionsChangeTriggers:a,offerChangeTriggers:s}=this._googlePayPaymentProcessor.getCallbackTriggers();if(!i.includes(e))return;const l=o.includes(e)?yield this._googlePayPaymentProcessor.handleShippingAddressChange(t):void 0;a.includes(e)&&(yield this._googlePayPaymentProcessor.handleShippingOptionChange(n.id));const{newOfferInfo:c,error:d}=s.includes(e)?yield this._googlePayPaymentProcessor.handleCoupons(r):{},h=d;return this._buyNowInitializeOptions?this._getBuyNowTransactionInfo(l,c,h):this._getTransactionInfo(l,c,h)})}}}_createBuyNowCartOrThrow(e){return ai(this,null,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 Zr(e);throw e}}})}_getBuyNowTransactionInfo(e,t,n){if(!this._buyNowCart)return;const{cartAmount:r}=this._buyNowCart,i=this._googlePayPaymentProcessor.getTotalPrice();return ii(ii(ii({newTransactionInfo:oi(ii({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:this._getCurrencyCodeOrThrow(),totalPrice:i||String(r),totalPriceStatus:R.FINAL})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})}_getTransactionInfo(e,t,n){return ai(this,null,function*(){yield this._paymentIntegrationService.loadCheckout();const r=this._googlePayPaymentProcessor.getTotalPrice(),{code:i}=this._paymentIntegrationService.getState().getCartOrThrow().currency;return ii(ii(ii({newTransactionInfo:oi(ii({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:i,totalPriceStatus:R.FINAL,totalPrice:r})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})})}_getMethodOrThrow(){return z(this._methodId,()=>new b(w.PaymentNotInitialized))}_getCurrencyCodeOrThrow(){return z(this._currencyCode,()=>new S('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}}const li=y(r=>{const i=t(),o=window,a=new Yt(r),s=new on(new cn(n(),o,a));return new si(r,new _e(Ye(),new wn(r,s),i,e()))},[{id:"googlepaybraintree"}]),ci=y(r=>new si(r,new _e(Ye(),new xn(r,new zn(n())),t(),e())),[{id:"googlepaypaypalcommerce"}]),di=y(r=>new si(r,new _e(Ye(),new hr(r,new ar(n())),t(),e())),[{id:"googlepay_bigcommerce_payments"}]),hi=y(n=>{const r=t();return new si(n,new _e(Ye(),new Q("adyen",n),r,e()))},[{id:"googlepayadyenv2"}]),ui=y(n=>{const r=t();return new si(n,new _e(Ye(),new Q("adyen",n),r,e()))},[{id:"googlepayadyenv3"}]),yi=y(n=>new si(n,new _e(Ye(),new at(n),t(),e())),[{id:"googlepayauthorizenet"}]),pi=y(n=>{const r=t();return new si(n,new _e(Ye(),new pt(n,r),r,e()))},[{id:"googlepaycheckoutcom"}]),gi=y(n=>new si(n,new _e(Ye(),new Pt(n),t(),e())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]),_i=y(n=>new si(n,new _e(Ye(),new St(n),t(),e())),[{id:"googlepayorbital"}]),mi=y(r=>new si(r,new _e(Ye(),new jt(r,new Dt(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]),Pi=y(n=>new si(n,new _e(Ye(),new Wt(n),t(),e())),[{id:"googlepayworldpayaccess"}]),fi=y(n=>new si(n,new _e(Ye(),new Cr(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);export{hi as createGooglePayAdyenV2ButtonStrategy,Rr as createGooglePayAdyenV2CustomerStrategy,Ze as createGooglePayAdyenV2PaymentStrategy,ui as createGooglePayAdyenV3ButtonStrategy,Br as createGooglePayAdyenV3CustomerStrategy,rt as createGooglePayAdyenV3PaymentStrategy,yi as createGooglePayAuthorizeDotNetButtonStrategy,Lr as createGooglePayAuthorizeDotNetCustomerStrategy,st as createGooglePayAuthorizeNetPaymentStrategy,di as createGooglePayBigCommercePaymentsButtonStrategy,Jr as createGooglePayBigCommercePaymentsCustomerStrategy,br as createGooglePayBigCommercePaymentsPaymentStrategy,Fr as createGooglePayBnzCustomerStrategy,li as createGooglePayBraintreeButtonStrategy,qr as createGooglePayBraintreeCustomerStrategy,bn as createGooglePayBraintreePaymentStrategy,pi as createGooglePayCheckoutComButtonStrategy,xr as createGooglePayCheckoutComCustomerStrategy,gt as createGooglePayCheckoutComPaymentStrategy,gi as createGooglePayCybersourceButtonStrategy,jr as createGooglePayCybersourceCustomerStrategy,ft as createGooglePayCybersourcePaymentStrategy,_i as createGooglePayOrbitalButtonStrategy,Vr as createGooglePayOrbitalCustomerStrategy,Ct as createGooglePayOrbitalPaymentStrategy,Zn as createGooglePayPPCPPaymentStrategy,ci as createGooglePayPayPalCommerceButtonStrategy,Kr as createGooglePayPayPalCommerceCustomerStrategy,mi as createGooglePayStripeButtonStrategy,Ur as createGooglePayStripeCustomerStrategy,Ft as createGooglePayStripePaymentStrategy,Wr as createGooglePayStripeUpeCustomerStrategy,fi as createGooglePayTdOnlineMartButtonStrategy,Yr as createGooglePayTdOnlineMartCustomerStrategy,vr as createGooglePayTdOnlineMartPaymentStrategy,Pi as createGooglePayWorldpayAccessButtonStrategy,Hr as createGooglePayWorldpayAccessCustomerStrategy,Ht 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 r}from"@bigcommerce/script-loader";import{find as i,includes as o,isArray as a,isObject as s,round as l,some as c}from"lodash";class d 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 d{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}class u{constructor(e,t,n=window){this._scriptLoader=e,this._stylesheetLoader=t,this._window=n}load(e){return t=this,n=function*(){var t,n;if(yield Promise.all([this._stylesheetLoader.loadStylesheet(`https://checkoutshopper-${null!=(t=e.environment)?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)?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 Promise((e,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},o=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,o);a((n=n.apply(t,null)).next())});var t,n}}function y(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}var g=(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",e))(g||{});class _ extends d{constructor(e){super(function(e){switch(e){case 0:return"Unable to proceed because billing address data is unavailable.";case 1:return"Unable to proceed because cart data is unavailable.";case 3:return"Unable to proceed because consignments data is unavailable.";case 2:return"Unable to proceed because checkout data is unavailable.";case 4:return"Unable to proceed because customer data is unavailable.";case 5:case 7:return"Unable to proceed because configuration data is unavailable.";case 6:return"Unable to proceed because order data is unavailable.";case 8:return"Unable to proceed because order ID is unavailable or not generated yet.";case 9:return"Unable to proceed because payment data is unavailable.";case 15:return"Unable to proceed because the token required to submit a payment is missing.";case 12:return"Unable to proceed because payment method data is unavailable or not properly configured.";case 16: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 P=e=>"object"==typeof e&&null!==e&&"body"in e;class f extends d{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}var w=(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",e))(w||{});class b extends d{constructor(e){super(function(e){switch(e){case 1:return"Unable to proceed because the customer step of checkout has not been initialized.";case 2:return"Unable to proceed because the payment step of checkout has not been initialized.";case 3:return"Unable to proceed because the shipping step of checkout has not been initialized.";case 4: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 S extends d{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}var C=Object.defineProperty,v=Object.defineProperties,I=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,A=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,M=(e,t,n)=>t in e?C(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function k(e,t,n){if("function"!=typeof n.value)return n;let r=n.value;return{get(){const e=r.bind(this);var i;return Object.defineProperty(this,t,(i=((e,t)=>{for(var n in t||(t={}))A.call(t,n)&&M(e,n,t[n]);if(O)for(var n of O(t))T.call(t,n)&&M(e,n,t[n]);return e})({},n),v(i,I({value:e})))),e},set(e){r=e}}}class E{constructor(e){if(!e)throw new Error("Currency settings missing");const{decimalPlaces:t,symbolLocation:n,symbol:r,thousandsSeparator:i,decimalSeparator:o}=e;if("string"!=typeof n||"string"!=typeof r||"string"!=typeof i||"string"!=typeof o||"string"!=typeof t)throw new S("Invalid currency settings provided");this._decimalPlaces=parseInt(t,10),this._symbolLocation=n,this._symbol=r,this._thousandsSeparator=i,this._decimalSeparator=o}format(e){if("number"!=typeof e)throw new S("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,r=""]=this._toFixed(t,this._decimalPlaces).split("."),i=n.replace(/\B(?=(\d{3})+(?!\d))/g,this._thousandsSeparator);return this._decimalPlaces<1?i:[i,r].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)}}Object.defineProperty,Object.getOwnPropertyDescriptor;let D=class{constructor(e){this._storeConfig=e,this._customerFormatter=new E(this._storeConfig.shopperCurrency),this._storeFormatter=new E(this._storeConfig.currency)}toCustomerCurrency(e){const t=this._storeConfig.shopperCurrency.exchangeRate;return this._customerFormatter.format(e*t)}toStoreCurrency(e){return this._storeFormatter.format(e)}};function z(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}D=((e,t)=>{for(var n,r=t,i=e.length-1;i>=0;i--)(n=e[i])&&(r=n(r)||r);return r})([function(e,t,n){return t&&n?k(0,t,n):function(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const r=Object.getOwnPropertyDescriptor(e.prototype,n);r&&"constructor"!==n&&Object.defineProperty(t.prototype,n,k(e.prototype,n,r))}),t}(e)}],D);function N(){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 G(e,t,n=!0){var r;return null!=(r=e[t])?r:n}var R=(e=>(e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN",e))(R||{}),B=(e=>(e.AMEX="AMEX",e.DISCOVER="DISCOVER",e.INTERAC="INTERAC",e.JCB="JCB",e.MC="MASTERCARD",e.VISA="VISA",e))(B||{}),L=(e=>(e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION",e))(L||{}),x=(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",e))(x||{}),j=(e=>(e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER",e))(j||{});function F(e){return e in B}var V=Object.defineProperty,U=Object.defineProperties,W=Object.getOwnPropertyDescriptors,H=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,J=(e,t,n)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Y=(e,t)=>{for(var n in t||(t={}))q.call(t,n)&&J(e,n,t[n]);if(H)for(var n of H(t))K.call(t,n)&&J(e,n,t[n]);return e},Z=(e,t)=>U(e,W(t)),X=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class Q{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:r="",email:i,customFields:o=[]}=this._paymentIntegrationService.getState().getBillingAddress()||{};return Z(Y({},this._mapToAddressRequestBody(t,n,r,o)),{email:i||e.email})}mapToExternalCheckoutData(e){var t;const{paymentMethodData:{tokenizationData:{token:n},info:{cardNetwork:r,cardDetails:i}}}=e;if(!n)throw new _(g.MissingPaymentToken);return Promise.resolve(Y({nonce:n,card_information:{type:r,number:i}},this._isBuyNowFlow&&{cart_id:null==(t=this._paymentIntegrationService.getState().getCart())?void 0:t.id}))}getRequiredData(){return X(this,null,function*(){var e;const t={emailRequired:!0};if(!this._isShippingAddressRequired())return t;const n=null==(e=(yield this._paymentIntegrationService.loadShippingCountries()).getShippingCountries())?void 0:e.map(e=>e.code);return Z(Y({},t),{shippingAddressRequired:!0,shippingAddressParameters:Y({phoneNumberRequired:!0},n&&{allowedCountryCodes:n}),shippingOptionRequired:!0})})}getCallbackIntents(){return this._isShippingAddressRequired()?[L.OFFER,L.SHIPPING_ADDRESS,L.SHIPPING_OPTION]:[L.OFFER]}getCallbackTriggers(){return{availableTriggers:[j.INITIALIZE,j.SHIPPING_ADDRESS,j.SHIPPING_OPTION,j.OFFER],initializationTrigger:[j.INITIALIZE],addressChangeTriggers:[j.INITIALIZE,j.SHIPPING_ADDRESS],shippingOptionsChangeTriggers:[j.SHIPPING_OPTION],offerChangeTriggers:[j.OFFER]}}getNonce(e){var t;const n=null==(t=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(e).initializationData)?void 0:t.nonce;if(!n)throw new _(g.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 Z(Y({},n&&{countryCode:n}),{currencyCode:e,totalPrice:t,totalPriceStatus:R.ESTIMATED})}return Z(Y({},n&&{countryCode:n}),{currencyCode:e,totalPriceStatus:R.ESTIMATED,totalPrice:"0"})}isWebViewWithRestrictions(){return null!==this._isWebViewExperimentOn?this._isWebViewExperimentOn&&N():N()}setIsWebViewExperimentOn(e){this._isWebViewExperimentOn=e}setFilterAvailableShippingOptions(e){this._filterAvailableShippingOptions=e}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData().gatewayMerchantId;if(!e)throw new S("Unable to proceed, gatewayMerchantId is missing.");return{gateway:this._gatewayIdentifier,gatewayMerchantId:e}}getCardParameters(){return{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:this.getPaymentMethod().supportedCards.filter(F).map(e=>B[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){return X(this,null,function*(){var t,n;e&&(e.name=e.name||"",e.address1=e.address1||"");const r=this.mapToShippingAddressRequestBody({shippingAddress:e});r&&(yield this._paymentIntegrationService.updateShippingAddress(r));const i=this._paymentIntegrationService.getState(),o=i.getConsignments();if(!(null==o?void 0:o[0]))return;const a=o[0],s=i.getStoreConfigOrThrow();this._currencyService||(this._currencyService=new D(s));let l=a.availableShippingOptions||[];if("function"==typeof this._filterAvailableShippingOptions)try{l=yield this._filterAvailableShippingOptions(l)}catch(e){console.error("Failed to filter available shipping options:",e)}const c=l.map(this._getGooglePayShippingOption.bind(this)),d=l.find(e=>e.isRecommended),h=l.some(e=>{var t;return e.id===(null==(t=a.selectedShippingOption)?void 0:t.id)})?null==(t=a.selectedShippingOption)?void 0:t.id:void 0;if(c.length){const e=h||(null==d?void 0:d.id)||(null==(n=c[0])?void 0:n.id);return!h&&c[0]&&(yield this.handleShippingOptionChange((null==d?void 0:d.id)||c[0].id)),{defaultSelectedOptionId:e,shippingOptions:c}}})}handleShippingOptionChange(e){return X(this,null,function*(){if("shipping_option_unselected"!==e)return this._paymentIntegrationService.selectShippingOption(e)})}getTotalPrice(){const{getCheckoutOrThrow:e,getCartOrThrow:t,getStoreConfigOrThrow:n}=this._paymentIntegrationService.getState(),{decimalPlaces:r}=t().currency,i=G(n().checkoutSettings.features,"PI-5075.google_pay_round_total_price_to_max_2_decimal_places")?Math.min(r,2):r;return l(e().outstandingBalance,i).toFixed(i)}handleCoupons(e){return X(this,null,function*(){const{redemptionCodes:t=[]}=e,{offers:n}=this.getAppliedCoupons()||{};let r;return yield t.reduce((e,t)=>X(this,null,function*(){if(yield e,(n||[]).some(({redemptionCode:e})=>e===t))return;const i=yield this.applyCoupon(t);i&&(r=i)}),Promise.resolve()),yield(n||[]).reduce((e,n)=>X(this,null,function*(){yield e,t.includes(n.redemptionCode)||(yield this._paymentIntegrationService.removeCoupon(n.redemptionCode))}),Promise.resolve()),{newOfferInfo:this.getAppliedCoupons(),error:r}})}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 X(this,null,function*(){let t;try{yield this._paymentIntegrationService.applyCoupon(e)}catch(e){return e instanceof Error&&(t={reason:x.OFFER_INVALID,message:e.message,intent:j.OFFER}),t}})}setShouldRequestShipping(e){this._shouldRequestShipping=e}getGooglePayInitializationData(){return z(this.getPaymentMethod().initializationData,()=>new S("Missing initialization data."))}getPaymentMethod(){return z(this._getPaymentMethodFn,()=>new b(w.PaymentNotInitialized))()}getGatewayIdentifier(){return this._gatewayIdentifier}setGatewayIdentifier(e){this._gatewayIdentifier=e||this.getGatewayIdentifier()}_isShippingAddressRequired(){const{getCartOrThrow:e,getStoreConfigOrThrow:t,getShippingAddress:n}=this._paymentIntegrationService.getState(),r=t();let i;return i=G(r.checkoutSettings.features,"PI-4290.google_pay_require_shipping_address")?this._shouldRequestShipping:void 0===n(),i&&(o=e(),a=r,!!o&&(!!o.lineItems.physicalItems.some(e=>e.isShippingRequired)||!(!a||!o.lineItems.customItems)&&o.lineItems.customItems.length>0));var o,a}_mapToAddressRequestBody(e,t,n,r){const{name:i,address1:o,address2:a,address3:s,locality:l,administrativeArea:c,countryCode:d,postalCode:h,phoneNumber:u}=e,[y,p]=this._getFirstAndLastName(i);return{firstName:y,lastName:p,company:t,address1:o,address2:`${a} ${s}`.trim(),city:l||c,stateOrProvince:c,stateOrProvinceCode:c,countryCode:d,postalCode:h,phone:u||n,customFields:r||[]}}_getFirstAndLastName(e){const t=e.split(" ");return 1===t.length?[e,""]:[t.slice(0,-1).join(" "),t[t.length-1]]}_getCurrencyCodeOrThrow(){return z(this._currencyCode,()=>new S('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}_getGooglePayShippingOption({id:e,cost:t,description:n,additionalDescription:r}){var i;return{id:e,label:`${(null==(i=this._currencyService)?void 0:i.toCustomerCurrency(t))||t} ${n}`,description:r}}}var $=Object.getPrototypeOf,ee=Reflect.get,te=(e,t,n)=>ee($(e),n,t),ne=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class re extends Q{constructor(e,t){super("adyen",e),this._scriptLoader=t,this._service=e}initialize(e,t,n){return ne(this,null,function*(){yield te(re.prototype,this,"initialize").call(this,e,t,n);const r=te(re.prototype,this,"getPaymentMethod").call(this),i=this._service.getState().getStoreConfig();if(!i)throw new _(g.MissingCheckoutConfig);return this._adyenClient=yield this._scriptLoader.load({environment:r.config.testMode?"test":"live",locale:i.storeProfile.storeLanguage}),Promise.resolve()})}getNonce(e){return ne(this,null,function*(){const t=yield te(re.prototype,this,"getNonce").call(this,e),n=te(re.prototype,this,"getPaymentMethod").call(this);return JSON.stringify({type:n.method,googlePayToken:t,browser_info:m()})})}processAdditionalAction(e){return ne(this,null,function*(){if(!P(e)||!p(e.body))throw e;const t=yield this._handleAction(e.body.provider_data);try{return yield this._service.submitPayment(t)}catch(e){return this.processAdditionalAction(e)}})}_handleAction(e){return new Promise((t,n)=>{const r=JSON.parse(e.action);this._getAdyenClient().createFromAction(r,{onAdditionalDetails:e=>{const n={methodId:r.paymentMethodType,paymentData:{nonce:JSON.stringify(e.data)}};t(n)},size:"05",onError:e=>n(e)}).mount("body"),n(new f)})}_getAdyenClient(){if(!this._adyenClient)throw new b(w.PaymentNotInitialized);return this._adyenClient}}const ie={"X-Checkout-SDK-Version":"1.979.1"};class oe extends d{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 ae=Object.defineProperty,se=Object.defineProperties,le=Object.getOwnPropertyDescriptors,ce=Object.getOwnPropertySymbols,de=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable,ue=(e,t,n)=>t in e?ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ye=(e,t)=>{for(var n in t||(t={}))de.call(t,n)&&ue(e,n,t[n]);if(ce)for(var n of ce(t))he.call(t,n)&&ue(e,n,t[n]);return e},pe=(e,t)=>se(e,le(t)),ge=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class _e{constructor(e,t,n,r){this._scriptLoader=e,this._gateway=t,this._requestSender=n,this._formPoster=r,this._baseRequest={apiVersion:2,apiVersionMinor:0}}initialize(e,t,n,r){return ge(this,null,function*(){this._paymentsClient=yield this._scriptLoader.getGooglePaymentsClient(e().config.testMode,t),yield this._gateway.initialize(e,n,r),this._buildButtonPayloads()})}initializeWidget(){return ge(this,null,function*(){yield this._buildWidgetPayloads(),yield this._determineReadinessToPay(),this._prefetchGooglePaymentData()})}getNonce(e){return this._gateway.getNonce(e)}extraPaymentData(){return ge(this,null,function*(){return this._gateway.extraPaymentData()})}addPaymentButton(e,t){const n=document.querySelector(`#${e}`);if(!n)return;const r=this._getPaymentsClient().createButton(pe(ye({},t),{allowedPaymentMethods:[this._getBaseCardPaymentMethod()]}));return n.appendChild(r)}showPaymentSheet(){return ge(this,null,function*(){const e=this._getPaymentDataRequest();return this._getPaymentsClient().loadPaymentData(e)})}setExternalCheckoutXhr(e,t){return ge(this,null,function*(){return this._setExternalCheckout(e,t)})}setExternalCheckoutForm(e,t,n){return ge(this,null,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 ge(this,null,function*(){yield this._requestSender.get(`/remote-checkout/${e}/signout`)})}getCallbackTriggers(){return this._gateway.getCallbackTriggers()}setShouldRequestShipping(e){return this._gateway.setShouldRequestShipping(e)}handleShippingAddressChange(e){return ge(this,null,function*(){return this._gateway.handleShippingAddressChange(e)})}handleShippingOptionChange(e){return ge(this,null,function*(){yield this._gateway.handleShippingOptionChange(e)})}handleCoupons(e){return ge(this,null,function*(){return this._gateway.handleCoupons(e)})}getTotalPrice(){return this._gateway.getTotalPrice()}_setExternalCheckout(e,t,n=!1,r){return ge(this,null,function*(){const i="/checkout.php",o=ye({action:"set_external_checkout",provider:e},yield this._gateway.mapToExternalCheckoutData(t));if(n)return new Promise(e=>{this._formPoster.postForm(r?`${r}/checkout`:i,pe(ye({},o),{card_information:JSON.stringify(o.card_information)}),e)});yield this._requestSender.post(i,{headers:ye({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},ie),body:o})})}isWebViewWithRestrictions(){return this._gateway.isWebViewWithRestrictions()}setIsWebViewExperimentOn(e){return this._gateway.setIsWebViewExperimentOn(e)}setFilterAvailableShippingOptions(e){return this._gateway.setFilterAvailableShippingOptions(e)}_prefetchGooglePaymentData(){const e=this._getPaymentDataRequest();e.transactionInfo=this._gateway.getTransactionInfo(),this._getPaymentsClient().prefetchPaymentData(e)}_determineReadinessToPay(){return ge(this,null,function*(){try{const{result:e}=yield this._getPaymentsClient().isReadyToPay(this._getIsReadyToPayRequest());if(!1===e)throw new oe("Google Pay is not supported by the current device and browser, please try another payment method.")}catch(e){if(e instanceof oe)throw e;throw new oe}})}_buildButtonPayloads(){this._baseCardPaymentMethod={type:"CARD",parameters:this._gateway.getCardParameters()}}_buildWidgetPayloads(){return ge(this,null,function*(){const e=this._getBaseCardPaymentMethod();this._cardPaymentMethod=pe(ye({},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=ye(ye(pe(ye({},this._baseRequest),{allowedPaymentMethods:[this._cardPaymentMethod],transactionInfo:this._gateway.getTransactionInfo(),merchantInfo:this._gateway.getMerchantInfo()}),yield this._gateway.getRequiredData()),t),this._isReadyToPayRequest=pe(ye({},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 z(e,()=>new b(w.PaymentNotInitialized))}}class me extends S{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 Pe extends d{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}var fe=Object.defineProperty,we=Object.getOwnPropertySymbols,be=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable,Ce=(e,t,n)=>t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ve=(e,t)=>{for(var n in t||(t={}))be.call(t,n)&&Ce(e,n,t[n]);if(we)for(var n of we(t))Se.call(t,n)&&Ce(e,n,t[n]);return e};const Ie={size:70,color:"#d9d9d9",backgroundColor:"#ffffff"},Oe={position:"fixed","background-color":"rgba(0, 0, 0, 0.4)","z-index":"1000"},Ae="embedded-checkout-loading-indicator-rotation";class Te{constructor(e){this.styles=ve(ve({},Ie),e&&e.styles),this.containerStyles=ve({},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=`${Ae} 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(Ae))return;const t=document.createElement("style");t.id=Ae,null==(e=document.head)||e.appendChild(t),t.sheet instanceof CSSStyleSheet&&t.sheet.insertRule(`\n @keyframes ${Ae} {\n 0% { transform: translateY(-50%) rotate(0deg); }\n 100% { transform: translateY(-50%) rotate(360deg); }\n }\n `,0)}}function Me(e){return"object"==typeof e&&null!==e&&"statusCode"in e}var ke=(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",e))(ke||{});function Ee(e){return Object.values(ke).includes(e)}var De=Object.defineProperty,ze=Object.defineProperties,Ne=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertySymbols,Re=Object.prototype.hasOwnProperty,Be=Object.prototype.propertyIsEnumerable,Le=(e,t,n)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xe=(e,t)=>{for(var n in t||(t={}))Re.call(t,n)&&Le(e,n,t[n]);if(Ge)for(var n of Ge(t))Be.call(t,n)&&Le(e,n,t[n]);return e},je=(e,t)=>ze(e,Ne(t)),Fe=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class Ve{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t,this._isDeinitializationBlocked=!1,this._isContainerMode=!1,this._loadingIndicator=new Te({containerStyles:Oe})}initialize(e){return Fe(this,null,function*(){var t,n;if(!(null==e?void 0:e.methodId)||!Ee(e.methodId))throw new S('Unable to proceed because "methodId" is not a valid key.');this._methodId=e.methodId;const r=e[this._getMethodId()];if(!(null==r?void 0:r.walletButton)&&!(null==r?void 0:r.container))throw new S("Unable to proceed without valid options.");const i=r,{walletButton:o,loadingContainerId:a,container:s,buttonColor:l,buttonSizeMode:c,buttonType:d,onInit:h}=i,u=((e,t)=>{var n={};for(var r in e)Re.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&Ge)for(var r of Ge(e))t.indexOf(r)<0&&Be.call(e,r)&&(n[r]=e[r]);return n})(i,["walletButton","loadingContainerId","container","buttonColor","buttonSizeMode","buttonType","onInit"]);this._loadingIndicatorContainer=a,yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodId());const y=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(this._getMethodId());if(this._googlePayPaymentProcessor.setIsWebViewExperimentOn(!!(null==(t=y.initializationData)?void 0:t.isWebViewExperimentOn)),yield this._googlePayPaymentProcessor.initialize(()=>y,this._getGooglePayClientOptions(null==(n=y.initializationData)?void 0:n.storeCountry)),s){this._isContainerMode=!0;const e=()=>this._addPaymentButtonToContainer(r);h?h(e):e()}else this._addPaymentButton(o,u)})}execute(e){return Fe(this,arguments,function*({payment:e}){if(!(null==e?void 0:e.methodId))throw new me(["payment"]);yield this._paymentIntegrationService.submitOrder();const t=yield this._googlePayPaymentProcessor.getNonce(e.methodId),n=yield this._googlePayPaymentProcessor.extraPaymentData();try{yield this._paymentIntegrationService.submitPayment(je(xe({},e),{paymentData:xe({nonce:t},n)}))}catch(t){yield this._googlePayPaymentProcessor.processAdditionalAction(t,e.methodId)}})}finalize(){return Promise.reject(new Pe)}deinitialize(){var e,t;return this._isDeinitializationBlocked||(this._isContainerMode?null==(e=this._paymentButton)||e.remove():this._clickListener&&(null==(t=this._paymentButton)||t.removeEventListener("click",this._clickListener)),this._paymentButton=void 0,this._clickListener=void 0,this._methodId=void 0,this._isContainerMode=!1),Promise.resolve()}_addPaymentButton(e,t){if(this._paymentButton)return;const n=document.getElementById(e);if(!n)throw new S("Unable to proceed without a walletButton.");this._paymentButton=n,this._clickListener=this._handleClick(t),this._paymentButton.addEventListener("click",this._clickListener)}_addPaymentButtonToContainer(e){if(this._paymentButton)return;const{container:t,buttonColor:n,buttonSizeMode:r,buttonType:i,onError:o}=e;if(!t)throw new S("Unable to proceed: container ID is not valid.");const a=this._googlePayPaymentProcessor.addPaymentButton(t,{buttonColor:null!=n?n:"default",buttonSizeMode:null!=r?r:"fill",buttonType:null!=i?i:"pay",onClick:this._handleContainerButtonClick(o)});if(!a)throw new S(`Unable to proceed: container element "#${t}" not found in the DOM.`);this._paymentButton=a}_handleContainerButtonClick(e){return t=>Fe(this,null,function*(){t.preventDefault(),yield this._runGooglePayWidgetInteractionWithErrorHandling(e,()=>Fe(this,null,function*(){this._googlePayPaymentProcessor.setShouldRequestShipping(!1),yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheetAndPay()}))})}_handleClick({onPaymentSelect:e,onError:t}){return n=>Fe(this,null,function*(){n.preventDefault(),yield this._runGooglePayWidgetInteractionWithErrorHandling(t,()=>Fe(this,null,function*(){this._googlePayPaymentProcessor.setShouldRequestShipping(!1),yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheetAndPay()})),null==e||e()})}_interactWithPaymentSheetAndPay(){return Fe(this,null,function*(){const e=yield this._googlePayPaymentProcessor.showPaymentSheet();this._toggleBlockDeinitialization(!0),this._toggleLoadingIndicator(!0);const t=this._getMethodId(),n=this._paymentIntegrationService.getState(),{features:r}=n.getStoreConfigOrThrow().checkoutSettings,i=G(r,"PI-5031.google_pay_dont_override_address"),o=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(e);o&&!i&&(yield this._paymentIntegrationService.updateBillingAddress(o)),yield this._googlePayPaymentProcessor.setExternalCheckoutXhr(t,e),yield this._paymentIntegrationService.loadPaymentMethod(t);const a=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(t);yield this._googlePayPaymentProcessor.initialize(()=>a);try{yield this.execute({useStoreCredit:!1,payment:{methodId:t}}),this._completeCheckoutFlow()}catch(e){throw yield this._paymentIntegrationService.loadCheckout(),e}})}_completeCheckoutFlow(){window.location.replace("/checkout/order-confirmation"),this._toggleLoadingIndicator(!1),this._toggleBlockDeinitialization(!1)}_getMethodId(){return z(this._methodId,()=>new b(w.PaymentNotInitialized))}_getIsSignedInOrThrow(){return Fe(this,null,function*(){try{return!!(yield this._googlePayPaymentProcessor.getNonce(this._getMethodId()))}catch(e){if(e instanceof _&&e.subtype===g.MissingPaymentToken)return!1;throw e}})}_handleOfferTrigger(e){return Fe(this,null,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:x.OFFER_INVALID,message:n,intent:j.OFFER}}})}_getGooglePayClientOptions(e){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:t=>Fe(this,[t],function*({callbackTrigger:t,offerData:n}){if(t!==j.INITIALIZE&&t!==j.OFFER)return;const{offerChangeTriggers:r}=this._googlePayPaymentProcessor.getCallbackTriggers(),{newOfferInfo:i,error:o}=r.includes(t)?yield this._handleOfferTrigger(n):{},a=o;yield this._paymentIntegrationService.loadCheckout();const{code:s}=this._paymentIntegrationService.getState().getCartOrThrow().currency,l=this._googlePayPaymentProcessor.getTotalPrice();return xe(xe({newTransactionInfo:je(xe({},e&&{countryCode:e}),{currencyCode:s,totalPriceStatus:R.FINAL,totalPrice:l})},i&&{newOfferInfo:i}),a&&{error:a})})}}}_runGooglePayWidgetInteractionWithErrorHandling(e,t){return Fe(this,null,function*(){try{yield t()}catch(t){let n=t;if(this._toggleLoadingIndicator(!1),Me(t)){if("CANCELED"===t.statusCode)throw new f;n=new oe(JSON.stringify(t))}throw null==e||e(new oe("An error occurred while requesting your Google Pay payment details.")),n}finally{this._toggleBlockDeinitialization(!1)}})}_toggleBlockDeinitialization(e){this._isDeinitializationBlocked=e}_toggleLoadingIndicator(e){e&&this._loadingIndicatorContainer?this._loadingIndicator.show(this._loadingIndicatorContainer):this._loadingIndicator.hide()}}var Ue=Object.defineProperty,We=Object.getOwnPropertySymbols,He=Object.prototype.hasOwnProperty,qe=Object.prototype.propertyIsEnumerable,Ke=(e,t,n)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class Je{constructor(e){this._scriptLoader=e,this._window=window}getGooglePaymentsClient(e=!1,t){return n=this,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(((e,t)=>{for(var n in t||(t={}))He.call(t,n)&&Ke(e,n,t[n]);if(We)for(var n of We(t))qe.call(t,n)&&Ke(e,n,t[n]);return e})({environment:e?"TEST":"PRODUCTION"},null!=t?t:{}))),this._paymentsClient},new Promise((e,t)=>{var i=e=>{try{a(r.next(e))}catch(e){t(e)}},o=e=>{try{a(r.throw(e))}catch(e){t(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,o);a((r=r.apply(n,null)).next())});var n,r}}function Ye(){return new Je(n())}const Ze=y(i=>new Ve(i,new _e(Ye(),new re(i,new u(n(),r())),t(),e())),[{id:"googlepayadyenv2"}]);class Xe{constructor(e,t,n=window){this._scriptLoader=e,this._stylesheetLoader=t,this._window=n}load(e){return t=this,n=function*(){var t,n;if(yield Promise.all([this._stylesheetLoader.loadStylesheet(`https://checkoutshopper-${null!=(t=e.environment)?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)?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 Promise((e,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},o=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,o);a((n=n.apply(t,null)).next())});var t,n}}var Qe=Object.getPrototypeOf,$e=Reflect.get,et=(e,t,n)=>$e(Qe(e),n,t),tt=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class nt extends Q{constructor(e,t){super("adyen",e),this._scriptLoader=t,this._service=e}initialize(e,t,n){return tt(this,null,function*(){yield et(nt.prototype,this,"initialize").call(this,e,t,n);const r=et(nt.prototype,this,"getPaymentMethod").call(this),i=this._service.getState().getStoreConfig();if(!i)throw new _(g.MissingCheckoutConfig);return this._adyenClient=yield this._scriptLoader.load({environment:r.config.testMode?"test":"live",locale:i.storeProfile.storeLanguage}),Promise.resolve()})}processAdditionalAction(e){return tt(this,null,function*(){if(!P(e)||!p(e.body))throw e;const t=yield this._handleAction(e.body.provider_data);try{return yield this._service.submitPayment(t)}catch(e){return this.processAdditionalAction(e)}})}getNonce(e){return tt(this,null,function*(){const t=yield et(nt.prototype,this,"getNonce").call(this,e),n=et(nt.prototype,this,"getPaymentMethod").call(this);return JSON.stringify({type:n.method,googlePayToken:t,browser_info:m()})})}_handleAction(e){return new Promise((t,n)=>{const r=JSON.parse(e.action);this._getAdyenClient().createFromAction(r,{onAdditionalDetails:e=>{const n={methodId:r.paymentMethodType,paymentData:{nonce:JSON.stringify(e.data)}};t(n)},size:"05",onError:e=>n(e)}).mount("body"),n(new f)})}_getAdyenClient(){if(!this._adyenClient)throw new b(w.PaymentNotInitialized);return this._adyenClient}}const rt=y(i=>new Ve(i,new _e(Ye(),new nt(i,new Xe(n(),r())),t(),e())),[{id:"googlepayadyenv3"}]);var it=Object.getPrototypeOf,ot=Reflect.get;class at extends Q{constructor(e){super("authorizenet",e)}mapToExternalCheckoutData(e){return t=this,n=function*(){const t=yield(n=at.prototype,ot(it(n),"mapToExternalCheckoutData",this)).call(this,e);var n;return t.nonce=btoa(t.nonce),t},new Promise((e,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},o=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,o);a((n=n.apply(t,null)).next())});var t,n}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return function(e){if(!function(e){return"paymentGatewayId"in e}(e))throw new _(g.MissingPaymentMethod)}(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.paymentGatewayId}}}const st=y(n=>new Ve(n,new _e(Ye(),new at(n),t(),e())),[{id:"googlepayauthorizenet"}]);var lt=(e=>(e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json",e))(lt||{});const ct=lt;function dt(e){if(!function(e){return"checkoutcomkey"in e}(e))throw new _(g.MissingPaymentMethod)}var ht=Object.getPrototypeOf,ut=Reflect.get,yt=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class pt extends Q{constructor(e,t){super("checkoutltd",e),this._requestSender=t}processAdditionalAction(e){return new Promise((t,n)=>{if(P(e)&&function(e){var t;if("object"!=typeof e||null===e)return!1;const n=e;return"string"==typeof(null==(t=n.three_ds_result)?void 0:t.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){return yt(this,null,function*(){const t=yield(n=pt.prototype,ut(ht(n),"mapToExternalCheckoutData",this)).call(this,e);var n;let r;try{r=JSON.parse(t.nonce)}catch(e){throw new S("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 _(g.MissingPaymentToken)}(r),t.nonce=yield this._tokenize(r),t})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return dt(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.checkoutcomkey}}_tokenize(e){return yt(this,null,function*(){const t=this.getPaymentMethod().config.testMode?"https://api.sandbox.checkout.com/tokens":"https://api.checkout.com/tokens",n=this.getGooglePayInitializationData();dt(n);const{body:r}=yield this._requestSender.post(t,{credentials:!1,body:{type:"googlepay",token_data:e},headers:{Authorization:n.checkoutcomkey,"Content-Type":ct.Json,"X-XSRF-TOKEN":null}});return r.token})}}const gt=y(n=>{const r=t();return new Ve(n,new _e(Ye(),new pt(n,r),r,e()))},[{id:"googlepaycheckoutcom"}]);var _t=Object.getPrototypeOf,mt=Reflect.get;class Pt extends Q{constructor(e){super("cybersource",e)}mapToExternalCheckoutData(e){return t=this,n=function*(){const t=yield(n=Pt.prototype,mt(_t(n),"mapToExternalCheckoutData",this)).call(this,e);var n;return t.nonce=btoa(t.nonce),t},new Promise((e,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},o=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,o);a((n=n.apply(t,null)).next())});var t,n}}const ft=y(n=>new Ve(n,new _e(Ye(),new Pt(n),t(),e())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]);var wt=Object.getPrototypeOf,bt=Reflect.get;class St extends Q{constructor(e){super("chase",e)}mapToExternalCheckoutData(e){return t=this,n=function*(){const t=yield(n=St.prototype,bt(wt(n),"mapToExternalCheckoutData",this)).call(this,e);var n;return t.nonce=btoa(t.nonce),t},new Promise((e,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},o=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,o);a((n=n.apply(t,null)).next())});var t,n}}const Ct=y(n=>new Ve(n,new _e(Ye(),new St(n),t(),e())),[{id:"googlepayorbital"}]);var vt=(e=>(e.V3="v3",e.ACACIA="acacia",e.BASIL="basil",e.CLOVER="clover",e))(vt||{}),It=Object.defineProperty,Ot=Object.getOwnPropertySymbols,At=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable,Mt=(e,t,n)=>t in e?It(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,kt=(e,t)=>{for(var n in t||(t={}))At.call(t,n)&&Mt(e,n,t[n]);if(Ot)for(var n of Ot(t))Tt.call(t,n)&&Mt(e,n,t[n]);return e},Et=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class Dt{constructor(e,t=window){this.scriptLoader=e,this.stripeWindow=t}getStripeClient(e,t,n,r,i){return Et(this,null,function*(){if(this.stripeWindow.bcStripeClient)return this.stripeWindow.bcStripeClient;const o=yield this.load(n),{stripePublishableKey:a,stripeConnectedAccount:s}=e,l=o(a,kt(kt(kt(kt({},s?{stripeAccount:s}:{}),t?{locale:t}:{}),r?{betas:r}:{}),i?{apiVersion:i}:{}));return Object.assign(this.stripeWindow,{bcStripeClient:l}),l})}getElements(e,t){return Et(this,null,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 Et(this,null,function*(){const t=this.stripeWindow.bcStripeElements;t&&(t.update(e),yield t.fetchUpdates())})}getStripeCheckout(e,t){return Et(this,null,function*(){let n=yield this.getStoredStripeCheckout(t);if(n){const{actions:e}=yield n.loadActions();yield null==e?void 0:e.runServerUpdate(()=>Promise.resolve())}else n=yield e.initCheckout(t),Object.assign(this.stripeWindow,{bcStripeCheckout:n});return n})}load(e){return Et(this,null,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!==vt.V3?`https://js.stripe.com/${e}/stripe.js`:"https://js.stripe.com/v3/"}getStoredStripeCheckout(e){return Et(this,null,function*(){const t=this.stripeWindow.bcStripeCheckout;if(t)try{const{actions:n,error:r}=yield t.loadActions();if(r||!n)return void this.logErrorToConsole(r);const i=yield n.getSession(),o=e.clientSecret.split("_secret_")[0];if(i.id===o)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 zt={body:{},headers:{},status:0};class Nt extends d{constructor(e,{message:t,errors:n}={}){const{body:r,headers:i,status:o}=e||zt;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=r,this.headers=i,this.status=o,this.errors=n||[]}}const Gt=["payment_element_beta_2","alipay_pm_beta_1","link_default_integration_beta_1","shipping_address_element_beta_1","address_element_beta_1"];function Rt(e){if(!function(e){return"stripeConnectedAccount"in e&&"stripePublishableKey"in e&&"stripeVersion"in e}(e))throw new _(g.MissingPaymentMethod)}var Bt=Object.getPrototypeOf,Lt=Reflect.get,xt=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class jt extends Q{constructor(e,t){super("stripe",e),this.paymentIntegrationService=e,this.scriptLoader=t}mapToExternalCheckoutData(e){return xt(this,null,function*(){const t=yield(n=jt.prototype,Lt(Bt(n),"mapToExternalCheckoutData",this)).call(this,e);var n;let r;try{r=JSON.parse(t.nonce)}catch(e){throw new S("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 _(g.MissingPaymentToken)}(r),t.nonce=r.id,t})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();Rt(e);const{stripeVersion:t,stripePublishableKey:n,stripeConnectedAccount:r}=e;return{gateway:this.getGatewayIdentifier(),"stripe:version":t,"stripe:publishableKey":`${n}/${r}`}}processAdditionalAction(e,t){return xt(this,null,function*(){var n,r;if(!t)throw new me(["payment"]);if(!P(e)||("object"!=typeof(r=e.body)||null===r||!("three_ds_result"in r)||!("errors"in r)))throw e;if(c(e.body.errors,{code:"three_d_secure_required"})){const r=this.getGooglePayInitializationData();Rt(r),this.stripeUPEClient=yield this.loadStripeJs(r,t);const i=e.body.three_ds_result.token;let o,a=!1;try{o=yield this.stripeUPEClient.confirmCardPayment(i)}catch(e){try{o=yield this.stripeUPEClient.retrievePaymentIntent(i)}catch(e){a=!0}}if(null==o?void 0:o.error){if(this._throwDisplayableStripeError(o.error),this._isCancellationError(o.error))throw new f;throw new oe}if(!(null==o?void 0:o.paymentIntent)&&!a)throw new Nt;return this.paymentIntegrationService.submitPayment({methodId:t,paymentData:{nonce:(null==(n=null==o?void 0:o.paymentIntent)?void 0:n.id)||i}})}throw e})}loadStripeJs(e,t){return xt(this,null,function*(){if(this.stripeUPEClient)return this.stripeUPEClient;const n=this.paymentIntegrationService.getState().getCartLocale();return"googlepaystripeocs"===t?this.scriptLoader.getStripeClient(e,n,vt.CLOVER):this.scriptLoader.getStripeClient(e,n,vt.V3,Gt,"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.message)?void 0:n.indexOf("canceled"))}_throwDisplayableStripeError(e){if(o(["card_error","invalid_request_error","validation_error"],e.type))throw new Error(e.message)}}const Ft=y(r=>new Ve(r,new _e(Ye(),new jt(r,new Dt(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]);var Vt=Object.getPrototypeOf,Ut=Reflect.get;class Wt extends Q{constructor(e){super("worldpay",e)}mapToExternalCheckoutData(e){return t=this,n=function*(){const t=yield(n=Wt.prototype,Ut(Vt(n),"mapToExternalCheckoutData",this)).call(this,e);var n;return t.nonce=btoa(t.nonce),t},new Promise((e,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},o=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,o);a((n=n.apply(t,null)).next())});var t,n}}const Ht=y(n=>new Ve(n,new _e(Ye(),new Wt(n),t(),e())),[{id:"googlepayworldpayaccess"}]),qt="3.128.0",Kt="3.123.2",Jt="3.106.0";class Yt{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()||(G(t,"PAYPAL-5809.braintree_hosted_fields_fix_version")?qt:G(t,"PAYPAL-5636.update_braintree_sdk_version")?Kt:Jt)}getPreloadedSDKVersion(){const e=this.braintreeWindow.braintree;if(e){const t=i(Object.values(e),e=>!!e.VERSION);return null==t?void 0:t.VERSION}}}class Zt extends d{constructor(e){super(e||"Unsupported browser error"),this.name="UnsupportedBrowserError",this.type="unsupported_browser"}}var Xt=(e=>(e.KountNotEnabled="DATA_COLLECTOR_KOUNT_NOT_ENABLED",e))(Xt||{}),Qt=Object.defineProperty,$t=Object.getOwnPropertySymbols,en=Object.prototype.hasOwnProperty,tn=Object.prototype.propertyIsEnumerable,nn=(e,t,n)=>t in e?Qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rn=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class on{constructor(e){this.braintreeScriptLoader=e}initialize(e){this.setClientToken(e)}deinitialize(){return rn(this,null,function*(){yield this.teardownModule(this.dataCollector),this.dataCollector=void 0})}getClient(){return rn(this,null,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 rn(this,null,function*(){const t={deviceData:void 0,teardown:()=>Promise.resolve()};if(!this.dataCollector)try{const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadDataCollector(),r=((e,t)=>{for(var n in t||(t={}))en.call(t,n)&&nn(e,n,t[n]);if($t)for(var n of $t(t))tn.call(t,n)&&nn(e,n,t[n]);return e})({client:t,kount:!0},e);this.dataCollector=yield n.create(r)}catch(e){if(function(e){return Boolean("object"==typeof e&&null!==e&&("type"in e||"message"in e||"code"in e))}(e)&&e.code===Xt.KountNotEnabled)return t;throw e}return this.dataCollector})}getBraintreeGooglePayment(){return rn(this,null,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 rn(this,null,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 rn(this,null,function*(){if(!this.braintreeLocalPayment){const[t,n]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadLocalPayment()]);this.braintreeLocalPayment=yield new Promise((r,i)=>{n.create({client:t,merchantAccountId:e},(e,t)=>{e&&i(e),r(t)})})}return this.braintreeLocalPayment})}getUsBankAccount(){return rn(this,null,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 rn(this,null,function*(){return this.visaCheckoutSDK||(this.visaCheckoutSDK=yield this.braintreeScriptLoader.loadVisaCheckoutSdk(e)),this.visaCheckoutSDK})}getVenmoCheckoutOrThrow(){return rn(this,null,function*(){if(!this.braintreeVenmo){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadVenmoCheckout(),n={client:e,allowDesktop:!0,paymentMethodUsage:"multi_use"},r=yield t.create(n);if(!r.isBrowserSupported())throw new Zt;this.braintreeVenmo=r}return this.braintreeVenmo})}setClientToken(e){this.clientToken=e}getClientTokenOrThrow(){if(!this.clientToken)throw new b(w.PaymentNotInitialized);return this.clientToken}teardownModule(e){return e?e.teardown():Promise.resolve()}}var an=(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",e))(an||{});const sn={[Jt]:{[an.Client]:"sha384-26BXDNnJI23JYRyFBj4xe4sVNrUSSiSSu11kxVXNM/vEPONm4LuL00w6ZaTgQewt",[an.PaypalCheckout]:"sha384-B+vzbZwnQtzWBthpkT4TXKUibO65tyeK7eCxSvpblgprTep2+IAXB2Cxxjrn710O",[an.Paypal]:"sha384-uyAGL1/3+XJAHnGoNy4eCoXdzJ4f7Ilzp+6w9PNnEjs6DCCz9WMyJjMN1gzc78U+",[an.LocalPayment]:"sha384-LIvOEMkIVEwVuYBdVOQc1AC5YbGGlwyfUheS0ACK218D2STuVYQlZ4FyEPowAEfT",[an.DataCollector]:"sha384-1bo9JDz+Kscthc085cCKWur8CLwUoBpoNyxsDi7932mCl0zFq3A5mv+FQLw9GHpV",[an.UsBankAccount]:"sha384-xmHBVaU+w74V+OebD3AaPONFxHUGMf+QRs8G/JxVPXNNP7MDa2jL0ICWHIe2tTfJ",[an.GooglePayment]:"sha384-WKDJl8mqoP82qZpMGH6AbZxnvXnSW8ILV4M64CyMLiugGMwu7LyP89wjCkHqsiBe",[an.ThreeDSecure]:"sha384-VQUlpGHzsGvs5XeiGFip7EXRsvoHWEXDVmgCacfbyieZI9mdBOqq3NSoyo28OCOB",[an.VisaCheckout]:"sha384-yx7mADfzTN0T43Q6rlH49LIg1EJ0iUZgBp/EczX9LXsUGkySgxrD+nWHQRBkyfoT",[an.Venmo]:"sha384-QX4rPjoj1ZDhuG0aSyKs56lEKDqTMTcjYxUHY1SzO5VZDsqIE2NTkqot7KNSCyov",[an.HostedFields]:"sha384-VvYBACfSu0Cr/J32uKmxG7AXcNOJE1AzIIL3kbikyS7YKp5fz5Is+NzNP/lyauNy",[an.Fastlane]:"sha384-9oGsZMRZwpGtDEDYa/dFt76dECqj1xAni9gIKgc3KfMIiRnR73nEeeUDLiBzxhFa"},[Kt]:{[an.Client]:"sha384-o+nbQGcwNNxIBeXeu3+XmbSq+Cg8R3EN3N0l5hXCgMMU2RGY0t1z0LroSEIAbfAO",[an.PaypalCheckout]:"sha384-WrfbWPBS4mH86GAoycPSgiH8hQ8KH7A67C93Hjhunv/xhNk2YpBn3wbFA4Fhg9U/",[an.Paypal]:"sha384-VF389nvvrRUgDsTXMxTYORDtVegB9IQa3Cxr//DyJnLYnz8/X8VCzEvck2c+Megt",[an.LocalPayment]:"sha384-tZKx2rEQbfmZpoPSY5VPmJEhaq4X75dLvwHMs3VE9U+C8lPyw+hWTIL1+GPvWCIH",[an.DataCollector]:"sha384-E6k3wOpP7syCDDwaRDLF06942Y00NkbwJvWi2OQXwwKzGwG5fd3E7RFUvCCecfvO",[an.UsBankAccount]:"sha384-258FON8LZGG0W9Qaz4Jij83pZHu30YnKjJA7gNulLBh6CclkucgF+tHDQuYFRYfW",[an.GooglePayment]:"sha384-taJ2p/0+n0VH328POAoBiuEbL3tnHUTE9S42hK1V+Txs3X+QYjZOyKW35JgHRFfO",[an.ThreeDSecure]:"sha384-+NSZH4Zj3sO5bdWvPKhU5N16QDxeueTVTnUVeleeESkhLSaz4Ob1hh/5myecc9Ym",[an.VisaCheckout]:"sha384-66DiBjghxk1OmBj8aksN8gbQ+CwoQcx1vPfiXUN08g1iQVM+BwewF0p7toM3i7SS",[an.Venmo]:"sha384-B5UwY42kE4RoLoWbQ7YpqosUlUad2/DlGWiw0HhoZbSPk30CQAaSA10ohyLDTkDU",[an.HostedFields]:"sha384-Aw9EesSaUeWxe36PqEHiOyOyOq8M6CIb1gw7/yHNVPRzGtFXXcd2OQ8qXrIlOj2P",[an.Fastlane]:"sha384-rhBL1hpZ71JqG+2TsT0Dih47mbjx8cjJCpeZjk9tw3df1gFMKfCTmMyZunhr7H4Y"},[qt]:{[an.Client]:"sha384-0WNxksIpRP+fYZiIdr12g6DBUQfLDzYCQJZtR/C8KkcwSGhPHfcFp3tTaGcMyFTq",[an.PaypalCheckout]:"sha384-lWM1jk4BOxoDNV6Kop7tVNvQgINlmEVz0c/OwM+HNHK3QC8xqwd54Ovrt2QRDTjh",[an.Paypal]:"sha384-fXUmVxC2EMZBDXZ7eTHSTL/LFBrHej/MSXT/vTBXvra4lzgLNGvREAp+x0GYObuH",[an.LocalPayment]:"sha384-pha1xGuGSkmZH5x9aqHvRaO4xLea7rmQ/79PFj9zxNzxuFcOWZg7gOP7FibygOEC",[an.DataCollector]:"sha384-Q6PI2F9eekWbAxhroybl+aEcvqhdowN/EQlGwBUyJOzPFn9982u9xl6SU6XfGKzc",[an.UsBankAccount]:"sha384-W3RLQSKJL1tQ3+Y7mP6tmkamtZ8bV4Yw/XxL9Jj5JtXHraD8loMF8hAIG5m2zK7F",[an.GooglePayment]:"sha384-TITQMsFWA3elDNGP2mWz2oKBo4qjt+TlqzovcaPoeBiAh/wPBi6nae50ADdgU1/i",[an.ThreeDSecure]:"sha384-YiycYN89ZlL/Evcaq4y1ajW1mhd7JYfZBDuOwHtIn4/Jnm20GL+/XCM+zYAwWD8D",[an.VisaCheckout]:"sha384-/OdaTv9qrkKzjObtUe6yzfDhHozFW/+uXlrSl736sOZRJpjGQETvpYXqMFFg69xv",[an.Venmo]:"sha384-dA+ojdW9vbJS4JavcXyOs9d5uZHJg5dNtYupoPSH2zsXIiYDVS5amLb/u8qmQ6oz",[an.HostedFields]:"sha384-31ZkS58+iaWsW06ftW52zzVZFp43WPd7pNYRiddYynSNg6Oh7WGbSFGorAUH6T1z",[an.Fastlane]:"sha384-jlbrwNvL3HvLAUCtLSmrnQ2GH1udCUrRS/bVmReAS5fuIVvcW8Pko/Gkg82tlgtr"}};var ln=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class cn{constructor(e,t,n){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSDKVersionManager=n}loadClient(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.Client,"client.min.js")})}loadFastlane(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.Fastlane,"fastlane.min.js")})}loadPaypalCheckout(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.PaypalCheckout,"paypal-checkout.min.js")})}loadPaypal(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.Paypal,"paypal.min.js")})}loadLocalPayment(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.LocalPayment,"local-payment.min.js")})}loadDataCollector(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.DataCollector,"data-collector.min.js")})}loadUsBankAccount(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.UsBankAccount,"us-bank-account.min.js")})}loadGooglePayment(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.GooglePayment,"google-payment.min.js")})}load3DS(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.ThreeDSecure,"three-d-secure.min.js")})}loadVisaCheckout(){return this.loadBraintreeModuleOrThrow(an.VisaCheckout,"visa-checkout.min.js")}loadVenmoCheckout(){return this.loadBraintreeModuleOrThrow(an.Venmo,"venmo.min.js")}loadHostedFields(){return ln(this,null,function*(){return this.loadBraintreeModuleOrThrow(an.HostedFields,"hosted-fields.min.js")})}loadVisaCheckoutSdk(e){return ln(this,null,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 ln(this,null,function*(){let n=this.getBraintreeModule(e);if(n)return n;const r=this.braintreeSDKVersionManager.getSDKVersion(),i=`//js.braintreegateway.com/web/${r}/js/${t}`,o=r in sn?this.getIntegrityValuesByModuleName(e,r):void 0;if(yield this.scriptLoader.loadScript(i,o?{async:!0,attributes:{integrity:o,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[e]}getIntegrityValuesByModuleName(e,t){const n=sn[t][e];if(!n)throw new Error("Unexpected fileName value");return n}}class dn{constructor(e){const t=new Promise((e,t)=>{this.cancel=t});this.promise=Promise.race([e,t])}}var hn=Object.defineProperty,un=Object.getOwnPropertySymbols,yn=Object.getPrototypeOf,pn=Object.prototype.hasOwnProperty,gn=Object.prototype.propertyIsEnumerable,_n=Reflect.get,mn=(e,t,n)=>t in e?hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pn=(e,t,n)=>_n(yn(e),n,t),fn=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class wn extends Q{constructor(e,t){super("braintree",e),this._braintreeSdk=t,this._methodId=ke.BRAINTREE,this._verificationsInProgress=0,this._service=e}initialize(e,t,n){return fn(this,null,function*(){yield Pn(wn.prototype,this,"initialize").call(this,e,t,n);let r=Pn(wn.prototype,this,"getPaymentMethod").call(this);if(r.clientToken||(r=(yield this._service.loadPaymentMethod(this._methodId)).getPaymentMethodOrThrow(this._methodId)),!r.clientToken||!r.initializationData)throw new _(g.MissingPaymentMethod);return this._braintreeSdk.initialize(r.clientToken),this._braintreeGooglePayment=yield this._braintreeSdk.getBraintreeGooglePayment(),Promise.resolve()})}getNonce(e){return fn(this,null,function*(){var t;const n=yield Pn(wn.prototype,this,"getNonce").call(this,e),{clientToken:r,initializationData:i}=Pn(wn.prototype,this,"getPaymentMethod").call(this);if(!r||!i||!(null==(t=i.card_information)?void 0:t.bin))throw new _(g.MissingPaymentMethod);const{isThreeDSecureEnabled:o,card_information:{bin:a,isNetworkTokenized:s}}=i;if(o&&!s){const e=yield this._braintreeSdk.getBraintreeThreeDS(),{orderAmount:t}=this._service.getState().getOrderOrThrow();return(yield this._braintreePresent3DSChallenge(e,t,n,a)).nonce}return n})}extraPaymentData(){return fn(this,null,function*(){return{deviceSessionId:yield this._getBraintreeDeviceData()}})}mapToExternalCheckoutData(e){return fn(this,null,function*(){const t=yield Pn(wn.prototype,this,"mapToExternalCheckoutData").call(this,e);let n;try{n=JSON.parse(t.nonce)}catch(e){throw new S("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 _(g.MissingPaymentToken)}(n),t.nonce=n.androidPayCards[0].nonce,t.card_information.bin=n.androidPayCards[0].details.bin,t.card_information.isNetworkTokenized=n.androidPayCards[0].details.isNetworkTokenized,t})}getCardParameters(){return super.getCardParameters()}getPaymentGatewayParameters(){return fn(this,null,function*(){return this.getBraintreeGooglePayment().createPaymentDataRequest(((e,t)=>{for(var n in t||(t={}))pn.call(t,n)&&mn(e,n,t[n]);if(un)for(var n of un(t))gn.call(t,n)&&mn(e,n,t[n]);return e})({merchantInfo:Pn(wn.prototype,this,"getMerchantInfo").call(this),transactionInfo:Pn(wn.prototype,this,"getTransactionInfo").call(this),cardRequirements:{billingAddressRequired:!0,billingAddressFormat:"FULL"}},yield Pn(wn.prototype,this,"getRequiredData").call(this))).paymentMethodTokenizationParameters.parameters})}getBraintreeGooglePayment(){if(!this._braintreeGooglePayment)throw new _(g.MissingPaymentMethod);return this._braintreeGooglePayment}_getBraintreeDeviceData(){return fn(this,null,function*(){const{deviceData:e}=yield this._braintreeSdk.getDataCollectorOrThrow();return e})}_braintreePresent3DSChallenge(e,t,n,r){return fn(this,null,function*(){this._verificationsInProgress>0&&(yield this._cancelBraintree3DSVerification(e)),this._verificationsInProgress+=1;const i=new dn(e.verifyCard({amount:t,bin:r,nonce:n,onLookupComplete:(e,t)=>{t()}}));try{return yield i.promise}finally{this._verificationsInProgress-=1}})}_cancelBraintree3DSVerification(e){return fn(this,null,function*(){try{yield e.cancelVerifyCard()}catch(e){}})}}const bn=y(r=>{const i=t(),o=window,a=new Yt(r),s=new on(new cn(n(),o,a));return new Ve(r,new _e(Ye(),new wn(r,s),i,e()))},[{id:"googlepaybraintree"}]),Sn=["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 Cn(e){if(!e)return;let t;if(e.includes("-")){const[n,r]=e.split("-");t=`${n}_${r.toUpperCase()}`}else t=`${e}_${e.toUpperCase()}`;return Sn.includes(t)?t:void 0}var vn=Object.defineProperty,In=Object.defineProperties,On=Object.getOwnPropertyDescriptors,An=Object.getOwnPropertySymbols,Tn=Object.prototype.hasOwnProperty,Mn=Object.prototype.propertyIsEnumerable,kn=(e,t,n)=>t in e?vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,En=(e,t)=>{for(var n in t||(t={}))Tn.call(t,n)&&kn(e,n,t[n]);if(An)for(var n of An(t))Mn.call(t,n)&&kn(e,n,t[n]);return e},Dn=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class zn{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n,r){return Dn(this,null,function*(){if(!this.window.paypalFastlaneSdk){const i=this.getPayPalFastlaneSdkConfiguration(e,t,n,r);if(yield this.loadPayPalSdk(i),!this.window.paypalFastlaneSdk)throw new h}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,r,i){return Dn(this,null,function*(){if(!this.window.paypalGooglePay||i){const i=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,r);yield this.loadPayPalSdk(i)}if(!this.window.paypalGooglePay)throw new h;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t,n){return Dn(this,null,function*(){if(!this.window.paypalApms){const r=this.getPayPalApmSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(r),!this.window.paypalApms)throw new h}return this.window.paypalApms})}getPayPalMessages(e,t,n){return Dn(this,null,function*(){if(!this.window.paypalMessages){const r=this.getPayPalSdkMessagesConfiguration(e,t,n);yield this.loadPayPalSdk(r)}if(!this.window.paypalMessages)throw new h;return this.window.paypalMessages})}loadPayPalSdk(e){return Dn(this,arguments,function*({options:e,attributes:t}){const n=this.transformConfig(e),r=this.transformConfig(t),i=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(i,{async:!0,attributes:r})})}getPayPalFastlaneSdkConfiguration(e,t,n,r){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new _(g.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:l,attributionId:c}=o,d=Cn(r);return{options:En({"client-id":s,"merchant-id":l,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t,intent:a},d&&{locale:d}),attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":i}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,r=!0){const{clientToken:i,initializationData:o}=e;if(!o||!o.clientId)throw new _(g.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:l,buyerCountry:c,attributionId:d,isHostedCheckoutEnabled:h,isDeveloperModeApplicable:u}=o,y=h||r,p=Cn(n);return{options:En(En({"client-id":s,"merchant-id":l,commit:y,components:["googlepay"],currency:t,intent:a},u&&{"buyer-country":c}),p&&{locale:p}),attributes:{"data-partner-attribution-id":d,"data-client-token":i,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t,n){const{initializationData:r}=e;if(!r||!r.clientId)throw new _(g.MissingPaymentMethod);const{intent:i,clientId:o,merchantId:a,buyerCountry:s,attributionId:l,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:d=[],enabledAlternativePaymentMethods:h=[]}=r,u=h,y=d.filter(e=>!h.includes(e)),p=Cn(n);return{options:En(En({"client-id":o,"merchant-id":a,"enable-funding":u.length>0?u:void 0,"disable-funding":y.length>0?y:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:i},c&&{"buyer-country":s}),p&&{locale:p}),attributes:{"data-partner-attribution-id":l,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t,n){const{initializationData:r}=e;if(!r||!r.clientId)throw new _(g.MissingPaymentMethod);const{clientId:i,merchantId:o,attributionId:a,isDeveloperModeApplicable:s,buyerCountry:l}=r,c=Cn(n);return{options:En(En({"client-id":i,"merchant-id":o,components:["messages"],currency:t},s&&{"buyer-country":l}),c&&{locale:c}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const r=e[n];var i,o;null==r||""===r||Array.isArray(r)&&0===r.length||(i=En({},t),o={[n]:Array.isArray(r)?r.join(","):r},t=In(i,On(o)))}),t}}function Nn(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 _(g.MissingPaymentMethod)}var Gn=Object.getPrototypeOf,Rn=Reflect.get,Bn=(e,t,n)=>Rn(Gn(e),n,t),Ln=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class xn extends Q{constructor(e,t){super("paypalsb",e),this.payPalCommerceSdk=t,this.service=e}initialize(e,t,n){return Ln(this,null,function*(){var r,i,o,a,s;const l=this.service.getState(),c=null!=(i=null==(r=l.getStoreConfig())?void 0:r.currency.code)?i:n;if(!c)throw new _(g.MissingPaymentMethod);yield Bn(xn.prototype,this,"initialize").call(this,e,t,c);const d=Bn(xn.prototype,this,"getPaymentMethod").call(this);if(!d.initializationData)throw new _(g.MissingPaymentMethod);Nn(d);const h=yield this.payPalCommerceSdk.getPayPalGooglePaySdk(d,c,l.getLocale());this.googlepayConfig=yield h.Googlepay().config();const{allowedPaymentMethods:u}=this.googlepayConfig;this.setGatewayIdentifier(null==(s=null==(a=null==(o=u[0])?void 0:o.tokenizationSpecification)?void 0:a.parameters)?void 0:s.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){return Ln(this,null,function*(){const t=yield Bn(xn.prototype,this,"mapToExternalCheckoutData").call(this,e);return t.nonce=btoa(t.nonce),t})}}const jn="This API endpoint is for internal use only and may change in the future";var Fn=(e=>(e.Approved="APPROVED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e))(Fn||{}),Vn=Object.defineProperty,Un=Object.getOwnPropertySymbols,Wn=Object.prototype.hasOwnProperty,Hn=Object.prototype.propertyIsEnumerable,qn=(e,t,n)=>t in e?Vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Kn=(e,t)=>{for(var n in t||(t={}))Wn.call(t,n)&&qn(e,n,t[n]);if(Un)for(var n of Un(t))Hn.call(t,n)&&qn(e,n,t[n]);return e},Jn=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class Yn extends Ve{constructor(e,t,n,r){super(e,t),this._payPalCommerceSdk=n,this._requestSender=r}execute(e){return Jn(this,arguments,function*({payment:e}){if(!(null==e?void 0:e.methodId))throw new me(["payment"]);const t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow().id,{initializationData:r}=t.getPaymentMethodOrThrow(this._getMethodId()),{orderId:i}=yield this.getOrderId(n),{card_information:o}=r||{},a=yield this._googlePayPaymentProcessor.getNonce(e.methodId),s={tokenizationData:{type:"PAYMENT_GATEWAY",token:atob(a)},info:{cardNetwork:(null==o?void 0:o.type)||"",cardDetails:(null==o?void 0:o.number)||""},type:"CARD"};yield this.confirmOrder(i,s),yield this._paymentIntegrationService.submitOrder();try{const t={formattedPayload:{method_id:e.methodId,paypal_account:{order_id:i}}};yield this._paymentIntegrationService.submitPayment({methodId:e.methodId,paymentData:t})}catch(e){yield this._googlePayPaymentProcessor.processAdditionalAction(e)}})}confirmOrder(e,t){return Jn(this,null,function*(){const n=this._paymentIntegrationService.getState(),r=n.getPaymentMethodOrThrow(this._getMethodId());if(!r.initializationData)throw new _(g.MissingPaymentMethod);const i=n.getCartOrThrow().currency.code,o=yield this._payPalCommerceSdk.getPayPalGooglePaySdk(r,i,n.getLocale(),!0),{status:a}=yield o.Googlepay().confirmOrder({orderId:e,paymentMethodData:t});if(a===Fn.PayerActionRequired)return yield o.Googlepay().initiatePayerAction({orderId:e}),Promise.resolve();if(a!==Fn.Approved)throw new S("Payment is not approved.");return Promise.resolve()})}getOrderId(e){return Jn(this,null,function*(){const t={cartId:e,shouldSaveInstrument:!1},{body:n}=yield this._requestSender.post("/api/storefront/payments/googlepaypaypalcommercecheckout",{headers:Kn({"X-API-INTERNAL":jn,"Content-Type":ct.Json},ie),body:t});return n})}}const Zn=y(r=>{const i=new zn(n());return new Yn(r,new _e(Ye(),new xn(r,i),t(),e()),i,t())},[{id:"googlepaypaypalcommerce"}]);var Xn=Object.defineProperty,Qn=Object.defineProperties,$n=Object.getOwnPropertyDescriptors,er=Object.getOwnPropertySymbols,tr=Object.prototype.hasOwnProperty,nr=Object.prototype.propertyIsEnumerable,rr=(e,t,n)=>t in e?Xn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ir=(e,t)=>{for(var n in t||(t={}))tr.call(t,n)&&rr(e,n,t[n]);if(er)for(var n of er(t))nr.call(t,n)&&rr(e,n,t[n]);return e},or=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class ar{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n){return or(this,null,function*(){if(!this.window.bigCommercePaymentsFastlaneSdk){const r=this.getPayPalFastlaneSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(r),!this.window.bigCommercePaymentsFastlaneSdk)throw new h}return this.window.bigCommercePaymentsFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,r){return or(this,null,function*(){if(!this.window.bigCommercePaymentsGooglePay||r){const r=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n);yield this.loadPayPalSdk(r)}if(!this.window.bigCommercePaymentsGooglePay)throw new h;return this.window.bigCommercePaymentsGooglePay})}getPayPalApmsSdk(e,t){return or(this,null,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 or(this,null,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(e){return or(this,arguments,function*({options:e,attributes:t}){const n=this.transformConfig(e),r=this.transformConfig(t),i=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(i,{async:!0,attributes:r})})}getPayPalFastlaneSdkConfiguration(e,t,n){const{clientToken:r,initializationData:i}=e;if(!i||!i.clientId)throw new _(g.MissingPaymentMethod);const{intent:o,clientId:a,merchantId:s,attributionId:l}=i;return{options:{"client-id":a,"merchant-id":s,commit:!0,components:["fastlane","three-domain-secure"],currency:t,intent:o},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"bigCommercePaymentsFastlaneSdk","data-partner-attribution-id":l,"data-sdk-client-token":r}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n=!0){const{clientToken:r,initializationData:i}=e;if(!i||!i.clientId)throw new _(g.MissingPaymentMethod);const{intent:o,clientId:a,merchantId:s,buyerCountry:l,attributionId:c,isHostedCheckoutEnabled:d,isDeveloperModeApplicable:h}=i;return{options:ir({"client-id":a,"merchant-id":s,commit:d||n,components:["googlepay"],currency:t,intent:o},h&&{"buyer-country":l}),attributes:{"data-partner-attribution-id":c,"data-client-token":r,"data-namespace":"bigCommercePaymentsGooglePay"}}}getPayPalApmSdkConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new _(g.MissingPaymentMethod);const{intent:r,clientId:i,merchantId:o,buyerCountry:a,attributionId:s,isDeveloperModeApplicable:l,availableAlternativePaymentMethods:c=[],enabledAlternativePaymentMethods:d=[]}=n,h=this.filterFundingOptions(d),u=this.filterFundingOptions(c.filter(e=>!d.includes(e)));return{options:ir({"client-id":i,"merchant-id":o,"enable-funding":h.length>0?h:void 0,"disable-funding":u.length>0?u:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:r},l&&{"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 _(g.MissingPaymentMethod);const{clientId:r,merchantId:i,attributionId:o,isDeveloperModeApplicable:a,buyerCountry:s}=n;return{options:ir({"client-id":r,"merchant-id":i,components:["messages"],currency:t},a&&{"buyer-country":s}),attributes:{"data-namespace":"bigCommercePaymentsMessages","data-partner-attribution-id":o}}}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 r=e[n];var i,o;null==r||""===r||Array.isArray(r)&&0===r.length||(i=ir({},t),o={[n]:Array.isArray(r)?r.join(","):r},t=Qn(i,$n(o)))}),t}}var sr=Object.getPrototypeOf,lr=Reflect.get,cr=(e,t,n)=>lr(sr(e),n,t),dr=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class hr extends Q{constructor(e,t){super("googlepay_bigcommerce_payments",e),this.payPalSdkHelper=t,this.service=e}initialize(e,t,n){return dr(this,null,function*(){var r,i,o,a,s;const l=null!=(i=null==(r=this.service.getState().getStoreConfig())?void 0:r.currency.code)?i:n;if(!l)throw new _(g.MissingPaymentMethod);yield cr(hr.prototype,this,"initialize").call(this,e,t,l);const c=cr(hr.prototype,this,"getPaymentMethod").call(this);if(!c.initializationData)throw new _(g.MissingPaymentMethod);Nn(c);const d=yield this.payPalSdkHelper.getPayPalGooglePaySdk(c,l);this.googlepayConfig=yield d.Googlepay().config();const{allowedPaymentMethods:h}=this.googlepayConfig;this.setGatewayIdentifier(null==(s=null==(a=null==(o=h[0])?void 0:o.tokenizationSpecification)?void 0:a.parameters)?void 0:s.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){return dr(this,null,function*(){const t=yield cr(hr.prototype,this,"mapToExternalCheckoutData").call(this,e);return t.nonce=btoa(t.nonce),t})}}var ur=(e=>(e.Approved="APPROVED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e))(ur||{}),yr=Object.defineProperty,pr=Object.getOwnPropertySymbols,gr=Object.prototype.hasOwnProperty,_r=Object.prototype.propertyIsEnumerable,mr=(e,t,n)=>t in e?yr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pr=(e,t)=>{for(var n in t||(t={}))gr.call(t,n)&&mr(e,n,t[n]);if(pr)for(var n of pr(t))_r.call(t,n)&&mr(e,n,t[n]);return e},fr=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class wr extends Ve{constructor(e,t,n,r){super(e,t),this._payPalSdkHelper=n,this._requestSender=r}execute(e){return fr(this,arguments,function*({payment:e}){if(!(null==e?void 0:e.methodId))throw new me(["payment"]);const t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow().id,{initializationData:r}=t.getPaymentMethodOrThrow(this._getMethodId()),{orderId:i}=yield this.getOrderId(n),{card_information:o}=r||{},a=yield this._googlePayPaymentProcessor.getNonce(e.methodId),s={tokenizationData:{type:"PAYMENT_GATEWAY",token:atob(a)},info:{cardNetwork:(null==o?void 0:o.type)||"",cardDetails:(null==o?void 0:o.number)||""},type:"CARD"};yield this.confirmOrder(i,s),yield this._paymentIntegrationService.submitOrder();try{const t={formattedPayload:{method_id:e.methodId,paypal_account:{order_id:i}}};yield this._paymentIntegrationService.submitPayment({methodId:e.methodId,paymentData:t})}catch(e){yield this._googlePayPaymentProcessor.processAdditionalAction(e)}})}confirmOrder(e,t){return fr(this,null,function*(){const n=this._paymentIntegrationService.getState(),r=n.getPaymentMethodOrThrow(this._getMethodId());if(!r.initializationData)throw new _(g.MissingPaymentMethod);const i=n.getCartOrThrow().currency.code,o=yield this._payPalSdkHelper.getPayPalGooglePaySdk(r,i,!0),{status:a}=yield o.Googlepay().confirmOrder({orderId:e,paymentMethodData:t});if(a===ur.PayerActionRequired)return yield o.Googlepay().initiatePayerAction({orderId:e}),Promise.resolve();if(a!==ur.Approved)throw new S("Payment is not approved.");return Promise.resolve()})}getOrderId(e){return fr(this,null,function*(){const t={cartId:e,shouldSaveInstrument:!1},{body:n}=yield this._requestSender.post("/api/storefront/payments/googlepay_bigcommerce_paymentscheckout",{headers:Pr({"X-API-INTERNAL":jn,"Content-Type":ct.Json},ie),body:t});return n})}}const br=y(r=>{const i=new ar(n());return new wr(r,new _e(Ye(),new hr(r,i),t(),e()),i,t())},[{id:"googlepay_bigcommerce_payments"}]);var Sr=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class Cr extends Q{constructor(e,t){super("worldlinena",e),this.formPoster=t}extraPaymentData(){return Sr(this,null,function*(){return Promise.resolve({browser_info:m()})})}processAdditionalAction(e){return Sr(this,null,function*(){if(!function(e){return P(e)&&(t=e.body,s(t)&&"object"==typeof t&&"errors"in t&&"three_ds_result"in t&&a(t.errors)&&c(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:r,merchant_data:i}=t||{};if(!n||!r||!i)throw new me(["formUrl","threeDSSessionData","creq"]);return new Promise(e=>{this.formPoster.postForm(n,{threeDSSessionData:r,creq:i},e,"_top")})})}}const vr=y(n=>new Ve(n,new _e(Ye(),new Cr(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);class Ir extends d{constructor(e){super(e||"Not implemented."),this.name="NotImplementedError",this.type="not_implemented"}}var Or=Object.defineProperty,Ar=Object.defineProperties,Tr=Object.getOwnPropertyDescriptors,Mr=Object.getOwnPropertySymbols,kr=Object.prototype.hasOwnProperty,Er=Object.prototype.propertyIsEnumerable,Dr=(e,t,n)=>t in e?Or(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zr=(e,t)=>{for(var n in t||(t={}))kr.call(t,n)&&Dr(e,n,t[n]);if(Mr)for(var n of Mr(t))Er.call(t,n)&&Dr(e,n,t[n]);return e},Nr=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class Gr{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){return Nr(this,null,function*(){var t,n;if(!(null==e?void 0:e.methodId)||!Ee(e.methodId))throw new S('Unable to proceed because "methodId" is not a valid key.');this._methodId=e.methodId;const r=e[this._getMethodId()];if(!r)throw new S("Unable to proceed without valid options.");let i,o=this._paymentIntegrationService.getState();try{i=o.getPaymentMethodOrThrow(this._getMethodId())}catch(e){o=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodId()),i=o.getPaymentMethodOrThrow(this._getMethodId())}try{this._googlePayPaymentProcessor.setIsWebViewExperimentOn(!!(null==(t=i.initializationData)?void 0:t.isWebViewExperimentOn)),this._googlePayPaymentProcessor.setFilterAvailableShippingOptions(r.filterAvailableShippingOptions),yield this._googlePayPaymentProcessor.initialize(()=>i,this._getGooglePayClientOptions(null==(n=i.initializationData)?void 0:n.storeCountry))}catch(e){return}this._addPaymentButton(r)})}signIn(){return Promise.reject(new Ir('In order to sign in via Google Pay, the shopper must click on "Google Pay" button.'))}signOut(){return Nr(this,null,function*(){var e;const t=null==(e=this._paymentIntegrationService.getState().getPaymentId())?void 0:e.providerId;t&&(yield this._googlePayPaymentProcessor.signOut(t))})}executePaymentMethodCheckout(e){var t;return null==(t=null==e?void 0:e.continueWithCheckoutCallback)||t.call(e),Promise.resolve()}deinitialize(){var e;return null==(e=this._paymentButton)||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()}_getGooglePayClientOptions(e){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:t=>Nr(this,[t],function*({callbackTrigger:t,shippingAddress:n,shippingOptionData:r,offerData:i}){const{availableTriggers:o,addressChangeTriggers:a,shippingOptionsChangeTriggers:s,offerChangeTriggers:l}=this._googlePayPaymentProcessor.getCallbackTriggers();if(!o.includes(t))return;const c=a.includes(t)?yield this._googlePayPaymentProcessor.handleShippingAddressChange(n):void 0;s.includes(t)&&(yield this._googlePayPaymentProcessor.handleShippingOptionChange(r.id));const{newOfferInfo:d,error:h}=l.includes(t)?yield this._googlePayPaymentProcessor.handleCoupons(i):{},u=h;yield this._paymentIntegrationService.loadCheckout();const y=this._googlePayPaymentProcessor.getTotalPrice(),{code:p}=this._paymentIntegrationService.getState().getCartOrThrow().currency;return zr(zr(zr({newTransactionInfo:(g=zr({},e&&{countryCode:e}),_={currencyCode:p,totalPriceStatus:R.FINAL,totalPrice:y},Ar(g,Tr(_)))},c&&{newShippingOptionParameters:c}),d&&{newOfferInfo:d}),u&&{error:u});var g,_})}}}_addPaymentButton({container:e,buttonColor:t,buttonType:n,onClick:r,onError:i}){var o;this._paymentButton=null!=(o=this._paymentButton)?o:this._googlePayPaymentProcessor.addPaymentButton(e,{buttonColor:null!=t?t:"default",buttonType:null!=n?n:"plain",onClick:this._handleClick(i,r)})}_handleClick(e,t){return n=>Nr(this,null,function*(){n.preventDefault(),t&&"function"==typeof t&&t();try{yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(t){let n=t;if(Me(t)){if("CANCELED"===t.statusCode)throw new f;n=new oe(JSON.stringify(t))}throw null==e||e(new oe("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){return Nr(this,null,function*(){const e=yield this._googlePayPaymentProcessor.showPaymentSheet(),t=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(e),n=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(e),r="/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,r)})}_getMethodId(){return z(this._methodId,()=>new b(w.PaymentNotInitialized))}}const Rr=y(n=>{const r=t();return new Gr(n,new _e(Ye(),new Q("adyen",n),r,e()))},[{id:"googlepayadyenv2"}]),Br=y(n=>{const r=t();return new Gr(n,new _e(Ye(),new Q("adyen",n),r,e()))},[{id:"googlepayadyenv3"}]),Lr=y(n=>new Gr(n,new _e(Ye(),new at(n),t(),e())),[{id:"googlepayauthorizenet"}]),xr=y(n=>{const r=t();return new Gr(n,new _e(Ye(),new pt(n,r),r,e()))},[{id:"googlepaycheckoutcom"}]),jr=y(n=>new Gr(n,new _e(Ye(),new Pt(n),t(),e())),[{id:"googlepaycybersourcev2"}]),Fr=y(n=>new Gr(n,new _e(Ye(),new Pt(n),t(),e())),[{id:"googlepaybnz"}]),Vr=y(n=>new Gr(n,new _e(Ye(),new St(n),t(),e())),[{id:"googlepayorbital"}]),Ur=y(r=>new Gr(r,new _e(Ye(),new jt(r,new Dt(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeocs"}]),Wr=y(r=>new Gr(r,new _e(Ye(),new jt(r,new Dt(n())),t(),e())),[{id:"googlepaystripeupe"}]),Hr=y(n=>new Gr(n,new _e(Ye(),new Wt(n),t(),e())),[{id:"googlepayworldpayaccess"}]),qr=y(r=>{const i=t(),o=window,a=new Yt(r),s=new on(new cn(n(),o,a));return new Gr(r,new _e(Ye(),new wn(r,s),i,e()))},[{id:"googlepaybraintree"}]),Kr=y(r=>new Gr(r,new _e(Ye(),new xn(r,new zn(n())),t(),e())),[{id:"googlepaypaypalcommerce"}]),Jr=y(r=>new Gr(r,new _e(Ye(),new hr(r,new ar(n())),t(),e())),[{id:"googlepay_bigcommerce_payments"}]),Yr=y(n=>new Gr(n,new _e(Ye(),new Cr(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);class Zr extends d{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 Xr=Object.defineProperty,Qr=Object.defineProperties,$r=Object.getOwnPropertyDescriptors,ei=Object.getOwnPropertySymbols,ti=Object.prototype.hasOwnProperty,ni=Object.prototype.propertyIsEnumerable,ri=(e,t,n)=>t in e?Xr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ii=(e,t)=>{for(var n in t||(t={}))ti.call(t,n)&&ri(e,n,t[n]);if(ei)for(var n of ei(t))ni.call(t,n)&&ri(e,n,t[n]);return e},oi=(e,t)=>Qr(e,$r(t)),ai=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});class si{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){return ai(this,null,function*(){var t,n,r;if(!e.methodId||!Ee(e.methodId))throw new S('Unable to proceed because "methodId" is not a valid key.');if(this._methodId=e.methodId,!e.containerId)throw new S('Unable to proceed because "containerId" is not a valid key.');const i=e[this._getMethodOrThrow()];if(!i)throw new S("Unable to proceed without valid options.");const{buyNowInitializeOptions:o,currencyCode:a,buttonColor:s,buttonType:l,onError:c,filterAvailableShippingOptions:d}=i;let h,u=this._paymentIntegrationService.getState();try{h=u.getPaymentMethodOrThrow(this._getMethodOrThrow())}catch(e){u=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodOrThrow()),h=u.getPaymentMethodOrThrow(this._getMethodOrThrow())}if(this._countryCode=null==(t=h.initializationData)?void 0:t.storeCountry,this._googlePayPaymentProcessor.setIsWebViewExperimentOn(!!(null==(n=h.initializationData)?void 0:n.isWebViewExperimentOn)),this._googlePayPaymentProcessor.setFilterAvailableShippingOptions(d),o){if(!a)throw new S('Unable to initialize payment because "options.currencyCode" argument is not provided.');this._currencyCode=a,this._buyNowInitializeOptions=o,yield this._googlePayPaymentProcessor.initialize(()=>h,this._getGooglePayClientOptions(),!!o,a)}else yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initialize(()=>h,this._getGooglePayClientOptions());this._paymentButton=null!=(r=this._paymentButton)?r:this._googlePayPaymentProcessor.addPaymentButton(e.containerId,{buttonColor:null!=s?s:"default",buttonType:null!=l?l:"plain",onClick:this._handleClick(c)})})}deinitialize(){var e;return null==(e=this._paymentButton)||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()}_handleClick(e){return t=>ai(this,null,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(Me(t)){if("CANCELED"===t.statusCode)throw new f;n=new oe(JSON.stringify(t))}throw null==e||e(new oe("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){return ai(this,null,function*(){var e;const t=yield this._googlePayPaymentProcessor.showPaymentSheet(),n=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(t),r=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(t),i="/embedded-checkout"===window.location.pathname?this._paymentIntegrationService.getState().getStoreConfigOrThrow().links.siteLink:void 0;n&&(yield this._paymentIntegrationService.updateBillingAddress(n)),r&&!(null==(e=this._buyNowCart)?void 0:e.lineItems.digitalItems.length)&&(yield this._paymentIntegrationService.updateShippingAddress(r)),yield this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodOrThrow(),t,i)})}_getGooglePayClientOptions(){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:e=>ai(this,[e],function*({callbackTrigger:e,shippingAddress:t,shippingOptionData:n,offerData:r}){const{availableTriggers:i,addressChangeTriggers:o,shippingOptionsChangeTriggers:a,offerChangeTriggers:s}=this._googlePayPaymentProcessor.getCallbackTriggers();if(!i.includes(e))return;const l=o.includes(e)?yield this._googlePayPaymentProcessor.handleShippingAddressChange(t):void 0;a.includes(e)&&(yield this._googlePayPaymentProcessor.handleShippingOptionChange(n.id));const{newOfferInfo:c,error:d}=s.includes(e)?yield this._googlePayPaymentProcessor.handleCoupons(r):{},h=d;return this._buyNowInitializeOptions?this._getBuyNowTransactionInfo(l,c,h):this._getTransactionInfo(l,c,h)})}}}_createBuyNowCartOrThrow(e){return ai(this,null,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 Zr(e);throw e}}})}_getBuyNowTransactionInfo(e,t,n){if(!this._buyNowCart)return;const{cartAmount:r}=this._buyNowCart,i=this._googlePayPaymentProcessor.getTotalPrice();return ii(ii(ii({newTransactionInfo:oi(ii({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:this._getCurrencyCodeOrThrow(),totalPrice:i||String(r),totalPriceStatus:R.FINAL})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})}_getTransactionInfo(e,t,n){return ai(this,null,function*(){yield this._paymentIntegrationService.loadCheckout();const r=this._googlePayPaymentProcessor.getTotalPrice(),{code:i}=this._paymentIntegrationService.getState().getCartOrThrow().currency;return ii(ii(ii({newTransactionInfo:oi(ii({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:i,totalPriceStatus:R.FINAL,totalPrice:r})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})})}_getMethodOrThrow(){return z(this._methodId,()=>new b(w.PaymentNotInitialized))}_getCurrencyCodeOrThrow(){return z(this._currencyCode,()=>new S('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}}const li=y(r=>{const i=t(),o=window,a=new Yt(r),s=new on(new cn(n(),o,a));return new si(r,new _e(Ye(),new wn(r,s),i,e()))},[{id:"googlepaybraintree"}]),ci=y(r=>new si(r,new _e(Ye(),new xn(r,new zn(n())),t(),e())),[{id:"googlepaypaypalcommerce"}]),di=y(r=>new si(r,new _e(Ye(),new hr(r,new ar(n())),t(),e())),[{id:"googlepay_bigcommerce_payments"}]),hi=y(n=>{const r=t();return new si(n,new _e(Ye(),new Q("adyen",n),r,e()))},[{id:"googlepayadyenv2"}]),ui=y(n=>{const r=t();return new si(n,new _e(Ye(),new Q("adyen",n),r,e()))},[{id:"googlepayadyenv3"}]),yi=y(n=>new si(n,new _e(Ye(),new at(n),t(),e())),[{id:"googlepayauthorizenet"}]),pi=y(n=>{const r=t();return new si(n,new _e(Ye(),new pt(n,r),r,e()))},[{id:"googlepaycheckoutcom"}]),gi=y(n=>new si(n,new _e(Ye(),new Pt(n),t(),e())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]),_i=y(n=>new si(n,new _e(Ye(),new St(n),t(),e())),[{id:"googlepayorbital"}]),mi=y(r=>new si(r,new _e(Ye(),new jt(r,new Dt(n())),t(),e())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]),Pi=y(n=>new si(n,new _e(Ye(),new Wt(n),t(),e())),[{id:"googlepayworldpayaccess"}]),fi=y(n=>new si(n,new _e(Ye(),new Cr(n,e()),t(),e())),[{id:"googlepaytdonlinemart"}]);export{hi as createGooglePayAdyenV2ButtonStrategy,Rr as createGooglePayAdyenV2CustomerStrategy,Ze as createGooglePayAdyenV2PaymentStrategy,ui as createGooglePayAdyenV3ButtonStrategy,Br as createGooglePayAdyenV3CustomerStrategy,rt as createGooglePayAdyenV3PaymentStrategy,yi as createGooglePayAuthorizeDotNetButtonStrategy,Lr as createGooglePayAuthorizeDotNetCustomerStrategy,st as createGooglePayAuthorizeNetPaymentStrategy,di as createGooglePayBigCommercePaymentsButtonStrategy,Jr as createGooglePayBigCommercePaymentsCustomerStrategy,br as createGooglePayBigCommercePaymentsPaymentStrategy,Fr as createGooglePayBnzCustomerStrategy,li as createGooglePayBraintreeButtonStrategy,qr as createGooglePayBraintreeCustomerStrategy,bn as createGooglePayBraintreePaymentStrategy,pi as createGooglePayCheckoutComButtonStrategy,xr as createGooglePayCheckoutComCustomerStrategy,gt as createGooglePayCheckoutComPaymentStrategy,gi as createGooglePayCybersourceButtonStrategy,jr as createGooglePayCybersourceCustomerStrategy,ft as createGooglePayCybersourcePaymentStrategy,_i as createGooglePayOrbitalButtonStrategy,Vr as createGooglePayOrbitalCustomerStrategy,Ct as createGooglePayOrbitalPaymentStrategy,Zn as createGooglePayPPCPPaymentStrategy,ci as createGooglePayPayPalCommerceButtonStrategy,Kr as createGooglePayPayPalCommerceCustomerStrategy,mi as createGooglePayStripeButtonStrategy,Ur as createGooglePayStripeCustomerStrategy,Ft as createGooglePayStripePaymentStrategy,Wr as createGooglePayStripeUpeCustomerStrategy,fi as createGooglePayTdOnlineMartButtonStrategy,Yr as createGooglePayTdOnlineMartCustomerStrategy,vr as createGooglePayTdOnlineMartPaymentStrategy,Pi as createGooglePayWorldpayAccessButtonStrategy,Hr as createGooglePayWorldpayAccessCustomerStrategy,Ht as createGooglePayWorldpayAccessPaymentStrategy};
|
|
2
2
|
//# sourceMappingURL=google-pay.js.map
|