@bigcommerce/checkout-sdk 1.661.4 → 1.661.5
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/checkout-button.js +1 -1
- package/dist/checkout-button.umd.js +1 -1
- package/dist/checkout-sdk.d.ts +32 -10
- package/dist/checkout-sdk.js +1 -1
- package/dist/checkout-sdk.js.map +1 -1
- package/dist/checkout-sdk.umd.js +1 -1
- package/dist/checkout-sdk.umd.js.map +1 -1
- package/dist/hosted-form-v2-iframe-host.js +1 -1
- package/dist/hosted-form-v2-iframe-host.umd.js +1 -1
- package/docs/README.md +7 -3
- package/docs/interfaces/AdyenComponent.md +1 -1
- package/docs/interfaces/AdyenComponentEvents.md +4 -2
- package/docs/interfaces/AdyenComponentState.md +47 -0
- package/docs/interfaces/AdyenCreditCardComponentOptions.md +2 -2
- package/docs/interfaces/AdyenIdealComponentOptions.md +101 -0
- package/docs/interfaces/CardState.md +0 -7
- package/docs/interfaces/CardStateData.md +43 -0
- package/docs/interfaces/IdealStateData.md +15 -0
- package/docs/interfaces/SepaStateData.md +22 -0
- package/package.json +1 -1
package/dist/checkout-button.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{createCheckoutButtonInitializer:()=>Hc,createTimeout:()=>r.createTimeout});var n={};e.r(n),e.d(n,{createAmazonPayV2ButtonStrategy:()=>Cs,createApplePayButtonStrategy:()=>zs,createBoltButtonStrategy:()=>Ys,createBraintreeVenmoButtonStrategy:()=>tu,createBraintreeVisaCheckoutButtonStrategy:()=>Zs,createGooglePayAdyenV2ButtonStrategy:()=>Mu,createGooglePayAdyenV3ButtonStrategy:()=>Nu,createGooglePayAuthorizeDotNetButtonStrategy:()=>Uu,createGooglePayBraintreeButtonStrategy:()=>Au,createGooglePayCheckoutComButtonStrategy:()=>Gu,createGooglePayCybersourceButtonStrategy:()=>ju,createGooglePayOrbitalButtonStrategy:()=>Ku,createGooglePayPayPalCommerceButtonStrategy:()=>Du,createGooglePayStripeButtonStrategy:()=>Ju,createGooglePayTdOnlineMartButtonStrategy:()=>ic,createGooglePayWorldpayAccessButtonStrategy:()=>ec,createPayPalCommerceAlternativeMethodsButtonStrategy:()=>Mc,createPayPalCommerceButtonStrategy:()=>Ic,createPayPalCommerceCreditButtonStrategy:()=>Ac,createPayPalCommerceVenmoButtonStrategy:()=>Rc,createPaypalExpressButtonStrategy:()=>Vc});const r=require("@bigcommerce/request-sender"),i=require("@bigcommerce/form-poster"),o=require("tslib"),a=require("@bigcommerce/data-store"),s=function(e){function t(t){var n,r,i=this.constructor,o=e.call(this,t||"An unexpected error has occurred.")||this;return o.name="StandardError",o.type="standard",n=o,r=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(o,i):o.stack=new Error(o.message).stack,o}return(0,o.__extends)(t,e),t}(Error);var u={body:{},headers:{},status:0},c=function(e){function t(t,n){var r=void 0===n?{}:n,i=r.message,o=r.errors,a=this,s=t||u,c=s.body,d=s.headers,l=s.status;return(a=e.call(this,i||"An unexpected error has occurred.")||this).name="RequestError",a.type="request",a.body=c,a.headers=d,a.status=l,a.errors=o||[],a}return(0,o.__extends)(t,e),t}(s);const d=c,l=function(e){function t(t){var n=e.call(this,t,{message:"There is a problem processing your payment. Please try again later."})||this;return n.name="PaymentMethodInvalidError",n.type="payment_method_invalid",n}return(0,o.__extends)(t,e),t}(d);const p=function(e){function t(t){var n,r,i=this.constructor,o=e.call(this,t||"An unexpected error has occurred.")||this;return o.name="StandardError",o.type="standard",n=o,r=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(o,i):o.stack=new Error(o.message).stack,o}return(0,o.__extends)(t,e),t}(Error);var h={body:{},headers:{},status:0},f=function(e){function t(t,n){var r=void 0===n?{}:n,i=r.message,o=r.errors,a=this,s=t||h,u=s.body,c=s.headers,d=s.status;return(a=e.call(this,i||"An unexpected error has occurred.")||this).name="RequestError",a.type="request",a.body=u,a.headers=c,a.status=d,a.errors=o||[],a}return(0,o.__extends)(t,e),t}(p);const g=f,m=function(e){function t(t,n){var r=e.call(this,t,{message:n||"An unexpected error has occurred. The checkout process cannot continue as a result."})||this;return r.name="UnrecoverableError",r.type="unrecoverable",r}return(0,o.__extends)(t,e),t}(g),_=require("lodash");function y(e){return e.reduce((function(e,t){return t?(0,o.__spreadArrays)(e,[t]):e}),[]).join(" ")}function v(e,t){var n=e.body.errors,r=void 0===n?[]:n;return new g(e,{message:C(r)||t,errors:r})}function C(e){if(Array.isArray(e))return e.reduce((function(e,t){return t&&t.message?(0,o.__spreadArrays)(e,[t.message]):e}),[]).join(" ")}const S=function(e){function t(t){var n=e.call(this,t,{message:"The request has timed out or aborted."})||this;return n.name="TimeoutError",n.type="timeout",n}return(0,o.__extends)(t,e),t}(g);var I=function(){function e(){this._factoryMethods={},this.register("default",(function(e,t){return new g(e,{message:t})})),this.register("internal",(function(e,t){return function(e,t){var n=e.body,r=n.errors,i=void 0===r?[]:r;return new g(e,{message:y(i)||n.detail||n.title||t,errors:i.length?i.map((function(e){return{code:n.type,message:e}})):[{code:n.type,message:n.detail||n.title}]})}(e,t)})),this.register("storefront",(function(e,t){return function(e,t){var n=e.body;return new g(e,{message:t||n.detail||n.title,errors:[{code:n.code||n.type,message:n.detail||n.title}]})}(e,t)})),this.register("payment",(function(e,t){return v(e,t)})),this.register("timeout",(function(e){return new S(e)}))}return e.prototype.register=function(e,t){this._factoryMethods[e]=t},e.prototype.createError=function(e,t){return(this._factoryMethods[this._getType(e)]||this._factoryMethods.default)(e,t)},e.prototype._getType=function(e){if(0===e.status)return"timeout";if(this._isStorefrontErrorResponseBody(e.body))return"storefront";if(this._isInternalErrorResponseBody(e.body)){var t=(0,_.last)(e.body.type.split("/"));return t&&this._factoryMethods[t]?t:"internal"}var n=(0,_.last)(e.body&&e.body.errors);return n&&n.code&&this._factoryMethods[n.code]?n.code:"payment"},e.prototype._isStorefrontErrorResponseBody=function(e){var t=e;return!this._isInternalErrorResponseBody(e)&&"string"==typeof t.title&&"string"==typeof t.type&&"number"==typeof t.status&&"string"==typeof t.detail},e.prototype._isInternalErrorResponseBody=function(e){var t=e;return"object"==typeof t.errors&&"string"==typeof t.title&&"string"==typeof t.type&&"number"==typeof t.status},e}();const w=I,E=require("rxjs"),b=require("rxjs/operators");var P,A,O,T;function R(e,t){return Array.isArray(e)?e.map((function(e){return R(e,t)})):(0,_.isPlainObject)(e)?(0,_.transform)((0,_.omitBy)(e,t),(function(e,n,r){e[r]=R(n,t)}),{}):e}function k(e,t){return function(e){return e.type===A.ClearError}(t)?R(e,(function(e){return e===t.payload})):e}function D(e,t,n){return e===t||(e&&t&&"object"==typeof e&&"object"==typeof t?Array.isArray(e)&&Array.isArray(t)?function(e,t,n){if(e.length!==t.length)return!1;for(var r=0,i=e.length;r<i;r++)if(!D(e[r],t[r],n))return!1;return!0}(e,t,n):!Array.isArray(e)&&!Array.isArray(t)&&(e instanceof Date&&t instanceof Date?function(e,t){return e.getTime()===t.getTime()}(e,t):!(e instanceof Date||t instanceof Date)&&(e instanceof RegExp&&t instanceof RegExp?function(e,t){return e.toString()===t.toString()}(e,t):!(e instanceof RegExp||t instanceof RegExp)&&function(e,t,n){var r=n&&n.keyFilter,i=r?Object.keys(e).filter(r):Object.keys(e),o=r?Object.keys(t).filter(r):Object.keys(t);if(i.length!==o.length)return!1;for(var a=0,s=i.length;a<s;a++){var u=i[a];if(!Object.prototype.hasOwnProperty.call(t,u))return!1;if(!D(e[u],t[u],n))return!1}return!0}(e,t,n))):e===t)}function M(e,t){return void 0===t||D(e,t)?e:t}function N(e,t,n){var r;return e&&Object.prototype.hasOwnProperty.call(e,t)&&D(e[t],n)?e:(0,o.__assign)((0,o.__assign)({},e),((r={})[t]=n,r))}!function(e){e.LoadCheckoutRequested="LOAD_CHECKOUT_REQUESTED",e.LoadCheckoutSucceeded="LOAD_CHECKOUT_SUCCEEDED",e.LoadCheckoutFailed="LOAD_CHECKOUT_FAILED",e.UpdateCheckoutRequested="UPDATE_CHECKOUT_REQUESTED",e.UpdateCheckoutSucceeded="UPDATE_CHECKOUT_SUCCEEDED",e.UpdateCheckoutFailed="UPDATE_CHECKOUT_FAILED"}(P||(P={})),function(e){e.ClearError="CLEAR_ERROR"}(A||(A={})),function(e){e.UpdateSubscriptionsRequested="UPDATE_SUBSCRIPTIONS_REQUESTED",e.UpdateSubscriptionsSucceeded="UPDATE_SUBSCRIPTIONS_SUCCEEDED",e.UpdateSubscriptionsFailed="UPDATE_SUBSCRIPTIONS_FAILED"}(O||(O={})),function(e){e.UpdateBillingAddressRequested="UPDATE_BILLING_ADDRESS_REQUESTED",e.UpdateBillingAddressSucceeded="UPDATE_BILLING_ADDRESS_SUCCEEDED",e.UpdateBillingAddressFailed="UPDATE_BILLING_ADDRESS_FAILED",e.ContinueAsGuestRequested="CONTINUE_AS_GUEST_REQUESTED",e.ContinueAsGuestSucceeded="CONTINUE_AS_GUEST_SUCCEEDED",e.ContinueAsGuestFailed="CONTINUE_AS_GUEST_FAILED"}(T||(T={}));var L={errors:{},statuses:{}};function z(e,t){return void 0===e&&(e=L),(0,a.combineReducers)({data:U,errors:(0,a.composeReducers)(F,k),statuses:B})(e,t)}function U(e,t){switch(t.type){case T.UpdateBillingAddressSucceeded:case T.ContinueAsGuestSucceeded:case P.LoadCheckoutSucceeded:return M(e,t.payload&&t.payload.billingAddress);default:return e}}function F(e,t){switch(void 0===e&&(e=L.errors),t.type){case P.LoadCheckoutRequested:case P.LoadCheckoutSucceeded:return N(e,"loadError",void 0);case P.LoadCheckoutFailed:return N(e,"loadError",t.payload);case T.UpdateBillingAddressRequested:case T.UpdateBillingAddressSucceeded:return N(e,"updateError",void 0);case T.UpdateBillingAddressFailed:return N(e,"updateError",t.payload);case O.UpdateSubscriptionsRequested:case O.UpdateSubscriptionsSucceeded:case T.ContinueAsGuestRequested:case T.ContinueAsGuestSucceeded:return N(e,"continueAsGuestError",void 0);case O.UpdateSubscriptionsFailed:case T.ContinueAsGuestFailed:return N(e,"continueAsGuestError",t.payload);default:return e}}function B(e,t){switch(void 0===e&&(e=L.statuses),t.type){case P.LoadCheckoutRequested:return N(e,"isLoading",!0);case P.LoadCheckoutSucceeded:case P.LoadCheckoutFailed:return N(e,"isLoading",!1);case T.UpdateBillingAddressRequested:return N(e,"isUpdating",!0);case T.UpdateBillingAddressFailed:case T.UpdateBillingAddressSucceeded:return N(e,"isUpdating",!1);case T.ContinueAsGuestRequested:case O.UpdateSubscriptionsRequested:return N(e,"isContinuingAsGuest",!0);case O.UpdateSubscriptionsSucceeded:case O.UpdateSubscriptionsFailed:case T.ContinueAsGuestFailed:case T.ContinueAsGuestSucceeded:return N(e,"isContinuingAsGuest",!1);default:return e}}function q(e){return(0,_.isPlainObject)(e)}const x=function e(t,n,r){var i=(r||{}).matchObject,o=void 0===i?function(e,t){return void 0!==e.id&&e.id===t.id}:i;if(!t)return n;if(!n||t===n)return t;var a=0,s=0,u=function(e,t,n){return a+=e===t?1:0,s+=e===n?1:0,e},c=n.map((function(n,r){var i=t&&t[r];return q(i)&&q(n)?o(i,n)?u(G(i,n),i,n):u(M(i,n),i,n):(0,_.isArray)(i)&&(0,_.isArray)(n)?u(e(i,n),i,n):u(M(i,n),i,n)}));return a===n.length&&t&&t.length===n.length?t:s===n.length?n:c},G=function e(t,n){return t?n&&t!==n?Object.keys(n).reduce((function(t,r){var i=t[r],o=n[r];return q(i)&&q(o)?N(t,r,e(i,o)):(0,_.isArray)(i)&&(0,_.isArray)(o)?N(t,r,x(i,o)):N(t,r,o)}),t):t:n};var V,H,j;!function(e){e.ApplyCouponRequested="APPLY_COUPON_REQUESTED",e.ApplyCouponSucceeded="APPLY_COUPON_SUCCEEDED",e.ApplyCouponFailed="APPLY_COUPON_FAILED",e.RemoveCouponRequested="REMOVE_COUPON_REQUESTED",e.RemoveCouponSucceeded="REMOVE_COUPON_SUCCEEDED",e.RemoveCouponFailed="REMOVE_COUPON_FAILED"}(V||(V={})),function(e){e.ApplyGiftCertificateRequested="APPLY_GIFT_CERTIFICATE_REQUESTED",e.ApplyGiftCertificateSucceeded="APPLY_GIFT_CERTIFICATE_SUCCEEDED",e.ApplyGiftCertificateFailed="APPLY_GIFT_CERTIFICATE_FAILED",e.RemoveGiftCertificateRequested="REMOVE_GIFT_CERTIFICATE_REQUESTED",e.RemoveGiftCertificateSucceeded="REMOVE_GIFT_CERTIFICATE_SUCCEEDED",e.RemoveGiftCertificateFailed="REMOVE_GIFT_CERTIFICATE_FAILED"}(H||(H={})),function(e){e.CreateConsignmentsRequested="CREATE_CONSIGNMENTS_REQUESTED",e.CreateConsignmentsSucceeded="CREATE_CONSIGNMENTS_SUCCEEDED",e.CreateConsignmentsFailed="CREATE_CONSIGNMENTS_FAILED",e.UpdateConsignmentRequested="UPDATE_CONSIGNMENT_REQUESTED",e.UpdateConsignmentSucceeded="UPDATE_CONSIGNMENT_SUCCEEDED",e.UpdateConsignmentFailed="UPDATE_CONSIGNMENT_FAILED",e.DeleteConsignmentRequested="DELETE_CONSIGNMENT_REQUESTED",e.DeleteConsignmentSucceeded="DELETE_CONSIGNMENT_SUCCEEDED",e.DeleteConsignmentFailed="DELETE_CONSIGNMENT_FAILED",e.UpdateShippingOptionRequested="UPDATE_SHIPPING_OPTION_REQUESTED",e.UpdateShippingOptionSucceeded="UPDATE_SHIPPING_OPTION_SUCCEEDED",e.UpdateShippingOptionFailed="UPDATE_SHIPPING_OPTION_FAILED",e.LoadShippingOptionsRequested="LOAD_SHIPPING_OPTIONS_REQUESTED",e.LoadShippingOptionsSucceeded="LOAD_SHIPPING_OPTIONS_SUCCEEDED",e.LoadShippingOptionsFailed="LOAD_SHIPPING_OPTIONS_FAILED"}(j||(j={}));var Y,W={errors:{},statuses:{}};function K(e,t){return void 0===e&&(e=W),(0,a.combineReducers)({data:Z,errors:(0,a.composeReducers)(J,k),statuses:Q})(e,t)}function Z(e,t){switch(t.type){case T.UpdateBillingAddressSucceeded:case P.LoadCheckoutSucceeded:case j.CreateConsignmentsSucceeded:case j.DeleteConsignmentSucceeded:case j.UpdateConsignmentSucceeded:case j.UpdateShippingOptionSucceeded:case j.LoadShippingOptionsSucceeded:case V.ApplyCouponSucceeded:case V.RemoveCouponSucceeded:case H.ApplyGiftCertificateSucceeded:case H.RemoveGiftCertificateSucceeded:return G(e,t.payload&&t.payload.cart);default:return e}}function Q(e,t){switch(void 0===e&&(e=W.statuses),t.type){case P.LoadCheckoutRequested:return N(e,"isLoading",!0);case P.LoadCheckoutFailed:case P.LoadCheckoutSucceeded:return N(e,"isLoading",!1);default:return e}}function J(e,t){switch(void 0===e&&(e=W.errors),t.type){case P.LoadCheckoutRequested:case P.LoadCheckoutSucceeded:return N(e,"loadError",void 0);case P.LoadCheckoutFailed:return N(e,"loadError",t.payload);default:return e}}!function(e){e.InitializeButtonFailed="INITIALIZE_BUTTON_FAILED",e.InitializeButtonRequested="INITIALIZE_BUTTON_REQUESTED",e.InitializeButtonSucceeded="INITIALIZE_BUTTON_SUCCEEDED",e.DeinitializeButtonFailed="DEINITIALIZE_BUTTON_FAILED",e.DeinitializeButtonRequested="DEINITIALIZE_BUTTON_REQUESTED",e.DeinitializeButtonSucceeded="DEINITIALIZE_BUTTON_SUCCEEDED"}(Y||(Y={}));var X,$={data:{},errors:{},statuses:{}},ee={initializedContainers:{}},te={},ne={};function re(e,t){var n,r,i;return void 0===e&&(e=$),t.meta&&t.meta.methodId?(0,a.combineReducers)({data:(0,a.combineReducers)((n={},n[t.meta.methodId]=ie,n)),errors:(0,a.combineReducers)((r={},r[t.meta.methodId]=oe,r)),statuses:(0,a.combineReducers)((i={},i[t.meta.methodId]=ae,i))})(e,t):e}function ie(e,t){var n;switch(void 0===e&&(e=ee),t.type){case Y.InitializeButtonSucceeded:return t.meta&&t.meta.containerId?G(e,{initializedContainers:(n={},n[t.meta.containerId]=!0,n)}):e;case Y.DeinitializeButtonSucceeded:return N(e,"initializedContainers",{})}return e}function oe(e,t){switch(void 0===e&&(e=te),t.type){case Y.InitializeButtonRequested:case Y.InitializeButtonSucceeded:return N(e,"initializeError",void 0);case Y.InitializeButtonFailed:return N(e,"initializeError",t.payload);case Y.DeinitializeButtonRequested:case Y.DeinitializeButtonSucceeded:return N(e,"deinitializeError",void 0);case Y.DeinitializeButtonFailed:return N(e,"deinitializeError",t.payload);default:return e}}function ae(e,t){switch(void 0===e&&(e=ne),t.type){case Y.InitializeButtonRequested:return N(e,"isInitializing",!0);case Y.InitializeButtonFailed:case Y.InitializeButtonSucceeded:return N(e,"isInitializing",!1);case Y.DeinitializeButtonRequested:return N(e,"isDeinitializing",!0);case Y.DeinitializeButtonFailed:case Y.DeinitializeButtonSucceeded:return N(e,"isDeinitializing",!1);default:return e}}!function(e){e.LoadConfigRequested="LOAD_CONFIG_REQUESTED",e.LoadConfigSucceeded="LOAD_CONFIG_SUCCEEDED",e.LoadConfigFailed="LOAD_CONFIG_FAILED"}(X||(X={}));var se,ue={meta:{},errors:{},statuses:{}};function ce(e,t){return void 0===e&&(e=ue),(0,a.combineReducers)({data:de,errors:(0,a.composeReducers)(le,k),statuses:pe})(e,t)}function de(e,t){return t.type===X.LoadConfigSucceeded?G(e,t.payload):e}function le(e,t){switch(void 0===e&&(e=ue.errors),t.type){case X.LoadConfigSucceeded:return N(e,"loadError",void 0);case X.LoadConfigFailed:return N(e,"loadError",t.payload);default:return e}}function pe(e,t){switch(void 0===e&&(e=ue.statuses),t.type){case X.LoadConfigRequested:return N(e,"isLoading",!0);case X.LoadConfigSucceeded:case X.LoadConfigFailed:return N(e,"isLoading",!1);default:return e}}!function(e){e.LoadOrderRequested="LOAD_ORDER_REQUESTED",e.LoadOrderSucceeded="LOAD_ORDER_SUCCEEDED",e.LoadOrderFailed="LOAD_ORDER_FAILED",e.LoadOrderPaymentsRequested="LOAD_ORDER_PAYMENTS_REQUESTED",e.LoadOrderPaymentsSucceeded="LOAD_ORDER_PAYMENTS_SUCCEEDED",e.LoadOrderPaymentsFailed="LOAD_ORDER_PAYMENTS_FAILED",e.SubmitOrderRequested="SUBMIT_ORDER_REQUESTED",e.SubmitOrderSucceeded="SUBMIT_ORDER_SUCCEEDED",e.SubmitOrderFailed="SUBMIT_ORDER_FAILED",e.FinalizeOrderRequested="FINALIZE_ORDER_REQUESTED",e.FinalizeOrderSucceeded="FINALIZE_ORDER_SUCCEEDED",e.FinalizeOrderFailed="FINALIZE_ORDER_FAILED"}(se||(se={}));var he={errors:{},statuses:{}};function fe(e,t){return void 0===e&&(e=he),(0,a.combineReducers)({data:ge,errors:(0,a.composeReducers)(me,k),statuses:_e})(e,t)}function ge(e,t){switch(t.type){case P.LoadCheckoutSucceeded:case V.ApplyCouponSucceeded:case j.UpdateShippingOptionSucceeded:case V.RemoveCouponSucceeded:case se.LoadOrderSucceeded:return x(e,t.payload&&t.payload.coupons);default:return e}}function me(e,t){switch(void 0===e&&(e={}),t.type){case V.ApplyCouponRequested:case V.ApplyCouponSucceeded:return N(e,"applyCouponError",void 0);case V.ApplyCouponFailed:return N(e,"applyCouponError",t.payload);case V.RemoveCouponRequested:case V.RemoveCouponSucceeded:return N(e,"removeCouponError",void 0);case V.RemoveCouponFailed:return N(e,"removeCouponError",t.payload);default:return e}}function _e(e,t){switch(void 0===e&&(e={}),t.type){case V.ApplyCouponRequested:return N(e,"isApplyingCoupon",!0);case V.ApplyCouponSucceeded:case V.ApplyCouponFailed:return N(e,"isApplyingCoupon",!1);case V.RemoveCouponRequested:return N(e,"isRemovingCoupon",!0);case V.RemoveCouponSucceeded:case V.RemoveCouponFailed:return N(e,"isRemovingCoupon",!1);default:return e}}var ye,ve={errors:{},statuses:{}};function Ce(e,t){return void 0===e&&(e=ve),(0,a.combineReducers)({data:Se,errors:(0,a.composeReducers)(Ie,k),statuses:we})(e,t)}function Se(e,t){switch(t.type){case P.LoadCheckoutSucceeded:case j.CreateConsignmentsSucceeded:case j.UpdateConsignmentSucceeded:case j.DeleteConsignmentSucceeded:case j.UpdateShippingOptionSucceeded:case V.ApplyCouponSucceeded:case V.RemoveCouponSucceeded:case H.ApplyGiftCertificateSucceeded:case H.RemoveGiftCertificateSucceeded:return x(e,t.payload&&t.payload.giftCertificates);default:return e}}function Ie(e,t){switch(void 0===e&&(e=ve.errors),t.type){case H.ApplyGiftCertificateRequested:case H.ApplyGiftCertificateSucceeded:return N(e,"applyGiftCertificateError",void 0);case H.ApplyGiftCertificateFailed:return N(e,"applyGiftCertificateError",t.payload);case H.RemoveGiftCertificateRequested:case H.RemoveGiftCertificateSucceeded:return N(e,"removeGiftCertificateError",void 0);case H.RemoveGiftCertificateFailed:return N(e,"removeGiftCertificateError",t.payload);default:return e}}function we(e,t){switch(void 0===e&&(e=ve.statuses),t.type){case H.ApplyGiftCertificateRequested:return N(e,"isApplyingGiftCertificate",!0);case H.ApplyGiftCertificateSucceeded:case H.ApplyGiftCertificateFailed:return N(e,"isApplyingGiftCertificate",!1);case H.RemoveGiftCertificateRequested:return N(e,"isRemovingGiftCertificate",!0);case H.RemoveGiftCertificateSucceeded:case H.RemoveGiftCertificateFailed:return N(e,"isRemovingGiftCertificate",!1);default:return e}}!function(e){e.SignInCustomerRequested="SIGN_IN_CUSTOMER_REQUESTED",e.SignInCustomerSucceeded="SIGN_IN_CUSTOMER_SUCCEEDED",e.SignInCustomerFailed="SIGN_IN_CUSTOMER_FAILED",e.SignOutCustomerRequested="SIGN_OUT_CUSTOMER_REQUESTED",e.SignOutCustomerSucceeded="SIGN_OUT_CUSTOMER_SUCCEEDED",e.SignOutCustomerFailed="SIGN_OUT_CUSTOMER_FAILED",e.CreateCustomerRequested="CREATE_CUSTOMER_REQUESTED",e.CreateCustomerSucceeded="CREATE_CUSTOMER_SUCCEEDED",e.CreateCustomerFailed="CREATE_CUSTOMER_FAILED",e.CreateCustomerAddressRequested="CREATE_CUSTOMER_ADDRESS_REQUESTED",e.CreateCustomerAddressSucceeded="CREATE_CUSTOMER_ADDRESS_SUCCEEDED",e.CreateCustomerAddressFailed="CREATE_CUSTOMER_ADDRESS_FAILED",e.StripeLinkAuthenticated="STRIPE_LINK_AUTHENTICATED"}(ye||(ye={}));var Ee,be={errors:{},statuses:{}};function Pe(e,t){return void 0===e&&(e=be),(0,a.combineReducers)({data:Ae,errors:(0,a.composeReducers)(Oe,k),statuses:Te})(e,t)}function Ae(e,t){switch(t.type){case T.ContinueAsGuestSucceeded:case P.LoadCheckoutSucceeded:return G(e,t.payload&&t.payload.customer);case ye.CreateCustomerAddressSucceeded:return G(e,t.payload);default:return e}}function Oe(e,t){switch(void 0===e&&(e=be.errors),t.type){case ye.CreateCustomerRequested:case ye.CreateCustomerSucceeded:return N(e,"createError",void 0);case ye.CreateCustomerFailed:return N(e,"createError",t.payload);case ye.CreateCustomerAddressRequested:case ye.CreateCustomerAddressSucceeded:return N(e,"createAddressError",void 0);case ye.CreateCustomerAddressFailed:return N(e,"createAddressError",t.payload);default:return e}}function Te(e,t){switch(void 0===e&&(e=be.statuses),t.type){case ye.CreateCustomerRequested:return N(e,"isCreating",!0);case ye.CreateCustomerFailed:case ye.CreateCustomerSucceeded:return N(e,"isCreating",!1);case ye.CreateCustomerAddressRequested:return N(e,"isCreatingAddress",!0);case ye.CreateCustomerAddressFailed:case ye.CreateCustomerAddressSucceeded:return N(e,"isCreatingAddress",!1);default:return e}}!function(e){e.SignInFailed="CUSTOMER_STRATEGY_SIGN_IN_FAILED",e.SignInRequested="CUSTOMER_STRATEGY_SIGN_IN_REQUESTED",e.SignInSucceeded="CUSTOMER_STRATEGY_SIGN_IN_SUCCEEDED",e.SignOutFailed="CUSTOMER_STRATEGY_SIGN_OUT_FAILED",e.SignOutRequested="CUSTOMER_STRATEGY_SIGN_OUT_REQUESTED",e.SignOutSucceeded="CUSTOMER_STRATEGY_SIGN_OUT_SUCCEEDED",e.ExecutePaymentMethodCheckoutFailed="CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_FAILED",e.ExecutePaymentMethodCheckoutRequested="CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_REQUESTED",e.ExecutePaymentMethodCheckoutSucceeded="CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_SUCCEEDED",e.InitializeFailed="CUSTOMER_STRATEGY_INITIALIZE_FAILED",e.InitializeRequested="CUSTOMER_STRATEGY_INITIALIZE_REQUESTED",e.InitializeSucceeded="CUSTOMER_STRATEGY_INITIALIZE_SUCCEEDED",e.DeinitializeFailed="CUSTOMER_STRATEGY_DEINITIALIZE_FAILED",e.DeinitializeRequested="CUSTOMER_STRATEGY_DEINITIALIZE_REQUESTED",e.DeinitializeSucceeded="CUSTOMER_STRATEGY_DEINITIALIZE_SUCCEEDED",e.WidgetInteractionStarted="CUSTOMER_STRATEGY_WIDGET_INTERACTION_STARTED",e.WidgetInteractionFinished="CUSTOMER_STRATEGY_WIDGET_INTERACTION_FINISHED",e.WidgetInteractionFailed="CUSTOMER_STRATEGY_WIDGET_INTERACTION_FAILED"}(Ee||(Ee={}));var Re,ke={data:{},errors:{},statuses:{}};function De(e,t){return void 0===e&&(e=ke),(0,a.combineReducers)({data:Me,errors:(0,a.composeReducers)(Ne,k),statuses:Le})(e,t)}function Me(e,t){var n,r;switch(void 0===e&&(e=ke.data),t.type){case Ee.InitializeSucceeded:return G(e,((n={})[t.meta&&t.meta.methodId]={isInitialized:!0},n));case Ee.DeinitializeSucceeded:return G(e,((r={})[t.meta&&t.meta.methodId]={isInitialized:!1},r))}return e}function Ne(e,t){var n;switch(void 0===e&&(e=ke.errors),t.type){case Ee.InitializeRequested:case Ee.InitializeSucceeded:return G(e,{initializeErrors:(0,o.__assign)({},e.initializeErrors),initializeMethodId:e.initializeMethodId?e.initializeMethodId:void 0});case Ee.InitializeFailed:return G(e,{initializeErrors:(0,o.__assign)((0,o.__assign)({},e.initializeErrors),(n={},n[t.meta&&t.meta.methodId]=t.payload,n)),initializeMethodId:t.meta&&t.meta.methodId});case Ee.DeinitializeRequested:case Ee.DeinitializeSucceeded:return G(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case Ee.DeinitializeFailed:return G(e,{deinitializeError:t.payload,deinitializeMethodId:t.meta&&t.meta.methodId});case Ee.SignInRequested:case Ee.SignInSucceeded:return G(e,{signInError:void 0,signInMethodId:void 0});case Ee.SignInFailed:return G(e,{signInError:t.payload,signInMethodId:t.meta&&t.meta.methodId});case Ee.SignOutRequested:case Ee.SignOutSucceeded:return G(e,{signOutError:void 0,signOutMethodId:void 0});case Ee.SignOutFailed:return G(e,{signOutError:t.payload,signOutMethodId:t.meta&&t.meta.methodId});case Ee.ExecutePaymentMethodCheckoutRequested:case Ee.ExecutePaymentMethodCheckoutSucceeded:return G(e,{executePaymentMethodCheckoutError:void 0,executePaymentMethodCheckoutMethodId:void 0});case Ee.ExecutePaymentMethodCheckoutFailed:return G(e,{executePaymentMethodCheckoutError:t.payload,executePaymentMethodCheckoutMethodId:t.meta&&t.meta.methodId});case Ee.WidgetInteractionStarted:case Ee.WidgetInteractionFinished:return G(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case Ee.WidgetInteractionFailed:return G(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta.methodId});default:return e}}function Le(e,t){switch(void 0===e&&(e=ke.statuses),t.type){case Ee.InitializeRequested:return G(e,{isInitializing:!0,initializeMethodId:t.meta&&t.meta.methodId});case Ee.InitializeFailed:case Ee.InitializeSucceeded:return G(e,{isInitializing:!1,initializeMethodId:void 0});case Ee.DeinitializeRequested:return G(e,{isDeinitializing:!0,deinitializeMethodId:t.meta&&t.meta.methodId});case Ee.DeinitializeFailed:case Ee.DeinitializeSucceeded:return G(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case Ee.SignInRequested:return G(e,{isSigningIn:!0,signInMethodId:t.meta&&t.meta.methodId});case Ee.SignInFailed:case Ee.SignInSucceeded:return G(e,{isSigningIn:!1,signInMethodId:void 0});case Ee.SignOutRequested:return G(e,{isSigningOut:!0,signOutMethodId:t.meta&&t.meta.methodId});case Ee.SignOutFailed:case Ee.SignOutSucceeded:return G(e,{isSigningOut:!1,signOutMethodId:void 0});case Ee.ExecutePaymentMethodCheckoutRequested:return G(e,{isExecutingPaymentMethodCheckout:!0,executePaymentMethodCheckoutMethodId:t.meta&&t.meta.methodId});case Ee.ExecutePaymentMethodCheckoutFailed:case Ee.ExecutePaymentMethodCheckoutSucceeded:return G(e,{isExecutingPaymentMethodCheckout:!1,executePaymentMethodCheckoutMethodId:void 0});case Ee.WidgetInteractionStarted:return G(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta.methodId});case Ee.WidgetInteractionFinished:case Ee.WidgetInteractionFailed:return G(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}!function(e){e.LoadExtensionsRequested="LOAD_EXTENSIONS_REQUESTED",e.LoadExtensionsSucceeded="LOAD_EXTENSIONS_SUCCEEDED",e.LoadExtensionsFailed="LOAD_EXTENSIONS_FAILED",e.RenderExtensionRequested="RENDER_EXTENSION_REQUESTED",e.RenderExtensionSucceeded="RENDER_EXTENSION_SUCCEEDED",e.RenderExtensionFailed="RENDER_EXTENSION_FAILED"}(Re||(Re={}));var ze,Ue={errors:{},statuses:{}};function Fe(e,t){return void 0===e&&(e=Ue),(0,a.combineReducers)({data:Be,errors:(0,a.composeReducers)(qe,k),statuses:xe})(e,t)}function Be(e,t){return t.type===Re.LoadExtensionsSucceeded?x(e,t.payload):e}function qe(e,t){switch(void 0===e&&(e=Ue.errors),t.type){case Re.LoadExtensionsRequested:case Re.LoadExtensionsSucceeded:return N(e,"loadError",void 0);case Re.RenderExtensionRequested:case Re.RenderExtensionSucceeded:return N(e,"renderError",void 0);case Re.LoadExtensionsFailed:return N(e,"loadError",t.payload);case Re.RenderExtensionFailed:return N(e,"renderError",t.payload);default:return e}}function xe(e,t){switch(void 0===e&&(e=Ue.statuses),t.type){case Re.LoadExtensionsRequested:return N(e,"isLoading",!0);case Re.LoadExtensionsSucceeded:case Re.LoadExtensionsFailed:return N(e,"isLoading",!1);default:return e}}!function(e){e.LoadFormFieldsRequested="LOAD_FORM_FIELDS_REQUESTED",e.LoadFormFieldsSucceeded="LOAD_FORM_FIELDS_SUCCEEDED",e.LoadFormFieldsFailed="LOAD_FORM_FIELDS_FAILED"}(ze||(ze={}));var Ge,Ve={errors:{},statuses:{}};function He(e,t){return void 0===e&&(e=Ve),(0,a.combineReducers)({data:je,errors:(0,a.composeReducers)(Ye,k),statuses:We})(e,t)}function je(e,t){return t.type===ze.LoadFormFieldsSucceeded?G(e,t.payload):e}function Ye(e,t){switch(void 0===e&&(e=Ve.errors),t.type){case ze.LoadFormFieldsSucceeded:return N(e,"loadError",void 0);case ze.LoadFormFieldsFailed:return N(e,"loadError",t.payload);default:return e}}function We(e,t){switch(void 0===e&&(e=Ve.statuses),t.type){case ze.LoadFormFieldsRequested:return N(e,"isLoading",!0);case ze.LoadFormFieldsSucceeded:case ze.LoadFormFieldsFailed:return N(e,"isLoading",!1);default:return e}}!function(e){e.LoadCountriesRequested="LOAD_COUNTRIES_REQUESTED",e.LoadCountriesSucceeded="LOAD_COUNTRIES_SUCCEEDED",e.LoadCountriesFailed="LOAD_COUNTRIES_FAILED"}(Ge||(Ge={}));var Ke={errors:{},statuses:{}};function Ze(e,t){return void 0===e&&(e=Ke),(0,a.combineReducers)({data:Qe,errors:(0,a.composeReducers)(Je,k),statuses:Xe})(e,t)}function Qe(e,t){return t.type===Ge.LoadCountriesSucceeded?x(e,t.payload):e}function Je(e,t){switch(void 0===e&&(e=Ke.errors),t.type){case Ge.LoadCountriesRequested:case Ge.LoadCountriesSucceeded:return N(e,"loadError",void 0);case Ge.LoadCountriesFailed:return N(e,"loadError",t.payload);default:return e}}function Xe(e,t){switch(void 0===e&&(e=Ke.statuses),t.type){case Ge.LoadCountriesRequested:return N(e,"isLoading",!0);case Ge.LoadCountriesSucceeded:case Ge.LoadCountriesFailed:return N(e,"isLoading",!1);default:return e}}var $e={errors:{},meta:{},statuses:{}};function et(e,t){return void 0===e&&(e=$e),(0,a.combineReducers)({data:tt,errors:(0,a.composeReducers)(rt,k),meta:nt,statuses:it})(e,t)}function tt(e,t){switch(t.type){case se.LoadOrderSucceeded:case se.LoadOrderPaymentsSucceeded:return G(e,(0,_.omit)(t.payload,["billingAddress","coupons"]));default:return e}}function nt(e,t){switch(t.type){case se.FinalizeOrderSucceeded:case se.SubmitOrderSucceeded:return G(e,(0,o.__assign)((0,o.__assign)({},t.meta),{callbackUrl:t.payload&&t.payload.order.callbackUrl,orderToken:t.payload&&t.payload.order.token,payment:t.payload&&t.payload.order&&t.payload.order.payment}));default:return e}}function rt(e,t){switch(void 0===e&&(e=$e.errors),t.type){case se.LoadOrderRequested:case se.LoadOrderSucceeded:case se.LoadOrderPaymentsSucceeded:case se.LoadOrderPaymentsRequested:return N(e,"loadError",void 0);case se.LoadOrderFailed:case se.LoadOrderPaymentsFailed:return N(e,"loadError",t.payload);default:return e}}function it(e,t){switch(void 0===e&&(e=$e.statuses),t.type){case se.LoadOrderRequested:case se.LoadOrderPaymentsRequested:return N(e,"isLoading",!0);case se.LoadOrderSucceeded:case se.LoadOrderFailed:case se.LoadOrderPaymentsSucceeded:case se.LoadOrderPaymentsFailed:return N(e,"isLoading",!1);default:return e}}var ot,at,st={};function ut(e,t){return void 0===e&&(e=st),(0,a.combineReducers)({data:ct})(e,t)}function ct(e,t){switch(t.type){case se.LoadOrderPaymentsSucceeded:case se.LoadOrderSucceeded:return M(e,t.payload&&t.payload.billingAddress);default:return e}}function dt(e,t){return void 0===e&&(e={}),(0,a.combineReducers)({data:lt})(e,t)}function lt(e,t){return t.type===ot.SubmitPaymentSucceeded?t.payload:e}!function(e){e.SubmitPaymentRequested="SUBMIT_PAYMENT_REQUESTED",e.SubmitPaymentSucceeded="SUBMIT_PAYMENT_SUCCEEDED",e.SubmitPaymentFailed="SUBMIT_PAYMENT_FAILED",e.InitializeOffsitePaymentRequested="INITIALIZE_OFFSITE_PAYMENT_REQUESTED",e.InitializeOffsitePaymentSucceeded="INITIALIZE_OFFSITE_PAYMENT_SUCCEEDED",e.InitializeOffsitePaymentFailed="INITIALIZE_OFFSITE_PAYMENT_FAILED"}(ot||(ot={})),function(e){e.LoadPaymentMethodRequested="LOAD_PAYMENT_METHOD_REQUESTED",e.LoadPaymentMethodSucceeded="LOAD_PAYMENT_METHOD_SUCCEEDED",e.LoadPaymentMethodFailed="LOAD_PAYMENT_METHOD_FAILED",e.LoadPaymentMethodsRequested="LOAD_PAYMENT_METHODS_REQUESTED",e.LoadPaymentMethodsSucceeded="LOAD_PAYMENT_METHODS_SUCCEEDED",e.LoadPaymentMethodsFailed="LOAD_PAYMENT_METHODS_FAILED"}(at||(at={}));var pt,ht={errors:{},statuses:{}};function ft(e,t){return void 0===e&&(e=ht),(0,a.combineReducers)({data:gt,errors:(0,a.composeReducers)(_t,k),meta:mt,statuses:yt})(e,t)}function gt(e,t){switch(t.type){case at.LoadPaymentMethodSucceeded:return function(e,t,n){if(!t)return e;var r=(0,_.pick)(t,"id"),i=(0,_.findIndex)(e,"object"==typeof n?(0,_.pickBy)(n):n||r),a=(0,o.__spreadArrays)(e);if(-1===i)a.push(t);else{var s=e[i];a[i]=q(s)&&q(t)?G(s,t):t}return a}(e||[],t.payload,t.payload&&{id:t.payload.id,gateway:t.payload.gateway});case at.LoadPaymentMethodsSucceeded:return x(e,t.payload,{matchObject:function(e,t){return e.id===t.id&&e.gateway===t.gateway}});default:return e}}function mt(e,t){return t.type===at.LoadPaymentMethodsSucceeded?G(e,t.meta):e}function _t(e,t){switch(void 0===e&&(e=ht.errors),t.type){case at.LoadPaymentMethodsRequested:case at.LoadPaymentMethodsSucceeded:return N(e,"loadError",void 0);case at.LoadPaymentMethodsFailed:return N(e,"loadError",t.payload);case at.LoadPaymentMethodRequested:case at.LoadPaymentMethodSucceeded:return G(e,{loadMethodId:void 0,loadMethodError:void 0});case at.LoadPaymentMethodFailed:return G(e,{loadMethodId:t.meta.methodId,loadMethodError:t.payload});default:return e}}function yt(e,t){switch(void 0===e&&(e=ht.statuses),t.type){case at.LoadPaymentMethodsRequested:return N(e,"isLoading",!0);case at.LoadPaymentMethodsSucceeded:case at.LoadPaymentMethodsFailed:return N(e,"isLoading",!1);case at.LoadPaymentMethodRequested:return G(e,{isLoadingMethod:!0,loadMethodId:t.meta.methodId});case at.LoadPaymentMethodSucceeded:case at.LoadPaymentMethodFailed:return G(e,{isLoadingMethod:!1,loadMethodId:void 0});default:return e}}!function(e){e.ExecuteFailed="PAYMENT_STRATEGY_EXECUTE_FAILED",e.ExecuteRequested="PAYMENT_STRATEGY_EXECUTE_REQUESTED",e.ExecuteSucceeded="PAYMENT_STRATEGY_EXECUTE_SUCCEEDED",e.FinalizeFailed="PAYMENT_STRATEGY_FINALIZE_FAILED",e.FinalizeRequested="PAYMENT_STRATEGY_FINALIZE_REQUESTED",e.FinalizeSucceeded="PAYMENT_STRATEGY_FINALIZE_SUCCEEDED",e.InitializeFailed="PAYMENT_STRATEGY_INITIALIZE_FAILED",e.InitializeRequested="PAYMENT_STRATEGY_INITIALIZE_REQUESTED",e.InitializeSucceeded="PAYMENT_STRATEGY_INITIALIZE_SUCCEEDED",e.DeinitializeFailed="PAYMENT_STRATEGY_DEINITIALIZE_FAILED",e.DeinitializeRequested="PAYMENT_STRATEGY_DEINITIALIZE_REQUESTED",e.DeinitializeSucceeded="PAYMENT_STRATEGY_DEINITIALIZE_SUCCEEDED",e.WidgetInteractionStarted="PAYMENT_STRATEGY_WIDGET_INTERACTION_STARTED",e.WidgetInteractionFinished="PAYMENT_STRATEGY_WIDGET_INTERACTION_FINISHED",e.WidgetInteractionFailed="PAYMENT_STRATEGY_WIDGET_INTERACTION_FAILED"}(pt||(pt={}));var vt,Ct={data:{},errors:{},statuses:{}};function St(e,t){return void 0===e&&(e=Ct),(0,a.combineReducers)({data:It,errors:(0,a.composeReducers)(wt,k),statuses:Et})(e,t)}function It(e,t){var n,r;switch(void 0===e&&(e=Ct.data),t.type){case pt.InitializeSucceeded:if(t.meta){var i=t.meta,o=i.methodId,a=i.gatewayId;return G(e,((n={})[a?o+"."+a:o]={isInitialized:!0},n))}break;case pt.DeinitializeSucceeded:if(t.meta){var s=t.meta;return o=s.methodId,a=s.gatewayId,G(e,((r={})[a?o+"."+a:o]={isInitialized:!1},r))}}return e}function wt(e,t){switch(void 0===e&&(e=Ct.errors),t.type){case pt.InitializeRequested:case pt.InitializeSucceeded:return G(e,{initializeError:void 0,initializeMethodId:void 0});case pt.InitializeFailed:var n=t.meta&&t.meta.methodId;if(t.meta){var r=t.meta,i=r.methodId;n=(a=r.gatewayId)?i+"."+a:i}return G(e,{initializeError:t.payload,initializeMethodId:n});case pt.DeinitializeRequested:case pt.DeinitializeSucceeded:return G(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case pt.DeinitializeFailed:var o=t.meta&&t.meta.methodId;if(t.meta){var a,s=t.meta;i=s.methodId,o=(a=s.gatewayId)?i+"."+a:i}return G(e,{deinitializeError:t.payload,deinitializeMethodId:o});case pt.ExecuteRequested:case pt.ExecuteSucceeded:return G(e,{executeError:void 0,executeMethodId:void 0});case pt.ExecuteFailed:return G(e,{executeError:t.payload,executeMethodId:t.meta&&t.meta.methodId});case pt.FinalizeRequested:case pt.FinalizeSucceeded:return G(e,{finalizeError:void 0,finalizeMethodId:void 0});case pt.FinalizeFailed:return G(e,{finalizeError:t.payload,finalizeMethodId:t.meta&&t.meta.methodId});case pt.WidgetInteractionStarted:case pt.WidgetInteractionFinished:return G(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case pt.WidgetInteractionFailed:return G(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta.methodId});default:return e}}function Et(e,t){switch(void 0===e&&(e=Ct.statuses),t.type){case pt.InitializeRequested:var n=t.meta&&t.meta.methodId;if(t.meta){var r=t.meta,i=r.methodId;n=(a=r.gatewayId)?i+"."+a:i}return G(e,{isInitializing:!0,initializeMethodId:n});case pt.InitializeFailed:case pt.InitializeSucceeded:return G(e,{isInitializing:!1,initializeMethodId:void 0});case pt.DeinitializeRequested:var o=t.meta&&t.meta.methodId;if(t.meta){var a,s=t.meta;i=s.methodId,o=(a=s.gatewayId)?i+"."+a:i}return G(e,{isDeinitializing:!0,deinitializeMethodId:o});case pt.DeinitializeFailed:case pt.DeinitializeSucceeded:return G(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case pt.ExecuteRequested:return G(e,{isExecuting:!0,executeMethodId:t.meta&&t.meta.methodId});case pt.ExecuteFailed:case pt.ExecuteSucceeded:return G(e,{isExecuting:!1,executeMethodId:void 0});case pt.FinalizeRequested:return G(e,{isFinalizing:!0,finalizeMethodId:t.meta&&t.meta.methodId});case pt.FinalizeFailed:case pt.FinalizeSucceeded:return G(e,{isFinalizing:!1,finalizeMethodId:void 0});case pt.WidgetInteractionStarted:return G(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta.methodId});case pt.WidgetInteractionFinished:case pt.WidgetInteractionFailed:return G(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}!function(e){e.UpdatePaymentProviderCustomer="UPDATE_PAYMENT_PROVIDER_CUSTOMER"}(vt||(vt={}));var bt,Pt={data:{}};function At(e,t){return void 0===e&&(e=Pt),(0,a.combineReducers)({data:Ot})(e,t)}function Ot(e,t){return void 0===e&&(e=Pt.data),t.type===vt.UpdatePaymentProviderCustomer?G(e,t.payload):e}!function(e){e.LoadInstrumentsRequested="LOAD_INSTRUMENTS_REQUESTED",e.LoadInstrumentsSucceeded="LOAD_INSTRUMENTS_SUCCEEDED",e.LoadInstrumentsFailed="LOAD_INSTRUMENTS_FAILED",e.DeleteInstrumentRequested="DELETE_INSTRUMENT_REQUESTED",e.DeleteInstrumentSucceeded="DELETE_INSTRUMENT_SUCCEEDED",e.DeleteInstrumentFailed="DELETE_INSTRUMENT_FAILED"}(bt||(bt={}));var Tt,Rt={data:[],errors:{},statuses:{}};function kt(e,t){return void 0===e&&(e=Rt),(0,a.combineReducers)({data:Dt,errors:(0,a.composeReducers)(Nt,k),meta:Mt,statuses:Lt})(e,t)}function Dt(e,t){return void 0===e&&(e=Rt.data),t.type===bt.LoadInstrumentsSucceeded?x(e,t.payload&&t.payload.vaultedInstruments||[]):e}function Mt(e,t){switch(t.type){case bt.LoadInstrumentsSucceeded:case bt.DeleteInstrumentSucceeded:return G(e,t.meta);default:return e}}function Nt(e,t){switch(void 0===e&&(e=Rt.errors),t.type){case bt.LoadInstrumentsRequested:case bt.LoadInstrumentsSucceeded:return N(e,"loadError",void 0);case bt.DeleteInstrumentRequested:case bt.DeleteInstrumentSucceeded:return G(e,{deleteError:void 0,failedInstrument:void 0});case bt.LoadInstrumentsFailed:return N(e,"loadError",t.payload);case bt.DeleteInstrumentFailed:return G(e,{deleteError:t.payload,failedInstrument:t.meta.instrumentId});default:return e}}function Lt(e,t){switch(void 0===e&&(e=Rt.statuses),t.type){case bt.LoadInstrumentsRequested:return N(e,"isLoading",!0);case bt.DeleteInstrumentRequested:return G(e,{isDeleting:!0,deletingInstrument:t.meta.instrumentId});case bt.LoadInstrumentsSucceeded:case bt.LoadInstrumentsFailed:return N(e,"isLoading",!1);case bt.DeleteInstrumentSucceeded:case bt.DeleteInstrumentFailed:return G(e,{isDeleting:!1,deletingInstrument:void 0});default:return e}}!function(e){e.ForgetCheckoutRemoteCustomerRequested="FORGET_CHECKOUT_REMOTE_CUSTOMER_REQUESTED",e.ForgetCheckoutRemoteCustomerSucceeded="FORGET_CHECKOUT_REMOTE_CUSTOMER_SUCCEEDED",e.ForgetCheckoutRemoteCustomerFailed="FORGET_CHECKOUT_REMOTE_CUSTOMER_FAILED",e.InitializeRemoteBillingRequested="INITIALIZE_REMOTE_BILLING_REQUESTED",e.InitializeRemoteBillingSucceeded="INITIALIZE_REMOTE_BILLING_SUCCEEDED",e.InitializeRemoteBillingFailed="INITIALIZE_REMOTE_BILLING_FAILED",e.InitializeRemoteShippingRequested="INITIALIZE_REMOTE_SHIPPING_REQUESTED",e.InitializeRemoteShippingSucceeded="INITIALIZE_REMOTE_SHIPPING_SUCCEEDED",e.InitializeRemoteShippingFailed="INITIALIZE_REMOTE_SHIPPING_FAILED",e.InitializeRemotePaymentRequested="INITIALIZE_REMOTE_PAYMENT_REQUESTED",e.InitializeRemotePaymentSucceeded="INITIALIZE_REMOTE_PAYMENT_SUCCEEDED",e.InitializeRemotePaymentFailed="INITIALIZE_REMOTE_PAYMENT_FAILED",e.LoadRemoteSettingsRequested="LOAD_REMOTE_SETTINGS_REQUESTED",e.LoadRemoteSettingsSucceeded="LOAD_REMOTE_SETTINGS_SUCCEEDED",e.LoadRemoteSettingsFailed="LOAD_REMOTE_SETTINGS_FAILED",e.SignOutRemoteCustomerRequested="SIGN_OUT_REMOTE_CUSTOMER_REQUESTED",e.SignOutRemoteCustomerSucceeded="SIGN_OUT_REMOTE_CUSTOMER_SUCCEEDED",e.SignOutRemoteCustomerFailed="SIGN_OUT_REMOTE_CUSTOMER_FAILED",e.UpdateRemoteCheckout="UPDATE_REMOTE_CHECKOUT"}(Tt||(Tt={}));var zt={data:{}};function Ut(e,t){var n;return void 0===e&&(e=zt),t.meta&&t.meta.methodId?(0,a.combineReducers)({data:(0,a.combineReducers)((n={},n[t.meta.methodId]=Ft,n))})(e,t):e}function Ft(e,t){switch(t.type){case Tt.InitializeRemoteBillingSucceeded:return N(e,"billing",t.payload&&t.payload.billing);case Tt.InitializeRemoteShippingSucceeded:return N(e,"shipping",t.payload&&t.payload.shipping);case Tt.LoadRemoteSettingsSucceeded:return N(e,"settings",t.payload);case Tt.UpdateRemoteCheckout:return G(e,t.payload);default:return e}}var Bt,qt={errors:{updateShippingOptionError:{},updateError:{},deleteError:{}},statuses:{isUpdating:{},isUpdatingShippingOption:{},isDeleting:{}}};function xt(e,t){return void 0===e&&(e=qt),(0,a.combineReducers)({data:Gt,errors:(0,a.composeReducers)(Vt,k),statuses:Ht})(e,t)}function Gt(e,t){switch(t.type){case P.LoadCheckoutSucceeded:case j.LoadShippingOptionsSucceeded:case j.CreateConsignmentsSucceeded:case j.UpdateConsignmentSucceeded:case j.DeleteConsignmentSucceeded:case j.UpdateShippingOptionSucceeded:case V.ApplyCouponSucceeded:case V.RemoveCouponSucceeded:return x(e,t.payload&&t.payload.consignments);case ye.SignOutCustomerSucceeded:return x(e,[]);default:return e}}function Vt(e,t){var n,r,i,o,a,s;switch(void 0===e&&(e=qt.errors),t.type){case P.LoadCheckoutRequested:case P.LoadCheckoutSucceeded:case j.LoadShippingOptionsSucceeded:case j.LoadShippingOptionsRequested:return N(e,"loadError",void 0);case P.LoadCheckoutFailed:case j.LoadShippingOptionsFailed:return N(e,"loadError",t.payload);case j.CreateConsignmentsRequested:case j.CreateConsignmentsSucceeded:return N(e,"createError",void 0);case j.CreateConsignmentsFailed:return N(e,"createError",t.payload);case j.UpdateConsignmentSucceeded:case j.UpdateConsignmentRequested:return t.meta?G(e,{updateError:(n={},n[t.meta.id]=void 0,n)}):e;case j.UpdateConsignmentFailed:return t.meta?G(e,{updateError:(r={},r[t.meta.id]=t.payload,r)}):e;case j.DeleteConsignmentSucceeded:case j.DeleteConsignmentRequested:return t.meta?G(e,{deleteError:(i={},i[t.meta.id]=void 0,i)}):e;case j.DeleteConsignmentFailed:return t.meta?G(e,{deleteError:(o={},o[t.meta.id]=t.payload,o)}):e;case j.UpdateShippingOptionRequested:case j.UpdateShippingOptionSucceeded:return t.meta?G(e,{updateShippingOptionError:(a={},a[t.meta.id]=void 0,a)}):e;case j.UpdateShippingOptionFailed:return t.meta?G(e,{updateShippingOptionError:(s={},s[t.meta.id]=t.payload,s)}):e;default:return e}}function Ht(e,t){var n,r,i,o,a,s;switch(void 0===e&&(e=qt.statuses),t.type){case P.LoadCheckoutRequested:return N(e,"isLoading",!0);case j.LoadShippingOptionsRequested:return N(e,"isLoadingShippingOptions",!0);case P.LoadCheckoutSucceeded:case P.LoadCheckoutFailed:return N(e,"isLoading",!1);case j.LoadShippingOptionsSucceeded:case j.LoadShippingOptionsFailed:return N(e,"isLoadingShippingOptions",!1);case j.CreateConsignmentsRequested:return N(e,"isCreating",!0);case j.CreateConsignmentsSucceeded:case j.CreateConsignmentsFailed:return N(e,"isCreating",!1);case j.UpdateConsignmentRequested:return t.meta?G(e,{isUpdating:(n={},n[t.meta.id]=!0,n)}):e;case j.UpdateConsignmentSucceeded:case j.UpdateConsignmentFailed:return t.meta?G(e,{isUpdating:(r={},r[t.meta.id]=!1,r)}):e;case j.DeleteConsignmentRequested:return t.meta?G(e,{isDeleting:(i={},i[t.meta.id]=!0,i)}):e;case j.DeleteConsignmentSucceeded:case j.DeleteConsignmentFailed:return t.meta?G(e,{isDeleting:(o={},o[t.meta.id]=!1,o)}):e;case j.UpdateShippingOptionRequested:return t.meta?G(e,{isUpdatingShippingOption:(a={},a[t.meta.id]=!0,a)}):e;case j.UpdateShippingOptionSucceeded:case j.UpdateShippingOptionFailed:return t.meta?G(e,{isUpdatingShippingOption:(s={},s[t.meta.id]=!1,s)}):e;default:return e}}function jt(e,t){var n={};return Object.keys(e).forEach((function(r){var i=e[r],o=t?t+"."+r:r;"object"==typeof i?Object.assign(n,jt(i,o)):n[o]=i})),n}function Yt(e){var t=Object.keys(e).sort().reduce((function(t,n){var r;return(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=e[n],r))}),{});return t}!function(e){e.LoadPickupOptionsRequested="LOAD_PICKUP_OPTIONS_REQUESTED",e.LoadPickupOptionsSucceeded="LOAD_PICKUP_OPTIONS_SUCCEEDED",e.LoadPickupOptionsFailed="LOAD_PICKUP_OPTIONS_FAILED"}(Bt||(Bt={}));var Wt,Kt={errors:{},statuses:{}};function Zt(e,t){return void 0===e&&(e=Kt),(0,a.combineReducers)({data:Qt,errors:(0,a.composeReducers)(Jt,k),statuses:Xt})(e,t)}function Qt(e,t){if(t.type!==Bt.LoadPickupOptionsSucceeded)return e;if(t.meta){var n=Yt(jt({consignmentId:t.meta.consignmentId,searchArea:t.meta.searchArea}));return N(e,btoa(""+JSON.stringify(n)),t.payload)}}function Jt(e,t){switch(void 0===e&&(e=Kt.errors),t.type){case Bt.LoadPickupOptionsRequested:case Bt.LoadPickupOptionsSucceeded:return N(e,"loadError",void 0);case Bt.LoadPickupOptionsFailed:return N(e,"loadError",t.payload);default:return e}}function Xt(e,t){switch(void 0===e&&(e=Kt.statuses),t.type){case Bt.LoadPickupOptionsRequested:return N(e,"isLoading",!0);case Bt.LoadPickupOptionsSucceeded:case Bt.LoadPickupOptionsFailed:return N(e,"isLoading",!1);default:return e}}!function(e){e.LoadShippingCountriesRequested="LOAD_SHIPPING_COUNTRIES_REQUESTED",e.LoadShippingCountriesSucceeded="LOAD_SHIPPING_COUNTRIES_SUCCEEDED",e.LoadShippingCountriesFailed="LOAD_SHIPPING_COUNTRIES_FAILED"}(Wt||(Wt={}));var $t,en={errors:{},statuses:{}};function tn(e,t){return void 0===e&&(e=en),(0,a.combineReducers)({data:nn,errors:(0,a.composeReducers)(rn,k),statuses:on})(e,t)}function nn(e,t){return t.type===Wt.LoadShippingCountriesSucceeded?x(e,t.payload):e}function rn(e,t){switch(void 0===e&&(e=en.errors),t.type){case Wt.LoadShippingCountriesRequested:case Wt.LoadShippingCountriesSucceeded:return N(e,"loadError",void 0);case Wt.LoadShippingCountriesFailed:return N(e,"loadError",t.payload);default:return e}}function on(e,t){switch(void 0===e&&(e=en.statuses),t.type){case Wt.LoadShippingCountriesRequested:return N(e,"isLoading",!0);case Wt.LoadShippingCountriesSucceeded:case Wt.LoadShippingCountriesFailed:return N(e,"isLoading",!1);default:return e}}!function(e){e.UpdateAddressFailed="SHIPPING_STRATEGY_UPDATE_ADDRESS_FAILED",e.UpdateAddressRequested="SHIPPING_STRATEGY_UPDATE_ADDRESS_REQUESTED",e.UpdateAddressSucceeded="SHIPPING_STRATEGY_UPDATE_ADDRESS_SUCCEEDED",e.SelectOptionFailed="SHIPPING_STRATEGY_SELECT_OPTION_FAILED",e.SelectOptionRequested="SHIPPING_STRATEGY_SELECT_OPTION_REQUESTED",e.SelectOptionSucceeded="SHIPPING_STRATEGY_SELECT_OPTION_SUCCEEDED",e.InitializeFailed="SHIPPING_STRATEGY_INITIALIZE_FAILED",e.InitializeRequested="SHIPPING_STRATEGY_INITIALIZE_REQUESTED",e.InitializeSucceeded="SHIPPING_STRATEGY_INITIALIZE_SUCCEEDED",e.DeinitializeFailed="SHIPPING_STRATEGY_DEINITIALIZE_FAILED",e.DeinitializeRequested="SHIPPING_STRATEGY_DEINITIALIZE_REQUESTED",e.DeinitializeSucceeded="SHIPPING_STRATEGY_DEINITIALIZE_SUCCEEDED",e.WidgetInteractionStarted="SHIPPING_STRATEGY_WIDGET_INTERACTION_STARTED",e.WidgetInteractionFinished="SHIPPING_STRATEGY_WIDGET_INTERACTION_FINISHED",e.WidgetInteractionFailed="SHIPPING_STRATEGY_WIDGET_INTERACTION_FAILED"}($t||($t={}));var an,sn={data:{},errors:{},statuses:{}};function un(e,t){return void 0===e&&(e=sn),(0,a.combineReducers)({data:cn,errors:(0,a.composeReducers)(dn,k),statuses:ln})(e,t)}function cn(e,t){var n,r;switch(void 0===e&&(e=sn.data),t.type){case $t.InitializeSucceeded:return G(e,((n={})[t.meta&&t.meta.methodId]={isInitialized:!0},n));case $t.DeinitializeSucceeded:return G(e,((r={})[t.meta&&t.meta.methodId]={isInitialized:!1},r))}return e}function dn(e,t){switch(void 0===e&&(e=sn.errors),t.type){case $t.InitializeRequested:case $t.InitializeSucceeded:return G(e,{initializeError:void 0,initializeMethodId:void 0});case $t.InitializeFailed:return G(e,{initializeError:t.payload,initializeMethodId:t.meta&&t.meta.methodId});case $t.DeinitializeRequested:case $t.DeinitializeSucceeded:return G(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case $t.DeinitializeFailed:return G(e,{deinitializeError:t.payload,deinitializeMethodId:t.meta&&t.meta.methodId});case $t.UpdateAddressRequested:case $t.UpdateAddressSucceeded:return G(e,{updateAddressError:void 0,updateAddressMethodId:void 0});case $t.UpdateAddressFailed:return G(e,{updateAddressError:t.payload,updateAddressMethodId:t.meta&&t.meta.methodId});case $t.SelectOptionRequested:case $t.SelectOptionSucceeded:return G(e,{selectOptionError:void 0,selectOptionMethodId:void 0});case $t.SelectOptionFailed:return G(e,{selectOptionError:t.payload,selectOptionMethodId:t.meta&&t.meta.methodId});case $t.WidgetInteractionStarted:case $t.WidgetInteractionFinished:return G(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case $t.WidgetInteractionFailed:return G(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta&&t.meta.methodId});default:return e}}function ln(e,t){switch(void 0===e&&(e=sn.statuses),t.type){case $t.InitializeRequested:return G(e,{isInitializing:!0,initializeMethodId:t.meta&&t.meta.methodId});case $t.InitializeFailed:case $t.InitializeSucceeded:return G(e,{isInitializing:!1,initializeMethodId:void 0});case $t.DeinitializeRequested:return G(e,{isDeinitializing:!0,deinitializeMethodId:t.meta&&t.meta.methodId});case $t.DeinitializeFailed:case $t.DeinitializeSucceeded:return G(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case $t.UpdateAddressRequested:return G(e,{isUpdatingAddress:!0,updateAddressMethodId:t.meta&&t.meta.methodId});case $t.UpdateAddressFailed:case $t.UpdateAddressSucceeded:return G(e,{isUpdatingAddress:!1,updateAddressMethodId:void 0});case $t.SelectOptionRequested:return G(e,{isSelectingOption:!0,selectOptionMethodId:t.meta&&t.meta.methodId});case $t.SelectOptionFailed:case $t.SelectOptionSucceeded:return G(e,{isSelectingOption:!1,selectOptionMethodId:void 0});case $t.WidgetInteractionStarted:return G(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta&&t.meta.methodId});case $t.WidgetInteractionFinished:case $t.WidgetInteractionFailed:return G(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}!function(e){e.SendSignInEmailRequested="SEND_SIGNIN_EMAIL_REQUESTED",e.SendSignInEmailSucceeded="SEND_SIGNIN_EMAIL_SUCCEEDED",e.SendSignInEmailFailed="SEND_SIGNIN_EMAIL_FAILED"}(an||(an={}));var pn,hn={errors:{},statuses:{}};function fn(e,t){return void 0===e&&(e=hn),(0,a.combineReducers)({data:gn,errors:(0,a.composeReducers)(mn,k),statuses:_n})(e,t)}function gn(e,t){return t.type===an.SendSignInEmailSucceeded?G(e,t.payload):e}function mn(e,t){switch(void 0===e&&(e=hn.errors),t.type){case an.SendSignInEmailRequested:case an.SendSignInEmailSucceeded:return N(e,"sendError",void 0);case an.SendSignInEmailFailed:return N(e,"sendError",t.payload);default:return e}}function _n(e,t){switch(void 0===e&&(e=hn.statuses),t.type){case an.SendSignInEmailRequested:return N(e,"isSending",!0);case an.SendSignInEmailFailed:case an.SendSignInEmailSucceeded:return N(e,"isSending",!1);default:return e}}!function(e){e.ApplyStoreCreditRequested="APPLY_STORE_CREDIT_REQUESTED",e.ApplyStoreCreditSucceeded="APPLY_STORE_CREDIT_SUCCEEDED",e.ApplyStoreCreditFailed="APPLY_STORE_CREDIT_FAILED"}(pn||(pn={}));var yn={errors:{},statuses:{}};function vn(e,t){return void 0===e&&(e=yn),(0,a.combineReducers)({errors:(0,a.composeReducers)(Cn,k),statuses:Sn})(e,t)}function Cn(e,t){switch(void 0===e&&(e=yn.errors),t.type){case pn.ApplyStoreCreditRequested:case pn.ApplyStoreCreditSucceeded:return N(e,"applyError",void 0);case pn.ApplyStoreCreditFailed:return N(e,"applyError",t.payload);default:return e}}function Sn(e,t){switch(void 0===e&&(e=yn.statuses),t.type){case pn.ApplyStoreCreditRequested:return N(e,"isApplying",!0);case pn.ApplyStoreCreditSucceeded:case pn.ApplyStoreCreditFailed:return N(e,"isApplying",!1);default:return e}}var In,wn={errors:{},statuses:{}};function En(e,t){return void 0===e&&(e=wn),(0,a.combineReducers)({errors:(0,a.composeReducers)(bn,k),statuses:Pn})(e,t)}function bn(e,t){switch(void 0===e&&(e=wn.errors),t.type){case O.UpdateSubscriptionsRequested:case O.UpdateSubscriptionsSucceeded:return N(e,"updateError",void 0);case O.UpdateSubscriptionsFailed:return N(e,"updateError",t.payload);default:return e}}function Pn(e,t){switch(void 0===e&&(e=wn.statuses),t.type){case O.UpdateSubscriptionsRequested:return N(e,"isUpdating",!0);case O.UpdateSubscriptionsFailed:case O.UpdateSubscriptionsSucceeded:return N(e,"isUpdating",!1);default:return e}}!function(e){e.InitializeFailed="SPAM_PROTECTION_INITIALIZE_FAILED",e.InitializeSucceeded="SPAM_PROTECTION_INITIALIZE_SUCCEEDED",e.InitializeRequested="SPAM_PROTECTION_INITIALIZE_REQUESTED",e.VerifyCheckoutRequested="SPAM_PROTECTION_CHECKOUT_VERIFY_REQUESTED",e.VerifyCheckoutSucceeded="SPAM_PROTECTION_CHECKOUT_VERIFY_SUCCEEDED",e.VerifyCheckoutFailed="SPAM_PROTECTION_CHECKOUT_VERIFY_FAILED",e.ExecuteRequested="SPAM_PROTECTION_EXECUTE_REQUESTED",e.ExecuteSucceeded="SPAM_PROTECTION_EXECUTE_SUCCEEDED",e.ExecuteFailed="SPAM_PROTECTION_EXECUTE_FAILED"}(In||(In={}));var An={errors:{},statuses:{}};function On(e,t){return void 0===e&&(e=An),(0,a.combineReducers)({data:Tn,errors:(0,a.composeReducers)(Rn,k),statuses:kn})(e,t)}function Tn(e,t){switch(t.type){case P.LoadCheckoutSucceeded:case P.UpdateCheckoutSucceeded:case pn.ApplyStoreCreditSucceeded:case T.UpdateBillingAddressSucceeded:case V.ApplyCouponSucceeded:case V.RemoveCouponSucceeded:case j.CreateConsignmentsSucceeded:case j.UpdateConsignmentSucceeded:case j.DeleteConsignmentSucceeded:case j.UpdateShippingOptionSucceeded:case j.LoadShippingOptionsSucceeded:case H.ApplyGiftCertificateSucceeded:case H.RemoveGiftCertificateSucceeded:case In.VerifyCheckoutSucceeded:return G(e,(0,_.omit)(t.payload,["billingAddress","cart","consignments","customer","coupons","giftCertificates"]));case se.SubmitOrderSucceeded:return N(e,"orderId",t.payload&&t.payload.order.orderId);default:return e}}function Rn(e,t){switch(void 0===e&&(e=An.errors),t.type){case P.LoadCheckoutRequested:case P.LoadCheckoutSucceeded:return N(e,"loadError",void 0);case P.LoadCheckoutFailed:return N(e,"loadError",t.payload);case P.UpdateCheckoutRequested:case P.UpdateCheckoutSucceeded:return N(e,"updateError",void 0);case P.UpdateCheckoutFailed:return N(e,"updateError",t.payload);default:return e}}function kn(e,t){switch(void 0===e&&(e=An.statuses),t.type){case P.LoadCheckoutRequested:return N(e,"isLoading",!0);case P.LoadCheckoutFailed:case P.LoadCheckoutSucceeded:return N(e,"isLoading",!1);case P.UpdateCheckoutRequested:return N(e,"isUpdating",!0);case P.UpdateCheckoutFailed:case P.UpdateCheckoutSucceeded:return N(e,"isUpdating",!1);case In.ExecuteRequested:return N(e,"isExecutingSpamCheck",!0);case In.ExecuteFailed:case In.ExecuteSucceeded:return N(e,"isExecutingSpamCheck",!1);default:return e}}const Dn=require("@bigcommerce/memoize");var Mn;!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentProviderCustomer=13]="MissingPaymentProviderCustomer",e[e.MissingPaymentRedirectUrl=14]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=15]="MissingPaymentStatus",e[e.MissingPaymentToken=16]="MissingPaymentToken",e[e.MissingShippingAddress=17]="MissingShippingAddress"}(Mn||(Mn={}));const Nn=function(e){function t(t){var n=e.call(this,function(e){switch(e){case Mn.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case Mn.MissingCart:return"Unable to proceed because cart data is unavailable.";case Mn.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case Mn.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case Mn.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case Mn.MissingCheckoutConfig:case Mn.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case Mn.MissingOrder:return"Unable to proceed because order data is unavailable.";case Mn.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case Mn.MissingPayment:return"Unable to proceed because payment data is unavailable.";case Mn.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case Mn.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case Mn.MissingPaymentProviderCustomer:return"Unable to proceed because payment provider customer is unavailable.";case Mn.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(t))||this;return n.subtype=t,n.name="MissingDataError",n.type="missing_data",n}return(0,o.__extends)(t,e),t}(p),Ln=require("reselect"),zn=(Un=Ln.createSelector,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.pop();return Un.apply(void 0,(0,o.__spreadArrays)(e,[function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=n.apply(void 0,e);return"function"==typeof r?(0,Dn.memoize)(r):r}]))});var Un;function Fn(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}function Bn(e){return function(e){var t=Object.create(e);return function(e,t){for(var n=Object.getPrototypeOf(e);n;)t(n),n=Object.getPrototypeOf(n)}(e,(function(n){Object.getOwnPropertyNames(n).forEach((function(n){"constructor"!==n&&"function"==typeof t[n]&&"_"!==n.charAt(0)&&(t[n]=function(e,t){return function(){for(var n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return(0,a.deepFreeze)((n=e[t]).call.apply(n,(0,o.__spreadArrays)([e],r)))}}(e,n))}))})),t}(e)}var qn="PAYMENT_TYPE_HOSTED",xn="ACKNOWLEDGE",Gn="FINALIZE";const Vn={"mollie.credit_card":{provider:"mollie",method:"credit_card"},"adyenv2.scheme":{provider:"adyenv2",method:"scheme"},"adyenv3.scheme":{provider:"adyenv3",method:"scheme"},"adyenv2.bcmc":{provider:"adyenv2",method:"bcmc"},"adyenv2.ideal":{provider:"adyenv2",method:"ideal"},"adyenv2.sepadirectdebit":{provider:"adyenv2",method:"sepadirectdebit"},"adyenv2.directEbanking":{provider:"adyenv2",method:"directEbanking"},"adyenv2.giropay":{provider:"adyenv2",method:"giropay"},barclays:{provider:"barclays",method:"credit_card"},braintree:{provider:"braintree",method:"credit_card"},braintreepaypal:{provider:"braintree",method:"paypal"},braintreeach:{provider:"braintree",method:"ach"},authorizenet:{provider:"authorizenet",method:"credit_card"},elavon:{provider:"elavon",method:"credit_card"},checkoutcom:{provider:"checkoutcom",method:"credit_card"},"checkoutcom.credit_card":{provider:"checkoutcom",method:"credit_card"},"checkoutcom.card":{provider:"checkoutcom",method:"card"},sagepay:{provider:"sagepay",method:"credit_card"},stripe:{provider:"stripe",method:"credit_card"},"stripev3.card":{provider:"stripev3",method:"card"},"stripeupe.card":{provider:"stripeupe",method:"card"},cybersource:{provider:"cybersource",method:"credit_card"},cybersourcev2:{provider:"cybersourcev2",method:"credit_card"},bnz:{provider:"bnz",method:"credit_card"},converge:{provider:"converge",method:"credit_card"},bluesnapv2:{provider:"bluesnapv2",method:"credit_card"},"bluesnapdirect.credit_card":{provider:"bluesnapdirect",method:"credit_card"},"bluesnapdirect.ecp":{provider:"bluesnapdirect",method:"ecp"},"bluesnapdirect.sepa_direct_debit":{provider:"bluesnapdirect",method:"sepa_direct_debit"},orbital:{provider:"orbital",method:"credit_card"},paymetric:{provider:"paymetric",method:"credit_card"},bolt:{provider:"bolt",method:"credit_card"},"barclaycard.credit_card":{provider:"barclaycard",method:"credit_card"},digitalriver:{provider:"digitalriver",method:"credit_card"},moneris:{provider:"moneris",method:"credit_card"},cba_mpgs:{provider:"cba_mpgs",method:"credit_card"},worldpayaccess:{provider:"worldpayaccess",method:"credit_card"},squarev2:{provider:"squarev2",method:"credit_card"},paypalcommercecreditcards:{provider:"paypalcommerce",method:"credit_card"},paypalcommerce:{provider:"paypalcommerce",method:"paypal"},tdonlinemart:{provider:"tdonlinemart",method:"credit_card"}};function Hn(e){return(0,_.pickBy)({firstName:e.firstName,lastName:e.lastName,company:e.company,address1:e.address1,address2:e.address2,city:e.city,stateOrProvince:e.stateOrProvince,countryCode:e.countryCode,postalCode:e.postalCode,phone:e.phone,customFields:e.customFields},_.identity)}var jn={errors:{},statuses:{}};function Yn(){var e,t,n,r,i,a,s,u,c,d,l,p,h,f,g,m,y,v,C,S,I,w,E,b,P,A,O,T,R,k,D,M,N,z,U,F,B,q,x,G,V,H,j,Y,K,Z,Q,J,X,ee=(e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn(e,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingBillingAddress)}))}})),n=zn((function(e){return e.errors.updateError}),(function(e){return function(){return e}})),r=zn((function(e){return e.errors.continueAsGuestError}),(function(e){return function(){return e}})),i=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),a=zn((function(e){return!!e.statuses.isUpdating}),(function(e){return function(){return e}})),s=zn((function(e){return!!e.statuses.isContinuingAsGuest}),(function(e){return function(){return e}})),u=zn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}})),(0,Dn.memoizeOne)((function(o){return void 0===o&&(o=L),{getBillingAddress:e(o),getBillingAddressOrThrow:t(o),getUpdateError:n(o),getContinueAsGuestError:r(o),getLoadError:i(o),isUpdating:a(o),isContinuingAsGuest:s(o),isLoading:u(o)}}))),te=function(){var e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn(e,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingCart)}))}})),n=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),r=zn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,Dn.memoizeOne)((function(i){return void 0===i&&(i=W),{getCart:e(i),getCartOrThrow:t(i),getLoadError:n(i),isLoading:r(i)}}))}(),ne=(c=zn((function(e){return e}),(function(e){return function(){return e}})),d=zn((function(e){return e.statuses}),(function(e){return(0,Dn.memoize)((function(t){if(t){var n=e[t];return!0===(n&&n.isInitializing)}return(0,_.some)(e,{isInitializing:!0})}))})),l=zn((function(e){return e.data}),(function(e){return(0,Dn.memoize)((function(t,n){var r=e[t];return!!r&&(n?!0===r.initializedContainers[n]:(0,_.some)(r.initializedContainers,(function(e){return!0===e})))}))})),p=zn((function(e){return e.statuses}),(function(e){return(0,Dn.memoize)((function(t){if(t){var n=e[t];return!0===(n&&n.isDeinitializing)}return(0,_.some)(e,{isDeinitializing:!0})}))})),h=zn((function(e){return e.errors}),(function(e){return(0,Dn.memoize)((function(t){var n=t?e[t]:(0,_.find)((0,_.values)(e),(function(e){return!(!e||!e.initializeError)}));return n&&n.initializeError}))})),f=zn((function(e){return e.errors}),(function(e){return(0,Dn.memoize)((function(t){var n=t?e[t]:(0,_.find)((0,_.values)(e),(function(e){return!(!e||!e.deinitializeError)}));return n&&n.deinitializeError}))})),(0,Dn.memoizeOne)((function(e){return void 0===e&&(e=$),{getState:c(e),isInitializing:d(e),isInitialized:l(e),isDeinitializing:p(e),getInitializeError:h(e),getDeinitializeError:f(e)}}))),re=function(){var e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn((function(e){return e.data}),(function(e){return function(t){if(e){var n=e.context.flashMessages;if(n)return void 0!==t?n.filter((function(e){var n=e.type;return t===n})):n}}})),n=zn((function(e){return e.data}),(function(e,t){var n=t.formState;return n&&n.data}),(function(e,t){return function(){return e&&t?(0,o.__assign)((0,o.__assign)({},e.storeConfig),{formFields:t}):void 0}})),r=zn(n,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingCheckoutConfig)}))}})),i=zn((function(e){return e.data&&e.data.context}),(function(e){return function(){return e}})),a=zn((function(e){return e.meta&&e.meta.externalSource}),(function(e){return function(){return e}})),s=zn((function(e){var t;return null===(t=e.meta)||void 0===t?void 0:t.host}),(function(e){return function(){return e}})),u=zn((function(e){var t;return null===(t=e.meta)||void 0===t?void 0:t.locale}),(function(e){return function(){return e}})),c=zn((function(e){return e.meta&&e.meta.variantIdentificationToken}),(function(e){return function(){return e}})),d=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),l=zn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,Dn.memoizeOne)((function(o,p){return void 0===o&&(o=ue),{getConfig:e(o),getFlashMessages:t(o),getStoreConfig:n(o,{formState:p}),getStoreConfigOrThrow:r(o,{formState:p}),getContextConfig:i(o),getExternalSource:a(o),getHost:s(o),getLocale:u(o),getVariantIdentificationToken:c(o),getLoadError:d(o),isLoading:l(o)}}))}(),ie=function(){var e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),n=zn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,Dn.memoizeOne)((function(r){return void 0===r&&(r=Ke),{getCountries:e(r),getLoadError:t(r),isLoading:n(r)}}))}(),oe=(g=zn((function(e){return e.data}),(function(e){return function(){return e}})),m=zn((function(e){return e.errors.removeCouponError}),(function(e){return function(){return e}})),y=zn((function(e){return e.errors.applyCouponError}),(function(e){return function(){return e}})),v=zn((function(e){return!!e.statuses.isApplyingCoupon}),(function(e){return function(){return e}})),C=zn((function(e){return!!e.statuses.isRemovingCoupon}),(function(e){return function(){return e}})),(0,Dn.memoizeOne)((function(e){return void 0===e&&(e=he),{getCoupons:g(e),getRemoveError:m(e),getApplyError:y(e),isApplying:v(e),isRemoving:C(e)}}))),ae=(S=zn((function(e){return e.data}),(function(e){return function(){return e}})),I=zn(S,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingCustomer)}))}})),w=zn((function(e){return e.errors.createError}),(function(e){return function(){return e}})),E=zn((function(e){return!!e.statuses.isCreating}),(function(e){return function(){return e}})),b=zn((function(e){return e.errors.createAddressError}),(function(e){return function(){return e}})),P=zn((function(e){return!!e.statuses.isCreatingAddress}),(function(e){return function(){return e}})),(0,Dn.memoizeOne)((function(e){return void 0===e&&(e=be),{getCustomer:S(e),getCustomerOrThrow:I(e),getCreateAccountError:w(e),isCreatingCustomerAccount:E(e),getCreateAddressError:b(e),isCreatingCustomerAddress:P(e)}}))),se=function(){var e=zn((function(e){return e.errors.signInMethodId}),(function(e){return e.errors.signInError}),(function(e,t){return function(n){if(!n||e===n)return t}})),t=zn((function(e){return e.errors.signOutMethodId}),(function(e){return e.errors.signOutError}),(function(e,t){return function(n){if(!n||e===n)return t}})),n=zn((function(e){return e.errors.executePaymentMethodCheckoutMethodId}),(function(e){return e.errors.executePaymentMethodCheckoutError}),(function(e,t){return function(n){if(!n||e===n)return t}})),r=zn((function(e){return e.errors.initializeMethodId}),(function(e){return e.errors.initializeErrors}),(function(e,t){return function(n){if(e&&t)return n?t[n]:t[e]}})),i=zn((function(e){return e.errors.widgetInteractionMethodId}),(function(e){return e.errors.widgetInteractionError}),(function(e,t){return function(n){if(!n||e===n)return t}})),o=zn((function(e){return e.statuses.signInMethodId}),(function(e){return e.statuses.isSigningIn}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),a=zn((function(e){return e.statuses.signOutMethodId}),(function(e){return e.statuses.isSigningOut}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),s=zn((function(e){return e.statuses.executePaymentMethodCheckoutMethodId}),(function(e){return e.statuses.isExecutingPaymentMethodCheckout}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),u=zn((function(e){return e.statuses.initializeMethodId}),(function(e){return e.statuses.isInitializing}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),c=zn((function(e){return e.data}),(function(e){return function(t){return!(!e[t]||!e[t].isInitialized)}})),d=zn((function(e){return e.statuses.widgetInteractionMethodId}),(function(e){return e.statuses.isWidgetInteracting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,Dn.memoizeOne)((function(l){return void 0===l&&(l=ke),{getSignInError:e(l),getSignOutError:t(l),getExecutePaymentMethodCheckoutError:n(l),getInitializeError:r(l),getWidgetInteractionError:i(l),isSigningIn:o(l),isSigningOut:a(l),isExecutingPaymentMethodCheckout:s(l),isInitializing:u(l),isInitialized:c(l),isWidgetInteracting:d(l)}}))}(),ce=function(){var e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn((function(e){return e.errors.removeGiftCertificateError}),(function(e){return function(){return e}})),n=zn((function(e){return e.errors.applyGiftCertificateError}),(function(e){return function(){return e}})),r=zn((function(e){return!!e.statuses.isApplyingGiftCertificate}),(function(e){return function(){return e}})),i=zn((function(e){return!!e.statuses.isRemovingGiftCertificate}),(function(e){return function(){return e}}));return(0,Dn.memoizeOne)((function(o){return void 0===o&&(o=ve),{getGiftCertificates:e(o),getRemoveError:t(o),getApplyError:n(o),isApplying:r(o),isRemoving:i(o)}}))}(),de=function(){var e=zn((function(e){return e.data}),(function(e){return function(t){if(e){var n=t.gateway?t.gateway+"."+t.id:t.id,r=Vn[n];return r?(0,_.filter)(e,r):[]}}})),t=zn((function(e){return e.data}),(function(e){return void 0===e&&(e=[]),function(t){var n=(0,_.values)(Vn);return e.find((function(e){return e.bigpayToken===t&&"card"===e.type&&n.some((function(t){return(0,_.isMatch)(e,t)}))}))}})),n=zn(t,(function(e){return function(t){return Fn(e(t),(function(){return new Nn(Mn.MissingPaymentInstrument)}))}})),r=zn((function(e){return e.data}),(function(e){return function(){if(e)return(0,_.flatMap)(Vn,(function(t){return(0,_.filter)(e,(function(e){return(0,_.isMatch)(e,t)}))}))}})),i=zn((function(e){return e.meta}),(function(e){return function(){return e}})),o=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),a=zn((function(e){return e.errors.failedInstrument}),(function(e){return e.errors.deleteError}),(function(e,t){return function(n){if(!n||e===n)return t}})),s=zn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!!e}})),u=zn((function(e){return e.statuses.deletingInstrument}),(function(e){return e.statuses.isDeleting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,Dn.memoizeOne)((function(c){return void 0===c&&(c=Rt),{getCardInstrument:t(c),getCardInstrumentOrThrow:n(c),getInstruments:r(c),getInstrumentsByPaymentMethod:e(c),getInstrumentsMeta:i(c),getLoadError:o(c),getDeleteError:a(c),isLoading:s(c),isDeleting:u(c)}}))}(),le=function(){var e=zn((function(e){return e.data}),(function(e){return function(t,n){void 0===t&&(t=[]);var r=(0,_.find)(t,{code:n});return(e?e.shippingAddress:[]).map((function(e){return a(e,t,r)}))}})),t=zn((function(e){return e.data}),(function(e){return function(t,n){void 0===t&&(t=[]);var r=(0,_.find)(t,{code:n});return(e?e.billingAddress:[]).map((function(e){return a(e,t,r)}))}})),n=zn((function(e){return e.data}),(function(e){return function(){return e?e.customerAccount:[]}})),r=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),i=zn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));function a(e,t,n){return"countryCode"===e.name?function(e,t,n){if(void 0===t&&(t=[]),!t.length)return e;var r=(n||{}).code,i=void 0===r?"":r,a=t.map((function(e){return{value:e.code,label:e.name}}));return(0,o.__assign)((0,o.__assign)({},e),{options:{items:a},default:i,type:"array",fieldType:"dropdown",itemtype:"string"})}(e,t,n):"stateOrProvince"===e.name?function(e,t){var n=t||{},r=n.subdivisions,i=void 0===r?[]:r,a=n.requiresState;if(!i.length)return(0,o.__assign)((0,o.__assign)({},e),{required:null!=a&&a});var s=i.map((function(e){return{value:e.code,label:e.name}}));return(0,o.__assign)((0,o.__assign)({},e),{name:"stateOrProvinceCode",options:{items:s},required:null==a||a,type:"array",fieldType:"dropdown",itemtype:"string"})}(e,n):"postalCode"===e.name?function(e,t){var n=(t||{}).hasPostalCodes,r=void 0===n?[]:n;return void 0===r?e:(0,o.__assign)((0,o.__assign)({},e),{required:Boolean(r)})}(e,n):e}return(0,Dn.memoizeOne)((function(o){return void 0===o&&(o=Ve),{getShippingAddressFields:e(o),getBillingAddressFields:t(o),getCustomerAccountFields:n(o),getLoadError:r(o),isLoading:i(o)}}))}(),pe=function(){var e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn((function(e){return e.meta}),(function(e){return function(){return e}})),n=zn((function(e){return e.data}),(function(e){return function(t,n){return n?(0,_.find)(e,{id:t,gateway:n}):(0,_.find)(e,{id:t})}})),r=zn(n,(function(e){return function(t,n){return Fn(e(t,n),(function(){return new Nn(Mn.MissingPaymentMethod)}))}})),i=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),o=zn((function(e){return e.errors.loadMethodId}),(function(e){return e.errors.loadMethodError}),(function(e,t){return function(n){if(!n||e===n)return t}})),a=zn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!!e}})),s=zn((function(e){return e.statuses.loadMethodId}),(function(e){return e.statuses.isLoadingMethod}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,Dn.memoizeOne)((function(u){return void 0===u&&(u=ht),{getPaymentMethods:e(u),getPaymentMethodsMeta:t(u),getPaymentMethod:n(u),getPaymentMethodOrThrow:r(u),getLoadError:i(u),getLoadMethodError:o(u),isLoading:a(u),isLoadingMethod:s(u)}}))}(),fe=function(){var e=zn((function(e){return e.errors.initializeMethodId}),(function(e){return e.errors.initializeError}),(function(e,t){return function(n){if(!n||e===n)return t}})),t=zn((function(e){return e.errors.executeMethodId}),(function(e){return e.errors.executeError}),(function(e,t){return function(n){if(!n||e===n)return t}})),n=zn((function(e){return e.errors.finalizeMethodId}),(function(e){return e.errors.finalizeError}),(function(e,t){return function(n){if(!n||e===n)return t}})),r=zn((function(e){return e.errors.widgetInteractionMethodId}),(function(e){return e.errors.widgetInteractionError}),(function(e,t){return function(n){if(!n||e===n)return t}})),i=zn((function(e){return e.statuses.initializeMethodId}),(function(e){return e.statuses.isInitializing}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),o=zn((function(e){return e.data}),(function(e){return function(t){var n=t.gatewayId?t.methodId+"."+t.gatewayId:t.methodId;return!(!e[n]||!e[n].isInitialized)}})),a=zn((function(e){return e.statuses.executeMethodId}),(function(e){return e.statuses.isExecuting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),s=zn((function(e){return e.statuses.finalizeMethodId}),(function(e){return e.statuses.isFinalizing}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),u=zn((function(e){return e.statuses.widgetInteractionMethodId}),(function(e){return e.statuses.isWidgetInteracting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,Dn.memoizeOne)((function(c){return void 0===c&&(c=Ct),{getInitializeError:e(c),getExecuteError:t(c),getFinalizeError:n(c),getWidgetInteractingError:r(c),isInitializing:i(c),isInitialized:o(c),isExecuting:a(c),isFinalizing:s(c),isWidgetInteracting:u(c)}}))}(),ge=function(){var e=zn((function(e){return e.data}),(function(e){return function(t,n){if(e){var r=Yt(jt({consignmentId:t,searchArea:n})),i=btoa(""+JSON.stringify(r));return e[i]}}})),t=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),n=zn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,Dn.memoizeOne)((function(r){return void 0===r&&(r=Kt),{getPickupOptions:e(r),getLoadError:t(r),isLoading:n(r)}}))}(),me=(A=zn((function(e){return e.data}),(function(e){return function(){return e}})),O=zn(A,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingPaymentProviderCustomer)}))}})),(0,Dn.memoizeOne)((function(e){return void 0===e&&(e=Pt),{getPaymentProviderCustomer:A(e),getPaymentProviderCustomerOrThrow:O(e)}}))),_e=(T=zn((function(e){return e.data}),(function(e){return function(t){return e[t]}})),(0,Dn.memoizeOne)((function(e){return void 0===e&&(e=zt),{getCheckout:T(e)}}))),ye=(R=zn((function(e){return e.data}),(function(e){return function(){var t=null==e?void 0:e.find((function(e){return!e.selectedPickupOption}));return null==t?void 0:t.shippingAddress}})),k=zn(R,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingShippingAddress)}))}})),D=zn((function(e){return e.data}),(function(e){return function(){var t=null==e?void 0:e.filter((function(e){return!e.selectedPickupOption}));return t?t.map((function(e){return e.shippingAddress})):[]}})),M=zn(D,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingShippingAddress)}))}})),(0,Dn.memoizeOne)((function(e){return void 0===e&&(e=qt),{getShippingAddress:R(e),getShippingAddressOrThrow:k(e),getShippingAddresses:D(e),getShippingAddressesOrThrow:M(e)}}))),Ce=function(){var e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),n=zn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!!e}}));return(0,Dn.memoizeOne)((function(r){return void 0===r&&(r=en),{getShippingCountries:e(r),getLoadError:t(r),isLoading:n(r)}}))}(),Se=function(){var e=zn((function(e){return e.errors.updateAddressMethodId}),(function(e){return e.errors.updateAddressError}),(function(e,t){return function(n){if(!n||e===n)return t}})),t=zn((function(e){return e.errors.selectOptionMethodId}),(function(e){return e.errors.selectOptionError}),(function(e,t){return function(n){if(!n||e===n)return t}})),n=zn((function(e){return e.errors.initializeMethodId}),(function(e){return e.errors.initializeError}),(function(e,t){return function(n){if(!n||e===n)return t}})),r=zn((function(e){return e.errors.widgetInteractionMethodId}),(function(e){return e.errors.widgetInteractionError}),(function(e,t){return function(n){if(!n||e===n)return t}})),i=zn((function(e){return e.statuses.updateAddressMethodId}),(function(e){return e.statuses.isUpdatingAddress}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),o=zn((function(e){return e.statuses.selectOptionMethodId}),(function(e){return e.statuses.isSelectingOption}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),a=zn((function(e){return e.statuses.initializeMethodId}),(function(e){return e.statuses.isInitializing}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),s=zn((function(e){return e.data}),(function(e){return function(t){return!(!e[t]||!e[t].isInitialized)}})),u=zn((function(e){return e.statuses.widgetInteractionMethodId}),(function(e){return e.statuses.isWidgetInteracting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,Dn.memoizeOne)((function(c){return void 0===c&&(c=sn),{getUpdateAddressError:e(c),getSelectOptionError:t(c),getInitializeError:n(c),getWidgetInteractionError:r(c),isUpdatingAddress:i(c),isSelectingOption:o(c),isInitializing:a(c),isInitialized:s(c),isWidgetInteracting:u(c)}}))}(),Ie=function(){var e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn(e,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingConsignments)}))}})),n=zn((function(e){return e.data}),(function(e){return function(t){if(e&&e.length)return(0,_.find)(e,{id:t})}})),r=zn((function(e){return e.data}),(function(e){return function(t){if(e&&e.length)return(0,_.find)(e,(function(e){return n=e.shippingAddress,r=t,(0,_.isEqual)(Hn(n),Hn(r));var n,r}))}})),i=zn((function(e){return e.data}),(function(e){return function(){if(e&&e.length)return e[0].selectedShippingOption}})),o=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),a=zn((function(e){return e.errors.createError}),(function(e){return function(){return e}})),s=zn((function(e){return e.errors.loadShippingOptionsError}),(function(e){return function(){return e}})),u=zn(e,(function(e,t){return t.cart.getCart}),(function(e,t){return function(){var n=t();if(!n)return[];var r=(e()||[]).reduce((function(e,t){return e.concat(t.lineItemIds)}),[]);return(n.lineItems.physicalItems||[]).filter((function(e){return r.indexOf(e.id)<0}))}})),c=zn((function(e){return e.errors.updateError}),(function(e){return function(t){return t?e[t]:(0,_.find)(e)}})),d=zn((function(e){return e.errors.deleteError}),(function(e){return function(t){return t?e[t]:(0,_.find)(e)}})),l=zn(r,c,a,(function(e,t,n){return function(r){var i=e(r);return i?t(i.id):n()}})),p=zn((function(e){return e.errors.updateShippingOptionError}),(function(e){return function(t){return t?e[t]:(0,_.find)(e)}})),h=zn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!0===e}})),f=zn((function(e){return e.statuses.isLoadingShippingOptions}),(function(e){return function(){return!0===e}})),g=zn((function(e){return e.statuses.isCreating}),(function(e){return function(){return!0===e}})),m=zn((function(e){return e.statuses.isUpdating}),(function(e){return function(t){return t?!0===e[t]:!0===(0,_.find)(e)}})),y=zn((function(e){return e.statuses.isDeleting}),(function(e){return function(t){return t?!0===e[t]:!0===(0,_.find)(e)}})),v=zn(r,m,g,(function(e,t,n){return function(r){var i=e(r);return i?t(i.id):n()}})),C=zn((function(e){return e.statuses.isUpdatingShippingOption}),(function(e){return function(t){return t?!0===e[t]:!0===(0,_.find)(e)}}));return(0,Dn.memoizeOne)((function(_,S){return void 0===_&&(_=qt),{getConsignments:e(_),getConsignmentsOrThrow:t(_),getConsignmentById:n(_),getConsignmentByAddress:r(_),getShippingOption:i(_),getLoadError:o(_),getCreateError:a(_),getLoadShippingOptionsError:s(_),getUnassignedItems:u(_,{cart:S}),getUpdateError:c(_),getDeleteError:d(_),getItemAssignmentError:l(_),getUpdateShippingOptionError:p(_),isLoading:h(_),isLoadingShippingOptions:f(_),isCreating:g(_),isUpdating:m(_),isDeleting:y(_),isAssigningItems:v(_),isUpdatingShippingOption:C(_)}}))}(),we=function(){var e=zn((function(e){return e.data}),(function(e,t){return t.billingAddress.getBillingAddress}),(function(e,t){return t.cart.getCart}),(function(e,t){return t.customer.getCustomer}),(function(e,t){return t.consignments.getConsignments}),(function(e,t){return t.coupons.getCoupons}),(function(e,t){return t.giftCertificates.getGiftCertificates}),(function(e,t,n,r,i,a,s){return function(){var u=t(),c=n(),d=r(),l=i()||[],p=a()||[],h=s()||[];if(e&&c&&d)return(0,o.__assign)((0,o.__assign)({},e),{billingAddress:u,cart:c,customer:d,consignments:l,coupons:p,giftCertificates:h})}})),t=zn(e,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingCheckout)}))}})),n=zn(e,(function(e){return function(t){var n=e();if(n){var r=n.grandTotal||0,i=n.customer.storeCredit||0;return t?Math.max(r-i,0):n.outstandingBalance}}})),r=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),i=zn((function(e){return e.errors.updateError}),(function(e){return function(){return e}})),a=zn((function(e){return e.statuses.isExecutingSpamCheck}),(function(e){return function(){return!0===e}})),s=zn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!0===e}})),u=zn((function(e){return e.statuses.isUpdating}),(function(e){return function(){return!0===e}}));return(0,Dn.memoizeOne)((function(o,c,d,l,p,h,f){return void 0===o&&(o=An),{getCheckout:e(o,{billingAddress:c,cart:d,consignments:l,coupons:p,customer:h,giftCertificates:f}),getCheckoutOrThrow:t(o,{billingAddress:c,cart:d,consignments:l,coupons:p,customer:h,giftCertificates:f}),getOutstandingBalance:n(o,{billingAddress:c,cart:d,consignments:l,coupons:p,customer:h,giftCertificates:f}),getLoadError:r(o),getUpdateError:i(o),isExecutingSpamCheck:a(o),isLoading:s(o),isUpdating:u(o)}}))}(),Ee=function(){var e=zn((function(e){return e.data}),(function(e,t){return t.billingAddress.getOrderBillingAddress()}),(function(e,t){return t.coupons.getCoupons()}),(function(e,t,n){return void 0===n&&(n=[]),function(){if(e&&t)return(0,o.__assign)((0,o.__assign)({},e),{billingAddress:t,coupons:n})}})),t=zn(e,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingOrder)}))}})),n=zn((function(e){return e.meta}),(function(e){return function(){return e}})),r=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),i=zn((function(e){var t;return null===(t=e.data)||void 0===t?void 0:t.payments}),(function(e){return void 0===e&&(e=[]),function(t){var n=e.find((function(e){return e.providerId===t}));return null==n?void 0:n.paymentId}})),a=zn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,Dn.memoizeOne)((function(o,s,u){return void 0===o&&(o=$e),{getOrder:e(o,{billingAddress:s,coupons:u}),getOrderOrThrow:t(o,{billingAddress:s,coupons:u}),getOrderMeta:n(o),getLoadError:r(o),getPaymentId:i(o),isLoading:a(o)}}))}(),Pe=(N=zn((function(e){return e.data}),(function(e){return function(){return e}})),(0,Dn.memoizeOne)((function(e){return void 0===e&&(e=st),{getOrderBillingAddress:N(e)}}))),Ae=(z=zn((function(e){return e.order.getOrderMeta}),(function(e){return function(){var t=e();return t&&t.payment}})),U=zn((function(e){return e.order.getOrder}),(function(e){return function(){var t=e();return(0,_.find)(t&&t.payments,(function(e){var t=e.providerId;return"giftcertificate"!==t&&"storecredit"!==t}))}})),F=zn((function(e){return e.checkout.getCheckout}),(function(e){return function(){var t=e();return(0,_.find)(t&&t.payments,(function(e){return e.providerType===qn}))}})),B=zn(z,F,U,(function(e,t,n){return function(){var r=e();if(r&&r.id)return{providerId:r.id,gatewayId:r.gateway};var i=t()||n();return i&&i.providerId?{providerId:i.providerId,gatewayId:i.gatewayId}:void 0}})),q=zn(B,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingPaymentId)}))}})),x=zn(z,F,U,(function(e,t,n){return function(){var r=e();if(r&&r.status)return r.status.replace("PAYMENT_STATUS_","");var i=t()||n();return i?i.detail.step:void 0}})),G=zn(x,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingPaymentStatus)}))}})),V=zn((function(e){return e.order.getOrderMeta}),(function(e){return function(){var t=e();return t&&t.token}})),H=zn(V,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingPaymentToken)}))}})),j=zn(z,(function(e){return function(){var t=e();return t&&t.redirectUrl}})),Y=zn(j,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingPaymentRedirectUrl)}))}})),K=zn((function(e){return e.checkout.getOutstandingBalance}),(function(e){return function(t){void 0===t&&(t=!1);var n=e(t);return!!n&&n>0}})),Z=zn(x,(function(e){return function(t){return!(!t||!t.nonce)||e()===xn||e()===Gn}})),(0,Dn.memoizeOne)((function(e,t){return{getPaymentId:B({checkout:e,order:t}),getPaymentIdOrThrow:q({checkout:e,order:t}),getPaymentStatus:x({checkout:e,order:t}),getPaymentStatusOrThrow:G({checkout:e,order:t}),getPaymentToken:V({checkout:e,order:t}),getPaymentTokenOrThrow:H({checkout:e,order:t}),getPaymentRedirectUrl:j({checkout:e,order:t}),getPaymentRedirectUrlOrThrow:Y({checkout:e,order:t}),isPaymentDataRequired:K({checkout:e,order:t}),isPaymentDataSubmitted:Z({checkout:e,order:t})}}))),Oe=function(){var e=zn((function(e){return e.errors.applyError}),(function(e){return function(){return e}})),t=zn((function(e){return!!e.statuses.isApplying}),(function(e){return function(){return e}}));return(0,Dn.memoizeOne)((function(n){return void 0===n&&(n=jn),{getApplyError:e(n),isApplying:t(n)}}))}(),Te=function(){var e=zn((function(e){return e.errors.updateError}),(function(e){return function(){return e}})),t=zn((function(e){return!!e.statuses.isUpdating}),(function(e){return function(){return e}}));return(0,Dn.memoizeOne)((function(n){return void 0===n&&(n=wn),{getUpdateError:e(n),isUpdating:t(n)}}))}(),Re=(Q=zn((function(e){return e.data}),(function(e){return function(){return e}})),J=zn((function(e){return e.errors.sendError}),(function(e){return function(){return e}})),X=zn((function(e){return!!e.statuses.isSending}),(function(e){return function(){return e}})),(0,Dn.memoizeOne)((function(e){return void 0===e&&(e=hn),{getEmail:Q(e),getSendError:J(e),isSending:X(e)}}))),De=function(){var e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn((function(e){return e.data}),(function(e){return function(t){return null==e?void 0:e.find((function(e){return e.region===t}))}})),n=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),r=zn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!!e}}));return(0,Dn.memoizeOne)((function(i){return void 0===i&&(i=Ue),{getExtensions:e(i),getExtensionByRegion:t(i),getLoadError:n(i),isLoading:r(i)}}))}();return function(e,t){void 0===t&&(t={});var n,r=ee(e.billingAddress),i=te(e.cart),o=ne(e.checkoutButton),a=ie(e.countries),s=oe(e.coupons),u=ae(e.customer),c=se(e.customerStrategies),d=De(e.extensions),l=le(e.formFields),p=ce(e.giftCertificates),h=de(e.instruments),f=Pe(e.orderBillingAddress),g=pe(e.paymentMethods),m=me(e.paymentProviderCustomer),_=fe(e.paymentStrategies),y=ge(e.pickupOptions),v=_e(e.remoteCheckout),C=ye(e.consignments),S=Ce(e.shippingCountries),I=Se(e.shippingStrategies),w=Te(e.subscriptions),E=Oe(e.storeCredit),b=Re(e.signInEmail),P=Ie(e.consignments,i),A=we(e.checkout,r,i,P,s,u,p),O=Ee(e.order,f,s),T=Ae(A,O),R={billingAddress:r,cart:i,checkout:A,checkoutButton:o,config:re(e.config,e.formFields),consignments:P,countries:a,coupons:s,customer:u,customerStrategies:c,extensions:d,form:l,giftCertificates:p,instruments:h,order:O,orderBillingAddress:f,payment:T,paymentMethods:g,paymentProviderCustomer:m,paymentStrategies:_,pickupOptions:y,remoteCheckout:v,shippingAddress:C,shippingCountries:S,shippingStrategies:I,signInEmail:b,subscriptions:w,storeCredit:E};return t.shouldWarnMutation?(n=R,Object.keys(n).reduce((function(e,t){return e[t]=Bn(n[t]),e}),{})):R}}function Wn(e,t){void 0===e&&(e={});var n,r,i=(n=new w,["catalog_only","empty_cart","invalid_order_id","invalid_order_token","missing_order_token","missing_provider_token","missing_shipping_method","order_completion_error","order_could_not_be_finalized_error","order_create_failed","provider_fatal_error","provider_setup_error","stock_too_low"].forEach((function(e){n.register(e,(function(e,t){return new m(e,t)}))})),n.register("invalid_payment_provider",(function(e){return new l(e)})),n.register("payment_config_not_found",(function(e){return new l(e)})),r=n,function(e){return(0,E.from)(e).pipe((0,b.catchError)((function(e){if(e instanceof Error||e.payload instanceof Error)throw e;if((n=e.payload)&&"object"==typeof n&&["body","headers","status","statusText"].every((function(e){return Object.prototype.hasOwnProperty.call(n,e)}))){var t=e.payload.body&&e.payload.body.detail;throw(0,o.__assign)((0,o.__assign)({},e),{payload:r.createError(e.payload,t)})}var n;throw e})))}),s=Yn();return(0,a.createDataStore)((0,a.combineReducers)({billingAddress:z,cart:K,checkout:On,checkoutButton:re,config:ce,consignments:xt,countries:Ze,coupons:fe,customer:Pe,customerStrategies:De,extensions:Fe,formFields:He,giftCertificates:Ce,instruments:kt,orderBillingAddress:ut,order:et,payment:dt,paymentMethods:ft,paymentStrategies:St,pickupOptions:Zt,paymentProviderCustomer:At,remoteCheckout:Ut,shippingCountries:tn,shippingStrategies:un,signInEmail:fn,subscriptions:En,storeCredit:vn}),e,(0,o.__assign)({actionTransformer:i,stateTransformer:function(e){return s(e)}},t))}function Kn(e,t,n){var r=new WeakMap;function i(e){var n=this;return function(){for(var i,a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];var u,c=a[a.length-1];if(!(u=c,u&&"boolean"==typeof u.useCache?c:{useCache:!1}).useCache)return e.call.apply(e,(0,o.__spreadArrays)([n],a));var d,l=r.get(n)||{};return r.get(n)||r.set(n,l),l[t]||(l[t]=(d=e,(0,Dn.memoize)((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=d.call.apply(d,(0,o.__spreadArrays)([this],e));return n instanceof E.Observable?(0,E.from)(n).pipe((0,b.shareReplay)()):"function"==typeof n?(0,Dn.memoize)((function(e){return(0,E.from)(n(e)).pipe((0,b.shareReplay)())}),{isEqual:_.isEqual}):n}),{isEqual:_.isEqual}))),(i=l[t]).call.apply(i,(0,o.__spreadArrays)([n],a))}}return{get:function(){if("function"!=typeof n.value)throw new Error("Decorator should be used in functions");var e=i.call(this,n.value);return Object.defineProperty(this,t,(0,o.__assign)((0,o.__assign)({},n),{value:e})),e}}}var Zn=function(e){return!!e},Qn=function(){function e(e){this._requestSender=e}return e.prototype.loadPaymentMethodsById=function(e,t){var n=this;return function(r){return new E.Observable((function(i){var s,u=null===(s=r.getState().cart.getCart())||void 0===s?void 0:s.id,c=u?(0,o.__assign)((0,o.__assign)({},null==t?void 0:t.params),{cartId:u}):(0,o.__assign)({},null==t?void 0:t.params);i.next((0,a.createAction)(at.LoadPaymentMethodsRequested)),Promise.all(e.map((function(e){return(0,o.__awaiter)(n,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this._requestSender.loadPaymentMethod(e,(0,o.__assign)((0,o.__assign)({},t),{params:c}))];case 1:return[2,n.sent().body];case 2:return n.sent(),[2,void 0];case 3:return[2]}}))}))}))).then((function(e){var t=e.filter(Zn);i.next((0,a.createAction)(at.LoadPaymentMethodsSucceeded,t)),i.complete()})).catch((function(e){i.next((0,a.createAction)(at.LoadPaymentMethodsFailed,e)),i.complete()}))}))}},e.prototype.loadPaymentMethods=function(e){var t=this;return function(n){return E.Observable.create((function(r){var i=n.getState().cart.getCartOrThrow();r.next((0,a.createAction)(at.LoadPaymentMethodsRequested)),t._requestSender.loadPaymentMethods((0,o.__assign)((0,o.__assign)({},e),{params:(0,o.__assign)((0,o.__assign)({},null==e?void 0:e.params),{cartId:i.id})})).then((function(e){var n={deviceSessionId:e.headers["x-device-session-id"],sessionHash:e.headers["x-session-hash"]},i=e.body,o=Array.isArray(i)?t._filterApplePay(i):i;r.next((0,a.createAction)(at.LoadPaymentMethodsSucceeded,o,n)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(at.LoadPaymentMethodsFailed,e))}))}))}},e.prototype.loadPaymentMethod=function(e,t){var n=this;return function(r){return E.Observable.create((function(i){var s,u=null===(s=r.getState().cart.getCart())||void 0===s?void 0:s.id,c=u?(0,o.__assign)((0,o.__assign)({},null==t?void 0:t.params),{cartId:u}):(0,o.__assign)({},null==t?void 0:t.params);i.next((0,a.createAction)(at.LoadPaymentMethodRequested,void 0,{methodId:e})),n._requestSender.loadPaymentMethod(e,(0,o.__assign)((0,o.__assign)({},t),{params:c})).then((function(t){i.next((0,a.createAction)(at.LoadPaymentMethodSucceeded,t.body,{methodId:e})),i.complete()})).catch((function(t){i.error((0,a.createErrorAction)(at.LoadPaymentMethodFailed,t,{methodId:e}))}))}))}},e.prototype._filterApplePay=function(e){return(0,_.filter)(e,(function(e){return!("applepay"===e.id&&!function(e){return"ApplePaySession"in e}(window))}))},(0,o.__decorate)([Kn],e.prototype,"loadPaymentMethod",null),e}();const Jn=Qn;var Xn;!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(Xn||(Xn={}));const $n=Xn;var er="This API endpoint is for internal use only and may change in the future",tr={"X-Checkout-SDK-Version":"1.661.4"},nr=function(){function e(e){this._requestSender=e}return e.prototype.loadPaymentMethods=function(e){var t=void 0===e?{}:e,n=t.timeout,r=t.params;return this._requestSender.get("/api/storefront/payments",{timeout:n,headers:(0,o.__assign)({Accept:$n.JsonV1,"X-API-INTERNAL":er},tr),params:r})},e.prototype.loadPaymentMethod=function(e,t){var n=void 0===t?{}:t,r=n.timeout,i=n.params,a="/api/storefront/payments/"+e;return this._requestSender.get(a,{timeout:r,headers:(0,o.__assign)({Accept:$n.JsonV1,"X-API-INTERNAL":er},tr),params:i})},e}();const rr=nr,ir=require("@bigcommerce/script-loader");function or(e,t,n){return(r=t)&&r.type&&r.error?(0,E.concat)((0,E.of)(t),(0,E.throwError)((0,a.createErrorAction)(e,t.payload,n))):(0,E.throwError)((0,a.createErrorAction)(e,t,n));var r}const ar=function(e){function t(t){var n=e.call(this,t||"Unable to continue as a guest because the customer is already signed in.")||this;return n.name="UnableToContinueAsGuestError",n.type="unable_to_continue_as_guest",n}return(0,o.__extends)(t,e),t}(p);var sr=function(){function e(e,t){this._requestSender=e,this._subscriptionActionCreator=t}return e.prototype.continueAsGuest=function(e,t){var n=this;return function(r){var i,s,u=r.getState(),c=u.checkout.getCheckout(),d=null===(s=null===(i=u.config.getConfig())||void 0===i?void 0:i.storeConfig.checkoutSettings.features["CHECKOUT-8392.fix_billing_creation_in_checkout"])||void 0===s||s;if(!c)throw new Nn(Mn.MissingCheckout);var l=u.customer.getCustomer();if(l&&!l.isGuest)throw new ar;var p,h=u.billingAddress.getBillingAddress();if(h){h.country;var f=(0,o.__rest)(h,["country"]);p=(0,o.__assign)((0,o.__assign)({},f),e)}else p=e;var g=!(0,_.isEmpty)(h);return(0,E.merge)((0,E.concat)((0,E.of)((0,a.createAction)(T.ContinueAsGuestRequested)),(0,E.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._createOrUpdateBillingAddress(c.id,p,d,g,t)];case 1:return e=n.sent().body,[2,(0,a.createAction)(T.ContinueAsGuestSucceeded,e)]}}))}))}))).pipe((0,b.catchError)((function(e){return or(T.ContinueAsGuestFailed,e)}))),n._updateCustomerConsent(e,t))}},e.prototype.updateAddress=function(e,t){var n=this;return function(r){return E.Observable.create((function(i){var s,u,c=r.getState(),d=c.checkout.getCheckout(),l=null===(u=null===(s=c.config.getConfig())||void 0===s?void 0:s.storeConfig.checkoutSettings.features["CHECKOUT-8392.fix_billing_creation_in_checkout"])||void 0===u||u;if(!d)throw new Nn(Mn.MissingCheckout);i.next((0,a.createAction)(T.UpdateBillingAddressRequested));var p=c.billingAddress.getBillingAddress(),h=!(0,_.isEmpty)(p),f=(0,o.__assign)((0,o.__assign)({},e),{email:void 0===e.email&&p?p.email:e.email});p&&p.id&&(f.id=p.id),n._createOrUpdateBillingAddress(d.id,f,l,h,t).then((function(e){var t=e.body;i.next((0,a.createAction)(T.UpdateBillingAddressSucceeded,t)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(T.UpdateBillingAddressFailed,e))}))}))}},e.prototype._updateCustomerConsent=function(e,t){var n=e.email,r=e.acceptsAbandonedCartEmails,i=e.acceptsMarketingNewsletter;return null==r&&null==i?(0,E.empty)():this._subscriptionActionCreator.updateSubscriptions({email:n,acceptsMarketingNewsletter:i||!1,acceptsAbandonedCartEmails:r||!1},t)},e.prototype._createOrUpdateBillingAddress=function(e,t,n,r,i){return n?r?this._requestSender.updateAddress(e,t,i):this._requestSender.createAddress(e,t,i):t.id?this._requestSender.updateAddress(e,t,i):this._requestSender.createAddress(e,t,i)},e}();const ur=sr;var cr={include:["cart.lineItems.physicalItems.options","cart.lineItems.digitalItems.options","customer","promotions.banners"].join(",")},dr=function(){function e(e){this._requestSender=e}return e.prototype.createAddress=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/api/storefront/checkouts/"+e+"/billing-address",a=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.post(i,{body:t,params:cr,headers:a,timeout:r})},e.prototype.updateAddress=function(e,t,n){var r=(void 0===n?{}:n).timeout,i=t.id,a=(0,o.__rest)(t,["id"]),s="/api/storefront/checkouts/"+e+"/billing-address/"+i,u=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.put(s,{params:cr,body:a,headers:u,timeout:r})},e}();const lr=dr;var pr=function(){function e(e){this._requestSender=e}return e.prototype.createBuyNowCart=function(e,t){var n=(void 0===t?{}:t).timeout,r=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.post("/api/storefront/carts",{body:e,headers:r,timeout:n})},e}();const hr=pr;var fr=function(){function e(e,t,n){this._checkoutRequestSender=e,this._configActionCreator=t,this._formFieldsActionCreator=n}return e.prototype.loadCheckout=function(e,t){var n=this;return function(r){return(0,E.concat)((0,E.of)((0,a.createAction)(P.LoadCheckoutRequested)),(0,E.merge)(n._configActionCreator.loadConfig({useCache:!0,timeout:null==t?void 0:t.timeout,params:{checkoutId:e}}),n._formFieldsActionCreator.loadFormFields({useCache:!0,timeout:null==t?void 0:t.timeout})),(0,E.defer)((function(){return n._checkoutRequestSender.loadCheckout(e,t).then((function(e){var t=e.body;return(0,a.createAction)(P.LoadCheckoutSucceeded,n._shouldTransformCustomerAddress(r.getState().config.getStoreConfigOrThrow())?n._transformCustomerAddresses(t):t)}))}))).pipe((0,b.catchError)((function(e){return or(P.LoadCheckoutFailed,e)})))}},e.prototype.loadDefaultCheckout=function(e){var t=this;return function(n){return(0,E.concat)((0,E.of)((0,a.createAction)(P.LoadCheckoutRequested)),(0,E.merge)(t._configActionCreator.loadConfig({useCache:!0,timeout:null==e?void 0:e.timeout}),t._formFieldsActionCreator.loadFormFields({useCache:!0,timeout:null==e?void 0:e.timeout})),(0,E.defer)((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=n.getState(),!(r=t.config.getContextConfig())||!r.checkoutId)throw new Nn(Mn.MissingCheckoutConfig);return[4,this._checkoutRequestSender.loadCheckout(r.checkoutId,e)];case 1:return i=o.sent().body,[2,(0,a.createAction)(P.LoadCheckoutSucceeded,this._shouldTransformCustomerAddress(t.config.getStoreConfigOrThrow())?this._transformCustomerAddresses(i):i)]}}))}))}))).pipe((0,b.catchError)((function(e){return or(P.LoadCheckoutFailed,e)})))}},e.prototype.updateCheckout=function(e,t){var n=this;return function(r){return new E.Observable((function(i){var o=r.getState().checkout.getCheckout();if(!o)throw new Nn(Mn.MissingCheckout);i.next((0,a.createAction)(P.UpdateCheckoutRequested)),n._checkoutRequestSender.updateCheckout(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(P.UpdateCheckoutSucceeded,t)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(P.UpdateCheckoutFailed,e))}))}))}},e.prototype.loadCurrentCheckout=function(e){var t=this;return function(n){var r=n.getState().checkout.getCheckout();if(!r)throw new Nn(Mn.MissingCheckout);return t.loadCheckout(r.id,e)(n)}},e.prototype._shouldTransformCustomerAddress=function(e){var t;return null===(t=e.checkoutSettings.features["CHECKOUT-8183.set_shouldSaveAddress_false_for_existing_address"])||void 0===t||t},e.prototype._transformCustomerAddresses=function(e){return(0,o.__assign)((0,o.__assign)({},e),{customer:(0,o.__assign)((0,o.__assign)({},e.customer),{addresses:e.customer.addresses.map((function(e){return(0,o.__assign)((0,o.__assign)({},e),{shouldSaveAddress:!1})}))})})},e}();const gr=fr;function mr(e){return(0,_.uniq)(e).join(",")}function _r(e,t){return void 0===t&&(t=[]),Array.isArray(t)?mr((0,o.__spreadArrays)(e,t)):function(e,t){var n=(0,_.keys)((0,_.pickBy)(t,(function(e){return!e}))),r=(0,_.keys)((0,_.filter)(t));return mr((0,o.__spreadArrays)((0,_.difference)(e,n),r))}(e,t)}const yr=["cart.lineItems.physicalItems.options","cart.lineItems.digitalItems.options","customer","customer.customerGroup","payments","promotions.banners"],vr=function(e){function t(t){var n=e.call(this,t,{message:t.body.title})||this;return n.name="CheckoutNotAvailableError",n.type="checkout_not_available",n}return(0,o.__extends)(t,e),t}(g);var Cr=function(){function e(e){this._requestSender=e}return e.prototype.loadCheckout=function(e,t){var n=void 0===t?{}:t,r=n.params,i=(void 0===r?{}:r).include,a=n.timeout,s="/api/storefront/checkout/"+e,u=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.get(s,{params:{include:_r(yr,i)},headers:u,timeout:a}).catch((function(e){if(e.status>=400&&e.status<500)throw new vr(e);throw e}))},e.prototype.updateCheckout=function(e,t,n){var r=void 0===n?{}:n,i=r.params,a=(void 0===i?{}:i).include,s=r.timeout,u="/api/storefront/checkout/"+e,c=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.put(u,{params:{include:_r(yr,a)},body:t,headers:c,timeout:s})},e}();const Sr=Cr,Ir=function(){function e(){}return e.prototype.isEqual=function(e,t){return(0,_.isEqual)(this._normalize(e),this._normalize(t))},e.prototype._normalize=function(e){return{cartAmount:e.cartAmount,currency:e.currency,id:e.id,lineItems:{digitalItems:e.lineItems.digitalItems.slice().sort((function(e,t){return(""+e.productId+e.variantId).localeCompare(""+t.productId+t.variantId)})).map((function(e){return{extendedSalePrice:e.extendedSalePrice,productId:e.productId,quantity:e.quantity,variantId:e.variantId}})),giftCertificates:e.lineItems.giftCertificates.slice().sort((function(e,t){return(""+e.id).localeCompare(""+t.id)})).map((function(e){return{amount:e.amount,recipient:e.recipient}})),physicalItems:e.lineItems.physicalItems.slice().sort((function(e,t){return(""+e.productId+e.variantId).localeCompare(""+t.productId+t.variantId)})).map((function(e){return{extendedSalePrice:e.extendedSalePrice,productId:e.productId,quantity:e.quantity,variantId:e.variantId,giftWrapping:e.giftWrapping}}))}}},e}(),wr=function(e){function t(t,n){var r=e.call(this,"An update to your shopping cart has been detected and your available shipping costs have been updated.")||this;return r.name="CartChangedError",r.type="cart_changed",r.data={previous:t,updated:n},r}return(0,o.__extends)(t,e),t}(p),Er=function(){function e(e){this._checkoutRequestSender=e}return e.prototype.validate=function(e,t){var n=this;if(!e)throw new Nn(Mn.MissingCheckout);return this._checkoutRequestSender.loadCheckout(e.id,t).then((function(t){var r=new Ir;if(!(e.outstandingBalance===t.body.outstandingBalance&&n._compareCoupons(e.coupons,t.body.coupons)&&n._compareGiftCertificates(e.giftCertificates,t.body.giftCertificates)&&r.isEqual(e.cart,t.body.cart)))throw new wr(n._getComparableCheckout(e),n._getComparableCheckout(t.body))}))},e.prototype._compareCoupons=function(e,t){return(0,_.isEqual)((0,_.map)(e,"code"),(0,_.map)(t,"code"))},e.prototype._compareGiftCertificates=function(e,t){return(0,_.isEqual)((0,_.map)(e,"code"),(0,_.map)(t,"code"))},e.prototype._getComparableCheckout=function(e){var t=e.cart,n=e.coupons,r=e.giftCertificates,i=e.outstandingBalance;return{cart:{cartAmount:t.cartAmount,currency:t.currency,lineItems:t.lineItems},coupons:n,giftCertificates:r,outstandingBalance:i}},e}(),br=function(){function e(e){this._configRequestSender=e}return e.prototype.loadConfig=function(e){var t=this;return E.Observable.create((function(n){n.next((0,a.createAction)(X.LoadConfigRequested)),t._configRequestSender.loadConfig(e).then((function(e){n.next((0,a.createAction)(X.LoadConfigSucceeded,e.body)),n.complete()})).catch((function(e){n.error((0,a.createErrorAction)(X.LoadConfigFailed,e))}))}))},(0,o.__decorate)([Kn],e.prototype,"loadConfig",null),e}();var Pr=function(){function e(e){this._requestSender=e}return e.prototype.loadConfig=function(e){var t=void 0===e?{}:e,n=t.timeout,r=t.params;return this._requestSender.get("/api/storefront/checkout-settings",{timeout:n,headers:(0,o.__assign)({Accept:$n.JsonV1,"X-API-INTERNAL":er},tr),params:r}).catch((function(e){if(e.status>=400&&e.status<500)throw new vr(e);throw e}))},e}();const Ar=Pr;function Or(e){var t=e;return"object"==typeof t&&"object"==typeof t.payload&&"string"==typeof t.payload.token}var Tr=function(){function e(e,t,n){this._customerRequestSender=e,this._checkoutActionCreator=t,this._spamProtectionActionCreator=n}return e.prototype.createCustomer=function(e,t){var n=this;return function(r){var i=r.getState().config.getStoreConfigOrThrow().checkoutSettings.isStorefrontSpamProtectionEnabled,s=function(i){return(0,E.from)(n._customerRequestSender.createAccount((0,o.__assign)((0,o.__assign)({},e),{token:i}),t)).pipe((0,b.switchMap)((function(){return(0,E.concat)(n._checkoutActionCreator.loadCurrentCheckout(t)(r),(0,E.of)((0,a.createAction)(ye.CreateCustomerSucceeded)))})))};return(0,E.concat)((0,E.of)((0,a.createAction)(ye.CreateCustomerRequested)),i?(0,E.from)(n._spamProtectionActionCreator.execute()(r)).pipe((0,b.switchMap)((function(e){var t;return Or(e)?(0,E.concat)((0,E.of)(e),s(null===(t=e.payload)||void 0===t?void 0:t.token)):(0,E.of)(e)}))):s()).pipe((0,b.catchError)((function(e){return or(ye.CreateCustomerFailed,e)})))}},e.prototype.createAddress=function(e,t){var n=this;return(0,E.concat)((0,E.of)((0,a.createAction)(ye.CreateCustomerAddressRequested)),(0,E.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._customerRequestSender.createAddress(e,t)];case 1:return n=r.sent().body,[2,(0,a.createAction)(ye.CreateCustomerAddressSucceeded,n)]}}))}))}))).pipe((0,b.catchError)((function(e){return or(ye.CreateCustomerAddressFailed,e)})))},e.prototype.signInCustomer=function(e,t){var n=this;return function(r){return(0,E.concat)((0,E.of)((0,a.createAction)(ye.SignInCustomerRequested)),(0,E.from)(n._customerRequestSender.signInCustomer(e,t)).pipe((0,b.switchMap)((function(e){var i=e.body;return(0,E.concat)(n._checkoutActionCreator.loadCurrentCheckout(t)(r),(0,E.of)((0,a.createAction)(ye.SignInCustomerSucceeded,i.data)))})))).pipe((0,b.catchError)((function(e){return or(ye.SignInCustomerFailed,e)})))}},e.prototype.signOutCustomer=function(e){var t=this;return function(n){return(0,E.concat)((0,E.of)((0,a.createAction)(ye.SignOutCustomerRequested)),(0,E.from)(t._customerRequestSender.signOutCustomer(e)).pipe((0,b.switchMap)((function(r){var i=r.body;return(0,E.concat)(t._checkoutActionCreator.loadCurrentCheckout(e)(n),(0,E.of)((0,a.createAction)(ye.SignOutCustomerSucceeded,i.data)))})))).pipe((0,b.catchError)((function(e){return or(ye.SignOutCustomerFailed,e)})))}},e}();const Rr=Tr;var kr=function(){function e(e){this._requestSender=e}return e.prototype.createAccount=function(e,t){var n=(void 0===t?{}:t).timeout;return this._requestSender.post("/api/storefront/customer",{timeout:n,headers:tr,body:e})},e.prototype.createAddress=function(e,t){var n=(void 0===t?{}:t).timeout;return this._requestSender.post("/api/storefront/customer-address",{timeout:n,headers:tr,body:e})},e.prototype.signInCustomer=function(e,t){var n=(void 0===t?{}:t).timeout;return this._requestSender.post("/internalapi/v1/checkout/customer",{timeout:n,headers:tr,body:e})},e.prototype.signOutCustomer=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.delete("/internalapi/v1/checkout/customer",{timeout:t,headers:tr})},e}();const Dr=kr;var Mr=function(){function e(e){this._formFieldsRequestSender=e}return e.prototype.loadFormFields=function(e){var t=this;return(0,E.concat)((0,E.of)((0,a.createAction)(ze.LoadFormFieldsRequested)),(0,E.defer)((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._formFieldsRequestSender.loadFields(e)];case 1:return t=n.sent().body,[2,(0,a.createAction)(ze.LoadFormFieldsSucceeded,t)]}}))}))}))).pipe((0,b.catchError)((function(e){return or(ze.LoadFormFieldsFailed,e)})))},(0,o.__decorate)([Kn],e.prototype,"loadFormFields",null),e}();const Nr=Mr;var Lr=function(){function e(e){this._requestSender=e}return e.prototype.loadFields=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.get("/api/storefront/form-fields",{timeout:t,headers:(0,o.__assign)({Accept:$n.JsonV1,"X-API-INTERNAL":er},tr)})},e}();const zr=Lr,Ur=function(e){var t=this,n=new Promise((function(e,n){t.cancel=n}));this.promise=Promise.race([e,n])},Fr=function(e){function t(t){var n=e.call(this,t||"Unable to proceed because the required element is unexpectedly detached from the page.")||this;return n.name="UnexpectedDetachmentError",n.type="unexpected_detachment",n}return(0,o.__extends)(t,e),t}(p);var Br=function(){function e(e){this._mutationObserver=e}return e.prototype.ensurePresence=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:n=new Ur(t),(r=this._mutationObserver.create((function(t){t.forEach((function(t){0!==Array.from(t.removedNodes).filter((function(t){return e.some((function(e){return t===e||t.contains(e)}))})).length&&n.cancel(new Fr)}))}))).observe(document.body,{childList:!0,subtree:!0}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,n.promise];case 2:return i=o.sent(),r.disconnect(),[2,i];case 3:throw a=o.sent(),r.disconnect(),a;case 4:return[2]}}))}))},e}();const qr=Br;var xr=function(){function e(e){void 0===e&&(e=window),this._window=e}return e.prototype.create=function(e){return new this._window.MutationObserver(e)},e}();const Gr=function(e){function t(t){var n=e.call(this,t||"Invalid arguments have been provided.")||this;return n.name="InvalidArgumentError",n.type="invalid_argument",n}return(0,o.__extends)(t,e),t}(p);function Vr(e){if(!/^(https?:)?\/\//.test(e))throw new Gr("The provided URL must be absolute.");var t=document.createElement("a");t.href=e;var n=t.port&&-1!==e.indexOf(t.hostname+":"+t.port)?t.port:"";return{hash:t.hash,hostname:t.hostname,href:t.href,origin:t.protocol+"//"+t.hostname+(n?":"+n:""),pathname:t.pathname,port:n,protocol:t.protocol,search:t.search}}function Hr(e,t){return e.type===t}const jr=function(){function e(e,t,n){this._targetWindow=t,this._context=n,this._targetOrigin="*"===e?"*":Vr(e).origin}return e.prototype.post=function(e,t){var n=this,r=this._targetWindow;if(window!==r){if(!r)throw new Error("Unable to post message because target window is not set.");var i=t&&(0,E.fromEvent)(window,"message").pipe((0,b.filter)((function(e){return e.origin===n._targetOrigin&&Hr(e.data,e.data.type)&&-1!==[t.successType,t.errorType].indexOf(e.data.type)})),(0,b.map)((function(e){if(t.errorType===e.data.type)throw e.data;return e.data})),(0,b.take)(1)).toPromise();return r.postMessage((0,o.__assign)((0,o.__assign)({},e),{context:this._context}),this._targetOrigin),i}},e.prototype.setTarget=function(e){this._targetWindow=e},e.prototype.setContext=function(e){this._context=e},e}(),Yr=function(e,t,n){return t&&n?Wr(0,t,n):function(e){var t=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,o.__extends)(t,e),t}(e);return Object.getOwnPropertyNames(e.prototype).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e.prototype,n);r&&"constructor"!==n&&Object.defineProperty(t.prototype,n,Wr(e.prototype,n,r))})),t}(e)};function Wr(e,t,n){if("function"!=typeof n.value)return n;var r=n.value;return{get:function(){var e=r.bind(this);return Object.defineProperty(this,t,(0,o.__assign)((0,o.__assign)({},n),{value:e})),e},set:function(e){r=e}}}var Kr=function(){function e(e){var t;this._sourceOrigins=[Vr(e).origin,(t=Vr(e),Vr(0===t.hostname.indexOf("www")?t.href:t.href.replace(t.hostname,"www."+t.hostname))).origin],this._isListening=!1,this._listeners={}}return e.prototype.listen=function(){this._isListening||(this._isListening=!0,window.addEventListener("message",this._handleMessage))},e.prototype.stopListen=function(){this._isListening&&(this._isListening=!1,window.removeEventListener("message",this._handleMessage))},e.prototype.addListener=function(e,t){var n=this._listeners[e];n||(this._listeners[e]=n=[]),-1===n.indexOf(t)&&n.push(t)},e.prototype.removeListener=function(e,t){var n=this._listeners[e];if(n){var r=n.indexOf(t);r>=0&&n.splice(r,1)}},e.prototype.trigger=function(e,t){var n=this._listeners[e.type];n&&n.forEach((function(n){return t?n(e,t):n(e)}))},e.prototype._handleMessage=function(e){if(-1!==this._sourceOrigins.indexOf(e.origin)&&Hr(e.data,e.data.type)){var t=e.data,n=t.context,r=(0,o.__rest)(t,["context"]);this.trigger(r,n)}},(0,o.__decorate)([Yr],e.prototype,"_handleMessage",null),e}();const Zr=Kr,Qr=function(e){function t(){var t=e.call(this,"You haven't complete our spam protection challenge. Please try again.")||this;return t.name="SpamProtectionChallengeNotCompletedError",t.type="spam_protection_challenge_not_completed",t}return(0,o.__extends)(t,e),t}(p),Jr=function(e){function t(){var t=e.call(this,"Please complete our human verification challenge and try again.")||this;return t.name="CardingProtectionChallengeNotCompletedError",t.type="carding_protection_challenge_not_completed",t}return(0,o.__extends)(t,e),t}(p),Xr=function(e){function t(){var t=e.call(this,"We were not able to verify that you are not a robot. Please try again.")||this;return t.name="CardingProtectionFailedError",t.type="carding_protection_failed",t}return(0,o.__extends)(t,e),t}(p);var $r=function(){function e(e){this._googleRecaptcha=e}return e.prototype.handle=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){return"string"==typeof e?[2,this.handleWithRecaptchaSitekey(e,t)]:[2,this.handleWithPaymentHumanVerificationRequestError(e)]}))}))},e.prototype.handleWithPaymentHumanVerificationRequestError=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:if(!this._isPaymentHumanVerificationRequest(e))throw e;return[4,this._initialize(e.body.additional_action_required.data.key)];case 1:return t.sent(),[2,this._performRecaptcha()]}}))}))},e.prototype.handleWithRecaptchaSitekey=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("recaptcha_v2"!==e)throw Error("Human verification method is not supported.");if(!t)throw Error("Recaptcha site key is missing.");return[4,this._initialize(t)];case 1:return n.sent(),[2,this._performRecaptcha()]}}))}))},e.prototype._performRecaptcha=function(){var e=this;return this._googleRecaptcha.execute().pipe((0,b.take)(1)).pipe((0,b.switchMap)((function(t){var n=t.error,r=t.token;return(0,o.__awaiter)(e,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){if(n instanceof Qr)throw new Jr;if(n||!r)throw new Xr;return[2,{type:"recaptcha_v2_verification",data:{human_verification_token:r}}]}))}))}))).toPromise()},e.prototype._initialize=function(e){var t="cardingProtectionContainer",n=document.getElementById(t);return n&&n.parentNode&&n.parentNode.removeChild(n),(n=document.createElement("div")).setAttribute("id",t),document.body.appendChild(n),this._googleRecaptcha.load(t,e)},e.prototype._isPaymentHumanVerificationRequest=function(e){var t=e.body||{},n=t.additional_action_required;return"additional_action_required"===t.status&&n&&"recaptcha_v2_verification"===n.type},e}();const ei=$r;var ti;!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(ti||(ti={}));const ni=function(e){function t(t){var n=e.call(this,function(e){switch(e){case ti.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case ti.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case ti.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case ti.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(t))||this;return n.subtype=t,n.name="NotInitializedError",n.type="not_initialized",n}return(0,o.__extends)(t,e),t}(p),ri=function(e){function t(){var t=e.call(this,"We were not able to complete your spam protection verification. Please try again.")||this;return t.name="SpamProtectionFailedError",t.type="spam_protection_failed",t}return(0,o.__extends)(t,e),t}(p),ii=function(e){function t(){var t=e.call(this,"Spam protection is not loaded. Please try again.")||this;return t.name="SpamProtectionNotLoadedError",t.type="spam_protection_failed",t}return(0,o.__extends)(t,e),t}(p),oi=function(){function e(e,t){var n=this;this.googleRecaptchaScriptLoader=e,this.mutationObserverFactory=t,this._memoized=(0,Dn.memoize)((function(e,t,r){var i=new E.Subject;if(!r)throw new Error;return n._widgetId=e.render(r.id,{sitekey:t,size:"invisible",callback:function(){i.next({token:e.getResponse(n._widgetId)}),e.reset(n._widgetId)},"error-callback":function(){i.next({error:new ri})}}),i}),{isEqual:function(e,t){return e===t}})}return e.prototype.load=function(e,t){var n=this;return this.googleRecaptchaScriptLoader.load().then((function(r){r&&(n._event$=n._memoized(r,t,document.getElementById(e)),n._recaptcha=r)}))},e.prototype.execute=function(){var e=this;return(0,E.defer)((function(){var t=e._event$,n=e._recaptcha;if(!t||!n)throw new ni(ti.SpamProtectionNotInitialized);return(0,E.defer)((function(){var e=document.querySelector('iframe[src*="bframe"]');return e?(0,E.of)(e):(0,E.throwError)(new ii)})).pipe((0,b.retryWhen)((function(e){return e.pipe((0,b.delay)(250),(0,b.switchMap)((function(e,t){return t<28?(0,E.of)(e):(0,E.throwError)(e)})))})),(0,b.switchMap)((function(r){return e._watchRecaptchaChallengeWindow(t,r),n.execute(e._widgetId),t})),(0,b.catchError)((function(e){return(0,E.of)({error:e})})))}))},e.prototype._watchRecaptchaChallengeWindow=function(e,t){var n=t.parentElement;if(!n)throw new ii;var r=n.parentElement;if(!r)throw new ii;this.mutationObserverFactory.create((function(){"hidden"===r.style.visibility&&e.next({error:new Qr})})).observe(r,{attributes:!0,attributeFilter:["style"]})},e}(),ai=function(){function e(e,t){void 0===t&&(t=window),this._scriptLoader=e,this._window=t}return e.prototype.load=function(){return this._loadPromise||(this._loadPromise=this._loadScript()),this._loadPromise},e.prototype._loadScript=function(){var e=this,t="initRecaptcha",n=["onload="+t,"render=explicit"].join("&");return new Promise((function(r,i){e._window[t]=function(){return r(e._window.grecaptcha)},e._scriptLoader.loadScript("//www.google.com/recaptcha/api.js?"+n).catch((function(t){e._loadPromise=void 0,i(t)}))}))},e}();function si(e){return new oi(new ai(e),new xr)}const ui=function(e){function t(t){var n=e.call(this,t||"Unable to proceed due to invalid configuration provided for the hosted payment form.")||this;return n.name="InvalidHostedFormConfigError",n.type="invalid_hosted_form_config",n}return(0,o.__extends)(t,e),t}(p),ci=function(e){function t(t){var n=e.call(this,t||"Unable to proceed due to an unknown error with the hosted payment form.")||this;return n.name="InvalidHostedFormError",n.type="invalid_hosted_form",n}return(0,o.__extends)(t,e),t}(p);var di=function(e){function t(t){var n=e.call(this,(0,o.__spreadArrays)(["Unable to proceed due to invalid user input values"],(0,_.flatMap)((0,_.values)(t),(function(e){return(0,_.map)(e,(function(e){return e.message}))}))).join(". "))||this;return n.errors=t,n.name="InvalidHostedFormValueError",n.type="invalid_hosted_form_value",n}return(0,o.__extends)(t,e),t}(p);const li=di;var pi,hi;!function(e){e.AttachRequested="HOSTED_FIELD:ATTACH_REQUESTED",e.SubmitRequested="HOSTED_FIELD:SUBMITTED_REQUESTED",e.ValidateRequested="HOSTED_FIELD:VALIDATE_REQUESTED",e.StoredCardRequested="HOSTED_FIELD:STORED_CARD_REQUESTED"}(pi||(pi={})),function(e){e.AttachSucceeded="HOSTED_INPUT:ATTACH_SUCCEEDED",e.AttachFailed="HOSTED_INPUT:ATTACH_FAILED",e.BinChanged="HOSTED_INPUT:BIN_CHANGED",e.Blurred="HOSTED_INPUT:BLURRED",e.Changed="HOSTED_INPUT:CHANGED",e.CardTypeChanged="HOSTED_INPUT:CARD_TYPE_CHANGED",e.Entered="HOSTED_INPUT:ENTERED",e.Focused="HOSTED_INPUT:FOCUSED",e.SubmitSucceeded="HOSTED_INPUT:SUBMIT_SUCCEEDED",e.SubmitFailed="HOSTED_INPUT:SUBMIT_FAILED",e.Validated="HOSTED_INPUT:VALIDATED",e.StoredCardSucceeded="HOSTED_INPUT:STORED_CARD_SUCCEEDED",e.StoredCardFailed="HOSTED_INPUT:STORED_CARD_FAILED"}(hi||(hi={}));var fi=function(){function e(e,t,n,r,i,o,a,s,u){this._type=e,this._containerId=t,this._placeholder=n,this._accessibilityLabel=r,this._styles=i,this._eventPoster=o,this._eventListener=a,this._detachmentObserver=s,this._cardInstrument=u,this._iframe=document.createElement("iframe"),this._iframe.src="/checkout/payment/hosted-field?version=1.661.4",this._iframe.style.border="none",this._iframe.style.height="100%",this._iframe.style.overflow="hidden",this._iframe.style.width="100%"}return e.prototype.getType=function(){return this._type},e.prototype.attach=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n=this;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:if(!(e=document.getElementById(this._containerId)))throw new ui("Unable to proceed because the provided container ID is not valid.");return e.appendChild(this._iframe),this._eventListener.listen(),t=(0,E.fromEvent)(this._iframe,"load").pipe((0,b.switchMap)((function(e){var t=e.target;return(0,o.__awaiter)(n,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if(!(e=t&&t.contentWindow))throw new Error("The content window of the iframe cannot be accessed.");return this._eventPoster.setTarget(e),[4,this._eventPoster.post({type:pi.AttachRequested,payload:{accessibilityLabel:this._accessibilityLabel,cardInstrument:this._cardInstrument,fontUrls:this._getFontUrls(),placeholder:this._placeholder,styles:this._styles,origin:document.location.origin,type:this._type}},{successType:hi.AttachSucceeded,errorType:hi.AttachFailed})];case 1:return n.sent(),[2]}}))}))})),(0,b.take)(1)).toPromise(),[4,this._detachmentObserver.ensurePresence([this._iframe],t)];case 1:return r.sent(),[2]}}))}))},e.prototype.detach=function(){this._iframe.parentElement&&(this._iframe.parentElement.removeChild(this._iframe),this._eventListener.stopListen())},e.prototype.submitForm=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=this._eventPoster.post({type:pi.SubmitRequested,payload:{fields:e,data:t}},{successType:hi.SubmitSucceeded,errorType:hi.SubmitFailed}),[4,this._detachmentObserver.ensurePresence([this._iframe],n)];case 1:return[2,i.sent()];case 2:if(r=i.sent(),this._isSubmitErrorEvent(r)){if("hosted_form_error"===r.payload.error.code)throw new ci(r.payload.error.message);if(r.payload.response)throw v(r.payload.response);throw new Error(r.payload.error.message)}throw r;case 3:return[2]}}))}))},e.prototype.submitStoredCardForm=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){return n=this._eventPoster.post({type:pi.StoredCardRequested,payload:{fields:e,data:t}},{successType:hi.StoredCardSucceeded,errorType:hi.StoredCardFailed}),[2,this._detachmentObserver.ensurePresence([this._iframe],n)]}))}))},e.prototype.validateForm=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e=this._eventPoster.post({type:pi.ValidateRequested},{successType:hi.Validated}),[4,this._detachmentObserver.ensurePresence([this._iframe],e)];case 1:if(!(t=n.sent().payload).isValid)throw new li(t.errors);return[2]}}))}))},e.prototype._getFontUrls=function(){var e=this,t="fonts.googleapis.com",n=document.querySelectorAll("link[href*='"+t+"'][rel='stylesheet']");return Array.prototype.slice.call(n).filter((function(e){return Vr(e.href).hostname===t})).filter((function(t){return(0,_.values)(e._styles).map((function(e){return e&&e.fontFamily})).filter((function(e){return"string"==typeof e})).some((function(e){return e.split(/,\s/).some((function(e){return-1!==t.href.indexOf(e.replace(" ","+"))}))}))})).map((function(e){return e.href}))},e.prototype._isSubmitErrorEvent=function(e){return e.type===hi.SubmitFailed},e}();const gi=fi;var mi=function(){function e(e,t,n,r,i){var a=this;this._fields=e,this._eventListener=t,this._payloadTransformer=n,this._eventCallbacks=r,this._paymentHumanVerificationHandler=i,this._handleEnter=function(e){var t=e.payload;return(0,o.__awaiter)(a,void 0,void 0,(function(){var e,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.validate()];case 1:return r.sent(),[3,3];case 2:if("InvalidHostedFormValueError"!==(e=r.sent()).name)throw e;return[3,3];case 3:return(void 0===(n=this._eventCallbacks.onEnter)?_.noop:n)(t),[2]}}))}))};var s=this._eventCallbacks,u=s.onBlur,c=void 0===u?_.noop:u,d=s.onCardTypeChange,l=void 0===d?_.noop:d,p=s.onFocus,h=void 0===p?_.noop:p,f=s.onValidate,g=void 0===f?_.noop:f;this._eventListener.addListener(hi.Blurred,(function(e){var t=e.payload;return c(t)})),this._eventListener.addListener(hi.CardTypeChanged,(function(e){var t=e.payload;return l(t)})),this._eventListener.addListener(hi.Focused,(function(e){var t=e.payload;return h(t)})),this._eventListener.addListener(hi.Validated,(function(e){var t=e.payload;return g(t)})),this._eventListener.addListener(hi.Entered,this._handleEnter),this._eventListener.addListener(hi.CardTypeChanged,(function(e){var t=e.payload;return a._cardType=t.cardType})),this._eventListener.addListener(hi.BinChanged,(function(e){var t=e.payload;return a._bin=t.bin}))}return e.prototype.getBin=function(){return this._bin},e.prototype.getCardType=function(){return this._cardType},e.prototype.attach=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return this._eventListener.listen(),e=this._getFirstField(),t=(0,_.without)(this._fields,e),[4,e.attach()];case 1:return n.sent(),[4,Promise.all(t.map((function(e){return e.attach()})))];case 2:return n.sent(),[2]}}))}))},e.prototype.detach=function(){this._eventListener.stopListen(),this._fields.forEach((function(e){e.detach()}))},e.prototype.submit=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,5]),[4,this._getFirstField().submitForm(this._fields.map((function(e){return e.getType()})),this._payloadTransformer.transform(e,t))];case 1:case 4:return[2,i.sent()];case 2:return n=i.sent(),[4,this._paymentHumanVerificationHandler.handle(n)];case 3:return r=i.sent(),[4,this._getFirstField().submitForm(this._fields.map((function(e){return e.getType()})),this._payloadTransformer.transform(e,r))];case 5:return[2]}}))}))},e.prototype.submitStoredCard=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){return[2,this._getFirstField().submitStoredCardForm(e.fields,e.data)]}))}))},e.prototype.validate=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this._getFirstField().validateForm()]}))}))},e.prototype._getFirstField=function(){var e=this._fields[0];if(!e)throw new ui("Unable to proceed because the payment form has no field defined.");return e},e}();const _i=mi;function yi(e){return Boolean(e.instrumentId)}const vi=function(){function e(e){this._store=e}return e.prototype.transform=function(e,t){var n=this._store.getState(),r=n.checkout.getCheckout(),i=n.config.getConfig(),o=n.instruments.getInstrumentsMeta(),a=n.order.getOrder(),s=n.order.getOrderMeta(),u=(0,_.omit)(e.paymentData,"ccExpiry","ccName","ccNumber","ccCvv"),c=n.paymentMethods.getPaymentMethod(e.methodId,e.gatewayId),d=n.paymentMethods.getPaymentMethodsMeta(),l=o&&u&&yi(u)?n.payment.getPaymentToken()+", "+o.vaultAccessToken:n.payment.getPaymentToken();if(!l)throw new Nn(Mn.MissingPaymentToken);return{additionalAction:t,authToken:l,checkout:r,config:i,order:a,orderMeta:s,payment:u,paymentMethod:c,paymentMethodMeta:d}},e}(),Ci=function(){function e(e){this._store=e}return e.prototype.create=function(e,t){var n=this,r=Object.keys(t.fields).reduce((function(r,i){var a=t.fields[i];return a?(0,o.__spreadArrays)(r,[new gi(i,a.containerId,a.placeholder||"",a.accessibilityLabel||"",t.styles||{},new jr(e),new Zr(e),new qr(new xr),"instrumentId"in a?n._getCardInstrument(a.instrumentId):void 0)]):r}),[]);return new _i(r,new Zr(e),new vi(this._store),(0,_.pick)(t,"onBlur","onEnter","onFocus","onCardTypeChange","onValidate"),new ei(si((0,ir.createScriptLoader)())))},e.prototype._getCardInstrument=function(e){var t=(0,this._store.getState().instruments.getCardInstrument)(e);if(!t)throw new Nn(Mn.MissingPaymentInstrument);return t},e}(),Si=function(e){function t(){var t=e.call(this,"You haven't complete our spam check. Please try again.")||this;return t.name="SpamProtectionNotCompletedError",t.type="spam_protection_not_completed",t}return(0,o.__extends)(t,e),t}(p),Ii=function(){function e(e,t){this._orderRequestSender=e,this._checkoutValidator=t}return e.prototype.loadOrder=function(e,t){var n=this;return new E.Observable((function(r){r.next((0,a.createAction)(se.LoadOrderRequested)),n._orderRequestSender.loadOrder(e,t).then((function(e){r.next((0,a.createAction)(se.LoadOrderSucceeded,e.body)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(se.LoadOrderFailed,e))}))}))},e.prototype.loadOrderPayments=function(e,t){var n=this;return new E.Observable((function(r){r.next((0,a.createAction)(se.LoadOrderPaymentsRequested)),n._orderRequestSender.loadOrder(e,t).then((function(e){r.next((0,a.createAction)(se.LoadOrderPaymentsSucceeded,e.body)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(se.LoadOrderPaymentsFailed,e))}))}))},e.prototype.loadCurrentOrder=function(e){var t=this;return function(n){return(0,E.defer)((function(){var r=t._getCurrentOrderId(n.getState());if(!r)throw new Nn(Mn.MissingOrderId);return t.loadOrder(r,e)}))}},e.prototype.submitOrder=function(e,t){var n=this;return function(r){return(0,E.concat)((0,E.of)((0,a.createAction)(se.SubmitOrderRequested)),(0,E.defer)((function(){var i=r.getState(),s=i.config.getExternalSource(),u=i.config.getVariantIdentificationToken(),c=i.checkout.getCheckout();if(!c)throw new Nn(Mn.MissingCheckout);if(c.shouldExecuteSpamCheck)throw new Si;return(0,E.from)(n._checkoutValidator.validate(c,t).then((function(){return n._orderRequestSender.submitOrder(n._mapToOrderRequestBody(null!=e?e:{},c.id,c.customerMessage,s),(0,o.__assign)((0,o.__assign)({},t),{headers:{checkoutVariant:u}}))}))).pipe((0,b.switchMap)((function(e){return(0,E.concat)(n.loadOrder(e.body.data.order.orderId,t),(0,E.of)((0,a.createAction)(se.SubmitOrderSucceeded,e.body.data,(0,o.__assign)((0,o.__assign)({},e.body.meta),{token:e.headers.token}))))})))})).pipe((0,b.catchError)((function(e){return or(se.SubmitOrderFailed,e)}))))}},e.prototype.finalizeOrder=function(e,t){var n=this;return(0,E.concat)((0,E.of)((0,a.createAction)(se.FinalizeOrderRequested)),(0,E.from)(this._orderRequestSender.finalizeOrder(e,t)).pipe((0,b.switchMap)((function(r){return(0,E.concat)(n.loadOrder(e,t),(0,E.of)((0,a.createAction)(se.FinalizeOrderSucceeded,r.body.data)))})))).pipe((0,b.catchError)((function(e){return or(se.FinalizeOrderFailed,e)})))},e.prototype._getCurrentOrderId=function(e){var t=e.order.getOrder(),n=e.checkout.getCheckout();return t&&t.orderId||n&&n.orderId},e.prototype._mapToOrderRequestBody=function(e,t,n,r){var i=e.payment,a=(0,o.__rest)(e,["payment"]);return i?(0,o.__assign)((0,o.__assign)({},a),{cartId:t,customerMessage:n,externalSource:r,payment:{paymentData:i.paymentData,name:i.methodId,gateway:i.gatewayId}}):(0,o.__assign)((0,o.__assign)({},a),{cartId:t,customerMessage:n,externalSource:r})},e}(),wi=function(e){function t(t){var n=e.call(this,t||"Your checkout could not be processed because some details have changed. Please review your order and try again.")||this;return n.name="CartConsistencyError",n.type="cart_consistency",n}return(0,o.__extends)(t,e),t}(p),Ei=function(e){function t(t){var n=e.call(this,t||"The tax provider is unavailable.")||this;return n.name="OrderTaxProviderUnavailableError",n.type="tax_provider_unavailable",n}return(0,o.__extends)(t,e),t}(p);var bi=function(){function e(e){this._requestSender=e}return e.prototype.loadOrder=function(e,t){var n=(void 0===t?{}:t).timeout,r="/api/storefront/orders/"+e,i=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.get(r,{params:{include:mr(["payments","lineItems.physicalItems.socialMedia","lineItems.physicalItems.options","lineItems.physicalItems.categories","lineItems.digitalItems.socialMedia","lineItems.digitalItems.options","lineItems.digitalItems.categories"])},headers:i,timeout:n})},e.prototype.submitOrder=function(e,t){var n=void 0===t?{}:t,r=n.headers,i=n.timeout;return this._requestSender.post("/internalapi/v1/checkout/order",{body:e,headers:(0,_.omitBy)((0,o.__assign)({"X-Checkout-Variant":r&&r.checkoutVariant},tr),_.isNil),timeout:i}).catch((function(e){if("tax_provider_unavailable"===e.body.type)throw new Ei;if("cart_has_changed"===e.body.type)throw new wi;throw e}))},e.prototype.finalizeOrder=function(e,t){var n=(void 0===t?{}:t).timeout,r="/internalapi/v1/checkout/order/"+e;return this._requestSender.post(r,{timeout:n,headers:tr})},e}();const Pi=bi;var Ai=function(){function e(e,t,n,r){var i=this;this._paymentRequestSender=e,this._orderActionCreator=t,this._paymentRequestTransformer=n,this._paymentHumanVerificationHandler=r,this.initializeOffsitePayment=function(e){var t=e.methodId,n=e.gatewayId,r=e.instrumentId,o=e.target,s=e.promise,u=e.shouldSaveInstrument,c=e.shouldSetAsDefaultInstrument;return function(e){var d;r?d={formattedPayload:{bigpay_token:r}}:u&&(d={formattedPayload:{vault_payment_instrument:u,set_as_default_stored_instrument:c||null}});var l=i._paymentRequestTransformer.transform({gatewayId:n,methodId:t,paymentData:d},e.getState());return(0,E.concat)((0,E.of)((0,a.createAction)(ot.InitializeOffsitePaymentRequested)),Promise.race([i._paymentRequestSender.initializeOffsitePayment(l,o),s].filter(Boolean)).then((function(){return(0,a.createAction)(ot.InitializeOffsitePaymentSucceeded)}))).pipe((0,b.catchError)((function(e){return or(ot.InitializeOffsitePaymentFailed,e)})))}}}return e.prototype.submitPayment=function(e){var t=this;return function(n){return(0,E.concat)((0,E.of)((0,a.createAction)(ot.SubmitPaymentRequested)),(0,E.defer)((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,5]),[4,this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transform(e,n.getState()))];case 1:case 4:return[2,i.sent()];case 2:return t=i.sent(),[4,this._paymentHumanVerificationHandler.handle(t)];case 3:return r=i.sent(),[4,this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transform((0,o.__assign)((0,o.__assign)({},e),{additionalAction:r}),n.getState()))];case 5:return[2]}}))}))})).pipe((0,b.switchMap)((function(e){var r=e.body;return(0,E.concat)(t._orderActionCreator.loadCurrentOrder()(n),(0,E.of)((0,a.createAction)(ot.SubmitPaymentSucceeded,r)))})))).pipe((0,b.catchError)((function(e){return or(ot.SubmitPaymentFailed,e)})))}},e}();const Oi=Ai,Ti=function(){function e(e){this._client=e}return e.prototype.submitPayment=function(e){var t=this;return new Promise((function(n,r){t._client.submitPayment(e,(function(e,i){e?r(t._transformResponse(e)):n(t._transformResponse(i))}))}))},e.prototype.initializeOffsitePayment=function(e,t){var n=this;return new Promise((function(){n._client.initializeOffsitePayment(e,null,t)}))},e.prototype._transformResponse=function(e){return{headers:e.headers,body:e.data,status:e.status,statusText:e.statusText}},e}(),Ri=require("@bigcommerce/bigpay-client");function ki(e,t){var n;return function(e){return void 0!==e.id}(e)?n=e.id:t&&t.length&&(n=t[0].id),{id:n,firstName:e.firstName,lastName:e.lastName,company:e.company,addressLine1:e.address1,addressLine2:e.address2,city:e.city,province:e.stateOrProvince,provinceCode:e.stateOrProvinceCode,postCode:e.postalCode,country:e.country,countryCode:e.countryCode,phone:e.phone,customFields:e.customFields}}const Di=function(){function e(e){this._decimalPlaces=e}return e.prototype.toInteger=function(e){return Math.round(e*Math.pow(10,this._decimalPlaces))},e}();var Mi,Ni=["per_item_discount","percentage_discount","per_total_discount","shipping_discount","free_shipping"];function Li(e){return{code:e.code,discount:e.displayName,discountType:Ni.indexOf(e.couponType)}}function zi(e){return{code:e.code,discountedAmount:e.used,remainingBalance:e.remaining,giftCertificate:{balance:e.balance,code:e.code,purchaseDate:e.purchaseDate}}}function Ui(e,t,n){return void 0===n&&(n="id"),Object.keys(e).reduce((function(r,i){return(0,o.__spreadArrays)(r,e[i].map((function(e){return"giftCertificates"===i?function(e,t){var n=new Di(t);return{id:e.id,imageUrl:"",name:e.name,amount:e.amount,amountAfterDiscount:e.amount,discount:0,integerAmount:n.toInteger(e.amount),integerAmountAfterDiscount:n.toInteger(e.amount),integerUnitPrice:n.toInteger(e.amount),integerUnitPriceAfterDiscount:n.toInteger(e.amount),integerDiscount:0,quantity:1,sender:e.sender,recipient:e.recipient,type:"ItemGiftCertificateEntity",attributes:[],variantId:null}}(e,t):function(e,t,n,r){void 0===r&&(r="id");var i=new Di(n);return{id:e[r],imageUrl:e.imageUrl,amount:e.extendedListPrice,amountAfterDiscount:e.extendedSalePrice,discount:e.discountAmount,integerAmount:i.toInteger(e.extendedListPrice),integerAmountAfterDiscount:i.toInteger(e.extendedSalePrice),integerDiscount:i.toInteger(e.discountAmount),integerUnitPrice:i.toInteger(e.listPrice),integerUnitPriceAfterDiscount:i.toInteger(e.salePrice),downloadsPageUrl:e.downloadPageUrl,name:e.name,quantity:e.quantity,brand:e.brand,sku:e.sku,categoryNames:e.categoryNames,variantId:e.variantId,productId:e.productId,attributes:(e.options||[]).map((function(e){return{name:e.name,value:e.value}})),addedByPromotion:e.addedByPromotion,type:t}}(e,function(e){switch(e){case"physicalItems":return"ItemPhysicalEntity";case"digitalItems":return"ItemDigitalEntity";case"giftCertificates":return"ItemGiftCertificateEntity";default:return""}}(i),t,n)})))}),[])}function Fi(e){var t,n,r=e.cart.currency.decimalPlaces,i=new Di(r);return{id:e.cart.id,items:Ui(e.cart.lineItems,r),currency:e.cart.currency.code,coupon:{discountedAmount:(0,_.reduce)(e.cart.coupons,(function(e,t){return e+t.discountedAmount}),0),coupons:e.cart.coupons.map(Li)},discount:{amount:e.cart.discountAmount,integerAmount:i.toInteger(e.cart.discountAmount)},discountNotifications:(t=e.promotions,n=[],(t||[]).forEach((function(e){(e.banners||[]).forEach((function(e){n.push({placeholders:[],discountType:null,message:"",messageHtml:e.text})}))})),n),giftCertificate:{totalDiscountedAmount:(0,_.reduce)(e.giftCertificates,(function(e,t){return e+t.used}),0),appliedGiftCertificates:(0,_.keyBy)(e.giftCertificates.map(zi),"code")},shipping:{amount:e.shippingCostTotal,integerAmount:i.toInteger(e.shippingCostTotal),amountBeforeDiscount:e.shippingCostBeforeDiscount,integerAmountBeforeDiscount:i.toInteger(e.shippingCostBeforeDiscount),required:(0,_.some)(e.cart.lineItems.physicalItems,(function(e){return e.isShippingRequired}))},subtotal:{amount:e.subtotal,integerAmount:i.toInteger(e.subtotal)},storeCredit:{amount:e.customer?e.customer.storeCredit:0},taxSubtotal:{amount:e.taxTotal,integerAmount:i.toInteger(e.taxTotal)},taxes:e.taxes,taxTotal:{amount:e.taxTotal,integerAmount:i.toInteger(e.taxTotal)},handling:{amount:e.handlingCostTotal,integerAmount:i.toInteger(e.handlingCostTotal)},grandTotal:{amount:e.grandTotal,integerAmount:i.toInteger(e.grandTotal)}}}!function(e){e.APPLEPAY="applepay",e.AMAZON_PAY_V2="amazonpay",e.BRAINTREE_PAYPAL="braintreepaypal",e.BRAINTREE_VENMO="braintreevenmo",e.BRAINTREE_PAYPAL_CREDIT="braintreepaypalcredit",e.GOOGLEPAY_ADYENV2="googlepayadyenv2",e.GOOGLEPAY_ADYENV3="googlepayadyenv3",e.GOOGLEPAY_AUTHORIZENET="googlepayauthorizenet",e.GOOGLEPAY_BNZ="googlepaybnz",e.GOOGLEPAY_BRAINTREE="googlepaybraintree",e.GOOGLEPAY_CHECKOUTCOM="googlepaycheckoutcom",e.GOOGLEPAY_CYBERSOURCEV2="googlepaycybersourcev2",e.GOOGLEPAY_ORBITAL="googlepayorbital",e.GOOGLEPAY_STRIPE="googlepaystripe",e.GOOGLEPAY_STRIPEUPE="googlepaystripeupe",e.GOOGLEPAY_WORLDPAYACCESS="googlepayworldpayaccess",e.MASTERPASS="masterpass",e.PAYPALEXPRESS="paypalexpress"}(Mi||(Mi={}));const Bi=Mi;function qi(e,t){var n=e.firstName||t.firstName||"",r=e.lastName||t.lastName||"";return{addresses:(e.addresses||[]).map((function(e){return ki(e)})),customerId:e.id,isGuest:e.isGuest,storeCredit:e.storeCredit,email:e.email||t.email||"",firstName:n,lastName:r,name:e.fullName||[n,r].join(" "),customerGroupName:e.customerGroup&&e.customerGroup.name}}var xi=function(){function e(){}return e.prototype.format=function(e){var t=e.split(new RegExp("\\s*/\\s*")),n=t[0],r=void 0===n?"":n,i=t[1],o=void 0===i?"":i,a=r.slice(0,2),s=4===o.length?o.slice(-2):o?o.slice(0,2):r.slice(2);return e.length<2?r:e.length>3&&!s?a:a+" / "+s},e.prototype.toObject=function(e){var t=e.split(new RegExp("\\s*/\\s*")),n=t[0],r=void 0===n?"":n,i=t[1],o=void 0===i?"":i;return/^\d+$/.test(r)&&/^\d+$/.test(o)?{month:1===r.length?"0"+r:r.slice(0,2),year:2===o.length?"20"+o:o.slice(0,4)}:{month:"",year:""}},e}();const Gi=xi,Vi=require("card-validator"),Hi=function(){function e(){}return e.prototype.format=function(e){var t=(0,Vi.number)(e).card;if(!t)return e;var n=(0,_.max)((0,Vi.creditCardType)(e).map((function(e){return(0,_.max)(e.lengths)}))),r=this.unformat(e).slice(0,n);return t.gaps.filter((function(e){return r.length>e})).reduce((function(e,t,n){return[e.slice(0,t+n),e.slice(t+n)].join(" ")}),r)},e.prototype.unformat=function(e){return(0,Vi.number)(e).card?e.replace(new RegExp(" ","g"),""):e},e}();function ji(e,t){void 0===t&&(t={});var n,r,i=e.currency.decimalPlaces,o=new Di(i);return{id:e.orderId,items:Ui(e.lineItems,e.currency.decimalPlaces,"productId"),orderId:e.orderId,currency:e.currency.code,customerCanBeCreated:e.customerCanBeCreated,payment:Wi(e.payments,t.payment),subtotal:{amount:e.baseAmount,integerAmount:o.toInteger(e.baseAmount)},coupon:{discountedAmount:(0,_.reduce)(e.coupons,(function(e,t){return e+t.discountedAmount}),0),coupons:e.coupons.map(Li)},discount:{amount:e.discountAmount,integerAmount:o.toInteger(e.discountAmount)},token:t.orderToken,callbackUrl:t.callbackUrl,discountNotifications:[],giftCertificate:(n=e.payments,r=(0,_.filter)(n,{providerId:"giftcertificate"}),{totalDiscountedAmount:(0,_.reduce)(r,(function(e,t){return t.amount+e}),0),appliedGiftCertificates:(0,_.keyBy)(r.map((function(e){return{code:e.detail.code,discountedAmount:e.amount,remainingBalance:e.detail.remaining,giftCertificate:{balance:e.amount+e.detail.remaining,code:e.detail.code,purchaseDate:""}}})),"code")}),socialData:Zi(e),status:e.status,hasDigitalItems:e.hasDigitalItems,isDownloadable:e.isDownloadable,isComplete:e.isComplete,shipping:{amount:e.shippingCostTotal,integerAmount:o.toInteger(e.shippingCostTotal),amountBeforeDiscount:e.shippingCostBeforeDiscount,integerAmountBeforeDiscount:o.toInteger(e.shippingCostBeforeDiscount)},storeCredit:{amount:Yi(e.payments)},taxes:e.taxes,taxTotal:{amount:e.taxTotal,integerAmount:o.toInteger(e.taxTotal)},handling:{amount:e.handlingCostTotal,integerAmount:o.toInteger(e.handlingCostTotal)},grandTotal:{amount:e.orderAmount,integerAmount:e.orderAmountAsInteger}}}function Yi(e){var t=(0,_.find)(e,{providerId:"storecredit"});return t?t.amount:0}function Wi(e,t){void 0===t&&(t={});var n,r=(0,_.find)(e,Ki);return r?{id:r.providerId,status:(n=r.detail.step,"PAYMENT_STATUS_"+n),helpText:r.detail.instructions,returnUrl:t.returnUrl}:{}}function Ki(e){return"giftcertificate"!==e.providerId&&"storecredit"!==e.providerId}function Zi(e){var t={};return(0,o.__spreadArrays)(e.lineItems.physicalItems,e.lineItems.digitalItems).forEach((function(e){var n;t[e.id]=(n=e,["fb","tw","gp"].reduce((function(e,t){var r=n.socialMedia&&(0,_.find)(n.socialMedia,(function(e){return e.code===t}));return r?(e[t]={name:n.name,description:n.name,image:n.imageUrl,url:r.link,shareText:r.text,sharingLink:r.link,channelName:r.channel,channelCode:r.code},e):e}),{}))})),t}function Qi(e,t){return{description:e.description,module:e.type,price:e.cost,id:e.id,selected:t,isRecommended:e.isRecommended,imageUrl:e.imageUrl,transitTime:e.transitTime}}var Ji=function(){function e(){this._cardExpiryFormatter=new Gi,this._cardNumberFormatter=new Hi}return e.prototype.transform=function(e,t){var n,r=t.billingAddress.getBillingAddress(),i=t.checkout.getCheckout(),a=t.customer.getCustomer(),s=t.order.getOrder(),u=t.paymentMethods.getPaymentMethod(e.methodId,e.gatewayId),c=this._mapShippingAddress(t,u),d=t.consignments.getConsignments(),l=t.consignments.getShippingOption(),p=t.config.getStoreConfig(),h=t.config.getContextConfig(),f=t.instruments.getInstrumentsMeta(),g=t.paymentMethods.getPaymentMethodsMeta(),m=t.order.getOrderMeta(),y=a&&r&&qi(a,r),v=f&&e.paymentData&&(yi(e.paymentData)||(n=e.paymentData.formattedPayload)&&("string"==typeof n.bigpay_token||Boolean(n.bigpay_token&&n.bigpay_token.token)))?t.payment.getPaymentToken()+", "+f.vaultAccessToken:t.payment.getPaymentToken();if(!v)throw new Nn(Mn.MissingPaymentToken);return{additionalAction:e.additionalAction,authToken:v,customer:y,billingAddress:r&&ki(r),shippingAddress:c&&ki(c,d),shippingOption:l&&Qi(l,!0),cart:i&&Fi(i),order:s&&ji(s,m),orderMeta:m,payment:e.paymentData,paymentMethod:u&&this._transformPaymentMethod(u),quoteMeta:{request:(0,o.__assign)((0,o.__assign)({},g),{geoCountryCode:h&&h.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:(0,_.pick)(p&&p.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}},e.prototype.transformWithHostedFormData=function(e,t,n){var r=t.additionalAction,i=t.authToken,a=t.checkout,s=t.config,u=t.order,c=t.orderMeta,d=t.payment,l=void 0===d?{}:d,p=t.paymentMethod,h=t.paymentMethodMeta,f=a&&a.consignments[0],g=f&&f.shippingAddress,m=f&&f.selectedShippingOption;return{additionalAction:r,authToken:i,paymentMethod:p&&this._transformPaymentMethod(p),customer:u&&u.billingAddress&&a&&qi(a.customer,u.billingAddress),billingAddress:u&&u.billingAddress&&ki(u.billingAddress),shippingAddress:g&&a&&ki(g,a.consignments),shippingOption:m&&Qi(m,!0),cart:a&&Fi(a),order:u&&ji(u,c),orderMeta:c,payment:this._transformHostedInputValues(e,l,n),quoteMeta:{request:(0,o.__assign)((0,o.__assign)({},h),{geoCountryCode:s&&s.context.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:s&&(0,_.pick)(s.storeConfig.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}},e.prototype._transformPaymentMethod=function(e){return"multi-option"!==e.method||e.gateway?e.initializationData&&e.initializationData.gateway?(0,o.__assign)((0,o.__assign)({},e),{id:e.initializationData.gateway}):e.id===Bi.BRAINTREE_VENMO?(0,o.__assign)((0,o.__assign)({},e),{id:Bi.BRAINTREE_PAYPAL}):e:(0,o.__assign)((0,o.__assign)({},e),{gateway:e.id})},e.prototype._transformHostedInputValues=function(e,t,n){return"instrumentId"in t?(0,o.__assign)((0,o.__assign)({},t),{ccCvv:e.cardCodeVerification,ccNumber:e.cardNumberVerification&&this._cardNumberFormatter.unformat(e.cardNumberVerification),hostedFormNonce:n}):(0,o.__assign)((0,o.__assign)({},t),{ccCvv:e.cardCode,ccExpiry:this._cardExpiryFormatter.toObject(e.cardExpiry||""),ccName:e.cardName||"",ccNumber:this._cardNumberFormatter.unformat(e.cardNumber||""),hostedFormNonce:n})},e.prototype._mapShippingAddress=function(e,t){var n,r,i,o;if(t){var a=null===(r=null===(n=t.initializationData)||void 0===n?void 0:n.bopis)||void 0===r?void 0:r.enabled,s=null===(o=null===(i=t.initializationData)||void 0===i?void 0:i.bopis)||void 0===o?void 0:o.requiredAddress,u=e.consignments.getConsignments(),c=null==u?void 0:u.every((function(e){return e.selectedPickupOption}));if(a&&c&&"none"===s)return}return e.shippingAddress.getShippingAddress()},e}();const Xi=Ji,$i=function(){function e(){}return e.prototype.updatePaymentProviderCustomer=function(e){return(0,E.of)((0,a.createAction)(vt.UpdatePaymentProviderCustomer,e))},e}(),eo=function(){function e(){}return e.prototype.widgetInteraction=function(e,t){var n={methodId:t&&t.methodId};return(0,E.concat)((0,E.of)((0,a.createAction)(pt.WidgetInteractionStarted,void 0,n)),(0,E.defer)((function(){return e().then((function(){return(0,a.createAction)(pt.WidgetInteractionFinished,void 0,n)}))}))).pipe((0,b.catchError)((function(e){return or(pt.WidgetInteractionFailed,e,n)})))},e}();var to=function(){function e(e,t){this._remoteCheckoutRequestSender=e,this._checkoutActionCreator=t}return e.prototype.initializeBilling=function(e,t,n){var r=this;return E.Observable.create((function(i){i.next((0,a.createAction)(Tt.InitializeRemoteBillingRequested,void 0,{methodId:e})),r._remoteCheckoutRequestSender.initializeBilling(e,t,n).then((function(t){var n=t.body,r=void 0===n?{}:n;i.next((0,a.createAction)(Tt.InitializeRemoteBillingSucceeded,r,{methodId:e})),i.complete()})).catch((function(t){i.error((0,a.createErrorAction)(Tt.InitializeRemoteBillingFailed,t,{methodId:e}))}))}))},e.prototype.initializeShipping=function(e,t,n){var r=this;return E.Observable.create((function(i){i.next((0,a.createAction)(Tt.InitializeRemoteShippingRequested,void 0,{methodId:e})),r._remoteCheckoutRequestSender.initializeShipping(e,t,n).then((function(t){var n=t.body,r=void 0===n?{}:n;i.next((0,a.createAction)(Tt.InitializeRemoteShippingSucceeded,r,{methodId:e})),i.complete()})).catch((function(t){i.error((0,a.createErrorAction)(Tt.InitializeRemoteShippingFailed,t,{methodId:e}))}))}))},e.prototype.initializePayment=function(e,t,n){var r=this;return E.Observable.create((function(i){i.next((0,a.createAction)(Tt.InitializeRemotePaymentRequested,void 0,{methodId:e})),r._remoteCheckoutRequestSender.initializePayment(e,t,n).then((function(t){var n=t.body,r=void 0===n?{}:n;i.next((0,a.createAction)(Tt.InitializeRemotePaymentSucceeded,r,{methodId:e})),i.complete()})).catch((function(t){i.error((0,a.createErrorAction)(Tt.InitializeRemotePaymentFailed,t,{methodId:e}))}))}))},e.prototype.loadSettings=function(e,t){var n=this;return E.Observable.create((function(r){r.next((0,a.createAction)(Tt.LoadRemoteSettingsRequested,void 0,{methodId:e})),n._remoteCheckoutRequestSender.loadSettings(e,t).then((function(t){var n=t.body;r.next((0,a.createAction)(Tt.LoadRemoteSettingsSucceeded,n,{methodId:e})),r.complete()})).catch((function(t){r.error((0,a.createErrorAction)(Tt.LoadRemoteSettingsFailed,t,{methodId:e}))}))}))},e.prototype.signOut=function(e,t){var n=this;return E.Observable.create((function(r){r.next((0,a.createAction)(Tt.SignOutRemoteCustomerRequested,void 0,{methodId:e})),n._remoteCheckoutRequestSender.signOut(e,t).then((function(){r.next((0,a.createAction)(Tt.SignOutRemoteCustomerSucceeded,void 0,{methodId:e})),r.complete()})).catch((function(t){r.error((0,a.createErrorAction)(Tt.SignOutRemoteCustomerFailed,t,{methodId:e}))}))}))},e.prototype.forgetCheckout=function(e,t){var n=this;return(0,E.concat)((0,E.of)((0,a.createAction)(Tt.ForgetCheckoutRemoteCustomerRequested,void 0,{methodId:e})),(0,E.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._remoteCheckoutRequestSender.forgetCheckout(t)];case 1:return n.sent(),[4,this._checkoutActionCreator.loadCurrentCheckout()];case 2:return n.sent(),[2,(0,a.createAction)(Tt.ForgetCheckoutRemoteCustomerSucceeded,void 0,{methodId:e})]}}))}))}))).pipe((0,b.catchError)((function(t){return or(Tt.ForgetCheckoutRemoteCustomerFailed,t,{methodId:e})})))},e.prototype.updateCheckout=function(e,t){return(0,a.createAction)(Tt.UpdateRemoteCheckout,t,{methodId:e})},e}();const no=to;var ro=function(){function e(e){this._requestSender=e}return e.prototype.initializeBilling=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/remote-checkout/"+e+"/billing";return this._requestSender.get(i,{params:t,timeout:r,headers:tr})},e.prototype.initializeShipping=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/remote-checkout/"+e+"/shipping";return this._requestSender.get(i,{params:t,timeout:r,headers:tr})},e.prototype.initializePayment=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/remote-checkout/"+e+"/payment";return this._requestSender.get(i,{params:t,timeout:r,headers:tr})},e.prototype.loadSettings=function(e,t){var n=(void 0===t?{}:t).timeout,r="/remote-checkout/"+e+"/settings";return this._requestSender.get(r,{timeout:n,headers:tr})},e.prototype.signOut=function(e,t){var n=(void 0===t?{}:t).timeout,r="/remote-checkout/"+e+"/signout";return this._requestSender.get(r,{timeout:n,headers:tr})},e.prototype.generateToken=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.get("/remote-checkout-token",{timeout:t,headers:tr})},e.prototype.trackAuthorizationEvent=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.post("/remote-checkout/events/shopper-checkout-service-provider-authorization-requested",{timeout:t,headers:tr})},e.prototype.forgetCheckout=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.post("/remote-checkout/forget-checkout",{timeout:t,headers:tr})},e}();const io=ro;var oo;!function(e){e.AvailableShippingOptions="consignments.availableShippingOptions",e.PhysicalItemsCategoryNames="cart.lineItems.physicalItems.categoryNames",e.DigitalItemsCategoryNames="cart.lineItems.digitalItems.categoryNames"}(oo||(oo={}));var ao=function(){function e(e,t){this._consignmentRequestSender=e,this._checkoutRequestSender=t}return e.prototype.unassignItemsByAddress=function(e,t){var n=this;return function(r){var i=r.getState();if(!i.checkout.getCheckout())throw new Nn(Mn.MissingCheckout);var o=n._consignmentHasAddress(e)?e.address:e.shippingAddress,a=i.consignments.getConsignmentByAddress(o);if(!a)throw new Gr("No consignment found for the specified address");var s=n._removeLineItems(e.lineItems,a,i.cart.getCart());return s.length?n.updateConsignment({id:a.id,address:o,lineItems:s},t)(r):n.deleteConsignment(a.id,t)(r)}},e.prototype.assignItemsByAddress=function(e,t){var n=this;return function(r){var i=r.getState(),o=n._consignmentHasAddress(e)?e.address:e.shippingAddress,a=i.consignments.getConsignmentByAddress(o);return n._createOrUpdateConsignment({id:a&&a.id,address:o,lineItems:n._addLineItems(e.lineItems,a,i.cart.getCart())},t)(r)}},e.prototype.selectShippingOption=function(e,t){var n=this;return function(r){return E.Observable.create((function(i){var o=r.getState(),s=o.checkout.getCheckout(),u=o.consignments.getConsignments();if(!s)throw new Nn(Mn.MissingCheckout);if(!u||!u.length)throw new Nn(Mn.MissingConsignments);var c={id:u[0].id,shippingOptionId:e},d={id:u[0].id};i.next((0,a.createAction)(j.UpdateShippingOptionRequested,void 0,d)),n._consignmentRequestSender.updateConsignment(s.id,c,t).then((function(e){var t=e.body;i.next((0,a.createAction)(j.UpdateShippingOptionSucceeded,t,d)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(j.UpdateShippingOptionFailed,e,d))}))}))}},e.prototype.loadShippingOptions=function(e){var t=this;return function(n){return E.Observable.create((function(r){var i=n.getState().checkout.getCheckout();if(!i)throw new Nn(Mn.MissingCheckout);r.next((0,a.createAction)(j.LoadShippingOptionsRequested)),t._checkoutRequestSender.loadCheckout(i.id,(0,o.__assign)((0,o.__assign)({},e),{params:{include:[oo.AvailableShippingOptions]}})).then((function(e){var t=e.body;r.next((0,a.createAction)(j.LoadShippingOptionsSucceeded,t)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(j.LoadShippingOptionsFailed,e))}))}))}},e.prototype.updateAddress=function(e,t){var n=this;return function(r){var i=n._getUpdateAddressRequestBody(e,r),o=r.getState().consignments.getConsignments();return o&&o.length&&(i.id=o[0].id),n._createOrUpdateConsignment(i,t)(r)}},e.prototype.createConsignments=function(e,t){var n=this;return function(r){return E.Observable.create((function(i){var o=r.getState().checkout.getCheckout();if(!o||!o.id)throw new Nn(Mn.MissingCheckout);i.next((0,a.createAction)(j.CreateConsignmentsRequested)),n._consignmentRequestSender.createConsignments(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(j.CreateConsignmentsSucceeded,t)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(j.CreateConsignmentsFailed,e))}))}))}},e.prototype.updateConsignment=function(e,t){var n=this;return function(r){return E.Observable.create((function(i){var o=r.getState().checkout.getCheckout();if(!o||!o.id)throw new Nn(Mn.MissingCheckout);var s={id:e.id};i.next((0,a.createAction)(j.UpdateConsignmentRequested,void 0,s)),n._consignmentRequestSender.updateConsignment(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(j.UpdateConsignmentSucceeded,t,s)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(j.UpdateConsignmentFailed,e,s))}))}))}},e.prototype.deleteConsignment=function(e,t){var n=this;return function(r){return E.Observable.create((function(i){var o=r.getState().checkout.getCheckout(),s={id:e};if(!o||!o.id)throw new Nn(Mn.MissingCheckout);i.next((0,a.createAction)(j.DeleteConsignmentRequested,void 0,s)),n._consignmentRequestSender.deleteConsignment(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(j.DeleteConsignmentSucceeded,t,s)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(j.DeleteConsignmentFailed,e,s))}))}))}},e.prototype.updateShippingOption=function(e,t){var n=this;return function(r){return E.Observable.create((function(i){var o=r.getState().checkout.getCheckout();if(!o||!o.id)throw new Nn(Mn.MissingCheckout);var s={id:e.id};i.next((0,a.createAction)(j.UpdateShippingOptionRequested,void 0,s)),n._consignmentRequestSender.updateConsignment(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(j.UpdateShippingOptionSucceeded,t,s)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(j.UpdateShippingOptionFailed,e,s))}))}))}},e.prototype._createOrUpdateConsignment=function(e,t){var n=this;return function(r){var i=r.getState().checkout.getCheckout();if(!i||!i.id)throw new Nn(Mn.MissingCheckout);return n._isUpdateConsignmentRequest(e)?n.updateConsignment(e,t)(r):n.createConsignments([e],t)(r)}},e.prototype._getUpdateAddressRequestBody=function(e,t){var n=t.getState().cart.getCart();if(!n)throw new Nn(Mn.MissingCart);var r=n.lineItems,i=r.physicalItems,a=r.customItems,s=void 0===a?[]:a;return{address:e,lineItems:(0,o.__spreadArrays)(i,s).map((function(e){return{itemId:e.id,quantity:e.quantity}}))}},e.prototype._removeLineItems=function(e,t,n){if(!n)throw new Nn(Mn.MissingCart);return this._hydrateLineItems(t.lineItemIds,n).map((function(t){var n=(0,_.find)(e,(function(e){return e.itemId===t.itemId}));return(0,o.__assign)((0,o.__assign)({},t),{quantity:n?t.quantity-n.quantity:t.quantity})})).filter((function(e){return e.quantity>0}))},e.prototype._addLineItems=function(e,t,n){if(!t)return e;if(!n)throw new Nn(Mn.MissingCart);return e.concat(this._hydrateLineItems(t.lineItemIds,n)).filter((function(e){return e.quantity>0}))},e.prototype._hydrateLineItems=function(e,t){return e.map((function(e){var n=(0,_.find)(t.lineItems.physicalItems,(function(t){return t.id===e}));return{itemId:e,quantity:n?n.quantity:0}}))},e.prototype._isUpdateConsignmentRequest=function(e){return!!e.id},e.prototype._consignmentHasAddress=function(e){return"object"==typeof e&&"address"in e},e}();const so=ao;var uo=["consignments.availableShippingOptions","cart.lineItems.physicalItems.options","cart.lineItems.digitalItems.options","customer","promotions.banners"],co=function(){function e(e){this._requestSender=e}return e.prototype.createConsignments=function(e,t,n){var r=void 0===n?{}:n,i=r.timeout,a=r.params,s=(void 0===a?{}:a).include,u="/api/storefront/checkouts/"+e+"/consignments",c=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.post(u,{body:t,params:{include:_r(uo,s)},headers:c,timeout:i})},e.prototype.updateConsignment=function(e,t,n){var r=void 0===n?{}:n,i=r.timeout,a=r.params,s=(void 0===a?{}:a).include,u=t.id,c=(0,o.__rest)(t,["id"]),d="/api/storefront/checkouts/"+e+"/consignments/"+u,l=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.put(d,{body:c,params:{include:_r(uo,s)},headers:l,timeout:i})},e.prototype.deleteConsignment=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/api/storefront/checkouts/"+e+"/consignments/"+t,a=(0,o.__assign)({Accept:$n.JsonV1},tr),s=mr(uo);return this._requestSender.delete(i,{params:{include:s},headers:a,timeout:r})},e}();const lo=co,po=function(){function e(e,t){this._shippingCountryRequestSender=e,this._store=t}return e.prototype.loadCountries=function(e){var t=this,n=this._store.getState().checkout.getCheckoutOrThrow().channelId;return E.Observable.create((function(r){r.next((0,a.createAction)(Wt.LoadShippingCountriesRequested)),t._shippingCountryRequestSender.loadCountries(n,e).then((function(e){r.next((0,a.createAction)(Wt.LoadShippingCountriesSucceeded,e.body.data)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(Wt.LoadShippingCountriesFailed,e))}))}))},e}();var ho=function(){function e(e,t){this._requestSender=e,this._config=t}return e.prototype.loadCountries=function(e,t){var n=(void 0===t?{}:t).timeout,r="/internalapi/v1/shipping/countries?channel_id="+e,i=(0,o.__assign)({"Accept-Language":this._config.locale},tr);return this._requestSender.get(r,{headers:i,timeout:n})},e}();const fo=ho;var go=function(){function e(e,t){this._googleRecaptcha=e,this._requestSender=t}return e.prototype.initialize=function(e){var t=this;return function(n){return(0,E.concat)((0,E.of)((0,a.createAction)(In.InitializeRequested,void 0)),(0,E.defer)((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,r,i,s,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return t=e?e.containerId:"spamProtectionContainer",e||document.getElementById(t)||((r=document.createElement("div")).setAttribute("id",t),document.body.appendChild(r)),i=n.getState(),s=i.config.getStoreConfigOrThrow(),u=s.checkoutSettings.googleRecaptchaSitekey,[4,this._googleRecaptcha.load(t,u)];case 1:return o.sent(),[2,(0,a.createAction)(In.InitializeSucceeded)]}}))}))}))).pipe((0,b.catchError)((function(e){return or(In.InitializeFailed,e)})))}},e.prototype.verifyCheckoutSpamProtection=function(){var e=this;return function(t){return(0,E.defer)((function(){var n=t.getState().checkout.getCheckout();if(!n)throw new Nn(Mn.MissingCheckout);return(0,E.concat)((0,E.of)((0,a.createAction)(In.VerifyCheckoutRequested)),(0,E.from)(e.execute()(t)).pipe((0,b.switchMap)((function(t){return Or(t)&&t.payload?(0,E.from)(e._requestSender.validate(n.id,t.payload.token)).pipe((0,b.switchMap)((function(e){var n=e.body;return(0,E.concat)((0,E.of)(t),(0,E.of)((0,a.createAction)(In.VerifyCheckoutSucceeded,n)))}))):(0,E.of)(t)})))).pipe((0,b.catchError)((function(e){return or(In.VerifyCheckoutFailed,e)})))}))}},e.prototype.execute=function(){var e=this;return function(t){return(0,E.concat)((0,E.of)((0,a.createAction)(In.ExecuteRequested)),e.initialize()(t),e._googleRecaptcha.execute().pipe((0,b.take)(1)).pipe((0,b.switchMap)((function(t){var n=t.error,r=t.token;return(0,o.__awaiter)(e,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){if(n instanceof Qr)throw n;if(n||!r)throw new ri;return[2,(0,a.createAction)(In.ExecuteSucceeded,{token:r})]}))}))})))).pipe((0,b.catchError)((function(e){return or(In.ExecuteFailed,e)})))}},e}();const mo=go;var _o=function(){function e(e){this._requestSender=e}return e.prototype.validate=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/api/storefront/checkouts/"+e+"/spam-protection",a=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.post(i,{body:{token:t},headers:a,timeout:r})},e}();const yo=_o;var vo=function(){function e(e){this._storeCreditRequestSender=e}return e.prototype.applyStoreCredit=function(e,t){var n=this;return function(r){return(0,E.concat)((0,E.of)((0,a.createAction)(pn.ApplyStoreCreditRequested)),(0,E.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){var n,i,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(n=r.getState(),!(i=n.checkout.getCheckout()))throw new Nn(Mn.MissingCheckout);return[4,e?this._storeCreditRequestSender.applyStoreCredit(i.id,t):this._storeCreditRequestSender.removeStoreCredit(i.id,t)];case 1:return s=o.sent().body,[2,(0,a.createAction)(pn.ApplyStoreCreditSucceeded,s)]}}))}))}))).pipe((0,b.catchError)((function(e){return or(pn.ApplyStoreCreditFailed,e)})))}},e}();const Co=vo;var So=function(){function e(e){this._requestSender=e}return e.prototype.applyStoreCredit=function(e,t){var n=(void 0===t?{}:t).timeout,r="/api/storefront/checkouts/"+e+"/store-credit",i=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.post(r,{headers:i,timeout:n,params:{include:mr(yr)}})},e.prototype.removeStoreCredit=function(e,t){var n=(void 0===t?{}:t).timeout,r="/api/storefront/checkouts/"+e+"/store-credit",i=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.delete(r,{headers:i,timeout:n,params:{include:mr(yr)}})},e}();const Io=So,wo=function(e){function t(t){var n=e.call(this,t)||this;return n.name="UpdateSubscriptionsError",n.type="update_subscriptions",n}return(0,o.__extends)(t,e),t}(g);var Eo=function(){function e(e){this._subscriptionsRequestSender=e}return e.prototype.updateSubscriptions=function(e,t){var n=this;return(0,E.concat)((0,E.of)((0,a.createAction)(O.UpdateSubscriptionsRequested)),(0,E.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._subscriptionsRequestSender.updateSubscriptions(e,t)];case 1:return n=r.sent().body,[2,(0,a.createAction)(O.UpdateSubscriptionsSucceeded,n)]}}))}))}))).pipe((0,b.catchError)((function(e){return or(O.UpdateSubscriptionsFailed,new wo(e))})))},e}();const bo=Eo;var Po=function(){function e(e){this._requestSender=e}return e.prototype.updateSubscriptions=function(e,t){var n=(void 0===t?{}:t).timeout,r=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.post("/api/storefront/subscriptions",{body:e,headers:r,timeout:n})},e}();const Ao=Po;var Oo=(0,_.memoize)((function(e){return Array.isArray(e)?e.map((function(e){return To(e)})):q(e)?Object.keys(e).reduce((function(t,n){var r;return(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=To(e[n]),r))}),{}):e}));Oo.cache=new WeakMap;var To=function(e){return"object"==typeof e&&null!==e?Oo(e):e};function Ro(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return To(e.apply(void 0,t))}}function ko(e){var t=e.billingAddress,n=t.getBillingAddress,r=t.getBillingAddressOrThrow,i=e.cart,o=i.getCart,a=i.getCartOrThrow,s=e.checkout,u=s.getCheckout,c=s.getCheckoutOrThrow,d=s.getOutstandingBalance,l=e.config,p=l.getContextConfig,h=l.getHost,f=l.getLocale,g=l.getStoreConfig,m=l.getStoreConfigOrThrow,_=l.getConfig,y=e.consignments,v=y.getConsignments,C=y.getConsignmentsOrThrow,S=e.countries.getCountries,I=e.customer,w=I.getCustomer,E=I.getCustomerOrThrow,b=e.instruments,P=b.getCardInstrument,A=b.getCardInstrumentOrThrow,O=b.getInstruments,T=b.getInstrumentsMeta,R=e.order,k=R.getOrder,D=R.getOrderOrThrow,M=R.getOrderMeta,N=e.payment,L=N.getPaymentToken,z=N.getPaymentTokenOrThrow,U=N.getPaymentId,F=N.getPaymentIdOrThrow,B=N.getPaymentStatus,q=N.getPaymentStatusOrThrow,x=N.getPaymentRedirectUrl,G=N.getPaymentRedirectUrlOrThrow,V=N.isPaymentDataRequired,H=e.paymentMethods,j=H.getPaymentMethod,Y=H.getPaymentMethodOrThrow,W=H.getPaymentMethodsMeta,K=e.paymentProviderCustomer,Z=K.getPaymentProviderCustomer,Q=K.getPaymentProviderCustomerOrThrow,J=e.paymentStrategies.isInitialized,X=e.shippingAddress,$=X.getShippingAddress,ee=X.getShippingAddressOrThrow,te=X.getShippingAddresses,ne=X.getShippingAddressesOrThrow,re=e.shippingCountries.getShippingCountries;return{getHost:Ro(h),getLocale:Ro(f),getBillingAddress:Ro(n),getBillingAddressOrThrow:Ro(r),getCart:Ro(o),getCartOrThrow:Ro(a),getCheckout:Ro(u),getCheckoutOrThrow:Ro(c),getCountries:Ro(S),getStoreConfig:Ro(g),getStoreConfigOrThrow:Ro(m),getConfig:Ro(_),getConsignments:Ro(v),getConsignmentsOrThrow:Ro(C),getContextConfig:Ro(p),getCustomer:Ro(w),getCustomerOrThrow:Ro(E),getCardInstrument:Ro(P),getInstruments:Ro(O),getCardInstrumentOrThrow:Ro(A),getOrder:Ro(k),getOrderOrThrow:Ro(D),getOrderMeta:Ro(M),getInstrumentsMeta:Ro(T),getPaymentToken:L,getPaymentTokenOrThrow:z,getPaymentId:U,getPaymentIdOrThrow:F,getPaymentStatus:B,getPaymentStatusOrThrow:q,getPaymentRedirectUrl:x,getPaymentRedirectUrlOrThrow:G,getPaymentMethod:Ro(j),getPaymentMethodOrThrow:Ro(Y),getPaymentMethodsMeta:Ro(W),getPaymentProviderCustomer:Ro(Z),getPaymentProviderCustomerOrThrow:Ro(Q),getShippingAddress:Ro($),getShippingAddressOrThrow:Ro(ee),getShippingAddresses:Ro(te),getShippingAddressesOrThrow:Ro(ne),getShippingCountries:Ro(re),getOutstandingBalance:Ro(d),isPaymentDataRequired:V,isPaymentMethodInitialized:J}}var Do=function(){function e(e,t,n,r,i,o,a,s,u,c,d,l,p,h,f,g,m,_,y){this._store=e,this._storeProjectionFactory=t,this._checkoutActionCreator=n,this._checkoutValidator=r,this._hostedFormFactory=i,this._orderActionCreator=o,this._billingAddressActionCreator=a,this._consignmentActionCreator=s,this._paymentMethodActionCreator=u,this._paymentActionCreator=c,this._paymentHumanVerificationHandler=d,this._customerActionCreator=l,this._cartRequestSender=p,this._storeCreditActionCreator=h,this._spamProtectionActionCreator=f,this._paymentProviderCustomerActionCreator=g,this._shippingCountryActionCreator=m,this._remoteCheckoutActionCreator=_,this._paymentStrategyWidgetActionCreator=y,this._storeProjection=this._storeProjectionFactory.create(this._store)}return e.prototype.createHostedForm=function(e,t){return this._hostedFormFactory.create(e,t)},e.prototype.subscribe=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return(t=this._storeProjection).subscribe.apply(t,(0,o.__spreadArrays)([e],n))},e.prototype.getState=function(){return this._storeProjection.getState()},e.prototype.initializeOffsitePayment=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentActionCreator.initializeOffsitePayment(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.loadCheckout=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return e?[4,this._store.dispatch(this._checkoutActionCreator.loadCheckout(e))]:[3,2];case 1:return t.sent(),[3,4];case 2:return[4,this._store.dispatch(this._checkoutActionCreator.loadCurrentCheckout())];case 3:t.sent(),t.label=4;case 4:return[2,this._storeProjection.getState()]}}))}))},e.prototype.loadDefaultCheckout=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 1:return e.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.loadPaymentMethod=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.loadPaymentMethods=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethods(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.submitOrder=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._orderActionCreator.submitOrder(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.submitPayment=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentActionCreator.submitPayment(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.finalizeOrder=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return t=this._store.getState().order.getOrderOrThrow,[4,this._store.dispatch(this._orderActionCreator.finalizeOrder(t().orderId,e))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.updateBillingAddress=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._billingAddressActionCreator.updateAddress(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.updateShippingAddress=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._consignmentActionCreator.updateAddress(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.selectShippingOption=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._consignmentActionCreator.selectShippingOption(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.signInCustomer=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._customerActionCreator.signInCustomer(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.signOutCustomer=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._customerActionCreator.signOutCustomer(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.createBuyNowCart=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._cartRequestSender.createBuyNowCart(e,t)];case 1:return[2,n.sent().body]}}))}))},e.prototype.applyStoreCredit=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._storeCreditActionCreator.applyStoreCredit(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.verifyCheckoutSpamProtection=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return this._store.getState().checkout.getCheckoutOrThrow().shouldExecuteSpamCheck?[4,this._store.dispatch(this._spamProtectionActionCreator.verifyCheckoutSpamProtection())]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2,this._storeProjection.getState()]}}))}))},e.prototype.loadCurrentOrder=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._orderActionCreator.loadCurrentOrder(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.updatePaymentProviderCustomer=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentProviderCustomerActionCreator.updatePaymentProviderCustomer(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.loadShippingCountries=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._shippingCountryActionCreator.loadCountries(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.deleteConsignment=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._consignmentActionCreator.deleteConsignment(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.initializePayment=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._store.dispatch(this._remoteCheckoutActionCreator.initializePayment(e,t,n))];case 1:return r.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.forgetCheckout=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._remoteCheckoutActionCreator.forgetCheckout(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.remoteCheckoutSignOut=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._remoteCheckoutActionCreator.signOut(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.validateCheckout=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._checkoutValidator.validate(e,t)];case 1:return n.sent(),[2]}}))}))},e.prototype.handlePaymentHumanVerification=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){return"string"==typeof e?[2,this._paymentHumanVerificationHandler.handle(e,null!=t?t:"")]:[2,this._paymentHumanVerificationHandler.handle(e)]}))}))},e.prototype.widgetInteraction=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentStrategyWidgetActionCreator.widgetInteraction(e),{queueId:"widgetInteraction"})];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e}();const Mo=Do;var No;!function(e){e.Synchronize="SYNCHRONIZE"}(No||(No={}));const Lo=function(){function e(e){this._transformSelectors=e}return e.prototype.create=function(e){return function(e,t){var n=(0,a.createDataStore)((function(e,t){return t.type===No.Synchronize?t.payload:e}),e.getState(),{stateTransformer:t});return e.subscribe((function(e){n.dispatch((0,a.createAction)(No.Synchronize,e))}),{initial:!1}),n}(e,this._transformSelectors)},e}();const zo=require("shallowequal");var Uo=e.n(zo);function Fo(e){return Object.prototype.hasOwnProperty.call(e,"cacheKey")}var Bo=function(){function e(e){this._lastId=0,this._map={maps:[]},this._usedMaps=[],this._options=(0,o.__assign)({maxSize:0,isEqual:Uo(),onExpire:_.noop},e)}return e.prototype.getKey=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._resolveMap.apply(this,e),r=n.index,i=n.parentMap,o=n.map;return o&&o.cacheKey?o.usedCount++:o=this._generateMap(i,e.slice(r)),this._removeLeastUsedMap(o),o.cacheKey},e.prototype.getUsedCount=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._resolveMap.apply(this,e).map;return n?n.usedCount:0},e.prototype._resolveMap=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r=0,i=this._map;i.maps.length;){for(var o=!1,a=0;a<i.maps.length;a++){var s=i.maps[a];if(this._options.isEqual(s.value,t[r])){if((e=i.maps).unshift.apply(e,i.maps.splice(a,1)),(0===t.length||r===t.length-1)&&Fo(s))return{index:r,map:s,parentMap:i};o=!0,i=s,r++;break}}if(!o)break}return{index:r,parentMap:i}},e.prototype._generateMap=function(e,t){var n,r=0,i=e;do{n={maps:[],parentMap:i,usedCount:1,value:t[r]},i.maps.unshift(n),i=n,r++}while(r<t.length);var o=n;return o.cacheKey=""+ ++this._lastId,o},e.prototype._removeLeastUsedMap=function(e){if(this._options.maxSize){var t=this._usedMaps.indexOf(e);if(this._usedMaps.splice(-1===t?0:t,-1===t?0:1,e),!(this._usedMaps.length<=this._options.maxSize)){var n=this._usedMaps.pop();n&&(this._removeMap(n),this._options.onExpire(n.cacheKey))}}},e.prototype._removeMap=function(e){e.parentMap&&(e.parentMap.maps.splice(e.parentMap.maps.indexOf(e),1),function(e){return Object.prototype.hasOwnProperty.call(e,"parentMap")}(e.parentMap)||this._removeMap(e.parentMap))},e}();const qo=Bo;function xo(e){var t=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,o.__extends)(t,e),t}(e);return Object.getOwnPropertyNames(e.prototype).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e.prototype,n);r&&"constructor"!==n&&Object.defineProperty(t.prototype,n,function(e,t,n){if("function"!=typeof n.value)return n;var r=new qo,i=n.value,a=(0,Dn.memoize)(i);return Yr(e,t,{get:function(){var e=this,s=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var s=a.call.apply(a,(0,o.__spreadArrays)([e],t));if(1===r.getUsedCount.apply(r,t))return s;var u=i.call.apply(i,(0,o.__spreadArrays)([e],t));return D(u,s,{keyFilter:function(e){return!function(e){return 0===(""+e).indexOf("$$")||0===(""+e).indexOf("_")}(e)}})?s:(a.cache.set(r.getKey.apply(r,t),u),u)};return Object.defineProperty(this,t,(0,o.__assign)((0,o.__assign)({},n),{value:s})),s},set:function(e){r=new qo,i=e,a=(0,Dn.memoize)(i)}})}(e.prototype,n,r))})),t}const Go=function(){function e(e){this._checkoutButton=e.checkoutButton}return e.prototype.getInitializeButtonError=function(e){return this._checkoutButton.getInitializeError(e)},e.prototype.getDeinitializeButtonError=function(e){return this._checkoutButton.getDeinitializeError(e)},(0,o.__decorate)([xo],e)}(),Vo=function(){function e(e){this._checkoutButton=e.checkoutButton}return e.prototype.isInitializingButton=function(e){return this._checkoutButton.isInitializing(e)},e.prototype.isDeinitializingButton=function(e){return this._checkoutButton.isDeinitializing(e)},(0,o.__decorate)([xo],e)}();function Ho(e){return{errors:new Go(e),statuses:new Vo(e)}}var jo=function(){function e(e,t){var n=this;this._store=e,this._buttonStrategyActionCreator=t,this._state=Ho(this._store.getState()),this._store.subscribe((function(e){n._state=Ho(e)}))}return e.prototype.getState=function(){return this._state},e.prototype.subscribe=function(e){for(var t,n=this,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return(t=this._store).subscribe.apply(t,(0,o.__spreadArrays)([function(){return e(n.getState())},function(e){return e.checkoutButton.getState()}],r.map((function(e){return function(t){return e(Ho(t))}}))))},e.prototype.initializeButton=function(e){var t,n=this,r=(t=e.containerId,/^\w[\w\-\:\.]*$/.test(t)?[e.containerId]:function(e,t){var n=document.querySelectorAll(e);if(!n.length)throw new Gr("Unable to find any element with the specified selector: "+e);return Array.prototype.slice.call(n).map((function(e){return e.id||(e.id=(0,_.uniqueId)(t)),e.id}))}(e.containerId,e.methodId+"-container"));return Promise.all(r.map((function(t){var r=n._buttonStrategyActionCreator.initialize((0,o.__assign)((0,o.__assign)({},e),{containerId:t})),i="checkoutButtonStrategy:"+e.methodId+":"+t;return n._store.dispatch(r,{queueId:i})}))).then((function(){return n.getState()}))},e.prototype.deinitializeButton=function(e){var t=this,n=this._buttonStrategyActionCreator.deinitialize(e),r="checkoutButtonStrategy:"+e.methodId;return this._store.dispatch(n,{queueId:r}).then((function(){return t.getState()}))},(0,o.__decorate)([Yr],e)}();const Yo=jo,Wo=function(){function e(e,t,n){this._registry=e,this._registryV2=t,this._paymentMethodActionCreator=n}return e.prototype.initialize=function(e){var t=this;return function(n){var r={methodId:e.methodId,containerId:e.containerId};if(n.getState().checkoutButton.isInitialized(e.methodId,e.containerId))return(0,E.empty)();var i=e.currencyCode?{params:{currencyCode:e.currencyCode}}:{},s=(0,o.__assign)((0,o.__assign)({},i),{timeout:e.timeout,useCache:!0});return(0,E.concat)((0,E.of)((0,a.createAction)(Y.InitializeButtonRequested,void 0,r)),t._paymentMethodActionCreator.loadPaymentMethod(e.methodId,s)(n),(0,E.defer)((function(){return t._getStrategy(e.methodId).initialize(e).then((function(){return(0,a.createAction)(Y.InitializeButtonSucceeded,void 0,r)}))}))).pipe((0,b.catchError)((function(e){return or(Y.InitializeButtonFailed,e,r)})))}},e.prototype.deinitialize=function(e){var t=this;return function(n){var r={methodId:e.methodId};return n.getState().checkoutButton.isInitialized(e.methodId)?(0,E.concat)((0,E.of)((0,a.createAction)(Y.DeinitializeButtonRequested,void 0,r)),(0,E.defer)((function(){return t._getStrategy(e.methodId).deinitialize().then((function(){return(0,a.createAction)(Y.DeinitializeButtonSucceeded,void 0,r)}))}))).pipe((0,b.catchError)((function(e){return or(Y.DeinitializeButtonFailed,e,r)}))):(0,E.empty)()}},e.prototype._getStrategy=function(e){var t;try{t=this._registryV2.get({id:e})}catch(n){t=this._registry.get(e)}return t},e}(),Ko=function(e){function t(t){var n=e.call(this,t||"Unable to proceed because the client library of a payment method is not loaded or ready to be used.")||this;return n.name="PaymentMethodClientUnavailableError",n.type="payment_method_client_unavailable",n}return(0,o.__extends)(t,e),t}(s);var Zo,Qo,Jo,Xo;!function(e){e.Sandbox="sandbox",e.Production="production"}(Zo||(Zo={})),function(e){e.Client="client",e.DataCollector="dataCollector",e.Fastlane="fastlane",e.GooglePayment="googlePayment",e.HostedFields="hostedFields",e.LocalPayment="localPayment",e.Paypal="paypal",e.PaypalCheckout="paypalCheckout",e.ThreeDSecure="threeDSecure",e.UsBankAccount="usBankAccount",e.Venmo="venmo",e.VisaCheckout="visaCheckout"}(Qo||(Qo={})),function(e){e.CardCode="cardCode",e.CardCodeVerification="cardCodeVerification",e.CardExpiry="cardExpiry",e.CardName="cardName",e.CardNumber="cardNumber",e.CardNumberVerification="cardNumberVerification"}(Jo||(Jo={}));var $o=((Xo={})[Qo.Client]="sha384-26BXDNnJI23JYRyFBj4xe4sVNrUSSiSSu11kxVXNM/vEPONm4LuL00w6ZaTgQewt",Xo[Qo.PaypalCheckout]="sha384-B+vzbZwnQtzWBthpkT4TXKUibO65tyeK7eCxSvpblgprTep2+IAXB2Cxxjrn710O",Xo[Qo.Paypal]="sha384-uyAGL1/3+XJAHnGoNy4eCoXdzJ4f7Ilzp+6w9PNnEjs6DCCz9WMyJjMN1gzc78U+",Xo[Qo.LocalPayment]="sha384-LIvOEMkIVEwVuYBdVOQc1AC5YbGGlwyfUheS0ACK218D2STuVYQlZ4FyEPowAEfT",Xo[Qo.DataCollector]="sha384-1bo9JDz+Kscthc085cCKWur8CLwUoBpoNyxsDi7932mCl0zFq3A5mv+FQLw9GHpV",Xo[Qo.UsBankAccount]="sha384-xmHBVaU+w74V+OebD3AaPONFxHUGMf+QRs8G/JxVPXNNP7MDa2jL0ICWHIe2tTfJ",Xo[Qo.GooglePayment]="sha384-WKDJl8mqoP82qZpMGH6AbZxnvXnSW8ILV4M64CyMLiugGMwu7LyP89wjCkHqsiBe",Xo[Qo.ThreeDSecure]="sha384-VQUlpGHzsGvs5XeiGFip7EXRsvoHWEXDVmgCacfbyieZI9mdBOqq3NSoyo28OCOB",Xo[Qo.VisaCheckout]="sha384-yx7mADfzTN0T43Q6rlH49LIg1EJ0iUZgBp/EczX9LXsUGkySgxrD+nWHQRBkyfoT",Xo[Qo.Venmo]="sha384-QX4rPjoj1ZDhuG0aSyKs56lEKDqTMTcjYxUHY1SzO5VZDsqIE2NTkqot7KNSCyov",Xo[Qo.HostedFields]="sha384-VvYBACfSu0Cr/J32uKmxG7AXcNOJE1AzIIL3kbikyS7YKp5fz5Is+NzNP/lyauNy",Xo[Qo.Fastlane]="sha384-9oGsZMRZwpGtDEDYa/dFt76dECqj1xAni9gIKgc3KfMIiRnR73nEeeUDLiBzxhFa",Xo),ea=function(){function e(e,t){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSdkVersion="3.106.0"}return e.prototype.loadClient=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.Client,"client.min.js")]}))}))},e.prototype.loadFastlane=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.Fastlane,"fastlane.min.js")]}))}))},e.prototype.loadPaypalCheckout=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.PaypalCheckout,"paypal-checkout.min.js")]}))}))},e.prototype.loadPaypal=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.Paypal,"paypal.min.js")]}))}))},e.prototype.loadBraintreeLocalMethods=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.LocalPayment,"local-payment.min.js")]}))}))},e.prototype.loadDataCollector=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.DataCollector,"data-collector.min.js")]}))}))},e.prototype.loadUsBankAccount=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.UsBankAccount,"us-bank-account.min.js")]}))}))},e.prototype.loadGooglePayment=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.GooglePayment,"google-payment.min.js")]}))}))},e.prototype.load3DS=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.ThreeDSecure,"three-d-secure.min.js")]}))}))},e.prototype.loadVisaCheckout=function(){return this.loadBraintreeModuleOrThrow(Qo.VisaCheckout,"visa-checkout.min.js")},e.prototype.loadVenmoCheckout=function(){return this.loadBraintreeModuleOrThrow(Qo.Venmo,"venmo.min.js")},e.prototype.loadHostedFields=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.HostedFields,"hosted-fields.min.js")]}))}))},e.prototype.loadVisaCheckoutSdk=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n=this;return(0,o.__generator)(this,(function(r){return this.braintreeHostWindow.V?[2,this.braintreeHostWindow.V]:(t=e?"sha384-0eu1s1GtqzXlL9DtLgmwzC5WWlEH/ADRM0n38cVQkvtT+W/gey96rcb1LwuUOPDm":"sha384-1f1csvP3ZFxg4dILH1GaY4LHlZ0oX7Rk83rxmLlwbnIi4TM0NYzXoev1VoEiVDS6",[2,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((function(){if(!n.braintreeHostWindow.V)throw new Ko;return n.braintreeHostWindow.V}))])}))}))},e.prototype.loadBraintreeModuleOrThrow=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return(n=this.getBraintreeModule(e))?[2,n]:(r="//js.braintreegateway.com/web/"+this.braintreeSdkVersion+"/js/"+t,i=this.getIntegrityValuesByModuleName(e),[4,this.scriptLoader.loadScript(r,i?{async:!0,attributes:{integrity:i,crossorigin:"anonymous"}}:void 0)]);case 1:if(o.sent(),!(n=this.getBraintreeModule(e)))throw new Ko;return[2,n]}}))}))},e.prototype.getBraintreeModule=function(e){var t;return null===(t=this.braintreeHostWindow.braintree)||void 0===t?void 0:t[e]},e.prototype.getIntegrityValuesByModuleName=function(e){var t=$o[e];if(!t)throw new Error("Unexpected fileName value");return t},e}();const ta=ea;var na=function(){function e(e){var t,n,r;this._factories={},this._instances={},this._defaultToken=null!==(t=null==e?void 0:e.defaultToken)&&void 0!==t?t:"default",this._useFallback=null===(n=null==e?void 0:e.useFallback)||void 0===n||n,this._tokenResolver=null!==(r=null==e?void 0:e.tokenResolver)&&void 0!==r?r:function(e){return e}}return e.prototype.get=function(e,t){try{return this._getInstance(e||this._defaultToken,t||e||this._defaultToken)}catch(e){if(!this._useFallback)throw e;return this._getInstance(this._defaultToken,t||this._defaultToken)}},e.prototype.register=function(e,t){if(this._hasFactory(e))throw new Gr("'"+e+"' is already registered.");this._factories[e]=t},e.prototype._hasFactory=function(e){return!!this._factories[e]},e.prototype._hasInstance=function(e){return!!this._instances[e]},e.prototype._getInstance=function(e,t){if(!this._hasInstance(t)){var n=this._tokenResolver(e,Object.keys(this._factories)),r=n&&this._factories[n];if(!r)throw new Gr("'"+e+"' is not registered.");this._instances[t]=r()}return this._instances[t]},e}();const ra=na;var ia,oa,aa,sa,ua,ca=["buttons","messages"];!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(ia||(ia={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(oa||(oa={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white"}(aa||(aa={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(sa||(sa={})),function(e){e.PILL="pill",e.RECT="rect"}(ua||(ua={}));const da=function(e){function t(t){var n=e.call(this,t||"Unsupported browser error")||this;return n.name="UnsupportedBrowserError",n.type="unsupported_browser",n}return(0,o.__extends)(t,e),t}(p);var la=function(){function e(e){this._braintreeScriptLoader=e,this._dataCollectors={},this._window=window}return e.prototype.initialize=function(e){this._clientToken=e},e.prototype.getClient=function(){var e=this;if(!this._clientToken)throw new ni(ti.PaymentNotInitialized);return this._client||(this._client=this._braintreeScriptLoader.loadClient().then((function(t){return t.create({authorization:e._clientToken})}))),this._client},e.prototype.getPaypalCheckout=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s,u=this;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,this.getClient()];case 1:return r=o.sent(),[4,this._braintreeScriptLoader.loadPaypalCheckout()];case 2:return i=o.sent(),a={client:r},s=function(r,i){if(r)return n(r);u._window.paypal?t(i):i.loadPayPalSDK(u._getPayPalSDKConfig(e),(function(){return t(i)}))},this._paypalCheckout=i.create(a,s),[2,this._paypalCheckout]}}))}))},e.prototype.getVenmoCheckout=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return this._venmoCheckout?[3,3]:[4,this.getClient()];case 1:return n=o.sent(),[4,this._braintreeScriptLoader.loadVenmoCheckout()];case 2:r=o.sent(),i={client:n,allowDesktop:!0,paymentMethodUsage:"multi_use"},a=function(n,r){return n?t(n):r.isBrowserSupported()?void e(r):t(new da)},this._venmoCheckout=r.create(i,a),o.label=3;case 3:return[2,this._venmoCheckout]}}))}))},e.prototype.get3DS=function(){return this._3ds||(this._3ds=Promise.all([this.getClient(),this._braintreeScriptLoader.load3DS()]).then((function(e){var t=e[0];return e[1].create({client:t,version:2})}))),this._3ds},e.prototype.getDataCollector=function(e){var t=e&&e.paypal?"paypal":"default",n=this._dataCollectors[t];return n||(n=Promise.all([this.getClient(),this._braintreeScriptLoader.loadDataCollector()]).then((function(t){var n=t[0];return t[1].create((0,o.__assign)({client:n,kount:!0},e))})).catch((function(e){if(e&&"DATA_COLLECTOR_KOUNT_NOT_ENABLED"===e.code)return{deviceData:void 0,teardown:function(){return Promise.resolve()}};throw e})),this._dataCollectors[t]=n),n},e.prototype.getVisaCheckout=function(){return this._visaCheckout||(this._visaCheckout=Promise.all([this.getClient(),this._braintreeScriptLoader.loadVisaCheckout()]).then((function(e){var t=e[0];return e[1].create({client:t})}))),this._visaCheckout},e.prototype.createHostedFields=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,Promise.all([this.getClient(),this._braintreeScriptLoader.loadHostedFields()])];case 1:return t=r.sent(),n=t[0],[2,t[1].create((0,o.__assign)((0,o.__assign)({},e),{client:n}))]}}))}))},e.prototype.teardown=function(){var e=this;return Promise.all([this._teardown(this._3ds),this._teardown(this._dataCollectors.default),this._teardown(this._dataCollectors.paypal),this._teardown(this._paypalCheckout),this._teardown(this._venmoCheckout),this._teardown(this._visaCheckout)]).then((function(){e._3ds=void 0,e._dataCollectors={},e._paypalCheckout=void 0,e._venmoCheckout=void 0,e._visaCheckout=void 0}))},e.prototype._teardown=function(e){return e?e.then((function(e){return e.teardown()})).catch((function(e){if("METHOD_CALLED_AFTER_TEARDOWN"!==e.code)throw e})):Promise.resolve()},e.prototype._getPayPalSDKConfig=function(e){return(0,o.__assign)((0,o.__assign)({currency:e.currency},e.isCreditEnabled&&{"enable-funding":"paylater"}),{components:ca.toString(),intent:e.intent,commit:!1})},e}();const pa=la;const ha=function(e){function t(t){var n=e.call(this,t||"Unable to proceed because the client library of a payment method is not loaded or ready to be used.")||this;return n.name="PaymentMethodClientUnavailableError",n.type="payment_method_client_unavailable",n}return(0,o.__extends)(t,e),t}(p);var fa=function(){function e(e,t){void 0===t&&(t=window),this._scriptLoader=e,this._window=t}return e.prototype.load=function(e){var t=e.useMasterpassSrc,n=e.language,r=e.testMode,i=e.checkoutId;return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return t?(e=["https://"+(r?"sandbox.":"")+"src.mastercard.com/srci/integration/merchant.js",["locale="+n,"checkoutid="+i].join("&")].join("?"),[4,this._scriptLoader.loadScript(e)]):[3,2];case 1:case 3:if(o.sent(),!this._window.masterpass)throw new ha;return[2,this._window.masterpass];case 2:return[4,this._scriptLoader.loadScript("//"+(r?"sandbox.":"")+"masterpass.com/integration/merchant.js")]}}))}))},e}();const ga=fa,ma=function(){function e(e){this._scriptLoader=e,this._window=window}return e.prototype.loadPaypal=function(e){return void 0===e&&(e=""),(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return t="//www.paypalobjects.com/api/checkout.min.js",n={async:!0,attributes:{"data-merchant-id":e}},e?[4,this._scriptLoader.loadScript(t,n)]:[3,2];case 1:return r.sent(),[3,4];case 2:return[4,this._scriptLoader.loadScript(t)];case 3:r.sent(),r.label=4;case 4:if(!this._window.paypal)throw new ha;return[2,this._window.paypal]}}))}))},e}(),_a=function(e){function t(t){var n=e.call(this,t||"An unexpected error has occurred during buy now cart creation process. Please try again later.")||this;return n.name="BuyNowCartCreationError",n.type="buy_now_cart_creation_error",n}return(0,o.__extends)(t,e),t}(p);function ya(e){return{recipientName:e.firstName+" "+e.lastName,line1:e.address1,line2:e.address2,city:e.city,state:e.stateOrProvinceCode,postalCode:e.postalCode,countryCode:e.countryCode,phone:e.phone}}function va(e){var t=e.color,n=e.fundingicons,r=e.height,i=e.layout,o=e.shape,a=e.size,s=e.tagline,u={color:t,fundingicons:n,height:Ca(r),layout:i,shape:o||"rect",size:a,tagline:s};return(0,_.omitBy)(u,_.isNil)}function Ca(e){return"number"!=typeof e||e>55?55:e<25?25:e}function Sa(e){var t=e.billingAddress,n=e.email,r=e.firstName,i=e.lastName,o=e.phone,a=e.shippingAddress,s=t||a;return{email:n,first_name:r,last_name:i,phone_number:o,address_line_1:null==s?void 0:s.line1,address_line_2:null==s?void 0:s.line2,city:null==s?void 0:s.city,state:null==s?void 0:s.state,country_code:null==s?void 0:s.countryCode,postal_code:null==s?void 0:s.postalCode}}function Ia(e){var t=e.email,n=e.phone,r=e.shippingAddress,i=((null==r?void 0:r.recipientName)||"").split(" ");return{email:t,first_name:i[0]||"",last_name:i[1]||"",phone_number:n,address_line_1:null==r?void 0:r.line1,address_line_2:null==r?void 0:r.line2,city:null==r?void 0:r.city,state:null==r?void 0:r.state,country_code:null==r?void 0:r.countryCode,postal_code:null==r?void 0:r.postalCode}}var wa=function(){function e(e,t,n,r,i,o){this._store=e,this._checkoutActionCreator=t,this._cartRequestSender=n,this._braintreeSDKCreator=r,this._formPoster=i,this._window=o}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h,f,g,m=this;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.braintreepaypal,n=e.containerId,r=e.methodId,a=(i=t||{}).messagingContainerId,s=i.onError,!r)throw new Gr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Gr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Gr('Unable to initialize payment because "options.braintreepaypal" argument is not provided.');if(!t.buyNowInitializeOptions)return[3,1];if(u=this._store.getState(),c=u.paymentMethods.getPaymentMethodOrThrow(r),!t.currencyCode)throw new Gr('Unable to initialize payment because "options.braintreepaypal.currencyCode" argument is not provided.');return d=t.currencyCode,[3,3];case 1:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 2:u=o.sent(),c=u.paymentMethods.getPaymentMethodOrThrow(r),d=u.cart.getCartOrThrow().currency.code,o.label=3;case 3:if(l=c.clientToken,p=c.initializationData,!l||!p)throw new Nn(Mn.MissingPaymentMethod);return h={currency:d,intent:p.intent,isCreditEnabled:p.isCreditEnabled},f=function(e){m._renderPayPalComponents(e,t,n,r,Boolean(c.config.testMode))},g=function(e){return m._handleError(e,n,a,s)},this._braintreeSDKCreator.initialize(l),[4,this._braintreeSDKCreator.getPaypalCheckout(h,f,g)];case 4:return o.sent(),[2]}}))}))},e.prototype.deinitialize=function(){return this._braintreeSDKCreator.teardown(),Promise.resolve()},e.prototype._renderPayPalComponents=function(e,t,n,r,i){var o=t.messagingContainerId;this._renderPayPalMessages(o),this._renderPayPalButton(e,t,n,r,i)},e.prototype._renderPayPalButton=function(e,t,n,r,i){var o=this,a=t.style,s=t.shouldProcessPayment,u=t.onAuthorizeError,c=this._window.paypal,d=null==c?void 0:c.FUNDING.PAYPAL;if(c&&d){var l=a?va(a):{},p=c.Buttons({env:i?"sandbox":"production",fundingSource:d,style:l,createOrder:function(){return o._setupPayment(e,t,r)},onApprove:function(t){return o._tokenizePayment(t,e,r,s,u)}});p.isEligible()&&p.render("#"+n)}else this._removeElement(n)},e.prototype._renderPayPalMessages=function(e){var t=e&&Boolean(document.getElementById(e)),n=this._window.paypal;if(n&&t){var r=this._store.getState().checkout.getCheckoutOrThrow().outstandingBalance;n.Messages({amount:r,placement:"cart"}).render("#"+e)}else this._removeElement(e)},e.prototype._setupPayment=function(e,t,n){var r,i;return(0,o.__awaiter)(this,void 0,void 0,(function(){var a,s,u,c,d,l,p,h,f,g,m,_;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:a=t.buyNowInitializeOptions,s=t.shippingAddress,u=t.onPaymentError,o.label=1;case 1:return o.trys.push([1,7,,8]),d=this,[4,this._createBuyNowCart({buyNowInitializeOptions:a})];case 2:return d._buyNowCart=o.sent(),this._buyNowCart?(c=this._store.getState(),[3,5]):[3,3];case 3:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 4:c=o.sent(),o.label=5;case 5:return l=c.customer.getCustomer(),p=c.paymentMethods.getPaymentMethodOrThrow(n),h=this._buyNowCart?this._buyNowCart.cartAmount:c.checkout.getCheckoutOrThrow().outstandingBalance,f=null!==(r=t.currencyCode)&&void 0!==r?r:c.config.getStoreConfigOrThrow().currency.code,g=s||(null==l?void 0:l.addresses[0]),m=g?ya(g):void 0,[4,e.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,shippingAddressOverride:m,amount:h,currency:f,offerCredit:!1,intent:null===(i=p.initializationData)||void 0===i?void 0:i.intent})];case 6:return[2,o.sent()];case 7:throw _=o.sent(),u&&u(_),_;case 8:return[2]}}))}))},e.prototype._createBuyNowCart=function(e){var t=e.buyNowInitializeOptions;return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("function"!=typeof(null==t?void 0:t.getBuyNowCartRequestBody))return[3,4];if(!(e=t.getBuyNowCartRequestBody()))throw new Nn(Mn.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._cartRequestSender.createBuyNowCart(e)];case 2:return[2,n.sent().body];case 3:throw n.sent(),new _a;case 4:return[2]}}))}))},e.prototype._tokenizePayment=function(e,t,n,r,i){var a;return(0,o.__awaiter)(this,void 0,void 0,(function(){var s,u,c,d,l,p;return(0,o.__generator)(this,(function(h){switch(h.label){case 0:return h.trys.push([0,3,,4]),[4,this._braintreeSDKCreator.getDataCollector({paypal:!0})];case 1:return s=h.sent().deviceData,[4,t.tokenizePayment(e)];case 2:return u=h.sent(),c=u.details,d=u.nonce,l=null===(a=this._buyNowCart)||void 0===a?void 0:a.id,this._formPoster.postForm("/checkout.php",(0,o.__assign)({payment_type:"paypal",provider:n,action:r?"process_payment":"set_external_checkout",nonce:d,device_data:s,billing_address:JSON.stringify(Sa(c)),shipping_address:JSON.stringify(Ia(c))},l&&{cart_id:l})),[2,u];case 3:throw p=h.sent(),i&&i(p),p;case 4:return[2]}}))}))},e.prototype._handleError=function(e,t,n,r){this._removeElement(t),this._removeElement(n),r&&r(e)},e.prototype._removeElement=function(e){var t=e&&document.getElementById(e);t&&t.remove()},e}();const Ea=wa;var ba,Pa,Aa,Oa,Ta;!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(ba||(ba={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(Pa||(Pa={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white"}(Aa||(Aa={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(Oa||(Oa={})),function(e){e.PILL="pill",e.RECT="rect"}(Ta||(Ta={}));var Ra=function(){function e(e,t,n,r,i,o){this._store=e,this._checkoutActionCreator=t,this._cartRequestSender=n,this._braintreeSDKCreator=r,this._formPoster=i,this._window=o}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h=this;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.braintreepaypalcredit,n=e.containerId,!(r=e.methodId))throw new Gr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Gr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Gr('Unable to initialize payment because "options.braintreepaypalcredit" argument is not provided.');if(!t.buyNowInitializeOptions)return[3,1];if(i=this._store.getState(),a=i.paymentMethods.getPaymentMethodOrThrow(r),!t.currencyCode)throw new Gr('Unable to initialize payment because "options.braintreepaypalcredit.currencyCode" argument is not provided.');return s=t.currencyCode,[3,3];case 1:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 2:i=o.sent(),a=i.paymentMethods.getPaymentMethodOrThrow(r),s=i.cart.getCartOrThrow().currency.code,o.label=3;case 3:if(u=a.clientToken,c=a.initializationData,!u||!c)throw new Nn(Mn.MissingPaymentMethod);return d={currency:s,intent:c.intent,isCreditEnabled:c.isCreditEnabled},l=function(e){return h._renderPayPalButton(e,t,n,r,Boolean(a.config.testMode))},p=function(e){return h._handleError(e,n,t.onError)},this._braintreeSDKCreator.initialize(u),[4,this._braintreeSDKCreator.getPaypalCheckout(d,l,p)];case 4:return o.sent(),[2]}}))}))},e.prototype.deinitialize=function(){return this._braintreeSDKCreator.teardown(),Promise.resolve()},e.prototype._renderPayPalButton=function(e,t,n,r,i){var a=this,s=t.style,u=t.shouldProcessPayment,c=t.onAuthorizeError,d=this._window.paypal,l=!1;if(d){var p=[d.FUNDING.PAYLATER,d.FUNDING.CREDIT],h=s?va(s):{};p.forEach((function(s){var p=s===d.FUNDING.CREDIT?(0,o.__assign)({label:Oa.CREDIT},h):h;if(!l){var f=d.Buttons({env:i?"sandbox":"production",fundingSource:s,style:p,createOrder:function(){return a._setupPayment(e,t,r)},onApprove:function(t){return a._tokenizePayment(t,e,r,u,c)}});f.isEligible()&&(f.render("#"+n),l=!0)}}))}d&&l||this._removeElement(n)},e.prototype._setupPayment=function(e,t,n){var r,i;return(0,o.__awaiter)(this,void 0,void 0,(function(){var a,s,u,c,d,l,p,h,f,g,m,_;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:a=t.onPaymentError,s=t.shippingAddress,u=t.buyNowInitializeOptions,o.label=1;case 1:return o.trys.push([1,7,,8]),d=this,[4,this._createBuyNowCart({buyNowInitializeOptions:u})];case 2:return d._buyNowCart=o.sent(),this._buyNowCart?(c=this._store.getState(),[3,5]):[3,3];case 3:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 4:c=o.sent(),o.label=5;case 5:return l=c.customer.getCustomer(),p=c.paymentMethods.getPaymentMethodOrThrow(n),h=this._buyNowCart?this._buyNowCart.cartAmount:c.checkout.getCheckoutOrThrow().outstandingBalance,f=null!==(r=t.currencyCode)&&void 0!==r?r:c.config.getStoreConfigOrThrow().currency.code,g=s||(null==l?void 0:l.addresses[0]),m=g?ya(g):void 0,[4,e.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,shippingAddressOverride:m,amount:h,currency:f,offerCredit:!0,intent:null===(i=p.initializationData)||void 0===i?void 0:i.intent})];case 6:return[2,o.sent()];case 7:throw _=o.sent(),a&&a(_),_;case 8:return[2]}}))}))},e.prototype._createBuyNowCart=function(e){var t=e.buyNowInitializeOptions;return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("function"!=typeof(null==t?void 0:t.getBuyNowCartRequestBody))return[3,4];if(!(e=t.getBuyNowCartRequestBody()))throw new Nn(Mn.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._cartRequestSender.createBuyNowCart(e)];case 2:return[2,n.sent().body];case 3:throw n.sent(),new _a;case 4:return[2]}}))}))},e.prototype._tokenizePayment=function(e,t,n,r,i){var a;return(0,o.__awaiter)(this,void 0,void 0,(function(){var s,u,c,d,l,p;return(0,o.__generator)(this,(function(h){switch(h.label){case 0:return h.trys.push([0,3,,4]),[4,this._braintreeSDKCreator.getDataCollector({paypal:!0})];case 1:return s=h.sent().deviceData,[4,t.tokenizePayment(e)];case 2:return u=h.sent(),c=u.details,d=u.nonce,l=null===(a=this._buyNowCart)||void 0===a?void 0:a.id,this._formPoster.postForm("/checkout.php",(0,o.__assign)({payment_type:"paypal",provider:n,action:r?"process_payment":"set_external_checkout",nonce:d,device_data:s,billing_address:JSON.stringify(Sa(c)),shipping_address:JSON.stringify(Ia(c))},l&&{cart_id:l})),[2,u];case 3:throw p=h.sent(),i&&i(p),p;case 4:return[2]}}))}))},e.prototype._handleError=function(e,t,n){this._removeElement(t),n&&n(e)},e.prototype._removeElement=function(e){var t=e&&document.getElementById(e);t&&t.remove()},e}();const ka=Ra;var Da={es:["es_es","es_mx","es_pe","es_co","es_ar","es_cl"],en:["en_us","en_gb","en_ca","en_es","en_fr","en_ie","en_sg","en_au","en_nz","en_my","en_hk","en_th","en_ae","en_sa","en_qa","en_kw","en_za"],pt:["pt_br"],zu:["zu_za"],ar:["ar_sa","ar_ae","ar_qa","ar_kw"],zh:["zh_sg","zh_hk"],ms:["ms_my"],uk:["uk_ua"],sv:["sv_se"],hr:["hr_hr"],pl:["pl_pl"],nl:["nl_be"],it:["it_it"],de:["de_de"],fr:["fr_fr","fr_ca"]};function Ma(e){var t=e.replace("-","_").toLowerCase().split("_"),n=t[0],r=n+"_"+t[1],i=Da[n];return i?i.indexOf(r)>-1?r:i[0]:"en_us"}const Na=function(){function e(e,t,n,r){this._store=e,this._checkoutActionCreator=t,this._masterpassScriptLoader=n,this._locale=r}return e.prototype.initialize=function(e){var t=this,n=e.containerId,r=e.methodId;if(!n||!r)throw new Gr('Unable to proceed because "containerId" argument is not provided.');return this._methodId=r,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout()).then((function(e){var n=e.paymentMethods.getPaymentMethod(r);if(!n||!n.initializationData.checkoutId)throw new Nn(Mn.MissingPaymentMethod);var i={useMasterpassSrc:n.initializationData.isMasterpassSrcEnabled,language:Ma(t._locale),testMode:n.config.testMode,checkoutId:n.initializationData.checkoutId};return t._masterpassScriptLoader.load(i)})).then((function(e){t._masterpassClient=e,t._signInButton=t._createSignInButton(n)}))},e.prototype.deinitialize=function(){return this._signInButton&&this._signInButton.parentNode&&(this._signInButton.removeEventListener("click",this._handleWalletButtonClick),this._signInButton.parentNode.removeChild(this._signInButton),this._signInButton=void 0),Promise.resolve()},e.prototype._createSignInButton=function(e){var t=document.getElementById(e),n=this._store.getState(),r=this._methodId?n.paymentMethods.getPaymentMethod(this._methodId):null,i=n.config.getStoreConfig();if(!t)throw new Error("Need a container to place the button");if(!r)throw new Nn(Mn.MissingPaymentMethod);if(!i)throw new Gr("Unable to retrieve store configuration");var o=document.createElement("input");if(o.type="image",r.initializationData.isMasterpassSrcEnabled){var a=r.config.testMode?"sandbox.":"",s=r.initializationData.checkoutId,u=["locale="+Ma(this._locale),"paymentmethod=master,visa,amex,discover","checkoutid="+s];o.src=["https://"+a+"src.mastercard.com/assets/img/btn/src_chk_btn_126x030px.svg",u.join("&")].join("?")}else o.src="https://static.masterpass.com/dyn/img/btn/global/mp_chk_btn_160x037px.svg";return t.appendChild(o),o.addEventListener("click",this._handleWalletButtonClick),o},e.prototype._createMasterpassPayload=function(){var e=this._store.getState(),t=e.checkout.getCheckout(),n=this._methodId?e.paymentMethods.getPaymentMethod(this._methodId):null;if(!t)throw new Nn(Mn.MissingCheckout);if(!n)throw new Nn(Mn.MissingPaymentMethod);return{checkoutId:n.initializationData.checkoutId,allowedCardTypes:n.initializationData.allowedCardTypes,amount:t.cart.cartAmount.toString(),currency:t.cart.currency.code,cartId:t.cart.id,callbackUrl:window.location.origin+"/checkout.php?action=set_external_checkout&provider=masterpass&gateway=stripe&origin=cart"}},e.prototype._handleWalletButtonClick=function(){if(!this._masterpassClient)throw new ni(ti.CheckoutButtonNotInitialized);this._masterpassClient.checkout(this._createMasterpassPayload())},(0,o.__decorate)([Yr],e.prototype,"_handleWalletButtonClick",null),e}();var La=function(){function e(e,t,n,r,i){void 0===i&&(i=""),this._store=e,this._checkoutActionCreator=t,this._paypalScriptLoader=n,this._formPoster=r,this._host=i}return e.prototype.initialize=function(e){var t=this,n=e.paypal,r=this._store.getState(),i=this._paymentMethod=r.paymentMethods.getPaymentMethod(e.methodId);if(!n)throw new Gr;if(!i)throw new Nn(Mn.MissingPaymentMethod);return this._paypalScriptLoader.loadPaypal(i.config.merchantId).then((function(r){var a,s,u;if(!i||!i.config.merchantId)throw new Nn(Mn.MissingPaymentMethod);var c=i.config.merchantId,d=i.config.testMode?"sandbox":"production",l=((a={})[d]=n.clientId,a),p=r.FUNDING.CREDIT||"credit",h=n.allowCredit?[p]:[],f=n.allowCredit?[]:[p];return r.Button.render({env:d,client:l,commit:n.shouldProcessPayment,funding:{allowed:h,disallowed:f},style:(0,o.__assign)((0,o.__assign)({shape:Ta.RECT},(0,_.pick)(n.style,"layout","color","label","shape","tagline","fundingicons")),{size:"paypalexpress"===i.id&&"small"===(null===(s=n.style)||void 0===s?void 0:s.size)?Pa.RESPONSIVE:null===(u=n.style)||void 0===u?void 0:u.size}),payment:function(e,r){return t._setupPayment(c,r,n.onPaymentError)},onAuthorize:function(e,r){return t._tokenizePayment(e,r,n.shouldProcessPayment,n.onAuthorizeError)}},e.containerId)}))},e.prototype.deinitialize=function(){return this._paymentMethod=void 0,Promise.resolve()},e.prototype._setupPayment=function(e,t,n){var r=this;if(!t)throw new ni(ti.CheckoutButtonNotInitialized);return this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout()).then((function(n){var i=n.cart.getCart(),a=i?i.id:"";return t.request.post(r._host+"/api/storefront/payment/paypalexpress",{merchantId:e,cartId:a},{headers:(0,o.__assign)({"X-API-INTERNAL":er},tr)})})).then((function(e){return e.id})).catch((function(e){throw n&&n(e),e}))},e.prototype._tokenizePayment=function(e,t,n,r){var i=this;if(!this._paymentMethod)throw new ni(ti.CheckoutButtonNotInitialized);if(!t)throw new ni(ti.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new Nn(Mn.MissingPayment);var o=this._paymentMethod.id;return t.payment.get(e.paymentID).then((function(t){i._formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:o,action:n?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(t.payer.payer_info)})}))},e}();const za=La;function Ua(){try{return process.env.NODE_ENV||0}catch(e){return"development"}}var Fa=function(){function e(e){this._console=e}return e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["log"],e))},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["info"],e))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["warn"],e))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["error"],e))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["debug"],e))},e.prototype._logToConsole=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];this._console&&this._console[e]&&(t=this._console[e]).call.apply(t,(0,o.__spreadArrays)([this._console],n))},e}();const Ba=Fa,qa=function(){function e(){}return e.prototype.log=function(){},e.prototype.info=function(){},e.prototype.warn=function(){},e.prototype.error=function(){},e.prototype.debug=function(){},e}();var xa,Ga=(void 0===(xa="test"!==Ua())&&(xa=!0),xa?new Ba(console):new qa),Va=function(){function e(e){void 0===e&&(e=!1),this._useFallback=e,this._registry=new ra({tokenResolver:this._resolveToken.bind(this),useFallback:this._useFallback})}return e.prototype.get=function(e){return this._registry.get(this._encodeToken(e))},e.prototype.register=function(e,t){this._registry.register(this._encodeToken(e),t)},e.prototype._encodeToken=function(e){return btoa(JSON.stringify(e))},e.prototype._decodeToken=function(e){return JSON.parse(atob(e))},e.prototype._resolveToken=function(e,t){var n,r=this,i=this._decodeToken(e),o=[];t.forEach((function(e){for(var t=r._decodeToken(e),n={token:e,matches:0,default:!1},a=0,s=Object.entries(t);a<s.length;a++){var u=s[a],c=u[0],d=u[1];if(c in i&&i[c]!==d){n.matches=0;break}c in i&&i[c]===d&&n.matches++,"default"===c&&!0===d&&(n.default=!0)}o.push(n)}));var a=o.sort((function(e,t){return t.matches-e.matches})).filter((function(e){return e.matches>0}));a.length>1&&a[0].matches===a[1].matches&&"development"===Ua()&&Ga.warn("The provided query matches at least two strategies with the same specificity. This warning can be resolved by making their resolve ID more specific.");var s=a[0];if(s&&s.token)return s.token;if(this._useFallback){var u=null===(n=o.find((function(e){return e.default})))||void 0===n?void 0:n.token;if(u)return u}throw new Error("Unable to resolve to a registered token with the provided token.")},e}();const Ha=Va;const ja=function(e){function t(t){var n=e.call(this,t||"Invalid arguments have been provided.")||this;return n.name="InvalidArgumentError",n.type="invalid_argument",n}return(0,o.__extends)(t,e),t}(s);var Ya;!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(Ya||(Ya={}));const Wa=function(e){function t(t){var n=e.call(this,function(e){switch(e){case Ya.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case Ya.MissingCart:return"Unable to proceed because cart data is unavailable.";case Ya.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case Ya.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case Ya.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case Ya.MissingCheckoutConfig:case Ya.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case Ya.MissingOrder:return"Unable to proceed because order data is unavailable.";case Ya.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case Ya.MissingPayment:return"Unable to proceed because payment data is unavailable.";case Ya.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case Ya.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case Ya.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(t))||this;return n.subtype=t,n.name="MissingDataError",n.type="missing_data",n}return(0,o.__extends)(t,e),t}(s);function Ka(e){return t=e.lineItems.physicalItems.filter((function(e){return!e.addedByPromotion})),(0,_.reduce)(t,(function(e,t){return e+t.quantity}),0);var t}function Za(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}var Qa;!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(Qa||(Qa={}));const Ja=function(e){function t(t){var n=e.call(this,function(e){switch(e){case Qa.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case Qa.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case Qa.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case Qa.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(t))||this;return n.subtype=t,n.name="NotInitializedError",n.type="not_initialized",n}return(0,o.__extends)(t,e),t}(s);var Xa,$a,es,ts,ns,rs,is={de:"eu",jp:"fe",uk:"eu",us:"na"};!function(e){e.en_US="en_US",e.en_GB="en_GB",e.de_DE="de_DE",e.fr_FR="fr_FR",e.it_IT="it_IT",e.es_ES="es_ES",e.ja_JP="ja_JP"}(Xa||(Xa={})),function(e){e.Home="Home",e.Product="Product",e.Cart="Cart",e.Checkout="Checkout",e.Other="Other"}($a||($a={})),function(e){e.USD="USD",e.EUR="EUR",e.GBP="GBP",e.JPY="JPY"}(es||(es={})),function(e){e.PayAndShip="PayAndShip",e.PayOnly="PayOnly"}(ts||(ts={})),function(e){e.Gold="Gold",e.LightGray="LightGray",e.DarkGray="DarkGray"}(ns||(ns={})),function(e){e.C0001="C0001"}(rs||(rs={}));var os=function(){function e(e){this.amazonPayV2ScriptLoader=e}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return t=this,[4,this.amazonPayV2ScriptLoader.load(e)];case 1:return t.amazonPayV2SDK=n.sent(),this.buttonParentContainer=this.buttonParentContainer||this.createAmazonPayButtonParentContainer(),[2]}}))}))},e.prototype.deinitialize=function(){var e;return this.amazonPayV2Button=void 0,null===(e=this.buttonParentContainer)||void 0===e||e.remove(),this.buttonParentContainer=void 0,this.amazonPayV2SDK=void 0,Promise.resolve()},e.prototype.bindButton=function(e,t,n){this.getAmazonPayV2SDK().Pay.bindChangeAction("#"+e,{amazonCheckoutSessionId:t,changeAction:n})},e.prototype.createButton=function(e,t){this.amazonPayV2Button=this.getAmazonPayV2SDK().Pay.renderButton("#"+e,t)},e.prototype.prepareCheckout=function(e){var t=this,n=this.prepareRequestConfig(e);this.getAmazonPayV2Button().onClick((function(){t.getAmazonPayV2Button().initCheckout(n)}))},e.prototype.prepareCheckoutWithCreationRequestConfig=function(e){var t=this;this.getAmazonPayV2Button().onClick((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,e()];case 1:return(t=r.sent())&&(n=this.prepareRequestConfig(t.createCheckoutSessionConfig,t.estimatedOrderAmount,t.productType),this.getAmazonPayV2Button().initCheckout(n)),[2]}}))}))}))},e.prototype.signout=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return this.amazonPayV2SDK&&this.amazonPayV2SDK.Pay.signout(),[2,Promise.resolve()]}))}))},e.prototype.renderAmazonPayButton=function(e){var t=e.buttonColor,n=e.checkoutState,r=e.containerId,i=e.decoupleCheckoutInitiation,o=void 0!==i&&i,a=e.methodId,s=e.options,u=e.placement,c=e.isButtonMicroTextDisabled,d=void 0!==c&&c,l=document.querySelector("#"+r);if(!l)throw new ja("Unable to render the Amazon Pay button to an invalid HTML container element.");var p=l.appendChild(this.getButtonParentContainer()).id;s&&d&&(s.design=rs.C0001);var h=null!=s?s:this.getAmazonPayV2ButtonOptions(n,a,u,o,t);return this.createButton(p,h),this.getButtonParentContainer()},e.prototype.updateBuyNowFlowFlag=function(e){this.isBuyNowFlow=Boolean(e)},e.prototype.isPh4Enabled=function(e,t){var n=!!e["PROJECT-3483.amazon_pay_ph4"],r=!!e["INT-6885.amazon_pay_ph4_us_only"];return n&&r?"US"===t:n},e.prototype.prepareRequestConfig=function(e,t,n){var r=e.publicKeyId,i=(0,o.__rest)(e,["publicKeyId"]);return(0,o.__assign)((0,o.__assign)({createCheckoutSessionConfig:this.isEnvironmentSpecific(r)?i:e},t&&{estimatedOrderAmount:t}),n&&{productType:n})},e.prototype.createAmazonPayButtonParentContainer=function(){var e=Math.random().toString(16).substr(-4),t=document.createElement("div");return t.id="amazonpay_button_parent_container_"+e,t},e.prototype.getAmazonPayV2ButtonOptions=function(e,t,n,r,i){var a;void 0===r&&(r=!1),void 0===i&&(i=ns.Gold);var s=this.getCheckoutState(e),u=s.getCart,c=s.getCheckout,d=s.getStoreConfigOrThrow,l=(0,s.getPaymentMethodOrThrow)(t),p=l.config,h=p.merchantId,f=p.testMode,g=l.initializationData;if(!g)throw new Wa(Ya.MissingPaymentMethod);var m=g.checkoutLanguage,_=g.checkoutSessionMethod,y=g.createCheckoutSessionConfig,v=g.extractAmazonCheckoutSessionId,C=g.ledgerCurrency,S=g.publicKeyId,I=void 0===S?"":S,w=g.isButtonMicroTextDisabled;if(!h||!C||!y)throw new Wa(Ya.MissingPaymentMethod);var E=(0,o.__assign)({merchantId:h,ledgerCurrency:C,checkoutLanguage:m,placement:n,buttonColor:i},w?{design:rs.C0001}:{});if(this.isBuyNowFlow)return(0,o.__assign)((0,o.__assign)({},E),{sandbox:!!f});var b=u();E.productType=b&&0===Ka(b)?ts.PayOnly:ts.PayAndShip;var P=d(),A=P.checkoutSettings.features,O=P.storeProfile,T=O.shopPath,R=O.storeCountryCode;if(this.isPh4Enabled(A,R)){var k=null===(a=c())||void 0===a?void 0:a.outstandingBalance.toString(),D=null==b?void 0:b.currency.code,M=(0,o.__assign)({},E),N=void 0;return this.isEnvironmentSpecific(I)?(M.publicKeyId=I,N=y):(M.sandbox=!!f,N=(0,o.__assign)((0,o.__assign)({},y),{publicKeyId:I})),r||(M.createCheckoutSessionConfig=N),k&&D&&(M.estimatedOrderAmount={amount:k,currencyCode:D}),M}var L={method:_,url:A["INT-5826.amazon_relative_url"]?"/remote-checkout/"+t+"/payment-session":T+"/remote-checkout/"+t+"/payment-session",extractAmazonCheckoutSessionId:v};return(0,o.__assign)((0,o.__assign)({},E),{createCheckoutSession:L,sandbox:!!f})},e.prototype.isEnvironmentSpecific=function(e){return/^(SANDBOX|LIVE)/.test(e)},e.prototype.getAmazonPayV2SDK=function(){return this.getOrThrow(this.amazonPayV2SDK)},e.prototype.getButtonParentContainer=function(){return this.getOrThrow(this.buttonParentContainer)},e.prototype.getAmazonPayV2Button=function(){return this.getOrThrow(this.amazonPayV2Button)},e.prototype.getOrThrow=function(e){return Za(e,(function(){return new Ja(Qa.PaymentNotInitialized)}))},e.prototype.getCheckoutState=function(e){return"object"==typeof(t=e)&&null!==t&&"cart"in t&&"checkout"in t&&"config"in t&&"paymentMethods"in t?{getCart:e.cart.getCart,getCheckout:e.checkout.getCheckout,getStoreConfigOrThrow:e.config.getStoreConfigOrThrow,getPaymentMethodOrThrow:function(t){return e.paymentMethods.getPaymentMethodOrThrow(t)}}:e;var t},e}();const as=os;var ss=function(){function e(e,t){void 0===t&&(t=window),this.scriptLoader=e,this.windowWithAmazonPay=t}return e.prototype.load=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return t=e.initializationData,n=(null==t?void 0:t.region)||"us",r=is[n],[4,this.scriptLoader.loadScript("https://static-"+r+".payments-amazon.com/checkout.js")];case 1:if(i.sent(),!this.windowWithAmazonPay.amazon)throw new Ko;return[2,this.windowWithAmazonPay.amazon]}}))}))},e}();const us=ss;function cs(e,t){return Object.assign(e,{resolveIds:t})}const ds=function(e){function t(t){var n=e.call(this,t||"An unexpected error has occurred during buy now cart creation process. Please try again later.")||this;return n.name="BuyNowCartCreationError",n.type="buy_now_cart_creation_error",n}return(0,o.__extends)(t,e),t}(s),ls=function(e){function t(t){var n=e.call(this,t||"An unexpected error has occurred during config creation process. Please try again later.")||this;return n.name="AmazonPayV2ConfigCreationError",n.type="amazon_pay_v2_config_creation_error",n}return(0,o.__extends)(t,e),t}(s);function ps(e){return e instanceof Object&&"buyNowInitializeOptions"in e}var hs=function(){function e(e,t,n){this.paymentIntegrationService=e,this.amazonPayV2PaymentProcessor=t,this.amazonPayV2ConfigRequestSender=n}return e.prototype.initialize=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(n=e.methodId,r=e.containerId,i=e.amazonpay,a=(i||{}).buttonColor,!n||!r)throw new ja('Unable to proceed because "methodId" or "containerId" argument is not provided.');return s=this.paymentIntegrationService.getState().getPaymentMethodOrThrow,u=s(n),c=u.initializationData,[4,this.amazonPayV2PaymentProcessor.initialize(u)];case 1:return o.sent(),i?[3,3]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 2:o.sent(),o.label=3;case 3:return d=ps(i)?void 0:i,ps(i)&&"function"==typeof(null===(t=i.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody)&&(this._buyNowInitializeOptions=i.buyNowInitializeOptions,this.amazonPayV2PaymentProcessor.updateBuyNowFlowFlag(!0)),this.amazonPayV2PaymentProcessor.renderAmazonPayButton({checkoutState:this.paymentIntegrationService.getState(),containerId:r,methodId:n,options:d,placement:$a.Cart,buttonColor:a,isButtonMicroTextDisabled:null==c?void 0:c.isButtonMicroTextDisabled}),this._buyNowInitializeOptions&&this.amazonPayV2PaymentProcessor.prepareCheckoutWithCreationRequestConfig(this._getCheckoutCreationRequestConfig.bind(this)),[2]}}))}))},e.prototype.deinitialize=function(){return this.amazonPayV2PaymentProcessor.deinitialize()},e.prototype._createBuyNowCartOrThrow=function(){var e,t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:if(!(n=null===(t=null===(e=this._buyNowInitializeOptions)||void 0===e?void 0:e.getBuyNowCartRequestBody)||void 0===t?void 0:t.call(e)))throw new Wa(Ya.MissingCart);r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.paymentIntegrationService.createBuyNowCart(n)];case 2:return[2,r.sent()];case 3:throw r.sent(),new ds;case 4:return[2]}}))}))},e.prototype._createCheckoutConfig=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.amazonPayV2ConfigRequestSender.createCheckoutConfig(e)];case 1:return t=a.sent().body,n=t.payload,r=t.public_key,i=(0,o.__rest)(t,["payload","public_key"]),[2,(0,o.__assign)({payloadJSON:n,publicKeyId:r},i)];case 2:throw a.sent(),new ls;case 3:return[2]}}))}))},e.prototype._getCheckoutCreationRequestConfig=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._createBuyNowCartOrThrow()];case 1:return e=n.sent(),t={amount:String(e.baseAmount),currencyCode:e.currency.code},[4,this._createCheckoutConfig(e.id)];case 2:return[2,{createCheckoutSessionConfig:n.sent(),estimatedOrderAmount:t,productType:0===Ka(e)?ts.PayOnly:ts.PayAndShip}]}}))}))},e}();const fs=hs;var gs,ms="This API endpoint is for internal use only and may change in the future";!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(gs||(gs={}));const _s=gs;var ys={"X-Checkout-SDK-Version":"1.661.4"};const vs=function(){function e(e){this._requestSender=e}return e.prototype.createCheckoutConfig=function(e){var t={cartId:e},n=(0,o.__assign)({"X-API-INTERNAL":ms,"Content-Type":_s.Json},ys);return this._requestSender.post("/api/storefront/payment/amazonpay",{headers:n,body:t})},e}(),Cs=cs((function(e){var t=(0,r.createRequestSender)(),n=new vs(t),i=new as(new us((0,ir.getScriptLoader)()));return new fs(e,i,n)}),[{id:"amazonpay"}]);const Ss=function(e){function t(t){var n=e.call(this,t||"Unsupported browser error")||this;return n.name="UnsupportedBrowserError",n.type="unsupported_browser",n}return(0,o.__extends)(t,e),t}(s);var Is,ws,Es,bs,Ps;!function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(Is||(Is={})),function(e){e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="cancelled",e.UNRECOGNIZED="unrecognized"}(ws||(ws={})),function(e){e.Customer="CUSTOMER",e.Merchant="MERCHANT",e.Network="NETWORK",e.Internal="INTERNAL",e.Unknown="UNKNOWN"}(Es||(Es={})),function(e){e.KountNotEnabled="DATA_COLLECTOR_KOUNT_NOT_ENABLED"}(bs||(bs={})),function(e){e.TRUSTLY="trustly"}(Ps||(Ps={}));var As=function(){function e(e){this.braintreeScriptLoader=e}return e.prototype.initialize=function(e){this.setClientToken(e)},e.prototype.deinitialize=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this.teardownModule(this.dataCollector)];case 1:return e.sent(),this.dataCollector=void 0,[2]}}))}))},e.prototype.getClient=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return this.client?[3,3]:(e=this.getClientTokenOrThrow(),[4,this.braintreeScriptLoader.loadClient()]);case 1:return t=r.sent(),n=this,[4,t.create({authorization:e})];case 2:n.client=r.sent(),r.label=3;case 3:return[2,this.client]}}))}))},e.prototype.getDataCollectorOrThrow=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s;return(0,o.__generator)(this,(function(u){switch(u.label){case 0:if(t={deviceData:void 0,teardown:function(){return Promise.resolve()}},this.dataCollector)return[3,6];u.label=1;case 1:return u.trys.push([1,5,,6]),[4,this.getClient()];case 2:return n=u.sent(),[4,this.braintreeScriptLoader.loadDataCollector()];case 3:return r=u.sent(),i=(0,o.__assign)({client:n,kount:!0},e),a=this,[4,r.create(i)];case 4:return a.dataCollector=u.sent(),[3,6];case 5:if(c=s=u.sent(),Boolean("object"==typeof c&&null!==c&&("type"in c||"message"in c||"code"in c))&&s.code===bs.KountNotEnabled)return[2,t];throw s;case 6:return[2,this.dataCollector]}var c}))}))},e.prototype.getBraintreeGooglePayment=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return this.googlePayment?[3,3]:[4,Promise.all([this.getClient(),this.braintreeScriptLoader.loadGooglePayment()])];case 1:return e=i.sent(),t=e[0],n=e[1],r=this,[4,n.create({client:t})];case 2:r.googlePayment=i.sent(),i.label=3;case 3:return[2,this.googlePayment]}}))}))},e.prototype.getBraintreeThreeDS=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return this.threeDS?[3,3]:[4,Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()])];case 1:return e=i.sent(),t=e[0],n=e[1],r=this,[4,n.create({client:t,version:2})];case 2:r.threeDS=i.sent(),i.label=3;case 3:return[2,this.threeDS]}}))}))},e.prototype.getUsBankAccount=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return this.usBankAccount?[3,4]:[4,this.getClient()];case 1:return e=r.sent(),[4,this.braintreeScriptLoader.loadUsBankAccount()];case 2:return t=r.sent(),n=this,[4,t.create({client:e})];case 3:n.usBankAccount=r.sent(),r.label=4;case 4:return[2,this.usBankAccount]}}))}))},e.prototype.getBraintreeVisaCheckout=function(){return this.visaCheckout||(this.visaCheckout=Promise.all([this.getClient(),this.braintreeScriptLoader.loadVisaCheckout()]).then((function(e){var t=e[0];return e[1].create({client:t})}))),this.visaCheckout},e.prototype.getVisaCheckoutSdk=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return this.visaCheckoutSDK?[3,2]:(t=this,[4,this.braintreeScriptLoader.loadVisaCheckoutSdk(e)]);case 1:t.visaCheckoutSDK=n.sent(),n.label=2;case 2:return[2,this.visaCheckoutSDK]}}))}))},e.prototype.getVenmoCheckoutOrThrow=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return this.braintreeVenmo?[3,4]:[4,this.getClient()];case 1:return e=i.sent(),[4,this.braintreeScriptLoader.loadVenmoCheckout()];case 2:return t=i.sent(),n={client:e,allowDesktop:!0,paymentMethodUsage:"multi_use"},[4,t.create(n)];case 3:if(!(r=i.sent()).isBrowserSupported())throw new Ss;this.braintreeVenmo=r,i.label=4;case 4:return[2,this.braintreeVenmo]}}))}))},e.prototype.setClientToken=function(e){this.clientToken=e},e.prototype.getClientTokenOrThrow=function(){if(!this.clientToken)throw new Ja(Qa.PaymentNotInitialized);return this.clientToken},e.prototype.teardownModule=function(e){return e?e.teardown():Promise.resolve()},e}();const Os=As,Ts=function(e){function t(t){var n=e.call(this,t||"Payment process was cancelled.")||this;return n.name="PaymentMethodCancelledError",n.type="payment_cancelled",n}return(0,o.__extends)(t,e),t}(s);var Rs;function ks(e){if(!function(e){return"ApplePaySession"in e}(e))throw new Error("Apple pay is not supported")}!function(e){e.BRAINTREE="braintree"}(Rs||(Rs={}));const Ds=function(){function e(){}return e.prototype.create=function(e){return ks(window),new ApplePaySession(1,e)},e}();var Ms;!function(e){e.Subtotal="Subtotal",e.Shipping="Shipping"}(Ms||(Ms={}));var Ns=function(){function e(e,t,n,r){this._requestSender=e,this._paymentIntegrationService=t,this._sessionFactory=n,this._braintreeSdk=r,this._onAuthorizeCallback=_.noop,this._subTotalLabel=Ms.Subtotal,this._shippingLabel=Ms.Shipping}return e.prototype.initialize=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(n=e.methodId,r=e.containerId,i=e.applepay,ks(window),!n||!i)throw new Wa(Ya.MissingPaymentMethod);return a=i.buttonClassName,s=i.onPaymentAuthorize,u=i.buyNowInitializeOptions,c=i.requiresShipping,this._requiresShipping=c,this._buyNowInitializeOptions=u,this._onAuthorizeCallback=s,u?[3,2]:[4,this._paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return[4,this._paymentIntegrationService.loadPaymentMethod(n)];case 3:return o.sent(),d=this._paymentIntegrationService.getState(),this._paymentMethod=d.getPaymentMethodOrThrow(n),d.getCart()?[4,this._paymentIntegrationService.verifyCheckoutSpamProtection()]:[3,5];case 4:o.sent(),o.label=5;case 5:return(null===(t=this._paymentMethod.initializationData)||void 0===t?void 0:t.gateway)!==Rs.BRAINTREE?[3,7]:[4,this._initializeBraintreeSdk()];case 6:o.sent(),o.label=7;case 7:return this._applePayButton=this._createButton(r,a),this._applePayButton.addEventListener("click",this._handleWalletButtonClick.bind(this)),[2,Promise.resolve()]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype._createButton=function(e,t){void 0===t&&(t="apple-pay-checkout-button");var n=document.getElementById(e);if(!n)throw new ja("Unable to create wallet button without valid container ID.");document.body.classList.add("apple-pay-supported");var r=document.createElement("div");return r.setAttribute("class",t),r.setAttribute("role","button"),r.setAttribute("aria-label","Apple Pay button"),n.appendChild(r),r},e.prototype._handleWalletButtonClick=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s,u,c,d,l,p,h,f;return(0,o.__generator)(this,(function(o){if(e.preventDefault(),!this._paymentMethod||!this._paymentMethod.initializationData)throw new Wa(Ya.MissingPaymentMethod);return this._buyNowInitializeOptions&&"function"==typeof this._buyNowInitializeOptions.getBuyNowCartRequestBody?(n=this._paymentMethod.initializationData,r=n.countryCode,i=n.currencyCode,a=n.merchantCapabilities,s=n.supportedNetworks,u=n.storeName,h=this._getRequestWithEmptyTotal(r,i,s,a),this._requiresShipping&&(null===(t=h.requiredShippingContactFields)||void 0===t||t.push("postalAddress")),f=this._sessionFactory.create(h),this._handleApplePayEvents(f,this._paymentMethod,u),f.begin()):(c=this._paymentIntegrationService.getState(),d=c.getCartOrThrow(),l=c.getStoreConfigOrThrow(),p=c.getCheckoutOrThrow(),h=this._getBaseRequest(d,p,l,this._paymentMethod),f=this._sessionFactory.create(h),this._handleApplePayEvents(f,this._paymentMethod,l.storeProfile.storeName),f.begin()),[2]}))}))},e.prototype._getRequestWithEmptyTotal=function(e,t,n,r){return{countryCode:e,currencyCode:t,supportedNetworks:n,merchantCapabilities:r,total:{label:"",amount:"0",type:"pending"},requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:["email","phone"]}},e.prototype._getBaseRequest=function(e,t,n,r){var i,o=n.storeProfile,a=o.storeCountryCode,s=o.storeName,u=e.currency,c=u.code,d=u.decimalPlaces,l=r.initializationData,p=l.merchantCapabilities,h=l.supportedNetworks,f=e.lineItems.physicalItems.length>0,g={requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:["email","phone"],countryCode:a,currencyCode:c,merchantCapabilities:p,supportedNetworks:h,lineItems:[],total:f?{label:s,amount:""+t.grandTotal.toFixed(d),type:"pending"}:{label:s,amount:""+t.grandTotal.toFixed(d),type:"final"}};if(f)null===(i=g.requiredShippingContactFields)||void 0===i||i.push("postalAddress");else{var m=[{label:this._subTotalLabel,amount:""+t.subtotal.toFixed(d)}];t.taxes.forEach((function(e){return m.push({label:e.name,amount:""+e.amount.toFixed(d)})})),g.lineItems=m}return g},e.prototype._handleApplePayEvents=function(e,t,n){var r=this;e.onvalidatemerchant=function(n){return(0,o.__awaiter)(r,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this._onValidateMerchant(t,n)];case 1:return r=i.sent().body,e.completeMerchantValidation(r),[3,3];case 2:throw i.sent(),new Error("Merchant validation failed");case 3:return[2]}}))}))},this._buyNowInitializeOptions&&!this._requiresShipping&&(e.onpaymentmethodselected=function(){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._createBuyNowCart()];case 1:return t.sent(),this._handlePaymentMethodSelected(e),[2]}}))}))}),e.onshippingcontactselected=function(t){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return this._buyNowInitializeOptions&&this._requiresShipping?[4,this._createBuyNowCart()]:[3,2];case 1:r.sent(),r.label=2;case 2:return[4,this._handleShippingContactSelected(e,n,t)];case 3:return r.sent(),[2]}}))}))},e.onshippingmethodselected=function(t){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._handleShippingMethodSelected(e,n,t)];case 1:return r.sent(),[2]}}))}))},e.oncancel=function(){return(0,o.__awaiter)(r,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),e="/remote-checkout/"+t.id+"/signout",[4,this._requestSender.get(e)];case 1:return n.sent(),[4,this._paymentIntegrationService.loadCheckout()];case 2:return[2,n.sent()];case 3:throw n.sent(),new Ts;case 4:return[2]}}))}))},e.onpaymentauthorized=function(n){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){return[2,this._onPaymentAuthorized(n,e,t)]}))}))}},e.prototype._createBuyNowCart=function(){var e,t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:if(i.trys.push([0,3,,4]),!(n=null===(t=null===(e=this._buyNowInitializeOptions)||void 0===e?void 0:e.getBuyNowCartRequestBody)||void 0===t?void 0:t.call(e)))throw new Wa(Ya.MissingCart);return[4,this._paymentIntegrationService.createBuyNowCart(n)];case 1:return r=i.sent(),[4,this._paymentIntegrationService.loadCheckout(r.id)];case 2:return i.sent(),[3,4];case 3:throw i.sent(),new ds;case 4:return[2]}}))}))},e.prototype._handlePaymentMethodSelected=function(e){var t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow(),r=t.getStoreConfigOrThrow(),i=t.getCheckoutOrThrow();if(!this._paymentMethod||!this._paymentMethod.initializationData)throw new Wa(Ya.MissingPaymentMethod);var o=this._getBaseRequest(n,i,r,this._paymentMethod);delete o.total.type,e.completePaymentMethodSelection({newTotal:o.total,newLineItems:o.lineItems})},e.prototype._handleShippingContactSelected=function(e,t,n){var r;return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d,l,p,h,f,g,m;return(0,o.__generator)(this,(function(_){switch(_.label){case 0:i=this._transformContactToAddress(n.shippingContact),_.label=1;case 1:return _.trys.push([1,3,,4]),[4,this._paymentIntegrationService.updateShippingAddress(i)];case 2:return _.sent(),[3,4];case 3:throw _.sent(),e.abort(),new Error("Shipping address update failed");case 4:if(a=this._paymentIntegrationService.getState(),s=a.getCartOrThrow().currency.decimalPlaces,u=a.getCheckoutOrThrow(),c=null===(r=u.consignments[0].selectedShippingOption)||void 0===r?void 0:r.id,d=u.consignments[0].availableShippingOptions,l=null==d?void 0:d.find((function(e){return e.id===c})),p=null==d?void 0:d.filter((function(e){return e.id!==c})),h=l?[{label:l.description,amount:""+l.cost.toFixed(s),detail:l.additionalDescription,identifier:l.id}]:[],p&&(0,o.__spreadArrays)(p.filter((function(e){return e.isRecommended})),p.filter((function(e){return!e.isRecommended}))).forEach((function(e){return h.push({label:e.description,amount:""+e.cost.toFixed(s),detail:e.additionalDescription,identifier:e.id})})),!(d instanceof Array))throw new Error("Shipping options not available.");if(0===d.length)return e.completeShippingContactSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,[],{type:"pending",label:t,amount:""+u.grandTotal.toFixed(s)},[]),[2];f=d.find((function(e){return e.isRecommended})),g=f?f.id:d[0].id,m=l?l.id:g,_.label=5;case 5:return _.trys.push([5,7,,8]),[4,this._updateShippingOption(m)];case 6:return _.sent(),[3,8];case 7:throw _.sent(),new Error("Shipping options update failed");case 8:return a=this._paymentIntegrationService.getState(),u=a.getCheckoutOrThrow(),e.completeShippingContactSelection({newShippingMethods:h,newTotal:{type:"final",label:t,amount:""+u.grandTotal.toFixed(s)},newLineItems:this._getUpdatedLineItems(u,s)}),[2]}}))}))},e.prototype._handleShippingMethodSelected=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:r=n.shippingMethod.identifier,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this._updateShippingOption(r)];case 2:return o.sent(),[3,4];case 3:throw o.sent(),e.abort(),new Error("Shipping option selection update failed.");case 4:return i=this._paymentIntegrationService.getState(),a=i.getCartOrThrow().currency.decimalPlaces,s=i.getCheckoutOrThrow(),e.completeShippingMethodSelection({newTotal:{type:"final",label:t,amount:""+s.grandTotal.toFixed(a)},newLineItems:this._getUpdatedLineItems(s,a)}),[2]}}))}))},e.prototype._getUpdatedLineItems=function(e,t){var n=[{label:this._subTotalLabel,amount:""+e.subtotal.toFixed(t)}];return e.taxes.forEach((function(e){return n.push({label:e.name,amount:""+e.amount.toFixed(t)})})),n.push({label:this._shippingLabel,amount:""+e.shippingCostTotal.toFixed(t)}),n},e.prototype._updateShippingOption=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){return[2,this._paymentIntegrationService.selectShippingOption(e)]}))}))},e.prototype._onValidateMerchant=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){return n=["validationUrl="+t.validationURL,"merchantIdentifier="+e.initializationData.merchantId,"displayName="+e.initializationData.storeName,"domainName="+window.location.hostname].join("&"),[2,this._requestSender.post((i=e.initializationData.paymentsUrl,i+"/api/public/v1/payments/applepay/validate_merchant"),{credentials:!1,headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","X-XSRF-TOKEN":null},body:n})];var i}))}))},e.prototype._onPaymentAuthorized=function(e,t,n){var r;return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d,l,p,h,f,g,m,_;return(0,o.__generator)(this,(function(y){switch(y.label){case 0:return i=e.payment,a=i.token,s=i.billingContact,u=i.shippingContact,c=this._paymentIntegrationService.getState(),d=c.getCartOrThrow(),l=d.lineItems.physicalItems.length>0,(null===(r=n.initializationData)||void 0===r?void 0:r.gateway)!==Rs.BRAINTREE?[3,2]:[4,this._getBraintreeDeviceData()];case 1:p=y.sent(),y.label=2;case 2:h={methodId:n.id,paymentData:{deviceSessionId:p,formattedPayload:{apple_pay_token:{payment_data:a.paymentData,payment_method:a.paymentMethod,transaction_id:a.transactionIdentifier}}}},f=this._transformContactToAddress(s),g=this._transformContactToAddress(u),m=null==u?void 0:u.emailAddress,_=(null==u?void 0:u.phoneNumber)||"",y.label=3;case 3:return y.trys.push([3,9,,10]),[4,this._paymentIntegrationService.updateBillingAddress((0,o.__assign)((0,o.__assign)({},f),{email:m,phone:_}))];case 4:return y.sent(),l?[4,this._paymentIntegrationService.updateShippingAddress(g)]:[3,6];case 5:y.sent(),y.label=6;case 6:return[4,this._paymentIntegrationService.submitOrder({useStoreCredit:!1})];case 7:return y.sent(),[4,this._paymentIntegrationService.submitPayment(h)];case 8:return y.sent(),t.completePayment(ApplePaySession.STATUS_SUCCESS),[2,this._onAuthorizeCallback()];case 9:throw y.sent(),t.completePayment(ApplePaySession.STATUS_FAILURE),new Error("Payment cannot complete");case 10:return[2]}}))}))},e.prototype._transformContactToAddress=function(e){return{firstName:(null==e?void 0:e.givenName)||"",lastName:(null==e?void 0:e.familyName)||"",city:(null==e?void 0:e.locality)||"",company:"",address1:(null==e?void 0:e.addressLines)&&e.addressLines[0]||"",address2:(null==e?void 0:e.addressLines)&&e.addressLines[1]||"",postalCode:(null==e?void 0:e.postalCode)||"",countryCode:(null==e?void 0:e.countryCode)||"",phone:(null==e?void 0:e.phoneNumber)||"",stateOrProvince:(null==e?void 0:e.administrativeArea)||"",stateOrProvinceCode:(null==e?void 0:e.administrativeArea)||"",customFields:[]}},e.prototype._getBraintreeDeviceData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this._braintreeSdk.getDataCollectorOrThrow()];case 1:return[2,e.sent().deviceData];case 2:return e.sent(),[3,3];case 3:return[2]}}))}))},e.prototype._initializeBraintreeSdk=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._paymentIntegrationService.loadPaymentMethod(Rs.BRAINTREE)];case 1:return n.sent(),e=this._paymentIntegrationService.getState(),(t=e.getPaymentMethod(Rs.BRAINTREE))&&t.clientToken&&t.initializationData?(this._braintreeSdk.initialize(t.clientToken),[2]):[2]}}))}))},e}();const Ls=Ns,zs=cs((function(e){var t=e.getState().getHost;return new Ls((0,r.createRequestSender)({host:t()}),e,new Ds,new Os(new ta((0,ir.getScriptLoader)(),window)))}),[{id:"applepay"}]),Us=require("query-string"),Fs=function(e){function t(t){var n=e.call(this,t||"Not implemented.")||this;return n.name="NotImplementedError",n.type="not_implemented",n}return(0,o.__extends)(t,e),t}(s);var Bs,qs,xs;!function(e){e.SandboxMode="bolt_sandbox",e.StagingMode="bolt_staging",e.DevelopmentMode="bolt_development"}(Bs||(Bs={})),function(e){e.Small="small",e.Medium="medium",e.Large="large"}(qs||(qs={})),function(e){e.Pill="pill",e.Rect="rect"}(xs||(xs={}));var Gs=function(){function e(e,t,n){void 0===n&&(n=window),this.paymentIntegrationService=e,this.boltScriptLoader=t,this.boltHostWindow=n}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h,f;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.bolt,n=e.containerId,r=e.methodId,a=(i=t||{}).buyNowInitializeOptions,s=i.style,!r)throw new ja('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new ja('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new ja('Unable to initialize payment because "options.bolt" argument is not provided.');if(!Boolean(a))throw new Fs("Only buy now flow is implemented for Bolt button");if(!(null==a?void 0:a.storefrontApiToken)||"string"!=typeof a.storefrontApiToken)throw new ja('Unable to initialize payment because "options.storefrontApiToken" argument is not provided.');return u=this.paymentIntegrationService.getState(),c=u.getPaymentMethodOrThrow(r),d=c.initializationData,l=c.config,h=(p=d||{}).publishableKey,f=p.developerConfig,[4,this.boltScriptLoader.loadBoltClient(h,l.testMode,f,"BigCommerce",a.storefrontApiToken)];case 1:return o.sent(),this.renderButton(n,c,s),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r;"function"==typeof(null===(r=this.boltHostWindow.BoltConnect)||void 0===r?void 0:r.setupProductPageCheckout)&&(this.addButtonContainer(e,t,n),this.boltHostWindow.BoltConnect.setupProductPageCheckout())},e.prototype.addButtonContainer=function(e,t,n){var r=document.getElementById(e);if(r){var i=document.createElement("div"),o=document.createElement("object");i.setAttribute("id","product-page-checkout-wrapper"),i.setAttribute("class","bolt-button-wrapper"),i.setAttribute("style","display:none"),i.setAttribute("data-tid","product-page-checkout-wrapper"),o.setAttribute("data",this.getBoltObjectData(t,n)),o.setAttribute("class","bolt-product-checkout-button"),i.append(o),r.innerHTML="",r.append(i)}},e.prototype.getBoltObjectData=function(e,t){var n=e.initializationData,r=e.config,i=n||{},o=i.publishableKey,a=i.developerConfig,s=this.boltScriptLoader.getDomainURL(!!r.testMode,a),u=this.getButtonHeight(null==t?void 0:t.size),c=this.getButtonBorderRadius(null==t?void 0:t.shape,u);return(0,Us.stringifyUrl)({url:"https://"+s+"/v1/checkout_button",query:{publishable_key:o,variant:"ppc",height:u,border_radius:c}})},e.prototype.getButtonHeight=function(e){if(e)switch(e){case qs.Small:return 25;case qs.Large:return 45;case qs.Medium:default:return 40}},e.prototype.getButtonBorderRadius=function(e,t){if(e)switch(e){case xs.Pill:return t?Math.round(t/2):void 0;case xs.Rect:default:return 4}},e}();const Vs=Gs;var Hs=function(){function e(e,t){void 0===t&&(t=window),this.scriptLoader=e,this.boltHostWindow=t}return e.prototype.loadBoltClient=function(e,t,n,r,i){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(this.boltHostWindow.BoltCheckout)return[2,this.boltHostWindow.BoltCheckout];if(!e)throw new ja('Unable to initialize payment because "publishableKey" argument is not provided.');return[4,this.scriptLoader.loadScript("//"+this.getDomainURL(!!t,n)+"/connect-bigcommerce.js",this.getScriptOptions("bolt-connect",e,r,i))];case 1:return o.sent(),[4,this.scriptLoader.loadScript("//"+this.getDomainURL(!!t,n)+"/track.js",this.getScriptOptions("bolt-track",e))];case 2:if(o.sent(),!this.boltHostWindow.BoltCheckout)throw new Ko;return[2,this.boltHostWindow.BoltCheckout]}}))}))},e.prototype.loadBoltEmbedded=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return r={async:!0,attributes:{id:"bolt-embedded"}},[4,this.scriptLoader.loadScript("//"+this.getDomainURL(!!t,n)+"/embed.js",r)];case 1:if(i.sent(),!this.boltHostWindow.Bolt)throw new Ko;return[2,this.boltHostWindow.Bolt(e)]}}))}))},e.prototype.getDomainURL=function(e,t){if(!e)return"connect.bolt.com";if(t)switch(t.developerMode){case Bs.StagingMode:return"connect-staging.bolt.com";case Bs.DevelopmentMode:return"connect."+t.developerDomain}return"connect-sandbox.bolt.com"},e.prototype.getScriptOptions=function(e,t,n,r){return{async:!0,attributes:(0,o.__assign)((0,o.__assign)({id:e,"data-publishable-key":t},n&&{"data-shopping-cart-id":n}),r&&{"data-storefront-api-token":r})}},e}();const js=Hs,Ys=cs((function(e){return new Vs(e,new js((0,ir.getScriptLoader)()))}),[{id:"bolt"}]);var Ws=function(){function e(e,t,n){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeSdk=n}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h,f,g=this;return(0,o.__generator)(this,(function(m){switch(m.label){case 0:if(t=e.containerId,!(n=e.methodId))throw new ja('Unable to initialize payment because "options.methodId" argument is not provided.');if(!t)throw new ja('Unable to initialize payment because "options.containerId" argument is not provided.');return[4,this.paymentIntegrationService.loadPaymentMethod(n)];case 1:if(m.sent(),r=this.paymentIntegrationService.getState(),i=r.getPaymentMethodOrThrow(n),a=i.clientToken,s=i.initializationData,u=i.config,!a||!s)throw new Wa(Ya.MissingPaymentMethod);return this.braintreeSdk.initialize(a),[4,this.braintreeSdk.getBraintreeVisaCheckout()];case 2:return c=m.sent(),d=r.getCartOrThrow(),l=d.currency.code,p=d.cartAmount,[4,this.braintreeSdk.getVisaCheckoutSdk(u.testMode)];case 3:return h=m.sent(),f=c.createInitOptions({paymentRequest:{currencyCode:l,subtotal:String(p)},settings:{shipping:{collectShipping:!0}}}),this.createSignInButton(t),[4,h.init(f)];case 4:return m.sent(),h.on("payment.success",(function(e){return(0,o.__awaiter)(g,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this.paymentSuccess(c,e)];case 1:return t.sent(),[2]}}))}))})),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.paymentSuccess=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n=this;return(0,o.__generator)(this,(function(r){return[2,Promise.all([e.tokenize(t),this.braintreeSdk.getDataCollectorOrThrow()]).then((function(e){var t=e[0],r=e[1],i=n.paymentIntegrationService.getState(),a=i.getShippingAddress(),s=i.getBillingAddress(),u=t.shippingAddress,c=void 0===u?n.toVisaCheckoutAddress(a):u,d=t.billingAddress,l=void 0===d?n.toVisaCheckoutAddress(s):d;return n.postForm((0,o.__assign)((0,o.__assign)({},t),{shippingAddress:c,billingAddress:l}),r)}))]}))}))},e.prototype.postForm=function(e,t){var n=e.userData,r=e.billingAddress,i=e.shippingAddress,o=e.details,a=n.userEmail,s=t.deviceData;return this.formPoster.postForm("/checkout.php",{payment_type:e.type,nonce:e.nonce,provider:"braintreevisacheckout",action:"set_external_checkout",device_data:s,card_information:JSON.stringify({type:o.cardType,number:o.lastTwo}),billing_address:JSON.stringify(this.getAddress(a,r)),shipping_address:JSON.stringify(this.getAddress(a,i))})},e.prototype.toVisaCheckoutAddress=function(e){return e?{firstName:e.firstName,lastName:e.lastName,phoneNumber:e.phone,streetAddress:e.address1,extendedAddress:e.address2,locality:e.city,region:e.stateOrProvinceCode,countryCode:e.countryCode,postalCode:e.postalCode}:{}},e.prototype.getAddress=function(e,t){return void 0===t&&(t={}),{email:e,first_name:t.firstName,last_name:t.lastName,phone_number:t.phoneNumber,address_line_1:t.streetAddress,address_line_2:t.extendedAddress,city:t.locality,state:t.region,country_code:t.countryCode,postal_code:t.postalCode}},e.prototype.createSignInButton=function(e){var t=document.querySelector("#"+e);if(!t)throw new Error("Need a container to place the button");return this.insertVisaCheckoutButton(t)},e.prototype.insertVisaCheckoutButton=function(e){var t=document.createElement("div");return t.style.display="flex",t.style.flexDirection="column",t.style.alignItems="flex-end",t.innerHTML='\n <img\n alt="Visa Checkout"\n class="v-button"\n role="button"\n src="https://secure.checkout.visa.com/wallet-services-web/xo/button.png?acceptCanadianVisaDebit=false&cobrand=true&height=34&width=178"\n />\n <a class="v-learn v-learn-default" style="text-align: right; display: block; font-size: 10px; color: #003366;" href="#" data-locale="en_US">Tell Me More</a>',e.appendChild(t),t},e}();const Ks=Ws,Zs=cs((function(e){var t=window,n=new Os(new ta((0,ir.getScriptLoader)(),t));return new Ks(e,(0,i.createFormPoster)(),n)}),[{id:"braintreevisacheckout"}]);function Qs(e){var t=e.billingAddress,n=e.email,r=e.firstName,i=e.lastName,o=e.phone,a=e.shippingAddress,s=t||a;return{email:n,first_name:r,last_name:i,phone_number:o,address_line_1:null==s?void 0:s.line1,address_line_2:null==s?void 0:s.line2,city:null==s?void 0:s.city,state:null==s?void 0:s.state,country_code:null==s?void 0:s.countryCode,postal_code:null==s?void 0:s.postalCode}}function Js(e){var t=e.email,n=e.phone,r=e.shippingAddress,i=((null==r?void 0:r.recipientName)||"").split(" ");return{email:t,first_name:i[0]||"",last_name:i[1]||"",phone_number:n,address_line_1:null==r?void 0:r.line1,address_line_2:null==r?void 0:r.line2,city:null==r?void 0:r.city,state:null==r?void 0:r.state,country_code:null==r?void 0:r.countryCode,postal_code:null==r?void 0:r.postalCode}}var Xs=function(e){var t,n=e.color,r=e.height;return{backgroundColor:(t=n||"",t===aa.WHITE?"#FFFFFF":"#3D95CE"),backgroundPosition:"50% 50%",backgroundSize:"80px auto",backgroundImage:'url("/app/assets/img/payment-providers/venmo-logo-'+(n===aa.WHITE?aa.BLUE:aa.WHITE)+'.svg")',backgroundRepeat:"no-repeat",borderRadius:"4px",cursor:"pointer",transition:"0.2s ease",minHeight:(r||36)+"px",minWidth:"150px",height:"100%",width:"100%",border:n===aa.WHITE?"1px solid black":"none"}},$s=function(){function e(e,t,n){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeSdk=n,this.onError=_.noop}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.braintreevenmo,n=e.containerId,!(r=e.methodId))throw new ja('Unable to initialize payment because "options.methodId" argument is not provided.');if(i=this.paymentIntegrationService.getState(),a=i.getPaymentMethodOrThrow(r),s=a.clientToken,u=a.initializationData,c=u.paymentButtonStyles,d=(c||{}).cartButtonStyles,l=(null==t?void 0:t.style)||d,!s||!u)throw new Wa(Ya.MissingPaymentMethod);if(!n)throw new ja('Unable to initialize payment because "options.containerId" argument is not provided.');this.onError=(null==t?void 0:t.onError)||this.handleError,this.braintreeSdk.initialize(s),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.braintreeSdk.getVenmoCheckoutOrThrow()];case 2:return p=o.sent(),this.renderVenmoButton(p,n,null==t?void 0:t.buyNowInitializeOptions,l),[3,4];case 3:return h=o.sent(),this.handleInitializationVenmoError(h,n),[3,4];case 4:return[2]}}))}))},e.prototype.deinitialize=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this.braintreeSdk.deinitialize()];case 1:return e.sent(),[2,Promise.resolve()]}}))}))},e.prototype.handleError=function(e){throw new Error(e.message)},e.prototype.createBuyNowCart=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("function"!=typeof(null==e?void 0:e.getBuyNowCartRequestBody))return[3,4];if(!(t=null==e?void 0:e.getBuyNowCartRequestBody()))throw new Wa(Ya.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.paymentIntegrationService.createBuyNowCart(t)];case 2:return[2,n.sent()];case 3:throw n.sent(),new ds;case 4:return[2,void 0]}}))}))},e.prototype.handleInitializationVenmoError=function(e,t){return this.removeVenmoContainer(t),this.onError(e)},e.prototype.removeVenmoContainer=function(e){var t=document.getElementById(e);t&&t.remove()},e.prototype.renderVenmoButton=function(e,t,n,r){var i=this,a=document.getElementById(t),s=(r||{}).color;if(!a)throw new ja("Unable to create wallet button without valid container ID.");a.setAttribute("aria-label","Venmo"),Object.assign(a.style,Xs(r||{})),a.addEventListener("click",(function(){return(0,o.__awaiter)(i,void 0,void 0,(function(){var t,r=this;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return a.setAttribute("disabled","true"),[4,this.createBuyNowCart(n)];case 1:return t=i.sent(),e.tokenize&&e.tokenize((function(e,n){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return a.removeAttribute("disabled"),e&&this.onError(e),[4,this.handlePostForm(n,null==t?void 0:t.id)];case 1:return r.sent(),[2]}}))}))})),[2]}}))}))})),s===aa.BLUE&&(a.addEventListener("mouseenter",(function(){a.style.backgroundColor="#0a7fc2"})),a.addEventListener("mouseleave",(function(){a.style.backgroundColor=Xs(r||{}).backgroundColor})))},e.prototype.handlePostForm=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return[4,this.braintreeSdk.getDataCollectorOrThrow()];case 1:return n=a.sent().deviceData,r=e.nonce,i=e.details,this.formPoster.postForm("/checkout.php",(0,o.__assign)({nonce:r,provider:"braintreevenmo",payment_type:"paypal",device_data:n,action:"set_external_checkout",billing_address:JSON.stringify(Qs(i)),shipping_address:JSON.stringify(Js(i))},t&&{cart_id:t})),[2]}}))}))},e}();const eu=$s,tu=cs((function(e){var t=window,n=(0,ir.getScriptLoader)(),r=new ta(n,t),o=new Os(r);return new eu(e,(0,i.createFormPoster)(),o)}),[{id:"braintreevenmo"}]);var nu=function(){function e(e){if(!e)throw new Error("Currency settings missing");var t=e.decimalPlaces,n=e.symbolLocation,r=e.symbol,i=e.thousandsSeparator,o=e.decimalSeparator;if("string"!=typeof n||"string"!=typeof r||"string"!=typeof i||"string"!=typeof o||"string"!=typeof t)throw new ja("Invalid currency settings provided");this._decimalPlaces=parseInt(t,10),this._symbolLocation=n,this._symbol=r,this._thousandsSeparator=i,this._decimalSeparator=o}return e.prototype.format=function(e){if("number"!=typeof e)throw new ja("Invalid amount provided");var t=this._formatNumber(e),n=this._formatCurrency(t);return e<0?"-"+n:n},e.prototype._formatNumber=function(e){var t=Math.abs(e),n=this._toFixed(t,this._decimalPlaces).split("."),r=n[0],i=n[1],o=void 0===i?"":i,a=r.replace(/\B(?=(\d{3})+(?!\d))/g,this._thousandsSeparator);return this._decimalPlaces<1?a:[a,o].join(this._decimalSeparator)},e.prototype._formatCurrency=function(e){return"left"===this._symbolLocation.toLowerCase()?""+this._symbol+e:""+e+this._symbol},e.prototype._toFixed=function(e,t){return(+(Math.round(+(e+"e"+t))+"e"+-t)).toFixed(t)},e}();const ru=nu,iu=function(){function e(e){this._storeConfig=e,this._customerFormatter=new ru(this._storeConfig.shopperCurrency),this._storeFormatter=new ru(this._storeConfig.currency)}return e.prototype.toCustomerCurrency=function(e){var t=this._storeConfig.shopperCurrency.exchangeRate;return this._customerFormatter.format(e*t)},e.prototype.toStoreCurrency=function(e){return this._storeFormatter.format(e)},(0,o.__decorate)([Yr],e)}();var ou,au,su,uu,cu,du,lu,pu;function hu(e){return e in du}!function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(ou||(ou={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(au||(au={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(su||(su={})),function(e){e.pill="pill",e.rect="rect"}(uu||(uu={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(cu||(cu={})),function(e){e.AMEX="AMEX",e.DISCOVER="DISCOVER",e.INTERAC="INTERAC",e.JCB="JCB",e.MC="MASTERCARD",e.VISA="VISA"}(du||(du={})),function(e){e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION"}(lu||(lu={})),function(e){e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER"}(pu||(pu={}));var fu=function(){function e(e,t){this._gatewayIdentifier=e,this._paymentIntegrationService=t,this._isBuyNowFlow=!1}return e.prototype.mapToShippingAddressRequestBody=function(e){var t=e.shippingAddress;if(t){var n=this._paymentIntegrationService.getState().getShippingAddress()||{},r=n.company,i=void 0===r?"":r,o=n.phone,a=void 0===o?"":o;return this._mapToAddressRequestBody(t,i,a)}},e.prototype.mapToBillingAddressRequestBody=function(e){var t=e.paymentMethodData.info.billingAddress;if(t){var n=this._paymentIntegrationService.getState().getBillingAddress()||{},r=n.company,i=void 0===r?"":r,a=n.phone,s=void 0===a?"":a,u=n.email;return(0,o.__assign)((0,o.__assign)({},this._mapToAddressRequestBody(t,i,s)),{email:u||e.email})}},e.prototype.mapToExternalCheckoutData=function(e){var t,n=e.paymentMethodData,r=n.tokenizationData.token,i=n.info,a=i.cardNetwork,s=i.cardDetails;return Promise.resolve((0,o.__assign)({nonce:r,card_information:{type:a,number:s}},this._isBuyNowFlow&&{cart_id:null===(t=this._paymentIntegrationService.getState().getCart())||void 0===t?void 0:t.id}))},e.prototype.getRequiredData=function(){var e;return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return t={emailRequired:!0},this._isShippingAddressRequired()?[4,this._paymentIntegrationService.loadShippingCountries()]:[2,t];case 1:return n=i.sent(),r=null===(e=n.getShippingCountries())||void 0===e?void 0:e.map((function(e){return e.code})),[2,(0,o.__assign)((0,o.__assign)({},t),{shippingAddressRequired:!0,shippingAddressParameters:(0,o.__assign)({phoneNumberRequired:!0},r&&{allowedCountryCodes:r}),shippingOptionRequired:this._isGooglePayShippingOptionsAvailable()})]}}))}))},e.prototype.getCallbackIntents=function(){return this._isGooglePayShippingOptionsAvailable()&&this._isShippingAddressRequired()?[lu.OFFER,lu.SHIPPING_ADDRESS,lu.SHIPPING_OPTION]:[lu.OFFER]},e.prototype.getCallbackTriggers=function(){var e=this._isGooglePayShippingOptionsAvailable();return{availableTriggers:e?[pu.INITIALIZE,pu.SHIPPING_ADDRESS,pu.SHIPPING_OPTION]:[pu.INITIALIZE],initializationTrigger:[pu.INITIALIZE],addressChangeTriggers:e?[pu.INITIALIZE,pu.SHIPPING_ADDRESS]:[],shippingOptionsChangeTriggers:e?[pu.SHIPPING_OPTION]:[]}},e.prototype.getNonce=function(e){var t,n=null===(t=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(e).initializationData)||void 0===t?void 0:t.nonce;if(!n)throw new Wa(Ya.MissingPaymentToken);return Promise.resolve(n)},e.prototype.extraPaymentData=function(){return Promise.resolve(void 0)},e.prototype.getMerchantInfo=function(){var e=this.getGooglePayInitializationData();return{merchantName:e.googleMerchantName,merchantId:e.googleMerchantId,authJwt:e.platformToken}},e.prototype.getTransactionInfo=function(){var e;e=this._isBuyNowFlow?this._getCurrencyCodeOrThrow():(0,this._paymentIntegrationService.getState().getCartOrThrow)().currency.code;var t=this.getGooglePayInitializationData().storeCountry;return(0,o.__assign)((0,o.__assign)({},t&&{countryCode:t}),{currencyCode:e,totalPriceStatus:cu.ESTIMATED,totalPrice:"0"})},e.prototype.getPaymentGatewayParameters=function(){var e=this.getGooglePayInitializationData().gatewayMerchantId;if(!e)throw new ja("Unable to proceed, gatewayMerchantId is missing.");return{gateway:this._gatewayIdentifier,gatewayMerchantId:e}},e.prototype.getCardParameters=function(){return{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:this.getPaymentMethod().supportedCards.filter(hu).map((function(e){return du[e]})),billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}},e.prototype.initialize=function(e,t,n){return this._getPaymentMethodFn=e,this._isBuyNowFlow=Boolean(t),this._currencyCode=n,this._isBuyNowFlow&&this._getCurrencyCodeOrThrow(),Promise.resolve()},e.prototype.handleShippingAddressChange=function(e){var t,n,r;return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d,l;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return e&&(e.name=e.name||"",e.address1=e.address1||""),(i=this.mapToShippingAddressRequestBody({shippingAddress:e}))?[4,this._paymentIntegrationService.updateShippingAddress(i)]:[3,2];case 1:o.sent(),o.label=2;case 2:return a=this._paymentIntegrationService.getState(),(null==(s=a.getConsignments())?void 0:s[0])?(u=s[0],c=a.getStoreConfigOrThrow(),this._currencyService||(this._currencyService=new iu(c)),(d=(u.availableShippingOptions||[]).map(this._getGooglePayShippingOption.bind(this))).length?(l=(null===(t=u.selectedShippingOption)||void 0===t?void 0:t.id)||(null===(n=d[0])||void 0===n?void 0:n.id),(null===(r=u.selectedShippingOption)||void 0===r?void 0:r.id)||!d[0]?[3,4]:[4,this.handleShippingOptionChange(d[0].id)]):[3,5]):[2];case 3:o.sent(),o.label=4;case 4:return[2,{defaultSelectedOptionId:l,shippingOptions:d}];case 5:return[2]}}))}))},e.prototype.handleShippingOptionChange=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){return"shipping_option_unselected"===e?[2]:[2,this._paymentIntegrationService.selectShippingOption(e)]}))}))},e.prototype.getTotalPrice=function(){var e=this._paymentIntegrationService.getState(),t=e.getCheckoutOrThrow,n=(0,e.getCartOrThrow)().currency.decimalPlaces;return(0,_.round)(t().outstandingBalance,n).toFixed(n)},e.prototype.getGooglePayInitializationData=function(){return Za(this.getPaymentMethod().initializationData,(function(){return new ja("Missing initialization data.")}))},e.prototype.getPaymentMethod=function(){return Za(this._getPaymentMethodFn,(function(){return new Ja(Qa.PaymentNotInitialized)}))()},e.prototype.getGatewayIdentifier=function(){return this._gatewayIdentifier},e.prototype.setGatewayIdentifier=function(e){this._gatewayIdentifier=e||this.getGatewayIdentifier()},e.prototype._isGooglePayShippingOptionsAvailable=function(){return!!this.getGooglePayInitializationData().isShippingOptionsEnabled},e.prototype._isShippingAddressRequired=function(){var e,t,n=this._paymentIntegrationService.getState(),r=n.getCartOrThrow,i=n.getStoreConfig;return void 0===(0,n.getShippingAddress)()&&(e=r(),t=i(),!!e&&(!!e.lineItems.physicalItems.some((function(e){return e.isShippingRequired}))||!(!t||!e.lineItems.customItems)&&e.lineItems.customItems.length>0))},e.prototype._mapToAddressRequestBody=function(e,t,n){var r=e.name,i=e.address1,o=e.address2,a=e.address3,s=e.locality,u=e.administrativeArea,c=e.countryCode,d=e.postalCode,l=e.phoneNumber,p=this._getFirstAndLastName(r);return{firstName:p[0],lastName:p[1],company:t,address1:i,address2:(o+" "+a).trim(),city:s,stateOrProvince:u,stateOrProvinceCode:u,countryCode:c,postalCode:d,phone:l||n,customFields:[]}},e.prototype._getFirstAndLastName=function(e){var t=e.split(" ");return 1===t.length?[e,""]:[t.slice(0,-1).join(" "),t[t.length-1]]},e.prototype._getCurrencyCodeOrThrow=function(){return Za(this._currencyCode,(function(){return new ja('Unable to initialize payment because "options.currencyCode" argument is not provided.')}))},e.prototype._getGooglePayShippingOption=function(e){var t,n=e.id,r=e.cost;return{id:n,label:e.description,description:(null===(t=this._currencyService)||void 0===t?void 0:t.toCustomerCurrency(r))||r}},e}();const gu=fu;var mu=function(e){function t(t,n){var r=e.call(this,"braintree",t)||this;return r._braintreeSdk=n,r._service=t,r}return(0,o.__extends)(t,e),t.prototype.initialize=function(t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,e.prototype.initialize.call(this,t,n,r)];case 1:if(o.sent(),!(i=e.prototype.getPaymentMethod.call(this)).clientToken||!i.initializationData)throw new Wa(Ya.MissingPaymentMethod);return this._braintreeSdk.initialize(i.clientToken),a=this,[4,this._braintreeSdk.getBraintreeGooglePayment()];case 2:return a._braintreeGooglePayment=o.sent(),[2,Promise.resolve()]}}))}))},t.prototype.getNonce=function(t){var n;return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s,u,c,d,l;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,e.prototype.getNonce.call(this,t)];case 1:if(r=o.sent(),i=e.prototype.getPaymentMethod.call(this),a=i.clientToken,s=i.initializationData,!a||!s||!(null===(n=s.card_information)||void 0===n?void 0:n.bin))throw new Wa(Ya.MissingPaymentMethod);return u=s.isThreeDSecureEnabled,c=s.card_information.bin,u?[4,this._braintreeSdk.getBraintreeThreeDS()]:[3,4];case 2:return d=o.sent(),l=this._service.getState().getOrderOrThrow().orderAmount,[4,this._braintreePresent3DSChallenge(d,l,r,c)];case 3:return[2,o.sent().nonce];case 4:return[2,r]}}))}))},t.prototype.extraPaymentData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return e={},[4,this._getBraintreeDeviceData()];case 1:return[2,(e.deviceSessionId=t.sent(),e)]}}))}))},t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:n=i.sent();try{r=JSON.parse(n.nonce)}catch(e){throw new ja("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 Wa(Ya.MissingPaymentToken)}(r),n.nonce=r.androidPayCards[0].nonce,n.card_information.bin=r.androidPayCards[0].details.bin,[2,n]}}))}))},t.prototype.getCardParameters=function(){return e.prototype.getCardParameters.call(this)},t.prototype.getPaymentGatewayParameters=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return t=this.getBraintreeGooglePayment(),r=(n=t).createPaymentDataRequest,i=[{merchantInfo:e.prototype.getMerchantInfo.call(this),transactionInfo:e.prototype.getTransactionInfo.call(this),cardRequirements:{billingAddressRequired:!0,billingAddressFormat:"FULL"}}],[4,e.prototype.getRequiredData.call(this)];case 1:return[2,r.apply(n,[o.__assign.apply(void 0,i.concat([a.sent()]))]).paymentMethodTokenizationParameters.parameters]}}))}))},t.prototype.getBraintreeGooglePayment=function(){if(!this._braintreeGooglePayment)throw new Wa(Ya.MissingPaymentMethod);return this._braintreeGooglePayment},t.prototype._getBraintreeDeviceData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this._braintreeSdk.getDataCollectorOrThrow()];case 1:return[2,e.sent().deviceData]}}))}))},t.prototype._braintreePresent3DSChallenge=function(e,t,n,r){return new Ur(e.verifyCard({amount:t,bin:r,nonce:n,onLookupComplete:function(e,t){t()}})).promise},t}(gu);const _u=mu,yu=function(e){function t(t){var n=e.call(this,t||"Unable to proceed because the client library of a payment method has thrown an unexpected error.")||this;return n.name="PaymentMethodFailedError",n.type="payment_method_client_invalid",n}return(0,o.__extends)(t,e),t}(s);var vu;!function(e){e.ADYEN_V2="googlepayadyenv2",e.ADYEN_V3="googlepayadyenv3",e.AUTHORIZE_NET="googlepayauthorizenet",e.BNZ="googlepaybnz",e.BRAINTREE="googlepaybraintree",e.PAYPAL_COMMERCE="googlepaypaypalcommerce",e.CHECKOUT_COM="googlepaycheckoutcom",e.CYBERSOURCE_V2="googlepaycybersourcev2",e.ORBITAL="googlepayorbital",e.STRIPE="googlepaystripe",e.STRIPE_UPE="googlepaystripeupe",e.WORLDPAY_ACCESS="googlepayworldpayaccess",e.TD_ONLINE_MART="googlepaytdonlinemart"}(vu||(vu={}));var Cu=function(){function e(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}return e.prototype.initialize=function(e){var t,n;return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s,u,c,d,l;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!e.methodId||(p=e.methodId,!Object.values(vu).includes(p)))throw new ja('Unable to proceed because "methodId" is not a valid key.');if(this._methodId=e.methodId,!e.containerId)throw new ja('Unable to proceed because "containerId" is not a valid key.');if(!(r=e[this._getMethodOrThrow()]))throw new ja("Unable to proceed without valid options.");i=r.buyNowInitializeOptions,a=r.currencyCode,s=r.buttonColor,u=r.buttonType,c=r.onError,d=this._paymentIntegrationService.getState(),o.label=1;case 1:return o.trys.push([1,2,,4]),l=d.getPaymentMethodOrThrow(this._getMethodOrThrow()),[3,4];case 2:return o.sent(),[4,this._paymentIntegrationService.loadPaymentMethod(this._getMethodOrThrow())];case 3:return d=o.sent(),l=d.getPaymentMethodOrThrow(this._getMethodOrThrow()),[3,4];case 4:if(this._countryCode=null===(t=l.initializationData)||void 0===t?void 0:t.storeCountry,!i)return[3,6];if(!a)throw new ja('Unable to initialize payment because "options.currencyCode" argument is not provided.');return this._currencyCode=a,this._buyNowInitializeOptions=i,[4,this._googlePayPaymentProcessor.initialize((function(){return l}),this._getGooglePayClientOptions(),!!i,a)];case 5:return o.sent(),[3,9];case 6:return[4,this._paymentIntegrationService.loadDefaultCheckout()];case 7:return o.sent(),[4,this._googlePayPaymentProcessor.initialize((function(){return l}),this._getGooglePayClientOptions())];case 8:o.sent(),o.label=9;case 9:return this._paymentButton=null!==(n=this._paymentButton)&&void 0!==n?n:this._googlePayPaymentProcessor.addPaymentButton(e.containerId,{buttonColor:null!=s?s:"default",buttonType:null!=u?u:"plain",onClick:this._handleClick(c)}),[2]}var p}))}))},e.prototype.deinitialize=function(){var e;return null===(e=this._paymentButton)||void 0===e||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()},e.prototype._handleClick=function(e){var t=this;return function(n){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:n.preventDefault(),i.label=1;case 1:return i.trys.push([1,8,,9]),this._buyNowInitializeOptions?[4,this._createBuyNowCartOrThrow(this._buyNowInitializeOptions)]:[3,3];case 2:return i.sent(),[3,5];case 3:return[4,this._paymentIntegrationService.loadDefaultCheckout()];case 4:i.sent(),i.label=5;case 5:return[4,this._googlePayPaymentProcessor.initializeWidget()];case 6:return i.sent(),[4,this._interactWithPaymentSheet()];case 7:return i.sent(),[3,9];case 8:if(t=i.sent(),r=t,"object"==typeof(o=t)&&null!==o&&"statusCode"in o){if("CANCELED"===t.statusCode)throw new Ts;r=new yu(JSON.stringify(t))}throw null==e||e(new yu("An error occurred while requesting your Google Pay payment details.")),r;case 9:return[2]}var o}))}))}},e.prototype._interactWithPaymentSheet=function(){var e;return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,this._googlePayPaymentProcessor.showPaymentSheet()];case 1:return t=o.sent(),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?[4,this._paymentIntegrationService.updateBillingAddress(n)]:[3,3];case 2:o.sent(),o.label=3;case 3:return!r||(null===(e=this._buyNowCart)||void 0===e?void 0:e.lineItems.digitalItems.length)?[3,5]:[4,this._paymentIntegrationService.updateShippingAddress(r)];case 4:o.sent(),o.label=5;case 5:return[4,this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodOrThrow(),t,i)];case 6:return o.sent(),[2]}}))}))},e.prototype._getGooglePayClientOptions=function(){var e=this;return{paymentDataCallbacks:{onPaymentDataChanged:function(t){var n=t.callbackTrigger,r=t.shippingAddress,i=t.shippingOptionData;return(0,o.__awaiter)(e,void 0,void 0,(function(){var e,t,a,s,u,c;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return e=this._googlePayPaymentProcessor.getCallbackTriggers(),t=e.availableTriggers,a=e.addressChangeTriggers,s=e.shippingOptionsChangeTriggers,t.includes(n)?a.includes(n)?[4,this._googlePayPaymentProcessor.handleShippingAddressChange(r)]:[3,2]:[2];case 1:return c=o.sent(),[3,3];case 2:c=void 0,o.label=3;case 3:return u=c,s.includes(n)?[4,this._googlePayPaymentProcessor.handleShippingOptionChange(i.id)]:[3,5];case 4:o.sent(),o.label=5;case 5:return this._buyNowInitializeOptions?[2,this._getBuyNowTransactionInfo(u)]:[2,this._getTransactionInfo(u)]}}))}))}}}},e.prototype._createBuyNowCartOrThrow=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:if("function"!=typeof(null==e?void 0:e.getBuyNowCartRequestBody))return[3,5];t=e.getBuyNowCartRequestBody(),i.label=1;case 1:return i.trys.push([1,4,,5]),n=this,[4,this._paymentIntegrationService.createBuyNowCart(t)];case 2:return n._buyNowCart=i.sent(),[4,this._paymentIntegrationService.loadCheckout(this._buyNowCart.id)];case 3:return i.sent(),[3,5];case 4:throw r=i.sent(),new ds(r);case 5:return[2]}}))}))},e.prototype._getBuyNowTransactionInfo=function(e){if(this._buyNowCart){var t=this._buyNowCart.cartAmount,n=this._googlePayPaymentProcessor.getTotalPrice();return(0,o.__assign)({newTransactionInfo:(0,o.__assign)((0,o.__assign)({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:this._getCurrencyCodeOrThrow(),totalPrice:n||String(t),totalPriceStatus:cu.FINAL})},e&&{newShippingOptionParameters:e})}},e.prototype._getTransactionInfo=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._paymentIntegrationService.loadCheckout()];case 1:return r.sent(),t=this._googlePayPaymentProcessor.getTotalPrice(),n=this._paymentIntegrationService.getState().getCartOrThrow().currency.code,[2,(0,o.__assign)({newTransactionInfo:(0,o.__assign)((0,o.__assign)({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:n,totalPriceStatus:cu.FINAL,totalPrice:t})},e&&{newShippingOptionParameters:e})]}}))}))},e.prototype._getMethodOrThrow=function(){return Za(this._methodId,(function(){return new Ja(Qa.PaymentNotInitialized)}))},e.prototype._getCurrencyCodeOrThrow=function(){return Za(this._currencyCode,(function(){return new ja('Unable to initialize payment because "options.currencyCode" argument is not provided.')}))},e}();const Su=Cu;var Iu=function(){function e(e,t,n,r){this._scriptLoader=e,this._gateway=t,this._requestSender=n,this._formPoster=r,this._baseRequest={apiVersion:2,apiVersionMinor:0}}return e.prototype.initialize=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return i=this,[4,this._scriptLoader.getGooglePaymentsClient(e().config.testMode,t)];case 1:return i._paymentsClient=o.sent(),[4,this._gateway.initialize(e,n,r)];case 2:return o.sent(),this._buildButtonPayloads(),[2]}}))}))},e.prototype.initializeWidget=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this._buildWidgetPayloads()];case 1:return e.sent(),[4,this._determineReadinessToPay()];case 2:return e.sent(),this._prefetchGooglePaymentData(),[2]}}))}))},e.prototype.getNonce=function(e){return this._gateway.getNonce(e)},e.prototype.extraPaymentData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this._gateway.extraPaymentData()]}))}))},e.prototype.addPaymentButton=function(e,t){var n=document.querySelector("#"+e);if(!n)throw new ja("Unable to render the Google Pay button to an invalid HTML container element.");var r=this._getPaymentsClient().createButton((0,o.__assign)((0,o.__assign)({},t),{allowedPaymentMethods:[this._getBaseCardPaymentMethod()]}));return n.appendChild(r)},e.prototype.showPaymentSheet=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(t){return e=this._getPaymentDataRequest(),[2,this._getPaymentsClient().loadPaymentData(e)]}))}))},e.prototype.setExternalCheckoutXhr=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){return[2,this._setExternalCheckout(e,t)]}))}))},e.prototype.setExternalCheckoutForm=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){return[2,this._setExternalCheckout(e,t,!0,n)]}))}))},e.prototype.mapToBillingAddressRequestBody=function(e){return this._gateway.mapToBillingAddressRequestBody(e)},e.prototype.mapToShippingAddressRequestBody=function(e){return this._gateway.mapToShippingAddressRequestBody(e)},e.prototype.processAdditionalAction=function(e){return"processAdditionalAction"in this._gateway?this._gateway.processAdditionalAction(e):Promise.reject(e)},e.prototype.signOut=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._requestSender.get("/remote-checkout/"+e+"/signout")];case 1:return t.sent(),[2]}}))}))},e.prototype.getCallbackTriggers=function(){return this._gateway.getCallbackTriggers()},e.prototype.handleShippingAddressChange=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){return[2,this._gateway.handleShippingAddressChange(e)]}))}))},e.prototype.handleShippingOptionChange=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._gateway.handleShippingOptionChange(e)];case 1:return t.sent(),[2]}}))}))},e.prototype.getTotalPrice=function(){return this._gateway.getTotalPrice()},e.prototype._setExternalCheckout=function(e,t,n,r){return void 0===n&&(n=!1),(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u=this;return(0,o.__generator)(this,(function(c){switch(c.label){case 0:return i="/checkout.php",s=[{action:"set_external_checkout",provider:e}],[4,this._gateway.mapToExternalCheckoutData(t)];case 1:return a=o.__assign.apply(void 0,s.concat([c.sent()])),n?[2,new Promise((function(e){u._formPoster.postForm(r?r+"/checkout":i,(0,o.__assign)((0,o.__assign)({},a),{card_information:JSON.stringify(a.card_information)}),e)}))]:[4,this._requestSender.post(i,{headers:(0,o.__assign)({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},ys),body:a})];case 2:return c.sent(),[2]}}))}))},e.prototype._prefetchGooglePaymentData=function(){var e=this._getPaymentDataRequest();e.transactionInfo=this._gateway.getTransactionInfo(),this._getPaymentsClient().prefetchPaymentData(e)},e.prototype._determineReadinessToPay=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this._getPaymentsClient().isReadyToPay(this._getIsReadyToPayRequest())];case 1:if(!1===t.sent().result)throw new yu("Google Pay is not supported by the current device and browser, please try another payment method.");return[3,3];case 2:if((e=t.sent())instanceof yu)throw e;throw new yu;case 3:return[2]}}))}))},e.prototype._buildButtonPayloads=function(){this._baseCardPaymentMethod={type:"CARD",parameters:this._gateway.getCardParameters()}},e.prototype._buildWidgetPayloads=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r,i,a,s;return(0,o.__generator)(this,(function(u){switch(u.label){case 0:return e=this._getBaseCardPaymentMethod(),t=this,n=[(0,o.__assign)({},e)],a={},s={type:"PAYMENT_GATEWAY"},[4,this._gateway.getPaymentGatewayParameters()];case 1:return t._cardPaymentMethod=o.__assign.apply(void 0,n.concat([(a.tokenizationSpecification=(s.parameters=u.sent(),s),a)])),r=this,i=[(0,o.__assign)((0,o.__assign)({},this._baseRequest),{allowedPaymentMethods:[this._cardPaymentMethod],transactionInfo:this._gateway.getTransactionInfo(),merchantInfo:this._gateway.getMerchantInfo()})],[4,this._gateway.getRequiredData()];case 2:return r._paymentDataRequest=o.__assign.apply(void 0,[o.__assign.apply(void 0,i.concat([u.sent()])),{callbackIntents:this._gateway.getCallbackIntents()}]),this._isReadyToPayRequest=(0,o.__assign)((0,o.__assign)({},this._baseRequest),{allowedPaymentMethods:[e]}),[2]}}))}))},e.prototype._getBaseCardPaymentMethod=function(){return this._getOrThrow(this._baseCardPaymentMethod)},e.prototype._getPaymentDataRequest=function(){return this._getOrThrow(this._paymentDataRequest)},e.prototype._getIsReadyToPayRequest=function(){return this._getOrThrow(this._isReadyToPayRequest)},e.prototype._getPaymentsClient=function(){return this._getOrThrow(this._paymentsClient)},e.prototype._getOrThrow=function(e){return Za(e,(function(){return new Ja(Qa.PaymentNotInitialized)}))},e}();const wu=Iu;var Eu=function(){function e(e){this._scriptLoader=e,this._window=window}return e.prototype.getGooglePaymentsClient=function(e,t){return void 0===e&&(e=!1),(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._scriptLoader.loadScript("https://pay.google.com/gp/p/js/pay.js")];case 1:if(n.sent(),!this._window.google)throw new Ko;return void 0===this._paymentsClient&&(this._paymentsClient=new this._window.google.payments.api.PaymentsClient((0,o.__assign)({environment:e?"TEST":"PRODUCTION"},null!=t?t:{}))),[2,this._paymentsClient]}}))}))},e}();const bu=Eu;function Pu(){return new bu((0,ir.getScriptLoader)())}const Au=cs((function(e){var t=(0,r.createRequestSender)(),n=window,o=new Os(new ta((0,ir.getScriptLoader)(),n));return new Su(e,new wu(Pu(),new _u(e,o),t,(0,i.createFormPoster)()))}),[{id:"googlepaybraintree"}]);var Ou=function(e){function t(t,n){var r=e.call(this,"paypalsb",t)||this;return r.paypalCommerceScriptLoader=n,r.service=t,r}return(0,o.__extends)(t,e),t.prototype.initialize=function(t,n,r){var i,a,s,u,c;return(0,o.__awaiter)(this,void 0,void 0,(function(){var d,l,p,h;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!(d=null!==(a=null===(i=this.service.getState().getStoreConfig())||void 0===i?void 0:i.currency.code)&&void 0!==a?a:r))throw new Wa(Ya.MissingPaymentMethod);return[4,e.prototype.initialize.call(this,t,n,d)];case 1:if(o.sent(),!(l=e.prototype.getPaymentMethod.call(this)).initializationData)throw new Wa(Ya.MissingPaymentMethod);return function(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 Wa(Ya.MissingPaymentMethod)}(l),[4,this.paypalCommerceScriptLoader.getPayPalSDK(l,d)];case 2:return o.sent(),p=this,[4,this.paypalCommerceScriptLoader.getGooglePayConfigOrThrow()];case 3:return p.googlepayConfig=o.sent(),h=this.googlepayConfig.allowedPaymentMethods,this.setGatewayIdentifier(null===(c=null===(u=null===(s=h[0])||void 0===s?void 0:s.tokenizationSpecification)||void 0===u?void 0:u.parameters)||void 0===c?void 0:c.gateway),[2]}}))}))},t.prototype.getPaymentGatewayParameters=function(){if(this.googlepayConfig){var e=this.googlepayConfig.allowedPaymentMethods[0].tokenizationSpecification.parameters.gatewayMerchantId;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e}}return{gateway:this.getGatewayIdentifier()}},t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:return(n=r.sent()).nonce=btoa(n.nonce),[2,n]}}))}))},t}(gu);const Tu=Ou;var Ru=function(){function e(e){this.scriptLoader=e,this.window=window}return e.prototype.getPayPalSDK=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i;return(0,o.__generator)(this,(function(o){return i=this.getPayPalSdkScriptConfigOrThrow(e,t,n),[2,this.loadPayPalSDK(i,r)]}))}))},e.prototype.getGooglePayConfigOrThrow=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(t){switch(t.label){case 0:if(!this.window.paypal)throw new Ko;return this.googlepayConfig?[3,2]:(e=this,[4,this.window.paypal.Googlepay().config()]);case 1:e.googlepayConfig=t.sent(),t.label=2;case 2:return[2,this.googlepayConfig]}}))}))},e.prototype.loadPayPalSDK=function(e,t){return void 0===t&&(t=!1),(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return this.window.paypal&&!t?[3,2]:(n=this.transformConfig(e.options),r=this.transformConfig(e.attributes),i=new URLSearchParams(n).toString(),a="https://www.paypal.com/sdk/js?"+i,[4,this.scriptLoader.loadScript(a,{async:!0,attributes:r})]);case 1:o.sent(),o.label=2;case 2:if(!this.window.paypal)throw new Ko;return[2,this.window.paypal]}}))}))},e.prototype.getPayPalSdkScriptConfigOrThrow=function(e,t,n){void 0===n&&(n=!0);var r=e.id,i=e.clientToken,a=e.initializationData;if(!(null==a?void 0:a.clientId))throw new Wa(Ya.MissingPaymentMethod);var s=a.intent,u=a.clientId,c=a.merchantId,d=a.buyerCountry,l=a.attributionId,p=a.isVenmoEnabled,h=a.isHostedCheckoutEnabled,f=a.isPayPalCreditAvailable,g=a.isDeveloperModeApplicable,m=a.availableAlternativePaymentMethods,_=void 0===m?[]:m,y=a.enabledAlternativePaymentMethods,v=void 0===y?[]:y,C=a.isGooglePayEnabled,S=h||n,I="paypalcommercecreditcards"===r,w=I?["card"]:[],E=I?[]:["card"],b=n?["card-fields"]:[],P=f?["credit","paylater"]:[],A=f?[]:["credit","paylater"],O=n||!S,T=O&&p?["venmo"]:[],R=O&&p?[]:["venmo"],k=O?v:[],D=O?_.filter((function(e){return!v.includes(e)})):_,M=(0,o.__spreadArrays)(E,A,R,D),N=(0,o.__spreadArrays)(w,P,T,k),L=C?["googlepay"]:[];return{options:(0,o.__assign)({"client-id":u,"merchant-id":c,"enable-funding":N.length>0?N:void 0,"disable-funding":M.length>0?M:void 0,commit:S,components:(0,o.__spreadArrays)(["buttons","hosted-fields","messages","payment-fields","legal"],L,b),currency:t,intent:s},g&&{"buyer-country":d}),attributes:{"data-partner-attribution-id":l,"data-client-token":i}}},e.prototype.transformConfig=function(e){var t={};return Object.keys(e).forEach((function(n){var r,i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=Array.isArray(i)?i.join(","):i,r)))})),t},e}();const ku=Ru,Du=cs((function(e){return new Su(e,new wu(Pu(),new Tu(e,new ku((0,ir.getScriptLoader)())),(0,r.createRequestSender)(),(0,i.createFormPoster)()))}),[{id:"googlepaypaypalcommerce"}]),Mu=cs((function(e){var t=(0,r.createRequestSender)();return new Su(e,new wu(Pu(),new gu("adyen",e),t,(0,i.createFormPoster)()))}),[{id:"googlepayadyenv2"}]),Nu=cs((function(e){var t=(0,r.createRequestSender)();return new Su(e,new wu(Pu(),new gu("adyen",e),t,(0,i.createFormPoster)()))}),[{id:"googlepayadyenv3"}]);var Lu=function(e){function t(t){return e.call(this,"authorizenet",t)||this}return(0,o.__extends)(t,e),t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:return(n=r.sent()).nonce=btoa(n.nonce),[2,n]}}))}))},t.prototype.getPaymentGatewayParameters=function(){var e=this.getGooglePayInitializationData();return function(e){if(!function(e){return"paymentGatewayId"in e}(e))throw new Wa(Ya.MissingPaymentMethod)}(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.paymentGatewayId}},t}(gu);const zu=Lu,Uu=cs((function(e){return new Su(e,new wu(Pu(),new zu(e),(0,r.createRequestSender)(),(0,i.createFormPoster)()))}),[{id:"googlepayauthorizenet"}]),Fu=function(e){return"object"==typeof e&&null!==e&&"body"in e};function Bu(e){if(!function(e){return"checkoutcomkey"in e}(e))throw new Wa(Ya.MissingPaymentMethod)}var qu=function(e){function t(t,n){var r=e.call(this,"checkoutltd",t)||this;return r._requestSender=n,r}return(0,o.__extends)(t,e),t.prototype.processAdditionalAction=function(e){return new Promise((function(t,n){if(Fu(e)&&function(e){var t;if("object"!=typeof e||null===e)return!1;var n=e;return"string"==typeof(null===(t=n.three_ds_result)||void 0===t?void 0:t.acs_url)&&"string"==typeof n.three_ds_result.code}(e.body)&&"three_d_secure_required"===e.body.three_ds_result.code)return window.location.assign(e.body.three_ds_result.acs_url);n(e)}))},t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:n=o.sent();try{r=JSON.parse(n.nonce)}catch(e){throw new ja("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 Wa(Ya.MissingPaymentToken)}(r),i=n,[4,this._tokenize(r)];case 2:return i.nonce=o.sent(),[2,n]}}))}))},t.prototype.getPaymentGatewayParameters=function(){var e=this.getGooglePayInitializationData();return Bu(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.checkoutcomkey}},t.prototype._tokenize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return t=this.getPaymentMethod().config.testMode?"https://api.sandbox.checkout.com/tokens":"https://api.checkout.com/tokens",Bu(n=this.getGooglePayInitializationData()),[4,this._requestSender.post(t,{credentials:!1,body:{type:"googlepay",token_data:e},headers:{Authorization:n.checkoutcomkey,"Content-Type":_s.Json,"X-XSRF-TOKEN":null}})];case 1:return[2,r.sent().body.token]}}))}))},t}(gu);const xu=qu,Gu=cs((function(e){var t=(0,r.createRequestSender)();return new Su(e,new wu(Pu(),new xu(e,t),t,(0,i.createFormPoster)()))}),[{id:"googlepaycheckoutcom"}]);var Vu=function(e){function t(t){return e.call(this,"cybersource",t)||this}return(0,o.__extends)(t,e),t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:return(n=r.sent()).nonce=btoa(n.nonce),[2,n]}}))}))},t}(gu);const Hu=Vu,ju=cs((function(e){return new Su(e,new wu(Pu(),new Hu(e),(0,r.createRequestSender)(),(0,i.createFormPoster)()))}),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]);var Yu=function(e){function t(t){return e.call(this,"chase",t)||this}return(0,o.__extends)(t,e),t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:return(n=r.sent()).nonce=btoa(n.nonce),[2,n]}}))}))},t}(gu);const Wu=Yu,Ku=cs((function(e){return new Su(e,new wu(Pu(),new Wu(e),(0,r.createRequestSender)(),(0,i.createFormPoster)()))}),[{id:"googlepayorbital"}]);var Zu=function(e){function t(t){return e.call(this,"stripe",t)||this}return(0,o.__extends)(t,e),t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:n=i.sent();try{r=JSON.parse(n.nonce)}catch(e){throw new ja("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 Wa(Ya.MissingPaymentToken)}(r),n.nonce=r.id,[2,n]}}))}))},t.prototype.getPaymentGatewayParameters=function(){var e=this.getGooglePayInitializationData();!function(e){if(!function(e){return"stripeConnectedAccount"in e&&"stripePublishableKey"in e&&"stripeVersion"in e}(e))throw new Wa(Ya.MissingPaymentMethod)}(e);var t=e.stripeVersion,n=e.stripePublishableKey,r=e.stripeConnectedAccount;return{gateway:this.getGatewayIdentifier(),"stripe:version":t,"stripe:publishableKey":n+"/"+r}},t}(gu);const Qu=Zu,Ju=cs((function(e){return new Su(e,new wu(Pu(),new Qu(e),(0,r.createRequestSender)(),(0,i.createFormPoster)()))}),[{id:"googlepaystripe"},{id:"googlepaystripeupe"}]);var Xu=function(e){function t(t){return e.call(this,"worldpay",t)||this}return(0,o.__extends)(t,e),t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:return(n=r.sent()).nonce=btoa(n.nonce),[2,n]}}))}))},t}(gu);const $u=Xu,ec=cs((function(e){return new Su(e,new wu(Pu(),new $u(e),(0,r.createRequestSender)(),(0,i.createFormPoster)()))}),[{id:"googlepayworldpayaccess"}]),tc=function(e){function t(t){var n=this,r="Unable to submit payment for the order because the payload is invalid.";return t&&(r=r+" Make sure the following fields are provided correctly: "+t.join(", ")+"."),(n=e.call(this,r)||this).name="PaymentArgumentInvalidError",n}return(0,o.__extends)(t,e),t}(ja);var nc=function(e){function t(t,n){var r=e.call(this,"worldlinena",t)||this;return r.formPoster=n,r}return(0,o.__extends)(t,e),t.prototype.extraPaymentData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,Promise.resolve({browser_info:(n=window.navigator,t=n.language?n.language:n.userLanguage,{color_depth:window.screen.colorDepth||24,java_enabled:"function"==typeof n.javaEnabled&&n.javaEnabled(),language:t,screen_height:window.screen.height,screen_width:window.screen.width,time_zone_offset:(new Date).getTimezoneOffset().toString()})})];var t,n}))}))},t.prototype.processAdditionalAction=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s=this;return(0,o.__generator)(this,(function(o){if(!function(e){return Fu(e)&&(t=e.body,(0,_.isObject)(t)&&"object"==typeof t&&"errors"in t&&"three_ds_result"in t&&(0,_.isArray)(t.errors)&&(0,_.some)(t.errors,{code:"three_d_secure_required"}));var t}(e))throw e;if(t=e.body.three_ds_result,r=(n=t||{}).acs_url,i=n.payer_auth_request,a=n.merchant_data,!r||!i||!a)throw new tc(["formUrl","threeDSSessionData","creq"]);return[2,new Promise((function(e){s.formPoster.postForm(r,{threeDSSessionData:i,creq:a},e,"_top")}))]}))}))},t}(gu);const rc=nc,ic=cs((function(e){return new Su(e,new wu(Pu(),new rc(e,(0,i.createFormPoster)()),(0,r.createRequestSender)(),(0,i.createFormPoster)()))}),[{id:"googlepaytdonlinemart"}]);var oc,ac,sc,uc,cc,dc,lc,pc;!function(e){e.BuyNow="BUY_NOW"}(oc||(oc={})),function(e){e.Possible="POSSIBLE",e.No="NO",e.Unknown="UNKNOWN",e.Yes="YES"}(ac||(ac={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(sc||(sc={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(uc||(uc={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(cc||(cc={})),function(e){e.pill="pill",e.rect="rect"}(dc||(dc={})),function(e){e.OXXO="oxxo"}(lc||(lc={})),function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(pc||(pc={}));var hc=function(){function e(e,t,n,r){this.formPoster=e,this.paymentIntegrationService=t,this.paypalCommerceRequestSender=n,this.paypalCommerceScriptLoader=r}return e.prototype.loadPayPalSdk=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return i=this.paymentIntegrationService.getState(),a=t||i.getCartOrThrow().currency.code,s=i.getPaymentMethodOrThrow(e),u=this,[4,this.paypalCommerceScriptLoader.getPayPalSDK(s,a,n,r)];case 1:return u.paypalSdk=o.sent(),[2,this.paypalSdk]}}))}))},e.prototype.getPayPalSdkOrThrow=function(){if(!this.paypalSdk)throw new Ko;return this.paypalSdk},e.prototype.createBuyNowCartOrThrow=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if(!(t=e.getBuyNowCartRequestBody()))throw new Wa(Ya.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.paymentIntegrationService.createBuyNowCart(t)];case 2:return[2,n.sent()];case 3:throw n.sent(),new ds;case 4:return[2]}}))}))},e.prototype.createOrder=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return n=this.paymentIntegrationService.getState().getCartOrThrow().id,[4,this.paypalCommerceRequestSender.createOrder(e,(0,o.__assign)({cartId:n},t))];case 1:return[2,r.sent().orderId]}}))}))},e.prototype.createOrderCardFields=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(s){switch(s.label){case 0:return n=this.paymentIntegrationService.getState().getCartOrThrow().id,[4,this.paypalCommerceRequestSender.createOrder(e,(0,o.__assign)({cartId:n},t))];case 1:return r=s.sent(),i=r.orderId,a=r.setupToken,[2,(0,o.__assign)({orderId:i},a?{setupToken:a}:{})]}}))}))},e.prototype.updateOrder=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:e=this.paymentIntegrationService.getState(),t=e.getCartOrThrow(),n=e.getConsignmentsOrThrow()[0],r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.paypalCommerceRequestSender.updateOrder({availableShippingOptions:n.availableShippingOptions,cartId:t.id,selectedShippingOption:n.selectedShippingOption})];case 2:return r.sent(),[3,4];case 3:throw r.sent(),new d;case 4:return[2]}}))}))},e.prototype.getOrderStatus=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.paypalCommerceRequestSender.getOrderStatus(e,t)];case 1:return[2,n.sent().status];case 2:throw n.sent(),new d;case 3:return[2]}}))}))},e.prototype.tokenizePayment=function(e,t){var n=this.paymentIntegrationService.getState().getCartOrThrow();if(!t)throw new Wa(Ya.MissingOrderId);return this.formPoster.postForm("/checkout.php",(0,o.__assign)({payment_type:"paypal",action:"set_external_checkout",provider:e,order_id:t},n.source===oc.BuyNow&&{cart_id:n.id}))},e.prototype.submitPayment=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return r={formattedPayload:{vault_payment_instrument:null,set_as_default_stored_instrument:null,device_info:null,method_id:e,paypal_account:{order_id:t}}},[4,this.paymentIntegrationService.submitPayment((0,o.__assign)({methodId:e,paymentData:r},n?{gatewayId:n}:{}))];case 1:return i.sent(),[2]}}))}))},e.prototype.getShippingOptionOrThrow=function(e){var t=this.paymentIntegrationService.getState().getConsignmentsOrThrow()[0],n=t.availableShippingOptions||[],r=n.find((function(e){return e.isRecommended})),i=e?n.find((function(t){return t.id===e})):n.find((function(e){var n;return e.id===(null===(n=t.selectedShippingOption)||void 0===n?void 0:n.id)})),o=i||r||n[0];if(!o)throw new Error("Your order can't be shipped to this address");return o},e.prototype.getAddress=function(e){return{firstName:(null==e?void 0:e.firstName)||"",lastName:(null==e?void 0:e.lastName)||"",email:(null==e?void 0:e.email)||"",phone:"",company:"",address1:(null==e?void 0:e.address1)||"",address2:"",city:(null==e?void 0:e.city)||"",countryCode:(null==e?void 0:e.countryCode)||"",postalCode:(null==e?void 0:e.postalCode)||"",stateOrProvince:"",stateOrProvinceCode:(null==e?void 0:e.stateOrProvinceCode)||"",customFields:[]}},e.prototype.getBillingAddressFromOrderDetails=function(e){var t=e.payer;return this.getAddress({firstName:t.name.given_name,lastName:t.name.surname,email:t.email_address,address1:t.address.address_line_1,city:t.address.admin_area_2,countryCode:t.address.country_code,postalCode:t.address.postal_code,stateOrProvinceCode:t.address.admin_area_1})},e.prototype.getShippingAddressFromOrderDetails=function(e){var t,n,r=e.payer,i=(null===(n=null===(t=e.purchase_units[0])||void 0===t?void 0:t.shipping)||void 0===n?void 0:n.address)||{};return this.getAddress({firstName:r.name.given_name,lastName:r.name.surname,email:r.email_address,address1:i.address_line_1,city:i.admin_area_2,countryCode:i.country_code,postalCode:i.postal_code,stateOrProvinceCode:i.admin_area_1})},e.prototype.getValidButtonStyle=function(e){var t=e||{},n=t.color,r=t.height,i=t.label,o=t.shape,a={color:n&&cc[n]?n:void 0,height:this.getValidHeight(r),label:i&&uc[i]?i:void 0,shape:o&&dc[o]?o:void 0};return(0,_.omitBy)(a,_.isNil)},e.prototype.getValidHeight=function(e){return e&&"number"==typeof e?e>55?55:e<25?25:e:40},e.prototype.removeElement=function(e){var t=e&&document.getElementById(e);t&&(t.style.display="none")},e}();const fc=hc;var gc=function(){function e(e){this.requestSender=e}return e.prototype.createOrder=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return n="/api/storefront/payment/"+e,r=t,i=(0,o.__assign)({"X-API-INTERNAL":ms,"Content-Type":_s.Json},ys),[4,this.requestSender.post(n,{headers:i,body:r})];case 1:return[2,a.sent().body]}}))}))},e.prototype.updateOrder=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return t=e,n=(0,o.__assign)({"X-API-INTERNAL":ms,"Content-Type":_s.Json},ys),[4,this.requestSender.put("/api/storefront/initialization/paypalcommerce",{headers:n,body:t})];case 1:return[2,r.sent().body]}}))}))},e.prototype.getOrderStatus=function(e,t){return void 0===e&&(e="paypalcommerce"),(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return n="/api/storefront/initialization/"+e,r=(0,o.__assign)({"X-API-INTERNAL":ms,"Content-Type":_s.Json},ys),[4,this.requestSender.get(n,(0,o.__assign)({headers:r},t))];case 1:return[2,i.sent().body]}}))}))},e}();const mc=gc;var _c=function(){function e(e){this.scriptLoader=e,this.window=window}return e.prototype.getPayPalSDK=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i;return(0,o.__generator)(this,(function(o){return i=this.getPayPalSdkScriptConfigOrThrow(e,t,n),[2,this.loadPayPalSDK(i,r)]}))}))},e.prototype.loadPayPalSDK=function(e,t){return void 0===t&&(t=!1),(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return this.window.paypal&&!t?[3,2]:(n=this.transformConfig(e.options),r=this.transformConfig(e.attributes),i=new URLSearchParams(n).toString(),a="https://www.paypal.com/sdk/js?"+i,[4,this.scriptLoader.loadScript(a,{async:!0,attributes:r})]);case 1:o.sent(),o.label=2;case 2:if(!this.window.paypal)throw new Ko;return[2,this.window.paypal]}}))}))},e.prototype.getPayPalSdkScriptConfigOrThrow=function(e,t,n){void 0===n&&(n=!0);var r=e.id,i=e.clientToken,a=e.initializationData;if(!(null==a?void 0:a.clientId))throw new Wa(Ya.MissingPaymentMethod);var s=a.intent,u=a.clientId,c=a.merchantId,d=a.buyerCountry,l=a.attributionId,p=a.isVenmoEnabled,h=a.isHostedCheckoutEnabled,f=a.isPayPalCreditAvailable,g=a.isDeveloperModeApplicable,m=a.availableAlternativePaymentMethods,_=void 0===m?[]:m,y=a.enabledAlternativePaymentMethods,v=void 0===y?[]:y,C=a.isGooglePayEnabled,S=h||n,I="paypalcommercecreditcards"===r,w=I?["card"]:[],E=I?[]:["card"],b=f?["credit","paylater"]:[],P=f?[]:["credit","paylater"],A=n||!S,O=A&&p?["venmo"]:[],T=A&&p?[]:["venmo"],R=A?v:[],k=A?_.filter((function(e){return!v.includes(e)})):_,D=C?["googlepay"]:[],M=n?["card-fields"]:[],N=(0,o.__spreadArrays)(E,P,T,k),L=(0,o.__spreadArrays)(w,b,O,R);return{options:(0,o.__assign)({"client-id":u,"merchant-id":c,"enable-funding":L.length>0?L:void 0,"disable-funding":N.length>0?N:void 0,commit:S,components:(0,o.__spreadArrays)(["buttons","hosted-fields","payment-fields","legal"],D,M),currency:t,intent:s},g&&{"buyer-country":d}),attributes:{"data-partner-attribution-id":l,"data-client-token":i}}},e.prototype.transformConfig=function(e){var t={};return Object.keys(e).forEach((function(n){var r,i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=Array.isArray(i)?i.join(","):i,r)))})),t},e}();const yc=_c,vc=function(e){var t=e.getState().getHost;return new fc((0,i.createFormPoster)(),e,new mc((0,r.createRequestSender)({host:t()})),new yc((0,ir.getScriptLoader)()))};var Cc=function(){function e(e,t){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t}return e.prototype.initialize=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(n=e.paypalcommerce,r=e.containerId,i=e.methodId,a=Boolean(null==n?void 0:n.buyNowInitializeOptions),!i)throw new ja('Unable to initialize payment because "options.methodId" argument is not provided.');if(!r)throw new ja('Unable to initialize payment because "options.containerId" argument is not provided.');if(!n)throw new ja('Unable to initialize payment because "options.paypalcommerce" argument is not provided.');if(a&&!n.currencyCode)throw new ja('Unable to initialize payment because "options.paypalcommerce.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null===(t=n.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody))throw new ja('Unable to initialize payment because "options.paypalcommerce.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');return a?[3,2]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return s=a?n.currencyCode:this.paymentIntegrationService.getState().getCartOrThrow().currency.code,[4,this.paypalCommerceIntegrationService.loadPayPalSdk(i,s,!1)];case 3:return o.sent(),this.renderButton(r,i,n),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r,i=this,a=n.buyNowInitializeOptions,s=n.style,u=n.onComplete,c=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState(),l=(d.getPaymentMethodOrThrow(t).initializationData||{}).isHostedCheckoutEnabled,p={createOrder:function(){return i.paypalCommerceIntegrationService.createOrder("paypalcommerce")},onApprove:function(e){var n=e.orderID;return i.paypalCommerceIntegrationService.tokenizePayment(t,n)}},h={onClick:function(){return i.handleClick(a)},onCancel:function(){return i.paymentIntegrationService.loadDefaultCheckout()}},f=(null===(r=d.getStoreConfig())||void 0===r?void 0:r.checkoutSettings.features["PAYPAL-4387.paypal_shipping_callbacks"])?{onShippingAddressChange:function(e){return i.onShippingAddressChange(e)},onShippingOptionsChange:function(e){return i.onShippingOptionsChange(e)}}:{onShippingChange:function(e){return i.onShippingChange(e)}},g=(0,o.__assign)((0,o.__assign)({},f),{onApprove:function(e,n){return i.onHostedCheckoutApprove(e,n,t,u)}}),m=(0,o.__assign)((0,o.__assign)((0,o.__assign)({fundingSource:c.FUNDING.PAYPAL,style:this.paypalCommerceIntegrationService.getValidButtonStyle(s)},p),a&&h),l&&g),_=c.Buttons(m);_.isEligible()?_.render("#"+e):this.paypalCommerceIntegrationService.removeElement(e)},e.prototype.handleClick=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e?[4,this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e)]:[3,3];case 1:return t=n.sent(),[4,this.paymentIntegrationService.loadCheckout(t.id)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e.prototype.onHostedCheckoutApprove=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!e.orderID)throw new Wa(Ya.MissingOrderId);return i=this.paymentIntegrationService.getState(),a=i.getCartOrThrow(),[4,t.order.get()];case 1:s=o.sent(),o.label=2;case 2:return o.trys.push([2,9,,10]),u=this.paypalCommerceIntegrationService.getBillingAddressFromOrderDetails(s),[4,this.paymentIntegrationService.updateBillingAddress(u)];case 3:return o.sent(),a.lineItems.physicalItems.length>0?(c=this.paypalCommerceIntegrationService.getShippingAddressFromOrderDetails(s),[4,this.paymentIntegrationService.updateShippingAddress(c)]):[3,6];case 4:return o.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:o.sent(),o.label=6;case 6:return[4,this.paymentIntegrationService.submitOrder({},{params:{methodId:n}})];case 7:return o.sent(),[4,this.paypalCommerceIntegrationService.submitPayment(n,e.orderID)];case 8:return o.sent(),r&&"function"==typeof r&&r(),[2,!0];case 9:throw d=o.sent(),new Error(d);case 10:return[2]}}))}))},e.prototype.onShippingAddressChange=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:t=this.paypalCommerceIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state}),i.label=1;case 1:return i.trys.push([1,6,,7]),[4,this.paymentIntegrationService.updateBillingAddress(t)];case 2:return i.sent(),[4,this.paymentIntegrationService.updateShippingAddress(t)];case 3:return i.sent(),n=this.paypalCommerceIntegrationService.getShippingOptionOrThrow(),[4,this.paymentIntegrationService.selectShippingOption(n.id)];case 4:return i.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:return i.sent(),[3,7];case 6:throw r=i.sent(),new Error(r);case 7:return[2]}}))}))},e.prototype.onShippingOptionsChange=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:t=this.paypalCommerceIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id),r.label=1;case 1:return r.trys.push([1,4,,5]),[4,this.paymentIntegrationService.selectShippingOption(t.id)];case 2:return r.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 3:return r.sent(),[3,5];case 4:throw n=r.sent(),new Error(n);case 5:return[2]}}))}))},e.prototype.onShippingChange=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:n=this.paypalCommerceIntegrationService.getAddress({city:e.shipping_address.city,countryCode:e.shipping_address.country_code,postalCode:e.shipping_address.postal_code,stateOrProvinceCode:e.shipping_address.state}),o.label=1;case 1:return o.trys.push([1,6,,7]),[4,this.paymentIntegrationService.updateBillingAddress(n)];case 2:return o.sent(),[4,this.paymentIntegrationService.updateShippingAddress(n)];case 3:return o.sent(),r=this.paypalCommerceIntegrationService.getShippingOptionOrThrow(null===(t=e.selected_shipping_option)||void 0===t?void 0:t.id),[4,this.paymentIntegrationService.selectShippingOption(r.id)];case 4:return o.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:return o.sent(),[3,7];case 6:throw i=o.sent(),new Error(i);case 7:return[2]}}))}))},e}();const Sc=Cc,Ic=cs((function(e){return new Sc(e,vc(e))}),[{id:"paypalcommerce"}]);var wc=function(){function e(e){this.scriptLoader=e,this.window=window}return e.prototype.getPayPalFastlaneSdk=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return this.window.paypalFastlaneSdk?[3,2]:(r=this.getPayPalFastlaneSdkConfiguration(e,t,n),[4,this.loadPayPalSdk(r)]);case 1:if(i.sent(),!this.window.paypalFastlaneSdk)throw new Ko;i.label=2;case 2:return[2,this.window.paypalFastlaneSdk]}}))}))},e.prototype.getPayPalApmsSdk=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return this.window.paypalApms?[3,2]:(n=this.getPayPalApmSdkConfiguration(e,t),[4,this.loadPayPalSdk(n)]);case 1:if(r.sent(),!this.window.paypalApms)throw new Ko;r.label=2;case 2:return[2,this.window.paypalApms]}}))}))},e.prototype.getPayPalMessages=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return this.window.paypalMessages?[3,2]:(n=this.getPayPalSdkMessagesConfiguration(e,t),[4,this.loadPayPalSdk(n)]);case 1:if(r.sent(),!this.window.paypalMessages)throw new Ko;r.label=2;case 2:return[2,this.window.paypalMessages]}}))}))},e.prototype.loadPayPalSdk=function(e){var t=e.options,n=e.attributes;return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return e=this.transformConfig(t),r=this.transformConfig(n),i=new URLSearchParams(e).toString(),a="https://www.paypal.com/sdk/js?"+i,[4,this.scriptLoader.loadScript(a,{async:!0,attributes:r})];case 1:return o.sent(),[2]}}))}))},e.prototype.getPayPalFastlaneSdkConfiguration=function(e,t,n){var r=e.clientToken,i=e.initializationData;if(!i||!i.clientId)throw new Wa(Ya.MissingPaymentMethod);var o=i.intent,a=i.clientId,s=i.merchantId,u=i.attributionId,c=i.connectClientToken;return{options:{"client-id":a,"merchant-id":s,commit:!0,components:["fastlane"],currency:t,intent:o},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":u,"data-user-id-token":c||r}}},e.prototype.getPayPalApmSdkConfiguration=function(e,t){var n=e.initializationData;if(!n||!n.clientId)throw new Wa(Ya.MissingPaymentMethod);var r=n.intent,i=n.clientId,a=n.merchantId,s=n.buyerCountry,u=n.attributionId,c=n.isDeveloperModeApplicable,d=n.availableAlternativePaymentMethods,l=void 0===d?[]:d,p=n.enabledAlternativePaymentMethods,h=void 0===p?[]:p,f=h,g=l.filter((function(e){return!h.includes(e)}));return{options:(0,o.__assign)({"client-id":i,"merchant-id":a,"enable-funding":f.length>0?f:void 0,"disable-funding":g.length>0?g:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:r},c&&{"buyer-country":s}),attributes:{"data-partner-attribution-id":u,"data-namespace":"paypalApms"}}},e.prototype.getPayPalSdkMessagesConfiguration=function(e,t){var n=e.initializationData;if(!n||!n.clientId)throw new Wa(Ya.MissingPaymentMethod);var r=n.clientId,i=n.merchantId,a=n.attributionId,s=n.isDeveloperModeApplicable,u=n.buyerCountry;return{options:(0,o.__assign)({"client-id":r,"merchant-id":i,components:["messages"],currency:t},s&&{"buyer-country":u}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}},e.prototype.transformConfig=function(e){var t={};return Object.keys(e).forEach((function(n){var r,i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=Array.isArray(i)?i.join(","):i,r)))})),t},e}();const Ec=wc;var bc=function(){function e(e,t,n){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t,this.paypalCommerceSdk=n}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.paypalcommercecredit,n=e.containerId,r=e.methodId,a=(i=t||{}).buyNowInitializeOptions,s=i.currencyCode,u=i.messagingContainerId,c=!!a,!r)throw new ja('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new ja('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new ja('Unable to initialize payment because "options.paypalcommercecredit" argument is not provided.');if(c&&!s)throw new ja('Unable to initialize payment because "options.paypalcommercecredit.currencyCode" argument is not provided.');if(c&&"function"!=typeof(null==a?void 0:a.getBuyNowCartRequestBody))throw new ja('Unable to initialize payment because "options.paypalcommercecredit.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');return c?[3,2]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return d=this.paymentIntegrationService.getState(),l=c?s:d.getCartOrThrow().currency.code,[4,this.paypalCommerceIntegrationService.loadPayPalSdk(r,l,!1)];case 3:return o.sent(),this.renderButton(n,r,t),l&&u?(p=d.getPaymentMethodOrThrow(r),[4,this.paypalCommerceSdk.getPayPalMessages(p,l)]):[3,5];case 4:h=o.sent(),this.renderMessages(h,u),o.label=5;case 5:return[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r,i=this,a=n.buyNowInitializeOptions,s=n.style,u=n.onComplete,c=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState(),l=(d.getPaymentMethodOrThrow(t).initializationData||{}).isHostedCheckoutEnabled,p={createOrder:function(){return i.paypalCommerceIntegrationService.createOrder("paypalcommercecredit")},onApprove:function(e){var n=e.orderID;return i.paypalCommerceIntegrationService.tokenizePayment(t,n)}},h={onClick:function(){return i.handleClick(a)},onCancel:function(){return i.paymentIntegrationService.loadDefaultCheckout()}},f=(null===(r=d.getStoreConfig())||void 0===r?void 0:r.checkoutSettings.features["PAYPAL-4387.paypal_shipping_callbacks"])?{onShippingAddressChange:function(e){return i.onShippingAddressChange(e)},onShippingOptionsChange:function(e){return i.onShippingOptionsChange(e)}}:{onShippingChange:function(e){return i.onShippingChange(e)}},g=(0,o.__assign)((0,o.__assign)({},f),{onApprove:function(e,n){return i.onHostedCheckoutApprove(e,n,t,u)}}),m=[c.FUNDING.PAYLATER,c.FUNDING.CREDIT],_=!1;m.forEach((function(t){if(!_){var n=(0,o.__assign)((0,o.__assign)((0,o.__assign)({fundingSource:t,style:i.paypalCommerceIntegrationService.getValidButtonStyle(s)},p),a&&h),l&&g),r=c.Buttons(n);r.isEligible()&&(r.render("#"+e),_=!0)}})),_||this.paypalCommerceIntegrationService.removeElement(e)},e.prototype.handleClick=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e?[4,this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e)]:[3,3];case 1:return t=n.sent(),[4,this.paymentIntegrationService.loadCheckout(t.id)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e.prototype.onHostedCheckoutApprove=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!e.orderID)throw new Wa(Ya.MissingOrderId);return i=this.paymentIntegrationService.getState(),a=i.getCartOrThrow(),[4,t.order.get()];case 1:s=o.sent(),o.label=2;case 2:return o.trys.push([2,9,,10]),u=this.paypalCommerceIntegrationService.getBillingAddressFromOrderDetails(s),[4,this.paymentIntegrationService.updateBillingAddress(u)];case 3:return o.sent(),a.lineItems.physicalItems.length>0?(c=this.paypalCommerceIntegrationService.getShippingAddressFromOrderDetails(s),[4,this.paymentIntegrationService.updateShippingAddress(c)]):[3,6];case 4:return o.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:o.sent(),o.label=6;case 6:return[4,this.paymentIntegrationService.submitOrder({},{params:{methodId:n}})];case 7:return o.sent(),[4,this.paypalCommerceIntegrationService.submitPayment(n,e.orderID)];case 8:return o.sent(),r&&"function"==typeof r&&r(),[2,!0];case 9:throw d=o.sent(),new Error(d);case 10:return[2]}}))}))},e.prototype.onShippingAddressChange=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:t=this.paypalCommerceIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state}),i.label=1;case 1:return i.trys.push([1,6,,7]),[4,this.paymentIntegrationService.updateBillingAddress(t)];case 2:return i.sent(),[4,this.paymentIntegrationService.updateShippingAddress(t)];case 3:return i.sent(),n=this.paypalCommerceIntegrationService.getShippingOptionOrThrow(),[4,this.paymentIntegrationService.selectShippingOption(n.id)];case 4:return i.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:return i.sent(),[3,7];case 6:throw r=i.sent(),new Error(r);case 7:return[2]}}))}))},e.prototype.onShippingOptionsChange=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:t=this.paypalCommerceIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id),r.label=1;case 1:return r.trys.push([1,4,,5]),[4,this.paymentIntegrationService.selectShippingOption(t.id)];case 2:return r.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 3:return r.sent(),[3,5];case 4:throw n=r.sent(),new Error(n);case 5:return[2]}}))}))},e.prototype.onShippingChange=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:n=this.paypalCommerceIntegrationService.getAddress({city:e.shipping_address.city,countryCode:e.shipping_address.country_code,postalCode:e.shipping_address.postal_code,stateOrProvinceCode:e.shipping_address.state}),o.label=1;case 1:return o.trys.push([1,6,,7]),[4,this.paymentIntegrationService.updateBillingAddress(n)];case 2:return o.sent(),[4,this.paymentIntegrationService.updateShippingAddress(n)];case 3:return o.sent(),r=this.paypalCommerceIntegrationService.getShippingOptionOrThrow(null===(t=e.selected_shipping_option)||void 0===t?void 0:t.id),[4,this.paymentIntegrationService.selectShippingOption(r.id)];case 4:return o.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:return o.sent(),[3,7];case 6:throw i=o.sent(),new Error(i);case 7:return[2]}}))}))},e.prototype.renderMessages=function(e,t){if(t&&document.getElementById(t)){var n={amount:this.paymentIntegrationService.getState().getCheckoutOrThrow().outstandingBalance,placement:"cart",style:{layout:"text"}};e.Messages(n).render("#"+t)}},e}();const Pc=bc,Ac=cs((function(e){return new Pc(e,vc(e),new Ec((0,ir.createScriptLoader)()))}),[{id:"paypalcommercecredit"}]);var Oc=function(){function e(e,t){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.paypalcommercevenmo,n=e.containerId,r=e.methodId,a=(i=t||{}).buyNowInitializeOptions,s=i.currencyCode,u=!!a,!r)throw new ja('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new ja('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new ja('Unable to initialize payment because "options.paypalcommercevenmo" argument is not provided.');if(u&&!s)throw new ja('Unable to initialize payment because "options.paypalcommercevenmo.currencyCode" argument is not provided.');if(u&&"function"!=typeof(null==a?void 0:a.getBuyNowCartRequestBody))throw new ja('Unable to initialize payment because "options.paypalcommercevenmo.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');return u?[3,2]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return c=u?s:this.paymentIntegrationService.getState().getCartOrThrow().currency.code,[4,this.paypalCommerceIntegrationService.loadPayPalSdk(r,c,!1)];case 3:return o.sent(),this.renderButton(n,r,t),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r=this,i=n.buyNowInitializeOptions,a=n.style,s=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow(),u=s.FUNDING.VENMO,c={createOrder:function(){return r.paypalCommerceIntegrationService.createOrder("paypalcommercevenmo")},onApprove:function(e){var n=e.orderID;return r.paypalCommerceIntegrationService.tokenizePayment(t,n)}},d={onClick:function(){return r.handleClick(i)},onCancel:function(){return r.paymentIntegrationService.loadDefaultCheckout()}},l=(0,o.__assign)((0,o.__assign)({fundingSource:u,style:this.getValidVenmoButtonStyles(a)},c),i&&d),p=s.Buttons(l);p.isEligible()?p.render("#"+e):this.paypalCommerceIntegrationService.removeElement(e)},e.prototype.getValidVenmoButtonStyles=function(e){var t=this.paypalCommerceIntegrationService.getValidButtonStyle(e);return t.color===cc.gold?(0,o.__assign)((0,o.__assign)({},t),{color:void 0}):t},e.prototype.handleClick=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e?[4,this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e)]:[3,3];case 1:return t=n.sent(),[4,this.paymentIntegrationService.loadCheckout(t.id)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e}();const Tc=Oc,Rc=cs((function(e){return new Tc(e,vc(e))}),[{id:"paypalcommercevenmo"}]);var kc=function(){function e(e,t){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.paypalcommercealternativemethods,n=e.containerId,r=e.methodId,a=(i=t||{}).apm,s=i.buyNowInitializeOptions,u=i.currencyCode,c=!!s,!r)throw new ja('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new ja('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new ja('Unable to initialize payment because "options.paypalcommercealternativemethods" argument is not provided.');if(!a)throw new ja('Unable to initialize payment because "options.paypalcommercealternativemethods.apm" argument is not provided.');if(c&&!u)throw new ja('Unable to initialize payment because "options.paypalcommercealternativemethods.currencyCode" argument is not provided.');if(c&&"function"!=typeof(null==s?void 0:s.getBuyNowCartRequestBody))throw new ja('Unable to initialize payment because "options.paypalcommercealternativemethods.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');return c?[3,2]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return d=c?u:this.paymentIntegrationService.getState().getCartOrThrow().currency.code,[4,this.paypalCommerceIntegrationService.loadPayPalSdk(r,d,!1)];case 3:return o.sent(),this.renderButton(n,r,t),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r=this,i=n.apm,a=n.buyNowInitializeOptions,s=n.style,u=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow();if(!Object.values(u.FUNDING).includes(i))throw new ja('Unable to initialize PayPal button because "options.paypalcommercealternativemethods.apm" argument is not valid funding source.');var c={createOrder:function(){return r.paypalCommerceIntegrationService.createOrder("paypalcommercealternativemethod")},onApprove:function(e){var n=e.orderID;return r.paypalCommerceIntegrationService.tokenizePayment(t,n)}},d={onClick:function(){return r.handleClick(a)},onCancel:function(){return r.paymentIntegrationService.loadDefaultCheckout()}},l=(0,o.__assign)((0,o.__assign)({fundingSource:i,style:this.paypalCommerceIntegrationService.getValidButtonStyle(s)},c),a&&d),p=u.Buttons(l);p.isEligible()?p.render("#"+e):this.paypalCommerceIntegrationService.removeElement(e)},e.prototype.handleClick=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e?[4,this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e)]:[3,3];case 1:return t=n.sent(),[4,this.paymentIntegrationService.loadCheckout(t.id)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e}();const Dc=kc,Mc=cs((function(e){return new Dc(e,vc(e))}),[{id:"paypalcommercealternativemethods"}]);var Nc,Lc,zc,Uc,Fc;!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(Nc||(Nc={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(Lc||(Lc={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black"}(zc||(zc={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(Uc||(Uc={})),function(e){e.PILL="pill",e.RECT="rect"}(Fc||(Fc={}));var Bc=function(){function e(e,t,n){this.paymentIntegrationService=e,this.paypalExpressScriptLoader=t,this.formPoster=n}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:if(t=this.paymentIntegrationService.getState(),n=t.getPaymentMethodOrThrow(e.methodId),!e.paypal)throw new ja;if(!n.config.merchantId)throw new Wa(Ya.MissingPaymentMethod);return[4,this.paypalExpressScriptLoader.loadPaypalSDK(n.config.merchantId)];case 1:return r=i.sent(),this.renderButton(e,r),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t){var n,r=this,i=e.containerId,o=e.methodId,a=e.paypal,s=a.allowCredit,u=a.clientId,c=a.onPaymentError,d=a.shouldProcessPayment,l=a.style,p=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!p.config.merchantId)throw new Wa(Ya.MissingPaymentMethod);var h=p.config.merchantId,f=p.config.testMode?"sandbox":"production",g=((n={})[f]=u,n),m=t.FUNDING.CREDIT||"credit",_=s?[m]:[],y=s?[]:[m];return t.Button.render({env:f,client:g,commit:d,funding:{allowed:_,disallowed:y},style:this.getStyle(l),payment:function(e,t){return r.setupPayment(h,t,c)},onAuthorize:function(e,t){return r.tokenizePayment(e,o,t,d)}},i)},e.prototype.getStyle=function(e){var t=e||{},n=t.color,r=t.fundingicons,i=t.label,o=t.layout,a=t.shape,s=t.size,u=t.tagline;return{color:n,fundingicons:r,label:i,layout:o,shape:a||Fc.RECT,size:"small"===s?Lc.RESPONSIVE:s,tagline:u}},e.prototype.setupPayment=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s;return(0,o.__generator)(this,(function(u){switch(u.label){case 0:if(!t)throw new Ja(Qa.CheckoutButtonNotInitialized);u.label=1;case 1:return u.trys.push([1,4,,5]),[4,this.paymentIntegrationService.loadDefaultCheckout()];case 2:return r=u.sent(),i=r.getCartOrThrow().id,a=r.getHost()||"",[4,t.request.post(a+"/api/storefront/payment/paypalexpress",{merchantId:e,cartId:i},{headers:(0,o.__assign)({"X-API-INTERNAL":ms},ys)})];case 3:return[2,u.sent().id];case 4:throw s=u.sent(),n&&n(s),s;case 5:return[2]}}))}))},e.prototype.tokenizePayment=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!n)throw new Ja(Qa.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new Wa(Ya.MissingPayment);return i=this.paymentIntegrationService.getState(),a=i.getPaymentMethodOrThrow(t),[4,n.payment.get(e.paymentID)];case 1:return s=o.sent(),[2,this.formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:a.id,action:r?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(s.payer.payer_info)})]}}))}))},e}();const qc=Bc;var xc=function(){function e(e){this.scriptLoader=e,this.window=window}return e.prototype.loadPaypalSDK=function(e){return void 0===e&&(e=""),(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return t=(0,o.__assign)({async:!0,attributes:{"data-merchant-id":e}},e&&{attributes:{"data-merchant-id":e}}),[4,this.scriptLoader.loadScript("//www.paypalobjects.com/api/checkout.min.js",t)];case 1:if(n.sent(),!this.window.paypal)throw new Ko;return[2,this.window.paypal]}}))}))},e}();const Gc=xc,Vc=cs((function(e){return new qc(e,new Gc((0,ir.getScriptLoader)()),(0,i.createFormPoster)())}),[{id:"paypalexpress"}]);function Hc(e){var t=null!=e?e:{},o=t.host,a=t.locale,s=void 0===a?"en":a,u=Wn({config:{meta:{host:null==e?void 0:e.host,locale:null==e?void 0:e.locale},errors:{},statuses:{}}}),c=(0,r.createRequestSender)({host:o}),d=(0,i.createFormPoster)({host:o}),l=function(e,t){void 0===t&&(t=n);for(var r=new Ha,i=function(t){if(!function(e){return"resolveIds"in e}(t))return"continue";for(var n=0,i=t.resolveIds;n<i.length;n++){var o=i[n];r.register(o,(function(){return t(e)}))}},o=0,a=Object.entries(t);o<a.length;o++)i(a[o][1]);return r}(function(e){var t=e.getState().config,n=t.getHost,i=t.getLocale,o=(0,r.createRequestSender)({host:n()}),a=new Lo(ko),s=new gr(new Sr(o),new br(new Ar(o)),new Nr(new zr(o))),u=new Er(new Sr(o)),c=new Ci(e),d=new Ii(new Pi(o),new Er(new Sr(o))),l=new ur(new lr(o),new bo(new Ao(o))),p=new so(new lo(o),new Sr(o)),h=new Jn(new rr(o)),f=new Oi(new Ti(function(e){var t=(0,Ri.createClient)();return e.subscribe((function(e){var n=e.config.getStoreConfig();n&&t.setHost(n.paymentSettings.bigpayBaseUrl)}),(function(e){return e.config.getStoreConfig()})),t}(e)),d,new Xi,new ei(si((0,ir.createScriptLoader)()))),g=new ei(si((0,ir.createScriptLoader)())),m=new Rr(new Dr(o),s,new mo(si((0,ir.createScriptLoader)()),new yo(o))),_=new Co(new Io(o)),y=si((0,ir.createScriptLoader)()),v=new yo(o),C=new mo(y,v),S=new hr(o),I=new $i,w=new po(new fo(o,{locale:i()}),e),E=new no(new io(o),s),b=new eo;return new Mo(e,a,s,u,c,d,l,p,h,f,g,m,S,_,C,I,w,E,b)}(u));return new Yo(u,new Wo(function(e,t,n,r,i){var o=new ra,a=(0,ir.getScriptLoader)(),s=new Sr(t),u=new gr(s,new br(new Ar(t)),new Nr(new zr(t))),c=new pa(new ta(a,window)),d=new hr(t);return o.register(Bi.BRAINTREE_PAYPAL,(function(){return new Ea(e,u,d,c,n,window)})),o.register(Bi.BRAINTREE_PAYPAL_CREDIT,(function(){return new ka(e,u,d,c,n,window)})),o.register(Bi.MASTERPASS,(function(){return new Na(e,u,new ga(a),r)})),o.register(Bi.PAYPALEXPRESS,(function(){return new za(e,u,new ma(a),n,i)})),o}(u,c,d,s,o),l,new Jn(new rr(c))))}module.exports=t})();
|
|
1
|
+
(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{createCheckoutButtonInitializer:()=>Hc,createTimeout:()=>r.createTimeout});var n={};e.r(n),e.d(n,{createAmazonPayV2ButtonStrategy:()=>Cs,createApplePayButtonStrategy:()=>zs,createBoltButtonStrategy:()=>Ys,createBraintreeVenmoButtonStrategy:()=>tu,createBraintreeVisaCheckoutButtonStrategy:()=>Zs,createGooglePayAdyenV2ButtonStrategy:()=>Mu,createGooglePayAdyenV3ButtonStrategy:()=>Nu,createGooglePayAuthorizeDotNetButtonStrategy:()=>Uu,createGooglePayBraintreeButtonStrategy:()=>Au,createGooglePayCheckoutComButtonStrategy:()=>Gu,createGooglePayCybersourceButtonStrategy:()=>ju,createGooglePayOrbitalButtonStrategy:()=>Ku,createGooglePayPayPalCommerceButtonStrategy:()=>Du,createGooglePayStripeButtonStrategy:()=>Ju,createGooglePayTdOnlineMartButtonStrategy:()=>ic,createGooglePayWorldpayAccessButtonStrategy:()=>ec,createPayPalCommerceAlternativeMethodsButtonStrategy:()=>Mc,createPayPalCommerceButtonStrategy:()=>Ic,createPayPalCommerceCreditButtonStrategy:()=>Ac,createPayPalCommerceVenmoButtonStrategy:()=>Rc,createPaypalExpressButtonStrategy:()=>Vc});const r=require("@bigcommerce/request-sender"),i=require("@bigcommerce/form-poster"),o=require("tslib"),a=require("@bigcommerce/data-store"),s=function(e){function t(t){var n,r,i=this.constructor,o=e.call(this,t||"An unexpected error has occurred.")||this;return o.name="StandardError",o.type="standard",n=o,r=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(o,i):o.stack=new Error(o.message).stack,o}return(0,o.__extends)(t,e),t}(Error);var u={body:{},headers:{},status:0},c=function(e){function t(t,n){var r=void 0===n?{}:n,i=r.message,o=r.errors,a=this,s=t||u,c=s.body,d=s.headers,l=s.status;return(a=e.call(this,i||"An unexpected error has occurred.")||this).name="RequestError",a.type="request",a.body=c,a.headers=d,a.status=l,a.errors=o||[],a}return(0,o.__extends)(t,e),t}(s);const d=c,l=function(e){function t(t){var n=e.call(this,t,{message:"There is a problem processing your payment. Please try again later."})||this;return n.name="PaymentMethodInvalidError",n.type="payment_method_invalid",n}return(0,o.__extends)(t,e),t}(d);const p=function(e){function t(t){var n,r,i=this.constructor,o=e.call(this,t||"An unexpected error has occurred.")||this;return o.name="StandardError",o.type="standard",n=o,r=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(o,i):o.stack=new Error(o.message).stack,o}return(0,o.__extends)(t,e),t}(Error);var h={body:{},headers:{},status:0},f=function(e){function t(t,n){var r=void 0===n?{}:n,i=r.message,o=r.errors,a=this,s=t||h,u=s.body,c=s.headers,d=s.status;return(a=e.call(this,i||"An unexpected error has occurred.")||this).name="RequestError",a.type="request",a.body=u,a.headers=c,a.status=d,a.errors=o||[],a}return(0,o.__extends)(t,e),t}(p);const g=f,m=function(e){function t(t,n){var r=e.call(this,t,{message:n||"An unexpected error has occurred. The checkout process cannot continue as a result."})||this;return r.name="UnrecoverableError",r.type="unrecoverable",r}return(0,o.__extends)(t,e),t}(g),_=require("lodash");function y(e){return e.reduce((function(e,t){return t?(0,o.__spreadArrays)(e,[t]):e}),[]).join(" ")}function v(e,t){var n=e.body.errors,r=void 0===n?[]:n;return new g(e,{message:C(r)||t,errors:r})}function C(e){if(Array.isArray(e))return e.reduce((function(e,t){return t&&t.message?(0,o.__spreadArrays)(e,[t.message]):e}),[]).join(" ")}const S=function(e){function t(t){var n=e.call(this,t,{message:"The request has timed out or aborted."})||this;return n.name="TimeoutError",n.type="timeout",n}return(0,o.__extends)(t,e),t}(g);var I=function(){function e(){this._factoryMethods={},this.register("default",(function(e,t){return new g(e,{message:t})})),this.register("internal",(function(e,t){return function(e,t){var n=e.body,r=n.errors,i=void 0===r?[]:r;return new g(e,{message:y(i)||n.detail||n.title||t,errors:i.length?i.map((function(e){return{code:n.type,message:e}})):[{code:n.type,message:n.detail||n.title}]})}(e,t)})),this.register("storefront",(function(e,t){return function(e,t){var n=e.body;return new g(e,{message:t||n.detail||n.title,errors:[{code:n.code||n.type,message:n.detail||n.title}]})}(e,t)})),this.register("payment",(function(e,t){return v(e,t)})),this.register("timeout",(function(e){return new S(e)}))}return e.prototype.register=function(e,t){this._factoryMethods[e]=t},e.prototype.createError=function(e,t){return(this._factoryMethods[this._getType(e)]||this._factoryMethods.default)(e,t)},e.prototype._getType=function(e){if(0===e.status)return"timeout";if(this._isStorefrontErrorResponseBody(e.body))return"storefront";if(this._isInternalErrorResponseBody(e.body)){var t=(0,_.last)(e.body.type.split("/"));return t&&this._factoryMethods[t]?t:"internal"}var n=(0,_.last)(e.body&&e.body.errors);return n&&n.code&&this._factoryMethods[n.code]?n.code:"payment"},e.prototype._isStorefrontErrorResponseBody=function(e){var t=e;return!this._isInternalErrorResponseBody(e)&&"string"==typeof t.title&&"string"==typeof t.type&&"number"==typeof t.status&&"string"==typeof t.detail},e.prototype._isInternalErrorResponseBody=function(e){var t=e;return"object"==typeof t.errors&&"string"==typeof t.title&&"string"==typeof t.type&&"number"==typeof t.status},e}();const w=I,E=require("rxjs"),b=require("rxjs/operators");var P,A,O,T;function R(e,t){return Array.isArray(e)?e.map((function(e){return R(e,t)})):(0,_.isPlainObject)(e)?(0,_.transform)((0,_.omitBy)(e,t),(function(e,n,r){e[r]=R(n,t)}),{}):e}function k(e,t){return function(e){return e.type===A.ClearError}(t)?R(e,(function(e){return e===t.payload})):e}function D(e,t,n){return e===t||(e&&t&&"object"==typeof e&&"object"==typeof t?Array.isArray(e)&&Array.isArray(t)?function(e,t,n){if(e.length!==t.length)return!1;for(var r=0,i=e.length;r<i;r++)if(!D(e[r],t[r],n))return!1;return!0}(e,t,n):!Array.isArray(e)&&!Array.isArray(t)&&(e instanceof Date&&t instanceof Date?function(e,t){return e.getTime()===t.getTime()}(e,t):!(e instanceof Date||t instanceof Date)&&(e instanceof RegExp&&t instanceof RegExp?function(e,t){return e.toString()===t.toString()}(e,t):!(e instanceof RegExp||t instanceof RegExp)&&function(e,t,n){var r=n&&n.keyFilter,i=r?Object.keys(e).filter(r):Object.keys(e),o=r?Object.keys(t).filter(r):Object.keys(t);if(i.length!==o.length)return!1;for(var a=0,s=i.length;a<s;a++){var u=i[a];if(!Object.prototype.hasOwnProperty.call(t,u))return!1;if(!D(e[u],t[u],n))return!1}return!0}(e,t,n))):e===t)}function M(e,t){return void 0===t||D(e,t)?e:t}function N(e,t,n){var r;return e&&Object.prototype.hasOwnProperty.call(e,t)&&D(e[t],n)?e:(0,o.__assign)((0,o.__assign)({},e),((r={})[t]=n,r))}!function(e){e.LoadCheckoutRequested="LOAD_CHECKOUT_REQUESTED",e.LoadCheckoutSucceeded="LOAD_CHECKOUT_SUCCEEDED",e.LoadCheckoutFailed="LOAD_CHECKOUT_FAILED",e.UpdateCheckoutRequested="UPDATE_CHECKOUT_REQUESTED",e.UpdateCheckoutSucceeded="UPDATE_CHECKOUT_SUCCEEDED",e.UpdateCheckoutFailed="UPDATE_CHECKOUT_FAILED"}(P||(P={})),function(e){e.ClearError="CLEAR_ERROR"}(A||(A={})),function(e){e.UpdateSubscriptionsRequested="UPDATE_SUBSCRIPTIONS_REQUESTED",e.UpdateSubscriptionsSucceeded="UPDATE_SUBSCRIPTIONS_SUCCEEDED",e.UpdateSubscriptionsFailed="UPDATE_SUBSCRIPTIONS_FAILED"}(O||(O={})),function(e){e.UpdateBillingAddressRequested="UPDATE_BILLING_ADDRESS_REQUESTED",e.UpdateBillingAddressSucceeded="UPDATE_BILLING_ADDRESS_SUCCEEDED",e.UpdateBillingAddressFailed="UPDATE_BILLING_ADDRESS_FAILED",e.ContinueAsGuestRequested="CONTINUE_AS_GUEST_REQUESTED",e.ContinueAsGuestSucceeded="CONTINUE_AS_GUEST_SUCCEEDED",e.ContinueAsGuestFailed="CONTINUE_AS_GUEST_FAILED"}(T||(T={}));var L={errors:{},statuses:{}};function z(e,t){return void 0===e&&(e=L),(0,a.combineReducers)({data:U,errors:(0,a.composeReducers)(F,k),statuses:B})(e,t)}function U(e,t){switch(t.type){case T.UpdateBillingAddressSucceeded:case T.ContinueAsGuestSucceeded:case P.LoadCheckoutSucceeded:return M(e,t.payload&&t.payload.billingAddress);default:return e}}function F(e,t){switch(void 0===e&&(e=L.errors),t.type){case P.LoadCheckoutRequested:case P.LoadCheckoutSucceeded:return N(e,"loadError",void 0);case P.LoadCheckoutFailed:return N(e,"loadError",t.payload);case T.UpdateBillingAddressRequested:case T.UpdateBillingAddressSucceeded:return N(e,"updateError",void 0);case T.UpdateBillingAddressFailed:return N(e,"updateError",t.payload);case O.UpdateSubscriptionsRequested:case O.UpdateSubscriptionsSucceeded:case T.ContinueAsGuestRequested:case T.ContinueAsGuestSucceeded:return N(e,"continueAsGuestError",void 0);case O.UpdateSubscriptionsFailed:case T.ContinueAsGuestFailed:return N(e,"continueAsGuestError",t.payload);default:return e}}function B(e,t){switch(void 0===e&&(e=L.statuses),t.type){case P.LoadCheckoutRequested:return N(e,"isLoading",!0);case P.LoadCheckoutSucceeded:case P.LoadCheckoutFailed:return N(e,"isLoading",!1);case T.UpdateBillingAddressRequested:return N(e,"isUpdating",!0);case T.UpdateBillingAddressFailed:case T.UpdateBillingAddressSucceeded:return N(e,"isUpdating",!1);case T.ContinueAsGuestRequested:case O.UpdateSubscriptionsRequested:return N(e,"isContinuingAsGuest",!0);case O.UpdateSubscriptionsSucceeded:case O.UpdateSubscriptionsFailed:case T.ContinueAsGuestFailed:case T.ContinueAsGuestSucceeded:return N(e,"isContinuingAsGuest",!1);default:return e}}function q(e){return(0,_.isPlainObject)(e)}const x=function e(t,n,r){var i=(r||{}).matchObject,o=void 0===i?function(e,t){return void 0!==e.id&&e.id===t.id}:i;if(!t)return n;if(!n||t===n)return t;var a=0,s=0,u=function(e,t,n){return a+=e===t?1:0,s+=e===n?1:0,e},c=n.map((function(n,r){var i=t&&t[r];return q(i)&&q(n)?o(i,n)?u(G(i,n),i,n):u(M(i,n),i,n):(0,_.isArray)(i)&&(0,_.isArray)(n)?u(e(i,n),i,n):u(M(i,n),i,n)}));return a===n.length&&t&&t.length===n.length?t:s===n.length?n:c},G=function e(t,n){return t?n&&t!==n?Object.keys(n).reduce((function(t,r){var i=t[r],o=n[r];return q(i)&&q(o)?N(t,r,e(i,o)):(0,_.isArray)(i)&&(0,_.isArray)(o)?N(t,r,x(i,o)):N(t,r,o)}),t):t:n};var V,H,j;!function(e){e.ApplyCouponRequested="APPLY_COUPON_REQUESTED",e.ApplyCouponSucceeded="APPLY_COUPON_SUCCEEDED",e.ApplyCouponFailed="APPLY_COUPON_FAILED",e.RemoveCouponRequested="REMOVE_COUPON_REQUESTED",e.RemoveCouponSucceeded="REMOVE_COUPON_SUCCEEDED",e.RemoveCouponFailed="REMOVE_COUPON_FAILED"}(V||(V={})),function(e){e.ApplyGiftCertificateRequested="APPLY_GIFT_CERTIFICATE_REQUESTED",e.ApplyGiftCertificateSucceeded="APPLY_GIFT_CERTIFICATE_SUCCEEDED",e.ApplyGiftCertificateFailed="APPLY_GIFT_CERTIFICATE_FAILED",e.RemoveGiftCertificateRequested="REMOVE_GIFT_CERTIFICATE_REQUESTED",e.RemoveGiftCertificateSucceeded="REMOVE_GIFT_CERTIFICATE_SUCCEEDED",e.RemoveGiftCertificateFailed="REMOVE_GIFT_CERTIFICATE_FAILED"}(H||(H={})),function(e){e.CreateConsignmentsRequested="CREATE_CONSIGNMENTS_REQUESTED",e.CreateConsignmentsSucceeded="CREATE_CONSIGNMENTS_SUCCEEDED",e.CreateConsignmentsFailed="CREATE_CONSIGNMENTS_FAILED",e.UpdateConsignmentRequested="UPDATE_CONSIGNMENT_REQUESTED",e.UpdateConsignmentSucceeded="UPDATE_CONSIGNMENT_SUCCEEDED",e.UpdateConsignmentFailed="UPDATE_CONSIGNMENT_FAILED",e.DeleteConsignmentRequested="DELETE_CONSIGNMENT_REQUESTED",e.DeleteConsignmentSucceeded="DELETE_CONSIGNMENT_SUCCEEDED",e.DeleteConsignmentFailed="DELETE_CONSIGNMENT_FAILED",e.UpdateShippingOptionRequested="UPDATE_SHIPPING_OPTION_REQUESTED",e.UpdateShippingOptionSucceeded="UPDATE_SHIPPING_OPTION_SUCCEEDED",e.UpdateShippingOptionFailed="UPDATE_SHIPPING_OPTION_FAILED",e.LoadShippingOptionsRequested="LOAD_SHIPPING_OPTIONS_REQUESTED",e.LoadShippingOptionsSucceeded="LOAD_SHIPPING_OPTIONS_SUCCEEDED",e.LoadShippingOptionsFailed="LOAD_SHIPPING_OPTIONS_FAILED"}(j||(j={}));var Y,W={errors:{},statuses:{}};function K(e,t){return void 0===e&&(e=W),(0,a.combineReducers)({data:Z,errors:(0,a.composeReducers)(J,k),statuses:Q})(e,t)}function Z(e,t){switch(t.type){case T.UpdateBillingAddressSucceeded:case P.LoadCheckoutSucceeded:case j.CreateConsignmentsSucceeded:case j.DeleteConsignmentSucceeded:case j.UpdateConsignmentSucceeded:case j.UpdateShippingOptionSucceeded:case j.LoadShippingOptionsSucceeded:case V.ApplyCouponSucceeded:case V.RemoveCouponSucceeded:case H.ApplyGiftCertificateSucceeded:case H.RemoveGiftCertificateSucceeded:return G(e,t.payload&&t.payload.cart);default:return e}}function Q(e,t){switch(void 0===e&&(e=W.statuses),t.type){case P.LoadCheckoutRequested:return N(e,"isLoading",!0);case P.LoadCheckoutFailed:case P.LoadCheckoutSucceeded:return N(e,"isLoading",!1);default:return e}}function J(e,t){switch(void 0===e&&(e=W.errors),t.type){case P.LoadCheckoutRequested:case P.LoadCheckoutSucceeded:return N(e,"loadError",void 0);case P.LoadCheckoutFailed:return N(e,"loadError",t.payload);default:return e}}!function(e){e.InitializeButtonFailed="INITIALIZE_BUTTON_FAILED",e.InitializeButtonRequested="INITIALIZE_BUTTON_REQUESTED",e.InitializeButtonSucceeded="INITIALIZE_BUTTON_SUCCEEDED",e.DeinitializeButtonFailed="DEINITIALIZE_BUTTON_FAILED",e.DeinitializeButtonRequested="DEINITIALIZE_BUTTON_REQUESTED",e.DeinitializeButtonSucceeded="DEINITIALIZE_BUTTON_SUCCEEDED"}(Y||(Y={}));var X,$={data:{},errors:{},statuses:{}},ee={initializedContainers:{}},te={},ne={};function re(e,t){var n,r,i;return void 0===e&&(e=$),t.meta&&t.meta.methodId?(0,a.combineReducers)({data:(0,a.combineReducers)((n={},n[t.meta.methodId]=ie,n)),errors:(0,a.combineReducers)((r={},r[t.meta.methodId]=oe,r)),statuses:(0,a.combineReducers)((i={},i[t.meta.methodId]=ae,i))})(e,t):e}function ie(e,t){var n;switch(void 0===e&&(e=ee),t.type){case Y.InitializeButtonSucceeded:return t.meta&&t.meta.containerId?G(e,{initializedContainers:(n={},n[t.meta.containerId]=!0,n)}):e;case Y.DeinitializeButtonSucceeded:return N(e,"initializedContainers",{})}return e}function oe(e,t){switch(void 0===e&&(e=te),t.type){case Y.InitializeButtonRequested:case Y.InitializeButtonSucceeded:return N(e,"initializeError",void 0);case Y.InitializeButtonFailed:return N(e,"initializeError",t.payload);case Y.DeinitializeButtonRequested:case Y.DeinitializeButtonSucceeded:return N(e,"deinitializeError",void 0);case Y.DeinitializeButtonFailed:return N(e,"deinitializeError",t.payload);default:return e}}function ae(e,t){switch(void 0===e&&(e=ne),t.type){case Y.InitializeButtonRequested:return N(e,"isInitializing",!0);case Y.InitializeButtonFailed:case Y.InitializeButtonSucceeded:return N(e,"isInitializing",!1);case Y.DeinitializeButtonRequested:return N(e,"isDeinitializing",!0);case Y.DeinitializeButtonFailed:case Y.DeinitializeButtonSucceeded:return N(e,"isDeinitializing",!1);default:return e}}!function(e){e.LoadConfigRequested="LOAD_CONFIG_REQUESTED",e.LoadConfigSucceeded="LOAD_CONFIG_SUCCEEDED",e.LoadConfigFailed="LOAD_CONFIG_FAILED"}(X||(X={}));var se,ue={meta:{},errors:{},statuses:{}};function ce(e,t){return void 0===e&&(e=ue),(0,a.combineReducers)({data:de,errors:(0,a.composeReducers)(le,k),statuses:pe})(e,t)}function de(e,t){return t.type===X.LoadConfigSucceeded?G(e,t.payload):e}function le(e,t){switch(void 0===e&&(e=ue.errors),t.type){case X.LoadConfigSucceeded:return N(e,"loadError",void 0);case X.LoadConfigFailed:return N(e,"loadError",t.payload);default:return e}}function pe(e,t){switch(void 0===e&&(e=ue.statuses),t.type){case X.LoadConfigRequested:return N(e,"isLoading",!0);case X.LoadConfigSucceeded:case X.LoadConfigFailed:return N(e,"isLoading",!1);default:return e}}!function(e){e.LoadOrderRequested="LOAD_ORDER_REQUESTED",e.LoadOrderSucceeded="LOAD_ORDER_SUCCEEDED",e.LoadOrderFailed="LOAD_ORDER_FAILED",e.LoadOrderPaymentsRequested="LOAD_ORDER_PAYMENTS_REQUESTED",e.LoadOrderPaymentsSucceeded="LOAD_ORDER_PAYMENTS_SUCCEEDED",e.LoadOrderPaymentsFailed="LOAD_ORDER_PAYMENTS_FAILED",e.SubmitOrderRequested="SUBMIT_ORDER_REQUESTED",e.SubmitOrderSucceeded="SUBMIT_ORDER_SUCCEEDED",e.SubmitOrderFailed="SUBMIT_ORDER_FAILED",e.FinalizeOrderRequested="FINALIZE_ORDER_REQUESTED",e.FinalizeOrderSucceeded="FINALIZE_ORDER_SUCCEEDED",e.FinalizeOrderFailed="FINALIZE_ORDER_FAILED"}(se||(se={}));var he={errors:{},statuses:{}};function fe(e,t){return void 0===e&&(e=he),(0,a.combineReducers)({data:ge,errors:(0,a.composeReducers)(me,k),statuses:_e})(e,t)}function ge(e,t){switch(t.type){case P.LoadCheckoutSucceeded:case V.ApplyCouponSucceeded:case j.UpdateShippingOptionSucceeded:case V.RemoveCouponSucceeded:case se.LoadOrderSucceeded:return x(e,t.payload&&t.payload.coupons);default:return e}}function me(e,t){switch(void 0===e&&(e={}),t.type){case V.ApplyCouponRequested:case V.ApplyCouponSucceeded:return N(e,"applyCouponError",void 0);case V.ApplyCouponFailed:return N(e,"applyCouponError",t.payload);case V.RemoveCouponRequested:case V.RemoveCouponSucceeded:return N(e,"removeCouponError",void 0);case V.RemoveCouponFailed:return N(e,"removeCouponError",t.payload);default:return e}}function _e(e,t){switch(void 0===e&&(e={}),t.type){case V.ApplyCouponRequested:return N(e,"isApplyingCoupon",!0);case V.ApplyCouponSucceeded:case V.ApplyCouponFailed:return N(e,"isApplyingCoupon",!1);case V.RemoveCouponRequested:return N(e,"isRemovingCoupon",!0);case V.RemoveCouponSucceeded:case V.RemoveCouponFailed:return N(e,"isRemovingCoupon",!1);default:return e}}var ye,ve={errors:{},statuses:{}};function Ce(e,t){return void 0===e&&(e=ve),(0,a.combineReducers)({data:Se,errors:(0,a.composeReducers)(Ie,k),statuses:we})(e,t)}function Se(e,t){switch(t.type){case P.LoadCheckoutSucceeded:case j.CreateConsignmentsSucceeded:case j.UpdateConsignmentSucceeded:case j.DeleteConsignmentSucceeded:case j.UpdateShippingOptionSucceeded:case V.ApplyCouponSucceeded:case V.RemoveCouponSucceeded:case H.ApplyGiftCertificateSucceeded:case H.RemoveGiftCertificateSucceeded:return x(e,t.payload&&t.payload.giftCertificates);default:return e}}function Ie(e,t){switch(void 0===e&&(e=ve.errors),t.type){case H.ApplyGiftCertificateRequested:case H.ApplyGiftCertificateSucceeded:return N(e,"applyGiftCertificateError",void 0);case H.ApplyGiftCertificateFailed:return N(e,"applyGiftCertificateError",t.payload);case H.RemoveGiftCertificateRequested:case H.RemoveGiftCertificateSucceeded:return N(e,"removeGiftCertificateError",void 0);case H.RemoveGiftCertificateFailed:return N(e,"removeGiftCertificateError",t.payload);default:return e}}function we(e,t){switch(void 0===e&&(e=ve.statuses),t.type){case H.ApplyGiftCertificateRequested:return N(e,"isApplyingGiftCertificate",!0);case H.ApplyGiftCertificateSucceeded:case H.ApplyGiftCertificateFailed:return N(e,"isApplyingGiftCertificate",!1);case H.RemoveGiftCertificateRequested:return N(e,"isRemovingGiftCertificate",!0);case H.RemoveGiftCertificateSucceeded:case H.RemoveGiftCertificateFailed:return N(e,"isRemovingGiftCertificate",!1);default:return e}}!function(e){e.SignInCustomerRequested="SIGN_IN_CUSTOMER_REQUESTED",e.SignInCustomerSucceeded="SIGN_IN_CUSTOMER_SUCCEEDED",e.SignInCustomerFailed="SIGN_IN_CUSTOMER_FAILED",e.SignOutCustomerRequested="SIGN_OUT_CUSTOMER_REQUESTED",e.SignOutCustomerSucceeded="SIGN_OUT_CUSTOMER_SUCCEEDED",e.SignOutCustomerFailed="SIGN_OUT_CUSTOMER_FAILED",e.CreateCustomerRequested="CREATE_CUSTOMER_REQUESTED",e.CreateCustomerSucceeded="CREATE_CUSTOMER_SUCCEEDED",e.CreateCustomerFailed="CREATE_CUSTOMER_FAILED",e.CreateCustomerAddressRequested="CREATE_CUSTOMER_ADDRESS_REQUESTED",e.CreateCustomerAddressSucceeded="CREATE_CUSTOMER_ADDRESS_SUCCEEDED",e.CreateCustomerAddressFailed="CREATE_CUSTOMER_ADDRESS_FAILED",e.StripeLinkAuthenticated="STRIPE_LINK_AUTHENTICATED"}(ye||(ye={}));var Ee,be={errors:{},statuses:{}};function Pe(e,t){return void 0===e&&(e=be),(0,a.combineReducers)({data:Ae,errors:(0,a.composeReducers)(Oe,k),statuses:Te})(e,t)}function Ae(e,t){switch(t.type){case T.ContinueAsGuestSucceeded:case P.LoadCheckoutSucceeded:return G(e,t.payload&&t.payload.customer);case ye.CreateCustomerAddressSucceeded:return G(e,t.payload);default:return e}}function Oe(e,t){switch(void 0===e&&(e=be.errors),t.type){case ye.CreateCustomerRequested:case ye.CreateCustomerSucceeded:return N(e,"createError",void 0);case ye.CreateCustomerFailed:return N(e,"createError",t.payload);case ye.CreateCustomerAddressRequested:case ye.CreateCustomerAddressSucceeded:return N(e,"createAddressError",void 0);case ye.CreateCustomerAddressFailed:return N(e,"createAddressError",t.payload);default:return e}}function Te(e,t){switch(void 0===e&&(e=be.statuses),t.type){case ye.CreateCustomerRequested:return N(e,"isCreating",!0);case ye.CreateCustomerFailed:case ye.CreateCustomerSucceeded:return N(e,"isCreating",!1);case ye.CreateCustomerAddressRequested:return N(e,"isCreatingAddress",!0);case ye.CreateCustomerAddressFailed:case ye.CreateCustomerAddressSucceeded:return N(e,"isCreatingAddress",!1);default:return e}}!function(e){e.SignInFailed="CUSTOMER_STRATEGY_SIGN_IN_FAILED",e.SignInRequested="CUSTOMER_STRATEGY_SIGN_IN_REQUESTED",e.SignInSucceeded="CUSTOMER_STRATEGY_SIGN_IN_SUCCEEDED",e.SignOutFailed="CUSTOMER_STRATEGY_SIGN_OUT_FAILED",e.SignOutRequested="CUSTOMER_STRATEGY_SIGN_OUT_REQUESTED",e.SignOutSucceeded="CUSTOMER_STRATEGY_SIGN_OUT_SUCCEEDED",e.ExecutePaymentMethodCheckoutFailed="CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_FAILED",e.ExecutePaymentMethodCheckoutRequested="CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_REQUESTED",e.ExecutePaymentMethodCheckoutSucceeded="CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_SUCCEEDED",e.InitializeFailed="CUSTOMER_STRATEGY_INITIALIZE_FAILED",e.InitializeRequested="CUSTOMER_STRATEGY_INITIALIZE_REQUESTED",e.InitializeSucceeded="CUSTOMER_STRATEGY_INITIALIZE_SUCCEEDED",e.DeinitializeFailed="CUSTOMER_STRATEGY_DEINITIALIZE_FAILED",e.DeinitializeRequested="CUSTOMER_STRATEGY_DEINITIALIZE_REQUESTED",e.DeinitializeSucceeded="CUSTOMER_STRATEGY_DEINITIALIZE_SUCCEEDED",e.WidgetInteractionStarted="CUSTOMER_STRATEGY_WIDGET_INTERACTION_STARTED",e.WidgetInteractionFinished="CUSTOMER_STRATEGY_WIDGET_INTERACTION_FINISHED",e.WidgetInteractionFailed="CUSTOMER_STRATEGY_WIDGET_INTERACTION_FAILED"}(Ee||(Ee={}));var Re,ke={data:{},errors:{},statuses:{}};function De(e,t){return void 0===e&&(e=ke),(0,a.combineReducers)({data:Me,errors:(0,a.composeReducers)(Ne,k),statuses:Le})(e,t)}function Me(e,t){var n,r;switch(void 0===e&&(e=ke.data),t.type){case Ee.InitializeSucceeded:return G(e,((n={})[t.meta&&t.meta.methodId]={isInitialized:!0},n));case Ee.DeinitializeSucceeded:return G(e,((r={})[t.meta&&t.meta.methodId]={isInitialized:!1},r))}return e}function Ne(e,t){var n;switch(void 0===e&&(e=ke.errors),t.type){case Ee.InitializeRequested:case Ee.InitializeSucceeded:return G(e,{initializeErrors:(0,o.__assign)({},e.initializeErrors),initializeMethodId:e.initializeMethodId?e.initializeMethodId:void 0});case Ee.InitializeFailed:return G(e,{initializeErrors:(0,o.__assign)((0,o.__assign)({},e.initializeErrors),(n={},n[t.meta&&t.meta.methodId]=t.payload,n)),initializeMethodId:t.meta&&t.meta.methodId});case Ee.DeinitializeRequested:case Ee.DeinitializeSucceeded:return G(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case Ee.DeinitializeFailed:return G(e,{deinitializeError:t.payload,deinitializeMethodId:t.meta&&t.meta.methodId});case Ee.SignInRequested:case Ee.SignInSucceeded:return G(e,{signInError:void 0,signInMethodId:void 0});case Ee.SignInFailed:return G(e,{signInError:t.payload,signInMethodId:t.meta&&t.meta.methodId});case Ee.SignOutRequested:case Ee.SignOutSucceeded:return G(e,{signOutError:void 0,signOutMethodId:void 0});case Ee.SignOutFailed:return G(e,{signOutError:t.payload,signOutMethodId:t.meta&&t.meta.methodId});case Ee.ExecutePaymentMethodCheckoutRequested:case Ee.ExecutePaymentMethodCheckoutSucceeded:return G(e,{executePaymentMethodCheckoutError:void 0,executePaymentMethodCheckoutMethodId:void 0});case Ee.ExecutePaymentMethodCheckoutFailed:return G(e,{executePaymentMethodCheckoutError:t.payload,executePaymentMethodCheckoutMethodId:t.meta&&t.meta.methodId});case Ee.WidgetInteractionStarted:case Ee.WidgetInteractionFinished:return G(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case Ee.WidgetInteractionFailed:return G(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta.methodId});default:return e}}function Le(e,t){switch(void 0===e&&(e=ke.statuses),t.type){case Ee.InitializeRequested:return G(e,{isInitializing:!0,initializeMethodId:t.meta&&t.meta.methodId});case Ee.InitializeFailed:case Ee.InitializeSucceeded:return G(e,{isInitializing:!1,initializeMethodId:void 0});case Ee.DeinitializeRequested:return G(e,{isDeinitializing:!0,deinitializeMethodId:t.meta&&t.meta.methodId});case Ee.DeinitializeFailed:case Ee.DeinitializeSucceeded:return G(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case Ee.SignInRequested:return G(e,{isSigningIn:!0,signInMethodId:t.meta&&t.meta.methodId});case Ee.SignInFailed:case Ee.SignInSucceeded:return G(e,{isSigningIn:!1,signInMethodId:void 0});case Ee.SignOutRequested:return G(e,{isSigningOut:!0,signOutMethodId:t.meta&&t.meta.methodId});case Ee.SignOutFailed:case Ee.SignOutSucceeded:return G(e,{isSigningOut:!1,signOutMethodId:void 0});case Ee.ExecutePaymentMethodCheckoutRequested:return G(e,{isExecutingPaymentMethodCheckout:!0,executePaymentMethodCheckoutMethodId:t.meta&&t.meta.methodId});case Ee.ExecutePaymentMethodCheckoutFailed:case Ee.ExecutePaymentMethodCheckoutSucceeded:return G(e,{isExecutingPaymentMethodCheckout:!1,executePaymentMethodCheckoutMethodId:void 0});case Ee.WidgetInteractionStarted:return G(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta.methodId});case Ee.WidgetInteractionFinished:case Ee.WidgetInteractionFailed:return G(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}!function(e){e.LoadExtensionsRequested="LOAD_EXTENSIONS_REQUESTED",e.LoadExtensionsSucceeded="LOAD_EXTENSIONS_SUCCEEDED",e.LoadExtensionsFailed="LOAD_EXTENSIONS_FAILED",e.RenderExtensionRequested="RENDER_EXTENSION_REQUESTED",e.RenderExtensionSucceeded="RENDER_EXTENSION_SUCCEEDED",e.RenderExtensionFailed="RENDER_EXTENSION_FAILED"}(Re||(Re={}));var ze,Ue={errors:{},statuses:{}};function Fe(e,t){return void 0===e&&(e=Ue),(0,a.combineReducers)({data:Be,errors:(0,a.composeReducers)(qe,k),statuses:xe})(e,t)}function Be(e,t){return t.type===Re.LoadExtensionsSucceeded?x(e,t.payload):e}function qe(e,t){switch(void 0===e&&(e=Ue.errors),t.type){case Re.LoadExtensionsRequested:case Re.LoadExtensionsSucceeded:return N(e,"loadError",void 0);case Re.RenderExtensionRequested:case Re.RenderExtensionSucceeded:return N(e,"renderError",void 0);case Re.LoadExtensionsFailed:return N(e,"loadError",t.payload);case Re.RenderExtensionFailed:return N(e,"renderError",t.payload);default:return e}}function xe(e,t){switch(void 0===e&&(e=Ue.statuses),t.type){case Re.LoadExtensionsRequested:return N(e,"isLoading",!0);case Re.LoadExtensionsSucceeded:case Re.LoadExtensionsFailed:return N(e,"isLoading",!1);default:return e}}!function(e){e.LoadFormFieldsRequested="LOAD_FORM_FIELDS_REQUESTED",e.LoadFormFieldsSucceeded="LOAD_FORM_FIELDS_SUCCEEDED",e.LoadFormFieldsFailed="LOAD_FORM_FIELDS_FAILED"}(ze||(ze={}));var Ge,Ve={errors:{},statuses:{}};function He(e,t){return void 0===e&&(e=Ve),(0,a.combineReducers)({data:je,errors:(0,a.composeReducers)(Ye,k),statuses:We})(e,t)}function je(e,t){return t.type===ze.LoadFormFieldsSucceeded?G(e,t.payload):e}function Ye(e,t){switch(void 0===e&&(e=Ve.errors),t.type){case ze.LoadFormFieldsSucceeded:return N(e,"loadError",void 0);case ze.LoadFormFieldsFailed:return N(e,"loadError",t.payload);default:return e}}function We(e,t){switch(void 0===e&&(e=Ve.statuses),t.type){case ze.LoadFormFieldsRequested:return N(e,"isLoading",!0);case ze.LoadFormFieldsSucceeded:case ze.LoadFormFieldsFailed:return N(e,"isLoading",!1);default:return e}}!function(e){e.LoadCountriesRequested="LOAD_COUNTRIES_REQUESTED",e.LoadCountriesSucceeded="LOAD_COUNTRIES_SUCCEEDED",e.LoadCountriesFailed="LOAD_COUNTRIES_FAILED"}(Ge||(Ge={}));var Ke={errors:{},statuses:{}};function Ze(e,t){return void 0===e&&(e=Ke),(0,a.combineReducers)({data:Qe,errors:(0,a.composeReducers)(Je,k),statuses:Xe})(e,t)}function Qe(e,t){return t.type===Ge.LoadCountriesSucceeded?x(e,t.payload):e}function Je(e,t){switch(void 0===e&&(e=Ke.errors),t.type){case Ge.LoadCountriesRequested:case Ge.LoadCountriesSucceeded:return N(e,"loadError",void 0);case Ge.LoadCountriesFailed:return N(e,"loadError",t.payload);default:return e}}function Xe(e,t){switch(void 0===e&&(e=Ke.statuses),t.type){case Ge.LoadCountriesRequested:return N(e,"isLoading",!0);case Ge.LoadCountriesSucceeded:case Ge.LoadCountriesFailed:return N(e,"isLoading",!1);default:return e}}var $e={errors:{},meta:{},statuses:{}};function et(e,t){return void 0===e&&(e=$e),(0,a.combineReducers)({data:tt,errors:(0,a.composeReducers)(rt,k),meta:nt,statuses:it})(e,t)}function tt(e,t){switch(t.type){case se.LoadOrderSucceeded:case se.LoadOrderPaymentsSucceeded:return G(e,(0,_.omit)(t.payload,["billingAddress","coupons"]));default:return e}}function nt(e,t){switch(t.type){case se.FinalizeOrderSucceeded:case se.SubmitOrderSucceeded:return G(e,(0,o.__assign)((0,o.__assign)({},t.meta),{callbackUrl:t.payload&&t.payload.order.callbackUrl,orderToken:t.payload&&t.payload.order.token,payment:t.payload&&t.payload.order&&t.payload.order.payment}));default:return e}}function rt(e,t){switch(void 0===e&&(e=$e.errors),t.type){case se.LoadOrderRequested:case se.LoadOrderSucceeded:case se.LoadOrderPaymentsSucceeded:case se.LoadOrderPaymentsRequested:return N(e,"loadError",void 0);case se.LoadOrderFailed:case se.LoadOrderPaymentsFailed:return N(e,"loadError",t.payload);default:return e}}function it(e,t){switch(void 0===e&&(e=$e.statuses),t.type){case se.LoadOrderRequested:case se.LoadOrderPaymentsRequested:return N(e,"isLoading",!0);case se.LoadOrderSucceeded:case se.LoadOrderFailed:case se.LoadOrderPaymentsSucceeded:case se.LoadOrderPaymentsFailed:return N(e,"isLoading",!1);default:return e}}var ot,at,st={};function ut(e,t){return void 0===e&&(e=st),(0,a.combineReducers)({data:ct})(e,t)}function ct(e,t){switch(t.type){case se.LoadOrderPaymentsSucceeded:case se.LoadOrderSucceeded:return M(e,t.payload&&t.payload.billingAddress);default:return e}}function dt(e,t){return void 0===e&&(e={}),(0,a.combineReducers)({data:lt})(e,t)}function lt(e,t){return t.type===ot.SubmitPaymentSucceeded?t.payload:e}!function(e){e.SubmitPaymentRequested="SUBMIT_PAYMENT_REQUESTED",e.SubmitPaymentSucceeded="SUBMIT_PAYMENT_SUCCEEDED",e.SubmitPaymentFailed="SUBMIT_PAYMENT_FAILED",e.InitializeOffsitePaymentRequested="INITIALIZE_OFFSITE_PAYMENT_REQUESTED",e.InitializeOffsitePaymentSucceeded="INITIALIZE_OFFSITE_PAYMENT_SUCCEEDED",e.InitializeOffsitePaymentFailed="INITIALIZE_OFFSITE_PAYMENT_FAILED"}(ot||(ot={})),function(e){e.LoadPaymentMethodRequested="LOAD_PAYMENT_METHOD_REQUESTED",e.LoadPaymentMethodSucceeded="LOAD_PAYMENT_METHOD_SUCCEEDED",e.LoadPaymentMethodFailed="LOAD_PAYMENT_METHOD_FAILED",e.LoadPaymentMethodsRequested="LOAD_PAYMENT_METHODS_REQUESTED",e.LoadPaymentMethodsSucceeded="LOAD_PAYMENT_METHODS_SUCCEEDED",e.LoadPaymentMethodsFailed="LOAD_PAYMENT_METHODS_FAILED"}(at||(at={}));var pt,ht={errors:{},statuses:{}};function ft(e,t){return void 0===e&&(e=ht),(0,a.combineReducers)({data:gt,errors:(0,a.composeReducers)(_t,k),meta:mt,statuses:yt})(e,t)}function gt(e,t){switch(t.type){case at.LoadPaymentMethodSucceeded:return function(e,t,n){if(!t)return e;var r=(0,_.pick)(t,"id"),i=(0,_.findIndex)(e,"object"==typeof n?(0,_.pickBy)(n):n||r),a=(0,o.__spreadArrays)(e);if(-1===i)a.push(t);else{var s=e[i];a[i]=q(s)&&q(t)?G(s,t):t}return a}(e||[],t.payload,t.payload&&{id:t.payload.id,gateway:t.payload.gateway});case at.LoadPaymentMethodsSucceeded:return x(e,t.payload,{matchObject:function(e,t){return e.id===t.id&&e.gateway===t.gateway}});default:return e}}function mt(e,t){return t.type===at.LoadPaymentMethodsSucceeded?G(e,t.meta):e}function _t(e,t){switch(void 0===e&&(e=ht.errors),t.type){case at.LoadPaymentMethodsRequested:case at.LoadPaymentMethodsSucceeded:return N(e,"loadError",void 0);case at.LoadPaymentMethodsFailed:return N(e,"loadError",t.payload);case at.LoadPaymentMethodRequested:case at.LoadPaymentMethodSucceeded:return G(e,{loadMethodId:void 0,loadMethodError:void 0});case at.LoadPaymentMethodFailed:return G(e,{loadMethodId:t.meta.methodId,loadMethodError:t.payload});default:return e}}function yt(e,t){switch(void 0===e&&(e=ht.statuses),t.type){case at.LoadPaymentMethodsRequested:return N(e,"isLoading",!0);case at.LoadPaymentMethodsSucceeded:case at.LoadPaymentMethodsFailed:return N(e,"isLoading",!1);case at.LoadPaymentMethodRequested:return G(e,{isLoadingMethod:!0,loadMethodId:t.meta.methodId});case at.LoadPaymentMethodSucceeded:case at.LoadPaymentMethodFailed:return G(e,{isLoadingMethod:!1,loadMethodId:void 0});default:return e}}!function(e){e.ExecuteFailed="PAYMENT_STRATEGY_EXECUTE_FAILED",e.ExecuteRequested="PAYMENT_STRATEGY_EXECUTE_REQUESTED",e.ExecuteSucceeded="PAYMENT_STRATEGY_EXECUTE_SUCCEEDED",e.FinalizeFailed="PAYMENT_STRATEGY_FINALIZE_FAILED",e.FinalizeRequested="PAYMENT_STRATEGY_FINALIZE_REQUESTED",e.FinalizeSucceeded="PAYMENT_STRATEGY_FINALIZE_SUCCEEDED",e.InitializeFailed="PAYMENT_STRATEGY_INITIALIZE_FAILED",e.InitializeRequested="PAYMENT_STRATEGY_INITIALIZE_REQUESTED",e.InitializeSucceeded="PAYMENT_STRATEGY_INITIALIZE_SUCCEEDED",e.DeinitializeFailed="PAYMENT_STRATEGY_DEINITIALIZE_FAILED",e.DeinitializeRequested="PAYMENT_STRATEGY_DEINITIALIZE_REQUESTED",e.DeinitializeSucceeded="PAYMENT_STRATEGY_DEINITIALIZE_SUCCEEDED",e.WidgetInteractionStarted="PAYMENT_STRATEGY_WIDGET_INTERACTION_STARTED",e.WidgetInteractionFinished="PAYMENT_STRATEGY_WIDGET_INTERACTION_FINISHED",e.WidgetInteractionFailed="PAYMENT_STRATEGY_WIDGET_INTERACTION_FAILED"}(pt||(pt={}));var vt,Ct={data:{},errors:{},statuses:{}};function St(e,t){return void 0===e&&(e=Ct),(0,a.combineReducers)({data:It,errors:(0,a.composeReducers)(wt,k),statuses:Et})(e,t)}function It(e,t){var n,r;switch(void 0===e&&(e=Ct.data),t.type){case pt.InitializeSucceeded:if(t.meta){var i=t.meta,o=i.methodId,a=i.gatewayId;return G(e,((n={})[a?o+"."+a:o]={isInitialized:!0},n))}break;case pt.DeinitializeSucceeded:if(t.meta){var s=t.meta;return o=s.methodId,a=s.gatewayId,G(e,((r={})[a?o+"."+a:o]={isInitialized:!1},r))}}return e}function wt(e,t){switch(void 0===e&&(e=Ct.errors),t.type){case pt.InitializeRequested:case pt.InitializeSucceeded:return G(e,{initializeError:void 0,initializeMethodId:void 0});case pt.InitializeFailed:var n=t.meta&&t.meta.methodId;if(t.meta){var r=t.meta,i=r.methodId;n=(a=r.gatewayId)?i+"."+a:i}return G(e,{initializeError:t.payload,initializeMethodId:n});case pt.DeinitializeRequested:case pt.DeinitializeSucceeded:return G(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case pt.DeinitializeFailed:var o=t.meta&&t.meta.methodId;if(t.meta){var a,s=t.meta;i=s.methodId,o=(a=s.gatewayId)?i+"."+a:i}return G(e,{deinitializeError:t.payload,deinitializeMethodId:o});case pt.ExecuteRequested:case pt.ExecuteSucceeded:return G(e,{executeError:void 0,executeMethodId:void 0});case pt.ExecuteFailed:return G(e,{executeError:t.payload,executeMethodId:t.meta&&t.meta.methodId});case pt.FinalizeRequested:case pt.FinalizeSucceeded:return G(e,{finalizeError:void 0,finalizeMethodId:void 0});case pt.FinalizeFailed:return G(e,{finalizeError:t.payload,finalizeMethodId:t.meta&&t.meta.methodId});case pt.WidgetInteractionStarted:case pt.WidgetInteractionFinished:return G(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case pt.WidgetInteractionFailed:return G(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta.methodId});default:return e}}function Et(e,t){switch(void 0===e&&(e=Ct.statuses),t.type){case pt.InitializeRequested:var n=t.meta&&t.meta.methodId;if(t.meta){var r=t.meta,i=r.methodId;n=(a=r.gatewayId)?i+"."+a:i}return G(e,{isInitializing:!0,initializeMethodId:n});case pt.InitializeFailed:case pt.InitializeSucceeded:return G(e,{isInitializing:!1,initializeMethodId:void 0});case pt.DeinitializeRequested:var o=t.meta&&t.meta.methodId;if(t.meta){var a,s=t.meta;i=s.methodId,o=(a=s.gatewayId)?i+"."+a:i}return G(e,{isDeinitializing:!0,deinitializeMethodId:o});case pt.DeinitializeFailed:case pt.DeinitializeSucceeded:return G(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case pt.ExecuteRequested:return G(e,{isExecuting:!0,executeMethodId:t.meta&&t.meta.methodId});case pt.ExecuteFailed:case pt.ExecuteSucceeded:return G(e,{isExecuting:!1,executeMethodId:void 0});case pt.FinalizeRequested:return G(e,{isFinalizing:!0,finalizeMethodId:t.meta&&t.meta.methodId});case pt.FinalizeFailed:case pt.FinalizeSucceeded:return G(e,{isFinalizing:!1,finalizeMethodId:void 0});case pt.WidgetInteractionStarted:return G(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta.methodId});case pt.WidgetInteractionFinished:case pt.WidgetInteractionFailed:return G(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}!function(e){e.UpdatePaymentProviderCustomer="UPDATE_PAYMENT_PROVIDER_CUSTOMER"}(vt||(vt={}));var bt,Pt={data:{}};function At(e,t){return void 0===e&&(e=Pt),(0,a.combineReducers)({data:Ot})(e,t)}function Ot(e,t){return void 0===e&&(e=Pt.data),t.type===vt.UpdatePaymentProviderCustomer?G(e,t.payload):e}!function(e){e.LoadInstrumentsRequested="LOAD_INSTRUMENTS_REQUESTED",e.LoadInstrumentsSucceeded="LOAD_INSTRUMENTS_SUCCEEDED",e.LoadInstrumentsFailed="LOAD_INSTRUMENTS_FAILED",e.DeleteInstrumentRequested="DELETE_INSTRUMENT_REQUESTED",e.DeleteInstrumentSucceeded="DELETE_INSTRUMENT_SUCCEEDED",e.DeleteInstrumentFailed="DELETE_INSTRUMENT_FAILED"}(bt||(bt={}));var Tt,Rt={data:[],errors:{},statuses:{}};function kt(e,t){return void 0===e&&(e=Rt),(0,a.combineReducers)({data:Dt,errors:(0,a.composeReducers)(Nt,k),meta:Mt,statuses:Lt})(e,t)}function Dt(e,t){return void 0===e&&(e=Rt.data),t.type===bt.LoadInstrumentsSucceeded?x(e,t.payload&&t.payload.vaultedInstruments||[]):e}function Mt(e,t){switch(t.type){case bt.LoadInstrumentsSucceeded:case bt.DeleteInstrumentSucceeded:return G(e,t.meta);default:return e}}function Nt(e,t){switch(void 0===e&&(e=Rt.errors),t.type){case bt.LoadInstrumentsRequested:case bt.LoadInstrumentsSucceeded:return N(e,"loadError",void 0);case bt.DeleteInstrumentRequested:case bt.DeleteInstrumentSucceeded:return G(e,{deleteError:void 0,failedInstrument:void 0});case bt.LoadInstrumentsFailed:return N(e,"loadError",t.payload);case bt.DeleteInstrumentFailed:return G(e,{deleteError:t.payload,failedInstrument:t.meta.instrumentId});default:return e}}function Lt(e,t){switch(void 0===e&&(e=Rt.statuses),t.type){case bt.LoadInstrumentsRequested:return N(e,"isLoading",!0);case bt.DeleteInstrumentRequested:return G(e,{isDeleting:!0,deletingInstrument:t.meta.instrumentId});case bt.LoadInstrumentsSucceeded:case bt.LoadInstrumentsFailed:return N(e,"isLoading",!1);case bt.DeleteInstrumentSucceeded:case bt.DeleteInstrumentFailed:return G(e,{isDeleting:!1,deletingInstrument:void 0});default:return e}}!function(e){e.ForgetCheckoutRemoteCustomerRequested="FORGET_CHECKOUT_REMOTE_CUSTOMER_REQUESTED",e.ForgetCheckoutRemoteCustomerSucceeded="FORGET_CHECKOUT_REMOTE_CUSTOMER_SUCCEEDED",e.ForgetCheckoutRemoteCustomerFailed="FORGET_CHECKOUT_REMOTE_CUSTOMER_FAILED",e.InitializeRemoteBillingRequested="INITIALIZE_REMOTE_BILLING_REQUESTED",e.InitializeRemoteBillingSucceeded="INITIALIZE_REMOTE_BILLING_SUCCEEDED",e.InitializeRemoteBillingFailed="INITIALIZE_REMOTE_BILLING_FAILED",e.InitializeRemoteShippingRequested="INITIALIZE_REMOTE_SHIPPING_REQUESTED",e.InitializeRemoteShippingSucceeded="INITIALIZE_REMOTE_SHIPPING_SUCCEEDED",e.InitializeRemoteShippingFailed="INITIALIZE_REMOTE_SHIPPING_FAILED",e.InitializeRemotePaymentRequested="INITIALIZE_REMOTE_PAYMENT_REQUESTED",e.InitializeRemotePaymentSucceeded="INITIALIZE_REMOTE_PAYMENT_SUCCEEDED",e.InitializeRemotePaymentFailed="INITIALIZE_REMOTE_PAYMENT_FAILED",e.LoadRemoteSettingsRequested="LOAD_REMOTE_SETTINGS_REQUESTED",e.LoadRemoteSettingsSucceeded="LOAD_REMOTE_SETTINGS_SUCCEEDED",e.LoadRemoteSettingsFailed="LOAD_REMOTE_SETTINGS_FAILED",e.SignOutRemoteCustomerRequested="SIGN_OUT_REMOTE_CUSTOMER_REQUESTED",e.SignOutRemoteCustomerSucceeded="SIGN_OUT_REMOTE_CUSTOMER_SUCCEEDED",e.SignOutRemoteCustomerFailed="SIGN_OUT_REMOTE_CUSTOMER_FAILED",e.UpdateRemoteCheckout="UPDATE_REMOTE_CHECKOUT"}(Tt||(Tt={}));var zt={data:{}};function Ut(e,t){var n;return void 0===e&&(e=zt),t.meta&&t.meta.methodId?(0,a.combineReducers)({data:(0,a.combineReducers)((n={},n[t.meta.methodId]=Ft,n))})(e,t):e}function Ft(e,t){switch(t.type){case Tt.InitializeRemoteBillingSucceeded:return N(e,"billing",t.payload&&t.payload.billing);case Tt.InitializeRemoteShippingSucceeded:return N(e,"shipping",t.payload&&t.payload.shipping);case Tt.LoadRemoteSettingsSucceeded:return N(e,"settings",t.payload);case Tt.UpdateRemoteCheckout:return G(e,t.payload);default:return e}}var Bt,qt={errors:{updateShippingOptionError:{},updateError:{},deleteError:{}},statuses:{isUpdating:{},isUpdatingShippingOption:{},isDeleting:{}}};function xt(e,t){return void 0===e&&(e=qt),(0,a.combineReducers)({data:Gt,errors:(0,a.composeReducers)(Vt,k),statuses:Ht})(e,t)}function Gt(e,t){switch(t.type){case P.LoadCheckoutSucceeded:case j.LoadShippingOptionsSucceeded:case j.CreateConsignmentsSucceeded:case j.UpdateConsignmentSucceeded:case j.DeleteConsignmentSucceeded:case j.UpdateShippingOptionSucceeded:case V.ApplyCouponSucceeded:case V.RemoveCouponSucceeded:return x(e,t.payload&&t.payload.consignments);case ye.SignOutCustomerSucceeded:return x(e,[]);default:return e}}function Vt(e,t){var n,r,i,o,a,s;switch(void 0===e&&(e=qt.errors),t.type){case P.LoadCheckoutRequested:case P.LoadCheckoutSucceeded:case j.LoadShippingOptionsSucceeded:case j.LoadShippingOptionsRequested:return N(e,"loadError",void 0);case P.LoadCheckoutFailed:case j.LoadShippingOptionsFailed:return N(e,"loadError",t.payload);case j.CreateConsignmentsRequested:case j.CreateConsignmentsSucceeded:return N(e,"createError",void 0);case j.CreateConsignmentsFailed:return N(e,"createError",t.payload);case j.UpdateConsignmentSucceeded:case j.UpdateConsignmentRequested:return t.meta?G(e,{updateError:(n={},n[t.meta.id]=void 0,n)}):e;case j.UpdateConsignmentFailed:return t.meta?G(e,{updateError:(r={},r[t.meta.id]=t.payload,r)}):e;case j.DeleteConsignmentSucceeded:case j.DeleteConsignmentRequested:return t.meta?G(e,{deleteError:(i={},i[t.meta.id]=void 0,i)}):e;case j.DeleteConsignmentFailed:return t.meta?G(e,{deleteError:(o={},o[t.meta.id]=t.payload,o)}):e;case j.UpdateShippingOptionRequested:case j.UpdateShippingOptionSucceeded:return t.meta?G(e,{updateShippingOptionError:(a={},a[t.meta.id]=void 0,a)}):e;case j.UpdateShippingOptionFailed:return t.meta?G(e,{updateShippingOptionError:(s={},s[t.meta.id]=t.payload,s)}):e;default:return e}}function Ht(e,t){var n,r,i,o,a,s;switch(void 0===e&&(e=qt.statuses),t.type){case P.LoadCheckoutRequested:return N(e,"isLoading",!0);case j.LoadShippingOptionsRequested:return N(e,"isLoadingShippingOptions",!0);case P.LoadCheckoutSucceeded:case P.LoadCheckoutFailed:return N(e,"isLoading",!1);case j.LoadShippingOptionsSucceeded:case j.LoadShippingOptionsFailed:return N(e,"isLoadingShippingOptions",!1);case j.CreateConsignmentsRequested:return N(e,"isCreating",!0);case j.CreateConsignmentsSucceeded:case j.CreateConsignmentsFailed:return N(e,"isCreating",!1);case j.UpdateConsignmentRequested:return t.meta?G(e,{isUpdating:(n={},n[t.meta.id]=!0,n)}):e;case j.UpdateConsignmentSucceeded:case j.UpdateConsignmentFailed:return t.meta?G(e,{isUpdating:(r={},r[t.meta.id]=!1,r)}):e;case j.DeleteConsignmentRequested:return t.meta?G(e,{isDeleting:(i={},i[t.meta.id]=!0,i)}):e;case j.DeleteConsignmentSucceeded:case j.DeleteConsignmentFailed:return t.meta?G(e,{isDeleting:(o={},o[t.meta.id]=!1,o)}):e;case j.UpdateShippingOptionRequested:return t.meta?G(e,{isUpdatingShippingOption:(a={},a[t.meta.id]=!0,a)}):e;case j.UpdateShippingOptionSucceeded:case j.UpdateShippingOptionFailed:return t.meta?G(e,{isUpdatingShippingOption:(s={},s[t.meta.id]=!1,s)}):e;default:return e}}function jt(e,t){var n={};return Object.keys(e).forEach((function(r){var i=e[r],o=t?t+"."+r:r;"object"==typeof i?Object.assign(n,jt(i,o)):n[o]=i})),n}function Yt(e){var t=Object.keys(e).sort().reduce((function(t,n){var r;return(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=e[n],r))}),{});return t}!function(e){e.LoadPickupOptionsRequested="LOAD_PICKUP_OPTIONS_REQUESTED",e.LoadPickupOptionsSucceeded="LOAD_PICKUP_OPTIONS_SUCCEEDED",e.LoadPickupOptionsFailed="LOAD_PICKUP_OPTIONS_FAILED"}(Bt||(Bt={}));var Wt,Kt={errors:{},statuses:{}};function Zt(e,t){return void 0===e&&(e=Kt),(0,a.combineReducers)({data:Qt,errors:(0,a.composeReducers)(Jt,k),statuses:Xt})(e,t)}function Qt(e,t){if(t.type!==Bt.LoadPickupOptionsSucceeded)return e;if(t.meta){var n=Yt(jt({consignmentId:t.meta.consignmentId,searchArea:t.meta.searchArea}));return N(e,btoa(""+JSON.stringify(n)),t.payload)}}function Jt(e,t){switch(void 0===e&&(e=Kt.errors),t.type){case Bt.LoadPickupOptionsRequested:case Bt.LoadPickupOptionsSucceeded:return N(e,"loadError",void 0);case Bt.LoadPickupOptionsFailed:return N(e,"loadError",t.payload);default:return e}}function Xt(e,t){switch(void 0===e&&(e=Kt.statuses),t.type){case Bt.LoadPickupOptionsRequested:return N(e,"isLoading",!0);case Bt.LoadPickupOptionsSucceeded:case Bt.LoadPickupOptionsFailed:return N(e,"isLoading",!1);default:return e}}!function(e){e.LoadShippingCountriesRequested="LOAD_SHIPPING_COUNTRIES_REQUESTED",e.LoadShippingCountriesSucceeded="LOAD_SHIPPING_COUNTRIES_SUCCEEDED",e.LoadShippingCountriesFailed="LOAD_SHIPPING_COUNTRIES_FAILED"}(Wt||(Wt={}));var $t,en={errors:{},statuses:{}};function tn(e,t){return void 0===e&&(e=en),(0,a.combineReducers)({data:nn,errors:(0,a.composeReducers)(rn,k),statuses:on})(e,t)}function nn(e,t){return t.type===Wt.LoadShippingCountriesSucceeded?x(e,t.payload):e}function rn(e,t){switch(void 0===e&&(e=en.errors),t.type){case Wt.LoadShippingCountriesRequested:case Wt.LoadShippingCountriesSucceeded:return N(e,"loadError",void 0);case Wt.LoadShippingCountriesFailed:return N(e,"loadError",t.payload);default:return e}}function on(e,t){switch(void 0===e&&(e=en.statuses),t.type){case Wt.LoadShippingCountriesRequested:return N(e,"isLoading",!0);case Wt.LoadShippingCountriesSucceeded:case Wt.LoadShippingCountriesFailed:return N(e,"isLoading",!1);default:return e}}!function(e){e.UpdateAddressFailed="SHIPPING_STRATEGY_UPDATE_ADDRESS_FAILED",e.UpdateAddressRequested="SHIPPING_STRATEGY_UPDATE_ADDRESS_REQUESTED",e.UpdateAddressSucceeded="SHIPPING_STRATEGY_UPDATE_ADDRESS_SUCCEEDED",e.SelectOptionFailed="SHIPPING_STRATEGY_SELECT_OPTION_FAILED",e.SelectOptionRequested="SHIPPING_STRATEGY_SELECT_OPTION_REQUESTED",e.SelectOptionSucceeded="SHIPPING_STRATEGY_SELECT_OPTION_SUCCEEDED",e.InitializeFailed="SHIPPING_STRATEGY_INITIALIZE_FAILED",e.InitializeRequested="SHIPPING_STRATEGY_INITIALIZE_REQUESTED",e.InitializeSucceeded="SHIPPING_STRATEGY_INITIALIZE_SUCCEEDED",e.DeinitializeFailed="SHIPPING_STRATEGY_DEINITIALIZE_FAILED",e.DeinitializeRequested="SHIPPING_STRATEGY_DEINITIALIZE_REQUESTED",e.DeinitializeSucceeded="SHIPPING_STRATEGY_DEINITIALIZE_SUCCEEDED",e.WidgetInteractionStarted="SHIPPING_STRATEGY_WIDGET_INTERACTION_STARTED",e.WidgetInteractionFinished="SHIPPING_STRATEGY_WIDGET_INTERACTION_FINISHED",e.WidgetInteractionFailed="SHIPPING_STRATEGY_WIDGET_INTERACTION_FAILED"}($t||($t={}));var an,sn={data:{},errors:{},statuses:{}};function un(e,t){return void 0===e&&(e=sn),(0,a.combineReducers)({data:cn,errors:(0,a.composeReducers)(dn,k),statuses:ln})(e,t)}function cn(e,t){var n,r;switch(void 0===e&&(e=sn.data),t.type){case $t.InitializeSucceeded:return G(e,((n={})[t.meta&&t.meta.methodId]={isInitialized:!0},n));case $t.DeinitializeSucceeded:return G(e,((r={})[t.meta&&t.meta.methodId]={isInitialized:!1},r))}return e}function dn(e,t){switch(void 0===e&&(e=sn.errors),t.type){case $t.InitializeRequested:case $t.InitializeSucceeded:return G(e,{initializeError:void 0,initializeMethodId:void 0});case $t.InitializeFailed:return G(e,{initializeError:t.payload,initializeMethodId:t.meta&&t.meta.methodId});case $t.DeinitializeRequested:case $t.DeinitializeSucceeded:return G(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case $t.DeinitializeFailed:return G(e,{deinitializeError:t.payload,deinitializeMethodId:t.meta&&t.meta.methodId});case $t.UpdateAddressRequested:case $t.UpdateAddressSucceeded:return G(e,{updateAddressError:void 0,updateAddressMethodId:void 0});case $t.UpdateAddressFailed:return G(e,{updateAddressError:t.payload,updateAddressMethodId:t.meta&&t.meta.methodId});case $t.SelectOptionRequested:case $t.SelectOptionSucceeded:return G(e,{selectOptionError:void 0,selectOptionMethodId:void 0});case $t.SelectOptionFailed:return G(e,{selectOptionError:t.payload,selectOptionMethodId:t.meta&&t.meta.methodId});case $t.WidgetInteractionStarted:case $t.WidgetInteractionFinished:return G(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case $t.WidgetInteractionFailed:return G(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta&&t.meta.methodId});default:return e}}function ln(e,t){switch(void 0===e&&(e=sn.statuses),t.type){case $t.InitializeRequested:return G(e,{isInitializing:!0,initializeMethodId:t.meta&&t.meta.methodId});case $t.InitializeFailed:case $t.InitializeSucceeded:return G(e,{isInitializing:!1,initializeMethodId:void 0});case $t.DeinitializeRequested:return G(e,{isDeinitializing:!0,deinitializeMethodId:t.meta&&t.meta.methodId});case $t.DeinitializeFailed:case $t.DeinitializeSucceeded:return G(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case $t.UpdateAddressRequested:return G(e,{isUpdatingAddress:!0,updateAddressMethodId:t.meta&&t.meta.methodId});case $t.UpdateAddressFailed:case $t.UpdateAddressSucceeded:return G(e,{isUpdatingAddress:!1,updateAddressMethodId:void 0});case $t.SelectOptionRequested:return G(e,{isSelectingOption:!0,selectOptionMethodId:t.meta&&t.meta.methodId});case $t.SelectOptionFailed:case $t.SelectOptionSucceeded:return G(e,{isSelectingOption:!1,selectOptionMethodId:void 0});case $t.WidgetInteractionStarted:return G(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta&&t.meta.methodId});case $t.WidgetInteractionFinished:case $t.WidgetInteractionFailed:return G(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}!function(e){e.SendSignInEmailRequested="SEND_SIGNIN_EMAIL_REQUESTED",e.SendSignInEmailSucceeded="SEND_SIGNIN_EMAIL_SUCCEEDED",e.SendSignInEmailFailed="SEND_SIGNIN_EMAIL_FAILED"}(an||(an={}));var pn,hn={errors:{},statuses:{}};function fn(e,t){return void 0===e&&(e=hn),(0,a.combineReducers)({data:gn,errors:(0,a.composeReducers)(mn,k),statuses:_n})(e,t)}function gn(e,t){return t.type===an.SendSignInEmailSucceeded?G(e,t.payload):e}function mn(e,t){switch(void 0===e&&(e=hn.errors),t.type){case an.SendSignInEmailRequested:case an.SendSignInEmailSucceeded:return N(e,"sendError",void 0);case an.SendSignInEmailFailed:return N(e,"sendError",t.payload);default:return e}}function _n(e,t){switch(void 0===e&&(e=hn.statuses),t.type){case an.SendSignInEmailRequested:return N(e,"isSending",!0);case an.SendSignInEmailFailed:case an.SendSignInEmailSucceeded:return N(e,"isSending",!1);default:return e}}!function(e){e.ApplyStoreCreditRequested="APPLY_STORE_CREDIT_REQUESTED",e.ApplyStoreCreditSucceeded="APPLY_STORE_CREDIT_SUCCEEDED",e.ApplyStoreCreditFailed="APPLY_STORE_CREDIT_FAILED"}(pn||(pn={}));var yn={errors:{},statuses:{}};function vn(e,t){return void 0===e&&(e=yn),(0,a.combineReducers)({errors:(0,a.composeReducers)(Cn,k),statuses:Sn})(e,t)}function Cn(e,t){switch(void 0===e&&(e=yn.errors),t.type){case pn.ApplyStoreCreditRequested:case pn.ApplyStoreCreditSucceeded:return N(e,"applyError",void 0);case pn.ApplyStoreCreditFailed:return N(e,"applyError",t.payload);default:return e}}function Sn(e,t){switch(void 0===e&&(e=yn.statuses),t.type){case pn.ApplyStoreCreditRequested:return N(e,"isApplying",!0);case pn.ApplyStoreCreditSucceeded:case pn.ApplyStoreCreditFailed:return N(e,"isApplying",!1);default:return e}}var In,wn={errors:{},statuses:{}};function En(e,t){return void 0===e&&(e=wn),(0,a.combineReducers)({errors:(0,a.composeReducers)(bn,k),statuses:Pn})(e,t)}function bn(e,t){switch(void 0===e&&(e=wn.errors),t.type){case O.UpdateSubscriptionsRequested:case O.UpdateSubscriptionsSucceeded:return N(e,"updateError",void 0);case O.UpdateSubscriptionsFailed:return N(e,"updateError",t.payload);default:return e}}function Pn(e,t){switch(void 0===e&&(e=wn.statuses),t.type){case O.UpdateSubscriptionsRequested:return N(e,"isUpdating",!0);case O.UpdateSubscriptionsFailed:case O.UpdateSubscriptionsSucceeded:return N(e,"isUpdating",!1);default:return e}}!function(e){e.InitializeFailed="SPAM_PROTECTION_INITIALIZE_FAILED",e.InitializeSucceeded="SPAM_PROTECTION_INITIALIZE_SUCCEEDED",e.InitializeRequested="SPAM_PROTECTION_INITIALIZE_REQUESTED",e.VerifyCheckoutRequested="SPAM_PROTECTION_CHECKOUT_VERIFY_REQUESTED",e.VerifyCheckoutSucceeded="SPAM_PROTECTION_CHECKOUT_VERIFY_SUCCEEDED",e.VerifyCheckoutFailed="SPAM_PROTECTION_CHECKOUT_VERIFY_FAILED",e.ExecuteRequested="SPAM_PROTECTION_EXECUTE_REQUESTED",e.ExecuteSucceeded="SPAM_PROTECTION_EXECUTE_SUCCEEDED",e.ExecuteFailed="SPAM_PROTECTION_EXECUTE_FAILED"}(In||(In={}));var An={errors:{},statuses:{}};function On(e,t){return void 0===e&&(e=An),(0,a.combineReducers)({data:Tn,errors:(0,a.composeReducers)(Rn,k),statuses:kn})(e,t)}function Tn(e,t){switch(t.type){case P.LoadCheckoutSucceeded:case P.UpdateCheckoutSucceeded:case pn.ApplyStoreCreditSucceeded:case T.UpdateBillingAddressSucceeded:case V.ApplyCouponSucceeded:case V.RemoveCouponSucceeded:case j.CreateConsignmentsSucceeded:case j.UpdateConsignmentSucceeded:case j.DeleteConsignmentSucceeded:case j.UpdateShippingOptionSucceeded:case j.LoadShippingOptionsSucceeded:case H.ApplyGiftCertificateSucceeded:case H.RemoveGiftCertificateSucceeded:case In.VerifyCheckoutSucceeded:return G(e,(0,_.omit)(t.payload,["billingAddress","cart","consignments","customer","coupons","giftCertificates"]));case se.SubmitOrderSucceeded:return N(e,"orderId",t.payload&&t.payload.order.orderId);default:return e}}function Rn(e,t){switch(void 0===e&&(e=An.errors),t.type){case P.LoadCheckoutRequested:case P.LoadCheckoutSucceeded:return N(e,"loadError",void 0);case P.LoadCheckoutFailed:return N(e,"loadError",t.payload);case P.UpdateCheckoutRequested:case P.UpdateCheckoutSucceeded:return N(e,"updateError",void 0);case P.UpdateCheckoutFailed:return N(e,"updateError",t.payload);default:return e}}function kn(e,t){switch(void 0===e&&(e=An.statuses),t.type){case P.LoadCheckoutRequested:return N(e,"isLoading",!0);case P.LoadCheckoutFailed:case P.LoadCheckoutSucceeded:return N(e,"isLoading",!1);case P.UpdateCheckoutRequested:return N(e,"isUpdating",!0);case P.UpdateCheckoutFailed:case P.UpdateCheckoutSucceeded:return N(e,"isUpdating",!1);case In.ExecuteRequested:return N(e,"isExecutingSpamCheck",!0);case In.ExecuteFailed:case In.ExecuteSucceeded:return N(e,"isExecutingSpamCheck",!1);default:return e}}const Dn=require("@bigcommerce/memoize");var Mn;!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentProviderCustomer=13]="MissingPaymentProviderCustomer",e[e.MissingPaymentRedirectUrl=14]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=15]="MissingPaymentStatus",e[e.MissingPaymentToken=16]="MissingPaymentToken",e[e.MissingShippingAddress=17]="MissingShippingAddress"}(Mn||(Mn={}));const Nn=function(e){function t(t){var n=e.call(this,function(e){switch(e){case Mn.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case Mn.MissingCart:return"Unable to proceed because cart data is unavailable.";case Mn.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case Mn.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case Mn.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case Mn.MissingCheckoutConfig:case Mn.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case Mn.MissingOrder:return"Unable to proceed because order data is unavailable.";case Mn.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case Mn.MissingPayment:return"Unable to proceed because payment data is unavailable.";case Mn.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case Mn.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case Mn.MissingPaymentProviderCustomer:return"Unable to proceed because payment provider customer is unavailable.";case Mn.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(t))||this;return n.subtype=t,n.name="MissingDataError",n.type="missing_data",n}return(0,o.__extends)(t,e),t}(p),Ln=require("reselect"),zn=(Un=Ln.createSelector,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.pop();return Un.apply(void 0,(0,o.__spreadArrays)(e,[function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=n.apply(void 0,e);return"function"==typeof r?(0,Dn.memoize)(r):r}]))});var Un;function Fn(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}function Bn(e){return function(e){var t=Object.create(e);return function(e,t){for(var n=Object.getPrototypeOf(e);n;)t(n),n=Object.getPrototypeOf(n)}(e,(function(n){Object.getOwnPropertyNames(n).forEach((function(n){"constructor"!==n&&"function"==typeof t[n]&&"_"!==n.charAt(0)&&(t[n]=function(e,t){return function(){for(var n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return(0,a.deepFreeze)((n=e[t]).call.apply(n,(0,o.__spreadArrays)([e],r)))}}(e,n))}))})),t}(e)}var qn="PAYMENT_TYPE_HOSTED",xn="ACKNOWLEDGE",Gn="FINALIZE";const Vn={"mollie.credit_card":{provider:"mollie",method:"credit_card"},"adyenv2.scheme":{provider:"adyenv2",method:"scheme"},"adyenv3.scheme":{provider:"adyenv3",method:"scheme"},"adyenv2.bcmc":{provider:"adyenv2",method:"bcmc"},"adyenv2.ideal":{provider:"adyenv2",method:"ideal"},"adyenv2.sepadirectdebit":{provider:"adyenv2",method:"sepadirectdebit"},"adyenv2.directEbanking":{provider:"adyenv2",method:"directEbanking"},"adyenv2.giropay":{provider:"adyenv2",method:"giropay"},barclays:{provider:"barclays",method:"credit_card"},braintree:{provider:"braintree",method:"credit_card"},braintreepaypal:{provider:"braintree",method:"paypal"},braintreeach:{provider:"braintree",method:"ach"},authorizenet:{provider:"authorizenet",method:"credit_card"},elavon:{provider:"elavon",method:"credit_card"},checkoutcom:{provider:"checkoutcom",method:"credit_card"},"checkoutcom.credit_card":{provider:"checkoutcom",method:"credit_card"},"checkoutcom.card":{provider:"checkoutcom",method:"card"},sagepay:{provider:"sagepay",method:"credit_card"},stripe:{provider:"stripe",method:"credit_card"},"stripev3.card":{provider:"stripev3",method:"card"},"stripeupe.card":{provider:"stripeupe",method:"card"},cybersource:{provider:"cybersource",method:"credit_card"},cybersourcev2:{provider:"cybersourcev2",method:"credit_card"},bnz:{provider:"bnz",method:"credit_card"},converge:{provider:"converge",method:"credit_card"},bluesnapv2:{provider:"bluesnapv2",method:"credit_card"},"bluesnapdirect.credit_card":{provider:"bluesnapdirect",method:"credit_card"},"bluesnapdirect.ecp":{provider:"bluesnapdirect",method:"ecp"},"bluesnapdirect.sepa_direct_debit":{provider:"bluesnapdirect",method:"sepa_direct_debit"},orbital:{provider:"orbital",method:"credit_card"},paymetric:{provider:"paymetric",method:"credit_card"},bolt:{provider:"bolt",method:"credit_card"},"barclaycard.credit_card":{provider:"barclaycard",method:"credit_card"},digitalriver:{provider:"digitalriver",method:"credit_card"},moneris:{provider:"moneris",method:"credit_card"},cba_mpgs:{provider:"cba_mpgs",method:"credit_card"},worldpayaccess:{provider:"worldpayaccess",method:"credit_card"},squarev2:{provider:"squarev2",method:"credit_card"},paypalcommercecreditcards:{provider:"paypalcommerce",method:"credit_card"},paypalcommerce:{provider:"paypalcommerce",method:"paypal"},tdonlinemart:{provider:"tdonlinemart",method:"credit_card"}};function Hn(e){return(0,_.pickBy)({firstName:e.firstName,lastName:e.lastName,company:e.company,address1:e.address1,address2:e.address2,city:e.city,stateOrProvince:e.stateOrProvince,countryCode:e.countryCode,postalCode:e.postalCode,phone:e.phone,customFields:e.customFields},_.identity)}var jn={errors:{},statuses:{}};function Yn(){var e,t,n,r,i,a,s,u,c,d,l,p,h,f,g,m,y,v,C,S,I,w,E,b,P,A,O,T,R,k,D,M,N,z,U,F,B,q,x,G,V,H,j,Y,K,Z,Q,J,X,ee=(e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn(e,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingBillingAddress)}))}})),n=zn((function(e){return e.errors.updateError}),(function(e){return function(){return e}})),r=zn((function(e){return e.errors.continueAsGuestError}),(function(e){return function(){return e}})),i=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),a=zn((function(e){return!!e.statuses.isUpdating}),(function(e){return function(){return e}})),s=zn((function(e){return!!e.statuses.isContinuingAsGuest}),(function(e){return function(){return e}})),u=zn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}})),(0,Dn.memoizeOne)((function(o){return void 0===o&&(o=L),{getBillingAddress:e(o),getBillingAddressOrThrow:t(o),getUpdateError:n(o),getContinueAsGuestError:r(o),getLoadError:i(o),isUpdating:a(o),isContinuingAsGuest:s(o),isLoading:u(o)}}))),te=function(){var e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn(e,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingCart)}))}})),n=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),r=zn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,Dn.memoizeOne)((function(i){return void 0===i&&(i=W),{getCart:e(i),getCartOrThrow:t(i),getLoadError:n(i),isLoading:r(i)}}))}(),ne=(c=zn((function(e){return e}),(function(e){return function(){return e}})),d=zn((function(e){return e.statuses}),(function(e){return(0,Dn.memoize)((function(t){if(t){var n=e[t];return!0===(n&&n.isInitializing)}return(0,_.some)(e,{isInitializing:!0})}))})),l=zn((function(e){return e.data}),(function(e){return(0,Dn.memoize)((function(t,n){var r=e[t];return!!r&&(n?!0===r.initializedContainers[n]:(0,_.some)(r.initializedContainers,(function(e){return!0===e})))}))})),p=zn((function(e){return e.statuses}),(function(e){return(0,Dn.memoize)((function(t){if(t){var n=e[t];return!0===(n&&n.isDeinitializing)}return(0,_.some)(e,{isDeinitializing:!0})}))})),h=zn((function(e){return e.errors}),(function(e){return(0,Dn.memoize)((function(t){var n=t?e[t]:(0,_.find)((0,_.values)(e),(function(e){return!(!e||!e.initializeError)}));return n&&n.initializeError}))})),f=zn((function(e){return e.errors}),(function(e){return(0,Dn.memoize)((function(t){var n=t?e[t]:(0,_.find)((0,_.values)(e),(function(e){return!(!e||!e.deinitializeError)}));return n&&n.deinitializeError}))})),(0,Dn.memoizeOne)((function(e){return void 0===e&&(e=$),{getState:c(e),isInitializing:d(e),isInitialized:l(e),isDeinitializing:p(e),getInitializeError:h(e),getDeinitializeError:f(e)}}))),re=function(){var e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn((function(e){return e.data}),(function(e){return function(t){if(e){var n=e.context.flashMessages;if(n)return void 0!==t?n.filter((function(e){var n=e.type;return t===n})):n}}})),n=zn((function(e){return e.data}),(function(e,t){var n=t.formState;return n&&n.data}),(function(e,t){return function(){return e&&t?(0,o.__assign)((0,o.__assign)({},e.storeConfig),{formFields:t}):void 0}})),r=zn(n,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingCheckoutConfig)}))}})),i=zn((function(e){return e.data&&e.data.context}),(function(e){return function(){return e}})),a=zn((function(e){return e.meta&&e.meta.externalSource}),(function(e){return function(){return e}})),s=zn((function(e){var t;return null===(t=e.meta)||void 0===t?void 0:t.host}),(function(e){return function(){return e}})),u=zn((function(e){var t;return null===(t=e.meta)||void 0===t?void 0:t.locale}),(function(e){return function(){return e}})),c=zn((function(e){return e.meta&&e.meta.variantIdentificationToken}),(function(e){return function(){return e}})),d=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),l=zn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,Dn.memoizeOne)((function(o,p){return void 0===o&&(o=ue),{getConfig:e(o),getFlashMessages:t(o),getStoreConfig:n(o,{formState:p}),getStoreConfigOrThrow:r(o,{formState:p}),getContextConfig:i(o),getExternalSource:a(o),getHost:s(o),getLocale:u(o),getVariantIdentificationToken:c(o),getLoadError:d(o),isLoading:l(o)}}))}(),ie=function(){var e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),n=zn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,Dn.memoizeOne)((function(r){return void 0===r&&(r=Ke),{getCountries:e(r),getLoadError:t(r),isLoading:n(r)}}))}(),oe=(g=zn((function(e){return e.data}),(function(e){return function(){return e}})),m=zn((function(e){return e.errors.removeCouponError}),(function(e){return function(){return e}})),y=zn((function(e){return e.errors.applyCouponError}),(function(e){return function(){return e}})),v=zn((function(e){return!!e.statuses.isApplyingCoupon}),(function(e){return function(){return e}})),C=zn((function(e){return!!e.statuses.isRemovingCoupon}),(function(e){return function(){return e}})),(0,Dn.memoizeOne)((function(e){return void 0===e&&(e=he),{getCoupons:g(e),getRemoveError:m(e),getApplyError:y(e),isApplying:v(e),isRemoving:C(e)}}))),ae=(S=zn((function(e){return e.data}),(function(e){return function(){return e}})),I=zn(S,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingCustomer)}))}})),w=zn((function(e){return e.errors.createError}),(function(e){return function(){return e}})),E=zn((function(e){return!!e.statuses.isCreating}),(function(e){return function(){return e}})),b=zn((function(e){return e.errors.createAddressError}),(function(e){return function(){return e}})),P=zn((function(e){return!!e.statuses.isCreatingAddress}),(function(e){return function(){return e}})),(0,Dn.memoizeOne)((function(e){return void 0===e&&(e=be),{getCustomer:S(e),getCustomerOrThrow:I(e),getCreateAccountError:w(e),isCreatingCustomerAccount:E(e),getCreateAddressError:b(e),isCreatingCustomerAddress:P(e)}}))),se=function(){var e=zn((function(e){return e.errors.signInMethodId}),(function(e){return e.errors.signInError}),(function(e,t){return function(n){if(!n||e===n)return t}})),t=zn((function(e){return e.errors.signOutMethodId}),(function(e){return e.errors.signOutError}),(function(e,t){return function(n){if(!n||e===n)return t}})),n=zn((function(e){return e.errors.executePaymentMethodCheckoutMethodId}),(function(e){return e.errors.executePaymentMethodCheckoutError}),(function(e,t){return function(n){if(!n||e===n)return t}})),r=zn((function(e){return e.errors.initializeMethodId}),(function(e){return e.errors.initializeErrors}),(function(e,t){return function(n){if(e&&t)return n?t[n]:t[e]}})),i=zn((function(e){return e.errors.widgetInteractionMethodId}),(function(e){return e.errors.widgetInteractionError}),(function(e,t){return function(n){if(!n||e===n)return t}})),o=zn((function(e){return e.statuses.signInMethodId}),(function(e){return e.statuses.isSigningIn}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),a=zn((function(e){return e.statuses.signOutMethodId}),(function(e){return e.statuses.isSigningOut}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),s=zn((function(e){return e.statuses.executePaymentMethodCheckoutMethodId}),(function(e){return e.statuses.isExecutingPaymentMethodCheckout}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),u=zn((function(e){return e.statuses.initializeMethodId}),(function(e){return e.statuses.isInitializing}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),c=zn((function(e){return e.data}),(function(e){return function(t){return!(!e[t]||!e[t].isInitialized)}})),d=zn((function(e){return e.statuses.widgetInteractionMethodId}),(function(e){return e.statuses.isWidgetInteracting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,Dn.memoizeOne)((function(l){return void 0===l&&(l=ke),{getSignInError:e(l),getSignOutError:t(l),getExecutePaymentMethodCheckoutError:n(l),getInitializeError:r(l),getWidgetInteractionError:i(l),isSigningIn:o(l),isSigningOut:a(l),isExecutingPaymentMethodCheckout:s(l),isInitializing:u(l),isInitialized:c(l),isWidgetInteracting:d(l)}}))}(),ce=function(){var e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn((function(e){return e.errors.removeGiftCertificateError}),(function(e){return function(){return e}})),n=zn((function(e){return e.errors.applyGiftCertificateError}),(function(e){return function(){return e}})),r=zn((function(e){return!!e.statuses.isApplyingGiftCertificate}),(function(e){return function(){return e}})),i=zn((function(e){return!!e.statuses.isRemovingGiftCertificate}),(function(e){return function(){return e}}));return(0,Dn.memoizeOne)((function(o){return void 0===o&&(o=ve),{getGiftCertificates:e(o),getRemoveError:t(o),getApplyError:n(o),isApplying:r(o),isRemoving:i(o)}}))}(),de=function(){var e=zn((function(e){return e.data}),(function(e){return function(t){if(e){var n=t.gateway?t.gateway+"."+t.id:t.id,r=Vn[n];return r?(0,_.filter)(e,r):[]}}})),t=zn((function(e){return e.data}),(function(e){return void 0===e&&(e=[]),function(t){var n=(0,_.values)(Vn);return e.find((function(e){return e.bigpayToken===t&&"card"===e.type&&n.some((function(t){return(0,_.isMatch)(e,t)}))}))}})),n=zn(t,(function(e){return function(t){return Fn(e(t),(function(){return new Nn(Mn.MissingPaymentInstrument)}))}})),r=zn((function(e){return e.data}),(function(e){return function(){if(e)return(0,_.flatMap)(Vn,(function(t){return(0,_.filter)(e,(function(e){return(0,_.isMatch)(e,t)}))}))}})),i=zn((function(e){return e.meta}),(function(e){return function(){return e}})),o=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),a=zn((function(e){return e.errors.failedInstrument}),(function(e){return e.errors.deleteError}),(function(e,t){return function(n){if(!n||e===n)return t}})),s=zn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!!e}})),u=zn((function(e){return e.statuses.deletingInstrument}),(function(e){return e.statuses.isDeleting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,Dn.memoizeOne)((function(c){return void 0===c&&(c=Rt),{getCardInstrument:t(c),getCardInstrumentOrThrow:n(c),getInstruments:r(c),getInstrumentsByPaymentMethod:e(c),getInstrumentsMeta:i(c),getLoadError:o(c),getDeleteError:a(c),isLoading:s(c),isDeleting:u(c)}}))}(),le=function(){var e=zn((function(e){return e.data}),(function(e){return function(t,n){void 0===t&&(t=[]);var r=(0,_.find)(t,{code:n});return(e?e.shippingAddress:[]).map((function(e){return a(e,t,r)}))}})),t=zn((function(e){return e.data}),(function(e){return function(t,n){void 0===t&&(t=[]);var r=(0,_.find)(t,{code:n});return(e?e.billingAddress:[]).map((function(e){return a(e,t,r)}))}})),n=zn((function(e){return e.data}),(function(e){return function(){return e?e.customerAccount:[]}})),r=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),i=zn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));function a(e,t,n){return"countryCode"===e.name?function(e,t,n){if(void 0===t&&(t=[]),!t.length)return e;var r=(n||{}).code,i=void 0===r?"":r,a=t.map((function(e){return{value:e.code,label:e.name}}));return(0,o.__assign)((0,o.__assign)({},e),{options:{items:a},default:i,type:"array",fieldType:"dropdown",itemtype:"string"})}(e,t,n):"stateOrProvince"===e.name?function(e,t){var n=t||{},r=n.subdivisions,i=void 0===r?[]:r,a=n.requiresState;if(!i.length)return(0,o.__assign)((0,o.__assign)({},e),{required:null!=a&&a});var s=i.map((function(e){return{value:e.code,label:e.name}}));return(0,o.__assign)((0,o.__assign)({},e),{name:"stateOrProvinceCode",options:{items:s},required:null==a||a,type:"array",fieldType:"dropdown",itemtype:"string"})}(e,n):"postalCode"===e.name?function(e,t){var n=(t||{}).hasPostalCodes,r=void 0===n?[]:n;return void 0===r?e:(0,o.__assign)((0,o.__assign)({},e),{required:Boolean(r)})}(e,n):e}return(0,Dn.memoizeOne)((function(o){return void 0===o&&(o=Ve),{getShippingAddressFields:e(o),getBillingAddressFields:t(o),getCustomerAccountFields:n(o),getLoadError:r(o),isLoading:i(o)}}))}(),pe=function(){var e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn((function(e){return e.meta}),(function(e){return function(){return e}})),n=zn((function(e){return e.data}),(function(e){return function(t,n){return n?(0,_.find)(e,{id:t,gateway:n}):(0,_.find)(e,{id:t})}})),r=zn(n,(function(e){return function(t,n){return Fn(e(t,n),(function(){return new Nn(Mn.MissingPaymentMethod)}))}})),i=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),o=zn((function(e){return e.errors.loadMethodId}),(function(e){return e.errors.loadMethodError}),(function(e,t){return function(n){if(!n||e===n)return t}})),a=zn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!!e}})),s=zn((function(e){return e.statuses.loadMethodId}),(function(e){return e.statuses.isLoadingMethod}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,Dn.memoizeOne)((function(u){return void 0===u&&(u=ht),{getPaymentMethods:e(u),getPaymentMethodsMeta:t(u),getPaymentMethod:n(u),getPaymentMethodOrThrow:r(u),getLoadError:i(u),getLoadMethodError:o(u),isLoading:a(u),isLoadingMethod:s(u)}}))}(),fe=function(){var e=zn((function(e){return e.errors.initializeMethodId}),(function(e){return e.errors.initializeError}),(function(e,t){return function(n){if(!n||e===n)return t}})),t=zn((function(e){return e.errors.executeMethodId}),(function(e){return e.errors.executeError}),(function(e,t){return function(n){if(!n||e===n)return t}})),n=zn((function(e){return e.errors.finalizeMethodId}),(function(e){return e.errors.finalizeError}),(function(e,t){return function(n){if(!n||e===n)return t}})),r=zn((function(e){return e.errors.widgetInteractionMethodId}),(function(e){return e.errors.widgetInteractionError}),(function(e,t){return function(n){if(!n||e===n)return t}})),i=zn((function(e){return e.statuses.initializeMethodId}),(function(e){return e.statuses.isInitializing}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),o=zn((function(e){return e.data}),(function(e){return function(t){var n=t.gatewayId?t.methodId+"."+t.gatewayId:t.methodId;return!(!e[n]||!e[n].isInitialized)}})),a=zn((function(e){return e.statuses.executeMethodId}),(function(e){return e.statuses.isExecuting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),s=zn((function(e){return e.statuses.finalizeMethodId}),(function(e){return e.statuses.isFinalizing}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),u=zn((function(e){return e.statuses.widgetInteractionMethodId}),(function(e){return e.statuses.isWidgetInteracting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,Dn.memoizeOne)((function(c){return void 0===c&&(c=Ct),{getInitializeError:e(c),getExecuteError:t(c),getFinalizeError:n(c),getWidgetInteractingError:r(c),isInitializing:i(c),isInitialized:o(c),isExecuting:a(c),isFinalizing:s(c),isWidgetInteracting:u(c)}}))}(),ge=function(){var e=zn((function(e){return e.data}),(function(e){return function(t,n){if(e){var r=Yt(jt({consignmentId:t,searchArea:n})),i=btoa(""+JSON.stringify(r));return e[i]}}})),t=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),n=zn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,Dn.memoizeOne)((function(r){return void 0===r&&(r=Kt),{getPickupOptions:e(r),getLoadError:t(r),isLoading:n(r)}}))}(),me=(A=zn((function(e){return e.data}),(function(e){return function(){return e}})),O=zn(A,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingPaymentProviderCustomer)}))}})),(0,Dn.memoizeOne)((function(e){return void 0===e&&(e=Pt),{getPaymentProviderCustomer:A(e),getPaymentProviderCustomerOrThrow:O(e)}}))),_e=(T=zn((function(e){return e.data}),(function(e){return function(t){return e[t]}})),(0,Dn.memoizeOne)((function(e){return void 0===e&&(e=zt),{getCheckout:T(e)}}))),ye=(R=zn((function(e){return e.data}),(function(e){return function(){var t=null==e?void 0:e.find((function(e){return!e.selectedPickupOption}));return null==t?void 0:t.shippingAddress}})),k=zn(R,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingShippingAddress)}))}})),D=zn((function(e){return e.data}),(function(e){return function(){var t=null==e?void 0:e.filter((function(e){return!e.selectedPickupOption}));return t?t.map((function(e){return e.shippingAddress})):[]}})),M=zn(D,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingShippingAddress)}))}})),(0,Dn.memoizeOne)((function(e){return void 0===e&&(e=qt),{getShippingAddress:R(e),getShippingAddressOrThrow:k(e),getShippingAddresses:D(e),getShippingAddressesOrThrow:M(e)}}))),Ce=function(){var e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),n=zn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!!e}}));return(0,Dn.memoizeOne)((function(r){return void 0===r&&(r=en),{getShippingCountries:e(r),getLoadError:t(r),isLoading:n(r)}}))}(),Se=function(){var e=zn((function(e){return e.errors.updateAddressMethodId}),(function(e){return e.errors.updateAddressError}),(function(e,t){return function(n){if(!n||e===n)return t}})),t=zn((function(e){return e.errors.selectOptionMethodId}),(function(e){return e.errors.selectOptionError}),(function(e,t){return function(n){if(!n||e===n)return t}})),n=zn((function(e){return e.errors.initializeMethodId}),(function(e){return e.errors.initializeError}),(function(e,t){return function(n){if(!n||e===n)return t}})),r=zn((function(e){return e.errors.widgetInteractionMethodId}),(function(e){return e.errors.widgetInteractionError}),(function(e,t){return function(n){if(!n||e===n)return t}})),i=zn((function(e){return e.statuses.updateAddressMethodId}),(function(e){return e.statuses.isUpdatingAddress}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),o=zn((function(e){return e.statuses.selectOptionMethodId}),(function(e){return e.statuses.isSelectingOption}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),a=zn((function(e){return e.statuses.initializeMethodId}),(function(e){return e.statuses.isInitializing}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),s=zn((function(e){return e.data}),(function(e){return function(t){return!(!e[t]||!e[t].isInitialized)}})),u=zn((function(e){return e.statuses.widgetInteractionMethodId}),(function(e){return e.statuses.isWidgetInteracting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,Dn.memoizeOne)((function(c){return void 0===c&&(c=sn),{getUpdateAddressError:e(c),getSelectOptionError:t(c),getInitializeError:n(c),getWidgetInteractionError:r(c),isUpdatingAddress:i(c),isSelectingOption:o(c),isInitializing:a(c),isInitialized:s(c),isWidgetInteracting:u(c)}}))}(),Ie=function(){var e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn(e,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingConsignments)}))}})),n=zn((function(e){return e.data}),(function(e){return function(t){if(e&&e.length)return(0,_.find)(e,{id:t})}})),r=zn((function(e){return e.data}),(function(e){return function(t){if(e&&e.length)return(0,_.find)(e,(function(e){return n=e.shippingAddress,r=t,(0,_.isEqual)(Hn(n),Hn(r));var n,r}))}})),i=zn((function(e){return e.data}),(function(e){return function(){if(e&&e.length)return e[0].selectedShippingOption}})),o=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),a=zn((function(e){return e.errors.createError}),(function(e){return function(){return e}})),s=zn((function(e){return e.errors.loadShippingOptionsError}),(function(e){return function(){return e}})),u=zn(e,(function(e,t){return t.cart.getCart}),(function(e,t){return function(){var n=t();if(!n)return[];var r=(e()||[]).reduce((function(e,t){return e.concat(t.lineItemIds)}),[]);return(n.lineItems.physicalItems||[]).filter((function(e){return r.indexOf(e.id)<0}))}})),c=zn((function(e){return e.errors.updateError}),(function(e){return function(t){return t?e[t]:(0,_.find)(e)}})),d=zn((function(e){return e.errors.deleteError}),(function(e){return function(t){return t?e[t]:(0,_.find)(e)}})),l=zn(r,c,a,(function(e,t,n){return function(r){var i=e(r);return i?t(i.id):n()}})),p=zn((function(e){return e.errors.updateShippingOptionError}),(function(e){return function(t){return t?e[t]:(0,_.find)(e)}})),h=zn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!0===e}})),f=zn((function(e){return e.statuses.isLoadingShippingOptions}),(function(e){return function(){return!0===e}})),g=zn((function(e){return e.statuses.isCreating}),(function(e){return function(){return!0===e}})),m=zn((function(e){return e.statuses.isUpdating}),(function(e){return function(t){return t?!0===e[t]:!0===(0,_.find)(e)}})),y=zn((function(e){return e.statuses.isDeleting}),(function(e){return function(t){return t?!0===e[t]:!0===(0,_.find)(e)}})),v=zn(r,m,g,(function(e,t,n){return function(r){var i=e(r);return i?t(i.id):n()}})),C=zn((function(e){return e.statuses.isUpdatingShippingOption}),(function(e){return function(t){return t?!0===e[t]:!0===(0,_.find)(e)}}));return(0,Dn.memoizeOne)((function(_,S){return void 0===_&&(_=qt),{getConsignments:e(_),getConsignmentsOrThrow:t(_),getConsignmentById:n(_),getConsignmentByAddress:r(_),getShippingOption:i(_),getLoadError:o(_),getCreateError:a(_),getLoadShippingOptionsError:s(_),getUnassignedItems:u(_,{cart:S}),getUpdateError:c(_),getDeleteError:d(_),getItemAssignmentError:l(_),getUpdateShippingOptionError:p(_),isLoading:h(_),isLoadingShippingOptions:f(_),isCreating:g(_),isUpdating:m(_),isDeleting:y(_),isAssigningItems:v(_),isUpdatingShippingOption:C(_)}}))}(),we=function(){var e=zn((function(e){return e.data}),(function(e,t){return t.billingAddress.getBillingAddress}),(function(e,t){return t.cart.getCart}),(function(e,t){return t.customer.getCustomer}),(function(e,t){return t.consignments.getConsignments}),(function(e,t){return t.coupons.getCoupons}),(function(e,t){return t.giftCertificates.getGiftCertificates}),(function(e,t,n,r,i,a,s){return function(){var u=t(),c=n(),d=r(),l=i()||[],p=a()||[],h=s()||[];if(e&&c&&d)return(0,o.__assign)((0,o.__assign)({},e),{billingAddress:u,cart:c,customer:d,consignments:l,coupons:p,giftCertificates:h})}})),t=zn(e,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingCheckout)}))}})),n=zn(e,(function(e){return function(t){var n=e();if(n){var r=n.grandTotal||0,i=n.customer.storeCredit||0;return t?Math.max(r-i,0):n.outstandingBalance}}})),r=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),i=zn((function(e){return e.errors.updateError}),(function(e){return function(){return e}})),a=zn((function(e){return e.statuses.isExecutingSpamCheck}),(function(e){return function(){return!0===e}})),s=zn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!0===e}})),u=zn((function(e){return e.statuses.isUpdating}),(function(e){return function(){return!0===e}}));return(0,Dn.memoizeOne)((function(o,c,d,l,p,h,f){return void 0===o&&(o=An),{getCheckout:e(o,{billingAddress:c,cart:d,consignments:l,coupons:p,customer:h,giftCertificates:f}),getCheckoutOrThrow:t(o,{billingAddress:c,cart:d,consignments:l,coupons:p,customer:h,giftCertificates:f}),getOutstandingBalance:n(o,{billingAddress:c,cart:d,consignments:l,coupons:p,customer:h,giftCertificates:f}),getLoadError:r(o),getUpdateError:i(o),isExecutingSpamCheck:a(o),isLoading:s(o),isUpdating:u(o)}}))}(),Ee=function(){var e=zn((function(e){return e.data}),(function(e,t){return t.billingAddress.getOrderBillingAddress()}),(function(e,t){return t.coupons.getCoupons()}),(function(e,t,n){return void 0===n&&(n=[]),function(){if(e&&t)return(0,o.__assign)((0,o.__assign)({},e),{billingAddress:t,coupons:n})}})),t=zn(e,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingOrder)}))}})),n=zn((function(e){return e.meta}),(function(e){return function(){return e}})),r=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),i=zn((function(e){var t;return null===(t=e.data)||void 0===t?void 0:t.payments}),(function(e){return void 0===e&&(e=[]),function(t){var n=e.find((function(e){return e.providerId===t}));return null==n?void 0:n.paymentId}})),a=zn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,Dn.memoizeOne)((function(o,s,u){return void 0===o&&(o=$e),{getOrder:e(o,{billingAddress:s,coupons:u}),getOrderOrThrow:t(o,{billingAddress:s,coupons:u}),getOrderMeta:n(o),getLoadError:r(o),getPaymentId:i(o),isLoading:a(o)}}))}(),Pe=(N=zn((function(e){return e.data}),(function(e){return function(){return e}})),(0,Dn.memoizeOne)((function(e){return void 0===e&&(e=st),{getOrderBillingAddress:N(e)}}))),Ae=(z=zn((function(e){return e.order.getOrderMeta}),(function(e){return function(){var t=e();return t&&t.payment}})),U=zn((function(e){return e.order.getOrder}),(function(e){return function(){var t=e();return(0,_.find)(t&&t.payments,(function(e){var t=e.providerId;return"giftcertificate"!==t&&"storecredit"!==t}))}})),F=zn((function(e){return e.checkout.getCheckout}),(function(e){return function(){var t=e();return(0,_.find)(t&&t.payments,(function(e){return e.providerType===qn}))}})),B=zn(z,F,U,(function(e,t,n){return function(){var r=e();if(r&&r.id)return{providerId:r.id,gatewayId:r.gateway};var i=t()||n();return i&&i.providerId?{providerId:i.providerId,gatewayId:i.gatewayId}:void 0}})),q=zn(B,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingPaymentId)}))}})),x=zn(z,F,U,(function(e,t,n){return function(){var r=e();if(r&&r.status)return r.status.replace("PAYMENT_STATUS_","");var i=t()||n();return i?i.detail.step:void 0}})),G=zn(x,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingPaymentStatus)}))}})),V=zn((function(e){return e.order.getOrderMeta}),(function(e){return function(){var t=e();return t&&t.token}})),H=zn(V,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingPaymentToken)}))}})),j=zn(z,(function(e){return function(){var t=e();return t&&t.redirectUrl}})),Y=zn(j,(function(e){return function(){return Fn(e(),(function(){return new Nn(Mn.MissingPaymentRedirectUrl)}))}})),K=zn((function(e){return e.checkout.getOutstandingBalance}),(function(e){return function(t){void 0===t&&(t=!1);var n=e(t);return!!n&&n>0}})),Z=zn(x,(function(e){return function(t){return!(!t||!t.nonce)||e()===xn||e()===Gn}})),(0,Dn.memoizeOne)((function(e,t){return{getPaymentId:B({checkout:e,order:t}),getPaymentIdOrThrow:q({checkout:e,order:t}),getPaymentStatus:x({checkout:e,order:t}),getPaymentStatusOrThrow:G({checkout:e,order:t}),getPaymentToken:V({checkout:e,order:t}),getPaymentTokenOrThrow:H({checkout:e,order:t}),getPaymentRedirectUrl:j({checkout:e,order:t}),getPaymentRedirectUrlOrThrow:Y({checkout:e,order:t}),isPaymentDataRequired:K({checkout:e,order:t}),isPaymentDataSubmitted:Z({checkout:e,order:t})}}))),Oe=function(){var e=zn((function(e){return e.errors.applyError}),(function(e){return function(){return e}})),t=zn((function(e){return!!e.statuses.isApplying}),(function(e){return function(){return e}}));return(0,Dn.memoizeOne)((function(n){return void 0===n&&(n=jn),{getApplyError:e(n),isApplying:t(n)}}))}(),Te=function(){var e=zn((function(e){return e.errors.updateError}),(function(e){return function(){return e}})),t=zn((function(e){return!!e.statuses.isUpdating}),(function(e){return function(){return e}}));return(0,Dn.memoizeOne)((function(n){return void 0===n&&(n=wn),{getUpdateError:e(n),isUpdating:t(n)}}))}(),Re=(Q=zn((function(e){return e.data}),(function(e){return function(){return e}})),J=zn((function(e){return e.errors.sendError}),(function(e){return function(){return e}})),X=zn((function(e){return!!e.statuses.isSending}),(function(e){return function(){return e}})),(0,Dn.memoizeOne)((function(e){return void 0===e&&(e=hn),{getEmail:Q(e),getSendError:J(e),isSending:X(e)}}))),De=function(){var e=zn((function(e){return e.data}),(function(e){return function(){return e}})),t=zn((function(e){return e.data}),(function(e){return function(t){return null==e?void 0:e.find((function(e){return e.region===t}))}})),n=zn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),r=zn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!!e}}));return(0,Dn.memoizeOne)((function(i){return void 0===i&&(i=Ue),{getExtensions:e(i),getExtensionByRegion:t(i),getLoadError:n(i),isLoading:r(i)}}))}();return function(e,t){void 0===t&&(t={});var n,r=ee(e.billingAddress),i=te(e.cart),o=ne(e.checkoutButton),a=ie(e.countries),s=oe(e.coupons),u=ae(e.customer),c=se(e.customerStrategies),d=De(e.extensions),l=le(e.formFields),p=ce(e.giftCertificates),h=de(e.instruments),f=Pe(e.orderBillingAddress),g=pe(e.paymentMethods),m=me(e.paymentProviderCustomer),_=fe(e.paymentStrategies),y=ge(e.pickupOptions),v=_e(e.remoteCheckout),C=ye(e.consignments),S=Ce(e.shippingCountries),I=Se(e.shippingStrategies),w=Te(e.subscriptions),E=Oe(e.storeCredit),b=Re(e.signInEmail),P=Ie(e.consignments,i),A=we(e.checkout,r,i,P,s,u,p),O=Ee(e.order,f,s),T=Ae(A,O),R={billingAddress:r,cart:i,checkout:A,checkoutButton:o,config:re(e.config,e.formFields),consignments:P,countries:a,coupons:s,customer:u,customerStrategies:c,extensions:d,form:l,giftCertificates:p,instruments:h,order:O,orderBillingAddress:f,payment:T,paymentMethods:g,paymentProviderCustomer:m,paymentStrategies:_,pickupOptions:y,remoteCheckout:v,shippingAddress:C,shippingCountries:S,shippingStrategies:I,signInEmail:b,subscriptions:w,storeCredit:E};return t.shouldWarnMutation?(n=R,Object.keys(n).reduce((function(e,t){return e[t]=Bn(n[t]),e}),{})):R}}function Wn(e,t){void 0===e&&(e={});var n,r,i=(n=new w,["catalog_only","empty_cart","invalid_order_id","invalid_order_token","missing_order_token","missing_provider_token","missing_shipping_method","order_completion_error","order_could_not_be_finalized_error","order_create_failed","provider_fatal_error","provider_setup_error","stock_too_low"].forEach((function(e){n.register(e,(function(e,t){return new m(e,t)}))})),n.register("invalid_payment_provider",(function(e){return new l(e)})),n.register("payment_config_not_found",(function(e){return new l(e)})),r=n,function(e){return(0,E.from)(e).pipe((0,b.catchError)((function(e){if(e instanceof Error||e.payload instanceof Error)throw e;if((n=e.payload)&&"object"==typeof n&&["body","headers","status","statusText"].every((function(e){return Object.prototype.hasOwnProperty.call(n,e)}))){var t=e.payload.body&&e.payload.body.detail;throw(0,o.__assign)((0,o.__assign)({},e),{payload:r.createError(e.payload,t)})}var n;throw e})))}),s=Yn();return(0,a.createDataStore)((0,a.combineReducers)({billingAddress:z,cart:K,checkout:On,checkoutButton:re,config:ce,consignments:xt,countries:Ze,coupons:fe,customer:Pe,customerStrategies:De,extensions:Fe,formFields:He,giftCertificates:Ce,instruments:kt,orderBillingAddress:ut,order:et,payment:dt,paymentMethods:ft,paymentStrategies:St,pickupOptions:Zt,paymentProviderCustomer:At,remoteCheckout:Ut,shippingCountries:tn,shippingStrategies:un,signInEmail:fn,subscriptions:En,storeCredit:vn}),e,(0,o.__assign)({actionTransformer:i,stateTransformer:function(e){return s(e)}},t))}function Kn(e,t,n){var r=new WeakMap;function i(e){var n=this;return function(){for(var i,a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];var u,c=a[a.length-1];if(!(u=c,u&&"boolean"==typeof u.useCache?c:{useCache:!1}).useCache)return e.call.apply(e,(0,o.__spreadArrays)([n],a));var d,l=r.get(n)||{};return r.get(n)||r.set(n,l),l[t]||(l[t]=(d=e,(0,Dn.memoize)((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=d.call.apply(d,(0,o.__spreadArrays)([this],e));return n instanceof E.Observable?(0,E.from)(n).pipe((0,b.shareReplay)()):"function"==typeof n?(0,Dn.memoize)((function(e){return(0,E.from)(n(e)).pipe((0,b.shareReplay)())}),{isEqual:_.isEqual}):n}),{isEqual:_.isEqual}))),(i=l[t]).call.apply(i,(0,o.__spreadArrays)([n],a))}}return{get:function(){if("function"!=typeof n.value)throw new Error("Decorator should be used in functions");var e=i.call(this,n.value);return Object.defineProperty(this,t,(0,o.__assign)((0,o.__assign)({},n),{value:e})),e}}}var Zn=function(e){return!!e},Qn=function(){function e(e){this._requestSender=e}return e.prototype.loadPaymentMethodsById=function(e,t){var n=this;return function(r){return new E.Observable((function(i){var s,u=null===(s=r.getState().cart.getCart())||void 0===s?void 0:s.id,c=u?(0,o.__assign)((0,o.__assign)({},null==t?void 0:t.params),{cartId:u}):(0,o.__assign)({},null==t?void 0:t.params);i.next((0,a.createAction)(at.LoadPaymentMethodsRequested)),Promise.all(e.map((function(e){return(0,o.__awaiter)(n,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this._requestSender.loadPaymentMethod(e,(0,o.__assign)((0,o.__assign)({},t),{params:c}))];case 1:return[2,n.sent().body];case 2:return n.sent(),[2,void 0];case 3:return[2]}}))}))}))).then((function(e){var t=e.filter(Zn);i.next((0,a.createAction)(at.LoadPaymentMethodsSucceeded,t)),i.complete()})).catch((function(e){i.next((0,a.createAction)(at.LoadPaymentMethodsFailed,e)),i.complete()}))}))}},e.prototype.loadPaymentMethods=function(e){var t=this;return function(n){return E.Observable.create((function(r){var i=n.getState().cart.getCartOrThrow();r.next((0,a.createAction)(at.LoadPaymentMethodsRequested)),t._requestSender.loadPaymentMethods((0,o.__assign)((0,o.__assign)({},e),{params:(0,o.__assign)((0,o.__assign)({},null==e?void 0:e.params),{cartId:i.id})})).then((function(e){var n={deviceSessionId:e.headers["x-device-session-id"],sessionHash:e.headers["x-session-hash"]},i=e.body,o=Array.isArray(i)?t._filterApplePay(i):i;r.next((0,a.createAction)(at.LoadPaymentMethodsSucceeded,o,n)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(at.LoadPaymentMethodsFailed,e))}))}))}},e.prototype.loadPaymentMethod=function(e,t){var n=this;return function(r){return E.Observable.create((function(i){var s,u=null===(s=r.getState().cart.getCart())||void 0===s?void 0:s.id,c=u?(0,o.__assign)((0,o.__assign)({},null==t?void 0:t.params),{cartId:u}):(0,o.__assign)({},null==t?void 0:t.params);i.next((0,a.createAction)(at.LoadPaymentMethodRequested,void 0,{methodId:e})),n._requestSender.loadPaymentMethod(e,(0,o.__assign)((0,o.__assign)({},t),{params:c})).then((function(t){i.next((0,a.createAction)(at.LoadPaymentMethodSucceeded,t.body,{methodId:e})),i.complete()})).catch((function(t){i.error((0,a.createErrorAction)(at.LoadPaymentMethodFailed,t,{methodId:e}))}))}))}},e.prototype._filterApplePay=function(e){return(0,_.filter)(e,(function(e){return!("applepay"===e.id&&!function(e){return"ApplePaySession"in e}(window))}))},(0,o.__decorate)([Kn],e.prototype,"loadPaymentMethod",null),e}();const Jn=Qn;var Xn;!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(Xn||(Xn={}));const $n=Xn;var er="This API endpoint is for internal use only and may change in the future",tr={"X-Checkout-SDK-Version":"1.661.5"},nr=function(){function e(e){this._requestSender=e}return e.prototype.loadPaymentMethods=function(e){var t=void 0===e?{}:e,n=t.timeout,r=t.params;return this._requestSender.get("/api/storefront/payments",{timeout:n,headers:(0,o.__assign)({Accept:$n.JsonV1,"X-API-INTERNAL":er},tr),params:r})},e.prototype.loadPaymentMethod=function(e,t){var n=void 0===t?{}:t,r=n.timeout,i=n.params,a="/api/storefront/payments/"+e;return this._requestSender.get(a,{timeout:r,headers:(0,o.__assign)({Accept:$n.JsonV1,"X-API-INTERNAL":er},tr),params:i})},e}();const rr=nr,ir=require("@bigcommerce/script-loader");function or(e,t,n){return(r=t)&&r.type&&r.error?(0,E.concat)((0,E.of)(t),(0,E.throwError)((0,a.createErrorAction)(e,t.payload,n))):(0,E.throwError)((0,a.createErrorAction)(e,t,n));var r}const ar=function(e){function t(t){var n=e.call(this,t||"Unable to continue as a guest because the customer is already signed in.")||this;return n.name="UnableToContinueAsGuestError",n.type="unable_to_continue_as_guest",n}return(0,o.__extends)(t,e),t}(p);var sr=function(){function e(e,t){this._requestSender=e,this._subscriptionActionCreator=t}return e.prototype.continueAsGuest=function(e,t){var n=this;return function(r){var i,s,u=r.getState(),c=u.checkout.getCheckout(),d=null===(s=null===(i=u.config.getConfig())||void 0===i?void 0:i.storeConfig.checkoutSettings.features["CHECKOUT-8392.fix_billing_creation_in_checkout"])||void 0===s||s;if(!c)throw new Nn(Mn.MissingCheckout);var l=u.customer.getCustomer();if(l&&!l.isGuest)throw new ar;var p,h=u.billingAddress.getBillingAddress();if(h){h.country;var f=(0,o.__rest)(h,["country"]);p=(0,o.__assign)((0,o.__assign)({},f),e)}else p=e;var g=!(0,_.isEmpty)(h);return(0,E.merge)((0,E.concat)((0,E.of)((0,a.createAction)(T.ContinueAsGuestRequested)),(0,E.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._createOrUpdateBillingAddress(c.id,p,d,g,t)];case 1:return e=n.sent().body,[2,(0,a.createAction)(T.ContinueAsGuestSucceeded,e)]}}))}))}))).pipe((0,b.catchError)((function(e){return or(T.ContinueAsGuestFailed,e)}))),n._updateCustomerConsent(e,t))}},e.prototype.updateAddress=function(e,t){var n=this;return function(r){return E.Observable.create((function(i){var s,u,c=r.getState(),d=c.checkout.getCheckout(),l=null===(u=null===(s=c.config.getConfig())||void 0===s?void 0:s.storeConfig.checkoutSettings.features["CHECKOUT-8392.fix_billing_creation_in_checkout"])||void 0===u||u;if(!d)throw new Nn(Mn.MissingCheckout);i.next((0,a.createAction)(T.UpdateBillingAddressRequested));var p=c.billingAddress.getBillingAddress(),h=!(0,_.isEmpty)(p),f=(0,o.__assign)((0,o.__assign)({},e),{email:void 0===e.email&&p?p.email:e.email});p&&p.id&&(f.id=p.id),n._createOrUpdateBillingAddress(d.id,f,l,h,t).then((function(e){var t=e.body;i.next((0,a.createAction)(T.UpdateBillingAddressSucceeded,t)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(T.UpdateBillingAddressFailed,e))}))}))}},e.prototype._updateCustomerConsent=function(e,t){var n=e.email,r=e.acceptsAbandonedCartEmails,i=e.acceptsMarketingNewsletter;return null==r&&null==i?(0,E.empty)():this._subscriptionActionCreator.updateSubscriptions({email:n,acceptsMarketingNewsletter:i||!1,acceptsAbandonedCartEmails:r||!1},t)},e.prototype._createOrUpdateBillingAddress=function(e,t,n,r,i){return n?r?this._requestSender.updateAddress(e,t,i):this._requestSender.createAddress(e,t,i):t.id?this._requestSender.updateAddress(e,t,i):this._requestSender.createAddress(e,t,i)},e}();const ur=sr;var cr={include:["cart.lineItems.physicalItems.options","cart.lineItems.digitalItems.options","customer","promotions.banners"].join(",")},dr=function(){function e(e){this._requestSender=e}return e.prototype.createAddress=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/api/storefront/checkouts/"+e+"/billing-address",a=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.post(i,{body:t,params:cr,headers:a,timeout:r})},e.prototype.updateAddress=function(e,t,n){var r=(void 0===n?{}:n).timeout,i=t.id,a=(0,o.__rest)(t,["id"]),s="/api/storefront/checkouts/"+e+"/billing-address/"+i,u=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.put(s,{params:cr,body:a,headers:u,timeout:r})},e}();const lr=dr;var pr=function(){function e(e){this._requestSender=e}return e.prototype.createBuyNowCart=function(e,t){var n=(void 0===t?{}:t).timeout,r=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.post("/api/storefront/carts",{body:e,headers:r,timeout:n})},e}();const hr=pr;var fr=function(){function e(e,t,n){this._checkoutRequestSender=e,this._configActionCreator=t,this._formFieldsActionCreator=n}return e.prototype.loadCheckout=function(e,t){var n=this;return function(r){return(0,E.concat)((0,E.of)((0,a.createAction)(P.LoadCheckoutRequested)),(0,E.merge)(n._configActionCreator.loadConfig({useCache:!0,timeout:null==t?void 0:t.timeout,params:{checkoutId:e}}),n._formFieldsActionCreator.loadFormFields({useCache:!0,timeout:null==t?void 0:t.timeout})),(0,E.defer)((function(){return n._checkoutRequestSender.loadCheckout(e,t).then((function(e){var t=e.body;return(0,a.createAction)(P.LoadCheckoutSucceeded,n._shouldTransformCustomerAddress(r.getState().config.getStoreConfigOrThrow())?n._transformCustomerAddresses(t):t)}))}))).pipe((0,b.catchError)((function(e){return or(P.LoadCheckoutFailed,e)})))}},e.prototype.loadDefaultCheckout=function(e){var t=this;return function(n){return(0,E.concat)((0,E.of)((0,a.createAction)(P.LoadCheckoutRequested)),(0,E.merge)(t._configActionCreator.loadConfig({useCache:!0,timeout:null==e?void 0:e.timeout}),t._formFieldsActionCreator.loadFormFields({useCache:!0,timeout:null==e?void 0:e.timeout})),(0,E.defer)((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=n.getState(),!(r=t.config.getContextConfig())||!r.checkoutId)throw new Nn(Mn.MissingCheckoutConfig);return[4,this._checkoutRequestSender.loadCheckout(r.checkoutId,e)];case 1:return i=o.sent().body,[2,(0,a.createAction)(P.LoadCheckoutSucceeded,this._shouldTransformCustomerAddress(t.config.getStoreConfigOrThrow())?this._transformCustomerAddresses(i):i)]}}))}))}))).pipe((0,b.catchError)((function(e){return or(P.LoadCheckoutFailed,e)})))}},e.prototype.updateCheckout=function(e,t){var n=this;return function(r){return new E.Observable((function(i){var o=r.getState().checkout.getCheckout();if(!o)throw new Nn(Mn.MissingCheckout);i.next((0,a.createAction)(P.UpdateCheckoutRequested)),n._checkoutRequestSender.updateCheckout(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(P.UpdateCheckoutSucceeded,t)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(P.UpdateCheckoutFailed,e))}))}))}},e.prototype.loadCurrentCheckout=function(e){var t=this;return function(n){var r=n.getState().checkout.getCheckout();if(!r)throw new Nn(Mn.MissingCheckout);return t.loadCheckout(r.id,e)(n)}},e.prototype._shouldTransformCustomerAddress=function(e){var t;return null===(t=e.checkoutSettings.features["CHECKOUT-8183.set_shouldSaveAddress_false_for_existing_address"])||void 0===t||t},e.prototype._transformCustomerAddresses=function(e){return(0,o.__assign)((0,o.__assign)({},e),{customer:(0,o.__assign)((0,o.__assign)({},e.customer),{addresses:e.customer.addresses.map((function(e){return(0,o.__assign)((0,o.__assign)({},e),{shouldSaveAddress:!1})}))})})},e}();const gr=fr;function mr(e){return(0,_.uniq)(e).join(",")}function _r(e,t){return void 0===t&&(t=[]),Array.isArray(t)?mr((0,o.__spreadArrays)(e,t)):function(e,t){var n=(0,_.keys)((0,_.pickBy)(t,(function(e){return!e}))),r=(0,_.keys)((0,_.filter)(t));return mr((0,o.__spreadArrays)((0,_.difference)(e,n),r))}(e,t)}const yr=["cart.lineItems.physicalItems.options","cart.lineItems.digitalItems.options","customer","customer.customerGroup","payments","promotions.banners"],vr=function(e){function t(t){var n=e.call(this,t,{message:t.body.title})||this;return n.name="CheckoutNotAvailableError",n.type="checkout_not_available",n}return(0,o.__extends)(t,e),t}(g);var Cr=function(){function e(e){this._requestSender=e}return e.prototype.loadCheckout=function(e,t){var n=void 0===t?{}:t,r=n.params,i=(void 0===r?{}:r).include,a=n.timeout,s="/api/storefront/checkout/"+e,u=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.get(s,{params:{include:_r(yr,i)},headers:u,timeout:a}).catch((function(e){if(e.status>=400&&e.status<500)throw new vr(e);throw e}))},e.prototype.updateCheckout=function(e,t,n){var r=void 0===n?{}:n,i=r.params,a=(void 0===i?{}:i).include,s=r.timeout,u="/api/storefront/checkout/"+e,c=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.put(u,{params:{include:_r(yr,a)},body:t,headers:c,timeout:s})},e}();const Sr=Cr,Ir=function(){function e(){}return e.prototype.isEqual=function(e,t){return(0,_.isEqual)(this._normalize(e),this._normalize(t))},e.prototype._normalize=function(e){return{cartAmount:e.cartAmount,currency:e.currency,id:e.id,lineItems:{digitalItems:e.lineItems.digitalItems.slice().sort((function(e,t){return(""+e.productId+e.variantId).localeCompare(""+t.productId+t.variantId)})).map((function(e){return{extendedSalePrice:e.extendedSalePrice,productId:e.productId,quantity:e.quantity,variantId:e.variantId}})),giftCertificates:e.lineItems.giftCertificates.slice().sort((function(e,t){return(""+e.id).localeCompare(""+t.id)})).map((function(e){return{amount:e.amount,recipient:e.recipient}})),physicalItems:e.lineItems.physicalItems.slice().sort((function(e,t){return(""+e.productId+e.variantId).localeCompare(""+t.productId+t.variantId)})).map((function(e){return{extendedSalePrice:e.extendedSalePrice,productId:e.productId,quantity:e.quantity,variantId:e.variantId,giftWrapping:e.giftWrapping}}))}}},e}(),wr=function(e){function t(t,n){var r=e.call(this,"An update to your shopping cart has been detected and your available shipping costs have been updated.")||this;return r.name="CartChangedError",r.type="cart_changed",r.data={previous:t,updated:n},r}return(0,o.__extends)(t,e),t}(p),Er=function(){function e(e){this._checkoutRequestSender=e}return e.prototype.validate=function(e,t){var n=this;if(!e)throw new Nn(Mn.MissingCheckout);return this._checkoutRequestSender.loadCheckout(e.id,t).then((function(t){var r=new Ir;if(!(e.outstandingBalance===t.body.outstandingBalance&&n._compareCoupons(e.coupons,t.body.coupons)&&n._compareGiftCertificates(e.giftCertificates,t.body.giftCertificates)&&r.isEqual(e.cart,t.body.cart)))throw new wr(n._getComparableCheckout(e),n._getComparableCheckout(t.body))}))},e.prototype._compareCoupons=function(e,t){return(0,_.isEqual)((0,_.map)(e,"code"),(0,_.map)(t,"code"))},e.prototype._compareGiftCertificates=function(e,t){return(0,_.isEqual)((0,_.map)(e,"code"),(0,_.map)(t,"code"))},e.prototype._getComparableCheckout=function(e){var t=e.cart,n=e.coupons,r=e.giftCertificates,i=e.outstandingBalance;return{cart:{cartAmount:t.cartAmount,currency:t.currency,lineItems:t.lineItems},coupons:n,giftCertificates:r,outstandingBalance:i}},e}(),br=function(){function e(e){this._configRequestSender=e}return e.prototype.loadConfig=function(e){var t=this;return E.Observable.create((function(n){n.next((0,a.createAction)(X.LoadConfigRequested)),t._configRequestSender.loadConfig(e).then((function(e){n.next((0,a.createAction)(X.LoadConfigSucceeded,e.body)),n.complete()})).catch((function(e){n.error((0,a.createErrorAction)(X.LoadConfigFailed,e))}))}))},(0,o.__decorate)([Kn],e.prototype,"loadConfig",null),e}();var Pr=function(){function e(e){this._requestSender=e}return e.prototype.loadConfig=function(e){var t=void 0===e?{}:e,n=t.timeout,r=t.params;return this._requestSender.get("/api/storefront/checkout-settings",{timeout:n,headers:(0,o.__assign)({Accept:$n.JsonV1,"X-API-INTERNAL":er},tr),params:r}).catch((function(e){if(e.status>=400&&e.status<500)throw new vr(e);throw e}))},e}();const Ar=Pr;function Or(e){var t=e;return"object"==typeof t&&"object"==typeof t.payload&&"string"==typeof t.payload.token}var Tr=function(){function e(e,t,n){this._customerRequestSender=e,this._checkoutActionCreator=t,this._spamProtectionActionCreator=n}return e.prototype.createCustomer=function(e,t){var n=this;return function(r){var i=r.getState().config.getStoreConfigOrThrow().checkoutSettings.isStorefrontSpamProtectionEnabled,s=function(i){return(0,E.from)(n._customerRequestSender.createAccount((0,o.__assign)((0,o.__assign)({},e),{token:i}),t)).pipe((0,b.switchMap)((function(){return(0,E.concat)(n._checkoutActionCreator.loadCurrentCheckout(t)(r),(0,E.of)((0,a.createAction)(ye.CreateCustomerSucceeded)))})))};return(0,E.concat)((0,E.of)((0,a.createAction)(ye.CreateCustomerRequested)),i?(0,E.from)(n._spamProtectionActionCreator.execute()(r)).pipe((0,b.switchMap)((function(e){var t;return Or(e)?(0,E.concat)((0,E.of)(e),s(null===(t=e.payload)||void 0===t?void 0:t.token)):(0,E.of)(e)}))):s()).pipe((0,b.catchError)((function(e){return or(ye.CreateCustomerFailed,e)})))}},e.prototype.createAddress=function(e,t){var n=this;return(0,E.concat)((0,E.of)((0,a.createAction)(ye.CreateCustomerAddressRequested)),(0,E.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._customerRequestSender.createAddress(e,t)];case 1:return n=r.sent().body,[2,(0,a.createAction)(ye.CreateCustomerAddressSucceeded,n)]}}))}))}))).pipe((0,b.catchError)((function(e){return or(ye.CreateCustomerAddressFailed,e)})))},e.prototype.signInCustomer=function(e,t){var n=this;return function(r){return(0,E.concat)((0,E.of)((0,a.createAction)(ye.SignInCustomerRequested)),(0,E.from)(n._customerRequestSender.signInCustomer(e,t)).pipe((0,b.switchMap)((function(e){var i=e.body;return(0,E.concat)(n._checkoutActionCreator.loadCurrentCheckout(t)(r),(0,E.of)((0,a.createAction)(ye.SignInCustomerSucceeded,i.data)))})))).pipe((0,b.catchError)((function(e){return or(ye.SignInCustomerFailed,e)})))}},e.prototype.signOutCustomer=function(e){var t=this;return function(n){return(0,E.concat)((0,E.of)((0,a.createAction)(ye.SignOutCustomerRequested)),(0,E.from)(t._customerRequestSender.signOutCustomer(e)).pipe((0,b.switchMap)((function(r){var i=r.body;return(0,E.concat)(t._checkoutActionCreator.loadCurrentCheckout(e)(n),(0,E.of)((0,a.createAction)(ye.SignOutCustomerSucceeded,i.data)))})))).pipe((0,b.catchError)((function(e){return or(ye.SignOutCustomerFailed,e)})))}},e}();const Rr=Tr;var kr=function(){function e(e){this._requestSender=e}return e.prototype.createAccount=function(e,t){var n=(void 0===t?{}:t).timeout;return this._requestSender.post("/api/storefront/customer",{timeout:n,headers:tr,body:e})},e.prototype.createAddress=function(e,t){var n=(void 0===t?{}:t).timeout;return this._requestSender.post("/api/storefront/customer-address",{timeout:n,headers:tr,body:e})},e.prototype.signInCustomer=function(e,t){var n=(void 0===t?{}:t).timeout;return this._requestSender.post("/internalapi/v1/checkout/customer",{timeout:n,headers:tr,body:e})},e.prototype.signOutCustomer=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.delete("/internalapi/v1/checkout/customer",{timeout:t,headers:tr})},e}();const Dr=kr;var Mr=function(){function e(e){this._formFieldsRequestSender=e}return e.prototype.loadFormFields=function(e){var t=this;return(0,E.concat)((0,E.of)((0,a.createAction)(ze.LoadFormFieldsRequested)),(0,E.defer)((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._formFieldsRequestSender.loadFields(e)];case 1:return t=n.sent().body,[2,(0,a.createAction)(ze.LoadFormFieldsSucceeded,t)]}}))}))}))).pipe((0,b.catchError)((function(e){return or(ze.LoadFormFieldsFailed,e)})))},(0,o.__decorate)([Kn],e.prototype,"loadFormFields",null),e}();const Nr=Mr;var Lr=function(){function e(e){this._requestSender=e}return e.prototype.loadFields=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.get("/api/storefront/form-fields",{timeout:t,headers:(0,o.__assign)({Accept:$n.JsonV1,"X-API-INTERNAL":er},tr)})},e}();const zr=Lr,Ur=function(e){var t=this,n=new Promise((function(e,n){t.cancel=n}));this.promise=Promise.race([e,n])},Fr=function(e){function t(t){var n=e.call(this,t||"Unable to proceed because the required element is unexpectedly detached from the page.")||this;return n.name="UnexpectedDetachmentError",n.type="unexpected_detachment",n}return(0,o.__extends)(t,e),t}(p);var Br=function(){function e(e){this._mutationObserver=e}return e.prototype.ensurePresence=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:n=new Ur(t),(r=this._mutationObserver.create((function(t){t.forEach((function(t){0!==Array.from(t.removedNodes).filter((function(t){return e.some((function(e){return t===e||t.contains(e)}))})).length&&n.cancel(new Fr)}))}))).observe(document.body,{childList:!0,subtree:!0}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,n.promise];case 2:return i=o.sent(),r.disconnect(),[2,i];case 3:throw a=o.sent(),r.disconnect(),a;case 4:return[2]}}))}))},e}();const qr=Br;var xr=function(){function e(e){void 0===e&&(e=window),this._window=e}return e.prototype.create=function(e){return new this._window.MutationObserver(e)},e}();const Gr=function(e){function t(t){var n=e.call(this,t||"Invalid arguments have been provided.")||this;return n.name="InvalidArgumentError",n.type="invalid_argument",n}return(0,o.__extends)(t,e),t}(p);function Vr(e){if(!/^(https?:)?\/\//.test(e))throw new Gr("The provided URL must be absolute.");var t=document.createElement("a");t.href=e;var n=t.port&&-1!==e.indexOf(t.hostname+":"+t.port)?t.port:"";return{hash:t.hash,hostname:t.hostname,href:t.href,origin:t.protocol+"//"+t.hostname+(n?":"+n:""),pathname:t.pathname,port:n,protocol:t.protocol,search:t.search}}function Hr(e,t){return e.type===t}const jr=function(){function e(e,t,n){this._targetWindow=t,this._context=n,this._targetOrigin="*"===e?"*":Vr(e).origin}return e.prototype.post=function(e,t){var n=this,r=this._targetWindow;if(window!==r){if(!r)throw new Error("Unable to post message because target window is not set.");var i=t&&(0,E.fromEvent)(window,"message").pipe((0,b.filter)((function(e){return e.origin===n._targetOrigin&&Hr(e.data,e.data.type)&&-1!==[t.successType,t.errorType].indexOf(e.data.type)})),(0,b.map)((function(e){if(t.errorType===e.data.type)throw e.data;return e.data})),(0,b.take)(1)).toPromise();return r.postMessage((0,o.__assign)((0,o.__assign)({},e),{context:this._context}),this._targetOrigin),i}},e.prototype.setTarget=function(e){this._targetWindow=e},e.prototype.setContext=function(e){this._context=e},e}(),Yr=function(e,t,n){return t&&n?Wr(0,t,n):function(e){var t=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,o.__extends)(t,e),t}(e);return Object.getOwnPropertyNames(e.prototype).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e.prototype,n);r&&"constructor"!==n&&Object.defineProperty(t.prototype,n,Wr(e.prototype,n,r))})),t}(e)};function Wr(e,t,n){if("function"!=typeof n.value)return n;var r=n.value;return{get:function(){var e=r.bind(this);return Object.defineProperty(this,t,(0,o.__assign)((0,o.__assign)({},n),{value:e})),e},set:function(e){r=e}}}var Kr=function(){function e(e){var t;this._sourceOrigins=[Vr(e).origin,(t=Vr(e),Vr(0===t.hostname.indexOf("www")?t.href:t.href.replace(t.hostname,"www."+t.hostname))).origin],this._isListening=!1,this._listeners={}}return e.prototype.listen=function(){this._isListening||(this._isListening=!0,window.addEventListener("message",this._handleMessage))},e.prototype.stopListen=function(){this._isListening&&(this._isListening=!1,window.removeEventListener("message",this._handleMessage))},e.prototype.addListener=function(e,t){var n=this._listeners[e];n||(this._listeners[e]=n=[]),-1===n.indexOf(t)&&n.push(t)},e.prototype.removeListener=function(e,t){var n=this._listeners[e];if(n){var r=n.indexOf(t);r>=0&&n.splice(r,1)}},e.prototype.trigger=function(e,t){var n=this._listeners[e.type];n&&n.forEach((function(n){return t?n(e,t):n(e)}))},e.prototype._handleMessage=function(e){if(-1!==this._sourceOrigins.indexOf(e.origin)&&Hr(e.data,e.data.type)){var t=e.data,n=t.context,r=(0,o.__rest)(t,["context"]);this.trigger(r,n)}},(0,o.__decorate)([Yr],e.prototype,"_handleMessage",null),e}();const Zr=Kr,Qr=function(e){function t(){var t=e.call(this,"You haven't complete our spam protection challenge. Please try again.")||this;return t.name="SpamProtectionChallengeNotCompletedError",t.type="spam_protection_challenge_not_completed",t}return(0,o.__extends)(t,e),t}(p),Jr=function(e){function t(){var t=e.call(this,"Please complete our human verification challenge and try again.")||this;return t.name="CardingProtectionChallengeNotCompletedError",t.type="carding_protection_challenge_not_completed",t}return(0,o.__extends)(t,e),t}(p),Xr=function(e){function t(){var t=e.call(this,"We were not able to verify that you are not a robot. Please try again.")||this;return t.name="CardingProtectionFailedError",t.type="carding_protection_failed",t}return(0,o.__extends)(t,e),t}(p);var $r=function(){function e(e){this._googleRecaptcha=e}return e.prototype.handle=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){return"string"==typeof e?[2,this.handleWithRecaptchaSitekey(e,t)]:[2,this.handleWithPaymentHumanVerificationRequestError(e)]}))}))},e.prototype.handleWithPaymentHumanVerificationRequestError=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:if(!this._isPaymentHumanVerificationRequest(e))throw e;return[4,this._initialize(e.body.additional_action_required.data.key)];case 1:return t.sent(),[2,this._performRecaptcha()]}}))}))},e.prototype.handleWithRecaptchaSitekey=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("recaptcha_v2"!==e)throw Error("Human verification method is not supported.");if(!t)throw Error("Recaptcha site key is missing.");return[4,this._initialize(t)];case 1:return n.sent(),[2,this._performRecaptcha()]}}))}))},e.prototype._performRecaptcha=function(){var e=this;return this._googleRecaptcha.execute().pipe((0,b.take)(1)).pipe((0,b.switchMap)((function(t){var n=t.error,r=t.token;return(0,o.__awaiter)(e,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){if(n instanceof Qr)throw new Jr;if(n||!r)throw new Xr;return[2,{type:"recaptcha_v2_verification",data:{human_verification_token:r}}]}))}))}))).toPromise()},e.prototype._initialize=function(e){var t="cardingProtectionContainer",n=document.getElementById(t);return n&&n.parentNode&&n.parentNode.removeChild(n),(n=document.createElement("div")).setAttribute("id",t),document.body.appendChild(n),this._googleRecaptcha.load(t,e)},e.prototype._isPaymentHumanVerificationRequest=function(e){var t=e.body||{},n=t.additional_action_required;return"additional_action_required"===t.status&&n&&"recaptcha_v2_verification"===n.type},e}();const ei=$r;var ti;!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(ti||(ti={}));const ni=function(e){function t(t){var n=e.call(this,function(e){switch(e){case ti.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case ti.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case ti.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case ti.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(t))||this;return n.subtype=t,n.name="NotInitializedError",n.type="not_initialized",n}return(0,o.__extends)(t,e),t}(p),ri=function(e){function t(){var t=e.call(this,"We were not able to complete your spam protection verification. Please try again.")||this;return t.name="SpamProtectionFailedError",t.type="spam_protection_failed",t}return(0,o.__extends)(t,e),t}(p),ii=function(e){function t(){var t=e.call(this,"Spam protection is not loaded. Please try again.")||this;return t.name="SpamProtectionNotLoadedError",t.type="spam_protection_failed",t}return(0,o.__extends)(t,e),t}(p),oi=function(){function e(e,t){var n=this;this.googleRecaptchaScriptLoader=e,this.mutationObserverFactory=t,this._memoized=(0,Dn.memoize)((function(e,t,r){var i=new E.Subject;if(!r)throw new Error;return n._widgetId=e.render(r.id,{sitekey:t,size:"invisible",callback:function(){i.next({token:e.getResponse(n._widgetId)}),e.reset(n._widgetId)},"error-callback":function(){i.next({error:new ri})}}),i}),{isEqual:function(e,t){return e===t}})}return e.prototype.load=function(e,t){var n=this;return this.googleRecaptchaScriptLoader.load().then((function(r){r&&(n._event$=n._memoized(r,t,document.getElementById(e)),n._recaptcha=r)}))},e.prototype.execute=function(){var e=this;return(0,E.defer)((function(){var t=e._event$,n=e._recaptcha;if(!t||!n)throw new ni(ti.SpamProtectionNotInitialized);return(0,E.defer)((function(){var e=document.querySelector('iframe[src*="bframe"]');return e?(0,E.of)(e):(0,E.throwError)(new ii)})).pipe((0,b.retryWhen)((function(e){return e.pipe((0,b.delay)(250),(0,b.switchMap)((function(e,t){return t<28?(0,E.of)(e):(0,E.throwError)(e)})))})),(0,b.switchMap)((function(r){return e._watchRecaptchaChallengeWindow(t,r),n.execute(e._widgetId),t})),(0,b.catchError)((function(e){return(0,E.of)({error:e})})))}))},e.prototype._watchRecaptchaChallengeWindow=function(e,t){var n=t.parentElement;if(!n)throw new ii;var r=n.parentElement;if(!r)throw new ii;this.mutationObserverFactory.create((function(){"hidden"===r.style.visibility&&e.next({error:new Qr})})).observe(r,{attributes:!0,attributeFilter:["style"]})},e}(),ai=function(){function e(e,t){void 0===t&&(t=window),this._scriptLoader=e,this._window=t}return e.prototype.load=function(){return this._loadPromise||(this._loadPromise=this._loadScript()),this._loadPromise},e.prototype._loadScript=function(){var e=this,t="initRecaptcha",n=["onload="+t,"render=explicit"].join("&");return new Promise((function(r,i){e._window[t]=function(){return r(e._window.grecaptcha)},e._scriptLoader.loadScript("//www.google.com/recaptcha/api.js?"+n).catch((function(t){e._loadPromise=void 0,i(t)}))}))},e}();function si(e){return new oi(new ai(e),new xr)}const ui=function(e){function t(t){var n=e.call(this,t||"Unable to proceed due to invalid configuration provided for the hosted payment form.")||this;return n.name="InvalidHostedFormConfigError",n.type="invalid_hosted_form_config",n}return(0,o.__extends)(t,e),t}(p),ci=function(e){function t(t){var n=e.call(this,t||"Unable to proceed due to an unknown error with the hosted payment form.")||this;return n.name="InvalidHostedFormError",n.type="invalid_hosted_form",n}return(0,o.__extends)(t,e),t}(p);var di=function(e){function t(t){var n=e.call(this,(0,o.__spreadArrays)(["Unable to proceed due to invalid user input values"],(0,_.flatMap)((0,_.values)(t),(function(e){return(0,_.map)(e,(function(e){return e.message}))}))).join(". "))||this;return n.errors=t,n.name="InvalidHostedFormValueError",n.type="invalid_hosted_form_value",n}return(0,o.__extends)(t,e),t}(p);const li=di;var pi,hi;!function(e){e.AttachRequested="HOSTED_FIELD:ATTACH_REQUESTED",e.SubmitRequested="HOSTED_FIELD:SUBMITTED_REQUESTED",e.ValidateRequested="HOSTED_FIELD:VALIDATE_REQUESTED",e.StoredCardRequested="HOSTED_FIELD:STORED_CARD_REQUESTED"}(pi||(pi={})),function(e){e.AttachSucceeded="HOSTED_INPUT:ATTACH_SUCCEEDED",e.AttachFailed="HOSTED_INPUT:ATTACH_FAILED",e.BinChanged="HOSTED_INPUT:BIN_CHANGED",e.Blurred="HOSTED_INPUT:BLURRED",e.Changed="HOSTED_INPUT:CHANGED",e.CardTypeChanged="HOSTED_INPUT:CARD_TYPE_CHANGED",e.Entered="HOSTED_INPUT:ENTERED",e.Focused="HOSTED_INPUT:FOCUSED",e.SubmitSucceeded="HOSTED_INPUT:SUBMIT_SUCCEEDED",e.SubmitFailed="HOSTED_INPUT:SUBMIT_FAILED",e.Validated="HOSTED_INPUT:VALIDATED",e.StoredCardSucceeded="HOSTED_INPUT:STORED_CARD_SUCCEEDED",e.StoredCardFailed="HOSTED_INPUT:STORED_CARD_FAILED"}(hi||(hi={}));var fi=function(){function e(e,t,n,r,i,o,a,s,u){this._type=e,this._containerId=t,this._placeholder=n,this._accessibilityLabel=r,this._styles=i,this._eventPoster=o,this._eventListener=a,this._detachmentObserver=s,this._cardInstrument=u,this._iframe=document.createElement("iframe"),this._iframe.src="/checkout/payment/hosted-field?version=1.661.5",this._iframe.style.border="none",this._iframe.style.height="100%",this._iframe.style.overflow="hidden",this._iframe.style.width="100%"}return e.prototype.getType=function(){return this._type},e.prototype.attach=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n=this;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:if(!(e=document.getElementById(this._containerId)))throw new ui("Unable to proceed because the provided container ID is not valid.");return e.appendChild(this._iframe),this._eventListener.listen(),t=(0,E.fromEvent)(this._iframe,"load").pipe((0,b.switchMap)((function(e){var t=e.target;return(0,o.__awaiter)(n,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if(!(e=t&&t.contentWindow))throw new Error("The content window of the iframe cannot be accessed.");return this._eventPoster.setTarget(e),[4,this._eventPoster.post({type:pi.AttachRequested,payload:{accessibilityLabel:this._accessibilityLabel,cardInstrument:this._cardInstrument,fontUrls:this._getFontUrls(),placeholder:this._placeholder,styles:this._styles,origin:document.location.origin,type:this._type}},{successType:hi.AttachSucceeded,errorType:hi.AttachFailed})];case 1:return n.sent(),[2]}}))}))})),(0,b.take)(1)).toPromise(),[4,this._detachmentObserver.ensurePresence([this._iframe],t)];case 1:return r.sent(),[2]}}))}))},e.prototype.detach=function(){this._iframe.parentElement&&(this._iframe.parentElement.removeChild(this._iframe),this._eventListener.stopListen())},e.prototype.submitForm=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=this._eventPoster.post({type:pi.SubmitRequested,payload:{fields:e,data:t}},{successType:hi.SubmitSucceeded,errorType:hi.SubmitFailed}),[4,this._detachmentObserver.ensurePresence([this._iframe],n)];case 1:return[2,i.sent()];case 2:if(r=i.sent(),this._isSubmitErrorEvent(r)){if("hosted_form_error"===r.payload.error.code)throw new ci(r.payload.error.message);if(r.payload.response)throw v(r.payload.response);throw new Error(r.payload.error.message)}throw r;case 3:return[2]}}))}))},e.prototype.submitStoredCardForm=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){return n=this._eventPoster.post({type:pi.StoredCardRequested,payload:{fields:e,data:t}},{successType:hi.StoredCardSucceeded,errorType:hi.StoredCardFailed}),[2,this._detachmentObserver.ensurePresence([this._iframe],n)]}))}))},e.prototype.validateForm=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e=this._eventPoster.post({type:pi.ValidateRequested},{successType:hi.Validated}),[4,this._detachmentObserver.ensurePresence([this._iframe],e)];case 1:if(!(t=n.sent().payload).isValid)throw new li(t.errors);return[2]}}))}))},e.prototype._getFontUrls=function(){var e=this,t="fonts.googleapis.com",n=document.querySelectorAll("link[href*='"+t+"'][rel='stylesheet']");return Array.prototype.slice.call(n).filter((function(e){return Vr(e.href).hostname===t})).filter((function(t){return(0,_.values)(e._styles).map((function(e){return e&&e.fontFamily})).filter((function(e){return"string"==typeof e})).some((function(e){return e.split(/,\s/).some((function(e){return-1!==t.href.indexOf(e.replace(" ","+"))}))}))})).map((function(e){return e.href}))},e.prototype._isSubmitErrorEvent=function(e){return e.type===hi.SubmitFailed},e}();const gi=fi;var mi=function(){function e(e,t,n,r,i){var a=this;this._fields=e,this._eventListener=t,this._payloadTransformer=n,this._eventCallbacks=r,this._paymentHumanVerificationHandler=i,this._handleEnter=function(e){var t=e.payload;return(0,o.__awaiter)(a,void 0,void 0,(function(){var e,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.validate()];case 1:return r.sent(),[3,3];case 2:if("InvalidHostedFormValueError"!==(e=r.sent()).name)throw e;return[3,3];case 3:return(void 0===(n=this._eventCallbacks.onEnter)?_.noop:n)(t),[2]}}))}))};var s=this._eventCallbacks,u=s.onBlur,c=void 0===u?_.noop:u,d=s.onCardTypeChange,l=void 0===d?_.noop:d,p=s.onFocus,h=void 0===p?_.noop:p,f=s.onValidate,g=void 0===f?_.noop:f;this._eventListener.addListener(hi.Blurred,(function(e){var t=e.payload;return c(t)})),this._eventListener.addListener(hi.CardTypeChanged,(function(e){var t=e.payload;return l(t)})),this._eventListener.addListener(hi.Focused,(function(e){var t=e.payload;return h(t)})),this._eventListener.addListener(hi.Validated,(function(e){var t=e.payload;return g(t)})),this._eventListener.addListener(hi.Entered,this._handleEnter),this._eventListener.addListener(hi.CardTypeChanged,(function(e){var t=e.payload;return a._cardType=t.cardType})),this._eventListener.addListener(hi.BinChanged,(function(e){var t=e.payload;return a._bin=t.bin}))}return e.prototype.getBin=function(){return this._bin},e.prototype.getCardType=function(){return this._cardType},e.prototype.attach=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return this._eventListener.listen(),e=this._getFirstField(),t=(0,_.without)(this._fields,e),[4,e.attach()];case 1:return n.sent(),[4,Promise.all(t.map((function(e){return e.attach()})))];case 2:return n.sent(),[2]}}))}))},e.prototype.detach=function(){this._eventListener.stopListen(),this._fields.forEach((function(e){e.detach()}))},e.prototype.submit=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,5]),[4,this._getFirstField().submitForm(this._fields.map((function(e){return e.getType()})),this._payloadTransformer.transform(e,t))];case 1:case 4:return[2,i.sent()];case 2:return n=i.sent(),[4,this._paymentHumanVerificationHandler.handle(n)];case 3:return r=i.sent(),[4,this._getFirstField().submitForm(this._fields.map((function(e){return e.getType()})),this._payloadTransformer.transform(e,r))];case 5:return[2]}}))}))},e.prototype.submitStoredCard=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){return[2,this._getFirstField().submitStoredCardForm(e.fields,e.data)]}))}))},e.prototype.validate=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this._getFirstField().validateForm()]}))}))},e.prototype._getFirstField=function(){var e=this._fields[0];if(!e)throw new ui("Unable to proceed because the payment form has no field defined.");return e},e}();const _i=mi;function yi(e){return Boolean(e.instrumentId)}const vi=function(){function e(e){this._store=e}return e.prototype.transform=function(e,t){var n=this._store.getState(),r=n.checkout.getCheckout(),i=n.config.getConfig(),o=n.instruments.getInstrumentsMeta(),a=n.order.getOrder(),s=n.order.getOrderMeta(),u=(0,_.omit)(e.paymentData,"ccExpiry","ccName","ccNumber","ccCvv"),c=n.paymentMethods.getPaymentMethod(e.methodId,e.gatewayId),d=n.paymentMethods.getPaymentMethodsMeta(),l=o&&u&&yi(u)?n.payment.getPaymentToken()+", "+o.vaultAccessToken:n.payment.getPaymentToken();if(!l)throw new Nn(Mn.MissingPaymentToken);return{additionalAction:t,authToken:l,checkout:r,config:i,order:a,orderMeta:s,payment:u,paymentMethod:c,paymentMethodMeta:d}},e}(),Ci=function(){function e(e){this._store=e}return e.prototype.create=function(e,t){var n=this,r=Object.keys(t.fields).reduce((function(r,i){var a=t.fields[i];return a?(0,o.__spreadArrays)(r,[new gi(i,a.containerId,a.placeholder||"",a.accessibilityLabel||"",t.styles||{},new jr(e),new Zr(e),new qr(new xr),"instrumentId"in a?n._getCardInstrument(a.instrumentId):void 0)]):r}),[]);return new _i(r,new Zr(e),new vi(this._store),(0,_.pick)(t,"onBlur","onEnter","onFocus","onCardTypeChange","onValidate"),new ei(si((0,ir.createScriptLoader)())))},e.prototype._getCardInstrument=function(e){var t=(0,this._store.getState().instruments.getCardInstrument)(e);if(!t)throw new Nn(Mn.MissingPaymentInstrument);return t},e}(),Si=function(e){function t(){var t=e.call(this,"You haven't complete our spam check. Please try again.")||this;return t.name="SpamProtectionNotCompletedError",t.type="spam_protection_not_completed",t}return(0,o.__extends)(t,e),t}(p),Ii=function(){function e(e,t){this._orderRequestSender=e,this._checkoutValidator=t}return e.prototype.loadOrder=function(e,t){var n=this;return new E.Observable((function(r){r.next((0,a.createAction)(se.LoadOrderRequested)),n._orderRequestSender.loadOrder(e,t).then((function(e){r.next((0,a.createAction)(se.LoadOrderSucceeded,e.body)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(se.LoadOrderFailed,e))}))}))},e.prototype.loadOrderPayments=function(e,t){var n=this;return new E.Observable((function(r){r.next((0,a.createAction)(se.LoadOrderPaymentsRequested)),n._orderRequestSender.loadOrder(e,t).then((function(e){r.next((0,a.createAction)(se.LoadOrderPaymentsSucceeded,e.body)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(se.LoadOrderPaymentsFailed,e))}))}))},e.prototype.loadCurrentOrder=function(e){var t=this;return function(n){return(0,E.defer)((function(){var r=t._getCurrentOrderId(n.getState());if(!r)throw new Nn(Mn.MissingOrderId);return t.loadOrder(r,e)}))}},e.prototype.submitOrder=function(e,t){var n=this;return function(r){return(0,E.concat)((0,E.of)((0,a.createAction)(se.SubmitOrderRequested)),(0,E.defer)((function(){var i=r.getState(),s=i.config.getExternalSource(),u=i.config.getVariantIdentificationToken(),c=i.checkout.getCheckout();if(!c)throw new Nn(Mn.MissingCheckout);if(c.shouldExecuteSpamCheck)throw new Si;return(0,E.from)(n._checkoutValidator.validate(c,t).then((function(){return n._orderRequestSender.submitOrder(n._mapToOrderRequestBody(null!=e?e:{},c.id,c.customerMessage,s),(0,o.__assign)((0,o.__assign)({},t),{headers:{checkoutVariant:u}}))}))).pipe((0,b.switchMap)((function(e){return(0,E.concat)(n.loadOrder(e.body.data.order.orderId,t),(0,E.of)((0,a.createAction)(se.SubmitOrderSucceeded,e.body.data,(0,o.__assign)((0,o.__assign)({},e.body.meta),{token:e.headers.token}))))})))})).pipe((0,b.catchError)((function(e){return or(se.SubmitOrderFailed,e)}))))}},e.prototype.finalizeOrder=function(e,t){var n=this;return(0,E.concat)((0,E.of)((0,a.createAction)(se.FinalizeOrderRequested)),(0,E.from)(this._orderRequestSender.finalizeOrder(e,t)).pipe((0,b.switchMap)((function(r){return(0,E.concat)(n.loadOrder(e,t),(0,E.of)((0,a.createAction)(se.FinalizeOrderSucceeded,r.body.data)))})))).pipe((0,b.catchError)((function(e){return or(se.FinalizeOrderFailed,e)})))},e.prototype._getCurrentOrderId=function(e){var t=e.order.getOrder(),n=e.checkout.getCheckout();return t&&t.orderId||n&&n.orderId},e.prototype._mapToOrderRequestBody=function(e,t,n,r){var i=e.payment,a=(0,o.__rest)(e,["payment"]);return i?(0,o.__assign)((0,o.__assign)({},a),{cartId:t,customerMessage:n,externalSource:r,payment:{paymentData:i.paymentData,name:i.methodId,gateway:i.gatewayId}}):(0,o.__assign)((0,o.__assign)({},a),{cartId:t,customerMessage:n,externalSource:r})},e}(),wi=function(e){function t(t){var n=e.call(this,t||"Your checkout could not be processed because some details have changed. Please review your order and try again.")||this;return n.name="CartConsistencyError",n.type="cart_consistency",n}return(0,o.__extends)(t,e),t}(p),Ei=function(e){function t(t){var n=e.call(this,t||"The tax provider is unavailable.")||this;return n.name="OrderTaxProviderUnavailableError",n.type="tax_provider_unavailable",n}return(0,o.__extends)(t,e),t}(p);var bi=function(){function e(e){this._requestSender=e}return e.prototype.loadOrder=function(e,t){var n=(void 0===t?{}:t).timeout,r="/api/storefront/orders/"+e,i=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.get(r,{params:{include:mr(["payments","lineItems.physicalItems.socialMedia","lineItems.physicalItems.options","lineItems.physicalItems.categories","lineItems.digitalItems.socialMedia","lineItems.digitalItems.options","lineItems.digitalItems.categories"])},headers:i,timeout:n})},e.prototype.submitOrder=function(e,t){var n=void 0===t?{}:t,r=n.headers,i=n.timeout;return this._requestSender.post("/internalapi/v1/checkout/order",{body:e,headers:(0,_.omitBy)((0,o.__assign)({"X-Checkout-Variant":r&&r.checkoutVariant},tr),_.isNil),timeout:i}).catch((function(e){if("tax_provider_unavailable"===e.body.type)throw new Ei;if("cart_has_changed"===e.body.type)throw new wi;throw e}))},e.prototype.finalizeOrder=function(e,t){var n=(void 0===t?{}:t).timeout,r="/internalapi/v1/checkout/order/"+e;return this._requestSender.post(r,{timeout:n,headers:tr})},e}();const Pi=bi;var Ai=function(){function e(e,t,n,r){var i=this;this._paymentRequestSender=e,this._orderActionCreator=t,this._paymentRequestTransformer=n,this._paymentHumanVerificationHandler=r,this.initializeOffsitePayment=function(e){var t=e.methodId,n=e.gatewayId,r=e.instrumentId,o=e.target,s=e.promise,u=e.shouldSaveInstrument,c=e.shouldSetAsDefaultInstrument;return function(e){var d;r?d={formattedPayload:{bigpay_token:r}}:u&&(d={formattedPayload:{vault_payment_instrument:u,set_as_default_stored_instrument:c||null}});var l=i._paymentRequestTransformer.transform({gatewayId:n,methodId:t,paymentData:d},e.getState());return(0,E.concat)((0,E.of)((0,a.createAction)(ot.InitializeOffsitePaymentRequested)),Promise.race([i._paymentRequestSender.initializeOffsitePayment(l,o),s].filter(Boolean)).then((function(){return(0,a.createAction)(ot.InitializeOffsitePaymentSucceeded)}))).pipe((0,b.catchError)((function(e){return or(ot.InitializeOffsitePaymentFailed,e)})))}}}return e.prototype.submitPayment=function(e){var t=this;return function(n){return(0,E.concat)((0,E.of)((0,a.createAction)(ot.SubmitPaymentRequested)),(0,E.defer)((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,5]),[4,this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transform(e,n.getState()))];case 1:case 4:return[2,i.sent()];case 2:return t=i.sent(),[4,this._paymentHumanVerificationHandler.handle(t)];case 3:return r=i.sent(),[4,this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transform((0,o.__assign)((0,o.__assign)({},e),{additionalAction:r}),n.getState()))];case 5:return[2]}}))}))})).pipe((0,b.switchMap)((function(e){var r=e.body;return(0,E.concat)(t._orderActionCreator.loadCurrentOrder()(n),(0,E.of)((0,a.createAction)(ot.SubmitPaymentSucceeded,r)))})))).pipe((0,b.catchError)((function(e){return or(ot.SubmitPaymentFailed,e)})))}},e}();const Oi=Ai,Ti=function(){function e(e){this._client=e}return e.prototype.submitPayment=function(e){var t=this;return new Promise((function(n,r){t._client.submitPayment(e,(function(e,i){e?r(t._transformResponse(e)):n(t._transformResponse(i))}))}))},e.prototype.initializeOffsitePayment=function(e,t){var n=this;return new Promise((function(){n._client.initializeOffsitePayment(e,null,t)}))},e.prototype._transformResponse=function(e){return{headers:e.headers,body:e.data,status:e.status,statusText:e.statusText}},e}(),Ri=require("@bigcommerce/bigpay-client");function ki(e,t){var n;return function(e){return void 0!==e.id}(e)?n=e.id:t&&t.length&&(n=t[0].id),{id:n,firstName:e.firstName,lastName:e.lastName,company:e.company,addressLine1:e.address1,addressLine2:e.address2,city:e.city,province:e.stateOrProvince,provinceCode:e.stateOrProvinceCode,postCode:e.postalCode,country:e.country,countryCode:e.countryCode,phone:e.phone,customFields:e.customFields}}const Di=function(){function e(e){this._decimalPlaces=e}return e.prototype.toInteger=function(e){return Math.round(e*Math.pow(10,this._decimalPlaces))},e}();var Mi,Ni=["per_item_discount","percentage_discount","per_total_discount","shipping_discount","free_shipping"];function Li(e){return{code:e.code,discount:e.displayName,discountType:Ni.indexOf(e.couponType)}}function zi(e){return{code:e.code,discountedAmount:e.used,remainingBalance:e.remaining,giftCertificate:{balance:e.balance,code:e.code,purchaseDate:e.purchaseDate}}}function Ui(e,t,n){return void 0===n&&(n="id"),Object.keys(e).reduce((function(r,i){return(0,o.__spreadArrays)(r,e[i].map((function(e){return"giftCertificates"===i?function(e,t){var n=new Di(t);return{id:e.id,imageUrl:"",name:e.name,amount:e.amount,amountAfterDiscount:e.amount,discount:0,integerAmount:n.toInteger(e.amount),integerAmountAfterDiscount:n.toInteger(e.amount),integerUnitPrice:n.toInteger(e.amount),integerUnitPriceAfterDiscount:n.toInteger(e.amount),integerDiscount:0,quantity:1,sender:e.sender,recipient:e.recipient,type:"ItemGiftCertificateEntity",attributes:[],variantId:null}}(e,t):function(e,t,n,r){void 0===r&&(r="id");var i=new Di(n);return{id:e[r],imageUrl:e.imageUrl,amount:e.extendedListPrice,amountAfterDiscount:e.extendedSalePrice,discount:e.discountAmount,integerAmount:i.toInteger(e.extendedListPrice),integerAmountAfterDiscount:i.toInteger(e.extendedSalePrice),integerDiscount:i.toInteger(e.discountAmount),integerUnitPrice:i.toInteger(e.listPrice),integerUnitPriceAfterDiscount:i.toInteger(e.salePrice),downloadsPageUrl:e.downloadPageUrl,name:e.name,quantity:e.quantity,brand:e.brand,sku:e.sku,categoryNames:e.categoryNames,variantId:e.variantId,productId:e.productId,attributes:(e.options||[]).map((function(e){return{name:e.name,value:e.value}})),addedByPromotion:e.addedByPromotion,type:t}}(e,function(e){switch(e){case"physicalItems":return"ItemPhysicalEntity";case"digitalItems":return"ItemDigitalEntity";case"giftCertificates":return"ItemGiftCertificateEntity";default:return""}}(i),t,n)})))}),[])}function Fi(e){var t,n,r=e.cart.currency.decimalPlaces,i=new Di(r);return{id:e.cart.id,items:Ui(e.cart.lineItems,r),currency:e.cart.currency.code,coupon:{discountedAmount:(0,_.reduce)(e.cart.coupons,(function(e,t){return e+t.discountedAmount}),0),coupons:e.cart.coupons.map(Li)},discount:{amount:e.cart.discountAmount,integerAmount:i.toInteger(e.cart.discountAmount)},discountNotifications:(t=e.promotions,n=[],(t||[]).forEach((function(e){(e.banners||[]).forEach((function(e){n.push({placeholders:[],discountType:null,message:"",messageHtml:e.text})}))})),n),giftCertificate:{totalDiscountedAmount:(0,_.reduce)(e.giftCertificates,(function(e,t){return e+t.used}),0),appliedGiftCertificates:(0,_.keyBy)(e.giftCertificates.map(zi),"code")},shipping:{amount:e.shippingCostTotal,integerAmount:i.toInteger(e.shippingCostTotal),amountBeforeDiscount:e.shippingCostBeforeDiscount,integerAmountBeforeDiscount:i.toInteger(e.shippingCostBeforeDiscount),required:(0,_.some)(e.cart.lineItems.physicalItems,(function(e){return e.isShippingRequired}))},subtotal:{amount:e.subtotal,integerAmount:i.toInteger(e.subtotal)},storeCredit:{amount:e.customer?e.customer.storeCredit:0},taxSubtotal:{amount:e.taxTotal,integerAmount:i.toInteger(e.taxTotal)},taxes:e.taxes,taxTotal:{amount:e.taxTotal,integerAmount:i.toInteger(e.taxTotal)},handling:{amount:e.handlingCostTotal,integerAmount:i.toInteger(e.handlingCostTotal)},grandTotal:{amount:e.grandTotal,integerAmount:i.toInteger(e.grandTotal)}}}!function(e){e.APPLEPAY="applepay",e.AMAZON_PAY_V2="amazonpay",e.BRAINTREE_PAYPAL="braintreepaypal",e.BRAINTREE_VENMO="braintreevenmo",e.BRAINTREE_PAYPAL_CREDIT="braintreepaypalcredit",e.GOOGLEPAY_ADYENV2="googlepayadyenv2",e.GOOGLEPAY_ADYENV3="googlepayadyenv3",e.GOOGLEPAY_AUTHORIZENET="googlepayauthorizenet",e.GOOGLEPAY_BNZ="googlepaybnz",e.GOOGLEPAY_BRAINTREE="googlepaybraintree",e.GOOGLEPAY_CHECKOUTCOM="googlepaycheckoutcom",e.GOOGLEPAY_CYBERSOURCEV2="googlepaycybersourcev2",e.GOOGLEPAY_ORBITAL="googlepayorbital",e.GOOGLEPAY_STRIPE="googlepaystripe",e.GOOGLEPAY_STRIPEUPE="googlepaystripeupe",e.GOOGLEPAY_WORLDPAYACCESS="googlepayworldpayaccess",e.MASTERPASS="masterpass",e.PAYPALEXPRESS="paypalexpress"}(Mi||(Mi={}));const Bi=Mi;function qi(e,t){var n=e.firstName||t.firstName||"",r=e.lastName||t.lastName||"";return{addresses:(e.addresses||[]).map((function(e){return ki(e)})),customerId:e.id,isGuest:e.isGuest,storeCredit:e.storeCredit,email:e.email||t.email||"",firstName:n,lastName:r,name:e.fullName||[n,r].join(" "),customerGroupName:e.customerGroup&&e.customerGroup.name}}var xi=function(){function e(){}return e.prototype.format=function(e){var t=e.split(new RegExp("\\s*/\\s*")),n=t[0],r=void 0===n?"":n,i=t[1],o=void 0===i?"":i,a=r.slice(0,2),s=4===o.length?o.slice(-2):o?o.slice(0,2):r.slice(2);return e.length<2?r:e.length>3&&!s?a:a+" / "+s},e.prototype.toObject=function(e){var t=e.split(new RegExp("\\s*/\\s*")),n=t[0],r=void 0===n?"":n,i=t[1],o=void 0===i?"":i;return/^\d+$/.test(r)&&/^\d+$/.test(o)?{month:1===r.length?"0"+r:r.slice(0,2),year:2===o.length?"20"+o:o.slice(0,4)}:{month:"",year:""}},e}();const Gi=xi,Vi=require("card-validator"),Hi=function(){function e(){}return e.prototype.format=function(e){var t=(0,Vi.number)(e).card;if(!t)return e;var n=(0,_.max)((0,Vi.creditCardType)(e).map((function(e){return(0,_.max)(e.lengths)}))),r=this.unformat(e).slice(0,n);return t.gaps.filter((function(e){return r.length>e})).reduce((function(e,t,n){return[e.slice(0,t+n),e.slice(t+n)].join(" ")}),r)},e.prototype.unformat=function(e){return(0,Vi.number)(e).card?e.replace(new RegExp(" ","g"),""):e},e}();function ji(e,t){void 0===t&&(t={});var n,r,i=e.currency.decimalPlaces,o=new Di(i);return{id:e.orderId,items:Ui(e.lineItems,e.currency.decimalPlaces,"productId"),orderId:e.orderId,currency:e.currency.code,customerCanBeCreated:e.customerCanBeCreated,payment:Wi(e.payments,t.payment),subtotal:{amount:e.baseAmount,integerAmount:o.toInteger(e.baseAmount)},coupon:{discountedAmount:(0,_.reduce)(e.coupons,(function(e,t){return e+t.discountedAmount}),0),coupons:e.coupons.map(Li)},discount:{amount:e.discountAmount,integerAmount:o.toInteger(e.discountAmount)},token:t.orderToken,callbackUrl:t.callbackUrl,discountNotifications:[],giftCertificate:(n=e.payments,r=(0,_.filter)(n,{providerId:"giftcertificate"}),{totalDiscountedAmount:(0,_.reduce)(r,(function(e,t){return t.amount+e}),0),appliedGiftCertificates:(0,_.keyBy)(r.map((function(e){return{code:e.detail.code,discountedAmount:e.amount,remainingBalance:e.detail.remaining,giftCertificate:{balance:e.amount+e.detail.remaining,code:e.detail.code,purchaseDate:""}}})),"code")}),socialData:Zi(e),status:e.status,hasDigitalItems:e.hasDigitalItems,isDownloadable:e.isDownloadable,isComplete:e.isComplete,shipping:{amount:e.shippingCostTotal,integerAmount:o.toInteger(e.shippingCostTotal),amountBeforeDiscount:e.shippingCostBeforeDiscount,integerAmountBeforeDiscount:o.toInteger(e.shippingCostBeforeDiscount)},storeCredit:{amount:Yi(e.payments)},taxes:e.taxes,taxTotal:{amount:e.taxTotal,integerAmount:o.toInteger(e.taxTotal)},handling:{amount:e.handlingCostTotal,integerAmount:o.toInteger(e.handlingCostTotal)},grandTotal:{amount:e.orderAmount,integerAmount:e.orderAmountAsInteger}}}function Yi(e){var t=(0,_.find)(e,{providerId:"storecredit"});return t?t.amount:0}function Wi(e,t){void 0===t&&(t={});var n,r=(0,_.find)(e,Ki);return r?{id:r.providerId,status:(n=r.detail.step,"PAYMENT_STATUS_"+n),helpText:r.detail.instructions,returnUrl:t.returnUrl}:{}}function Ki(e){return"giftcertificate"!==e.providerId&&"storecredit"!==e.providerId}function Zi(e){var t={};return(0,o.__spreadArrays)(e.lineItems.physicalItems,e.lineItems.digitalItems).forEach((function(e){var n;t[e.id]=(n=e,["fb","tw","gp"].reduce((function(e,t){var r=n.socialMedia&&(0,_.find)(n.socialMedia,(function(e){return e.code===t}));return r?(e[t]={name:n.name,description:n.name,image:n.imageUrl,url:r.link,shareText:r.text,sharingLink:r.link,channelName:r.channel,channelCode:r.code},e):e}),{}))})),t}function Qi(e,t){return{description:e.description,module:e.type,price:e.cost,id:e.id,selected:t,isRecommended:e.isRecommended,imageUrl:e.imageUrl,transitTime:e.transitTime}}var Ji=function(){function e(){this._cardExpiryFormatter=new Gi,this._cardNumberFormatter=new Hi}return e.prototype.transform=function(e,t){var n,r=t.billingAddress.getBillingAddress(),i=t.checkout.getCheckout(),a=t.customer.getCustomer(),s=t.order.getOrder(),u=t.paymentMethods.getPaymentMethod(e.methodId,e.gatewayId),c=this._mapShippingAddress(t,u),d=t.consignments.getConsignments(),l=t.consignments.getShippingOption(),p=t.config.getStoreConfig(),h=t.config.getContextConfig(),f=t.instruments.getInstrumentsMeta(),g=t.paymentMethods.getPaymentMethodsMeta(),m=t.order.getOrderMeta(),y=a&&r&&qi(a,r),v=f&&e.paymentData&&(yi(e.paymentData)||(n=e.paymentData.formattedPayload)&&("string"==typeof n.bigpay_token||Boolean(n.bigpay_token&&n.bigpay_token.token)))?t.payment.getPaymentToken()+", "+f.vaultAccessToken:t.payment.getPaymentToken();if(!v)throw new Nn(Mn.MissingPaymentToken);return{additionalAction:e.additionalAction,authToken:v,customer:y,billingAddress:r&&ki(r),shippingAddress:c&&ki(c,d),shippingOption:l&&Qi(l,!0),cart:i&&Fi(i),order:s&&ji(s,m),orderMeta:m,payment:e.paymentData,paymentMethod:u&&this._transformPaymentMethod(u),quoteMeta:{request:(0,o.__assign)((0,o.__assign)({},g),{geoCountryCode:h&&h.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:(0,_.pick)(p&&p.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}},e.prototype.transformWithHostedFormData=function(e,t,n){var r=t.additionalAction,i=t.authToken,a=t.checkout,s=t.config,u=t.order,c=t.orderMeta,d=t.payment,l=void 0===d?{}:d,p=t.paymentMethod,h=t.paymentMethodMeta,f=a&&a.consignments[0],g=f&&f.shippingAddress,m=f&&f.selectedShippingOption;return{additionalAction:r,authToken:i,paymentMethod:p&&this._transformPaymentMethod(p),customer:u&&u.billingAddress&&a&&qi(a.customer,u.billingAddress),billingAddress:u&&u.billingAddress&&ki(u.billingAddress),shippingAddress:g&&a&&ki(g,a.consignments),shippingOption:m&&Qi(m,!0),cart:a&&Fi(a),order:u&&ji(u,c),orderMeta:c,payment:this._transformHostedInputValues(e,l,n),quoteMeta:{request:(0,o.__assign)((0,o.__assign)({},h),{geoCountryCode:s&&s.context.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:s&&(0,_.pick)(s.storeConfig.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}},e.prototype._transformPaymentMethod=function(e){return"multi-option"!==e.method||e.gateway?e.initializationData&&e.initializationData.gateway?(0,o.__assign)((0,o.__assign)({},e),{id:e.initializationData.gateway}):e.id===Bi.BRAINTREE_VENMO?(0,o.__assign)((0,o.__assign)({},e),{id:Bi.BRAINTREE_PAYPAL}):e:(0,o.__assign)((0,o.__assign)({},e),{gateway:e.id})},e.prototype._transformHostedInputValues=function(e,t,n){return"instrumentId"in t?(0,o.__assign)((0,o.__assign)({},t),{ccCvv:e.cardCodeVerification,ccNumber:e.cardNumberVerification&&this._cardNumberFormatter.unformat(e.cardNumberVerification),hostedFormNonce:n}):(0,o.__assign)((0,o.__assign)({},t),{ccCvv:e.cardCode,ccExpiry:this._cardExpiryFormatter.toObject(e.cardExpiry||""),ccName:e.cardName||"",ccNumber:this._cardNumberFormatter.unformat(e.cardNumber||""),hostedFormNonce:n})},e.prototype._mapShippingAddress=function(e,t){var n,r,i,o;if(t){var a=null===(r=null===(n=t.initializationData)||void 0===n?void 0:n.bopis)||void 0===r?void 0:r.enabled,s=null===(o=null===(i=t.initializationData)||void 0===i?void 0:i.bopis)||void 0===o?void 0:o.requiredAddress,u=e.consignments.getConsignments(),c=null==u?void 0:u.every((function(e){return e.selectedPickupOption}));if(a&&c&&"none"===s)return}return e.shippingAddress.getShippingAddress()},e}();const Xi=Ji,$i=function(){function e(){}return e.prototype.updatePaymentProviderCustomer=function(e){return(0,E.of)((0,a.createAction)(vt.UpdatePaymentProviderCustomer,e))},e}(),eo=function(){function e(){}return e.prototype.widgetInteraction=function(e,t){var n={methodId:t&&t.methodId};return(0,E.concat)((0,E.of)((0,a.createAction)(pt.WidgetInteractionStarted,void 0,n)),(0,E.defer)((function(){return e().then((function(){return(0,a.createAction)(pt.WidgetInteractionFinished,void 0,n)}))}))).pipe((0,b.catchError)((function(e){return or(pt.WidgetInteractionFailed,e,n)})))},e}();var to=function(){function e(e,t){this._remoteCheckoutRequestSender=e,this._checkoutActionCreator=t}return e.prototype.initializeBilling=function(e,t,n){var r=this;return E.Observable.create((function(i){i.next((0,a.createAction)(Tt.InitializeRemoteBillingRequested,void 0,{methodId:e})),r._remoteCheckoutRequestSender.initializeBilling(e,t,n).then((function(t){var n=t.body,r=void 0===n?{}:n;i.next((0,a.createAction)(Tt.InitializeRemoteBillingSucceeded,r,{methodId:e})),i.complete()})).catch((function(t){i.error((0,a.createErrorAction)(Tt.InitializeRemoteBillingFailed,t,{methodId:e}))}))}))},e.prototype.initializeShipping=function(e,t,n){var r=this;return E.Observable.create((function(i){i.next((0,a.createAction)(Tt.InitializeRemoteShippingRequested,void 0,{methodId:e})),r._remoteCheckoutRequestSender.initializeShipping(e,t,n).then((function(t){var n=t.body,r=void 0===n?{}:n;i.next((0,a.createAction)(Tt.InitializeRemoteShippingSucceeded,r,{methodId:e})),i.complete()})).catch((function(t){i.error((0,a.createErrorAction)(Tt.InitializeRemoteShippingFailed,t,{methodId:e}))}))}))},e.prototype.initializePayment=function(e,t,n){var r=this;return E.Observable.create((function(i){i.next((0,a.createAction)(Tt.InitializeRemotePaymentRequested,void 0,{methodId:e})),r._remoteCheckoutRequestSender.initializePayment(e,t,n).then((function(t){var n=t.body,r=void 0===n?{}:n;i.next((0,a.createAction)(Tt.InitializeRemotePaymentSucceeded,r,{methodId:e})),i.complete()})).catch((function(t){i.error((0,a.createErrorAction)(Tt.InitializeRemotePaymentFailed,t,{methodId:e}))}))}))},e.prototype.loadSettings=function(e,t){var n=this;return E.Observable.create((function(r){r.next((0,a.createAction)(Tt.LoadRemoteSettingsRequested,void 0,{methodId:e})),n._remoteCheckoutRequestSender.loadSettings(e,t).then((function(t){var n=t.body;r.next((0,a.createAction)(Tt.LoadRemoteSettingsSucceeded,n,{methodId:e})),r.complete()})).catch((function(t){r.error((0,a.createErrorAction)(Tt.LoadRemoteSettingsFailed,t,{methodId:e}))}))}))},e.prototype.signOut=function(e,t){var n=this;return E.Observable.create((function(r){r.next((0,a.createAction)(Tt.SignOutRemoteCustomerRequested,void 0,{methodId:e})),n._remoteCheckoutRequestSender.signOut(e,t).then((function(){r.next((0,a.createAction)(Tt.SignOutRemoteCustomerSucceeded,void 0,{methodId:e})),r.complete()})).catch((function(t){r.error((0,a.createErrorAction)(Tt.SignOutRemoteCustomerFailed,t,{methodId:e}))}))}))},e.prototype.forgetCheckout=function(e,t){var n=this;return(0,E.concat)((0,E.of)((0,a.createAction)(Tt.ForgetCheckoutRemoteCustomerRequested,void 0,{methodId:e})),(0,E.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._remoteCheckoutRequestSender.forgetCheckout(t)];case 1:return n.sent(),[4,this._checkoutActionCreator.loadCurrentCheckout()];case 2:return n.sent(),[2,(0,a.createAction)(Tt.ForgetCheckoutRemoteCustomerSucceeded,void 0,{methodId:e})]}}))}))}))).pipe((0,b.catchError)((function(t){return or(Tt.ForgetCheckoutRemoteCustomerFailed,t,{methodId:e})})))},e.prototype.updateCheckout=function(e,t){return(0,a.createAction)(Tt.UpdateRemoteCheckout,t,{methodId:e})},e}();const no=to;var ro=function(){function e(e){this._requestSender=e}return e.prototype.initializeBilling=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/remote-checkout/"+e+"/billing";return this._requestSender.get(i,{params:t,timeout:r,headers:tr})},e.prototype.initializeShipping=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/remote-checkout/"+e+"/shipping";return this._requestSender.get(i,{params:t,timeout:r,headers:tr})},e.prototype.initializePayment=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/remote-checkout/"+e+"/payment";return this._requestSender.get(i,{params:t,timeout:r,headers:tr})},e.prototype.loadSettings=function(e,t){var n=(void 0===t?{}:t).timeout,r="/remote-checkout/"+e+"/settings";return this._requestSender.get(r,{timeout:n,headers:tr})},e.prototype.signOut=function(e,t){var n=(void 0===t?{}:t).timeout,r="/remote-checkout/"+e+"/signout";return this._requestSender.get(r,{timeout:n,headers:tr})},e.prototype.generateToken=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.get("/remote-checkout-token",{timeout:t,headers:tr})},e.prototype.trackAuthorizationEvent=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.post("/remote-checkout/events/shopper-checkout-service-provider-authorization-requested",{timeout:t,headers:tr})},e.prototype.forgetCheckout=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.post("/remote-checkout/forget-checkout",{timeout:t,headers:tr})},e}();const io=ro;var oo;!function(e){e.AvailableShippingOptions="consignments.availableShippingOptions",e.PhysicalItemsCategoryNames="cart.lineItems.physicalItems.categoryNames",e.DigitalItemsCategoryNames="cart.lineItems.digitalItems.categoryNames"}(oo||(oo={}));var ao=function(){function e(e,t){this._consignmentRequestSender=e,this._checkoutRequestSender=t}return e.prototype.unassignItemsByAddress=function(e,t){var n=this;return function(r){var i=r.getState();if(!i.checkout.getCheckout())throw new Nn(Mn.MissingCheckout);var o=n._consignmentHasAddress(e)?e.address:e.shippingAddress,a=i.consignments.getConsignmentByAddress(o);if(!a)throw new Gr("No consignment found for the specified address");var s=n._removeLineItems(e.lineItems,a,i.cart.getCart());return s.length?n.updateConsignment({id:a.id,address:o,lineItems:s},t)(r):n.deleteConsignment(a.id,t)(r)}},e.prototype.assignItemsByAddress=function(e,t){var n=this;return function(r){var i=r.getState(),o=n._consignmentHasAddress(e)?e.address:e.shippingAddress,a=i.consignments.getConsignmentByAddress(o);return n._createOrUpdateConsignment({id:a&&a.id,address:o,lineItems:n._addLineItems(e.lineItems,a,i.cart.getCart())},t)(r)}},e.prototype.selectShippingOption=function(e,t){var n=this;return function(r){return E.Observable.create((function(i){var o=r.getState(),s=o.checkout.getCheckout(),u=o.consignments.getConsignments();if(!s)throw new Nn(Mn.MissingCheckout);if(!u||!u.length)throw new Nn(Mn.MissingConsignments);var c={id:u[0].id,shippingOptionId:e},d={id:u[0].id};i.next((0,a.createAction)(j.UpdateShippingOptionRequested,void 0,d)),n._consignmentRequestSender.updateConsignment(s.id,c,t).then((function(e){var t=e.body;i.next((0,a.createAction)(j.UpdateShippingOptionSucceeded,t,d)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(j.UpdateShippingOptionFailed,e,d))}))}))}},e.prototype.loadShippingOptions=function(e){var t=this;return function(n){return E.Observable.create((function(r){var i=n.getState().checkout.getCheckout();if(!i)throw new Nn(Mn.MissingCheckout);r.next((0,a.createAction)(j.LoadShippingOptionsRequested)),t._checkoutRequestSender.loadCheckout(i.id,(0,o.__assign)((0,o.__assign)({},e),{params:{include:[oo.AvailableShippingOptions]}})).then((function(e){var t=e.body;r.next((0,a.createAction)(j.LoadShippingOptionsSucceeded,t)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(j.LoadShippingOptionsFailed,e))}))}))}},e.prototype.updateAddress=function(e,t){var n=this;return function(r){var i=n._getUpdateAddressRequestBody(e,r),o=r.getState().consignments.getConsignments();return o&&o.length&&(i.id=o[0].id),n._createOrUpdateConsignment(i,t)(r)}},e.prototype.createConsignments=function(e,t){var n=this;return function(r){return E.Observable.create((function(i){var o=r.getState().checkout.getCheckout();if(!o||!o.id)throw new Nn(Mn.MissingCheckout);i.next((0,a.createAction)(j.CreateConsignmentsRequested)),n._consignmentRequestSender.createConsignments(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(j.CreateConsignmentsSucceeded,t)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(j.CreateConsignmentsFailed,e))}))}))}},e.prototype.updateConsignment=function(e,t){var n=this;return function(r){return E.Observable.create((function(i){var o=r.getState().checkout.getCheckout();if(!o||!o.id)throw new Nn(Mn.MissingCheckout);var s={id:e.id};i.next((0,a.createAction)(j.UpdateConsignmentRequested,void 0,s)),n._consignmentRequestSender.updateConsignment(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(j.UpdateConsignmentSucceeded,t,s)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(j.UpdateConsignmentFailed,e,s))}))}))}},e.prototype.deleteConsignment=function(e,t){var n=this;return function(r){return E.Observable.create((function(i){var o=r.getState().checkout.getCheckout(),s={id:e};if(!o||!o.id)throw new Nn(Mn.MissingCheckout);i.next((0,a.createAction)(j.DeleteConsignmentRequested,void 0,s)),n._consignmentRequestSender.deleteConsignment(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(j.DeleteConsignmentSucceeded,t,s)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(j.DeleteConsignmentFailed,e,s))}))}))}},e.prototype.updateShippingOption=function(e,t){var n=this;return function(r){return E.Observable.create((function(i){var o=r.getState().checkout.getCheckout();if(!o||!o.id)throw new Nn(Mn.MissingCheckout);var s={id:e.id};i.next((0,a.createAction)(j.UpdateShippingOptionRequested,void 0,s)),n._consignmentRequestSender.updateConsignment(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(j.UpdateShippingOptionSucceeded,t,s)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(j.UpdateShippingOptionFailed,e,s))}))}))}},e.prototype._createOrUpdateConsignment=function(e,t){var n=this;return function(r){var i=r.getState().checkout.getCheckout();if(!i||!i.id)throw new Nn(Mn.MissingCheckout);return n._isUpdateConsignmentRequest(e)?n.updateConsignment(e,t)(r):n.createConsignments([e],t)(r)}},e.prototype._getUpdateAddressRequestBody=function(e,t){var n=t.getState().cart.getCart();if(!n)throw new Nn(Mn.MissingCart);var r=n.lineItems,i=r.physicalItems,a=r.customItems,s=void 0===a?[]:a;return{address:e,lineItems:(0,o.__spreadArrays)(i,s).map((function(e){return{itemId:e.id,quantity:e.quantity}}))}},e.prototype._removeLineItems=function(e,t,n){if(!n)throw new Nn(Mn.MissingCart);return this._hydrateLineItems(t.lineItemIds,n).map((function(t){var n=(0,_.find)(e,(function(e){return e.itemId===t.itemId}));return(0,o.__assign)((0,o.__assign)({},t),{quantity:n?t.quantity-n.quantity:t.quantity})})).filter((function(e){return e.quantity>0}))},e.prototype._addLineItems=function(e,t,n){if(!t)return e;if(!n)throw new Nn(Mn.MissingCart);return e.concat(this._hydrateLineItems(t.lineItemIds,n)).filter((function(e){return e.quantity>0}))},e.prototype._hydrateLineItems=function(e,t){return e.map((function(e){var n=(0,_.find)(t.lineItems.physicalItems,(function(t){return t.id===e}));return{itemId:e,quantity:n?n.quantity:0}}))},e.prototype._isUpdateConsignmentRequest=function(e){return!!e.id},e.prototype._consignmentHasAddress=function(e){return"object"==typeof e&&"address"in e},e}();const so=ao;var uo=["consignments.availableShippingOptions","cart.lineItems.physicalItems.options","cart.lineItems.digitalItems.options","customer","promotions.banners"],co=function(){function e(e){this._requestSender=e}return e.prototype.createConsignments=function(e,t,n){var r=void 0===n?{}:n,i=r.timeout,a=r.params,s=(void 0===a?{}:a).include,u="/api/storefront/checkouts/"+e+"/consignments",c=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.post(u,{body:t,params:{include:_r(uo,s)},headers:c,timeout:i})},e.prototype.updateConsignment=function(e,t,n){var r=void 0===n?{}:n,i=r.timeout,a=r.params,s=(void 0===a?{}:a).include,u=t.id,c=(0,o.__rest)(t,["id"]),d="/api/storefront/checkouts/"+e+"/consignments/"+u,l=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.put(d,{body:c,params:{include:_r(uo,s)},headers:l,timeout:i})},e.prototype.deleteConsignment=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/api/storefront/checkouts/"+e+"/consignments/"+t,a=(0,o.__assign)({Accept:$n.JsonV1},tr),s=mr(uo);return this._requestSender.delete(i,{params:{include:s},headers:a,timeout:r})},e}();const lo=co,po=function(){function e(e,t){this._shippingCountryRequestSender=e,this._store=t}return e.prototype.loadCountries=function(e){var t=this,n=this._store.getState().checkout.getCheckoutOrThrow().channelId;return E.Observable.create((function(r){r.next((0,a.createAction)(Wt.LoadShippingCountriesRequested)),t._shippingCountryRequestSender.loadCountries(n,e).then((function(e){r.next((0,a.createAction)(Wt.LoadShippingCountriesSucceeded,e.body.data)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(Wt.LoadShippingCountriesFailed,e))}))}))},e}();var ho=function(){function e(e,t){this._requestSender=e,this._config=t}return e.prototype.loadCountries=function(e,t){var n=(void 0===t?{}:t).timeout,r="/internalapi/v1/shipping/countries?channel_id="+e,i=(0,o.__assign)({"Accept-Language":this._config.locale},tr);return this._requestSender.get(r,{headers:i,timeout:n})},e}();const fo=ho;var go=function(){function e(e,t){this._googleRecaptcha=e,this._requestSender=t}return e.prototype.initialize=function(e){var t=this;return function(n){return(0,E.concat)((0,E.of)((0,a.createAction)(In.InitializeRequested,void 0)),(0,E.defer)((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,r,i,s,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return t=e?e.containerId:"spamProtectionContainer",e||document.getElementById(t)||((r=document.createElement("div")).setAttribute("id",t),document.body.appendChild(r)),i=n.getState(),s=i.config.getStoreConfigOrThrow(),u=s.checkoutSettings.googleRecaptchaSitekey,[4,this._googleRecaptcha.load(t,u)];case 1:return o.sent(),[2,(0,a.createAction)(In.InitializeSucceeded)]}}))}))}))).pipe((0,b.catchError)((function(e){return or(In.InitializeFailed,e)})))}},e.prototype.verifyCheckoutSpamProtection=function(){var e=this;return function(t){return(0,E.defer)((function(){var n=t.getState().checkout.getCheckout();if(!n)throw new Nn(Mn.MissingCheckout);return(0,E.concat)((0,E.of)((0,a.createAction)(In.VerifyCheckoutRequested)),(0,E.from)(e.execute()(t)).pipe((0,b.switchMap)((function(t){return Or(t)&&t.payload?(0,E.from)(e._requestSender.validate(n.id,t.payload.token)).pipe((0,b.switchMap)((function(e){var n=e.body;return(0,E.concat)((0,E.of)(t),(0,E.of)((0,a.createAction)(In.VerifyCheckoutSucceeded,n)))}))):(0,E.of)(t)})))).pipe((0,b.catchError)((function(e){return or(In.VerifyCheckoutFailed,e)})))}))}},e.prototype.execute=function(){var e=this;return function(t){return(0,E.concat)((0,E.of)((0,a.createAction)(In.ExecuteRequested)),e.initialize()(t),e._googleRecaptcha.execute().pipe((0,b.take)(1)).pipe((0,b.switchMap)((function(t){var n=t.error,r=t.token;return(0,o.__awaiter)(e,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){if(n instanceof Qr)throw n;if(n||!r)throw new ri;return[2,(0,a.createAction)(In.ExecuteSucceeded,{token:r})]}))}))})))).pipe((0,b.catchError)((function(e){return or(In.ExecuteFailed,e)})))}},e}();const mo=go;var _o=function(){function e(e){this._requestSender=e}return e.prototype.validate=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/api/storefront/checkouts/"+e+"/spam-protection",a=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.post(i,{body:{token:t},headers:a,timeout:r})},e}();const yo=_o;var vo=function(){function e(e){this._storeCreditRequestSender=e}return e.prototype.applyStoreCredit=function(e,t){var n=this;return function(r){return(0,E.concat)((0,E.of)((0,a.createAction)(pn.ApplyStoreCreditRequested)),(0,E.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){var n,i,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(n=r.getState(),!(i=n.checkout.getCheckout()))throw new Nn(Mn.MissingCheckout);return[4,e?this._storeCreditRequestSender.applyStoreCredit(i.id,t):this._storeCreditRequestSender.removeStoreCredit(i.id,t)];case 1:return s=o.sent().body,[2,(0,a.createAction)(pn.ApplyStoreCreditSucceeded,s)]}}))}))}))).pipe((0,b.catchError)((function(e){return or(pn.ApplyStoreCreditFailed,e)})))}},e}();const Co=vo;var So=function(){function e(e){this._requestSender=e}return e.prototype.applyStoreCredit=function(e,t){var n=(void 0===t?{}:t).timeout,r="/api/storefront/checkouts/"+e+"/store-credit",i=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.post(r,{headers:i,timeout:n,params:{include:mr(yr)}})},e.prototype.removeStoreCredit=function(e,t){var n=(void 0===t?{}:t).timeout,r="/api/storefront/checkouts/"+e+"/store-credit",i=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.delete(r,{headers:i,timeout:n,params:{include:mr(yr)}})},e}();const Io=So,wo=function(e){function t(t){var n=e.call(this,t)||this;return n.name="UpdateSubscriptionsError",n.type="update_subscriptions",n}return(0,o.__extends)(t,e),t}(g);var Eo=function(){function e(e){this._subscriptionsRequestSender=e}return e.prototype.updateSubscriptions=function(e,t){var n=this;return(0,E.concat)((0,E.of)((0,a.createAction)(O.UpdateSubscriptionsRequested)),(0,E.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._subscriptionsRequestSender.updateSubscriptions(e,t)];case 1:return n=r.sent().body,[2,(0,a.createAction)(O.UpdateSubscriptionsSucceeded,n)]}}))}))}))).pipe((0,b.catchError)((function(e){return or(O.UpdateSubscriptionsFailed,new wo(e))})))},e}();const bo=Eo;var Po=function(){function e(e){this._requestSender=e}return e.prototype.updateSubscriptions=function(e,t){var n=(void 0===t?{}:t).timeout,r=(0,o.__assign)({Accept:$n.JsonV1},tr);return this._requestSender.post("/api/storefront/subscriptions",{body:e,headers:r,timeout:n})},e}();const Ao=Po;var Oo=(0,_.memoize)((function(e){return Array.isArray(e)?e.map((function(e){return To(e)})):q(e)?Object.keys(e).reduce((function(t,n){var r;return(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=To(e[n]),r))}),{}):e}));Oo.cache=new WeakMap;var To=function(e){return"object"==typeof e&&null!==e?Oo(e):e};function Ro(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return To(e.apply(void 0,t))}}function ko(e){var t=e.billingAddress,n=t.getBillingAddress,r=t.getBillingAddressOrThrow,i=e.cart,o=i.getCart,a=i.getCartOrThrow,s=e.checkout,u=s.getCheckout,c=s.getCheckoutOrThrow,d=s.getOutstandingBalance,l=e.config,p=l.getContextConfig,h=l.getHost,f=l.getLocale,g=l.getStoreConfig,m=l.getStoreConfigOrThrow,_=l.getConfig,y=e.consignments,v=y.getConsignments,C=y.getConsignmentsOrThrow,S=e.countries.getCountries,I=e.customer,w=I.getCustomer,E=I.getCustomerOrThrow,b=e.instruments,P=b.getCardInstrument,A=b.getCardInstrumentOrThrow,O=b.getInstruments,T=b.getInstrumentsMeta,R=e.order,k=R.getOrder,D=R.getOrderOrThrow,M=R.getOrderMeta,N=e.payment,L=N.getPaymentToken,z=N.getPaymentTokenOrThrow,U=N.getPaymentId,F=N.getPaymentIdOrThrow,B=N.getPaymentStatus,q=N.getPaymentStatusOrThrow,x=N.getPaymentRedirectUrl,G=N.getPaymentRedirectUrlOrThrow,V=N.isPaymentDataRequired,H=e.paymentMethods,j=H.getPaymentMethod,Y=H.getPaymentMethodOrThrow,W=H.getPaymentMethodsMeta,K=e.paymentProviderCustomer,Z=K.getPaymentProviderCustomer,Q=K.getPaymentProviderCustomerOrThrow,J=e.paymentStrategies.isInitialized,X=e.shippingAddress,$=X.getShippingAddress,ee=X.getShippingAddressOrThrow,te=X.getShippingAddresses,ne=X.getShippingAddressesOrThrow,re=e.shippingCountries.getShippingCountries;return{getHost:Ro(h),getLocale:Ro(f),getBillingAddress:Ro(n),getBillingAddressOrThrow:Ro(r),getCart:Ro(o),getCartOrThrow:Ro(a),getCheckout:Ro(u),getCheckoutOrThrow:Ro(c),getCountries:Ro(S),getStoreConfig:Ro(g),getStoreConfigOrThrow:Ro(m),getConfig:Ro(_),getConsignments:Ro(v),getConsignmentsOrThrow:Ro(C),getContextConfig:Ro(p),getCustomer:Ro(w),getCustomerOrThrow:Ro(E),getCardInstrument:Ro(P),getInstruments:Ro(O),getCardInstrumentOrThrow:Ro(A),getOrder:Ro(k),getOrderOrThrow:Ro(D),getOrderMeta:Ro(M),getInstrumentsMeta:Ro(T),getPaymentToken:L,getPaymentTokenOrThrow:z,getPaymentId:U,getPaymentIdOrThrow:F,getPaymentStatus:B,getPaymentStatusOrThrow:q,getPaymentRedirectUrl:x,getPaymentRedirectUrlOrThrow:G,getPaymentMethod:Ro(j),getPaymentMethodOrThrow:Ro(Y),getPaymentMethodsMeta:Ro(W),getPaymentProviderCustomer:Ro(Z),getPaymentProviderCustomerOrThrow:Ro(Q),getShippingAddress:Ro($),getShippingAddressOrThrow:Ro(ee),getShippingAddresses:Ro(te),getShippingAddressesOrThrow:Ro(ne),getShippingCountries:Ro(re),getOutstandingBalance:Ro(d),isPaymentDataRequired:V,isPaymentMethodInitialized:J}}var Do=function(){function e(e,t,n,r,i,o,a,s,u,c,d,l,p,h,f,g,m,_,y){this._store=e,this._storeProjectionFactory=t,this._checkoutActionCreator=n,this._checkoutValidator=r,this._hostedFormFactory=i,this._orderActionCreator=o,this._billingAddressActionCreator=a,this._consignmentActionCreator=s,this._paymentMethodActionCreator=u,this._paymentActionCreator=c,this._paymentHumanVerificationHandler=d,this._customerActionCreator=l,this._cartRequestSender=p,this._storeCreditActionCreator=h,this._spamProtectionActionCreator=f,this._paymentProviderCustomerActionCreator=g,this._shippingCountryActionCreator=m,this._remoteCheckoutActionCreator=_,this._paymentStrategyWidgetActionCreator=y,this._storeProjection=this._storeProjectionFactory.create(this._store)}return e.prototype.createHostedForm=function(e,t){return this._hostedFormFactory.create(e,t)},e.prototype.subscribe=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return(t=this._storeProjection).subscribe.apply(t,(0,o.__spreadArrays)([e],n))},e.prototype.getState=function(){return this._storeProjection.getState()},e.prototype.initializeOffsitePayment=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentActionCreator.initializeOffsitePayment(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.loadCheckout=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return e?[4,this._store.dispatch(this._checkoutActionCreator.loadCheckout(e))]:[3,2];case 1:return t.sent(),[3,4];case 2:return[4,this._store.dispatch(this._checkoutActionCreator.loadCurrentCheckout())];case 3:t.sent(),t.label=4;case 4:return[2,this._storeProjection.getState()]}}))}))},e.prototype.loadDefaultCheckout=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 1:return e.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.loadPaymentMethod=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.loadPaymentMethods=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethods(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.submitOrder=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._orderActionCreator.submitOrder(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.submitPayment=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentActionCreator.submitPayment(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.finalizeOrder=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return t=this._store.getState().order.getOrderOrThrow,[4,this._store.dispatch(this._orderActionCreator.finalizeOrder(t().orderId,e))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.updateBillingAddress=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._billingAddressActionCreator.updateAddress(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.updateShippingAddress=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._consignmentActionCreator.updateAddress(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.selectShippingOption=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._consignmentActionCreator.selectShippingOption(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.signInCustomer=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._customerActionCreator.signInCustomer(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.signOutCustomer=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._customerActionCreator.signOutCustomer(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.createBuyNowCart=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._cartRequestSender.createBuyNowCart(e,t)];case 1:return[2,n.sent().body]}}))}))},e.prototype.applyStoreCredit=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._storeCreditActionCreator.applyStoreCredit(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.verifyCheckoutSpamProtection=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return this._store.getState().checkout.getCheckoutOrThrow().shouldExecuteSpamCheck?[4,this._store.dispatch(this._spamProtectionActionCreator.verifyCheckoutSpamProtection())]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2,this._storeProjection.getState()]}}))}))},e.prototype.loadCurrentOrder=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._orderActionCreator.loadCurrentOrder(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.updatePaymentProviderCustomer=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentProviderCustomerActionCreator.updatePaymentProviderCustomer(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.loadShippingCountries=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._shippingCountryActionCreator.loadCountries(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.deleteConsignment=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._consignmentActionCreator.deleteConsignment(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.initializePayment=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._store.dispatch(this._remoteCheckoutActionCreator.initializePayment(e,t,n))];case 1:return r.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.forgetCheckout=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._remoteCheckoutActionCreator.forgetCheckout(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.remoteCheckoutSignOut=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._remoteCheckoutActionCreator.signOut(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.validateCheckout=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._checkoutValidator.validate(e,t)];case 1:return n.sent(),[2]}}))}))},e.prototype.handlePaymentHumanVerification=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){return"string"==typeof e?[2,this._paymentHumanVerificationHandler.handle(e,null!=t?t:"")]:[2,this._paymentHumanVerificationHandler.handle(e)]}))}))},e.prototype.widgetInteraction=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentStrategyWidgetActionCreator.widgetInteraction(e),{queueId:"widgetInteraction"})];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e}();const Mo=Do;var No;!function(e){e.Synchronize="SYNCHRONIZE"}(No||(No={}));const Lo=function(){function e(e){this._transformSelectors=e}return e.prototype.create=function(e){return function(e,t){var n=(0,a.createDataStore)((function(e,t){return t.type===No.Synchronize?t.payload:e}),e.getState(),{stateTransformer:t});return e.subscribe((function(e){n.dispatch((0,a.createAction)(No.Synchronize,e))}),{initial:!1}),n}(e,this._transformSelectors)},e}();const zo=require("shallowequal");var Uo=e.n(zo);function Fo(e){return Object.prototype.hasOwnProperty.call(e,"cacheKey")}var Bo=function(){function e(e){this._lastId=0,this._map={maps:[]},this._usedMaps=[],this._options=(0,o.__assign)({maxSize:0,isEqual:Uo(),onExpire:_.noop},e)}return e.prototype.getKey=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._resolveMap.apply(this,e),r=n.index,i=n.parentMap,o=n.map;return o&&o.cacheKey?o.usedCount++:o=this._generateMap(i,e.slice(r)),this._removeLeastUsedMap(o),o.cacheKey},e.prototype.getUsedCount=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._resolveMap.apply(this,e).map;return n?n.usedCount:0},e.prototype._resolveMap=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r=0,i=this._map;i.maps.length;){for(var o=!1,a=0;a<i.maps.length;a++){var s=i.maps[a];if(this._options.isEqual(s.value,t[r])){if((e=i.maps).unshift.apply(e,i.maps.splice(a,1)),(0===t.length||r===t.length-1)&&Fo(s))return{index:r,map:s,parentMap:i};o=!0,i=s,r++;break}}if(!o)break}return{index:r,parentMap:i}},e.prototype._generateMap=function(e,t){var n,r=0,i=e;do{n={maps:[],parentMap:i,usedCount:1,value:t[r]},i.maps.unshift(n),i=n,r++}while(r<t.length);var o=n;return o.cacheKey=""+ ++this._lastId,o},e.prototype._removeLeastUsedMap=function(e){if(this._options.maxSize){var t=this._usedMaps.indexOf(e);if(this._usedMaps.splice(-1===t?0:t,-1===t?0:1,e),!(this._usedMaps.length<=this._options.maxSize)){var n=this._usedMaps.pop();n&&(this._removeMap(n),this._options.onExpire(n.cacheKey))}}},e.prototype._removeMap=function(e){e.parentMap&&(e.parentMap.maps.splice(e.parentMap.maps.indexOf(e),1),function(e){return Object.prototype.hasOwnProperty.call(e,"parentMap")}(e.parentMap)||this._removeMap(e.parentMap))},e}();const qo=Bo;function xo(e){var t=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,o.__extends)(t,e),t}(e);return Object.getOwnPropertyNames(e.prototype).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e.prototype,n);r&&"constructor"!==n&&Object.defineProperty(t.prototype,n,function(e,t,n){if("function"!=typeof n.value)return n;var r=new qo,i=n.value,a=(0,Dn.memoize)(i);return Yr(e,t,{get:function(){var e=this,s=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var s=a.call.apply(a,(0,o.__spreadArrays)([e],t));if(1===r.getUsedCount.apply(r,t))return s;var u=i.call.apply(i,(0,o.__spreadArrays)([e],t));return D(u,s,{keyFilter:function(e){return!function(e){return 0===(""+e).indexOf("$$")||0===(""+e).indexOf("_")}(e)}})?s:(a.cache.set(r.getKey.apply(r,t),u),u)};return Object.defineProperty(this,t,(0,o.__assign)((0,o.__assign)({},n),{value:s})),s},set:function(e){r=new qo,i=e,a=(0,Dn.memoize)(i)}})}(e.prototype,n,r))})),t}const Go=function(){function e(e){this._checkoutButton=e.checkoutButton}return e.prototype.getInitializeButtonError=function(e){return this._checkoutButton.getInitializeError(e)},e.prototype.getDeinitializeButtonError=function(e){return this._checkoutButton.getDeinitializeError(e)},(0,o.__decorate)([xo],e)}(),Vo=function(){function e(e){this._checkoutButton=e.checkoutButton}return e.prototype.isInitializingButton=function(e){return this._checkoutButton.isInitializing(e)},e.prototype.isDeinitializingButton=function(e){return this._checkoutButton.isDeinitializing(e)},(0,o.__decorate)([xo],e)}();function Ho(e){return{errors:new Go(e),statuses:new Vo(e)}}var jo=function(){function e(e,t){var n=this;this._store=e,this._buttonStrategyActionCreator=t,this._state=Ho(this._store.getState()),this._store.subscribe((function(e){n._state=Ho(e)}))}return e.prototype.getState=function(){return this._state},e.prototype.subscribe=function(e){for(var t,n=this,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return(t=this._store).subscribe.apply(t,(0,o.__spreadArrays)([function(){return e(n.getState())},function(e){return e.checkoutButton.getState()}],r.map((function(e){return function(t){return e(Ho(t))}}))))},e.prototype.initializeButton=function(e){var t,n=this,r=(t=e.containerId,/^\w[\w\-\:\.]*$/.test(t)?[e.containerId]:function(e,t){var n=document.querySelectorAll(e);if(!n.length)throw new Gr("Unable to find any element with the specified selector: "+e);return Array.prototype.slice.call(n).map((function(e){return e.id||(e.id=(0,_.uniqueId)(t)),e.id}))}(e.containerId,e.methodId+"-container"));return Promise.all(r.map((function(t){var r=n._buttonStrategyActionCreator.initialize((0,o.__assign)((0,o.__assign)({},e),{containerId:t})),i="checkoutButtonStrategy:"+e.methodId+":"+t;return n._store.dispatch(r,{queueId:i})}))).then((function(){return n.getState()}))},e.prototype.deinitializeButton=function(e){var t=this,n=this._buttonStrategyActionCreator.deinitialize(e),r="checkoutButtonStrategy:"+e.methodId;return this._store.dispatch(n,{queueId:r}).then((function(){return t.getState()}))},(0,o.__decorate)([Yr],e)}();const Yo=jo,Wo=function(){function e(e,t,n){this._registry=e,this._registryV2=t,this._paymentMethodActionCreator=n}return e.prototype.initialize=function(e){var t=this;return function(n){var r={methodId:e.methodId,containerId:e.containerId};if(n.getState().checkoutButton.isInitialized(e.methodId,e.containerId))return(0,E.empty)();var i=e.currencyCode?{params:{currencyCode:e.currencyCode}}:{},s=(0,o.__assign)((0,o.__assign)({},i),{timeout:e.timeout,useCache:!0});return(0,E.concat)((0,E.of)((0,a.createAction)(Y.InitializeButtonRequested,void 0,r)),t._paymentMethodActionCreator.loadPaymentMethod(e.methodId,s)(n),(0,E.defer)((function(){return t._getStrategy(e.methodId).initialize(e).then((function(){return(0,a.createAction)(Y.InitializeButtonSucceeded,void 0,r)}))}))).pipe((0,b.catchError)((function(e){return or(Y.InitializeButtonFailed,e,r)})))}},e.prototype.deinitialize=function(e){var t=this;return function(n){var r={methodId:e.methodId};return n.getState().checkoutButton.isInitialized(e.methodId)?(0,E.concat)((0,E.of)((0,a.createAction)(Y.DeinitializeButtonRequested,void 0,r)),(0,E.defer)((function(){return t._getStrategy(e.methodId).deinitialize().then((function(){return(0,a.createAction)(Y.DeinitializeButtonSucceeded,void 0,r)}))}))).pipe((0,b.catchError)((function(e){return or(Y.DeinitializeButtonFailed,e,r)}))):(0,E.empty)()}},e.prototype._getStrategy=function(e){var t;try{t=this._registryV2.get({id:e})}catch(n){t=this._registry.get(e)}return t},e}(),Ko=function(e){function t(t){var n=e.call(this,t||"Unable to proceed because the client library of a payment method is not loaded or ready to be used.")||this;return n.name="PaymentMethodClientUnavailableError",n.type="payment_method_client_unavailable",n}return(0,o.__extends)(t,e),t}(s);var Zo,Qo,Jo,Xo;!function(e){e.Sandbox="sandbox",e.Production="production"}(Zo||(Zo={})),function(e){e.Client="client",e.DataCollector="dataCollector",e.Fastlane="fastlane",e.GooglePayment="googlePayment",e.HostedFields="hostedFields",e.LocalPayment="localPayment",e.Paypal="paypal",e.PaypalCheckout="paypalCheckout",e.ThreeDSecure="threeDSecure",e.UsBankAccount="usBankAccount",e.Venmo="venmo",e.VisaCheckout="visaCheckout"}(Qo||(Qo={})),function(e){e.CardCode="cardCode",e.CardCodeVerification="cardCodeVerification",e.CardExpiry="cardExpiry",e.CardName="cardName",e.CardNumber="cardNumber",e.CardNumberVerification="cardNumberVerification"}(Jo||(Jo={}));var $o=((Xo={})[Qo.Client]="sha384-26BXDNnJI23JYRyFBj4xe4sVNrUSSiSSu11kxVXNM/vEPONm4LuL00w6ZaTgQewt",Xo[Qo.PaypalCheckout]="sha384-B+vzbZwnQtzWBthpkT4TXKUibO65tyeK7eCxSvpblgprTep2+IAXB2Cxxjrn710O",Xo[Qo.Paypal]="sha384-uyAGL1/3+XJAHnGoNy4eCoXdzJ4f7Ilzp+6w9PNnEjs6DCCz9WMyJjMN1gzc78U+",Xo[Qo.LocalPayment]="sha384-LIvOEMkIVEwVuYBdVOQc1AC5YbGGlwyfUheS0ACK218D2STuVYQlZ4FyEPowAEfT",Xo[Qo.DataCollector]="sha384-1bo9JDz+Kscthc085cCKWur8CLwUoBpoNyxsDi7932mCl0zFq3A5mv+FQLw9GHpV",Xo[Qo.UsBankAccount]="sha384-xmHBVaU+w74V+OebD3AaPONFxHUGMf+QRs8G/JxVPXNNP7MDa2jL0ICWHIe2tTfJ",Xo[Qo.GooglePayment]="sha384-WKDJl8mqoP82qZpMGH6AbZxnvXnSW8ILV4M64CyMLiugGMwu7LyP89wjCkHqsiBe",Xo[Qo.ThreeDSecure]="sha384-VQUlpGHzsGvs5XeiGFip7EXRsvoHWEXDVmgCacfbyieZI9mdBOqq3NSoyo28OCOB",Xo[Qo.VisaCheckout]="sha384-yx7mADfzTN0T43Q6rlH49LIg1EJ0iUZgBp/EczX9LXsUGkySgxrD+nWHQRBkyfoT",Xo[Qo.Venmo]="sha384-QX4rPjoj1ZDhuG0aSyKs56lEKDqTMTcjYxUHY1SzO5VZDsqIE2NTkqot7KNSCyov",Xo[Qo.HostedFields]="sha384-VvYBACfSu0Cr/J32uKmxG7AXcNOJE1AzIIL3kbikyS7YKp5fz5Is+NzNP/lyauNy",Xo[Qo.Fastlane]="sha384-9oGsZMRZwpGtDEDYa/dFt76dECqj1xAni9gIKgc3KfMIiRnR73nEeeUDLiBzxhFa",Xo),ea=function(){function e(e,t){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSdkVersion="3.106.0"}return e.prototype.loadClient=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.Client,"client.min.js")]}))}))},e.prototype.loadFastlane=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.Fastlane,"fastlane.min.js")]}))}))},e.prototype.loadPaypalCheckout=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.PaypalCheckout,"paypal-checkout.min.js")]}))}))},e.prototype.loadPaypal=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.Paypal,"paypal.min.js")]}))}))},e.prototype.loadBraintreeLocalMethods=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.LocalPayment,"local-payment.min.js")]}))}))},e.prototype.loadDataCollector=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.DataCollector,"data-collector.min.js")]}))}))},e.prototype.loadUsBankAccount=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.UsBankAccount,"us-bank-account.min.js")]}))}))},e.prototype.loadGooglePayment=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.GooglePayment,"google-payment.min.js")]}))}))},e.prototype.load3DS=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.ThreeDSecure,"three-d-secure.min.js")]}))}))},e.prototype.loadVisaCheckout=function(){return this.loadBraintreeModuleOrThrow(Qo.VisaCheckout,"visa-checkout.min.js")},e.prototype.loadVenmoCheckout=function(){return this.loadBraintreeModuleOrThrow(Qo.Venmo,"venmo.min.js")},e.prototype.loadHostedFields=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Qo.HostedFields,"hosted-fields.min.js")]}))}))},e.prototype.loadVisaCheckoutSdk=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n=this;return(0,o.__generator)(this,(function(r){return this.braintreeHostWindow.V?[2,this.braintreeHostWindow.V]:(t=e?"sha384-0eu1s1GtqzXlL9DtLgmwzC5WWlEH/ADRM0n38cVQkvtT+W/gey96rcb1LwuUOPDm":"sha384-1f1csvP3ZFxg4dILH1GaY4LHlZ0oX7Rk83rxmLlwbnIi4TM0NYzXoev1VoEiVDS6",[2,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((function(){if(!n.braintreeHostWindow.V)throw new Ko;return n.braintreeHostWindow.V}))])}))}))},e.prototype.loadBraintreeModuleOrThrow=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return(n=this.getBraintreeModule(e))?[2,n]:(r="//js.braintreegateway.com/web/"+this.braintreeSdkVersion+"/js/"+t,i=this.getIntegrityValuesByModuleName(e),[4,this.scriptLoader.loadScript(r,i?{async:!0,attributes:{integrity:i,crossorigin:"anonymous"}}:void 0)]);case 1:if(o.sent(),!(n=this.getBraintreeModule(e)))throw new Ko;return[2,n]}}))}))},e.prototype.getBraintreeModule=function(e){var t;return null===(t=this.braintreeHostWindow.braintree)||void 0===t?void 0:t[e]},e.prototype.getIntegrityValuesByModuleName=function(e){var t=$o[e];if(!t)throw new Error("Unexpected fileName value");return t},e}();const ta=ea;var na=function(){function e(e){var t,n,r;this._factories={},this._instances={},this._defaultToken=null!==(t=null==e?void 0:e.defaultToken)&&void 0!==t?t:"default",this._useFallback=null===(n=null==e?void 0:e.useFallback)||void 0===n||n,this._tokenResolver=null!==(r=null==e?void 0:e.tokenResolver)&&void 0!==r?r:function(e){return e}}return e.prototype.get=function(e,t){try{return this._getInstance(e||this._defaultToken,t||e||this._defaultToken)}catch(e){if(!this._useFallback)throw e;return this._getInstance(this._defaultToken,t||this._defaultToken)}},e.prototype.register=function(e,t){if(this._hasFactory(e))throw new Gr("'"+e+"' is already registered.");this._factories[e]=t},e.prototype._hasFactory=function(e){return!!this._factories[e]},e.prototype._hasInstance=function(e){return!!this._instances[e]},e.prototype._getInstance=function(e,t){if(!this._hasInstance(t)){var n=this._tokenResolver(e,Object.keys(this._factories)),r=n&&this._factories[n];if(!r)throw new Gr("'"+e+"' is not registered.");this._instances[t]=r()}return this._instances[t]},e}();const ra=na;var ia,oa,aa,sa,ua,ca=["buttons","messages"];!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(ia||(ia={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(oa||(oa={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white"}(aa||(aa={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(sa||(sa={})),function(e){e.PILL="pill",e.RECT="rect"}(ua||(ua={}));const da=function(e){function t(t){var n=e.call(this,t||"Unsupported browser error")||this;return n.name="UnsupportedBrowserError",n.type="unsupported_browser",n}return(0,o.__extends)(t,e),t}(p);var la=function(){function e(e){this._braintreeScriptLoader=e,this._dataCollectors={},this._window=window}return e.prototype.initialize=function(e){this._clientToken=e},e.prototype.getClient=function(){var e=this;if(!this._clientToken)throw new ni(ti.PaymentNotInitialized);return this._client||(this._client=this._braintreeScriptLoader.loadClient().then((function(t){return t.create({authorization:e._clientToken})}))),this._client},e.prototype.getPaypalCheckout=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s,u=this;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,this.getClient()];case 1:return r=o.sent(),[4,this._braintreeScriptLoader.loadPaypalCheckout()];case 2:return i=o.sent(),a={client:r},s=function(r,i){if(r)return n(r);u._window.paypal?t(i):i.loadPayPalSDK(u._getPayPalSDKConfig(e),(function(){return t(i)}))},this._paypalCheckout=i.create(a,s),[2,this._paypalCheckout]}}))}))},e.prototype.getVenmoCheckout=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return this._venmoCheckout?[3,3]:[4,this.getClient()];case 1:return n=o.sent(),[4,this._braintreeScriptLoader.loadVenmoCheckout()];case 2:r=o.sent(),i={client:n,allowDesktop:!0,paymentMethodUsage:"multi_use"},a=function(n,r){return n?t(n):r.isBrowserSupported()?void e(r):t(new da)},this._venmoCheckout=r.create(i,a),o.label=3;case 3:return[2,this._venmoCheckout]}}))}))},e.prototype.get3DS=function(){return this._3ds||(this._3ds=Promise.all([this.getClient(),this._braintreeScriptLoader.load3DS()]).then((function(e){var t=e[0];return e[1].create({client:t,version:2})}))),this._3ds},e.prototype.getDataCollector=function(e){var t=e&&e.paypal?"paypal":"default",n=this._dataCollectors[t];return n||(n=Promise.all([this.getClient(),this._braintreeScriptLoader.loadDataCollector()]).then((function(t){var n=t[0];return t[1].create((0,o.__assign)({client:n,kount:!0},e))})).catch((function(e){if(e&&"DATA_COLLECTOR_KOUNT_NOT_ENABLED"===e.code)return{deviceData:void 0,teardown:function(){return Promise.resolve()}};throw e})),this._dataCollectors[t]=n),n},e.prototype.getVisaCheckout=function(){return this._visaCheckout||(this._visaCheckout=Promise.all([this.getClient(),this._braintreeScriptLoader.loadVisaCheckout()]).then((function(e){var t=e[0];return e[1].create({client:t})}))),this._visaCheckout},e.prototype.createHostedFields=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,Promise.all([this.getClient(),this._braintreeScriptLoader.loadHostedFields()])];case 1:return t=r.sent(),n=t[0],[2,t[1].create((0,o.__assign)((0,o.__assign)({},e),{client:n}))]}}))}))},e.prototype.teardown=function(){var e=this;return Promise.all([this._teardown(this._3ds),this._teardown(this._dataCollectors.default),this._teardown(this._dataCollectors.paypal),this._teardown(this._paypalCheckout),this._teardown(this._venmoCheckout),this._teardown(this._visaCheckout)]).then((function(){e._3ds=void 0,e._dataCollectors={},e._paypalCheckout=void 0,e._venmoCheckout=void 0,e._visaCheckout=void 0}))},e.prototype._teardown=function(e){return e?e.then((function(e){return e.teardown()})).catch((function(e){if("METHOD_CALLED_AFTER_TEARDOWN"!==e.code)throw e})):Promise.resolve()},e.prototype._getPayPalSDKConfig=function(e){return(0,o.__assign)((0,o.__assign)({currency:e.currency},e.isCreditEnabled&&{"enable-funding":"paylater"}),{components:ca.toString(),intent:e.intent,commit:!1})},e}();const pa=la;const ha=function(e){function t(t){var n=e.call(this,t||"Unable to proceed because the client library of a payment method is not loaded or ready to be used.")||this;return n.name="PaymentMethodClientUnavailableError",n.type="payment_method_client_unavailable",n}return(0,o.__extends)(t,e),t}(p);var fa=function(){function e(e,t){void 0===t&&(t=window),this._scriptLoader=e,this._window=t}return e.prototype.load=function(e){var t=e.useMasterpassSrc,n=e.language,r=e.testMode,i=e.checkoutId;return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return t?(e=["https://"+(r?"sandbox.":"")+"src.mastercard.com/srci/integration/merchant.js",["locale="+n,"checkoutid="+i].join("&")].join("?"),[4,this._scriptLoader.loadScript(e)]):[3,2];case 1:case 3:if(o.sent(),!this._window.masterpass)throw new ha;return[2,this._window.masterpass];case 2:return[4,this._scriptLoader.loadScript("//"+(r?"sandbox.":"")+"masterpass.com/integration/merchant.js")]}}))}))},e}();const ga=fa,ma=function(){function e(e){this._scriptLoader=e,this._window=window}return e.prototype.loadPaypal=function(e){return void 0===e&&(e=""),(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return t="//www.paypalobjects.com/api/checkout.min.js",n={async:!0,attributes:{"data-merchant-id":e}},e?[4,this._scriptLoader.loadScript(t,n)]:[3,2];case 1:return r.sent(),[3,4];case 2:return[4,this._scriptLoader.loadScript(t)];case 3:r.sent(),r.label=4;case 4:if(!this._window.paypal)throw new ha;return[2,this._window.paypal]}}))}))},e}(),_a=function(e){function t(t){var n=e.call(this,t||"An unexpected error has occurred during buy now cart creation process. Please try again later.")||this;return n.name="BuyNowCartCreationError",n.type="buy_now_cart_creation_error",n}return(0,o.__extends)(t,e),t}(p);function ya(e){return{recipientName:e.firstName+" "+e.lastName,line1:e.address1,line2:e.address2,city:e.city,state:e.stateOrProvinceCode,postalCode:e.postalCode,countryCode:e.countryCode,phone:e.phone}}function va(e){var t=e.color,n=e.fundingicons,r=e.height,i=e.layout,o=e.shape,a=e.size,s=e.tagline,u={color:t,fundingicons:n,height:Ca(r),layout:i,shape:o||"rect",size:a,tagline:s};return(0,_.omitBy)(u,_.isNil)}function Ca(e){return"number"!=typeof e||e>55?55:e<25?25:e}function Sa(e){var t=e.billingAddress,n=e.email,r=e.firstName,i=e.lastName,o=e.phone,a=e.shippingAddress,s=t||a;return{email:n,first_name:r,last_name:i,phone_number:o,address_line_1:null==s?void 0:s.line1,address_line_2:null==s?void 0:s.line2,city:null==s?void 0:s.city,state:null==s?void 0:s.state,country_code:null==s?void 0:s.countryCode,postal_code:null==s?void 0:s.postalCode}}function Ia(e){var t=e.email,n=e.phone,r=e.shippingAddress,i=((null==r?void 0:r.recipientName)||"").split(" ");return{email:t,first_name:i[0]||"",last_name:i[1]||"",phone_number:n,address_line_1:null==r?void 0:r.line1,address_line_2:null==r?void 0:r.line2,city:null==r?void 0:r.city,state:null==r?void 0:r.state,country_code:null==r?void 0:r.countryCode,postal_code:null==r?void 0:r.postalCode}}var wa=function(){function e(e,t,n,r,i,o){this._store=e,this._checkoutActionCreator=t,this._cartRequestSender=n,this._braintreeSDKCreator=r,this._formPoster=i,this._window=o}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h,f,g,m=this;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.braintreepaypal,n=e.containerId,r=e.methodId,a=(i=t||{}).messagingContainerId,s=i.onError,!r)throw new Gr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Gr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Gr('Unable to initialize payment because "options.braintreepaypal" argument is not provided.');if(!t.buyNowInitializeOptions)return[3,1];if(u=this._store.getState(),c=u.paymentMethods.getPaymentMethodOrThrow(r),!t.currencyCode)throw new Gr('Unable to initialize payment because "options.braintreepaypal.currencyCode" argument is not provided.');return d=t.currencyCode,[3,3];case 1:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 2:u=o.sent(),c=u.paymentMethods.getPaymentMethodOrThrow(r),d=u.cart.getCartOrThrow().currency.code,o.label=3;case 3:if(l=c.clientToken,p=c.initializationData,!l||!p)throw new Nn(Mn.MissingPaymentMethod);return h={currency:d,intent:p.intent,isCreditEnabled:p.isCreditEnabled},f=function(e){m._renderPayPalComponents(e,t,n,r,Boolean(c.config.testMode))},g=function(e){return m._handleError(e,n,a,s)},this._braintreeSDKCreator.initialize(l),[4,this._braintreeSDKCreator.getPaypalCheckout(h,f,g)];case 4:return o.sent(),[2]}}))}))},e.prototype.deinitialize=function(){return this._braintreeSDKCreator.teardown(),Promise.resolve()},e.prototype._renderPayPalComponents=function(e,t,n,r,i){var o=t.messagingContainerId;this._renderPayPalMessages(o),this._renderPayPalButton(e,t,n,r,i)},e.prototype._renderPayPalButton=function(e,t,n,r,i){var o=this,a=t.style,s=t.shouldProcessPayment,u=t.onAuthorizeError,c=this._window.paypal,d=null==c?void 0:c.FUNDING.PAYPAL;if(c&&d){var l=a?va(a):{},p=c.Buttons({env:i?"sandbox":"production",fundingSource:d,style:l,createOrder:function(){return o._setupPayment(e,t,r)},onApprove:function(t){return o._tokenizePayment(t,e,r,s,u)}});p.isEligible()&&p.render("#"+n)}else this._removeElement(n)},e.prototype._renderPayPalMessages=function(e){var t=e&&Boolean(document.getElementById(e)),n=this._window.paypal;if(n&&t){var r=this._store.getState().checkout.getCheckoutOrThrow().outstandingBalance;n.Messages({amount:r,placement:"cart"}).render("#"+e)}else this._removeElement(e)},e.prototype._setupPayment=function(e,t,n){var r,i;return(0,o.__awaiter)(this,void 0,void 0,(function(){var a,s,u,c,d,l,p,h,f,g,m,_;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:a=t.buyNowInitializeOptions,s=t.shippingAddress,u=t.onPaymentError,o.label=1;case 1:return o.trys.push([1,7,,8]),d=this,[4,this._createBuyNowCart({buyNowInitializeOptions:a})];case 2:return d._buyNowCart=o.sent(),this._buyNowCart?(c=this._store.getState(),[3,5]):[3,3];case 3:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 4:c=o.sent(),o.label=5;case 5:return l=c.customer.getCustomer(),p=c.paymentMethods.getPaymentMethodOrThrow(n),h=this._buyNowCart?this._buyNowCart.cartAmount:c.checkout.getCheckoutOrThrow().outstandingBalance,f=null!==(r=t.currencyCode)&&void 0!==r?r:c.config.getStoreConfigOrThrow().currency.code,g=s||(null==l?void 0:l.addresses[0]),m=g?ya(g):void 0,[4,e.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,shippingAddressOverride:m,amount:h,currency:f,offerCredit:!1,intent:null===(i=p.initializationData)||void 0===i?void 0:i.intent})];case 6:return[2,o.sent()];case 7:throw _=o.sent(),u&&u(_),_;case 8:return[2]}}))}))},e.prototype._createBuyNowCart=function(e){var t=e.buyNowInitializeOptions;return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("function"!=typeof(null==t?void 0:t.getBuyNowCartRequestBody))return[3,4];if(!(e=t.getBuyNowCartRequestBody()))throw new Nn(Mn.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._cartRequestSender.createBuyNowCart(e)];case 2:return[2,n.sent().body];case 3:throw n.sent(),new _a;case 4:return[2]}}))}))},e.prototype._tokenizePayment=function(e,t,n,r,i){var a;return(0,o.__awaiter)(this,void 0,void 0,(function(){var s,u,c,d,l,p;return(0,o.__generator)(this,(function(h){switch(h.label){case 0:return h.trys.push([0,3,,4]),[4,this._braintreeSDKCreator.getDataCollector({paypal:!0})];case 1:return s=h.sent().deviceData,[4,t.tokenizePayment(e)];case 2:return u=h.sent(),c=u.details,d=u.nonce,l=null===(a=this._buyNowCart)||void 0===a?void 0:a.id,this._formPoster.postForm("/checkout.php",(0,o.__assign)({payment_type:"paypal",provider:n,action:r?"process_payment":"set_external_checkout",nonce:d,device_data:s,billing_address:JSON.stringify(Sa(c)),shipping_address:JSON.stringify(Ia(c))},l&&{cart_id:l})),[2,u];case 3:throw p=h.sent(),i&&i(p),p;case 4:return[2]}}))}))},e.prototype._handleError=function(e,t,n,r){this._removeElement(t),this._removeElement(n),r&&r(e)},e.prototype._removeElement=function(e){var t=e&&document.getElementById(e);t&&t.remove()},e}();const Ea=wa;var ba,Pa,Aa,Oa,Ta;!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(ba||(ba={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(Pa||(Pa={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white"}(Aa||(Aa={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(Oa||(Oa={})),function(e){e.PILL="pill",e.RECT="rect"}(Ta||(Ta={}));var Ra=function(){function e(e,t,n,r,i,o){this._store=e,this._checkoutActionCreator=t,this._cartRequestSender=n,this._braintreeSDKCreator=r,this._formPoster=i,this._window=o}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h=this;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.braintreepaypalcredit,n=e.containerId,!(r=e.methodId))throw new Gr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Gr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Gr('Unable to initialize payment because "options.braintreepaypalcredit" argument is not provided.');if(!t.buyNowInitializeOptions)return[3,1];if(i=this._store.getState(),a=i.paymentMethods.getPaymentMethodOrThrow(r),!t.currencyCode)throw new Gr('Unable to initialize payment because "options.braintreepaypalcredit.currencyCode" argument is not provided.');return s=t.currencyCode,[3,3];case 1:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 2:i=o.sent(),a=i.paymentMethods.getPaymentMethodOrThrow(r),s=i.cart.getCartOrThrow().currency.code,o.label=3;case 3:if(u=a.clientToken,c=a.initializationData,!u||!c)throw new Nn(Mn.MissingPaymentMethod);return d={currency:s,intent:c.intent,isCreditEnabled:c.isCreditEnabled},l=function(e){return h._renderPayPalButton(e,t,n,r,Boolean(a.config.testMode))},p=function(e){return h._handleError(e,n,t.onError)},this._braintreeSDKCreator.initialize(u),[4,this._braintreeSDKCreator.getPaypalCheckout(d,l,p)];case 4:return o.sent(),[2]}}))}))},e.prototype.deinitialize=function(){return this._braintreeSDKCreator.teardown(),Promise.resolve()},e.prototype._renderPayPalButton=function(e,t,n,r,i){var a=this,s=t.style,u=t.shouldProcessPayment,c=t.onAuthorizeError,d=this._window.paypal,l=!1;if(d){var p=[d.FUNDING.PAYLATER,d.FUNDING.CREDIT],h=s?va(s):{};p.forEach((function(s){var p=s===d.FUNDING.CREDIT?(0,o.__assign)({label:Oa.CREDIT},h):h;if(!l){var f=d.Buttons({env:i?"sandbox":"production",fundingSource:s,style:p,createOrder:function(){return a._setupPayment(e,t,r)},onApprove:function(t){return a._tokenizePayment(t,e,r,u,c)}});f.isEligible()&&(f.render("#"+n),l=!0)}}))}d&&l||this._removeElement(n)},e.prototype._setupPayment=function(e,t,n){var r,i;return(0,o.__awaiter)(this,void 0,void 0,(function(){var a,s,u,c,d,l,p,h,f,g,m,_;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:a=t.onPaymentError,s=t.shippingAddress,u=t.buyNowInitializeOptions,o.label=1;case 1:return o.trys.push([1,7,,8]),d=this,[4,this._createBuyNowCart({buyNowInitializeOptions:u})];case 2:return d._buyNowCart=o.sent(),this._buyNowCart?(c=this._store.getState(),[3,5]):[3,3];case 3:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 4:c=o.sent(),o.label=5;case 5:return l=c.customer.getCustomer(),p=c.paymentMethods.getPaymentMethodOrThrow(n),h=this._buyNowCart?this._buyNowCart.cartAmount:c.checkout.getCheckoutOrThrow().outstandingBalance,f=null!==(r=t.currencyCode)&&void 0!==r?r:c.config.getStoreConfigOrThrow().currency.code,g=s||(null==l?void 0:l.addresses[0]),m=g?ya(g):void 0,[4,e.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,shippingAddressOverride:m,amount:h,currency:f,offerCredit:!0,intent:null===(i=p.initializationData)||void 0===i?void 0:i.intent})];case 6:return[2,o.sent()];case 7:throw _=o.sent(),a&&a(_),_;case 8:return[2]}}))}))},e.prototype._createBuyNowCart=function(e){var t=e.buyNowInitializeOptions;return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("function"!=typeof(null==t?void 0:t.getBuyNowCartRequestBody))return[3,4];if(!(e=t.getBuyNowCartRequestBody()))throw new Nn(Mn.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._cartRequestSender.createBuyNowCart(e)];case 2:return[2,n.sent().body];case 3:throw n.sent(),new _a;case 4:return[2]}}))}))},e.prototype._tokenizePayment=function(e,t,n,r,i){var a;return(0,o.__awaiter)(this,void 0,void 0,(function(){var s,u,c,d,l,p;return(0,o.__generator)(this,(function(h){switch(h.label){case 0:return h.trys.push([0,3,,4]),[4,this._braintreeSDKCreator.getDataCollector({paypal:!0})];case 1:return s=h.sent().deviceData,[4,t.tokenizePayment(e)];case 2:return u=h.sent(),c=u.details,d=u.nonce,l=null===(a=this._buyNowCart)||void 0===a?void 0:a.id,this._formPoster.postForm("/checkout.php",(0,o.__assign)({payment_type:"paypal",provider:n,action:r?"process_payment":"set_external_checkout",nonce:d,device_data:s,billing_address:JSON.stringify(Sa(c)),shipping_address:JSON.stringify(Ia(c))},l&&{cart_id:l})),[2,u];case 3:throw p=h.sent(),i&&i(p),p;case 4:return[2]}}))}))},e.prototype._handleError=function(e,t,n){this._removeElement(t),n&&n(e)},e.prototype._removeElement=function(e){var t=e&&document.getElementById(e);t&&t.remove()},e}();const ka=Ra;var Da={es:["es_es","es_mx","es_pe","es_co","es_ar","es_cl"],en:["en_us","en_gb","en_ca","en_es","en_fr","en_ie","en_sg","en_au","en_nz","en_my","en_hk","en_th","en_ae","en_sa","en_qa","en_kw","en_za"],pt:["pt_br"],zu:["zu_za"],ar:["ar_sa","ar_ae","ar_qa","ar_kw"],zh:["zh_sg","zh_hk"],ms:["ms_my"],uk:["uk_ua"],sv:["sv_se"],hr:["hr_hr"],pl:["pl_pl"],nl:["nl_be"],it:["it_it"],de:["de_de"],fr:["fr_fr","fr_ca"]};function Ma(e){var t=e.replace("-","_").toLowerCase().split("_"),n=t[0],r=n+"_"+t[1],i=Da[n];return i?i.indexOf(r)>-1?r:i[0]:"en_us"}const Na=function(){function e(e,t,n,r){this._store=e,this._checkoutActionCreator=t,this._masterpassScriptLoader=n,this._locale=r}return e.prototype.initialize=function(e){var t=this,n=e.containerId,r=e.methodId;if(!n||!r)throw new Gr('Unable to proceed because "containerId" argument is not provided.');return this._methodId=r,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout()).then((function(e){var n=e.paymentMethods.getPaymentMethod(r);if(!n||!n.initializationData.checkoutId)throw new Nn(Mn.MissingPaymentMethod);var i={useMasterpassSrc:n.initializationData.isMasterpassSrcEnabled,language:Ma(t._locale),testMode:n.config.testMode,checkoutId:n.initializationData.checkoutId};return t._masterpassScriptLoader.load(i)})).then((function(e){t._masterpassClient=e,t._signInButton=t._createSignInButton(n)}))},e.prototype.deinitialize=function(){return this._signInButton&&this._signInButton.parentNode&&(this._signInButton.removeEventListener("click",this._handleWalletButtonClick),this._signInButton.parentNode.removeChild(this._signInButton),this._signInButton=void 0),Promise.resolve()},e.prototype._createSignInButton=function(e){var t=document.getElementById(e),n=this._store.getState(),r=this._methodId?n.paymentMethods.getPaymentMethod(this._methodId):null,i=n.config.getStoreConfig();if(!t)throw new Error("Need a container to place the button");if(!r)throw new Nn(Mn.MissingPaymentMethod);if(!i)throw new Gr("Unable to retrieve store configuration");var o=document.createElement("input");if(o.type="image",r.initializationData.isMasterpassSrcEnabled){var a=r.config.testMode?"sandbox.":"",s=r.initializationData.checkoutId,u=["locale="+Ma(this._locale),"paymentmethod=master,visa,amex,discover","checkoutid="+s];o.src=["https://"+a+"src.mastercard.com/assets/img/btn/src_chk_btn_126x030px.svg",u.join("&")].join("?")}else o.src="https://static.masterpass.com/dyn/img/btn/global/mp_chk_btn_160x037px.svg";return t.appendChild(o),o.addEventListener("click",this._handleWalletButtonClick),o},e.prototype._createMasterpassPayload=function(){var e=this._store.getState(),t=e.checkout.getCheckout(),n=this._methodId?e.paymentMethods.getPaymentMethod(this._methodId):null;if(!t)throw new Nn(Mn.MissingCheckout);if(!n)throw new Nn(Mn.MissingPaymentMethod);return{checkoutId:n.initializationData.checkoutId,allowedCardTypes:n.initializationData.allowedCardTypes,amount:t.cart.cartAmount.toString(),currency:t.cart.currency.code,cartId:t.cart.id,callbackUrl:window.location.origin+"/checkout.php?action=set_external_checkout&provider=masterpass&gateway=stripe&origin=cart"}},e.prototype._handleWalletButtonClick=function(){if(!this._masterpassClient)throw new ni(ti.CheckoutButtonNotInitialized);this._masterpassClient.checkout(this._createMasterpassPayload())},(0,o.__decorate)([Yr],e.prototype,"_handleWalletButtonClick",null),e}();var La=function(){function e(e,t,n,r,i){void 0===i&&(i=""),this._store=e,this._checkoutActionCreator=t,this._paypalScriptLoader=n,this._formPoster=r,this._host=i}return e.prototype.initialize=function(e){var t=this,n=e.paypal,r=this._store.getState(),i=this._paymentMethod=r.paymentMethods.getPaymentMethod(e.methodId);if(!n)throw new Gr;if(!i)throw new Nn(Mn.MissingPaymentMethod);return this._paypalScriptLoader.loadPaypal(i.config.merchantId).then((function(r){var a,s,u;if(!i||!i.config.merchantId)throw new Nn(Mn.MissingPaymentMethod);var c=i.config.merchantId,d=i.config.testMode?"sandbox":"production",l=((a={})[d]=n.clientId,a),p=r.FUNDING.CREDIT||"credit",h=n.allowCredit?[p]:[],f=n.allowCredit?[]:[p];return r.Button.render({env:d,client:l,commit:n.shouldProcessPayment,funding:{allowed:h,disallowed:f},style:(0,o.__assign)((0,o.__assign)({shape:Ta.RECT},(0,_.pick)(n.style,"layout","color","label","shape","tagline","fundingicons")),{size:"paypalexpress"===i.id&&"small"===(null===(s=n.style)||void 0===s?void 0:s.size)?Pa.RESPONSIVE:null===(u=n.style)||void 0===u?void 0:u.size}),payment:function(e,r){return t._setupPayment(c,r,n.onPaymentError)},onAuthorize:function(e,r){return t._tokenizePayment(e,r,n.shouldProcessPayment,n.onAuthorizeError)}},e.containerId)}))},e.prototype.deinitialize=function(){return this._paymentMethod=void 0,Promise.resolve()},e.prototype._setupPayment=function(e,t,n){var r=this;if(!t)throw new ni(ti.CheckoutButtonNotInitialized);return this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout()).then((function(n){var i=n.cart.getCart(),a=i?i.id:"";return t.request.post(r._host+"/api/storefront/payment/paypalexpress",{merchantId:e,cartId:a},{headers:(0,o.__assign)({"X-API-INTERNAL":er},tr)})})).then((function(e){return e.id})).catch((function(e){throw n&&n(e),e}))},e.prototype._tokenizePayment=function(e,t,n,r){var i=this;if(!this._paymentMethod)throw new ni(ti.CheckoutButtonNotInitialized);if(!t)throw new ni(ti.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new Nn(Mn.MissingPayment);var o=this._paymentMethod.id;return t.payment.get(e.paymentID).then((function(t){i._formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:o,action:n?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(t.payer.payer_info)})}))},e}();const za=La;function Ua(){try{return process.env.NODE_ENV||0}catch(e){return"development"}}var Fa=function(){function e(e){this._console=e}return e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["log"],e))},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["info"],e))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["warn"],e))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["error"],e))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["debug"],e))},e.prototype._logToConsole=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];this._console&&this._console[e]&&(t=this._console[e]).call.apply(t,(0,o.__spreadArrays)([this._console],n))},e}();const Ba=Fa,qa=function(){function e(){}return e.prototype.log=function(){},e.prototype.info=function(){},e.prototype.warn=function(){},e.prototype.error=function(){},e.prototype.debug=function(){},e}();var xa,Ga=(void 0===(xa="test"!==Ua())&&(xa=!0),xa?new Ba(console):new qa),Va=function(){function e(e){void 0===e&&(e=!1),this._useFallback=e,this._registry=new ra({tokenResolver:this._resolveToken.bind(this),useFallback:this._useFallback})}return e.prototype.get=function(e){return this._registry.get(this._encodeToken(e))},e.prototype.register=function(e,t){this._registry.register(this._encodeToken(e),t)},e.prototype._encodeToken=function(e){return btoa(JSON.stringify(e))},e.prototype._decodeToken=function(e){return JSON.parse(atob(e))},e.prototype._resolveToken=function(e,t){var n,r=this,i=this._decodeToken(e),o=[];t.forEach((function(e){for(var t=r._decodeToken(e),n={token:e,matches:0,default:!1},a=0,s=Object.entries(t);a<s.length;a++){var u=s[a],c=u[0],d=u[1];if(c in i&&i[c]!==d){n.matches=0;break}c in i&&i[c]===d&&n.matches++,"default"===c&&!0===d&&(n.default=!0)}o.push(n)}));var a=o.sort((function(e,t){return t.matches-e.matches})).filter((function(e){return e.matches>0}));a.length>1&&a[0].matches===a[1].matches&&"development"===Ua()&&Ga.warn("The provided query matches at least two strategies with the same specificity. This warning can be resolved by making their resolve ID more specific.");var s=a[0];if(s&&s.token)return s.token;if(this._useFallback){var u=null===(n=o.find((function(e){return e.default})))||void 0===n?void 0:n.token;if(u)return u}throw new Error("Unable to resolve to a registered token with the provided token.")},e}();const Ha=Va;const ja=function(e){function t(t){var n=e.call(this,t||"Invalid arguments have been provided.")||this;return n.name="InvalidArgumentError",n.type="invalid_argument",n}return(0,o.__extends)(t,e),t}(s);var Ya;!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(Ya||(Ya={}));const Wa=function(e){function t(t){var n=e.call(this,function(e){switch(e){case Ya.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case Ya.MissingCart:return"Unable to proceed because cart data is unavailable.";case Ya.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case Ya.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case Ya.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case Ya.MissingCheckoutConfig:case Ya.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case Ya.MissingOrder:return"Unable to proceed because order data is unavailable.";case Ya.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case Ya.MissingPayment:return"Unable to proceed because payment data is unavailable.";case Ya.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case Ya.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case Ya.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(t))||this;return n.subtype=t,n.name="MissingDataError",n.type="missing_data",n}return(0,o.__extends)(t,e),t}(s);function Ka(e){return t=e.lineItems.physicalItems.filter((function(e){return!e.addedByPromotion})),(0,_.reduce)(t,(function(e,t){return e+t.quantity}),0);var t}function Za(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}var Qa;!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(Qa||(Qa={}));const Ja=function(e){function t(t){var n=e.call(this,function(e){switch(e){case Qa.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case Qa.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case Qa.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case Qa.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(t))||this;return n.subtype=t,n.name="NotInitializedError",n.type="not_initialized",n}return(0,o.__extends)(t,e),t}(s);var Xa,$a,es,ts,ns,rs,is={de:"eu",jp:"fe",uk:"eu",us:"na"};!function(e){e.en_US="en_US",e.en_GB="en_GB",e.de_DE="de_DE",e.fr_FR="fr_FR",e.it_IT="it_IT",e.es_ES="es_ES",e.ja_JP="ja_JP"}(Xa||(Xa={})),function(e){e.Home="Home",e.Product="Product",e.Cart="Cart",e.Checkout="Checkout",e.Other="Other"}($a||($a={})),function(e){e.USD="USD",e.EUR="EUR",e.GBP="GBP",e.JPY="JPY"}(es||(es={})),function(e){e.PayAndShip="PayAndShip",e.PayOnly="PayOnly"}(ts||(ts={})),function(e){e.Gold="Gold",e.LightGray="LightGray",e.DarkGray="DarkGray"}(ns||(ns={})),function(e){e.C0001="C0001"}(rs||(rs={}));var os=function(){function e(e){this.amazonPayV2ScriptLoader=e}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return t=this,[4,this.amazonPayV2ScriptLoader.load(e)];case 1:return t.amazonPayV2SDK=n.sent(),this.buttonParentContainer=this.buttonParentContainer||this.createAmazonPayButtonParentContainer(),[2]}}))}))},e.prototype.deinitialize=function(){var e;return this.amazonPayV2Button=void 0,null===(e=this.buttonParentContainer)||void 0===e||e.remove(),this.buttonParentContainer=void 0,this.amazonPayV2SDK=void 0,Promise.resolve()},e.prototype.bindButton=function(e,t,n){this.getAmazonPayV2SDK().Pay.bindChangeAction("#"+e,{amazonCheckoutSessionId:t,changeAction:n})},e.prototype.createButton=function(e,t){this.amazonPayV2Button=this.getAmazonPayV2SDK().Pay.renderButton("#"+e,t)},e.prototype.prepareCheckout=function(e){var t=this,n=this.prepareRequestConfig(e);this.getAmazonPayV2Button().onClick((function(){t.getAmazonPayV2Button().initCheckout(n)}))},e.prototype.prepareCheckoutWithCreationRequestConfig=function(e){var t=this;this.getAmazonPayV2Button().onClick((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,e()];case 1:return(t=r.sent())&&(n=this.prepareRequestConfig(t.createCheckoutSessionConfig,t.estimatedOrderAmount,t.productType),this.getAmazonPayV2Button().initCheckout(n)),[2]}}))}))}))},e.prototype.signout=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return this.amazonPayV2SDK&&this.amazonPayV2SDK.Pay.signout(),[2,Promise.resolve()]}))}))},e.prototype.renderAmazonPayButton=function(e){var t=e.buttonColor,n=e.checkoutState,r=e.containerId,i=e.decoupleCheckoutInitiation,o=void 0!==i&&i,a=e.methodId,s=e.options,u=e.placement,c=e.isButtonMicroTextDisabled,d=void 0!==c&&c,l=document.querySelector("#"+r);if(!l)throw new ja("Unable to render the Amazon Pay button to an invalid HTML container element.");var p=l.appendChild(this.getButtonParentContainer()).id;s&&d&&(s.design=rs.C0001);var h=null!=s?s:this.getAmazonPayV2ButtonOptions(n,a,u,o,t);return this.createButton(p,h),this.getButtonParentContainer()},e.prototype.updateBuyNowFlowFlag=function(e){this.isBuyNowFlow=Boolean(e)},e.prototype.isPh4Enabled=function(e,t){var n=!!e["PROJECT-3483.amazon_pay_ph4"],r=!!e["INT-6885.amazon_pay_ph4_us_only"];return n&&r?"US"===t:n},e.prototype.prepareRequestConfig=function(e,t,n){var r=e.publicKeyId,i=(0,o.__rest)(e,["publicKeyId"]);return(0,o.__assign)((0,o.__assign)({createCheckoutSessionConfig:this.isEnvironmentSpecific(r)?i:e},t&&{estimatedOrderAmount:t}),n&&{productType:n})},e.prototype.createAmazonPayButtonParentContainer=function(){var e=Math.random().toString(16).substr(-4),t=document.createElement("div");return t.id="amazonpay_button_parent_container_"+e,t},e.prototype.getAmazonPayV2ButtonOptions=function(e,t,n,r,i){var a;void 0===r&&(r=!1),void 0===i&&(i=ns.Gold);var s=this.getCheckoutState(e),u=s.getCart,c=s.getCheckout,d=s.getStoreConfigOrThrow,l=(0,s.getPaymentMethodOrThrow)(t),p=l.config,h=p.merchantId,f=p.testMode,g=l.initializationData;if(!g)throw new Wa(Ya.MissingPaymentMethod);var m=g.checkoutLanguage,_=g.checkoutSessionMethod,y=g.createCheckoutSessionConfig,v=g.extractAmazonCheckoutSessionId,C=g.ledgerCurrency,S=g.publicKeyId,I=void 0===S?"":S,w=g.isButtonMicroTextDisabled;if(!h||!C||!y)throw new Wa(Ya.MissingPaymentMethod);var E=(0,o.__assign)({merchantId:h,ledgerCurrency:C,checkoutLanguage:m,placement:n,buttonColor:i},w?{design:rs.C0001}:{});if(this.isBuyNowFlow)return(0,o.__assign)((0,o.__assign)({},E),{sandbox:!!f});var b=u();E.productType=b&&0===Ka(b)?ts.PayOnly:ts.PayAndShip;var P=d(),A=P.checkoutSettings.features,O=P.storeProfile,T=O.shopPath,R=O.storeCountryCode;if(this.isPh4Enabled(A,R)){var k=null===(a=c())||void 0===a?void 0:a.outstandingBalance.toString(),D=null==b?void 0:b.currency.code,M=(0,o.__assign)({},E),N=void 0;return this.isEnvironmentSpecific(I)?(M.publicKeyId=I,N=y):(M.sandbox=!!f,N=(0,o.__assign)((0,o.__assign)({},y),{publicKeyId:I})),r||(M.createCheckoutSessionConfig=N),k&&D&&(M.estimatedOrderAmount={amount:k,currencyCode:D}),M}var L={method:_,url:A["INT-5826.amazon_relative_url"]?"/remote-checkout/"+t+"/payment-session":T+"/remote-checkout/"+t+"/payment-session",extractAmazonCheckoutSessionId:v};return(0,o.__assign)((0,o.__assign)({},E),{createCheckoutSession:L,sandbox:!!f})},e.prototype.isEnvironmentSpecific=function(e){return/^(SANDBOX|LIVE)/.test(e)},e.prototype.getAmazonPayV2SDK=function(){return this.getOrThrow(this.amazonPayV2SDK)},e.prototype.getButtonParentContainer=function(){return this.getOrThrow(this.buttonParentContainer)},e.prototype.getAmazonPayV2Button=function(){return this.getOrThrow(this.amazonPayV2Button)},e.prototype.getOrThrow=function(e){return Za(e,(function(){return new Ja(Qa.PaymentNotInitialized)}))},e.prototype.getCheckoutState=function(e){return"object"==typeof(t=e)&&null!==t&&"cart"in t&&"checkout"in t&&"config"in t&&"paymentMethods"in t?{getCart:e.cart.getCart,getCheckout:e.checkout.getCheckout,getStoreConfigOrThrow:e.config.getStoreConfigOrThrow,getPaymentMethodOrThrow:function(t){return e.paymentMethods.getPaymentMethodOrThrow(t)}}:e;var t},e}();const as=os;var ss=function(){function e(e,t){void 0===t&&(t=window),this.scriptLoader=e,this.windowWithAmazonPay=t}return e.prototype.load=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return t=e.initializationData,n=(null==t?void 0:t.region)||"us",r=is[n],[4,this.scriptLoader.loadScript("https://static-"+r+".payments-amazon.com/checkout.js")];case 1:if(i.sent(),!this.windowWithAmazonPay.amazon)throw new Ko;return[2,this.windowWithAmazonPay.amazon]}}))}))},e}();const us=ss;function cs(e,t){return Object.assign(e,{resolveIds:t})}const ds=function(e){function t(t){var n=e.call(this,t||"An unexpected error has occurred during buy now cart creation process. Please try again later.")||this;return n.name="BuyNowCartCreationError",n.type="buy_now_cart_creation_error",n}return(0,o.__extends)(t,e),t}(s),ls=function(e){function t(t){var n=e.call(this,t||"An unexpected error has occurred during config creation process. Please try again later.")||this;return n.name="AmazonPayV2ConfigCreationError",n.type="amazon_pay_v2_config_creation_error",n}return(0,o.__extends)(t,e),t}(s);function ps(e){return e instanceof Object&&"buyNowInitializeOptions"in e}var hs=function(){function e(e,t,n){this.paymentIntegrationService=e,this.amazonPayV2PaymentProcessor=t,this.amazonPayV2ConfigRequestSender=n}return e.prototype.initialize=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(n=e.methodId,r=e.containerId,i=e.amazonpay,a=(i||{}).buttonColor,!n||!r)throw new ja('Unable to proceed because "methodId" or "containerId" argument is not provided.');return s=this.paymentIntegrationService.getState().getPaymentMethodOrThrow,u=s(n),c=u.initializationData,[4,this.amazonPayV2PaymentProcessor.initialize(u)];case 1:return o.sent(),i?[3,3]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 2:o.sent(),o.label=3;case 3:return d=ps(i)?void 0:i,ps(i)&&"function"==typeof(null===(t=i.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody)&&(this._buyNowInitializeOptions=i.buyNowInitializeOptions,this.amazonPayV2PaymentProcessor.updateBuyNowFlowFlag(!0)),this.amazonPayV2PaymentProcessor.renderAmazonPayButton({checkoutState:this.paymentIntegrationService.getState(),containerId:r,methodId:n,options:d,placement:$a.Cart,buttonColor:a,isButtonMicroTextDisabled:null==c?void 0:c.isButtonMicroTextDisabled}),this._buyNowInitializeOptions&&this.amazonPayV2PaymentProcessor.prepareCheckoutWithCreationRequestConfig(this._getCheckoutCreationRequestConfig.bind(this)),[2]}}))}))},e.prototype.deinitialize=function(){return this.amazonPayV2PaymentProcessor.deinitialize()},e.prototype._createBuyNowCartOrThrow=function(){var e,t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:if(!(n=null===(t=null===(e=this._buyNowInitializeOptions)||void 0===e?void 0:e.getBuyNowCartRequestBody)||void 0===t?void 0:t.call(e)))throw new Wa(Ya.MissingCart);r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.paymentIntegrationService.createBuyNowCart(n)];case 2:return[2,r.sent()];case 3:throw r.sent(),new ds;case 4:return[2]}}))}))},e.prototype._createCheckoutConfig=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.amazonPayV2ConfigRequestSender.createCheckoutConfig(e)];case 1:return t=a.sent().body,n=t.payload,r=t.public_key,i=(0,o.__rest)(t,["payload","public_key"]),[2,(0,o.__assign)({payloadJSON:n,publicKeyId:r},i)];case 2:throw a.sent(),new ls;case 3:return[2]}}))}))},e.prototype._getCheckoutCreationRequestConfig=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._createBuyNowCartOrThrow()];case 1:return e=n.sent(),t={amount:String(e.baseAmount),currencyCode:e.currency.code},[4,this._createCheckoutConfig(e.id)];case 2:return[2,{createCheckoutSessionConfig:n.sent(),estimatedOrderAmount:t,productType:0===Ka(e)?ts.PayOnly:ts.PayAndShip}]}}))}))},e}();const fs=hs;var gs,ms="This API endpoint is for internal use only and may change in the future";!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(gs||(gs={}));const _s=gs;var ys={"X-Checkout-SDK-Version":"1.661.5"};const vs=function(){function e(e){this._requestSender=e}return e.prototype.createCheckoutConfig=function(e){var t={cartId:e},n=(0,o.__assign)({"X-API-INTERNAL":ms,"Content-Type":_s.Json},ys);return this._requestSender.post("/api/storefront/payment/amazonpay",{headers:n,body:t})},e}(),Cs=cs((function(e){var t=(0,r.createRequestSender)(),n=new vs(t),i=new as(new us((0,ir.getScriptLoader)()));return new fs(e,i,n)}),[{id:"amazonpay"}]);const Ss=function(e){function t(t){var n=e.call(this,t||"Unsupported browser error")||this;return n.name="UnsupportedBrowserError",n.type="unsupported_browser",n}return(0,o.__extends)(t,e),t}(s);var Is,ws,Es,bs,Ps;!function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(Is||(Is={})),function(e){e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="cancelled",e.UNRECOGNIZED="unrecognized"}(ws||(ws={})),function(e){e.Customer="CUSTOMER",e.Merchant="MERCHANT",e.Network="NETWORK",e.Internal="INTERNAL",e.Unknown="UNKNOWN"}(Es||(Es={})),function(e){e.KountNotEnabled="DATA_COLLECTOR_KOUNT_NOT_ENABLED"}(bs||(bs={})),function(e){e.TRUSTLY="trustly"}(Ps||(Ps={}));var As=function(){function e(e){this.braintreeScriptLoader=e}return e.prototype.initialize=function(e){this.setClientToken(e)},e.prototype.deinitialize=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this.teardownModule(this.dataCollector)];case 1:return e.sent(),this.dataCollector=void 0,[2]}}))}))},e.prototype.getClient=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return this.client?[3,3]:(e=this.getClientTokenOrThrow(),[4,this.braintreeScriptLoader.loadClient()]);case 1:return t=r.sent(),n=this,[4,t.create({authorization:e})];case 2:n.client=r.sent(),r.label=3;case 3:return[2,this.client]}}))}))},e.prototype.getDataCollectorOrThrow=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s;return(0,o.__generator)(this,(function(u){switch(u.label){case 0:if(t={deviceData:void 0,teardown:function(){return Promise.resolve()}},this.dataCollector)return[3,6];u.label=1;case 1:return u.trys.push([1,5,,6]),[4,this.getClient()];case 2:return n=u.sent(),[4,this.braintreeScriptLoader.loadDataCollector()];case 3:return r=u.sent(),i=(0,o.__assign)({client:n,kount:!0},e),a=this,[4,r.create(i)];case 4:return a.dataCollector=u.sent(),[3,6];case 5:if(c=s=u.sent(),Boolean("object"==typeof c&&null!==c&&("type"in c||"message"in c||"code"in c))&&s.code===bs.KountNotEnabled)return[2,t];throw s;case 6:return[2,this.dataCollector]}var c}))}))},e.prototype.getBraintreeGooglePayment=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return this.googlePayment?[3,3]:[4,Promise.all([this.getClient(),this.braintreeScriptLoader.loadGooglePayment()])];case 1:return e=i.sent(),t=e[0],n=e[1],r=this,[4,n.create({client:t})];case 2:r.googlePayment=i.sent(),i.label=3;case 3:return[2,this.googlePayment]}}))}))},e.prototype.getBraintreeThreeDS=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return this.threeDS?[3,3]:[4,Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()])];case 1:return e=i.sent(),t=e[0],n=e[1],r=this,[4,n.create({client:t,version:2})];case 2:r.threeDS=i.sent(),i.label=3;case 3:return[2,this.threeDS]}}))}))},e.prototype.getUsBankAccount=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return this.usBankAccount?[3,4]:[4,this.getClient()];case 1:return e=r.sent(),[4,this.braintreeScriptLoader.loadUsBankAccount()];case 2:return t=r.sent(),n=this,[4,t.create({client:e})];case 3:n.usBankAccount=r.sent(),r.label=4;case 4:return[2,this.usBankAccount]}}))}))},e.prototype.getBraintreeVisaCheckout=function(){return this.visaCheckout||(this.visaCheckout=Promise.all([this.getClient(),this.braintreeScriptLoader.loadVisaCheckout()]).then((function(e){var t=e[0];return e[1].create({client:t})}))),this.visaCheckout},e.prototype.getVisaCheckoutSdk=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return this.visaCheckoutSDK?[3,2]:(t=this,[4,this.braintreeScriptLoader.loadVisaCheckoutSdk(e)]);case 1:t.visaCheckoutSDK=n.sent(),n.label=2;case 2:return[2,this.visaCheckoutSDK]}}))}))},e.prototype.getVenmoCheckoutOrThrow=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return this.braintreeVenmo?[3,4]:[4,this.getClient()];case 1:return e=i.sent(),[4,this.braintreeScriptLoader.loadVenmoCheckout()];case 2:return t=i.sent(),n={client:e,allowDesktop:!0,paymentMethodUsage:"multi_use"},[4,t.create(n)];case 3:if(!(r=i.sent()).isBrowserSupported())throw new Ss;this.braintreeVenmo=r,i.label=4;case 4:return[2,this.braintreeVenmo]}}))}))},e.prototype.setClientToken=function(e){this.clientToken=e},e.prototype.getClientTokenOrThrow=function(){if(!this.clientToken)throw new Ja(Qa.PaymentNotInitialized);return this.clientToken},e.prototype.teardownModule=function(e){return e?e.teardown():Promise.resolve()},e}();const Os=As,Ts=function(e){function t(t){var n=e.call(this,t||"Payment process was cancelled.")||this;return n.name="PaymentMethodCancelledError",n.type="payment_cancelled",n}return(0,o.__extends)(t,e),t}(s);var Rs;function ks(e){if(!function(e){return"ApplePaySession"in e}(e))throw new Error("Apple pay is not supported")}!function(e){e.BRAINTREE="braintree"}(Rs||(Rs={}));const Ds=function(){function e(){}return e.prototype.create=function(e){return ks(window),new ApplePaySession(1,e)},e}();var Ms;!function(e){e.Subtotal="Subtotal",e.Shipping="Shipping"}(Ms||(Ms={}));var Ns=function(){function e(e,t,n,r){this._requestSender=e,this._paymentIntegrationService=t,this._sessionFactory=n,this._braintreeSdk=r,this._onAuthorizeCallback=_.noop,this._subTotalLabel=Ms.Subtotal,this._shippingLabel=Ms.Shipping}return e.prototype.initialize=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(n=e.methodId,r=e.containerId,i=e.applepay,ks(window),!n||!i)throw new Wa(Ya.MissingPaymentMethod);return a=i.buttonClassName,s=i.onPaymentAuthorize,u=i.buyNowInitializeOptions,c=i.requiresShipping,this._requiresShipping=c,this._buyNowInitializeOptions=u,this._onAuthorizeCallback=s,u?[3,2]:[4,this._paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return[4,this._paymentIntegrationService.loadPaymentMethod(n)];case 3:return o.sent(),d=this._paymentIntegrationService.getState(),this._paymentMethod=d.getPaymentMethodOrThrow(n),d.getCart()?[4,this._paymentIntegrationService.verifyCheckoutSpamProtection()]:[3,5];case 4:o.sent(),o.label=5;case 5:return(null===(t=this._paymentMethod.initializationData)||void 0===t?void 0:t.gateway)!==Rs.BRAINTREE?[3,7]:[4,this._initializeBraintreeSdk()];case 6:o.sent(),o.label=7;case 7:return this._applePayButton=this._createButton(r,a),this._applePayButton.addEventListener("click",this._handleWalletButtonClick.bind(this)),[2,Promise.resolve()]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype._createButton=function(e,t){void 0===t&&(t="apple-pay-checkout-button");var n=document.getElementById(e);if(!n)throw new ja("Unable to create wallet button without valid container ID.");document.body.classList.add("apple-pay-supported");var r=document.createElement("div");return r.setAttribute("class",t),r.setAttribute("role","button"),r.setAttribute("aria-label","Apple Pay button"),n.appendChild(r),r},e.prototype._handleWalletButtonClick=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s,u,c,d,l,p,h,f;return(0,o.__generator)(this,(function(o){if(e.preventDefault(),!this._paymentMethod||!this._paymentMethod.initializationData)throw new Wa(Ya.MissingPaymentMethod);return this._buyNowInitializeOptions&&"function"==typeof this._buyNowInitializeOptions.getBuyNowCartRequestBody?(n=this._paymentMethod.initializationData,r=n.countryCode,i=n.currencyCode,a=n.merchantCapabilities,s=n.supportedNetworks,u=n.storeName,h=this._getRequestWithEmptyTotal(r,i,s,a),this._requiresShipping&&(null===(t=h.requiredShippingContactFields)||void 0===t||t.push("postalAddress")),f=this._sessionFactory.create(h),this._handleApplePayEvents(f,this._paymentMethod,u),f.begin()):(c=this._paymentIntegrationService.getState(),d=c.getCartOrThrow(),l=c.getStoreConfigOrThrow(),p=c.getCheckoutOrThrow(),h=this._getBaseRequest(d,p,l,this._paymentMethod),f=this._sessionFactory.create(h),this._handleApplePayEvents(f,this._paymentMethod,l.storeProfile.storeName),f.begin()),[2]}))}))},e.prototype._getRequestWithEmptyTotal=function(e,t,n,r){return{countryCode:e,currencyCode:t,supportedNetworks:n,merchantCapabilities:r,total:{label:"",amount:"0",type:"pending"},requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:["email","phone"]}},e.prototype._getBaseRequest=function(e,t,n,r){var i,o=n.storeProfile,a=o.storeCountryCode,s=o.storeName,u=e.currency,c=u.code,d=u.decimalPlaces,l=r.initializationData,p=l.merchantCapabilities,h=l.supportedNetworks,f=e.lineItems.physicalItems.length>0,g={requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:["email","phone"],countryCode:a,currencyCode:c,merchantCapabilities:p,supportedNetworks:h,lineItems:[],total:f?{label:s,amount:""+t.grandTotal.toFixed(d),type:"pending"}:{label:s,amount:""+t.grandTotal.toFixed(d),type:"final"}};if(f)null===(i=g.requiredShippingContactFields)||void 0===i||i.push("postalAddress");else{var m=[{label:this._subTotalLabel,amount:""+t.subtotal.toFixed(d)}];t.taxes.forEach((function(e){return m.push({label:e.name,amount:""+e.amount.toFixed(d)})})),g.lineItems=m}return g},e.prototype._handleApplePayEvents=function(e,t,n){var r=this;e.onvalidatemerchant=function(n){return(0,o.__awaiter)(r,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this._onValidateMerchant(t,n)];case 1:return r=i.sent().body,e.completeMerchantValidation(r),[3,3];case 2:throw i.sent(),new Error("Merchant validation failed");case 3:return[2]}}))}))},this._buyNowInitializeOptions&&!this._requiresShipping&&(e.onpaymentmethodselected=function(){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._createBuyNowCart()];case 1:return t.sent(),this._handlePaymentMethodSelected(e),[2]}}))}))}),e.onshippingcontactselected=function(t){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return this._buyNowInitializeOptions&&this._requiresShipping?[4,this._createBuyNowCart()]:[3,2];case 1:r.sent(),r.label=2;case 2:return[4,this._handleShippingContactSelected(e,n,t)];case 3:return r.sent(),[2]}}))}))},e.onshippingmethodselected=function(t){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._handleShippingMethodSelected(e,n,t)];case 1:return r.sent(),[2]}}))}))},e.oncancel=function(){return(0,o.__awaiter)(r,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),e="/remote-checkout/"+t.id+"/signout",[4,this._requestSender.get(e)];case 1:return n.sent(),[4,this._paymentIntegrationService.loadCheckout()];case 2:return[2,n.sent()];case 3:throw n.sent(),new Ts;case 4:return[2]}}))}))},e.onpaymentauthorized=function(n){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){return[2,this._onPaymentAuthorized(n,e,t)]}))}))}},e.prototype._createBuyNowCart=function(){var e,t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:if(i.trys.push([0,3,,4]),!(n=null===(t=null===(e=this._buyNowInitializeOptions)||void 0===e?void 0:e.getBuyNowCartRequestBody)||void 0===t?void 0:t.call(e)))throw new Wa(Ya.MissingCart);return[4,this._paymentIntegrationService.createBuyNowCart(n)];case 1:return r=i.sent(),[4,this._paymentIntegrationService.loadCheckout(r.id)];case 2:return i.sent(),[3,4];case 3:throw i.sent(),new ds;case 4:return[2]}}))}))},e.prototype._handlePaymentMethodSelected=function(e){var t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow(),r=t.getStoreConfigOrThrow(),i=t.getCheckoutOrThrow();if(!this._paymentMethod||!this._paymentMethod.initializationData)throw new Wa(Ya.MissingPaymentMethod);var o=this._getBaseRequest(n,i,r,this._paymentMethod);delete o.total.type,e.completePaymentMethodSelection({newTotal:o.total,newLineItems:o.lineItems})},e.prototype._handleShippingContactSelected=function(e,t,n){var r;return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d,l,p,h,f,g,m;return(0,o.__generator)(this,(function(_){switch(_.label){case 0:i=this._transformContactToAddress(n.shippingContact),_.label=1;case 1:return _.trys.push([1,3,,4]),[4,this._paymentIntegrationService.updateShippingAddress(i)];case 2:return _.sent(),[3,4];case 3:throw _.sent(),e.abort(),new Error("Shipping address update failed");case 4:if(a=this._paymentIntegrationService.getState(),s=a.getCartOrThrow().currency.decimalPlaces,u=a.getCheckoutOrThrow(),c=null===(r=u.consignments[0].selectedShippingOption)||void 0===r?void 0:r.id,d=u.consignments[0].availableShippingOptions,l=null==d?void 0:d.find((function(e){return e.id===c})),p=null==d?void 0:d.filter((function(e){return e.id!==c})),h=l?[{label:l.description,amount:""+l.cost.toFixed(s),detail:l.additionalDescription,identifier:l.id}]:[],p&&(0,o.__spreadArrays)(p.filter((function(e){return e.isRecommended})),p.filter((function(e){return!e.isRecommended}))).forEach((function(e){return h.push({label:e.description,amount:""+e.cost.toFixed(s),detail:e.additionalDescription,identifier:e.id})})),!(d instanceof Array))throw new Error("Shipping options not available.");if(0===d.length)return e.completeShippingContactSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,[],{type:"pending",label:t,amount:""+u.grandTotal.toFixed(s)},[]),[2];f=d.find((function(e){return e.isRecommended})),g=f?f.id:d[0].id,m=l?l.id:g,_.label=5;case 5:return _.trys.push([5,7,,8]),[4,this._updateShippingOption(m)];case 6:return _.sent(),[3,8];case 7:throw _.sent(),new Error("Shipping options update failed");case 8:return a=this._paymentIntegrationService.getState(),u=a.getCheckoutOrThrow(),e.completeShippingContactSelection({newShippingMethods:h,newTotal:{type:"final",label:t,amount:""+u.grandTotal.toFixed(s)},newLineItems:this._getUpdatedLineItems(u,s)}),[2]}}))}))},e.prototype._handleShippingMethodSelected=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:r=n.shippingMethod.identifier,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this._updateShippingOption(r)];case 2:return o.sent(),[3,4];case 3:throw o.sent(),e.abort(),new Error("Shipping option selection update failed.");case 4:return i=this._paymentIntegrationService.getState(),a=i.getCartOrThrow().currency.decimalPlaces,s=i.getCheckoutOrThrow(),e.completeShippingMethodSelection({newTotal:{type:"final",label:t,amount:""+s.grandTotal.toFixed(a)},newLineItems:this._getUpdatedLineItems(s,a)}),[2]}}))}))},e.prototype._getUpdatedLineItems=function(e,t){var n=[{label:this._subTotalLabel,amount:""+e.subtotal.toFixed(t)}];return e.taxes.forEach((function(e){return n.push({label:e.name,amount:""+e.amount.toFixed(t)})})),n.push({label:this._shippingLabel,amount:""+e.shippingCostTotal.toFixed(t)}),n},e.prototype._updateShippingOption=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){return[2,this._paymentIntegrationService.selectShippingOption(e)]}))}))},e.prototype._onValidateMerchant=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){return n=["validationUrl="+t.validationURL,"merchantIdentifier="+e.initializationData.merchantId,"displayName="+e.initializationData.storeName,"domainName="+window.location.hostname].join("&"),[2,this._requestSender.post((i=e.initializationData.paymentsUrl,i+"/api/public/v1/payments/applepay/validate_merchant"),{credentials:!1,headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","X-XSRF-TOKEN":null},body:n})];var i}))}))},e.prototype._onPaymentAuthorized=function(e,t,n){var r;return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d,l,p,h,f,g,m,_;return(0,o.__generator)(this,(function(y){switch(y.label){case 0:return i=e.payment,a=i.token,s=i.billingContact,u=i.shippingContact,c=this._paymentIntegrationService.getState(),d=c.getCartOrThrow(),l=d.lineItems.physicalItems.length>0,(null===(r=n.initializationData)||void 0===r?void 0:r.gateway)!==Rs.BRAINTREE?[3,2]:[4,this._getBraintreeDeviceData()];case 1:p=y.sent(),y.label=2;case 2:h={methodId:n.id,paymentData:{deviceSessionId:p,formattedPayload:{apple_pay_token:{payment_data:a.paymentData,payment_method:a.paymentMethod,transaction_id:a.transactionIdentifier}}}},f=this._transformContactToAddress(s),g=this._transformContactToAddress(u),m=null==u?void 0:u.emailAddress,_=(null==u?void 0:u.phoneNumber)||"",y.label=3;case 3:return y.trys.push([3,9,,10]),[4,this._paymentIntegrationService.updateBillingAddress((0,o.__assign)((0,o.__assign)({},f),{email:m,phone:_}))];case 4:return y.sent(),l?[4,this._paymentIntegrationService.updateShippingAddress(g)]:[3,6];case 5:y.sent(),y.label=6;case 6:return[4,this._paymentIntegrationService.submitOrder({useStoreCredit:!1})];case 7:return y.sent(),[4,this._paymentIntegrationService.submitPayment(h)];case 8:return y.sent(),t.completePayment(ApplePaySession.STATUS_SUCCESS),[2,this._onAuthorizeCallback()];case 9:throw y.sent(),t.completePayment(ApplePaySession.STATUS_FAILURE),new Error("Payment cannot complete");case 10:return[2]}}))}))},e.prototype._transformContactToAddress=function(e){return{firstName:(null==e?void 0:e.givenName)||"",lastName:(null==e?void 0:e.familyName)||"",city:(null==e?void 0:e.locality)||"",company:"",address1:(null==e?void 0:e.addressLines)&&e.addressLines[0]||"",address2:(null==e?void 0:e.addressLines)&&e.addressLines[1]||"",postalCode:(null==e?void 0:e.postalCode)||"",countryCode:(null==e?void 0:e.countryCode)||"",phone:(null==e?void 0:e.phoneNumber)||"",stateOrProvince:(null==e?void 0:e.administrativeArea)||"",stateOrProvinceCode:(null==e?void 0:e.administrativeArea)||"",customFields:[]}},e.prototype._getBraintreeDeviceData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this._braintreeSdk.getDataCollectorOrThrow()];case 1:return[2,e.sent().deviceData];case 2:return e.sent(),[3,3];case 3:return[2]}}))}))},e.prototype._initializeBraintreeSdk=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._paymentIntegrationService.loadPaymentMethod(Rs.BRAINTREE)];case 1:return n.sent(),e=this._paymentIntegrationService.getState(),(t=e.getPaymentMethod(Rs.BRAINTREE))&&t.clientToken&&t.initializationData?(this._braintreeSdk.initialize(t.clientToken),[2]):[2]}}))}))},e}();const Ls=Ns,zs=cs((function(e){var t=e.getState().getHost;return new Ls((0,r.createRequestSender)({host:t()}),e,new Ds,new Os(new ta((0,ir.getScriptLoader)(),window)))}),[{id:"applepay"}]),Us=require("query-string"),Fs=function(e){function t(t){var n=e.call(this,t||"Not implemented.")||this;return n.name="NotImplementedError",n.type="not_implemented",n}return(0,o.__extends)(t,e),t}(s);var Bs,qs,xs;!function(e){e.SandboxMode="bolt_sandbox",e.StagingMode="bolt_staging",e.DevelopmentMode="bolt_development"}(Bs||(Bs={})),function(e){e.Small="small",e.Medium="medium",e.Large="large"}(qs||(qs={})),function(e){e.Pill="pill",e.Rect="rect"}(xs||(xs={}));var Gs=function(){function e(e,t,n){void 0===n&&(n=window),this.paymentIntegrationService=e,this.boltScriptLoader=t,this.boltHostWindow=n}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h,f;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.bolt,n=e.containerId,r=e.methodId,a=(i=t||{}).buyNowInitializeOptions,s=i.style,!r)throw new ja('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new ja('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new ja('Unable to initialize payment because "options.bolt" argument is not provided.');if(!Boolean(a))throw new Fs("Only buy now flow is implemented for Bolt button");if(!(null==a?void 0:a.storefrontApiToken)||"string"!=typeof a.storefrontApiToken)throw new ja('Unable to initialize payment because "options.storefrontApiToken" argument is not provided.');return u=this.paymentIntegrationService.getState(),c=u.getPaymentMethodOrThrow(r),d=c.initializationData,l=c.config,h=(p=d||{}).publishableKey,f=p.developerConfig,[4,this.boltScriptLoader.loadBoltClient(h,l.testMode,f,"BigCommerce",a.storefrontApiToken)];case 1:return o.sent(),this.renderButton(n,c,s),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r;"function"==typeof(null===(r=this.boltHostWindow.BoltConnect)||void 0===r?void 0:r.setupProductPageCheckout)&&(this.addButtonContainer(e,t,n),this.boltHostWindow.BoltConnect.setupProductPageCheckout())},e.prototype.addButtonContainer=function(e,t,n){var r=document.getElementById(e);if(r){var i=document.createElement("div"),o=document.createElement("object");i.setAttribute("id","product-page-checkout-wrapper"),i.setAttribute("class","bolt-button-wrapper"),i.setAttribute("style","display:none"),i.setAttribute("data-tid","product-page-checkout-wrapper"),o.setAttribute("data",this.getBoltObjectData(t,n)),o.setAttribute("class","bolt-product-checkout-button"),i.append(o),r.innerHTML="",r.append(i)}},e.prototype.getBoltObjectData=function(e,t){var n=e.initializationData,r=e.config,i=n||{},o=i.publishableKey,a=i.developerConfig,s=this.boltScriptLoader.getDomainURL(!!r.testMode,a),u=this.getButtonHeight(null==t?void 0:t.size),c=this.getButtonBorderRadius(null==t?void 0:t.shape,u);return(0,Us.stringifyUrl)({url:"https://"+s+"/v1/checkout_button",query:{publishable_key:o,variant:"ppc",height:u,border_radius:c}})},e.prototype.getButtonHeight=function(e){if(e)switch(e){case qs.Small:return 25;case qs.Large:return 45;case qs.Medium:default:return 40}},e.prototype.getButtonBorderRadius=function(e,t){if(e)switch(e){case xs.Pill:return t?Math.round(t/2):void 0;case xs.Rect:default:return 4}},e}();const Vs=Gs;var Hs=function(){function e(e,t){void 0===t&&(t=window),this.scriptLoader=e,this.boltHostWindow=t}return e.prototype.loadBoltClient=function(e,t,n,r,i){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(this.boltHostWindow.BoltCheckout)return[2,this.boltHostWindow.BoltCheckout];if(!e)throw new ja('Unable to initialize payment because "publishableKey" argument is not provided.');return[4,this.scriptLoader.loadScript("//"+this.getDomainURL(!!t,n)+"/connect-bigcommerce.js",this.getScriptOptions("bolt-connect",e,r,i))];case 1:return o.sent(),[4,this.scriptLoader.loadScript("//"+this.getDomainURL(!!t,n)+"/track.js",this.getScriptOptions("bolt-track",e))];case 2:if(o.sent(),!this.boltHostWindow.BoltCheckout)throw new Ko;return[2,this.boltHostWindow.BoltCheckout]}}))}))},e.prototype.loadBoltEmbedded=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return r={async:!0,attributes:{id:"bolt-embedded"}},[4,this.scriptLoader.loadScript("//"+this.getDomainURL(!!t,n)+"/embed.js",r)];case 1:if(i.sent(),!this.boltHostWindow.Bolt)throw new Ko;return[2,this.boltHostWindow.Bolt(e)]}}))}))},e.prototype.getDomainURL=function(e,t){if(!e)return"connect.bolt.com";if(t)switch(t.developerMode){case Bs.StagingMode:return"connect-staging.bolt.com";case Bs.DevelopmentMode:return"connect."+t.developerDomain}return"connect-sandbox.bolt.com"},e.prototype.getScriptOptions=function(e,t,n,r){return{async:!0,attributes:(0,o.__assign)((0,o.__assign)({id:e,"data-publishable-key":t},n&&{"data-shopping-cart-id":n}),r&&{"data-storefront-api-token":r})}},e}();const js=Hs,Ys=cs((function(e){return new Vs(e,new js((0,ir.getScriptLoader)()))}),[{id:"bolt"}]);var Ws=function(){function e(e,t,n){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeSdk=n}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h,f,g=this;return(0,o.__generator)(this,(function(m){switch(m.label){case 0:if(t=e.containerId,!(n=e.methodId))throw new ja('Unable to initialize payment because "options.methodId" argument is not provided.');if(!t)throw new ja('Unable to initialize payment because "options.containerId" argument is not provided.');return[4,this.paymentIntegrationService.loadPaymentMethod(n)];case 1:if(m.sent(),r=this.paymentIntegrationService.getState(),i=r.getPaymentMethodOrThrow(n),a=i.clientToken,s=i.initializationData,u=i.config,!a||!s)throw new Wa(Ya.MissingPaymentMethod);return this.braintreeSdk.initialize(a),[4,this.braintreeSdk.getBraintreeVisaCheckout()];case 2:return c=m.sent(),d=r.getCartOrThrow(),l=d.currency.code,p=d.cartAmount,[4,this.braintreeSdk.getVisaCheckoutSdk(u.testMode)];case 3:return h=m.sent(),f=c.createInitOptions({paymentRequest:{currencyCode:l,subtotal:String(p)},settings:{shipping:{collectShipping:!0}}}),this.createSignInButton(t),[4,h.init(f)];case 4:return m.sent(),h.on("payment.success",(function(e){return(0,o.__awaiter)(g,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this.paymentSuccess(c,e)];case 1:return t.sent(),[2]}}))}))})),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.paymentSuccess=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n=this;return(0,o.__generator)(this,(function(r){return[2,Promise.all([e.tokenize(t),this.braintreeSdk.getDataCollectorOrThrow()]).then((function(e){var t=e[0],r=e[1],i=n.paymentIntegrationService.getState(),a=i.getShippingAddress(),s=i.getBillingAddress(),u=t.shippingAddress,c=void 0===u?n.toVisaCheckoutAddress(a):u,d=t.billingAddress,l=void 0===d?n.toVisaCheckoutAddress(s):d;return n.postForm((0,o.__assign)((0,o.__assign)({},t),{shippingAddress:c,billingAddress:l}),r)}))]}))}))},e.prototype.postForm=function(e,t){var n=e.userData,r=e.billingAddress,i=e.shippingAddress,o=e.details,a=n.userEmail,s=t.deviceData;return this.formPoster.postForm("/checkout.php",{payment_type:e.type,nonce:e.nonce,provider:"braintreevisacheckout",action:"set_external_checkout",device_data:s,card_information:JSON.stringify({type:o.cardType,number:o.lastTwo}),billing_address:JSON.stringify(this.getAddress(a,r)),shipping_address:JSON.stringify(this.getAddress(a,i))})},e.prototype.toVisaCheckoutAddress=function(e){return e?{firstName:e.firstName,lastName:e.lastName,phoneNumber:e.phone,streetAddress:e.address1,extendedAddress:e.address2,locality:e.city,region:e.stateOrProvinceCode,countryCode:e.countryCode,postalCode:e.postalCode}:{}},e.prototype.getAddress=function(e,t){return void 0===t&&(t={}),{email:e,first_name:t.firstName,last_name:t.lastName,phone_number:t.phoneNumber,address_line_1:t.streetAddress,address_line_2:t.extendedAddress,city:t.locality,state:t.region,country_code:t.countryCode,postal_code:t.postalCode}},e.prototype.createSignInButton=function(e){var t=document.querySelector("#"+e);if(!t)throw new Error("Need a container to place the button");return this.insertVisaCheckoutButton(t)},e.prototype.insertVisaCheckoutButton=function(e){var t=document.createElement("div");return t.style.display="flex",t.style.flexDirection="column",t.style.alignItems="flex-end",t.innerHTML='\n <img\n alt="Visa Checkout"\n class="v-button"\n role="button"\n src="https://secure.checkout.visa.com/wallet-services-web/xo/button.png?acceptCanadianVisaDebit=false&cobrand=true&height=34&width=178"\n />\n <a class="v-learn v-learn-default" style="text-align: right; display: block; font-size: 10px; color: #003366;" href="#" data-locale="en_US">Tell Me More</a>',e.appendChild(t),t},e}();const Ks=Ws,Zs=cs((function(e){var t=window,n=new Os(new ta((0,ir.getScriptLoader)(),t));return new Ks(e,(0,i.createFormPoster)(),n)}),[{id:"braintreevisacheckout"}]);function Qs(e){var t=e.billingAddress,n=e.email,r=e.firstName,i=e.lastName,o=e.phone,a=e.shippingAddress,s=t||a;return{email:n,first_name:r,last_name:i,phone_number:o,address_line_1:null==s?void 0:s.line1,address_line_2:null==s?void 0:s.line2,city:null==s?void 0:s.city,state:null==s?void 0:s.state,country_code:null==s?void 0:s.countryCode,postal_code:null==s?void 0:s.postalCode}}function Js(e){var t=e.email,n=e.phone,r=e.shippingAddress,i=((null==r?void 0:r.recipientName)||"").split(" ");return{email:t,first_name:i[0]||"",last_name:i[1]||"",phone_number:n,address_line_1:null==r?void 0:r.line1,address_line_2:null==r?void 0:r.line2,city:null==r?void 0:r.city,state:null==r?void 0:r.state,country_code:null==r?void 0:r.countryCode,postal_code:null==r?void 0:r.postalCode}}var Xs=function(e){var t,n=e.color,r=e.height;return{backgroundColor:(t=n||"",t===aa.WHITE?"#FFFFFF":"#3D95CE"),backgroundPosition:"50% 50%",backgroundSize:"80px auto",backgroundImage:'url("/app/assets/img/payment-providers/venmo-logo-'+(n===aa.WHITE?aa.BLUE:aa.WHITE)+'.svg")',backgroundRepeat:"no-repeat",borderRadius:"4px",cursor:"pointer",transition:"0.2s ease",minHeight:(r||36)+"px",minWidth:"150px",height:"100%",width:"100%",border:n===aa.WHITE?"1px solid black":"none"}},$s=function(){function e(e,t,n){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeSdk=n,this.onError=_.noop}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.braintreevenmo,n=e.containerId,!(r=e.methodId))throw new ja('Unable to initialize payment because "options.methodId" argument is not provided.');if(i=this.paymentIntegrationService.getState(),a=i.getPaymentMethodOrThrow(r),s=a.clientToken,u=a.initializationData,c=u.paymentButtonStyles,d=(c||{}).cartButtonStyles,l=(null==t?void 0:t.style)||d,!s||!u)throw new Wa(Ya.MissingPaymentMethod);if(!n)throw new ja('Unable to initialize payment because "options.containerId" argument is not provided.');this.onError=(null==t?void 0:t.onError)||this.handleError,this.braintreeSdk.initialize(s),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.braintreeSdk.getVenmoCheckoutOrThrow()];case 2:return p=o.sent(),this.renderVenmoButton(p,n,null==t?void 0:t.buyNowInitializeOptions,l),[3,4];case 3:return h=o.sent(),this.handleInitializationVenmoError(h,n),[3,4];case 4:return[2]}}))}))},e.prototype.deinitialize=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this.braintreeSdk.deinitialize()];case 1:return e.sent(),[2,Promise.resolve()]}}))}))},e.prototype.handleError=function(e){throw new Error(e.message)},e.prototype.createBuyNowCart=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("function"!=typeof(null==e?void 0:e.getBuyNowCartRequestBody))return[3,4];if(!(t=null==e?void 0:e.getBuyNowCartRequestBody()))throw new Wa(Ya.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.paymentIntegrationService.createBuyNowCart(t)];case 2:return[2,n.sent()];case 3:throw n.sent(),new ds;case 4:return[2,void 0]}}))}))},e.prototype.handleInitializationVenmoError=function(e,t){return this.removeVenmoContainer(t),this.onError(e)},e.prototype.removeVenmoContainer=function(e){var t=document.getElementById(e);t&&t.remove()},e.prototype.renderVenmoButton=function(e,t,n,r){var i=this,a=document.getElementById(t),s=(r||{}).color;if(!a)throw new ja("Unable to create wallet button without valid container ID.");a.setAttribute("aria-label","Venmo"),Object.assign(a.style,Xs(r||{})),a.addEventListener("click",(function(){return(0,o.__awaiter)(i,void 0,void 0,(function(){var t,r=this;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return a.setAttribute("disabled","true"),[4,this.createBuyNowCart(n)];case 1:return t=i.sent(),e.tokenize&&e.tokenize((function(e,n){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return a.removeAttribute("disabled"),e&&this.onError(e),[4,this.handlePostForm(n,null==t?void 0:t.id)];case 1:return r.sent(),[2]}}))}))})),[2]}}))}))})),s===aa.BLUE&&(a.addEventListener("mouseenter",(function(){a.style.backgroundColor="#0a7fc2"})),a.addEventListener("mouseleave",(function(){a.style.backgroundColor=Xs(r||{}).backgroundColor})))},e.prototype.handlePostForm=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return[4,this.braintreeSdk.getDataCollectorOrThrow()];case 1:return n=a.sent().deviceData,r=e.nonce,i=e.details,this.formPoster.postForm("/checkout.php",(0,o.__assign)({nonce:r,provider:"braintreevenmo",payment_type:"paypal",device_data:n,action:"set_external_checkout",billing_address:JSON.stringify(Qs(i)),shipping_address:JSON.stringify(Js(i))},t&&{cart_id:t})),[2]}}))}))},e}();const eu=$s,tu=cs((function(e){var t=window,n=(0,ir.getScriptLoader)(),r=new ta(n,t),o=new Os(r);return new eu(e,(0,i.createFormPoster)(),o)}),[{id:"braintreevenmo"}]);var nu=function(){function e(e){if(!e)throw new Error("Currency settings missing");var t=e.decimalPlaces,n=e.symbolLocation,r=e.symbol,i=e.thousandsSeparator,o=e.decimalSeparator;if("string"!=typeof n||"string"!=typeof r||"string"!=typeof i||"string"!=typeof o||"string"!=typeof t)throw new ja("Invalid currency settings provided");this._decimalPlaces=parseInt(t,10),this._symbolLocation=n,this._symbol=r,this._thousandsSeparator=i,this._decimalSeparator=o}return e.prototype.format=function(e){if("number"!=typeof e)throw new ja("Invalid amount provided");var t=this._formatNumber(e),n=this._formatCurrency(t);return e<0?"-"+n:n},e.prototype._formatNumber=function(e){var t=Math.abs(e),n=this._toFixed(t,this._decimalPlaces).split("."),r=n[0],i=n[1],o=void 0===i?"":i,a=r.replace(/\B(?=(\d{3})+(?!\d))/g,this._thousandsSeparator);return this._decimalPlaces<1?a:[a,o].join(this._decimalSeparator)},e.prototype._formatCurrency=function(e){return"left"===this._symbolLocation.toLowerCase()?""+this._symbol+e:""+e+this._symbol},e.prototype._toFixed=function(e,t){return(+(Math.round(+(e+"e"+t))+"e"+-t)).toFixed(t)},e}();const ru=nu,iu=function(){function e(e){this._storeConfig=e,this._customerFormatter=new ru(this._storeConfig.shopperCurrency),this._storeFormatter=new ru(this._storeConfig.currency)}return e.prototype.toCustomerCurrency=function(e){var t=this._storeConfig.shopperCurrency.exchangeRate;return this._customerFormatter.format(e*t)},e.prototype.toStoreCurrency=function(e){return this._storeFormatter.format(e)},(0,o.__decorate)([Yr],e)}();var ou,au,su,uu,cu,du,lu,pu;function hu(e){return e in du}!function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(ou||(ou={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(au||(au={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(su||(su={})),function(e){e.pill="pill",e.rect="rect"}(uu||(uu={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(cu||(cu={})),function(e){e.AMEX="AMEX",e.DISCOVER="DISCOVER",e.INTERAC="INTERAC",e.JCB="JCB",e.MC="MASTERCARD",e.VISA="VISA"}(du||(du={})),function(e){e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION"}(lu||(lu={})),function(e){e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER"}(pu||(pu={}));var fu=function(){function e(e,t){this._gatewayIdentifier=e,this._paymentIntegrationService=t,this._isBuyNowFlow=!1}return e.prototype.mapToShippingAddressRequestBody=function(e){var t=e.shippingAddress;if(t){var n=this._paymentIntegrationService.getState().getShippingAddress()||{},r=n.company,i=void 0===r?"":r,o=n.phone,a=void 0===o?"":o;return this._mapToAddressRequestBody(t,i,a)}},e.prototype.mapToBillingAddressRequestBody=function(e){var t=e.paymentMethodData.info.billingAddress;if(t){var n=this._paymentIntegrationService.getState().getBillingAddress()||{},r=n.company,i=void 0===r?"":r,a=n.phone,s=void 0===a?"":a,u=n.email;return(0,o.__assign)((0,o.__assign)({},this._mapToAddressRequestBody(t,i,s)),{email:u||e.email})}},e.prototype.mapToExternalCheckoutData=function(e){var t,n=e.paymentMethodData,r=n.tokenizationData.token,i=n.info,a=i.cardNetwork,s=i.cardDetails;return Promise.resolve((0,o.__assign)({nonce:r,card_information:{type:a,number:s}},this._isBuyNowFlow&&{cart_id:null===(t=this._paymentIntegrationService.getState().getCart())||void 0===t?void 0:t.id}))},e.prototype.getRequiredData=function(){var e;return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return t={emailRequired:!0},this._isShippingAddressRequired()?[4,this._paymentIntegrationService.loadShippingCountries()]:[2,t];case 1:return n=i.sent(),r=null===(e=n.getShippingCountries())||void 0===e?void 0:e.map((function(e){return e.code})),[2,(0,o.__assign)((0,o.__assign)({},t),{shippingAddressRequired:!0,shippingAddressParameters:(0,o.__assign)({phoneNumberRequired:!0},r&&{allowedCountryCodes:r}),shippingOptionRequired:this._isGooglePayShippingOptionsAvailable()})]}}))}))},e.prototype.getCallbackIntents=function(){return this._isGooglePayShippingOptionsAvailable()&&this._isShippingAddressRequired()?[lu.OFFER,lu.SHIPPING_ADDRESS,lu.SHIPPING_OPTION]:[lu.OFFER]},e.prototype.getCallbackTriggers=function(){var e=this._isGooglePayShippingOptionsAvailable();return{availableTriggers:e?[pu.INITIALIZE,pu.SHIPPING_ADDRESS,pu.SHIPPING_OPTION]:[pu.INITIALIZE],initializationTrigger:[pu.INITIALIZE],addressChangeTriggers:e?[pu.INITIALIZE,pu.SHIPPING_ADDRESS]:[],shippingOptionsChangeTriggers:e?[pu.SHIPPING_OPTION]:[]}},e.prototype.getNonce=function(e){var t,n=null===(t=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(e).initializationData)||void 0===t?void 0:t.nonce;if(!n)throw new Wa(Ya.MissingPaymentToken);return Promise.resolve(n)},e.prototype.extraPaymentData=function(){return Promise.resolve(void 0)},e.prototype.getMerchantInfo=function(){var e=this.getGooglePayInitializationData();return{merchantName:e.googleMerchantName,merchantId:e.googleMerchantId,authJwt:e.platformToken}},e.prototype.getTransactionInfo=function(){var e;e=this._isBuyNowFlow?this._getCurrencyCodeOrThrow():(0,this._paymentIntegrationService.getState().getCartOrThrow)().currency.code;var t=this.getGooglePayInitializationData().storeCountry;return(0,o.__assign)((0,o.__assign)({},t&&{countryCode:t}),{currencyCode:e,totalPriceStatus:cu.ESTIMATED,totalPrice:"0"})},e.prototype.getPaymentGatewayParameters=function(){var e=this.getGooglePayInitializationData().gatewayMerchantId;if(!e)throw new ja("Unable to proceed, gatewayMerchantId is missing.");return{gateway:this._gatewayIdentifier,gatewayMerchantId:e}},e.prototype.getCardParameters=function(){return{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:this.getPaymentMethod().supportedCards.filter(hu).map((function(e){return du[e]})),billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}},e.prototype.initialize=function(e,t,n){return this._getPaymentMethodFn=e,this._isBuyNowFlow=Boolean(t),this._currencyCode=n,this._isBuyNowFlow&&this._getCurrencyCodeOrThrow(),Promise.resolve()},e.prototype.handleShippingAddressChange=function(e){var t,n,r;return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d,l;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return e&&(e.name=e.name||"",e.address1=e.address1||""),(i=this.mapToShippingAddressRequestBody({shippingAddress:e}))?[4,this._paymentIntegrationService.updateShippingAddress(i)]:[3,2];case 1:o.sent(),o.label=2;case 2:return a=this._paymentIntegrationService.getState(),(null==(s=a.getConsignments())?void 0:s[0])?(u=s[0],c=a.getStoreConfigOrThrow(),this._currencyService||(this._currencyService=new iu(c)),(d=(u.availableShippingOptions||[]).map(this._getGooglePayShippingOption.bind(this))).length?(l=(null===(t=u.selectedShippingOption)||void 0===t?void 0:t.id)||(null===(n=d[0])||void 0===n?void 0:n.id),(null===(r=u.selectedShippingOption)||void 0===r?void 0:r.id)||!d[0]?[3,4]:[4,this.handleShippingOptionChange(d[0].id)]):[3,5]):[2];case 3:o.sent(),o.label=4;case 4:return[2,{defaultSelectedOptionId:l,shippingOptions:d}];case 5:return[2]}}))}))},e.prototype.handleShippingOptionChange=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){return"shipping_option_unselected"===e?[2]:[2,this._paymentIntegrationService.selectShippingOption(e)]}))}))},e.prototype.getTotalPrice=function(){var e=this._paymentIntegrationService.getState(),t=e.getCheckoutOrThrow,n=(0,e.getCartOrThrow)().currency.decimalPlaces;return(0,_.round)(t().outstandingBalance,n).toFixed(n)},e.prototype.getGooglePayInitializationData=function(){return Za(this.getPaymentMethod().initializationData,(function(){return new ja("Missing initialization data.")}))},e.prototype.getPaymentMethod=function(){return Za(this._getPaymentMethodFn,(function(){return new Ja(Qa.PaymentNotInitialized)}))()},e.prototype.getGatewayIdentifier=function(){return this._gatewayIdentifier},e.prototype.setGatewayIdentifier=function(e){this._gatewayIdentifier=e||this.getGatewayIdentifier()},e.prototype._isGooglePayShippingOptionsAvailable=function(){return!!this.getGooglePayInitializationData().isShippingOptionsEnabled},e.prototype._isShippingAddressRequired=function(){var e,t,n=this._paymentIntegrationService.getState(),r=n.getCartOrThrow,i=n.getStoreConfig;return void 0===(0,n.getShippingAddress)()&&(e=r(),t=i(),!!e&&(!!e.lineItems.physicalItems.some((function(e){return e.isShippingRequired}))||!(!t||!e.lineItems.customItems)&&e.lineItems.customItems.length>0))},e.prototype._mapToAddressRequestBody=function(e,t,n){var r=e.name,i=e.address1,o=e.address2,a=e.address3,s=e.locality,u=e.administrativeArea,c=e.countryCode,d=e.postalCode,l=e.phoneNumber,p=this._getFirstAndLastName(r);return{firstName:p[0],lastName:p[1],company:t,address1:i,address2:(o+" "+a).trim(),city:s,stateOrProvince:u,stateOrProvinceCode:u,countryCode:c,postalCode:d,phone:l||n,customFields:[]}},e.prototype._getFirstAndLastName=function(e){var t=e.split(" ");return 1===t.length?[e,""]:[t.slice(0,-1).join(" "),t[t.length-1]]},e.prototype._getCurrencyCodeOrThrow=function(){return Za(this._currencyCode,(function(){return new ja('Unable to initialize payment because "options.currencyCode" argument is not provided.')}))},e.prototype._getGooglePayShippingOption=function(e){var t,n=e.id,r=e.cost;return{id:n,label:e.description,description:(null===(t=this._currencyService)||void 0===t?void 0:t.toCustomerCurrency(r))||r}},e}();const gu=fu;var mu=function(e){function t(t,n){var r=e.call(this,"braintree",t)||this;return r._braintreeSdk=n,r._service=t,r}return(0,o.__extends)(t,e),t.prototype.initialize=function(t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,e.prototype.initialize.call(this,t,n,r)];case 1:if(o.sent(),!(i=e.prototype.getPaymentMethod.call(this)).clientToken||!i.initializationData)throw new Wa(Ya.MissingPaymentMethod);return this._braintreeSdk.initialize(i.clientToken),a=this,[4,this._braintreeSdk.getBraintreeGooglePayment()];case 2:return a._braintreeGooglePayment=o.sent(),[2,Promise.resolve()]}}))}))},t.prototype.getNonce=function(t){var n;return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s,u,c,d,l;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,e.prototype.getNonce.call(this,t)];case 1:if(r=o.sent(),i=e.prototype.getPaymentMethod.call(this),a=i.clientToken,s=i.initializationData,!a||!s||!(null===(n=s.card_information)||void 0===n?void 0:n.bin))throw new Wa(Ya.MissingPaymentMethod);return u=s.isThreeDSecureEnabled,c=s.card_information.bin,u?[4,this._braintreeSdk.getBraintreeThreeDS()]:[3,4];case 2:return d=o.sent(),l=this._service.getState().getOrderOrThrow().orderAmount,[4,this._braintreePresent3DSChallenge(d,l,r,c)];case 3:return[2,o.sent().nonce];case 4:return[2,r]}}))}))},t.prototype.extraPaymentData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return e={},[4,this._getBraintreeDeviceData()];case 1:return[2,(e.deviceSessionId=t.sent(),e)]}}))}))},t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:n=i.sent();try{r=JSON.parse(n.nonce)}catch(e){throw new ja("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 Wa(Ya.MissingPaymentToken)}(r),n.nonce=r.androidPayCards[0].nonce,n.card_information.bin=r.androidPayCards[0].details.bin,[2,n]}}))}))},t.prototype.getCardParameters=function(){return e.prototype.getCardParameters.call(this)},t.prototype.getPaymentGatewayParameters=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return t=this.getBraintreeGooglePayment(),r=(n=t).createPaymentDataRequest,i=[{merchantInfo:e.prototype.getMerchantInfo.call(this),transactionInfo:e.prototype.getTransactionInfo.call(this),cardRequirements:{billingAddressRequired:!0,billingAddressFormat:"FULL"}}],[4,e.prototype.getRequiredData.call(this)];case 1:return[2,r.apply(n,[o.__assign.apply(void 0,i.concat([a.sent()]))]).paymentMethodTokenizationParameters.parameters]}}))}))},t.prototype.getBraintreeGooglePayment=function(){if(!this._braintreeGooglePayment)throw new Wa(Ya.MissingPaymentMethod);return this._braintreeGooglePayment},t.prototype._getBraintreeDeviceData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this._braintreeSdk.getDataCollectorOrThrow()];case 1:return[2,e.sent().deviceData]}}))}))},t.prototype._braintreePresent3DSChallenge=function(e,t,n,r){return new Ur(e.verifyCard({amount:t,bin:r,nonce:n,onLookupComplete:function(e,t){t()}})).promise},t}(gu);const _u=mu,yu=function(e){function t(t){var n=e.call(this,t||"Unable to proceed because the client library of a payment method has thrown an unexpected error.")||this;return n.name="PaymentMethodFailedError",n.type="payment_method_client_invalid",n}return(0,o.__extends)(t,e),t}(s);var vu;!function(e){e.ADYEN_V2="googlepayadyenv2",e.ADYEN_V3="googlepayadyenv3",e.AUTHORIZE_NET="googlepayauthorizenet",e.BNZ="googlepaybnz",e.BRAINTREE="googlepaybraintree",e.PAYPAL_COMMERCE="googlepaypaypalcommerce",e.CHECKOUT_COM="googlepaycheckoutcom",e.CYBERSOURCE_V2="googlepaycybersourcev2",e.ORBITAL="googlepayorbital",e.STRIPE="googlepaystripe",e.STRIPE_UPE="googlepaystripeupe",e.WORLDPAY_ACCESS="googlepayworldpayaccess",e.TD_ONLINE_MART="googlepaytdonlinemart"}(vu||(vu={}));var Cu=function(){function e(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}return e.prototype.initialize=function(e){var t,n;return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s,u,c,d,l;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!e.methodId||(p=e.methodId,!Object.values(vu).includes(p)))throw new ja('Unable to proceed because "methodId" is not a valid key.');if(this._methodId=e.methodId,!e.containerId)throw new ja('Unable to proceed because "containerId" is not a valid key.');if(!(r=e[this._getMethodOrThrow()]))throw new ja("Unable to proceed without valid options.");i=r.buyNowInitializeOptions,a=r.currencyCode,s=r.buttonColor,u=r.buttonType,c=r.onError,d=this._paymentIntegrationService.getState(),o.label=1;case 1:return o.trys.push([1,2,,4]),l=d.getPaymentMethodOrThrow(this._getMethodOrThrow()),[3,4];case 2:return o.sent(),[4,this._paymentIntegrationService.loadPaymentMethod(this._getMethodOrThrow())];case 3:return d=o.sent(),l=d.getPaymentMethodOrThrow(this._getMethodOrThrow()),[3,4];case 4:if(this._countryCode=null===(t=l.initializationData)||void 0===t?void 0:t.storeCountry,!i)return[3,6];if(!a)throw new ja('Unable to initialize payment because "options.currencyCode" argument is not provided.');return this._currencyCode=a,this._buyNowInitializeOptions=i,[4,this._googlePayPaymentProcessor.initialize((function(){return l}),this._getGooglePayClientOptions(),!!i,a)];case 5:return o.sent(),[3,9];case 6:return[4,this._paymentIntegrationService.loadDefaultCheckout()];case 7:return o.sent(),[4,this._googlePayPaymentProcessor.initialize((function(){return l}),this._getGooglePayClientOptions())];case 8:o.sent(),o.label=9;case 9:return this._paymentButton=null!==(n=this._paymentButton)&&void 0!==n?n:this._googlePayPaymentProcessor.addPaymentButton(e.containerId,{buttonColor:null!=s?s:"default",buttonType:null!=u?u:"plain",onClick:this._handleClick(c)}),[2]}var p}))}))},e.prototype.deinitialize=function(){var e;return null===(e=this._paymentButton)||void 0===e||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()},e.prototype._handleClick=function(e){var t=this;return function(n){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:n.preventDefault(),i.label=1;case 1:return i.trys.push([1,8,,9]),this._buyNowInitializeOptions?[4,this._createBuyNowCartOrThrow(this._buyNowInitializeOptions)]:[3,3];case 2:return i.sent(),[3,5];case 3:return[4,this._paymentIntegrationService.loadDefaultCheckout()];case 4:i.sent(),i.label=5;case 5:return[4,this._googlePayPaymentProcessor.initializeWidget()];case 6:return i.sent(),[4,this._interactWithPaymentSheet()];case 7:return i.sent(),[3,9];case 8:if(t=i.sent(),r=t,"object"==typeof(o=t)&&null!==o&&"statusCode"in o){if("CANCELED"===t.statusCode)throw new Ts;r=new yu(JSON.stringify(t))}throw null==e||e(new yu("An error occurred while requesting your Google Pay payment details.")),r;case 9:return[2]}var o}))}))}},e.prototype._interactWithPaymentSheet=function(){var e;return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,this._googlePayPaymentProcessor.showPaymentSheet()];case 1:return t=o.sent(),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?[4,this._paymentIntegrationService.updateBillingAddress(n)]:[3,3];case 2:o.sent(),o.label=3;case 3:return!r||(null===(e=this._buyNowCart)||void 0===e?void 0:e.lineItems.digitalItems.length)?[3,5]:[4,this._paymentIntegrationService.updateShippingAddress(r)];case 4:o.sent(),o.label=5;case 5:return[4,this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodOrThrow(),t,i)];case 6:return o.sent(),[2]}}))}))},e.prototype._getGooglePayClientOptions=function(){var e=this;return{paymentDataCallbacks:{onPaymentDataChanged:function(t){var n=t.callbackTrigger,r=t.shippingAddress,i=t.shippingOptionData;return(0,o.__awaiter)(e,void 0,void 0,(function(){var e,t,a,s,u,c;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return e=this._googlePayPaymentProcessor.getCallbackTriggers(),t=e.availableTriggers,a=e.addressChangeTriggers,s=e.shippingOptionsChangeTriggers,t.includes(n)?a.includes(n)?[4,this._googlePayPaymentProcessor.handleShippingAddressChange(r)]:[3,2]:[2];case 1:return c=o.sent(),[3,3];case 2:c=void 0,o.label=3;case 3:return u=c,s.includes(n)?[4,this._googlePayPaymentProcessor.handleShippingOptionChange(i.id)]:[3,5];case 4:o.sent(),o.label=5;case 5:return this._buyNowInitializeOptions?[2,this._getBuyNowTransactionInfo(u)]:[2,this._getTransactionInfo(u)]}}))}))}}}},e.prototype._createBuyNowCartOrThrow=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:if("function"!=typeof(null==e?void 0:e.getBuyNowCartRequestBody))return[3,5];t=e.getBuyNowCartRequestBody(),i.label=1;case 1:return i.trys.push([1,4,,5]),n=this,[4,this._paymentIntegrationService.createBuyNowCart(t)];case 2:return n._buyNowCart=i.sent(),[4,this._paymentIntegrationService.loadCheckout(this._buyNowCart.id)];case 3:return i.sent(),[3,5];case 4:throw r=i.sent(),new ds(r);case 5:return[2]}}))}))},e.prototype._getBuyNowTransactionInfo=function(e){if(this._buyNowCart){var t=this._buyNowCart.cartAmount,n=this._googlePayPaymentProcessor.getTotalPrice();return(0,o.__assign)({newTransactionInfo:(0,o.__assign)((0,o.__assign)({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:this._getCurrencyCodeOrThrow(),totalPrice:n||String(t),totalPriceStatus:cu.FINAL})},e&&{newShippingOptionParameters:e})}},e.prototype._getTransactionInfo=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._paymentIntegrationService.loadCheckout()];case 1:return r.sent(),t=this._googlePayPaymentProcessor.getTotalPrice(),n=this._paymentIntegrationService.getState().getCartOrThrow().currency.code,[2,(0,o.__assign)({newTransactionInfo:(0,o.__assign)((0,o.__assign)({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:n,totalPriceStatus:cu.FINAL,totalPrice:t})},e&&{newShippingOptionParameters:e})]}}))}))},e.prototype._getMethodOrThrow=function(){return Za(this._methodId,(function(){return new Ja(Qa.PaymentNotInitialized)}))},e.prototype._getCurrencyCodeOrThrow=function(){return Za(this._currencyCode,(function(){return new ja('Unable to initialize payment because "options.currencyCode" argument is not provided.')}))},e}();const Su=Cu;var Iu=function(){function e(e,t,n,r){this._scriptLoader=e,this._gateway=t,this._requestSender=n,this._formPoster=r,this._baseRequest={apiVersion:2,apiVersionMinor:0}}return e.prototype.initialize=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return i=this,[4,this._scriptLoader.getGooglePaymentsClient(e().config.testMode,t)];case 1:return i._paymentsClient=o.sent(),[4,this._gateway.initialize(e,n,r)];case 2:return o.sent(),this._buildButtonPayloads(),[2]}}))}))},e.prototype.initializeWidget=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this._buildWidgetPayloads()];case 1:return e.sent(),[4,this._determineReadinessToPay()];case 2:return e.sent(),this._prefetchGooglePaymentData(),[2]}}))}))},e.prototype.getNonce=function(e){return this._gateway.getNonce(e)},e.prototype.extraPaymentData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this._gateway.extraPaymentData()]}))}))},e.prototype.addPaymentButton=function(e,t){var n=document.querySelector("#"+e);if(!n)throw new ja("Unable to render the Google Pay button to an invalid HTML container element.");var r=this._getPaymentsClient().createButton((0,o.__assign)((0,o.__assign)({},t),{allowedPaymentMethods:[this._getBaseCardPaymentMethod()]}));return n.appendChild(r)},e.prototype.showPaymentSheet=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(t){return e=this._getPaymentDataRequest(),[2,this._getPaymentsClient().loadPaymentData(e)]}))}))},e.prototype.setExternalCheckoutXhr=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){return[2,this._setExternalCheckout(e,t)]}))}))},e.prototype.setExternalCheckoutForm=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){return[2,this._setExternalCheckout(e,t,!0,n)]}))}))},e.prototype.mapToBillingAddressRequestBody=function(e){return this._gateway.mapToBillingAddressRequestBody(e)},e.prototype.mapToShippingAddressRequestBody=function(e){return this._gateway.mapToShippingAddressRequestBody(e)},e.prototype.processAdditionalAction=function(e){return"processAdditionalAction"in this._gateway?this._gateway.processAdditionalAction(e):Promise.reject(e)},e.prototype.signOut=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._requestSender.get("/remote-checkout/"+e+"/signout")];case 1:return t.sent(),[2]}}))}))},e.prototype.getCallbackTriggers=function(){return this._gateway.getCallbackTriggers()},e.prototype.handleShippingAddressChange=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){return[2,this._gateway.handleShippingAddressChange(e)]}))}))},e.prototype.handleShippingOptionChange=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._gateway.handleShippingOptionChange(e)];case 1:return t.sent(),[2]}}))}))},e.prototype.getTotalPrice=function(){return this._gateway.getTotalPrice()},e.prototype._setExternalCheckout=function(e,t,n,r){return void 0===n&&(n=!1),(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u=this;return(0,o.__generator)(this,(function(c){switch(c.label){case 0:return i="/checkout.php",s=[{action:"set_external_checkout",provider:e}],[4,this._gateway.mapToExternalCheckoutData(t)];case 1:return a=o.__assign.apply(void 0,s.concat([c.sent()])),n?[2,new Promise((function(e){u._formPoster.postForm(r?r+"/checkout":i,(0,o.__assign)((0,o.__assign)({},a),{card_information:JSON.stringify(a.card_information)}),e)}))]:[4,this._requestSender.post(i,{headers:(0,o.__assign)({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},ys),body:a})];case 2:return c.sent(),[2]}}))}))},e.prototype._prefetchGooglePaymentData=function(){var e=this._getPaymentDataRequest();e.transactionInfo=this._gateway.getTransactionInfo(),this._getPaymentsClient().prefetchPaymentData(e)},e.prototype._determineReadinessToPay=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this._getPaymentsClient().isReadyToPay(this._getIsReadyToPayRequest())];case 1:if(!1===t.sent().result)throw new yu("Google Pay is not supported by the current device and browser, please try another payment method.");return[3,3];case 2:if((e=t.sent())instanceof yu)throw e;throw new yu;case 3:return[2]}}))}))},e.prototype._buildButtonPayloads=function(){this._baseCardPaymentMethod={type:"CARD",parameters:this._gateway.getCardParameters()}},e.prototype._buildWidgetPayloads=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r,i,a,s;return(0,o.__generator)(this,(function(u){switch(u.label){case 0:return e=this._getBaseCardPaymentMethod(),t=this,n=[(0,o.__assign)({},e)],a={},s={type:"PAYMENT_GATEWAY"},[4,this._gateway.getPaymentGatewayParameters()];case 1:return t._cardPaymentMethod=o.__assign.apply(void 0,n.concat([(a.tokenizationSpecification=(s.parameters=u.sent(),s),a)])),r=this,i=[(0,o.__assign)((0,o.__assign)({},this._baseRequest),{allowedPaymentMethods:[this._cardPaymentMethod],transactionInfo:this._gateway.getTransactionInfo(),merchantInfo:this._gateway.getMerchantInfo()})],[4,this._gateway.getRequiredData()];case 2:return r._paymentDataRequest=o.__assign.apply(void 0,[o.__assign.apply(void 0,i.concat([u.sent()])),{callbackIntents:this._gateway.getCallbackIntents()}]),this._isReadyToPayRequest=(0,o.__assign)((0,o.__assign)({},this._baseRequest),{allowedPaymentMethods:[e]}),[2]}}))}))},e.prototype._getBaseCardPaymentMethod=function(){return this._getOrThrow(this._baseCardPaymentMethod)},e.prototype._getPaymentDataRequest=function(){return this._getOrThrow(this._paymentDataRequest)},e.prototype._getIsReadyToPayRequest=function(){return this._getOrThrow(this._isReadyToPayRequest)},e.prototype._getPaymentsClient=function(){return this._getOrThrow(this._paymentsClient)},e.prototype._getOrThrow=function(e){return Za(e,(function(){return new Ja(Qa.PaymentNotInitialized)}))},e}();const wu=Iu;var Eu=function(){function e(e){this._scriptLoader=e,this._window=window}return e.prototype.getGooglePaymentsClient=function(e,t){return void 0===e&&(e=!1),(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._scriptLoader.loadScript("https://pay.google.com/gp/p/js/pay.js")];case 1:if(n.sent(),!this._window.google)throw new Ko;return void 0===this._paymentsClient&&(this._paymentsClient=new this._window.google.payments.api.PaymentsClient((0,o.__assign)({environment:e?"TEST":"PRODUCTION"},null!=t?t:{}))),[2,this._paymentsClient]}}))}))},e}();const bu=Eu;function Pu(){return new bu((0,ir.getScriptLoader)())}const Au=cs((function(e){var t=(0,r.createRequestSender)(),n=window,o=new Os(new ta((0,ir.getScriptLoader)(),n));return new Su(e,new wu(Pu(),new _u(e,o),t,(0,i.createFormPoster)()))}),[{id:"googlepaybraintree"}]);var Ou=function(e){function t(t,n){var r=e.call(this,"paypalsb",t)||this;return r.paypalCommerceScriptLoader=n,r.service=t,r}return(0,o.__extends)(t,e),t.prototype.initialize=function(t,n,r){var i,a,s,u,c;return(0,o.__awaiter)(this,void 0,void 0,(function(){var d,l,p,h;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!(d=null!==(a=null===(i=this.service.getState().getStoreConfig())||void 0===i?void 0:i.currency.code)&&void 0!==a?a:r))throw new Wa(Ya.MissingPaymentMethod);return[4,e.prototype.initialize.call(this,t,n,d)];case 1:if(o.sent(),!(l=e.prototype.getPaymentMethod.call(this)).initializationData)throw new Wa(Ya.MissingPaymentMethod);return function(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 Wa(Ya.MissingPaymentMethod)}(l),[4,this.paypalCommerceScriptLoader.getPayPalSDK(l,d)];case 2:return o.sent(),p=this,[4,this.paypalCommerceScriptLoader.getGooglePayConfigOrThrow()];case 3:return p.googlepayConfig=o.sent(),h=this.googlepayConfig.allowedPaymentMethods,this.setGatewayIdentifier(null===(c=null===(u=null===(s=h[0])||void 0===s?void 0:s.tokenizationSpecification)||void 0===u?void 0:u.parameters)||void 0===c?void 0:c.gateway),[2]}}))}))},t.prototype.getPaymentGatewayParameters=function(){if(this.googlepayConfig){var e=this.googlepayConfig.allowedPaymentMethods[0].tokenizationSpecification.parameters.gatewayMerchantId;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e}}return{gateway:this.getGatewayIdentifier()}},t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:return(n=r.sent()).nonce=btoa(n.nonce),[2,n]}}))}))},t}(gu);const Tu=Ou;var Ru=function(){function e(e){this.scriptLoader=e,this.window=window}return e.prototype.getPayPalSDK=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i;return(0,o.__generator)(this,(function(o){return i=this.getPayPalSdkScriptConfigOrThrow(e,t,n),[2,this.loadPayPalSDK(i,r)]}))}))},e.prototype.getGooglePayConfigOrThrow=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(t){switch(t.label){case 0:if(!this.window.paypal)throw new Ko;return this.googlepayConfig?[3,2]:(e=this,[4,this.window.paypal.Googlepay().config()]);case 1:e.googlepayConfig=t.sent(),t.label=2;case 2:return[2,this.googlepayConfig]}}))}))},e.prototype.loadPayPalSDK=function(e,t){return void 0===t&&(t=!1),(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return this.window.paypal&&!t?[3,2]:(n=this.transformConfig(e.options),r=this.transformConfig(e.attributes),i=new URLSearchParams(n).toString(),a="https://www.paypal.com/sdk/js?"+i,[4,this.scriptLoader.loadScript(a,{async:!0,attributes:r})]);case 1:o.sent(),o.label=2;case 2:if(!this.window.paypal)throw new Ko;return[2,this.window.paypal]}}))}))},e.prototype.getPayPalSdkScriptConfigOrThrow=function(e,t,n){void 0===n&&(n=!0);var r=e.id,i=e.clientToken,a=e.initializationData;if(!(null==a?void 0:a.clientId))throw new Wa(Ya.MissingPaymentMethod);var s=a.intent,u=a.clientId,c=a.merchantId,d=a.buyerCountry,l=a.attributionId,p=a.isVenmoEnabled,h=a.isHostedCheckoutEnabled,f=a.isPayPalCreditAvailable,g=a.isDeveloperModeApplicable,m=a.availableAlternativePaymentMethods,_=void 0===m?[]:m,y=a.enabledAlternativePaymentMethods,v=void 0===y?[]:y,C=a.isGooglePayEnabled,S=h||n,I="paypalcommercecreditcards"===r,w=I?["card"]:[],E=I?[]:["card"],b=n?["card-fields"]:[],P=f?["credit","paylater"]:[],A=f?[]:["credit","paylater"],O=n||!S,T=O&&p?["venmo"]:[],R=O&&p?[]:["venmo"],k=O?v:[],D=O?_.filter((function(e){return!v.includes(e)})):_,M=(0,o.__spreadArrays)(E,A,R,D),N=(0,o.__spreadArrays)(w,P,T,k),L=C?["googlepay"]:[];return{options:(0,o.__assign)({"client-id":u,"merchant-id":c,"enable-funding":N.length>0?N:void 0,"disable-funding":M.length>0?M:void 0,commit:S,components:(0,o.__spreadArrays)(["buttons","hosted-fields","messages","payment-fields","legal"],L,b),currency:t,intent:s},g&&{"buyer-country":d}),attributes:{"data-partner-attribution-id":l,"data-client-token":i}}},e.prototype.transformConfig=function(e){var t={};return Object.keys(e).forEach((function(n){var r,i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=Array.isArray(i)?i.join(","):i,r)))})),t},e}();const ku=Ru,Du=cs((function(e){return new Su(e,new wu(Pu(),new Tu(e,new ku((0,ir.getScriptLoader)())),(0,r.createRequestSender)(),(0,i.createFormPoster)()))}),[{id:"googlepaypaypalcommerce"}]),Mu=cs((function(e){var t=(0,r.createRequestSender)();return new Su(e,new wu(Pu(),new gu("adyen",e),t,(0,i.createFormPoster)()))}),[{id:"googlepayadyenv2"}]),Nu=cs((function(e){var t=(0,r.createRequestSender)();return new Su(e,new wu(Pu(),new gu("adyen",e),t,(0,i.createFormPoster)()))}),[{id:"googlepayadyenv3"}]);var Lu=function(e){function t(t){return e.call(this,"authorizenet",t)||this}return(0,o.__extends)(t,e),t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:return(n=r.sent()).nonce=btoa(n.nonce),[2,n]}}))}))},t.prototype.getPaymentGatewayParameters=function(){var e=this.getGooglePayInitializationData();return function(e){if(!function(e){return"paymentGatewayId"in e}(e))throw new Wa(Ya.MissingPaymentMethod)}(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.paymentGatewayId}},t}(gu);const zu=Lu,Uu=cs((function(e){return new Su(e,new wu(Pu(),new zu(e),(0,r.createRequestSender)(),(0,i.createFormPoster)()))}),[{id:"googlepayauthorizenet"}]),Fu=function(e){return"object"==typeof e&&null!==e&&"body"in e};function Bu(e){if(!function(e){return"checkoutcomkey"in e}(e))throw new Wa(Ya.MissingPaymentMethod)}var qu=function(e){function t(t,n){var r=e.call(this,"checkoutltd",t)||this;return r._requestSender=n,r}return(0,o.__extends)(t,e),t.prototype.processAdditionalAction=function(e){return new Promise((function(t,n){if(Fu(e)&&function(e){var t;if("object"!=typeof e||null===e)return!1;var n=e;return"string"==typeof(null===(t=n.three_ds_result)||void 0===t?void 0:t.acs_url)&&"string"==typeof n.three_ds_result.code}(e.body)&&"three_d_secure_required"===e.body.three_ds_result.code)return window.location.assign(e.body.three_ds_result.acs_url);n(e)}))},t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:n=o.sent();try{r=JSON.parse(n.nonce)}catch(e){throw new ja("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 Wa(Ya.MissingPaymentToken)}(r),i=n,[4,this._tokenize(r)];case 2:return i.nonce=o.sent(),[2,n]}}))}))},t.prototype.getPaymentGatewayParameters=function(){var e=this.getGooglePayInitializationData();return Bu(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.checkoutcomkey}},t.prototype._tokenize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return t=this.getPaymentMethod().config.testMode?"https://api.sandbox.checkout.com/tokens":"https://api.checkout.com/tokens",Bu(n=this.getGooglePayInitializationData()),[4,this._requestSender.post(t,{credentials:!1,body:{type:"googlepay",token_data:e},headers:{Authorization:n.checkoutcomkey,"Content-Type":_s.Json,"X-XSRF-TOKEN":null}})];case 1:return[2,r.sent().body.token]}}))}))},t}(gu);const xu=qu,Gu=cs((function(e){var t=(0,r.createRequestSender)();return new Su(e,new wu(Pu(),new xu(e,t),t,(0,i.createFormPoster)()))}),[{id:"googlepaycheckoutcom"}]);var Vu=function(e){function t(t){return e.call(this,"cybersource",t)||this}return(0,o.__extends)(t,e),t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:return(n=r.sent()).nonce=btoa(n.nonce),[2,n]}}))}))},t}(gu);const Hu=Vu,ju=cs((function(e){return new Su(e,new wu(Pu(),new Hu(e),(0,r.createRequestSender)(),(0,i.createFormPoster)()))}),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]);var Yu=function(e){function t(t){return e.call(this,"chase",t)||this}return(0,o.__extends)(t,e),t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:return(n=r.sent()).nonce=btoa(n.nonce),[2,n]}}))}))},t}(gu);const Wu=Yu,Ku=cs((function(e){return new Su(e,new wu(Pu(),new Wu(e),(0,r.createRequestSender)(),(0,i.createFormPoster)()))}),[{id:"googlepayorbital"}]);var Zu=function(e){function t(t){return e.call(this,"stripe",t)||this}return(0,o.__extends)(t,e),t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:n=i.sent();try{r=JSON.parse(n.nonce)}catch(e){throw new ja("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 Wa(Ya.MissingPaymentToken)}(r),n.nonce=r.id,[2,n]}}))}))},t.prototype.getPaymentGatewayParameters=function(){var e=this.getGooglePayInitializationData();!function(e){if(!function(e){return"stripeConnectedAccount"in e&&"stripePublishableKey"in e&&"stripeVersion"in e}(e))throw new Wa(Ya.MissingPaymentMethod)}(e);var t=e.stripeVersion,n=e.stripePublishableKey,r=e.stripeConnectedAccount;return{gateway:this.getGatewayIdentifier(),"stripe:version":t,"stripe:publishableKey":n+"/"+r}},t}(gu);const Qu=Zu,Ju=cs((function(e){return new Su(e,new wu(Pu(),new Qu(e),(0,r.createRequestSender)(),(0,i.createFormPoster)()))}),[{id:"googlepaystripe"},{id:"googlepaystripeupe"}]);var Xu=function(e){function t(t){return e.call(this,"worldpay",t)||this}return(0,o.__extends)(t,e),t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:return(n=r.sent()).nonce=btoa(n.nonce),[2,n]}}))}))},t}(gu);const $u=Xu,ec=cs((function(e){return new Su(e,new wu(Pu(),new $u(e),(0,r.createRequestSender)(),(0,i.createFormPoster)()))}),[{id:"googlepayworldpayaccess"}]),tc=function(e){function t(t){var n=this,r="Unable to submit payment for the order because the payload is invalid.";return t&&(r=r+" Make sure the following fields are provided correctly: "+t.join(", ")+"."),(n=e.call(this,r)||this).name="PaymentArgumentInvalidError",n}return(0,o.__extends)(t,e),t}(ja);var nc=function(e){function t(t,n){var r=e.call(this,"worldlinena",t)||this;return r.formPoster=n,r}return(0,o.__extends)(t,e),t.prototype.extraPaymentData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,Promise.resolve({browser_info:(n=window.navigator,t=n.language?n.language:n.userLanguage,{color_depth:window.screen.colorDepth||24,java_enabled:"function"==typeof n.javaEnabled&&n.javaEnabled(),language:t,screen_height:window.screen.height,screen_width:window.screen.width,time_zone_offset:(new Date).getTimezoneOffset().toString()})})];var t,n}))}))},t.prototype.processAdditionalAction=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s=this;return(0,o.__generator)(this,(function(o){if(!function(e){return Fu(e)&&(t=e.body,(0,_.isObject)(t)&&"object"==typeof t&&"errors"in t&&"three_ds_result"in t&&(0,_.isArray)(t.errors)&&(0,_.some)(t.errors,{code:"three_d_secure_required"}));var t}(e))throw e;if(t=e.body.three_ds_result,r=(n=t||{}).acs_url,i=n.payer_auth_request,a=n.merchant_data,!r||!i||!a)throw new tc(["formUrl","threeDSSessionData","creq"]);return[2,new Promise((function(e){s.formPoster.postForm(r,{threeDSSessionData:i,creq:a},e,"_top")}))]}))}))},t}(gu);const rc=nc,ic=cs((function(e){return new Su(e,new wu(Pu(),new rc(e,(0,i.createFormPoster)()),(0,r.createRequestSender)(),(0,i.createFormPoster)()))}),[{id:"googlepaytdonlinemart"}]);var oc,ac,sc,uc,cc,dc,lc,pc;!function(e){e.BuyNow="BUY_NOW"}(oc||(oc={})),function(e){e.Possible="POSSIBLE",e.No="NO",e.Unknown="UNKNOWN",e.Yes="YES"}(ac||(ac={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(sc||(sc={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(uc||(uc={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(cc||(cc={})),function(e){e.pill="pill",e.rect="rect"}(dc||(dc={})),function(e){e.OXXO="oxxo"}(lc||(lc={})),function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(pc||(pc={}));var hc=function(){function e(e,t,n,r){this.formPoster=e,this.paymentIntegrationService=t,this.paypalCommerceRequestSender=n,this.paypalCommerceScriptLoader=r}return e.prototype.loadPayPalSdk=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return i=this.paymentIntegrationService.getState(),a=t||i.getCartOrThrow().currency.code,s=i.getPaymentMethodOrThrow(e),u=this,[4,this.paypalCommerceScriptLoader.getPayPalSDK(s,a,n,r)];case 1:return u.paypalSdk=o.sent(),[2,this.paypalSdk]}}))}))},e.prototype.getPayPalSdkOrThrow=function(){if(!this.paypalSdk)throw new Ko;return this.paypalSdk},e.prototype.createBuyNowCartOrThrow=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if(!(t=e.getBuyNowCartRequestBody()))throw new Wa(Ya.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.paymentIntegrationService.createBuyNowCart(t)];case 2:return[2,n.sent()];case 3:throw n.sent(),new ds;case 4:return[2]}}))}))},e.prototype.createOrder=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return n=this.paymentIntegrationService.getState().getCartOrThrow().id,[4,this.paypalCommerceRequestSender.createOrder(e,(0,o.__assign)({cartId:n},t))];case 1:return[2,r.sent().orderId]}}))}))},e.prototype.createOrderCardFields=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(s){switch(s.label){case 0:return n=this.paymentIntegrationService.getState().getCartOrThrow().id,[4,this.paypalCommerceRequestSender.createOrder(e,(0,o.__assign)({cartId:n},t))];case 1:return r=s.sent(),i=r.orderId,a=r.setupToken,[2,(0,o.__assign)({orderId:i},a?{setupToken:a}:{})]}}))}))},e.prototype.updateOrder=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:e=this.paymentIntegrationService.getState(),t=e.getCartOrThrow(),n=e.getConsignmentsOrThrow()[0],r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.paypalCommerceRequestSender.updateOrder({availableShippingOptions:n.availableShippingOptions,cartId:t.id,selectedShippingOption:n.selectedShippingOption})];case 2:return r.sent(),[3,4];case 3:throw r.sent(),new d;case 4:return[2]}}))}))},e.prototype.getOrderStatus=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.paypalCommerceRequestSender.getOrderStatus(e,t)];case 1:return[2,n.sent().status];case 2:throw n.sent(),new d;case 3:return[2]}}))}))},e.prototype.tokenizePayment=function(e,t){var n=this.paymentIntegrationService.getState().getCartOrThrow();if(!t)throw new Wa(Ya.MissingOrderId);return this.formPoster.postForm("/checkout.php",(0,o.__assign)({payment_type:"paypal",action:"set_external_checkout",provider:e,order_id:t},n.source===oc.BuyNow&&{cart_id:n.id}))},e.prototype.submitPayment=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return r={formattedPayload:{vault_payment_instrument:null,set_as_default_stored_instrument:null,device_info:null,method_id:e,paypal_account:{order_id:t}}},[4,this.paymentIntegrationService.submitPayment((0,o.__assign)({methodId:e,paymentData:r},n?{gatewayId:n}:{}))];case 1:return i.sent(),[2]}}))}))},e.prototype.getShippingOptionOrThrow=function(e){var t=this.paymentIntegrationService.getState().getConsignmentsOrThrow()[0],n=t.availableShippingOptions||[],r=n.find((function(e){return e.isRecommended})),i=e?n.find((function(t){return t.id===e})):n.find((function(e){var n;return e.id===(null===(n=t.selectedShippingOption)||void 0===n?void 0:n.id)})),o=i||r||n[0];if(!o)throw new Error("Your order can't be shipped to this address");return o},e.prototype.getAddress=function(e){return{firstName:(null==e?void 0:e.firstName)||"",lastName:(null==e?void 0:e.lastName)||"",email:(null==e?void 0:e.email)||"",phone:"",company:"",address1:(null==e?void 0:e.address1)||"",address2:"",city:(null==e?void 0:e.city)||"",countryCode:(null==e?void 0:e.countryCode)||"",postalCode:(null==e?void 0:e.postalCode)||"",stateOrProvince:"",stateOrProvinceCode:(null==e?void 0:e.stateOrProvinceCode)||"",customFields:[]}},e.prototype.getBillingAddressFromOrderDetails=function(e){var t=e.payer;return this.getAddress({firstName:t.name.given_name,lastName:t.name.surname,email:t.email_address,address1:t.address.address_line_1,city:t.address.admin_area_2,countryCode:t.address.country_code,postalCode:t.address.postal_code,stateOrProvinceCode:t.address.admin_area_1})},e.prototype.getShippingAddressFromOrderDetails=function(e){var t,n,r=e.payer,i=(null===(n=null===(t=e.purchase_units[0])||void 0===t?void 0:t.shipping)||void 0===n?void 0:n.address)||{};return this.getAddress({firstName:r.name.given_name,lastName:r.name.surname,email:r.email_address,address1:i.address_line_1,city:i.admin_area_2,countryCode:i.country_code,postalCode:i.postal_code,stateOrProvinceCode:i.admin_area_1})},e.prototype.getValidButtonStyle=function(e){var t=e||{},n=t.color,r=t.height,i=t.label,o=t.shape,a={color:n&&cc[n]?n:void 0,height:this.getValidHeight(r),label:i&&uc[i]?i:void 0,shape:o&&dc[o]?o:void 0};return(0,_.omitBy)(a,_.isNil)},e.prototype.getValidHeight=function(e){return e&&"number"==typeof e?e>55?55:e<25?25:e:40},e.prototype.removeElement=function(e){var t=e&&document.getElementById(e);t&&(t.style.display="none")},e}();const fc=hc;var gc=function(){function e(e){this.requestSender=e}return e.prototype.createOrder=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return n="/api/storefront/payment/"+e,r=t,i=(0,o.__assign)({"X-API-INTERNAL":ms,"Content-Type":_s.Json},ys),[4,this.requestSender.post(n,{headers:i,body:r})];case 1:return[2,a.sent().body]}}))}))},e.prototype.updateOrder=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return t=e,n=(0,o.__assign)({"X-API-INTERNAL":ms,"Content-Type":_s.Json},ys),[4,this.requestSender.put("/api/storefront/initialization/paypalcommerce",{headers:n,body:t})];case 1:return[2,r.sent().body]}}))}))},e.prototype.getOrderStatus=function(e,t){return void 0===e&&(e="paypalcommerce"),(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return n="/api/storefront/initialization/"+e,r=(0,o.__assign)({"X-API-INTERNAL":ms,"Content-Type":_s.Json},ys),[4,this.requestSender.get(n,(0,o.__assign)({headers:r},t))];case 1:return[2,i.sent().body]}}))}))},e}();const mc=gc;var _c=function(){function e(e){this.scriptLoader=e,this.window=window}return e.prototype.getPayPalSDK=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i;return(0,o.__generator)(this,(function(o){return i=this.getPayPalSdkScriptConfigOrThrow(e,t,n),[2,this.loadPayPalSDK(i,r)]}))}))},e.prototype.loadPayPalSDK=function(e,t){return void 0===t&&(t=!1),(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return this.window.paypal&&!t?[3,2]:(n=this.transformConfig(e.options),r=this.transformConfig(e.attributes),i=new URLSearchParams(n).toString(),a="https://www.paypal.com/sdk/js?"+i,[4,this.scriptLoader.loadScript(a,{async:!0,attributes:r})]);case 1:o.sent(),o.label=2;case 2:if(!this.window.paypal)throw new Ko;return[2,this.window.paypal]}}))}))},e.prototype.getPayPalSdkScriptConfigOrThrow=function(e,t,n){void 0===n&&(n=!0);var r=e.id,i=e.clientToken,a=e.initializationData;if(!(null==a?void 0:a.clientId))throw new Wa(Ya.MissingPaymentMethod);var s=a.intent,u=a.clientId,c=a.merchantId,d=a.buyerCountry,l=a.attributionId,p=a.isVenmoEnabled,h=a.isHostedCheckoutEnabled,f=a.isPayPalCreditAvailable,g=a.isDeveloperModeApplicable,m=a.availableAlternativePaymentMethods,_=void 0===m?[]:m,y=a.enabledAlternativePaymentMethods,v=void 0===y?[]:y,C=a.isGooglePayEnabled,S=h||n,I="paypalcommercecreditcards"===r,w=I?["card"]:[],E=I?[]:["card"],b=f?["credit","paylater"]:[],P=f?[]:["credit","paylater"],A=n||!S,O=A&&p?["venmo"]:[],T=A&&p?[]:["venmo"],R=A?v:[],k=A?_.filter((function(e){return!v.includes(e)})):_,D=C?["googlepay"]:[],M=n?["card-fields"]:[],N=(0,o.__spreadArrays)(E,P,T,k),L=(0,o.__spreadArrays)(w,b,O,R);return{options:(0,o.__assign)({"client-id":u,"merchant-id":c,"enable-funding":L.length>0?L:void 0,"disable-funding":N.length>0?N:void 0,commit:S,components:(0,o.__spreadArrays)(["buttons","hosted-fields","payment-fields","legal"],D,M),currency:t,intent:s},g&&{"buyer-country":d}),attributes:{"data-partner-attribution-id":l,"data-client-token":i}}},e.prototype.transformConfig=function(e){var t={};return Object.keys(e).forEach((function(n){var r,i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=Array.isArray(i)?i.join(","):i,r)))})),t},e}();const yc=_c,vc=function(e){var t=e.getState().getHost;return new fc((0,i.createFormPoster)(),e,new mc((0,r.createRequestSender)({host:t()})),new yc((0,ir.getScriptLoader)()))};var Cc=function(){function e(e,t){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t}return e.prototype.initialize=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(n=e.paypalcommerce,r=e.containerId,i=e.methodId,a=Boolean(null==n?void 0:n.buyNowInitializeOptions),!i)throw new ja('Unable to initialize payment because "options.methodId" argument is not provided.');if(!r)throw new ja('Unable to initialize payment because "options.containerId" argument is not provided.');if(!n)throw new ja('Unable to initialize payment because "options.paypalcommerce" argument is not provided.');if(a&&!n.currencyCode)throw new ja('Unable to initialize payment because "options.paypalcommerce.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null===(t=n.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody))throw new ja('Unable to initialize payment because "options.paypalcommerce.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');return a?[3,2]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return s=a?n.currencyCode:this.paymentIntegrationService.getState().getCartOrThrow().currency.code,[4,this.paypalCommerceIntegrationService.loadPayPalSdk(i,s,!1)];case 3:return o.sent(),this.renderButton(r,i,n),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r,i=this,a=n.buyNowInitializeOptions,s=n.style,u=n.onComplete,c=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState(),l=(d.getPaymentMethodOrThrow(t).initializationData||{}).isHostedCheckoutEnabled,p={createOrder:function(){return i.paypalCommerceIntegrationService.createOrder("paypalcommerce")},onApprove:function(e){var n=e.orderID;return i.paypalCommerceIntegrationService.tokenizePayment(t,n)}},h={onClick:function(){return i.handleClick(a)},onCancel:function(){return i.paymentIntegrationService.loadDefaultCheckout()}},f=(null===(r=d.getStoreConfig())||void 0===r?void 0:r.checkoutSettings.features["PAYPAL-4387.paypal_shipping_callbacks"])?{onShippingAddressChange:function(e){return i.onShippingAddressChange(e)},onShippingOptionsChange:function(e){return i.onShippingOptionsChange(e)}}:{onShippingChange:function(e){return i.onShippingChange(e)}},g=(0,o.__assign)((0,o.__assign)({},f),{onApprove:function(e,n){return i.onHostedCheckoutApprove(e,n,t,u)}}),m=(0,o.__assign)((0,o.__assign)((0,o.__assign)({fundingSource:c.FUNDING.PAYPAL,style:this.paypalCommerceIntegrationService.getValidButtonStyle(s)},p),a&&h),l&&g),_=c.Buttons(m);_.isEligible()?_.render("#"+e):this.paypalCommerceIntegrationService.removeElement(e)},e.prototype.handleClick=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e?[4,this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e)]:[3,3];case 1:return t=n.sent(),[4,this.paymentIntegrationService.loadCheckout(t.id)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e.prototype.onHostedCheckoutApprove=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!e.orderID)throw new Wa(Ya.MissingOrderId);return i=this.paymentIntegrationService.getState(),a=i.getCartOrThrow(),[4,t.order.get()];case 1:s=o.sent(),o.label=2;case 2:return o.trys.push([2,9,,10]),u=this.paypalCommerceIntegrationService.getBillingAddressFromOrderDetails(s),[4,this.paymentIntegrationService.updateBillingAddress(u)];case 3:return o.sent(),a.lineItems.physicalItems.length>0?(c=this.paypalCommerceIntegrationService.getShippingAddressFromOrderDetails(s),[4,this.paymentIntegrationService.updateShippingAddress(c)]):[3,6];case 4:return o.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:o.sent(),o.label=6;case 6:return[4,this.paymentIntegrationService.submitOrder({},{params:{methodId:n}})];case 7:return o.sent(),[4,this.paypalCommerceIntegrationService.submitPayment(n,e.orderID)];case 8:return o.sent(),r&&"function"==typeof r&&r(),[2,!0];case 9:throw d=o.sent(),new Error(d);case 10:return[2]}}))}))},e.prototype.onShippingAddressChange=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:t=this.paypalCommerceIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state}),i.label=1;case 1:return i.trys.push([1,6,,7]),[4,this.paymentIntegrationService.updateBillingAddress(t)];case 2:return i.sent(),[4,this.paymentIntegrationService.updateShippingAddress(t)];case 3:return i.sent(),n=this.paypalCommerceIntegrationService.getShippingOptionOrThrow(),[4,this.paymentIntegrationService.selectShippingOption(n.id)];case 4:return i.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:return i.sent(),[3,7];case 6:throw r=i.sent(),new Error(r);case 7:return[2]}}))}))},e.prototype.onShippingOptionsChange=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:t=this.paypalCommerceIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id),r.label=1;case 1:return r.trys.push([1,4,,5]),[4,this.paymentIntegrationService.selectShippingOption(t.id)];case 2:return r.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 3:return r.sent(),[3,5];case 4:throw n=r.sent(),new Error(n);case 5:return[2]}}))}))},e.prototype.onShippingChange=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:n=this.paypalCommerceIntegrationService.getAddress({city:e.shipping_address.city,countryCode:e.shipping_address.country_code,postalCode:e.shipping_address.postal_code,stateOrProvinceCode:e.shipping_address.state}),o.label=1;case 1:return o.trys.push([1,6,,7]),[4,this.paymentIntegrationService.updateBillingAddress(n)];case 2:return o.sent(),[4,this.paymentIntegrationService.updateShippingAddress(n)];case 3:return o.sent(),r=this.paypalCommerceIntegrationService.getShippingOptionOrThrow(null===(t=e.selected_shipping_option)||void 0===t?void 0:t.id),[4,this.paymentIntegrationService.selectShippingOption(r.id)];case 4:return o.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:return o.sent(),[3,7];case 6:throw i=o.sent(),new Error(i);case 7:return[2]}}))}))},e}();const Sc=Cc,Ic=cs((function(e){return new Sc(e,vc(e))}),[{id:"paypalcommerce"}]);var wc=function(){function e(e){this.scriptLoader=e,this.window=window}return e.prototype.getPayPalFastlaneSdk=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return this.window.paypalFastlaneSdk?[3,2]:(r=this.getPayPalFastlaneSdkConfiguration(e,t,n),[4,this.loadPayPalSdk(r)]);case 1:if(i.sent(),!this.window.paypalFastlaneSdk)throw new Ko;i.label=2;case 2:return[2,this.window.paypalFastlaneSdk]}}))}))},e.prototype.getPayPalApmsSdk=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return this.window.paypalApms?[3,2]:(n=this.getPayPalApmSdkConfiguration(e,t),[4,this.loadPayPalSdk(n)]);case 1:if(r.sent(),!this.window.paypalApms)throw new Ko;r.label=2;case 2:return[2,this.window.paypalApms]}}))}))},e.prototype.getPayPalMessages=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return this.window.paypalMessages?[3,2]:(n=this.getPayPalSdkMessagesConfiguration(e,t),[4,this.loadPayPalSdk(n)]);case 1:if(r.sent(),!this.window.paypalMessages)throw new Ko;r.label=2;case 2:return[2,this.window.paypalMessages]}}))}))},e.prototype.loadPayPalSdk=function(e){var t=e.options,n=e.attributes;return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return e=this.transformConfig(t),r=this.transformConfig(n),i=new URLSearchParams(e).toString(),a="https://www.paypal.com/sdk/js?"+i,[4,this.scriptLoader.loadScript(a,{async:!0,attributes:r})];case 1:return o.sent(),[2]}}))}))},e.prototype.getPayPalFastlaneSdkConfiguration=function(e,t,n){var r=e.clientToken,i=e.initializationData;if(!i||!i.clientId)throw new Wa(Ya.MissingPaymentMethod);var o=i.intent,a=i.clientId,s=i.merchantId,u=i.attributionId,c=i.connectClientToken;return{options:{"client-id":a,"merchant-id":s,commit:!0,components:["fastlane"],currency:t,intent:o},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":u,"data-user-id-token":c||r}}},e.prototype.getPayPalApmSdkConfiguration=function(e,t){var n=e.initializationData;if(!n||!n.clientId)throw new Wa(Ya.MissingPaymentMethod);var r=n.intent,i=n.clientId,a=n.merchantId,s=n.buyerCountry,u=n.attributionId,c=n.isDeveloperModeApplicable,d=n.availableAlternativePaymentMethods,l=void 0===d?[]:d,p=n.enabledAlternativePaymentMethods,h=void 0===p?[]:p,f=h,g=l.filter((function(e){return!h.includes(e)}));return{options:(0,o.__assign)({"client-id":i,"merchant-id":a,"enable-funding":f.length>0?f:void 0,"disable-funding":g.length>0?g:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:r},c&&{"buyer-country":s}),attributes:{"data-partner-attribution-id":u,"data-namespace":"paypalApms"}}},e.prototype.getPayPalSdkMessagesConfiguration=function(e,t){var n=e.initializationData;if(!n||!n.clientId)throw new Wa(Ya.MissingPaymentMethod);var r=n.clientId,i=n.merchantId,a=n.attributionId,s=n.isDeveloperModeApplicable,u=n.buyerCountry;return{options:(0,o.__assign)({"client-id":r,"merchant-id":i,components:["messages"],currency:t},s&&{"buyer-country":u}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}},e.prototype.transformConfig=function(e){var t={};return Object.keys(e).forEach((function(n){var r,i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=Array.isArray(i)?i.join(","):i,r)))})),t},e}();const Ec=wc;var bc=function(){function e(e,t,n){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t,this.paypalCommerceSdk=n}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.paypalcommercecredit,n=e.containerId,r=e.methodId,a=(i=t||{}).buyNowInitializeOptions,s=i.currencyCode,u=i.messagingContainerId,c=!!a,!r)throw new ja('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new ja('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new ja('Unable to initialize payment because "options.paypalcommercecredit" argument is not provided.');if(c&&!s)throw new ja('Unable to initialize payment because "options.paypalcommercecredit.currencyCode" argument is not provided.');if(c&&"function"!=typeof(null==a?void 0:a.getBuyNowCartRequestBody))throw new ja('Unable to initialize payment because "options.paypalcommercecredit.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');return c?[3,2]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return d=this.paymentIntegrationService.getState(),l=c?s:d.getCartOrThrow().currency.code,[4,this.paypalCommerceIntegrationService.loadPayPalSdk(r,l,!1)];case 3:return o.sent(),this.renderButton(n,r,t),l&&u?(p=d.getPaymentMethodOrThrow(r),[4,this.paypalCommerceSdk.getPayPalMessages(p,l)]):[3,5];case 4:h=o.sent(),this.renderMessages(h,u),o.label=5;case 5:return[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r,i=this,a=n.buyNowInitializeOptions,s=n.style,u=n.onComplete,c=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState(),l=(d.getPaymentMethodOrThrow(t).initializationData||{}).isHostedCheckoutEnabled,p={createOrder:function(){return i.paypalCommerceIntegrationService.createOrder("paypalcommercecredit")},onApprove:function(e){var n=e.orderID;return i.paypalCommerceIntegrationService.tokenizePayment(t,n)}},h={onClick:function(){return i.handleClick(a)},onCancel:function(){return i.paymentIntegrationService.loadDefaultCheckout()}},f=(null===(r=d.getStoreConfig())||void 0===r?void 0:r.checkoutSettings.features["PAYPAL-4387.paypal_shipping_callbacks"])?{onShippingAddressChange:function(e){return i.onShippingAddressChange(e)},onShippingOptionsChange:function(e){return i.onShippingOptionsChange(e)}}:{onShippingChange:function(e){return i.onShippingChange(e)}},g=(0,o.__assign)((0,o.__assign)({},f),{onApprove:function(e,n){return i.onHostedCheckoutApprove(e,n,t,u)}}),m=[c.FUNDING.PAYLATER,c.FUNDING.CREDIT],_=!1;m.forEach((function(t){if(!_){var n=(0,o.__assign)((0,o.__assign)((0,o.__assign)({fundingSource:t,style:i.paypalCommerceIntegrationService.getValidButtonStyle(s)},p),a&&h),l&&g),r=c.Buttons(n);r.isEligible()&&(r.render("#"+e),_=!0)}})),_||this.paypalCommerceIntegrationService.removeElement(e)},e.prototype.handleClick=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e?[4,this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e)]:[3,3];case 1:return t=n.sent(),[4,this.paymentIntegrationService.loadCheckout(t.id)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e.prototype.onHostedCheckoutApprove=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!e.orderID)throw new Wa(Ya.MissingOrderId);return i=this.paymentIntegrationService.getState(),a=i.getCartOrThrow(),[4,t.order.get()];case 1:s=o.sent(),o.label=2;case 2:return o.trys.push([2,9,,10]),u=this.paypalCommerceIntegrationService.getBillingAddressFromOrderDetails(s),[4,this.paymentIntegrationService.updateBillingAddress(u)];case 3:return o.sent(),a.lineItems.physicalItems.length>0?(c=this.paypalCommerceIntegrationService.getShippingAddressFromOrderDetails(s),[4,this.paymentIntegrationService.updateShippingAddress(c)]):[3,6];case 4:return o.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:o.sent(),o.label=6;case 6:return[4,this.paymentIntegrationService.submitOrder({},{params:{methodId:n}})];case 7:return o.sent(),[4,this.paypalCommerceIntegrationService.submitPayment(n,e.orderID)];case 8:return o.sent(),r&&"function"==typeof r&&r(),[2,!0];case 9:throw d=o.sent(),new Error(d);case 10:return[2]}}))}))},e.prototype.onShippingAddressChange=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:t=this.paypalCommerceIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state}),i.label=1;case 1:return i.trys.push([1,6,,7]),[4,this.paymentIntegrationService.updateBillingAddress(t)];case 2:return i.sent(),[4,this.paymentIntegrationService.updateShippingAddress(t)];case 3:return i.sent(),n=this.paypalCommerceIntegrationService.getShippingOptionOrThrow(),[4,this.paymentIntegrationService.selectShippingOption(n.id)];case 4:return i.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:return i.sent(),[3,7];case 6:throw r=i.sent(),new Error(r);case 7:return[2]}}))}))},e.prototype.onShippingOptionsChange=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:t=this.paypalCommerceIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id),r.label=1;case 1:return r.trys.push([1,4,,5]),[4,this.paymentIntegrationService.selectShippingOption(t.id)];case 2:return r.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 3:return r.sent(),[3,5];case 4:throw n=r.sent(),new Error(n);case 5:return[2]}}))}))},e.prototype.onShippingChange=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:n=this.paypalCommerceIntegrationService.getAddress({city:e.shipping_address.city,countryCode:e.shipping_address.country_code,postalCode:e.shipping_address.postal_code,stateOrProvinceCode:e.shipping_address.state}),o.label=1;case 1:return o.trys.push([1,6,,7]),[4,this.paymentIntegrationService.updateBillingAddress(n)];case 2:return o.sent(),[4,this.paymentIntegrationService.updateShippingAddress(n)];case 3:return o.sent(),r=this.paypalCommerceIntegrationService.getShippingOptionOrThrow(null===(t=e.selected_shipping_option)||void 0===t?void 0:t.id),[4,this.paymentIntegrationService.selectShippingOption(r.id)];case 4:return o.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:return o.sent(),[3,7];case 6:throw i=o.sent(),new Error(i);case 7:return[2]}}))}))},e.prototype.renderMessages=function(e,t){if(t&&document.getElementById(t)){var n={amount:this.paymentIntegrationService.getState().getCheckoutOrThrow().outstandingBalance,placement:"cart",style:{layout:"text"}};e.Messages(n).render("#"+t)}},e}();const Pc=bc,Ac=cs((function(e){return new Pc(e,vc(e),new Ec((0,ir.createScriptLoader)()))}),[{id:"paypalcommercecredit"}]);var Oc=function(){function e(e,t){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.paypalcommercevenmo,n=e.containerId,r=e.methodId,a=(i=t||{}).buyNowInitializeOptions,s=i.currencyCode,u=!!a,!r)throw new ja('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new ja('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new ja('Unable to initialize payment because "options.paypalcommercevenmo" argument is not provided.');if(u&&!s)throw new ja('Unable to initialize payment because "options.paypalcommercevenmo.currencyCode" argument is not provided.');if(u&&"function"!=typeof(null==a?void 0:a.getBuyNowCartRequestBody))throw new ja('Unable to initialize payment because "options.paypalcommercevenmo.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');return u?[3,2]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return c=u?s:this.paymentIntegrationService.getState().getCartOrThrow().currency.code,[4,this.paypalCommerceIntegrationService.loadPayPalSdk(r,c,!1)];case 3:return o.sent(),this.renderButton(n,r,t),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r=this,i=n.buyNowInitializeOptions,a=n.style,s=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow(),u=s.FUNDING.VENMO,c={createOrder:function(){return r.paypalCommerceIntegrationService.createOrder("paypalcommercevenmo")},onApprove:function(e){var n=e.orderID;return r.paypalCommerceIntegrationService.tokenizePayment(t,n)}},d={onClick:function(){return r.handleClick(i)},onCancel:function(){return r.paymentIntegrationService.loadDefaultCheckout()}},l=(0,o.__assign)((0,o.__assign)({fundingSource:u,style:this.getValidVenmoButtonStyles(a)},c),i&&d),p=s.Buttons(l);p.isEligible()?p.render("#"+e):this.paypalCommerceIntegrationService.removeElement(e)},e.prototype.getValidVenmoButtonStyles=function(e){var t=this.paypalCommerceIntegrationService.getValidButtonStyle(e);return t.color===cc.gold?(0,o.__assign)((0,o.__assign)({},t),{color:void 0}):t},e.prototype.handleClick=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e?[4,this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e)]:[3,3];case 1:return t=n.sent(),[4,this.paymentIntegrationService.loadCheckout(t.id)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e}();const Tc=Oc,Rc=cs((function(e){return new Tc(e,vc(e))}),[{id:"paypalcommercevenmo"}]);var kc=function(){function e(e,t){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.paypalcommercealternativemethods,n=e.containerId,r=e.methodId,a=(i=t||{}).apm,s=i.buyNowInitializeOptions,u=i.currencyCode,c=!!s,!r)throw new ja('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new ja('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new ja('Unable to initialize payment because "options.paypalcommercealternativemethods" argument is not provided.');if(!a)throw new ja('Unable to initialize payment because "options.paypalcommercealternativemethods.apm" argument is not provided.');if(c&&!u)throw new ja('Unable to initialize payment because "options.paypalcommercealternativemethods.currencyCode" argument is not provided.');if(c&&"function"!=typeof(null==s?void 0:s.getBuyNowCartRequestBody))throw new ja('Unable to initialize payment because "options.paypalcommercealternativemethods.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');return c?[3,2]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return d=c?u:this.paymentIntegrationService.getState().getCartOrThrow().currency.code,[4,this.paypalCommerceIntegrationService.loadPayPalSdk(r,d,!1)];case 3:return o.sent(),this.renderButton(n,r,t),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r=this,i=n.apm,a=n.buyNowInitializeOptions,s=n.style,u=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow();if(!Object.values(u.FUNDING).includes(i))throw new ja('Unable to initialize PayPal button because "options.paypalcommercealternativemethods.apm" argument is not valid funding source.');var c={createOrder:function(){return r.paypalCommerceIntegrationService.createOrder("paypalcommercealternativemethod")},onApprove:function(e){var n=e.orderID;return r.paypalCommerceIntegrationService.tokenizePayment(t,n)}},d={onClick:function(){return r.handleClick(a)},onCancel:function(){return r.paymentIntegrationService.loadDefaultCheckout()}},l=(0,o.__assign)((0,o.__assign)({fundingSource:i,style:this.paypalCommerceIntegrationService.getValidButtonStyle(s)},c),a&&d),p=u.Buttons(l);p.isEligible()?p.render("#"+e):this.paypalCommerceIntegrationService.removeElement(e)},e.prototype.handleClick=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e?[4,this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e)]:[3,3];case 1:return t=n.sent(),[4,this.paymentIntegrationService.loadCheckout(t.id)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e}();const Dc=kc,Mc=cs((function(e){return new Dc(e,vc(e))}),[{id:"paypalcommercealternativemethods"}]);var Nc,Lc,zc,Uc,Fc;!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(Nc||(Nc={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(Lc||(Lc={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black"}(zc||(zc={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(Uc||(Uc={})),function(e){e.PILL="pill",e.RECT="rect"}(Fc||(Fc={}));var Bc=function(){function e(e,t,n){this.paymentIntegrationService=e,this.paypalExpressScriptLoader=t,this.formPoster=n}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:if(t=this.paymentIntegrationService.getState(),n=t.getPaymentMethodOrThrow(e.methodId),!e.paypal)throw new ja;if(!n.config.merchantId)throw new Wa(Ya.MissingPaymentMethod);return[4,this.paypalExpressScriptLoader.loadPaypalSDK(n.config.merchantId)];case 1:return r=i.sent(),this.renderButton(e,r),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t){var n,r=this,i=e.containerId,o=e.methodId,a=e.paypal,s=a.allowCredit,u=a.clientId,c=a.onPaymentError,d=a.shouldProcessPayment,l=a.style,p=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!p.config.merchantId)throw new Wa(Ya.MissingPaymentMethod);var h=p.config.merchantId,f=p.config.testMode?"sandbox":"production",g=((n={})[f]=u,n),m=t.FUNDING.CREDIT||"credit",_=s?[m]:[],y=s?[]:[m];return t.Button.render({env:f,client:g,commit:d,funding:{allowed:_,disallowed:y},style:this.getStyle(l),payment:function(e,t){return r.setupPayment(h,t,c)},onAuthorize:function(e,t){return r.tokenizePayment(e,o,t,d)}},i)},e.prototype.getStyle=function(e){var t=e||{},n=t.color,r=t.fundingicons,i=t.label,o=t.layout,a=t.shape,s=t.size,u=t.tagline;return{color:n,fundingicons:r,label:i,layout:o,shape:a||Fc.RECT,size:"small"===s?Lc.RESPONSIVE:s,tagline:u}},e.prototype.setupPayment=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s;return(0,o.__generator)(this,(function(u){switch(u.label){case 0:if(!t)throw new Ja(Qa.CheckoutButtonNotInitialized);u.label=1;case 1:return u.trys.push([1,4,,5]),[4,this.paymentIntegrationService.loadDefaultCheckout()];case 2:return r=u.sent(),i=r.getCartOrThrow().id,a=r.getHost()||"",[4,t.request.post(a+"/api/storefront/payment/paypalexpress",{merchantId:e,cartId:i},{headers:(0,o.__assign)({"X-API-INTERNAL":ms},ys)})];case 3:return[2,u.sent().id];case 4:throw s=u.sent(),n&&n(s),s;case 5:return[2]}}))}))},e.prototype.tokenizePayment=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!n)throw new Ja(Qa.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new Wa(Ya.MissingPayment);return i=this.paymentIntegrationService.getState(),a=i.getPaymentMethodOrThrow(t),[4,n.payment.get(e.paymentID)];case 1:return s=o.sent(),[2,this.formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:a.id,action:r?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(s.payer.payer_info)})]}}))}))},e}();const qc=Bc;var xc=function(){function e(e){this.scriptLoader=e,this.window=window}return e.prototype.loadPaypalSDK=function(e){return void 0===e&&(e=""),(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return t=(0,o.__assign)({async:!0,attributes:{"data-merchant-id":e}},e&&{attributes:{"data-merchant-id":e}}),[4,this.scriptLoader.loadScript("//www.paypalobjects.com/api/checkout.min.js",t)];case 1:if(n.sent(),!this.window.paypal)throw new Ko;return[2,this.window.paypal]}}))}))},e}();const Gc=xc,Vc=cs((function(e){return new qc(e,new Gc((0,ir.getScriptLoader)()),(0,i.createFormPoster)())}),[{id:"paypalexpress"}]);function Hc(e){var t=null!=e?e:{},o=t.host,a=t.locale,s=void 0===a?"en":a,u=Wn({config:{meta:{host:null==e?void 0:e.host,locale:null==e?void 0:e.locale},errors:{},statuses:{}}}),c=(0,r.createRequestSender)({host:o}),d=(0,i.createFormPoster)({host:o}),l=function(e,t){void 0===t&&(t=n);for(var r=new Ha,i=function(t){if(!function(e){return"resolveIds"in e}(t))return"continue";for(var n=0,i=t.resolveIds;n<i.length;n++){var o=i[n];r.register(o,(function(){return t(e)}))}},o=0,a=Object.entries(t);o<a.length;o++)i(a[o][1]);return r}(function(e){var t=e.getState().config,n=t.getHost,i=t.getLocale,o=(0,r.createRequestSender)({host:n()}),a=new Lo(ko),s=new gr(new Sr(o),new br(new Ar(o)),new Nr(new zr(o))),u=new Er(new Sr(o)),c=new Ci(e),d=new Ii(new Pi(o),new Er(new Sr(o))),l=new ur(new lr(o),new bo(new Ao(o))),p=new so(new lo(o),new Sr(o)),h=new Jn(new rr(o)),f=new Oi(new Ti(function(e){var t=(0,Ri.createClient)();return e.subscribe((function(e){var n=e.config.getStoreConfig();n&&t.setHost(n.paymentSettings.bigpayBaseUrl)}),(function(e){return e.config.getStoreConfig()})),t}(e)),d,new Xi,new ei(si((0,ir.createScriptLoader)()))),g=new ei(si((0,ir.createScriptLoader)())),m=new Rr(new Dr(o),s,new mo(si((0,ir.createScriptLoader)()),new yo(o))),_=new Co(new Io(o)),y=si((0,ir.createScriptLoader)()),v=new yo(o),C=new mo(y,v),S=new hr(o),I=new $i,w=new po(new fo(o,{locale:i()}),e),E=new no(new io(o),s),b=new eo;return new Mo(e,a,s,u,c,d,l,p,h,f,g,m,S,_,C,I,w,E,b)}(u));return new Yo(u,new Wo(function(e,t,n,r,i){var o=new ra,a=(0,ir.getScriptLoader)(),s=new Sr(t),u=new gr(s,new br(new Ar(t)),new Nr(new zr(t))),c=new pa(new ta(a,window)),d=new hr(t);return o.register(Bi.BRAINTREE_PAYPAL,(function(){return new Ea(e,u,d,c,n,window)})),o.register(Bi.BRAINTREE_PAYPAL_CREDIT,(function(){return new ka(e,u,d,c,n,window)})),o.register(Bi.MASTERPASS,(function(){return new Na(e,u,new ga(a),r)})),o.register(Bi.PAYPALEXPRESS,(function(){return new za(e,u,new ma(a),n,i)})),o}(u,c,d,s,o),l,new Jn(new rr(c))))}module.exports=t})();
|
|
2
2
|
//# sourceMappingURL=checkout-button.js.map
|