@bigcommerce/checkout-sdk 1.934.0 → 1.934.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import{createRequestSender as e,createTimeout as t}from"@bigcommerce/request-sender";import{createFormPoster as n}from"@bigcommerce/form-poster";import{combineReducers as i,composeReducers as r,createAction as o,createDataStore as a,createErrorAction as s,deepFreeze as d}from"@bigcommerce/data-store";import{difference as c,filter as u,find as l,findIndex as h,flatMap as p,identity as g,includes as m,isArray as y,isEmpty as f,isEqual as _,isMatch as S,isNil as v,isObject as C,isPlainObject as I,keyBy as w,keys as E,last as b,map as P,max as O,memoize as A,noop as T,omit as k,omitBy as R,pick as D,pickBy as M,reduce as N,round as L,some as z,transform as U,uniq as F,uniqueId as B,values as x,without as q}from"lodash";import{Observable as j,Subject as G,concat as V,defer as H,empty as W,from as Y,fromEvent as K,merge as $,of as Z,throwError as J}from"rxjs";import{catchError as Q,delay as X,filter as ee,map as te,retryWhen as ne,shareReplay as ie,switchMap as re,take as oe}from"rxjs/operators";import{memoize as ae,memoizeOne as se}from"@bigcommerce/memoize";import{createSelector as de}from"reselect";import{ScriptLoader as ce,createScriptLoader as ue,getScriptLoader as le}from"@bigcommerce/script-loader";import{stringifyUrl as he}from"query-string";import{supportsPopups as pe}from"@braintree/browser-detection";import{createClient as ge}from"@bigcommerce/bigpay-client";import{creditCardType as me,number as ye}from"card-validator";import{default as fe}from"shallowequal";var _e={d:(e,t)=>{for(var n in t)_e.o(t,n)&&!_e.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},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})}},Se={};_e.r(Se),_e.d(Se,{createAmazonPayV2ButtonStrategy:()=>xr,createApplePayButtonStrategy:()=>So,createBigCommercePaymentsButtonStrategy:()=>Uo,createBigCommercePaymentsPayLaterButtonStrategy:()=>xo,createBigCommercePaymentsVenmoButtonStrategy:()=>Go,createBoltButtonStrategy:()=>Jo,createBraintreePaypalButtonStrategy:()=>ma,createBraintreePaypalCreditButtonStrategy:()=>_a,createBraintreeVenmoButtonStrategy:()=>Oa,createBraintreeVisaCheckoutButtonStrategy:()=>Ca,createGooglePayAdyenV2ButtonStrategy:()=>fs,createGooglePayAdyenV3ButtonStrategy:()=>_s,createGooglePayAuthorizeDotNetButtonStrategy:()=>vs,createGooglePayBigCommercePaymentsButtonStrategy:()=>ys,createGooglePayBraintreeButtonStrategy:()=>is,createGooglePayCheckoutComButtonStrategy:()=>bs,createGooglePayCybersourceButtonStrategy:()=>Os,createGooglePayOrbitalButtonStrategy:()=>Ts,createGooglePayPayPalCommerceButtonStrategy:()=>ls,createGooglePayStripeButtonStrategy:()=>Ks,createGooglePayTdOnlineMartButtonStrategy:()=>ed,createGooglePayWorldpayAccessButtonStrategy:()=>Zs,createLinkV2ButtonStrategy:()=>sc,createPayPalCommerceButtonStrategy:()=>Cd,createPayPalCommerceCreditButtonStrategy:()=>Ed,createPayPalCommerceVenmoButtonStrategy:()=>xd,createPaypalExpressButtonStrategy:()=>Zd});class ve extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}const Ce={body:{},headers:{},status:0};class Ie extends ve{constructor(e,{message:t,errors:n}={}){const{body:i,headers:r,status:o}=e||Ce;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=i,this.headers=r,this.status=o,this.errors=n||[]}}class we extends Ie{constructor(e){super(e,{message:"There is a problem processing your payment. Please try again later."}),this.name="PaymentMethodInvalidError",this.type="payment_method_invalid"}}class Ee extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}const be={body:{},headers:{},status:0};class Pe extends Ee{constructor(e,{message:t,errors:n}={}){const{body:i,headers:r,status:o}=e||be;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=i,this.headers=r,this.status=o,this.errors=n||[]}}class Oe extends Pe{constructor(e,t){super(e,{message:t||"An unexpected error has occurred. The checkout process cannot continue as a result."}),this.name="UnrecoverableError",this.type="unrecoverable"}}function Ae(e){return e.reduce((e,t)=>t?[...e,t]:e,[]).join(" ")}function Te(e,t){const{body:n}=e,{errors:i=[]}=n;return new Pe(e,{message:ke(i)||t,errors:i})}function ke(e){if(Array.isArray(e))return e.reduce((e,t)=>t&&t.message?[...e,t.message]:e,[]).join(" ")}class Re extends Pe{constructor(e){super(e,{message:"The request has timed out or aborted."}),this.name="TimeoutError",this.type="timeout"}}class De{constructor(){this._factoryMethods={},this.register("default",(e,t)=>new Pe(e,{message:t})),this.register("internal",(e,t)=>function(e,t){const{body:n}=e,{errors:i=[]}=n;return new Pe(e,{message:Ae(i)||n.detail||n.title||t,errors:i.length?i.map(e=>({code:n.type,message:e})):[{code:n.type,message:n.detail||n.title}]})}(e,t)),this.register("storefront",(e,t)=>function(e,t){const{body:n}=e;return new Pe(e,{message:t||n.detail||n.title,errors:[{code:n.code||n.type,message:n.detail||n.title}]})}(e,t)),this.register("payment",(e,t)=>Te(e,t)),this.register("timeout",e=>new Re(e))}register(e,t){this._factoryMethods[e]=t}createError(e,t){return(this._factoryMethods[this._getType(e)]||this._factoryMethods.default)(e,t)}_getType(e){if(0===e.status)return"timeout";if(this._isStorefrontErrorResponseBody(e.body))return"storefront";if(this._isInternalErrorResponseBody(e.body)){const t=b(e.body.type.split("/"));return t&&this._factoryMethods[t]?t:"internal"}const t=b(e.body&&e.body.errors);return t&&t.code&&this._factoryMethods[t.code]?t.code:"payment"}_isStorefrontErrorResponseBody(e){const t=e;return!this._isInternalErrorResponseBody(e)&&"string"==typeof t.title&&"string"==typeof t.type&&"number"==typeof t.status&&"string"==typeof t.detail}_isInternalErrorResponseBody(e){const t=e;return"object"==typeof t.errors&&"string"==typeof t.title&&"string"==typeof t.type&&"number"==typeof t.status}}function Me(e,t){return Array.isArray(e)?e.map(e=>Me(e,t)):I(e)?U(R(e,t),(e,n,i)=>{e[i]=Me(n,t)},{}):e}var Ne,Le;function ze(e,t){return function(e){return e.type===Ne.ClearError}(t)?Me(e,e=>e===t.payload):e}function Ue(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(let i=0,r=e.length;i<r;i++)if(!Ue(e[i],t[i],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){const i=n&&n.keyFilter,r=i?Object.keys(e).filter(i):Object.keys(e),o=i?Object.keys(t).filter(i):Object.keys(t);if(r.length!==o.length)return!1;for(let i=0,o=r.length;i<o;i++){const o=r[i];if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Ue(e[o],t[o],n))return!1}return!0}(e,t,n))):e===t)}function Fe(e,t,n){return e&&Object.prototype.hasOwnProperty.call(e,t)&&Ue(e[t],n)?e:Object.assign(Object.assign({},e),{[t]:n})}!function(e){e.ClearError="CLEAR_ERROR"}(Ne||(Ne={})),function(e){e.LoadB2BTokenRequested="LOAD_B2B_TOKEN_REQUESTED",e.LoadB2BTokenSucceeded="LOAD_B2B_TOKEN_SUCCEEDED",e.LoadB2BTokenFailed="LOAD_B2B_TOKEN_FAILED"}(Le||(Le={}));const Be={errors:{},statuses:{}};function xe(e=Be,t){return i({data:qe,errors:r(je,ze),statuses:Ge})(e,t)}function qe(e,t){return t.type===Le.LoadB2BTokenSucceeded?t.payload:e}function je(e=Be.errors,t){switch(t.type){case Le.LoadB2BTokenRequested:case Le.LoadB2BTokenSucceeded:return Fe(e,"loadError",void 0);case Le.LoadB2BTokenFailed:return Fe(e,"loadError",t.payload);default:return e}}function Ge(e=Be.statuses,t){switch(t.type){case Le.LoadB2BTokenRequested:return Fe(e,"isLoading",!0);case Le.LoadB2BTokenFailed:case Le.LoadB2BTokenSucceeded:return Fe(e,"isLoading",!1);default:return e}}var Ve,He,We,Ye;function Ke(e,t){return void 0===t||Ue(e,t)?e:t}!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",e.DeleteCheckoutRequested="DELETE_CHECKOUT_REQUESTED",e.DeleteCheckoutSucceeded="DELETE_CHECKOUT_SUCCEEDED",e.DeleteCheckoutFailed="DELETE_CHECKOUT_FAILED"}(Ve||(Ve={})),function(e){e.HydrateInitialState="HYDRATE_INITIAL_STATE"}(He||(He={})),function(e){e.UpdateSubscriptionsRequested="UPDATE_SUBSCRIPTIONS_REQUESTED",e.UpdateSubscriptionsSucceeded="UPDATE_SUBSCRIPTIONS_SUCCEEDED",e.UpdateSubscriptionsFailed="UPDATE_SUBSCRIPTIONS_FAILED"}(We||(We={})),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"}(Ye||(Ye={}));const $e={errors:{},statuses:{}};function Ze(e=$e,t){return i({data:Je,errors:r(Qe,ze),statuses:Xe})(e,t)}function Je(e,t){var n,i;switch(t.type){case Ye.UpdateBillingAddressSucceeded:case Ye.ContinueAsGuestSucceeded:case Ve.LoadCheckoutSucceeded:return Ke(e,t.payload&&t.payload.billingAddress);case He.HydrateInitialState:return Ke(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.billingAddress);default:return e}}function Qe(e=$e.errors,t){switch(t.type){case Ve.LoadCheckoutRequested:case Ve.LoadCheckoutSucceeded:return Fe(e,"loadError",void 0);case Ve.LoadCheckoutFailed:return Fe(e,"loadError",t.payload);case Ye.UpdateBillingAddressRequested:case Ye.UpdateBillingAddressSucceeded:return Fe(e,"updateError",void 0);case Ye.UpdateBillingAddressFailed:return Fe(e,"updateError",t.payload);case We.UpdateSubscriptionsRequested:case We.UpdateSubscriptionsSucceeded:case Ye.ContinueAsGuestRequested:case Ye.ContinueAsGuestSucceeded:return Fe(e,"continueAsGuestError",void 0);case We.UpdateSubscriptionsFailed:case Ye.ContinueAsGuestFailed:return Fe(e,"continueAsGuestError",t.payload);default:return e}}function Xe(e=$e.statuses,t){switch(t.type){case Ve.LoadCheckoutRequested:return Fe(e,"isLoading",!0);case Ve.LoadCheckoutSucceeded:case Ve.LoadCheckoutFailed:return Fe(e,"isLoading",!1);case Ye.UpdateBillingAddressRequested:return Fe(e,"isUpdating",!0);case Ye.UpdateBillingAddressFailed:case Ye.UpdateBillingAddressSucceeded:return Fe(e,"isUpdating",!1);case Ye.ContinueAsGuestRequested:case We.UpdateSubscriptionsRequested:return Fe(e,"isContinuingAsGuest",!0);case We.UpdateSubscriptionsSucceeded:case We.UpdateSubscriptionsFailed:case Ye.ContinueAsGuestFailed:case Ye.ContinueAsGuestSucceeded:return Fe(e,"isContinuingAsGuest",!1);default:return e}}function et(e){return I(e)}const tt=function e(t,n,i){const{matchObject:r=(e,t)=>void 0!==e.id&&e.id===t.id}=i||{};if(!t)return n;if(!n||t===n)return t;let o=0,a=0;const s=(e,t,n)=>(o+=e===t?1:0,a+=e===n?1:0,e),d=n.map((n,i)=>{const o=t&&t[i];return et(o)&&et(n)?r(o,n)?s(nt(o,n),o,n):s(Ke(o,n),o,n):y(o)&&y(n)?s(e(o,n),o,n):s(Ke(o,n),o,n)});return o===n.length&&t&&t.length===n.length?t:a===n.length?n:d},nt=function e(t,n){return t?n&&t!==n?Object.keys(n).reduce((t,i)=>{const r=t[i],o=n[i];return et(r)&&et(o)?Fe(t,i,e(r,o)):y(r)&&y(o)?Fe(t,i,tt(r,o)):Fe(t,i,o)},t):t:n};var it,rt,ot;!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"}(it||(it={})),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"}(rt||(rt={})),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"}(ot||(ot={}));const at={errors:{},statuses:{}};function st(e=at,t){return i({data:dt,errors:r(ut,ze),statuses:ct})(e,t)}function dt(e,t){var n,i;switch(t.type){case Ye.UpdateBillingAddressSucceeded:case Ve.LoadCheckoutSucceeded:case ot.CreateConsignmentsSucceeded:case ot.DeleteConsignmentSucceeded:case ot.UpdateConsignmentSucceeded:case ot.UpdateShippingOptionSucceeded:case ot.LoadShippingOptionsSucceeded:case it.ApplyCouponSucceeded:case it.RemoveCouponSucceeded:case rt.ApplyGiftCertificateSucceeded:case rt.RemoveGiftCertificateSucceeded:return nt(e,t.payload&&t.payload.cart);case He.HydrateInitialState:return nt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.cart);case Ve.DeleteCheckoutSucceeded:return;default:return e}}function ct(e=at.statuses,t){switch(t.type){case Ve.LoadCheckoutRequested:return Fe(e,"isLoading",!0);case Ve.LoadCheckoutFailed:case Ve.LoadCheckoutSucceeded:return Fe(e,"isLoading",!1);default:return e}}function ut(e=at.errors,t){switch(t.type){case Ve.LoadCheckoutRequested:case Ve.LoadCheckoutSucceeded:return Fe(e,"loadError",void 0);case Ve.LoadCheckoutFailed:return Fe(e,"loadError",t.payload);default:return e}}var lt;!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"}(lt||(lt={}));const ht={data:{},errors:{},statuses:{}},pt={initializedContainers:{}},gt={},mt={};function yt(e=ht,t){return t.meta&&t.meta.methodId?i({data:i({[t.meta.methodId]:ft}),errors:i({[t.meta.methodId]:_t}),statuses:i({[t.meta.methodId]:St})})(e,t):e}function ft(e=pt,t){switch(t.type){case lt.InitializeButtonSucceeded:return t.meta&&t.meta.containerId?nt(e,{initializedContainers:{[t.meta.containerId]:!0}}):e;case lt.DeinitializeButtonSucceeded:return Fe(e,"initializedContainers",{})}return e}function _t(e=gt,t){switch(t.type){case lt.InitializeButtonRequested:case lt.InitializeButtonSucceeded:return Fe(e,"initializeError",void 0);case lt.InitializeButtonFailed:return Fe(e,"initializeError",t.payload);case lt.DeinitializeButtonRequested:case lt.DeinitializeButtonSucceeded:return Fe(e,"deinitializeError",void 0);case lt.DeinitializeButtonFailed:return Fe(e,"deinitializeError",t.payload);default:return e}}function St(e=mt,t){switch(t.type){case lt.InitializeButtonRequested:return Fe(e,"isInitializing",!0);case lt.InitializeButtonFailed:case lt.InitializeButtonSucceeded:return Fe(e,"isInitializing",!1);case lt.DeinitializeButtonRequested:return Fe(e,"isDeinitializing",!0);case lt.DeinitializeButtonFailed:case lt.DeinitializeButtonSucceeded:return Fe(e,"isDeinitializing",!1);default:return e}}var vt;!function(e){e.LoadConfigRequested="LOAD_CONFIG_REQUESTED",e.LoadConfigSucceeded="LOAD_CONFIG_SUCCEEDED",e.LoadConfigFailed="LOAD_CONFIG_FAILED"}(vt||(vt={}));const Ct={meta:{},errors:{},statuses:{}};function It(e=Ct,t){return i({data:wt,errors:r(Et,ze),statuses:bt})(e,t)}function wt(e,t){var n,i;switch(t.type){case vt.LoadConfigSucceeded:return nt(e,t.payload);case He.HydrateInitialState:{const r=nt(e,null===(n=t.payload)||void 0===n?void 0:n.config);return r&&(null===(i=t.payload)||void 0===i?void 0:i.b2bApiSettings)?Object.assign(Object.assign({},r),{storeConfig:Object.assign(Object.assign({},r.storeConfig),{b2bApiSettings:t.payload.b2bApiSettings})}):r}default:return e}}function Et(e=Ct.errors,t){switch(t.type){case vt.LoadConfigSucceeded:return Fe(e,"loadError",void 0);case vt.LoadConfigFailed:return Fe(e,"loadError",t.payload);default:return e}}function bt(e=Ct.statuses,t){switch(t.type){case vt.LoadConfigRequested:return Fe(e,"isLoading",!0);case vt.LoadConfigSucceeded:case vt.LoadConfigFailed:return Fe(e,"isLoading",!1);default:return e}}var Pt;!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"}(Pt||(Pt={}));const Ot={errors:{},statuses:{}};function At(e=Ot,t){return i({data:Tt,errors:r(kt,ze),statuses:Rt})(e,t)}function Tt(e,t){var n,i;switch(t.type){case Ve.LoadCheckoutSucceeded:case it.ApplyCouponSucceeded:case ot.UpdateShippingOptionSucceeded:case it.RemoveCouponSucceeded:case Pt.LoadOrderSucceeded:return tt(e,t.payload&&t.payload.coupons);case He.HydrateInitialState:return tt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.coupons);default:return e}}function kt(e={},t){switch(t.type){case it.ApplyCouponRequested:case it.ApplyCouponSucceeded:return Fe(e,"applyCouponError",void 0);case it.ApplyCouponFailed:return Fe(e,"applyCouponError",t.payload);case it.RemoveCouponRequested:case it.RemoveCouponSucceeded:return Fe(e,"removeCouponError",void 0);case it.RemoveCouponFailed:return Fe(e,"removeCouponError",t.payload);default:return e}}function Rt(e={},t){switch(t.type){case it.ApplyCouponRequested:return Fe(e,"isApplyingCoupon",!0);case it.ApplyCouponSucceeded:case it.ApplyCouponFailed:return Fe(e,"isApplyingCoupon",!1);case it.RemoveCouponRequested:return Fe(e,"isRemovingCoupon",!0);case it.RemoveCouponSucceeded:case it.RemoveCouponFailed:return Fe(e,"isRemovingCoupon",!1);default:return e}}const Dt={errors:{},statuses:{}};function Mt(e=Dt,t){return i({data:Nt,errors:r(Lt,ze),statuses:zt})(e,t)}function Nt(e,t){var n,i;switch(t.type){case Ve.LoadCheckoutSucceeded:case ot.CreateConsignmentsSucceeded:case ot.UpdateConsignmentSucceeded:case ot.DeleteConsignmentSucceeded:case ot.UpdateShippingOptionSucceeded:case it.ApplyCouponSucceeded:case it.RemoveCouponSucceeded:case rt.ApplyGiftCertificateSucceeded:case rt.RemoveGiftCertificateSucceeded:return tt(e,t.payload&&t.payload.giftCertificates);case He.HydrateInitialState:return tt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.giftCertificates);default:return e}}function Lt(e=Dt.errors,t){switch(t.type){case rt.ApplyGiftCertificateRequested:case rt.ApplyGiftCertificateSucceeded:return Fe(e,"applyGiftCertificateError",void 0);case rt.ApplyGiftCertificateFailed:return Fe(e,"applyGiftCertificateError",t.payload);case rt.RemoveGiftCertificateRequested:case rt.RemoveGiftCertificateSucceeded:return Fe(e,"removeGiftCertificateError",void 0);case rt.RemoveGiftCertificateFailed:return Fe(e,"removeGiftCertificateError",t.payload);default:return e}}function zt(e=Dt.statuses,t){switch(t.type){case rt.ApplyGiftCertificateRequested:return Fe(e,"isApplyingGiftCertificate",!0);case rt.ApplyGiftCertificateSucceeded:case rt.ApplyGiftCertificateFailed:return Fe(e,"isApplyingGiftCertificate",!1);case rt.RemoveGiftCertificateRequested:return Fe(e,"isRemovingGiftCertificate",!0);case rt.RemoveGiftCertificateSucceeded:case rt.RemoveGiftCertificateFailed:return Fe(e,"isRemovingGiftCertificate",!1);default:return e}}var Ut;!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"}(Ut||(Ut={}));const Ft={errors:{},statuses:{}};function Bt(e=Ft,t){return i({data:xt,errors:r(qt,ze),statuses:jt})(e,t)}function xt(e,t){var n,i;switch(t.type){case Ye.ContinueAsGuestSucceeded:case Ve.LoadCheckoutSucceeded:return nt(e,t.payload&&t.payload.customer);case Ut.CreateCustomerAddressSucceeded:return nt(e,t.payload);case He.HydrateInitialState:return nt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.customer);default:return e}}function qt(e=Ft.errors,t){switch(t.type){case Ut.CreateCustomerRequested:case Ut.CreateCustomerSucceeded:return Fe(e,"createError",void 0);case Ut.CreateCustomerFailed:return Fe(e,"createError",t.payload);case Ut.CreateCustomerAddressRequested:case Ut.CreateCustomerAddressSucceeded:return Fe(e,"createAddressError",void 0);case Ut.CreateCustomerAddressFailed:return Fe(e,"createAddressError",t.payload);default:return e}}function jt(e=Ft.statuses,t){switch(t.type){case Ut.CreateCustomerRequested:return Fe(e,"isCreating",!0);case Ut.CreateCustomerFailed:case Ut.CreateCustomerSucceeded:return Fe(e,"isCreating",!1);case Ut.CreateCustomerAddressRequested:return Fe(e,"isCreatingAddress",!0);case Ut.CreateCustomerAddressFailed:case Ut.CreateCustomerAddressSucceeded:return Fe(e,"isCreatingAddress",!1);default:return e}}var Gt;!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"}(Gt||(Gt={}));const Vt={data:{},errors:{},statuses:{}};function Ht(e=Vt,t){return i({data:Wt,errors:r(Yt,ze),statuses:Kt})(e,t)}function Wt(e=Vt.data,t){switch(t.type){case Gt.InitializeSucceeded:return nt(e,{[t.meta&&t.meta.methodId]:{isInitialized:!0}});case Gt.DeinitializeSucceeded:return nt(e,{[t.meta&&t.meta.methodId]:{isInitialized:!1}})}return e}function Yt(e=Vt.errors,t){switch(t.type){case Gt.InitializeRequested:case Gt.InitializeSucceeded:return nt(e,{initializeErrors:Object.assign({},e.initializeErrors),initializeMethodId:e.initializeMethodId?e.initializeMethodId:void 0});case Gt.InitializeFailed:return nt(e,{initializeErrors:Object.assign(Object.assign({},e.initializeErrors),{[t.meta&&t.meta.methodId]:t.payload}),initializeMethodId:t.meta&&t.meta.methodId});case Gt.DeinitializeRequested:case Gt.DeinitializeSucceeded:return nt(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case Gt.DeinitializeFailed:return nt(e,{deinitializeError:t.payload,deinitializeMethodId:t.meta&&t.meta.methodId});case Gt.SignInRequested:case Gt.SignInSucceeded:return nt(e,{signInError:void 0,signInMethodId:void 0});case Gt.SignInFailed:return nt(e,{signInError:t.payload,signInMethodId:t.meta&&t.meta.methodId});case Gt.SignOutRequested:case Gt.SignOutSucceeded:return nt(e,{signOutError:void 0,signOutMethodId:void 0});case Gt.SignOutFailed:return nt(e,{signOutError:t.payload,signOutMethodId:t.meta&&t.meta.methodId});case Gt.ExecutePaymentMethodCheckoutRequested:case Gt.ExecutePaymentMethodCheckoutSucceeded:return nt(e,{executePaymentMethodCheckoutError:void 0,executePaymentMethodCheckoutMethodId:void 0});case Gt.ExecutePaymentMethodCheckoutFailed:return nt(e,{executePaymentMethodCheckoutError:t.payload,executePaymentMethodCheckoutMethodId:t.meta&&t.meta.methodId});case Gt.WidgetInteractionStarted:case Gt.WidgetInteractionFinished:return nt(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case Gt.WidgetInteractionFailed:return nt(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta.methodId});default:return e}}function Kt(e=Vt.statuses,t){switch(t.type){case Gt.InitializeRequested:return nt(e,{isInitializing:!0,initializeMethodId:t.meta&&t.meta.methodId});case Gt.InitializeFailed:case Gt.InitializeSucceeded:return nt(e,{isInitializing:!1,initializeMethodId:void 0});case Gt.DeinitializeRequested:return nt(e,{isDeinitializing:!0,deinitializeMethodId:t.meta&&t.meta.methodId});case Gt.DeinitializeFailed:case Gt.DeinitializeSucceeded:return nt(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case Gt.SignInRequested:return nt(e,{isSigningIn:!0,signInMethodId:t.meta&&t.meta.methodId});case Gt.SignInFailed:case Gt.SignInSucceeded:return nt(e,{isSigningIn:!1,signInMethodId:void 0});case Gt.SignOutRequested:return nt(e,{isSigningOut:!0,signOutMethodId:t.meta&&t.meta.methodId});case Gt.SignOutFailed:case Gt.SignOutSucceeded:return nt(e,{isSigningOut:!1,signOutMethodId:void 0});case Gt.ExecutePaymentMethodCheckoutRequested:return nt(e,{isExecutingPaymentMethodCheckout:!0,executePaymentMethodCheckoutMethodId:t.meta&&t.meta.methodId});case Gt.ExecutePaymentMethodCheckoutFailed:case Gt.ExecutePaymentMethodCheckoutSucceeded:return nt(e,{isExecutingPaymentMethodCheckout:!1,executePaymentMethodCheckoutMethodId:void 0});case Gt.WidgetInteractionStarted:return nt(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta.methodId});case Gt.WidgetInteractionFinished:case Gt.WidgetInteractionFailed:return nt(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}var $t;!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"}($t||($t={}));const Zt={errors:{},statuses:{}};function Jt(e=Zt,t){return i({data:Qt,errors:r(Xt,ze),statuses:en})(e,t)}function Qt(e,t){var n;return t.type===$t.LoadExtensionsSucceeded?tt(e,t.payload):t.type===He.HydrateInitialState?tt(e,null===(n=t.payload)||void 0===n?void 0:n.extensions):e}function Xt(e=Zt.errors,t){switch(t.type){case $t.LoadExtensionsRequested:case $t.LoadExtensionsSucceeded:return Fe(e,"loadError",void 0);case $t.RenderExtensionRequested:case $t.RenderExtensionSucceeded:return Fe(e,"renderError",void 0);case $t.LoadExtensionsFailed:return Fe(e,"loadError",t.payload);case $t.RenderExtensionFailed:return Fe(e,"renderError",t.payload);default:return e}}function en(e=Zt.statuses,t){switch(t.type){case $t.LoadExtensionsRequested:return Fe(e,"isLoading",!0);case $t.LoadExtensionsSucceeded:case $t.LoadExtensionsFailed:return Fe(e,"isLoading",!1);default:return e}}var tn;!function(e){e.LoadFormFieldsRequested="LOAD_FORM_FIELDS_REQUESTED",e.LoadFormFieldsSucceeded="LOAD_FORM_FIELDS_SUCCEEDED",e.LoadFormFieldsFailed="LOAD_FORM_FIELDS_FAILED"}(tn||(tn={}));const nn={errors:{},statuses:{}};function rn(e=nn,t){return i({data:on,extraFields:an,errors:r(sn,ze),statuses:dn})(e,t)}function on(e,t){var n;switch(t.type){case tn.LoadFormFieldsSucceeded:return nt(e,t.payload);case He.HydrateInitialState:return nt(e,null===(n=t.payload)||void 0===n?void 0:n.formFields);default:return e}}function an(e,t){var n,i;return t.type===He.HydrateInitialState&&null!==(i=null===(n=t.payload)||void 0===n?void 0:n.extraFields)&&void 0!==i?i:e}function sn(e=nn.errors,t){switch(t.type){case tn.LoadFormFieldsSucceeded:return Fe(e,"loadError",void 0);case tn.LoadFormFieldsFailed:return Fe(e,"loadError",t.payload);default:return e}}function dn(e=nn.statuses,t){switch(t.type){case tn.LoadFormFieldsRequested:return Fe(e,"isLoading",!0);case tn.LoadFormFieldsSucceeded:case tn.LoadFormFieldsFailed:return Fe(e,"isLoading",!1);default:return e}}var cn;!function(e){e.LoadCountriesRequested="LOAD_COUNTRIES_REQUESTED",e.LoadCountriesSucceeded="LOAD_COUNTRIES_SUCCEEDED",e.LoadCountriesFailed="LOAD_COUNTRIES_FAILED"}(cn||(cn={}));const un={errors:{},statuses:{}};function ln(e=un,t){return i({data:hn,errors:r(pn,ze),statuses:gn})(e,t)}function hn(e,t){return t.type===cn.LoadCountriesSucceeded?tt(e,t.payload):e}function pn(e=un.errors,t){switch(t.type){case cn.LoadCountriesRequested:case cn.LoadCountriesSucceeded:return Fe(e,"loadError",void 0);case cn.LoadCountriesFailed:return Fe(e,"loadError",t.payload);default:return e}}function gn(e=un.statuses,t){switch(t.type){case cn.LoadCountriesRequested:return Fe(e,"isLoading",!0);case cn.LoadCountriesSucceeded:case cn.LoadCountriesFailed:return Fe(e,"isLoading",!1);default:return e}}const mn={errors:{},meta:{},statuses:{}};function yn(e=mn,t){return i({data:fn,errors:r(Sn,ze),meta:_n,statuses:vn})(e,t)}function fn(e,t){switch(t.type){case Pt.LoadOrderSucceeded:case Pt.LoadOrderPaymentsSucceeded:return nt(e,k(t.payload,["billingAddress","coupons"]));default:return e}}function _n(e,t){switch(t.type){case Pt.FinalizeOrderSucceeded:case Pt.SubmitOrderSucceeded:return nt(e,Object.assign(Object.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 Sn(e=mn.errors,t){switch(t.type){case Pt.LoadOrderRequested:case Pt.LoadOrderSucceeded:case Pt.LoadOrderPaymentsSucceeded:case Pt.LoadOrderPaymentsRequested:return Fe(e,"loadError",void 0);case Pt.LoadOrderFailed:case Pt.LoadOrderPaymentsFailed:return Fe(e,"loadError",t.payload);default:return e}}function vn(e=mn.statuses,t){switch(t.type){case Pt.LoadOrderRequested:case Pt.LoadOrderPaymentsRequested:return Fe(e,"isLoading",!0);case Pt.LoadOrderSucceeded:case Pt.LoadOrderFailed:case Pt.LoadOrderPaymentsSucceeded:case Pt.LoadOrderPaymentsFailed:return Fe(e,"isLoading",!1);default:return e}}const Cn={};function In(e=Cn,t){return i({data:wn})(e,t)}function wn(e,t){switch(t.type){case Pt.LoadOrderPaymentsSucceeded:case Pt.LoadOrderSucceeded:return Ke(e,t.payload&&t.payload.billingAddress);default:return e}}var En;!function(e){e.PersistB2BMetadataRequested="PERSIST_B2B_METADATA_REQUESTED",e.PersistB2BMetadataSucceeded="PERSIST_B2B_METADATA_SUCCEEDED",e.PersistB2BMetadataFailed="PERSIST_B2B_METADATA_FAILED"}(En||(En={}));const bn={errors:{},statuses:{}};function Pn(e=bn,t){return i({data:On,errors:r(An,ze),statuses:Tn})(e,t)}function On(e,t){return t.type===En.PersistB2BMetadataSucceeded?t.payload:e}function An(e=bn.errors,t){switch(t.type){case En.PersistB2BMetadataRequested:case En.PersistB2BMetadataSucceeded:return Fe(e,"persistB2bMetadataError",void 0);case En.PersistB2BMetadataFailed:return Fe(e,"persistB2bMetadataError",t.payload);default:return e}}function Tn(e=bn.statuses,t){switch(t.type){case En.PersistB2BMetadataRequested:return Fe(e,"isPersisting",!0);case En.PersistB2BMetadataFailed:case En.PersistB2BMetadataSucceeded:return Fe(e,"isPersisting",!1);default:return e}}var kn,Rn;function Dn(e={},t){return i({data:Mn})(e,t)}function Mn(e,t){return t.type===kn.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"}(kn||(kn={})),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"}(Rn||(Rn={}));const Nn={errors:{},statuses:{}};function Ln(e=Nn,t){return i({data:zn,errors:r(Fn,ze),meta:Un,statuses:Bn})(e,t)}function zn(e,t){switch(t.type){case Rn.LoadPaymentMethodSucceeded:return function(e,t,n){if(!t)return e;const i=D(t,"id"),r="object"==typeof n?M(n):n||i,o=h(e,r),a=[...e];if(-1===o)a.push(t);else{const n=e[o];a[o]=et(n)&&et(t)?nt(n,t):t}return a}(e||[],t.payload,t.payload&&{id:t.payload.id,gateway:t.payload.gateway});case Rn.LoadPaymentMethodsSucceeded:return tt(e,t.payload,{matchObject:(e,t)=>e.id===t.id&&e.gateway===t.gateway});default:return e}}function Un(e,t){return t.type===Rn.LoadPaymentMethodsSucceeded?nt(e,t.meta):e}function Fn(e=Nn.errors,t){switch(t.type){case Rn.LoadPaymentMethodsRequested:case Rn.LoadPaymentMethodsSucceeded:return Fe(e,"loadError",void 0);case Rn.LoadPaymentMethodsFailed:return Fe(e,"loadError",t.payload);case Rn.LoadPaymentMethodRequested:case Rn.LoadPaymentMethodSucceeded:return nt(e,{loadMethodId:void 0,loadMethodError:void 0});case Rn.LoadPaymentMethodFailed:return nt(e,{loadMethodId:t.meta.methodId,loadMethodError:t.payload});default:return e}}function Bn(e=Nn.statuses,t){switch(t.type){case Rn.LoadPaymentMethodsRequested:return Fe(e,"isLoading",!0);case Rn.LoadPaymentMethodsSucceeded:case Rn.LoadPaymentMethodsFailed:return Fe(e,"isLoading",!1);case Rn.LoadPaymentMethodRequested:return nt(e,{isLoadingMethod:!0,loadMethodId:t.meta.methodId});case Rn.LoadPaymentMethodSucceeded:case Rn.LoadPaymentMethodFailed:return nt(e,{isLoadingMethod:!1,loadMethodId:void 0});default:return e}}var xn;!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"}(xn||(xn={}));const qn={data:{},errors:{},statuses:{}};function jn(e=qn,t){return i({data:Gn,errors:r(Vn,ze),statuses:Hn})(e,t)}function Gn(e=qn.data,t){switch(t.type){case xn.InitializeSucceeded:if(t.meta){const{methodId:n,gatewayId:i}=t.meta,r=i?`${n}.${i}`:n;return nt(e,{[r]:{isInitialized:!0}})}break;case xn.DeinitializeSucceeded:if(t.meta){const{methodId:n,gatewayId:i}=t.meta,r=i?`${n}.${i}`:n;return nt(e,{[r]:{isInitialized:!1}})}}return e}function Vn(e=qn.errors,t){switch(t.type){case xn.InitializeRequested:case xn.InitializeSucceeded:return nt(e,{initializeError:void 0,initializeMethodId:void 0});case xn.InitializeFailed:{let n=t.meta&&t.meta.methodId;if(t.meta){const{methodId:e,gatewayId:i}=t.meta;n=i?`${e}.${i}`:e}return nt(e,{initializeError:t.payload,initializeMethodId:n})}case xn.DeinitializeRequested:case xn.DeinitializeSucceeded:return nt(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case xn.DeinitializeFailed:{let n=t.meta&&t.meta.methodId;if(t.meta){const{methodId:e,gatewayId:i}=t.meta;n=i?`${e}.${i}`:e}return nt(e,{deinitializeError:t.payload,deinitializeMethodId:n})}case xn.ExecuteRequested:case xn.ExecuteSucceeded:return nt(e,{executeError:void 0,executeMethodId:void 0});case xn.ExecuteFailed:return nt(e,{executeError:t.payload,executeMethodId:t.meta&&t.meta.methodId});case xn.FinalizeRequested:case xn.FinalizeSucceeded:return nt(e,{finalizeError:void 0,finalizeMethodId:void 0});case xn.FinalizeFailed:return nt(e,{finalizeError:t.payload,finalizeMethodId:t.meta&&t.meta.methodId});case xn.WidgetInteractionStarted:case xn.WidgetInteractionFinished:return nt(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case xn.WidgetInteractionFailed:return nt(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta.methodId});default:return e}}function Hn(e=qn.statuses,t){switch(t.type){case xn.InitializeRequested:{let n=t.meta&&t.meta.methodId;if(t.meta){const{methodId:e,gatewayId:i}=t.meta;n=i?`${e}.${i}`:e}return nt(e,{isInitializing:!0,initializeMethodId:n})}case xn.InitializeFailed:case xn.InitializeSucceeded:return nt(e,{isInitializing:!1,initializeMethodId:void 0});case xn.DeinitializeRequested:{let n=t.meta&&t.meta.methodId;if(t.meta){const{methodId:e,gatewayId:i}=t.meta;n=i?`${e}.${i}`:e}return nt(e,{isDeinitializing:!0,deinitializeMethodId:n})}case xn.DeinitializeFailed:case xn.DeinitializeSucceeded:return nt(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case xn.ExecuteRequested:return nt(e,{isExecuting:!0,executeMethodId:t.meta&&t.meta.methodId});case xn.ExecuteFailed:case xn.ExecuteSucceeded:return nt(e,{isExecuting:!1,executeMethodId:void 0});case xn.FinalizeRequested:return nt(e,{isFinalizing:!0,finalizeMethodId:t.meta&&t.meta.methodId});case xn.FinalizeFailed:case xn.FinalizeSucceeded:return nt(e,{isFinalizing:!1,finalizeMethodId:void 0});case xn.WidgetInteractionStarted:return nt(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta.methodId});case xn.WidgetInteractionFinished:case xn.WidgetInteractionFailed:return nt(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}var Wn;!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"}(Wn||(Wn={}));const Yn={data:[],errors:{},statuses:{}};function Kn(e=Yn,t){return i({data:$n,errors:r(Jn,ze),meta:Zn,statuses:Qn})(e,t)}function $n(e=Yn.data,t){return t.type===Wn.LoadInstrumentsSucceeded?tt(e,t.payload&&t.payload.vaultedInstruments||[]):e}function Zn(e,t){switch(t.type){case Wn.LoadInstrumentsSucceeded:case Wn.DeleteInstrumentSucceeded:return nt(e,t.meta);default:return e}}function Jn(e=Yn.errors,t){switch(t.type){case Wn.LoadInstrumentsRequested:case Wn.LoadInstrumentsSucceeded:return Fe(e,"loadError",void 0);case Wn.DeleteInstrumentRequested:case Wn.DeleteInstrumentSucceeded:return nt(e,{deleteError:void 0,failedInstrument:void 0});case Wn.LoadInstrumentsFailed:return Fe(e,"loadError",t.payload);case Wn.DeleteInstrumentFailed:return nt(e,{deleteError:t.payload,failedInstrument:t.meta.instrumentId});default:return e}}function Qn(e=Yn.statuses,t){switch(t.type){case Wn.LoadInstrumentsRequested:return Fe(e,"isLoading",!0);case Wn.DeleteInstrumentRequested:return nt(e,{isDeleting:!0,deletingInstrument:t.meta.instrumentId});case Wn.LoadInstrumentsSucceeded:case Wn.LoadInstrumentsFailed:return Fe(e,"isLoading",!1);case Wn.DeleteInstrumentSucceeded:case Wn.DeleteInstrumentFailed:return nt(e,{isDeleting:!1,deletingInstrument:void 0});default:return e}}var Xn;!function(e){e.UpdatePaymentProviderCustomer="UPDATE_PAYMENT_PROVIDER_CUSTOMER"}(Xn||(Xn={}));const ei={data:{}};function ti(e=ei,t){return i({data:ni})(e,t)}function ni(e=ei.data,t){return t.type===Xn.UpdatePaymentProviderCustomer?nt(e,t.payload):e}var ii;!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"}(ii||(ii={}));const ri={data:{}};function oi(e=ri,t){return t.meta&&t.meta.methodId?i({data:i({[t.meta.methodId]:ai})})(e,t):e}function ai(e,t){switch(t.type){case ii.InitializeRemoteBillingSucceeded:return Fe(e,"billing",t.payload&&t.payload.billing);case ii.InitializeRemoteShippingSucceeded:return Fe(e,"shipping",t.payload&&t.payload.shipping);case ii.LoadRemoteSettingsSucceeded:return Fe(e,"settings",t.payload);case ii.UpdateRemoteCheckout:return nt(e,t.payload);default:return e}}const si={errors:{updateShippingOptionError:{},updateError:{},deleteError:{}},statuses:{isUpdating:{},isUpdatingShippingOption:{},isDeleting:{}}};function di(e=si,t){return i({data:ci,errors:r(ui,ze),statuses:li})(e,t)}function ci(e,t){var n,i;switch(t.type){case Ve.LoadCheckoutSucceeded:case ot.LoadShippingOptionsSucceeded:case ot.CreateConsignmentsSucceeded:case ot.UpdateConsignmentSucceeded:case ot.DeleteConsignmentSucceeded:case ot.UpdateShippingOptionSucceeded:case it.ApplyCouponSucceeded:case it.RemoveCouponSucceeded:return tt(e,t.payload&&t.payload.consignments);case Ut.SignOutCustomerSucceeded:return tt(e,[]);case He.HydrateInitialState:return tt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.consignments);default:return e}}function ui(e=si.errors,t){switch(t.type){case Ve.LoadCheckoutRequested:case Ve.LoadCheckoutSucceeded:case ot.LoadShippingOptionsSucceeded:case ot.LoadShippingOptionsRequested:return Fe(e,"loadError",void 0);case Ve.LoadCheckoutFailed:case ot.LoadShippingOptionsFailed:return Fe(e,"loadError",t.payload);case ot.CreateConsignmentsRequested:case ot.CreateConsignmentsSucceeded:return Fe(e,"createError",void 0);case ot.CreateConsignmentsFailed:return Fe(e,"createError",t.payload);case ot.UpdateConsignmentSucceeded:case ot.UpdateConsignmentRequested:return t.meta?nt(e,{updateError:{[t.meta.id]:void 0}}):e;case ot.UpdateConsignmentFailed:return t.meta?nt(e,{updateError:{[t.meta.id]:t.payload}}):e;case ot.DeleteConsignmentSucceeded:case ot.DeleteConsignmentRequested:return t.meta?nt(e,{deleteError:{[t.meta.id]:void 0}}):e;case ot.DeleteConsignmentFailed:return t.meta?nt(e,{deleteError:{[t.meta.id]:t.payload}}):e;case ot.UpdateShippingOptionRequested:case ot.UpdateShippingOptionSucceeded:return t.meta?nt(e,{updateShippingOptionError:{[t.meta.id]:void 0}}):e;case ot.UpdateShippingOptionFailed:return t.meta?nt(e,{updateShippingOptionError:{[t.meta.id]:t.payload}}):e;default:return e}}function li(e=si.statuses,t){switch(t.type){case Ve.LoadCheckoutRequested:return Fe(e,"isLoading",!0);case ot.LoadShippingOptionsRequested:return Fe(e,"isLoadingShippingOptions",!0);case Ve.LoadCheckoutSucceeded:case Ve.LoadCheckoutFailed:return Fe(e,"isLoading",!1);case ot.LoadShippingOptionsSucceeded:case ot.LoadShippingOptionsFailed:return Fe(e,"isLoadingShippingOptions",!1);case ot.CreateConsignmentsRequested:return Fe(e,"isCreating",!0);case ot.CreateConsignmentsSucceeded:case ot.CreateConsignmentsFailed:return Fe(e,"isCreating",!1);case ot.UpdateConsignmentRequested:return t.meta?nt(e,{isUpdating:{[t.meta.id]:!0}}):e;case ot.UpdateConsignmentSucceeded:case ot.UpdateConsignmentFailed:return t.meta?nt(e,{isUpdating:{[t.meta.id]:!1}}):e;case ot.DeleteConsignmentRequested:return t.meta?nt(e,{isDeleting:{[t.meta.id]:!0}}):e;case ot.DeleteConsignmentSucceeded:case ot.DeleteConsignmentFailed:return t.meta?nt(e,{isDeleting:{[t.meta.id]:!1}}):e;case ot.UpdateShippingOptionRequested:return t.meta?nt(e,{isUpdatingShippingOption:{[t.meta.id]:!0}}):e;case ot.UpdateShippingOptionSucceeded:case ot.UpdateShippingOptionFailed:return t.meta?nt(e,{isUpdatingShippingOption:{[t.meta.id]:!1}}):e;default:return e}}function hi(e,t){const n={};return Object.keys(e).forEach(i=>{const r=e[i],o=t?`${t}.${i}`:i;"object"==typeof r?Object.assign(n,hi(r,o)):n[o]=r}),n}function pi(e){return Object.keys(e).sort().reduce((t,n)=>Object.assign(Object.assign({},t),{[n]:e[n]}),{})}var gi;!function(e){e.LoadPickupOptionsRequested="LOAD_PICKUP_OPTIONS_REQUESTED",e.LoadPickupOptionsSucceeded="LOAD_PICKUP_OPTIONS_SUCCEEDED",e.LoadPickupOptionsFailed="LOAD_PICKUP_OPTIONS_FAILED"}(gi||(gi={}));const mi={errors:{},statuses:{}};function yi(e=mi,t){return i({data:fi,errors:r(_i,ze),statuses:Si})(e,t)}function fi(e,t){if(t.type!==gi.LoadPickupOptionsSucceeded)return e;if(t.meta){const n=pi(hi({consignmentId:t.meta.consignmentId,searchArea:t.meta.searchArea}));return Fe(e,btoa(`${JSON.stringify(n)}`),t.payload)}}function _i(e=mi.errors,t){switch(t.type){case gi.LoadPickupOptionsRequested:case gi.LoadPickupOptionsSucceeded:return Fe(e,"loadError",void 0);case gi.LoadPickupOptionsFailed:return Fe(e,"loadError",t.payload);default:return e}}function Si(e=mi.statuses,t){switch(t.type){case gi.LoadPickupOptionsRequested:return Fe(e,"isLoading",!0);case gi.LoadPickupOptionsSucceeded:case gi.LoadPickupOptionsFailed:return Fe(e,"isLoading",!1);default:return e}}var vi;!function(e){e.LoadShippingCountriesRequested="LOAD_SHIPPING_COUNTRIES_REQUESTED",e.LoadShippingCountriesSucceeded="LOAD_SHIPPING_COUNTRIES_SUCCEEDED",e.LoadShippingCountriesFailed="LOAD_SHIPPING_COUNTRIES_FAILED"}(vi||(vi={}));const Ci={errors:{},statuses:{}};function Ii(e=Ci,t){return i({data:wi,errors:r(Ei,ze),statuses:bi})(e,t)}function wi(e,t){return t.type===vi.LoadShippingCountriesSucceeded?tt(e,t.payload):e}function Ei(e=Ci.errors,t){switch(t.type){case vi.LoadShippingCountriesRequested:case vi.LoadShippingCountriesSucceeded:return Fe(e,"loadError",void 0);case vi.LoadShippingCountriesFailed:return Fe(e,"loadError",t.payload);default:return e}}function bi(e=Ci.statuses,t){switch(t.type){case vi.LoadShippingCountriesRequested:return Fe(e,"isLoading",!0);case vi.LoadShippingCountriesSucceeded:case vi.LoadShippingCountriesFailed:return Fe(e,"isLoading",!1);default:return e}}var Pi;!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"}(Pi||(Pi={}));const Oi={data:{},errors:{},statuses:{}};function Ai(e=Oi,t){return i({data:Ti,errors:r(ki,ze),statuses:Ri})(e,t)}function Ti(e=Oi.data,t){switch(t.type){case Pi.InitializeSucceeded:return nt(e,{[t.meta&&t.meta.methodId]:{isInitialized:!0}});case Pi.DeinitializeSucceeded:return nt(e,{[t.meta&&t.meta.methodId]:{isInitialized:!1}})}return e}function ki(e=Oi.errors,t){switch(t.type){case Pi.InitializeRequested:case Pi.InitializeSucceeded:return nt(e,{initializeError:void 0,initializeMethodId:void 0});case Pi.InitializeFailed:return nt(e,{initializeError:t.payload,initializeMethodId:t.meta&&t.meta.methodId});case Pi.DeinitializeRequested:case Pi.DeinitializeSucceeded:return nt(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case Pi.DeinitializeFailed:return nt(e,{deinitializeError:t.payload,deinitializeMethodId:t.meta&&t.meta.methodId});case Pi.UpdateAddressRequested:case Pi.UpdateAddressSucceeded:return nt(e,{updateAddressError:void 0,updateAddressMethodId:void 0});case Pi.UpdateAddressFailed:return nt(e,{updateAddressError:t.payload,updateAddressMethodId:t.meta&&t.meta.methodId});case Pi.SelectOptionRequested:case Pi.SelectOptionSucceeded:return nt(e,{selectOptionError:void 0,selectOptionMethodId:void 0});case Pi.SelectOptionFailed:return nt(e,{selectOptionError:t.payload,selectOptionMethodId:t.meta&&t.meta.methodId});case Pi.WidgetInteractionStarted:case Pi.WidgetInteractionFinished:return nt(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case Pi.WidgetInteractionFailed:return nt(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta&&t.meta.methodId});default:return e}}function Ri(e=Oi.statuses,t){switch(t.type){case Pi.InitializeRequested:return nt(e,{isInitializing:!0,initializeMethodId:t.meta&&t.meta.methodId});case Pi.InitializeFailed:case Pi.InitializeSucceeded:return nt(e,{isInitializing:!1,initializeMethodId:void 0});case Pi.DeinitializeRequested:return nt(e,{isDeinitializing:!0,deinitializeMethodId:t.meta&&t.meta.methodId});case Pi.DeinitializeFailed:case Pi.DeinitializeSucceeded:return nt(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case Pi.UpdateAddressRequested:return nt(e,{isUpdatingAddress:!0,updateAddressMethodId:t.meta&&t.meta.methodId});case Pi.UpdateAddressFailed:case Pi.UpdateAddressSucceeded:return nt(e,{isUpdatingAddress:!1,updateAddressMethodId:void 0});case Pi.SelectOptionRequested:return nt(e,{isSelectingOption:!0,selectOptionMethodId:t.meta&&t.meta.methodId});case Pi.SelectOptionFailed:case Pi.SelectOptionSucceeded:return nt(e,{isSelectingOption:!1,selectOptionMethodId:void 0});case Pi.WidgetInteractionStarted:return nt(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta&&t.meta.methodId});case Pi.WidgetInteractionFinished:case Pi.WidgetInteractionFailed:return nt(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}var Di;!function(e){e.SendSignInEmailRequested="SEND_SIGNIN_EMAIL_REQUESTED",e.SendSignInEmailSucceeded="SEND_SIGNIN_EMAIL_SUCCEEDED",e.SendSignInEmailFailed="SEND_SIGNIN_EMAIL_FAILED"}(Di||(Di={}));const Mi={errors:{},statuses:{}};function Ni(e=Mi,t){return i({data:Li,errors:r(zi,ze),statuses:Ui})(e,t)}function Li(e,t){return t.type===Di.SendSignInEmailSucceeded?nt(e,t.payload):e}function zi(e=Mi.errors,t){switch(t.type){case Di.SendSignInEmailRequested:case Di.SendSignInEmailSucceeded:return Fe(e,"sendError",void 0);case Di.SendSignInEmailFailed:return Fe(e,"sendError",t.payload);default:return e}}function Ui(e=Mi.statuses,t){switch(t.type){case Di.SendSignInEmailRequested:return Fe(e,"isSending",!0);case Di.SendSignInEmailFailed:case Di.SendSignInEmailSucceeded:return Fe(e,"isSending",!1);default:return e}}var Fi;!function(e){e.ApplyStoreCreditRequested="APPLY_STORE_CREDIT_REQUESTED",e.ApplyStoreCreditSucceeded="APPLY_STORE_CREDIT_SUCCEEDED",e.ApplyStoreCreditFailed="APPLY_STORE_CREDIT_FAILED"}(Fi||(Fi={}));const Bi={errors:{},statuses:{}};function xi(e=Bi,t){return i({errors:r(qi,ze),statuses:ji})(e,t)}function qi(e=Bi.errors,t){switch(t.type){case Fi.ApplyStoreCreditRequested:case Fi.ApplyStoreCreditSucceeded:return Fe(e,"applyError",void 0);case Fi.ApplyStoreCreditFailed:return Fe(e,"applyError",t.payload);default:return e}}function ji(e=Bi.statuses,t){switch(t.type){case Fi.ApplyStoreCreditRequested:return Fe(e,"isApplying",!0);case Fi.ApplyStoreCreditSucceeded:case Fi.ApplyStoreCreditFailed:return Fe(e,"isApplying",!1);default:return e}}const Gi={errors:{},statuses:{}};function Vi(e=Gi,t){return i({errors:r(Hi,ze),statuses:Wi})(e,t)}function Hi(e=Gi.errors,t){switch(t.type){case We.UpdateSubscriptionsRequested:case We.UpdateSubscriptionsSucceeded:return Fe(e,"updateError",void 0);case We.UpdateSubscriptionsFailed:return Fe(e,"updateError",t.payload);default:return e}}function Wi(e=Gi.statuses,t){switch(t.type){case We.UpdateSubscriptionsRequested:return Fe(e,"isUpdating",!0);case We.UpdateSubscriptionsFailed:case We.UpdateSubscriptionsSucceeded:return Fe(e,"isUpdating",!1);default:return e}}var Yi;!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"}(Yi||(Yi={}));const Ki={errors:{},statuses:{}};function $i(e=Ki,t){return i({data:Zi,errors:r(Ji,ze),statuses:Qi})(e,t)}function Zi(e,t){var n;switch(t.type){case Ve.LoadCheckoutSucceeded:case Ve.UpdateCheckoutSucceeded:case Fi.ApplyStoreCreditSucceeded:case Ye.UpdateBillingAddressSucceeded:case it.ApplyCouponSucceeded:case it.RemoveCouponSucceeded:case ot.CreateConsignmentsSucceeded:case ot.UpdateConsignmentSucceeded:case ot.DeleteConsignmentSucceeded:case ot.UpdateShippingOptionSucceeded:case ot.LoadShippingOptionsSucceeded:case rt.ApplyGiftCertificateSucceeded:case rt.RemoveGiftCertificateSucceeded:case Yi.VerifyCheckoutSucceeded:return nt(e,k(t.payload,["billingAddress","cart","consignments","customer","coupons","giftCertificates"]));case Ve.DeleteCheckoutSucceeded:return;case Pt.SubmitOrderSucceeded:return Fe(e,"orderId",t.payload&&t.payload.order.orderId);case He.HydrateInitialState:return nt(e,k(null===(n=t.payload)||void 0===n?void 0:n.checkout,["billingAddress","cart","consignments","customer","coupons","giftCertificates"]));default:return e}}function Ji(e=Ki.errors,t){switch(t.type){case Ve.LoadCheckoutRequested:case Ve.LoadCheckoutSucceeded:return Fe(e,"loadError",void 0);case Ve.LoadCheckoutFailed:return Fe(e,"loadError",t.payload);case Ve.UpdateCheckoutRequested:case Ve.UpdateCheckoutSucceeded:return Fe(e,"updateError",void 0);case Ve.UpdateCheckoutFailed:return Fe(e,"updateError",t.payload);case Ve.DeleteCheckoutRequested:case Ve.DeleteCheckoutSucceeded:return Fe(e,"deleteError",void 0);case Ve.DeleteCheckoutFailed:return Fe(e,"deleteError",t.payload);default:return e}}function Qi(e=Ki.statuses,t){switch(t.type){case Ve.LoadCheckoutRequested:return Fe(e,"isLoading",!0);case Ve.LoadCheckoutFailed:case Ve.LoadCheckoutSucceeded:return Fe(e,"isLoading",!1);case Ve.UpdateCheckoutRequested:return Fe(e,"isUpdating",!0);case Ve.UpdateCheckoutFailed:case Ve.UpdateCheckoutSucceeded:return Fe(e,"isUpdating",!1);case Ve.DeleteCheckoutRequested:return Fe(e,"isDeleting",!0);case Ve.DeleteCheckoutFailed:case Ve.DeleteCheckoutSucceeded:return Fe(e,"isDeleting",!1);case Yi.ExecuteRequested:return Fe(e,"isExecutingSpamCheck",!0);case Yi.ExecuteFailed:case Yi.ExecuteSucceeded:return Fe(e,"isExecutingSpamCheck",!1);default:return e}}const Xi=(er=de,(...e)=>{const t=e.pop();return er(...e,(...e)=>{const n=t(...e);return"function"==typeof n?ae(n):n})});var er,tr;!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"}(tr||(tr={}));class nr extends Ee{constructor(e){super(function(e){switch(e){case tr.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case tr.MissingCart:return"Unable to proceed because cart data is unavailable.";case tr.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case tr.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case tr.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case tr.MissingCheckoutConfig:case tr.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case tr.MissingOrder:return"Unable to proceed because order data is unavailable.";case tr.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case tr.MissingPayment:return"Unable to proceed because payment data is unavailable.";case tr.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case tr.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case tr.MissingPaymentProviderCustomer:return"Unable to proceed because payment provider customer is unavailable.";case tr.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}function ir(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}function rr(e){return function(e){const t=Object.create(e);return function(e,t){let n=Object.getPrototypeOf(e);for(;n;)t(n),n=Object.getPrototypeOf(n)}(e,n=>{Object.getOwnPropertyNames(n).forEach(n=>{"constructor"!==n&&"function"==typeof t[n]&&"_"!==n.charAt(0)&&(t[n]=((e,t)=>(...n)=>d(e[t].call(e,...n)))(e,n))})}),t}(e)}const or="b2bExtraField_";function ar(e){var t;const{fieldType:n,type:i}=function(e){switch(e){case"multiline_text":return{fieldType:"multiline",type:"string"};case"number":return{fieldType:"text",type:"integer"};case"dropdown":return{fieldType:"dropdown",type:"array"};default:return{fieldType:"text",type:"string"}}}(e.type);let r;return e.config.numberOfRows&&(r={rows:e.config.numberOfRows}),(null===(t=e.config.options)||void 0===t?void 0:t.length)&&(r=Object.assign(Object.assign({},r),{items:e.config.options.map(e=>({value:e,label:e}))})),{id:`${or}${e.id}`,name:`${or}${e.id}`,custom:!1,label:e.name,hidden:!e.visibleToStorefront,required:e.isRequired,default:null!=e.config.defaultValue?String(e.config.defaultValue):void 0,fieldType:n,type:i,maxLength:e.config.maxLength,max:e.config.maxValue,options:r}}const sr={"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"},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"},moneris:{provider:"moneris",method:"credit_card"},cba_mpgs:{provider:"cba_mpgs",method:"credit_card"},worldpayaccess:{provider:"worldpayaccess",method:"credit_card"},"worldpayaccess.credit_card":{provider:"worldpayaccess",method:"credit_card"},squarev2:{provider:"squarev2",method:"credit_card"},paypalcommercecreditcards:{provider:"paypalcommerce",method:"credit_card"},paypalcommerce:{provider:"paypalcommerce",method:"paypal"},bigcommerce_payments_creditcards:{provider:"bigcommerce_payments",method:"credit_card"},bigcommerce_payments:{provider:"bigcommerce_payments",method:"paypal"},tdonlinemart:{provider:"tdonlinemart",method:"credit_card"}};function dr(e){return M({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},g)}const cr={errors:{},statuses:{}};function ur(){const e=function(){const e=Xi(e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.receiptId},e=>()=>e),t=Xi(e=>e.errors.persistB2bMetadataError,e=>()=>e),n=Xi(e=>!!e.statuses.isPersisting,e=>()=>e);return se((i=bn)=>({getReceiptId:e(i),getPersistError:t(i),isPersisting:n(i)}))}(),t=function(){const e=Xi(e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.token},e=>()=>e),t=Xi(e=>e.errors.loadError,e=>()=>e),n=Xi(e=>!!e.statuses.isLoading,e=>()=>e);return se((i=Be)=>({getToken:e(i),getLoadError:t(i),isLoading:n(i)}))}(),n=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e,e=>()=>ir(e(),()=>new nr(tr.MissingBillingAddress))),n=Xi(e=>e.errors.updateError,e=>()=>e),i=Xi(e=>e.errors.continueAsGuestError,e=>()=>e),r=Xi(e=>e.errors.loadError,e=>()=>e),o=Xi(e=>!!e.statuses.isUpdating,e=>()=>e),a=Xi(e=>!!e.statuses.isContinuingAsGuest,e=>()=>e),s=Xi(e=>!!e.statuses.isLoading,e=>()=>e);return se((d=$e)=>({getBillingAddress:e(d),getBillingAddressOrThrow:t(d),getUpdateError:n(d),getContinueAsGuestError:i(d),getLoadError:r(d),isUpdating:o(d),isContinuingAsGuest:a(d),isLoading:s(d)}))}(),i=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e,e=>()=>ir(e(),()=>new nr(tr.MissingCart))),n=Xi(e=>e.errors.loadError,e=>()=>e),i=Xi(e=>!!e.statuses.isLoading,e=>()=>e),r=Xi(e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.locale},e=>()=>e);return se((o=at)=>({getCart:e(o),getCartOrThrow:t(o),getLoadError:n(o),isLoading:i(o),getLocale:r(o)}))}(),r=function(){const e=Xi(e=>e,e=>()=>e),t=Xi(e=>e.statuses,e=>ae(t=>{if(t){const n=e[t];return!0===(n&&n.isInitializing)}return z(e,{isInitializing:!0})})),n=Xi(e=>e.data,e=>ae((t,n)=>{const i=e[t];return!!i&&(n?!0===i.initializedContainers[n]:z(i.initializedContainers,e=>!0===e))})),i=Xi(e=>e.statuses,e=>ae(t=>{if(t){const n=e[t];return!0===(n&&n.isDeinitializing)}return z(e,{isDeinitializing:!0})})),r=Xi(e=>e.errors,e=>ae(t=>{const n=t?e[t]:l(x(e),e=>!(!e||!e.initializeError));return n&&n.initializeError})),o=Xi(e=>e.errors,e=>ae(t=>{const n=t?e[t]:l(x(e),e=>!(!e||!e.deinitializeError));return n&&n.deinitializeError}));return se((a=ht)=>({getState:e(a),isInitializing:t(a),isInitialized:n(a),isDeinitializing:i(a),getInitializeError:r(a),getDeinitializeError:o(a)}))}(),o=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e=>e.data,e=>t=>{if(!e)return;const{flashMessages:n}=e.context;return n?void 0!==t?n.filter(({type:e})=>t===e):n:void 0}),n=Xi(e=>e.data,(e,{formState:t})=>t&&t.data,(e,t={customerAccount:[],shippingAddress:[],billingAddress:[]})=>()=>e?Object.assign(Object.assign({},e.storeConfig),{formFields:t}):void 0),i=Xi(n,e=>()=>ir(e(),()=>new nr(tr.MissingCheckoutConfig))),r=Xi(e=>e.data&&e.data.context,e=>()=>e),o=Xi(e=>e.meta&&e.meta.externalSource,e=>()=>e),a=Xi(e=>{var t;return null===(t=e.meta)||void 0===t?void 0:t.host},e=>()=>e),s=Xi(e=>{var t;return null===(t=e.meta)||void 0===t?void 0:t.locale},e=>()=>e),d=Xi(e=>e.meta&&e.meta.variantIdentificationToken,e=>()=>e),c=Xi(e=>e.errors.loadError,e=>()=>e),u=Xi(e=>!!e.statuses.isLoading,e=>()=>e);return se((l=Ct,h)=>({getConfig:e(l),getFlashMessages:t(l),getStoreConfig:n(l,{formState:h}),getStoreConfigOrThrow:i(l,{formState:h}),getContextConfig:r(l),getExternalSource:o(l),getHost:a(l),getLocale:s(l),getVariantIdentificationToken:d(l),getLoadError:c(l),isLoading:u(l)}))}(),a=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e=>e.errors.loadError,e=>()=>e),n=Xi(e=>!!e.statuses.isLoading,e=>()=>e);return se((i=un)=>({getCountries:e(i),getLoadError:t(i),isLoading:n(i)}))}(),s=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e=>e.errors.removeCouponError,e=>()=>e),n=Xi(e=>e.errors.applyCouponError,e=>()=>e),i=Xi(e=>!!e.statuses.isApplyingCoupon,e=>()=>e),r=Xi(e=>!!e.statuses.isRemovingCoupon,e=>()=>e);return se((o=Ot)=>({getCoupons:e(o),getRemoveError:t(o),getApplyError:n(o),isApplying:i(o),isRemoving:r(o)}))}(),d=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e,e=>()=>ir(e(),()=>new nr(tr.MissingCustomer))),n=Xi(e=>e.errors.createError,e=>()=>e),i=Xi(e=>!!e.statuses.isCreating,e=>()=>e),r=Xi(e=>e.errors.createAddressError,e=>()=>e),o=Xi(e=>!!e.statuses.isCreatingAddress,e=>()=>e);return se((a=Ft)=>({getCustomer:e(a),getCustomerOrThrow:t(a),getCreateAccountError:n(a),isCreatingCustomerAccount:i(a),getCreateAddressError:r(a),isCreatingCustomerAddress:o(a)}))}(),c=function(){const e=Xi(e=>e.errors.signInMethodId,e=>e.errors.signInError,(e,t)=>n=>{if(!n||e===n)return t}),t=Xi(e=>e.errors.signOutMethodId,e=>e.errors.signOutError,(e,t)=>n=>{if(!n||e===n)return t}),n=Xi(e=>e.errors.executePaymentMethodCheckoutMethodId,e=>e.errors.executePaymentMethodCheckoutError,(e,t)=>n=>{if(!n||e===n)return t}),i=Xi(e=>e.errors.initializeMethodId,e=>e.errors.initializeErrors,(e,t)=>n=>{if(e&&t)return n?t[n]:t[e]}),r=Xi(e=>e.errors.widgetInteractionMethodId,e=>e.errors.widgetInteractionError,(e,t)=>n=>{if(!n||e===n)return t}),o=Xi(e=>e.statuses.signInMethodId,e=>e.statuses.isSigningIn,(e,t)=>n=>!(n&&e!==n||!t)),a=Xi(e=>e.statuses.signOutMethodId,e=>e.statuses.isSigningOut,(e,t)=>n=>!(n&&e!==n||!t)),s=Xi(e=>e.statuses.executePaymentMethodCheckoutMethodId,e=>e.statuses.isExecutingPaymentMethodCheckout,(e,t)=>n=>!(n&&e!==n||!t)),d=Xi(e=>e.statuses.initializeMethodId,e=>e.statuses.isInitializing,(e,t)=>n=>!(n&&e!==n||!t)),c=Xi(e=>e.data,e=>t=>!(!e[t]||!e[t].isInitialized)),u=Xi(e=>e.statuses.widgetInteractionMethodId,e=>e.statuses.isWidgetInteracting,(e,t)=>n=>!(n&&e!==n||!t));return se((l=Vt)=>({getSignInError:e(l),getSignOutError:t(l),getExecutePaymentMethodCheckoutError:n(l),getInitializeError:i(l),getWidgetInteractionError:r(l),isSigningIn:o(l),isSigningOut:a(l),isExecutingPaymentMethodCheckout:s(l),isInitializing:d(l),isInitialized:c(l),isWidgetInteracting:u(l)}))}(),h=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e=>e.errors.removeGiftCertificateError,e=>()=>e),n=Xi(e=>e.errors.applyGiftCertificateError,e=>()=>e),i=Xi(e=>!!e.statuses.isApplyingGiftCertificate,e=>()=>e),r=Xi(e=>!!e.statuses.isRemovingGiftCertificate,e=>()=>e);return se((o=Dt)=>({getGiftCertificates:e(o),getRemoveError:t(o),getApplyError:n(o),isApplying:i(o),isRemoving:r(o)}))}(),g=function(){const e=Xi(e=>e.data,e=>t=>{if(!e)return;const n=t.gateway?`${t.gateway}.${t.id}`:t.id,i=sr[n];return i?u(e,i):[]}),t=Xi(e=>e.data,(e=[])=>t=>{const n=x(sr);return e.find(e=>e.bigpayToken===t&&"card"===e.type&&n.some(t=>S(e,t)))}),n=Xi(t,e=>t=>ir(e(t),()=>new nr(tr.MissingPaymentInstrument))),i=Xi(e=>e.data,e=>()=>{if(e)return p(sr,t=>u(e,e=>S(e,t)))}),r=Xi(e=>e.meta,e=>()=>e),o=Xi(e=>e.errors.loadError,e=>()=>e),a=Xi(e=>e.errors.failedInstrument,e=>e.errors.deleteError,(e,t)=>n=>{if(!n||e===n)return t}),s=Xi(e=>e.statuses.isLoading,e=>()=>!!e),d=Xi(e=>e.statuses.deletingInstrument,e=>e.statuses.isDeleting,(e,t)=>n=>!(n&&e!==n||!t));return se((c=Yn)=>({getCardInstrument:t(c),getCardInstrumentOrThrow:n(c),getInstruments:i(c),getInstrumentsByPaymentMethod:e(c),getInstrumentsMeta:r(c),getLoadError:o(c),getDeleteError:a(c),isLoading:s(c),isDeleting:d(c)}))}(),m=function(){const e=Xi(e=>e.data,e=>(t=[],n)=>{const i=l(t,{code:n});return(e?e.shippingAddress:[]).map(e=>s(e,t,i))}),t=Xi(e=>e.data,e=>(t=[],n)=>{const i=l(t,{code:n});return(e?e.billingAddress:[]).map(e=>s(e,t,i))}),n=Xi(e=>e.data,e=>()=>e?e.customerAccount:[]),i=Xi(e=>e.extraFields,e=>()=>e&&e.address.length?e.address.map(ar):[]),r=Xi(e=>e.extraFields,e=>()=>e&&e.order.length?e.order.map(ar):[]),o=Xi(e=>e.errors.loadError,e=>()=>e),a=Xi(e=>!!e.statuses.isLoading,e=>()=>e);function s(e,t,n){return"countryCode"===e.name?function(e,t=[],n){if(!t.length)return e;const{code:i=""}=n||{},r=t.map(({code:e,name:t})=>({value:e,label:t}));return Object.assign(Object.assign({},e),{options:{items:r},default:i,type:"array",fieldType:"dropdown",itemtype:"string"})}(e,t,n):"stateOrProvince"===e.name?function(e,t){const{subdivisions:n=[],requiresState:i}=t||{};if(!n.length)return Object.assign(Object.assign({},e),{required:null!=i&&i});const r=n.map(({code:e,name:t})=>({value:e,label:t}));return Object.assign(Object.assign({},e),{name:"stateOrProvinceCode",options:{items:r},required:null==i||i,type:"array",fieldType:"dropdown",itemtype:"string"})}(e,n):"postalCode"===e.name?function(e,t){const{hasPostalCodes:n=[]}=t||{};return void 0===n?e:Object.assign(Object.assign({},e),{required:Boolean(n)})}(e,n):e}return se((s=nn)=>({getShippingAddressFields:e(s),getBillingAddressFields:t(s),getCustomerAccountFields:n(s),getAddressExtraFields:i(s),getOrderExtraFields:r(s),getLoadError:o(s),isLoading:a(s)}))}(),y=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e=>e.meta,e=>()=>e),n=Xi(e=>e.data,e=>(t,n)=>l(e,n?{id:t,gateway:n}:{id:t})),i=Xi(n,e=>(t,n)=>ir(e(t,n),()=>new nr(tr.MissingPaymentMethod))),r=Xi(e=>e.errors.loadError,e=>()=>e),o=Xi(e=>e.errors.loadMethodId,e=>e.errors.loadMethodError,(e,t)=>n=>{if(!n||e===n)return t}),a=Xi(e=>e.statuses.isLoading,e=>()=>!!e),s=Xi(e=>e.statuses.loadMethodId,e=>e.statuses.isLoadingMethod,(e,t)=>n=>!(n&&e!==n||!t));return se((d=Nn)=>({getPaymentMethods:e(d),getPaymentMethodsMeta:t(d),getPaymentMethod:n(d),getPaymentMethodOrThrow:i(d),getLoadError:r(d),getLoadMethodError:o(d),isLoading:a(d),isLoadingMethod:s(d)}))}(),f=function(){const e=Xi(e=>e.errors.initializeMethodId,e=>e.errors.initializeError,(e,t)=>n=>{if(!n||e===n)return t}),t=Xi(e=>e.errors.executeMethodId,e=>e.errors.executeError,(e,t)=>n=>{if(!n||e===n)return t}),n=Xi(e=>e.errors.finalizeMethodId,e=>e.errors.finalizeError,(e,t)=>n=>{if(!n||e===n)return t}),i=Xi(e=>e.errors.widgetInteractionMethodId,e=>e.errors.widgetInteractionError,(e,t)=>n=>{if(!n||e===n)return t}),r=Xi(e=>e.statuses.initializeMethodId,e=>e.statuses.isInitializing,(e,t)=>n=>!(n&&e!==n||!t)),o=Xi(e=>e.data,e=>t=>{const n=t.gatewayId?`${t.methodId}.${t.gatewayId}`:t.methodId;return!(!e[n]||!e[n].isInitialized)}),a=Xi(e=>e.statuses.executeMethodId,e=>e.statuses.isExecuting,(e,t)=>n=>!(n&&e!==n||!t)),s=Xi(e=>e.statuses.finalizeMethodId,e=>e.statuses.isFinalizing,(e,t)=>n=>!(n&&e!==n||!t)),d=Xi(e=>e.statuses.widgetInteractionMethodId,e=>e.statuses.isWidgetInteracting,(e,t)=>n=>!(n&&e!==n||!t));return se((c=qn)=>({getInitializeError:e(c),getExecuteError:t(c),getFinalizeError:n(c),getWidgetInteractingError:i(c),isInitializing:r(c),isInitialized:o(c),isExecuting:a(c),isFinalizing:s(c),isWidgetInteracting:d(c)}))}(),v=function(){const e=Xi(e=>e.data,e=>(t,n)=>{if(!e)return;const i=pi(hi({consignmentId:t,searchArea:n})),r=btoa(`${JSON.stringify(i)}`);return e[r]}),t=Xi(e=>e.errors.loadError,e=>()=>e),n=Xi(e=>!!e.statuses.isLoading,e=>()=>e);return se((i=mi)=>({getPickupOptions:e(i),getLoadError:t(i),isLoading:n(i)}))}(),C=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e,e=>()=>ir(e(),()=>new nr(tr.MissingPaymentProviderCustomer)));return se((n=ei)=>({getPaymentProviderCustomer:e(n),getPaymentProviderCustomerOrThrow:t(n)}))}(),I=function(){const e=Xi(e=>e.data,e=>t=>e[t]);return se((t=ri)=>({getCheckout:e(t)}))}(),w=function(){const e=Xi(e=>e.data,e=>()=>{const t=null==e?void 0:e.find(e=>!e.selectedPickupOption);return null==t?void 0:t.shippingAddress}),t=Xi(e,e=>()=>ir(e(),()=>new nr(tr.MissingShippingAddress))),n=Xi(e=>e.data,e=>()=>{const t=null==e?void 0:e.filter(e=>!e.selectedPickupOption);return t?t.map(e=>e.shippingAddress):[]}),i=Xi(n,e=>()=>ir(e(),()=>new nr(tr.MissingShippingAddress)));return se((r=si)=>({getShippingAddress:e(r),getShippingAddressOrThrow:t(r),getShippingAddresses:n(r),getShippingAddressesOrThrow:i(r)}))}(),E=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e=>e.errors.loadError,e=>()=>e),n=Xi(e=>e.statuses.isLoading,e=>()=>!!e);return se((i=Ci)=>({getShippingCountries:e(i),getLoadError:t(i),isLoading:n(i)}))}(),b=function(){const e=Xi(e=>e.errors.updateAddressMethodId,e=>e.errors.updateAddressError,(e,t)=>n=>{if(!n||e===n)return t}),t=Xi(e=>e.errors.selectOptionMethodId,e=>e.errors.selectOptionError,(e,t)=>n=>{if(!n||e===n)return t}),n=Xi(e=>e.errors.initializeMethodId,e=>e.errors.initializeError,(e,t)=>n=>{if(!n||e===n)return t}),i=Xi(e=>e.errors.widgetInteractionMethodId,e=>e.errors.widgetInteractionError,(e,t)=>n=>{if(!n||e===n)return t}),r=Xi(e=>e.statuses.updateAddressMethodId,e=>e.statuses.isUpdatingAddress,(e,t)=>n=>!(n&&e!==n||!t)),o=Xi(e=>e.statuses.selectOptionMethodId,e=>e.statuses.isSelectingOption,(e,t)=>n=>!(n&&e!==n||!t)),a=Xi(e=>e.statuses.initializeMethodId,e=>e.statuses.isInitializing,(e,t)=>n=>!(n&&e!==n||!t)),s=Xi(e=>e.data,e=>t=>!(!e[t]||!e[t].isInitialized)),d=Xi(e=>e.statuses.widgetInteractionMethodId,e=>e.statuses.isWidgetInteracting,(e,t)=>n=>!(n&&e!==n||!t));return se((c=Oi)=>({getUpdateAddressError:e(c),getSelectOptionError:t(c),getInitializeError:n(c),getWidgetInteractionError:i(c),isUpdatingAddress:r(c),isSelectingOption:o(c),isInitializing:a(c),isInitialized:s(c),isWidgetInteracting:d(c)}))}(),P=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e,e=>()=>ir(e(),()=>new nr(tr.MissingConsignments))),n=Xi(e=>e.data,e=>t=>{if(e&&e.length)return l(e,{id:t})}),i=Xi(e=>e.data,e=>t=>{if(e&&e.length)return l(e,e=>{return n=e.shippingAddress,i=t,_(dr(n),dr(i));var n,i})}),r=Xi(e=>e.data,e=>()=>{if(e&&e.length)return e[0].selectedShippingOption}),o=Xi(e=>e.errors.loadError,e=>()=>e),a=Xi(e=>e.errors.createError,e=>()=>e),s=Xi(e=>e.errors.loadShippingOptionsError,e=>()=>e),d=Xi(e,(e,{cart:t})=>t.getCart,(e,t)=>()=>{const n=t();if(!n)return[];const i=(e()||[]).reduce((e,t)=>e.concat(t.lineItemIds),[]);return(n.lineItems.physicalItems||[]).filter(e=>i.indexOf(e.id)<0)}),c=Xi(e=>e.errors.updateError,e=>t=>t?e[t]:l(e)),u=Xi(e=>e.errors.deleteError,e=>t=>t?e[t]:l(e)),h=Xi(i,c,a,(e,t,n)=>i=>{const r=e(i);return r?t(r.id):n()}),p=Xi(e=>e.errors.updateShippingOptionError,e=>t=>t?e[t]:l(e)),g=Xi(e=>e.statuses.isLoading,e=>()=>!0===e),m=Xi(e=>e.statuses.isLoadingShippingOptions,e=>()=>!0===e),y=Xi(e=>e.statuses.isCreating,e=>()=>!0===e),f=Xi(e=>e.statuses.isUpdating,e=>t=>t?!0===e[t]:!0===l(e)),S=Xi(e=>e.statuses.isDeleting,e=>t=>t?!0===e[t]:!0===l(e)),v=Xi(i,f,y,(e,t,n)=>i=>{const r=e(i);return r?t(r.id):n()}),C=Xi(e=>e.statuses.isUpdatingShippingOption,e=>t=>t?!0===e[t]:!0===l(e));return se((l=si,_)=>({getConsignments:e(l),getConsignmentsOrThrow:t(l),getConsignmentById:n(l),getConsignmentByAddress:i(l),getShippingOption:r(l),getLoadError:o(l),getCreateError:a(l),getLoadShippingOptionsError:s(l),getUnassignedItems:d(l,{cart:_}),getUpdateError:c(l),getDeleteError:u(l),getItemAssignmentError:h(l),getUpdateShippingOptionError:p(l),isLoading:g(l),isLoadingShippingOptions:m(l),isCreating:y(l),isUpdating:f(l),isDeleting:S(l),isAssigningItems:v(l),isUpdatingShippingOption:C(l)}))}(),O=function(){const e=Xi(e=>e.data,(e,{billingAddress:t})=>t.getBillingAddress,(e,{cart:t})=>t.getCart,(e,{customer:t})=>t.getCustomer,(e,{consignments:t})=>t.getConsignments,(e,{coupons:t})=>t.getCoupons,(e,{giftCertificates:t})=>t.getGiftCertificates,(e,t,n,i,r,o,a)=>()=>{const s=t(),d=n(),c=i(),u=r()||[],l=o()||[],h=a()||[];if(e&&d&&c)return Object.assign(Object.assign({},e),{billingAddress:s,cart:d,customer:c,consignments:u,coupons:l,giftCertificates:h})}),t=Xi(e,e=>()=>ir(e(),()=>new nr(tr.MissingCheckout))),n=Xi(e,e=>t=>{const n=e();if(!n)return;const i=n.grandTotal||0,r=n.customer.storeCredit||0;return t?Math.max(i-r,0):n.outstandingBalance}),i=Xi(e=>e.errors.loadError,e=>()=>e),r=Xi(e=>e.errors.updateError,e=>()=>e),o=Xi(e=>e.errors.deleteError,e=>()=>e),a=Xi(e=>e.statuses.isExecutingSpamCheck,e=>()=>!0===e),s=Xi(e=>e.statuses.isLoading,e=>()=>!0===e),d=Xi(e=>e.statuses.isUpdating,e=>()=>!0===e),c=Xi(e=>e.statuses.isDeleting,e=>()=>!0===e);return se((u=Ki,l,h,p,g,m,y)=>({getCheckout:e(u,{billingAddress:l,cart:h,consignments:p,coupons:g,customer:m,giftCertificates:y}),getCheckoutOrThrow:t(u,{billingAddress:l,cart:h,consignments:p,coupons:g,customer:m,giftCertificates:y}),getOutstandingBalance:n(u,{billingAddress:l,cart:h,consignments:p,coupons:g,customer:m,giftCertificates:y}),getLoadError:i(u),getUpdateError:r(u),getDeleteError:o(u),isExecutingSpamCheck:a(u),isLoading:s(u),isUpdating:d(u),isDeleting:c(u)}))}(),A=function(){const e=Xi(e=>e.data,(e,{billingAddress:t})=>t.getOrderBillingAddress(),(e,{coupons:t})=>t.getCoupons(),(e,t,n=[])=>()=>{if(e&&t)return Object.assign(Object.assign({},e),{billingAddress:t,coupons:n})}),t=Xi(e,e=>()=>ir(e(),()=>new nr(tr.MissingOrder))),n=Xi(e=>e.meta,e=>()=>e),i=Xi(e=>e.errors.loadError,e=>()=>e),r=Xi(e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.payments},(e=[])=>t=>{const n=e.find(({providerId:e})=>e===t);return null==n?void 0:n.paymentId}),o=Xi(e=>!!e.statuses.isLoading,e=>()=>e);return se((a=mn,s,d)=>({getOrder:e(a,{billingAddress:s,coupons:d}),getOrderOrThrow:t(a,{billingAddress:s,coupons:d}),getOrderMeta:n(a),getLoadError:i(a),getPaymentId:r(a),isLoading:o(a)}))}(),T=function(){const e=Xi(e=>e.data,e=>()=>e);return se((t=Cn)=>({getOrderBillingAddress:e(t)}))}(),k=function(){const e=Xi(({order:e})=>e.getOrderMeta,e=>()=>{const t=e();return t&&t.payment}),t=Xi(({order:e})=>e.getOrder,e=>()=>{const t=e();return l(t&&t.payments,({providerId:e})=>"giftcertificate"!==e&&"storecredit"!==e)}),n=Xi(({checkout:e})=>e.getCheckout,e=>()=>{const t=e();return l(t&&t.payments,({providerType:e})=>"PAYMENT_TYPE_HOSTED"===e)}),i=Xi(e,n,t,(e,t,n)=>()=>{const i=e();if(i&&i.id)return{providerId:i.id,gatewayId:i.gateway};const r=t()||n();return r&&r.providerId?{providerId:r.providerId,gatewayId:r.gatewayId}:void 0}),r=Xi(i,e=>()=>ir(e(),()=>new nr(tr.MissingPaymentId))),o=Xi(e,n,t,(e,t,n)=>()=>{const i=e();if(i&&i.status)return i.status.replace("PAYMENT_STATUS_","");const r=t()||n();return r?r.detail.step:void 0}),a=Xi(o,e=>()=>ir(e(),()=>new nr(tr.MissingPaymentStatus))),s=Xi(({order:e})=>e.getOrderMeta,e=>()=>{const t=e();return t&&t.token}),d=Xi(s,e=>()=>ir(e(),()=>new nr(tr.MissingPaymentToken))),c=Xi(e,e=>()=>{const t=e();return t&&t.redirectUrl}),u=Xi(c,e=>()=>ir(e(),()=>new nr(tr.MissingPaymentRedirectUrl))),h=Xi(({checkout:e})=>e.getOutstandingBalance,e=>(t=!1)=>{const n=e(t);return!!n&&n>0}),p=Xi(o,e=>t=>!(!t||!t.nonce)||"ACKNOWLEDGE"===e()||"FINALIZE"===e());return se((e,t)=>({getPaymentId:i({checkout:e,order:t}),getPaymentIdOrThrow:r({checkout:e,order:t}),getPaymentStatus:o({checkout:e,order:t}),getPaymentStatusOrThrow:a({checkout:e,order:t}),getPaymentToken:s({checkout:e,order:t}),getPaymentTokenOrThrow:d({checkout:e,order:t}),getPaymentRedirectUrl:c({checkout:e,order:t}),getPaymentRedirectUrlOrThrow:u({checkout:e,order:t}),isPaymentDataRequired:h({checkout:e,order:t}),isPaymentDataSubmitted:p({checkout:e,order:t})}))}(),R=function(){const e=Xi(e=>e.errors.applyError,e=>()=>e),t=Xi(e=>!!e.statuses.isApplying,e=>()=>e);return se((n=cr)=>({getApplyError:e(n),isApplying:t(n)}))}(),D=function(){const e=Xi(e=>e.errors.updateError,e=>()=>e),t=Xi(e=>!!e.statuses.isUpdating,e=>()=>e);return se((n=Gi)=>({getUpdateError:e(n),isUpdating:t(n)}))}(),M=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e=>e.errors.sendError,e=>()=>e),n=Xi(e=>!!e.statuses.isSending,e=>()=>e);return se((i=Mi)=>({getEmail:e(i),getSendError:t(i),isSending:n(i)}))}(),N=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e=>e.data,e=>t=>null==e?void 0:e.find(e=>e.region===t)),n=Xi(e=>e.errors.loadError,e=>()=>e),i=Xi(e=>e.statuses.isLoading,e=>()=>!!e);return se((r=Zt)=>({getExtensions:e(r),getExtensionByRegion:t(r),getLoadError:n(r),isLoading:i(r)}))}();return(u,l={})=>{const p=e(u.b2bPostOrder),_=t(u.b2bToken),S=n(u.billingAddress),L=i(u.cart),z=r(u.checkoutButton),U=a(u.countries),F=s(u.coupons),B=d(u.customer),x=c(u.customerStrategies),q=N(u.extensions),j=m(u.formFields),G=h(u.giftCertificates),V=g(u.instruments),H=T(u.orderBillingAddress),W=y(u.paymentMethods),Y=C(u.paymentProviderCustomer),K=f(u.paymentStrategies),$=v(u.pickupOptions),Z=I(u.remoteCheckout),J=w(u.consignments),Q=E(u.shippingCountries),X=b(u.shippingStrategies),ee=D(u.subscriptions),te=R(u.storeCredit),ne=M(u.signInEmail),ie=P(u.consignments,L),re=O(u.checkout,S,L,ie,F,B,G),oe=A(u.order,H,F),ae=k(re,oe),se={b2bPostOrder:p,b2bToken:_,billingAddress:S,cart:L,checkout:re,checkoutButton:z,config:o(u.config,u.formFields),consignments:ie,countries:U,coupons:F,customer:B,customerStrategies:x,extensions:q,form:j,giftCertificates:G,instruments:V,order:oe,orderBillingAddress:H,payment:ae,paymentMethods:W,paymentProviderCustomer:Y,paymentStrategies:K,pickupOptions:$,remoteCheckout:Z,shippingAddress:J,shippingCountries:Q,shippingStrategies:X,signInEmail:ne,subscriptions:ee,storeCredit:te};return l.shouldWarnMutation?(de=se,Object.keys(de).reduce((e,t)=>(e[t]=rr(de[t]),e),{})):se;var de}}function lr(e={},t){const n=(s=function(){const e=new De;return["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(t=>{e.register(t,(e,t)=>new Oe(e,t))}),e.register("invalid_payment_provider",e=>new we(e)),e.register("payment_config_not_found",e=>new we(e)),e}(),e=>Y(e).pipe(Q(e=>{if(e instanceof Error||e.payload instanceof Error)throw e;if((t=e.payload)&&"object"==typeof t&&["body","headers","status","statusText"].every(e=>Object.prototype.hasOwnProperty.call(t,e))){const t=e.payload.body&&e.payload.body.detail;throw Object.assign(Object.assign({},e),{payload:s.createError(e.payload,t)})}var t;throw e}))),r=ur(),o=i({b2bPostOrder:Pn,b2bToken:xe,billingAddress:Ze,cart:st,checkout:$i,checkoutButton:yt,config:It,consignments:di,countries:ln,coupons:At,customer:Bt,customerStrategies:Ht,extensions:Jt,formFields:rn,giftCertificates:Mt,instruments:Kn,orderBillingAddress:In,order:yn,payment:Dn,paymentMethods:Ln,paymentStrategies:jn,pickupOptions:yi,paymentProviderCustomer:ti,remoteCheckout:oi,shippingCountries:Ii,shippingStrategies:Ai,signInEmail:Ni,subscriptions:Vi,storeCredit:xi});var s;return a(o,e,Object.assign({actionTransformer:n,stateTransformer:e=>r(e)},t))}var hr,pr;!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"}(hr||(hr={}));class gr extends ve{constructor(e){super(function(e){switch(e){case hr.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case hr.MissingCart:return"Unable to proceed because cart data is unavailable.";case hr.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case hr.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case hr.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case hr.MissingCheckoutConfig:case hr.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case hr.MissingOrder:return"Unable to proceed because order data is unavailable.";case hr.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case hr.MissingPayment:return"Unable to proceed because payment data is unavailable.";case hr.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case hr.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case hr.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}function mr(e){return t=e.lineItems.physicalItems.filter(e=>!e.addedByPromotion),N(t,(e,t)=>e+t.quantity,0);var t}function yr(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}!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"}(pr||(pr={}));class fr extends ve{constructor(e){super(function(e){switch(e){case pr.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case pr.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case pr.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case pr.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}const _r={de:"eu",jp:"fe",uk:"eu",us:"na"};var Sr,vr,Cr,Ir,wr;!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"}(Sr||(Sr={})),function(e){e.Home="Home",e.Product="Product",e.Cart="Cart",e.Checkout="Checkout",e.Other="Other"}(vr||(vr={})),function(e){e.USD="USD",e.EUR="EUR",e.GBP="GBP",e.JPY="JPY"}(Cr||(Cr={})),function(e){e.PayAndShip="PayAndShip",e.PayOnly="PayOnly"}(Ir||(Ir={})),function(e){e.Gold="Gold",e.LightGray="LightGray",e.DarkGray="DarkGray"}(wr||(wr={}));var Er=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class br{constructor(e){this.amazonPayV2ScriptLoader=e}initialize(e){return Er(this,void 0,void 0,function*(){this.amazonPayV2SDK=yield this.amazonPayV2ScriptLoader.load(e),this.buttonParentContainer=this.buttonParentContainer||this.createAmazonPayButtonParentContainer()})}deinitialize(){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()}bindButton(e,t,n){this.getAmazonPayV2SDK().Pay.bindChangeAction(`#${e}`,{amazonCheckoutSessionId:t,changeAction:n})}createButton(e,t){this.amazonPayV2Button=this.getAmazonPayV2SDK().Pay.renderButton(`#${e}`,t)}prepareCheckout(e){const t=this.prepareRequestConfig(e);this.getAmazonPayV2Button().onClick(()=>{this.getAmazonPayV2Button().initCheckout(t)})}prepareCheckoutWithCreationRequestConfig(e){this.getAmazonPayV2Button().onClick(()=>Er(this,void 0,void 0,function*(){const t=yield e();if(t){const e=this.prepareRequestConfig(t.createCheckoutSessionConfig,t.estimatedOrderAmount,t.productType);this.getAmazonPayV2Button().initCheckout(e)}}))}signout(){return Er(this,void 0,void 0,function*(){return this.amazonPayV2SDK&&this.amazonPayV2SDK.Pay.signout(),Promise.resolve()})}renderAmazonPayButton({buttonColor:e,checkoutState:t,containerId:n,decoupleCheckoutInitiation:i=!1,methodId:r,options:o,placement:a}){const s=document.querySelector(`#${n}`);if(!s)return;const{id:d}=s.appendChild(this.getButtonParentContainer()),c=null!=o?o:this.getAmazonPayV2ButtonOptions(t,r,a,i,e);return this.createButton(d,c),this.getButtonParentContainer()}updateBuyNowFlowFlag(e){this.isBuyNowFlow=Boolean(e)}isPh4Enabled(e,t){const n=!!e["PROJECT-3483.amazon_pay_ph4"],i=!!e["INT-6885.amazon_pay_ph4_us_only"];return n&&i?"US"===t:n}prepareRequestConfig(e,t,n){const{publicKeyId:i}=e,r=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["publicKeyId"]);return Object.assign(Object.assign({createCheckoutSessionConfig:this.isEnvironmentSpecific(i)?r:e},t&&{estimatedOrderAmount:t}),n&&{productType:n})}createAmazonPayButtonParentContainer(){const e=Math.random().toString(16).substr(-4),t=document.createElement("div");return t.id=`amazonpay_button_parent_container_${e}`,t}getAmazonPayV2ButtonOptions(e,t,n,i=!1,r=wr.Gold){var o;const{getCart:a,getCheckout:s,getStoreConfigOrThrow:d,getPaymentMethodOrThrow:c}=this.getCheckoutState(e),{config:{merchantId:u,testMode:l},initializationData:h}=c(t);if(!h)throw new gr(hr.MissingPaymentMethod);const{checkoutLanguage:p,checkoutSessionMethod:g,createCheckoutSessionConfig:m,extractAmazonCheckoutSessionId:y,ledgerCurrency:f,publicKeyId:_=""}=h;if(!u||!f)throw new gr(hr.MissingPaymentMethod);const S={merchantId:u,ledgerCurrency:f,checkoutLanguage:p,placement:n,buttonColor:r};if(this.isBuyNowFlow)return Object.assign(Object.assign({},S),{sandbox:!!l});const v=a();S.productType=v&&0===mr(v)?Ir.PayOnly:Ir.PayAndShip;const{checkoutSettings:{features:C},storeProfile:{shopPath:I,storeCountryCode:w}}=d();if(this.isPh4Enabled(C,w)){if(!m)throw new gr(hr.MissingPaymentMethod);const e=null===(o=s())||void 0===o?void 0:o.outstandingBalance.toString(),t=null==v?void 0:v.currency.code,n=Object.assign({},S);let r;return this.isEnvironmentSpecific(_)?(n.publicKeyId=_,r=m):(n.sandbox=!!l,r=Object.assign(Object.assign({},m),{publicKeyId:_})),i||(n.createCheckoutSessionConfig=r),e&&t&&(n.estimatedOrderAmount={amount:e,currencyCode:t}),n}const E={method:g,url:`${I}/remote-checkout/${t}/payment-session`,extractAmazonCheckoutSessionId:y};return Object.assign(Object.assign({},S),{createCheckoutSession:E,sandbox:!!l})}isEnvironmentSpecific(e){return/^(SANDBOX|LIVE)/.test(e)}getAmazonPayV2SDK(){return this.getOrThrow(this.amazonPayV2SDK)}getButtonParentContainer(){return this.getOrThrow(this.buttonParentContainer)}getAmazonPayV2Button(){return this.getOrThrow(this.amazonPayV2Button)}getOrThrow(e){return yr(e,()=>new fr(pr.PaymentNotInitialized))}getCheckoutState(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:t=>e.paymentMethods.getPaymentMethodOrThrow(t)}:e;var t}}class Pr extends ve{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}class Or{constructor(e,t=window){this.scriptLoader=e,this.windowWithAmazonPay=t}load(e){return t=this,n=void 0,r=function*(){const{initializationData:t}=e,n=(null==t?void 0:t.region)||"us",i=_r[n];if(yield this.scriptLoader.loadScript(`https://static-${i}.payments-amazon.com/checkout.js`),!this.windowWithAmazonPay.amazon)throw new Pr;return this.windowWithAmazonPay.amazon},new((i=void 0)||(i=Promise))(function(e,o){function a(e){try{d(r.next(e))}catch(e){o(e)}}function s(e){try{d(r.throw(e))}catch(e){o(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,s)}d((r=r.apply(t,n||[])).next())});var t,n,i,r}}function Ar(e,t){return Object.assign(e,{resolveIds:t})}class Tr extends ve{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class kr extends ve{constructor(e){super(e||"An unexpected error has occurred during buy now cart creation process. Please try again later."),this.name="BuyNowCartCreationError",this.type="buy_now_cart_creation_error"}}class Rr extends ve{constructor(e){super(e||"An unexpected error has occurred during config creation process. Please try again later."),this.name="AmazonPayV2ConfigCreationError",this.type="amazon_pay_v2_config_creation_error"}}function Dr(e){return e instanceof Object&&"buyNowInitializeOptions"in e}var Mr=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Nr{constructor(e,t,n){this.paymentIntegrationService=e,this.amazonPayV2PaymentProcessor=t,this.amazonPayV2ConfigRequestSender=n}initialize(e){return Mr(this,void 0,void 0,function*(){var t;const{methodId:n,containerId:i,amazonpay:r}=e,{buttonColor:o}=r||{};if(!n||!i)throw new Tr('Unable to proceed because "methodId" or "containerId" argument is not provided.');const{getPaymentMethodOrThrow:a}=this.paymentIntegrationService.getState(),s=a(n);yield this.amazonPayV2PaymentProcessor.initialize(s),r||(yield this.paymentIntegrationService.loadDefaultCheckout());const d=Dr(r)?void 0:r;Dr(r)&&"function"==typeof(null===(t=r.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody)&&(this._buyNowInitializeOptions=r.buyNowInitializeOptions,this.amazonPayV2PaymentProcessor.updateBuyNowFlowFlag(!0)),this.amazonPayV2PaymentProcessor.renderAmazonPayButton({checkoutState:this.paymentIntegrationService.getState(),containerId:i,methodId:n,options:d,placement:vr.Cart,buttonColor:o}),this._buyNowInitializeOptions&&this.amazonPayV2PaymentProcessor.prepareCheckoutWithCreationRequestConfig(this._getCheckoutCreationRequestConfig.bind(this))})}deinitialize(){return this.amazonPayV2PaymentProcessor.deinitialize()}_createBuyNowCartOrThrow(){return Mr(this,void 0,void 0,function*(){var e,t;const n=null===(t=null===(e=this._buyNowInitializeOptions)||void 0===e?void 0:e.getBuyNowCartRequestBody)||void 0===t?void 0:t.call(e);if(!n)throw new gr(hr.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(n)}catch(e){throw new kr}})}_createCheckoutConfig(e){return Mr(this,void 0,void 0,function*(){try{const t=(yield this.amazonPayV2ConfigRequestSender.createCheckoutConfig(e)).body,{payload:n,public_key:i}=t,r=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["payload","public_key"]);return Object.assign({payloadJSON:n,publicKeyId:i},r)}catch(e){throw new Rr}})}_getCheckoutCreationRequestConfig(){return Mr(this,void 0,void 0,function*(){const e=yield this._createBuyNowCartOrThrow(),t={amount:String(e.baseAmount),currencyCode:e.currency.code};return{createCheckoutSessionConfig:yield this._createCheckoutConfig(e.id),estimatedOrderAmount:t,productType:0===mr(e)?Ir.PayOnly:Ir.PayAndShip}})}}const Lr="This API endpoint is for internal use only and may change in the future";var zr;!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(zr||(zr={}));const Ur=zr,Fr={"X-Checkout-SDK-Version":"1.934.0"};class Br{constructor(e){this._requestSender=e}createCheckoutConfig(e){const t={cartId:e},n=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return this._requestSender.post("/api/storefront/payment/amazonpay",{headers:n,body:t})}}const xr=Ar(t=>{const n=e(),i=new Br(n),r=new br(new Or(le()));return new Nr(t,r,i)},[{id:"amazonpay"}]);function qr(e,t,n=!0){var i;return null!==(i=e[t])&&void 0!==i?i:n}const jr="3.128.0",Gr="3.123.2",Vr="3.106.0";class Hr{constructor(e){this.paymentIntegrationService=e,this.braintreeWindow=window}getSDKVersion(){const e=this.paymentIntegrationService.getState().getStoreConfig(),t=(null==e?void 0:e.checkoutSettings.features)||{};return this.getPreloadedSDKVersion()||(qr(t,"PAYPAL-5809.braintree_hosted_fields_fix_version")?jr:qr(t,"PAYPAL-5636.update_braintree_sdk_version")?Gr:Vr)}getPreloadedSDKVersion(){const e=this.braintreeWindow.braintree;if(e){const t=l(Object.values(e),e=>!!e.VERSION);return null==t?void 0:t.VERSION}}}class Wr extends ve{constructor(e){super(e||"Unsupported browser error"),this.name="UnsupportedBrowserError",this.type="unsupported_browser"}}var Yr,Kr,$r,Zr,Jr,Qr,Xr;function eo(e){return Boolean("object"==typeof e&&null!==e&&("type"in e||"message"in e||"code"in e))}!function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(Yr||(Yr={})),function(e){e.Completed="COMPLETED",e.Pending="PENDING",e.Failed="FAILED"}(Kr||(Kr={})),function(e){e.TRUSTLY="trustly"}($r||($r={})),function(e){e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="cancelled",e.UNRECOGNIZED="unrecognized"}(Zr||(Zr={})),function(e){e.Customer="CUSTOMER",e.Merchant="MERCHANT",e.Network="NETWORK",e.Internal="INTERNAL",e.Unknown="UNKNOWN"}(Jr||(Jr={})),function(e){e.KountNotEnabled="DATA_COLLECTOR_KOUNT_NOT_ENABLED"}(Qr||(Qr={})),function(e){e.Visa="visa",e.Mastercard="mastercard",e.AmericanExpress="american-express",e.DinersClub="diners-club",e.Discover="discover",e.Jcb="jcb",e.UnionPay="union-pay",e.Maestro="maestro",e.Elo="elo",e.Mir="mir",e.Hiper="hiper",e.Hipercard="hipercard"}(Xr||(Xr={}));var to,no,io,ro=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class oo{constructor(e){this.braintreeScriptLoader=e}initialize(e){this.setClientToken(e)}deinitialize(){return ro(this,void 0,void 0,function*(){yield this.teardownModule(this.dataCollector),this.dataCollector=void 0})}getClient(){return ro(this,void 0,void 0,function*(){if(!this.client){const e=this.getClientTokenOrThrow(),t=yield this.braintreeScriptLoader.loadClient();this.client=yield t.create({authorization:e})}return this.client})}getDataCollectorOrThrow(e){return ro(this,void 0,void 0,function*(){const t={deviceData:void 0,teardown:()=>Promise.resolve()};if(!this.dataCollector)try{const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadDataCollector(),i=Object.assign({client:t,kount:!0},e);this.dataCollector=yield n.create(i)}catch(e){if(eo(e)&&e.code===Qr.KountNotEnabled)return t;throw e}return this.dataCollector})}getBraintreeGooglePayment(){return ro(this,void 0,void 0,function*(){if(!this.googlePayment){const[e,t]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadGooglePayment()]);this.googlePayment=yield t.create({client:e})}return this.googlePayment})}getBraintreeThreeDS(){return ro(this,void 0,void 0,function*(){if(!this.threeDS){const[e,t]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()]);this.threeDS=yield t.create({client:e,version:2})}return this.threeDS})}getBraintreeLocalPayment(e){return ro(this,void 0,void 0,function*(){if(!this.braintreeLocalPayment){const[t,n]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadLocalPayment()]);this.braintreeLocalPayment=yield new Promise((i,r)=>{n.create({client:t,merchantAccountId:e},(e,t)=>{e&&r(e),i(t)})})}return this.braintreeLocalPayment})}getUsBankAccount(){return ro(this,void 0,void 0,function*(){if(!this.usBankAccount){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadUsBankAccount();this.usBankAccount=yield t.create({client:e})}return this.usBankAccount})}getBraintreeVisaCheckout(){return this.visaCheckout||(this.visaCheckout=Promise.all([this.getClient(),this.braintreeScriptLoader.loadVisaCheckout()]).then(([e,t])=>t.create({client:e}))),this.visaCheckout}getVisaCheckoutSdk(e){return ro(this,void 0,void 0,function*(){return this.visaCheckoutSDK||(this.visaCheckoutSDK=yield this.braintreeScriptLoader.loadVisaCheckoutSdk(e)),this.visaCheckoutSDK})}getVenmoCheckoutOrThrow(){return ro(this,void 0,void 0,function*(){if(!this.braintreeVenmo){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadVenmoCheckout(),n={client:e,allowDesktop:!0,paymentMethodUsage:"multi_use"},i=yield t.create(n);if(!i.isBrowserSupported())throw new Wr;this.braintreeVenmo=i}return this.braintreeVenmo})}setClientToken(e){this.clientToken=e}getClientTokenOrThrow(){if(!this.clientToken)throw new fr(pr.PaymentNotInitialized);return this.clientToken}teardownModule(e){return e?e.teardown():Promise.resolve()}}!function(e){e.Sandbox="sandbox",e.Production="production"}(to||(to={})),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"}(no||(no={})),function(e){e.CardCode="cardCode",e.CardCodeVerification="cardCodeVerification",e.CardExpiry="cardExpiry",e.CardName="cardName",e.CardNumber="cardNumber",e.CardNumberVerification="cardNumberVerification"}(io||(io={}));const ao={[Vr]:{[no.Client]:"sha384-26BXDNnJI23JYRyFBj4xe4sVNrUSSiSSu11kxVXNM/vEPONm4LuL00w6ZaTgQewt",[no.PaypalCheckout]:"sha384-B+vzbZwnQtzWBthpkT4TXKUibO65tyeK7eCxSvpblgprTep2+IAXB2Cxxjrn710O",[no.Paypal]:"sha384-uyAGL1/3+XJAHnGoNy4eCoXdzJ4f7Ilzp+6w9PNnEjs6DCCz9WMyJjMN1gzc78U+",[no.LocalPayment]:"sha384-LIvOEMkIVEwVuYBdVOQc1AC5YbGGlwyfUheS0ACK218D2STuVYQlZ4FyEPowAEfT",[no.DataCollector]:"sha384-1bo9JDz+Kscthc085cCKWur8CLwUoBpoNyxsDi7932mCl0zFq3A5mv+FQLw9GHpV",[no.UsBankAccount]:"sha384-xmHBVaU+w74V+OebD3AaPONFxHUGMf+QRs8G/JxVPXNNP7MDa2jL0ICWHIe2tTfJ",[no.GooglePayment]:"sha384-WKDJl8mqoP82qZpMGH6AbZxnvXnSW8ILV4M64CyMLiugGMwu7LyP89wjCkHqsiBe",[no.ThreeDSecure]:"sha384-VQUlpGHzsGvs5XeiGFip7EXRsvoHWEXDVmgCacfbyieZI9mdBOqq3NSoyo28OCOB",[no.VisaCheckout]:"sha384-yx7mADfzTN0T43Q6rlH49LIg1EJ0iUZgBp/EczX9LXsUGkySgxrD+nWHQRBkyfoT",[no.Venmo]:"sha384-QX4rPjoj1ZDhuG0aSyKs56lEKDqTMTcjYxUHY1SzO5VZDsqIE2NTkqot7KNSCyov",[no.HostedFields]:"sha384-VvYBACfSu0Cr/J32uKmxG7AXcNOJE1AzIIL3kbikyS7YKp5fz5Is+NzNP/lyauNy",[no.Fastlane]:"sha384-9oGsZMRZwpGtDEDYa/dFt76dECqj1xAni9gIKgc3KfMIiRnR73nEeeUDLiBzxhFa"},[Gr]:{[no.Client]:"sha384-o+nbQGcwNNxIBeXeu3+XmbSq+Cg8R3EN3N0l5hXCgMMU2RGY0t1z0LroSEIAbfAO",[no.PaypalCheckout]:"sha384-WrfbWPBS4mH86GAoycPSgiH8hQ8KH7A67C93Hjhunv/xhNk2YpBn3wbFA4Fhg9U/",[no.Paypal]:"sha384-VF389nvvrRUgDsTXMxTYORDtVegB9IQa3Cxr//DyJnLYnz8/X8VCzEvck2c+Megt",[no.LocalPayment]:"sha384-tZKx2rEQbfmZpoPSY5VPmJEhaq4X75dLvwHMs3VE9U+C8lPyw+hWTIL1+GPvWCIH",[no.DataCollector]:"sha384-E6k3wOpP7syCDDwaRDLF06942Y00NkbwJvWi2OQXwwKzGwG5fd3E7RFUvCCecfvO",[no.UsBankAccount]:"sha384-258FON8LZGG0W9Qaz4Jij83pZHu30YnKjJA7gNulLBh6CclkucgF+tHDQuYFRYfW",[no.GooglePayment]:"sha384-taJ2p/0+n0VH328POAoBiuEbL3tnHUTE9S42hK1V+Txs3X+QYjZOyKW35JgHRFfO",[no.ThreeDSecure]:"sha384-+NSZH4Zj3sO5bdWvPKhU5N16QDxeueTVTnUVeleeESkhLSaz4Ob1hh/5myecc9Ym",[no.VisaCheckout]:"sha384-66DiBjghxk1OmBj8aksN8gbQ+CwoQcx1vPfiXUN08g1iQVM+BwewF0p7toM3i7SS",[no.Venmo]:"sha384-B5UwY42kE4RoLoWbQ7YpqosUlUad2/DlGWiw0HhoZbSPk30CQAaSA10ohyLDTkDU",[no.HostedFields]:"sha384-Aw9EesSaUeWxe36PqEHiOyOyOq8M6CIb1gw7/yHNVPRzGtFXXcd2OQ8qXrIlOj2P",[no.Fastlane]:"sha384-rhBL1hpZ71JqG+2TsT0Dih47mbjx8cjJCpeZjk9tw3df1gFMKfCTmMyZunhr7H4Y"},[jr]:{[no.Client]:"sha384-0WNxksIpRP+fYZiIdr12g6DBUQfLDzYCQJZtR/C8KkcwSGhPHfcFp3tTaGcMyFTq",[no.PaypalCheckout]:"sha384-lWM1jk4BOxoDNV6Kop7tVNvQgINlmEVz0c/OwM+HNHK3QC8xqwd54Ovrt2QRDTjh",[no.Paypal]:"sha384-fXUmVxC2EMZBDXZ7eTHSTL/LFBrHej/MSXT/vTBXvra4lzgLNGvREAp+x0GYObuH",[no.LocalPayment]:"sha384-pha1xGuGSkmZH5x9aqHvRaO4xLea7rmQ/79PFj9zxNzxuFcOWZg7gOP7FibygOEC",[no.DataCollector]:"sha384-Q6PI2F9eekWbAxhroybl+aEcvqhdowN/EQlGwBUyJOzPFn9982u9xl6SU6XfGKzc",[no.UsBankAccount]:"sha384-W3RLQSKJL1tQ3+Y7mP6tmkamtZ8bV4Yw/XxL9Jj5JtXHraD8loMF8hAIG5m2zK7F",[no.GooglePayment]:"sha384-TITQMsFWA3elDNGP2mWz2oKBo4qjt+TlqzovcaPoeBiAh/wPBi6nae50ADdgU1/i",[no.ThreeDSecure]:"sha384-YiycYN89ZlL/Evcaq4y1ajW1mhd7JYfZBDuOwHtIn4/Jnm20GL+/XCM+zYAwWD8D",[no.VisaCheckout]:"sha384-/OdaTv9qrkKzjObtUe6yzfDhHozFW/+uXlrSl736sOZRJpjGQETvpYXqMFFg69xv",[no.Venmo]:"sha384-dA+ojdW9vbJS4JavcXyOs9d5uZHJg5dNtYupoPSH2zsXIiYDVS5amLb/u8qmQ6oz",[no.HostedFields]:"sha384-31ZkS58+iaWsW06ftW52zzVZFp43WPd7pNYRiddYynSNg6Oh7WGbSFGorAUH6T1z",[no.Fastlane]:"sha384-jlbrwNvL3HvLAUCtLSmrnQ2GH1udCUrRS/bVmReAS5fuIVvcW8Pko/Gkg82tlgtr"}};var so,co=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class uo{constructor(e,t,n){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSDKVersionManager=n}loadClient(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.Client,"client.min.js")})}loadFastlane(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.Fastlane,"fastlane.min.js")})}loadPaypalCheckout(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.PaypalCheckout,"paypal-checkout.min.js")})}loadPaypal(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.Paypal,"paypal.min.js")})}loadLocalPayment(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.LocalPayment,"local-payment.min.js")})}loadDataCollector(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.DataCollector,"data-collector.min.js")})}loadUsBankAccount(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.UsBankAccount,"us-bank-account.min.js")})}loadGooglePayment(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.GooglePayment,"google-payment.min.js")})}load3DS(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.ThreeDSecure,"three-d-secure.min.js")})}loadVisaCheckout(){return this.loadBraintreeModuleOrThrow(no.VisaCheckout,"visa-checkout.min.js")}loadVenmoCheckout(){return this.loadBraintreeModuleOrThrow(no.Venmo,"venmo.min.js")}loadHostedFields(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.HostedFields,"hosted-fields.min.js")})}loadVisaCheckoutSdk(e){return co(this,void 0,void 0,function*(){if(this.braintreeHostWindow.V)return this.braintreeHostWindow.V;const t=e?"sha384-0eu1s1GtqzXlL9DtLgmwzC5WWlEH/ADRM0n38cVQkvtT+W/gey96rcb1LwuUOPDm":"sha384-1f1csvP3ZFxg4dILH1GaY4LHlZ0oX7Rk83rxmLlwbnIi4TM0NYzXoev1VoEiVDS6";return this.scriptLoader.loadScript(`//${e?"sandbox-":""}assets.secure.checkout.visa.com/checkout-widget/resources/js/integration/v1/sdk.js`,{async:!0,attributes:{integrity:t,crossorigin:"anonymous"}}).then(()=>{if(!this.braintreeHostWindow.V)throw new Pr;return this.braintreeHostWindow.V})})}loadBraintreeModuleOrThrow(e,t){return co(this,void 0,void 0,function*(){let n=this.getBraintreeModule(e);if(n)return n;const i=this.braintreeSDKVersionManager.getSDKVersion(),r=`//js.braintreegateway.com/web/${i}/js/${t}`,o=i in ao?this.getIntegrityValuesByModuleName(e,i):void 0;if(yield this.scriptLoader.loadScript(r,o?{async:!0,attributes:{integrity:o,crossorigin:"anonymous"}}:void 0),n=this.getBraintreeModule(e),!n)throw new Pr;return n})}getBraintreeModule(e){var t;return null===(t=this.braintreeHostWindow.braintree)||void 0===t?void 0:t[e]}getIntegrityValuesByModuleName(e,t){const n=ao[t][e];if(!n)throw new Error("Unexpected fileName value");return n}}class lo extends ve{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}!function(e){e.BRAINTREE="braintree",e.BRAINTREE_FASTLANE="braintreeacceleratedcheckout"}(so||(so={}));var ho,po,go=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};!function(e){e.Subtotal="Subtotal",e.Shipping="Shipping"}(ho||(ho={})),function(e){e.Black="black",e.White="white",e.WhiteBorder="white-border"}(po||(po={}));class mo{constructor(e,t,n,i,r){this._requestSender=e,this._paymentIntegrationService=t,this._sessionFactory=n,this._braintreeSdk=i,this._applePayScriptLoader=r,this._onAuthorizeCallback=T,this._subTotalLabel=ho.Subtotal,this._shippingLabel=ho.Shipping}initialize(e){return go(this,void 0,void 0,function*(){var t,n;const{methodId:i,containerId:r,applepay:o}=e;if(!i||!o)throw new gr(hr.MissingPaymentMethod);yield this._applePayScriptLoader.loadSdk();const{onPaymentAuthorize:a,buyNowInitializeOptions:s,requiresShipping:d}=o;this._requiresShipping=d,this._buyNowInitializeOptions=s,this._onAuthorizeCallback=a,s||(yield this._paymentIntegrationService.loadDefaultCheckout());const c=this._paymentIntegrationService.getState();return this._paymentMethod=c.getPaymentMethodOrThrow(i),c.getCart()&&(yield this._paymentIntegrationService.verifyCheckoutSpamProtection()),(null===(t=this._paymentMethod.initializationData)||void 0===t?void 0:t.gateway)===so.BRAINTREE&&this._paymentMethod.clientToken&&this._braintreeSdk.initialize(this._paymentMethod.clientToken),this._applePayButton=this._createButton(r,null===(n=this._paymentMethod.initializationData)||void 0===n?void 0:n.styleOption),this._applePayButton.addEventListener("click",this._handleWalletButtonClick.bind(this)),Promise.resolve()})}deinitialize(){return Promise.resolve()}_createButton(e,t){const n=document.getElementById(e);if(!n)throw new Tr("Unable to create wallet button without valid container ID.");const i=this._createApplePayButtonElement(t);return n.appendChild(i),i}_createApplePayButtonElement(e){const t=document.createElement("apple-pay-button");return t.setAttribute("buttonstyle",(e=>{switch(e){case po.White:return"white";case po.WhiteBorder:return"white-outline";case po.Black:default:return"black"}})(e)),t.setAttribute("type","plain"),t.setAttribute("style","--apple-pay-button-width: 100%; --apple-pay-button-height: 40px; --apple-pay-button-border-radius: 4px;"),t}_handleWalletButtonClick(e){return go(this,void 0,void 0,function*(){var t;if(e.preventDefault(),!this._paymentMethod||!this._paymentMethod.initializationData)throw new gr(hr.MissingPaymentMethod);if(this._buyNowInitializeOptions&&"function"==typeof this._buyNowInitializeOptions.getBuyNowCartRequestBody){const{countryCode:e,currencyCode:n,merchantCapabilities:i,supportedNetworks:r,storeName:o}=this._paymentMethod.initializationData,a=this._getRequestWithEmptyTotal(e,n,r,i);this._requiresShipping&&(null===(t=a.requiredShippingContactFields)||void 0===t||t.push("postalAddress"));const s=this._sessionFactory.create(a);this._handleApplePayEvents(s,this._paymentMethod,o),s.begin()}else{const e=this._paymentIntegrationService.getState(),t=e.getCartOrThrow(),n=e.getStoreConfigOrThrow(),i=e.getCheckoutOrThrow(),r=this._getBaseRequest(t,i,n,this._paymentMethod),o=this._sessionFactory.create(r);this._handleApplePayEvents(o,this._paymentMethod,n.storeProfile.storeName),o.begin()}})}_getRequestWithEmptyTotal(e,t,n,i){return{countryCode:e,currencyCode:t,supportedNetworks:n,merchantCapabilities:i,total:{label:"",amount:"0",type:"pending"},requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:["email","phone"]}}_getBaseRequest(e,t,n,i){var r;const{storeProfile:{storeCountryCode:o,storeName:a}}=n,{currency:{code:s,decimalPlaces:d}}=e,{initializationData:{merchantCapabilities:c,supportedNetworks:u}}=i,l=e.lineItems.physicalItems.length>0,h={requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:["email","phone"],countryCode:o,currencyCode:s,merchantCapabilities:c,supportedNetworks:u,lineItems:[],total:l?{label:a,amount:`${t.grandTotal.toFixed(d)}`,type:"pending"}:{label:a,amount:`${t.grandTotal.toFixed(d)}`,type:"final"}};if(l)null===(r=h.requiredShippingContactFields)||void 0===r||r.push("postalAddress");else{const e=[{label:this._subTotalLabel,amount:`${t.subtotal.toFixed(d)}`}];t.taxes.forEach(t=>e.push({label:t.name,amount:`${t.amount.toFixed(d)}`})),h.lineItems=e}return h}_handleApplePayEvents(e,t,n){e.onvalidatemerchant=n=>go(this,void 0,void 0,function*(){try{const{body:i}=yield this._onValidateMerchant(t,n);e.completeMerchantValidation(i)}catch(e){throw new Error("Merchant validation failed")}}),this._buyNowInitializeOptions&&!this._requiresShipping&&(e.onpaymentmethodselected=()=>go(this,void 0,void 0,function*(){yield this._createBuyNowCart(),this._handlePaymentMethodSelected(e)})),e.onshippingcontactselected=t=>go(this,void 0,void 0,function*(){this._buyNowInitializeOptions&&this._requiresShipping&&(yield this._createBuyNowCart()),yield this._handleShippingContactSelected(e,n,t)}),e.onshippingmethodselected=t=>go(this,void 0,void 0,function*(){yield this._handleShippingMethodSelected(e,n,t)}),e.oncancel=()=>go(this,void 0,void 0,function*(){try{const e=`/remote-checkout/${t.id}/signout`;return yield this._requestSender.get(e),yield this._paymentIntegrationService.loadCheckout()}catch(e){throw new lo}}),e.onpaymentauthorized=n=>go(this,void 0,void 0,function*(){return this._onPaymentAuthorized(n,e,t)})}_createBuyNowCart(){return go(this,void 0,void 0,function*(){var e,t;try{const n=null===(t=null===(e=this._buyNowInitializeOptions)||void 0===e?void 0:e.getBuyNowCartRequestBody)||void 0===t?void 0:t.call(e);if(!n)throw new gr(hr.MissingCart);const i=yield this._paymentIntegrationService.createBuyNowCart(n);yield this._paymentIntegrationService.loadCheckout(i.id);const r=this._paymentIntegrationService.getState(),{shouldExecuteSpamCheck:o}=r.getCheckoutOrThrow();o&&(yield this._paymentIntegrationService.verifyCheckoutSpamProtection())}catch(e){throw new kr}})}_handlePaymentMethodSelected(e){const t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow(),i=t.getStoreConfigOrThrow(),r=t.getCheckoutOrThrow();if(!this._paymentMethod||!this._paymentMethod.initializationData)throw new gr(hr.MissingPaymentMethod);const o=this._getBaseRequest(n,r,i,this._paymentMethod);delete o.total.type,e.completePaymentMethodSelection({newTotal:o.total,newLineItems:o.lineItems})}_handleShippingContactSelected(e,t,n){return go(this,void 0,void 0,function*(){var i;const r=this._transformContactToAddress(n.shippingContact);try{yield this._paymentIntegrationService.updateShippingAddress(r)}catch(t){throw e.abort(),new Error("Shipping address update failed")}let o=this._paymentIntegrationService.getState();const{currency:{decimalPlaces:a}}=o.getCartOrThrow();let s=o.getCheckoutOrThrow();const d=null===(i=s.consignments[0].selectedShippingOption)||void 0===i?void 0:i.id,c=s.consignments[0].availableShippingOptions,u=null==c?void 0:c.find(({id:e})=>e===d),l=null==c?void 0:c.filter(e=>e.id!==d),h=u?[{label:u.description,amount:`${u.cost.toFixed(a)}`,detail:u.additionalDescription,identifier:u.id}]:[];if(l&&[...l.filter(e=>e.isRecommended),...l.filter(e=>!e.isRecommended)].forEach(e=>h.push({label:e.description,amount:`${e.cost.toFixed(a)}`,detail:e.additionalDescription,identifier:e.id})),!(c instanceof Array))throw new Error("Shipping options not available.");if(0===c.length)return void e.completeShippingContactSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,[],{type:"pending",label:t,amount:`${s.grandTotal.toFixed(a)}`},[]);const p=c.find(e=>e.isRecommended),g=p?p.id:c[0].id,m=u?u.id:g;try{yield this._updateShippingOption(m)}catch(e){throw new Error("Shipping options update failed")}o=this._paymentIntegrationService.getState(),s=o.getCheckoutOrThrow(),e.completeShippingContactSelection({newShippingMethods:h,newTotal:{type:"final",label:t,amount:`${s.grandTotal.toFixed(a)}`},newLineItems:this._getUpdatedLineItems(s,a)})})}_handleShippingMethodSelected(e,t,n){return go(this,void 0,void 0,function*(){const{shippingMethod:{identifier:i}}=n;try{yield this._updateShippingOption(i)}catch(t){throw e.abort(),new Error("Shipping option selection update failed.")}const r=this._paymentIntegrationService.getState(),{currency:{decimalPlaces:o}}=r.getCartOrThrow(),a=r.getCheckoutOrThrow();e.completeShippingMethodSelection({newTotal:{type:"final",label:t,amount:`${a.grandTotal.toFixed(o)}`},newLineItems:this._getUpdatedLineItems(a,o)})})}_getUpdatedLineItems(e,t){const n=[{label:this._subTotalLabel,amount:`${e.subtotal.toFixed(t)}`}];return e.taxes.forEach(e=>n.push({label:e.name,amount:`${e.amount.toFixed(t)}`})),n.push({label:this._shippingLabel,amount:`${e.shippingCostTotal.toFixed(t)}`}),n}_updateShippingOption(e){return go(this,void 0,void 0,function*(){return this._paymentIntegrationService.selectShippingOption(e)})}_onValidateMerchant(e,t){return go(this,void 0,void 0,function*(){const n=[`validationUrl=${t.validationURL}`,`merchantIdentifier=${e.initializationData.merchantId}`,`displayName=${e.initializationData.storeName}`,`domainName=${window.location.hostname}`].join("&");return this._requestSender.post(`${e.initializationData.paymentsUrl}/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})})}_onPaymentAuthorized(e,t,n){return go(this,void 0,void 0,function*(){var i;const{token:r,billingContact:o,shippingContact:a}=e.payment,s=this._paymentIntegrationService.getState().getCartOrThrow().lineItems.physicalItems.length>0;let d;(null===(i=n.initializationData)||void 0===i?void 0:i.gateway)===so.BRAINTREE&&(d=yield this._getBraintreeDeviceData());const c={methodId:n.id,paymentData:{deviceSessionId:d,formattedPayload:{apple_pay_token:{payment_data:r.paymentData,payment_method:r.paymentMethod,transaction_id:r.transactionIdentifier}}}},u=this._transformContactToAddress(o),l=this._transformContactToAddress(a),h=null==a?void 0:a.emailAddress,p=(null==a?void 0:a.phoneNumber)||"";try{return yield this._paymentIntegrationService.updateBillingAddress(Object.assign(Object.assign({},u),{email:h,phone:p})),s&&(yield this._paymentIntegrationService.updateShippingAddress(l)),yield this._paymentIntegrationService.submitOrder({useStoreCredit:!1}),yield this._paymentIntegrationService.submitPayment(c),t.completePayment(ApplePaySession.STATUS_SUCCESS),this._onAuthorizeCallback()}catch(e){throw t.completePayment(ApplePaySession.STATUS_FAILURE),new Error("Payment cannot complete")}})}_transformContactToAddress(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:[]}}_getBraintreeDeviceData(){return go(this,void 0,void 0,function*(){try{const{deviceData:e}=yield this._braintreeSdk.getDataCollectorOrThrow();return e}catch(e){}})}}function yo(e){if(!function(e){return"ApplePaySession"in e}(e))throw new Error("Apple pay is not supported")}class fo{create(e){return yo(window),new ApplePaySession(1,e)}}class _o{constructor(e){this.scriptLoader=e,this.sdkVersion="1.latest"}loadSdk(){return e=this,t=void 0,i=function*(){(function(e){return"ApplePaySDK"in e})(window)||(yield this.scriptLoader.loadScript(`https://applepay.cdn-apple.com/jsapi/${this.sdkVersion}/apple-pay-sdk.js`),yo(window))},new((n=void 0)||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())});var e,t,n,i}}const So=Ar(t=>{const{getHost:n}=t.getState(),i=new Hr(t);return new mo(e({host:n()}),t,new fo,new oo(new uo(le(),window,i)),new _o(new ce))},[{id:"applepay"}]);var vo,Co,Io,wo,Eo,bo,Po,Oo;!function(e){e.BuyNow="BUY_NOW",e.INVOICE="B2B_INVOICE"}(vo||(vo={})),function(e){e.Possible="POSSIBLE",e.No="NO",e.Unknown="UNKNOWN",e.Yes="YES"}(Co||(Co={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(Io||(Io={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(wo||(wo={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(Eo||(Eo={})),function(e){e.pill="pill",e.rect="rect"}(bo||(bo={})),function(e){e.OXXO="oxxo"}(Po||(Po={})),function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(Oo||(Oo={}));var Ao=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class To{constructor(e,t,n,i){this.formPoster=e,this.paymentIntegrationService=t,this.bigCommercePaymentsRequestSender=n,this.bigCommercePaymentsScriptLoader=i}loadPayPalSdk(e,t,n,i){return Ao(this,void 0,void 0,function*(){const r=this.paymentIntegrationService.getState(),o=t||r.getCartOrThrow().currency.code,a=r.getPaymentMethodOrThrow(e);return this.paypalSdk=yield this.bigCommercePaymentsScriptLoader.getPayPalSDK(a,o,n,i),this.paypalSdk})}getPayPalSdkOrThrow(){if(!this.paypalSdk)throw new Pr;return this.paypalSdk}createBuyNowCartOrThrow(e){return Ao(this,void 0,void 0,function*(){const t=e.getBuyNowCartRequestBody();if(!t)throw new gr(hr.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(t)}catch(e){throw new kr}})}createOrder(e,t){return Ao(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i}=yield this.bigCommercePaymentsRequestSender.createOrder(e,Object.assign({cartId:n},t));return i})}createOrderCardFields(e,t){return Ao(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i,setupToken:r}=yield this.bigCommercePaymentsRequestSender.createOrder(e,Object.assign({cartId:n},t));return Object.assign({orderId:i},r?{setupToken:r}:{})})}updateOrder(e){return Ao(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState(),n=t.getCartOrThrow();let i;e||(i=t.getConsignmentsOrThrow()[0]);try{yield this.bigCommercePaymentsRequestSender.updateOrder({availableShippingOptions:e?[]:null==i?void 0:i.availableShippingOptions,cartId:n.id,selectedShippingOption:e?null:null==i?void 0:i.selectedShippingOption})}catch(e){throw new Ie}})}getOrderStatus(e,t){return Ao(this,void 0,void 0,function*(){try{const{status:n}=yield this.bigCommercePaymentsRequestSender.getOrderStatus(e,t);return n}catch(e){throw new Ie}})}tokenizePayment(e,t){const n=this.paymentIntegrationService.getState().getCartOrThrow();if(!t)throw new gr(hr.MissingOrderId);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",action:"set_external_checkout",provider:e,order_id:t},n.source===vo.BuyNow&&{cart_id:n.id}))}submitPayment(e,t,n){return Ao(this,void 0,void 0,function*(){const i={formattedPayload:{vault_payment_instrument:null,set_as_default_stored_instrument:null,device_info:null,method_id:e,paypal_account:{order_id:t}}};yield this.paymentIntegrationService.submitPayment(Object.assign({methodId:e,paymentData:i},n?{gatewayId:n}:{}))})}getShippingOptionOrThrow(e){const t=this.paymentIntegrationService.getState().getConsignmentsOrThrow()[0],n=t.availableShippingOptions||[],i=n.find(e=>e.isRecommended),r=(e?n.find(t=>t.id===e):n.find(e=>{var n;return e.id===(null===(n=t.selectedShippingOption)||void 0===n?void 0:n.id)}))||i||n[0];if(!r)throw new Error("Your order can't be shipped to this address");return r}getAddress(e){return{firstName:(null==e?void 0:e.firstName)||"",lastName:(null==e?void 0:e.lastName)||"",email:(null==e?void 0:e.email)||"",phone:(null==e?void 0:e.phone)||"",company:"",address1:(null==e?void 0:e.address1)||"",address2:(null==e?void 0:e.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:[]}}getBillingAddressFromOrderDetails({payer:e}){var t,n;return this.getAddress({firstName:e.name.given_name,lastName:e.name.surname,email:e.email_address,address1:e.address.address_line_1,address2:e.address.address_line_2,city:e.address.admin_area_2,countryCode:e.address.country_code,postalCode:e.address.postal_code,stateOrProvinceCode:e.address.admin_area_1,phone:null===(n=null===(t=e.phone)||void 0===t?void 0:t.phone_number)||void 0===n?void 0:n.national_number})}getShippingAddressFromOrderDetails(e){const{payer:t,purchase_units:n}=e,{address:i,name:{full_name:r}}=n[0].shipping,[o,...a]=r.split(" ");return this.getAddress({firstName:o,lastName:a.join(" "),email:t.email_address,address1:i.address_line_1,address2:i.address_line_2,city:i.admin_area_2,countryCode:i.country_code,postalCode:i.postal_code,stateOrProvinceCode:i.admin_area_1})}getValidButtonStyle(e){const{color:t,height:n,label:i,shape:r}=e||{},o={color:t&&Eo[t]?t:void 0,height:this.getValidHeight(n),label:i&&wo[i]?i:void 0,shape:r&&bo[r]?r:void 0};return R(o,v)}getValidHeight(e){return e&&"number"==typeof e?e>55?55:e<25?25:e:40}removeElement(e){const t=e&&document.getElementById(e);t&&(t.style.display="none")}}var ko=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ro{constructor(e){this.requestSender=e}createOrder(e,t){return ko(this,void 0,void 0,function*(){const n=`/api/storefront/payment/${e}`,i=t,r=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.post(n,{headers:r,body:i})).body})}updateOrder(e){return ko(this,void 0,void 0,function*(){const t=e,n=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.put("/api/storefront/initialization/bigcommerce_payments",{headers:n,body:t})).body})}getOrderStatus(){return ko(this,arguments,void 0,function*(e="bigcommerce_payments",t){const n=`/api/storefront/initialization/${e}`,i=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.get(n,Object.assign({headers:i},t))).body})}}var Do=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Mo{constructor(e){this.scriptLoader=e,this.window=window}getPayPalSDK(e,t,n,i){return Do(this,void 0,void 0,function*(){const r=this.getPayPalSdkScriptConfigOrThrow(e,t,n);return this.loadPayPalSDK(r,i)})}loadPayPalSDK(e){return Do(this,arguments,void 0,function*(e,t=!1){if(!this.window.bigCommercePaymentsPayPalSDK||t){const t=this.transformConfig(e.options),n=this.transformConfig(e.attributes),i=`https://www.paypal.com/sdk/js?${new URLSearchParams(t).toString()}`;yield this.scriptLoader.loadScript(i,{async:!0,attributes:n})}if(!this.window.bigCommercePaymentsPayPalSDK)throw new Pr;return this.window.bigCommercePaymentsPayPalSDK})}getPayPalSdkScriptConfigOrThrow(e,t,n=!0){const{id:i,clientToken:r,initializationData:o}=e;if(!(null==o?void 0:o.clientId))throw new gr(hr.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,buyerCountry:c,attributionId:u,isVenmoEnabled:l,isHostedCheckoutEnabled:h,isPayPalCreditAvailable:p,isDeveloperModeApplicable:g,availableAlternativePaymentMethods:m=[],enabledAlternativePaymentMethods:y=[],isGooglePayEnabled:f}=o,_=h||n,S="bigcommerce_payments_creditcards"===i,v=S?["card"]:[],C=S?[]:["card"],I=p?["credit","paylater"]:[],w=p?[]:["credit","paylater"],E=l?["venmo"]:[],b=l?[]:["venmo"],P=m.filter(e=>!y.includes(e)),O=f?["googlepay"]:[],A=n?["card-fields"]:[],T=this.filterFundingOptions([...C,...w,...b,...P]),k=this.filterFundingOptions([...v,...I,...E,...y]);return{options:Object.assign({"client-id":s,"merchant-id":d,"enable-funding":k.length>0?k:void 0,"disable-funding":T.length>0?T:void 0,commit:_,components:["buttons","hosted-fields","payment-fields","legal",...O,...A],currency:t,intent:a},g&&{"buyer-country":c}),attributes:{"data-partner-attribution-id":u,"data-client-token":r,"data-namespace":"bigCommercePaymentsPayPalSDK"}}}filterFundingOptions(e){const t=["klarna","afterpay"];return e?e.filter(e=>!t.includes(e)):[]}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}const No=t=>{const{getHost:i}=t.getState();return new To(n(),t,new Ro(e({host:i()})),new Mo(le()))};var Lo=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class zo{constructor(e,t){this.paymentIntegrationService=e,this.bigCommercePaymentsIntegrationService=t}initialize(e){return Lo(this,void 0,void 0,function*(){var t;const{bigcommerce_payments:n,containerId:i,methodId:r}=e,o=Boolean(null==n?void 0:n.buyNowInitializeOptions);if(!r)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.bigcommerce_payments" argument is not provided.');if(o&&!n.currencyCode)throw new Tr('Unable to initialize payment because "options.bigcommerce_payments.currencyCode" argument is not provided.');if(o&&"function"!=typeof(null===(t=n.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody))throw new Tr('Unable to initialize payment because "options.bigcommerce_payments.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');o||(yield this.paymentIntegrationService.loadDefaultCheckout());const a=o?n.currencyCode:this.paymentIntegrationService.getState().getCartOrThrow().currency.code;yield this.bigCommercePaymentsIntegrationService.loadPayPalSdk(r,a,!1),this.renderButton(i,r,n)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onComplete:o,onEligibilityFailure:a}=n,s=this.bigCommercePaymentsIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),{isHostedCheckoutEnabled:c,isServerSideShippingCallbacksEnabled:u}=d.initializationData||{},l={createOrder:()=>this.bigCommercePaymentsIntegrationService.createOrder("bigcommerce_payments"),onApprove:({orderID:e})=>this.bigCommercePaymentsIntegrationService.tokenizePayment(t,e)},h={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},p=Object.assign(Object.assign({},!u&&{onShippingAddressChange:e=>this.onShippingAddressChange(e),onShippingOptionsChange:e=>this.onShippingOptionsChange(e)}),{onApprove:(e,n)=>this.onHostedCheckoutApprove(e,n,t,o,u)}),g=Object.assign(Object.assign(Object.assign({fundingSource:s.FUNDING.PAYPAL,style:this.bigCommercePaymentsIntegrationService.getValidButtonStyle(r)},l),i&&h),c&&p),m=s.Buttons(g);m.isEligible()?m.render(`#${e}`):a&&"function"==typeof a?a():this.bigCommercePaymentsIntegrationService.removeElement(e)}handleClick(e){return Lo(this,void 0,void 0,function*(){if(e){const t=yield this.bigCommercePaymentsIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}onHostedCheckoutApprove(e,t,n,i,r){return Lo(this,void 0,void 0,function*(){if(!e.orderID)throw new gr(hr.MissingOrderId);const o=this.paymentIntegrationService.getState().getCartOrThrow();try{const a=o.lineItems.physicalItems.length>0;if(!r){const e=yield t.order.get(),n=this.bigCommercePaymentsIntegrationService.getBillingAddressFromOrderDetails(e);if(yield this.paymentIntegrationService.updateBillingAddress(n),a){const t=this.bigCommercePaymentsIntegrationService.getShippingAddressFromOrderDetails(e);yield this.paymentIntegrationService.updateShippingAddress(t)}}return a&&(yield this.bigCommercePaymentsIntegrationService.updateOrder(r)),r&&(yield this.paymentIntegrationService.loadCheckout()),yield this.paymentIntegrationService.submitOrder({},{params:{methodId:n}}),yield this.bigCommercePaymentsIntegrationService.submitPayment(n,e.orderID),i&&"function"==typeof i&&i(),!0}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingAddressChange(e){return Lo(this,void 0,void 0,function*(){const t=this.bigCommercePaymentsIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state});try{yield this.paymentIntegrationService.updateBillingAddress(t),yield this.paymentIntegrationService.updateShippingAddress(t);const e=this.bigCommercePaymentsIntegrationService.getShippingOptionOrThrow();yield this.paymentIntegrationService.selectShippingOption(e.id),yield this.bigCommercePaymentsIntegrationService.updateOrder()}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingOptionsChange(e){return Lo(this,void 0,void 0,function*(){const t=this.bigCommercePaymentsIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id);try{yield this.paymentIntegrationService.selectShippingOption(t.id),yield this.bigCommercePaymentsIntegrationService.updateOrder()}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}}const Uo=Ar(e=>new zo(e,No(e)),[{id:"bigcommerce_payments"}]);var Fo=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Bo{constructor(e,t){this.paymentIntegrationService=e,this.bigCommercePaymentsIntegrationService=t}initialize(e){return Fo(this,void 0,void 0,function*(){const{bigcommerce_payments_paylater:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,currencyCode:o}=t||{},a=!!r;if(!i)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Tr('Unable to initialize payment because "options.bigcommerce_payments_paylater" argument is not provided.');if(a&&!o)throw new Tr('Unable to initialize payment because "options.bigcommerce_payments_paylater.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null==r?void 0:r.getBuyNowCartRequestBody))throw new Tr('Unable to initialize payment because "options.bigcommerce_payments_paylater.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');a||(yield this.paymentIntegrationService.loadDefaultCheckout());const s=this.paymentIntegrationService.getState(),d=a?o:s.getCartOrThrow().currency.code;yield this.bigCommercePaymentsIntegrationService.loadPayPalSdk(i,d,!1),this.renderButton(n,i,t)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onComplete:o,onEligibilityFailure:a}=n,s=this.bigCommercePaymentsIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),{isHostedCheckoutEnabled:c}=d.initializationData||{},u={createOrder:()=>this.bigCommercePaymentsIntegrationService.createOrder("bigcommerce_payments_paylater"),onApprove:({orderID:e})=>this.bigCommercePaymentsIntegrationService.tokenizePayment(t,e)},l={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},h={onShippingAddressChange:e=>this.onShippingAddressChange(e),onShippingOptionsChange:e=>this.onShippingOptionsChange(e),onApprove:(e,n)=>this.onHostedCheckoutApprove(e,n,t,o)},p=[s.FUNDING.PAYLATER,s.FUNDING.CREDIT];let g=!1;p.forEach(t=>{if(!g){const n=Object.assign(Object.assign(Object.assign({fundingSource:t,style:this.bigCommercePaymentsIntegrationService.getValidButtonStyle(r)},u),i&&l),c&&h),o=s.Buttons(n);o.isEligible()?(o.render(`#${e}`),g=!0):a&&"function"==typeof a&&a()}}),g||this.bigCommercePaymentsIntegrationService.removeElement(e)}handleClick(e){return Fo(this,void 0,void 0,function*(){if(e){const t=yield this.bigCommercePaymentsIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}onHostedCheckoutApprove(e,t,n,i){return Fo(this,void 0,void 0,function*(){if(!e.orderID)throw new gr(hr.MissingOrderId);const r=this.paymentIntegrationService.getState().getCartOrThrow(),o=yield t.order.get();try{const t=this.bigCommercePaymentsIntegrationService.getBillingAddressFromOrderDetails(o);if(yield this.paymentIntegrationService.updateBillingAddress(t),r.lineItems.physicalItems.length>0){const e=this.bigCommercePaymentsIntegrationService.getShippingAddressFromOrderDetails(o);yield this.paymentIntegrationService.updateShippingAddress(e),yield this.bigCommercePaymentsIntegrationService.updateOrder()}return yield this.paymentIntegrationService.submitOrder({},{params:{methodId:n}}),yield this.bigCommercePaymentsIntegrationService.submitPayment(n,e.orderID),i&&"function"==typeof i&&i(),!0}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingAddressChange(e){return Fo(this,void 0,void 0,function*(){const t=this.bigCommercePaymentsIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state});try{yield this.paymentIntegrationService.updateBillingAddress(t),yield this.paymentIntegrationService.updateShippingAddress(t);const e=this.bigCommercePaymentsIntegrationService.getShippingOptionOrThrow();yield this.paymentIntegrationService.selectShippingOption(e.id),yield this.bigCommercePaymentsIntegrationService.updateOrder()}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingOptionsChange(e){return Fo(this,void 0,void 0,function*(){const t=this.bigCommercePaymentsIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id);try{yield this.paymentIntegrationService.selectShippingOption(t.id),yield this.bigCommercePaymentsIntegrationService.updateOrder()}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}}const xo=Ar(e=>new Bo(e,No(e)),[{id:"bigcommerce_payments_paylater"}]);var qo=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class jo{constructor(e,t){this.paymentIntegrationService=e,this.bigCommercePaymentsIntegrationService=t}initialize(e){return qo(this,void 0,void 0,function*(){const{bigcommerce_payments_venmo:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,currencyCode:o}=t||{},a=!!r;if(!i)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Tr('Unable to initialize payment because "options.bigcommerce_payments_venmo" argument is not provided.');if(a&&!o)throw new Tr('Unable to initialize payment because "options.bigcommerce_payments_venmo.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null==r?void 0:r.getBuyNowCartRequestBody))throw new Tr('Unable to initialize payment because "options.bigcommerce_payments_venmo.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');a||(yield this.paymentIntegrationService.loadDefaultCheckout());const s=a?o:this.paymentIntegrationService.getState().getCartOrThrow().currency.code;yield this.bigCommercePaymentsIntegrationService.loadPayPalSdk(i,s,!1),this.renderButton(n,i,t)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onEligibilityFailure:o}=n,a=this.bigCommercePaymentsIntegrationService.getPayPalSdkOrThrow(),s=a.FUNDING.VENMO,d={createOrder:()=>this.bigCommercePaymentsIntegrationService.createOrder("bigcommerce_payments_venmo"),onApprove:({orderID:e})=>this.bigCommercePaymentsIntegrationService.tokenizePayment(t,e)},c={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},u=Object.assign(Object.assign({fundingSource:s,style:this.getValidVenmoButtonStyles(r)},d),i&&c),l=a.Buttons(u);l.isEligible()?l.render(`#${e}`):o&&"function"==typeof o?o():this.bigCommercePaymentsIntegrationService.removeElement(e)}getValidVenmoButtonStyles(e){const t=this.bigCommercePaymentsIntegrationService.getValidButtonStyle(e);return t.color===Eo.gold?Object.assign(Object.assign({},t),{color:void 0}):t}handleClick(e){return qo(this,void 0,void 0,function*(){if(e){const t=yield this.bigCommercePaymentsIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}}const Go=Ar(e=>new jo(e,No(e)),[{id:"bigcommerce_payments_venmo"}]);class Vo extends ve{constructor(e){super(e||"Not implemented."),this.name="NotImplementedError",this.type="not_implemented"}}var Ho,Wo,Yo;!function(e){e.SandboxMode="bolt_sandbox",e.StagingMode="bolt_staging",e.DevelopmentMode="bolt_development"}(Ho||(Ho={})),function(e){e.Small="small",e.Medium="medium",e.Large="large"}(Wo||(Wo={})),function(e){e.Pill="pill",e.Rect="rect"}(Yo||(Yo={}));class Ko{constructor(e,t,n=window){this.paymentIntegrationService=e,this.boltScriptLoader=t,this.boltHostWindow=n}initialize(e){return t=this,n=void 0,r=function*(){const{bolt:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,style:o}=t||{};if(!i)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Tr('Unable to initialize payment because "options.bolt" argument is not provided.');if(!Boolean(r))throw new Vo("Only buy now flow is implemented for Bolt button");if(!(null==r?void 0:r.storefrontApiToken)||"string"!=typeof r.storefrontApiToken)throw new Tr('Unable to initialize payment because "options.storefrontApiToken" argument is not provided.');const a=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(i),{initializationData:s,config:d}=a,{publishableKey:c,developerConfig:u}=s||{};yield this.boltScriptLoader.loadBoltClient(c,d.testMode,u,"BigCommerce",r.storefrontApiToken),this.renderButton(n,a,o)},new((i=void 0)||(i=Promise))(function(e,o){function a(e){try{d(r.next(e))}catch(e){o(e)}}function s(e){try{d(r.throw(e))}catch(e){o(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,s)}d((r=r.apply(t,n||[])).next())});var t,n,i,r}deinitialize(){return Promise.resolve()}renderButton(e,t,n){var i;"function"==typeof(null===(i=this.boltHostWindow.BoltConnect)||void 0===i?void 0:i.setupProductPageCheckout)&&(this.addButtonContainer(e,t,n),this.boltHostWindow.BoltConnect.setupProductPageCheckout())}addButtonContainer(e,t,n){const i=document.getElementById(e);if(!i)return;const r=document.createElement("div"),o=document.createElement("object");r.setAttribute("id","product-page-checkout-wrapper"),r.setAttribute("class","bolt-button-wrapper"),r.setAttribute("style","display:none"),r.setAttribute("data-tid","product-page-checkout-wrapper"),o.setAttribute("data",this.getBoltObjectData(t,n)),o.setAttribute("class","bolt-product-checkout-button"),r.append(o),i.innerHTML="",i.append(r)}getBoltObjectData(e,t){const{initializationData:n,config:i}=e,{publishableKey:r,developerConfig:o}=n||{},a=this.boltScriptLoader.getDomainURL(!!i.testMode,o),s=this.getButtonHeight(null==t?void 0:t.size),d=this.getButtonBorderRadius(null==t?void 0:t.shape,s);return he({url:`https://${a}/v1/checkout_button`,query:{publishable_key:r,variant:"ppc",height:s,border_radius:d}})}getButtonHeight(e){if(e)switch(e){case Wo.Small:return 25;case Wo.Large:return 45;case Wo.Medium:default:return 40}}getButtonBorderRadius(e,t){if(e)switch(e){case Yo.Pill:return t?Math.round(t/2):void 0;case Yo.Rect:default:return 4}}}var $o=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Zo{constructor(e,t=window){this.scriptLoader=e,this.boltHostWindow=t}loadBoltClient(e,t,n,i,r){return $o(this,void 0,void 0,function*(){if(this.boltHostWindow.BoltCheckout)return this.boltHostWindow.BoltCheckout;if(!e)throw new Tr('Unable to initialize payment because "publishableKey" argument is not provided.');if(yield this.scriptLoader.loadScript(`//${this.getDomainURL(!!t,n)}/connect-bigcommerce.js`,this.getScriptOptions("bolt-connect",e,i,r)),yield this.scriptLoader.loadScript(`//${this.getDomainURL(!!t,n)}/track.js`,this.getScriptOptions("bolt-track",e)),!this.boltHostWindow.BoltCheckout)throw new Pr;return this.boltHostWindow.BoltCheckout})}loadBoltEmbedded(e,t,n){return $o(this,void 0,void 0,function*(){if(yield this.scriptLoader.loadScript(`//${this.getDomainURL(!!t,n)}/embed.js`,{async:!0,attributes:{id:"bolt-embedded"}}),!this.boltHostWindow.Bolt)throw new Pr;return this.boltHostWindow.Bolt(e)})}getDomainURL(e,t){if(!e)return"connect.bolt.com";if(t)switch(t.developerMode){case Ho.StagingMode:return"connect-staging.bolt.com";case Ho.DevelopmentMode:return`connect.${t.developerDomain}`}return"connect-sandbox.bolt.com"}getScriptOptions(e,t,n,i){return{async:!0,attributes:Object.assign(Object.assign({id:e,"data-publishable-key":t},n&&{"data-shopping-cart-id":n}),i&&{"data-storefront-api-token":i})}}}const Jo=Ar(e=>new Ko(e,new Zo(le())),[{id:"bolt"}]);class Qo extends Tr{constructor(e){let t="Unable to submit payment for the order because the payload is invalid.";e&&(t=`${t} Make sure the following fields are provided correctly: ${e.join(", ")}.`),super(t),this.name="PaymentArgumentInvalidError"}}class Xo extends ve{constructor(e,t){super(t||"Unable to proceed because the payment form contains invalid data."),this.details=e,this.name="PaymentInvalidFormError",this.type="payment_invalid_form"}}let ea=null;const ta=["buttons","messages"];var na,ia,ra,oa,aa,sa;!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(na||(na={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(ia||(ia={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white"}(ra||(ra={})),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"}(aa||(aa={})),function(e){e.CART="cart",e.HOME="homepage",e.PAYMENT="payment",e.PRODUCT="product"}(sa||(sa={}));var da=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ca{constructor(e,t,n){this.braintreeScriptLoader=e,this.braintreeHostWindow=t,this.overlay=n,this.dataCollectors={}}initialize(e,t){this.clientToken=e,this.threeDSecureOptions=t}getBraintreeFastlane(e,t,n){return da(this,void 0,void 0,function*(){if(t&&(window.localStorage.setItem("axoEnv","sandbox"),window.localStorage.setItem("fastlaneEnv","sandbox")),!this.braintreeHostWindow.braintreeFastlane){const t=this.getClientTokenOrThrow(),i=yield this.getClient(),r=yield this.getSessionId(e),o=yield this.braintreeScriptLoader.loadFastlane(),a={root:{backgroundColorPrimary:"transparent"}};this.braintreeHostWindow.braintreeFastlane=yield o.create({authorization:t,client:i,deviceData:r,styles:n||a})}return this.braintreeHostWindow.braintreeFastlane})}getClient(){return da(this,void 0,void 0,function*(){if(!this.client){const e=this.getClientTokenOrThrow(),t=yield this.braintreeScriptLoader.loadClient();this.client=t.create({authorization:e})}return this.client})}getPaypal(){return this.braintreePaypal||(this.braintreePaypal=Promise.all([this.getClient(),this.braintreeScriptLoader.loadPaypal()]).then(([e,t])=>t.create({client:e}))),this.braintreePaypal}paypal(e){var{shouldSaveInstrument:t}=e,n=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["shouldSaveInstrument"]);const i=pe();return this.getPaypal().then(e=>{var r;return i&&(null===(r=this.overlay)||void 0===r||r.show({onClick:()=>e.focusWindow()})),e.tokenize(Object.assign({enableShippingAddress:!0,flow:t?"vault":"checkout",useraction:"commit"},n))}).then(e=>{var t;return null===(t=this.overlay)||void 0===t||t.remove(),e}).catch(e=>{var t;throw null===(t=this.overlay)||void 0===t||t.remove(),e})}getPaypalCheckout(e,t,n){return da(this,void 0,void 0,function*(){const i=yield this.getClient(),r=yield this.braintreeScriptLoader.loadPaypalCheckout(),o={client:i};return this.paypalCheckout=yield r.create(o,(i,r)=>{var o;if(i)return n(i);const a=Object.assign(Object.assign({currency:e.currency},e.isCreditEnabled&&{"enable-funding":"paylater"}),{components:ta.toString(),intent:e.intent,commit:null===(o=e.commit)||void 0===o||o});this.braintreeHostWindow.paypal?t(r):function(e,t){return ea||(ea=new Promise((n,i)=>{e.loadPayPalSDK(t,t=>{t?(ea=null,i(t)):n(e)})})),ea}(r,a).then(()=>t(r))}),this.paypalCheckout})}getDataCollector(e){return da(this,void 0,void 0,function*(){const t=(null==e?void 0:e.paypal)?"paypal":"default";let n=this.dataCollectors[t];if(!n){try{const t=yield this.getClient(),i=yield this.braintreeScriptLoader.loadDataCollector(),r=Object.assign({client:t,kount:!0},e);n=yield i.create(r)}catch(e){if(!eo(e)||"DATA_COLLECTOR_KOUNT_NOT_ENABLED"!==e.code)throw e;n={deviceData:void 0,teardown:()=>Promise.resolve()}}this.dataCollectors[t]=n}return n})}getBraintreeEnv(e=!1){return e?to.Sandbox:to.Production}mapToBraintreeShippingAddressOverride(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}}mapToLegacyShippingAddress(e){const{email:t,phone:n,shippingAddress:i}=e,r=(null==i?void 0:i.recipientName)||"",[o,a]=r.split(" ");return{email:t,first_name:o||"",last_name:a||"",phone_number:n,address_line_1:null==i?void 0:i.line1,address_line_2:null==i?void 0:i.line2,city:null==i?void 0:i.city,state:null==i?void 0:i.state,country_code:null==i?void 0:i.countryCode,postal_code:null==i?void 0:i.postalCode}}mapToLegacyBillingAddress(e){const{billingAddress:t,email:n,firstName:i,lastName:r,phone:o,shippingAddress:a}=e,s=t||a;return{email:n,first_name:i,last_name:r,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}}removeElement(e){const t=e&&document.getElementById(e);t&&t.remove()}getSessionId(e){return da(this,void 0,void 0,function*(){const{deviceData:t}=yield this.getDataCollector({riskCorrelationId:e});return t})}teardown(){return da(this,void 0,void 0,function*(){yield this.teardownModule(this.dataCollectors.default),yield this.teardownModule(this.dataCollectors.paypal),this.dataCollectors={},yield this.teardownModule(this.paypalCheckout),this.paypalCheckout=void 0})}get3DS(){return da(this,void 0,void 0,function*(){return this.threeDS||(this.threeDS=Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()]).then(([e,t])=>t.create({client:e,version:2}))),this.threeDS})}getVenmoCheckout(e){return da(this,void 0,void 0,function*(){if(!this.venmoCheckout){const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadVenmoCheckout(),i=Object.assign({client:t,allowDesktop:!0,paymentMethodUsage:"multi_use"},e||{});this.venmoCheckout=yield new Promise((e,t)=>{n.create(i,(n,i)=>n?t(n):i.isBrowserSupported()?void e(i):t(new Wr))})}return this.venmoCheckout})}verifyCard(e,t,n){return da(this,void 0,void 0,function*(){const i=yield this.tokenizeCard(e,t);return this.challenge3DSVerification(i,n)})}tokenizeCard(e,t){return da(this,void 0,void 0,function*(){const{paymentData:n}=e;if(!function(e){if("object"!=typeof e||null===e)return!1;const t=e;return"object"==typeof t.ccExpiry&&null!==t.ccExpiry&&"string"==typeof t.ccNumber&&"string"==typeof t.ccName}(n))throw new Qo(["payment.paymentData"]);const i=this.getErrorsRequiredFields(n);if(!f(i))throw new Xo(i);const r=this.mapToCreditCard(n,t),o=yield this.getClient(),{creditCards:a}=yield o.request(r);return{nonce:a[0].nonce,bin:a[0].details.bin}})}challenge3DSVerification(e,t){return da(this,void 0,void 0,function*(){const n=yield this.get3DS();return this.present3DSChallenge(n,t,e)})}teardownModule(e){return e?e.teardown():Promise.resolve()}getClientTokenOrThrow(){if(!this.clientToken)throw new fr(pr.PaymentNotInitialized);return this.clientToken}getErrorsRequiredFields(e){const{ccNumber:t,ccExpiry:n}=e,i={};return t||(i.ccNumber=[{message:"Credit card number is required",type:"required"}]),n||(i.ccExpiry=[{message:"Expiration date is required",type:"required"}]),i}mapToCreditCard(e,t){return{data:{creditCard:{cardholderName:e.ccName,number:e.ccNumber,cvv:e.ccCvv,expirationDate:`${e.ccExpiry.month}/${e.ccExpiry.year}`,options:{validate:!1},billingAddress:t&&{countryCodeAlpha2:t.countryCode,locality:t.city,countryName:t.country,postalCode:t.postalCode,streetAddress:t.address2?`${t.address1} ${t.address2}`:t.address1}}},endpoint:"payment_methods/credit_cards",method:"post"}}present3DSChallenge(e,t,n){const{nonce:i,bin:r}=n;if(!i)throw new fr(pr.PaymentNotInitialized);const{challengeRequested:o=!0,additionalInformation:a}=this.threeDSecureOptions||{},s=t.toFixed(2);return e.verifyCard({amount:Number(s),bin:r,challengeRequested:o,nonce:i,onLookupComplete:(e,t)=>{t()},collectDeviceData:!0,additionalInformation:a})}}function ua(e){const{color:t,fundingicons:n,height:i=40,layout:r,shape:o,size:a,tagline:s}=e||{},d={color:t,fundingicons:n,height:la(i),layout:r,shape:o||"rect",size:a,tagline:s};return R(d,v)}function la(e){const t=Number(e);return!t||Number.isNaN(t)?40:t>55?55:t<25?25:t}function ha(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}}var pa=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ga{constructor(e,t,n,i){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeIntegrationService=n,this.braintreeHostWindow=i}initialize(e){return pa(this,void 0,void 0,function*(){const{braintreepaypal:t,containerId:n,methodId:i}=e;if(!i)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Tr('Unable to initialize payment because "options.braintreepaypal" argument is not provided.');let r,o=this.paymentIntegrationService.getState();if(t.buyNowInitializeOptions){if(!t.currencyCode)throw new Tr('Unable to initialize payment because "options.braintreepaypalcredit.currencyCode" argument is not provided.');r=t.currencyCode}else yield this.paymentIntegrationService.loadDefaultCheckout(),o=this.paymentIntegrationService.getState(),r=o.getCartOrThrow().currency.code;const a=o.getPaymentMethodOrThrow(i),{clientToken:s,config:d,initializationData:c}=a;if(!s||!c)throw new gr(hr.MissingPaymentMethod);const u={currency:r,intent:c.intent,isCreditEnabled:c.isCreditEnabled,commit:!1};this.braintreeIntegrationService.initialize(s),yield this.braintreeIntegrationService.getPaypalCheckout(u,e=>{this.renderPayPalButton(e,t,n,i,!!d.testMode)},e=>this.handleError(e,n,t.onError))})}deinitialize(){return pa(this,void 0,void 0,function*(){yield this.braintreeIntegrationService.teardown()})}renderPayPalButton(e,t,n,i,r){const{style:o,shouldProcessPayment:a,onAuthorizeError:s,onEligibilityFailure:d}=t,{paypal:c}=this.braintreeHostWindow;if(c){const u=c.Buttons({env:r?"sandbox":"production",fundingSource:c.FUNDING.PAYPAL,style:ua(o),createOrder:()=>this.setupPayment(e,t,i),onApprove:t=>this.tokenizePayment(t,e,i,a,s)});u.isEligible()?u.render(`#${n}`):d&&"function"==typeof d&&d()}else this.braintreeIntegrationService.removeElement(n)}setupPayment(e,t,n){return pa(this,void 0,void 0,function*(){var i;const{onPaymentError:r,shippingAddress:o,buyNowInitializeOptions:a}=t;try{const r="function"==typeof(null==a?void 0:a.getBuyNowCartRequestBody)?yield this.createBuyNowCart(a.getBuyNowCartRequestBody()):void 0;this.buyNowCartId=null==r?void 0:r.id;const s=this.paymentIntegrationService.getState(),d=s.getCustomer(),c=s.getPaymentMethodOrThrow(n),u=r?r.cartAmount:s.getCartOrThrow().cartAmount,l=r?t.currencyCode:s.getCartOrThrow().currency.code,h=o||(null==d?void 0:d.addresses[0]),p=h?ha(h):void 0;return yield e.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,shippingAddressOverride:p,amount:u,currency:l,offerCredit:!1,intent:null===(i=c.initializationData)||void 0===i?void 0:i.intent})}catch(e){throw r&&(eo(e)||e instanceof ve)&&r(e),e}})}tokenizePayment(e,t,n,i,r){return pa(this,void 0,void 0,function*(){try{const{deviceData:r}=yield this.braintreeIntegrationService.getDataCollector({paypal:!0}),o=yield t.tokenizePayment(e),{details:a,nonce:s}=o,d=this.braintreeIntegrationService.mapToLegacyBillingAddress(a),c=this.braintreeIntegrationService.mapToLegacyShippingAddress(a);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",provider:n,action:i?"process_payment":"set_external_checkout",nonce:s,device_data:r,billing_address:JSON.stringify(d),shipping_address:JSON.stringify(c)},this.buyNowCartId&&{cart_id:this.buyNowCartId})),o}catch(e){throw r&&(eo(e)||e instanceof ve)&&r(e),e}})}createBuyNowCart(e){return pa(this,void 0,void 0,function*(){if(!e)throw new gr(hr.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(e)}catch(e){throw new kr}})}handleError(e,t,n){if(this.braintreeIntegrationService.removeElement(t),!n||!eo(e))throw e;n(e)}}const ma=Ar(e=>{const t=window,i=new Hr(e),r=new ca(new uo(le(),t,i),t);return new ga(e,n(),r,t)},[{id:"braintreepaypal"}]);var ya=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class fa{constructor(e,t,n,i){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeIntegrationService=n,this.braintreeHostWindow=i}initialize(e){return ya(this,void 0,void 0,function*(){const{braintreepaypalcredit:t,containerId:n,methodId:i}=e;if(!i)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Tr('Unable to initialize payment because "options.braintreepaypalcredit" argument is not provided.');let r,o=this.paymentIntegrationService.getState();if(t.buyNowInitializeOptions){if(!t.currencyCode)throw new Tr('Unable to initialize payment because "options.braintreepaypalcredit.currencyCode" argument is not provided.');r=t.currencyCode}else yield this.paymentIntegrationService.loadDefaultCheckout(),o=this.paymentIntegrationService.getState(),r=o.getCartOrThrow().currency.code;const a=o.getPaymentMethodOrThrow(i),{clientToken:s,config:d,initializationData:c}=a;if(!s||!c)throw new gr(hr.MissingPaymentMethod);const u={currency:r,intent:c.intent,isCreditEnabled:c.isCreditEnabled,commit:!1};this.braintreeIntegrationService.initialize(s),yield this.braintreeIntegrationService.getPaypalCheckout(u,e=>{this.renderPayPalButton(e,t,n,i,!!d.testMode)},e=>this.handleError(e,n,t.onError))})}deinitialize(){return ya(this,void 0,void 0,function*(){yield this.braintreeIntegrationService.teardown()})}renderPayPalButton(e,t,n,i,r){const{style:o,shouldProcessPayment:a,onAuthorizeError:s,onEligibilityFailure:d}=t,{paypal:c}=this.braintreeHostWindow;let u=!1;c&&[c.FUNDING.PAYLATER,c.FUNDING.CREDIT].forEach(l=>{const h=l===c.FUNDING.CREDIT?Object.assign({label:oa.CREDIT},ua(o)):ua(o);if(!u){const o=c.Buttons({env:r?"sandbox":"production",fundingSource:l,style:h,createOrder:()=>this.setupPayment(e,t,i),onApprove:t=>this.tokenizePayment(t,e,i,a,s)});o.isEligible()?(o.render(`#${n}`),u=!0):c.FUNDING.CREDIT&&d&&"function"==typeof d&&d()}}),c&&u||this.braintreeIntegrationService.removeElement(n)}setupPayment(e,t,n){return ya(this,void 0,void 0,function*(){var i;const{onPaymentError:r,shippingAddress:o,buyNowInitializeOptions:a}=t;try{const r="function"==typeof(null==a?void 0:a.getBuyNowCartRequestBody)?yield this.createBuyNowCart(a.getBuyNowCartRequestBody()):void 0;this.buyNowCartId=null==r?void 0:r.id;const s=this.paymentIntegrationService.getState(),d=s.getCustomer(),c=s.getPaymentMethodOrThrow(n),u=r?r.cartAmount:s.getCartOrThrow().cartAmount,l=r?t.currencyCode:s.getCartOrThrow().currency.code,h=o||(null==d?void 0:d.addresses[0]),p=h?ha(h):void 0;return yield e.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,shippingAddressOverride:p,amount:u,currency:l,offerCredit:!0,intent:null===(i=c.initializationData)||void 0===i?void 0:i.intent})}catch(e){throw r&&(eo(e)||e instanceof ve)&&r(e),e}})}tokenizePayment(e,t,n,i,r){return ya(this,void 0,void 0,function*(){try{const{deviceData:r}=yield this.braintreeIntegrationService.getDataCollector({paypal:!0}),o=yield t.tokenizePayment(e),{details:a,nonce:s}=o,d=this.braintreeIntegrationService.mapToLegacyBillingAddress(a),c=this.braintreeIntegrationService.mapToLegacyShippingAddress(a);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",provider:n,action:i?"process_payment":"set_external_checkout",nonce:s,device_data:r,billing_address:JSON.stringify(d),shipping_address:JSON.stringify(c)},this.buyNowCartId&&{cart_id:this.buyNowCartId})),o}catch(e){throw r&&(eo(e)||e instanceof ve)&&r(e),e}})}createBuyNowCart(e){return ya(this,void 0,void 0,function*(){if(!e)throw new gr(hr.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(e)}catch(e){throw new kr}})}handleError(e,t,n){if(this.braintreeIntegrationService.removeElement(t),!n||!eo(e))throw e;n(e)}}const _a=Ar(e=>{const t=window,i=new Hr(e),r=new ca(new uo(le(),t,i),t);return new fa(e,n(),r,t)},[{id:"braintreepaypalcredit"}]);var Sa=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class va{constructor(e,t,n){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeSdk=n}initialize(e){return Sa(this,void 0,void 0,function*(){const{containerId:t,methodId:n}=e;if(!n)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!t)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');yield this.paymentIntegrationService.loadPaymentMethod(n);const i=this.paymentIntegrationService.getState(),{clientToken:r,initializationData:o,config:a}=i.getPaymentMethodOrThrow(n);if(!r||!o)throw new gr(hr.MissingPaymentMethod);this.braintreeSdk.initialize(r);const s=yield this.braintreeSdk.getBraintreeVisaCheckout(),{currency:{code:d},cartAmount:c}=i.getCartOrThrow(),u=yield this.braintreeSdk.getVisaCheckoutSdk(a.testMode),l=s.createInitOptions({paymentRequest:{currencyCode:d,subtotal:String(c)},settings:{shipping:{collectShipping:!0}}});this.createSignInButton(t),yield u.init(l),u.on("payment.success",e=>Sa(this,void 0,void 0,function*(){yield this.paymentSuccess(s,e)}))})}deinitialize(){return Promise.resolve()}paymentSuccess(e,t){return Sa(this,void 0,void 0,function*(){return Promise.all([e.tokenize(t),this.braintreeSdk.getDataCollectorOrThrow()]).then(([e,t])=>{const n=this.paymentIntegrationService.getState(),i=n.getShippingAddress(),r=n.getBillingAddress(),{shippingAddress:o=this.toVisaCheckoutAddress(i),billingAddress:a=this.toVisaCheckoutAddress(r)}=e;return this.postForm(Object.assign(Object.assign({},e),{shippingAddress:o,billingAddress:a}),t)})})}postForm(e,t){const{userData:n,billingAddress:i,shippingAddress:r,details:o}=e,{userEmail:a}=n,{deviceData:s}=t;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,i)),shipping_address:JSON.stringify(this.getAddress(a,r))})}toVisaCheckoutAddress(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}:{}}getAddress(e,t={}){return{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}}createSignInButton(e){const t=document.querySelector(`#${e}`);if(!t)throw new Error("Need a container to place the button");return this.insertVisaCheckoutButton(t)}insertVisaCheckoutButton(e){const 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}}const Ca=Ar(e=>{const t=window,i=new Hr(e),r=new oo(new uo(le(),t,i));return new va(e,n(),r)},[{id:"braintreevisacheckout"}]);function Ia(e){const{billingAddress:t,email:n,firstName:i,lastName:r,phone:o,shippingAddress:a}=e,s=t||a;return{email:n,first_name:i,last_name:r,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 wa(e){const{email:t,phone:n,shippingAddress:i}=e,r=(null==i?void 0:i.recipientName)||"",[o,a]=r.split(" ");return{email:t,first_name:o||"",last_name:a||"",phone_number:n,address_line_1:null==i?void 0:i.line1,address_line_2:null==i?void 0:i.line2,city:null==i?void 0:i.city,state:null==i?void 0:i.state,country_code:null==i?void 0:i.countryCode,postal_code:null==i?void 0:i.postalCode}}var Ea=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};const ba=e=>{const{color:t,height:n}=e;return{backgroundColor:(i=t||"",i===ra.WHITE?"#FFFFFF":"#3D95CE"),backgroundPosition:"50% 50%",backgroundSize:"80px auto",backgroundImage:`url("/app/assets/img/payment-providers/venmo-logo-${t===ra.WHITE?ra.BLUE:ra.WHITE}.svg")`,backgroundRepeat:"no-repeat",borderRadius:"4px",cursor:"pointer",transition:"0.2s ease",minHeight:`${n||40}px`,minWidth:"150px",height:"100%",width:"100%",border:t===ra.WHITE?"1px solid black":"none"};var i};class Pa{constructor(e,t,n){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeSdk=n,this.onError=T}initialize(e){return Ea(this,void 0,void 0,function*(){const{braintreevenmo:t,containerId:n,methodId:i}=e;if(!i)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');const r=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(i),{clientToken:o,initializationData:a}=r,{paymentButtonStyles:s}=a,{cartButtonStyles:d}=s||{},c=(null==t?void 0:t.style)||d;if(!o||!a)throw new gr(hr.MissingPaymentMethod);if(!n)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');yield this.paymentIntegrationService.loadDefaultCheckout(),this.onError=(null==t?void 0:t.onError)||this.handleError,this.braintreeSdk.initialize(o);try{const e=yield this.braintreeSdk.getVenmoCheckoutOrThrow();this.renderVenmoButton(e,n,null==t?void 0:t.buyNowInitializeOptions,c)}catch(e){(function(e){return"object"==typeof e&&null!==e&&"name"in e&&"BraintreeError"===e.name}(e)||function(e){return e instanceof Wr}(e))&&this.handleInitializationVenmoError(e,n)}})}deinitialize(){return Ea(this,void 0,void 0,function*(){return yield this.braintreeSdk.deinitialize(),Promise.resolve()})}handleError(e){throw new Error(e.message)}createBuyNowCart(e){return Ea(this,void 0,void 0,function*(){if("function"==typeof(null==e?void 0:e.getBuyNowCartRequestBody)){const t=null==e?void 0:e.getBuyNowCartRequestBody();if(!t)throw new gr(hr.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(t)}catch(e){throw new kr}}})}handleInitializationVenmoError(e,t){return this.removeVenmoContainer(t),this.onError(e)}removeVenmoContainer(e){const t=document.getElementById(e);t&&t.remove()}renderVenmoButton(e,t,n,i){const r=document.getElementById(t),{color:o}=i||{};if(!r)throw new Tr("Unable to create wallet button without valid container ID.");r.setAttribute("aria-label","Venmo"),Object.assign(r.style,ba(i||{})),r.addEventListener("click",()=>Ea(this,void 0,void 0,function*(){r.setAttribute("disabled","true");const t=yield this.createBuyNowCart(n);e.tokenize&&e.tokenize((e,n)=>Ea(this,void 0,void 0,function*(){r.removeAttribute("disabled"),e&&this.onError(e),yield this.handlePostForm(n,null==t?void 0:t.id)}))})),o===ra.BLUE&&(r.addEventListener("mouseenter",()=>{r.style.backgroundColor="#0a7fc2"}),r.addEventListener("mouseleave",()=>{r.style.backgroundColor=ba(i||{}).backgroundColor}))}handlePostForm(e,t){return Ea(this,void 0,void 0,function*(){const{deviceData:n}=yield this.braintreeSdk.getDataCollectorOrThrow(),{nonce:i,details:r}=e;this.formPoster.postForm("/checkout.php",Object.assign({nonce:i,provider:"braintreevenmo",payment_type:"paypal",device_data:n,action:"set_external_checkout",billing_address:JSON.stringify(Ia(r)),shipping_address:JSON.stringify(wa(r))},t&&{cart_id:t}))})}}const Oa=Ar(e=>{const t=window,i=le(),r=new Hr(e),o=new uo(i,t,r),a=new oo(o);return new Pa(e,n(),a)},[{id:"braintreevenmo"}]);class Aa{constructor(e){const t=new Promise((e,t)=>{this.cancel=t});this.promise=Promise.race([e,t])}}var Ta;!function(e){e.ADYEN_V2="googlepayadyenv2",e.ADYEN_V3="googlepayadyenv3",e.AUTHORIZE_NET="googlepayauthorizenet",e.BNZ="googlepaybnz",e.BRAINTREE="googlepaybraintree",e.PAYPAL_COMMERCE="googlepaypaypalcommerce",e.BIGCOMMERCE_PAYMENTS="googlepay_bigcommerce_payments",e.CHECKOUT_COM="googlepaycheckoutcom",e.CYBERSOURCE_V2="googlepaycybersourcev2",e.ORBITAL="googlepayorbital",e.STRIPE="googlepaystripe",e.STRIPE_UPE="googlepaystripeupe",e.STRIPE_OCS="googlepaystripeocs",e.WORLDPAY_ACCESS="googlepayworldpayaccess",e.TD_ONLINE_MART="googlepaytdonlinemart"}(Ta||(Ta={}));const ka=function(e,t,n){return t&&n?Ra(0,t,n):function(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&"constructor"!==n&&Object.defineProperty(t.prototype,n,Ra(e.prototype,n,i))}),t}(e)};function Ra(e,t,n){if("function"!=typeof n.value)return n;let i=n.value;return{get(){const e=i.bind(this);return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e},set(e){i=e}}}class Da{constructor(e){if(!e)throw new Error("Currency settings missing");const{decimalPlaces:t,symbolLocation:n,symbol:i,thousandsSeparator:r,decimalSeparator:o}=e;if("string"!=typeof n||"string"!=typeof i||"string"!=typeof r||"string"!=typeof o||"string"!=typeof t)throw new Tr("Invalid currency settings provided");this._decimalPlaces=parseInt(t,10),this._symbolLocation=n,this._symbol=i,this._thousandsSeparator=r,this._decimalSeparator=o}format(e){if("number"!=typeof e)throw new Tr("Invalid amount provided");const t=this._formatNumber(e),n=this._formatCurrency(t);return e<0?`-${n}`:n}_formatNumber(e){const t=Math.abs(e),[n,i=""]=this._toFixed(t,this._decimalPlaces).split("."),r=n.replace(/\B(?=(\d{3})+(?!\d))/g,this._thousandsSeparator);return this._decimalPlaces<1?r:[r,i].join(this._decimalSeparator)}_formatCurrency(e){return"left"===this._symbolLocation.toLowerCase()?`${this._symbol}${e}`:`${e}${this._symbol}`}_toFixed(e,t){return(+`${Math.round(+`${e}e${t}`)}e${-t}`).toFixed(t)}}let Ma=class{constructor(e){this._storeConfig=e,this._customerFormatter=new Da(this._storeConfig.shopperCurrency),this._storeFormatter=new Da(this._storeConfig.currency)}toCustomerCurrency(e){const t=this._storeConfig.shopperCurrency.exchangeRate;return this._customerFormatter.format(e*t)}toStoreCurrency(e){return this._storeFormatter.format(e)}};Ma=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([ka],Ma);const Na=Ma;function La(){if("undefined"==typeof window)return!1;if(function(e){return"ReactNativeWebView"in e}(window))return!0;const e=navigator.userAgent||navigator.vendor||(function(e){return"opera"in e}(window)?window.opera:""),t=/android.+; wv/i.test(e),n=/iPhone|iPod|iPad/i.test(e)&&/AppleWebKit/i.test(e)&&!/Safari/i.test(e);return t||n}var za,Ua,Fa,Ba,xa,qa,ja,Ga,Va;function Ha(e){return e in qa}!function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(za||(za={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(Ua||(Ua={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(Fa||(Fa={})),function(e){e.pill="pill",e.rect="rect"}(Ba||(Ba={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(xa||(xa={})),function(e){e.AMEX="AMEX",e.DISCOVER="DISCOVER",e.INTERAC="INTERAC",e.JCB="JCB",e.MC="MASTERCARD",e.VISA="VISA"}(qa||(qa={})),function(e){e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION"}(ja||(ja={})),function(e){e.OFFER_INVALID="OFFER_INVALID",e.PAYMENT_DATA_INVALID="PAYMENT_DATA_INVALID",e.SHIPPING_ADDRESS_INVALID="SHIPPING_ADDRESS_INVALID",e.SHIPPING_ADDRESS_UNSERVICEABLE="SHIPPING_ADDRESS_UNSERVICEABLE",e.SHIPPING_OPTION_INVALID="SHIPPING_OPTION_INVALID",e.OTHER_ERROR="OTHER_ERROR"}(Ga||(Ga={})),function(e){e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER"}(Va||(Va={}));var Wa=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ya{constructor(e,t){this._gatewayIdentifier=e,this._paymentIntegrationService=t,this._isBuyNowFlow=!1,this._shouldRequestShipping=!0,this._isWebViewExperimentOn=null}mapToShippingAddressRequestBody({shippingAddress:e}){if(!e)return;const{company:t="",phone:n=""}=this._paymentIntegrationService.getState().getShippingAddress()||{};return this._mapToAddressRequestBody(e,t,n)}mapToBillingAddressRequestBody(e){const{billingAddress:t}=e.paymentMethodData.info;if(!t)return;const{company:n="",phone:i="",email:r,customFields:o=[]}=this._paymentIntegrationService.getState().getBillingAddress()||{};return Object.assign(Object.assign({},this._mapToAddressRequestBody(t,n,i,o)),{email:r||e.email})}mapToExternalCheckoutData(e){var t;const{paymentMethodData:{tokenizationData:{token:n},info:{cardNetwork:i,cardDetails:r}}}=e;if(!n)throw new gr(hr.MissingPaymentToken);return Promise.resolve(Object.assign({nonce:n,card_information:{type:i,number:r}},this._isBuyNowFlow&&{cart_id:null===(t=this._paymentIntegrationService.getState().getCart())||void 0===t?void 0:t.id}))}getRequiredData(){return Wa(this,void 0,void 0,function*(){var e;const t={emailRequired:!0};if(!this._isShippingAddressRequired())return t;const n=null===(e=(yield this._paymentIntegrationService.loadShippingCountries()).getShippingCountries())||void 0===e?void 0:e.map(e=>e.code);return Object.assign(Object.assign({},t),{shippingAddressRequired:!0,shippingAddressParameters:Object.assign({phoneNumberRequired:!0},n&&{allowedCountryCodes:n}),shippingOptionRequired:!0})})}getCallbackIntents(){return this._isShippingAddressRequired()?[ja.OFFER,ja.SHIPPING_ADDRESS,ja.SHIPPING_OPTION]:[ja.OFFER]}getCallbackTriggers(){return{availableTriggers:[Va.INITIALIZE,Va.SHIPPING_ADDRESS,Va.SHIPPING_OPTION,Va.OFFER],initializationTrigger:[Va.INITIALIZE],addressChangeTriggers:[Va.INITIALIZE,Va.SHIPPING_ADDRESS],shippingOptionsChangeTriggers:[Va.SHIPPING_OPTION],offerChangeTriggers:[Va.OFFER]}}getNonce(e){var t;const n=null===(t=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(e).initializationData)||void 0===t?void 0:t.nonce;if(!n)throw new gr(hr.MissingPaymentToken);return Promise.resolve(n)}extraPaymentData(){return Promise.resolve(void 0)}getMerchantInfo(){const{googleMerchantName:e,googleMerchantId:t,platformToken:n}=this.getGooglePayInitializationData();return{merchantName:e,merchantId:t,authJwt:n}}getTransactionInfo(){let e;const{getCartOrThrow:t}=this._paymentIntegrationService.getState();e=this._isBuyNowFlow?this._getCurrencyCodeOrThrow():t().currency.code;const n=this.getGooglePayInitializationData().storeCountry;if(this.isWebViewWithRestrictions()){const t=this.getTotalPrice();return Object.assign(Object.assign({},n&&{countryCode:n}),{currencyCode:e,totalPrice:t,totalPriceStatus:xa.ESTIMATED})}return Object.assign(Object.assign({},n&&{countryCode:n}),{currencyCode:e,totalPriceStatus:xa.ESTIMATED,totalPrice:"0"})}isWebViewWithRestrictions(){return null!==this._isWebViewExperimentOn?this._isWebViewExperimentOn&&La():La()}setIsWebViewExperimentOn(e){this._isWebViewExperimentOn=e}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData().gatewayMerchantId;if(!e)throw new Tr("Unable to proceed, gatewayMerchantId is missing.");return{gateway:this._gatewayIdentifier,gatewayMerchantId:e}}getCardParameters(){return{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:this.getPaymentMethod().supportedCards.filter(Ha).map(e=>qa[e]),billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}}initialize(e,t,n){return this._getPaymentMethodFn=e,this._isBuyNowFlow=Boolean(t),this._currencyCode=n,this._isBuyNowFlow&&this._getCurrencyCodeOrThrow(),Promise.resolve()}handleShippingAddressChange(e){return Wa(this,void 0,void 0,function*(){var t,n,i,r;e&&(e.name=e.name||"",e.address1=e.address1||"");const o=this.mapToShippingAddressRequestBody({shippingAddress:e});o&&(yield this._paymentIntegrationService.updateShippingAddress(o));const a=this._paymentIntegrationService.getState(),s=a.getConsignments();if(!(null==s?void 0:s[0]))return;const d=s[0],c=a.getStoreConfigOrThrow();this._currencyService||(this._currencyService=new Na(c));const u=(d.availableShippingOptions||[]).map(this._getGooglePayShippingOption.bind(this)),l=null===(t=d.availableShippingOptions)||void 0===t?void 0:t.find(e=>e.isRecommended);if(u.length){const e=(null===(n=d.selectedShippingOption)||void 0===n?void 0:n.id)||(null==l?void 0:l.id)||(null===(i=u[0])||void 0===i?void 0:i.id);return!(null===(r=d.selectedShippingOption)||void 0===r?void 0:r.id)&&u[0]&&(yield this.handleShippingOptionChange((null==l?void 0:l.id)||u[0].id)),{defaultSelectedOptionId:e,shippingOptions:u}}})}handleShippingOptionChange(e){return Wa(this,void 0,void 0,function*(){if("shipping_option_unselected"!==e)return this._paymentIntegrationService.selectShippingOption(e)})}getTotalPrice(){const{getCheckoutOrThrow:e,getCartOrThrow:t,getStoreConfigOrThrow:n}=this._paymentIntegrationService.getState(),{decimalPlaces:i}=t().currency,r=qr(n().checkoutSettings.features,"PI-5075.google_pay_round_total_price_to_max_2_decimal_places")?Math.min(i,2):i;return L(e().outstandingBalance,r).toFixed(r)}handleCoupons(e){return Wa(this,void 0,void 0,function*(){const{redemptionCodes:t=[]}=e,{offers:n}=this.getAppliedCoupons()||{};let i;return yield t.reduce((e,t)=>Wa(this,void 0,void 0,function*(){if(yield e,(n||[]).some(({redemptionCode:e})=>e===t))return;const r=yield this.applyCoupon(t);r&&(i=r)}),Promise.resolve()),yield(n||[]).reduce((e,n)=>Wa(this,void 0,void 0,function*(){yield e,t.includes(n.redemptionCode)||(yield this._paymentIntegrationService.removeCoupon(n.redemptionCode))}),Promise.resolve()),{newOfferInfo:this.getAppliedCoupons(),error:i}})}getAppliedCoupons(){const e=this._paymentIntegrationService.getState(),{coupons:t}=e.getCheckout()||{};return{offers:(t||[]).map(e=>{const{displayName:t,code:n}=e;return{redemptionCode:n,description:t}})}}applyCoupon(e){return Wa(this,void 0,void 0,function*(){let t;try{yield this._paymentIntegrationService.applyCoupon(e)}catch(e){return e instanceof Error&&(t={reason:Ga.OFFER_INVALID,message:e.message,intent:Va.OFFER}),t}})}setShouldRequestShipping(e){this._shouldRequestShipping=e}getGooglePayInitializationData(){return yr(this.getPaymentMethod().initializationData,()=>new Tr("Missing initialization data."))}getPaymentMethod(){return yr(this._getPaymentMethodFn,()=>new fr(pr.PaymentNotInitialized))()}getGatewayIdentifier(){return this._gatewayIdentifier}setGatewayIdentifier(e){this._gatewayIdentifier=e||this.getGatewayIdentifier()}_isShippingAddressRequired(){const{getCartOrThrow:e,getStoreConfigOrThrow:t,getShippingAddress:n}=this._paymentIntegrationService.getState(),i=t();let r;return r=qr(i.checkoutSettings.features,"PI-4290.google_pay_require_shipping_address")?this._shouldRequestShipping:void 0===n(),r&&(o=e(),a=i,!!o&&(!!o.lineItems.physicalItems.some(e=>e.isShippingRequired)||!(!a||!o.lineItems.customItems)&&o.lineItems.customItems.length>0));var o,a}_mapToAddressRequestBody(e,t,n,i){const{name:r,address1:o,address2:a,address3:s,locality:d,administrativeArea:c,countryCode:u,postalCode:l,phoneNumber:h}=e,[p,g]=this._getFirstAndLastName(r);return{firstName:p,lastName:g,company:t,address1:o,address2:`${a} ${s}`.trim(),city:d||c,stateOrProvince:c,stateOrProvinceCode:c,countryCode:u,postalCode:l,phone:h||n,customFields:i||[]}}_getFirstAndLastName(e){const t=e.split(" ");return 1===t.length?[e,""]:[t.slice(0,-1).join(" "),t[t.length-1]]}_getCurrencyCodeOrThrow(){return yr(this._currencyCode,()=>new Tr('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}_getGooglePayShippingOption({id:e,cost:t,description:n,additionalDescription:i}){var r;return{id:e,label:`${(null===(r=this._currencyService)||void 0===r?void 0:r.toCustomerCurrency(t))||t} ${n}`,description:i}}}var Ka=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class $a extends Ya{constructor(e,t){super("braintree",e),this._braintreeSdk=t,this._methodId=Ta.BRAINTREE,this._service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return Ka(this,void 0,void 0,function*(){yield i.initialize.call(this,e,t,n);let r=i.getPaymentMethod.call(this);if(r.clientToken||(r=(yield this._service.loadPaymentMethod(this._methodId)).getPaymentMethodOrThrow(this._methodId)),!r.clientToken||!r.initializationData)throw new gr(hr.MissingPaymentMethod);return this._braintreeSdk.initialize(r.clientToken),this._braintreeGooglePayment=yield this._braintreeSdk.getBraintreeGooglePayment(),Promise.resolve()})}getNonce(e){const t=Object.create(null,{getNonce:{get:()=>super.getNonce},getPaymentMethod:{get:()=>super.getPaymentMethod}});return Ka(this,void 0,void 0,function*(){var n;const i=yield t.getNonce.call(this,e),{clientToken:r,initializationData:o}=t.getPaymentMethod.call(this);if(!r||!o||!(null===(n=o.card_information)||void 0===n?void 0:n.bin))throw new gr(hr.MissingPaymentMethod);const{isThreeDSecureEnabled:a,card_information:{bin:s,isNetworkTokenized:d}}=o;if(a&&!d){const e=yield this._braintreeSdk.getBraintreeThreeDS(),{orderAmount:t}=this._service.getState().getOrderOrThrow();return(yield this._braintreePresent3DSChallenge(e,t,i,s)).nonce}return i})}extraPaymentData(){return Ka(this,void 0,void 0,function*(){return{deviceSessionId:yield this._getBraintreeDeviceData()}})}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return Ka(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new Tr("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 gr(hr.MissingPaymentToken)}(i),n.nonce=i.androidPayCards[0].nonce,n.card_information.bin=i.androidPayCards[0].details.bin,n.card_information.isNetworkTokenized=i.androidPayCards[0].details.isNetworkTokenized,n})}getCardParameters(){return super.getCardParameters()}getPaymentGatewayParameters(){const e=Object.create(null,{getMerchantInfo:{get:()=>super.getMerchantInfo},getTransactionInfo:{get:()=>super.getTransactionInfo},getRequiredData:{get:()=>super.getRequiredData}});return Ka(this,void 0,void 0,function*(){return this.getBraintreeGooglePayment().createPaymentDataRequest(Object.assign({merchantInfo:e.getMerchantInfo.call(this),transactionInfo:e.getTransactionInfo.call(this),cardRequirements:{billingAddressRequired:!0,billingAddressFormat:"FULL"}},yield e.getRequiredData.call(this))).paymentMethodTokenizationParameters.parameters})}getBraintreeGooglePayment(){if(!this._braintreeGooglePayment)throw new gr(hr.MissingPaymentMethod);return this._braintreeGooglePayment}_getBraintreeDeviceData(){return Ka(this,void 0,void 0,function*(){const{deviceData:e}=yield this._braintreeSdk.getDataCollectorOrThrow();return e})}_braintreePresent3DSChallenge(e,t,n,i){return new Aa(e.verifyCard({amount:t,bin:i,nonce:n,onLookupComplete:(e,t)=>{t()}})).promise}}class Za extends ve{constructor(e){super(e||"Unable to proceed because the client library of a payment method has thrown an unexpected error."),this.name="PaymentMethodFailedError",this.type="payment_method_client_invalid"}}var Ja=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Qa{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){return Ja(this,void 0,void 0,function*(){var t,n,i,r;if(!e.methodId||(r=e.methodId,!Object.values(Ta).includes(r)))throw new Tr('Unable to proceed because "methodId" is not a valid key.');if(this._methodId=e.methodId,!e.containerId)throw new Tr('Unable to proceed because "containerId" is not a valid key.');const o=e[this._getMethodOrThrow()];if(!o)throw new Tr("Unable to proceed without valid options.");const{buyNowInitializeOptions:a,currencyCode:s,buttonColor:d,buttonType:c,onError:u}=o;let l,h=this._paymentIntegrationService.getState();try{l=h.getPaymentMethodOrThrow(this._getMethodOrThrow())}catch(e){h=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodOrThrow()),l=h.getPaymentMethodOrThrow(this._getMethodOrThrow())}if(this._countryCode=null===(t=l.initializationData)||void 0===t?void 0:t.storeCountry,this._googlePayPaymentProcessor.setIsWebViewExperimentOn(!!(null===(n=l.initializationData)||void 0===n?void 0:n.isWebViewExperimentOn)),a){if(!s)throw new Tr('Unable to initialize payment because "options.currencyCode" argument is not provided.');this._currencyCode=s,this._buyNowInitializeOptions=a,yield this._googlePayPaymentProcessor.initialize(()=>l,this._getGooglePayClientOptions(),!!a,s)}else yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initialize(()=>l,this._getGooglePayClientOptions());this._paymentButton=null!==(i=this._paymentButton)&&void 0!==i?i:this._googlePayPaymentProcessor.addPaymentButton(e.containerId,{buttonColor:null!=d?d:"default",buttonType:null!=c?c:"plain",onClick:this._handleClick(u)})})}deinitialize(){var e;return null===(e=this._paymentButton)||void 0===e||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()}_handleClick(e){return t=>Ja(this,void 0,void 0,function*(){t.preventDefault();try{this._buyNowInitializeOptions?yield this._createBuyNowCartOrThrow(this._buyNowInitializeOptions):yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(t){let n=t;if(function(e){return"object"==typeof e&&null!==e&&"statusCode"in e}(t)){if("CANCELED"===t.statusCode)throw new lo;n=new Za(JSON.stringify(t))}throw null==e||e(new Za("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){return Ja(this,void 0,void 0,function*(){var e;const t=yield this._googlePayPaymentProcessor.showPaymentSheet(),n=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(t),i=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(t),r="/embedded-checkout"===window.location.pathname?this._paymentIntegrationService.getState().getStoreConfigOrThrow().links.siteLink:void 0;n&&(yield this._paymentIntegrationService.updateBillingAddress(n)),i&&!(null===(e=this._buyNowCart)||void 0===e?void 0:e.lineItems.digitalItems.length)&&(yield this._paymentIntegrationService.updateShippingAddress(i)),yield this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodOrThrow(),t,r)})}_getGooglePayClientOptions(){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:e=>Ja(this,[e],void 0,function*({callbackTrigger:e,shippingAddress:t,shippingOptionData:n,offerData:i}){const{availableTriggers:r,addressChangeTriggers:o,shippingOptionsChangeTriggers:a,offerChangeTriggers:s}=this._googlePayPaymentProcessor.getCallbackTriggers();if(!r.includes(e))return;const d=o.includes(e)?yield this._googlePayPaymentProcessor.handleShippingAddressChange(t):void 0;a.includes(e)&&(yield this._googlePayPaymentProcessor.handleShippingOptionChange(n.id));const{newOfferInfo:c,error:u}=s.includes(e)?yield this._googlePayPaymentProcessor.handleCoupons(i):{},l=u;return this._buyNowInitializeOptions?this._getBuyNowTransactionInfo(d,c,l):this._getTransactionInfo(d,c,l)})}}}_createBuyNowCartOrThrow(e){return Ja(this,void 0,void 0,function*(){if("function"==typeof(null==e?void 0:e.getBuyNowCartRequestBody)){const t=e.getBuyNowCartRequestBody();try{this._buyNowCart=yield this._paymentIntegrationService.createBuyNowCart(t),yield this._paymentIntegrationService.loadCheckout(this._buyNowCart.id)}catch(e){if("string"==typeof e)throw new kr(e);throw e}}})}_getBuyNowTransactionInfo(e,t,n){if(!this._buyNowCart)return;const{cartAmount:i}=this._buyNowCart,r=this._googlePayPaymentProcessor.getTotalPrice();return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:this._getCurrencyCodeOrThrow(),totalPrice:r||String(i),totalPriceStatus:xa.FINAL})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})}_getTransactionInfo(e,t,n){return Ja(this,void 0,void 0,function*(){yield this._paymentIntegrationService.loadCheckout();const i=this._googlePayPaymentProcessor.getTotalPrice(),{code:r}=this._paymentIntegrationService.getState().getCartOrThrow().currency;return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:r,totalPriceStatus:xa.FINAL,totalPrice:i})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})})}_getMethodOrThrow(){return yr(this._methodId,()=>new fr(pr.PaymentNotInitialized))}_getCurrencyCodeOrThrow(){return yr(this._currencyCode,()=>new Tr('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}}var Xa=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class es{constructor(e,t,n,i){this._scriptLoader=e,this._gateway=t,this._requestSender=n,this._formPoster=i,this._baseRequest={apiVersion:2,apiVersionMinor:0}}initialize(e,t,n,i){return Xa(this,void 0,void 0,function*(){this._paymentsClient=yield this._scriptLoader.getGooglePaymentsClient(e().config.testMode,t),yield this._gateway.initialize(e,n,i),this._buildButtonPayloads()})}initializeWidget(){return Xa(this,void 0,void 0,function*(){yield this._buildWidgetPayloads(),yield this._determineReadinessToPay(),this._prefetchGooglePaymentData()})}getNonce(e){return this._gateway.getNonce(e)}extraPaymentData(){return Xa(this,void 0,void 0,function*(){return this._gateway.extraPaymentData()})}addPaymentButton(e,t){const n=document.querySelector(`#${e}`);if(!n)return;const i=this._getPaymentsClient().createButton(Object.assign(Object.assign({},t),{allowedPaymentMethods:[this._getBaseCardPaymentMethod()]}));return n.appendChild(i)}showPaymentSheet(){return Xa(this,void 0,void 0,function*(){const e=this._getPaymentDataRequest();return this._getPaymentsClient().loadPaymentData(e)})}setExternalCheckoutXhr(e,t){return Xa(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t)})}setExternalCheckoutForm(e,t,n){return Xa(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t,!0,n)})}mapToBillingAddressRequestBody(e){return this._gateway.mapToBillingAddressRequestBody(e)}mapToShippingAddressRequestBody(e){return this._gateway.mapToShippingAddressRequestBody(e)}processAdditionalAction(e,t){return"processAdditionalAction"in this._gateway?this._gateway.processAdditionalAction(e,t):Promise.reject(e)}signOut(e){return Xa(this,void 0,void 0,function*(){yield this._requestSender.get(`/remote-checkout/${e}/signout`)})}getCallbackTriggers(){return this._gateway.getCallbackTriggers()}setShouldRequestShipping(e){return this._gateway.setShouldRequestShipping(e)}handleShippingAddressChange(e){return Xa(this,void 0,void 0,function*(){return this._gateway.handleShippingAddressChange(e)})}handleShippingOptionChange(e){return Xa(this,void 0,void 0,function*(){yield this._gateway.handleShippingOptionChange(e)})}handleCoupons(e){return Xa(this,void 0,void 0,function*(){return this._gateway.handleCoupons(e)})}getTotalPrice(){return this._gateway.getTotalPrice()}_setExternalCheckout(e,t){return Xa(this,arguments,void 0,function*(e,t,n=!1,i){const r="/checkout.php",o=Object.assign({action:"set_external_checkout",provider:e},yield this._gateway.mapToExternalCheckoutData(t));if(n)return new Promise(e=>{this._formPoster.postForm(i?`${i}/checkout`:r,Object.assign(Object.assign({},o),{card_information:JSON.stringify(o.card_information)}),e)});yield this._requestSender.post(r,{headers:Object.assign({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},Fr),body:o})})}isWebViewWithRestrictions(){return this._gateway.isWebViewWithRestrictions()}setIsWebViewExperimentOn(e){return this._gateway.setIsWebViewExperimentOn(e)}_prefetchGooglePaymentData(){const e=this._getPaymentDataRequest();e.transactionInfo=this._gateway.getTransactionInfo(),this._getPaymentsClient().prefetchPaymentData(e)}_determineReadinessToPay(){return Xa(this,void 0,void 0,function*(){try{const{result:e}=yield this._getPaymentsClient().isReadyToPay(this._getIsReadyToPayRequest());if(!1===e)throw new Za("Google Pay is not supported by the current device and browser, please try another payment method.")}catch(e){if(e instanceof Za)throw e;throw new Za}})}_buildButtonPayloads(){this._baseCardPaymentMethod={type:"CARD",parameters:this._gateway.getCardParameters()}}_buildWidgetPayloads(){return Xa(this,void 0,void 0,function*(){const e=this._getBaseCardPaymentMethod();this._cardPaymentMethod=Object.assign(Object.assign({},e),{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:yield this._gateway.getPaymentGatewayParameters()}});const t=this._gateway.isWebViewWithRestrictions()?{shippingOptionRequired:!1}:{callbackIntents:this._gateway.getCallbackIntents(),offerInfo:this._gateway.getAppliedCoupons()};this._paymentDataRequest=Object.assign(Object.assign(Object.assign(Object.assign({},this._baseRequest),{allowedPaymentMethods:[this._cardPaymentMethod],transactionInfo:this._gateway.getTransactionInfo(),merchantInfo:this._gateway.getMerchantInfo()}),yield this._gateway.getRequiredData()),t),this._isReadyToPayRequest=Object.assign(Object.assign({},this._baseRequest),{allowedPaymentMethods:[e]})})}_getBaseCardPaymentMethod(){return this._getOrThrow(this._baseCardPaymentMethod)}_getPaymentDataRequest(){return this._getOrThrow(this._paymentDataRequest)}_getIsReadyToPayRequest(){return this._getOrThrow(this._isReadyToPayRequest)}_getPaymentsClient(){return this._getOrThrow(this._paymentsClient)}_getOrThrow(e){return yr(e,()=>new fr(pr.PaymentNotInitialized))}}class ts{constructor(e){this._scriptLoader=e,this._window=window}getGooglePaymentsClient(){return e=this,t=arguments,i=function*(e=!1,t){if(yield this._scriptLoader.loadScript("https://pay.google.com/gp/p/js/pay.js"),!this._window.google)throw new Pr;return void 0===this._paymentsClient&&(this._paymentsClient=new this._window.google.payments.api.PaymentsClient(Object.assign({environment:e?"TEST":"PRODUCTION"},null!=t?t:{}))),this._paymentsClient},new((n=void 0)||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())});var e,t,n,i}}function ns(){return new ts(le())}const is=Ar(t=>{const i=e(),r=window,o=new Hr(t),a=new oo(new uo(le(),r,o));return new Qa(t,new es(ns(),new $a(t,a),i,n()))},[{id:"googlepaybraintree"}]),rs=["ar_BH","ar_DZ","ar_EG","ar_JO","ar_KW","ar_MA","ar_OM","ar_QA","ar_SA","ar_TN","ar_YE","ar_AE","bg_BG","cs_CZ","da_DK","da_FO","da_GL","de_AT","de_CH","de_DE","de_LU","el_GR","en_AD","en_AE","en_AG","en_AI","en_AL","en_AM","en_AN","en_AO","en_AT","en_AU","en_AW","en_AZ","en_BB","en_BE","en_BH","en_BJ","en_BM","en_BN","en_BS","en_BT","en_BW","en_BY","en_BZ","en_C2","en_CA","en_CD","en_CG","en_CH","en_CI","en_CK","en_CL","en_CM","en_CN","en_CO","en_CR","en_CV","en_CY","en_CZ","en_DE","en_DJ","en_DK","en_DM","en_DO","en_DZ","en_EC","en_EE","en_EG","en_ER","en_ES","en_ET","en_FI","en_FJ","en_FK","en_FM","en_FO","en_FR","en_GA","en_GB","en_GD","en_GE","en_GF","en_GI","en_GL","en_GM","en_GN","en_GP","en_GR","en_GT","en_GW","en_GY","en_HK","en_HN","en_HR","en_HU","en_ID","en_IE","en_IL","en_IN","en_IS","en_IT","en_JM","en_JO","en_JP","en_KE","en_KG","en_KH","en_KI","en_KM","en_KN","en_KR","en_KW","en_KY","en_KZ","en_LA","en_LC","en_LI","en_LK","en_LS","en_LT","en_LU","en_LV","en_MA","en_MC","en_MD","en_ME","en_MG","en_MH","en_MK","en_ML","en_MN","en_MQ","en_MR","en_MS","en_MT","en_MU","en_MV","en_MW","en_MY","en_MZ","en_NA","en_NC","en_NE","en_NF","en_NG","en_NI","en_NL","en_NO","en_NP","en_NR","en_NU","en_NZ","en_OM","en_PA","en_PE","en_PF","en_PG","en_PH","en_PL","en_PM","en_PN","en_PT","en_PW","en_PY","en_QA","en_RE","en_RO","en_RS","en_RU","en_RW","en_SA","en_SB","en_SC","en_SE","en_SG","en_SH","en_SI","en_SJ","en_SK","en_SL","en_SM","en_SN","en_SO","en_SR","en_ST","en_SV","en_SZ","en_TC","en_TD","en_TG","en_TH","en_TJ","en_TM","en_TN","en_TO","en_TR","en_TT","en_TV","en_TW","en_TZ","en_UA","en_UG","en_US","en_UY","en_VA","en_VC","en_VE","en_VG","en_VN","en_VU","en_WF","en_WS","en_YE","en_YT","en_ZA","en_ZM","en_ZW","es_AD","es_AI","es_AO","es_AR","es_AW","es_BB","es_BJ","es_BM","es_BO","es_BS","es_BZ","es_CD","es_CG","es_CK","es_CL","es_CO","es_CR","es_CV","es_DJ","es_DM","es_DO","es_DZ","es_EC","es_EG","es_ER","es_ES","es_ET","es_FJ","es_FK","es_FO","es_GA","es_GD","es_GE","es_GI","es_GL","es_GM","es_GN","es_GT","es_GW","es_GY","es_HN","es_IE","es_JM","es_JO","es_KE","es_KG","es_KI","es_KM","es_KN","es_KW","es_KY","es_KZ","es_LC","es_LI","es_LS","es_LU","es_MA","es_MG","es_MH","es_ML","es_MR","es_MS","es_MU","es_MW","es_MX","es_MZ","es_NA","es_NC","es_NE","es_NF","es_NI","es_NR","es_NU","es_NZ","es_OM","es_PA","es_PE","es_PF","es_PG","es_PM","es_PN","es_PW","es_PY","es_QA","es_RS","es_RW","es_SA","es_SB","es_SC","es_SH","es_SJ","es_SL","es_SM","es_SN","es_SO","es_SR","es_ST","es_SV","es_SZ","es_TC","es_TD","es_TG","es_TJ","es_TM","es_TN","es_TT","es_TV","es_UA","es_UG","es_US","es_UY","es_VA","es_VC","es_VE","es_VG","es_VU","es_WF","es_YE","es_ZM","et_EE","fi_FI","fr_AD","fr_AE","fr_AI","fr_AM","fr_AO","fr_AW","fr_AZ","fr_BB","fr_BE","fr_BF","fr_BI","fr_BJ","fr_BM","fr_BS","fr_BZ","fr_CA","fr_CD","fr_CG","fr_CH","fr_CI","fr_CK","fr_CM","fr_CV","fr_DJ","fr_DM","fr_DO","fr_DZ","fr_EC","fr_ER","fr_ET","fr_FJ","fr_FK","fr_FO","fr_FR","fr_GA","fr_GD","fr_GE","fr_GF","fr_GI","fr_GL","fr_GM","fr_GN","fr_GP","fr_GT","fr_GW","fr_GY","fr_HN","fr_IE","fr_JM","fr_JO","fr_KE","fr_KG","fr_KI","fr_KM","fr_KN","fr_KW","fr_KY","fr_KZ","fr_LC","fr_LI","fr_LS","fr_LU","fr_MA","fr_MC","fr_MG","fr_MH","fr_ML","fr_MQ","fr_MR","fr_MS","fr_MU","fr_MW","fr_MZ","fr_NA","fr_NC","fr_NE","fr_NF","fr_NI","fr_NR","fr_NU","fr_NZ","fr_OM","fr_PA","fr_PE","fr_PF","fr_PG","fr_PM","fr_PN","fr_PW","fr_QA","fr_RE","fr_RS","fr_RW","fr_SA","fr_SB","fr_SC","fr_SH","fr_SJ","fr_SL","fr_SM","fr_SN","fr_SO","fr_SR","fr_ST","fr_SV","fr_SZ","fr_TC","fr_TD","fr_TG","fr_TJ","fr_TM","fr_TN","fr_TT","fr_TV","fr_UA","fr_UG","fr_US","fr_UY","fr_VA","fr_VC","fr_VE","fr_VG","fr_VU","fr_WF","fr_YE","fr_YT","fr_ZA","fr_ZM","he_IL","hu_HU","id_ID","it_IT","ja_JP","ko_KR","lv_LV","lt_LT","ms_BN","ms_MY","nl_BE","nl_NL","pl_PL","pt_BR","pt_PT","ro_RO","ru_EE","ru_LT","ru_LV","ru_RU","ru_UA","si_LK","sk_SK","sl_SI","sq_AL","sv_SE","tl_PH","th_TH","tr_TR","vi_VN","zh_C2","zh_CN","zh_HK","zh_TW","zh_AD","zh_AE","zh_AI","zh_AO","zh_AW","zh_BB","zh_BH","zh_BJ","zh_BM","zh_BS","zh_BZ","zh_CD","zh_CG","zh_CK","zh_CL","zh_CO","zh_CV","zh_DJ","zh_DM","zh_DO","zh_DZ","zh_EC","zh_EG","zh_ER","zh_ET","zh_FJ","zh_FK","zh_FO","zh_GA","zh_GD","zh_GE","zh_GI","zh_GL","zh_GM","zh_GN","zh_GT","zh_GW","zh_GY","zh_HN","zh_IE","zh_JM","zh_JO","zh_KE","zh_KG","zh_KI","zh_KM","zh_KN","zh_KW","zh_KY","zh_KZ","zh_LC","zh_LI","zh_LS","zh_LT","zh_LU","zh_MA","zh_MG","zh_MH","zh_ML","zh_MR","zh_MS","zh_MU","zh_MW","zh_MZ","zh_NA","zh_NC","zh_NE","zh_NF","zh_NI","zh_NR","zh_NU","zh_NZ","zh_OM","zh_PA","zh_PE","zh_PF","zh_PG","zh_PM","zh_PN","zh_PW","zh_QA","zh_RS","zh_RW","zh_SA","zh_SB","zh_SC","zh_SH","zh_SJ","zh_SL","zh_SM","zh_SN","zh_SO","zh_SR","zh_ST","zh_SV","zh_SZ","zh_TC","zh_TD","zh_TG","zh_TJ","zh_TM","zh_TN","zh_TT","zh_TV","zh_UA","zh_UG","zh_US","zh_UY","zh_VA","zh_VC","zh_VE","zh_VG","zh_VU","zh_WF","zh_YE","zh_ZA","zh_ZM"];function os(e){if(!e)return;let t;if(e.includes("-")){const[n,i]=e.split("-");t=`${n}_${i.toUpperCase()}`}else t=`${e}_${e.toUpperCase()}`;return rs.includes(t)?t:void 0}var as=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ss{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n,i){return as(this,void 0,void 0,function*(){if(!this.window.paypalFastlaneSdk){const r=this.getPayPalFastlaneSdkConfiguration(e,t,n,i);if(yield this.loadPayPalSdk(r),!this.window.paypalFastlaneSdk)throw new Pr}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i,r){return as(this,void 0,void 0,function*(){if(!this.window.paypalGooglePay||r){const r=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i);yield this.loadPayPalSdk(r)}if(!this.window.paypalGooglePay)throw new Pr;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t,n){return as(this,void 0,void 0,function*(){if(!this.window.paypalApms){const i=this.getPayPalApmSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.paypalApms)throw new Pr}return this.window.paypalApms})}getPayPalMessages(e,t,n){return as(this,void 0,void 0,function*(){if(!this.window.paypalMessages){const i=this.getPayPalSdkMessagesConfiguration(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.paypalMessages)throw new Pr;return this.window.paypalMessages})}loadPayPalSdk(e){return as(this,arguments,void 0,function*({options:e,attributes:t}){const n=this.transformConfig(e),i=this.transformConfig(t),r=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(r,{async:!0,attributes:i})})}getPayPalFastlaneSdkConfiguration(e,t,n,i){const{clientToken:r,initializationData:o}=e;if(!o||!o.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,attributionId:c}=o,u=os(i);return{options:Object.assign({"client-id":s,"merchant-id":d,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t,intent:a},u&&{locale:u}),attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":r}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i=!0){const{clientToken:r,initializationData:o}=e;if(!o||!o.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,buyerCountry:c,attributionId:u,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:h}=o,p=l||i,g=os(n);return{options:Object.assign(Object.assign({"client-id":s,"merchant-id":d,commit:p,components:["googlepay"],currency:t,intent:a},h&&{"buyer-country":c}),g&&{locale:g}),attributes:{"data-partner-attribution-id":u,"data-client-token":r,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:r,clientId:o,merchantId:a,buyerCountry:s,attributionId:d,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:u=[],enabledAlternativePaymentMethods:l=[]}=i,h=l,p=u.filter(e=>!l.includes(e)),g=os(n);return{options:Object.assign(Object.assign({"client-id":o,"merchant-id":a,"enable-funding":h.length>0?h:void 0,"disable-funding":p.length>0?p:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:r},c&&{"buyer-country":s}),g&&{locale:g}),attributes:{"data-partner-attribution-id":d,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new gr(hr.MissingPaymentMethod);const{clientId:r,merchantId:o,attributionId:a,isDeveloperModeApplicable:s,buyerCountry:d}=i,c=os(n);return{options:Object.assign(Object.assign({"client-id":r,"merchant-id":o,components:["messages"],currency:t},s&&{"buyer-country":d}),c&&{locale:c}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}function ds(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 gr(hr.MissingPaymentMethod)}var cs=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class us extends Ya{constructor(e,t){super("paypalsb",e),this.payPalCommerceSdk=t,this.service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return cs(this,void 0,void 0,function*(){var r,o,a,s,d;const c=this.service.getState(),u=null!==(o=null===(r=c.getStoreConfig())||void 0===r?void 0:r.currency.code)&&void 0!==o?o:n;if(!u)throw new gr(hr.MissingPaymentMethod);yield i.initialize.call(this,e,t,u);const l=i.getPaymentMethod.call(this);if(!l.initializationData)throw new gr(hr.MissingPaymentMethod);ds(l);const h=yield this.payPalCommerceSdk.getPayPalGooglePaySdk(l,u,c.getLocale());this.googlepayConfig=yield h.Googlepay().config();const{allowedPaymentMethods:p}=this.googlepayConfig;this.setGatewayIdentifier(null===(d=null===(s=null===(a=p[0])||void 0===a?void 0:a.tokenizationSpecification)||void 0===s?void 0:s.parameters)||void 0===d?void 0:d.gateway)})}getPaymentGatewayParameters(){if(this.googlepayConfig){const{allowedPaymentMethods:e}=this.googlepayConfig,{gatewayMerchantId:t}=e[0].tokenizationSpecification.parameters;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:t}}return{gateway:this.getGatewayIdentifier()}}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return cs(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n})}}const ls=Ar(t=>new Qa(t,new es(ns(),new us(t,new ss(le())),e(),n())),[{id:"googlepaypaypalcommerce"}]);var hs=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ps{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n){return hs(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsFastlaneSdk){const i=this.getPayPalFastlaneSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.bigCommercePaymentsFastlaneSdk)throw new Pr}return this.window.bigCommercePaymentsFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i){return hs(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsGooglePay||i){const i=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.bigCommercePaymentsGooglePay)throw new Pr;return this.window.bigCommercePaymentsGooglePay})}getPayPalApmsSdk(e,t){return hs(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsApms){const n=this.getPayPalApmSdkConfiguration(e,t);if(yield this.loadPayPalSdk(n),!this.window.bigCommercePaymentsApms)throw new Pr}return this.window.bigCommercePaymentsApms})}getPayPalMessages(e,t){return hs(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsMessages){const n=this.getPayPalSdkMessagesConfiguration(e,t);yield this.loadPayPalSdk(n)}if(!this.window.bigCommercePaymentsMessages)throw new Pr;return this.window.bigCommercePaymentsMessages})}loadPayPalSdk(e){return hs(this,arguments,void 0,function*({options:e,attributes:t}){const n=this.transformConfig(e),i=this.transformConfig(t),r=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(r,{async:!0,attributes:i})})}getPayPalFastlaneSdkConfiguration(e,t,n){const{clientToken:i,initializationData:r}=e;if(!r||!r.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:o,clientId:a,merchantId:s,attributionId:d}=r;return{options:{"client-id":a,"merchant-id":s,commit:!0,components:["fastlane","three-domain-secure"],currency:t,intent:o},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"bigCommercePaymentsFastlaneSdk","data-partner-attribution-id":d,"data-sdk-client-token":i}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n=!0){const{clientToken:i,initializationData:r}=e;if(!r||!r.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:o,clientId:a,merchantId:s,buyerCountry:d,attributionId:c,isHostedCheckoutEnabled:u,isDeveloperModeApplicable:l}=r,h=u||n;return{options:Object.assign({"client-id":a,"merchant-id":s,commit:h,components:["googlepay"],currency:t,intent:o},l&&{"buyer-country":d}),attributes:{"data-partner-attribution-id":c,"data-client-token":i,"data-namespace":"bigCommercePaymentsGooglePay"}}}getPayPalApmSdkConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:i,clientId:r,merchantId:o,buyerCountry:a,attributionId:s,isDeveloperModeApplicable:d,availableAlternativePaymentMethods:c=[],enabledAlternativePaymentMethods:u=[]}=n,l=this.filterFundingOptions(u),h=this.filterFundingOptions(c.filter(e=>!u.includes(e)));return{options:Object.assign({"client-id":r,"merchant-id":o,"enable-funding":l.length>0?l:void 0,"disable-funding":h.length>0?h:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:i},d&&{"buyer-country":a}),attributes:{"data-partner-attribution-id":s,"data-namespace":"bigCommercePaymentsApms"}}}getPayPalSdkMessagesConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new gr(hr.MissingPaymentMethod);const{clientId:i,merchantId:r,attributionId:o,isDeveloperModeApplicable:a,buyerCountry:s}=n;return{options:Object.assign({"client-id":i,"merchant-id":r,components:["messages"],currency:t},a&&{"buyer-country":s}),attributes:{"data-namespace":"bigCommercePaymentsMessages","data-partner-attribution-id":o}}}filterFundingOptions(e){const t=["klarna","afterpay"];return e?e.filter(e=>!t.includes(e)):[]}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}var gs=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ms extends Ya{constructor(e,t){super("googlepay_bigcommerce_payments",e),this.payPalSdkHelper=t,this.service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return gs(this,void 0,void 0,function*(){var r,o,a,s,d;const c=null!==(o=null===(r=this.service.getState().getStoreConfig())||void 0===r?void 0:r.currency.code)&&void 0!==o?o:n;if(!c)throw new gr(hr.MissingPaymentMethod);yield i.initialize.call(this,e,t,c);const u=i.getPaymentMethod.call(this);if(!u.initializationData)throw new gr(hr.MissingPaymentMethod);ds(u);const l=yield this.payPalSdkHelper.getPayPalGooglePaySdk(u,c);this.googlepayConfig=yield l.Googlepay().config();const{allowedPaymentMethods:h}=this.googlepayConfig;this.setGatewayIdentifier(null===(d=null===(s=null===(a=h[0])||void 0===a?void 0:a.tokenizationSpecification)||void 0===s?void 0:s.parameters)||void 0===d?void 0:d.gateway)})}getPaymentGatewayParameters(){if(this.googlepayConfig){const{allowedPaymentMethods:e}=this.googlepayConfig,{gatewayMerchantId:t}=e[0].tokenizationSpecification.parameters;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:t}}return{gateway:this.getGatewayIdentifier()}}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return gs(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n})}}const ys=Ar(t=>new Qa(t,new es(ns(),new ms(t,new ps(le())),e(),n())),[{id:"googlepay_bigcommerce_payments"}]),fs=Ar(t=>{const i=e();return new Qa(t,new es(ns(),new Ya("adyen",t),i,n()))},[{id:"googlepayadyenv2"}]),_s=Ar(t=>{const i=e();return new Qa(t,new es(ns(),new Ya("adyen",t),i,n()))},[{id:"googlepayadyenv3"}]);class Ss extends Ya{constructor(e){super("authorizenet",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,o=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return function(e){if(!function(e){return"paymentGatewayId"in e}(e))throw new gr(hr.MissingPaymentMethod)}(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.paymentGatewayId}}}const vs=Ar(t=>new Qa(t,new es(ns(),new Ss(t),e(),n())),[{id:"googlepayauthorizenet"}]),Cs=e=>"object"==typeof e&&null!==e&&"body"in e;function Is(e){if(!function(e){return"checkoutcomkey"in e}(e))throw new gr(hr.MissingPaymentMethod)}var ws=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Es extends Ya{constructor(e,t){super("checkoutltd",e),this._requestSender=t}processAdditionalAction(e){return new Promise((t,n)=>{if(Cs(e)&&function(e){var t;if("object"!=typeof e||null===e)return!1;const n=e;return"string"==typeof(null===(t=n.three_ds_result)||void 0===t?void 0:t.acs_url)&&"string"==typeof n.three_ds_result.code}(e.body)&&"three_d_secure_required"===e.body.three_ds_result.code)return window.location.assign(e.body.three_ds_result.acs_url);n(e)})}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return ws(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new Tr("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 gr(hr.MissingPaymentToken)}(i),n.nonce=yield this._tokenize(i),n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return Is(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.checkoutcomkey}}_tokenize(e){return ws(this,void 0,void 0,function*(){const t=this.getPaymentMethod().config.testMode?"https://api.sandbox.checkout.com/tokens":"https://api.checkout.com/tokens",n=this.getGooglePayInitializationData();Is(n);const{body:i}=yield this._requestSender.post(t,{credentials:!1,body:{type:"googlepay",token_data:e},headers:{Authorization:n.checkoutcomkey,"Content-Type":Ur.Json,"X-XSRF-TOKEN":null}});return i.token})}}const bs=Ar(t=>{const i=e();return new Qa(t,new es(ns(),new Es(t,i),i,n()))},[{id:"googlepaycheckoutcom"}]);class Ps extends Ya{constructor(e){super("cybersource",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,o=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}}const Os=Ar(t=>new Qa(t,new es(ns(),new Ps(t),e(),n())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]);class As extends Ya{constructor(e){super("chase",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,o=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}}const Ts=Ar(t=>new Qa(t,new es(ns(),new As(t),e(),n())),[{id:"googlepayorbital"}]);var ks,Rs,Ds,Ms,Ns,Ls,zs,Us,Fs,Bs,xs,qs;!function(e){e.SHIPPING="shipping",e.BILLING="billing"}(ks||(ks={})),function(e){e.SPLIT="split",e.FULL="full",e.ORGANIZATION="organization"}(Rs||(Rs={})),function(e){e.Open="open",e.Expired="expired",e.Complete="complete"}(Ds||(Ds={})),function(e){e.Paid="paid",e.UnPaid="unpaid",e.NoPaymentRequired="no_payment_required"}(Ms||(Ms={})),function(e){e.SUCCESS="success",e.ERROR="error"}(Ns||(Ns={})),function(e){e.CreditCard="card",e.ACH="us_bank_account",e.Link="link",e.EPS="eps",e.GRABPAY="grabpay",e.BANCONTACT="bancontact",e.IDEAL="ideal",e.ALIPAY="alipay",e.KLARNA="klarna",e.OCS="optimized_checkout",e.CHECKOUT_SESSION="checkout_session"}(Ls||(Ls={})),function(e){e.NEVER="never",e.AUTO="auto",e.ALWAYS="always",e.PAYMENT="payment",e.IF_REQUIRED="if_required"}(zs||(zs={})),function(e){e.V3="v3",e.ACACIA="acacia",e.BASIL="basil",e.CLOVER="clover"}(Us||(Us={})),function(e){e.PAYMENT="payment",e.AUTHENTICATION="linkAuthentication",e.SHIPPING="address",e.EXPRESS_CHECKOUT="expressCheckout"}(Fs||(Fs={})),function(e){e.REQUIRES_PAYMENT_METHOD="requires_payment_method",e.REQUIRES_CONFIRMATION="requires_confirmation",e.REQUIRES_ACTION="requires_action",e.PROCESSING="processing",e.SUCCEEDED="succeeded",e.CANCELED="canceled"}(Bs||(Bs={})),function(e){e.CLICK="click",e.CHANGE="change",e.READY="ready",e.SHIPPING_ADDRESS_CHANGE="shippingaddresschange",e.SHIPPING_RATE_CHANGE="shippingratechange",e.CONFIRM="confirm",e.CANCEL="cancel",e.LOADER_START="loaderstart"}(xs||(xs={})),function(e){e.ON_SESSION="on_session",e.OFF_SESSION="off_session"}(qs||(qs={}));var js=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Gs{constructor(e,t=window){this.scriptLoader=e,this.stripeWindow=t}getStripeClient(e,t,n,i,r){return js(this,void 0,void 0,function*(){if(this.stripeWindow.bcStripeClient)return this.stripeWindow.bcStripeClient;const o=yield this.load(n),{stripePublishableKey:a,stripeConnectedAccount:s}=e,d=o(a,Object.assign(Object.assign(Object.assign(Object.assign({},s?{stripeAccount:s}:{}),t?{locale:t}:{}),i?{betas:i}:{}),r?{apiVersion:r}:{}));return Object.assign(this.stripeWindow,{bcStripeClient:d}),d})}getElements(e,t){return js(this,void 0,void 0,function*(){let n=this.stripeWindow.bcStripeElements;return n?yield this.updateStripeElements(t):(n=e.elements(t),Object.assign(this.stripeWindow,{bcStripeElements:n})),n})}updateStripeElements(e){return js(this,void 0,void 0,function*(){const t=this.stripeWindow.bcStripeElements;t&&(t.update(e),yield t.fetchUpdates())})}getStripeCheckout(e,t){return js(this,void 0,void 0,function*(){let n=yield this.getStoredStripeCheckout(t);return n||(n=yield e.initCheckout(t),Object.assign(this.stripeWindow,{bcStripeCheckout:n})),n})}load(e){return js(this,void 0,void 0,function*(){if(!this.stripeWindow.Stripe&&(yield this.scriptLoader.loadScript(this.getScriptUrl(e)),!this.stripeWindow.Stripe))throw new Pr;return this.stripeWindow.Stripe})}getScriptUrl(e){return e&&e!==Us.V3?`https://js.stripe.com/${e}/stripe.js`:"https://js.stripe.com/v3/"}getStoredStripeCheckout(e){return js(this,void 0,void 0,function*(){const t=this.stripeWindow.bcStripeCheckout;if(t)try{const{actions:n,error:i}=yield t.loadActions();if(i||!n)return void this.logErrorToConsole(i);const r=yield n.getSession(),o=e.clientSecret.split("_secret_")[0];if(r.id===o)return t}catch(e){return void this.logErrorToConsole(e)}})}logErrorToConsole(e){e?console.error(e):console.error("No stripe checkout actions available on loadActions().")}}const Vs=["payment_element_beta_2","alipay_pm_beta_1","link_default_integration_beta_1","shipping_address_element_beta_1","address_element_beta_1"];function Hs(e){if(!function(e){return"stripeConnectedAccount"in e&&"stripePublishableKey"in e&&"stripeVersion"in e}(e))throw new gr(hr.MissingPaymentMethod)}var Ws=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ys extends Ya{constructor(e,t){super("stripe",e),this.paymentIntegrationService=e,this.scriptLoader=t}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return Ws(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new Tr("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 gr(hr.MissingPaymentToken)}(i),n.nonce=i.id,n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();Hs(e);const{stripeVersion:t,stripePublishableKey:n,stripeConnectedAccount:i}=e;return{gateway:this.getGatewayIdentifier(),"stripe:version":t,"stripe:publishableKey":`${n}/${i}`}}processAdditionalAction(e,t){return Ws(this,void 0,void 0,function*(){var n,i;if(!t)throw new Qo(["payment"]);if(!Cs(e)||("object"!=typeof(i=e.body)||null===i||!("three_ds_result"in i)||!("errors"in i)))throw e;if(z(e.body.errors,{code:"three_d_secure_required"})){const i=this.getGooglePayInitializationData();Hs(i),this.stripeUPEClient=yield this.loadStripeJs(i,t);const r=e.body.three_ds_result.token;let o,a=!1;try{o=yield this.stripeUPEClient.confirmCardPayment(r)}catch(e){try{o=yield this.stripeUPEClient.retrievePaymentIntent(r)}catch(e){a=!0}}if(null==o?void 0:o.error){if(this._throwDisplayableStripeError(o.error),this._isCancellationError(o.error))throw new lo;throw new Za}if(!(null==o?void 0:o.paymentIntent)&&!a)throw new Ie;return this.paymentIntegrationService.submitPayment({methodId:t,paymentData:{nonce:(null===(n=null==o?void 0:o.paymentIntent)||void 0===n?void 0:n.id)||r}})}throw e})}loadStripeJs(e,t){return Ws(this,void 0,void 0,function*(){if(this.stripeUPEClient)return this.stripeUPEClient;const n=this.paymentIntegrationService.getState().getCartLocale();return"googlepaystripeocs"===t&&e.useNewStripeJsVersion?this.scriptLoader.getStripeClient(e,n,Us.CLOVER):this.scriptLoader.getStripeClient(e,n,Us.V3,Vs,"2020-03-02;alipay_beta=v1;link_beta=v1")})}_isCancellationError(e){var t,n;return e&&-1!==(null===(n=null===(t=e.payment_intent.last_payment_error)||void 0===t?void 0:t.message)||void 0===n?void 0:n.indexOf("canceled"))}_throwDisplayableStripeError(e){if(m(["card_error","invalid_request_error","validation_error"],e.type))throw new Error(e.message)}}const Ks=Ar(t=>new Qa(t,new es(ns(),new Ys(t,new Gs(le())),e(),n())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]);class $s extends Ya{constructor(e){super("worldpay",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,o=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}}const Zs=Ar(t=>new Qa(t,new es(ns(),new $s(t),e(),n())),[{id:"googlepayworldpayaccess"}]);function Js(){const{navigator:e}=window;let t;return t=e.language?e.language:e.userLanguage,{color_depth:window.screen.colorDepth||24,java_enabled:"function"==typeof e.javaEnabled&&e.javaEnabled(),language:t,screen_height:window.screen.height,screen_width:window.screen.width,time_zone_offset:(new Date).getTimezoneOffset().toString()}}var Qs=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Xs extends Ya{constructor(e,t){super("worldlinena",e),this.formPoster=t}extraPaymentData(){return Qs(this,void 0,void 0,function*(){return Promise.resolve({browser_info:Js()})})}processAdditionalAction(e){return Qs(this,void 0,void 0,function*(){if(!function(e){return Cs(e)&&(t=e.body,C(t)&&"object"==typeof t&&"errors"in t&&"three_ds_result"in t&&y(t.errors)&&z(t.errors,{code:"three_d_secure_required"}));var t}(e))throw e;const{three_ds_result:t}=e.body,{acs_url:n,payer_auth_request:i,merchant_data:r}=t||{};if(!n||!i||!r)throw new Qo(["formUrl","threeDSSessionData","creq"]);return new Promise(e=>{this.formPoster.postForm(n,{threeDSSessionData:i,creq:r},e,"_top")})})}}const ed=Ar(t=>new Qa(t,new es(ns(),new Xs(t,n()),e(),n())),[{id:"googlepaytdonlinemart"}]);var td,nd,id,rd,od,ad,sd,dd,cd,ud,ld=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class hd{constructor(e){this.scriptLoader=e,this.window=window}getPayPalSDK(e,t,n,i,r){return ld(this,void 0,void 0,function*(){if(!this.window.paypal||r){const r=this.getPayPalSdkScriptConfigOrThrow(e,t,n,i);if(yield this.loadPayPalSdk(r),!this.window.paypal)throw new Pr}return this.window.paypal})}getPayPalFastlaneSdk(e,t,n,i){return ld(this,void 0,void 0,function*(){if(!this.window.paypalFastlaneSdk){const r=this.getPayPalFastlaneSdkConfiguration(e,t,n,i);if(yield this.loadPayPalSdk(r),!this.window.paypalFastlaneSdk)throw new Pr}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i,r){return ld(this,void 0,void 0,function*(){if(!this.window.paypalGooglePay||r){const r=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i);yield this.loadPayPalSdk(r)}if(!this.window.paypalGooglePay)throw new Pr;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t,n){return ld(this,void 0,void 0,function*(){if(!this.window.paypalApms){const i=this.getPayPalApmSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.paypalApms)throw new Pr}return this.window.paypalApms})}getPayPalMessages(e,t,n){return ld(this,void 0,void 0,function*(){if(!this.window.paypalMessages){const i=this.getPayPalSdkMessagesConfiguration(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.paypalMessages)throw new Pr;return this.window.paypalMessages})}loadPayPalSdk(e){return ld(this,arguments,void 0,function*({options:e,attributes:t}){const n=this.transformConfig(e),i=this.transformConfig(t),r=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(r,{async:!0,attributes:i})})}getPayPalSdkScriptConfigOrThrow(e,t,n,i=!0){const{id:r,clientToken:o,initializationData:a}=e;if(!a||!a.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:s,clientId:d,merchantId:c,buyerCountry:u,attributionId:l,isVenmoEnabled:h,isHostedCheckoutEnabled:p,isPayPalCreditAvailable:g,isDeveloperModeApplicable:m,availableAlternativePaymentMethods:y=[],enabledAlternativePaymentMethods:f=[],isGooglePayEnabled:_}=a,S=p||i,v="paypalcommercecreditcards"===r||"bigcommerce_payments_creditcards"===r,C=v?["card"]:[],I=g?["credit","paylater"]:[],w=h?["venmo"]:[],E=_?["googlepay"]:[],b=i?["card-fields"]:[],P=[...v?[]:["card"],...g?[]:["credit","paylater"],...h?[]:["venmo"],...y.filter(e=>!f.includes(e))],O=[...C,...I,...w,...f],A=os(n);return{options:Object.assign(Object.assign({"client-id":d,"merchant-id":c,"enable-funding":O.length>0?O:void 0,"disable-funding":P.length>0?P:void 0,commit:S,components:["buttons","hosted-fields","payment-fields","legal",...E,...b],currency:t,intent:s},m&&{"buyer-country":u}),A&&{locale:A}),attributes:{"data-partner-attribution-id":l,"data-client-token":o}}}getPayPalFastlaneSdkConfiguration(e,t,n,i){const{clientToken:r,initializationData:o}=e;if(!o||!o.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,attributionId:c}=o,u=os(i);return{options:Object.assign(Object.assign({"client-id":s,"merchant-id":d,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t},u&&{locale:u}),{intent:a}),attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":r}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i=!0){const{clientToken:r,initializationData:o}=e;if(!o||!o.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,buyerCountry:c,attributionId:u,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:h}=o,p=l||i,g=os(n);return{options:Object.assign(Object.assign({"client-id":s,"merchant-id":d,commit:p,components:["googlepay"],currency:t,intent:a},h&&{"buyer-country":c}),g&&{locale:g}),attributes:{"data-partner-attribution-id":u,"data-client-token":r,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:r,clientId:o,merchantId:a,buyerCountry:s,attributionId:d,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:u=[],enabledAlternativePaymentMethods:l=[]}=i,h=l,p=u.filter(e=>!l.includes(e)),g=os(n);return{options:Object.assign(Object.assign({"client-id":o,"merchant-id":a,"enable-funding":h.length>0?h:void 0,"disable-funding":p.length>0?p:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:r},c&&{"buyer-country":s}),g&&{locale:g}),attributes:{"data-partner-attribution-id":d,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new gr(hr.MissingPaymentMethod);const{clientId:r,merchantId:o,attributionId:a,isDeveloperModeApplicable:s,buyerCountry:d}=i,c=os(n);return{options:Object.assign(Object.assign({"client-id":r,"merchant-id":o,components:["messages"],currency:t},s&&{"buyer-country":d}),c&&{locale:c}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}!function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(td||(td={})),function(e){e.Always="SCA_ALWAYS"}(nd||(nd={})),function(e){e.Succeeded="succeeded",e.Cancelled="cancelled",e.Errored="errored"}(id||(id={})),function(e){e.Possible="POSSIBLE",e.No="NO",e.Unknown="UNKNOWN",e.Yes="YES"}(rd||(rd={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(od||(od={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(ad||(ad={})),function(e){e.pill="pill",e.rect="rect"}(sd||(sd={})),function(e){e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="canceled",e.UNRECOGNIZED="unrecognized"}(dd||(dd={})),(cd||(cd={})).OXXO="oxxo",function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(ud||(ud={}));var pd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class gd{constructor(e,t,n,i){this.formPoster=e,this.paymentIntegrationService=t,this.paypalRequestSender=n,this.paypalSdkLoader=i}loadPayPalSdk(e,t,n,i){return pd(this,void 0,void 0,function*(){const r=this.paymentIntegrationService.getState(),o=t||r.getCartOrThrow().currency.code,a=r.getPaymentMethodOrThrow(e),s=r.getLocale();return this.paypalSdk=yield this.paypalSdkLoader.getPayPalSDK(a,o,s,n,i),this.paypalSdk})}getPayPalSdkOrThrow(){if(!this.paypalSdk)throw new Pr;return this.paypalSdk}createBuyNowCartOrThrow(e){return pd(this,void 0,void 0,function*(){const t=e.getBuyNowCartRequestBody();if(!t)throw new gr(hr.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(t)}catch(e){throw new kr}})}createOrder(e,t){return pd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i}=yield this.paypalRequestSender.createOrder(e,Object.assign({cartId:n},t));return i})}createOrderCardFields(e,t){return pd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i,setupToken:r}=yield this.paypalRequestSender.createOrder(e,Object.assign({cartId:n},t));return Object.assign({orderId:i},r?{setupToken:r}:{})})}updateOrder(e,t,n,i){return pd(this,void 0,void 0,function*(){const r=this.paymentIntegrationService.getState(),o=r.getCartOrThrow();let a;i||(a=r.getConsignmentsOrThrow()[0]);try{yield this.paypalRequestSender.updateOrder(e,Object.assign(Object.assign({availableShippingOptions:i?[]:null==a?void 0:a.availableShippingOptions,cartId:o.id,selectedShippingOption:i?null:null==a?void 0:a.selectedShippingOption},t?{methodId:t}:{}),n?{orderId:n}:{}))}catch(e){throw new Ie}})}getOrderStatus(e,t){return pd(this,void 0,void 0,function*(){try{const{status:n}=yield this.paypalRequestSender.getOrderStatus(e,t);return n}catch(e){throw new Ie}})}tokenizePayment(e,t){const n=this.paymentIntegrationService.getState().getCartOrThrow();if(!t)throw new gr(hr.MissingOrderId);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",action:"set_external_checkout",provider:e,order_id:t},n.source===vo.BuyNow&&{cart_id:n.id}))}submitPayment(e,t,n){return pd(this,void 0,void 0,function*(){const i={formattedPayload:{vault_payment_instrument:null,set_as_default_stored_instrument:null,device_info:null,method_id:e,paypal_account:{order_id:t}}};yield this.paymentIntegrationService.submitPayment(Object.assign({methodId:e,paymentData:i},n?{gatewayId:n}:{}))})}getShippingOptionOrThrow(e){const t=this.paymentIntegrationService.getState().getConsignmentsOrThrow()[0],n=t.availableShippingOptions||[],i=n.find(e=>e.isRecommended),r=(e?n.find(t=>t.id===e):n.find(e=>{if(t.selectedShippingOption){const n=t.selectedShippingOption.id;return e.id===n}return!1}))||i||n[0];if(!r)throw new Error("Your order can't be shipped to this address");return r}getAddress(e){return{firstName:(null==e?void 0:e.firstName)||"",lastName:(null==e?void 0:e.lastName)||"",email:(null==e?void 0:e.email)||"",phone:(null==e?void 0:e.phone)||"",company:"",address1:(null==e?void 0:e.address1)||"",address2:(null==e?void 0:e.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:[]}}getBillingAddressFromOrderDetails({payer:e}){var t,n;return this.getAddress({firstName:e.name.given_name,lastName:e.name.surname,email:e.email_address,address1:e.address.address_line_1,address2:e.address.address_line_2,city:e.address.admin_area_2,countryCode:e.address.country_code,postalCode:e.address.postal_code,stateOrProvinceCode:e.address.admin_area_1,phone:null===(n=null===(t=e.phone)||void 0===t?void 0:t.phone_number)||void 0===n?void 0:n.national_number})}getShippingAddressFromOrderDetails(e){const{payer:t,purchase_units:n}=e,{address:i,name:{full_name:r}}=n[0].shipping,[o,...a]=r.split(" ");return this.getAddress({firstName:o,lastName:a.join(" "),email:t.email_address,address1:i.address_line_1,address2:i.address_line_2,city:i.admin_area_2,countryCode:i.country_code,postalCode:i.postal_code,stateOrProvinceCode:i.admin_area_1})}getValidButtonStyle(e={}){const{color:t,height:n,label:i,shape:r}=e,o={color:t&&ad[t]?t:void 0,height:this.getValidHeight(n),label:i&&od[i]?i:void 0,shape:r&&sd[r]?r:void 0};return R(o,v)}getValidHeight(e){return e&&"number"==typeof e?e>55?55:e<25?25:e:40}removeElement(e){const t=e&&document.getElementById(e);t&&(t.style.display="none")}}var md=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class yd{constructor(e){this.requestSender=e}createOrder(e,t){return md(this,void 0,void 0,function*(){const n=`/api/storefront/payment/${e}`,i=t,r=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.post(n,{headers:r,body:i})).body})}updateOrder(e,t){return md(this,void 0,void 0,function*(){const n=`/api/storefront/initialization/${e}`,i=t,r=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.put(n,{headers:r,body:i})).body})}getOrderStatus(e,t){return md(this,void 0,void 0,function*(){const n=`/api/storefront/initialization/${e}`,i=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.get(n,Object.assign({headers:i},t))).body})}}const fd=t=>{const{getHost:i}=t.getState();return new gd(n(),t,new yd(e({host:i()})),new hd(le()))};var _d=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};const Sd=class{constructor(e,t){this.paymentIntegrationService=e,this.paypalIntegrationService=t}createPayPalButton(e,t,n,i){const{style:r,fundingSource:o,isHostedCheckoutEnabled:a,isServerSideShippingCallbacksEnabled:s,onClick:d,onCancel:c,onPaymentComplete:u,onError:l}=n;this.onError=l;const h=this.paypalIntegrationService.getPayPalSdkOrThrow();if(!Object.values(h.FUNDING).includes(o))throw new Tr('Unable to initialize PayPal button because "fundingSource" argument is not valid funding source.');const p=Object.assign(Object.assign({},!s&&{onShippingAddressChange:t=>this.onShippingAddressChange(t,e),onShippingOptionsChange:t=>this.onShippingOptionsChange(t,e)}),{onApprove:(n,i)=>this.onHostedCheckoutApprove(n,i,t,e,u,s)});return h.Buttons(Object.assign(Object.assign(Object.assign({fundingSource:o,style:this.paypalIntegrationService.getValidButtonStyle(r),createOrder:()=>_d(this,void 0,void 0,function*(){if(i){const e=yield this.paypalIntegrationService.createBuyNowCartOrThrow(i);yield this.paymentIntegrationService.loadCheckout(e.id)}return this.paypalIntegrationService.createOrder(e)}),onApprove:({orderID:e})=>this.paypalIntegrationService.tokenizePayment(t,e)},d?{onClick:d}:{}),c?{onCancel:c}:{}),a&&p))}onHostedCheckoutApprove(e,t,n,i,r,o){return _d(this,void 0,void 0,function*(){if(!e.orderID)throw new gr(hr.MissingOrderId);const a=this.paymentIntegrationService.getState().getCartOrThrow();try{const s=a.lineItems.physicalItems.length>0;if(!o){const e=yield t.order.get(),n=this.paypalIntegrationService.getBillingAddressFromOrderDetails(e);if(yield this.paymentIntegrationService.updateBillingAddress(n),s){const t=this.paypalIntegrationService.getShippingAddressFromOrderDetails(e);yield this.paymentIntegrationService.updateShippingAddress(t)}}s&&(yield this.paypalIntegrationService.updateOrder(i,void 0,void 0,o)),o&&(yield this.paymentIntegrationService.loadCheckout()),yield this.paymentIntegrationService.submitOrder({},{params:{methodId:n}}),yield this.paypalIntegrationService.submitPayment(n,e.orderID),r&&"function"==typeof r&&r()}catch(e){this.handleError(e)}})}onShippingAddressChange(e,t){return _d(this,void 0,void 0,function*(){const n=this.paypalIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state});try{yield this.paymentIntegrationService.updateBillingAddress(n),yield this.paymentIntegrationService.updateShippingAddress(n);const e=this.paypalIntegrationService.getShippingOptionOrThrow();yield this.paymentIntegrationService.selectShippingOption(e.id),yield this.paypalIntegrationService.updateOrder(t)}catch(e){this.handleError(e)}})}onShippingOptionsChange(e,t){return _d(this,void 0,void 0,function*(){const n=this.paypalIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id);try{yield this.paymentIntegrationService.selectShippingOption(n.id),yield this.paypalIntegrationService.updateOrder(t)}catch(e){this.handleError(e)}})}handleError(e){if("function"!=typeof this.onError)throw e;this.onError(e)}};class vd{constructor(e,t,n){this.paymentIntegrationService=e,this.paypalIntegrationService=t,this.paypalButtonCreationService=n}initialize(e){return t=this,n=void 0,r=function*(){var t;const{paypalcommerce:n,containerId:i,methodId:r}=e,o=Boolean(null==n?void 0:n.buyNowInitializeOptions);if(!r)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.paypalcommerce" argument is not provided.');if(o&&!n.currencyCode)throw new Tr('Unable to initialize payment because "options.paypalcommerce.currencyCode" argument is not provided.');if(o&&"function"!=typeof(null===(t=n.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody))throw new Tr('Unable to initialize payment because "options.paypalcommerce.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');o||(yield this.paymentIntegrationService.loadDefaultCheckout());const a=o?n.currencyCode:this.paymentIntegrationService.getState().getCartOrThrow().currency.code;yield this.paypalIntegrationService.loadPayPalSdk(r,a,!1),this.renderButton(i,r,n)},new((i=void 0)||(i=Promise))(function(e,o){function a(e){try{d(r.next(e))}catch(e){o(e)}}function s(e){try{d(r.throw(e))}catch(e){o(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,s)}d((r=r.apply(t,n||[])).next())});var t,n,i,r}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onComplete:o,onEligibilityFailure:a}=n,s=this.paypalIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),{isHostedCheckoutEnabled:c,isServerSideShippingCallbacksEnabled:u}=d.initializationData||{},l={onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},h=Object.assign(Object.assign({fundingSource:s.FUNDING.PAYPAL,style:this.paypalIntegrationService.getValidButtonStyle(r),isServerSideShippingCallbacksEnabled:u,isHostedCheckoutEnabled:c},i&&l),c&&o&&{onPaymentComplete:()=>o()}),p=this.paypalButtonCreationService.createPayPalButton("paypalcommerce",t,h,i);p.isEligible()?p.render(`#${e}`):a&&"function"==typeof a?a():this.paypalIntegrationService.removeElement(e)}}const Cd=Ar(e=>{const t=fd(e),n=new Sd(e,t);return new vd(e,t,n)},[{id:"paypalcommerce"}]);var Id=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class wd{constructor(e,t){this.paymentIntegrationService=e,this.paypalIntegrationService=t}initialize(e){return Id(this,void 0,void 0,function*(){const{paypalcommercecredit:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,currencyCode:o}=t||{},a=!!r;if(!i)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Tr('Unable to initialize payment because "options.paypalcommercecredit" argument is not provided.');if(a&&!o)throw new Tr('Unable to initialize payment because "options.paypalcommercecredit.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null==r?void 0:r.getBuyNowCartRequestBody))throw new Tr('Unable to initialize payment because "options.paypalcommercecredit.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');a||(yield this.paymentIntegrationService.loadDefaultCheckout());const s=this.paymentIntegrationService.getState(),d=a?o:s.getCartOrThrow().currency.code;yield this.paypalIntegrationService.loadPayPalSdk(i,d,!1),this.renderButton(n,i,t)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onComplete:o,onEligibilityFailure:a}=n,s=this.paypalIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),{isHostedCheckoutEnabled:c,isServerSideShippingCallbacksEnabled:u}=d.initializationData||{},l={createOrder:()=>this.paypalIntegrationService.createOrder("paypalcommercecredit"),onApprove:({orderID:e})=>this.paypalIntegrationService.tokenizePayment(t,e)},h={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},p=Object.assign(Object.assign({},!u&&{onShippingAddressChange:e=>this.onShippingAddressChange(e),onShippingOptionsChange:e=>this.onShippingOptionsChange(e)}),{onApprove:(e,n)=>this.onHostedCheckoutApprove(e,n,t,o,u)}),g=[s.FUNDING.PAYLATER,s.FUNDING.CREDIT];let m=!1;g.forEach(t=>{if(!m){const n=Object.assign(Object.assign(Object.assign({fundingSource:t,style:this.paypalIntegrationService.getValidButtonStyle(r)},l),i&&h),c&&p),o=s.Buttons(n);o.isEligible()?(o.render(`#${e}`),m=!0):a&&"function"==typeof a&&a()}}),m||this.paypalIntegrationService.removeElement(e)}handleClick(e){return Id(this,void 0,void 0,function*(){if(e){const t=yield this.paypalIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}onHostedCheckoutApprove(e,t,n,i,r){return Id(this,void 0,void 0,function*(){if(!e.orderID)throw new gr(hr.MissingOrderId);const o=this.paymentIntegrationService.getState().getCartOrThrow();try{const a=o.lineItems.physicalItems.length>0;if(!r){const e=yield t.order.get(),n=this.paypalIntegrationService.getBillingAddressFromOrderDetails(e);if(yield this.paymentIntegrationService.updateBillingAddress(n),a){const t=this.paypalIntegrationService.getShippingAddressFromOrderDetails(e);yield this.paymentIntegrationService.updateShippingAddress(t)}}return a&&(yield this.paypalIntegrationService.updateOrder("paypalcommerce",void 0,void 0,r)),r&&(yield this.paymentIntegrationService.loadCheckout()),yield this.paymentIntegrationService.submitOrder({},{params:{methodId:n}}),yield this.paypalIntegrationService.submitPayment(n,e.orderID),i&&"function"==typeof i&&i(),!0}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingAddressChange(e){return Id(this,void 0,void 0,function*(){const t=this.paypalIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state});try{yield this.paymentIntegrationService.updateBillingAddress(t),yield this.paymentIntegrationService.updateShippingAddress(t);const e=this.paypalIntegrationService.getShippingOptionOrThrow();yield this.paymentIntegrationService.selectShippingOption(e.id),yield this.paypalIntegrationService.updateOrder("paypalcommerce")}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingOptionsChange(e){return Id(this,void 0,void 0,function*(){const t=this.paypalIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id);try{yield this.paymentIntegrationService.selectShippingOption(t.id),yield this.paypalIntegrationService.updateOrder("paypalcommerce")}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}}const Ed=Ar(e=>new wd(e,fd(e)),[{id:"paypalcommercecredit"}]);var bd,Pd,Od,Ad,Td,kd,Rd;!function(e){e.Possible="POSSIBLE",e.No="NO",e.Unknown="UNKNOWN",e.Yes="YES"}(bd||(bd={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(Pd||(Pd={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(Od||(Od={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(Ad||(Ad={})),function(e){e.pill="pill",e.rect="rect"}(Td||(Td={})),function(e){e.OXXO="oxxo",e.IDEAL="ideal"}(kd||(kd={})),function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(Rd||(Rd={}));var Dd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Md{constructor(e,t,n,i){this.formPoster=e,this.paymentIntegrationService=t,this.paypalCommerceRequestSender=n,this.paypalCommerceScriptLoader=i}loadPayPalSdk(e,t,n,i){return Dd(this,void 0,void 0,function*(){const r=this.paymentIntegrationService.getState(),o=t||r.getCartOrThrow().currency.code,a=r.getPaymentMethodOrThrow(e);return this.paypalSdk=yield this.paypalCommerceScriptLoader.getPayPalSDK(a,o,r.getLocale(),n,i),this.paypalSdk})}getPayPalSdkOrThrow(){if(!this.paypalSdk)throw new Pr;return this.paypalSdk}createBuyNowCartOrThrow(e){return Dd(this,void 0,void 0,function*(){const t=e.getBuyNowCartRequestBody();if(!t)throw new gr(hr.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(t)}catch(e){throw new kr}})}createOrder(e,t){return Dd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i}=yield this.paypalCommerceRequestSender.createOrder(e,Object.assign({cartId:n},t));return i})}createOrderCardFields(e,t){return Dd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i,setupToken:r}=yield this.paypalCommerceRequestSender.createOrder(e,Object.assign({cartId:n},t));return Object.assign({orderId:i},r?{setupToken:r}:{})})}updateOrder(e){return Dd(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState(),n=t.getCartOrThrow(),i=t.getConsignmentsOrThrow()[0];try{yield this.paypalCommerceRequestSender.updateOrder({availableShippingOptions:e?[]:i.availableShippingOptions,cartId:n.id,selectedShippingOption:e?null:i.selectedShippingOption})}catch(e){throw new Ie}})}getOrderStatus(e,t){return Dd(this,void 0,void 0,function*(){try{const{status:n}=yield this.paypalCommerceRequestSender.getOrderStatus(e,t);return n}catch(e){throw new Ie}})}tokenizePayment(e,t){const n=this.paymentIntegrationService.getState().getCartOrThrow();if(!t)throw new gr(hr.MissingOrderId);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",action:"set_external_checkout",provider:e,order_id:t},n.source===vo.BuyNow&&{cart_id:n.id}))}submitPayment(e,t,n){return Dd(this,void 0,void 0,function*(){const i={formattedPayload:{vault_payment_instrument:null,set_as_default_stored_instrument:null,device_info:null,method_id:e,paypal_account:{order_id:t}}};yield this.paymentIntegrationService.submitPayment(Object.assign({methodId:e,paymentData:i},n?{gatewayId:n}:{}))})}getShippingOptionOrThrow(e){const t=this.paymentIntegrationService.getState().getConsignmentsOrThrow()[0],n=t.availableShippingOptions||[],i=n.find(e=>e.isRecommended),r=(e?n.find(t=>t.id===e):n.find(e=>{var n;return e.id===(null===(n=t.selectedShippingOption)||void 0===n?void 0:n.id)}))||i||n[0];if(!r)throw new Error("Your order can't be shipped to this address");return r}getAddress(e){return{firstName:(null==e?void 0:e.firstName)||"",lastName:(null==e?void 0:e.lastName)||"",email:(null==e?void 0:e.email)||"",phone:(null==e?void 0:e.phone)||"",company:"",address1:(null==e?void 0:e.address1)||"",address2:(null==e?void 0:e.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:[]}}getBillingAddressFromOrderDetails({payer:e}){var t,n;return this.getAddress({firstName:e.name.given_name,lastName:e.name.surname,email:e.email_address,address1:e.address.address_line_1,address2:e.address.address_line_2,city:e.address.admin_area_2,countryCode:e.address.country_code,postalCode:e.address.postal_code,stateOrProvinceCode:e.address.admin_area_1,phone:null===(n=null===(t=e.phone)||void 0===t?void 0:t.phone_number)||void 0===n?void 0:n.national_number})}getShippingAddressFromOrderDetails(e){const{payer:t,purchase_units:n}=e,{address:i,name:{full_name:r}}=n[0].shipping,[o,...a]=r.split(" ");return this.getAddress({firstName:o,lastName:a.join(" "),email:t.email_address,address1:i.address_line_1,address2:i.address_line_2,city:i.admin_area_2,countryCode:i.country_code,postalCode:i.postal_code,stateOrProvinceCode:i.admin_area_1})}getValidButtonStyle(e){const{color:t,height:n,label:i,shape:r}=e||{},o={color:t&&Ad[t]?t:void 0,height:this.getValidHeight(n),label:i&&Od[i]?i:void 0,shape:r&&Td[r]?r:void 0};return R(o,v)}getValidHeight(e){return e&&"number"==typeof e?e>55?55:e<25?25:e:40}removeElement(e){const t=e&&document.getElementById(e);t&&(t.style.display="none")}}var Nd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ld{constructor(e){this.requestSender=e}createOrder(e,t){return Nd(this,void 0,void 0,function*(){const n=`/api/storefront/payment/${e}`,i=t,r=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.post(n,{headers:r,body:i})).body})}updateOrder(e){return Nd(this,void 0,void 0,function*(){const t=e,n=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.put("/api/storefront/initialization/paypalcommerce",{headers:n,body:t})).body})}getOrderStatus(){return Nd(this,arguments,void 0,function*(e="paypalcommerce",t){const n=`/api/storefront/initialization/${e}`,i=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.get(n,Object.assign({headers:i},t))).body})}}var zd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ud{constructor(e){this.scriptLoader=e,this.window=window}getPayPalSDK(e,t,n,i,r){return zd(this,void 0,void 0,function*(){const o=this.getPayPalSdkScriptConfigOrThrow(e,t,n,i);return this.loadPayPalSDK(o,r)})}loadPayPalSDK(e){return zd(this,arguments,void 0,function*(e,t=!1){if(!this.window.paypal||t){const t=this.transformConfig(e.options),n=this.transformConfig(e.attributes),i=`https://www.paypal.com/sdk/js?${new URLSearchParams(t).toString()}`;yield this.scriptLoader.loadScript(i,{async:!0,attributes:n})}if(!this.window.paypal)throw new Pr;return this.window.paypal})}getPayPalSdkScriptConfigOrThrow(e,t,n,i=!0){const{id:r,clientToken:o,initializationData:a}=e;if(!(null==a?void 0:a.clientId))throw new gr(hr.MissingPaymentMethod);const{intent:s,clientId:d,merchantId:c,buyerCountry:u,attributionId:l,isVenmoEnabled:h,isHostedCheckoutEnabled:p,isPayPalCreditAvailable:g,isDeveloperModeApplicable:m,availableAlternativePaymentMethods:y=[],enabledAlternativePaymentMethods:f=[],isGooglePayEnabled:_}=a,S=p||i,v="paypalcommercecreditcards"===r,C=v?["card"]:[],I=g?["credit","paylater"]:[],w=h?["venmo"]:[],E=_?["googlepay"]:[],b=i?["card-fields"]:[],P=[...v?[]:["card"],...g?[]:["credit","paylater"],...h?[]:["venmo"],...y.filter(e=>!f.includes(e))],O=[...C,...I,...w,...f],A=os(n);return{options:Object.assign(Object.assign({"client-id":d,"merchant-id":c,"enable-funding":O.length>0?O:void 0,"disable-funding":P.length>0?P:void 0,commit:S,components:["buttons","hosted-fields","payment-fields","legal",...E,...b],currency:t,intent:s},m&&{"buyer-country":u}),A&&{locale:A}),attributes:{"data-partner-attribution-id":l,"data-client-token":o}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}var Fd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Bd{constructor(e,t){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t}initialize(e){return Fd(this,void 0,void 0,function*(){const{paypalcommercevenmo:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,currencyCode:o}=t||{},a=!!r;if(!i)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Tr('Unable to initialize payment because "options.paypalcommercevenmo" argument is not provided.');if(a&&!o)throw new Tr('Unable to initialize payment because "options.paypalcommercevenmo.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null==r?void 0:r.getBuyNowCartRequestBody))throw new Tr('Unable to initialize payment because "options.paypalcommercevenmo.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');a||(yield this.paymentIntegrationService.loadDefaultCheckout());const s=a?o:this.paymentIntegrationService.getState().getCartOrThrow().currency.code;yield this.paypalCommerceIntegrationService.loadPayPalSdk(i,s,!1),this.renderButton(n,i,t)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onEligibilityFailure:o}=n,a=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow(),s=a.FUNDING.VENMO,d={createOrder:()=>this.paypalCommerceIntegrationService.createOrder("paypalcommercevenmo"),onApprove:({orderID:e})=>this.paypalCommerceIntegrationService.tokenizePayment(t,e)},c={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},u=Object.assign(Object.assign({fundingSource:s,style:this.getValidVenmoButtonStyles(r)},d),i&&c),l=a.Buttons(u);l.isEligible()?l.render(`#${e}`):o&&"function"==typeof o?o():this.paypalCommerceIntegrationService.removeElement(e)}getValidVenmoButtonStyles(e){const t=this.paypalCommerceIntegrationService.getValidButtonStyle(e);return t.color===Ad.gold?Object.assign(Object.assign({},t),{color:void 0}):t}handleClick(e){return Fd(this,void 0,void 0,function*(){if(e){const t=yield this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}}const xd=Ar(t=>new Bd(t,(t=>{const{getHost:i}=t.getState();return new Md(n(),t,new Ld(e({host:i()})),new Ud(le()))})(t)),[{id:"paypalcommercevenmo"}]);var qd,jd,Gd,Vd,Hd,Wd;!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(qd||(qd={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(jd||(jd={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black"}(Gd||(Gd={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(Vd||(Vd={})),function(e){e.PILL="pill",e.RECT="rect"}(Hd||(Hd={})),function(e){e.ACKNOWLEDGE="ACKNOWLEDGE",e.FINALIZE="FINALIZE",e.INITIALIZE="INITIALIZE"}(Wd||(Wd={}));var Yd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Kd{constructor(e,t,n){this.paymentIntegrationService=e,this.paypalExpressScriptLoader=t,this.formPoster=n}initialize(e){return Yd(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!e.paypal)throw new Tr;if(!t.config.merchantId)throw new gr(hr.MissingPaymentMethod);const n=yield this.paypalExpressScriptLoader.loadPaypalSDK(t.config.merchantId);this.renderButton(e,n)})}deinitialize(){return Promise.resolve()}renderButton(e,t){const{containerId:n,methodId:i,paypal:r}=e,{allowCredit:o,clientId:a,onPaymentError:s,shouldProcessPayment:d,style:c}=r,u=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!u.config.merchantId)throw new gr(hr.MissingPaymentMethod);const l=u.config.merchantId,h=u.config.testMode?"sandbox":"production",p={[h]:a},g=t.FUNDING.CREDIT||"credit",m=o?[g]:[],y=o?[]:[g];return t.Button.render({env:h,client:p,commit:d,funding:{allowed:m,disallowed:y},style:this.getStyle(c),payment:(e,t)=>this.setupPayment(l,t,s),onAuthorize:(e,t)=>this.tokenizePayment(e,i,t,d)},n)}getStyle(e){const{color:t,fundingicons:n,label:i,layout:r,shape:o,size:a,tagline:s}=e||{};return{color:t,fundingicons:n,label:i,layout:r,shape:o||Hd.RECT,size:"small"===a?jd.RESPONSIVE:a,tagline:s}}setupPayment(e,t,n){return Yd(this,void 0,void 0,function*(){if(!t)throw new fr(pr.CheckoutButtonNotInitialized);try{const n=yield this.paymentIntegrationService.loadDefaultCheckout(),{id:i}=n.getCartOrThrow(),r=n.getHost()||"";return(yield t.request.post(`${r}/api/storefront/payment/paypalexpress`,{merchantId:e,cartId:i},{headers:Object.assign({"X-API-INTERNAL":Lr},Fr)})).id}catch(e){throw n&&e instanceof ve&&n(e),e}})}tokenizePayment(e,t,n,i){return Yd(this,void 0,void 0,function*(){if(!n)throw new fr(pr.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new gr(hr.MissingPayment);const r=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),o=yield n.payment.get(e.paymentID);return this.formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:r.id,action:i?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(o.payer.payer_info)})})}}class $d{constructor(e){this.scriptLoader=e,this.window=window}loadPaypalSDK(){return e=this,t=arguments,i=function*(e=""){const t=Object.assign({async:!0,attributes:{"data-merchant-id":e}},e&&{attributes:{"data-merchant-id":e}});if(yield this.scriptLoader.loadScript("//www.paypalobjects.com/api/checkout.min.js",t),!this.window.paypal)throw new Pr;return this.window.paypal},new((n=void 0)||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())});var e,t,n,i}}const Zd=Ar(e=>new Kd(e,new $d(le()),n()),[{id:"paypalexpress"}]);var Jd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Qd{constructor(e,t){this.paymentIntegrationService=e,this.scriptLoader=t,this.isMounted=!1}deinitialize(){var e;null===(e=this.checkoutEventsUnsubscribe)||void 0===e||e.call(this),this.isMounted=!1}initCheckoutEventsSubscription(e,t,n,i){this.checkoutEventsUnsubscribe=this.paymentIntegrationService.subscribe(()=>Jd(this,void 0,void 0,function*(){var r;const o=null==i?void 0:i.getElement(Fs.PAYMENT);if(o){try{yield this.updateStripePaymentIntent(e,t)}catch(e){return this.isMounted&&(o.unmount(),this.isMounted=!1),void(e instanceof Error&&(null===(r=n.onError)||void 0===r||r.call(n,e)))}this.isMounted||(yield null==i?void 0:i.fetchUpdates(),this.mountElement(o,n.containerId))}}),e=>{var t;return null===(t=e.getCheckout())||void 0===t?void 0:t.outstandingBalance},e=>{var t;return null===(t=e.getCheckout())||void 0===t?void 0:t.coupons})}mountElement(e,t){document.getElementById(t)&&(e.mount(`#${t}`),this.isMounted=!0)}mapAppearanceVariables(e){return{colorPrimary:e.fieldInnerShadow,colorBackground:e.fieldBackground,colorText:e.labelText,colorDanger:e.fieldErrorText,colorTextSecondary:e.labelText,colorTextPlaceholder:e.fieldPlaceholderText,colorIcon:e.fieldPlaceholderText}}mapInputAppearanceRules(e){return{borderColor:e.fieldBorder,color:e.fieldText,boxShadow:e.fieldInnerShadow}}throwStripeError(e){if("object"==typeof(t=e)&&null!==t&&"type"in t&&(this.throwDisplayableStripeError(e),this.isCancellationError(e)))throw new lo;var t;throw new Za}throwDisplayableStripeError(e){if(m(["card_error","invalid_request_error","validation_error"],e.type))throw new Error(e.message)}isCancellationError(e){var t;const n=null===(t=null==e?void 0:e.payment_intent.last_payment_error)||void 0===t?void 0:t.message;return!!n&&-1!==n.indexOf("canceled")}throwPaymentConfirmationProceedMessage(){throw new Za("We've received your order and are processing your payment. Once the payment is verified, your order will be completed. We will send you an email when it's completed. Please note, this process may take a few minutes depending on the processing times of your chosen method.")}isPaymentCompleted(e,t){return Jd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState(),i=n.getPaymentMethodOrThrow(e),{features:r}=n.getStoreConfigOrThrow().checkoutSettings;if(!i.clientToken||!t||!r["PI-626.Block_unnecessary_payment_confirmation_for_StripeUPE"])return!1;const{paymentIntent:o}=yield t.retrievePaymentIntent(i.clientToken);return(null==o?void 0:o.status)===Bs.SUCCEEDED})}mapStripePaymentData(e,t,n=!1){const i=this.paymentIntegrationService.getState().getBillingAddress(),{firstName:r="",lastName:o="",email:a=""}=i||{},s=this.mapStripeAddress(i);if(!e)throw new fr(pr.PaymentNotInitialized);if(!(a&&s&&s.city&&s.country&&r&&o))throw new gr(hr.MissingBillingAddress);return{elements:e,redirect:zs.IF_REQUIRED,confirmParams:Object.assign({payment_method_data:Object.assign(Object.assign({},n?{allow_redisplay:"always"}:{}),{billing_details:{email:a,address:s,name:this.getShopperFullName(i)}})},t&&{return_url:t})}}isAdditionalActionError(e){return z(e,{code:"additional_action_required"})}isSessionExpiredError(e){return z(e,{code:"authorization_expired"})}isRedirectAction(e){const{type:t,data:{redirect_url:n}}=e;return"redirect_to_url"===t&&!!n}isOnPageAdditionalAction(e){const{type:t,data:{token:n}}=e;return"additional_action_requires_payment_method"===t&&!!n}updateStripePaymentIntent(e,t){return Jd(this,void 0,void 0,function*(){const n=yield this.paymentIntegrationService.loadPaymentMethod(e,{params:{method:t}}),{clientToken:i}=n.getPaymentMethodOrThrow(t);i&&this.scriptLoader.updateStripeElements({clientSecret:i})})}getStripeJsVersion(e){return e.useNewStripeJsVersion?Us.CLOVER:Us.V3}mapStripeAddress(e){if(e){const{city:t,address1:n,address2:i,countryCode:r,postalCode:o,stateOrProvinceCode:a}=e;return Object.assign({city:t,country:r,postal_code:o,line1:n,line2:i},a?{state:a}:{})}throw new gr(hr.MissingBillingAddress)}getShopperFullName(e){const{firstName:t="",lastName:n=""}=e||{};return`${t} ${n}`.trim()}verifyCheckoutSpamProtection(){return Jd(this,void 0,void 0,function*(){const{shouldExecuteSpamCheck:e}=this.paymentIntegrationService.getState().getCheckoutOrThrow();e&&(yield this.paymentIntegrationService.verifyCheckoutSpamProtection())})}}const Xd={size:70,color:"#d9d9d9",backgroundColor:"#ffffff"},ec={position:"fixed","background-color":"rgba(0, 0, 0, 0.4)","z-index":"1000"},tc="embedded-checkout-loading-indicator-rotation";class nc{constructor(e){this.styles=Object.assign(Object.assign({},Xd),e&&e.styles),this.containerStyles=Object.assign({},e&&e.containerStyles),this.defineAnimation(),this.container=this.buildContainer(),this.indicator=this.buildIndicator(),this.container.appendChild(this.indicator)}show(e){if(e){const t=document.getElementById(e);if(!t)throw new Error("Unable to attach the loading indicator because the parent ID is not valid.");t.appendChild(this.container)}this.container.style.visibility="visible",this.container.style.opacity="1"}hide(){const e=()=>{this.container.style.visibility="hidden",this.container.removeEventListener("transitionend",e)};this.container.addEventListener("transitionend",e),this.container.style.opacity="0"}buildContainer(){const e=document.createElement("div");return e.style.display="block",e.style.bottom="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.position="absolute",e.style.right="0",e.style.top="0",e.style.transition="all 250ms ease-out",e.style.opacity="0",this.setStyleAttribute(e,this.containerStyles),e}buildIndicator(){const e=document.createElement("div");return e.style.display="block",e.style.width=`${this.styles.size}px`,e.style.height=`${this.styles.size}px`,e.style.borderRadius=`${this.styles.size}px`,e.style.border="solid 1px",e.style.borderColor=`${this.styles.backgroundColor} ${this.styles.backgroundColor} ${this.styles.color} ${this.styles.color}`,e.style.margin="0 auto",e.style.position="absolute",e.style.left="0",e.style.right="0",e.style.top="50%",e.style.transform="translateY(-50%) rotate(0deg)",e.style.transformStyle="preserve-3d",e.style.animation=`${tc} 500ms infinite cubic-bezier(0.69, 0.31, 0.56, 0.83)`,e}setStyleAttribute(e,t){Object.keys(t).forEach(n=>{e.style.setProperty(n,t[n])})}defineAnimation(){var e;if(document.getElementById(tc))return;const t=document.createElement("style");t.id=tc,null===(e=document.head)||void 0===e||e.appendChild(t),t.sheet instanceof CSSStyleSheet&&t.sheet.insertRule(`\n @keyframes ${tc} {\n 0% { transform: translateY(-50%) rotate(0deg); }\n 100% { transform: translateY(-50%) rotate(360deg); }\n }\n `,0)}}class ic{constructor(e){this._decimalPlaces=e}toInteger(e){return Math.round(e*Math.pow(10,this._decimalPlaces))}}const rc=["AC","AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CV","CW","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MK","ML","MM","MN","MO","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SZ","TA","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","US","UY","UZ","VA","VC","VE","VG","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW","ZZ"];var oc=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ac{constructor(e,t,n,i){this.paymentIntegrationService=e,this.scriptLoader=t,this.stripeIntegrationService=n,this.loadingIndicator=i}initialize(e){return oc(this,void 0,void 0,function*(){const{stripeocs:t,containerId:n}=e||{};if(!t||!n)throw new fr(pr.PaymentNotInitialized);const{gatewayId:i}=t;if(!i)throw new gr(hr.MissingPaymentMethod);const r=this._getMethodId(i),o=yield this.paymentIntegrationService.loadPaymentMethod(i,{params:{method:r}}),a=o.getPaymentMethodOrThrow(r,i),{loadingContainerId:s,buttonHeight:d,onComplete:c}=t;if(this._loadingIndicatorContainer=s,this._onComplete=c,!function(e){return"object"==typeof e&&null!==e&&"initializationData"in e&&void 0!==e.initializationData&&null!==e.initializationData&&"object"==typeof e.initializationData&&"stripePublishableKey"in e.initializationData&&"stripeConnectedAccount"in e.initializationData&&"shopperLanguage"in e.initializationData&&void 0!==e.initializationData.stripePublishableKey&&void 0!==e.initializationData.stripeConnectedAccount&&void 0!==e.initializationData.shopperLanguage}(a))throw new gr(hr.MissingPaymentMethod);const{initializationData:u}=a,{captureMethod:l}=u,h=this.stripeIntegrationService.getStripeJsVersion(u);this._captureMethod=l,this._stripeClient=yield this.scriptLoader.getStripeClient(u,o.getCartLocale(),h),yield this.paymentIntegrationService.loadDefaultCheckout(),yield this._mountExpressCheckoutElement(n,this._stripeClient,d),this._initializeEvents(r)})}signIn(){return Promise.resolve()}signOut(){return Promise.resolve()}executePaymentMethodCheckout(){return Promise.resolve()}deinitialize(){return Promise.resolve()}_mountExpressCheckoutElement(e,t){return oc(this,arguments,void 0,function*(e,t,n=40){const i=this._shouldRequireShippingAddress(),r=Object.assign(Object.assign(Object.assign({shippingAddressRequired:i},i?{allowedShippingCountries:yield this._getAvailableCountries()}:{}),i?{shippingRates:[{id:"_",amount:0,displayName:"Pending rates"}]}:{}),{billingAddressRequired:!0,emailRequired:!0,phoneNumberRequired:!0,paymentMethods:{link:zs.AUTO,applePay:zs.NEVER,googlePay:zs.NEVER,amazonPay:zs.NEVER,paypal:zs.NEVER,klarna:zs.NEVER},buttonHeight:n}),{cartAmount:o=1}=this.paymentIntegrationService.getState().getCart()||{},a=Object.assign({mode:"payment",amount:this._toCents(o),currency:this._getCurrency()},this._captureMethod?{captureMethod:this._captureMethod}:{});this._stripeElements=t.elements(a),this._linkV2Element=this._stripeElements.create(Fs.EXPRESS_CHECKOUT,r),this._linkV2Element.mount(`#${e}`)})}_initializeEvents(e){this._linkV2Element&&(this._shouldRequireShippingAddress()&&(this._linkV2Element.on(xs.SHIPPING_ADDRESS_CHANGE,e=>oc(this,void 0,void 0,function*(){return this._onShippingAddressChange(e)})),this._linkV2Element.on(xs.SHIPPING_RATE_CHANGE,e=>oc(this,void 0,void 0,function*(){return this._onShippingRateChange(e)}))),this._linkV2Element.on(xs.CONFIRM,t=>oc(this,void 0,void 0,function*(){return this._onConfirm(t,e)})),this._linkV2Element.on(xs.CANCEL,this._onCancel))}_onShippingAddressChange(e){return oc(this,void 0,void 0,function*(){if(!("address"in e))return;const t=e.address,n={firstName:"",lastName:"",phone:"",company:"",address1:"",address2:"",city:(null==t?void 0:t.city)||"",countryCode:(null==t?void 0:t.country)||"",postalCode:(null==t?void 0:t.postal_code)||"",stateOrProvince:(null==t?void 0:t.state)||"",stateOrProvinceCode:(null==t?void 0:t.state)||"",customFields:[]};yield this.paymentIntegrationService.updateShippingAddress(n);const i=yield this._getAvailableShippingOptions();yield this._updateDisplayedPrice(),(null==i?void 0:i.length)?e.resolve({shippingRates:i}):e.reject()})}_onCancel(){throw new lo}_onShippingRateChange(e){return oc(this,void 0,void 0,function*(){if("shippingRate"in e){const{shippingRate:t}=e;yield this._handleShippingOptionChange(null==t?void 0:t.id),yield this._updateDisplayedPrice(),e.resolve({})}})}_onConfirm(e,t){return oc(this,void 0,void 0,function*(){if("billingDetails"in e&&"shippingAddress"in e&&this._stripeClient&&this._stripeElements){yield this.stripeIntegrationService.verifyCheckoutSpamProtection(),yield this._updateShippingAndBillingAddress(e),yield this.paymentIntegrationService.submitOrder();const n=this._getPaymentPayload(t);try{yield this.paymentIntegrationService.submitPayment(n)}catch(e){yield this._processAdditionalAction(e,t)}}return Promise.resolve()})}_updateShippingAndBillingAddress(e){return oc(this,void 0,void 0,function*(){var t,n,i,r,o,a,s,d;const c=this._shouldRequireShippingAddress(),u=(null===(n=null===(t=e.shippingAddress)||void 0===t?void 0:t.name)||void 0===n?void 0:n.split(" ")[0])||(null===(r=null===(i=e.billingDetails)||void 0===i?void 0:i.name)||void 0===r?void 0:r.split(" ")[0])||"",l=(null===(a=null===(o=e.shippingAddress)||void 0===o?void 0:o.name)||void 0===a?void 0:a.split(" ")[1])||(null===(d=null===(s=e.billingDetails)||void 0===s?void 0:s.name)||void 0===d?void 0:d.split(" ")[1])||"";if(c){const t=this._mapShippingAddress(e.shippingAddress,e.billingDetails,u,l);yield this.paymentIntegrationService.updateShippingAddress(t)}const h=this._mapBillingAddress(e.shippingAddress,e.billingDetails,u,l);yield this.paymentIntegrationService.updateBillingAddress(h)})}_mapShippingAddress(e,t,n,i){var r,o,a,s,d,c,u;return{firstName:n,lastName:i,phone:(null==t?void 0:t.phone)||"",company:"",address1:(null===(r=null==e?void 0:e.address)||void 0===r?void 0:r.line1)||"",address2:(null===(o=null==e?void 0:e.address)||void 0===o?void 0:o.line2)||"",city:(null===(a=null==e?void 0:e.address)||void 0===a?void 0:a.city)||"",countryCode:(null===(s=null==e?void 0:e.address)||void 0===s?void 0:s.country)||"",postalCode:(null===(d=null==e?void 0:e.address)||void 0===d?void 0:d.postal_code)||"",stateOrProvince:(null===(c=null==e?void 0:e.address)||void 0===c?void 0:c.state)||"",stateOrProvinceCode:(null===(u=null==e?void 0:e.address)||void 0===u?void 0:u.state)||"",customFields:[]}}_mapBillingAddress(e,t,n,i){var r,o,a,s,d,c;return{email:(null==t?void 0:t.email)||"",firstName:n,lastName:i,phone:(null==t?void 0:t.phone)||"",company:"",address1:(null===(r=null==t?void 0:t.address)||void 0===r?void 0:r.line1)||"",address2:"",city:(null===(o=null==t?void 0:t.address)||void 0===o?void 0:o.city)||"",countryCode:(null===(a=null==t?void 0:t.address)||void 0===a?void 0:a.country)||"",postalCode:(null===(s=null==t?void 0:t.address)||void 0===s?void 0:s.postal_code)||"",stateOrProvince:(null===(d=null==t?void 0:t.address)||void 0===d?void 0:d.state)||"",stateOrProvinceCode:(null===(c=null==e?void 0:e.address)||void 0===c?void 0:c.state)||"",customFields:[]}}_processAdditionalAction(e,t){return oc(this,void 0,void 0,function*(){if(!Cs(e)||!this.stripeIntegrationService.isAdditionalActionError(e.body.errors))throw e;if(!this._stripeClient||!this._stripeElements)throw new fr(pr.PaymentNotInitialized);const{data:n}=e.body.additional_action_required,{token:i}=n,{paymentIntent:r}=yield this._confirmStripePaymentOrThrow(n,t),o=this._getPaymentPayload(t,(null==r?void 0:r.id)||i);try{this._toggleLoadingIndicator(!0),yield this.paymentIntegrationService.submitPayment(o),yield this._completeCheckoutFlow()}catch(e){this.stripeIntegrationService.throwPaymentConfirmationProceedMessage()}finally{this._toggleLoadingIndicator(!1)}})}_confirmStripePaymentOrThrow(e,t){return oc(this,void 0,void 0,function*(){var n,i,r;const{token:o,redirect_url:a}=e,s=this.stripeIntegrationService.mapStripePaymentData(this._stripeElements,a);let d;try{const e=(yield this.stripeIntegrationService.isPaymentCompleted(t,this._stripeClient))?yield null===(r=this._stripeClient)||void 0===r?void 0:r.retrievePaymentIntent(o||""):yield null===(n=this._stripeClient)||void 0===n?void 0:n.confirmPayment({elements:s.elements,clientSecret:o,redirect:zs.IF_REQUIRED,confirmParams:{return_url:null===(i=s.confirmParams)||void 0===i?void 0:i.return_url}});if(d=null==e?void 0:e.error,d||!(null==e?void 0:e.paymentIntent))throw new Za;return e}catch(e){return this.stripeIntegrationService.throwStripeError(d)}})}_completeCheckoutFlow(){return oc(this,void 0,void 0,function*(){return"function"==typeof this._onComplete?this._onComplete():(window.location.replace("/checkout/order-confirmation"),Promise.resolve())})}_getPaymentPayload(e,t){var n;const i=(null===(n=this.paymentIntegrationService.getState().getCart())||void 0===n?void 0:n.id)||"";return{methodId:e,paymentData:{formattedPayload:Object.assign(Object.assign({cart_id:i},t?{credit_card_token:{token:t}}:{}),{confirm:!1,method:Ls.Link})}}}_shouldRequireShippingAddress(){const{getCart:e}=this.paymentIntegrationService.getState(),{lineItems:t}=e()||{};return!!(null==t?void 0:t.physicalItems.length)}_updateDisplayedPrice(){return oc(this,void 0,void 0,function*(){this._stripeElements&&this._stripeElements.update({currency:this._getCurrency(),mode:"payment",amount:yield this._getTotalPrice()})})}_getCurrency(){var e;if(!this._currencyCode){const t=null===(e=this.paymentIntegrationService.getState().getCart())||void 0===e?void 0:e.currency;t&&(this._currencyCode=t.code.toLowerCase())}return this._currencyCode}_getTotalPrice(){return oc(this,void 0,void 0,function*(){var e;yield this.paymentIntegrationService.loadCheckout();const{getCheckoutOrThrow:t,getCart:n}=this.paymentIntegrationService.getState(),{decimalPlaces:i}=(null===(e=n())||void 0===e?void 0:e.currency)||{},r=L(t().outstandingBalance,i).toFixed(i);return this._toCents(+r)})}_getAvailableCountries(){return oc(this,void 0,void 0,function*(){var e;return((null===(e=(yield this.paymentIntegrationService.loadShippingCountries()).getShippingCountries())||void 0===e?void 0:e.map(e=>e.code))||[]).filter(e=>rc.includes(e))})}_getAvailableShippingOptions(){return oc(this,void 0,void 0,function*(){var e,t,n;const i=this.paymentIntegrationService.getState().getConsignments();if(!(null==i?void 0:i[0]))return;const r=i[0],o=(r.availableShippingOptions||[]).map(this._getStripeShippingOption.bind(this)),a=null===(e=r.availableShippingOptions)||void 0===e?void 0:e.find(e=>e.isRecommended),s=null===(t=r.selectedShippingOption)||void 0===t?void 0:t.id,d=null==a?void 0:a.id;return s?o.sort(e=>e.id===s?-1:0):d?(o.sort(e=>e.id===d?-1:0),yield this._handleShippingOptionChange(d)):yield this._handleShippingOptionChange(null===(n=o[0])||void 0===n?void 0:n.id),o.slice(0,9)})}_getStripeShippingOption({id:e,cost:t,description:n}){return{id:e,displayName:n,amount:this._toCents(t)}}_handleShippingOptionChange(e){return oc(this,void 0,void 0,function*(){if(e&&"shipping_option_unselected"!==e)return this.paymentIntegrationService.selectShippingOption(e)})}_getAmountTransformer(){if(this._amountTransformer)return this._amountTransformer;const{getCart:e}=this.paymentIntegrationService.getState(),{currency:t}=e()||{};return t?new ic(t.decimalPlaces):void 0}_toCents(e){const t=Math.round(100*e),n=this._getAmountTransformer();return n?n.toInteger(e):t}_toggleLoadingIndicator(e){e&&this._loadingIndicatorContainer?this.loadingIndicator.show(this._loadingIndicatorContainer):this.loadingIndicator.hide()}_getMethodId(e){const{initializationData:{checkoutSessionEnabled:t}={}}=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e);return t?Ls.CHECKOUT_SESSION:Ls.OCS}}const sc=Ar(e=>{const t=new Gs(le()),n=new nc({containerStyles:ec});return new ac(e,t,new Qd(e,t),n)},[{id:"stripeocs"}]);var dc;function cc(e,t,n){const i=new WeakMap;function r(e){return(...n)=>{const r=n[n.length-1],{useCache:o}=(a=r)&&"boolean"==typeof a.useCache?r:{useCache:!1};var a;if(!o)return e.call(this,...n);const s=i.get(this)||{};var d;return i.get(this)||i.set(this,s),s[t]||(s[t]=(d=e,ae(function(...e){const t=d.call(this,...e);return t instanceof j?Y(t).pipe(ie()):"function"==typeof t?ae(e=>Y(t(e)).pipe(ie()),{isEqual:_}):t},{isEqual:_}))),s[t].call(this,...n)}}return{get(){if("function"!=typeof n.value)throw new Error("Decorator should be used in functions");const e=r.call(this,n.value);return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e}}}!function(e){e.Standard="standard",e.Invoice="invoice"}(dc||(dc={}));var uc=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};const lc=e=>!!e;class hc{constructor(e,t){this._requestSender=e,this._b2bCompanyPaymentMethodRequestSender=t}loadPaymentMethodsById(e,t){return n=>new j(i=>{var r;const a=null===(r=n.getState().cart.getCart())||void 0===r?void 0:r.id,s=a?Object.assign(Object.assign({},null==t?void 0:t.params),{cartId:a}):Object.assign({},null==t?void 0:t.params);i.next(o(Rn.LoadPaymentMethodsRequested)),Promise.all(e.map(e=>uc(this,void 0,void 0,function*(){try{return(yield this._requestSender.loadPaymentMethod(e,Object.assign(Object.assign({},t),{params:s}))).body}catch(e){return}}))).then(e=>{const t=e.filter(lc);i.next(o(Rn.LoadPaymentMethodsSucceeded,t)),i.complete()}).catch(e=>{i.next(o(Rn.LoadPaymentMethodsFailed,e)),i.complete()})})}loadPaymentMethods(e){return t=>j.create(n=>{const i=t.getState(),r=i.cart.getCartOrThrow();n.next(o(Rn.LoadPaymentMethodsRequested)),this._requestSender.loadPaymentMethods(Object.assign(Object.assign({},e),{params:Object.assign(Object.assign({},null==e?void 0:e.params),{cartId:r.id})})).then(t=>uc(this,void 0,void 0,function*(){const r={deviceSessionId:t.headers["x-device-session-id"],sessionHash:t.headers["x-session-hash"]};let a=t.body;this._shouldFilterForB2b(i)&&(a=yield this._applyB2bFilter(a,i,e)),n.next(o(Rn.LoadPaymentMethodsSucceeded,a,r)),n.complete()})).catch(e=>{n.error(s(Rn.LoadPaymentMethodsFailed,e))})})}loadPaymentMethod(e,t){return n=>j.create(i=>{var r;const a=null===(r=n.getState().cart.getCart())||void 0===r?void 0:r.id,d=a?Object.assign(Object.assign({},null==t?void 0:t.params),{cartId:a}):Object.assign({},null==t?void 0:t.params);i.next(o(Rn.LoadPaymentMethodRequested,void 0,{methodId:e})),this._requestSender.loadPaymentMethod(e,Object.assign(Object.assign({},t),{params:d})).then(t=>{i.next(o(Rn.LoadPaymentMethodSucceeded,t.body,{methodId:e})),i.complete()}).catch(t=>{i.error(s(Rn.LoadPaymentMethodFailed,t,{methodId:e}))})})}_shouldFilterForB2b(e){var t,n;return!!(null===(n=null===(t=e.config.getStoreConfigOrThrow().checkoutSettings)||void 0===t?void 0:t.capabilities)||void 0===n?void 0:n.payment.b2bPaymentMethodFilterType)}_applyB2bFilter(e,t,n){return uc(this,void 0,void 0,function*(){var i,r,o,a,s;const d=t.config.getStoreConfigOrThrow(),c=t.customer.getCustomerOrThrow(),u=t.cart.getCartOrThrow(),l=t.b2bToken.getToken(),h=(p=null!==(o=null===(r=null===(i=t.config.getStoreConfig())||void 0===i?void 0:i.b2bApiSettings)||void 0===r?void 0:r.baseUrl)&&void 0!==o?o:"",function(){if("undefined"==typeof window||!window.location)return!1;try{return!!new URLSearchParams(window.location.search).has("enableB2bDevMode")&&(console.log("B2B Dev Mode Enabled"),!0)}catch(e){return!1}}()?"https://api-b2b.bigcommerce.com":p);var p;if(c.isGuest||!l||!h||!u.companyId)throw new nr(tr.MissingCheckoutConfig);return(null===(s=null===(a=d.checkoutSettings)||void 0===a?void 0:a.capabilities)||void 0===s?void 0:s.payment.b2bPaymentMethodFilterType)===dc.Invoice?this._applyB2bInvoiceFilter(e,h,l,n):this._applyB2bCompanyFilter(e,u.companyId,l,h,n)})}_applyB2bCompanyFilter(e,t,n,i,r){return uc(this,void 0,void 0,function*(){const{body:o}=yield this._b2bCompanyPaymentMethodRequestSender.getB2BCompanyPaymentMethods(t,n,i,r);return function(e,t){const n=new Set(t.data.filter(e=>"1"===e.isEnabled).map(e=>e.code));return e.filter(e=>n.has(e.id))}(e,o)})}_applyB2bInvoiceFilter(e,t,n,i){return uc(this,void 0,void 0,function*(){const{body:r}=yield this._b2bCompanyPaymentMethodRequestSender.getB2BInvoiceAllowedPaymentMethods(t,n,i);return e.filter(e=>new Set(r.data.allowedMethods).has(e.id))})}}var pc;(function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);o>3&&a&&Object.defineProperty(t,n,a)})([cc],hc.prototype,"loadPaymentMethod",null),function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(pc||(pc={}));const gc=pc,mc="This API endpoint is for internal use only and may change in the future",yc={"X-Checkout-SDK-Version":"1.934.0"};class fc{constructor(e){this._requestSender=e}loadPaymentMethods({timeout:e,params:t}={}){return this._requestSender.get("/api/storefront/payments",{timeout:e,headers:Object.assign({Accept:gc.JsonV1,"X-API-INTERNAL":mc},yc),params:t})}loadPaymentMethod(e,{timeout:t,params:n}={}){const i=`/api/storefront/payments/${e}`;return this._requestSender.get(i,{timeout:t,headers:Object.assign({Accept:gc.JsonV1,"X-API-INTERNAL":mc},yc),params:n})}}var _c=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Sc{constructor(e){this._requestSender=e}getB2BCompanyPaymentMethods(e,t,n,i){return _c(this,void 0,void 0,function*(){return this._requestSender.get(`${n}/api/v2/companies/${e}/payments`,{timeout:null==i?void 0:i.timeout,credentials:!1,headers:{authToken:t,Authorization:`Bearer ${t}`}})})}getB2BInvoiceAllowedPaymentMethods(e,t,n){return _c(this,void 0,void 0,function*(){return this._requestSender.get(`${e}/api/v1/ip/storefront/payments/bigcommerce/allowed-methods`,{timeout:null==n?void 0:n.timeout,credentials:!1,headers:{authToken:t,Authorization:`Bearer ${t}`}})})}}function vc(e,t,n){return(i=t)&&i.type&&i.error?V(Z(t),J(s(e,t.payload,n))):J(s(e,t,n));var i}class Cc extends Ee{constructor(e){super(e||"Unable to continue as a guest because the customer is already signed in."),this.name="UnableToContinueAsGuestError",this.type="unable_to_continue_as_guest"}}class Ic{constructor(e,t){this._requestSender=e,this._subscriptionActionCreator=t}continueAsGuest(e,t){return n=>{const i=n.getState(),r=i.checkout.getCheckout();if(!r)throw new nr(tr.MissingCheckout);const a=i.customer.getCustomer();if(a&&!a.isGuest)throw new Cc;const s=i.billingAddress.getBillingAddress();let d;if(s){const{country:t}=s,n=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(s,["country"]);d=Object.assign(Object.assign({},n),e)}else d=e;const c=!f(s);return $(V(Z(o(Ye.ContinueAsGuestRequested)),H(()=>{return e=this,n=void 0,a=function*(){const{body:e}=yield this._createOrUpdateBillingAddress(r.id,d,c,t);return o(Ye.ContinueAsGuestSucceeded,e)},new((i=void 0)||(i=Promise))(function(t,r){function o(e){try{d(a.next(e))}catch(e){r(e)}}function s(e){try{d(a.throw(e))}catch(e){r(e)}}function d(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i(function(e){e(n)})).then(o,s)}d((a=a.apply(e,n||[])).next())});var e,n,i,a})).pipe(Q(e=>vc(Ye.ContinueAsGuestFailed,e))),this._updateCustomerConsent(e,t))}}updateAddress(e,t){return n=>j.create(i=>{const r=n.getState(),a=r.checkout.getCheckout();if(!a)throw new nr(tr.MissingCheckout);i.next(o(Ye.UpdateBillingAddressRequested));const d=r.billingAddress.getBillingAddress(),c=!f(d),u=Object.assign(Object.assign({},e),{email:void 0===e.email&&d?d.email:e.email});d&&d.id&&(u.id=d.id),this._createOrUpdateBillingAddress(a.id,u,c,t).then(({body:e})=>{i.next(o(Ye.UpdateBillingAddressSucceeded,e)),i.complete()}).catch(e=>{i.error(s(Ye.UpdateBillingAddressFailed,e))})})}_updateCustomerConsent({email:e,acceptsAbandonedCartEmails:t,acceptsMarketingNewsletter:n},i){return null==t&&null==n?W():this._subscriptionActionCreator.updateSubscriptions({email:e,acceptsMarketingNewsletter:n||!1,acceptsAbandonedCartEmails:t||!1},i)}_createOrUpdateBillingAddress(e,t,n,i){return n?this._requestSender.updateAddress(e,t,i):this._requestSender.createAddress(e,t,i)}}class wc extends Ee{constructor(e){super(e||"Your checkout could not be processed because your cart is empty. Please add items to your cart and try again."),this.name="EmptyCartError",this.type="empty_cart"}}const Ec={include:["cart.lineItems.physicalItems.options","cart.lineItems.physicalItems.stockPosition","cart.lineItems.digitalItems.options","cart.lineItems.digitalItems.stockPosition","customer","promotions.banners"].join(",")};class bc{constructor(e){this._requestSender=e}createAddress(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/billing-address`,r=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.post(i,{body:t,params:Ec,headers:r,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}updateAddress(e,t,{timeout:n}={}){const{id:i}=t,r=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["id"]),o=`/api/storefront/checkouts/${e}/billing-address/${i}`,a=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.put(o,{params:Ec,body:r,headers:a,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}}class Pc{constructor(e){this._requestSender=e}createBuyNowCart(e,{timeout:t}={}){const n=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.post("/api/storefront/carts",{body:e,headers:n,timeout:t})}}class Oc{constructor(e,t,n){this._checkoutRequestSender=e,this._configActionCreator=t,this._formFieldsActionCreator=n}loadCheckout(e,t){return()=>V(Z(o(Ve.LoadCheckoutRequested)),$(this._configActionCreator.loadConfig({useCache:!0,timeout:null==t?void 0:t.timeout,params:{checkoutId:e}}),this._formFieldsActionCreator.loadFormFields({useCache:!0,timeout:null==t?void 0:t.timeout})),H(()=>this._checkoutRequestSender.loadCheckout(e,t).then(({body:e})=>o(Ve.LoadCheckoutSucceeded,this._transformCustomerAddresses(e))))).pipe(Q(e=>vc(Ve.LoadCheckoutFailed,e)))}loadDefaultCheckout(e){return t=>V(Z(o(Ve.LoadCheckoutRequested)),$(this._configActionCreator.loadConfig({useCache:!0,timeout:null==e?void 0:e.timeout}),this._formFieldsActionCreator.loadFormFields({useCache:!0,timeout:null==e?void 0:e.timeout})),H(()=>{return n=this,i=void 0,a=function*(){const n=t.getState().config.getContextConfig();if(!n||!n.checkoutId)throw new nr(tr.MissingCheckoutConfig);const{body:i}=yield this._checkoutRequestSender.loadCheckout(n.checkoutId,e);return o(Ve.LoadCheckoutSucceeded,this._transformCustomerAddresses(i))},new((r=void 0)||(r=Promise))(function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function s(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(o,s)}d((a=a.apply(n,i||[])).next())});var n,i,r,a})).pipe(Q(e=>vc(Ve.LoadCheckoutFailed,e)))}updateCheckout(e,t){return n=>new j(i=>{const r=n.getState().checkout.getCheckout();if(!r)throw new nr(tr.MissingCheckout);i.next(o(Ve.UpdateCheckoutRequested)),this._checkoutRequestSender.updateCheckout(r.id,e,t).then(({body:e})=>{i.next(o(Ve.UpdateCheckoutSucceeded,e)),i.complete()}).catch(e=>{i.error(s(Ve.UpdateCheckoutFailed,e))})})}deleteCheckout(e){return t=>new j(n=>{const i=t.getState().checkout.getCheckout();if(!i)throw new nr(tr.MissingCheckout);n.next(o(Ve.DeleteCheckoutRequested)),this._checkoutRequestSender.deleteCheckout(i.id,e).then(()=>{n.next(o(Ve.DeleteCheckoutSucceeded)),n.complete()}).catch(e=>{n.error(s(Ve.DeleteCheckoutFailed,e))})})}loadCurrentCheckout(e){return t=>{const n=t.getState().checkout.getCheckout();if(!n)throw new nr(tr.MissingCheckout);return this.loadCheckout(n.id,e)(t)}}hydrateInitialState(e){return{type:He.HydrateInitialState,payload:e}}_transformCustomerAddresses(e){return Object.assign(Object.assign({},e),{customer:Object.assign(Object.assign({},e.customer),{addresses:e.customer.addresses.map(e=>Object.assign(Object.assign({},e),{shouldSaveAddress:!1}))})})}}function Ac(e){return F(e).join(",")}function Tc(e,t=[]){return Array.isArray(t)?Ac([...e,...t]):function(e,t){const n=E(M(t,e=>!e)),i=E(u(t));return Ac([...c(e,n),...i])}(e,t)}const kc=["cart.lineItems.physicalItems.options","cart.lineItems.physicalItems.stockPosition","cart.lineItems.digitalItems.options","cart.lineItems.digitalItems.stockPosition","customer","customer.customerGroup","payments","promotions.banners"];class Rc extends Pe{constructor(e){super(e,{message:e.body.title}),this.name="CheckoutNotAvailableError",this.type="checkout_not_available"}}class Dc{constructor(e){this._requestSender=e}loadCheckout(e,{params:{include:t}={},timeout:n}={}){const i=`/api/storefront/checkout/${e}`,r=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.get(i,{params:{include:Tc(kc,t)},headers:r,timeout:n}).catch(e=>{if(e.status>=400&&e.status<500)throw new Rc(e);throw e})}updateCheckout(e,t,{params:{include:n}={},timeout:i}={}){const r=`/api/storefront/checkout/${e}`,o=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.put(r,{params:{include:Tc(kc,n)},body:t,headers:o,timeout:i}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}deleteCheckout(e,{timeout:t}={}){const n=`/api/storefront/carts/${e}`,i=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.delete(n,{headers:i,timeout:t})}}class Mc{isEqual(e,t){return _(this._normalize(e),this._normalize(t))}_normalize(e){return{cartAmount:e.cartAmount,currency:e.currency,id:e.id,lineItems:{digitalItems:e.lineItems.digitalItems.slice().sort((e,t)=>`${e.productId}${e.variantId}`.localeCompare(`${t.productId}${t.variantId}`)).map(e=>({extendedSalePrice:e.extendedSalePrice,productId:e.productId,quantity:e.quantity,variantId:e.variantId})),giftCertificates:e.lineItems.giftCertificates.slice().sort((e,t)=>`${e.id}`.localeCompare(`${t.id}`)).map(e=>({amount:e.amount,recipient:e.recipient})),physicalItems:e.lineItems.physicalItems.slice().sort((e,t)=>`${e.productId}${e.variantId}`.localeCompare(`${t.productId}${t.variantId}`)).map(e=>({extendedSalePrice:e.extendedSalePrice,productId:e.productId,quantity:e.quantity,variantId:e.variantId,giftWrapping:e.giftWrapping}))}}}}class Nc extends Ee{constructor(e,t){super("An update to your shopping cart has been detected and your available shipping costs have been updated."),this.name="CartChangedError",this.type="cart_changed",this.data={previous:e,updated:t}}}class Lc{constructor(e){this._checkoutRequestSender=e}validate(e,t){if(!e)throw new nr(tr.MissingCheckout);return this._checkoutRequestSender.loadCheckout(e.id,t).then(t=>{const n=new Mc;if(!(e.outstandingBalance===t.body.outstandingBalance&&this._compareCoupons(e.coupons,t.body.coupons)&&this._compareGiftCertificates(e.giftCertificates,t.body.giftCertificates)&&n.isEqual(e.cart,t.body.cart)))throw new Nc(this._getComparableCheckout(e),this._getComparableCheckout(t.body))})}_compareCoupons(e,t){return _(P(e,"code"),P(t,"code"))}_compareGiftCertificates(e,t){return _(P(e,"code"),P(t,"code"))}_getComparableCheckout(e){const{cart:t,coupons:n,giftCertificates:i,outstandingBalance:r}=e;return{cart:{cartAmount:t.cartAmount,currency:t.currency,lineItems:t.lineItems},coupons:n,giftCertificates:i,outstandingBalance:r}}}var zc;class Uc{constructor(e){this._configRequestSender=e}loadConfig(e){return j.create(t=>{t.next(o(vt.LoadConfigRequested)),this._configRequestSender.loadConfig(e).then(e=>{t.next(o(vt.LoadConfigSucceeded,e.body)),t.complete()}).catch(e=>{t.error(s(vt.LoadConfigFailed,e))})})}}!function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);o>3&&a&&Object.defineProperty(t,n,a)}([cc],Uc.prototype,"loadConfig",null);class Fc{constructor(e){this._requestSender=e}loadConfig({timeout:e,params:t}={}){return this._requestSender.get("/api/storefront/checkout-settings",{timeout:e,headers:Object.assign({Accept:gc.JsonV1,"X-API-INTERNAL":mc},yc),params:t}).catch(e=>{if(e.status>=400&&e.status<500)throw new Rc(e);throw e})}}class Bc{constructor(e){this._couponRequestSender=e}applyCoupon(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout();if(!r)throw new nr(tr.MissingCheckout);i.next(o(it.ApplyCouponRequested)),this._couponRequestSender.applyCoupon(r.id,e,t).then(({body:e})=>{i.next(o(it.ApplyCouponSucceeded,e)),i.complete()}).catch(e=>{i.error(s(it.ApplyCouponFailed,e))})})}removeCoupon(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout();if(!r)throw new nr(tr.MissingCheckout);i.next(o(it.RemoveCouponRequested)),this._couponRequestSender.removeCoupon(r.id,e,t).then(({body:e})=>{i.next(o(it.RemoveCouponSucceeded,e)),i.complete()}).catch(e=>{i.error(s(it.RemoveCouponFailed,e))})})}}!function(e){e.AvailableShippingOptions="consignments.availableShippingOptions",e.PhysicalItemsCategoryNames="cart.lineItems.physicalItems.categoryNames",e.DigitalItemsCategoryNames="cart.lineItems.digitalItems.categoryNames"}(zc||(zc={}));class xc{constructor(e){this._requestSender=e}applyCoupon(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/coupons`,r=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.post(i,{headers:r,timeout:n,params:{include:Ac([...kc,zc.AvailableShippingOptions])},body:{couponCode:t}}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}removeCoupon(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/coupons/${t}`,r=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.delete(i,{headers:r,timeout:n,params:{include:Ac([...kc,zc.AvailableShippingOptions])}}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}}function qc(e){const t=e;return"object"==typeof t&&"object"==typeof t.payload&&"string"==typeof t.payload.token}class jc{constructor(e,t,n){this._customerRequestSender=e,this._checkoutActionCreator=t,this._spamProtectionActionCreator=n}createCustomer(e,t){return n=>{const i=n.getState().config.getStoreConfigOrThrow(),{isStorefrontSpamProtectionEnabled:r}=i.checkoutSettings,a=i=>Y(this._customerRequestSender.createAccount(Object.assign(Object.assign({},e),{token:i}),t)).pipe(re(()=>V(this._checkoutActionCreator.loadCurrentCheckout(t)(n),Z(o(Ut.CreateCustomerSucceeded)))));return V(Z(o(Ut.CreateCustomerRequested)),r?Y(this._spamProtectionActionCreator.execute()(n)).pipe(re(e=>{var t;return qc(e)?V(Z(e),a(null===(t=e.payload)||void 0===t?void 0:t.token)):Z(e)})):a()).pipe(Q(e=>vc(Ut.CreateCustomerFailed,e)))}}createAddress(e,t){return V(Z(o(Ut.CreateCustomerAddressRequested)),H(()=>{return n=this,i=void 0,a=function*(){const{body:n}=yield this._customerRequestSender.createAddress(e,t);return o(Ut.CreateCustomerAddressSucceeded,n)},new((r=void 0)||(r=Promise))(function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function s(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(o,s)}d((a=a.apply(n,i||[])).next())});var n,i,r,a})).pipe(Q(e=>vc(Ut.CreateCustomerAddressFailed,e)))}signInCustomer(e,t){return n=>{const i=n.getState().checkout.getCheckoutOrThrow(),r=i.cart.source===vo.BuyNow?i.id:void 0;return V(Z(o(Ut.SignInCustomerRequested)),Y(this._customerRequestSender.signInCustomer(Object.assign(Object.assign({},e),{cartId:r}),t)).pipe(re(({body:e})=>e.data.persistentCartRetrievalInformation?V(this._checkoutActionCreator.loadCheckout(e.data.persistentCartRetrievalInformation.id,t)(n),Z(o(Ut.SignInCustomerSucceeded,e.data))):V(this._checkoutActionCreator.loadCurrentCheckout(t)(n),Z(o(Ut.SignInCustomerSucceeded,e.data)))))).pipe(Q(e=>vc(Ut.SignInCustomerFailed,e)))}}signOutCustomer(e){return t=>{const n=t.getState().checkout.getCheckoutOrThrow(),i=n.cart.source===vo.BuyNow?n.id:void 0;return V(Z(o(Ut.SignOutCustomerRequested)),Y(this._customerRequestSender.signOutCustomer(e,i)).pipe(re(({body:n})=>V(this._checkoutActionCreator.loadCurrentCheckout(e)(t),Z(o(Ut.SignOutCustomerSucceeded,n.data)))))).pipe(Q(e=>vc(Ut.SignOutCustomerFailed,e)))}}}class Gc{constructor(e){this._requestSender=e}createAccount(e,{timeout:t}={}){return this._requestSender.post("/api/storefront/customer",{timeout:t,headers:yc,body:e})}createAddress(e,{timeout:t}={}){return this._requestSender.post("/api/storefront/customer-address",{timeout:t,headers:yc,body:e})}signInCustomer(e,{timeout:t}={}){return this._requestSender.post("/internalapi/v1/checkout/customer",{timeout:t,headers:yc,body:e})}signOutCustomer({timeout:e}={},t){return this._requestSender.delete("/internalapi/v1/checkout/customer",Object.assign({timeout:e,headers:yc},t&&{body:{cartId:t}}))}}class Vc{constructor(e){this._formFieldsRequestSender=e}loadFormFields(e){return V(Z(o(tn.LoadFormFieldsRequested)),H(()=>{return t=this,n=void 0,r=function*(){const{body:t}=yield this._formFieldsRequestSender.loadFields(e);return o(tn.LoadFormFieldsSucceeded,t)},new((i=void 0)||(i=Promise))(function(e,o){function a(e){try{d(r.next(e))}catch(e){o(e)}}function s(e){try{d(r.throw(e))}catch(e){o(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,s)}d((r=r.apply(t,n||[])).next())});var t,n,i,r})).pipe(Q(e=>vc(tn.LoadFormFieldsFailed,e)))}}!function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);o>3&&a&&Object.defineProperty(t,n,a)}([cc],Vc.prototype,"loadFormFields",null);class Hc{constructor(e){this._requestSender=e}loadFields({timeout:e}={}){return this._requestSender.get("/api/storefront/form-fields",{timeout:e,headers:Object.assign({Accept:gc.JsonV1,"X-API-INTERNAL":mc},yc)})}}class Wc extends Ee{constructor(e){super(e||"Unable to proceed because the required element is unexpectedly detached from the page."),this.name="UnexpectedDetachmentError",this.type="unexpected_detachment"}}class Yc{constructor(e){this._mutationObserver=e}ensurePresence(e,t){return n=this,i=void 0,o=function*(){const n=new Aa(t),i=this._mutationObserver.create(t=>{t.forEach(t=>{0!==Array.from(t.removedNodes).filter(t=>e.some(e=>t===e||t.contains(e))).length&&n.cancel(new Wc)})});i.observe(document.body,{childList:!0,subtree:!0});try{const e=yield n.promise;return i.disconnect(),e}catch(e){throw i.disconnect(),e}},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}}class Kc{constructor(e=window){this._window=e}create(e){return new this._window.MutationObserver(e)}}class $c extends Ee{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}function Zc(e){if(!/^(https?:)?\/\//.test(e))throw new $c("The provided URL must be absolute.");const t=document.createElement("a");t.href=e;const 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 Jc(e,t){return e.type===t}class Qc{constructor(e,t,n){this._targetWindow=t,this._context=n,this._targetOrigin="*"===e?"*":Zc(e).origin}post(e,t){const n=this._targetWindow;if(window===n)return;if(!n)throw new Error("Unable to post message because target window is not set.");const i=t&&K(window,"message").pipe(ee(e=>e.origin===this._targetOrigin&&Jc(e.data,e.data.type)&&-1!==[t.successType,t.errorType].indexOf(e.data.type)),te(e=>{if(t.errorType===e.data.type)throw e.data;return e.data}),oe(1)).toPromise();return n.postMessage(Object.assign(Object.assign({},e),{context:this._context}),this._targetOrigin),i}setTarget(e){this._targetWindow=e}setContext(e){this._context=e}}class Xc{constructor(e){var t;this._sourceOrigins=[Zc(e).origin,(t=Zc(e),Zc(0===t.hostname.indexOf("www")?t.href:t.href.replace(t.hostname,`www.${t.hostname}`))).origin],this._isListening=!1,this._listeners={}}listen(){this._isListening||(this._isListening=!0,window.addEventListener("message",this._handleMessage))}stopListen(){this._isListening&&(this._isListening=!1,window.removeEventListener("message",this._handleMessage))}addListener(e,t){let n=this._listeners[e];n||(this._listeners[e]=n=[]),-1===n.indexOf(t)&&n.push(t)}removeListener(e,t){const n=this._listeners[e];if(!n)return;const i=n.indexOf(t);i>=0&&n.splice(i,1)}trigger(e,t){const n=this._listeners[e.type];n&&n.forEach(n=>t?n(e,t):n(e))}_handleMessage(e){if(-1===this._sourceOrigins.indexOf(e.origin)||!Jc(e.data,e.data.type))return;const t=e.data,{context:n}=t,i=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["context"]);this.trigger(i,n)}}!function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);o>3&&a&&Object.defineProperty(t,n,a)}([ka],Xc.prototype,"_handleMessage",null);class eu extends Ee{constructor(){super("You haven't complete our spam protection challenge. Please try again."),this.name="SpamProtectionChallengeNotCompletedError",this.type="spam_protection_challenge_not_completed"}}class tu extends Ee{constructor(){super("Please complete our human verification challenge and try again."),this.name="CardingProtectionChallengeNotCompletedError",this.type="carding_protection_challenge_not_completed"}}class nu extends Ee{constructor(){super("We were not able to verify that you are not a robot. Please try again."),this.name="CardingProtectionFailedError",this.type="carding_protection_failed"}}var iu,ru,ou,au=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class su{constructor(e){this._googleRecaptcha=e}handle(e,t){return au(this,void 0,void 0,function*(){return"string"==typeof e?this.handleWithRecaptchaSitekey(e,t):this.handleWithPaymentHumanVerificationRequestError(e)})}handleWithPaymentHumanVerificationRequestError(e){return au(this,void 0,void 0,function*(){if(!this._isPaymentHumanVerificationRequest(e))throw e;return yield this._initialize(e.body.additional_action_required.data.key),this._performRecaptcha()})}handleWithRecaptchaSitekey(e,t){return au(this,void 0,void 0,function*(){if("recaptcha_v2"!==e)throw Error("Human verification method is not supported.");if(!t)throw Error("Recaptcha site key is missing.");return yield this._initialize(t),this._performRecaptcha()})}_performRecaptcha(){return this._googleRecaptcha.execute().pipe(oe(1)).pipe(re(e=>au(this,[e],void 0,function*({error:e,token:t}){if(e instanceof eu)throw new tu;if(e||!t)throw new nu;return{type:"recaptcha_v2_verification",data:{human_verification_token:t}}}))).toPromise()}_initialize(e){const t="cardingProtectionContainer";let n=document.getElementById(t);return n&&n.parentNode&&n.parentNode.removeChild(n),n=document.createElement("div"),n.setAttribute("id",t),document.body.appendChild(n),this._googleRecaptcha.load(t,e)}_isPaymentHumanVerificationRequest(e){const{additional_action_required:t,status:n}=e.body||{};return"additional_action_required"===n&&t&&"recaptcha_v2_verification"===t.type}}!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"}(iu||(iu={}));class du extends Ee{constructor(e){super(function(e){switch(e){case iu.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case iu.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case iu.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case iu.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}class cu extends Ee{constructor(){super("We were not able to complete your spam protection verification. Please try again."),this.name="SpamProtectionFailedError",this.type="spam_protection_failed"}}class uu extends Ee{constructor(){super("Spam protection is not loaded. Please try again."),this.name="SpamProtectionNotLoadedError",this.type="spam_protection_failed"}}class lu{constructor(e,t){this.googleRecaptchaScriptLoader=e,this.mutationObserverFactory=t,this._memoized=ae((e,t,n)=>{const i=new G;if(!n)throw new Error;return this._widgetId=e.render(n.id,{sitekey:t,size:"invisible",callback:()=>{i.next({token:e.getResponse(this._widgetId)}),e.reset(this._widgetId)},"error-callback":()=>{i.next({error:new cu})}}),i},{isEqual:(e,t)=>e===t})}load(e,t){return this.googleRecaptchaScriptLoader.load().then(n=>{n&&(this._event$=this._memoized(n,t,document.getElementById(e)),this._recaptcha=n)}).catch(e=>{throw e})}reset(e){var t;const n=document.getElementById(e);null==n||n.remove(),null===(t=this._recaptcha)||void 0===t||t.reset(this._widgetId)}execute(){return H(()=>{const e=this._event$,t=this._recaptcha;if(!e||!t)throw new du(iu.SpamProtectionNotInitialized);return H(()=>{const e=document.querySelector('iframe[src*="bframe"]');return e?Z(e):J(new uu)}).pipe(ne(e=>e.pipe(X(250),re((e,t)=>t<28?Z(e):J(e)))),re(n=>(this._watchRecaptchaChallengeWindow(e,n),t.execute(this._widgetId),e)),Q(e=>Z({error:e})))})}_watchRecaptchaChallengeWindow(e,t){const n=t.parentElement;if(!n)throw new uu;const i=n.parentElement;if(!i)throw new uu;this.mutationObserverFactory.create(()=>{"hidden"===i.style.visibility&&e.next({error:new eu})}).observe(i,{attributes:!0,attributeFilter:["style"]})}}class hu{constructor(e,t=window){this._scriptLoader=e,this._window=t}load(){return this._loadPromise||(this._loadPromise=this._loadScript()),this._loadPromise}_loadScript(){const e="initRecaptcha",t=[`onload=${e}`,"render=explicit"].join("&");return new Promise((n,i)=>{this._window[e]=()=>n(this._window.grecaptcha),this._scriptLoader.loadScript(`//www.google.com/recaptcha/api.js?${t}`).catch(e=>{this._loadPromise=void 0,i(e)})})}}function pu(e){return new lu(new hu(e),new Kc)}class gu extends Ee{constructor(e){super(e||"Unable to proceed due to invalid configuration provided for the hosted payment form."),this.name="InvalidHostedFormConfigError",this.type="invalid_hosted_form_config"}}class mu extends Ee{constructor(e){super(e||"Unable to proceed due to an unknown error with the hosted payment form."),this.name="InvalidHostedFormError",this.type="invalid_hosted_form"}}class yu extends Ee{constructor(e){super(["Unable to proceed due to invalid user input values",...p(x(e),e=>P(e,({message:e})=>e))].join(". ")),this.errors=e,this.name="InvalidHostedFormValueError",this.type="invalid_hosted_form_value"}}!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"}(ru||(ru={})),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"}(ou||(ou={}));var fu=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class _u{constructor(e,t,n,i,r,o,a,s,d,c){this._type=e,this._containerId=t,this._placeholder=n,this._accessibilityLabel=i,this._styles=r,this._eventPoster=o,this._eventListener=a,this._detachmentObserver=s,this._checkoutId=d,this._cardInstrument=c,this._iframe=document.createElement("iframe");const u=this._checkoutId?`/checkout/payment/hosted-field?version=1.934.0&checkoutId=${this._checkoutId}`:"/checkout/payment/hosted-field?version=1.934.0";this._iframe.src=u,this._iframe.style.border="none",this._iframe.style.height="100%",this._iframe.style.overflow="hidden",this._iframe.style.width="100%"}getType(){return this._type}attach(){return fu(this,void 0,void 0,function*(){const e=document.getElementById(this._containerId);if(!e)throw new gu("Unable to proceed because the provided container ID is not valid.");e.appendChild(this._iframe),this._eventListener.listen();const t=K(this._iframe,"load").pipe(re(e=>fu(this,[e],void 0,function*({target:e}){const t=e&&e.contentWindow;if(!t)throw new Error("The content window of the iframe cannot be accessed.");this._eventPoster.setTarget(t),yield this._eventPoster.post({type:ru.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:ou.AttachSucceeded,errorType:ou.AttachFailed})})),oe(1)).toPromise();yield this._detachmentObserver.ensurePresence([this._iframe],t)})}detach(){this._iframe.parentElement&&(this._iframe.parentElement.removeChild(this._iframe),this._eventListener.stopListen())}submitForm(e,t){return fu(this,void 0,void 0,function*(){try{const n=this._eventPoster.post({type:ru.SubmitRequested,payload:{fields:e,data:t}},{successType:ou.SubmitSucceeded,errorType:ou.SubmitFailed});return yield this._detachmentObserver.ensurePresence([this._iframe],n)}catch(e){if(this._isSubmitErrorEvent(e)){if("hosted_form_error"===e.payload.error.code)throw new mu(e.payload.error.message);if(e.payload.response)throw Te(e.payload.response);throw new Error(e.payload.error.message)}throw e}})}submitStoredCardForm(e,t){return fu(this,void 0,void 0,function*(){const n=this._eventPoster.post({type:ru.StoredCardRequested,payload:{fields:e,data:t}},{successType:ou.StoredCardSucceeded,errorType:ou.StoredCardFailed});return this._detachmentObserver.ensurePresence([this._iframe],n)})}validateForm(){return fu(this,void 0,void 0,function*(){const e=this._eventPoster.post({type:ru.ValidateRequested},{successType:ou.Validated}),{payload:t}=yield this._detachmentObserver.ensurePresence([this._iframe],e);if(!t.isValid)throw new yu(t.errors)})}_getFontUrls(){const e="fonts.googleapis.com",t=document.querySelectorAll(`link[href*='${e}'][rel='stylesheet']`);return Array.prototype.slice.call(t).filter(t=>Zc(t.href).hostname===e).filter(e=>x(this._styles).map(e=>e&&e.fontFamily).filter(e=>"string"==typeof e).some(t=>t.split(/,\s/).some(t=>-1!==e.href.indexOf(t.replace(" ","+"))))).map(e=>e.href)}_isSubmitErrorEvent(e){return e.type===ou.SubmitFailed}}var Su=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class vu{constructor(e,t,n,i,r){this._fields=e,this._eventListener=t,this._payloadTransformer=n,this._eventCallbacks=i,this._paymentHumanVerificationHandler=r,this._handleEnter=e=>Su(this,[e],void 0,function*({payload:e}){try{yield this.validate()}catch(e){if(e instanceof Error&&"InvalidHostedFormValueError"!==e.name)throw e}const{onEnter:t=T}=this._eventCallbacks;t(e)});const{onBlur:o=T,onCardTypeChange:a=T,onFocus:s=T,onValidate:d=T}=this._eventCallbacks;this._eventListener.addListener(ou.Blurred,({payload:e})=>o(e)),this._eventListener.addListener(ou.CardTypeChanged,({payload:e})=>a(e)),this._eventListener.addListener(ou.Focused,({payload:e})=>s(e)),this._eventListener.addListener(ou.Validated,({payload:e})=>d(e)),this._eventListener.addListener(ou.Entered,this._handleEnter),this._eventListener.addListener(ou.CardTypeChanged,({payload:e})=>this._cardType=e.cardType),this._eventListener.addListener(ou.BinChanged,({payload:e})=>this._bin=e.bin)}getBin(){return this._bin}getCardType(){return this._cardType}attach(){return Su(this,void 0,void 0,function*(){this._eventListener.listen();const e=this._getFirstField(),t=q(this._fields,e);yield e.attach(),yield Promise.all(t.map(e=>e.attach()))})}detach(){this._eventListener.stopListen(),this._fields.forEach(e=>{e.detach()})}submit(e,t){return Su(this,void 0,void 0,function*(){try{return yield this._getFirstField().submitForm(this._fields.map(e=>e.getType()),this._payloadTransformer.transform(e,t))}catch(t){const n=yield this._paymentHumanVerificationHandler.handle(t);return yield this._getFirstField().submitForm(this._fields.map(e=>e.getType()),this._payloadTransformer.transform(e,n))}})}submitStoredCard(e){return Su(this,void 0,void 0,function*(){return this._getFirstField().submitStoredCardForm(e.fields,e.data)})}validate(){return Su(this,void 0,void 0,function*(){return this._getFirstField().validateForm()})}_getFirstField(){const e=this._fields[0];if(!e)throw new gu("Unable to proceed because the payment form has no field defined.");return e}}function Cu(e){return Boolean(e.instrumentId)}class Iu{constructor(e){this._store=e}transform(e,t){const n=this._store.getState(),i=n.checkout.getCheckout(),r=n.config.getConfig(),o=n.instruments.getInstrumentsMeta(),a=n.order.getOrder(),s=n.order.getOrderMeta(),d=k(e.paymentData,"ccExpiry","ccName","ccNumber","ccCvv");let c=n.paymentMethods.getPaymentMethod(e.methodId,e.gatewayId);"worldpayaccess"===(null==c?void 0:c.gateway)&&"credit_card"===(null==c?void 0:c.id)&&(c=Object.assign(Object.assign({},c),{id:"worldpayaccess",method:"credit-card"}));const u=n.paymentMethods.getPaymentMethodsMeta(),l=o&&d&&Cu(d)?`${n.payment.getPaymentToken()}, ${o.vaultAccessToken}`:n.payment.getPaymentToken();if(!l)throw new nr(tr.MissingPaymentToken);return{additionalAction:t,authToken:l,checkout:i,config:r,order:a,orderMeta:s,payment:d,paymentMethod:c,paymentMethodMeta:u}}}class wu{constructor(e){this._store=e}create(e,t,n){const i=Object.keys(t.fields).reduce((i,r)=>{const o=t.fields[r];return o?[...i,new _u(r,o.containerId,o.placeholder||"",o.accessibilityLabel||"",t.styles||{},new Qc(e),new Xc(e),new Yc(new Kc),n,"instrumentId"in o?this._getCardInstrument(o.instrumentId):void 0)]:i},[]);return new vu(i,new Xc(e),new Iu(this._store),D(t,"onBlur","onEnter","onFocus","onCardTypeChange","onValidate"),new su(pu(ue())))}_getCardInstrument(e){const{instruments:{getCardInstrument:t}}=this._store.getState(),n=t(e);if(!n)throw new nr(tr.MissingPaymentInstrument);return n}}class Eu extends Ee{constructor(){super("You haven't complete our spam check. Please try again."),this.name="SpamProtectionNotCompletedError",this.type="spam_protection_not_completed"}}class bu{constructor(e,t){this._orderRequestSender=e,this._checkoutValidator=t}loadOrder(e,t){return new j(n=>{n.next(o(Pt.LoadOrderRequested)),this._orderRequestSender.loadOrder(e,t).then(e=>{n.next(o(Pt.LoadOrderSucceeded,e.body)),n.complete()}).catch(e=>{n.error(s(Pt.LoadOrderFailed,e))})})}loadOrderPayments(e,t){return new j(n=>{n.next(o(Pt.LoadOrderPaymentsRequested)),this._orderRequestSender.loadOrder(e,t).then(e=>{n.next(o(Pt.LoadOrderPaymentsSucceeded,e.body)),n.complete()}).catch(e=>{n.error(s(Pt.LoadOrderPaymentsFailed,e))})})}loadCurrentOrder(e){return t=>H(()=>{const n=this._getCurrentOrderId(t.getState());if(!n)throw new nr(tr.MissingOrderId);return this.loadOrder(n,e)})}submitOrder(e,t){return n=>V(Z(o(Pt.SubmitOrderRequested)),H(()=>{const i=n.getState(),r=i.config.getExternalSource(),a=i.config.getVariantIdentificationToken(),s=i.checkout.getCheckout();if(!s)throw new nr(tr.MissingCheckout);if(s.shouldExecuteSpamCheck)throw new Eu;return Y(this._checkoutValidator.validate(s,t).then(()=>this._orderRequestSender.submitOrder(this._mapToOrderRequestBody(null!=e?e:{},s.id,s.customerMessage,r),Object.assign(Object.assign({},t),{headers:{checkoutVariant:a}})))).pipe(re(e=>V(this.loadOrder(e.body.data.order.orderId,t),Z(o(Pt.SubmitOrderSucceeded,e.body.data,Object.assign(Object.assign({},e.body.meta),{token:e.headers.token}))))))}).pipe(Q(e=>vc(Pt.SubmitOrderFailed,e))))}finalizeOrder(e,t){return V(Z(o(Pt.FinalizeOrderRequested)),Y(this._orderRequestSender.finalizeOrder(e,t)).pipe(re(n=>V(this.loadOrder(e,t),Z(o(Pt.FinalizeOrderSucceeded,n.body.data)))))).pipe(Q(e=>vc(Pt.FinalizeOrderFailed,e)))}_getCurrentOrderId(e){const t=e.order.getOrder(),n=e.checkout.getCheckout();return t&&t.orderId||n&&n.orderId}_mapToOrderRequestBody(e,t,n,i){const{payment:r}=e,o=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["payment"]);return r?Object.assign(Object.assign({},o),{cartId:t,customerMessage:n,externalSource:i,payment:{paymentData:r.paymentData,name:r.methodId,gateway:r.gatewayId}}):Object.assign(Object.assign({},o),{cartId:t,customerMessage:n,externalSource:i})}}class Pu extends Ee{constructor(e){super(e||"Your checkout could not be processed because some details have changed. Please review your order and try again."),this.name="CartConsistencyError",this.type="cart_consistency"}}class Ou extends Ee{constructor(e,t){super(t||"At least one item changed stock position. Please review your cart and try again."),this.name="CartStockPositionsChangedError",this.type="cart_stock_positions_changed",this.changedItemIds=e}}class Au extends Ee{constructor(e){super(e||"The tax provider is unavailable."),this.name="OrderTaxProviderUnavailableError",this.type="tax_provider_unavailable"}}class Tu extends Ee{constructor(e){super(e),this.name="MissingShippingMethodError",this.type="missing_shipping_method"}}class ku extends Ee{constructor(e){super(e),this.name="InvalidShippingAddressError",this.type="invalid_shipping_address"}}class Ru{constructor(e){this._requestSender=e}loadOrder(e,{timeout:t}={}){const n=`/api/storefront/orders/${e}`,i=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.get(n,{params:{include:Ac(["payments","lineItems.physicalItems.socialMedia","lineItems.physicalItems.options","lineItems.physicalItems.categories","lineItems.digitalItems.socialMedia","lineItems.digitalItems.options","lineItems.digitalItems.categories"])},headers:i,timeout:t})}submitOrder(e,{headers:t,timeout:n}={}){return this._requestSender.post("/internalapi/v1/checkout/order",{body:e,headers:R(Object.assign({"X-Checkout-Variant":t&&t.checkoutVariant},yc),v),timeout:n}).catch(e=>{var t,n;if("tax_provider_unavailable"===e.body.type)throw new Au;if("cart_has_changed"===e.body.type)throw new Pu;if("cart_stock_positions_changed"===e.body.type){const i=null!==(n=null===(t=e.body.errors)||void 0===t?void 0:t.changedItemIds)&&void 0!==n?n:[];throw new Ou(i)}if("missing_shipping_method"===e.body.type)throw new Tu(e.body.detail);if("invalid_shipping_address"===e.body.type)throw new ku(e.body.detail);if("empty_cart"===e.body.type)throw new wc;throw e})}finalizeOrder(e,{timeout:t}={}){const n=`/internalapi/v1/checkout/order/${e}`;return this._requestSender.post(n,{timeout:t,headers:yc})}}class Du{constructor(e,t,n,i){this._paymentRequestSender=e,this._orderActionCreator=t,this._paymentRequestTransformer=n,this._paymentHumanVerificationHandler=i,this.initializeOffsitePayment=({methodId:e,gatewayId:t,instrumentId:n,target:i,promise:r,shouldSaveInstrument:a,shouldSetAsDefaultInstrument:s})=>d=>{let c;n?c={formattedPayload:{bigpay_token:n}}:a&&(c={formattedPayload:{vault_payment_instrument:a,set_as_default_stored_instrument:s||null}});const u=this._paymentRequestTransformer.transform({gatewayId:t,methodId:e,paymentData:c},d.getState());return V(Z(o(kn.InitializeOffsitePaymentRequested)),Promise.race([this._paymentRequestSender.initializeOffsitePayment(u,i),r].filter(Boolean)).then(()=>o(kn.InitializeOffsitePaymentSucceeded))).pipe(Q(e=>vc(kn.InitializeOffsitePaymentFailed,e)))}}submitPayment(e){return t=>V(Z(o(kn.SubmitPaymentRequested)),H(()=>{return n=this,i=void 0,o=function*(){try{return yield this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transform(e,t.getState()))}catch(n){const i=yield this._paymentHumanVerificationHandler.handle(n);return yield this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transform(Object.assign(Object.assign({},e),{additionalAction:i}),t.getState()))}},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}).pipe(re(({body:e})=>V(this._orderActionCreator.loadCurrentOrder()(t),Z(o(kn.SubmitPaymentSucceeded,e)))))).pipe(Q(e=>vc(kn.SubmitPaymentFailed,e)))}}class Mu{constructor(e){this._client=e}submitPayment(e){return new Promise((t,n)=>{this._client.submitPayment(e,(e,i)=>{e?n(this._transformResponse(e)):t(this._transformResponse(i))})})}initializeOffsitePayment(e,t){return new Promise(()=>{this._client.initializeOffsitePayment(e,null,t)})}_transformResponse(e){return{headers:e.headers,body:e.data,status:e.status,statusText:e.statusText}}}function Nu(e,t){let 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 Lu=["per_item_discount","percentage_discount","per_total_discount","shipping_discount","free_shipping"];function zu(e){return{code:e.code,discount:e.displayName,discountType:Lu.indexOf(e.couponType)}}function Uu(e){return{code:e.code,discountedAmount:e.used,remainingBalance:e.remaining,giftCertificate:{balance:e.balance,code:e.code,purchaseDate:e.purchaseDate}}}function Fu(e){const t=[];return(e||[]).forEach(e=>{(e.banners||[]).forEach(e=>{t.push({placeholders:[],discountType:null,message:"",messageHtml:e.text})})}),t}function Bu(e,t,n="id"){return Object.keys(e).reduce((i,r)=>[...i,...e[r].map(e=>"giftCertificates"===r?function(e,t){const n=new ic(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,i="id"){const r=new ic(n);return{id:e[i],imageUrl:e.imageUrl,amount:e.extendedListPrice,amountAfterDiscount:e.extendedSalePrice,discount:e.discountAmount,integerAmount:r.toInteger(e.extendedListPrice),integerAmountAfterDiscount:r.toInteger(e.extendedSalePrice),integerDiscount:r.toInteger(e.discountAmount),integerUnitPrice:r.toInteger(e.listPrice),integerUnitPriceAfterDiscount:r.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(e=>({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""}}(r),t,n))],[])}function xu(e){const t=e.cart.currency.decimalPlaces,n=new ic(t);return{id:e.cart.id,items:Bu(e.cart.lineItems,t),currency:e.cart.currency.code,coupon:{discountedAmount:N(e.cart.coupons,(e,t)=>e+t.discountedAmount,0),coupons:e.cart.coupons.map(zu)},discount:{amount:e.cart.discountAmount,integerAmount:n.toInteger(e.cart.discountAmount)},discountNotifications:Fu(e.promotions),giftCertificate:{totalDiscountedAmount:N(e.giftCertificates,(e,t)=>e+t.used,0),appliedGiftCertificates:w(e.giftCertificates.map(Uu),"code")},shipping:{amount:e.shippingCostTotal,integerAmount:n.toInteger(e.shippingCostTotal),amountBeforeDiscount:e.shippingCostBeforeDiscount,integerAmountBeforeDiscount:n.toInteger(e.shippingCostBeforeDiscount),required:z(e.cart.lineItems.physicalItems,e=>e.isShippingRequired)},subtotal:{amount:e.subtotal,integerAmount:n.toInteger(e.subtotal)},storeCredit:{amount:e.customer?e.customer.storeCredit:0},taxSubtotal:{amount:e.taxTotal,integerAmount:n.toInteger(e.taxTotal)},taxes:e.taxes,taxTotal:{amount:e.taxTotal,integerAmount:n.toInteger(e.taxTotal)},handling:{amount:e.handlingCostTotal,integerAmount:n.toInteger(e.handlingCostTotal)},grandTotal:{amount:e.grandTotal,integerAmount:n.toInteger(e.grandTotal)}}}var qu;!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.PAYPALEXPRESS="paypalexpress"}(qu||(qu={}));const ju=qu;function Gu(e,t){const n=e.firstName||t.firstName||"",i=e.lastName||t.lastName||"";return{addresses:(e.addresses||[]).map(e=>Nu(e)),customerId:e.id,isGuest:e.isGuest,storeCredit:e.storeCredit,email:e.email||t.email||"",firstName:n,lastName:i,name:e.fullName||[n,i].join(" "),customerGroupName:e.customerGroup&&e.customerGroup.name}}class Vu{format(e){const[t="",n=""]=e.split(new RegExp("\\s*/\\s*")),i=t.slice(0,2),r=4===n.length?n.slice(-2):n?n.slice(0,2):t.slice(2);return e.length<2?t:e.length>3&&!r?i:`${i} / ${r}`}toObject(e){const[t="",n=""]=e.split(new RegExp("\\s*/\\s*"));return/^\d+$/.test(t)&&/^\d+$/.test(n)?{month:1===t.length?`0${t}`:t.slice(0,2),year:2===n.length?`20${n}`:n.slice(0,4)}:{month:"",year:""}}}class Hu{format(e){const{card:t}=ye(e);if(!t)return e;const n=O(me(e).map(e=>O(e.lengths))),i=this.unformat(e).slice(0,n);return t.gaps.filter(e=>i.length>e).reduce((e,t,n)=>[e.slice(0,t+n),e.slice(t+n)].join(" "),i)}unformat(e){const{card:t}=ye(e);return t?e.replace(new RegExp(" ","g"),""):e}}function Wu(e,t={}){const n=e.currency.decimalPlaces,i=new ic(n);return{id:e.orderId,items:Bu(e.lineItems,e.currency.decimalPlaces,"productId"),orderId:e.orderId,currency:e.currency.code,customerCanBeCreated:e.customerCanBeCreated,payment:$u(e.payments,t.payment),subtotal:{amount:e.baseAmount,integerAmount:i.toInteger(e.baseAmount)},coupon:{discountedAmount:N(e.coupons,(e,t)=>e+t.discountedAmount,0),coupons:e.coupons.map(zu)},discount:{amount:e.discountAmount,integerAmount:i.toInteger(e.discountAmount)},token:t.orderToken,callbackUrl:t.callbackUrl,discountNotifications:[],giftCertificate:Ku(e.payments),socialData:Ju(e),status:e.status,hasDigitalItems:e.hasDigitalItems,isDownloadable:e.isDownloadable,isComplete:e.isComplete,shipping:{amount:e.shippingCostTotal,integerAmount:i.toInteger(e.shippingCostTotal),amountBeforeDiscount:e.shippingCostBeforeDiscount,integerAmountBeforeDiscount:i.toInteger(e.shippingCostBeforeDiscount)},storeCredit:{amount:Yu(e.payments)},taxes:e.taxes,taxTotal:{amount:e.taxTotal,integerAmount:i.toInteger(e.taxTotal)},handling:{amount:e.handlingCostTotal,integerAmount:i.toInteger(e.handlingCostTotal)},grandTotal:{amount:e.orderAmount,integerAmount:e.orderAmountAsInteger}}}function Yu(e){const t=l(e,{providerId:"storecredit"});return t?t.amount:0}function Ku(e){const t=u(e,{providerId:"giftcertificate"});return{totalDiscountedAmount:N(t,(e,t)=>t.amount+e,0),appliedGiftCertificates:w(t.map(e=>({code:e.detail.code,discountedAmount:e.amount,remainingBalance:e.detail.remaining,giftCertificate:{balance:e.amount+e.detail.remaining,code:e.detail.code,purchaseDate:""}})),"code")}}function $u(e,t={}){const n=l(e,Zu);return n?{id:n.providerId,status:(i=n.detail.step,`PAYMENT_STATUS_${i}`),helpText:n.detail.instructions,returnUrl:t.returnUrl}:{};var i}function Zu(e){return"giftcertificate"!==e.providerId&&"storecredit"!==e.providerId}function Ju(e){const t={};return[...e.lineItems.physicalItems,...e.lineItems.digitalItems].forEach(e=>{var n;t[e.id]=(n=e,["fb","tw","gp"].reduce((e,t)=>{const i=n.socialMedia&&l(n.socialMedia,e=>e.code===t);return i?(e[t]={name:n.name,description:n.name,image:n.imageUrl,url:i.link,shareText:i.text,sharingLink:i.link,channelName:i.channel,channelCode:i.code},e):e},{}))}),t}function Qu(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}}class Xu{constructor(){this._cardExpiryFormatter=new Vu,this._cardNumberFormatter=new Hu}transform(e,t){const n=t.billingAddress.getBillingAddress(),i=t.checkout.getCheckout(),r=t.customer.getCustomer(),o=t.order.getOrder(),a=t.paymentMethods.getPaymentMethod(e.methodId,e.gatewayId),s=this._mapShippingAddress(t,a),d=t.consignments.getConsignments(),c=t.consignments.getShippingOption(),u=t.config.getStoreConfig(),l=t.config.getContextConfig(),h=t.instruments.getInstrumentsMeta(),p=t.paymentMethods.getPaymentMethodsMeta(),g=t.order.getOrderMeta(),m=r&&n&&Gu(r,n),y=h&&e.paymentData&&(Cu(e.paymentData)||function(e){const t=e.formattedPayload;return!!t&&("string"==typeof t.bigpay_token||Boolean(t.bigpay_token&&t.bigpay_token.token))}(e.paymentData))?`${t.payment.getPaymentToken()}, ${h.vaultAccessToken}`:t.payment.getPaymentToken();if(!y)throw new nr(tr.MissingPaymentToken);return{additionalAction:e.additionalAction,authToken:y,customer:m,billingAddress:n&&Nu(n),shippingAddress:s&&Nu(s,d),shippingOption:c&&Qu(c,!0),cart:i&&xu(i),order:o&&Wu(o,g),orderMeta:g,payment:e.paymentData,paymentMethod:a&&this._transformPaymentMethod(a),quoteMeta:{request:Object.assign(Object.assign({},p),{geoCountryCode:l&&l.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:D(u&&u.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}}transformWithHostedFormData(e,t,n){const{additionalAction:i,authToken:r,checkout:o,config:a,order:s,orderMeta:d,payment:c={},paymentMethod:u,paymentMethodMeta:l}=t,h=o&&o.consignments[0],p=h&&h.shippingAddress,g=h&&h.selectedShippingOption;return{additionalAction:i,authToken:r,paymentMethod:u&&this._transformPaymentMethod(u),customer:s&&s.billingAddress&&o&&Gu(o.customer,s.billingAddress),billingAddress:s&&s.billingAddress&&Nu(s.billingAddress),shippingAddress:p&&o&&Nu(p,o.consignments),shippingOption:g&&Qu(g,!0),cart:o&&xu(o),order:s&&Wu(s,d),orderMeta:d,payment:this._transformHostedInputValues(e,c,n),quoteMeta:{request:Object.assign(Object.assign({},l),{geoCountryCode:a&&a.context.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:a&&D(a.storeConfig.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}}_transformPaymentMethod(e){if("multi-option"===e.method&&!e.gateway)return Object.assign(Object.assign({},e),{gateway:e.id});if(e.initializationData&&e.initializationData.gateway)return Object.assign(Object.assign({},e),{id:e.initializationData.gateway});if("worldpayaccess"===e.gateway){if("credit_card"===e.id)return Object.assign(Object.assign({},e),{id:"worldpayaccess",method:"credit-card"});if("open_banking"===e.id)return Object.assign(Object.assign({},e),{id:"worldpayaccess",method:"open_banking"})}return e.id===ju.BRAINTREE_VENMO?Object.assign(Object.assign({},e),{id:ju.BRAINTREE_PAYPAL}):e}_transformHostedInputValues(e,t,n){return"instrumentId"in t?Object.assign(Object.assign({},t),{ccCvv:e.cardCodeVerification,ccNumber:e.cardNumberVerification&&this._cardNumberFormatter.unformat(e.cardNumberVerification),hostedFormNonce:n}):Object.assign(Object.assign({},t),{ccCvv:e.cardCode,ccExpiry:this._cardExpiryFormatter.toObject(e.cardExpiry||""),ccName:e.cardName||"",ccNumber:this._cardNumberFormatter.unformat(e.cardNumber||""),hostedFormNonce:n})}_mapShippingAddress(e,t){var n,i,r,o;if(t){const a=null===(i=null===(n=t.initializationData)||void 0===n?void 0:n.bopis)||void 0===i?void 0:i.enabled,s=null===(o=null===(r=t.initializationData)||void 0===r?void 0:r.bopis)||void 0===o?void 0:o.requiredAddress,d=e.consignments.getConsignments(),c=null==d?void 0:d.every(e=>e.selectedPickupOption);if(a&&c&&"none"===s)return}return e.shippingAddress.getShippingAddress()}}class el{widgetInteraction(e,t){const n={methodId:t&&t.methodId};return V(Z(o(xn.WidgetInteractionStarted,void 0,n)),H(()=>e().then(()=>o(xn.WidgetInteractionFinished,void 0,n)))).pipe(Q(e=>vc(xn.WidgetInteractionFailed,e,n)))}}class tl{updatePaymentProviderCustomer(e){return Z(o(Xn.UpdatePaymentProviderCustomer,e))}}class nl{constructor(e,t){this._remoteCheckoutRequestSender=e,this._checkoutActionCreator=t}initializeBilling(e,t,n){return j.create(i=>{i.next(o(ii.InitializeRemoteBillingRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.initializeBilling(e,t,n).then(({body:t={}})=>{i.next(o(ii.InitializeRemoteBillingSucceeded,t,{methodId:e})),i.complete()}).catch(t=>{i.error(s(ii.InitializeRemoteBillingFailed,t,{methodId:e}))})})}initializeShipping(e,t,n){return j.create(i=>{i.next(o(ii.InitializeRemoteShippingRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.initializeShipping(e,t,n).then(({body:t={}})=>{i.next(o(ii.InitializeRemoteShippingSucceeded,t,{methodId:e})),i.complete()}).catch(t=>{i.error(s(ii.InitializeRemoteShippingFailed,t,{methodId:e}))})})}initializePayment(e,t,n){return j.create(i=>{i.next(o(ii.InitializeRemotePaymentRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.initializePayment(e,t,n).then(({body:t={}})=>{i.next(o(ii.InitializeRemotePaymentSucceeded,t,{methodId:e})),i.complete()}).catch(t=>{i.error(s(ii.InitializeRemotePaymentFailed,t,{methodId:e}))})})}loadSettings(e,t){return j.create(n=>{n.next(o(ii.LoadRemoteSettingsRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.loadSettings(e,t).then(({body:t})=>{n.next(o(ii.LoadRemoteSettingsSucceeded,t,{methodId:e})),n.complete()}).catch(t=>{n.error(s(ii.LoadRemoteSettingsFailed,t,{methodId:e}))})})}signOut(e,t){return j.create(n=>{n.next(o(ii.SignOutRemoteCustomerRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.signOut(e,t).then(()=>{n.next(o(ii.SignOutRemoteCustomerSucceeded,void 0,{methodId:e})),n.complete()}).catch(t=>{n.error(s(ii.SignOutRemoteCustomerFailed,t,{methodId:e}))})})}forgetCheckout(e,t){return V(Z(o(ii.ForgetCheckoutRemoteCustomerRequested,void 0,{methodId:e})),H(()=>{return n=this,i=void 0,a=function*(){return yield this._remoteCheckoutRequestSender.forgetCheckout(t),yield this._checkoutActionCreator.loadCurrentCheckout(),o(ii.ForgetCheckoutRemoteCustomerSucceeded,void 0,{methodId:e})},new((r=void 0)||(r=Promise))(function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function s(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(o,s)}d((a=a.apply(n,i||[])).next())});var n,i,r,a})).pipe(Q(t=>vc(ii.ForgetCheckoutRemoteCustomerFailed,t,{methodId:e})))}updateCheckout(e,t){return o(ii.UpdateRemoteCheckout,t,{methodId:e})}}class il{constructor(e){this._requestSender=e}initializeBilling(e,t,{timeout:n}={}){const i=`/remote-checkout/${e}/billing`;return this._requestSender.get(i,{params:t,timeout:n,headers:yc})}initializeShipping(e,t,{timeout:n}={}){const i=`/remote-checkout/${e}/shipping`;return this._requestSender.get(i,{params:t,timeout:n,headers:yc})}initializePayment(e,t,{timeout:n}={}){const i=`/remote-checkout/${e}/payment`;return this._requestSender.get(i,{params:t,timeout:n,headers:yc})}loadSettings(e,{timeout:t}={}){const n=`/remote-checkout/${e}/settings`;return this._requestSender.get(n,{timeout:t,headers:yc})}signOut(e,{timeout:t}={}){const n=`/remote-checkout/${e}/signout`;return this._requestSender.get(n,{timeout:t,headers:yc})}generateToken({timeout:e}={}){return this._requestSender.get("/remote-checkout-token",{timeout:e,headers:yc})}trackAuthorizationEvent({timeout:e}={}){return this._requestSender.post("/remote-checkout/events/shopper-checkout-service-provider-authorization-requested",{timeout:e,headers:yc})}forgetCheckout({timeout:e}={}){return this._requestSender.post("/remote-checkout/forget-checkout",{timeout:e,headers:yc})}}class rl{constructor(e,t){this._consignmentRequestSender=e,this._checkoutRequestSender=t}unassignItemsByAddress(e,t){return n=>{const i=n.getState();if(!i.checkout.getCheckout())throw new nr(tr.MissingCheckout);const r=this._consignmentHasAddress(e)?e.address:e.shippingAddress,o=i.consignments.getConsignmentByAddress(r);if(!o)throw new $c("No consignment found for the specified address");const a=this._removeLineItems(e.lineItems,o,i.cart.getCart());return a.length?this.updateConsignment({id:o.id,address:r,lineItems:a},t)(n):this.deleteConsignment(o.id,t)(n)}}assignItemsByAddress(e,t){return n=>{const i=n.getState(),r=this._consignmentHasAddress(e)?e.address:e.shippingAddress,o=i.consignments.getConsignmentByAddress(r);return this._createOrUpdateConsignment({id:o&&o.id,address:r,lineItems:this._addLineItems(e.lineItems,o,i.cart.getCart())},t)(n)}}selectShippingOption(e,t){return n=>j.create(i=>{const r=n.getState(),a=r.checkout.getCheckout(),d=r.consignments.getConsignments();if(!a)throw new nr(tr.MissingCheckout);if(!d||!d.length)throw new nr(tr.MissingConsignments);const c={id:d[0].id,shippingOptionId:e},u={id:d[0].id};i.next(o(ot.UpdateShippingOptionRequested,void 0,u)),this._consignmentRequestSender.updateConsignment(a.id,c,t).then(({body:e})=>{i.next(o(ot.UpdateShippingOptionSucceeded,e,u)),i.complete()}).catch(e=>{i.error(s(ot.UpdateShippingOptionFailed,e,u))})})}loadShippingOptions(e){return t=>j.create(n=>{const i=t.getState().checkout.getCheckout();if(!i)throw new nr(tr.MissingCheckout);n.next(o(ot.LoadShippingOptionsRequested)),this._checkoutRequestSender.loadCheckout(i.id,Object.assign(Object.assign({},e),{params:{include:[zc.AvailableShippingOptions]}})).then(({body:e})=>{n.next(o(ot.LoadShippingOptionsSucceeded,e)),n.complete()}).catch(e=>{n.error(s(ot.LoadShippingOptionsFailed,e))})})}updateAddress(e,t){return n=>{const i=this._getUpdateAddressRequestBody(e,n),r=n.getState().consignments.getConsignments();return r&&r.length&&(i.id=r[0].id),this._createOrUpdateConsignment(i,t)(n)}}createConsignments(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout();if(!r||!r.id)throw new nr(tr.MissingCheckout);i.next(o(ot.CreateConsignmentsRequested)),this._consignmentRequestSender.createConsignments(r.id,e,t).then(({body:e})=>{i.next(o(ot.CreateConsignmentsSucceeded,e)),i.complete()}).catch(e=>{i.error(s(ot.CreateConsignmentsFailed,e))})})}updateConsignment(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout();if(!r||!r.id)throw new nr(tr.MissingCheckout);const a={id:e.id};i.next(o(ot.UpdateConsignmentRequested,void 0,a)),this._consignmentRequestSender.updateConsignment(r.id,e,t).then(({body:e})=>{i.next(o(ot.UpdateConsignmentSucceeded,e,a)),i.complete()}).catch(e=>{i.error(s(ot.UpdateConsignmentFailed,e,a))})})}deleteConsignment(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout(),a={id:e};if(!r||!r.id)throw new nr(tr.MissingCheckout);i.next(o(ot.DeleteConsignmentRequested,void 0,a)),this._consignmentRequestSender.deleteConsignment(r.id,e,t).then(({body:e})=>{i.next(o(ot.DeleteConsignmentSucceeded,e,a)),i.complete()}).catch(e=>{i.error(s(ot.DeleteConsignmentFailed,e,a))})})}updateShippingOption(e,t){return n=>j.create(i=>{var r;const a=n.getState().checkout.getCheckout(),d=n.getState().consignments.getConsignmentById(e.id);if((null===(r=null==d?void 0:d.selectedShippingOption)||void 0===r?void 0:r.id)===e.shippingOptionId)return void i.complete();if(!a||!a.id)throw new nr(tr.MissingCheckout);const c={id:e.id};i.next(o(ot.UpdateShippingOptionRequested,void 0,c)),this._consignmentRequestSender.updateConsignment(a.id,e,t).then(({body:e})=>{i.next(o(ot.UpdateShippingOptionSucceeded,e,c)),i.complete()}).catch(e=>{i.error(s(ot.UpdateShippingOptionFailed,e,c))})})}_createOrUpdateConsignment(e,t){return n=>{const i=n.getState().checkout.getCheckout();if(!i||!i.id)throw new nr(tr.MissingCheckout);return this._isUpdateConsignmentRequest(e)?this.updateConsignment(e,t)(n):this.createConsignments([e],t)(n)}}_getUpdateAddressRequestBody(e,t){const n=t.getState().cart.getCart();if(!n)throw new nr(tr.MissingCart);const{physicalItems:i,customItems:r=[]}=n.lineItems;return{address:e,lineItems:[...i,...r].map(e=>({itemId:e.id,quantity:e.quantity}))}}_removeLineItems(e,t,n){if(!n)throw new nr(tr.MissingCart);return this._hydrateLineItems(t.lineItemIds,n).map(t=>{const n=l(e,e=>e.itemId===t.itemId);return Object.assign(Object.assign({},t),{quantity:n?t.quantity-n.quantity:t.quantity})}).filter(e=>e.quantity>0)}_addLineItems(e,t,n){if(!t)return e;if(!n)throw new nr(tr.MissingCart);return e.concat(this._hydrateLineItems(t.lineItemIds,n)).filter(e=>e.quantity>0)}_hydrateLineItems(e,t){return e.map(e=>{const n=l(t.lineItems.physicalItems,t=>t.id===e);return{itemId:e,quantity:n?n.quantity:0}})}_isUpdateConsignmentRequest(e){return!!e.id}_consignmentHasAddress(e){return"object"==typeof e&&"address"in e}}const ol=["consignments.availableShippingOptions","cart.lineItems.physicalItems.options","cart.lineItems.physicalItems.stockPosition","cart.lineItems.digitalItems.options","cart.lineItems.digitalItems.stockPosition","customer","promotions.banners"];class al{constructor(e){this._requestSender=e}createConsignments(e,t,{timeout:n,params:{include:i}={}}={}){const r=`/api/storefront/checkouts/${e}/consignments`,o=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.post(r,{body:t,params:{include:Tc(ol,i)},headers:o,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}updateConsignment(e,t,{timeout:n,params:{include:i}={}}={}){const{id:r}=t,o=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["id"]),a=`/api/storefront/checkouts/${e}/consignments/${r}`,s=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.put(a,{body:o,params:{include:Tc(ol,i)},headers:s,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}deleteConsignment(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/consignments/${t}`,r=Object.assign({Accept:gc.JsonV1},yc),o=Ac(ol);return this._requestSender.delete(i,{params:{include:o},headers:r,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}}class sl{constructor(e,t){this._shippingCountryRequestSender=e,this._store=t}loadCountries(e){const{checkout:t}=this._store.getState(),n=t.getCheckout(),i=n?n.channelId:null;return j.create(t=>{t.next(o(vi.LoadShippingCountriesRequested)),this._shippingCountryRequestSender.loadCountries(i,e).then(e=>{t.next(o(vi.LoadShippingCountriesSucceeded,e.body.data)),t.complete()}).catch(e=>{t.error(s(vi.LoadShippingCountriesFailed,e))})})}}class dl{constructor(e,t){this._requestSender=e,this._config=t}loadCountries(e,{timeout:t}={}){const n="/internalapi/v1/shipping/countries"+(e?`?channel_id=${e}`:""),i=Object.assign({"Accept-Language":this._config.locale},yc);return this._requestSender.get(n,{headers:i,timeout:t})}}var cl=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ul{constructor(e,t){this._googleRecaptcha=e,this._requestSender=t}initialize(e){return t=>V(Z(o(Yi.InitializeRequested,void 0)),H(()=>cl(this,void 0,void 0,function*(){const n=e?e.containerId:"spamProtectionContainer";if(document.getElementById(n)&&this._googleRecaptcha.reset(n),!e&&!document.getElementById(n)){const e=document.createElement("div");e.setAttribute("id",n),document.body.appendChild(e)}const i=t.getState().config.getStoreConfigOrThrow().checkoutSettings.googleRecaptchaSitekey;return yield this._googleRecaptcha.load(n,i),o(Yi.InitializeSucceeded)}))).pipe(Q(e=>vc(Yi.InitializeFailed,e)))}verifyCheckoutSpamProtection(){return e=>H(()=>{const t=e.getState().checkout.getCheckout();if(!t)throw new nr(tr.MissingCheckout);return V(Z(o(Yi.VerifyCheckoutRequested)),Y(this.execute()(e)).pipe(re(e=>qc(e)&&e.payload?Y(this._requestSender.validate(t.id,e.payload.token)).pipe(re(({body:t})=>V(Z(e),Z(o(Yi.VerifyCheckoutSucceeded,t))))):Z(e)))).pipe(Q(e=>vc(Yi.VerifyCheckoutFailed,e)))})}execute(){return e=>V(Z(o(Yi.ExecuteRequested)),this.initialize()(e),this._googleRecaptcha.execute().pipe(oe(1)).pipe(re(e=>cl(this,[e],void 0,function*({error:e,token:t}){if(e instanceof eu)throw e;if(e||!t)throw new cu;return o(Yi.ExecuteSucceeded,{token:t})})))).pipe(Q(e=>vc(Yi.ExecuteFailed,e)))}}class ll{constructor(e){this._requestSender=e}validate(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/spam-protection`,r=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.post(i,{body:{token:t},headers:r,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}}class hl{constructor(e){this._storeCreditRequestSender=e}applyStoreCredit(e,t){return n=>V(Z(o(Fi.ApplyStoreCreditRequested)),H(()=>{return i=this,r=void 0,s=function*(){var i;const r=n.getState().checkout.getCheckout();if(!r)throw new nr(tr.MissingCheckout);const{id:a}=r,s=null!==(i=null==t?void 0:t.version)&&void 0!==i?i:r.version,{body:d}=yield e?this._storeCreditRequestSender.applyStoreCredit(a,Object.assign(Object.assign({},t),{version:s})):this._storeCreditRequestSender.removeStoreCredit(a,Object.assign(Object.assign({},t),{version:s}));return o(Fi.ApplyStoreCreditSucceeded,d)},new((a=void 0)||(a=Promise))(function(e,t){function n(e){try{d(s.next(e))}catch(e){t(e)}}function o(e){try{d(s.throw(e))}catch(e){t(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a(function(e){e(i)})).then(n,o)}d((s=s.apply(i,r||[])).next())});var i,r,a,s})).pipe(Q(e=>vc(Fi.ApplyStoreCreditFailed,e)))}}class pl{constructor(e){this._requestSender=e}applyStoreCredit(e,{timeout:t,version:n}={}){const i=`/api/storefront/checkouts/${e}/store-credit`,r=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.post(i,{headers:r,timeout:t,params:{include:Ac(kc)},body:{version:n}})}removeStoreCredit(e,{timeout:t,version:n}={}){const i=`/api/storefront/checkouts/${e}/store-credit`,r=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.delete(i,{headers:r,timeout:t,params:{include:Ac(kc)},body:{version:n}})}}class gl extends Pe{constructor(e){super(e),this.name="UpdateSubscriptionsError",this.type="update_subscriptions"}}class ml{constructor(e){this._subscriptionsRequestSender=e}updateSubscriptions(e,t){return V(Z(o(We.UpdateSubscriptionsRequested)),H(()=>{return n=this,i=void 0,a=function*(){const{body:n}=yield this._subscriptionsRequestSender.updateSubscriptions(e,t);return o(We.UpdateSubscriptionsSucceeded,n)},new((r=void 0)||(r=Promise))(function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function s(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(o,s)}d((a=a.apply(n,i||[])).next())});var n,i,r,a})).pipe(Q(e=>vc(We.UpdateSubscriptionsFailed,new gl(e))))}}class yl{constructor(e){this._requestSender=e}updateSubscriptions(e,{timeout:t}={}){const n=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.post("/api/storefront/subscriptions",{body:e,headers:n,timeout:t})}}const fl=A(e=>Array.isArray(e)?e.map(e=>_l(e)):et(e)?Object.keys(e).reduce((t,n)=>Object.assign(Object.assign({},t),{[n]:_l(e[n])}),{}):e);fl.cache=new WeakMap;const _l=e=>"object"==typeof e&&null!==e?fl(e):e;function Sl(e){return(...t)=>_l(e(...t))}function vl({billingAddress:{getBillingAddress:e,getBillingAddressOrThrow:t},cart:{getCart:n,getCartOrThrow:i,getLocale:r},checkout:{getCheckout:o,getCheckoutOrThrow:a,getOutstandingBalance:s},config:{getContextConfig:d,getHost:c,getLocale:u,getStoreConfig:l,getStoreConfigOrThrow:h,getConfig:p},consignments:{getConsignments:g,getConsignmentsOrThrow:m},countries:{getCountries:y},customer:{getCustomer:f,getCustomerOrThrow:_},instruments:{getCardInstrument:S,getCardInstrumentOrThrow:v,getInstruments:C,getInstrumentsMeta:I},order:{getOrder:w,getOrderOrThrow:E,getOrderMeta:b},payment:{getPaymentToken:P,getPaymentTokenOrThrow:O,getPaymentId:A,getPaymentIdOrThrow:T,getPaymentStatus:k,getPaymentStatusOrThrow:R,getPaymentRedirectUrl:D,getPaymentRedirectUrlOrThrow:M,isPaymentDataRequired:N},paymentMethods:{getPaymentMethod:L,getPaymentMethodOrThrow:z,getPaymentMethodsMeta:U},paymentProviderCustomer:{getPaymentProviderCustomer:F,getPaymentProviderCustomerOrThrow:B},paymentStrategies:{isInitialized:x},shippingAddress:{getShippingAddress:q,getShippingAddressOrThrow:j,getShippingAddresses:G,getShippingAddressesOrThrow:V},shippingCountries:{getShippingCountries:H}}){return{getHost:Sl(c),getLocale:Sl(u),getCartLocale:Sl(r),getBillingAddress:Sl(e),getBillingAddressOrThrow:Sl(t),getCart:Sl(n),getCartOrThrow:Sl(i),getCheckout:Sl(o),getCheckoutOrThrow:Sl(a),getCountries:Sl(y),getStoreConfig:Sl(l),getStoreConfigOrThrow:Sl(h),getConfig:Sl(p),getConsignments:Sl(g),getConsignmentsOrThrow:Sl(m),getContextConfig:Sl(d),getCustomer:Sl(f),getCustomerOrThrow:Sl(_),getCardInstrument:Sl(S),getInstruments:Sl(C),getCardInstrumentOrThrow:Sl(v),getOrder:Sl(w),getOrderOrThrow:Sl(E),getOrderMeta:Sl(b),getInstrumentsMeta:Sl(I),getPaymentToken:P,getPaymentTokenOrThrow:O,getPaymentId:A,getPaymentIdOrThrow:T,getPaymentStatus:k,getPaymentStatusOrThrow:R,getPaymentRedirectUrl:D,getPaymentRedirectUrlOrThrow:M,getPaymentMethod:Sl(L),getPaymentMethodOrThrow:Sl(z),getPaymentMethodsMeta:Sl(U),getPaymentProviderCustomer:Sl(F),getPaymentProviderCustomerOrThrow:Sl(B),getShippingAddress:Sl(q),getShippingAddressOrThrow:Sl(j),getShippingAddresses:Sl(G),getShippingAddressesOrThrow:Sl(V),getShippingCountries:Sl(H),getOutstandingBalance:Sl(s),isPaymentDataRequired:N,isPaymentMethodInitialized:x}}var Cl,Il=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class wl{constructor(e,t,n,i,r,o,a,s,d,c,u,l,h,p,g,m,y,f,_,S){this._store=e,this._storeProjectionFactory=t,this._checkoutActionCreator=n,this._checkoutValidator=i,this._hostedFormFactory=r,this._orderActionCreator=o,this._billingAddressActionCreator=a,this._consignmentActionCreator=s,this._paymentMethodActionCreator=d,this._paymentActionCreator=c,this._paymentHumanVerificationHandler=u,this._customerActionCreator=l,this._cartRequestSender=h,this._storeCreditActionCreator=p,this._couponActionCreator=g,this._spamProtectionActionCreator=m,this._paymentProviderCustomerActionCreator=y,this._shippingCountryActionCreator=f,this._remoteCheckoutActionCreator=_,this._paymentStrategyWidgetActionCreator=S,this._storeProjection=this._storeProjectionFactory.create(this._store)}createHostedForm(e,t){const n=this._storeProjection.getState().getCheckoutOrThrow().id;return this._hostedFormFactory.create(e,t,n)}subscribe(e,...t){return this._storeProjection.subscribe(e,...t)}getState(){return this._storeProjection.getState()}initializeOffsitePayment(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentActionCreator.initializeOffsitePayment(e)),this._storeProjection.getState()})}loadCheckout(e){return Il(this,void 0,void 0,function*(){return e?yield this._store.dispatch(this._checkoutActionCreator.loadCheckout(e)):yield this._store.dispatch(this._checkoutActionCreator.loadCurrentCheckout()),this._storeProjection.getState()})}loadDefaultCheckout(){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout()),this._storeProjection.getState()})}loadPaymentMethod(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(e,t)),this._storeProjection.getState()})}loadPaymentMethods(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethods(e)),this._storeProjection.getState()})}submitOrder(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._orderActionCreator.submitOrder(e,t)),this._storeProjection.getState()})}submitPayment(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentActionCreator.submitPayment(e)),this._storeProjection.getState()})}finalizeOrder(e){return Il(this,void 0,void 0,function*(){const{order:{getOrderOrThrow:t}}=this._store.getState();return yield this._store.dispatch(this._orderActionCreator.finalizeOrder(t().orderId,e)),this._storeProjection.getState()})}updateBillingAddress(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._billingAddressActionCreator.updateAddress(e)),this._storeProjection.getState()})}updateShippingAddress(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._consignmentActionCreator.updateAddress(e)),this._storeProjection.getState()})}selectShippingOption(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._consignmentActionCreator.selectShippingOption(e,t)),this._storeProjection.getState()})}signInCustomer(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._customerActionCreator.signInCustomer(e,t)),this._storeProjection.getState()})}signOutCustomer(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._customerActionCreator.signOutCustomer(e)),this._storeProjection.getState()})}createBuyNowCart(e,t){return Il(this,void 0,void 0,function*(){const{body:n}=yield this._cartRequestSender.createBuyNowCart(e,t);return n})}applyStoreCredit(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._storeCreditActionCreator.applyStoreCredit(e,t)),this._storeProjection.getState()})}applyCoupon(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._couponActionCreator.applyCoupon(e,t)),this._storeProjection.getState()})}removeCoupon(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._couponActionCreator.removeCoupon(e,t)),this._storeProjection.getState()})}verifyCheckoutSpamProtection(){return Il(this,void 0,void 0,function*(){const{checkout:e}=this._store.getState(),{shouldExecuteSpamCheck:t}=e.getCheckoutOrThrow();return t&&(yield this._store.dispatch(this._spamProtectionActionCreator.verifyCheckoutSpamProtection())),this._storeProjection.getState()})}loadCurrentOrder(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._orderActionCreator.loadCurrentOrder(e)),this._storeProjection.getState()})}updatePaymentProviderCustomer(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentProviderCustomerActionCreator.updatePaymentProviderCustomer(e)),this._storeProjection.getState()})}loadShippingCountries(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._shippingCountryActionCreator.loadCountries(e)),this._storeProjection.getState()})}deleteConsignment(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._consignmentActionCreator.deleteConsignment(e,t)),this._storeProjection.getState()})}initializePayment(e,t,n){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._remoteCheckoutActionCreator.initializePayment(e,t,n)),this._storeProjection.getState()})}forgetCheckout(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._remoteCheckoutActionCreator.forgetCheckout(e,t)),this._storeProjection.getState()})}remoteCheckoutSignOut(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._remoteCheckoutActionCreator.signOut(e,t)),this._storeProjection.getState()})}validateCheckout(e,t){return Il(this,void 0,void 0,function*(){yield this._checkoutValidator.validate(e,t)})}handlePaymentHumanVerification(e,t){return Il(this,void 0,void 0,function*(){return"string"==typeof e?this._paymentHumanVerificationHandler.handle(e,null!=t?t:""):this._paymentHumanVerificationHandler.handle(e)})}widgetInteraction(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentStrategyWidgetActionCreator.widgetInteraction(e),{queueId:"widgetInteraction"}),this._storeProjection.getState()})}}!function(e){e.Synchronize="SYNCHRONIZE"}(Cl||(Cl={}));class El{constructor(e){this._transformSelectors=e}create(e){return function(e,t){const n=a((e,t)=>t.type===Cl.Synchronize?t.payload:e,e.getState(),{stateTransformer:t});return e.subscribe(e=>{n.dispatch(o(Cl.Synchronize,e))},{initial:!1}),n}(e,this._transformSelectors)}}const bl=e=>{const t=B(e);return document.getElementById(t)?bl(e):t};function Pl(e){return Object.prototype.hasOwnProperty.call(e,"cacheKey")}class Ol{constructor(e){this._lastId=0,this._map={maps:[]},this._usedMaps=[],this._options=Object.assign({maxSize:0,isEqual:fe,onExpire:T},e)}getKey(...e){const t=this._resolveMap(...e),{index:n,parentMap:i}=t;let{map:r}=t;return r&&r.cacheKey?r.usedCount++:r=this._generateMap(i,e.slice(n)),this._removeLeastUsedMap(r),r.cacheKey}getUsedCount(...e){const{map:t}=this._resolveMap(...e);return t?t.usedCount:0}_resolveMap(...e){let t=0,n=this._map;for(;n.maps.length;){let i=!1;for(let r=0;r<n.maps.length;r++){const o=n.maps[r];if(this._options.isEqual(o.value,e[t])){if(n.maps.unshift(...n.maps.splice(r,1)),(0===e.length||t===e.length-1)&&Pl(o))return{index:t,map:o,parentMap:n};i=!0,n=o,t++;break}}if(!i)break}return{index:t,parentMap:n}}_generateMap(e,t){let n,i=0,r=e;do{n={maps:[],parentMap:r,usedCount:1,value:t[i]},r.maps.unshift(n),r=n,i++}while(i<t.length);const o=n;return o.cacheKey=""+ ++this._lastId,o}_removeLeastUsedMap(e){if(!this._options.maxSize)return;const t=this._usedMaps.indexOf(e);if(this._usedMaps.splice(-1===t?0:t,-1===t?0:1,e),this._usedMaps.length<=this._options.maxSize)return;const n=this._usedMaps.pop();n&&(this._removeMap(n),this._options.onExpire(n.cacheKey))}_removeMap(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))}}function Al(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&"constructor"!==n&&Object.defineProperty(t.prototype,n,function(e,t,n){if("function"!=typeof n.value)return n;let i=new Ol,r=n.value,o=ae(r);return ka(e,t,{get(){const e=(...e)=>{const t=o.call(this,...e);if(1===i.getUsedCount(...e))return t;const n=r.call(this,...e);return Ue(n,t,{keyFilter:e=>!function(e){return 0===`${e}`.indexOf("$$")||0===`${e}`.indexOf("_")}(e)})?t:(o.cache.set(i.getKey(...e),n),n)};return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e},set(e){i=new Ol,r=e,o=ae(r)}})}(e.prototype,n,i))}),t}let Tl=class{constructor(e){this._checkoutButton=e.checkoutButton}getInitializeButtonError(e){return this._checkoutButton.getInitializeError(e)}getDeinitializeButtonError(e){return this._checkoutButton.getDeinitializeError(e)}};Tl=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([Al],Tl);const kl=Tl;let Rl=class{constructor(e){this._checkoutButton=e.checkoutButton}isInitializingButton(e){return this._checkoutButton.isInitializing(e)}isDeinitializingButton(e){return this._checkoutButton.isDeinitializing(e)}};Rl=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([Al],Rl);const Dl=Rl;function Ml(e){return{errors:new kl(e),statuses:new Dl(e)}}let Nl=class{constructor(e,t){this._store=e,this._buttonStrategyActionCreator=t,this._state=Ml(this._store.getState()),this._store.subscribe(e=>{this._state=Ml(e)})}getState(){return this._state}subscribe(e,...t){return this._store.subscribe(()=>e(this.getState()),e=>e.checkoutButton.getState(),...t.map(e=>t=>e(Ml(t))))}initializeButton(e){const t=(n=e.containerId,/^\w[\w\-\:\.]*$/.test(n)?[e.containerId]:function(e,t){const n=document.querySelectorAll(e);if(!n.length)throw new $c(`Unable to find any element with the specified selector: ${e}`);return Array.prototype.slice.call(n).map(e=>(e.id||(e.id=bl(t)),e.id))}(e.containerId,`${e.methodId}-container`));var n;return Promise.all(t.map(t=>{const n=this._buttonStrategyActionCreator.initialize(Object.assign(Object.assign({},e),{containerId:t})),i=`checkoutButtonStrategy:${e.methodId}:${t}`;return this._store.dispatch(n,{queueId:i})})).then(()=>this.getState())}deinitializeButton(e){const t=this._buttonStrategyActionCreator.deinitialize(e),n=`checkoutButtonStrategy:${e.methodId}`;return this._store.dispatch(t,{queueId:n}).then(()=>this.getState())}};Nl=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([ka],Nl);const Ll=Nl;class zl{constructor(e,t,n){this._registry=e,this._registryV2=t,this._paymentMethodActionCreator=n}initialize(e){return t=>{const n={methodId:e.methodId,containerId:e.containerId};if(t.getState().checkoutButton.isInitialized(e.methodId,e.containerId))return W();const i=e.currencyCode?{params:{currencyCode:e.currencyCode}}:{},r=Object.assign(Object.assign({},i),{timeout:e.timeout,useCache:!0});return V(Z(o(lt.InitializeButtonRequested,void 0,n)),this._paymentMethodActionCreator.loadPaymentMethod(e.methodId,r)(t),H(()=>this._getStrategy(e.methodId).initialize(e).then(()=>o(lt.InitializeButtonSucceeded,void 0,n)))).pipe(Q(e=>vc(lt.InitializeButtonFailed,e,n)))}}deinitialize(e){return t=>{const n={methodId:e.methodId};return t.getState().checkoutButton.isInitialized(e.methodId)?V(Z(o(lt.DeinitializeButtonRequested,void 0,n)),H(()=>this._getStrategy(e.methodId).deinitialize().then(()=>o(lt.DeinitializeButtonSucceeded,void 0,n)))).pipe(Q(e=>vc(lt.DeinitializeButtonFailed,e,n))):W()}}_getStrategy(e){let t;try{t=this._registryV2.get({id:e})}catch(n){t=this._registry.get(e)}return t}}class Ul{constructor(e){var t,n,i;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!==(i=null==e?void 0:e.tokenResolver)&&void 0!==i?i:e=>e}get(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)}}getFactory(e,t){const n=this._tokenResolver(e,Object.keys(this._factories),t);return n?this._factories[n]:void 0}register(e,t){if(this._hasFactory(e))throw new $c(`'${e}' is already registered.`);this._factories[e]=t}_hasFactory(e){return!!this._factories[e]}_hasInstance(e){return!!this._instances[e]}_getInstance(e,t){if(!this._hasInstance(t)){const n=this.getFactory(e);if(!n)throw new $c(`'${e}' is not registered.`);this._instances[t]=n()}return this._instances[t]}}class Fl extends Ee{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}var Bl,xl,ql,jl,Gl;class Vl{constructor(e){this._scriptLoader=e,this._window=window}loadPaypal(){return e=this,t=arguments,i=function*(e=""){const t="//www.paypalobjects.com/api/checkout.min.js",n={async:!0,attributes:{"data-merchant-id":e}};if(e?yield this._scriptLoader.loadScript(t,n):yield this._scriptLoader.loadScript(t),!this._window.paypal)throw new Fl;return this._window.paypal},new((n=void 0)||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())});var e,t,n,i}}!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(Bl||(Bl={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(xl||(xl={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white"}(ql||(ql={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(jl||(jl={})),function(e){e.PILL="pill",e.RECT="rect"}(Gl||(Gl={}));class Hl{constructor(e,t,n,i,r=""){this._store=e,this._checkoutActionCreator=t,this._paypalScriptLoader=n,this._formPoster=i,this._host=r}initialize(e){const t=e.paypal,n=this._store.getState(),i=this._paymentMethod=n.paymentMethods.getPaymentMethod(e.methodId);if(!t)throw new $c;if(!i)throw new nr(tr.MissingPaymentMethod);return this._paypalScriptLoader.loadPaypal(i.config.merchantId).then(n=>{var r,o;if(!i||!i.config.merchantId)throw new nr(tr.MissingPaymentMethod);const a=i.config.merchantId,s=i.config.testMode?"sandbox":"production",d={[s]:t.clientId},c=n.FUNDING.CREDIT||"credit",u=t.allowCredit?[c]:[],l=t.allowCredit?[]:[c];return n.Button.render({env:s,client:d,commit:t.shouldProcessPayment,funding:{allowed:u,disallowed:l},style:Object.assign(Object.assign({shape:Gl.RECT},D(t.style,"layout","color","label","shape","tagline","fundingicons")),{size:"paypalexpress"===i.id&&"small"===(null===(r=t.style)||void 0===r?void 0:r.size)?xl.RESPONSIVE:null===(o=t.style)||void 0===o?void 0:o.size}),payment:(e,n)=>this._setupPayment(a,n,t.onPaymentError),onAuthorize:(e,n)=>this._tokenizePayment(e,n,t.shouldProcessPayment,t.onAuthorizeError)},e.containerId)})}deinitialize(){return this._paymentMethod=void 0,Promise.resolve()}_setupPayment(e,t,n){if(!t)throw new du(iu.CheckoutButtonNotInitialized);return this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout()).then(n=>{const i=n.cart.getCart(),r=i?i.id:"";return t.request.post(`${this._host}/api/storefront/payment/paypalexpress`,{merchantId:e,cartId:r},{headers:Object.assign({"X-API-INTERNAL":mc},yc)})}).then(e=>e.id).catch(e=>{throw n&&n(e),e})}_tokenizePayment(e,t,n,i){if(!this._paymentMethod)throw new du(iu.CheckoutButtonNotInitialized);if(!t)throw new du(iu.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new nr(tr.MissingPayment);const r=this._paymentMethod.id;return t.payment.get(e.paymentID).then(t=>{this._formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:r,action:n?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(t.payer.payer_info)})})}}function Wl(e){return e&&"resolveIds"in e}function Yl(){try{return"production"}catch(e){return"development"}}class Kl{constructor(e){this._console=e}log(...e){this._logToConsole("log",...e)}info(...e){this._logToConsole("info",...e)}warn(...e){this._logToConsole("warn",...e)}error(...e){this._logToConsole("error",...e)}debug(...e){this._logToConsole("debug",...e)}_logToConsole(e,...t){this._console&&this._console[e]&&this._console[e].call(this._console,...t)}}class $l{log(){}info(){}warn(){}error(){}debug(){}}const Zl=function(e=!0){return e?new Kl(console):new $l}("test"!==Yl());class Jl{constructor(e=!1){this._useFallback=e,this._registry=new Ul({tokenResolver:this._resolveToken.bind(this),defaultToken:this._encodeToken({default:!0}),useFallback:this._useFallback})}get(e){return this._registry.get(this._encodeToken(e))}getFactory(e,t){try{return this._registry.getFactory(this._encodeToken(e),t)}catch(e){return}}getUseFallback(){return this._useFallback}register(e,t){this._registry.register(this._encodeToken(e),t)}_encodeToken(e){return btoa(JSON.stringify(e))}_decodeToken(e){return JSON.parse(atob(e))}_resolveToken(e,t,n){var i;const r=this._decodeToken(e),o=[];t.forEach(e=>{const t=this._decodeToken(e),n={token:e,matches:0,default:!1,totalKeys:Object.keys(t).length};for(const[e,i]of Object.entries(t)){if(e in r&&r[e]!==i){n.matches=0;break}e in r&&r[e]===i&&n.matches++,"default"===e&&!0===i&&(n.default=!0)}o.push(n)});const a=o.sort((e,t)=>t.matches-e.matches).filter(e=>e.matches>0);a.length>1&&a[0].matches===a[1].matches&&"development"===Yl()&&Zl.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.");const s=Object.keys(r).length;if(n){const e=a.find(e=>e.matches===s&&e.matches===e.totalKeys);if(!e)throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(r)} with exact match.`);return e.token}const d=a[0];if(d&&d.token)return d.token;if(this._useFallback){const e=null===(i=o.find(e=>e.default))||void 0===i?void 0:i.token;if(e)return e}throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(r)}.`)}}function Ql(t){const{host:i}=null!=t?t:{},r=lr({config:{meta:{host:null==t?void 0:t.host,locale:null==t?void 0:t.locale},errors:{},statuses:{}}}),o=e({host:i}),a=n({host:i}),s=function(e,t){const n=new Jl;for(const[,i]of Object.entries(t))if(Wl(i))for(const t of i.resolveIds)n.register(t,()=>i(e));return n}(function(t,n){const{config:{getHost:i,getLocale:r}}=t.getState();n||(n=e({host:i()}));const o=new El(vl),a=new Oc(new Dc(n),new Uc(new Fc(n)),new Vc(new Hc(n))),s=new Lc(new Dc(n)),d=new wu(t),c=new bu(new Ru(n),new Lc(new Dc(n))),u=new Ic(new bc(n),new ml(new yl(n))),l=new rl(new al(n),new Dc(n)),h=new hc(new fc(n),new Sc(n)),p=new Du(new Mu(function(e){const t=ge();return e.subscribe(e=>{const n=e.config.getStoreConfig();n&&t.setHost(n.paymentSettings.bigpayBaseUrl)},e=>e.config.getStoreConfig()),t}(t)),c,new Xu,new su(pu(ue()))),g=new su(pu(ue())),m=new jc(new Gc(n),a,new ul(pu(ue()),new ll(n))),y=new hl(new pl(n)),f=new Bc(new xc(n)),_=pu(ue()),S=new ll(n),v=new ul(_,S),C=new Pc(n),I=new tl,w=new sl(new dl(n,{locale:r()}),t),E=new nl(new il(n),a),b=new el;return new wl(t,o,a,s,d,c,u,l,h,p,g,m,C,y,f,v,I,w,E,b)}(r),Se);return new Ll(r,new zl(function(e,t,n,i){const r=new Ul,o=le(),a=new Dc(t),s=new Oc(a,new Uc(new Fc(t)),new Vc(new Hc(t)));return r.register(ju.PAYPALEXPRESS,()=>new Hl(e,s,new Vl(o),n,i)),r}(r,o,a,i),s,new hc(new fc(o),new Sc(o))))}export{Ql as createCheckoutButtonInitializer,t as createTimeout};
1
+ import{createRequestSender as e,createTimeout as t}from"@bigcommerce/request-sender";import{createFormPoster as n}from"@bigcommerce/form-poster";import{combineReducers as i,composeReducers as r,createAction as o,createDataStore as a,createErrorAction as s,deepFreeze as d}from"@bigcommerce/data-store";import{difference as c,filter as u,find as l,findIndex as h,flatMap as p,identity as g,includes as m,isArray as y,isEmpty as f,isEqual as _,isMatch as S,isNil as v,isObject as C,isPlainObject as I,keyBy as w,keys as E,last as b,map as P,max as O,memoize as A,noop as T,omit as k,omitBy as R,pick as D,pickBy as M,reduce as N,round as L,some as z,transform as U,uniq as F,uniqueId as B,values as x,without as q}from"lodash";import{Observable as j,Subject as G,concat as V,defer as H,empty as W,from as Y,fromEvent as K,merge as $,of as Z,throwError as J}from"rxjs";import{catchError as Q,delay as X,filter as ee,map as te,retryWhen as ne,shareReplay as ie,switchMap as re,take as oe}from"rxjs/operators";import{memoize as ae,memoizeOne as se}from"@bigcommerce/memoize";import{createSelector as de}from"reselect";import{ScriptLoader as ce,createScriptLoader as ue,getScriptLoader as le}from"@bigcommerce/script-loader";import{stringifyUrl as he}from"query-string";import{supportsPopups as pe}from"@braintree/browser-detection";import{createClient as ge}from"@bigcommerce/bigpay-client";import{creditCardType as me,number as ye}from"card-validator";import{default as fe}from"shallowequal";var _e={d:(e,t)=>{for(var n in t)_e.o(t,n)&&!_e.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},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})}},Se={};_e.r(Se),_e.d(Se,{createAmazonPayV2ButtonStrategy:()=>xr,createApplePayButtonStrategy:()=>So,createBigCommercePaymentsButtonStrategy:()=>Uo,createBigCommercePaymentsPayLaterButtonStrategy:()=>xo,createBigCommercePaymentsVenmoButtonStrategy:()=>Go,createBoltButtonStrategy:()=>Jo,createBraintreePaypalButtonStrategy:()=>ma,createBraintreePaypalCreditButtonStrategy:()=>_a,createBraintreeVenmoButtonStrategy:()=>Oa,createBraintreeVisaCheckoutButtonStrategy:()=>Ca,createGooglePayAdyenV2ButtonStrategy:()=>fs,createGooglePayAdyenV3ButtonStrategy:()=>_s,createGooglePayAuthorizeDotNetButtonStrategy:()=>vs,createGooglePayBigCommercePaymentsButtonStrategy:()=>ys,createGooglePayBraintreeButtonStrategy:()=>is,createGooglePayCheckoutComButtonStrategy:()=>bs,createGooglePayCybersourceButtonStrategy:()=>Os,createGooglePayOrbitalButtonStrategy:()=>Ts,createGooglePayPayPalCommerceButtonStrategy:()=>ls,createGooglePayStripeButtonStrategy:()=>Ks,createGooglePayTdOnlineMartButtonStrategy:()=>ed,createGooglePayWorldpayAccessButtonStrategy:()=>Zs,createLinkV2ButtonStrategy:()=>sc,createPayPalCommerceButtonStrategy:()=>Cd,createPayPalCommerceCreditButtonStrategy:()=>Ed,createPayPalCommerceVenmoButtonStrategy:()=>xd,createPaypalExpressButtonStrategy:()=>Zd});class ve extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}const Ce={body:{},headers:{},status:0};class Ie extends ve{constructor(e,{message:t,errors:n}={}){const{body:i,headers:r,status:o}=e||Ce;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=i,this.headers=r,this.status=o,this.errors=n||[]}}class we extends Ie{constructor(e){super(e,{message:"There is a problem processing your payment. Please try again later."}),this.name="PaymentMethodInvalidError",this.type="payment_method_invalid"}}class Ee extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}const be={body:{},headers:{},status:0};class Pe extends Ee{constructor(e,{message:t,errors:n}={}){const{body:i,headers:r,status:o}=e||be;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=i,this.headers=r,this.status=o,this.errors=n||[]}}class Oe extends Pe{constructor(e,t){super(e,{message:t||"An unexpected error has occurred. The checkout process cannot continue as a result."}),this.name="UnrecoverableError",this.type="unrecoverable"}}function Ae(e){return e.reduce((e,t)=>t?[...e,t]:e,[]).join(" ")}function Te(e,t){const{body:n}=e,{errors:i=[]}=n;return new Pe(e,{message:ke(i)||t,errors:i})}function ke(e){if(Array.isArray(e))return e.reduce((e,t)=>t&&t.message?[...e,t.message]:e,[]).join(" ")}class Re extends Pe{constructor(e){super(e,{message:"The request has timed out or aborted."}),this.name="TimeoutError",this.type="timeout"}}class De{constructor(){this._factoryMethods={},this.register("default",(e,t)=>new Pe(e,{message:t})),this.register("internal",(e,t)=>function(e,t){const{body:n}=e,{errors:i=[]}=n;return new Pe(e,{message:Ae(i)||n.detail||n.title||t,errors:i.length?i.map(e=>({code:n.type,message:e})):[{code:n.type,message:n.detail||n.title}]})}(e,t)),this.register("storefront",(e,t)=>function(e,t){const{body:n}=e;return new Pe(e,{message:t||n.detail||n.title,errors:[{code:n.code||n.type,message:n.detail||n.title}]})}(e,t)),this.register("payment",(e,t)=>Te(e,t)),this.register("timeout",e=>new Re(e))}register(e,t){this._factoryMethods[e]=t}createError(e,t){return(this._factoryMethods[this._getType(e)]||this._factoryMethods.default)(e,t)}_getType(e){if(0===e.status)return"timeout";if(this._isStorefrontErrorResponseBody(e.body))return"storefront";if(this._isInternalErrorResponseBody(e.body)){const t=b(e.body.type.split("/"));return t&&this._factoryMethods[t]?t:"internal"}const t=b(e.body&&e.body.errors);return t&&t.code&&this._factoryMethods[t.code]?t.code:"payment"}_isStorefrontErrorResponseBody(e){const t=e;return!this._isInternalErrorResponseBody(e)&&"string"==typeof t.title&&"string"==typeof t.type&&"number"==typeof t.status&&"string"==typeof t.detail}_isInternalErrorResponseBody(e){const t=e;return"object"==typeof t.errors&&"string"==typeof t.title&&"string"==typeof t.type&&"number"==typeof t.status}}function Me(e,t){return Array.isArray(e)?e.map(e=>Me(e,t)):I(e)?U(R(e,t),(e,n,i)=>{e[i]=Me(n,t)},{}):e}var Ne,Le;function ze(e,t){return function(e){return e.type===Ne.ClearError}(t)?Me(e,e=>e===t.payload):e}function Ue(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(let i=0,r=e.length;i<r;i++)if(!Ue(e[i],t[i],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){const i=n&&n.keyFilter,r=i?Object.keys(e).filter(i):Object.keys(e),o=i?Object.keys(t).filter(i):Object.keys(t);if(r.length!==o.length)return!1;for(let i=0,o=r.length;i<o;i++){const o=r[i];if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Ue(e[o],t[o],n))return!1}return!0}(e,t,n))):e===t)}function Fe(e,t,n){return e&&Object.prototype.hasOwnProperty.call(e,t)&&Ue(e[t],n)?e:Object.assign(Object.assign({},e),{[t]:n})}!function(e){e.ClearError="CLEAR_ERROR"}(Ne||(Ne={})),function(e){e.LoadB2BTokenRequested="LOAD_B2B_TOKEN_REQUESTED",e.LoadB2BTokenSucceeded="LOAD_B2B_TOKEN_SUCCEEDED",e.LoadB2BTokenFailed="LOAD_B2B_TOKEN_FAILED"}(Le||(Le={}));const Be={errors:{},statuses:{}};function xe(e=Be,t){return i({data:qe,errors:r(je,ze),statuses:Ge})(e,t)}function qe(e,t){return t.type===Le.LoadB2BTokenSucceeded?t.payload:e}function je(e=Be.errors,t){switch(t.type){case Le.LoadB2BTokenRequested:case Le.LoadB2BTokenSucceeded:return Fe(e,"loadError",void 0);case Le.LoadB2BTokenFailed:return Fe(e,"loadError",t.payload);default:return e}}function Ge(e=Be.statuses,t){switch(t.type){case Le.LoadB2BTokenRequested:return Fe(e,"isLoading",!0);case Le.LoadB2BTokenFailed:case Le.LoadB2BTokenSucceeded:return Fe(e,"isLoading",!1);default:return e}}var Ve,He,We,Ye;function Ke(e,t){return void 0===t||Ue(e,t)?e:t}!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",e.DeleteCheckoutRequested="DELETE_CHECKOUT_REQUESTED",e.DeleteCheckoutSucceeded="DELETE_CHECKOUT_SUCCEEDED",e.DeleteCheckoutFailed="DELETE_CHECKOUT_FAILED"}(Ve||(Ve={})),function(e){e.HydrateInitialState="HYDRATE_INITIAL_STATE"}(He||(He={})),function(e){e.UpdateSubscriptionsRequested="UPDATE_SUBSCRIPTIONS_REQUESTED",e.UpdateSubscriptionsSucceeded="UPDATE_SUBSCRIPTIONS_SUCCEEDED",e.UpdateSubscriptionsFailed="UPDATE_SUBSCRIPTIONS_FAILED"}(We||(We={})),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"}(Ye||(Ye={}));const $e={errors:{},statuses:{}};function Ze(e=$e,t){return i({data:Je,errors:r(Qe,ze),statuses:Xe})(e,t)}function Je(e,t){var n,i;switch(t.type){case Ye.UpdateBillingAddressSucceeded:case Ye.ContinueAsGuestSucceeded:case Ve.LoadCheckoutSucceeded:return Ke(e,t.payload&&t.payload.billingAddress);case He.HydrateInitialState:return Ke(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.billingAddress);default:return e}}function Qe(e=$e.errors,t){switch(t.type){case Ve.LoadCheckoutRequested:case Ve.LoadCheckoutSucceeded:return Fe(e,"loadError",void 0);case Ve.LoadCheckoutFailed:return Fe(e,"loadError",t.payload);case Ye.UpdateBillingAddressRequested:case Ye.UpdateBillingAddressSucceeded:return Fe(e,"updateError",void 0);case Ye.UpdateBillingAddressFailed:return Fe(e,"updateError",t.payload);case We.UpdateSubscriptionsRequested:case We.UpdateSubscriptionsSucceeded:case Ye.ContinueAsGuestRequested:case Ye.ContinueAsGuestSucceeded:return Fe(e,"continueAsGuestError",void 0);case We.UpdateSubscriptionsFailed:case Ye.ContinueAsGuestFailed:return Fe(e,"continueAsGuestError",t.payload);default:return e}}function Xe(e=$e.statuses,t){switch(t.type){case Ve.LoadCheckoutRequested:return Fe(e,"isLoading",!0);case Ve.LoadCheckoutSucceeded:case Ve.LoadCheckoutFailed:return Fe(e,"isLoading",!1);case Ye.UpdateBillingAddressRequested:return Fe(e,"isUpdating",!0);case Ye.UpdateBillingAddressFailed:case Ye.UpdateBillingAddressSucceeded:return Fe(e,"isUpdating",!1);case Ye.ContinueAsGuestRequested:case We.UpdateSubscriptionsRequested:return Fe(e,"isContinuingAsGuest",!0);case We.UpdateSubscriptionsSucceeded:case We.UpdateSubscriptionsFailed:case Ye.ContinueAsGuestFailed:case Ye.ContinueAsGuestSucceeded:return Fe(e,"isContinuingAsGuest",!1);default:return e}}function et(e){return I(e)}const tt=function e(t,n,i){const{matchObject:r=(e,t)=>void 0!==e.id&&e.id===t.id}=i||{};if(!t)return n;if(!n||t===n)return t;let o=0,a=0;const s=(e,t,n)=>(o+=e===t?1:0,a+=e===n?1:0,e),d=n.map((n,i)=>{const o=t&&t[i];return et(o)&&et(n)?r(o,n)?s(nt(o,n),o,n):s(Ke(o,n),o,n):y(o)&&y(n)?s(e(o,n),o,n):s(Ke(o,n),o,n)});return o===n.length&&t&&t.length===n.length?t:a===n.length?n:d},nt=function e(t,n){return t?n&&t!==n?Object.keys(n).reduce((t,i)=>{const r=t[i],o=n[i];return et(r)&&et(o)?Fe(t,i,e(r,o)):y(r)&&y(o)?Fe(t,i,tt(r,o)):Fe(t,i,o)},t):t:n};var it,rt,ot;!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"}(it||(it={})),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"}(rt||(rt={})),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"}(ot||(ot={}));const at={errors:{},statuses:{}};function st(e=at,t){return i({data:dt,errors:r(ut,ze),statuses:ct})(e,t)}function dt(e,t){var n,i;switch(t.type){case Ye.UpdateBillingAddressSucceeded:case Ve.LoadCheckoutSucceeded:case ot.CreateConsignmentsSucceeded:case ot.DeleteConsignmentSucceeded:case ot.UpdateConsignmentSucceeded:case ot.UpdateShippingOptionSucceeded:case ot.LoadShippingOptionsSucceeded:case it.ApplyCouponSucceeded:case it.RemoveCouponSucceeded:case rt.ApplyGiftCertificateSucceeded:case rt.RemoveGiftCertificateSucceeded:return nt(e,t.payload&&t.payload.cart);case He.HydrateInitialState:return nt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.cart);case Ve.DeleteCheckoutSucceeded:return;default:return e}}function ct(e=at.statuses,t){switch(t.type){case Ve.LoadCheckoutRequested:return Fe(e,"isLoading",!0);case Ve.LoadCheckoutFailed:case Ve.LoadCheckoutSucceeded:return Fe(e,"isLoading",!1);default:return e}}function ut(e=at.errors,t){switch(t.type){case Ve.LoadCheckoutRequested:case Ve.LoadCheckoutSucceeded:return Fe(e,"loadError",void 0);case Ve.LoadCheckoutFailed:return Fe(e,"loadError",t.payload);default:return e}}var lt;!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"}(lt||(lt={}));const ht={data:{},errors:{},statuses:{}},pt={initializedContainers:{}},gt={},mt={};function yt(e=ht,t){return t.meta&&t.meta.methodId?i({data:i({[t.meta.methodId]:ft}),errors:i({[t.meta.methodId]:_t}),statuses:i({[t.meta.methodId]:St})})(e,t):e}function ft(e=pt,t){switch(t.type){case lt.InitializeButtonSucceeded:return t.meta&&t.meta.containerId?nt(e,{initializedContainers:{[t.meta.containerId]:!0}}):e;case lt.DeinitializeButtonSucceeded:return Fe(e,"initializedContainers",{})}return e}function _t(e=gt,t){switch(t.type){case lt.InitializeButtonRequested:case lt.InitializeButtonSucceeded:return Fe(e,"initializeError",void 0);case lt.InitializeButtonFailed:return Fe(e,"initializeError",t.payload);case lt.DeinitializeButtonRequested:case lt.DeinitializeButtonSucceeded:return Fe(e,"deinitializeError",void 0);case lt.DeinitializeButtonFailed:return Fe(e,"deinitializeError",t.payload);default:return e}}function St(e=mt,t){switch(t.type){case lt.InitializeButtonRequested:return Fe(e,"isInitializing",!0);case lt.InitializeButtonFailed:case lt.InitializeButtonSucceeded:return Fe(e,"isInitializing",!1);case lt.DeinitializeButtonRequested:return Fe(e,"isDeinitializing",!0);case lt.DeinitializeButtonFailed:case lt.DeinitializeButtonSucceeded:return Fe(e,"isDeinitializing",!1);default:return e}}var vt;!function(e){e.LoadConfigRequested="LOAD_CONFIG_REQUESTED",e.LoadConfigSucceeded="LOAD_CONFIG_SUCCEEDED",e.LoadConfigFailed="LOAD_CONFIG_FAILED"}(vt||(vt={}));const Ct={meta:{},errors:{},statuses:{}};function It(e=Ct,t){return i({data:wt,errors:r(Et,ze),statuses:bt})(e,t)}function wt(e,t){var n,i;switch(t.type){case vt.LoadConfigSucceeded:return nt(e,t.payload);case He.HydrateInitialState:{const r=nt(e,null===(n=t.payload)||void 0===n?void 0:n.config);return r&&(null===(i=t.payload)||void 0===i?void 0:i.b2bApiSettings)?Object.assign(Object.assign({},r),{storeConfig:Object.assign(Object.assign({},r.storeConfig),{b2bApiSettings:t.payload.b2bApiSettings})}):r}default:return e}}function Et(e=Ct.errors,t){switch(t.type){case vt.LoadConfigSucceeded:return Fe(e,"loadError",void 0);case vt.LoadConfigFailed:return Fe(e,"loadError",t.payload);default:return e}}function bt(e=Ct.statuses,t){switch(t.type){case vt.LoadConfigRequested:return Fe(e,"isLoading",!0);case vt.LoadConfigSucceeded:case vt.LoadConfigFailed:return Fe(e,"isLoading",!1);default:return e}}var Pt;!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"}(Pt||(Pt={}));const Ot={errors:{},statuses:{}};function At(e=Ot,t){return i({data:Tt,errors:r(kt,ze),statuses:Rt})(e,t)}function Tt(e,t){var n,i;switch(t.type){case Ve.LoadCheckoutSucceeded:case it.ApplyCouponSucceeded:case ot.UpdateShippingOptionSucceeded:case it.RemoveCouponSucceeded:case Pt.LoadOrderSucceeded:return tt(e,t.payload&&t.payload.coupons);case He.HydrateInitialState:return tt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.coupons);default:return e}}function kt(e={},t){switch(t.type){case it.ApplyCouponRequested:case it.ApplyCouponSucceeded:return Fe(e,"applyCouponError",void 0);case it.ApplyCouponFailed:return Fe(e,"applyCouponError",t.payload);case it.RemoveCouponRequested:case it.RemoveCouponSucceeded:return Fe(e,"removeCouponError",void 0);case it.RemoveCouponFailed:return Fe(e,"removeCouponError",t.payload);default:return e}}function Rt(e={},t){switch(t.type){case it.ApplyCouponRequested:return Fe(e,"isApplyingCoupon",!0);case it.ApplyCouponSucceeded:case it.ApplyCouponFailed:return Fe(e,"isApplyingCoupon",!1);case it.RemoveCouponRequested:return Fe(e,"isRemovingCoupon",!0);case it.RemoveCouponSucceeded:case it.RemoveCouponFailed:return Fe(e,"isRemovingCoupon",!1);default:return e}}const Dt={errors:{},statuses:{}};function Mt(e=Dt,t){return i({data:Nt,errors:r(Lt,ze),statuses:zt})(e,t)}function Nt(e,t){var n,i;switch(t.type){case Ve.LoadCheckoutSucceeded:case ot.CreateConsignmentsSucceeded:case ot.UpdateConsignmentSucceeded:case ot.DeleteConsignmentSucceeded:case ot.UpdateShippingOptionSucceeded:case it.ApplyCouponSucceeded:case it.RemoveCouponSucceeded:case rt.ApplyGiftCertificateSucceeded:case rt.RemoveGiftCertificateSucceeded:return tt(e,t.payload&&t.payload.giftCertificates);case He.HydrateInitialState:return tt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.giftCertificates);default:return e}}function Lt(e=Dt.errors,t){switch(t.type){case rt.ApplyGiftCertificateRequested:case rt.ApplyGiftCertificateSucceeded:return Fe(e,"applyGiftCertificateError",void 0);case rt.ApplyGiftCertificateFailed:return Fe(e,"applyGiftCertificateError",t.payload);case rt.RemoveGiftCertificateRequested:case rt.RemoveGiftCertificateSucceeded:return Fe(e,"removeGiftCertificateError",void 0);case rt.RemoveGiftCertificateFailed:return Fe(e,"removeGiftCertificateError",t.payload);default:return e}}function zt(e=Dt.statuses,t){switch(t.type){case rt.ApplyGiftCertificateRequested:return Fe(e,"isApplyingGiftCertificate",!0);case rt.ApplyGiftCertificateSucceeded:case rt.ApplyGiftCertificateFailed:return Fe(e,"isApplyingGiftCertificate",!1);case rt.RemoveGiftCertificateRequested:return Fe(e,"isRemovingGiftCertificate",!0);case rt.RemoveGiftCertificateSucceeded:case rt.RemoveGiftCertificateFailed:return Fe(e,"isRemovingGiftCertificate",!1);default:return e}}var Ut;!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"}(Ut||(Ut={}));const Ft={errors:{},statuses:{}};function Bt(e=Ft,t){return i({data:xt,errors:r(qt,ze),statuses:jt})(e,t)}function xt(e,t){var n,i;switch(t.type){case Ye.ContinueAsGuestSucceeded:case Ve.LoadCheckoutSucceeded:return nt(e,t.payload&&t.payload.customer);case Ut.CreateCustomerAddressSucceeded:return nt(e,t.payload);case He.HydrateInitialState:return nt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.customer);default:return e}}function qt(e=Ft.errors,t){switch(t.type){case Ut.CreateCustomerRequested:case Ut.CreateCustomerSucceeded:return Fe(e,"createError",void 0);case Ut.CreateCustomerFailed:return Fe(e,"createError",t.payload);case Ut.CreateCustomerAddressRequested:case Ut.CreateCustomerAddressSucceeded:return Fe(e,"createAddressError",void 0);case Ut.CreateCustomerAddressFailed:return Fe(e,"createAddressError",t.payload);default:return e}}function jt(e=Ft.statuses,t){switch(t.type){case Ut.CreateCustomerRequested:return Fe(e,"isCreating",!0);case Ut.CreateCustomerFailed:case Ut.CreateCustomerSucceeded:return Fe(e,"isCreating",!1);case Ut.CreateCustomerAddressRequested:return Fe(e,"isCreatingAddress",!0);case Ut.CreateCustomerAddressFailed:case Ut.CreateCustomerAddressSucceeded:return Fe(e,"isCreatingAddress",!1);default:return e}}var Gt;!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"}(Gt||(Gt={}));const Vt={data:{},errors:{},statuses:{}};function Ht(e=Vt,t){return i({data:Wt,errors:r(Yt,ze),statuses:Kt})(e,t)}function Wt(e=Vt.data,t){switch(t.type){case Gt.InitializeSucceeded:return nt(e,{[t.meta&&t.meta.methodId]:{isInitialized:!0}});case Gt.DeinitializeSucceeded:return nt(e,{[t.meta&&t.meta.methodId]:{isInitialized:!1}})}return e}function Yt(e=Vt.errors,t){switch(t.type){case Gt.InitializeRequested:case Gt.InitializeSucceeded:return nt(e,{initializeErrors:Object.assign({},e.initializeErrors),initializeMethodId:e.initializeMethodId?e.initializeMethodId:void 0});case Gt.InitializeFailed:return nt(e,{initializeErrors:Object.assign(Object.assign({},e.initializeErrors),{[t.meta&&t.meta.methodId]:t.payload}),initializeMethodId:t.meta&&t.meta.methodId});case Gt.DeinitializeRequested:case Gt.DeinitializeSucceeded:return nt(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case Gt.DeinitializeFailed:return nt(e,{deinitializeError:t.payload,deinitializeMethodId:t.meta&&t.meta.methodId});case Gt.SignInRequested:case Gt.SignInSucceeded:return nt(e,{signInError:void 0,signInMethodId:void 0});case Gt.SignInFailed:return nt(e,{signInError:t.payload,signInMethodId:t.meta&&t.meta.methodId});case Gt.SignOutRequested:case Gt.SignOutSucceeded:return nt(e,{signOutError:void 0,signOutMethodId:void 0});case Gt.SignOutFailed:return nt(e,{signOutError:t.payload,signOutMethodId:t.meta&&t.meta.methodId});case Gt.ExecutePaymentMethodCheckoutRequested:case Gt.ExecutePaymentMethodCheckoutSucceeded:return nt(e,{executePaymentMethodCheckoutError:void 0,executePaymentMethodCheckoutMethodId:void 0});case Gt.ExecutePaymentMethodCheckoutFailed:return nt(e,{executePaymentMethodCheckoutError:t.payload,executePaymentMethodCheckoutMethodId:t.meta&&t.meta.methodId});case Gt.WidgetInteractionStarted:case Gt.WidgetInteractionFinished:return nt(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case Gt.WidgetInteractionFailed:return nt(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta.methodId});default:return e}}function Kt(e=Vt.statuses,t){switch(t.type){case Gt.InitializeRequested:return nt(e,{isInitializing:!0,initializeMethodId:t.meta&&t.meta.methodId});case Gt.InitializeFailed:case Gt.InitializeSucceeded:return nt(e,{isInitializing:!1,initializeMethodId:void 0});case Gt.DeinitializeRequested:return nt(e,{isDeinitializing:!0,deinitializeMethodId:t.meta&&t.meta.methodId});case Gt.DeinitializeFailed:case Gt.DeinitializeSucceeded:return nt(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case Gt.SignInRequested:return nt(e,{isSigningIn:!0,signInMethodId:t.meta&&t.meta.methodId});case Gt.SignInFailed:case Gt.SignInSucceeded:return nt(e,{isSigningIn:!1,signInMethodId:void 0});case Gt.SignOutRequested:return nt(e,{isSigningOut:!0,signOutMethodId:t.meta&&t.meta.methodId});case Gt.SignOutFailed:case Gt.SignOutSucceeded:return nt(e,{isSigningOut:!1,signOutMethodId:void 0});case Gt.ExecutePaymentMethodCheckoutRequested:return nt(e,{isExecutingPaymentMethodCheckout:!0,executePaymentMethodCheckoutMethodId:t.meta&&t.meta.methodId});case Gt.ExecutePaymentMethodCheckoutFailed:case Gt.ExecutePaymentMethodCheckoutSucceeded:return nt(e,{isExecutingPaymentMethodCheckout:!1,executePaymentMethodCheckoutMethodId:void 0});case Gt.WidgetInteractionStarted:return nt(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta.methodId});case Gt.WidgetInteractionFinished:case Gt.WidgetInteractionFailed:return nt(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}var $t;!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"}($t||($t={}));const Zt={errors:{},statuses:{}};function Jt(e=Zt,t){return i({data:Qt,errors:r(Xt,ze),statuses:en})(e,t)}function Qt(e,t){var n;return t.type===$t.LoadExtensionsSucceeded?tt(e,t.payload):t.type===He.HydrateInitialState?tt(e,null===(n=t.payload)||void 0===n?void 0:n.extensions):e}function Xt(e=Zt.errors,t){switch(t.type){case $t.LoadExtensionsRequested:case $t.LoadExtensionsSucceeded:return Fe(e,"loadError",void 0);case $t.RenderExtensionRequested:case $t.RenderExtensionSucceeded:return Fe(e,"renderError",void 0);case $t.LoadExtensionsFailed:return Fe(e,"loadError",t.payload);case $t.RenderExtensionFailed:return Fe(e,"renderError",t.payload);default:return e}}function en(e=Zt.statuses,t){switch(t.type){case $t.LoadExtensionsRequested:return Fe(e,"isLoading",!0);case $t.LoadExtensionsSucceeded:case $t.LoadExtensionsFailed:return Fe(e,"isLoading",!1);default:return e}}var tn;!function(e){e.LoadFormFieldsRequested="LOAD_FORM_FIELDS_REQUESTED",e.LoadFormFieldsSucceeded="LOAD_FORM_FIELDS_SUCCEEDED",e.LoadFormFieldsFailed="LOAD_FORM_FIELDS_FAILED"}(tn||(tn={}));const nn={errors:{},statuses:{}};function rn(e=nn,t){return i({data:on,extraFields:an,errors:r(sn,ze),statuses:dn})(e,t)}function on(e,t){var n;switch(t.type){case tn.LoadFormFieldsSucceeded:return nt(e,t.payload);case He.HydrateInitialState:return nt(e,null===(n=t.payload)||void 0===n?void 0:n.formFields);default:return e}}function an(e,t){var n,i;return t.type===He.HydrateInitialState&&null!==(i=null===(n=t.payload)||void 0===n?void 0:n.extraFields)&&void 0!==i?i:e}function sn(e=nn.errors,t){switch(t.type){case tn.LoadFormFieldsSucceeded:return Fe(e,"loadError",void 0);case tn.LoadFormFieldsFailed:return Fe(e,"loadError",t.payload);default:return e}}function dn(e=nn.statuses,t){switch(t.type){case tn.LoadFormFieldsRequested:return Fe(e,"isLoading",!0);case tn.LoadFormFieldsSucceeded:case tn.LoadFormFieldsFailed:return Fe(e,"isLoading",!1);default:return e}}var cn;!function(e){e.LoadCountriesRequested="LOAD_COUNTRIES_REQUESTED",e.LoadCountriesSucceeded="LOAD_COUNTRIES_SUCCEEDED",e.LoadCountriesFailed="LOAD_COUNTRIES_FAILED"}(cn||(cn={}));const un={errors:{},statuses:{}};function ln(e=un,t){return i({data:hn,errors:r(pn,ze),statuses:gn})(e,t)}function hn(e,t){return t.type===cn.LoadCountriesSucceeded?tt(e,t.payload):e}function pn(e=un.errors,t){switch(t.type){case cn.LoadCountriesRequested:case cn.LoadCountriesSucceeded:return Fe(e,"loadError",void 0);case cn.LoadCountriesFailed:return Fe(e,"loadError",t.payload);default:return e}}function gn(e=un.statuses,t){switch(t.type){case cn.LoadCountriesRequested:return Fe(e,"isLoading",!0);case cn.LoadCountriesSucceeded:case cn.LoadCountriesFailed:return Fe(e,"isLoading",!1);default:return e}}const mn={errors:{},meta:{},statuses:{}};function yn(e=mn,t){return i({data:fn,errors:r(Sn,ze),meta:_n,statuses:vn})(e,t)}function fn(e,t){switch(t.type){case Pt.LoadOrderSucceeded:case Pt.LoadOrderPaymentsSucceeded:return nt(e,k(t.payload,["billingAddress","coupons"]));default:return e}}function _n(e,t){switch(t.type){case Pt.FinalizeOrderSucceeded:case Pt.SubmitOrderSucceeded:return nt(e,Object.assign(Object.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 Sn(e=mn.errors,t){switch(t.type){case Pt.LoadOrderRequested:case Pt.LoadOrderSucceeded:case Pt.LoadOrderPaymentsSucceeded:case Pt.LoadOrderPaymentsRequested:return Fe(e,"loadError",void 0);case Pt.LoadOrderFailed:case Pt.LoadOrderPaymentsFailed:return Fe(e,"loadError",t.payload);default:return e}}function vn(e=mn.statuses,t){switch(t.type){case Pt.LoadOrderRequested:case Pt.LoadOrderPaymentsRequested:return Fe(e,"isLoading",!0);case Pt.LoadOrderSucceeded:case Pt.LoadOrderFailed:case Pt.LoadOrderPaymentsSucceeded:case Pt.LoadOrderPaymentsFailed:return Fe(e,"isLoading",!1);default:return e}}const Cn={};function In(e=Cn,t){return i({data:wn})(e,t)}function wn(e,t){switch(t.type){case Pt.LoadOrderPaymentsSucceeded:case Pt.LoadOrderSucceeded:return Ke(e,t.payload&&t.payload.billingAddress);default:return e}}var En;!function(e){e.PersistB2BMetadataRequested="PERSIST_B2B_METADATA_REQUESTED",e.PersistB2BMetadataSucceeded="PERSIST_B2B_METADATA_SUCCEEDED",e.PersistB2BMetadataFailed="PERSIST_B2B_METADATA_FAILED"}(En||(En={}));const bn={errors:{},statuses:{}};function Pn(e=bn,t){return i({data:On,errors:r(An,ze),statuses:Tn})(e,t)}function On(e,t){return t.type===En.PersistB2BMetadataSucceeded?t.payload:e}function An(e=bn.errors,t){switch(t.type){case En.PersistB2BMetadataRequested:case En.PersistB2BMetadataSucceeded:return Fe(e,"persistB2bMetadataError",void 0);case En.PersistB2BMetadataFailed:return Fe(e,"persistB2bMetadataError",t.payload);default:return e}}function Tn(e=bn.statuses,t){switch(t.type){case En.PersistB2BMetadataRequested:return Fe(e,"isPersisting",!0);case En.PersistB2BMetadataFailed:case En.PersistB2BMetadataSucceeded:return Fe(e,"isPersisting",!1);default:return e}}var kn,Rn;function Dn(e={},t){return i({data:Mn})(e,t)}function Mn(e,t){return t.type===kn.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"}(kn||(kn={})),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"}(Rn||(Rn={}));const Nn={errors:{},statuses:{}};function Ln(e=Nn,t){return i({data:zn,errors:r(Fn,ze),meta:Un,statuses:Bn})(e,t)}function zn(e,t){switch(t.type){case Rn.LoadPaymentMethodSucceeded:return function(e,t,n){if(!t)return e;const i=D(t,"id"),r="object"==typeof n?M(n):n||i,o=h(e,r),a=[...e];if(-1===o)a.push(t);else{const n=e[o];a[o]=et(n)&&et(t)?nt(n,t):t}return a}(e||[],t.payload,t.payload&&{id:t.payload.id,gateway:t.payload.gateway});case Rn.LoadPaymentMethodsSucceeded:return tt(e,t.payload,{matchObject:(e,t)=>e.id===t.id&&e.gateway===t.gateway});default:return e}}function Un(e,t){return t.type===Rn.LoadPaymentMethodsSucceeded?nt(e,t.meta):e}function Fn(e=Nn.errors,t){switch(t.type){case Rn.LoadPaymentMethodsRequested:case Rn.LoadPaymentMethodsSucceeded:return Fe(e,"loadError",void 0);case Rn.LoadPaymentMethodsFailed:return Fe(e,"loadError",t.payload);case Rn.LoadPaymentMethodRequested:case Rn.LoadPaymentMethodSucceeded:return nt(e,{loadMethodId:void 0,loadMethodError:void 0});case Rn.LoadPaymentMethodFailed:return nt(e,{loadMethodId:t.meta.methodId,loadMethodError:t.payload});default:return e}}function Bn(e=Nn.statuses,t){switch(t.type){case Rn.LoadPaymentMethodsRequested:return Fe(e,"isLoading",!0);case Rn.LoadPaymentMethodsSucceeded:case Rn.LoadPaymentMethodsFailed:return Fe(e,"isLoading",!1);case Rn.LoadPaymentMethodRequested:return nt(e,{isLoadingMethod:!0,loadMethodId:t.meta.methodId});case Rn.LoadPaymentMethodSucceeded:case Rn.LoadPaymentMethodFailed:return nt(e,{isLoadingMethod:!1,loadMethodId:void 0});default:return e}}var xn;!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"}(xn||(xn={}));const qn={data:{},errors:{},statuses:{}};function jn(e=qn,t){return i({data:Gn,errors:r(Vn,ze),statuses:Hn})(e,t)}function Gn(e=qn.data,t){switch(t.type){case xn.InitializeSucceeded:if(t.meta){const{methodId:n,gatewayId:i}=t.meta,r=i?`${n}.${i}`:n;return nt(e,{[r]:{isInitialized:!0}})}break;case xn.DeinitializeSucceeded:if(t.meta){const{methodId:n,gatewayId:i}=t.meta,r=i?`${n}.${i}`:n;return nt(e,{[r]:{isInitialized:!1}})}}return e}function Vn(e=qn.errors,t){switch(t.type){case xn.InitializeRequested:case xn.InitializeSucceeded:return nt(e,{initializeError:void 0,initializeMethodId:void 0});case xn.InitializeFailed:{let n=t.meta&&t.meta.methodId;if(t.meta){const{methodId:e,gatewayId:i}=t.meta;n=i?`${e}.${i}`:e}return nt(e,{initializeError:t.payload,initializeMethodId:n})}case xn.DeinitializeRequested:case xn.DeinitializeSucceeded:return nt(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case xn.DeinitializeFailed:{let n=t.meta&&t.meta.methodId;if(t.meta){const{methodId:e,gatewayId:i}=t.meta;n=i?`${e}.${i}`:e}return nt(e,{deinitializeError:t.payload,deinitializeMethodId:n})}case xn.ExecuteRequested:case xn.ExecuteSucceeded:return nt(e,{executeError:void 0,executeMethodId:void 0});case xn.ExecuteFailed:return nt(e,{executeError:t.payload,executeMethodId:t.meta&&t.meta.methodId});case xn.FinalizeRequested:case xn.FinalizeSucceeded:return nt(e,{finalizeError:void 0,finalizeMethodId:void 0});case xn.FinalizeFailed:return nt(e,{finalizeError:t.payload,finalizeMethodId:t.meta&&t.meta.methodId});case xn.WidgetInteractionStarted:case xn.WidgetInteractionFinished:return nt(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case xn.WidgetInteractionFailed:return nt(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta.methodId});default:return e}}function Hn(e=qn.statuses,t){switch(t.type){case xn.InitializeRequested:{let n=t.meta&&t.meta.methodId;if(t.meta){const{methodId:e,gatewayId:i}=t.meta;n=i?`${e}.${i}`:e}return nt(e,{isInitializing:!0,initializeMethodId:n})}case xn.InitializeFailed:case xn.InitializeSucceeded:return nt(e,{isInitializing:!1,initializeMethodId:void 0});case xn.DeinitializeRequested:{let n=t.meta&&t.meta.methodId;if(t.meta){const{methodId:e,gatewayId:i}=t.meta;n=i?`${e}.${i}`:e}return nt(e,{isDeinitializing:!0,deinitializeMethodId:n})}case xn.DeinitializeFailed:case xn.DeinitializeSucceeded:return nt(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case xn.ExecuteRequested:return nt(e,{isExecuting:!0,executeMethodId:t.meta&&t.meta.methodId});case xn.ExecuteFailed:case xn.ExecuteSucceeded:return nt(e,{isExecuting:!1,executeMethodId:void 0});case xn.FinalizeRequested:return nt(e,{isFinalizing:!0,finalizeMethodId:t.meta&&t.meta.methodId});case xn.FinalizeFailed:case xn.FinalizeSucceeded:return nt(e,{isFinalizing:!1,finalizeMethodId:void 0});case xn.WidgetInteractionStarted:return nt(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta.methodId});case xn.WidgetInteractionFinished:case xn.WidgetInteractionFailed:return nt(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}var Wn;!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"}(Wn||(Wn={}));const Yn={data:[],errors:{},statuses:{}};function Kn(e=Yn,t){return i({data:$n,errors:r(Jn,ze),meta:Zn,statuses:Qn})(e,t)}function $n(e=Yn.data,t){return t.type===Wn.LoadInstrumentsSucceeded?tt(e,t.payload&&t.payload.vaultedInstruments||[]):e}function Zn(e,t){switch(t.type){case Wn.LoadInstrumentsSucceeded:case Wn.DeleteInstrumentSucceeded:return nt(e,t.meta);default:return e}}function Jn(e=Yn.errors,t){switch(t.type){case Wn.LoadInstrumentsRequested:case Wn.LoadInstrumentsSucceeded:return Fe(e,"loadError",void 0);case Wn.DeleteInstrumentRequested:case Wn.DeleteInstrumentSucceeded:return nt(e,{deleteError:void 0,failedInstrument:void 0});case Wn.LoadInstrumentsFailed:return Fe(e,"loadError",t.payload);case Wn.DeleteInstrumentFailed:return nt(e,{deleteError:t.payload,failedInstrument:t.meta.instrumentId});default:return e}}function Qn(e=Yn.statuses,t){switch(t.type){case Wn.LoadInstrumentsRequested:return Fe(e,"isLoading",!0);case Wn.DeleteInstrumentRequested:return nt(e,{isDeleting:!0,deletingInstrument:t.meta.instrumentId});case Wn.LoadInstrumentsSucceeded:case Wn.LoadInstrumentsFailed:return Fe(e,"isLoading",!1);case Wn.DeleteInstrumentSucceeded:case Wn.DeleteInstrumentFailed:return nt(e,{isDeleting:!1,deletingInstrument:void 0});default:return e}}var Xn;!function(e){e.UpdatePaymentProviderCustomer="UPDATE_PAYMENT_PROVIDER_CUSTOMER"}(Xn||(Xn={}));const ei={data:{}};function ti(e=ei,t){return i({data:ni})(e,t)}function ni(e=ei.data,t){return t.type===Xn.UpdatePaymentProviderCustomer?nt(e,t.payload):e}var ii;!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"}(ii||(ii={}));const ri={data:{}};function oi(e=ri,t){return t.meta&&t.meta.methodId?i({data:i({[t.meta.methodId]:ai})})(e,t):e}function ai(e,t){switch(t.type){case ii.InitializeRemoteBillingSucceeded:return Fe(e,"billing",t.payload&&t.payload.billing);case ii.InitializeRemoteShippingSucceeded:return Fe(e,"shipping",t.payload&&t.payload.shipping);case ii.LoadRemoteSettingsSucceeded:return Fe(e,"settings",t.payload);case ii.UpdateRemoteCheckout:return nt(e,t.payload);default:return e}}const si={errors:{updateShippingOptionError:{},updateError:{},deleteError:{}},statuses:{isUpdating:{},isUpdatingShippingOption:{},isDeleting:{}}};function di(e=si,t){return i({data:ci,errors:r(ui,ze),statuses:li})(e,t)}function ci(e,t){var n,i;switch(t.type){case Ve.LoadCheckoutSucceeded:case ot.LoadShippingOptionsSucceeded:case ot.CreateConsignmentsSucceeded:case ot.UpdateConsignmentSucceeded:case ot.DeleteConsignmentSucceeded:case ot.UpdateShippingOptionSucceeded:case it.ApplyCouponSucceeded:case it.RemoveCouponSucceeded:return tt(e,t.payload&&t.payload.consignments);case Ut.SignOutCustomerSucceeded:return tt(e,[]);case He.HydrateInitialState:return tt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.consignments);default:return e}}function ui(e=si.errors,t){switch(t.type){case Ve.LoadCheckoutRequested:case Ve.LoadCheckoutSucceeded:case ot.LoadShippingOptionsSucceeded:case ot.LoadShippingOptionsRequested:return Fe(e,"loadError",void 0);case Ve.LoadCheckoutFailed:case ot.LoadShippingOptionsFailed:return Fe(e,"loadError",t.payload);case ot.CreateConsignmentsRequested:case ot.CreateConsignmentsSucceeded:return Fe(e,"createError",void 0);case ot.CreateConsignmentsFailed:return Fe(e,"createError",t.payload);case ot.UpdateConsignmentSucceeded:case ot.UpdateConsignmentRequested:return t.meta?nt(e,{updateError:{[t.meta.id]:void 0}}):e;case ot.UpdateConsignmentFailed:return t.meta?nt(e,{updateError:{[t.meta.id]:t.payload}}):e;case ot.DeleteConsignmentSucceeded:case ot.DeleteConsignmentRequested:return t.meta?nt(e,{deleteError:{[t.meta.id]:void 0}}):e;case ot.DeleteConsignmentFailed:return t.meta?nt(e,{deleteError:{[t.meta.id]:t.payload}}):e;case ot.UpdateShippingOptionRequested:case ot.UpdateShippingOptionSucceeded:return t.meta?nt(e,{updateShippingOptionError:{[t.meta.id]:void 0}}):e;case ot.UpdateShippingOptionFailed:return t.meta?nt(e,{updateShippingOptionError:{[t.meta.id]:t.payload}}):e;default:return e}}function li(e=si.statuses,t){switch(t.type){case Ve.LoadCheckoutRequested:return Fe(e,"isLoading",!0);case ot.LoadShippingOptionsRequested:return Fe(e,"isLoadingShippingOptions",!0);case Ve.LoadCheckoutSucceeded:case Ve.LoadCheckoutFailed:return Fe(e,"isLoading",!1);case ot.LoadShippingOptionsSucceeded:case ot.LoadShippingOptionsFailed:return Fe(e,"isLoadingShippingOptions",!1);case ot.CreateConsignmentsRequested:return Fe(e,"isCreating",!0);case ot.CreateConsignmentsSucceeded:case ot.CreateConsignmentsFailed:return Fe(e,"isCreating",!1);case ot.UpdateConsignmentRequested:return t.meta?nt(e,{isUpdating:{[t.meta.id]:!0}}):e;case ot.UpdateConsignmentSucceeded:case ot.UpdateConsignmentFailed:return t.meta?nt(e,{isUpdating:{[t.meta.id]:!1}}):e;case ot.DeleteConsignmentRequested:return t.meta?nt(e,{isDeleting:{[t.meta.id]:!0}}):e;case ot.DeleteConsignmentSucceeded:case ot.DeleteConsignmentFailed:return t.meta?nt(e,{isDeleting:{[t.meta.id]:!1}}):e;case ot.UpdateShippingOptionRequested:return t.meta?nt(e,{isUpdatingShippingOption:{[t.meta.id]:!0}}):e;case ot.UpdateShippingOptionSucceeded:case ot.UpdateShippingOptionFailed:return t.meta?nt(e,{isUpdatingShippingOption:{[t.meta.id]:!1}}):e;default:return e}}function hi(e,t){const n={};return Object.keys(e).forEach(i=>{const r=e[i],o=t?`${t}.${i}`:i;"object"==typeof r?Object.assign(n,hi(r,o)):n[o]=r}),n}function pi(e){return Object.keys(e).sort().reduce((t,n)=>Object.assign(Object.assign({},t),{[n]:e[n]}),{})}var gi;!function(e){e.LoadPickupOptionsRequested="LOAD_PICKUP_OPTIONS_REQUESTED",e.LoadPickupOptionsSucceeded="LOAD_PICKUP_OPTIONS_SUCCEEDED",e.LoadPickupOptionsFailed="LOAD_PICKUP_OPTIONS_FAILED"}(gi||(gi={}));const mi={errors:{},statuses:{}};function yi(e=mi,t){return i({data:fi,errors:r(_i,ze),statuses:Si})(e,t)}function fi(e,t){if(t.type!==gi.LoadPickupOptionsSucceeded)return e;if(t.meta){const n=pi(hi({consignmentId:t.meta.consignmentId,searchArea:t.meta.searchArea}));return Fe(e,btoa(`${JSON.stringify(n)}`),t.payload)}}function _i(e=mi.errors,t){switch(t.type){case gi.LoadPickupOptionsRequested:case gi.LoadPickupOptionsSucceeded:return Fe(e,"loadError",void 0);case gi.LoadPickupOptionsFailed:return Fe(e,"loadError",t.payload);default:return e}}function Si(e=mi.statuses,t){switch(t.type){case gi.LoadPickupOptionsRequested:return Fe(e,"isLoading",!0);case gi.LoadPickupOptionsSucceeded:case gi.LoadPickupOptionsFailed:return Fe(e,"isLoading",!1);default:return e}}var vi;!function(e){e.LoadShippingCountriesRequested="LOAD_SHIPPING_COUNTRIES_REQUESTED",e.LoadShippingCountriesSucceeded="LOAD_SHIPPING_COUNTRIES_SUCCEEDED",e.LoadShippingCountriesFailed="LOAD_SHIPPING_COUNTRIES_FAILED"}(vi||(vi={}));const Ci={errors:{},statuses:{}};function Ii(e=Ci,t){return i({data:wi,errors:r(Ei,ze),statuses:bi})(e,t)}function wi(e,t){return t.type===vi.LoadShippingCountriesSucceeded?tt(e,t.payload):e}function Ei(e=Ci.errors,t){switch(t.type){case vi.LoadShippingCountriesRequested:case vi.LoadShippingCountriesSucceeded:return Fe(e,"loadError",void 0);case vi.LoadShippingCountriesFailed:return Fe(e,"loadError",t.payload);default:return e}}function bi(e=Ci.statuses,t){switch(t.type){case vi.LoadShippingCountriesRequested:return Fe(e,"isLoading",!0);case vi.LoadShippingCountriesSucceeded:case vi.LoadShippingCountriesFailed:return Fe(e,"isLoading",!1);default:return e}}var Pi;!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"}(Pi||(Pi={}));const Oi={data:{},errors:{},statuses:{}};function Ai(e=Oi,t){return i({data:Ti,errors:r(ki,ze),statuses:Ri})(e,t)}function Ti(e=Oi.data,t){switch(t.type){case Pi.InitializeSucceeded:return nt(e,{[t.meta&&t.meta.methodId]:{isInitialized:!0}});case Pi.DeinitializeSucceeded:return nt(e,{[t.meta&&t.meta.methodId]:{isInitialized:!1}})}return e}function ki(e=Oi.errors,t){switch(t.type){case Pi.InitializeRequested:case Pi.InitializeSucceeded:return nt(e,{initializeError:void 0,initializeMethodId:void 0});case Pi.InitializeFailed:return nt(e,{initializeError:t.payload,initializeMethodId:t.meta&&t.meta.methodId});case Pi.DeinitializeRequested:case Pi.DeinitializeSucceeded:return nt(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case Pi.DeinitializeFailed:return nt(e,{deinitializeError:t.payload,deinitializeMethodId:t.meta&&t.meta.methodId});case Pi.UpdateAddressRequested:case Pi.UpdateAddressSucceeded:return nt(e,{updateAddressError:void 0,updateAddressMethodId:void 0});case Pi.UpdateAddressFailed:return nt(e,{updateAddressError:t.payload,updateAddressMethodId:t.meta&&t.meta.methodId});case Pi.SelectOptionRequested:case Pi.SelectOptionSucceeded:return nt(e,{selectOptionError:void 0,selectOptionMethodId:void 0});case Pi.SelectOptionFailed:return nt(e,{selectOptionError:t.payload,selectOptionMethodId:t.meta&&t.meta.methodId});case Pi.WidgetInteractionStarted:case Pi.WidgetInteractionFinished:return nt(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case Pi.WidgetInteractionFailed:return nt(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta&&t.meta.methodId});default:return e}}function Ri(e=Oi.statuses,t){switch(t.type){case Pi.InitializeRequested:return nt(e,{isInitializing:!0,initializeMethodId:t.meta&&t.meta.methodId});case Pi.InitializeFailed:case Pi.InitializeSucceeded:return nt(e,{isInitializing:!1,initializeMethodId:void 0});case Pi.DeinitializeRequested:return nt(e,{isDeinitializing:!0,deinitializeMethodId:t.meta&&t.meta.methodId});case Pi.DeinitializeFailed:case Pi.DeinitializeSucceeded:return nt(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case Pi.UpdateAddressRequested:return nt(e,{isUpdatingAddress:!0,updateAddressMethodId:t.meta&&t.meta.methodId});case Pi.UpdateAddressFailed:case Pi.UpdateAddressSucceeded:return nt(e,{isUpdatingAddress:!1,updateAddressMethodId:void 0});case Pi.SelectOptionRequested:return nt(e,{isSelectingOption:!0,selectOptionMethodId:t.meta&&t.meta.methodId});case Pi.SelectOptionFailed:case Pi.SelectOptionSucceeded:return nt(e,{isSelectingOption:!1,selectOptionMethodId:void 0});case Pi.WidgetInteractionStarted:return nt(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta&&t.meta.methodId});case Pi.WidgetInteractionFinished:case Pi.WidgetInteractionFailed:return nt(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}var Di;!function(e){e.SendSignInEmailRequested="SEND_SIGNIN_EMAIL_REQUESTED",e.SendSignInEmailSucceeded="SEND_SIGNIN_EMAIL_SUCCEEDED",e.SendSignInEmailFailed="SEND_SIGNIN_EMAIL_FAILED"}(Di||(Di={}));const Mi={errors:{},statuses:{}};function Ni(e=Mi,t){return i({data:Li,errors:r(zi,ze),statuses:Ui})(e,t)}function Li(e,t){return t.type===Di.SendSignInEmailSucceeded?nt(e,t.payload):e}function zi(e=Mi.errors,t){switch(t.type){case Di.SendSignInEmailRequested:case Di.SendSignInEmailSucceeded:return Fe(e,"sendError",void 0);case Di.SendSignInEmailFailed:return Fe(e,"sendError",t.payload);default:return e}}function Ui(e=Mi.statuses,t){switch(t.type){case Di.SendSignInEmailRequested:return Fe(e,"isSending",!0);case Di.SendSignInEmailFailed:case Di.SendSignInEmailSucceeded:return Fe(e,"isSending",!1);default:return e}}var Fi;!function(e){e.ApplyStoreCreditRequested="APPLY_STORE_CREDIT_REQUESTED",e.ApplyStoreCreditSucceeded="APPLY_STORE_CREDIT_SUCCEEDED",e.ApplyStoreCreditFailed="APPLY_STORE_CREDIT_FAILED"}(Fi||(Fi={}));const Bi={errors:{},statuses:{}};function xi(e=Bi,t){return i({errors:r(qi,ze),statuses:ji})(e,t)}function qi(e=Bi.errors,t){switch(t.type){case Fi.ApplyStoreCreditRequested:case Fi.ApplyStoreCreditSucceeded:return Fe(e,"applyError",void 0);case Fi.ApplyStoreCreditFailed:return Fe(e,"applyError",t.payload);default:return e}}function ji(e=Bi.statuses,t){switch(t.type){case Fi.ApplyStoreCreditRequested:return Fe(e,"isApplying",!0);case Fi.ApplyStoreCreditSucceeded:case Fi.ApplyStoreCreditFailed:return Fe(e,"isApplying",!1);default:return e}}const Gi={errors:{},statuses:{}};function Vi(e=Gi,t){return i({errors:r(Hi,ze),statuses:Wi})(e,t)}function Hi(e=Gi.errors,t){switch(t.type){case We.UpdateSubscriptionsRequested:case We.UpdateSubscriptionsSucceeded:return Fe(e,"updateError",void 0);case We.UpdateSubscriptionsFailed:return Fe(e,"updateError",t.payload);default:return e}}function Wi(e=Gi.statuses,t){switch(t.type){case We.UpdateSubscriptionsRequested:return Fe(e,"isUpdating",!0);case We.UpdateSubscriptionsFailed:case We.UpdateSubscriptionsSucceeded:return Fe(e,"isUpdating",!1);default:return e}}var Yi;!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"}(Yi||(Yi={}));const Ki={errors:{},statuses:{}};function $i(e=Ki,t){return i({data:Zi,errors:r(Ji,ze),statuses:Qi})(e,t)}function Zi(e,t){var n;switch(t.type){case Ve.LoadCheckoutSucceeded:case Ve.UpdateCheckoutSucceeded:case Fi.ApplyStoreCreditSucceeded:case Ye.UpdateBillingAddressSucceeded:case it.ApplyCouponSucceeded:case it.RemoveCouponSucceeded:case ot.CreateConsignmentsSucceeded:case ot.UpdateConsignmentSucceeded:case ot.DeleteConsignmentSucceeded:case ot.UpdateShippingOptionSucceeded:case ot.LoadShippingOptionsSucceeded:case rt.ApplyGiftCertificateSucceeded:case rt.RemoveGiftCertificateSucceeded:case Yi.VerifyCheckoutSucceeded:return nt(e,k(t.payload,["billingAddress","cart","consignments","customer","coupons","giftCertificates"]));case Ve.DeleteCheckoutSucceeded:return;case Pt.SubmitOrderSucceeded:return Fe(e,"orderId",t.payload&&t.payload.order.orderId);case He.HydrateInitialState:return nt(e,k(null===(n=t.payload)||void 0===n?void 0:n.checkout,["billingAddress","cart","consignments","customer","coupons","giftCertificates"]));default:return e}}function Ji(e=Ki.errors,t){switch(t.type){case Ve.LoadCheckoutRequested:case Ve.LoadCheckoutSucceeded:return Fe(e,"loadError",void 0);case Ve.LoadCheckoutFailed:return Fe(e,"loadError",t.payload);case Ve.UpdateCheckoutRequested:case Ve.UpdateCheckoutSucceeded:return Fe(e,"updateError",void 0);case Ve.UpdateCheckoutFailed:return Fe(e,"updateError",t.payload);case Ve.DeleteCheckoutRequested:case Ve.DeleteCheckoutSucceeded:return Fe(e,"deleteError",void 0);case Ve.DeleteCheckoutFailed:return Fe(e,"deleteError",t.payload);default:return e}}function Qi(e=Ki.statuses,t){switch(t.type){case Ve.LoadCheckoutRequested:return Fe(e,"isLoading",!0);case Ve.LoadCheckoutFailed:case Ve.LoadCheckoutSucceeded:return Fe(e,"isLoading",!1);case Ve.UpdateCheckoutRequested:return Fe(e,"isUpdating",!0);case Ve.UpdateCheckoutFailed:case Ve.UpdateCheckoutSucceeded:return Fe(e,"isUpdating",!1);case Ve.DeleteCheckoutRequested:return Fe(e,"isDeleting",!0);case Ve.DeleteCheckoutFailed:case Ve.DeleteCheckoutSucceeded:return Fe(e,"isDeleting",!1);case Yi.ExecuteRequested:return Fe(e,"isExecutingSpamCheck",!0);case Yi.ExecuteFailed:case Yi.ExecuteSucceeded:return Fe(e,"isExecutingSpamCheck",!1);default:return e}}const Xi=(er=de,(...e)=>{const t=e.pop();return er(...e,(...e)=>{const n=t(...e);return"function"==typeof n?ae(n):n})});var er,tr;!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"}(tr||(tr={}));class nr extends Ee{constructor(e){super(function(e){switch(e){case tr.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case tr.MissingCart:return"Unable to proceed because cart data is unavailable.";case tr.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case tr.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case tr.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case tr.MissingCheckoutConfig:case tr.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case tr.MissingOrder:return"Unable to proceed because order data is unavailable.";case tr.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case tr.MissingPayment:return"Unable to proceed because payment data is unavailable.";case tr.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case tr.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case tr.MissingPaymentProviderCustomer:return"Unable to proceed because payment provider customer is unavailable.";case tr.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}function ir(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}function rr(e){return function(e){const t=Object.create(e);return function(e,t){let n=Object.getPrototypeOf(e);for(;n;)t(n),n=Object.getPrototypeOf(n)}(e,n=>{Object.getOwnPropertyNames(n).forEach(n=>{"constructor"!==n&&"function"==typeof t[n]&&"_"!==n.charAt(0)&&(t[n]=((e,t)=>(...n)=>d(e[t].call(e,...n)))(e,n))})}),t}(e)}const or="b2bExtraField_";function ar(e){var t;const{fieldType:n,type:i}=function(e){switch(e){case"multiline_text":return{fieldType:"multiline",type:"string"};case"number":return{fieldType:"text",type:"integer"};case"dropdown":return{fieldType:"dropdown",type:"array"};default:return{fieldType:"text",type:"string"}}}(e.type);let r;return e.config.numberOfRows&&(r={rows:e.config.numberOfRows}),(null===(t=e.config.options)||void 0===t?void 0:t.length)&&(r=Object.assign(Object.assign({},r),{items:e.config.options.map(e=>({value:e,label:e}))})),{id:`${or}${e.id}`,name:`${or}${e.id}`,custom:!1,label:e.name,hidden:!e.visibleToStorefront,required:e.isRequired,default:null!=e.config.defaultValue?String(e.config.defaultValue):void 0,fieldType:n,type:i,maxLength:e.config.maxLength,max:e.config.maxValue,options:r}}const sr={"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"},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"},moneris:{provider:"moneris",method:"credit_card"},cba_mpgs:{provider:"cba_mpgs",method:"credit_card"},worldpayaccess:{provider:"worldpayaccess",method:"credit_card"},"worldpayaccess.credit_card":{provider:"worldpayaccess",method:"credit_card"},squarev2:{provider:"squarev2",method:"credit_card"},paypalcommercecreditcards:{provider:"paypalcommerce",method:"credit_card"},paypalcommerce:{provider:"paypalcommerce",method:"paypal"},bigcommerce_payments_creditcards:{provider:"bigcommerce_payments",method:"credit_card"},bigcommerce_payments:{provider:"bigcommerce_payments",method:"paypal"},tdonlinemart:{provider:"tdonlinemart",method:"credit_card"}};function dr(e){return M({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},g)}const cr={errors:{},statuses:{}};function ur(){const e=function(){const e=Xi(e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.receiptId},e=>()=>e),t=Xi(e=>e.errors.persistB2bMetadataError,e=>()=>e),n=Xi(e=>!!e.statuses.isPersisting,e=>()=>e);return se((i=bn)=>({getReceiptId:e(i),getPersistError:t(i),isPersisting:n(i)}))}(),t=function(){const e=Xi(e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.token},e=>()=>e),t=Xi(e=>e.errors.loadError,e=>()=>e),n=Xi(e=>!!e.statuses.isLoading,e=>()=>e);return se((i=Be)=>({getToken:e(i),getLoadError:t(i),isLoading:n(i)}))}(),n=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e,e=>()=>ir(e(),()=>new nr(tr.MissingBillingAddress))),n=Xi(e=>e.errors.updateError,e=>()=>e),i=Xi(e=>e.errors.continueAsGuestError,e=>()=>e),r=Xi(e=>e.errors.loadError,e=>()=>e),o=Xi(e=>!!e.statuses.isUpdating,e=>()=>e),a=Xi(e=>!!e.statuses.isContinuingAsGuest,e=>()=>e),s=Xi(e=>!!e.statuses.isLoading,e=>()=>e);return se((d=$e)=>({getBillingAddress:e(d),getBillingAddressOrThrow:t(d),getUpdateError:n(d),getContinueAsGuestError:i(d),getLoadError:r(d),isUpdating:o(d),isContinuingAsGuest:a(d),isLoading:s(d)}))}(),i=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e,e=>()=>ir(e(),()=>new nr(tr.MissingCart))),n=Xi(e=>e.errors.loadError,e=>()=>e),i=Xi(e=>!!e.statuses.isLoading,e=>()=>e),r=Xi(e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.locale},e=>()=>e);return se((o=at)=>({getCart:e(o),getCartOrThrow:t(o),getLoadError:n(o),isLoading:i(o),getLocale:r(o)}))}(),r=function(){const e=Xi(e=>e,e=>()=>e),t=Xi(e=>e.statuses,e=>ae(t=>{if(t){const n=e[t];return!0===(n&&n.isInitializing)}return z(e,{isInitializing:!0})})),n=Xi(e=>e.data,e=>ae((t,n)=>{const i=e[t];return!!i&&(n?!0===i.initializedContainers[n]:z(i.initializedContainers,e=>!0===e))})),i=Xi(e=>e.statuses,e=>ae(t=>{if(t){const n=e[t];return!0===(n&&n.isDeinitializing)}return z(e,{isDeinitializing:!0})})),r=Xi(e=>e.errors,e=>ae(t=>{const n=t?e[t]:l(x(e),e=>!(!e||!e.initializeError));return n&&n.initializeError})),o=Xi(e=>e.errors,e=>ae(t=>{const n=t?e[t]:l(x(e),e=>!(!e||!e.deinitializeError));return n&&n.deinitializeError}));return se((a=ht)=>({getState:e(a),isInitializing:t(a),isInitialized:n(a),isDeinitializing:i(a),getInitializeError:r(a),getDeinitializeError:o(a)}))}(),o=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e=>e.data,e=>t=>{if(!e)return;const{flashMessages:n}=e.context;return n?void 0!==t?n.filter(({type:e})=>t===e):n:void 0}),n=Xi(e=>e.data,(e,{formState:t})=>t&&t.data,(e,t={customerAccount:[],shippingAddress:[],billingAddress:[]})=>()=>e?Object.assign(Object.assign({},e.storeConfig),{formFields:t}):void 0),i=Xi(n,e=>()=>ir(e(),()=>new nr(tr.MissingCheckoutConfig))),r=Xi(e=>e.data&&e.data.context,e=>()=>e),o=Xi(e=>e.meta&&e.meta.externalSource,e=>()=>e),a=Xi(e=>{var t;return null===(t=e.meta)||void 0===t?void 0:t.host},e=>()=>e),s=Xi(e=>{var t;return null===(t=e.meta)||void 0===t?void 0:t.locale},e=>()=>e),d=Xi(e=>e.meta&&e.meta.variantIdentificationToken,e=>()=>e),c=Xi(e=>e.errors.loadError,e=>()=>e),u=Xi(e=>!!e.statuses.isLoading,e=>()=>e);return se((l=Ct,h)=>({getConfig:e(l),getFlashMessages:t(l),getStoreConfig:n(l,{formState:h}),getStoreConfigOrThrow:i(l,{formState:h}),getContextConfig:r(l),getExternalSource:o(l),getHost:a(l),getLocale:s(l),getVariantIdentificationToken:d(l),getLoadError:c(l),isLoading:u(l)}))}(),a=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e=>e.errors.loadError,e=>()=>e),n=Xi(e=>!!e.statuses.isLoading,e=>()=>e);return se((i=un)=>({getCountries:e(i),getLoadError:t(i),isLoading:n(i)}))}(),s=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e=>e.errors.removeCouponError,e=>()=>e),n=Xi(e=>e.errors.applyCouponError,e=>()=>e),i=Xi(e=>!!e.statuses.isApplyingCoupon,e=>()=>e),r=Xi(e=>!!e.statuses.isRemovingCoupon,e=>()=>e);return se((o=Ot)=>({getCoupons:e(o),getRemoveError:t(o),getApplyError:n(o),isApplying:i(o),isRemoving:r(o)}))}(),d=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e,e=>()=>ir(e(),()=>new nr(tr.MissingCustomer))),n=Xi(e=>e.errors.createError,e=>()=>e),i=Xi(e=>!!e.statuses.isCreating,e=>()=>e),r=Xi(e=>e.errors.createAddressError,e=>()=>e),o=Xi(e=>!!e.statuses.isCreatingAddress,e=>()=>e);return se((a=Ft)=>({getCustomer:e(a),getCustomerOrThrow:t(a),getCreateAccountError:n(a),isCreatingCustomerAccount:i(a),getCreateAddressError:r(a),isCreatingCustomerAddress:o(a)}))}(),c=function(){const e=Xi(e=>e.errors.signInMethodId,e=>e.errors.signInError,(e,t)=>n=>{if(!n||e===n)return t}),t=Xi(e=>e.errors.signOutMethodId,e=>e.errors.signOutError,(e,t)=>n=>{if(!n||e===n)return t}),n=Xi(e=>e.errors.executePaymentMethodCheckoutMethodId,e=>e.errors.executePaymentMethodCheckoutError,(e,t)=>n=>{if(!n||e===n)return t}),i=Xi(e=>e.errors.initializeMethodId,e=>e.errors.initializeErrors,(e,t)=>n=>{if(e&&t)return n?t[n]:t[e]}),r=Xi(e=>e.errors.widgetInteractionMethodId,e=>e.errors.widgetInteractionError,(e,t)=>n=>{if(!n||e===n)return t}),o=Xi(e=>e.statuses.signInMethodId,e=>e.statuses.isSigningIn,(e,t)=>n=>!(n&&e!==n||!t)),a=Xi(e=>e.statuses.signOutMethodId,e=>e.statuses.isSigningOut,(e,t)=>n=>!(n&&e!==n||!t)),s=Xi(e=>e.statuses.executePaymentMethodCheckoutMethodId,e=>e.statuses.isExecutingPaymentMethodCheckout,(e,t)=>n=>!(n&&e!==n||!t)),d=Xi(e=>e.statuses.initializeMethodId,e=>e.statuses.isInitializing,(e,t)=>n=>!(n&&e!==n||!t)),c=Xi(e=>e.data,e=>t=>!(!e[t]||!e[t].isInitialized)),u=Xi(e=>e.statuses.widgetInteractionMethodId,e=>e.statuses.isWidgetInteracting,(e,t)=>n=>!(n&&e!==n||!t));return se((l=Vt)=>({getSignInError:e(l),getSignOutError:t(l),getExecutePaymentMethodCheckoutError:n(l),getInitializeError:i(l),getWidgetInteractionError:r(l),isSigningIn:o(l),isSigningOut:a(l),isExecutingPaymentMethodCheckout:s(l),isInitializing:d(l),isInitialized:c(l),isWidgetInteracting:u(l)}))}(),h=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e=>e.errors.removeGiftCertificateError,e=>()=>e),n=Xi(e=>e.errors.applyGiftCertificateError,e=>()=>e),i=Xi(e=>!!e.statuses.isApplyingGiftCertificate,e=>()=>e),r=Xi(e=>!!e.statuses.isRemovingGiftCertificate,e=>()=>e);return se((o=Dt)=>({getGiftCertificates:e(o),getRemoveError:t(o),getApplyError:n(o),isApplying:i(o),isRemoving:r(o)}))}(),g=function(){const e=Xi(e=>e.data,e=>t=>{if(!e)return;const n=t.gateway?`${t.gateway}.${t.id}`:t.id,i=sr[n];return i?u(e,i):[]}),t=Xi(e=>e.data,(e=[])=>t=>{const n=x(sr);return e.find(e=>e.bigpayToken===t&&"card"===e.type&&n.some(t=>S(e,t)))}),n=Xi(t,e=>t=>ir(e(t),()=>new nr(tr.MissingPaymentInstrument))),i=Xi(e=>e.data,e=>()=>{if(e)return p(sr,t=>u(e,e=>S(e,t)))}),r=Xi(e=>e.meta,e=>()=>e),o=Xi(e=>e.errors.loadError,e=>()=>e),a=Xi(e=>e.errors.failedInstrument,e=>e.errors.deleteError,(e,t)=>n=>{if(!n||e===n)return t}),s=Xi(e=>e.statuses.isLoading,e=>()=>!!e),d=Xi(e=>e.statuses.deletingInstrument,e=>e.statuses.isDeleting,(e,t)=>n=>!(n&&e!==n||!t));return se((c=Yn)=>({getCardInstrument:t(c),getCardInstrumentOrThrow:n(c),getInstruments:i(c),getInstrumentsByPaymentMethod:e(c),getInstrumentsMeta:r(c),getLoadError:o(c),getDeleteError:a(c),isLoading:s(c),isDeleting:d(c)}))}(),m=function(){const e=Xi(e=>e.data,e=>(t=[],n)=>{const i=l(t,{code:n});return(e?e.shippingAddress:[]).map(e=>s(e,t,i))}),t=Xi(e=>e.data,e=>(t=[],n)=>{const i=l(t,{code:n});return(e?e.billingAddress:[]).map(e=>s(e,t,i))}),n=Xi(e=>e.data,e=>()=>e?e.customerAccount:[]),i=Xi(e=>e.extraFields,e=>()=>e&&e.address.length?e.address.map(ar):[]),r=Xi(e=>e.extraFields,e=>()=>e&&e.order.length?e.order.map(ar):[]),o=Xi(e=>e.errors.loadError,e=>()=>e),a=Xi(e=>!!e.statuses.isLoading,e=>()=>e);function s(e,t,n){return"countryCode"===e.name?function(e,t=[],n){if(!t.length)return e;const{code:i=""}=n||{},r=t.map(({code:e,name:t})=>({value:e,label:t}));return Object.assign(Object.assign({},e),{options:{items:r},default:i,type:"array",fieldType:"dropdown",itemtype:"string"})}(e,t,n):"stateOrProvince"===e.name?function(e,t){const{subdivisions:n=[],requiresState:i}=t||{};if(!n.length)return Object.assign(Object.assign({},e),{required:null!=i&&i});const r=n.map(({code:e,name:t})=>({value:e,label:t}));return Object.assign(Object.assign({},e),{name:"stateOrProvinceCode",options:{items:r},required:null==i||i,type:"array",fieldType:"dropdown",itemtype:"string"})}(e,n):"postalCode"===e.name?function(e,t){const{hasPostalCodes:n=[]}=t||{};return void 0===n?e:Object.assign(Object.assign({},e),{required:Boolean(n)})}(e,n):e}return se((s=nn)=>({getShippingAddressFields:e(s),getBillingAddressFields:t(s),getCustomerAccountFields:n(s),getAddressExtraFields:i(s),getOrderExtraFields:r(s),getLoadError:o(s),isLoading:a(s)}))}(),y=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e=>e.meta,e=>()=>e),n=Xi(e=>e.data,e=>(t,n)=>l(e,n?{id:t,gateway:n}:{id:t})),i=Xi(n,e=>(t,n)=>ir(e(t,n),()=>new nr(tr.MissingPaymentMethod))),r=Xi(e=>e.errors.loadError,e=>()=>e),o=Xi(e=>e.errors.loadMethodId,e=>e.errors.loadMethodError,(e,t)=>n=>{if(!n||e===n)return t}),a=Xi(e=>e.statuses.isLoading,e=>()=>!!e),s=Xi(e=>e.statuses.loadMethodId,e=>e.statuses.isLoadingMethod,(e,t)=>n=>!(n&&e!==n||!t));return se((d=Nn)=>({getPaymentMethods:e(d),getPaymentMethodsMeta:t(d),getPaymentMethod:n(d),getPaymentMethodOrThrow:i(d),getLoadError:r(d),getLoadMethodError:o(d),isLoading:a(d),isLoadingMethod:s(d)}))}(),f=function(){const e=Xi(e=>e.errors.initializeMethodId,e=>e.errors.initializeError,(e,t)=>n=>{if(!n||e===n)return t}),t=Xi(e=>e.errors.executeMethodId,e=>e.errors.executeError,(e,t)=>n=>{if(!n||e===n)return t}),n=Xi(e=>e.errors.finalizeMethodId,e=>e.errors.finalizeError,(e,t)=>n=>{if(!n||e===n)return t}),i=Xi(e=>e.errors.widgetInteractionMethodId,e=>e.errors.widgetInteractionError,(e,t)=>n=>{if(!n||e===n)return t}),r=Xi(e=>e.statuses.initializeMethodId,e=>e.statuses.isInitializing,(e,t)=>n=>!(n&&e!==n||!t)),o=Xi(e=>e.data,e=>t=>{const n=t.gatewayId?`${t.methodId}.${t.gatewayId}`:t.methodId;return!(!e[n]||!e[n].isInitialized)}),a=Xi(e=>e.statuses.executeMethodId,e=>e.statuses.isExecuting,(e,t)=>n=>!(n&&e!==n||!t)),s=Xi(e=>e.statuses.finalizeMethodId,e=>e.statuses.isFinalizing,(e,t)=>n=>!(n&&e!==n||!t)),d=Xi(e=>e.statuses.widgetInteractionMethodId,e=>e.statuses.isWidgetInteracting,(e,t)=>n=>!(n&&e!==n||!t));return se((c=qn)=>({getInitializeError:e(c),getExecuteError:t(c),getFinalizeError:n(c),getWidgetInteractingError:i(c),isInitializing:r(c),isInitialized:o(c),isExecuting:a(c),isFinalizing:s(c),isWidgetInteracting:d(c)}))}(),v=function(){const e=Xi(e=>e.data,e=>(t,n)=>{if(!e)return;const i=pi(hi({consignmentId:t,searchArea:n})),r=btoa(`${JSON.stringify(i)}`);return e[r]}),t=Xi(e=>e.errors.loadError,e=>()=>e),n=Xi(e=>!!e.statuses.isLoading,e=>()=>e);return se((i=mi)=>({getPickupOptions:e(i),getLoadError:t(i),isLoading:n(i)}))}(),C=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e,e=>()=>ir(e(),()=>new nr(tr.MissingPaymentProviderCustomer)));return se((n=ei)=>({getPaymentProviderCustomer:e(n),getPaymentProviderCustomerOrThrow:t(n)}))}(),I=function(){const e=Xi(e=>e.data,e=>t=>e[t]);return se((t=ri)=>({getCheckout:e(t)}))}(),w=function(){const e=Xi(e=>e.data,e=>()=>{const t=null==e?void 0:e.find(e=>!e.selectedPickupOption);return null==t?void 0:t.shippingAddress}),t=Xi(e,e=>()=>ir(e(),()=>new nr(tr.MissingShippingAddress))),n=Xi(e=>e.data,e=>()=>{const t=null==e?void 0:e.filter(e=>!e.selectedPickupOption);return t?t.map(e=>e.shippingAddress):[]}),i=Xi(n,e=>()=>ir(e(),()=>new nr(tr.MissingShippingAddress)));return se((r=si)=>({getShippingAddress:e(r),getShippingAddressOrThrow:t(r),getShippingAddresses:n(r),getShippingAddressesOrThrow:i(r)}))}(),E=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e=>e.errors.loadError,e=>()=>e),n=Xi(e=>e.statuses.isLoading,e=>()=>!!e);return se((i=Ci)=>({getShippingCountries:e(i),getLoadError:t(i),isLoading:n(i)}))}(),b=function(){const e=Xi(e=>e.errors.updateAddressMethodId,e=>e.errors.updateAddressError,(e,t)=>n=>{if(!n||e===n)return t}),t=Xi(e=>e.errors.selectOptionMethodId,e=>e.errors.selectOptionError,(e,t)=>n=>{if(!n||e===n)return t}),n=Xi(e=>e.errors.initializeMethodId,e=>e.errors.initializeError,(e,t)=>n=>{if(!n||e===n)return t}),i=Xi(e=>e.errors.widgetInteractionMethodId,e=>e.errors.widgetInteractionError,(e,t)=>n=>{if(!n||e===n)return t}),r=Xi(e=>e.statuses.updateAddressMethodId,e=>e.statuses.isUpdatingAddress,(e,t)=>n=>!(n&&e!==n||!t)),o=Xi(e=>e.statuses.selectOptionMethodId,e=>e.statuses.isSelectingOption,(e,t)=>n=>!(n&&e!==n||!t)),a=Xi(e=>e.statuses.initializeMethodId,e=>e.statuses.isInitializing,(e,t)=>n=>!(n&&e!==n||!t)),s=Xi(e=>e.data,e=>t=>!(!e[t]||!e[t].isInitialized)),d=Xi(e=>e.statuses.widgetInteractionMethodId,e=>e.statuses.isWidgetInteracting,(e,t)=>n=>!(n&&e!==n||!t));return se((c=Oi)=>({getUpdateAddressError:e(c),getSelectOptionError:t(c),getInitializeError:n(c),getWidgetInteractionError:i(c),isUpdatingAddress:r(c),isSelectingOption:o(c),isInitializing:a(c),isInitialized:s(c),isWidgetInteracting:d(c)}))}(),P=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e,e=>()=>ir(e(),()=>new nr(tr.MissingConsignments))),n=Xi(e=>e.data,e=>t=>{if(e&&e.length)return l(e,{id:t})}),i=Xi(e=>e.data,e=>t=>{if(e&&e.length)return l(e,e=>{return n=e.shippingAddress,i=t,_(dr(n),dr(i));var n,i})}),r=Xi(e=>e.data,e=>()=>{if(e&&e.length)return e[0].selectedShippingOption}),o=Xi(e=>e.errors.loadError,e=>()=>e),a=Xi(e=>e.errors.createError,e=>()=>e),s=Xi(e=>e.errors.loadShippingOptionsError,e=>()=>e),d=Xi(e,(e,{cart:t})=>t.getCart,(e,t)=>()=>{const n=t();if(!n)return[];const i=(e()||[]).reduce((e,t)=>e.concat(t.lineItemIds),[]);return(n.lineItems.physicalItems||[]).filter(e=>i.indexOf(e.id)<0)}),c=Xi(e=>e.errors.updateError,e=>t=>t?e[t]:l(e)),u=Xi(e=>e.errors.deleteError,e=>t=>t?e[t]:l(e)),h=Xi(i,c,a,(e,t,n)=>i=>{const r=e(i);return r?t(r.id):n()}),p=Xi(e=>e.errors.updateShippingOptionError,e=>t=>t?e[t]:l(e)),g=Xi(e=>e.statuses.isLoading,e=>()=>!0===e),m=Xi(e=>e.statuses.isLoadingShippingOptions,e=>()=>!0===e),y=Xi(e=>e.statuses.isCreating,e=>()=>!0===e),f=Xi(e=>e.statuses.isUpdating,e=>t=>t?!0===e[t]:!0===l(e)),S=Xi(e=>e.statuses.isDeleting,e=>t=>t?!0===e[t]:!0===l(e)),v=Xi(i,f,y,(e,t,n)=>i=>{const r=e(i);return r?t(r.id):n()}),C=Xi(e=>e.statuses.isUpdatingShippingOption,e=>t=>t?!0===e[t]:!0===l(e));return se((l=si,_)=>({getConsignments:e(l),getConsignmentsOrThrow:t(l),getConsignmentById:n(l),getConsignmentByAddress:i(l),getShippingOption:r(l),getLoadError:o(l),getCreateError:a(l),getLoadShippingOptionsError:s(l),getUnassignedItems:d(l,{cart:_}),getUpdateError:c(l),getDeleteError:u(l),getItemAssignmentError:h(l),getUpdateShippingOptionError:p(l),isLoading:g(l),isLoadingShippingOptions:m(l),isCreating:y(l),isUpdating:f(l),isDeleting:S(l),isAssigningItems:v(l),isUpdatingShippingOption:C(l)}))}(),O=function(){const e=Xi(e=>e.data,(e,{billingAddress:t})=>t.getBillingAddress,(e,{cart:t})=>t.getCart,(e,{customer:t})=>t.getCustomer,(e,{consignments:t})=>t.getConsignments,(e,{coupons:t})=>t.getCoupons,(e,{giftCertificates:t})=>t.getGiftCertificates,(e,t,n,i,r,o,a)=>()=>{const s=t(),d=n(),c=i(),u=r()||[],l=o()||[],h=a()||[];if(e&&d&&c)return Object.assign(Object.assign({},e),{billingAddress:s,cart:d,customer:c,consignments:u,coupons:l,giftCertificates:h})}),t=Xi(e,e=>()=>ir(e(),()=>new nr(tr.MissingCheckout))),n=Xi(e,e=>t=>{const n=e();if(!n)return;const i=n.grandTotal||0,r=n.customer.storeCredit||0;return t?Math.max(i-r,0):n.outstandingBalance}),i=Xi(e=>e.errors.loadError,e=>()=>e),r=Xi(e=>e.errors.updateError,e=>()=>e),o=Xi(e=>e.errors.deleteError,e=>()=>e),a=Xi(e=>e.statuses.isExecutingSpamCheck,e=>()=>!0===e),s=Xi(e=>e.statuses.isLoading,e=>()=>!0===e),d=Xi(e=>e.statuses.isUpdating,e=>()=>!0===e),c=Xi(e=>e.statuses.isDeleting,e=>()=>!0===e);return se((u=Ki,l,h,p,g,m,y)=>({getCheckout:e(u,{billingAddress:l,cart:h,consignments:p,coupons:g,customer:m,giftCertificates:y}),getCheckoutOrThrow:t(u,{billingAddress:l,cart:h,consignments:p,coupons:g,customer:m,giftCertificates:y}),getOutstandingBalance:n(u,{billingAddress:l,cart:h,consignments:p,coupons:g,customer:m,giftCertificates:y}),getLoadError:i(u),getUpdateError:r(u),getDeleteError:o(u),isExecutingSpamCheck:a(u),isLoading:s(u),isUpdating:d(u),isDeleting:c(u)}))}(),A=function(){const e=Xi(e=>e.data,(e,{billingAddress:t})=>t.getOrderBillingAddress(),(e,{coupons:t})=>t.getCoupons(),(e,t,n=[])=>()=>{if(e&&t)return Object.assign(Object.assign({},e),{billingAddress:t,coupons:n})}),t=Xi(e,e=>()=>ir(e(),()=>new nr(tr.MissingOrder))),n=Xi(e=>e.meta,e=>()=>e),i=Xi(e=>e.errors.loadError,e=>()=>e),r=Xi(e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.payments},(e=[])=>t=>{const n=e.find(({providerId:e})=>e===t);return null==n?void 0:n.paymentId}),o=Xi(e=>!!e.statuses.isLoading,e=>()=>e);return se((a=mn,s,d)=>({getOrder:e(a,{billingAddress:s,coupons:d}),getOrderOrThrow:t(a,{billingAddress:s,coupons:d}),getOrderMeta:n(a),getLoadError:i(a),getPaymentId:r(a),isLoading:o(a)}))}(),T=function(){const e=Xi(e=>e.data,e=>()=>e);return se((t=Cn)=>({getOrderBillingAddress:e(t)}))}(),k=function(){const e=Xi(({order:e})=>e.getOrderMeta,e=>()=>{const t=e();return t&&t.payment}),t=Xi(({order:e})=>e.getOrder,e=>()=>{const t=e();return l(t&&t.payments,({providerId:e})=>"giftcertificate"!==e&&"storecredit"!==e)}),n=Xi(({checkout:e})=>e.getCheckout,e=>()=>{const t=e();return l(t&&t.payments,({providerType:e})=>"PAYMENT_TYPE_HOSTED"===e)}),i=Xi(e,n,t,(e,t,n)=>()=>{const i=e();if(i&&i.id)return{providerId:i.id,gatewayId:i.gateway};const r=t()||n();return r&&r.providerId?{providerId:r.providerId,gatewayId:r.gatewayId}:void 0}),r=Xi(i,e=>()=>ir(e(),()=>new nr(tr.MissingPaymentId))),o=Xi(e,n,t,(e,t,n)=>()=>{const i=e();if(i&&i.status)return i.status.replace("PAYMENT_STATUS_","");const r=t()||n();return r?r.detail.step:void 0}),a=Xi(o,e=>()=>ir(e(),()=>new nr(tr.MissingPaymentStatus))),s=Xi(({order:e})=>e.getOrderMeta,e=>()=>{const t=e();return t&&t.token}),d=Xi(s,e=>()=>ir(e(),()=>new nr(tr.MissingPaymentToken))),c=Xi(e,e=>()=>{const t=e();return t&&t.redirectUrl}),u=Xi(c,e=>()=>ir(e(),()=>new nr(tr.MissingPaymentRedirectUrl))),h=Xi(({checkout:e})=>e.getOutstandingBalance,e=>(t=!1)=>{const n=e(t);return!!n&&n>0}),p=Xi(o,e=>t=>!(!t||!t.nonce)||"ACKNOWLEDGE"===e()||"FINALIZE"===e());return se((e,t)=>({getPaymentId:i({checkout:e,order:t}),getPaymentIdOrThrow:r({checkout:e,order:t}),getPaymentStatus:o({checkout:e,order:t}),getPaymentStatusOrThrow:a({checkout:e,order:t}),getPaymentToken:s({checkout:e,order:t}),getPaymentTokenOrThrow:d({checkout:e,order:t}),getPaymentRedirectUrl:c({checkout:e,order:t}),getPaymentRedirectUrlOrThrow:u({checkout:e,order:t}),isPaymentDataRequired:h({checkout:e,order:t}),isPaymentDataSubmitted:p({checkout:e,order:t})}))}(),R=function(){const e=Xi(e=>e.errors.applyError,e=>()=>e),t=Xi(e=>!!e.statuses.isApplying,e=>()=>e);return se((n=cr)=>({getApplyError:e(n),isApplying:t(n)}))}(),D=function(){const e=Xi(e=>e.errors.updateError,e=>()=>e),t=Xi(e=>!!e.statuses.isUpdating,e=>()=>e);return se((n=Gi)=>({getUpdateError:e(n),isUpdating:t(n)}))}(),M=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e=>e.errors.sendError,e=>()=>e),n=Xi(e=>!!e.statuses.isSending,e=>()=>e);return se((i=Mi)=>({getEmail:e(i),getSendError:t(i),isSending:n(i)}))}(),N=function(){const e=Xi(e=>e.data,e=>()=>e),t=Xi(e=>e.data,e=>t=>null==e?void 0:e.find(e=>e.region===t)),n=Xi(e=>e.errors.loadError,e=>()=>e),i=Xi(e=>e.statuses.isLoading,e=>()=>!!e);return se((r=Zt)=>({getExtensions:e(r),getExtensionByRegion:t(r),getLoadError:n(r),isLoading:i(r)}))}();return(u,l={})=>{const p=e(u.b2bPostOrder),_=t(u.b2bToken),S=n(u.billingAddress),L=i(u.cart),z=r(u.checkoutButton),U=a(u.countries),F=s(u.coupons),B=d(u.customer),x=c(u.customerStrategies),q=N(u.extensions),j=m(u.formFields),G=h(u.giftCertificates),V=g(u.instruments),H=T(u.orderBillingAddress),W=y(u.paymentMethods),Y=C(u.paymentProviderCustomer),K=f(u.paymentStrategies),$=v(u.pickupOptions),Z=I(u.remoteCheckout),J=w(u.consignments),Q=E(u.shippingCountries),X=b(u.shippingStrategies),ee=D(u.subscriptions),te=R(u.storeCredit),ne=M(u.signInEmail),ie=P(u.consignments,L),re=O(u.checkout,S,L,ie,F,B,G),oe=A(u.order,H,F),ae=k(re,oe),se={b2bPostOrder:p,b2bToken:_,billingAddress:S,cart:L,checkout:re,checkoutButton:z,config:o(u.config,u.formFields),consignments:ie,countries:U,coupons:F,customer:B,customerStrategies:x,extensions:q,form:j,giftCertificates:G,instruments:V,order:oe,orderBillingAddress:H,payment:ae,paymentMethods:W,paymentProviderCustomer:Y,paymentStrategies:K,pickupOptions:$,remoteCheckout:Z,shippingAddress:J,shippingCountries:Q,shippingStrategies:X,signInEmail:ne,subscriptions:ee,storeCredit:te};return l.shouldWarnMutation?(de=se,Object.keys(de).reduce((e,t)=>(e[t]=rr(de[t]),e),{})):se;var de}}function lr(e={},t){const n=(s=function(){const e=new De;return["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(t=>{e.register(t,(e,t)=>new Oe(e,t))}),e.register("invalid_payment_provider",e=>new we(e)),e.register("payment_config_not_found",e=>new we(e)),e}(),e=>Y(e).pipe(Q(e=>{if(e instanceof Error||e.payload instanceof Error)throw e;if((t=e.payload)&&"object"==typeof t&&["body","headers","status","statusText"].every(e=>Object.prototype.hasOwnProperty.call(t,e))){const t=e.payload.body&&e.payload.body.detail;throw Object.assign(Object.assign({},e),{payload:s.createError(e.payload,t)})}var t;throw e}))),r=ur(),o=i({b2bPostOrder:Pn,b2bToken:xe,billingAddress:Ze,cart:st,checkout:$i,checkoutButton:yt,config:It,consignments:di,countries:ln,coupons:At,customer:Bt,customerStrategies:Ht,extensions:Jt,formFields:rn,giftCertificates:Mt,instruments:Kn,orderBillingAddress:In,order:yn,payment:Dn,paymentMethods:Ln,paymentStrategies:jn,pickupOptions:yi,paymentProviderCustomer:ti,remoteCheckout:oi,shippingCountries:Ii,shippingStrategies:Ai,signInEmail:Ni,subscriptions:Vi,storeCredit:xi});var s;return a(o,e,Object.assign({actionTransformer:n,stateTransformer:e=>r(e)},t))}var hr,pr;!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"}(hr||(hr={}));class gr extends ve{constructor(e){super(function(e){switch(e){case hr.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case hr.MissingCart:return"Unable to proceed because cart data is unavailable.";case hr.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case hr.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case hr.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case hr.MissingCheckoutConfig:case hr.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case hr.MissingOrder:return"Unable to proceed because order data is unavailable.";case hr.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case hr.MissingPayment:return"Unable to proceed because payment data is unavailable.";case hr.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case hr.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case hr.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}function mr(e){return t=e.lineItems.physicalItems.filter(e=>!e.addedByPromotion),N(t,(e,t)=>e+t.quantity,0);var t}function yr(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}!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"}(pr||(pr={}));class fr extends ve{constructor(e){super(function(e){switch(e){case pr.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case pr.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case pr.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case pr.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}const _r={de:"eu",jp:"fe",uk:"eu",us:"na"};var Sr,vr,Cr,Ir,wr;!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"}(Sr||(Sr={})),function(e){e.Home="Home",e.Product="Product",e.Cart="Cart",e.Checkout="Checkout",e.Other="Other"}(vr||(vr={})),function(e){e.USD="USD",e.EUR="EUR",e.GBP="GBP",e.JPY="JPY"}(Cr||(Cr={})),function(e){e.PayAndShip="PayAndShip",e.PayOnly="PayOnly"}(Ir||(Ir={})),function(e){e.Gold="Gold",e.LightGray="LightGray",e.DarkGray="DarkGray"}(wr||(wr={}));var Er=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class br{constructor(e){this.amazonPayV2ScriptLoader=e}initialize(e){return Er(this,void 0,void 0,function*(){this.amazonPayV2SDK=yield this.amazonPayV2ScriptLoader.load(e),this.buttonParentContainer=this.buttonParentContainer||this.createAmazonPayButtonParentContainer()})}deinitialize(){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()}bindButton(e,t,n){this.getAmazonPayV2SDK().Pay.bindChangeAction(`#${e}`,{amazonCheckoutSessionId:t,changeAction:n})}createButton(e,t){this.amazonPayV2Button=this.getAmazonPayV2SDK().Pay.renderButton(`#${e}`,t)}prepareCheckout(e){const t=this.prepareRequestConfig(e);this.getAmazonPayV2Button().onClick(()=>{this.getAmazonPayV2Button().initCheckout(t)})}prepareCheckoutWithCreationRequestConfig(e){this.getAmazonPayV2Button().onClick(()=>Er(this,void 0,void 0,function*(){const t=yield e();if(t){const e=this.prepareRequestConfig(t.createCheckoutSessionConfig,t.estimatedOrderAmount,t.productType);this.getAmazonPayV2Button().initCheckout(e)}}))}signout(){return Er(this,void 0,void 0,function*(){return this.amazonPayV2SDK&&this.amazonPayV2SDK.Pay.signout(),Promise.resolve()})}renderAmazonPayButton({buttonColor:e,checkoutState:t,containerId:n,decoupleCheckoutInitiation:i=!1,methodId:r,options:o,placement:a}){const s=document.querySelector(`#${n}`);if(!s)return;const{id:d}=s.appendChild(this.getButtonParentContainer()),c=null!=o?o:this.getAmazonPayV2ButtonOptions(t,r,a,i,e);return this.createButton(d,c),this.getButtonParentContainer()}updateBuyNowFlowFlag(e){this.isBuyNowFlow=Boolean(e)}isPh4Enabled(e,t){const n=!!e["PROJECT-3483.amazon_pay_ph4"],i=!!e["INT-6885.amazon_pay_ph4_us_only"];return n&&i?"US"===t:n}prepareRequestConfig(e,t,n){const{publicKeyId:i}=e,r=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["publicKeyId"]);return Object.assign(Object.assign({createCheckoutSessionConfig:this.isEnvironmentSpecific(i)?r:e},t&&{estimatedOrderAmount:t}),n&&{productType:n})}createAmazonPayButtonParentContainer(){const e=Math.random().toString(16).substr(-4),t=document.createElement("div");return t.id=`amazonpay_button_parent_container_${e}`,t}getAmazonPayV2ButtonOptions(e,t,n,i=!1,r=wr.Gold){var o;const{getCart:a,getCheckout:s,getStoreConfigOrThrow:d,getPaymentMethodOrThrow:c}=this.getCheckoutState(e),{config:{merchantId:u,testMode:l},initializationData:h}=c(t);if(!h)throw new gr(hr.MissingPaymentMethod);const{checkoutLanguage:p,checkoutSessionMethod:g,createCheckoutSessionConfig:m,extractAmazonCheckoutSessionId:y,ledgerCurrency:f,publicKeyId:_=""}=h;if(!u||!f)throw new gr(hr.MissingPaymentMethod);const S={merchantId:u,ledgerCurrency:f,checkoutLanguage:p,placement:n,buttonColor:r};if(this.isBuyNowFlow)return Object.assign(Object.assign({},S),{sandbox:!!l});const v=a();S.productType=v&&0===mr(v)?Ir.PayOnly:Ir.PayAndShip;const{checkoutSettings:{features:C},storeProfile:{shopPath:I,storeCountryCode:w}}=d();if(this.isPh4Enabled(C,w)){if(!m)throw new gr(hr.MissingPaymentMethod);const e=null===(o=s())||void 0===o?void 0:o.outstandingBalance.toString(),t=null==v?void 0:v.currency.code,n=Object.assign({},S);let r;return this.isEnvironmentSpecific(_)?(n.publicKeyId=_,r=m):(n.sandbox=!!l,r=Object.assign(Object.assign({},m),{publicKeyId:_})),i||(n.createCheckoutSessionConfig=r),e&&t&&(n.estimatedOrderAmount={amount:e,currencyCode:t}),n}const E={method:g,url:`${I}/remote-checkout/${t}/payment-session`,extractAmazonCheckoutSessionId:y};return Object.assign(Object.assign({},S),{createCheckoutSession:E,sandbox:!!l})}isEnvironmentSpecific(e){return/^(SANDBOX|LIVE)/.test(e)}getAmazonPayV2SDK(){return this.getOrThrow(this.amazonPayV2SDK)}getButtonParentContainer(){return this.getOrThrow(this.buttonParentContainer)}getAmazonPayV2Button(){return this.getOrThrow(this.amazonPayV2Button)}getOrThrow(e){return yr(e,()=>new fr(pr.PaymentNotInitialized))}getCheckoutState(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:t=>e.paymentMethods.getPaymentMethodOrThrow(t)}:e;var t}}class Pr extends ve{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}class Or{constructor(e,t=window){this.scriptLoader=e,this.windowWithAmazonPay=t}load(e){return t=this,n=void 0,r=function*(){const{initializationData:t}=e,n=(null==t?void 0:t.region)||"us",i=_r[n];if(yield this.scriptLoader.loadScript(`https://static-${i}.payments-amazon.com/checkout.js`),!this.windowWithAmazonPay.amazon)throw new Pr;return this.windowWithAmazonPay.amazon},new((i=void 0)||(i=Promise))(function(e,o){function a(e){try{d(r.next(e))}catch(e){o(e)}}function s(e){try{d(r.throw(e))}catch(e){o(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,s)}d((r=r.apply(t,n||[])).next())});var t,n,i,r}}function Ar(e,t){return Object.assign(e,{resolveIds:t})}class Tr extends ve{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class kr extends ve{constructor(e){super(e||"An unexpected error has occurred during buy now cart creation process. Please try again later."),this.name="BuyNowCartCreationError",this.type="buy_now_cart_creation_error"}}class Rr extends ve{constructor(e){super(e||"An unexpected error has occurred during config creation process. Please try again later."),this.name="AmazonPayV2ConfigCreationError",this.type="amazon_pay_v2_config_creation_error"}}function Dr(e){return e instanceof Object&&"buyNowInitializeOptions"in e}var Mr=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Nr{constructor(e,t,n){this.paymentIntegrationService=e,this.amazonPayV2PaymentProcessor=t,this.amazonPayV2ConfigRequestSender=n}initialize(e){return Mr(this,void 0,void 0,function*(){var t;const{methodId:n,containerId:i,amazonpay:r}=e,{buttonColor:o}=r||{};if(!n||!i)throw new Tr('Unable to proceed because "methodId" or "containerId" argument is not provided.');const{getPaymentMethodOrThrow:a}=this.paymentIntegrationService.getState(),s=a(n);yield this.amazonPayV2PaymentProcessor.initialize(s),r||(yield this.paymentIntegrationService.loadDefaultCheckout());const d=Dr(r)?void 0:r;Dr(r)&&"function"==typeof(null===(t=r.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody)&&(this._buyNowInitializeOptions=r.buyNowInitializeOptions,this.amazonPayV2PaymentProcessor.updateBuyNowFlowFlag(!0)),this.amazonPayV2PaymentProcessor.renderAmazonPayButton({checkoutState:this.paymentIntegrationService.getState(),containerId:i,methodId:n,options:d,placement:vr.Cart,buttonColor:o}),this._buyNowInitializeOptions&&this.amazonPayV2PaymentProcessor.prepareCheckoutWithCreationRequestConfig(this._getCheckoutCreationRequestConfig.bind(this))})}deinitialize(){return this.amazonPayV2PaymentProcessor.deinitialize()}_createBuyNowCartOrThrow(){return Mr(this,void 0,void 0,function*(){var e,t;const n=null===(t=null===(e=this._buyNowInitializeOptions)||void 0===e?void 0:e.getBuyNowCartRequestBody)||void 0===t?void 0:t.call(e);if(!n)throw new gr(hr.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(n)}catch(e){throw new kr}})}_createCheckoutConfig(e){return Mr(this,void 0,void 0,function*(){try{const t=(yield this.amazonPayV2ConfigRequestSender.createCheckoutConfig(e)).body,{payload:n,public_key:i}=t,r=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["payload","public_key"]);return Object.assign({payloadJSON:n,publicKeyId:i},r)}catch(e){throw new Rr}})}_getCheckoutCreationRequestConfig(){return Mr(this,void 0,void 0,function*(){const e=yield this._createBuyNowCartOrThrow(),t={amount:String(e.baseAmount),currencyCode:e.currency.code};return{createCheckoutSessionConfig:yield this._createCheckoutConfig(e.id),estimatedOrderAmount:t,productType:0===mr(e)?Ir.PayOnly:Ir.PayAndShip}})}}const Lr="This API endpoint is for internal use only and may change in the future";var zr;!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(zr||(zr={}));const Ur=zr,Fr={"X-Checkout-SDK-Version":"1.934.1"};class Br{constructor(e){this._requestSender=e}createCheckoutConfig(e){const t={cartId:e},n=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return this._requestSender.post("/api/storefront/payment/amazonpay",{headers:n,body:t})}}const xr=Ar(t=>{const n=e(),i=new Br(n),r=new br(new Or(le()));return new Nr(t,r,i)},[{id:"amazonpay"}]);function qr(e,t,n=!0){var i;return null!==(i=e[t])&&void 0!==i?i:n}const jr="3.128.0",Gr="3.123.2",Vr="3.106.0";class Hr{constructor(e){this.paymentIntegrationService=e,this.braintreeWindow=window}getSDKVersion(){const e=this.paymentIntegrationService.getState().getStoreConfig(),t=(null==e?void 0:e.checkoutSettings.features)||{};return this.getPreloadedSDKVersion()||(qr(t,"PAYPAL-5809.braintree_hosted_fields_fix_version")?jr:qr(t,"PAYPAL-5636.update_braintree_sdk_version")?Gr:Vr)}getPreloadedSDKVersion(){const e=this.braintreeWindow.braintree;if(e){const t=l(Object.values(e),e=>!!e.VERSION);return null==t?void 0:t.VERSION}}}class Wr extends ve{constructor(e){super(e||"Unsupported browser error"),this.name="UnsupportedBrowserError",this.type="unsupported_browser"}}var Yr,Kr,$r,Zr,Jr,Qr,Xr;function eo(e){return Boolean("object"==typeof e&&null!==e&&("type"in e||"message"in e||"code"in e))}!function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(Yr||(Yr={})),function(e){e.Completed="COMPLETED",e.Pending="PENDING",e.Failed="FAILED"}(Kr||(Kr={})),function(e){e.TRUSTLY="trustly"}($r||($r={})),function(e){e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="cancelled",e.UNRECOGNIZED="unrecognized"}(Zr||(Zr={})),function(e){e.Customer="CUSTOMER",e.Merchant="MERCHANT",e.Network="NETWORK",e.Internal="INTERNAL",e.Unknown="UNKNOWN"}(Jr||(Jr={})),function(e){e.KountNotEnabled="DATA_COLLECTOR_KOUNT_NOT_ENABLED"}(Qr||(Qr={})),function(e){e.Visa="visa",e.Mastercard="mastercard",e.AmericanExpress="american-express",e.DinersClub="diners-club",e.Discover="discover",e.Jcb="jcb",e.UnionPay="union-pay",e.Maestro="maestro",e.Elo="elo",e.Mir="mir",e.Hiper="hiper",e.Hipercard="hipercard"}(Xr||(Xr={}));var to,no,io,ro=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class oo{constructor(e){this.braintreeScriptLoader=e}initialize(e){this.setClientToken(e)}deinitialize(){return ro(this,void 0,void 0,function*(){yield this.teardownModule(this.dataCollector),this.dataCollector=void 0})}getClient(){return ro(this,void 0,void 0,function*(){if(!this.client){const e=this.getClientTokenOrThrow(),t=yield this.braintreeScriptLoader.loadClient();this.client=yield t.create({authorization:e})}return this.client})}getDataCollectorOrThrow(e){return ro(this,void 0,void 0,function*(){const t={deviceData:void 0,teardown:()=>Promise.resolve()};if(!this.dataCollector)try{const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadDataCollector(),i=Object.assign({client:t,kount:!0},e);this.dataCollector=yield n.create(i)}catch(e){if(eo(e)&&e.code===Qr.KountNotEnabled)return t;throw e}return this.dataCollector})}getBraintreeGooglePayment(){return ro(this,void 0,void 0,function*(){if(!this.googlePayment){const[e,t]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadGooglePayment()]);this.googlePayment=yield t.create({client:e})}return this.googlePayment})}getBraintreeThreeDS(){return ro(this,void 0,void 0,function*(){if(!this.threeDS){const[e,t]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()]);this.threeDS=yield t.create({client:e,version:2})}return this.threeDS})}getBraintreeLocalPayment(e){return ro(this,void 0,void 0,function*(){if(!this.braintreeLocalPayment){const[t,n]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadLocalPayment()]);this.braintreeLocalPayment=yield new Promise((i,r)=>{n.create({client:t,merchantAccountId:e},(e,t)=>{e&&r(e),i(t)})})}return this.braintreeLocalPayment})}getUsBankAccount(){return ro(this,void 0,void 0,function*(){if(!this.usBankAccount){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadUsBankAccount();this.usBankAccount=yield t.create({client:e})}return this.usBankAccount})}getBraintreeVisaCheckout(){return this.visaCheckout||(this.visaCheckout=Promise.all([this.getClient(),this.braintreeScriptLoader.loadVisaCheckout()]).then(([e,t])=>t.create({client:e}))),this.visaCheckout}getVisaCheckoutSdk(e){return ro(this,void 0,void 0,function*(){return this.visaCheckoutSDK||(this.visaCheckoutSDK=yield this.braintreeScriptLoader.loadVisaCheckoutSdk(e)),this.visaCheckoutSDK})}getVenmoCheckoutOrThrow(){return ro(this,void 0,void 0,function*(){if(!this.braintreeVenmo){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadVenmoCheckout(),n={client:e,allowDesktop:!0,paymentMethodUsage:"multi_use"},i=yield t.create(n);if(!i.isBrowserSupported())throw new Wr;this.braintreeVenmo=i}return this.braintreeVenmo})}setClientToken(e){this.clientToken=e}getClientTokenOrThrow(){if(!this.clientToken)throw new fr(pr.PaymentNotInitialized);return this.clientToken}teardownModule(e){return e?e.teardown():Promise.resolve()}}!function(e){e.Sandbox="sandbox",e.Production="production"}(to||(to={})),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"}(no||(no={})),function(e){e.CardCode="cardCode",e.CardCodeVerification="cardCodeVerification",e.CardExpiry="cardExpiry",e.CardName="cardName",e.CardNumber="cardNumber",e.CardNumberVerification="cardNumberVerification"}(io||(io={}));const ao={[Vr]:{[no.Client]:"sha384-26BXDNnJI23JYRyFBj4xe4sVNrUSSiSSu11kxVXNM/vEPONm4LuL00w6ZaTgQewt",[no.PaypalCheckout]:"sha384-B+vzbZwnQtzWBthpkT4TXKUibO65tyeK7eCxSvpblgprTep2+IAXB2Cxxjrn710O",[no.Paypal]:"sha384-uyAGL1/3+XJAHnGoNy4eCoXdzJ4f7Ilzp+6w9PNnEjs6DCCz9WMyJjMN1gzc78U+",[no.LocalPayment]:"sha384-LIvOEMkIVEwVuYBdVOQc1AC5YbGGlwyfUheS0ACK218D2STuVYQlZ4FyEPowAEfT",[no.DataCollector]:"sha384-1bo9JDz+Kscthc085cCKWur8CLwUoBpoNyxsDi7932mCl0zFq3A5mv+FQLw9GHpV",[no.UsBankAccount]:"sha384-xmHBVaU+w74V+OebD3AaPONFxHUGMf+QRs8G/JxVPXNNP7MDa2jL0ICWHIe2tTfJ",[no.GooglePayment]:"sha384-WKDJl8mqoP82qZpMGH6AbZxnvXnSW8ILV4M64CyMLiugGMwu7LyP89wjCkHqsiBe",[no.ThreeDSecure]:"sha384-VQUlpGHzsGvs5XeiGFip7EXRsvoHWEXDVmgCacfbyieZI9mdBOqq3NSoyo28OCOB",[no.VisaCheckout]:"sha384-yx7mADfzTN0T43Q6rlH49LIg1EJ0iUZgBp/EczX9LXsUGkySgxrD+nWHQRBkyfoT",[no.Venmo]:"sha384-QX4rPjoj1ZDhuG0aSyKs56lEKDqTMTcjYxUHY1SzO5VZDsqIE2NTkqot7KNSCyov",[no.HostedFields]:"sha384-VvYBACfSu0Cr/J32uKmxG7AXcNOJE1AzIIL3kbikyS7YKp5fz5Is+NzNP/lyauNy",[no.Fastlane]:"sha384-9oGsZMRZwpGtDEDYa/dFt76dECqj1xAni9gIKgc3KfMIiRnR73nEeeUDLiBzxhFa"},[Gr]:{[no.Client]:"sha384-o+nbQGcwNNxIBeXeu3+XmbSq+Cg8R3EN3N0l5hXCgMMU2RGY0t1z0LroSEIAbfAO",[no.PaypalCheckout]:"sha384-WrfbWPBS4mH86GAoycPSgiH8hQ8KH7A67C93Hjhunv/xhNk2YpBn3wbFA4Fhg9U/",[no.Paypal]:"sha384-VF389nvvrRUgDsTXMxTYORDtVegB9IQa3Cxr//DyJnLYnz8/X8VCzEvck2c+Megt",[no.LocalPayment]:"sha384-tZKx2rEQbfmZpoPSY5VPmJEhaq4X75dLvwHMs3VE9U+C8lPyw+hWTIL1+GPvWCIH",[no.DataCollector]:"sha384-E6k3wOpP7syCDDwaRDLF06942Y00NkbwJvWi2OQXwwKzGwG5fd3E7RFUvCCecfvO",[no.UsBankAccount]:"sha384-258FON8LZGG0W9Qaz4Jij83pZHu30YnKjJA7gNulLBh6CclkucgF+tHDQuYFRYfW",[no.GooglePayment]:"sha384-taJ2p/0+n0VH328POAoBiuEbL3tnHUTE9S42hK1V+Txs3X+QYjZOyKW35JgHRFfO",[no.ThreeDSecure]:"sha384-+NSZH4Zj3sO5bdWvPKhU5N16QDxeueTVTnUVeleeESkhLSaz4Ob1hh/5myecc9Ym",[no.VisaCheckout]:"sha384-66DiBjghxk1OmBj8aksN8gbQ+CwoQcx1vPfiXUN08g1iQVM+BwewF0p7toM3i7SS",[no.Venmo]:"sha384-B5UwY42kE4RoLoWbQ7YpqosUlUad2/DlGWiw0HhoZbSPk30CQAaSA10ohyLDTkDU",[no.HostedFields]:"sha384-Aw9EesSaUeWxe36PqEHiOyOyOq8M6CIb1gw7/yHNVPRzGtFXXcd2OQ8qXrIlOj2P",[no.Fastlane]:"sha384-rhBL1hpZ71JqG+2TsT0Dih47mbjx8cjJCpeZjk9tw3df1gFMKfCTmMyZunhr7H4Y"},[jr]:{[no.Client]:"sha384-0WNxksIpRP+fYZiIdr12g6DBUQfLDzYCQJZtR/C8KkcwSGhPHfcFp3tTaGcMyFTq",[no.PaypalCheckout]:"sha384-lWM1jk4BOxoDNV6Kop7tVNvQgINlmEVz0c/OwM+HNHK3QC8xqwd54Ovrt2QRDTjh",[no.Paypal]:"sha384-fXUmVxC2EMZBDXZ7eTHSTL/LFBrHej/MSXT/vTBXvra4lzgLNGvREAp+x0GYObuH",[no.LocalPayment]:"sha384-pha1xGuGSkmZH5x9aqHvRaO4xLea7rmQ/79PFj9zxNzxuFcOWZg7gOP7FibygOEC",[no.DataCollector]:"sha384-Q6PI2F9eekWbAxhroybl+aEcvqhdowN/EQlGwBUyJOzPFn9982u9xl6SU6XfGKzc",[no.UsBankAccount]:"sha384-W3RLQSKJL1tQ3+Y7mP6tmkamtZ8bV4Yw/XxL9Jj5JtXHraD8loMF8hAIG5m2zK7F",[no.GooglePayment]:"sha384-TITQMsFWA3elDNGP2mWz2oKBo4qjt+TlqzovcaPoeBiAh/wPBi6nae50ADdgU1/i",[no.ThreeDSecure]:"sha384-YiycYN89ZlL/Evcaq4y1ajW1mhd7JYfZBDuOwHtIn4/Jnm20GL+/XCM+zYAwWD8D",[no.VisaCheckout]:"sha384-/OdaTv9qrkKzjObtUe6yzfDhHozFW/+uXlrSl736sOZRJpjGQETvpYXqMFFg69xv",[no.Venmo]:"sha384-dA+ojdW9vbJS4JavcXyOs9d5uZHJg5dNtYupoPSH2zsXIiYDVS5amLb/u8qmQ6oz",[no.HostedFields]:"sha384-31ZkS58+iaWsW06ftW52zzVZFp43WPd7pNYRiddYynSNg6Oh7WGbSFGorAUH6T1z",[no.Fastlane]:"sha384-jlbrwNvL3HvLAUCtLSmrnQ2GH1udCUrRS/bVmReAS5fuIVvcW8Pko/Gkg82tlgtr"}};var so,co=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class uo{constructor(e,t,n){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSDKVersionManager=n}loadClient(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.Client,"client.min.js")})}loadFastlane(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.Fastlane,"fastlane.min.js")})}loadPaypalCheckout(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.PaypalCheckout,"paypal-checkout.min.js")})}loadPaypal(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.Paypal,"paypal.min.js")})}loadLocalPayment(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.LocalPayment,"local-payment.min.js")})}loadDataCollector(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.DataCollector,"data-collector.min.js")})}loadUsBankAccount(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.UsBankAccount,"us-bank-account.min.js")})}loadGooglePayment(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.GooglePayment,"google-payment.min.js")})}load3DS(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.ThreeDSecure,"three-d-secure.min.js")})}loadVisaCheckout(){return this.loadBraintreeModuleOrThrow(no.VisaCheckout,"visa-checkout.min.js")}loadVenmoCheckout(){return this.loadBraintreeModuleOrThrow(no.Venmo,"venmo.min.js")}loadHostedFields(){return co(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(no.HostedFields,"hosted-fields.min.js")})}loadVisaCheckoutSdk(e){return co(this,void 0,void 0,function*(){if(this.braintreeHostWindow.V)return this.braintreeHostWindow.V;const t=e?"sha384-0eu1s1GtqzXlL9DtLgmwzC5WWlEH/ADRM0n38cVQkvtT+W/gey96rcb1LwuUOPDm":"sha384-1f1csvP3ZFxg4dILH1GaY4LHlZ0oX7Rk83rxmLlwbnIi4TM0NYzXoev1VoEiVDS6";return this.scriptLoader.loadScript(`//${e?"sandbox-":""}assets.secure.checkout.visa.com/checkout-widget/resources/js/integration/v1/sdk.js`,{async:!0,attributes:{integrity:t,crossorigin:"anonymous"}}).then(()=>{if(!this.braintreeHostWindow.V)throw new Pr;return this.braintreeHostWindow.V})})}loadBraintreeModuleOrThrow(e,t){return co(this,void 0,void 0,function*(){let n=this.getBraintreeModule(e);if(n)return n;const i=this.braintreeSDKVersionManager.getSDKVersion(),r=`//js.braintreegateway.com/web/${i}/js/${t}`,o=i in ao?this.getIntegrityValuesByModuleName(e,i):void 0;if(yield this.scriptLoader.loadScript(r,o?{async:!0,attributes:{integrity:o,crossorigin:"anonymous"}}:void 0),n=this.getBraintreeModule(e),!n)throw new Pr;return n})}getBraintreeModule(e){var t;return null===(t=this.braintreeHostWindow.braintree)||void 0===t?void 0:t[e]}getIntegrityValuesByModuleName(e,t){const n=ao[t][e];if(!n)throw new Error("Unexpected fileName value");return n}}class lo extends ve{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}!function(e){e.BRAINTREE="braintree",e.BRAINTREE_FASTLANE="braintreeacceleratedcheckout"}(so||(so={}));var ho,po,go=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};!function(e){e.Subtotal="Subtotal",e.Shipping="Shipping"}(ho||(ho={})),function(e){e.Black="black",e.White="white",e.WhiteBorder="white-border"}(po||(po={}));class mo{constructor(e,t,n,i,r){this._requestSender=e,this._paymentIntegrationService=t,this._sessionFactory=n,this._braintreeSdk=i,this._applePayScriptLoader=r,this._onAuthorizeCallback=T,this._subTotalLabel=ho.Subtotal,this._shippingLabel=ho.Shipping}initialize(e){return go(this,void 0,void 0,function*(){var t,n;const{methodId:i,containerId:r,applepay:o}=e;if(!i||!o)throw new gr(hr.MissingPaymentMethod);yield this._applePayScriptLoader.loadSdk();const{onPaymentAuthorize:a,buyNowInitializeOptions:s,requiresShipping:d}=o;this._requiresShipping=d,this._buyNowInitializeOptions=s,this._onAuthorizeCallback=a,s||(yield this._paymentIntegrationService.loadDefaultCheckout());const c=this._paymentIntegrationService.getState();return this._paymentMethod=c.getPaymentMethodOrThrow(i),c.getCart()&&(yield this._paymentIntegrationService.verifyCheckoutSpamProtection()),(null===(t=this._paymentMethod.initializationData)||void 0===t?void 0:t.gateway)===so.BRAINTREE&&this._paymentMethod.clientToken&&this._braintreeSdk.initialize(this._paymentMethod.clientToken),this._applePayButton=this._createButton(r,null===(n=this._paymentMethod.initializationData)||void 0===n?void 0:n.styleOption),this._applePayButton.addEventListener("click",this._handleWalletButtonClick.bind(this)),Promise.resolve()})}deinitialize(){return Promise.resolve()}_createButton(e,t){const n=document.getElementById(e);if(!n)throw new Tr("Unable to create wallet button without valid container ID.");const i=this._createApplePayButtonElement(t);return n.appendChild(i),i}_createApplePayButtonElement(e){const t=document.createElement("apple-pay-button");return t.setAttribute("buttonstyle",(e=>{switch(e){case po.White:return"white";case po.WhiteBorder:return"white-outline";case po.Black:default:return"black"}})(e)),t.setAttribute("type","plain"),t.setAttribute("style","--apple-pay-button-width: 100%; --apple-pay-button-height: 40px; --apple-pay-button-border-radius: 4px;"),t}_handleWalletButtonClick(e){return go(this,void 0,void 0,function*(){var t;if(e.preventDefault(),!this._paymentMethod||!this._paymentMethod.initializationData)throw new gr(hr.MissingPaymentMethod);if(this._buyNowInitializeOptions&&"function"==typeof this._buyNowInitializeOptions.getBuyNowCartRequestBody){const{countryCode:e,currencyCode:n,merchantCapabilities:i,supportedNetworks:r,storeName:o}=this._paymentMethod.initializationData,a=this._getRequestWithEmptyTotal(e,n,r,i);this._requiresShipping&&(null===(t=a.requiredShippingContactFields)||void 0===t||t.push("postalAddress"));const s=this._sessionFactory.create(a);this._handleApplePayEvents(s,this._paymentMethod,o),s.begin()}else{const e=this._paymentIntegrationService.getState(),t=e.getCartOrThrow(),n=e.getStoreConfigOrThrow(),i=e.getCheckoutOrThrow(),r=this._getBaseRequest(t,i,n,this._paymentMethod),o=this._sessionFactory.create(r);this._handleApplePayEvents(o,this._paymentMethod,n.storeProfile.storeName),o.begin()}})}_getRequestWithEmptyTotal(e,t,n,i){return{countryCode:e,currencyCode:t,supportedNetworks:n,merchantCapabilities:i,total:{label:"",amount:"0",type:"pending"},requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:["email","phone"]}}_getBaseRequest(e,t,n,i){var r;const{storeProfile:{storeCountryCode:o,storeName:a}}=n,{currency:{code:s,decimalPlaces:d}}=e,{initializationData:{merchantCapabilities:c,supportedNetworks:u}}=i,l=e.lineItems.physicalItems.length>0,h={requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:["email","phone"],countryCode:o,currencyCode:s,merchantCapabilities:c,supportedNetworks:u,lineItems:[],total:l?{label:a,amount:`${t.grandTotal.toFixed(d)}`,type:"pending"}:{label:a,amount:`${t.grandTotal.toFixed(d)}`,type:"final"}};if(l)null===(r=h.requiredShippingContactFields)||void 0===r||r.push("postalAddress");else{const e=[{label:this._subTotalLabel,amount:`${t.subtotal.toFixed(d)}`}];t.taxes.forEach(t=>e.push({label:t.name,amount:`${t.amount.toFixed(d)}`})),h.lineItems=e}return h}_handleApplePayEvents(e,t,n){e.onvalidatemerchant=n=>go(this,void 0,void 0,function*(){try{const{body:i}=yield this._onValidateMerchant(t,n);e.completeMerchantValidation(i)}catch(e){throw new Error("Merchant validation failed")}}),this._buyNowInitializeOptions&&!this._requiresShipping&&(e.onpaymentmethodselected=()=>go(this,void 0,void 0,function*(){yield this._createBuyNowCart(),this._handlePaymentMethodSelected(e)})),e.onshippingcontactselected=t=>go(this,void 0,void 0,function*(){this._buyNowInitializeOptions&&this._requiresShipping&&(yield this._createBuyNowCart()),yield this._handleShippingContactSelected(e,n,t)}),e.onshippingmethodselected=t=>go(this,void 0,void 0,function*(){yield this._handleShippingMethodSelected(e,n,t)}),e.oncancel=()=>go(this,void 0,void 0,function*(){try{const e=`/remote-checkout/${t.id}/signout`;return yield this._requestSender.get(e),yield this._paymentIntegrationService.loadCheckout()}catch(e){throw new lo}}),e.onpaymentauthorized=n=>go(this,void 0,void 0,function*(){return this._onPaymentAuthorized(n,e,t)})}_createBuyNowCart(){return go(this,void 0,void 0,function*(){var e,t;try{const n=null===(t=null===(e=this._buyNowInitializeOptions)||void 0===e?void 0:e.getBuyNowCartRequestBody)||void 0===t?void 0:t.call(e);if(!n)throw new gr(hr.MissingCart);const i=yield this._paymentIntegrationService.createBuyNowCart(n);yield this._paymentIntegrationService.loadCheckout(i.id);const r=this._paymentIntegrationService.getState(),{shouldExecuteSpamCheck:o}=r.getCheckoutOrThrow();o&&(yield this._paymentIntegrationService.verifyCheckoutSpamProtection())}catch(e){throw new kr}})}_handlePaymentMethodSelected(e){const t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow(),i=t.getStoreConfigOrThrow(),r=t.getCheckoutOrThrow();if(!this._paymentMethod||!this._paymentMethod.initializationData)throw new gr(hr.MissingPaymentMethod);const o=this._getBaseRequest(n,r,i,this._paymentMethod);delete o.total.type,e.completePaymentMethodSelection({newTotal:o.total,newLineItems:o.lineItems})}_handleShippingContactSelected(e,t,n){return go(this,void 0,void 0,function*(){var i;const r=this._transformContactToAddress(n.shippingContact);try{yield this._paymentIntegrationService.updateShippingAddress(r)}catch(t){throw e.abort(),new Error("Shipping address update failed")}let o=this._paymentIntegrationService.getState();const{currency:{decimalPlaces:a}}=o.getCartOrThrow();let s=o.getCheckoutOrThrow();const d=null===(i=s.consignments[0].selectedShippingOption)||void 0===i?void 0:i.id,c=s.consignments[0].availableShippingOptions,u=null==c?void 0:c.find(({id:e})=>e===d),l=null==c?void 0:c.filter(e=>e.id!==d),h=u?[{label:u.description,amount:`${u.cost.toFixed(a)}`,detail:u.additionalDescription,identifier:u.id}]:[];if(l&&[...l.filter(e=>e.isRecommended),...l.filter(e=>!e.isRecommended)].forEach(e=>h.push({label:e.description,amount:`${e.cost.toFixed(a)}`,detail:e.additionalDescription,identifier:e.id})),!(c instanceof Array))throw new Error("Shipping options not available.");if(0===c.length)return void e.completeShippingContactSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,[],{type:"pending",label:t,amount:`${s.grandTotal.toFixed(a)}`},[]);const p=c.find(e=>e.isRecommended),g=p?p.id:c[0].id,m=u?u.id:g;try{yield this._updateShippingOption(m)}catch(e){throw new Error("Shipping options update failed")}o=this._paymentIntegrationService.getState(),s=o.getCheckoutOrThrow(),e.completeShippingContactSelection({newShippingMethods:h,newTotal:{type:"final",label:t,amount:`${s.grandTotal.toFixed(a)}`},newLineItems:this._getUpdatedLineItems(s,a)})})}_handleShippingMethodSelected(e,t,n){return go(this,void 0,void 0,function*(){const{shippingMethod:{identifier:i}}=n;try{yield this._updateShippingOption(i)}catch(t){throw e.abort(),new Error("Shipping option selection update failed.")}const r=this._paymentIntegrationService.getState(),{currency:{decimalPlaces:o}}=r.getCartOrThrow(),a=r.getCheckoutOrThrow();e.completeShippingMethodSelection({newTotal:{type:"final",label:t,amount:`${a.grandTotal.toFixed(o)}`},newLineItems:this._getUpdatedLineItems(a,o)})})}_getUpdatedLineItems(e,t){const n=[{label:this._subTotalLabel,amount:`${e.subtotal.toFixed(t)}`}];return e.taxes.forEach(e=>n.push({label:e.name,amount:`${e.amount.toFixed(t)}`})),n.push({label:this._shippingLabel,amount:`${e.shippingCostTotal.toFixed(t)}`}),n}_updateShippingOption(e){return go(this,void 0,void 0,function*(){return this._paymentIntegrationService.selectShippingOption(e)})}_onValidateMerchant(e,t){return go(this,void 0,void 0,function*(){const n=[`validationUrl=${t.validationURL}`,`merchantIdentifier=${e.initializationData.merchantId}`,`displayName=${e.initializationData.storeName}`,`domainName=${window.location.hostname}`].join("&");return this._requestSender.post(`${e.initializationData.paymentsUrl}/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})})}_onPaymentAuthorized(e,t,n){return go(this,void 0,void 0,function*(){var i;const{token:r,billingContact:o,shippingContact:a}=e.payment,s=this._paymentIntegrationService.getState().getCartOrThrow().lineItems.physicalItems.length>0;let d;(null===(i=n.initializationData)||void 0===i?void 0:i.gateway)===so.BRAINTREE&&(d=yield this._getBraintreeDeviceData());const c={methodId:n.id,paymentData:{deviceSessionId:d,formattedPayload:{apple_pay_token:{payment_data:r.paymentData,payment_method:r.paymentMethod,transaction_id:r.transactionIdentifier}}}},u=this._transformContactToAddress(o),l=this._transformContactToAddress(a),h=null==a?void 0:a.emailAddress,p=(null==a?void 0:a.phoneNumber)||"";try{return yield this._paymentIntegrationService.updateBillingAddress(Object.assign(Object.assign({},u),{email:h,phone:p})),s&&(yield this._paymentIntegrationService.updateShippingAddress(l)),yield this._paymentIntegrationService.submitOrder({useStoreCredit:!1}),yield this._paymentIntegrationService.submitPayment(c),t.completePayment(ApplePaySession.STATUS_SUCCESS),this._onAuthorizeCallback()}catch(e){throw t.completePayment(ApplePaySession.STATUS_FAILURE),new Error("Payment cannot complete")}})}_transformContactToAddress(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:[]}}_getBraintreeDeviceData(){return go(this,void 0,void 0,function*(){try{const{deviceData:e}=yield this._braintreeSdk.getDataCollectorOrThrow();return e}catch(e){}})}}function yo(e){if(!function(e){return"ApplePaySession"in e}(e))throw new Error("Apple pay is not supported")}class fo{create(e){return yo(window),new ApplePaySession(1,e)}}class _o{constructor(e){this.scriptLoader=e,this.sdkVersion="1.latest"}loadSdk(){return e=this,t=void 0,i=function*(){(function(e){return"ApplePaySDK"in e})(window)||(yield this.scriptLoader.loadScript(`https://applepay.cdn-apple.com/jsapi/${this.sdkVersion}/apple-pay-sdk.js`),yo(window))},new((n=void 0)||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())});var e,t,n,i}}const So=Ar(t=>{const{getHost:n}=t.getState(),i=new Hr(t);return new mo(e({host:n()}),t,new fo,new oo(new uo(le(),window,i)),new _o(new ce))},[{id:"applepay"}]);var vo,Co,Io,wo,Eo,bo,Po,Oo;!function(e){e.BuyNow="BUY_NOW",e.INVOICE="B2B_INVOICE"}(vo||(vo={})),function(e){e.Possible="POSSIBLE",e.No="NO",e.Unknown="UNKNOWN",e.Yes="YES"}(Co||(Co={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(Io||(Io={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(wo||(wo={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(Eo||(Eo={})),function(e){e.pill="pill",e.rect="rect"}(bo||(bo={})),function(e){e.OXXO="oxxo"}(Po||(Po={})),function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(Oo||(Oo={}));var Ao=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class To{constructor(e,t,n,i){this.formPoster=e,this.paymentIntegrationService=t,this.bigCommercePaymentsRequestSender=n,this.bigCommercePaymentsScriptLoader=i}loadPayPalSdk(e,t,n,i){return Ao(this,void 0,void 0,function*(){const r=this.paymentIntegrationService.getState(),o=t||r.getCartOrThrow().currency.code,a=r.getPaymentMethodOrThrow(e);return this.paypalSdk=yield this.bigCommercePaymentsScriptLoader.getPayPalSDK(a,o,n,i),this.paypalSdk})}getPayPalSdkOrThrow(){if(!this.paypalSdk)throw new Pr;return this.paypalSdk}createBuyNowCartOrThrow(e){return Ao(this,void 0,void 0,function*(){const t=e.getBuyNowCartRequestBody();if(!t)throw new gr(hr.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(t)}catch(e){throw new kr}})}createOrder(e,t){return Ao(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i}=yield this.bigCommercePaymentsRequestSender.createOrder(e,Object.assign({cartId:n},t));return i})}createOrderCardFields(e,t){return Ao(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i,setupToken:r}=yield this.bigCommercePaymentsRequestSender.createOrder(e,Object.assign({cartId:n},t));return Object.assign({orderId:i},r?{setupToken:r}:{})})}updateOrder(e){return Ao(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState(),n=t.getCartOrThrow();let i;e||(i=t.getConsignmentsOrThrow()[0]);try{yield this.bigCommercePaymentsRequestSender.updateOrder({availableShippingOptions:e?[]:null==i?void 0:i.availableShippingOptions,cartId:n.id,selectedShippingOption:e?null:null==i?void 0:i.selectedShippingOption})}catch(e){throw new Ie}})}getOrderStatus(e,t){return Ao(this,void 0,void 0,function*(){try{const{status:n}=yield this.bigCommercePaymentsRequestSender.getOrderStatus(e,t);return n}catch(e){throw new Ie}})}tokenizePayment(e,t){const n=this.paymentIntegrationService.getState().getCartOrThrow();if(!t)throw new gr(hr.MissingOrderId);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",action:"set_external_checkout",provider:e,order_id:t},n.source===vo.BuyNow&&{cart_id:n.id}))}submitPayment(e,t,n){return Ao(this,void 0,void 0,function*(){const i={formattedPayload:{vault_payment_instrument:null,set_as_default_stored_instrument:null,device_info:null,method_id:e,paypal_account:{order_id:t}}};yield this.paymentIntegrationService.submitPayment(Object.assign({methodId:e,paymentData:i},n?{gatewayId:n}:{}))})}getShippingOptionOrThrow(e){const t=this.paymentIntegrationService.getState().getConsignmentsOrThrow()[0],n=t.availableShippingOptions||[],i=n.find(e=>e.isRecommended),r=(e?n.find(t=>t.id===e):n.find(e=>{var n;return e.id===(null===(n=t.selectedShippingOption)||void 0===n?void 0:n.id)}))||i||n[0];if(!r)throw new Error("Your order can't be shipped to this address");return r}getAddress(e){return{firstName:(null==e?void 0:e.firstName)||"",lastName:(null==e?void 0:e.lastName)||"",email:(null==e?void 0:e.email)||"",phone:(null==e?void 0:e.phone)||"",company:"",address1:(null==e?void 0:e.address1)||"",address2:(null==e?void 0:e.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:[]}}getBillingAddressFromOrderDetails({payer:e}){var t,n;return this.getAddress({firstName:e.name.given_name,lastName:e.name.surname,email:e.email_address,address1:e.address.address_line_1,address2:e.address.address_line_2,city:e.address.admin_area_2,countryCode:e.address.country_code,postalCode:e.address.postal_code,stateOrProvinceCode:e.address.admin_area_1,phone:null===(n=null===(t=e.phone)||void 0===t?void 0:t.phone_number)||void 0===n?void 0:n.national_number})}getShippingAddressFromOrderDetails(e){const{payer:t,purchase_units:n}=e,{address:i,name:{full_name:r}}=n[0].shipping,[o,...a]=r.split(" ");return this.getAddress({firstName:o,lastName:a.join(" "),email:t.email_address,address1:i.address_line_1,address2:i.address_line_2,city:i.admin_area_2,countryCode:i.country_code,postalCode:i.postal_code,stateOrProvinceCode:i.admin_area_1})}getValidButtonStyle(e){const{color:t,height:n,label:i,shape:r}=e||{},o={color:t&&Eo[t]?t:void 0,height:this.getValidHeight(n),label:i&&wo[i]?i:void 0,shape:r&&bo[r]?r:void 0};return R(o,v)}getValidHeight(e){return e&&"number"==typeof e?e>55?55:e<25?25:e:40}removeElement(e){const t=e&&document.getElementById(e);t&&(t.style.display="none")}}var ko=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ro{constructor(e){this.requestSender=e}createOrder(e,t){return ko(this,void 0,void 0,function*(){const n=`/api/storefront/payment/${e}`,i=t,r=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.post(n,{headers:r,body:i})).body})}updateOrder(e){return ko(this,void 0,void 0,function*(){const t=e,n=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.put("/api/storefront/initialization/bigcommerce_payments",{headers:n,body:t})).body})}getOrderStatus(){return ko(this,arguments,void 0,function*(e="bigcommerce_payments",t){const n=`/api/storefront/initialization/${e}`,i=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.get(n,Object.assign({headers:i},t))).body})}}var Do=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Mo{constructor(e){this.scriptLoader=e,this.window=window}getPayPalSDK(e,t,n,i){return Do(this,void 0,void 0,function*(){const r=this.getPayPalSdkScriptConfigOrThrow(e,t,n);return this.loadPayPalSDK(r,i)})}loadPayPalSDK(e){return Do(this,arguments,void 0,function*(e,t=!1){if(!this.window.bigCommercePaymentsPayPalSDK||t){const t=this.transformConfig(e.options),n=this.transformConfig(e.attributes),i=`https://www.paypal.com/sdk/js?${new URLSearchParams(t).toString()}`;yield this.scriptLoader.loadScript(i,{async:!0,attributes:n})}if(!this.window.bigCommercePaymentsPayPalSDK)throw new Pr;return this.window.bigCommercePaymentsPayPalSDK})}getPayPalSdkScriptConfigOrThrow(e,t,n=!0){const{id:i,clientToken:r,initializationData:o}=e;if(!(null==o?void 0:o.clientId))throw new gr(hr.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,buyerCountry:c,attributionId:u,isVenmoEnabled:l,isHostedCheckoutEnabled:h,isPayPalCreditAvailable:p,isDeveloperModeApplicable:g,availableAlternativePaymentMethods:m=[],enabledAlternativePaymentMethods:y=[],isGooglePayEnabled:f}=o,_=h||n,S="bigcommerce_payments_creditcards"===i,v=S?["card"]:[],C=S?[]:["card"],I=p?["credit","paylater"]:[],w=p?[]:["credit","paylater"],E=l?["venmo"]:[],b=l?[]:["venmo"],P=m.filter(e=>!y.includes(e)),O=f?["googlepay"]:[],A=n?["card-fields"]:[],T=this.filterFundingOptions([...C,...w,...b,...P]),k=this.filterFundingOptions([...v,...I,...E,...y]);return{options:Object.assign({"client-id":s,"merchant-id":d,"enable-funding":k.length>0?k:void 0,"disable-funding":T.length>0?T:void 0,commit:_,components:["buttons","hosted-fields","payment-fields","legal",...O,...A],currency:t,intent:a},g&&{"buyer-country":c}),attributes:{"data-partner-attribution-id":u,"data-client-token":r,"data-namespace":"bigCommercePaymentsPayPalSDK"}}}filterFundingOptions(e){const t=["klarna","afterpay"];return e?e.filter(e=>!t.includes(e)):[]}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}const No=t=>{const{getHost:i}=t.getState();return new To(n(),t,new Ro(e({host:i()})),new Mo(le()))};var Lo=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class zo{constructor(e,t){this.paymentIntegrationService=e,this.bigCommercePaymentsIntegrationService=t}initialize(e){return Lo(this,void 0,void 0,function*(){var t;const{bigcommerce_payments:n,containerId:i,methodId:r}=e,o=Boolean(null==n?void 0:n.buyNowInitializeOptions);if(!r)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.bigcommerce_payments" argument is not provided.');if(o&&!n.currencyCode)throw new Tr('Unable to initialize payment because "options.bigcommerce_payments.currencyCode" argument is not provided.');if(o&&"function"!=typeof(null===(t=n.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody))throw new Tr('Unable to initialize payment because "options.bigcommerce_payments.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');o||(yield this.paymentIntegrationService.loadDefaultCheckout());const a=o?n.currencyCode:this.paymentIntegrationService.getState().getCartOrThrow().currency.code;yield this.bigCommercePaymentsIntegrationService.loadPayPalSdk(r,a,!1),this.renderButton(i,r,n)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onComplete:o,onEligibilityFailure:a}=n,s=this.bigCommercePaymentsIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),{isHostedCheckoutEnabled:c,isServerSideShippingCallbacksEnabled:u}=d.initializationData||{},l={createOrder:()=>this.bigCommercePaymentsIntegrationService.createOrder("bigcommerce_payments"),onApprove:({orderID:e})=>this.bigCommercePaymentsIntegrationService.tokenizePayment(t,e)},h={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},p=Object.assign(Object.assign({},!u&&{onShippingAddressChange:e=>this.onShippingAddressChange(e),onShippingOptionsChange:e=>this.onShippingOptionsChange(e)}),{onApprove:(e,n)=>this.onHostedCheckoutApprove(e,n,t,o,u)}),g=Object.assign(Object.assign(Object.assign({fundingSource:s.FUNDING.PAYPAL,style:this.bigCommercePaymentsIntegrationService.getValidButtonStyle(r)},l),i&&h),c&&p),m=s.Buttons(g);m.isEligible()?m.render(`#${e}`):a&&"function"==typeof a?a():this.bigCommercePaymentsIntegrationService.removeElement(e)}handleClick(e){return Lo(this,void 0,void 0,function*(){if(e){const t=yield this.bigCommercePaymentsIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}onHostedCheckoutApprove(e,t,n,i,r){return Lo(this,void 0,void 0,function*(){if(!e.orderID)throw new gr(hr.MissingOrderId);const o=this.paymentIntegrationService.getState().getCartOrThrow();try{const a=o.lineItems.physicalItems.length>0;if(!r){const e=yield t.order.get(),n=this.bigCommercePaymentsIntegrationService.getBillingAddressFromOrderDetails(e);if(yield this.paymentIntegrationService.updateBillingAddress(n),a){const t=this.bigCommercePaymentsIntegrationService.getShippingAddressFromOrderDetails(e);yield this.paymentIntegrationService.updateShippingAddress(t)}}return a&&(yield this.bigCommercePaymentsIntegrationService.updateOrder(r)),r&&(yield this.paymentIntegrationService.loadCheckout()),yield this.paymentIntegrationService.submitOrder({},{params:{methodId:n}}),yield this.bigCommercePaymentsIntegrationService.submitPayment(n,e.orderID),i&&"function"==typeof i&&i(),!0}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingAddressChange(e){return Lo(this,void 0,void 0,function*(){const t=this.bigCommercePaymentsIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state});try{yield this.paymentIntegrationService.updateBillingAddress(t),yield this.paymentIntegrationService.updateShippingAddress(t);const e=this.bigCommercePaymentsIntegrationService.getShippingOptionOrThrow();yield this.paymentIntegrationService.selectShippingOption(e.id),yield this.bigCommercePaymentsIntegrationService.updateOrder()}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingOptionsChange(e){return Lo(this,void 0,void 0,function*(){const t=this.bigCommercePaymentsIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id);try{yield this.paymentIntegrationService.selectShippingOption(t.id),yield this.bigCommercePaymentsIntegrationService.updateOrder()}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}}const Uo=Ar(e=>new zo(e,No(e)),[{id:"bigcommerce_payments"}]);var Fo=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Bo{constructor(e,t){this.paymentIntegrationService=e,this.bigCommercePaymentsIntegrationService=t}initialize(e){return Fo(this,void 0,void 0,function*(){const{bigcommerce_payments_paylater:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,currencyCode:o}=t||{},a=!!r;if(!i)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Tr('Unable to initialize payment because "options.bigcommerce_payments_paylater" argument is not provided.');if(a&&!o)throw new Tr('Unable to initialize payment because "options.bigcommerce_payments_paylater.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null==r?void 0:r.getBuyNowCartRequestBody))throw new Tr('Unable to initialize payment because "options.bigcommerce_payments_paylater.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');a||(yield this.paymentIntegrationService.loadDefaultCheckout());const s=this.paymentIntegrationService.getState(),d=a?o:s.getCartOrThrow().currency.code;yield this.bigCommercePaymentsIntegrationService.loadPayPalSdk(i,d,!1),this.renderButton(n,i,t)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onComplete:o,onEligibilityFailure:a}=n,s=this.bigCommercePaymentsIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),{isHostedCheckoutEnabled:c}=d.initializationData||{},u={createOrder:()=>this.bigCommercePaymentsIntegrationService.createOrder("bigcommerce_payments_paylater"),onApprove:({orderID:e})=>this.bigCommercePaymentsIntegrationService.tokenizePayment(t,e)},l={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},h={onShippingAddressChange:e=>this.onShippingAddressChange(e),onShippingOptionsChange:e=>this.onShippingOptionsChange(e),onApprove:(e,n)=>this.onHostedCheckoutApprove(e,n,t,o)},p=[s.FUNDING.PAYLATER,s.FUNDING.CREDIT];let g=!1;p.forEach(t=>{if(!g){const n=Object.assign(Object.assign(Object.assign({fundingSource:t,style:this.bigCommercePaymentsIntegrationService.getValidButtonStyle(r)},u),i&&l),c&&h),o=s.Buttons(n);o.isEligible()?(o.render(`#${e}`),g=!0):a&&"function"==typeof a&&a()}}),g||this.bigCommercePaymentsIntegrationService.removeElement(e)}handleClick(e){return Fo(this,void 0,void 0,function*(){if(e){const t=yield this.bigCommercePaymentsIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}onHostedCheckoutApprove(e,t,n,i){return Fo(this,void 0,void 0,function*(){if(!e.orderID)throw new gr(hr.MissingOrderId);const r=this.paymentIntegrationService.getState().getCartOrThrow(),o=yield t.order.get();try{const t=this.bigCommercePaymentsIntegrationService.getBillingAddressFromOrderDetails(o);if(yield this.paymentIntegrationService.updateBillingAddress(t),r.lineItems.physicalItems.length>0){const e=this.bigCommercePaymentsIntegrationService.getShippingAddressFromOrderDetails(o);yield this.paymentIntegrationService.updateShippingAddress(e),yield this.bigCommercePaymentsIntegrationService.updateOrder()}return yield this.paymentIntegrationService.submitOrder({},{params:{methodId:n}}),yield this.bigCommercePaymentsIntegrationService.submitPayment(n,e.orderID),i&&"function"==typeof i&&i(),!0}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingAddressChange(e){return Fo(this,void 0,void 0,function*(){const t=this.bigCommercePaymentsIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state});try{yield this.paymentIntegrationService.updateBillingAddress(t),yield this.paymentIntegrationService.updateShippingAddress(t);const e=this.bigCommercePaymentsIntegrationService.getShippingOptionOrThrow();yield this.paymentIntegrationService.selectShippingOption(e.id),yield this.bigCommercePaymentsIntegrationService.updateOrder()}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingOptionsChange(e){return Fo(this,void 0,void 0,function*(){const t=this.bigCommercePaymentsIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id);try{yield this.paymentIntegrationService.selectShippingOption(t.id),yield this.bigCommercePaymentsIntegrationService.updateOrder()}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}}const xo=Ar(e=>new Bo(e,No(e)),[{id:"bigcommerce_payments_paylater"}]);var qo=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class jo{constructor(e,t){this.paymentIntegrationService=e,this.bigCommercePaymentsIntegrationService=t}initialize(e){return qo(this,void 0,void 0,function*(){const{bigcommerce_payments_venmo:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,currencyCode:o}=t||{},a=!!r;if(!i)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Tr('Unable to initialize payment because "options.bigcommerce_payments_venmo" argument is not provided.');if(a&&!o)throw new Tr('Unable to initialize payment because "options.bigcommerce_payments_venmo.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null==r?void 0:r.getBuyNowCartRequestBody))throw new Tr('Unable to initialize payment because "options.bigcommerce_payments_venmo.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');a||(yield this.paymentIntegrationService.loadDefaultCheckout());const s=a?o:this.paymentIntegrationService.getState().getCartOrThrow().currency.code;yield this.bigCommercePaymentsIntegrationService.loadPayPalSdk(i,s,!1),this.renderButton(n,i,t)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onEligibilityFailure:o}=n,a=this.bigCommercePaymentsIntegrationService.getPayPalSdkOrThrow(),s=a.FUNDING.VENMO,d={createOrder:()=>this.bigCommercePaymentsIntegrationService.createOrder("bigcommerce_payments_venmo"),onApprove:({orderID:e})=>this.bigCommercePaymentsIntegrationService.tokenizePayment(t,e)},c={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},u=Object.assign(Object.assign({fundingSource:s,style:this.getValidVenmoButtonStyles(r)},d),i&&c),l=a.Buttons(u);l.isEligible()?l.render(`#${e}`):o&&"function"==typeof o?o():this.bigCommercePaymentsIntegrationService.removeElement(e)}getValidVenmoButtonStyles(e){const t=this.bigCommercePaymentsIntegrationService.getValidButtonStyle(e);return t.color===Eo.gold?Object.assign(Object.assign({},t),{color:void 0}):t}handleClick(e){return qo(this,void 0,void 0,function*(){if(e){const t=yield this.bigCommercePaymentsIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}}const Go=Ar(e=>new jo(e,No(e)),[{id:"bigcommerce_payments_venmo"}]);class Vo extends ve{constructor(e){super(e||"Not implemented."),this.name="NotImplementedError",this.type="not_implemented"}}var Ho,Wo,Yo;!function(e){e.SandboxMode="bolt_sandbox",e.StagingMode="bolt_staging",e.DevelopmentMode="bolt_development"}(Ho||(Ho={})),function(e){e.Small="small",e.Medium="medium",e.Large="large"}(Wo||(Wo={})),function(e){e.Pill="pill",e.Rect="rect"}(Yo||(Yo={}));class Ko{constructor(e,t,n=window){this.paymentIntegrationService=e,this.boltScriptLoader=t,this.boltHostWindow=n}initialize(e){return t=this,n=void 0,r=function*(){const{bolt:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,style:o}=t||{};if(!i)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Tr('Unable to initialize payment because "options.bolt" argument is not provided.');if(!Boolean(r))throw new Vo("Only buy now flow is implemented for Bolt button");if(!(null==r?void 0:r.storefrontApiToken)||"string"!=typeof r.storefrontApiToken)throw new Tr('Unable to initialize payment because "options.storefrontApiToken" argument is not provided.');const a=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(i),{initializationData:s,config:d}=a,{publishableKey:c,developerConfig:u}=s||{};yield this.boltScriptLoader.loadBoltClient(c,d.testMode,u,"BigCommerce",r.storefrontApiToken),this.renderButton(n,a,o)},new((i=void 0)||(i=Promise))(function(e,o){function a(e){try{d(r.next(e))}catch(e){o(e)}}function s(e){try{d(r.throw(e))}catch(e){o(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,s)}d((r=r.apply(t,n||[])).next())});var t,n,i,r}deinitialize(){return Promise.resolve()}renderButton(e,t,n){var i;"function"==typeof(null===(i=this.boltHostWindow.BoltConnect)||void 0===i?void 0:i.setupProductPageCheckout)&&(this.addButtonContainer(e,t,n),this.boltHostWindow.BoltConnect.setupProductPageCheckout())}addButtonContainer(e,t,n){const i=document.getElementById(e);if(!i)return;const r=document.createElement("div"),o=document.createElement("object");r.setAttribute("id","product-page-checkout-wrapper"),r.setAttribute("class","bolt-button-wrapper"),r.setAttribute("style","display:none"),r.setAttribute("data-tid","product-page-checkout-wrapper"),o.setAttribute("data",this.getBoltObjectData(t,n)),o.setAttribute("class","bolt-product-checkout-button"),r.append(o),i.innerHTML="",i.append(r)}getBoltObjectData(e,t){const{initializationData:n,config:i}=e,{publishableKey:r,developerConfig:o}=n||{},a=this.boltScriptLoader.getDomainURL(!!i.testMode,o),s=this.getButtonHeight(null==t?void 0:t.size),d=this.getButtonBorderRadius(null==t?void 0:t.shape,s);return he({url:`https://${a}/v1/checkout_button`,query:{publishable_key:r,variant:"ppc",height:s,border_radius:d}})}getButtonHeight(e){if(e)switch(e){case Wo.Small:return 25;case Wo.Large:return 45;case Wo.Medium:default:return 40}}getButtonBorderRadius(e,t){if(e)switch(e){case Yo.Pill:return t?Math.round(t/2):void 0;case Yo.Rect:default:return 4}}}var $o=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Zo{constructor(e,t=window){this.scriptLoader=e,this.boltHostWindow=t}loadBoltClient(e,t,n,i,r){return $o(this,void 0,void 0,function*(){if(this.boltHostWindow.BoltCheckout)return this.boltHostWindow.BoltCheckout;if(!e)throw new Tr('Unable to initialize payment because "publishableKey" argument is not provided.');if(yield this.scriptLoader.loadScript(`//${this.getDomainURL(!!t,n)}/connect-bigcommerce.js`,this.getScriptOptions("bolt-connect",e,i,r)),yield this.scriptLoader.loadScript(`//${this.getDomainURL(!!t,n)}/track.js`,this.getScriptOptions("bolt-track",e)),!this.boltHostWindow.BoltCheckout)throw new Pr;return this.boltHostWindow.BoltCheckout})}loadBoltEmbedded(e,t,n){return $o(this,void 0,void 0,function*(){if(yield this.scriptLoader.loadScript(`//${this.getDomainURL(!!t,n)}/embed.js`,{async:!0,attributes:{id:"bolt-embedded"}}),!this.boltHostWindow.Bolt)throw new Pr;return this.boltHostWindow.Bolt(e)})}getDomainURL(e,t){if(!e)return"connect.bolt.com";if(t)switch(t.developerMode){case Ho.StagingMode:return"connect-staging.bolt.com";case Ho.DevelopmentMode:return`connect.${t.developerDomain}`}return"connect-sandbox.bolt.com"}getScriptOptions(e,t,n,i){return{async:!0,attributes:Object.assign(Object.assign({id:e,"data-publishable-key":t},n&&{"data-shopping-cart-id":n}),i&&{"data-storefront-api-token":i})}}}const Jo=Ar(e=>new Ko(e,new Zo(le())),[{id:"bolt"}]);class Qo extends Tr{constructor(e){let t="Unable to submit payment for the order because the payload is invalid.";e&&(t=`${t} Make sure the following fields are provided correctly: ${e.join(", ")}.`),super(t),this.name="PaymentArgumentInvalidError"}}class Xo extends ve{constructor(e,t){super(t||"Unable to proceed because the payment form contains invalid data."),this.details=e,this.name="PaymentInvalidFormError",this.type="payment_invalid_form"}}let ea=null;const ta=["buttons","messages"];var na,ia,ra,oa,aa,sa;!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(na||(na={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(ia||(ia={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white"}(ra||(ra={})),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"}(aa||(aa={})),function(e){e.CART="cart",e.HOME="homepage",e.PAYMENT="payment",e.PRODUCT="product"}(sa||(sa={}));var da=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ca{constructor(e,t,n){this.braintreeScriptLoader=e,this.braintreeHostWindow=t,this.overlay=n,this.dataCollectors={}}initialize(e,t){this.clientToken=e,this.threeDSecureOptions=t}getBraintreeFastlane(e,t,n){return da(this,void 0,void 0,function*(){if(t&&(window.localStorage.setItem("axoEnv","sandbox"),window.localStorage.setItem("fastlaneEnv","sandbox")),!this.braintreeHostWindow.braintreeFastlane){const t=this.getClientTokenOrThrow(),i=yield this.getClient(),r=yield this.getSessionId(e),o=yield this.braintreeScriptLoader.loadFastlane(),a={root:{backgroundColorPrimary:"transparent"}};this.braintreeHostWindow.braintreeFastlane=yield o.create({authorization:t,client:i,deviceData:r,styles:n||a})}return this.braintreeHostWindow.braintreeFastlane})}getClient(){return da(this,void 0,void 0,function*(){if(!this.client){const e=this.getClientTokenOrThrow(),t=yield this.braintreeScriptLoader.loadClient();this.client=t.create({authorization:e})}return this.client})}getPaypal(){return this.braintreePaypal||(this.braintreePaypal=Promise.all([this.getClient(),this.braintreeScriptLoader.loadPaypal()]).then(([e,t])=>t.create({client:e}))),this.braintreePaypal}paypal(e){var{shouldSaveInstrument:t}=e,n=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["shouldSaveInstrument"]);const i=pe();return this.getPaypal().then(e=>{var r;return i&&(null===(r=this.overlay)||void 0===r||r.show({onClick:()=>e.focusWindow()})),e.tokenize(Object.assign({enableShippingAddress:!0,flow:t?"vault":"checkout",useraction:"commit"},n))}).then(e=>{var t;return null===(t=this.overlay)||void 0===t||t.remove(),e}).catch(e=>{var t;throw null===(t=this.overlay)||void 0===t||t.remove(),e})}getPaypalCheckout(e,t,n){return da(this,void 0,void 0,function*(){const i=yield this.getClient(),r=yield this.braintreeScriptLoader.loadPaypalCheckout(),o={client:i};return this.paypalCheckout=yield r.create(o,(i,r)=>{var o;if(i)return n(i);const a=Object.assign(Object.assign({currency:e.currency},e.isCreditEnabled&&{"enable-funding":"paylater"}),{components:ta.toString(),intent:e.intent,commit:null===(o=e.commit)||void 0===o||o});this.braintreeHostWindow.paypal?t(r):function(e,t){return ea||(ea=new Promise((n,i)=>{e.loadPayPalSDK(t,t=>{t?(ea=null,i(t)):n(e)})})),ea}(r,a).then(()=>t(r))}),this.paypalCheckout})}getDataCollector(e){return da(this,void 0,void 0,function*(){const t=(null==e?void 0:e.paypal)?"paypal":"default";let n=this.dataCollectors[t];if(!n){try{const t=yield this.getClient(),i=yield this.braintreeScriptLoader.loadDataCollector(),r=Object.assign({client:t,kount:!0},e);n=yield i.create(r)}catch(e){if(!eo(e)||"DATA_COLLECTOR_KOUNT_NOT_ENABLED"!==e.code)throw e;n={deviceData:void 0,teardown:()=>Promise.resolve()}}this.dataCollectors[t]=n}return n})}getBraintreeEnv(e=!1){return e?to.Sandbox:to.Production}mapToBraintreeShippingAddressOverride(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}}mapToLegacyShippingAddress(e){const{email:t,phone:n,shippingAddress:i}=e,r=(null==i?void 0:i.recipientName)||"",[o,a]=r.split(" ");return{email:t,first_name:o||"",last_name:a||"",phone_number:n,address_line_1:null==i?void 0:i.line1,address_line_2:null==i?void 0:i.line2,city:null==i?void 0:i.city,state:null==i?void 0:i.state,country_code:null==i?void 0:i.countryCode,postal_code:null==i?void 0:i.postalCode}}mapToLegacyBillingAddress(e){const{billingAddress:t,email:n,firstName:i,lastName:r,phone:o,shippingAddress:a}=e,s=t||a;return{email:n,first_name:i,last_name:r,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}}removeElement(e){const t=e&&document.getElementById(e);t&&t.remove()}getSessionId(e){return da(this,void 0,void 0,function*(){const{deviceData:t}=yield this.getDataCollector({riskCorrelationId:e});return t})}teardown(){return da(this,void 0,void 0,function*(){yield this.teardownModule(this.dataCollectors.default),yield this.teardownModule(this.dataCollectors.paypal),this.dataCollectors={},yield this.teardownModule(this.paypalCheckout),this.paypalCheckout=void 0})}get3DS(){return da(this,void 0,void 0,function*(){return this.threeDS||(this.threeDS=Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()]).then(([e,t])=>t.create({client:e,version:2}))),this.threeDS})}getVenmoCheckout(e){return da(this,void 0,void 0,function*(){if(!this.venmoCheckout){const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadVenmoCheckout(),i=Object.assign({client:t,allowDesktop:!0,paymentMethodUsage:"multi_use"},e||{});this.venmoCheckout=yield new Promise((e,t)=>{n.create(i,(n,i)=>n?t(n):i.isBrowserSupported()?void e(i):t(new Wr))})}return this.venmoCheckout})}verifyCard(e,t,n){return da(this,void 0,void 0,function*(){const i=yield this.tokenizeCard(e,t);return this.challenge3DSVerification(i,n)})}tokenizeCard(e,t){return da(this,void 0,void 0,function*(){const{paymentData:n}=e;if(!function(e){if("object"!=typeof e||null===e)return!1;const t=e;return"object"==typeof t.ccExpiry&&null!==t.ccExpiry&&"string"==typeof t.ccNumber&&"string"==typeof t.ccName}(n))throw new Qo(["payment.paymentData"]);const i=this.getErrorsRequiredFields(n);if(!f(i))throw new Xo(i);const r=this.mapToCreditCard(n,t),o=yield this.getClient(),{creditCards:a}=yield o.request(r);return{nonce:a[0].nonce,bin:a[0].details.bin}})}challenge3DSVerification(e,t){return da(this,void 0,void 0,function*(){const n=yield this.get3DS();return this.present3DSChallenge(n,t,e)})}teardownModule(e){return e?e.teardown():Promise.resolve()}getClientTokenOrThrow(){if(!this.clientToken)throw new fr(pr.PaymentNotInitialized);return this.clientToken}getErrorsRequiredFields(e){const{ccNumber:t,ccExpiry:n}=e,i={};return t||(i.ccNumber=[{message:"Credit card number is required",type:"required"}]),n||(i.ccExpiry=[{message:"Expiration date is required",type:"required"}]),i}mapToCreditCard(e,t){return{data:{creditCard:{cardholderName:e.ccName,number:e.ccNumber,cvv:e.ccCvv,expirationDate:`${e.ccExpiry.month}/${e.ccExpiry.year}`,options:{validate:!1},billingAddress:t&&{countryCodeAlpha2:t.countryCode,locality:t.city,countryName:t.country,postalCode:t.postalCode,streetAddress:t.address2?`${t.address1} ${t.address2}`:t.address1}}},endpoint:"payment_methods/credit_cards",method:"post"}}present3DSChallenge(e,t,n){const{nonce:i,bin:r}=n;if(!i)throw new fr(pr.PaymentNotInitialized);const{challengeRequested:o=!0,additionalInformation:a}=this.threeDSecureOptions||{},s=t.toFixed(2);return e.verifyCard({amount:Number(s),bin:r,challengeRequested:o,nonce:i,onLookupComplete:(e,t)=>{t()},collectDeviceData:!0,additionalInformation:a})}}function ua(e){const{color:t,fundingicons:n,height:i=40,layout:r,shape:o,size:a,tagline:s}=e||{},d={color:t,fundingicons:n,height:la(i),layout:r,shape:o||"rect",size:a,tagline:s};return R(d,v)}function la(e){const t=Number(e);return!t||Number.isNaN(t)?40:t>55?55:t<25?25:t}function ha(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}}var pa=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ga{constructor(e,t,n,i){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeIntegrationService=n,this.braintreeHostWindow=i}initialize(e){return pa(this,void 0,void 0,function*(){const{braintreepaypal:t,containerId:n,methodId:i}=e;if(!i)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Tr('Unable to initialize payment because "options.braintreepaypal" argument is not provided.');let r,o=this.paymentIntegrationService.getState();if(t.buyNowInitializeOptions){if(!t.currencyCode)throw new Tr('Unable to initialize payment because "options.braintreepaypalcredit.currencyCode" argument is not provided.');r=t.currencyCode}else yield this.paymentIntegrationService.loadDefaultCheckout(),o=this.paymentIntegrationService.getState(),r=o.getCartOrThrow().currency.code;const a=o.getPaymentMethodOrThrow(i),{clientToken:s,config:d,initializationData:c}=a;if(!s||!c)throw new gr(hr.MissingPaymentMethod);const u={currency:r,intent:c.intent,isCreditEnabled:c.isCreditEnabled,commit:!1};this.braintreeIntegrationService.initialize(s),yield this.braintreeIntegrationService.getPaypalCheckout(u,e=>{this.renderPayPalButton(e,t,n,i,!!d.testMode)},e=>this.handleError(e,n,t.onError))})}deinitialize(){return pa(this,void 0,void 0,function*(){yield this.braintreeIntegrationService.teardown()})}renderPayPalButton(e,t,n,i,r){const{style:o,shouldProcessPayment:a,onAuthorizeError:s,onEligibilityFailure:d}=t,{paypal:c}=this.braintreeHostWindow;if(c){const u=c.Buttons({env:r?"sandbox":"production",fundingSource:c.FUNDING.PAYPAL,style:ua(o),createOrder:()=>this.setupPayment(e,t,i),onApprove:t=>this.tokenizePayment(t,e,i,a,s)});u.isEligible()?u.render(`#${n}`):d&&"function"==typeof d&&d()}else this.braintreeIntegrationService.removeElement(n)}setupPayment(e,t,n){return pa(this,void 0,void 0,function*(){var i;const{onPaymentError:r,shippingAddress:o,buyNowInitializeOptions:a}=t;try{const r="function"==typeof(null==a?void 0:a.getBuyNowCartRequestBody)?yield this.createBuyNowCart(a.getBuyNowCartRequestBody()):void 0;this.buyNowCartId=null==r?void 0:r.id;const s=this.paymentIntegrationService.getState(),d=s.getCustomer(),c=s.getPaymentMethodOrThrow(n),u=r?r.cartAmount:s.getCartOrThrow().cartAmount,l=r?t.currencyCode:s.getCartOrThrow().currency.code,h=o||(null==d?void 0:d.addresses[0]),p=h?ha(h):void 0;return yield e.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,shippingAddressOverride:p,amount:u,currency:l,offerCredit:!1,intent:null===(i=c.initializationData)||void 0===i?void 0:i.intent})}catch(e){throw r&&(eo(e)||e instanceof ve)&&r(e),e}})}tokenizePayment(e,t,n,i,r){return pa(this,void 0,void 0,function*(){try{const{deviceData:r}=yield this.braintreeIntegrationService.getDataCollector({paypal:!0}),o=yield t.tokenizePayment(e),{details:a,nonce:s}=o,d=this.braintreeIntegrationService.mapToLegacyBillingAddress(a),c=this.braintreeIntegrationService.mapToLegacyShippingAddress(a);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",provider:n,action:i?"process_payment":"set_external_checkout",nonce:s,device_data:r,billing_address:JSON.stringify(d),shipping_address:JSON.stringify(c)},this.buyNowCartId&&{cart_id:this.buyNowCartId})),o}catch(e){throw r&&(eo(e)||e instanceof ve)&&r(e),e}})}createBuyNowCart(e){return pa(this,void 0,void 0,function*(){if(!e)throw new gr(hr.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(e)}catch(e){throw new kr}})}handleError(e,t,n){if(this.braintreeIntegrationService.removeElement(t),!n||!eo(e))throw e;n(e)}}const ma=Ar(e=>{const t=window,i=new Hr(e),r=new ca(new uo(le(),t,i),t);return new ga(e,n(),r,t)},[{id:"braintreepaypal"}]);var ya=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class fa{constructor(e,t,n,i){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeIntegrationService=n,this.braintreeHostWindow=i}initialize(e){return ya(this,void 0,void 0,function*(){const{braintreepaypalcredit:t,containerId:n,methodId:i}=e;if(!i)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Tr('Unable to initialize payment because "options.braintreepaypalcredit" argument is not provided.');let r,o=this.paymentIntegrationService.getState();if(t.buyNowInitializeOptions){if(!t.currencyCode)throw new Tr('Unable to initialize payment because "options.braintreepaypalcredit.currencyCode" argument is not provided.');r=t.currencyCode}else yield this.paymentIntegrationService.loadDefaultCheckout(),o=this.paymentIntegrationService.getState(),r=o.getCartOrThrow().currency.code;const a=o.getPaymentMethodOrThrow(i),{clientToken:s,config:d,initializationData:c}=a;if(!s||!c)throw new gr(hr.MissingPaymentMethod);const u={currency:r,intent:c.intent,isCreditEnabled:c.isCreditEnabled,commit:!1};this.braintreeIntegrationService.initialize(s),yield this.braintreeIntegrationService.getPaypalCheckout(u,e=>{this.renderPayPalButton(e,t,n,i,!!d.testMode)},e=>this.handleError(e,n,t.onError))})}deinitialize(){return ya(this,void 0,void 0,function*(){yield this.braintreeIntegrationService.teardown()})}renderPayPalButton(e,t,n,i,r){const{style:o,shouldProcessPayment:a,onAuthorizeError:s,onEligibilityFailure:d}=t,{paypal:c}=this.braintreeHostWindow;let u=!1;c&&[c.FUNDING.PAYLATER,c.FUNDING.CREDIT].forEach(l=>{const h=l===c.FUNDING.CREDIT?Object.assign({label:oa.CREDIT},ua(o)):ua(o);if(!u){const o=c.Buttons({env:r?"sandbox":"production",fundingSource:l,style:h,createOrder:()=>this.setupPayment(e,t,i),onApprove:t=>this.tokenizePayment(t,e,i,a,s)});o.isEligible()?(o.render(`#${n}`),u=!0):c.FUNDING.CREDIT&&d&&"function"==typeof d&&d()}}),c&&u||this.braintreeIntegrationService.removeElement(n)}setupPayment(e,t,n){return ya(this,void 0,void 0,function*(){var i;const{onPaymentError:r,shippingAddress:o,buyNowInitializeOptions:a}=t;try{const r="function"==typeof(null==a?void 0:a.getBuyNowCartRequestBody)?yield this.createBuyNowCart(a.getBuyNowCartRequestBody()):void 0;this.buyNowCartId=null==r?void 0:r.id;const s=this.paymentIntegrationService.getState(),d=s.getCustomer(),c=s.getPaymentMethodOrThrow(n),u=r?r.cartAmount:s.getCartOrThrow().cartAmount,l=r?t.currencyCode:s.getCartOrThrow().currency.code,h=o||(null==d?void 0:d.addresses[0]),p=h?ha(h):void 0;return yield e.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,shippingAddressOverride:p,amount:u,currency:l,offerCredit:!0,intent:null===(i=c.initializationData)||void 0===i?void 0:i.intent})}catch(e){throw r&&(eo(e)||e instanceof ve)&&r(e),e}})}tokenizePayment(e,t,n,i,r){return ya(this,void 0,void 0,function*(){try{const{deviceData:r}=yield this.braintreeIntegrationService.getDataCollector({paypal:!0}),o=yield t.tokenizePayment(e),{details:a,nonce:s}=o,d=this.braintreeIntegrationService.mapToLegacyBillingAddress(a),c=this.braintreeIntegrationService.mapToLegacyShippingAddress(a);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",provider:n,action:i?"process_payment":"set_external_checkout",nonce:s,device_data:r,billing_address:JSON.stringify(d),shipping_address:JSON.stringify(c)},this.buyNowCartId&&{cart_id:this.buyNowCartId})),o}catch(e){throw r&&(eo(e)||e instanceof ve)&&r(e),e}})}createBuyNowCart(e){return ya(this,void 0,void 0,function*(){if(!e)throw new gr(hr.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(e)}catch(e){throw new kr}})}handleError(e,t,n){if(this.braintreeIntegrationService.removeElement(t),!n||!eo(e))throw e;n(e)}}const _a=Ar(e=>{const t=window,i=new Hr(e),r=new ca(new uo(le(),t,i),t);return new fa(e,n(),r,t)},[{id:"braintreepaypalcredit"}]);var Sa=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class va{constructor(e,t,n){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeSdk=n}initialize(e){return Sa(this,void 0,void 0,function*(){const{containerId:t,methodId:n}=e;if(!n)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!t)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');yield this.paymentIntegrationService.loadPaymentMethod(n);const i=this.paymentIntegrationService.getState(),{clientToken:r,initializationData:o,config:a}=i.getPaymentMethodOrThrow(n);if(!r||!o)throw new gr(hr.MissingPaymentMethod);this.braintreeSdk.initialize(r);const s=yield this.braintreeSdk.getBraintreeVisaCheckout(),{currency:{code:d},cartAmount:c}=i.getCartOrThrow(),u=yield this.braintreeSdk.getVisaCheckoutSdk(a.testMode),l=s.createInitOptions({paymentRequest:{currencyCode:d,subtotal:String(c)},settings:{shipping:{collectShipping:!0}}});this.createSignInButton(t),yield u.init(l),u.on("payment.success",e=>Sa(this,void 0,void 0,function*(){yield this.paymentSuccess(s,e)}))})}deinitialize(){return Promise.resolve()}paymentSuccess(e,t){return Sa(this,void 0,void 0,function*(){return Promise.all([e.tokenize(t),this.braintreeSdk.getDataCollectorOrThrow()]).then(([e,t])=>{const n=this.paymentIntegrationService.getState(),i=n.getShippingAddress(),r=n.getBillingAddress(),{shippingAddress:o=this.toVisaCheckoutAddress(i),billingAddress:a=this.toVisaCheckoutAddress(r)}=e;return this.postForm(Object.assign(Object.assign({},e),{shippingAddress:o,billingAddress:a}),t)})})}postForm(e,t){const{userData:n,billingAddress:i,shippingAddress:r,details:o}=e,{userEmail:a}=n,{deviceData:s}=t;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,i)),shipping_address:JSON.stringify(this.getAddress(a,r))})}toVisaCheckoutAddress(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}:{}}getAddress(e,t={}){return{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}}createSignInButton(e){const t=document.querySelector(`#${e}`);if(!t)throw new Error("Need a container to place the button");return this.insertVisaCheckoutButton(t)}insertVisaCheckoutButton(e){const 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}}const Ca=Ar(e=>{const t=window,i=new Hr(e),r=new oo(new uo(le(),t,i));return new va(e,n(),r)},[{id:"braintreevisacheckout"}]);function Ia(e){const{billingAddress:t,email:n,firstName:i,lastName:r,phone:o,shippingAddress:a}=e,s=t||a;return{email:n,first_name:i,last_name:r,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 wa(e){const{email:t,phone:n,shippingAddress:i}=e,r=(null==i?void 0:i.recipientName)||"",[o,a]=r.split(" ");return{email:t,first_name:o||"",last_name:a||"",phone_number:n,address_line_1:null==i?void 0:i.line1,address_line_2:null==i?void 0:i.line2,city:null==i?void 0:i.city,state:null==i?void 0:i.state,country_code:null==i?void 0:i.countryCode,postal_code:null==i?void 0:i.postalCode}}var Ea=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};const ba=e=>{const{color:t,height:n}=e;return{backgroundColor:(i=t||"",i===ra.WHITE?"#FFFFFF":"#3D95CE"),backgroundPosition:"50% 50%",backgroundSize:"80px auto",backgroundImage:`url("/app/assets/img/payment-providers/venmo-logo-${t===ra.WHITE?ra.BLUE:ra.WHITE}.svg")`,backgroundRepeat:"no-repeat",borderRadius:"4px",cursor:"pointer",transition:"0.2s ease",minHeight:`${n||40}px`,minWidth:"150px",height:"100%",width:"100%",border:t===ra.WHITE?"1px solid black":"none"};var i};class Pa{constructor(e,t,n){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeSdk=n,this.onError=T}initialize(e){return Ea(this,void 0,void 0,function*(){const{braintreevenmo:t,containerId:n,methodId:i}=e;if(!i)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');const r=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(i),{clientToken:o,initializationData:a}=r,{paymentButtonStyles:s}=a,{cartButtonStyles:d}=s||{},c=(null==t?void 0:t.style)||d;if(!o||!a)throw new gr(hr.MissingPaymentMethod);if(!n)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');yield this.paymentIntegrationService.loadDefaultCheckout(),this.onError=(null==t?void 0:t.onError)||this.handleError,this.braintreeSdk.initialize(o);try{const e=yield this.braintreeSdk.getVenmoCheckoutOrThrow();this.renderVenmoButton(e,n,null==t?void 0:t.buyNowInitializeOptions,c)}catch(e){(function(e){return"object"==typeof e&&null!==e&&"name"in e&&"BraintreeError"===e.name}(e)||function(e){return e instanceof Wr}(e))&&this.handleInitializationVenmoError(e,n)}})}deinitialize(){return Ea(this,void 0,void 0,function*(){return yield this.braintreeSdk.deinitialize(),Promise.resolve()})}handleError(e){throw new Error(e.message)}createBuyNowCart(e){return Ea(this,void 0,void 0,function*(){if("function"==typeof(null==e?void 0:e.getBuyNowCartRequestBody)){const t=null==e?void 0:e.getBuyNowCartRequestBody();if(!t)throw new gr(hr.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(t)}catch(e){throw new kr}}})}handleInitializationVenmoError(e,t){return this.removeVenmoContainer(t),this.onError(e)}removeVenmoContainer(e){const t=document.getElementById(e);t&&t.remove()}renderVenmoButton(e,t,n,i){const r=document.getElementById(t),{color:o}=i||{};if(!r)throw new Tr("Unable to create wallet button without valid container ID.");r.setAttribute("aria-label","Venmo"),Object.assign(r.style,ba(i||{})),r.addEventListener("click",()=>Ea(this,void 0,void 0,function*(){r.setAttribute("disabled","true");const t=yield this.createBuyNowCart(n);e.tokenize&&e.tokenize((e,n)=>Ea(this,void 0,void 0,function*(){r.removeAttribute("disabled"),e&&this.onError(e),yield this.handlePostForm(n,null==t?void 0:t.id)}))})),o===ra.BLUE&&(r.addEventListener("mouseenter",()=>{r.style.backgroundColor="#0a7fc2"}),r.addEventListener("mouseleave",()=>{r.style.backgroundColor=ba(i||{}).backgroundColor}))}handlePostForm(e,t){return Ea(this,void 0,void 0,function*(){const{deviceData:n}=yield this.braintreeSdk.getDataCollectorOrThrow(),{nonce:i,details:r}=e;this.formPoster.postForm("/checkout.php",Object.assign({nonce:i,provider:"braintreevenmo",payment_type:"paypal",device_data:n,action:"set_external_checkout",billing_address:JSON.stringify(Ia(r)),shipping_address:JSON.stringify(wa(r))},t&&{cart_id:t}))})}}const Oa=Ar(e=>{const t=window,i=le(),r=new Hr(e),o=new uo(i,t,r),a=new oo(o);return new Pa(e,n(),a)},[{id:"braintreevenmo"}]);class Aa{constructor(e){const t=new Promise((e,t)=>{this.cancel=t});this.promise=Promise.race([e,t])}}var Ta;!function(e){e.ADYEN_V2="googlepayadyenv2",e.ADYEN_V3="googlepayadyenv3",e.AUTHORIZE_NET="googlepayauthorizenet",e.BNZ="googlepaybnz",e.BRAINTREE="googlepaybraintree",e.PAYPAL_COMMERCE="googlepaypaypalcommerce",e.BIGCOMMERCE_PAYMENTS="googlepay_bigcommerce_payments",e.CHECKOUT_COM="googlepaycheckoutcom",e.CYBERSOURCE_V2="googlepaycybersourcev2",e.ORBITAL="googlepayorbital",e.STRIPE="googlepaystripe",e.STRIPE_UPE="googlepaystripeupe",e.STRIPE_OCS="googlepaystripeocs",e.WORLDPAY_ACCESS="googlepayworldpayaccess",e.TD_ONLINE_MART="googlepaytdonlinemart"}(Ta||(Ta={}));const ka=function(e,t,n){return t&&n?Ra(0,t,n):function(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&"constructor"!==n&&Object.defineProperty(t.prototype,n,Ra(e.prototype,n,i))}),t}(e)};function Ra(e,t,n){if("function"!=typeof n.value)return n;let i=n.value;return{get(){const e=i.bind(this);return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e},set(e){i=e}}}class Da{constructor(e){if(!e)throw new Error("Currency settings missing");const{decimalPlaces:t,symbolLocation:n,symbol:i,thousandsSeparator:r,decimalSeparator:o}=e;if("string"!=typeof n||"string"!=typeof i||"string"!=typeof r||"string"!=typeof o||"string"!=typeof t)throw new Tr("Invalid currency settings provided");this._decimalPlaces=parseInt(t,10),this._symbolLocation=n,this._symbol=i,this._thousandsSeparator=r,this._decimalSeparator=o}format(e){if("number"!=typeof e)throw new Tr("Invalid amount provided");const t=this._formatNumber(e),n=this._formatCurrency(t);return e<0?`-${n}`:n}_formatNumber(e){const t=Math.abs(e),[n,i=""]=this._toFixed(t,this._decimalPlaces).split("."),r=n.replace(/\B(?=(\d{3})+(?!\d))/g,this._thousandsSeparator);return this._decimalPlaces<1?r:[r,i].join(this._decimalSeparator)}_formatCurrency(e){return"left"===this._symbolLocation.toLowerCase()?`${this._symbol}${e}`:`${e}${this._symbol}`}_toFixed(e,t){return(+`${Math.round(+`${e}e${t}`)}e${-t}`).toFixed(t)}}let Ma=class{constructor(e){this._storeConfig=e,this._customerFormatter=new Da(this._storeConfig.shopperCurrency),this._storeFormatter=new Da(this._storeConfig.currency)}toCustomerCurrency(e){const t=this._storeConfig.shopperCurrency.exchangeRate;return this._customerFormatter.format(e*t)}toStoreCurrency(e){return this._storeFormatter.format(e)}};Ma=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([ka],Ma);const Na=Ma;function La(){if("undefined"==typeof window)return!1;if(function(e){return"ReactNativeWebView"in e}(window))return!0;const e=navigator.userAgent||navigator.vendor||(function(e){return"opera"in e}(window)?window.opera:""),t=/android.+; wv/i.test(e),n=/iPhone|iPod|iPad/i.test(e)&&/AppleWebKit/i.test(e)&&!/Safari/i.test(e);return t||n}var za,Ua,Fa,Ba,xa,qa,ja,Ga,Va;function Ha(e){return e in qa}!function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(za||(za={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(Ua||(Ua={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(Fa||(Fa={})),function(e){e.pill="pill",e.rect="rect"}(Ba||(Ba={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(xa||(xa={})),function(e){e.AMEX="AMEX",e.DISCOVER="DISCOVER",e.INTERAC="INTERAC",e.JCB="JCB",e.MC="MASTERCARD",e.VISA="VISA"}(qa||(qa={})),function(e){e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION"}(ja||(ja={})),function(e){e.OFFER_INVALID="OFFER_INVALID",e.PAYMENT_DATA_INVALID="PAYMENT_DATA_INVALID",e.SHIPPING_ADDRESS_INVALID="SHIPPING_ADDRESS_INVALID",e.SHIPPING_ADDRESS_UNSERVICEABLE="SHIPPING_ADDRESS_UNSERVICEABLE",e.SHIPPING_OPTION_INVALID="SHIPPING_OPTION_INVALID",e.OTHER_ERROR="OTHER_ERROR"}(Ga||(Ga={})),function(e){e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER"}(Va||(Va={}));var Wa=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ya{constructor(e,t){this._gatewayIdentifier=e,this._paymentIntegrationService=t,this._isBuyNowFlow=!1,this._shouldRequestShipping=!0,this._isWebViewExperimentOn=null}mapToShippingAddressRequestBody({shippingAddress:e}){if(!e)return;const{company:t="",phone:n=""}=this._paymentIntegrationService.getState().getShippingAddress()||{};return this._mapToAddressRequestBody(e,t,n)}mapToBillingAddressRequestBody(e){const{billingAddress:t}=e.paymentMethodData.info;if(!t)return;const{company:n="",phone:i="",email:r,customFields:o=[]}=this._paymentIntegrationService.getState().getBillingAddress()||{};return Object.assign(Object.assign({},this._mapToAddressRequestBody(t,n,i,o)),{email:r||e.email})}mapToExternalCheckoutData(e){var t;const{paymentMethodData:{tokenizationData:{token:n},info:{cardNetwork:i,cardDetails:r}}}=e;if(!n)throw new gr(hr.MissingPaymentToken);return Promise.resolve(Object.assign({nonce:n,card_information:{type:i,number:r}},this._isBuyNowFlow&&{cart_id:null===(t=this._paymentIntegrationService.getState().getCart())||void 0===t?void 0:t.id}))}getRequiredData(){return Wa(this,void 0,void 0,function*(){var e;const t={emailRequired:!0};if(!this._isShippingAddressRequired())return t;const n=null===(e=(yield this._paymentIntegrationService.loadShippingCountries()).getShippingCountries())||void 0===e?void 0:e.map(e=>e.code);return Object.assign(Object.assign({},t),{shippingAddressRequired:!0,shippingAddressParameters:Object.assign({phoneNumberRequired:!0},n&&{allowedCountryCodes:n}),shippingOptionRequired:!0})})}getCallbackIntents(){return this._isShippingAddressRequired()?[ja.OFFER,ja.SHIPPING_ADDRESS,ja.SHIPPING_OPTION]:[ja.OFFER]}getCallbackTriggers(){return{availableTriggers:[Va.INITIALIZE,Va.SHIPPING_ADDRESS,Va.SHIPPING_OPTION,Va.OFFER],initializationTrigger:[Va.INITIALIZE],addressChangeTriggers:[Va.INITIALIZE,Va.SHIPPING_ADDRESS],shippingOptionsChangeTriggers:[Va.SHIPPING_OPTION],offerChangeTriggers:[Va.OFFER]}}getNonce(e){var t;const n=null===(t=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(e).initializationData)||void 0===t?void 0:t.nonce;if(!n)throw new gr(hr.MissingPaymentToken);return Promise.resolve(n)}extraPaymentData(){return Promise.resolve(void 0)}getMerchantInfo(){const{googleMerchantName:e,googleMerchantId:t,platformToken:n}=this.getGooglePayInitializationData();return{merchantName:e,merchantId:t,authJwt:n}}getTransactionInfo(){let e;const{getCartOrThrow:t}=this._paymentIntegrationService.getState();e=this._isBuyNowFlow?this._getCurrencyCodeOrThrow():t().currency.code;const n=this.getGooglePayInitializationData().storeCountry;if(this.isWebViewWithRestrictions()){const t=this.getTotalPrice();return Object.assign(Object.assign({},n&&{countryCode:n}),{currencyCode:e,totalPrice:t,totalPriceStatus:xa.ESTIMATED})}return Object.assign(Object.assign({},n&&{countryCode:n}),{currencyCode:e,totalPriceStatus:xa.ESTIMATED,totalPrice:"0"})}isWebViewWithRestrictions(){return null!==this._isWebViewExperimentOn?this._isWebViewExperimentOn&&La():La()}setIsWebViewExperimentOn(e){this._isWebViewExperimentOn=e}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData().gatewayMerchantId;if(!e)throw new Tr("Unable to proceed, gatewayMerchantId is missing.");return{gateway:this._gatewayIdentifier,gatewayMerchantId:e}}getCardParameters(){return{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:this.getPaymentMethod().supportedCards.filter(Ha).map(e=>qa[e]),billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}}initialize(e,t,n){return this._getPaymentMethodFn=e,this._isBuyNowFlow=Boolean(t),this._currencyCode=n,this._isBuyNowFlow&&this._getCurrencyCodeOrThrow(),Promise.resolve()}handleShippingAddressChange(e){return Wa(this,void 0,void 0,function*(){var t,n,i,r;e&&(e.name=e.name||"",e.address1=e.address1||"");const o=this.mapToShippingAddressRequestBody({shippingAddress:e});o&&(yield this._paymentIntegrationService.updateShippingAddress(o));const a=this._paymentIntegrationService.getState(),s=a.getConsignments();if(!(null==s?void 0:s[0]))return;const d=s[0],c=a.getStoreConfigOrThrow();this._currencyService||(this._currencyService=new Na(c));const u=(d.availableShippingOptions||[]).map(this._getGooglePayShippingOption.bind(this)),l=null===(t=d.availableShippingOptions)||void 0===t?void 0:t.find(e=>e.isRecommended);if(u.length){const e=(null===(n=d.selectedShippingOption)||void 0===n?void 0:n.id)||(null==l?void 0:l.id)||(null===(i=u[0])||void 0===i?void 0:i.id);return!(null===(r=d.selectedShippingOption)||void 0===r?void 0:r.id)&&u[0]&&(yield this.handleShippingOptionChange((null==l?void 0:l.id)||u[0].id)),{defaultSelectedOptionId:e,shippingOptions:u}}})}handleShippingOptionChange(e){return Wa(this,void 0,void 0,function*(){if("shipping_option_unselected"!==e)return this._paymentIntegrationService.selectShippingOption(e)})}getTotalPrice(){const{getCheckoutOrThrow:e,getCartOrThrow:t,getStoreConfigOrThrow:n}=this._paymentIntegrationService.getState(),{decimalPlaces:i}=t().currency,r=qr(n().checkoutSettings.features,"PI-5075.google_pay_round_total_price_to_max_2_decimal_places")?Math.min(i,2):i;return L(e().outstandingBalance,r).toFixed(r)}handleCoupons(e){return Wa(this,void 0,void 0,function*(){const{redemptionCodes:t=[]}=e,{offers:n}=this.getAppliedCoupons()||{};let i;return yield t.reduce((e,t)=>Wa(this,void 0,void 0,function*(){if(yield e,(n||[]).some(({redemptionCode:e})=>e===t))return;const r=yield this.applyCoupon(t);r&&(i=r)}),Promise.resolve()),yield(n||[]).reduce((e,n)=>Wa(this,void 0,void 0,function*(){yield e,t.includes(n.redemptionCode)||(yield this._paymentIntegrationService.removeCoupon(n.redemptionCode))}),Promise.resolve()),{newOfferInfo:this.getAppliedCoupons(),error:i}})}getAppliedCoupons(){const e=this._paymentIntegrationService.getState(),{coupons:t}=e.getCheckout()||{};return{offers:(t||[]).map(e=>{const{displayName:t,code:n}=e;return{redemptionCode:n,description:t}})}}applyCoupon(e){return Wa(this,void 0,void 0,function*(){let t;try{yield this._paymentIntegrationService.applyCoupon(e)}catch(e){return e instanceof Error&&(t={reason:Ga.OFFER_INVALID,message:e.message,intent:Va.OFFER}),t}})}setShouldRequestShipping(e){this._shouldRequestShipping=e}getGooglePayInitializationData(){return yr(this.getPaymentMethod().initializationData,()=>new Tr("Missing initialization data."))}getPaymentMethod(){return yr(this._getPaymentMethodFn,()=>new fr(pr.PaymentNotInitialized))()}getGatewayIdentifier(){return this._gatewayIdentifier}setGatewayIdentifier(e){this._gatewayIdentifier=e||this.getGatewayIdentifier()}_isShippingAddressRequired(){const{getCartOrThrow:e,getStoreConfigOrThrow:t,getShippingAddress:n}=this._paymentIntegrationService.getState(),i=t();let r;return r=qr(i.checkoutSettings.features,"PI-4290.google_pay_require_shipping_address")?this._shouldRequestShipping:void 0===n(),r&&(o=e(),a=i,!!o&&(!!o.lineItems.physicalItems.some(e=>e.isShippingRequired)||!(!a||!o.lineItems.customItems)&&o.lineItems.customItems.length>0));var o,a}_mapToAddressRequestBody(e,t,n,i){const{name:r,address1:o,address2:a,address3:s,locality:d,administrativeArea:c,countryCode:u,postalCode:l,phoneNumber:h}=e,[p,g]=this._getFirstAndLastName(r);return{firstName:p,lastName:g,company:t,address1:o,address2:`${a} ${s}`.trim(),city:d||c,stateOrProvince:c,stateOrProvinceCode:c,countryCode:u,postalCode:l,phone:h||n,customFields:i||[]}}_getFirstAndLastName(e){const t=e.split(" ");return 1===t.length?[e,""]:[t.slice(0,-1).join(" "),t[t.length-1]]}_getCurrencyCodeOrThrow(){return yr(this._currencyCode,()=>new Tr('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}_getGooglePayShippingOption({id:e,cost:t,description:n,additionalDescription:i}){var r;return{id:e,label:`${(null===(r=this._currencyService)||void 0===r?void 0:r.toCustomerCurrency(t))||t} ${n}`,description:i}}}var Ka=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class $a extends Ya{constructor(e,t){super("braintree",e),this._braintreeSdk=t,this._methodId=Ta.BRAINTREE,this._service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return Ka(this,void 0,void 0,function*(){yield i.initialize.call(this,e,t,n);let r=i.getPaymentMethod.call(this);if(r.clientToken||(r=(yield this._service.loadPaymentMethod(this._methodId)).getPaymentMethodOrThrow(this._methodId)),!r.clientToken||!r.initializationData)throw new gr(hr.MissingPaymentMethod);return this._braintreeSdk.initialize(r.clientToken),this._braintreeGooglePayment=yield this._braintreeSdk.getBraintreeGooglePayment(),Promise.resolve()})}getNonce(e){const t=Object.create(null,{getNonce:{get:()=>super.getNonce},getPaymentMethod:{get:()=>super.getPaymentMethod}});return Ka(this,void 0,void 0,function*(){var n;const i=yield t.getNonce.call(this,e),{clientToken:r,initializationData:o}=t.getPaymentMethod.call(this);if(!r||!o||!(null===(n=o.card_information)||void 0===n?void 0:n.bin))throw new gr(hr.MissingPaymentMethod);const{isThreeDSecureEnabled:a,card_information:{bin:s,isNetworkTokenized:d}}=o;if(a&&!d){const e=yield this._braintreeSdk.getBraintreeThreeDS(),{orderAmount:t}=this._service.getState().getOrderOrThrow();return(yield this._braintreePresent3DSChallenge(e,t,i,s)).nonce}return i})}extraPaymentData(){return Ka(this,void 0,void 0,function*(){return{deviceSessionId:yield this._getBraintreeDeviceData()}})}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return Ka(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new Tr("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 gr(hr.MissingPaymentToken)}(i),n.nonce=i.androidPayCards[0].nonce,n.card_information.bin=i.androidPayCards[0].details.bin,n.card_information.isNetworkTokenized=i.androidPayCards[0].details.isNetworkTokenized,n})}getCardParameters(){return super.getCardParameters()}getPaymentGatewayParameters(){const e=Object.create(null,{getMerchantInfo:{get:()=>super.getMerchantInfo},getTransactionInfo:{get:()=>super.getTransactionInfo},getRequiredData:{get:()=>super.getRequiredData}});return Ka(this,void 0,void 0,function*(){return this.getBraintreeGooglePayment().createPaymentDataRequest(Object.assign({merchantInfo:e.getMerchantInfo.call(this),transactionInfo:e.getTransactionInfo.call(this),cardRequirements:{billingAddressRequired:!0,billingAddressFormat:"FULL"}},yield e.getRequiredData.call(this))).paymentMethodTokenizationParameters.parameters})}getBraintreeGooglePayment(){if(!this._braintreeGooglePayment)throw new gr(hr.MissingPaymentMethod);return this._braintreeGooglePayment}_getBraintreeDeviceData(){return Ka(this,void 0,void 0,function*(){const{deviceData:e}=yield this._braintreeSdk.getDataCollectorOrThrow();return e})}_braintreePresent3DSChallenge(e,t,n,i){return new Aa(e.verifyCard({amount:t,bin:i,nonce:n,onLookupComplete:(e,t)=>{t()}})).promise}}class Za extends ve{constructor(e){super(e||"Unable to proceed because the client library of a payment method has thrown an unexpected error."),this.name="PaymentMethodFailedError",this.type="payment_method_client_invalid"}}var Ja=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Qa{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){return Ja(this,void 0,void 0,function*(){var t,n,i,r;if(!e.methodId||(r=e.methodId,!Object.values(Ta).includes(r)))throw new Tr('Unable to proceed because "methodId" is not a valid key.');if(this._methodId=e.methodId,!e.containerId)throw new Tr('Unable to proceed because "containerId" is not a valid key.');const o=e[this._getMethodOrThrow()];if(!o)throw new Tr("Unable to proceed without valid options.");const{buyNowInitializeOptions:a,currencyCode:s,buttonColor:d,buttonType:c,onError:u}=o;let l,h=this._paymentIntegrationService.getState();try{l=h.getPaymentMethodOrThrow(this._getMethodOrThrow())}catch(e){h=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodOrThrow()),l=h.getPaymentMethodOrThrow(this._getMethodOrThrow())}if(this._countryCode=null===(t=l.initializationData)||void 0===t?void 0:t.storeCountry,this._googlePayPaymentProcessor.setIsWebViewExperimentOn(!!(null===(n=l.initializationData)||void 0===n?void 0:n.isWebViewExperimentOn)),a){if(!s)throw new Tr('Unable to initialize payment because "options.currencyCode" argument is not provided.');this._currencyCode=s,this._buyNowInitializeOptions=a,yield this._googlePayPaymentProcessor.initialize(()=>l,this._getGooglePayClientOptions(),!!a,s)}else yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initialize(()=>l,this._getGooglePayClientOptions());this._paymentButton=null!==(i=this._paymentButton)&&void 0!==i?i:this._googlePayPaymentProcessor.addPaymentButton(e.containerId,{buttonColor:null!=d?d:"default",buttonType:null!=c?c:"plain",onClick:this._handleClick(u)})})}deinitialize(){var e;return null===(e=this._paymentButton)||void 0===e||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()}_handleClick(e){return t=>Ja(this,void 0,void 0,function*(){t.preventDefault();try{this._buyNowInitializeOptions?yield this._createBuyNowCartOrThrow(this._buyNowInitializeOptions):yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(t){let n=t;if(function(e){return"object"==typeof e&&null!==e&&"statusCode"in e}(t)){if("CANCELED"===t.statusCode)throw new lo;n=new Za(JSON.stringify(t))}throw null==e||e(new Za("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){return Ja(this,void 0,void 0,function*(){var e;const t=yield this._googlePayPaymentProcessor.showPaymentSheet(),n=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(t),i=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(t),r="/embedded-checkout"===window.location.pathname?this._paymentIntegrationService.getState().getStoreConfigOrThrow().links.siteLink:void 0;n&&(yield this._paymentIntegrationService.updateBillingAddress(n)),i&&!(null===(e=this._buyNowCart)||void 0===e?void 0:e.lineItems.digitalItems.length)&&(yield this._paymentIntegrationService.updateShippingAddress(i)),yield this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodOrThrow(),t,r)})}_getGooglePayClientOptions(){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:e=>Ja(this,[e],void 0,function*({callbackTrigger:e,shippingAddress:t,shippingOptionData:n,offerData:i}){const{availableTriggers:r,addressChangeTriggers:o,shippingOptionsChangeTriggers:a,offerChangeTriggers:s}=this._googlePayPaymentProcessor.getCallbackTriggers();if(!r.includes(e))return;const d=o.includes(e)?yield this._googlePayPaymentProcessor.handleShippingAddressChange(t):void 0;a.includes(e)&&(yield this._googlePayPaymentProcessor.handleShippingOptionChange(n.id));const{newOfferInfo:c,error:u}=s.includes(e)?yield this._googlePayPaymentProcessor.handleCoupons(i):{},l=u;return this._buyNowInitializeOptions?this._getBuyNowTransactionInfo(d,c,l):this._getTransactionInfo(d,c,l)})}}}_createBuyNowCartOrThrow(e){return Ja(this,void 0,void 0,function*(){if("function"==typeof(null==e?void 0:e.getBuyNowCartRequestBody)){const t=e.getBuyNowCartRequestBody();try{this._buyNowCart=yield this._paymentIntegrationService.createBuyNowCart(t),yield this._paymentIntegrationService.loadCheckout(this._buyNowCart.id)}catch(e){if("string"==typeof e)throw new kr(e);throw e}}})}_getBuyNowTransactionInfo(e,t,n){if(!this._buyNowCart)return;const{cartAmount:i}=this._buyNowCart,r=this._googlePayPaymentProcessor.getTotalPrice();return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:this._getCurrencyCodeOrThrow(),totalPrice:r||String(i),totalPriceStatus:xa.FINAL})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})}_getTransactionInfo(e,t,n){return Ja(this,void 0,void 0,function*(){yield this._paymentIntegrationService.loadCheckout();const i=this._googlePayPaymentProcessor.getTotalPrice(),{code:r}=this._paymentIntegrationService.getState().getCartOrThrow().currency;return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:r,totalPriceStatus:xa.FINAL,totalPrice:i})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})})}_getMethodOrThrow(){return yr(this._methodId,()=>new fr(pr.PaymentNotInitialized))}_getCurrencyCodeOrThrow(){return yr(this._currencyCode,()=>new Tr('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}}var Xa=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class es{constructor(e,t,n,i){this._scriptLoader=e,this._gateway=t,this._requestSender=n,this._formPoster=i,this._baseRequest={apiVersion:2,apiVersionMinor:0}}initialize(e,t,n,i){return Xa(this,void 0,void 0,function*(){this._paymentsClient=yield this._scriptLoader.getGooglePaymentsClient(e().config.testMode,t),yield this._gateway.initialize(e,n,i),this._buildButtonPayloads()})}initializeWidget(){return Xa(this,void 0,void 0,function*(){yield this._buildWidgetPayloads(),yield this._determineReadinessToPay(),this._prefetchGooglePaymentData()})}getNonce(e){return this._gateway.getNonce(e)}extraPaymentData(){return Xa(this,void 0,void 0,function*(){return this._gateway.extraPaymentData()})}addPaymentButton(e,t){const n=document.querySelector(`#${e}`);if(!n)return;const i=this._getPaymentsClient().createButton(Object.assign(Object.assign({},t),{allowedPaymentMethods:[this._getBaseCardPaymentMethod()]}));return n.appendChild(i)}showPaymentSheet(){return Xa(this,void 0,void 0,function*(){const e=this._getPaymentDataRequest();return this._getPaymentsClient().loadPaymentData(e)})}setExternalCheckoutXhr(e,t){return Xa(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t)})}setExternalCheckoutForm(e,t,n){return Xa(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t,!0,n)})}mapToBillingAddressRequestBody(e){return this._gateway.mapToBillingAddressRequestBody(e)}mapToShippingAddressRequestBody(e){return this._gateway.mapToShippingAddressRequestBody(e)}processAdditionalAction(e,t){return"processAdditionalAction"in this._gateway?this._gateway.processAdditionalAction(e,t):Promise.reject(e)}signOut(e){return Xa(this,void 0,void 0,function*(){yield this._requestSender.get(`/remote-checkout/${e}/signout`)})}getCallbackTriggers(){return this._gateway.getCallbackTriggers()}setShouldRequestShipping(e){return this._gateway.setShouldRequestShipping(e)}handleShippingAddressChange(e){return Xa(this,void 0,void 0,function*(){return this._gateway.handleShippingAddressChange(e)})}handleShippingOptionChange(e){return Xa(this,void 0,void 0,function*(){yield this._gateway.handleShippingOptionChange(e)})}handleCoupons(e){return Xa(this,void 0,void 0,function*(){return this._gateway.handleCoupons(e)})}getTotalPrice(){return this._gateway.getTotalPrice()}_setExternalCheckout(e,t){return Xa(this,arguments,void 0,function*(e,t,n=!1,i){const r="/checkout.php",o=Object.assign({action:"set_external_checkout",provider:e},yield this._gateway.mapToExternalCheckoutData(t));if(n)return new Promise(e=>{this._formPoster.postForm(i?`${i}/checkout`:r,Object.assign(Object.assign({},o),{card_information:JSON.stringify(o.card_information)}),e)});yield this._requestSender.post(r,{headers:Object.assign({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},Fr),body:o})})}isWebViewWithRestrictions(){return this._gateway.isWebViewWithRestrictions()}setIsWebViewExperimentOn(e){return this._gateway.setIsWebViewExperimentOn(e)}_prefetchGooglePaymentData(){const e=this._getPaymentDataRequest();e.transactionInfo=this._gateway.getTransactionInfo(),this._getPaymentsClient().prefetchPaymentData(e)}_determineReadinessToPay(){return Xa(this,void 0,void 0,function*(){try{const{result:e}=yield this._getPaymentsClient().isReadyToPay(this._getIsReadyToPayRequest());if(!1===e)throw new Za("Google Pay is not supported by the current device and browser, please try another payment method.")}catch(e){if(e instanceof Za)throw e;throw new Za}})}_buildButtonPayloads(){this._baseCardPaymentMethod={type:"CARD",parameters:this._gateway.getCardParameters()}}_buildWidgetPayloads(){return Xa(this,void 0,void 0,function*(){const e=this._getBaseCardPaymentMethod();this._cardPaymentMethod=Object.assign(Object.assign({},e),{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:yield this._gateway.getPaymentGatewayParameters()}});const t=this._gateway.isWebViewWithRestrictions()?{shippingOptionRequired:!1}:{callbackIntents:this._gateway.getCallbackIntents(),offerInfo:this._gateway.getAppliedCoupons()};this._paymentDataRequest=Object.assign(Object.assign(Object.assign(Object.assign({},this._baseRequest),{allowedPaymentMethods:[this._cardPaymentMethod],transactionInfo:this._gateway.getTransactionInfo(),merchantInfo:this._gateway.getMerchantInfo()}),yield this._gateway.getRequiredData()),t),this._isReadyToPayRequest=Object.assign(Object.assign({},this._baseRequest),{allowedPaymentMethods:[e]})})}_getBaseCardPaymentMethod(){return this._getOrThrow(this._baseCardPaymentMethod)}_getPaymentDataRequest(){return this._getOrThrow(this._paymentDataRequest)}_getIsReadyToPayRequest(){return this._getOrThrow(this._isReadyToPayRequest)}_getPaymentsClient(){return this._getOrThrow(this._paymentsClient)}_getOrThrow(e){return yr(e,()=>new fr(pr.PaymentNotInitialized))}}class ts{constructor(e){this._scriptLoader=e,this._window=window}getGooglePaymentsClient(){return e=this,t=arguments,i=function*(e=!1,t){if(yield this._scriptLoader.loadScript("https://pay.google.com/gp/p/js/pay.js"),!this._window.google)throw new Pr;return void 0===this._paymentsClient&&(this._paymentsClient=new this._window.google.payments.api.PaymentsClient(Object.assign({environment:e?"TEST":"PRODUCTION"},null!=t?t:{}))),this._paymentsClient},new((n=void 0)||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())});var e,t,n,i}}function ns(){return new ts(le())}const is=Ar(t=>{const i=e(),r=window,o=new Hr(t),a=new oo(new uo(le(),r,o));return new Qa(t,new es(ns(),new $a(t,a),i,n()))},[{id:"googlepaybraintree"}]),rs=["ar_BH","ar_DZ","ar_EG","ar_JO","ar_KW","ar_MA","ar_OM","ar_QA","ar_SA","ar_TN","ar_YE","ar_AE","bg_BG","cs_CZ","da_DK","da_FO","da_GL","de_AT","de_CH","de_DE","de_LU","el_GR","en_AD","en_AE","en_AG","en_AI","en_AL","en_AM","en_AN","en_AO","en_AT","en_AU","en_AW","en_AZ","en_BB","en_BE","en_BH","en_BJ","en_BM","en_BN","en_BS","en_BT","en_BW","en_BY","en_BZ","en_C2","en_CA","en_CD","en_CG","en_CH","en_CI","en_CK","en_CL","en_CM","en_CN","en_CO","en_CR","en_CV","en_CY","en_CZ","en_DE","en_DJ","en_DK","en_DM","en_DO","en_DZ","en_EC","en_EE","en_EG","en_ER","en_ES","en_ET","en_FI","en_FJ","en_FK","en_FM","en_FO","en_FR","en_GA","en_GB","en_GD","en_GE","en_GF","en_GI","en_GL","en_GM","en_GN","en_GP","en_GR","en_GT","en_GW","en_GY","en_HK","en_HN","en_HR","en_HU","en_ID","en_IE","en_IL","en_IN","en_IS","en_IT","en_JM","en_JO","en_JP","en_KE","en_KG","en_KH","en_KI","en_KM","en_KN","en_KR","en_KW","en_KY","en_KZ","en_LA","en_LC","en_LI","en_LK","en_LS","en_LT","en_LU","en_LV","en_MA","en_MC","en_MD","en_ME","en_MG","en_MH","en_MK","en_ML","en_MN","en_MQ","en_MR","en_MS","en_MT","en_MU","en_MV","en_MW","en_MY","en_MZ","en_NA","en_NC","en_NE","en_NF","en_NG","en_NI","en_NL","en_NO","en_NP","en_NR","en_NU","en_NZ","en_OM","en_PA","en_PE","en_PF","en_PG","en_PH","en_PL","en_PM","en_PN","en_PT","en_PW","en_PY","en_QA","en_RE","en_RO","en_RS","en_RU","en_RW","en_SA","en_SB","en_SC","en_SE","en_SG","en_SH","en_SI","en_SJ","en_SK","en_SL","en_SM","en_SN","en_SO","en_SR","en_ST","en_SV","en_SZ","en_TC","en_TD","en_TG","en_TH","en_TJ","en_TM","en_TN","en_TO","en_TR","en_TT","en_TV","en_TW","en_TZ","en_UA","en_UG","en_US","en_UY","en_VA","en_VC","en_VE","en_VG","en_VN","en_VU","en_WF","en_WS","en_YE","en_YT","en_ZA","en_ZM","en_ZW","es_AD","es_AI","es_AO","es_AR","es_AW","es_BB","es_BJ","es_BM","es_BO","es_BS","es_BZ","es_CD","es_CG","es_CK","es_CL","es_CO","es_CR","es_CV","es_DJ","es_DM","es_DO","es_DZ","es_EC","es_EG","es_ER","es_ES","es_ET","es_FJ","es_FK","es_FO","es_GA","es_GD","es_GE","es_GI","es_GL","es_GM","es_GN","es_GT","es_GW","es_GY","es_HN","es_IE","es_JM","es_JO","es_KE","es_KG","es_KI","es_KM","es_KN","es_KW","es_KY","es_KZ","es_LC","es_LI","es_LS","es_LU","es_MA","es_MG","es_MH","es_ML","es_MR","es_MS","es_MU","es_MW","es_MX","es_MZ","es_NA","es_NC","es_NE","es_NF","es_NI","es_NR","es_NU","es_NZ","es_OM","es_PA","es_PE","es_PF","es_PG","es_PM","es_PN","es_PW","es_PY","es_QA","es_RS","es_RW","es_SA","es_SB","es_SC","es_SH","es_SJ","es_SL","es_SM","es_SN","es_SO","es_SR","es_ST","es_SV","es_SZ","es_TC","es_TD","es_TG","es_TJ","es_TM","es_TN","es_TT","es_TV","es_UA","es_UG","es_US","es_UY","es_VA","es_VC","es_VE","es_VG","es_VU","es_WF","es_YE","es_ZM","et_EE","fi_FI","fr_AD","fr_AE","fr_AI","fr_AM","fr_AO","fr_AW","fr_AZ","fr_BB","fr_BE","fr_BF","fr_BI","fr_BJ","fr_BM","fr_BS","fr_BZ","fr_CA","fr_CD","fr_CG","fr_CH","fr_CI","fr_CK","fr_CM","fr_CV","fr_DJ","fr_DM","fr_DO","fr_DZ","fr_EC","fr_ER","fr_ET","fr_FJ","fr_FK","fr_FO","fr_FR","fr_GA","fr_GD","fr_GE","fr_GF","fr_GI","fr_GL","fr_GM","fr_GN","fr_GP","fr_GT","fr_GW","fr_GY","fr_HN","fr_IE","fr_JM","fr_JO","fr_KE","fr_KG","fr_KI","fr_KM","fr_KN","fr_KW","fr_KY","fr_KZ","fr_LC","fr_LI","fr_LS","fr_LU","fr_MA","fr_MC","fr_MG","fr_MH","fr_ML","fr_MQ","fr_MR","fr_MS","fr_MU","fr_MW","fr_MZ","fr_NA","fr_NC","fr_NE","fr_NF","fr_NI","fr_NR","fr_NU","fr_NZ","fr_OM","fr_PA","fr_PE","fr_PF","fr_PG","fr_PM","fr_PN","fr_PW","fr_QA","fr_RE","fr_RS","fr_RW","fr_SA","fr_SB","fr_SC","fr_SH","fr_SJ","fr_SL","fr_SM","fr_SN","fr_SO","fr_SR","fr_ST","fr_SV","fr_SZ","fr_TC","fr_TD","fr_TG","fr_TJ","fr_TM","fr_TN","fr_TT","fr_TV","fr_UA","fr_UG","fr_US","fr_UY","fr_VA","fr_VC","fr_VE","fr_VG","fr_VU","fr_WF","fr_YE","fr_YT","fr_ZA","fr_ZM","he_IL","hu_HU","id_ID","it_IT","ja_JP","ko_KR","lv_LV","lt_LT","ms_BN","ms_MY","nl_BE","nl_NL","pl_PL","pt_BR","pt_PT","ro_RO","ru_EE","ru_LT","ru_LV","ru_RU","ru_UA","si_LK","sk_SK","sl_SI","sq_AL","sv_SE","tl_PH","th_TH","tr_TR","vi_VN","zh_C2","zh_CN","zh_HK","zh_TW","zh_AD","zh_AE","zh_AI","zh_AO","zh_AW","zh_BB","zh_BH","zh_BJ","zh_BM","zh_BS","zh_BZ","zh_CD","zh_CG","zh_CK","zh_CL","zh_CO","zh_CV","zh_DJ","zh_DM","zh_DO","zh_DZ","zh_EC","zh_EG","zh_ER","zh_ET","zh_FJ","zh_FK","zh_FO","zh_GA","zh_GD","zh_GE","zh_GI","zh_GL","zh_GM","zh_GN","zh_GT","zh_GW","zh_GY","zh_HN","zh_IE","zh_JM","zh_JO","zh_KE","zh_KG","zh_KI","zh_KM","zh_KN","zh_KW","zh_KY","zh_KZ","zh_LC","zh_LI","zh_LS","zh_LT","zh_LU","zh_MA","zh_MG","zh_MH","zh_ML","zh_MR","zh_MS","zh_MU","zh_MW","zh_MZ","zh_NA","zh_NC","zh_NE","zh_NF","zh_NI","zh_NR","zh_NU","zh_NZ","zh_OM","zh_PA","zh_PE","zh_PF","zh_PG","zh_PM","zh_PN","zh_PW","zh_QA","zh_RS","zh_RW","zh_SA","zh_SB","zh_SC","zh_SH","zh_SJ","zh_SL","zh_SM","zh_SN","zh_SO","zh_SR","zh_ST","zh_SV","zh_SZ","zh_TC","zh_TD","zh_TG","zh_TJ","zh_TM","zh_TN","zh_TT","zh_TV","zh_UA","zh_UG","zh_US","zh_UY","zh_VA","zh_VC","zh_VE","zh_VG","zh_VU","zh_WF","zh_YE","zh_ZA","zh_ZM"];function os(e){if(!e)return;let t;if(e.includes("-")){const[n,i]=e.split("-");t=`${n}_${i.toUpperCase()}`}else t=`${e}_${e.toUpperCase()}`;return rs.includes(t)?t:void 0}var as=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ss{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n,i){return as(this,void 0,void 0,function*(){if(!this.window.paypalFastlaneSdk){const r=this.getPayPalFastlaneSdkConfiguration(e,t,n,i);if(yield this.loadPayPalSdk(r),!this.window.paypalFastlaneSdk)throw new Pr}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i,r){return as(this,void 0,void 0,function*(){if(!this.window.paypalGooglePay||r){const r=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i);yield this.loadPayPalSdk(r)}if(!this.window.paypalGooglePay)throw new Pr;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t,n){return as(this,void 0,void 0,function*(){if(!this.window.paypalApms){const i=this.getPayPalApmSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.paypalApms)throw new Pr}return this.window.paypalApms})}getPayPalMessages(e,t,n){return as(this,void 0,void 0,function*(){if(!this.window.paypalMessages){const i=this.getPayPalSdkMessagesConfiguration(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.paypalMessages)throw new Pr;return this.window.paypalMessages})}loadPayPalSdk(e){return as(this,arguments,void 0,function*({options:e,attributes:t}){const n=this.transformConfig(e),i=this.transformConfig(t),r=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(r,{async:!0,attributes:i})})}getPayPalFastlaneSdkConfiguration(e,t,n,i){const{clientToken:r,initializationData:o}=e;if(!o||!o.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,attributionId:c}=o,u=os(i);return{options:Object.assign({"client-id":s,"merchant-id":d,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t,intent:a},u&&{locale:u}),attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":r}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i=!0){const{clientToken:r,initializationData:o}=e;if(!o||!o.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,buyerCountry:c,attributionId:u,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:h}=o,p=l||i,g=os(n);return{options:Object.assign(Object.assign({"client-id":s,"merchant-id":d,commit:p,components:["googlepay"],currency:t,intent:a},h&&{"buyer-country":c}),g&&{locale:g}),attributes:{"data-partner-attribution-id":u,"data-client-token":r,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:r,clientId:o,merchantId:a,buyerCountry:s,attributionId:d,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:u=[],enabledAlternativePaymentMethods:l=[]}=i,h=l,p=u.filter(e=>!l.includes(e)),g=os(n);return{options:Object.assign(Object.assign({"client-id":o,"merchant-id":a,"enable-funding":h.length>0?h:void 0,"disable-funding":p.length>0?p:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:r},c&&{"buyer-country":s}),g&&{locale:g}),attributes:{"data-partner-attribution-id":d,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new gr(hr.MissingPaymentMethod);const{clientId:r,merchantId:o,attributionId:a,isDeveloperModeApplicable:s,buyerCountry:d}=i,c=os(n);return{options:Object.assign(Object.assign({"client-id":r,"merchant-id":o,components:["messages"],currency:t},s&&{"buyer-country":d}),c&&{locale:c}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}function ds(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 gr(hr.MissingPaymentMethod)}var cs=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class us extends Ya{constructor(e,t){super("paypalsb",e),this.payPalCommerceSdk=t,this.service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return cs(this,void 0,void 0,function*(){var r,o,a,s,d;const c=this.service.getState(),u=null!==(o=null===(r=c.getStoreConfig())||void 0===r?void 0:r.currency.code)&&void 0!==o?o:n;if(!u)throw new gr(hr.MissingPaymentMethod);yield i.initialize.call(this,e,t,u);const l=i.getPaymentMethod.call(this);if(!l.initializationData)throw new gr(hr.MissingPaymentMethod);ds(l);const h=yield this.payPalCommerceSdk.getPayPalGooglePaySdk(l,u,c.getLocale());this.googlepayConfig=yield h.Googlepay().config();const{allowedPaymentMethods:p}=this.googlepayConfig;this.setGatewayIdentifier(null===(d=null===(s=null===(a=p[0])||void 0===a?void 0:a.tokenizationSpecification)||void 0===s?void 0:s.parameters)||void 0===d?void 0:d.gateway)})}getPaymentGatewayParameters(){if(this.googlepayConfig){const{allowedPaymentMethods:e}=this.googlepayConfig,{gatewayMerchantId:t}=e[0].tokenizationSpecification.parameters;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:t}}return{gateway:this.getGatewayIdentifier()}}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return cs(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n})}}const ls=Ar(t=>new Qa(t,new es(ns(),new us(t,new ss(le())),e(),n())),[{id:"googlepaypaypalcommerce"}]);var hs=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ps{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n){return hs(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsFastlaneSdk){const i=this.getPayPalFastlaneSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.bigCommercePaymentsFastlaneSdk)throw new Pr}return this.window.bigCommercePaymentsFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i){return hs(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsGooglePay||i){const i=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.bigCommercePaymentsGooglePay)throw new Pr;return this.window.bigCommercePaymentsGooglePay})}getPayPalApmsSdk(e,t){return hs(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsApms){const n=this.getPayPalApmSdkConfiguration(e,t);if(yield this.loadPayPalSdk(n),!this.window.bigCommercePaymentsApms)throw new Pr}return this.window.bigCommercePaymentsApms})}getPayPalMessages(e,t){return hs(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsMessages){const n=this.getPayPalSdkMessagesConfiguration(e,t);yield this.loadPayPalSdk(n)}if(!this.window.bigCommercePaymentsMessages)throw new Pr;return this.window.bigCommercePaymentsMessages})}loadPayPalSdk(e){return hs(this,arguments,void 0,function*({options:e,attributes:t}){const n=this.transformConfig(e),i=this.transformConfig(t),r=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(r,{async:!0,attributes:i})})}getPayPalFastlaneSdkConfiguration(e,t,n){const{clientToken:i,initializationData:r}=e;if(!r||!r.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:o,clientId:a,merchantId:s,attributionId:d}=r;return{options:{"client-id":a,"merchant-id":s,commit:!0,components:["fastlane","three-domain-secure"],currency:t,intent:o},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"bigCommercePaymentsFastlaneSdk","data-partner-attribution-id":d,"data-sdk-client-token":i}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n=!0){const{clientToken:i,initializationData:r}=e;if(!r||!r.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:o,clientId:a,merchantId:s,buyerCountry:d,attributionId:c,isHostedCheckoutEnabled:u,isDeveloperModeApplicable:l}=r,h=u||n;return{options:Object.assign({"client-id":a,"merchant-id":s,commit:h,components:["googlepay"],currency:t,intent:o},l&&{"buyer-country":d}),attributes:{"data-partner-attribution-id":c,"data-client-token":i,"data-namespace":"bigCommercePaymentsGooglePay"}}}getPayPalApmSdkConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:i,clientId:r,merchantId:o,buyerCountry:a,attributionId:s,isDeveloperModeApplicable:d,availableAlternativePaymentMethods:c=[],enabledAlternativePaymentMethods:u=[]}=n,l=this.filterFundingOptions(u),h=this.filterFundingOptions(c.filter(e=>!u.includes(e)));return{options:Object.assign({"client-id":r,"merchant-id":o,"enable-funding":l.length>0?l:void 0,"disable-funding":h.length>0?h:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:i},d&&{"buyer-country":a}),attributes:{"data-partner-attribution-id":s,"data-namespace":"bigCommercePaymentsApms"}}}getPayPalSdkMessagesConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new gr(hr.MissingPaymentMethod);const{clientId:i,merchantId:r,attributionId:o,isDeveloperModeApplicable:a,buyerCountry:s}=n;return{options:Object.assign({"client-id":i,"merchant-id":r,components:["messages"],currency:t},a&&{"buyer-country":s}),attributes:{"data-namespace":"bigCommercePaymentsMessages","data-partner-attribution-id":o}}}filterFundingOptions(e){const t=["klarna","afterpay"];return e?e.filter(e=>!t.includes(e)):[]}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}var gs=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ms extends Ya{constructor(e,t){super("googlepay_bigcommerce_payments",e),this.payPalSdkHelper=t,this.service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return gs(this,void 0,void 0,function*(){var r,o,a,s,d;const c=null!==(o=null===(r=this.service.getState().getStoreConfig())||void 0===r?void 0:r.currency.code)&&void 0!==o?o:n;if(!c)throw new gr(hr.MissingPaymentMethod);yield i.initialize.call(this,e,t,c);const u=i.getPaymentMethod.call(this);if(!u.initializationData)throw new gr(hr.MissingPaymentMethod);ds(u);const l=yield this.payPalSdkHelper.getPayPalGooglePaySdk(u,c);this.googlepayConfig=yield l.Googlepay().config();const{allowedPaymentMethods:h}=this.googlepayConfig;this.setGatewayIdentifier(null===(d=null===(s=null===(a=h[0])||void 0===a?void 0:a.tokenizationSpecification)||void 0===s?void 0:s.parameters)||void 0===d?void 0:d.gateway)})}getPaymentGatewayParameters(){if(this.googlepayConfig){const{allowedPaymentMethods:e}=this.googlepayConfig,{gatewayMerchantId:t}=e[0].tokenizationSpecification.parameters;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:t}}return{gateway:this.getGatewayIdentifier()}}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return gs(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n})}}const ys=Ar(t=>new Qa(t,new es(ns(),new ms(t,new ps(le())),e(),n())),[{id:"googlepay_bigcommerce_payments"}]),fs=Ar(t=>{const i=e();return new Qa(t,new es(ns(),new Ya("adyen",t),i,n()))},[{id:"googlepayadyenv2"}]),_s=Ar(t=>{const i=e();return new Qa(t,new es(ns(),new Ya("adyen",t),i,n()))},[{id:"googlepayadyenv3"}]);class Ss extends Ya{constructor(e){super("authorizenet",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,o=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return function(e){if(!function(e){return"paymentGatewayId"in e}(e))throw new gr(hr.MissingPaymentMethod)}(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.paymentGatewayId}}}const vs=Ar(t=>new Qa(t,new es(ns(),new Ss(t),e(),n())),[{id:"googlepayauthorizenet"}]),Cs=e=>"object"==typeof e&&null!==e&&"body"in e;function Is(e){if(!function(e){return"checkoutcomkey"in e}(e))throw new gr(hr.MissingPaymentMethod)}var ws=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Es extends Ya{constructor(e,t){super("checkoutltd",e),this._requestSender=t}processAdditionalAction(e){return new Promise((t,n)=>{if(Cs(e)&&function(e){var t;if("object"!=typeof e||null===e)return!1;const n=e;return"string"==typeof(null===(t=n.three_ds_result)||void 0===t?void 0:t.acs_url)&&"string"==typeof n.three_ds_result.code}(e.body)&&"three_d_secure_required"===e.body.three_ds_result.code)return window.location.assign(e.body.three_ds_result.acs_url);n(e)})}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return ws(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new Tr("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 gr(hr.MissingPaymentToken)}(i),n.nonce=yield this._tokenize(i),n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return Is(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.checkoutcomkey}}_tokenize(e){return ws(this,void 0,void 0,function*(){const t=this.getPaymentMethod().config.testMode?"https://api.sandbox.checkout.com/tokens":"https://api.checkout.com/tokens",n=this.getGooglePayInitializationData();Is(n);const{body:i}=yield this._requestSender.post(t,{credentials:!1,body:{type:"googlepay",token_data:e},headers:{Authorization:n.checkoutcomkey,"Content-Type":Ur.Json,"X-XSRF-TOKEN":null}});return i.token})}}const bs=Ar(t=>{const i=e();return new Qa(t,new es(ns(),new Es(t,i),i,n()))},[{id:"googlepaycheckoutcom"}]);class Ps extends Ya{constructor(e){super("cybersource",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,o=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}}const Os=Ar(t=>new Qa(t,new es(ns(),new Ps(t),e(),n())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]);class As extends Ya{constructor(e){super("chase",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,o=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}}const Ts=Ar(t=>new Qa(t,new es(ns(),new As(t),e(),n())),[{id:"googlepayorbital"}]);var ks,Rs,Ds,Ms,Ns,Ls,zs,Us,Fs,Bs,xs,qs;!function(e){e.SHIPPING="shipping",e.BILLING="billing"}(ks||(ks={})),function(e){e.SPLIT="split",e.FULL="full",e.ORGANIZATION="organization"}(Rs||(Rs={})),function(e){e.Open="open",e.Expired="expired",e.Complete="complete"}(Ds||(Ds={})),function(e){e.Paid="paid",e.UnPaid="unpaid",e.NoPaymentRequired="no_payment_required"}(Ms||(Ms={})),function(e){e.SUCCESS="success",e.ERROR="error"}(Ns||(Ns={})),function(e){e.CreditCard="card",e.ACH="us_bank_account",e.Link="link",e.EPS="eps",e.GRABPAY="grabpay",e.BANCONTACT="bancontact",e.IDEAL="ideal",e.ALIPAY="alipay",e.KLARNA="klarna",e.OCS="optimized_checkout",e.CHECKOUT_SESSION="checkout_session"}(Ls||(Ls={})),function(e){e.NEVER="never",e.AUTO="auto",e.ALWAYS="always",e.PAYMENT="payment",e.IF_REQUIRED="if_required"}(zs||(zs={})),function(e){e.V3="v3",e.ACACIA="acacia",e.BASIL="basil",e.CLOVER="clover"}(Us||(Us={})),function(e){e.PAYMENT="payment",e.AUTHENTICATION="linkAuthentication",e.SHIPPING="address",e.EXPRESS_CHECKOUT="expressCheckout"}(Fs||(Fs={})),function(e){e.REQUIRES_PAYMENT_METHOD="requires_payment_method",e.REQUIRES_CONFIRMATION="requires_confirmation",e.REQUIRES_ACTION="requires_action",e.PROCESSING="processing",e.SUCCEEDED="succeeded",e.CANCELED="canceled"}(Bs||(Bs={})),function(e){e.CLICK="click",e.CHANGE="change",e.READY="ready",e.SHIPPING_ADDRESS_CHANGE="shippingaddresschange",e.SHIPPING_RATE_CHANGE="shippingratechange",e.CONFIRM="confirm",e.CANCEL="cancel",e.LOADER_START="loaderstart"}(xs||(xs={})),function(e){e.ON_SESSION="on_session",e.OFF_SESSION="off_session"}(qs||(qs={}));var js=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Gs{constructor(e,t=window){this.scriptLoader=e,this.stripeWindow=t}getStripeClient(e,t,n,i,r){return js(this,void 0,void 0,function*(){if(this.stripeWindow.bcStripeClient)return this.stripeWindow.bcStripeClient;const o=yield this.load(n),{stripePublishableKey:a,stripeConnectedAccount:s}=e,d=o(a,Object.assign(Object.assign(Object.assign(Object.assign({},s?{stripeAccount:s}:{}),t?{locale:t}:{}),i?{betas:i}:{}),r?{apiVersion:r}:{}));return Object.assign(this.stripeWindow,{bcStripeClient:d}),d})}getElements(e,t){return js(this,void 0,void 0,function*(){let n=this.stripeWindow.bcStripeElements;return n?yield this.updateStripeElements(t):(n=e.elements(t),Object.assign(this.stripeWindow,{bcStripeElements:n})),n})}updateStripeElements(e){return js(this,void 0,void 0,function*(){const t=this.stripeWindow.bcStripeElements;t&&(t.update(e),yield t.fetchUpdates())})}getStripeCheckout(e,t){return js(this,void 0,void 0,function*(){let n=yield this.getStoredStripeCheckout(t);return n||(n=yield e.initCheckout(t),Object.assign(this.stripeWindow,{bcStripeCheckout:n})),n})}load(e){return js(this,void 0,void 0,function*(){if(!this.stripeWindow.Stripe&&(yield this.scriptLoader.loadScript(this.getScriptUrl(e)),!this.stripeWindow.Stripe))throw new Pr;return this.stripeWindow.Stripe})}getScriptUrl(e){return e&&e!==Us.V3?`https://js.stripe.com/${e}/stripe.js`:"https://js.stripe.com/v3/"}getStoredStripeCheckout(e){return js(this,void 0,void 0,function*(){const t=this.stripeWindow.bcStripeCheckout;if(t)try{const{actions:n,error:i}=yield t.loadActions();if(i||!n)return void this.logErrorToConsole(i);const r=yield n.getSession(),o=e.clientSecret.split("_secret_")[0];if(r.id===o)return t}catch(e){return void this.logErrorToConsole(e)}})}logErrorToConsole(e){e?console.error(e):console.error("No stripe checkout actions available on loadActions().")}}const Vs=["payment_element_beta_2","alipay_pm_beta_1","link_default_integration_beta_1","shipping_address_element_beta_1","address_element_beta_1"];function Hs(e){if(!function(e){return"stripeConnectedAccount"in e&&"stripePublishableKey"in e&&"stripeVersion"in e}(e))throw new gr(hr.MissingPaymentMethod)}var Ws=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ys extends Ya{constructor(e,t){super("stripe",e),this.paymentIntegrationService=e,this.scriptLoader=t}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return Ws(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new Tr("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 gr(hr.MissingPaymentToken)}(i),n.nonce=i.id,n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();Hs(e);const{stripeVersion:t,stripePublishableKey:n,stripeConnectedAccount:i}=e;return{gateway:this.getGatewayIdentifier(),"stripe:version":t,"stripe:publishableKey":`${n}/${i}`}}processAdditionalAction(e,t){return Ws(this,void 0,void 0,function*(){var n,i;if(!t)throw new Qo(["payment"]);if(!Cs(e)||("object"!=typeof(i=e.body)||null===i||!("three_ds_result"in i)||!("errors"in i)))throw e;if(z(e.body.errors,{code:"three_d_secure_required"})){const i=this.getGooglePayInitializationData();Hs(i),this.stripeUPEClient=yield this.loadStripeJs(i,t);const r=e.body.three_ds_result.token;let o,a=!1;try{o=yield this.stripeUPEClient.confirmCardPayment(r)}catch(e){try{o=yield this.stripeUPEClient.retrievePaymentIntent(r)}catch(e){a=!0}}if(null==o?void 0:o.error){if(this._throwDisplayableStripeError(o.error),this._isCancellationError(o.error))throw new lo;throw new Za}if(!(null==o?void 0:o.paymentIntent)&&!a)throw new Ie;return this.paymentIntegrationService.submitPayment({methodId:t,paymentData:{nonce:(null===(n=null==o?void 0:o.paymentIntent)||void 0===n?void 0:n.id)||r}})}throw e})}loadStripeJs(e,t){return Ws(this,void 0,void 0,function*(){if(this.stripeUPEClient)return this.stripeUPEClient;const n=this.paymentIntegrationService.getState().getCartLocale();return"googlepaystripeocs"===t&&e.useNewStripeJsVersion?this.scriptLoader.getStripeClient(e,n,Us.CLOVER):this.scriptLoader.getStripeClient(e,n,Us.V3,Vs,"2020-03-02;alipay_beta=v1;link_beta=v1")})}_isCancellationError(e){var t,n;return e&&-1!==(null===(n=null===(t=e.payment_intent.last_payment_error)||void 0===t?void 0:t.message)||void 0===n?void 0:n.indexOf("canceled"))}_throwDisplayableStripeError(e){if(m(["card_error","invalid_request_error","validation_error"],e.type))throw new Error(e.message)}}const Ks=Ar(t=>new Qa(t,new es(ns(),new Ys(t,new Gs(le())),e(),n())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]);class $s extends Ya{constructor(e){super("worldpay",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,o=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}}const Zs=Ar(t=>new Qa(t,new es(ns(),new $s(t),e(),n())),[{id:"googlepayworldpayaccess"}]);function Js(){const{navigator:e}=window;let t;return t=e.language?e.language:e.userLanguage,{color_depth:window.screen.colorDepth||24,java_enabled:"function"==typeof e.javaEnabled&&e.javaEnabled(),language:t,screen_height:window.screen.height,screen_width:window.screen.width,time_zone_offset:(new Date).getTimezoneOffset().toString()}}var Qs=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Xs extends Ya{constructor(e,t){super("worldlinena",e),this.formPoster=t}extraPaymentData(){return Qs(this,void 0,void 0,function*(){return Promise.resolve({browser_info:Js()})})}processAdditionalAction(e){return Qs(this,void 0,void 0,function*(){if(!function(e){return Cs(e)&&(t=e.body,C(t)&&"object"==typeof t&&"errors"in t&&"three_ds_result"in t&&y(t.errors)&&z(t.errors,{code:"three_d_secure_required"}));var t}(e))throw e;const{three_ds_result:t}=e.body,{acs_url:n,payer_auth_request:i,merchant_data:r}=t||{};if(!n||!i||!r)throw new Qo(["formUrl","threeDSSessionData","creq"]);return new Promise(e=>{this.formPoster.postForm(n,{threeDSSessionData:i,creq:r},e,"_top")})})}}const ed=Ar(t=>new Qa(t,new es(ns(),new Xs(t,n()),e(),n())),[{id:"googlepaytdonlinemart"}]);var td,nd,id,rd,od,ad,sd,dd,cd,ud,ld=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class hd{constructor(e){this.scriptLoader=e,this.window=window}getPayPalSDK(e,t,n,i,r){return ld(this,void 0,void 0,function*(){if(!this.window.paypal||r){const r=this.getPayPalSdkScriptConfigOrThrow(e,t,n,i);if(yield this.loadPayPalSdk(r),!this.window.paypal)throw new Pr}return this.window.paypal})}getPayPalFastlaneSdk(e,t,n,i){return ld(this,void 0,void 0,function*(){if(!this.window.paypalFastlaneSdk){const r=this.getPayPalFastlaneSdkConfiguration(e,t,n,i);if(yield this.loadPayPalSdk(r),!this.window.paypalFastlaneSdk)throw new Pr}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i,r){return ld(this,void 0,void 0,function*(){if(!this.window.paypalGooglePay||r){const r=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i);yield this.loadPayPalSdk(r)}if(!this.window.paypalGooglePay)throw new Pr;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t,n){return ld(this,void 0,void 0,function*(){if(!this.window.paypalApms){const i=this.getPayPalApmSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.paypalApms)throw new Pr}return this.window.paypalApms})}getPayPalMessages(e,t,n){return ld(this,void 0,void 0,function*(){if(!this.window.paypalMessages){const i=this.getPayPalSdkMessagesConfiguration(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.paypalMessages)throw new Pr;return this.window.paypalMessages})}loadPayPalSdk(e){return ld(this,arguments,void 0,function*({options:e,attributes:t}){const n=this.transformConfig(e),i=this.transformConfig(t),r=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(r,{async:!0,attributes:i})})}getPayPalSdkScriptConfigOrThrow(e,t,n,i=!0){const{id:r,clientToken:o,initializationData:a}=e;if(!a||!a.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:s,clientId:d,merchantId:c,buyerCountry:u,attributionId:l,isVenmoEnabled:h,isHostedCheckoutEnabled:p,isPayPalCreditAvailable:g,isDeveloperModeApplicable:m,availableAlternativePaymentMethods:y=[],enabledAlternativePaymentMethods:f=[],isGooglePayEnabled:_}=a,S=p||i,v="paypalcommercecreditcards"===r||"bigcommerce_payments_creditcards"===r,C=v?["card"]:[],I=g?["credit","paylater"]:[],w=h?["venmo"]:[],E=_?["googlepay"]:[],b=i?["card-fields"]:[],P=[...v?[]:["card"],...g?[]:["credit","paylater"],...h?[]:["venmo"],...y.filter(e=>!f.includes(e))],O=[...C,...I,...w,...f],A=os(n);return{options:Object.assign(Object.assign({"client-id":d,"merchant-id":c,"enable-funding":O.length>0?O:void 0,"disable-funding":P.length>0?P:void 0,commit:S,components:["buttons","hosted-fields","payment-fields","legal",...E,...b],currency:t,intent:s},m&&{"buyer-country":u}),A&&{locale:A}),attributes:{"data-partner-attribution-id":l,"data-client-token":o}}}getPayPalFastlaneSdkConfiguration(e,t,n,i){const{clientToken:r,initializationData:o}=e;if(!o||!o.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,attributionId:c}=o,u=os(i);return{options:Object.assign(Object.assign({"client-id":s,"merchant-id":d,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t},u&&{locale:u}),{intent:a}),attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":r}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i=!0){const{clientToken:r,initializationData:o}=e;if(!o||!o.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,buyerCountry:c,attributionId:u,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:h}=o,p=l||i,g=os(n);return{options:Object.assign(Object.assign({"client-id":s,"merchant-id":d,commit:p,components:["googlepay"],currency:t,intent:a},h&&{"buyer-country":c}),g&&{locale:g}),attributes:{"data-partner-attribution-id":u,"data-client-token":r,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new gr(hr.MissingPaymentMethod);const{intent:r,clientId:o,merchantId:a,buyerCountry:s,attributionId:d,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:u=[],enabledAlternativePaymentMethods:l=[]}=i,h=l,p=u.filter(e=>!l.includes(e)),g=os(n);return{options:Object.assign(Object.assign({"client-id":o,"merchant-id":a,"enable-funding":h.length>0?h:void 0,"disable-funding":p.length>0?p:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:r},c&&{"buyer-country":s}),g&&{locale:g}),attributes:{"data-partner-attribution-id":d,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new gr(hr.MissingPaymentMethod);const{clientId:r,merchantId:o,attributionId:a,isDeveloperModeApplicable:s,buyerCountry:d}=i,c=os(n);return{options:Object.assign(Object.assign({"client-id":r,"merchant-id":o,components:["messages"],currency:t},s&&{"buyer-country":d}),c&&{locale:c}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}!function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(td||(td={})),function(e){e.Always="SCA_ALWAYS"}(nd||(nd={})),function(e){e.Succeeded="succeeded",e.Cancelled="cancelled",e.Errored="errored"}(id||(id={})),function(e){e.Possible="POSSIBLE",e.No="NO",e.Unknown="UNKNOWN",e.Yes="YES"}(rd||(rd={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(od||(od={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(ad||(ad={})),function(e){e.pill="pill",e.rect="rect"}(sd||(sd={})),function(e){e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="canceled",e.UNRECOGNIZED="unrecognized"}(dd||(dd={})),(cd||(cd={})).OXXO="oxxo",function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(ud||(ud={}));var pd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class gd{constructor(e,t,n,i){this.formPoster=e,this.paymentIntegrationService=t,this.paypalRequestSender=n,this.paypalSdkLoader=i}loadPayPalSdk(e,t,n,i){return pd(this,void 0,void 0,function*(){const r=this.paymentIntegrationService.getState(),o=t||r.getCartOrThrow().currency.code,a=r.getPaymentMethodOrThrow(e),s=r.getLocale();return this.paypalSdk=yield this.paypalSdkLoader.getPayPalSDK(a,o,s,n,i),this.paypalSdk})}getPayPalSdkOrThrow(){if(!this.paypalSdk)throw new Pr;return this.paypalSdk}createBuyNowCartOrThrow(e){return pd(this,void 0,void 0,function*(){const t=e.getBuyNowCartRequestBody();if(!t)throw new gr(hr.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(t)}catch(e){throw new kr}})}createOrder(e,t){return pd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i}=yield this.paypalRequestSender.createOrder(e,Object.assign({cartId:n},t));return i})}createOrderCardFields(e,t){return pd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i,setupToken:r}=yield this.paypalRequestSender.createOrder(e,Object.assign({cartId:n},t));return Object.assign({orderId:i},r?{setupToken:r}:{})})}updateOrder(e,t,n,i){return pd(this,void 0,void 0,function*(){const r=this.paymentIntegrationService.getState(),o=r.getCartOrThrow();let a;i||(a=r.getConsignmentsOrThrow()[0]);try{yield this.paypalRequestSender.updateOrder(e,Object.assign(Object.assign({availableShippingOptions:i?[]:null==a?void 0:a.availableShippingOptions,cartId:o.id,selectedShippingOption:i?null:null==a?void 0:a.selectedShippingOption},t?{methodId:t}:{}),n?{orderId:n}:{}))}catch(e){throw new Ie}})}getOrderStatus(e,t){return pd(this,void 0,void 0,function*(){try{const{status:n}=yield this.paypalRequestSender.getOrderStatus(e,t);return n}catch(e){throw new Ie}})}tokenizePayment(e,t){const n=this.paymentIntegrationService.getState().getCartOrThrow();if(!t)throw new gr(hr.MissingOrderId);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",action:"set_external_checkout",provider:e,order_id:t},n.source===vo.BuyNow&&{cart_id:n.id}))}submitPayment(e,t,n){return pd(this,void 0,void 0,function*(){const i={formattedPayload:{vault_payment_instrument:null,set_as_default_stored_instrument:null,device_info:null,method_id:e,paypal_account:{order_id:t}}};yield this.paymentIntegrationService.submitPayment(Object.assign({methodId:e,paymentData:i},n?{gatewayId:n}:{}))})}getShippingOptionOrThrow(e){const t=this.paymentIntegrationService.getState().getConsignmentsOrThrow()[0],n=t.availableShippingOptions||[],i=n.find(e=>e.isRecommended),r=(e?n.find(t=>t.id===e):n.find(e=>{if(t.selectedShippingOption){const n=t.selectedShippingOption.id;return e.id===n}return!1}))||i||n[0];if(!r)throw new Error("Your order can't be shipped to this address");return r}getAddress(e){return{firstName:(null==e?void 0:e.firstName)||"",lastName:(null==e?void 0:e.lastName)||"",email:(null==e?void 0:e.email)||"",phone:(null==e?void 0:e.phone)||"",company:"",address1:(null==e?void 0:e.address1)||"",address2:(null==e?void 0:e.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:[]}}getBillingAddressFromOrderDetails({payer:e}){var t,n;return this.getAddress({firstName:e.name.given_name,lastName:e.name.surname,email:e.email_address,address1:e.address.address_line_1,address2:e.address.address_line_2,city:e.address.admin_area_2,countryCode:e.address.country_code,postalCode:e.address.postal_code,stateOrProvinceCode:e.address.admin_area_1,phone:null===(n=null===(t=e.phone)||void 0===t?void 0:t.phone_number)||void 0===n?void 0:n.national_number})}getShippingAddressFromOrderDetails(e){const{payer:t,purchase_units:n}=e,{address:i,name:{full_name:r}}=n[0].shipping,[o,...a]=r.split(" ");return this.getAddress({firstName:o,lastName:a.join(" "),email:t.email_address,address1:i.address_line_1,address2:i.address_line_2,city:i.admin_area_2,countryCode:i.country_code,postalCode:i.postal_code,stateOrProvinceCode:i.admin_area_1})}getValidButtonStyle(e={}){const{color:t,height:n,label:i,shape:r}=e,o={color:t&&ad[t]?t:void 0,height:this.getValidHeight(n),label:i&&od[i]?i:void 0,shape:r&&sd[r]?r:void 0};return R(o,v)}getValidHeight(e){return e&&"number"==typeof e?e>55?55:e<25?25:e:40}removeElement(e){const t=e&&document.getElementById(e);t&&(t.style.display="none")}}var md=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class yd{constructor(e){this.requestSender=e}createOrder(e,t){return md(this,void 0,void 0,function*(){const n=`/api/storefront/payment/${e}`,i=t,r=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.post(n,{headers:r,body:i})).body})}updateOrder(e,t){return md(this,void 0,void 0,function*(){const n=`/api/storefront/initialization/${e}`,i=t,r=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.put(n,{headers:r,body:i})).body})}getOrderStatus(e,t){return md(this,void 0,void 0,function*(){const n=`/api/storefront/initialization/${e}`,i=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.get(n,Object.assign({headers:i},t))).body})}}const fd=t=>{const{getHost:i}=t.getState();return new gd(n(),t,new yd(e({host:i()})),new hd(le()))};var _d=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};const Sd=class{constructor(e,t){this.paymentIntegrationService=e,this.paypalIntegrationService=t}createPayPalButton(e,t,n,i){const{style:r,fundingSource:o,isHostedCheckoutEnabled:a,isServerSideShippingCallbacksEnabled:s,onClick:d,onCancel:c,onPaymentComplete:u,onError:l}=n;this.onError=l;const h=this.paypalIntegrationService.getPayPalSdkOrThrow();if(!Object.values(h.FUNDING).includes(o))throw new Tr('Unable to initialize PayPal button because "fundingSource" argument is not valid funding source.');const p=Object.assign(Object.assign({},!s&&{onShippingAddressChange:t=>this.onShippingAddressChange(t,e),onShippingOptionsChange:t=>this.onShippingOptionsChange(t,e)}),{onApprove:(n,i)=>this.onHostedCheckoutApprove(n,i,t,e,u,s)});return h.Buttons(Object.assign(Object.assign(Object.assign({fundingSource:o,style:this.paypalIntegrationService.getValidButtonStyle(r),createOrder:()=>_d(this,void 0,void 0,function*(){if(i){const e=yield this.paypalIntegrationService.createBuyNowCartOrThrow(i);yield this.paymentIntegrationService.loadCheckout(e.id)}return this.paypalIntegrationService.createOrder(e)}),onApprove:({orderID:e})=>this.paypalIntegrationService.tokenizePayment(t,e)},d?{onClick:d}:{}),c?{onCancel:c}:{}),a&&p))}onHostedCheckoutApprove(e,t,n,i,r,o){return _d(this,void 0,void 0,function*(){if(!e.orderID)throw new gr(hr.MissingOrderId);const a=this.paymentIntegrationService.getState().getCartOrThrow();try{const s=a.lineItems.physicalItems.length>0;if(!o){const e=yield t.order.get(),n=this.paypalIntegrationService.getBillingAddressFromOrderDetails(e);if(yield this.paymentIntegrationService.updateBillingAddress(n),s){const t=this.paypalIntegrationService.getShippingAddressFromOrderDetails(e);yield this.paymentIntegrationService.updateShippingAddress(t)}}s&&(yield this.paypalIntegrationService.updateOrder(i,void 0,void 0,o)),o&&(yield this.paymentIntegrationService.loadCheckout()),yield this.paymentIntegrationService.submitOrder({},{params:{methodId:n}}),yield this.paypalIntegrationService.submitPayment(n,e.orderID),r&&"function"==typeof r&&r()}catch(e){this.handleError(e)}})}onShippingAddressChange(e,t){return _d(this,void 0,void 0,function*(){const n=this.paypalIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state});try{yield this.paymentIntegrationService.updateBillingAddress(n),yield this.paymentIntegrationService.updateShippingAddress(n);const e=this.paypalIntegrationService.getShippingOptionOrThrow();yield this.paymentIntegrationService.selectShippingOption(e.id),yield this.paypalIntegrationService.updateOrder(t)}catch(e){this.handleError(e)}})}onShippingOptionsChange(e,t){return _d(this,void 0,void 0,function*(){const n=this.paypalIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id);try{yield this.paymentIntegrationService.selectShippingOption(n.id),yield this.paypalIntegrationService.updateOrder(t)}catch(e){this.handleError(e)}})}handleError(e){if("function"!=typeof this.onError)throw e;this.onError(e)}};class vd{constructor(e,t,n){this.paymentIntegrationService=e,this.paypalIntegrationService=t,this.paypalButtonCreationService=n}initialize(e){return t=this,n=void 0,r=function*(){var t;const{paypalcommerce:n,containerId:i,methodId:r}=e,o=Boolean(null==n?void 0:n.buyNowInitializeOptions);if(!r)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.paypalcommerce" argument is not provided.');if(o&&!n.currencyCode)throw new Tr('Unable to initialize payment because "options.paypalcommerce.currencyCode" argument is not provided.');if(o&&"function"!=typeof(null===(t=n.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody))throw new Tr('Unable to initialize payment because "options.paypalcommerce.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');o||(yield this.paymentIntegrationService.loadDefaultCheckout());const a=o?n.currencyCode:this.paymentIntegrationService.getState().getCartOrThrow().currency.code;yield this.paypalIntegrationService.loadPayPalSdk(r,a,!1),this.renderButton(i,r,n)},new((i=void 0)||(i=Promise))(function(e,o){function a(e){try{d(r.next(e))}catch(e){o(e)}}function s(e){try{d(r.throw(e))}catch(e){o(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,s)}d((r=r.apply(t,n||[])).next())});var t,n,i,r}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onComplete:o,onEligibilityFailure:a}=n,s=this.paypalIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),{isHostedCheckoutEnabled:c,isServerSideShippingCallbacksEnabled:u}=d.initializationData||{},l={onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},h=Object.assign(Object.assign({fundingSource:s.FUNDING.PAYPAL,style:this.paypalIntegrationService.getValidButtonStyle(r),isServerSideShippingCallbacksEnabled:u,isHostedCheckoutEnabled:c},i&&l),c&&o&&{onPaymentComplete:()=>o()}),p=this.paypalButtonCreationService.createPayPalButton("paypalcommerce",t,h,i);p.isEligible()?p.render(`#${e}`):a&&"function"==typeof a?a():this.paypalIntegrationService.removeElement(e)}}const Cd=Ar(e=>{const t=fd(e),n=new Sd(e,t);return new vd(e,t,n)},[{id:"paypalcommerce"}]);var Id=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class wd{constructor(e,t){this.paymentIntegrationService=e,this.paypalIntegrationService=t}initialize(e){return Id(this,void 0,void 0,function*(){const{paypalcommercecredit:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,currencyCode:o}=t||{},a=!!r;if(!i)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Tr('Unable to initialize payment because "options.paypalcommercecredit" argument is not provided.');if(a&&!o)throw new Tr('Unable to initialize payment because "options.paypalcommercecredit.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null==r?void 0:r.getBuyNowCartRequestBody))throw new Tr('Unable to initialize payment because "options.paypalcommercecredit.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');a||(yield this.paymentIntegrationService.loadDefaultCheckout());const s=this.paymentIntegrationService.getState(),d=a?o:s.getCartOrThrow().currency.code;yield this.paypalIntegrationService.loadPayPalSdk(i,d,!1),this.renderButton(n,i,t)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onComplete:o,onEligibilityFailure:a}=n,s=this.paypalIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),{isHostedCheckoutEnabled:c,isServerSideShippingCallbacksEnabled:u}=d.initializationData||{},l={createOrder:()=>this.paypalIntegrationService.createOrder("paypalcommercecredit"),onApprove:({orderID:e})=>this.paypalIntegrationService.tokenizePayment(t,e)},h={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},p=Object.assign(Object.assign({},!u&&{onShippingAddressChange:e=>this.onShippingAddressChange(e),onShippingOptionsChange:e=>this.onShippingOptionsChange(e)}),{onApprove:(e,n)=>this.onHostedCheckoutApprove(e,n,t,o,u)}),g=[s.FUNDING.PAYLATER,s.FUNDING.CREDIT];let m=!1;g.forEach(t=>{if(!m){const n=Object.assign(Object.assign(Object.assign({fundingSource:t,style:this.paypalIntegrationService.getValidButtonStyle(r)},l),i&&h),c&&p),o=s.Buttons(n);o.isEligible()?(o.render(`#${e}`),m=!0):a&&"function"==typeof a&&a()}}),m||this.paypalIntegrationService.removeElement(e)}handleClick(e){return Id(this,void 0,void 0,function*(){if(e){const t=yield this.paypalIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}onHostedCheckoutApprove(e,t,n,i,r){return Id(this,void 0,void 0,function*(){if(!e.orderID)throw new gr(hr.MissingOrderId);const o=this.paymentIntegrationService.getState().getCartOrThrow();try{const a=o.lineItems.physicalItems.length>0;if(!r){const e=yield t.order.get(),n=this.paypalIntegrationService.getBillingAddressFromOrderDetails(e);if(yield this.paymentIntegrationService.updateBillingAddress(n),a){const t=this.paypalIntegrationService.getShippingAddressFromOrderDetails(e);yield this.paymentIntegrationService.updateShippingAddress(t)}}return a&&(yield this.paypalIntegrationService.updateOrder("paypalcommerce",void 0,void 0,r)),r&&(yield this.paymentIntegrationService.loadCheckout()),yield this.paymentIntegrationService.submitOrder({},{params:{methodId:n}}),yield this.paypalIntegrationService.submitPayment(n,e.orderID),i&&"function"==typeof i&&i(),!0}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingAddressChange(e){return Id(this,void 0,void 0,function*(){const t=this.paypalIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state});try{yield this.paymentIntegrationService.updateBillingAddress(t),yield this.paymentIntegrationService.updateShippingAddress(t);const e=this.paypalIntegrationService.getShippingOptionOrThrow();yield this.paymentIntegrationService.selectShippingOption(e.id),yield this.paypalIntegrationService.updateOrder("paypalcommerce")}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingOptionsChange(e){return Id(this,void 0,void 0,function*(){const t=this.paypalIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id);try{yield this.paymentIntegrationService.selectShippingOption(t.id),yield this.paypalIntegrationService.updateOrder("paypalcommerce")}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}}const Ed=Ar(e=>new wd(e,fd(e)),[{id:"paypalcommercecredit"}]);var bd,Pd,Od,Ad,Td,kd,Rd;!function(e){e.Possible="POSSIBLE",e.No="NO",e.Unknown="UNKNOWN",e.Yes="YES"}(bd||(bd={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(Pd||(Pd={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(Od||(Od={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(Ad||(Ad={})),function(e){e.pill="pill",e.rect="rect"}(Td||(Td={})),function(e){e.OXXO="oxxo",e.IDEAL="ideal"}(kd||(kd={})),function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(Rd||(Rd={}));var Dd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Md{constructor(e,t,n,i){this.formPoster=e,this.paymentIntegrationService=t,this.paypalCommerceRequestSender=n,this.paypalCommerceScriptLoader=i}loadPayPalSdk(e,t,n,i){return Dd(this,void 0,void 0,function*(){const r=this.paymentIntegrationService.getState(),o=t||r.getCartOrThrow().currency.code,a=r.getPaymentMethodOrThrow(e);return this.paypalSdk=yield this.paypalCommerceScriptLoader.getPayPalSDK(a,o,r.getLocale(),n,i),this.paypalSdk})}getPayPalSdkOrThrow(){if(!this.paypalSdk)throw new Pr;return this.paypalSdk}createBuyNowCartOrThrow(e){return Dd(this,void 0,void 0,function*(){const t=e.getBuyNowCartRequestBody();if(!t)throw new gr(hr.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(t)}catch(e){throw new kr}})}createOrder(e,t){return Dd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i}=yield this.paypalCommerceRequestSender.createOrder(e,Object.assign({cartId:n},t));return i})}createOrderCardFields(e,t){return Dd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i,setupToken:r}=yield this.paypalCommerceRequestSender.createOrder(e,Object.assign({cartId:n},t));return Object.assign({orderId:i},r?{setupToken:r}:{})})}updateOrder(e){return Dd(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState(),n=t.getCartOrThrow(),i=t.getConsignmentsOrThrow()[0];try{yield this.paypalCommerceRequestSender.updateOrder({availableShippingOptions:e?[]:i.availableShippingOptions,cartId:n.id,selectedShippingOption:e?null:i.selectedShippingOption})}catch(e){throw new Ie}})}getOrderStatus(e,t){return Dd(this,void 0,void 0,function*(){try{const{status:n}=yield this.paypalCommerceRequestSender.getOrderStatus(e,t);return n}catch(e){throw new Ie}})}tokenizePayment(e,t){const n=this.paymentIntegrationService.getState().getCartOrThrow();if(!t)throw new gr(hr.MissingOrderId);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",action:"set_external_checkout",provider:e,order_id:t},n.source===vo.BuyNow&&{cart_id:n.id}))}submitPayment(e,t,n){return Dd(this,void 0,void 0,function*(){const i={formattedPayload:{vault_payment_instrument:null,set_as_default_stored_instrument:null,device_info:null,method_id:e,paypal_account:{order_id:t}}};yield this.paymentIntegrationService.submitPayment(Object.assign({methodId:e,paymentData:i},n?{gatewayId:n}:{}))})}getShippingOptionOrThrow(e){const t=this.paymentIntegrationService.getState().getConsignmentsOrThrow()[0],n=t.availableShippingOptions||[],i=n.find(e=>e.isRecommended),r=(e?n.find(t=>t.id===e):n.find(e=>{var n;return e.id===(null===(n=t.selectedShippingOption)||void 0===n?void 0:n.id)}))||i||n[0];if(!r)throw new Error("Your order can't be shipped to this address");return r}getAddress(e){return{firstName:(null==e?void 0:e.firstName)||"",lastName:(null==e?void 0:e.lastName)||"",email:(null==e?void 0:e.email)||"",phone:(null==e?void 0:e.phone)||"",company:"",address1:(null==e?void 0:e.address1)||"",address2:(null==e?void 0:e.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:[]}}getBillingAddressFromOrderDetails({payer:e}){var t,n;return this.getAddress({firstName:e.name.given_name,lastName:e.name.surname,email:e.email_address,address1:e.address.address_line_1,address2:e.address.address_line_2,city:e.address.admin_area_2,countryCode:e.address.country_code,postalCode:e.address.postal_code,stateOrProvinceCode:e.address.admin_area_1,phone:null===(n=null===(t=e.phone)||void 0===t?void 0:t.phone_number)||void 0===n?void 0:n.national_number})}getShippingAddressFromOrderDetails(e){const{payer:t,purchase_units:n}=e,{address:i,name:{full_name:r}}=n[0].shipping,[o,...a]=r.split(" ");return this.getAddress({firstName:o,lastName:a.join(" "),email:t.email_address,address1:i.address_line_1,address2:i.address_line_2,city:i.admin_area_2,countryCode:i.country_code,postalCode:i.postal_code,stateOrProvinceCode:i.admin_area_1})}getValidButtonStyle(e){const{color:t,height:n,label:i,shape:r}=e||{},o={color:t&&Ad[t]?t:void 0,height:this.getValidHeight(n),label:i&&Od[i]?i:void 0,shape:r&&Td[r]?r:void 0};return R(o,v)}getValidHeight(e){return e&&"number"==typeof e?e>55?55:e<25?25:e:40}removeElement(e){const t=e&&document.getElementById(e);t&&(t.style.display="none")}}var Nd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ld{constructor(e){this.requestSender=e}createOrder(e,t){return Nd(this,void 0,void 0,function*(){const n=`/api/storefront/payment/${e}`,i=t,r=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.post(n,{headers:r,body:i})).body})}updateOrder(e){return Nd(this,void 0,void 0,function*(){const t=e,n=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.put("/api/storefront/initialization/paypalcommerce",{headers:n,body:t})).body})}getOrderStatus(){return Nd(this,arguments,void 0,function*(e="paypalcommerce",t){const n=`/api/storefront/initialization/${e}`,i=Object.assign({"X-API-INTERNAL":Lr,"Content-Type":Ur.Json},Fr);return(yield this.requestSender.get(n,Object.assign({headers:i},t))).body})}}var zd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ud{constructor(e){this.scriptLoader=e,this.window=window}getPayPalSDK(e,t,n,i,r){return zd(this,void 0,void 0,function*(){const o=this.getPayPalSdkScriptConfigOrThrow(e,t,n,i);return this.loadPayPalSDK(o,r)})}loadPayPalSDK(e){return zd(this,arguments,void 0,function*(e,t=!1){if(!this.window.paypal||t){const t=this.transformConfig(e.options),n=this.transformConfig(e.attributes),i=`https://www.paypal.com/sdk/js?${new URLSearchParams(t).toString()}`;yield this.scriptLoader.loadScript(i,{async:!0,attributes:n})}if(!this.window.paypal)throw new Pr;return this.window.paypal})}getPayPalSdkScriptConfigOrThrow(e,t,n,i=!0){const{id:r,clientToken:o,initializationData:a}=e;if(!(null==a?void 0:a.clientId))throw new gr(hr.MissingPaymentMethod);const{intent:s,clientId:d,merchantId:c,buyerCountry:u,attributionId:l,isVenmoEnabled:h,isHostedCheckoutEnabled:p,isPayPalCreditAvailable:g,isDeveloperModeApplicable:m,availableAlternativePaymentMethods:y=[],enabledAlternativePaymentMethods:f=[],isGooglePayEnabled:_}=a,S=p||i,v="paypalcommercecreditcards"===r,C=v?["card"]:[],I=g?["credit","paylater"]:[],w=h?["venmo"]:[],E=_?["googlepay"]:[],b=i?["card-fields"]:[],P=[...v?[]:["card"],...g?[]:["credit","paylater"],...h?[]:["venmo"],...y.filter(e=>!f.includes(e))],O=[...C,...I,...w,...f],A=os(n);return{options:Object.assign(Object.assign({"client-id":d,"merchant-id":c,"enable-funding":O.length>0?O:void 0,"disable-funding":P.length>0?P:void 0,commit:S,components:["buttons","hosted-fields","payment-fields","legal",...E,...b],currency:t,intent:s},m&&{"buyer-country":u}),A&&{locale:A}),attributes:{"data-partner-attribution-id":l,"data-client-token":o}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}var Fd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Bd{constructor(e,t){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t}initialize(e){return Fd(this,void 0,void 0,function*(){const{paypalcommercevenmo:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,currencyCode:o}=t||{},a=!!r;if(!i)throw new Tr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Tr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Tr('Unable to initialize payment because "options.paypalcommercevenmo" argument is not provided.');if(a&&!o)throw new Tr('Unable to initialize payment because "options.paypalcommercevenmo.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null==r?void 0:r.getBuyNowCartRequestBody))throw new Tr('Unable to initialize payment because "options.paypalcommercevenmo.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');a||(yield this.paymentIntegrationService.loadDefaultCheckout());const s=a?o:this.paymentIntegrationService.getState().getCartOrThrow().currency.code;yield this.paypalCommerceIntegrationService.loadPayPalSdk(i,s,!1),this.renderButton(n,i,t)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onEligibilityFailure:o}=n,a=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow(),s=a.FUNDING.VENMO,d={createOrder:()=>this.paypalCommerceIntegrationService.createOrder("paypalcommercevenmo"),onApprove:({orderID:e})=>this.paypalCommerceIntegrationService.tokenizePayment(t,e)},c={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},u=Object.assign(Object.assign({fundingSource:s,style:this.getValidVenmoButtonStyles(r)},d),i&&c),l=a.Buttons(u);l.isEligible()?l.render(`#${e}`):o&&"function"==typeof o?o():this.paypalCommerceIntegrationService.removeElement(e)}getValidVenmoButtonStyles(e){const t=this.paypalCommerceIntegrationService.getValidButtonStyle(e);return t.color===Ad.gold?Object.assign(Object.assign({},t),{color:void 0}):t}handleClick(e){return Fd(this,void 0,void 0,function*(){if(e){const t=yield this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}}const xd=Ar(t=>new Bd(t,(t=>{const{getHost:i}=t.getState();return new Md(n(),t,new Ld(e({host:i()})),new Ud(le()))})(t)),[{id:"paypalcommercevenmo"}]);var qd,jd,Gd,Vd,Hd,Wd;!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(qd||(qd={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(jd||(jd={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black"}(Gd||(Gd={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(Vd||(Vd={})),function(e){e.PILL="pill",e.RECT="rect"}(Hd||(Hd={})),function(e){e.ACKNOWLEDGE="ACKNOWLEDGE",e.FINALIZE="FINALIZE",e.INITIALIZE="INITIALIZE"}(Wd||(Wd={}));var Yd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Kd{constructor(e,t,n){this.paymentIntegrationService=e,this.paypalExpressScriptLoader=t,this.formPoster=n}initialize(e){return Yd(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!e.paypal)throw new Tr;if(!t.config.merchantId)throw new gr(hr.MissingPaymentMethod);const n=yield this.paypalExpressScriptLoader.loadPaypalSDK(t.config.merchantId);this.renderButton(e,n)})}deinitialize(){return Promise.resolve()}renderButton(e,t){const{containerId:n,methodId:i,paypal:r}=e,{allowCredit:o,clientId:a,onPaymentError:s,shouldProcessPayment:d,style:c}=r,u=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!u.config.merchantId)throw new gr(hr.MissingPaymentMethod);const l=u.config.merchantId,h=u.config.testMode?"sandbox":"production",p={[h]:a},g=t.FUNDING.CREDIT||"credit",m=o?[g]:[],y=o?[]:[g];return t.Button.render({env:h,client:p,commit:d,funding:{allowed:m,disallowed:y},style:this.getStyle(c),payment:(e,t)=>this.setupPayment(l,t,s),onAuthorize:(e,t)=>this.tokenizePayment(e,i,t,d)},n)}getStyle(e){const{color:t,fundingicons:n,label:i,layout:r,shape:o,size:a,tagline:s}=e||{};return{color:t,fundingicons:n,label:i,layout:r,shape:o||Hd.RECT,size:"small"===a?jd.RESPONSIVE:a,tagline:s}}setupPayment(e,t,n){return Yd(this,void 0,void 0,function*(){if(!t)throw new fr(pr.CheckoutButtonNotInitialized);try{const n=yield this.paymentIntegrationService.loadDefaultCheckout(),{id:i}=n.getCartOrThrow(),r=n.getHost()||"";return(yield t.request.post(`${r}/api/storefront/payment/paypalexpress`,{merchantId:e,cartId:i},{headers:Object.assign({"X-API-INTERNAL":Lr},Fr)})).id}catch(e){throw n&&e instanceof ve&&n(e),e}})}tokenizePayment(e,t,n,i){return Yd(this,void 0,void 0,function*(){if(!n)throw new fr(pr.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new gr(hr.MissingPayment);const r=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),o=yield n.payment.get(e.paymentID);return this.formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:r.id,action:i?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(o.payer.payer_info)})})}}class $d{constructor(e){this.scriptLoader=e,this.window=window}loadPaypalSDK(){return e=this,t=arguments,i=function*(e=""){const t=Object.assign({async:!0,attributes:{"data-merchant-id":e}},e&&{attributes:{"data-merchant-id":e}});if(yield this.scriptLoader.loadScript("//www.paypalobjects.com/api/checkout.min.js",t),!this.window.paypal)throw new Pr;return this.window.paypal},new((n=void 0)||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())});var e,t,n,i}}const Zd=Ar(e=>new Kd(e,new $d(le()),n()),[{id:"paypalexpress"}]);var Jd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Qd{constructor(e,t){this.paymentIntegrationService=e,this.scriptLoader=t,this.isMounted=!1}deinitialize(){var e;null===(e=this.checkoutEventsUnsubscribe)||void 0===e||e.call(this),this.isMounted=!1}initCheckoutEventsSubscription(e,t,n,i){this.checkoutEventsUnsubscribe=this.paymentIntegrationService.subscribe(()=>Jd(this,void 0,void 0,function*(){var r;const o=null==i?void 0:i.getElement(Fs.PAYMENT);if(o){try{yield this.updateStripePaymentIntent(e,t)}catch(e){return this.isMounted&&(o.unmount(),this.isMounted=!1),void(e instanceof Error&&(null===(r=n.onError)||void 0===r||r.call(n,e)))}this.isMounted||(yield null==i?void 0:i.fetchUpdates(),this.mountElement(o,n.containerId))}}),e=>{var t;return null===(t=e.getCheckout())||void 0===t?void 0:t.outstandingBalance},e=>{var t;return null===(t=e.getCheckout())||void 0===t?void 0:t.coupons})}mountElement(e,t){document.getElementById(t)&&(e.mount(`#${t}`),this.isMounted=!0)}mapAppearanceVariables(e){return{colorPrimary:e.fieldInnerShadow,colorBackground:e.fieldBackground,colorText:e.labelText,colorDanger:e.fieldErrorText,colorTextSecondary:e.labelText,colorTextPlaceholder:e.fieldPlaceholderText,colorIcon:e.fieldPlaceholderText}}mapInputAppearanceRules(e){return{borderColor:e.fieldBorder,color:e.fieldText,boxShadow:e.fieldInnerShadow}}throwStripeError(e){if("object"==typeof(t=e)&&null!==t&&"type"in t&&(this.throwDisplayableStripeError(e),this.isCancellationError(e)))throw new lo;var t;throw new Za}throwDisplayableStripeError(e){if(m(["card_error","invalid_request_error","validation_error"],e.type))throw new Error(e.message)}isCancellationError(e){var t;const n=null===(t=null==e?void 0:e.payment_intent.last_payment_error)||void 0===t?void 0:t.message;return!!n&&-1!==n.indexOf("canceled")}throwPaymentConfirmationProceedMessage(){throw new Za("We've received your order and are processing your payment. Once the payment is verified, your order will be completed. We will send you an email when it's completed. Please note, this process may take a few minutes depending on the processing times of your chosen method.")}isPaymentCompleted(e,t){return Jd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState(),i=n.getPaymentMethodOrThrow(e),{features:r}=n.getStoreConfigOrThrow().checkoutSettings;if(!i.clientToken||!t||!r["PI-626.Block_unnecessary_payment_confirmation_for_StripeUPE"])return!1;const{paymentIntent:o}=yield t.retrievePaymentIntent(i.clientToken);return(null==o?void 0:o.status)===Bs.SUCCEEDED})}mapStripePaymentData(e,t,n=!1){const i=this.paymentIntegrationService.getState().getBillingAddress(),{firstName:r="",lastName:o="",email:a=""}=i||{},s=this.mapStripeAddress(i);if(!e)throw new fr(pr.PaymentNotInitialized);if(!(a&&s&&s.city&&s.country&&r&&o))throw new gr(hr.MissingBillingAddress);return{elements:e,redirect:zs.IF_REQUIRED,confirmParams:Object.assign({payment_method_data:Object.assign(Object.assign({},n?{allow_redisplay:"always"}:{}),{billing_details:{email:a,address:s,name:this.getShopperFullName(i)}})},t&&{return_url:t})}}isAdditionalActionError(e){return z(e,{code:"additional_action_required"})}isSessionExpiredError(e){return z(e,{code:"authorization_expired"})}isRedirectAction(e){const{type:t,data:{redirect_url:n}}=e;return"redirect_to_url"===t&&!!n}isOnPageAdditionalAction(e){const{type:t,data:{token:n}}=e;return"additional_action_requires_payment_method"===t&&!!n}updateStripePaymentIntent(e,t){return Jd(this,void 0,void 0,function*(){const n=yield this.paymentIntegrationService.loadPaymentMethod(e,{params:{method:t}}),{clientToken:i}=n.getPaymentMethodOrThrow(t);i&&this.scriptLoader.updateStripeElements({clientSecret:i})})}getStripeJsVersion(e){return e.useNewStripeJsVersion?Us.CLOVER:Us.V3}mapStripeAddress(e){if(e){const{city:t,address1:n,address2:i,countryCode:r,postalCode:o,stateOrProvinceCode:a}=e;return Object.assign({city:t,country:r,postal_code:o,line1:n,line2:i},a?{state:a}:{})}throw new gr(hr.MissingBillingAddress)}getShopperFullName(e){const{firstName:t="",lastName:n=""}=e||{};return`${t} ${n}`.trim()}verifyCheckoutSpamProtection(){return Jd(this,void 0,void 0,function*(){const{shouldExecuteSpamCheck:e}=this.paymentIntegrationService.getState().getCheckoutOrThrow();e&&(yield this.paymentIntegrationService.verifyCheckoutSpamProtection())})}}const Xd={size:70,color:"#d9d9d9",backgroundColor:"#ffffff"},ec={position:"fixed","background-color":"rgba(0, 0, 0, 0.4)","z-index":"1000"},tc="embedded-checkout-loading-indicator-rotation";class nc{constructor(e){this.styles=Object.assign(Object.assign({},Xd),e&&e.styles),this.containerStyles=Object.assign({},e&&e.containerStyles),this.defineAnimation(),this.container=this.buildContainer(),this.indicator=this.buildIndicator(),this.container.appendChild(this.indicator)}show(e){if(e){const t=document.getElementById(e);if(!t)throw new Error("Unable to attach the loading indicator because the parent ID is not valid.");t.appendChild(this.container)}this.container.style.visibility="visible",this.container.style.opacity="1"}hide(){const e=()=>{this.container.style.visibility="hidden",this.container.removeEventListener("transitionend",e)};this.container.addEventListener("transitionend",e),this.container.style.opacity="0"}buildContainer(){const e=document.createElement("div");return e.style.display="block",e.style.bottom="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.position="absolute",e.style.right="0",e.style.top="0",e.style.transition="all 250ms ease-out",e.style.opacity="0",this.setStyleAttribute(e,this.containerStyles),e}buildIndicator(){const e=document.createElement("div");return e.style.display="block",e.style.width=`${this.styles.size}px`,e.style.height=`${this.styles.size}px`,e.style.borderRadius=`${this.styles.size}px`,e.style.border="solid 1px",e.style.borderColor=`${this.styles.backgroundColor} ${this.styles.backgroundColor} ${this.styles.color} ${this.styles.color}`,e.style.margin="0 auto",e.style.position="absolute",e.style.left="0",e.style.right="0",e.style.top="50%",e.style.transform="translateY(-50%) rotate(0deg)",e.style.transformStyle="preserve-3d",e.style.animation=`${tc} 500ms infinite cubic-bezier(0.69, 0.31, 0.56, 0.83)`,e}setStyleAttribute(e,t){Object.keys(t).forEach(n=>{e.style.setProperty(n,t[n])})}defineAnimation(){var e;if(document.getElementById(tc))return;const t=document.createElement("style");t.id=tc,null===(e=document.head)||void 0===e||e.appendChild(t),t.sheet instanceof CSSStyleSheet&&t.sheet.insertRule(`\n @keyframes ${tc} {\n 0% { transform: translateY(-50%) rotate(0deg); }\n 100% { transform: translateY(-50%) rotate(360deg); }\n }\n `,0)}}class ic{constructor(e){this._decimalPlaces=e}toInteger(e){return Math.round(e*Math.pow(10,this._decimalPlaces))}}const rc=["AC","AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CV","CW","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MK","ML","MM","MN","MO","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SZ","TA","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","US","UY","UZ","VA","VC","VE","VG","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW","ZZ"];var oc=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ac{constructor(e,t,n,i){this.paymentIntegrationService=e,this.scriptLoader=t,this.stripeIntegrationService=n,this.loadingIndicator=i}initialize(e){return oc(this,void 0,void 0,function*(){const{stripeocs:t,containerId:n}=e||{};if(!t||!n)throw new fr(pr.PaymentNotInitialized);const{gatewayId:i}=t;if(!i)throw new gr(hr.MissingPaymentMethod);const r=this._getMethodId(i),o=yield this.paymentIntegrationService.loadPaymentMethod(i,{params:{method:r}}),a=o.getPaymentMethodOrThrow(r,i),{loadingContainerId:s,buttonHeight:d,onComplete:c}=t;if(this._loadingIndicatorContainer=s,this._onComplete=c,!function(e){return"object"==typeof e&&null!==e&&"initializationData"in e&&void 0!==e.initializationData&&null!==e.initializationData&&"object"==typeof e.initializationData&&"stripePublishableKey"in e.initializationData&&"stripeConnectedAccount"in e.initializationData&&"shopperLanguage"in e.initializationData&&void 0!==e.initializationData.stripePublishableKey&&void 0!==e.initializationData.stripeConnectedAccount&&void 0!==e.initializationData.shopperLanguage}(a))throw new gr(hr.MissingPaymentMethod);const{initializationData:u}=a,{captureMethod:l}=u,h=this.stripeIntegrationService.getStripeJsVersion(u);this._captureMethod=l,this._stripeClient=yield this.scriptLoader.getStripeClient(u,o.getCartLocale(),h),yield this.paymentIntegrationService.loadDefaultCheckout(),yield this._mountExpressCheckoutElement(n,this._stripeClient,d),this._initializeEvents(r)})}signIn(){return Promise.resolve()}signOut(){return Promise.resolve()}executePaymentMethodCheckout(){return Promise.resolve()}deinitialize(){return Promise.resolve()}_mountExpressCheckoutElement(e,t){return oc(this,arguments,void 0,function*(e,t,n=40){const i=this._shouldRequireShippingAddress(),r=Object.assign(Object.assign(Object.assign({shippingAddressRequired:i},i?{allowedShippingCountries:yield this._getAvailableCountries()}:{}),i?{shippingRates:[{id:"_",amount:0,displayName:"Pending rates"}]}:{}),{billingAddressRequired:!0,emailRequired:!0,phoneNumberRequired:!0,paymentMethods:{link:zs.AUTO,applePay:zs.NEVER,googlePay:zs.NEVER,amazonPay:zs.NEVER,paypal:zs.NEVER,klarna:zs.NEVER},buttonHeight:n}),{cartAmount:o=1}=this.paymentIntegrationService.getState().getCart()||{},a=Object.assign({mode:"payment",amount:this._toCents(o),currency:this._getCurrency()},this._captureMethod?{captureMethod:this._captureMethod}:{});this._stripeElements=t.elements(a),this._linkV2Element=this._stripeElements.create(Fs.EXPRESS_CHECKOUT,r),this._linkV2Element.mount(`#${e}`)})}_initializeEvents(e){this._linkV2Element&&(this._shouldRequireShippingAddress()&&(this._linkV2Element.on(xs.SHIPPING_ADDRESS_CHANGE,e=>oc(this,void 0,void 0,function*(){return this._onShippingAddressChange(e)})),this._linkV2Element.on(xs.SHIPPING_RATE_CHANGE,e=>oc(this,void 0,void 0,function*(){return this._onShippingRateChange(e)}))),this._linkV2Element.on(xs.CONFIRM,t=>oc(this,void 0,void 0,function*(){return this._onConfirm(t,e)})),this._linkV2Element.on(xs.CANCEL,this._onCancel))}_onShippingAddressChange(e){return oc(this,void 0,void 0,function*(){if(!("address"in e))return;const t=e.address,n={firstName:"",lastName:"",phone:"",company:"",address1:"",address2:"",city:(null==t?void 0:t.city)||"",countryCode:(null==t?void 0:t.country)||"",postalCode:(null==t?void 0:t.postal_code)||"",stateOrProvince:(null==t?void 0:t.state)||"",stateOrProvinceCode:(null==t?void 0:t.state)||"",customFields:[]};yield this.paymentIntegrationService.updateShippingAddress(n);const i=yield this._getAvailableShippingOptions();yield this._updateDisplayedPrice(),(null==i?void 0:i.length)?e.resolve({shippingRates:i}):e.reject()})}_onCancel(){throw new lo}_onShippingRateChange(e){return oc(this,void 0,void 0,function*(){if("shippingRate"in e){const{shippingRate:t}=e;yield this._handleShippingOptionChange(null==t?void 0:t.id),yield this._updateDisplayedPrice(),e.resolve({})}})}_onConfirm(e,t){return oc(this,void 0,void 0,function*(){if("billingDetails"in e&&"shippingAddress"in e&&this._stripeClient&&this._stripeElements){yield this.stripeIntegrationService.verifyCheckoutSpamProtection(),yield this._updateShippingAndBillingAddress(e),yield this.paymentIntegrationService.submitOrder();const n=this._getPaymentPayload(t);try{yield this.paymentIntegrationService.submitPayment(n)}catch(e){yield this._processAdditionalAction(e,t)}}return Promise.resolve()})}_updateShippingAndBillingAddress(e){return oc(this,void 0,void 0,function*(){var t,n,i,r,o,a,s,d;const c=this._shouldRequireShippingAddress(),u=(null===(n=null===(t=e.shippingAddress)||void 0===t?void 0:t.name)||void 0===n?void 0:n.split(" ")[0])||(null===(r=null===(i=e.billingDetails)||void 0===i?void 0:i.name)||void 0===r?void 0:r.split(" ")[0])||"",l=(null===(a=null===(o=e.shippingAddress)||void 0===o?void 0:o.name)||void 0===a?void 0:a.split(" ")[1])||(null===(d=null===(s=e.billingDetails)||void 0===s?void 0:s.name)||void 0===d?void 0:d.split(" ")[1])||"";if(c){const t=this._mapShippingAddress(e.shippingAddress,e.billingDetails,u,l);yield this.paymentIntegrationService.updateShippingAddress(t)}const h=this._mapBillingAddress(e.shippingAddress,e.billingDetails,u,l);yield this.paymentIntegrationService.updateBillingAddress(h)})}_mapShippingAddress(e,t,n,i){var r,o,a,s,d,c,u;return{firstName:n,lastName:i,phone:(null==t?void 0:t.phone)||"",company:"",address1:(null===(r=null==e?void 0:e.address)||void 0===r?void 0:r.line1)||"",address2:(null===(o=null==e?void 0:e.address)||void 0===o?void 0:o.line2)||"",city:(null===(a=null==e?void 0:e.address)||void 0===a?void 0:a.city)||"",countryCode:(null===(s=null==e?void 0:e.address)||void 0===s?void 0:s.country)||"",postalCode:(null===(d=null==e?void 0:e.address)||void 0===d?void 0:d.postal_code)||"",stateOrProvince:(null===(c=null==e?void 0:e.address)||void 0===c?void 0:c.state)||"",stateOrProvinceCode:(null===(u=null==e?void 0:e.address)||void 0===u?void 0:u.state)||"",customFields:[]}}_mapBillingAddress(e,t,n,i){var r,o,a,s,d,c;return{email:(null==t?void 0:t.email)||"",firstName:n,lastName:i,phone:(null==t?void 0:t.phone)||"",company:"",address1:(null===(r=null==t?void 0:t.address)||void 0===r?void 0:r.line1)||"",address2:"",city:(null===(o=null==t?void 0:t.address)||void 0===o?void 0:o.city)||"",countryCode:(null===(a=null==t?void 0:t.address)||void 0===a?void 0:a.country)||"",postalCode:(null===(s=null==t?void 0:t.address)||void 0===s?void 0:s.postal_code)||"",stateOrProvince:(null===(d=null==t?void 0:t.address)||void 0===d?void 0:d.state)||"",stateOrProvinceCode:(null===(c=null==e?void 0:e.address)||void 0===c?void 0:c.state)||"",customFields:[]}}_processAdditionalAction(e,t){return oc(this,void 0,void 0,function*(){if(!Cs(e)||!this.stripeIntegrationService.isAdditionalActionError(e.body.errors))throw e;if(!this._stripeClient||!this._stripeElements)throw new fr(pr.PaymentNotInitialized);const{data:n}=e.body.additional_action_required,{token:i}=n,{paymentIntent:r}=yield this._confirmStripePaymentOrThrow(n,t),o=this._getPaymentPayload(t,(null==r?void 0:r.id)||i);try{this._toggleLoadingIndicator(!0),yield this.paymentIntegrationService.submitPayment(o),yield this._completeCheckoutFlow()}catch(e){this.stripeIntegrationService.throwPaymentConfirmationProceedMessage()}finally{this._toggleLoadingIndicator(!1)}})}_confirmStripePaymentOrThrow(e,t){return oc(this,void 0,void 0,function*(){var n,i,r;const{token:o,redirect_url:a}=e,s=this.stripeIntegrationService.mapStripePaymentData(this._stripeElements,a);let d;try{const e=(yield this.stripeIntegrationService.isPaymentCompleted(t,this._stripeClient))?yield null===(r=this._stripeClient)||void 0===r?void 0:r.retrievePaymentIntent(o||""):yield null===(n=this._stripeClient)||void 0===n?void 0:n.confirmPayment({elements:s.elements,clientSecret:o,redirect:zs.IF_REQUIRED,confirmParams:{return_url:null===(i=s.confirmParams)||void 0===i?void 0:i.return_url}});if(d=null==e?void 0:e.error,d||!(null==e?void 0:e.paymentIntent))throw new Za;return e}catch(e){return this.stripeIntegrationService.throwStripeError(d)}})}_completeCheckoutFlow(){return oc(this,void 0,void 0,function*(){return"function"==typeof this._onComplete?this._onComplete():(window.location.replace("/checkout/order-confirmation"),Promise.resolve())})}_getPaymentPayload(e,t){var n;const i=(null===(n=this.paymentIntegrationService.getState().getCart())||void 0===n?void 0:n.id)||"";return{methodId:e,paymentData:{formattedPayload:Object.assign(Object.assign({cart_id:i},t?{credit_card_token:{token:t}}:{}),{confirm:!1,method:Ls.Link})}}}_shouldRequireShippingAddress(){const{getCart:e}=this.paymentIntegrationService.getState(),{lineItems:t}=e()||{};return!!(null==t?void 0:t.physicalItems.length)}_updateDisplayedPrice(){return oc(this,void 0,void 0,function*(){this._stripeElements&&this._stripeElements.update({currency:this._getCurrency(),mode:"payment",amount:yield this._getTotalPrice()})})}_getCurrency(){var e;if(!this._currencyCode){const t=null===(e=this.paymentIntegrationService.getState().getCart())||void 0===e?void 0:e.currency;t&&(this._currencyCode=t.code.toLowerCase())}return this._currencyCode}_getTotalPrice(){return oc(this,void 0,void 0,function*(){var e;yield this.paymentIntegrationService.loadCheckout();const{getCheckoutOrThrow:t,getCart:n}=this.paymentIntegrationService.getState(),{decimalPlaces:i}=(null===(e=n())||void 0===e?void 0:e.currency)||{},r=L(t().outstandingBalance,i).toFixed(i);return this._toCents(+r)})}_getAvailableCountries(){return oc(this,void 0,void 0,function*(){var e;return((null===(e=(yield this.paymentIntegrationService.loadShippingCountries()).getShippingCountries())||void 0===e?void 0:e.map(e=>e.code))||[]).filter(e=>rc.includes(e))})}_getAvailableShippingOptions(){return oc(this,void 0,void 0,function*(){var e,t,n;const i=this.paymentIntegrationService.getState().getConsignments();if(!(null==i?void 0:i[0]))return;const r=i[0],o=(r.availableShippingOptions||[]).map(this._getStripeShippingOption.bind(this)),a=null===(e=r.availableShippingOptions)||void 0===e?void 0:e.find(e=>e.isRecommended),s=null===(t=r.selectedShippingOption)||void 0===t?void 0:t.id,d=null==a?void 0:a.id;return s?o.sort(e=>e.id===s?-1:0):d?(o.sort(e=>e.id===d?-1:0),yield this._handleShippingOptionChange(d)):yield this._handleShippingOptionChange(null===(n=o[0])||void 0===n?void 0:n.id),o.slice(0,9)})}_getStripeShippingOption({id:e,cost:t,description:n}){return{id:e,displayName:n,amount:this._toCents(t)}}_handleShippingOptionChange(e){return oc(this,void 0,void 0,function*(){if(e&&"shipping_option_unselected"!==e)return this.paymentIntegrationService.selectShippingOption(e)})}_getAmountTransformer(){if(this._amountTransformer)return this._amountTransformer;const{getCart:e}=this.paymentIntegrationService.getState(),{currency:t}=e()||{};return t?new ic(t.decimalPlaces):void 0}_toCents(e){const t=Math.round(100*e),n=this._getAmountTransformer();return n?n.toInteger(e):t}_toggleLoadingIndicator(e){e&&this._loadingIndicatorContainer?this.loadingIndicator.show(this._loadingIndicatorContainer):this.loadingIndicator.hide()}_getMethodId(e){const{initializationData:{checkoutSessionEnabled:t}={}}=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e);return t?Ls.CHECKOUT_SESSION:Ls.OCS}}const sc=Ar(e=>{const t=new Gs(le()),n=new nc({containerStyles:ec});return new ac(e,t,new Qd(e,t),n)},[{id:"stripeocs"}]);var dc;function cc(e,t,n){const i=new WeakMap;function r(e){return(...n)=>{const r=n[n.length-1],{useCache:o}=(a=r)&&"boolean"==typeof a.useCache?r:{useCache:!1};var a;if(!o)return e.call(this,...n);const s=i.get(this)||{};var d;return i.get(this)||i.set(this,s),s[t]||(s[t]=(d=e,ae(function(...e){const t=d.call(this,...e);return t instanceof j?Y(t).pipe(ie()):"function"==typeof t?ae(e=>Y(t(e)).pipe(ie()),{isEqual:_}):t},{isEqual:_}))),s[t].call(this,...n)}}return{get(){if("function"!=typeof n.value)throw new Error("Decorator should be used in functions");const e=r.call(this,n.value);return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e}}}!function(e){e.Standard="standard",e.Invoice="invoice"}(dc||(dc={}));var uc=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};const lc=e=>!!e;class hc{constructor(e,t){this._requestSender=e,this._b2bCompanyPaymentMethodRequestSender=t}loadPaymentMethodsById(e,t){return n=>new j(i=>{var r;const a=null===(r=n.getState().cart.getCart())||void 0===r?void 0:r.id,s=a?Object.assign(Object.assign({},null==t?void 0:t.params),{cartId:a}):Object.assign({},null==t?void 0:t.params);i.next(o(Rn.LoadPaymentMethodsRequested)),Promise.all(e.map(e=>uc(this,void 0,void 0,function*(){try{return(yield this._requestSender.loadPaymentMethod(e,Object.assign(Object.assign({},t),{params:s}))).body}catch(e){return}}))).then(e=>{const t=e.filter(lc);i.next(o(Rn.LoadPaymentMethodsSucceeded,t)),i.complete()}).catch(e=>{i.next(o(Rn.LoadPaymentMethodsFailed,e)),i.complete()})})}loadPaymentMethods(e){return t=>j.create(n=>{const i=t.getState(),r=i.cart.getCartOrThrow();n.next(o(Rn.LoadPaymentMethodsRequested)),this._requestSender.loadPaymentMethods(Object.assign(Object.assign({},e),{params:Object.assign(Object.assign({},null==e?void 0:e.params),{cartId:r.id})})).then(t=>uc(this,void 0,void 0,function*(){const r={deviceSessionId:t.headers["x-device-session-id"],sessionHash:t.headers["x-session-hash"]};let a=t.body;this._shouldFilterForB2b(i)&&(a=yield this._applyB2bFilter(a,i,e)),n.next(o(Rn.LoadPaymentMethodsSucceeded,a,r)),n.complete()})).catch(e=>{n.error(s(Rn.LoadPaymentMethodsFailed,e))})})}loadPaymentMethod(e,t){return n=>j.create(i=>{var r;const a=null===(r=n.getState().cart.getCart())||void 0===r?void 0:r.id,d=a?Object.assign(Object.assign({},null==t?void 0:t.params),{cartId:a}):Object.assign({},null==t?void 0:t.params);i.next(o(Rn.LoadPaymentMethodRequested,void 0,{methodId:e})),this._requestSender.loadPaymentMethod(e,Object.assign(Object.assign({},t),{params:d})).then(t=>{i.next(o(Rn.LoadPaymentMethodSucceeded,t.body,{methodId:e})),i.complete()}).catch(t=>{i.error(s(Rn.LoadPaymentMethodFailed,t,{methodId:e}))})})}_shouldFilterForB2b(e){var t,n;return!!(null===(n=null===(t=e.config.getStoreConfigOrThrow().checkoutSettings)||void 0===t?void 0:t.capabilities)||void 0===n?void 0:n.payment.b2bPaymentMethodFilterType)}_applyB2bFilter(e,t,n){return uc(this,void 0,void 0,function*(){var i,r,o,a,s;const d=t.config.getStoreConfigOrThrow(),c=t.customer.getCustomerOrThrow(),u=t.cart.getCartOrThrow(),l=t.b2bToken.getToken(),h=(p=null!==(o=null===(r=null===(i=t.config.getStoreConfig())||void 0===i?void 0:i.b2bApiSettings)||void 0===r?void 0:r.baseUrl)&&void 0!==o?o:"",function(){if("undefined"==typeof window||!window.location)return!1;try{return!!new URLSearchParams(window.location.search).has("enableB2bDevMode")&&(console.log("B2B Dev Mode Enabled"),!0)}catch(e){return!1}}()?"https://api-b2b.bigcommerce.com":p);var p;if(c.isGuest||!l||!h||!u.companyId)throw new nr(tr.MissingCheckoutConfig);return(null===(s=null===(a=d.checkoutSettings)||void 0===a?void 0:a.capabilities)||void 0===s?void 0:s.payment.b2bPaymentMethodFilterType)===dc.Invoice?this._applyB2bInvoiceFilter(e,h,l,n):this._applyB2bCompanyFilter(e,u.companyId,l,h,n)})}_applyB2bCompanyFilter(e,t,n,i,r){return uc(this,void 0,void 0,function*(){const{body:o}=yield this._b2bCompanyPaymentMethodRequestSender.getB2BCompanyPaymentMethods(t,n,i,r);return function(e,t){const n=new Set(t.data.filter(e=>"1"===e.isEnabled).map(e=>e.code));return e.filter(e=>n.has(e.id))}(e,o)})}_applyB2bInvoiceFilter(e,t,n,i){return uc(this,void 0,void 0,function*(){const{body:r}=yield this._b2bCompanyPaymentMethodRequestSender.getB2BInvoiceAllowedPaymentMethods(t,n,i);return e.filter(e=>new Set(r.data.allowedMethods).has(e.id))})}}var pc;(function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);o>3&&a&&Object.defineProperty(t,n,a)})([cc],hc.prototype,"loadPaymentMethod",null),function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(pc||(pc={}));const gc=pc,mc="This API endpoint is for internal use only and may change in the future",yc={"X-Checkout-SDK-Version":"1.934.1"};class fc{constructor(e){this._requestSender=e}loadPaymentMethods({timeout:e,params:t}={}){return this._requestSender.get("/api/storefront/payments",{timeout:e,headers:Object.assign({Accept:gc.JsonV1,"X-API-INTERNAL":mc},yc),params:t})}loadPaymentMethod(e,{timeout:t,params:n}={}){const i=`/api/storefront/payments/${e}`;return this._requestSender.get(i,{timeout:t,headers:Object.assign({Accept:gc.JsonV1,"X-API-INTERNAL":mc},yc),params:n})}}var _c=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Sc{constructor(e){this._requestSender=e}getB2BCompanyPaymentMethods(e,t,n,i){return _c(this,void 0,void 0,function*(){return this._requestSender.get(`${n}/api/v2/companies/${e}/payments`,{timeout:null==i?void 0:i.timeout,credentials:!1,headers:{authToken:t,Authorization:`Bearer ${t}`}})})}getB2BInvoiceAllowedPaymentMethods(e,t,n){return _c(this,void 0,void 0,function*(){return this._requestSender.get(`${e}/api/v1/ip/storefront/payments/bigcommerce/allowed-methods`,{timeout:null==n?void 0:n.timeout,credentials:!1,headers:{authToken:t,Authorization:`Bearer ${t}`}})})}}function vc(e,t,n){return(i=t)&&i.type&&i.error?V(Z(t),J(s(e,t.payload,n))):J(s(e,t,n));var i}class Cc extends Ee{constructor(e){super(e||"Unable to continue as a guest because the customer is already signed in."),this.name="UnableToContinueAsGuestError",this.type="unable_to_continue_as_guest"}}class Ic{constructor(e,t){this._requestSender=e,this._subscriptionActionCreator=t}continueAsGuest(e,t){return n=>{const i=n.getState(),r=i.checkout.getCheckout();if(!r)throw new nr(tr.MissingCheckout);const a=i.customer.getCustomer();if(a&&!a.isGuest)throw new Cc;const s=i.billingAddress.getBillingAddress();let d;if(s){const{country:t}=s,n=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(s,["country"]);d=Object.assign(Object.assign({},n),e)}else d=e;const c=!f(s);return $(V(Z(o(Ye.ContinueAsGuestRequested)),H(()=>{return e=this,n=void 0,a=function*(){const{body:e}=yield this._createOrUpdateBillingAddress(r.id,d,c,t);return o(Ye.ContinueAsGuestSucceeded,e)},new((i=void 0)||(i=Promise))(function(t,r){function o(e){try{d(a.next(e))}catch(e){r(e)}}function s(e){try{d(a.throw(e))}catch(e){r(e)}}function d(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i(function(e){e(n)})).then(o,s)}d((a=a.apply(e,n||[])).next())});var e,n,i,a})).pipe(Q(e=>vc(Ye.ContinueAsGuestFailed,e))),this._updateCustomerConsent(e,t))}}updateAddress(e,t){return n=>j.create(i=>{const r=n.getState(),a=r.checkout.getCheckout();if(!a)throw new nr(tr.MissingCheckout);i.next(o(Ye.UpdateBillingAddressRequested));const d=r.billingAddress.getBillingAddress(),c=!f(d),u=Object.assign(Object.assign({},e),{email:void 0===e.email&&d?d.email:e.email});d&&d.id&&(u.id=d.id),this._createOrUpdateBillingAddress(a.id,u,c,t).then(({body:e})=>{i.next(o(Ye.UpdateBillingAddressSucceeded,e)),i.complete()}).catch(e=>{i.error(s(Ye.UpdateBillingAddressFailed,e))})})}_updateCustomerConsent({email:e,acceptsAbandonedCartEmails:t,acceptsMarketingNewsletter:n},i){return null==t&&null==n?W():this._subscriptionActionCreator.updateSubscriptions({email:e,acceptsMarketingNewsletter:n||!1,acceptsAbandonedCartEmails:t||!1},i)}_createOrUpdateBillingAddress(e,t,n,i){return n?this._requestSender.updateAddress(e,t,i):this._requestSender.createAddress(e,t,i)}}class wc extends Ee{constructor(e){super(e||"Your checkout could not be processed because your cart is empty. Please add items to your cart and try again."),this.name="EmptyCartError",this.type="empty_cart"}}const Ec={include:["cart.lineItems.physicalItems.options","cart.lineItems.physicalItems.stockPosition","cart.lineItems.digitalItems.options","cart.lineItems.digitalItems.stockPosition","customer","promotions.banners"].join(",")};class bc{constructor(e){this._requestSender=e}createAddress(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/billing-address`,r=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.post(i,{body:t,params:Ec,headers:r,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}updateAddress(e,t,{timeout:n}={}){const{id:i}=t,r=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["id"]),o=`/api/storefront/checkouts/${e}/billing-address/${i}`,a=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.put(o,{params:Ec,body:r,headers:a,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}}class Pc{constructor(e){this._requestSender=e}createBuyNowCart(e,{timeout:t}={}){const n=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.post("/api/storefront/carts",{body:e,headers:n,timeout:t})}}class Oc{constructor(e,t,n){this._checkoutRequestSender=e,this._configActionCreator=t,this._formFieldsActionCreator=n}loadCheckout(e,t){return()=>V(Z(o(Ve.LoadCheckoutRequested)),$(this._configActionCreator.loadConfig({useCache:!0,timeout:null==t?void 0:t.timeout,params:{checkoutId:e}}),this._formFieldsActionCreator.loadFormFields({useCache:!0,timeout:null==t?void 0:t.timeout})),H(()=>this._checkoutRequestSender.loadCheckout(e,t).then(({body:e})=>o(Ve.LoadCheckoutSucceeded,this._transformCustomerAddresses(e))))).pipe(Q(e=>vc(Ve.LoadCheckoutFailed,e)))}loadDefaultCheckout(e){return t=>V(Z(o(Ve.LoadCheckoutRequested)),$(this._configActionCreator.loadConfig({useCache:!0,timeout:null==e?void 0:e.timeout}),this._formFieldsActionCreator.loadFormFields({useCache:!0,timeout:null==e?void 0:e.timeout})),H(()=>{return n=this,i=void 0,a=function*(){const n=t.getState().config.getContextConfig();if(!n||!n.checkoutId)throw new nr(tr.MissingCheckoutConfig);const{body:i}=yield this._checkoutRequestSender.loadCheckout(n.checkoutId,e);return o(Ve.LoadCheckoutSucceeded,this._transformCustomerAddresses(i))},new((r=void 0)||(r=Promise))(function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function s(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(o,s)}d((a=a.apply(n,i||[])).next())});var n,i,r,a})).pipe(Q(e=>vc(Ve.LoadCheckoutFailed,e)))}updateCheckout(e,t){return n=>new j(i=>{const r=n.getState().checkout.getCheckout();if(!r)throw new nr(tr.MissingCheckout);i.next(o(Ve.UpdateCheckoutRequested)),this._checkoutRequestSender.updateCheckout(r.id,e,t).then(({body:e})=>{i.next(o(Ve.UpdateCheckoutSucceeded,e)),i.complete()}).catch(e=>{i.error(s(Ve.UpdateCheckoutFailed,e))})})}deleteCheckout(e){return t=>new j(n=>{const i=t.getState().checkout.getCheckout();if(!i)throw new nr(tr.MissingCheckout);n.next(o(Ve.DeleteCheckoutRequested)),this._checkoutRequestSender.deleteCheckout(i.id,e).then(()=>{n.next(o(Ve.DeleteCheckoutSucceeded)),n.complete()}).catch(e=>{n.error(s(Ve.DeleteCheckoutFailed,e))})})}loadCurrentCheckout(e){return t=>{const n=t.getState().checkout.getCheckout();if(!n)throw new nr(tr.MissingCheckout);return this.loadCheckout(n.id,e)(t)}}hydrateInitialState(e){return{type:He.HydrateInitialState,payload:e}}_transformCustomerAddresses(e){return Object.assign(Object.assign({},e),{customer:Object.assign(Object.assign({},e.customer),{addresses:e.customer.addresses.map(e=>Object.assign(Object.assign({},e),{shouldSaveAddress:!1}))})})}}function Ac(e){return F(e).join(",")}function Tc(e,t=[]){return Array.isArray(t)?Ac([...e,...t]):function(e,t){const n=E(M(t,e=>!e)),i=E(u(t));return Ac([...c(e,n),...i])}(e,t)}const kc=["cart.lineItems.physicalItems.options","cart.lineItems.physicalItems.stockPosition","cart.lineItems.digitalItems.options","cart.lineItems.digitalItems.stockPosition","customer","customer.customerGroup","payments","promotions.banners"];class Rc extends Pe{constructor(e){super(e,{message:e.body.title}),this.name="CheckoutNotAvailableError",this.type="checkout_not_available"}}class Dc{constructor(e){this._requestSender=e}loadCheckout(e,{params:{include:t}={},timeout:n}={}){const i=`/api/storefront/checkout/${e}`,r=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.get(i,{params:{include:Tc(kc,t)},headers:r,timeout:n}).catch(e=>{if(e.status>=400&&e.status<500)throw new Rc(e);throw e})}updateCheckout(e,t,{params:{include:n}={},timeout:i}={}){const r=`/api/storefront/checkout/${e}`,o=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.put(r,{params:{include:Tc(kc,n)},body:t,headers:o,timeout:i}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}deleteCheckout(e,{timeout:t}={}){const n=`/api/storefront/carts/${e}`,i=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.delete(n,{headers:i,timeout:t})}}class Mc{isEqual(e,t){return _(this._normalize(e),this._normalize(t))}_normalize(e){return{cartAmount:e.cartAmount,currency:e.currency,id:e.id,lineItems:{digitalItems:e.lineItems.digitalItems.slice().sort((e,t)=>`${e.productId}${e.variantId}`.localeCompare(`${t.productId}${t.variantId}`)).map(e=>({extendedSalePrice:e.extendedSalePrice,productId:e.productId,quantity:e.quantity,variantId:e.variantId})),giftCertificates:e.lineItems.giftCertificates.slice().sort((e,t)=>`${e.id}`.localeCompare(`${t.id}`)).map(e=>({amount:e.amount,recipient:e.recipient})),physicalItems:e.lineItems.physicalItems.slice().sort((e,t)=>`${e.productId}${e.variantId}`.localeCompare(`${t.productId}${t.variantId}`)).map(e=>({extendedSalePrice:e.extendedSalePrice,productId:e.productId,quantity:e.quantity,variantId:e.variantId,giftWrapping:e.giftWrapping}))}}}}class Nc extends Ee{constructor(e,t){super("An update to your shopping cart has been detected and your available shipping costs have been updated."),this.name="CartChangedError",this.type="cart_changed",this.data={previous:e,updated:t}}}class Lc{constructor(e){this._checkoutRequestSender=e}validate(e,t){if(!e)throw new nr(tr.MissingCheckout);return this._checkoutRequestSender.loadCheckout(e.id,t).then(t=>{const n=new Mc;if(!(e.outstandingBalance===t.body.outstandingBalance&&this._compareCoupons(e.coupons,t.body.coupons)&&this._compareGiftCertificates(e.giftCertificates,t.body.giftCertificates)&&n.isEqual(e.cart,t.body.cart)))throw new Nc(this._getComparableCheckout(e),this._getComparableCheckout(t.body))})}_compareCoupons(e,t){return _(P(e,"code"),P(t,"code"))}_compareGiftCertificates(e,t){return _(P(e,"code"),P(t,"code"))}_getComparableCheckout(e){const{cart:t,coupons:n,giftCertificates:i,outstandingBalance:r}=e;return{cart:{cartAmount:t.cartAmount,currency:t.currency,lineItems:t.lineItems},coupons:n,giftCertificates:i,outstandingBalance:r}}}var zc;class Uc{constructor(e){this._configRequestSender=e}loadConfig(e){return j.create(t=>{t.next(o(vt.LoadConfigRequested)),this._configRequestSender.loadConfig(e).then(e=>{t.next(o(vt.LoadConfigSucceeded,e.body)),t.complete()}).catch(e=>{t.error(s(vt.LoadConfigFailed,e))})})}}!function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);o>3&&a&&Object.defineProperty(t,n,a)}([cc],Uc.prototype,"loadConfig",null);class Fc{constructor(e){this._requestSender=e}loadConfig({timeout:e,params:t}={}){return this._requestSender.get("/api/storefront/checkout-settings",{timeout:e,headers:Object.assign({Accept:gc.JsonV1,"X-API-INTERNAL":mc},yc),params:t}).catch(e=>{if(e.status>=400&&e.status<500)throw new Rc(e);throw e})}}class Bc{constructor(e){this._couponRequestSender=e}applyCoupon(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout();if(!r)throw new nr(tr.MissingCheckout);i.next(o(it.ApplyCouponRequested)),this._couponRequestSender.applyCoupon(r.id,e,t).then(({body:e})=>{i.next(o(it.ApplyCouponSucceeded,e)),i.complete()}).catch(e=>{i.error(s(it.ApplyCouponFailed,e))})})}removeCoupon(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout();if(!r)throw new nr(tr.MissingCheckout);i.next(o(it.RemoveCouponRequested)),this._couponRequestSender.removeCoupon(r.id,e,t).then(({body:e})=>{i.next(o(it.RemoveCouponSucceeded,e)),i.complete()}).catch(e=>{i.error(s(it.RemoveCouponFailed,e))})})}}!function(e){e.AvailableShippingOptions="consignments.availableShippingOptions",e.PhysicalItemsCategoryNames="cart.lineItems.physicalItems.categoryNames",e.DigitalItemsCategoryNames="cart.lineItems.digitalItems.categoryNames"}(zc||(zc={}));class xc{constructor(e){this._requestSender=e}applyCoupon(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/coupons`,r=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.post(i,{headers:r,timeout:n,params:{include:Ac([...kc,zc.AvailableShippingOptions])},body:{couponCode:t}}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}removeCoupon(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/coupons/${t}`,r=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.delete(i,{headers:r,timeout:n,params:{include:Ac([...kc,zc.AvailableShippingOptions])}}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}}function qc(e){const t=e;return"object"==typeof t&&"object"==typeof t.payload&&"string"==typeof t.payload.token}class jc{constructor(e,t,n){this._customerRequestSender=e,this._checkoutActionCreator=t,this._spamProtectionActionCreator=n}createCustomer(e,t){return n=>{const i=n.getState().config.getStoreConfigOrThrow(),{isStorefrontSpamProtectionEnabled:r}=i.checkoutSettings,a=i=>Y(this._customerRequestSender.createAccount(Object.assign(Object.assign({},e),{token:i}),t)).pipe(re(()=>V(this._checkoutActionCreator.loadCurrentCheckout(t)(n),Z(o(Ut.CreateCustomerSucceeded)))));return V(Z(o(Ut.CreateCustomerRequested)),r?Y(this._spamProtectionActionCreator.execute()(n)).pipe(re(e=>{var t;return qc(e)?V(Z(e),a(null===(t=e.payload)||void 0===t?void 0:t.token)):Z(e)})):a()).pipe(Q(e=>vc(Ut.CreateCustomerFailed,e)))}}createAddress(e,t){return V(Z(o(Ut.CreateCustomerAddressRequested)),H(()=>{return n=this,i=void 0,a=function*(){const{body:n}=yield this._customerRequestSender.createAddress(e,t);return o(Ut.CreateCustomerAddressSucceeded,n)},new((r=void 0)||(r=Promise))(function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function s(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(o,s)}d((a=a.apply(n,i||[])).next())});var n,i,r,a})).pipe(Q(e=>vc(Ut.CreateCustomerAddressFailed,e)))}signInCustomer(e,t){return n=>{const i=n.getState().checkout.getCheckoutOrThrow(),r=i.cart.source===vo.BuyNow?i.id:void 0;return V(Z(o(Ut.SignInCustomerRequested)),Y(this._customerRequestSender.signInCustomer(Object.assign(Object.assign({},e),{cartId:r}),t)).pipe(re(({body:e})=>e.data.persistentCartRetrievalInformation?V(this._checkoutActionCreator.loadCheckout(e.data.persistentCartRetrievalInformation.id,t)(n),Z(o(Ut.SignInCustomerSucceeded,e.data))):V(this._checkoutActionCreator.loadCurrentCheckout(t)(n),Z(o(Ut.SignInCustomerSucceeded,e.data)))))).pipe(Q(e=>vc(Ut.SignInCustomerFailed,e)))}}signOutCustomer(e){return t=>{const n=t.getState().checkout.getCheckoutOrThrow(),i=n.cart.source===vo.BuyNow?n.id:void 0;return V(Z(o(Ut.SignOutCustomerRequested)),Y(this._customerRequestSender.signOutCustomer(e,i)).pipe(re(({body:n})=>V(this._checkoutActionCreator.loadCurrentCheckout(e)(t),Z(o(Ut.SignOutCustomerSucceeded,n.data)))))).pipe(Q(e=>vc(Ut.SignOutCustomerFailed,e)))}}}class Gc{constructor(e){this._requestSender=e}createAccount(e,{timeout:t}={}){return this._requestSender.post("/api/storefront/customer",{timeout:t,headers:yc,body:e})}createAddress(e,{timeout:t}={}){return this._requestSender.post("/api/storefront/customer-address",{timeout:t,headers:yc,body:e})}signInCustomer(e,{timeout:t}={}){return this._requestSender.post("/internalapi/v1/checkout/customer",{timeout:t,headers:yc,body:e})}signOutCustomer({timeout:e}={},t){return this._requestSender.delete("/internalapi/v1/checkout/customer",Object.assign({timeout:e,headers:yc},t&&{body:{cartId:t}}))}}class Vc{constructor(e){this._formFieldsRequestSender=e}loadFormFields(e){return V(Z(o(tn.LoadFormFieldsRequested)),H(()=>{return t=this,n=void 0,r=function*(){const{body:t}=yield this._formFieldsRequestSender.loadFields(e);return o(tn.LoadFormFieldsSucceeded,t)},new((i=void 0)||(i=Promise))(function(e,o){function a(e){try{d(r.next(e))}catch(e){o(e)}}function s(e){try{d(r.throw(e))}catch(e){o(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,s)}d((r=r.apply(t,n||[])).next())});var t,n,i,r})).pipe(Q(e=>vc(tn.LoadFormFieldsFailed,e)))}}!function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);o>3&&a&&Object.defineProperty(t,n,a)}([cc],Vc.prototype,"loadFormFields",null);class Hc{constructor(e){this._requestSender=e}loadFields({timeout:e}={}){return this._requestSender.get("/api/storefront/form-fields",{timeout:e,headers:Object.assign({Accept:gc.JsonV1,"X-API-INTERNAL":mc},yc)})}}class Wc extends Ee{constructor(e){super(e||"Unable to proceed because the required element is unexpectedly detached from the page."),this.name="UnexpectedDetachmentError",this.type="unexpected_detachment"}}class Yc{constructor(e){this._mutationObserver=e}ensurePresence(e,t){return n=this,i=void 0,o=function*(){const n=new Aa(t),i=this._mutationObserver.create(t=>{t.forEach(t=>{0!==Array.from(t.removedNodes).filter(t=>e.some(e=>t===e||t.contains(e))).length&&n.cancel(new Wc)})});i.observe(document.body,{childList:!0,subtree:!0});try{const e=yield n.promise;return i.disconnect(),e}catch(e){throw i.disconnect(),e}},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}}class Kc{constructor(e=window){this._window=e}create(e){return new this._window.MutationObserver(e)}}class $c extends Ee{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}function Zc(e){if(!/^(https?:)?\/\//.test(e))throw new $c("The provided URL must be absolute.");const t=document.createElement("a");t.href=e;const 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 Jc(e,t){return e.type===t}class Qc{constructor(e,t,n){this._targetWindow=t,this._context=n,this._targetOrigin="*"===e?"*":Zc(e).origin}post(e,t){const n=this._targetWindow;if(window===n)return;if(!n)throw new Error("Unable to post message because target window is not set.");const i=t&&K(window,"message").pipe(ee(e=>e.origin===this._targetOrigin&&Jc(e.data,e.data.type)&&-1!==[t.successType,t.errorType].indexOf(e.data.type)),te(e=>{if(t.errorType===e.data.type)throw e.data;return e.data}),oe(1)).toPromise();return n.postMessage(Object.assign(Object.assign({},e),{context:this._context}),this._targetOrigin),i}setTarget(e){this._targetWindow=e}setContext(e){this._context=e}}class Xc{constructor(e){var t;this._sourceOrigins=[Zc(e).origin,(t=Zc(e),Zc(0===t.hostname.indexOf("www")?t.href:t.href.replace(t.hostname,`www.${t.hostname}`))).origin],this._isListening=!1,this._listeners={}}listen(){this._isListening||(this._isListening=!0,window.addEventListener("message",this._handleMessage))}stopListen(){this._isListening&&(this._isListening=!1,window.removeEventListener("message",this._handleMessage))}addListener(e,t){let n=this._listeners[e];n||(this._listeners[e]=n=[]),-1===n.indexOf(t)&&n.push(t)}removeListener(e,t){const n=this._listeners[e];if(!n)return;const i=n.indexOf(t);i>=0&&n.splice(i,1)}trigger(e,t){const n=this._listeners[e.type];n&&n.forEach(n=>t?n(e,t):n(e))}_handleMessage(e){if(-1===this._sourceOrigins.indexOf(e.origin)||!Jc(e.data,e.data.type))return;const t=e.data,{context:n}=t,i=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["context"]);this.trigger(i,n)}}!function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);o>3&&a&&Object.defineProperty(t,n,a)}([ka],Xc.prototype,"_handleMessage",null);class eu extends Ee{constructor(){super("You haven't complete our spam protection challenge. Please try again."),this.name="SpamProtectionChallengeNotCompletedError",this.type="spam_protection_challenge_not_completed"}}class tu extends Ee{constructor(){super("Please complete our human verification challenge and try again."),this.name="CardingProtectionChallengeNotCompletedError",this.type="carding_protection_challenge_not_completed"}}class nu extends Ee{constructor(){super("We were not able to verify that you are not a robot. Please try again."),this.name="CardingProtectionFailedError",this.type="carding_protection_failed"}}var iu,ru,ou,au=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class su{constructor(e){this._googleRecaptcha=e}handle(e,t){return au(this,void 0,void 0,function*(){return"string"==typeof e?this.handleWithRecaptchaSitekey(e,t):this.handleWithPaymentHumanVerificationRequestError(e)})}handleWithPaymentHumanVerificationRequestError(e){return au(this,void 0,void 0,function*(){if(!this._isPaymentHumanVerificationRequest(e))throw e;return yield this._initialize(e.body.additional_action_required.data.key),this._performRecaptcha()})}handleWithRecaptchaSitekey(e,t){return au(this,void 0,void 0,function*(){if("recaptcha_v2"!==e)throw Error("Human verification method is not supported.");if(!t)throw Error("Recaptcha site key is missing.");return yield this._initialize(t),this._performRecaptcha()})}_performRecaptcha(){return this._googleRecaptcha.execute().pipe(oe(1)).pipe(re(e=>au(this,[e],void 0,function*({error:e,token:t}){if(e instanceof eu)throw new tu;if(e||!t)throw new nu;return{type:"recaptcha_v2_verification",data:{human_verification_token:t}}}))).toPromise()}_initialize(e){const t="cardingProtectionContainer";let n=document.getElementById(t);return n&&n.parentNode&&n.parentNode.removeChild(n),n=document.createElement("div"),n.setAttribute("id",t),document.body.appendChild(n),this._googleRecaptcha.load(t,e)}_isPaymentHumanVerificationRequest(e){const{additional_action_required:t,status:n}=e.body||{};return"additional_action_required"===n&&t&&"recaptcha_v2_verification"===t.type}}!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"}(iu||(iu={}));class du extends Ee{constructor(e){super(function(e){switch(e){case iu.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case iu.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case iu.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case iu.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}class cu extends Ee{constructor(){super("We were not able to complete your spam protection verification. Please try again."),this.name="SpamProtectionFailedError",this.type="spam_protection_failed"}}class uu extends Ee{constructor(){super("Spam protection is not loaded. Please try again."),this.name="SpamProtectionNotLoadedError",this.type="spam_protection_failed"}}class lu{constructor(e,t){this.googleRecaptchaScriptLoader=e,this.mutationObserverFactory=t,this._memoized=ae((e,t,n)=>{const i=new G;if(!n)throw new Error;return this._widgetId=e.render(n.id,{sitekey:t,size:"invisible",callback:()=>{i.next({token:e.getResponse(this._widgetId)}),e.reset(this._widgetId)},"error-callback":()=>{i.next({error:new cu})}}),i},{isEqual:(e,t)=>e===t})}load(e,t){return this.googleRecaptchaScriptLoader.load().then(n=>{n&&(this._event$=this._memoized(n,t,document.getElementById(e)),this._recaptcha=n)}).catch(e=>{throw e})}reset(e){var t;const n=document.getElementById(e);null==n||n.remove(),null===(t=this._recaptcha)||void 0===t||t.reset(this._widgetId)}execute(){return H(()=>{const e=this._event$,t=this._recaptcha;if(!e||!t)throw new du(iu.SpamProtectionNotInitialized);return H(()=>{const e=document.querySelector('iframe[src*="bframe"]');return e?Z(e):J(new uu)}).pipe(ne(e=>e.pipe(X(250),re((e,t)=>t<28?Z(e):J(e)))),re(n=>(this._watchRecaptchaChallengeWindow(e,n),t.execute(this._widgetId),e)),Q(e=>Z({error:e})))})}_watchRecaptchaChallengeWindow(e,t){const n=t.parentElement;if(!n)throw new uu;const i=n.parentElement;if(!i)throw new uu;this.mutationObserverFactory.create(()=>{"hidden"===i.style.visibility&&e.next({error:new eu})}).observe(i,{attributes:!0,attributeFilter:["style"]})}}class hu{constructor(e,t=window){this._scriptLoader=e,this._window=t}load(){return this._loadPromise||(this._loadPromise=this._loadScript()),this._loadPromise}_loadScript(){const e="initRecaptcha",t=[`onload=${e}`,"render=explicit"].join("&");return new Promise((n,i)=>{this._window[e]=()=>n(this._window.grecaptcha),this._scriptLoader.loadScript(`//www.google.com/recaptcha/api.js?${t}`).catch(e=>{this._loadPromise=void 0,i(e)})})}}function pu(e){return new lu(new hu(e),new Kc)}class gu extends Ee{constructor(e){super(e||"Unable to proceed due to invalid configuration provided for the hosted payment form."),this.name="InvalidHostedFormConfigError",this.type="invalid_hosted_form_config"}}class mu extends Ee{constructor(e){super(e||"Unable to proceed due to an unknown error with the hosted payment form."),this.name="InvalidHostedFormError",this.type="invalid_hosted_form"}}class yu extends Ee{constructor(e){super(["Unable to proceed due to invalid user input values",...p(x(e),e=>P(e,({message:e})=>e))].join(". ")),this.errors=e,this.name="InvalidHostedFormValueError",this.type="invalid_hosted_form_value"}}!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"}(ru||(ru={})),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"}(ou||(ou={}));var fu=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class _u{constructor(e,t,n,i,r,o,a,s,d,c){this._type=e,this._containerId=t,this._placeholder=n,this._accessibilityLabel=i,this._styles=r,this._eventPoster=o,this._eventListener=a,this._detachmentObserver=s,this._checkoutId=d,this._cardInstrument=c,this._iframe=document.createElement("iframe");const u=this._checkoutId?`/checkout/payment/hosted-field?version=1.934.1&checkoutId=${this._checkoutId}`:"/checkout/payment/hosted-field?version=1.934.1";this._iframe.src=u,this._iframe.style.border="none",this._iframe.style.height="100%",this._iframe.style.overflow="hidden",this._iframe.style.width="100%"}getType(){return this._type}attach(){return fu(this,void 0,void 0,function*(){const e=document.getElementById(this._containerId);if(!e)throw new gu("Unable to proceed because the provided container ID is not valid.");e.appendChild(this._iframe),this._eventListener.listen();const t=K(this._iframe,"load").pipe(re(e=>fu(this,[e],void 0,function*({target:e}){const t=e&&e.contentWindow;if(!t)throw new Error("The content window of the iframe cannot be accessed.");this._eventPoster.setTarget(t),yield this._eventPoster.post({type:ru.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:ou.AttachSucceeded,errorType:ou.AttachFailed})})),oe(1)).toPromise();yield this._detachmentObserver.ensurePresence([this._iframe],t)})}detach(){this._iframe.parentElement&&(this._iframe.parentElement.removeChild(this._iframe),this._eventListener.stopListen())}submitForm(e,t){return fu(this,void 0,void 0,function*(){try{const n=this._eventPoster.post({type:ru.SubmitRequested,payload:{fields:e,data:t}},{successType:ou.SubmitSucceeded,errorType:ou.SubmitFailed});return yield this._detachmentObserver.ensurePresence([this._iframe],n)}catch(e){if(this._isSubmitErrorEvent(e)){if("hosted_form_error"===e.payload.error.code)throw new mu(e.payload.error.message);if(e.payload.response)throw Te(e.payload.response);throw new Error(e.payload.error.message)}throw e}})}submitStoredCardForm(e,t){return fu(this,void 0,void 0,function*(){const n=this._eventPoster.post({type:ru.StoredCardRequested,payload:{fields:e,data:t}},{successType:ou.StoredCardSucceeded,errorType:ou.StoredCardFailed});return this._detachmentObserver.ensurePresence([this._iframe],n)})}validateForm(){return fu(this,void 0,void 0,function*(){const e=this._eventPoster.post({type:ru.ValidateRequested},{successType:ou.Validated}),{payload:t}=yield this._detachmentObserver.ensurePresence([this._iframe],e);if(!t.isValid)throw new yu(t.errors)})}_getFontUrls(){const e="fonts.googleapis.com",t=document.querySelectorAll(`link[href*='${e}'][rel='stylesheet']`);return Array.prototype.slice.call(t).filter(t=>Zc(t.href).hostname===e).filter(e=>x(this._styles).map(e=>e&&e.fontFamily).filter(e=>"string"==typeof e).some(t=>t.split(/,\s/).some(t=>-1!==e.href.indexOf(t.replace(" ","+"))))).map(e=>e.href)}_isSubmitErrorEvent(e){return e.type===ou.SubmitFailed}}var Su=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class vu{constructor(e,t,n,i,r){this._fields=e,this._eventListener=t,this._payloadTransformer=n,this._eventCallbacks=i,this._paymentHumanVerificationHandler=r,this._handleEnter=e=>Su(this,[e],void 0,function*({payload:e}){try{yield this.validate()}catch(e){if(e instanceof Error&&"InvalidHostedFormValueError"!==e.name)throw e}const{onEnter:t=T}=this._eventCallbacks;t(e)});const{onBlur:o=T,onCardTypeChange:a=T,onFocus:s=T,onValidate:d=T}=this._eventCallbacks;this._eventListener.addListener(ou.Blurred,({payload:e})=>o(e)),this._eventListener.addListener(ou.CardTypeChanged,({payload:e})=>a(e)),this._eventListener.addListener(ou.Focused,({payload:e})=>s(e)),this._eventListener.addListener(ou.Validated,({payload:e})=>d(e)),this._eventListener.addListener(ou.Entered,this._handleEnter),this._eventListener.addListener(ou.CardTypeChanged,({payload:e})=>this._cardType=e.cardType),this._eventListener.addListener(ou.BinChanged,({payload:e})=>this._bin=e.bin)}getBin(){return this._bin}getCardType(){return this._cardType}attach(){return Su(this,void 0,void 0,function*(){this._eventListener.listen();const e=this._getFirstField(),t=q(this._fields,e);yield e.attach(),yield Promise.all(t.map(e=>e.attach()))})}detach(){this._eventListener.stopListen(),this._fields.forEach(e=>{e.detach()})}submit(e,t){return Su(this,void 0,void 0,function*(){try{return yield this._getFirstField().submitForm(this._fields.map(e=>e.getType()),this._payloadTransformer.transform(e,t))}catch(t){const n=yield this._paymentHumanVerificationHandler.handle(t);return yield this._getFirstField().submitForm(this._fields.map(e=>e.getType()),this._payloadTransformer.transform(e,n))}})}submitStoredCard(e){return Su(this,void 0,void 0,function*(){return this._getFirstField().submitStoredCardForm(e.fields,e.data)})}validate(){return Su(this,void 0,void 0,function*(){return this._getFirstField().validateForm()})}_getFirstField(){const e=this._fields[0];if(!e)throw new gu("Unable to proceed because the payment form has no field defined.");return e}}function Cu(e){return Boolean(e.instrumentId)}class Iu{constructor(e){this._store=e}transform(e,t){const n=this._store.getState(),i=n.checkout.getCheckout(),r=n.config.getConfig(),o=n.instruments.getInstrumentsMeta(),a=n.order.getOrder(),s=n.order.getOrderMeta(),d=k(e.paymentData,"ccExpiry","ccName","ccNumber","ccCvv");let c=n.paymentMethods.getPaymentMethod(e.methodId,e.gatewayId);"worldpayaccess"===(null==c?void 0:c.gateway)&&"credit_card"===(null==c?void 0:c.id)&&(c=Object.assign(Object.assign({},c),{id:"worldpayaccess",method:"credit-card"}));const u=n.paymentMethods.getPaymentMethodsMeta(),l=o&&d&&Cu(d)?`${n.payment.getPaymentToken()}, ${o.vaultAccessToken}`:n.payment.getPaymentToken();if(!l)throw new nr(tr.MissingPaymentToken);return{additionalAction:t,authToken:l,checkout:i,config:r,order:a,orderMeta:s,payment:d,paymentMethod:c,paymentMethodMeta:u}}}class wu{constructor(e){this._store=e}create(e,t,n){const i=Object.keys(t.fields).reduce((i,r)=>{const o=t.fields[r];return o?[...i,new _u(r,o.containerId,o.placeholder||"",o.accessibilityLabel||"",t.styles||{},new Qc(e),new Xc(e),new Yc(new Kc),n,"instrumentId"in o?this._getCardInstrument(o.instrumentId):void 0)]:i},[]);return new vu(i,new Xc(e),new Iu(this._store),D(t,"onBlur","onEnter","onFocus","onCardTypeChange","onValidate"),new su(pu(ue())))}_getCardInstrument(e){const{instruments:{getCardInstrument:t}}=this._store.getState(),n=t(e);if(!n)throw new nr(tr.MissingPaymentInstrument);return n}}class Eu extends Ee{constructor(){super("You haven't complete our spam check. Please try again."),this.name="SpamProtectionNotCompletedError",this.type="spam_protection_not_completed"}}class bu{constructor(e,t){this._orderRequestSender=e,this._checkoutValidator=t}loadOrder(e,t){return new j(n=>{n.next(o(Pt.LoadOrderRequested)),this._orderRequestSender.loadOrder(e,t).then(e=>{n.next(o(Pt.LoadOrderSucceeded,e.body)),n.complete()}).catch(e=>{n.error(s(Pt.LoadOrderFailed,e))})})}loadOrderPayments(e,t){return new j(n=>{n.next(o(Pt.LoadOrderPaymentsRequested)),this._orderRequestSender.loadOrder(e,t).then(e=>{n.next(o(Pt.LoadOrderPaymentsSucceeded,e.body)),n.complete()}).catch(e=>{n.error(s(Pt.LoadOrderPaymentsFailed,e))})})}loadCurrentOrder(e){return t=>H(()=>{const n=this._getCurrentOrderId(t.getState());if(!n)throw new nr(tr.MissingOrderId);return this.loadOrder(n,e)})}submitOrder(e,t){return n=>V(Z(o(Pt.SubmitOrderRequested)),H(()=>{const i=n.getState(),r=i.config.getExternalSource(),a=i.config.getVariantIdentificationToken(),s=i.checkout.getCheckout();if(!s)throw new nr(tr.MissingCheckout);if(s.shouldExecuteSpamCheck)throw new Eu;return Y(this._checkoutValidator.validate(s,t).then(()=>this._orderRequestSender.submitOrder(this._mapToOrderRequestBody(null!=e?e:{},s.id,s.customerMessage,r),Object.assign(Object.assign({},t),{headers:{checkoutVariant:a}})))).pipe(re(e=>V(this.loadOrder(e.body.data.order.orderId,t),Z(o(Pt.SubmitOrderSucceeded,e.body.data,Object.assign(Object.assign({},e.body.meta),{token:e.headers.token}))))))}).pipe(Q(e=>vc(Pt.SubmitOrderFailed,e))))}finalizeOrder(e,t){return V(Z(o(Pt.FinalizeOrderRequested)),Y(this._orderRequestSender.finalizeOrder(e,t)).pipe(re(n=>V(this.loadOrder(e,t),Z(o(Pt.FinalizeOrderSucceeded,n.body.data)))))).pipe(Q(e=>vc(Pt.FinalizeOrderFailed,e)))}_getCurrentOrderId(e){const t=e.order.getOrder(),n=e.checkout.getCheckout();return t&&t.orderId||n&&n.orderId}_mapToOrderRequestBody(e,t,n,i){const{payment:r}=e,o=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["payment"]);return r?Object.assign(Object.assign({},o),{cartId:t,customerMessage:n,externalSource:i,payment:{paymentData:r.paymentData,name:r.methodId,gateway:r.gatewayId}}):Object.assign(Object.assign({},o),{cartId:t,customerMessage:n,externalSource:i})}}class Pu extends Ee{constructor(e){super(e||"Your checkout could not be processed because some details have changed. Please review your order and try again."),this.name="CartConsistencyError",this.type="cart_consistency"}}class Ou extends Ee{constructor(e,t){super(t||"At least one item changed stock position. Please review your cart and try again."),this.name="CartStockPositionsChangedError",this.type="cart_stock_positions_changed",this.changedItemIds=e}}class Au extends Ee{constructor(e){super(e||"The tax provider is unavailable."),this.name="OrderTaxProviderUnavailableError",this.type="tax_provider_unavailable"}}class Tu extends Ee{constructor(e){super(e),this.name="MissingShippingMethodError",this.type="missing_shipping_method"}}class ku extends Ee{constructor(e){super(e),this.name="InvalidShippingAddressError",this.type="invalid_shipping_address"}}class Ru{constructor(e){this._requestSender=e}loadOrder(e,{timeout:t}={}){const n=`/api/storefront/orders/${e}`,i=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.get(n,{params:{include:Ac(["payments","lineItems.physicalItems.socialMedia","lineItems.physicalItems.options","lineItems.physicalItems.categories","lineItems.digitalItems.socialMedia","lineItems.digitalItems.options","lineItems.digitalItems.categories"])},headers:i,timeout:t})}submitOrder(e,{headers:t,timeout:n}={}){return this._requestSender.post("/internalapi/v1/checkout/order",{body:e,headers:R(Object.assign({"X-Checkout-Variant":t&&t.checkoutVariant},yc),v),timeout:n}).catch(e=>{var t,n;if("tax_provider_unavailable"===e.body.type)throw new Au;if("cart_has_changed"===e.body.type)throw new Pu;if("cart_stock_positions_changed"===e.body.type){const i=null!==(n=null===(t=e.body.errors)||void 0===t?void 0:t.changedItemIds)&&void 0!==n?n:[];throw new Ou(i)}if("missing_shipping_method"===e.body.type)throw new Tu(e.body.detail);if("invalid_shipping_address"===e.body.type)throw new ku(e.body.detail);if("empty_cart"===e.body.type)throw new wc;throw e})}finalizeOrder(e,{timeout:t}={}){const n=`/internalapi/v1/checkout/order/${e}`;return this._requestSender.post(n,{timeout:t,headers:yc})}}class Du{constructor(e,t,n,i){this._paymentRequestSender=e,this._orderActionCreator=t,this._paymentRequestTransformer=n,this._paymentHumanVerificationHandler=i,this.initializeOffsitePayment=({methodId:e,gatewayId:t,instrumentId:n,target:i,promise:r,shouldSaveInstrument:a,shouldSetAsDefaultInstrument:s})=>d=>{let c;n?c={formattedPayload:{bigpay_token:n}}:a&&(c={formattedPayload:{vault_payment_instrument:a,set_as_default_stored_instrument:s||null}});const u=this._paymentRequestTransformer.transform({gatewayId:t,methodId:e,paymentData:c},d.getState());return V(Z(o(kn.InitializeOffsitePaymentRequested)),Promise.race([this._paymentRequestSender.initializeOffsitePayment(u,i),r].filter(Boolean)).then(()=>o(kn.InitializeOffsitePaymentSucceeded))).pipe(Q(e=>vc(kn.InitializeOffsitePaymentFailed,e)))}}submitPayment(e){return t=>V(Z(o(kn.SubmitPaymentRequested)),H(()=>{return n=this,i=void 0,o=function*(){try{return yield this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transform(e,t.getState()))}catch(n){const i=yield this._paymentHumanVerificationHandler.handle(n);return yield this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transform(Object.assign(Object.assign({},e),{additionalAction:i}),t.getState()))}},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}).pipe(re(({body:e})=>V(this._orderActionCreator.loadCurrentOrder()(t),Z(o(kn.SubmitPaymentSucceeded,e)))))).pipe(Q(e=>vc(kn.SubmitPaymentFailed,e)))}}class Mu{constructor(e){this._client=e}submitPayment(e){return new Promise((t,n)=>{this._client.submitPayment(e,(e,i)=>{e?n(this._transformResponse(e)):t(this._transformResponse(i))})})}initializeOffsitePayment(e,t){return new Promise(()=>{this._client.initializeOffsitePayment(e,null,t)})}_transformResponse(e){return{headers:e.headers,body:e.data,status:e.status,statusText:e.statusText}}}function Nu(e,t){let 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 Lu=["per_item_discount","percentage_discount","per_total_discount","shipping_discount","free_shipping"];function zu(e){return{code:e.code,discount:e.displayName,discountType:Lu.indexOf(e.couponType)}}function Uu(e){return{code:e.code,discountedAmount:e.used,remainingBalance:e.remaining,giftCertificate:{balance:e.balance,code:e.code,purchaseDate:e.purchaseDate}}}function Fu(e){const t=[];return(e||[]).forEach(e=>{(e.banners||[]).forEach(e=>{t.push({placeholders:[],discountType:null,message:"",messageHtml:e.text})})}),t}function Bu(e,t,n="id"){return Object.keys(e).reduce((i,r)=>[...i,...e[r].map(e=>"giftCertificates"===r?function(e,t){const n=new ic(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,i="id"){const r=new ic(n);return{id:e[i],imageUrl:e.imageUrl,amount:e.extendedListPrice,amountAfterDiscount:e.extendedSalePrice,discount:e.discountAmount,integerAmount:r.toInteger(e.extendedListPrice),integerAmountAfterDiscount:r.toInteger(e.extendedSalePrice),integerDiscount:r.toInteger(e.discountAmount),integerUnitPrice:r.toInteger(e.listPrice),integerUnitPriceAfterDiscount:r.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(e=>({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""}}(r),t,n))],[])}function xu(e){const t=e.cart.currency.decimalPlaces,n=new ic(t);return{id:e.cart.id,items:Bu(e.cart.lineItems,t),currency:e.cart.currency.code,coupon:{discountedAmount:N(e.cart.coupons,(e,t)=>e+t.discountedAmount,0),coupons:e.cart.coupons.map(zu)},discount:{amount:e.cart.discountAmount,integerAmount:n.toInteger(e.cart.discountAmount)},discountNotifications:Fu(e.promotions),giftCertificate:{totalDiscountedAmount:N(e.giftCertificates,(e,t)=>e+t.used,0),appliedGiftCertificates:w(e.giftCertificates.map(Uu),"code")},shipping:{amount:e.shippingCostTotal,integerAmount:n.toInteger(e.shippingCostTotal),amountBeforeDiscount:e.shippingCostBeforeDiscount,integerAmountBeforeDiscount:n.toInteger(e.shippingCostBeforeDiscount),required:z(e.cart.lineItems.physicalItems,e=>e.isShippingRequired)},subtotal:{amount:e.subtotal,integerAmount:n.toInteger(e.subtotal)},storeCredit:{amount:e.customer?e.customer.storeCredit:0},taxSubtotal:{amount:e.taxTotal,integerAmount:n.toInteger(e.taxTotal)},taxes:e.taxes,taxTotal:{amount:e.taxTotal,integerAmount:n.toInteger(e.taxTotal)},handling:{amount:e.handlingCostTotal,integerAmount:n.toInteger(e.handlingCostTotal)},grandTotal:{amount:e.grandTotal,integerAmount:n.toInteger(e.grandTotal)}}}var qu;!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.PAYPALEXPRESS="paypalexpress"}(qu||(qu={}));const ju=qu;function Gu(e,t){const n=e.firstName||t.firstName||"",i=e.lastName||t.lastName||"";return{addresses:(e.addresses||[]).map(e=>Nu(e)),customerId:e.id,isGuest:e.isGuest,storeCredit:e.storeCredit,email:e.email||t.email||"",firstName:n,lastName:i,name:e.fullName||[n,i].join(" "),customerGroupName:e.customerGroup&&e.customerGroup.name}}class Vu{format(e){const[t="",n=""]=e.split(new RegExp("\\s*/\\s*")),i=t.slice(0,2),r=4===n.length?n.slice(-2):n?n.slice(0,2):t.slice(2);return e.length<2?t:e.length>3&&!r?i:`${i} / ${r}`}toObject(e){const[t="",n=""]=e.split(new RegExp("\\s*/\\s*"));return/^\d+$/.test(t)&&/^\d+$/.test(n)?{month:1===t.length?`0${t}`:t.slice(0,2),year:2===n.length?`20${n}`:n.slice(0,4)}:{month:"",year:""}}}class Hu{format(e){const{card:t}=ye(e);if(!t)return e;const n=O(me(e).map(e=>O(e.lengths))),i=this.unformat(e).slice(0,n);return t.gaps.filter(e=>i.length>e).reduce((e,t,n)=>[e.slice(0,t+n),e.slice(t+n)].join(" "),i)}unformat(e){const{card:t}=ye(e);return t?e.replace(new RegExp(" ","g"),""):e}}function Wu(e,t={}){const n=e.currency.decimalPlaces,i=new ic(n);return{id:e.orderId,items:Bu(e.lineItems,e.currency.decimalPlaces,"productId"),orderId:e.orderId,currency:e.currency.code,customerCanBeCreated:e.customerCanBeCreated,payment:$u(e.payments,t.payment),subtotal:{amount:e.baseAmount,integerAmount:i.toInteger(e.baseAmount)},coupon:{discountedAmount:N(e.coupons,(e,t)=>e+t.discountedAmount,0),coupons:e.coupons.map(zu)},discount:{amount:e.discountAmount,integerAmount:i.toInteger(e.discountAmount)},token:t.orderToken,callbackUrl:t.callbackUrl,discountNotifications:[],giftCertificate:Ku(e.payments),socialData:Ju(e),status:e.status,hasDigitalItems:e.hasDigitalItems,isDownloadable:e.isDownloadable,isComplete:e.isComplete,shipping:{amount:e.shippingCostTotal,integerAmount:i.toInteger(e.shippingCostTotal),amountBeforeDiscount:e.shippingCostBeforeDiscount,integerAmountBeforeDiscount:i.toInteger(e.shippingCostBeforeDiscount)},storeCredit:{amount:Yu(e.payments)},taxes:e.taxes,taxTotal:{amount:e.taxTotal,integerAmount:i.toInteger(e.taxTotal)},handling:{amount:e.handlingCostTotal,integerAmount:i.toInteger(e.handlingCostTotal)},grandTotal:{amount:e.orderAmount,integerAmount:e.orderAmountAsInteger}}}function Yu(e){const t=l(e,{providerId:"storecredit"});return t?t.amount:0}function Ku(e){const t=u(e,{providerId:"giftcertificate"});return{totalDiscountedAmount:N(t,(e,t)=>t.amount+e,0),appliedGiftCertificates:w(t.map(e=>({code:e.detail.code,discountedAmount:e.amount,remainingBalance:e.detail.remaining,giftCertificate:{balance:e.amount+e.detail.remaining,code:e.detail.code,purchaseDate:""}})),"code")}}function $u(e,t={}){const n=l(e,Zu);return n?{id:n.providerId,status:(i=n.detail.step,`PAYMENT_STATUS_${i}`),helpText:n.detail.instructions,returnUrl:t.returnUrl}:{};var i}function Zu(e){return"giftcertificate"!==e.providerId&&"storecredit"!==e.providerId}function Ju(e){const t={};return[...e.lineItems.physicalItems,...e.lineItems.digitalItems].forEach(e=>{var n;t[e.id]=(n=e,["fb","tw","gp"].reduce((e,t)=>{const i=n.socialMedia&&l(n.socialMedia,e=>e.code===t);return i?(e[t]={name:n.name,description:n.name,image:n.imageUrl,url:i.link,shareText:i.text,sharingLink:i.link,channelName:i.channel,channelCode:i.code},e):e},{}))}),t}function Qu(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}}class Xu{constructor(){this._cardExpiryFormatter=new Vu,this._cardNumberFormatter=new Hu}transform(e,t){const n=t.billingAddress.getBillingAddress(),i=t.checkout.getCheckout(),r=t.customer.getCustomer(),o=t.order.getOrder(),a=t.paymentMethods.getPaymentMethod(e.methodId,e.gatewayId),s=this._mapShippingAddress(t,a),d=t.consignments.getConsignments(),c=t.consignments.getShippingOption(),u=t.config.getStoreConfig(),l=t.config.getContextConfig(),h=t.instruments.getInstrumentsMeta(),p=t.paymentMethods.getPaymentMethodsMeta(),g=t.order.getOrderMeta(),m=r&&n&&Gu(r,n),y=h&&e.paymentData&&(Cu(e.paymentData)||function(e){const t=e.formattedPayload;return!!t&&("string"==typeof t.bigpay_token||Boolean(t.bigpay_token&&t.bigpay_token.token))}(e.paymentData))?`${t.payment.getPaymentToken()}, ${h.vaultAccessToken}`:t.payment.getPaymentToken();if(!y)throw new nr(tr.MissingPaymentToken);return{additionalAction:e.additionalAction,authToken:y,customer:m,billingAddress:n&&Nu(n),shippingAddress:s&&Nu(s,d),shippingOption:c&&Qu(c,!0),cart:i&&xu(i),order:o&&Wu(o,g),orderMeta:g,payment:e.paymentData,paymentMethod:a&&this._transformPaymentMethod(a),quoteMeta:{request:Object.assign(Object.assign({},p),{geoCountryCode:l&&l.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:D(u&&u.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}}transformWithHostedFormData(e,t,n){const{additionalAction:i,authToken:r,checkout:o,config:a,order:s,orderMeta:d,payment:c={},paymentMethod:u,paymentMethodMeta:l}=t,h=o&&o.consignments[0],p=h&&h.shippingAddress,g=h&&h.selectedShippingOption;return{additionalAction:i,authToken:r,paymentMethod:u&&this._transformPaymentMethod(u),customer:s&&s.billingAddress&&o&&Gu(o.customer,s.billingAddress),billingAddress:s&&s.billingAddress&&Nu(s.billingAddress),shippingAddress:p&&o&&Nu(p,o.consignments),shippingOption:g&&Qu(g,!0),cart:o&&xu(o),order:s&&Wu(s,d),orderMeta:d,payment:this._transformHostedInputValues(e,c,n),quoteMeta:{request:Object.assign(Object.assign({},l),{geoCountryCode:a&&a.context.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:a&&D(a.storeConfig.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}}_transformPaymentMethod(e){if("multi-option"===e.method&&!e.gateway)return Object.assign(Object.assign({},e),{gateway:e.id});if(e.initializationData&&e.initializationData.gateway)return Object.assign(Object.assign({},e),{id:e.initializationData.gateway});if("worldpayaccess"===e.gateway){if("credit_card"===e.id)return Object.assign(Object.assign({},e),{id:"worldpayaccess",method:"credit-card"});if("open_banking"===e.id)return Object.assign(Object.assign({},e),{id:"worldpayaccess",method:"open_banking"})}return e.id===ju.BRAINTREE_VENMO?Object.assign(Object.assign({},e),{id:ju.BRAINTREE_PAYPAL}):e}_transformHostedInputValues(e,t,n){return"instrumentId"in t?Object.assign(Object.assign({},t),{ccCvv:e.cardCodeVerification,ccNumber:e.cardNumberVerification&&this._cardNumberFormatter.unformat(e.cardNumberVerification),hostedFormNonce:n}):Object.assign(Object.assign({},t),{ccCvv:e.cardCode,ccExpiry:this._cardExpiryFormatter.toObject(e.cardExpiry||""),ccName:e.cardName||"",ccNumber:this._cardNumberFormatter.unformat(e.cardNumber||""),hostedFormNonce:n})}_mapShippingAddress(e,t){var n,i,r,o;if(t){const a=null===(i=null===(n=t.initializationData)||void 0===n?void 0:n.bopis)||void 0===i?void 0:i.enabled,s=null===(o=null===(r=t.initializationData)||void 0===r?void 0:r.bopis)||void 0===o?void 0:o.requiredAddress,d=e.consignments.getConsignments(),c=null==d?void 0:d.every(e=>e.selectedPickupOption);if(a&&c&&"none"===s)return}return e.shippingAddress.getShippingAddress()}}class el{widgetInteraction(e,t){const n={methodId:t&&t.methodId};return V(Z(o(xn.WidgetInteractionStarted,void 0,n)),H(()=>e().then(()=>o(xn.WidgetInteractionFinished,void 0,n)))).pipe(Q(e=>vc(xn.WidgetInteractionFailed,e,n)))}}class tl{updatePaymentProviderCustomer(e){return Z(o(Xn.UpdatePaymentProviderCustomer,e))}}class nl{constructor(e,t){this._remoteCheckoutRequestSender=e,this._checkoutActionCreator=t}initializeBilling(e,t,n){return j.create(i=>{i.next(o(ii.InitializeRemoteBillingRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.initializeBilling(e,t,n).then(({body:t={}})=>{i.next(o(ii.InitializeRemoteBillingSucceeded,t,{methodId:e})),i.complete()}).catch(t=>{i.error(s(ii.InitializeRemoteBillingFailed,t,{methodId:e}))})})}initializeShipping(e,t,n){return j.create(i=>{i.next(o(ii.InitializeRemoteShippingRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.initializeShipping(e,t,n).then(({body:t={}})=>{i.next(o(ii.InitializeRemoteShippingSucceeded,t,{methodId:e})),i.complete()}).catch(t=>{i.error(s(ii.InitializeRemoteShippingFailed,t,{methodId:e}))})})}initializePayment(e,t,n){return j.create(i=>{i.next(o(ii.InitializeRemotePaymentRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.initializePayment(e,t,n).then(({body:t={}})=>{i.next(o(ii.InitializeRemotePaymentSucceeded,t,{methodId:e})),i.complete()}).catch(t=>{i.error(s(ii.InitializeRemotePaymentFailed,t,{methodId:e}))})})}loadSettings(e,t){return j.create(n=>{n.next(o(ii.LoadRemoteSettingsRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.loadSettings(e,t).then(({body:t})=>{n.next(o(ii.LoadRemoteSettingsSucceeded,t,{methodId:e})),n.complete()}).catch(t=>{n.error(s(ii.LoadRemoteSettingsFailed,t,{methodId:e}))})})}signOut(e,t){return j.create(n=>{n.next(o(ii.SignOutRemoteCustomerRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.signOut(e,t).then(()=>{n.next(o(ii.SignOutRemoteCustomerSucceeded,void 0,{methodId:e})),n.complete()}).catch(t=>{n.error(s(ii.SignOutRemoteCustomerFailed,t,{methodId:e}))})})}forgetCheckout(e,t){return V(Z(o(ii.ForgetCheckoutRemoteCustomerRequested,void 0,{methodId:e})),H(()=>{return n=this,i=void 0,a=function*(){return yield this._remoteCheckoutRequestSender.forgetCheckout(t),yield this._checkoutActionCreator.loadCurrentCheckout(),o(ii.ForgetCheckoutRemoteCustomerSucceeded,void 0,{methodId:e})},new((r=void 0)||(r=Promise))(function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function s(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(o,s)}d((a=a.apply(n,i||[])).next())});var n,i,r,a})).pipe(Q(t=>vc(ii.ForgetCheckoutRemoteCustomerFailed,t,{methodId:e})))}updateCheckout(e,t){return o(ii.UpdateRemoteCheckout,t,{methodId:e})}}class il{constructor(e){this._requestSender=e}initializeBilling(e,t,{timeout:n}={}){const i=`/remote-checkout/${e}/billing`;return this._requestSender.get(i,{params:t,timeout:n,headers:yc})}initializeShipping(e,t,{timeout:n}={}){const i=`/remote-checkout/${e}/shipping`;return this._requestSender.get(i,{params:t,timeout:n,headers:yc})}initializePayment(e,t,{timeout:n}={}){const i=`/remote-checkout/${e}/payment`;return this._requestSender.get(i,{params:t,timeout:n,headers:yc})}loadSettings(e,{timeout:t}={}){const n=`/remote-checkout/${e}/settings`;return this._requestSender.get(n,{timeout:t,headers:yc})}signOut(e,{timeout:t}={}){const n=`/remote-checkout/${e}/signout`;return this._requestSender.get(n,{timeout:t,headers:yc})}generateToken({timeout:e}={}){return this._requestSender.get("/remote-checkout-token",{timeout:e,headers:yc})}trackAuthorizationEvent({timeout:e}={}){return this._requestSender.post("/remote-checkout/events/shopper-checkout-service-provider-authorization-requested",{timeout:e,headers:yc})}forgetCheckout({timeout:e}={}){return this._requestSender.post("/remote-checkout/forget-checkout",{timeout:e,headers:yc})}}class rl{constructor(e,t){this._consignmentRequestSender=e,this._checkoutRequestSender=t}unassignItemsByAddress(e,t){return n=>{const i=n.getState();if(!i.checkout.getCheckout())throw new nr(tr.MissingCheckout);const r=this._consignmentHasAddress(e)?e.address:e.shippingAddress,o=i.consignments.getConsignmentByAddress(r);if(!o)throw new $c("No consignment found for the specified address");const a=this._removeLineItems(e.lineItems,o,i.cart.getCart());return a.length?this.updateConsignment({id:o.id,address:r,lineItems:a},t)(n):this.deleteConsignment(o.id,t)(n)}}assignItemsByAddress(e,t){return n=>{const i=n.getState(),r=this._consignmentHasAddress(e)?e.address:e.shippingAddress,o=i.consignments.getConsignmentByAddress(r);return this._createOrUpdateConsignment({id:o&&o.id,address:r,lineItems:this._addLineItems(e.lineItems,o,i.cart.getCart())},t)(n)}}selectShippingOption(e,t){return n=>j.create(i=>{const r=n.getState(),a=r.checkout.getCheckout(),d=r.consignments.getConsignments();if(!a)throw new nr(tr.MissingCheckout);if(!d||!d.length)throw new nr(tr.MissingConsignments);const c={id:d[0].id,shippingOptionId:e},u={id:d[0].id};i.next(o(ot.UpdateShippingOptionRequested,void 0,u)),this._consignmentRequestSender.updateConsignment(a.id,c,t).then(({body:e})=>{i.next(o(ot.UpdateShippingOptionSucceeded,e,u)),i.complete()}).catch(e=>{i.error(s(ot.UpdateShippingOptionFailed,e,u))})})}loadShippingOptions(e){return t=>j.create(n=>{const i=t.getState().checkout.getCheckout();if(!i)throw new nr(tr.MissingCheckout);n.next(o(ot.LoadShippingOptionsRequested)),this._checkoutRequestSender.loadCheckout(i.id,Object.assign(Object.assign({},e),{params:{include:[zc.AvailableShippingOptions]}})).then(({body:e})=>{n.next(o(ot.LoadShippingOptionsSucceeded,e)),n.complete()}).catch(e=>{n.error(s(ot.LoadShippingOptionsFailed,e))})})}updateAddress(e,t){return n=>{const i=this._getUpdateAddressRequestBody(e,n),r=n.getState().consignments.getConsignments();return r&&r.length&&(i.id=r[0].id),this._createOrUpdateConsignment(i,t)(n)}}createConsignments(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout();if(!r||!r.id)throw new nr(tr.MissingCheckout);i.next(o(ot.CreateConsignmentsRequested)),this._consignmentRequestSender.createConsignments(r.id,e,t).then(({body:e})=>{i.next(o(ot.CreateConsignmentsSucceeded,e)),i.complete()}).catch(e=>{i.error(s(ot.CreateConsignmentsFailed,e))})})}updateConsignment(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout();if(!r||!r.id)throw new nr(tr.MissingCheckout);const a={id:e.id};i.next(o(ot.UpdateConsignmentRequested,void 0,a)),this._consignmentRequestSender.updateConsignment(r.id,e,t).then(({body:e})=>{i.next(o(ot.UpdateConsignmentSucceeded,e,a)),i.complete()}).catch(e=>{i.error(s(ot.UpdateConsignmentFailed,e,a))})})}deleteConsignment(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout(),a={id:e};if(!r||!r.id)throw new nr(tr.MissingCheckout);i.next(o(ot.DeleteConsignmentRequested,void 0,a)),this._consignmentRequestSender.deleteConsignment(r.id,e,t).then(({body:e})=>{i.next(o(ot.DeleteConsignmentSucceeded,e,a)),i.complete()}).catch(e=>{i.error(s(ot.DeleteConsignmentFailed,e,a))})})}updateShippingOption(e,t){return n=>j.create(i=>{var r;const a=n.getState().checkout.getCheckout(),d=n.getState().consignments.getConsignmentById(e.id);if((null===(r=null==d?void 0:d.selectedShippingOption)||void 0===r?void 0:r.id)===e.shippingOptionId)return void i.complete();if(!a||!a.id)throw new nr(tr.MissingCheckout);const c={id:e.id};i.next(o(ot.UpdateShippingOptionRequested,void 0,c)),this._consignmentRequestSender.updateConsignment(a.id,e,t).then(({body:e})=>{i.next(o(ot.UpdateShippingOptionSucceeded,e,c)),i.complete()}).catch(e=>{i.error(s(ot.UpdateShippingOptionFailed,e,c))})})}_createOrUpdateConsignment(e,t){return n=>{const i=n.getState().checkout.getCheckout();if(!i||!i.id)throw new nr(tr.MissingCheckout);return this._isUpdateConsignmentRequest(e)?this.updateConsignment(e,t)(n):this.createConsignments([e],t)(n)}}_getUpdateAddressRequestBody(e,t){const n=t.getState().cart.getCart();if(!n)throw new nr(tr.MissingCart);const{physicalItems:i,customItems:r=[]}=n.lineItems;return{address:e,lineItems:[...i,...r].map(e=>({itemId:e.id,quantity:e.quantity}))}}_removeLineItems(e,t,n){if(!n)throw new nr(tr.MissingCart);return this._hydrateLineItems(t.lineItemIds,n).map(t=>{const n=l(e,e=>e.itemId===t.itemId);return Object.assign(Object.assign({},t),{quantity:n?t.quantity-n.quantity:t.quantity})}).filter(e=>e.quantity>0)}_addLineItems(e,t,n){if(!t)return e;if(!n)throw new nr(tr.MissingCart);return e.concat(this._hydrateLineItems(t.lineItemIds,n)).filter(e=>e.quantity>0)}_hydrateLineItems(e,t){return e.map(e=>{const n=l(t.lineItems.physicalItems,t=>t.id===e);return{itemId:e,quantity:n?n.quantity:0}})}_isUpdateConsignmentRequest(e){return!!e.id}_consignmentHasAddress(e){return"object"==typeof e&&"address"in e}}const ol=["consignments.availableShippingOptions","cart.lineItems.physicalItems.options","cart.lineItems.physicalItems.stockPosition","cart.lineItems.digitalItems.options","cart.lineItems.digitalItems.stockPosition","customer","promotions.banners"];class al{constructor(e){this._requestSender=e}createConsignments(e,t,{timeout:n,params:{include:i}={}}={}){const r=`/api/storefront/checkouts/${e}/consignments`,o=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.post(r,{body:t,params:{include:Tc(ol,i)},headers:o,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}updateConsignment(e,t,{timeout:n,params:{include:i}={}}={}){const{id:r}=t,o=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["id"]),a=`/api/storefront/checkouts/${e}/consignments/${r}`,s=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.put(a,{body:o,params:{include:Tc(ol,i)},headers:s,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}deleteConsignment(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/consignments/${t}`,r=Object.assign({Accept:gc.JsonV1},yc),o=Ac(ol);return this._requestSender.delete(i,{params:{include:o},headers:r,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}}class sl{constructor(e,t){this._shippingCountryRequestSender=e,this._store=t}loadCountries(e){const{checkout:t}=this._store.getState(),n=t.getCheckout(),i=n?n.channelId:null;return j.create(t=>{t.next(o(vi.LoadShippingCountriesRequested)),this._shippingCountryRequestSender.loadCountries(i,e).then(e=>{t.next(o(vi.LoadShippingCountriesSucceeded,e.body.data)),t.complete()}).catch(e=>{t.error(s(vi.LoadShippingCountriesFailed,e))})})}}class dl{constructor(e,t){this._requestSender=e,this._config=t}loadCountries(e,{timeout:t}={}){const n="/internalapi/v1/shipping/countries"+(e?`?channel_id=${e}`:""),i=Object.assign({"Accept-Language":this._config.locale},yc);return this._requestSender.get(n,{headers:i,timeout:t})}}var cl=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ul{constructor(e,t){this._googleRecaptcha=e,this._requestSender=t}initialize(e){return t=>V(Z(o(Yi.InitializeRequested,void 0)),H(()=>cl(this,void 0,void 0,function*(){const n=e?e.containerId:"spamProtectionContainer";if(document.getElementById(n)&&this._googleRecaptcha.reset(n),!e&&!document.getElementById(n)){const e=document.createElement("div");e.setAttribute("id",n),document.body.appendChild(e)}const i=t.getState().config.getStoreConfigOrThrow().checkoutSettings.googleRecaptchaSitekey;return yield this._googleRecaptcha.load(n,i),o(Yi.InitializeSucceeded)}))).pipe(Q(e=>vc(Yi.InitializeFailed,e)))}verifyCheckoutSpamProtection(){return e=>H(()=>{const t=e.getState().checkout.getCheckout();if(!t)throw new nr(tr.MissingCheckout);return V(Z(o(Yi.VerifyCheckoutRequested)),Y(this.execute()(e)).pipe(re(e=>qc(e)&&e.payload?Y(this._requestSender.validate(t.id,e.payload.token)).pipe(re(({body:t})=>V(Z(e),Z(o(Yi.VerifyCheckoutSucceeded,t))))):Z(e)))).pipe(Q(e=>vc(Yi.VerifyCheckoutFailed,e)))})}execute(){return e=>V(Z(o(Yi.ExecuteRequested)),this.initialize()(e),this._googleRecaptcha.execute().pipe(oe(1)).pipe(re(e=>cl(this,[e],void 0,function*({error:e,token:t}){if(e instanceof eu)throw e;if(e||!t)throw new cu;return o(Yi.ExecuteSucceeded,{token:t})})))).pipe(Q(e=>vc(Yi.ExecuteFailed,e)))}}class ll{constructor(e){this._requestSender=e}validate(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/spam-protection`,r=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.post(i,{body:{token:t},headers:r,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new wc;throw e})}}class hl{constructor(e){this._storeCreditRequestSender=e}applyStoreCredit(e,t){return n=>V(Z(o(Fi.ApplyStoreCreditRequested)),H(()=>{return i=this,r=void 0,s=function*(){var i;const r=n.getState().checkout.getCheckout();if(!r)throw new nr(tr.MissingCheckout);const{id:a}=r,s=null!==(i=null==t?void 0:t.version)&&void 0!==i?i:r.version,{body:d}=yield e?this._storeCreditRequestSender.applyStoreCredit(a,Object.assign(Object.assign({},t),{version:s})):this._storeCreditRequestSender.removeStoreCredit(a,Object.assign(Object.assign({},t),{version:s}));return o(Fi.ApplyStoreCreditSucceeded,d)},new((a=void 0)||(a=Promise))(function(e,t){function n(e){try{d(s.next(e))}catch(e){t(e)}}function o(e){try{d(s.throw(e))}catch(e){t(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a(function(e){e(i)})).then(n,o)}d((s=s.apply(i,r||[])).next())});var i,r,a,s})).pipe(Q(e=>vc(Fi.ApplyStoreCreditFailed,e)))}}class pl{constructor(e){this._requestSender=e}applyStoreCredit(e,{timeout:t,version:n}={}){const i=`/api/storefront/checkouts/${e}/store-credit`,r=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.post(i,{headers:r,timeout:t,params:{include:Ac(kc)},body:{version:n}})}removeStoreCredit(e,{timeout:t,version:n}={}){const i=`/api/storefront/checkouts/${e}/store-credit`,r=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.delete(i,{headers:r,timeout:t,params:{include:Ac(kc)},body:{version:n}})}}class gl extends Pe{constructor(e){super(e),this.name="UpdateSubscriptionsError",this.type="update_subscriptions"}}class ml{constructor(e){this._subscriptionsRequestSender=e}updateSubscriptions(e,t){return V(Z(o(We.UpdateSubscriptionsRequested)),H(()=>{return n=this,i=void 0,a=function*(){const{body:n}=yield this._subscriptionsRequestSender.updateSubscriptions(e,t);return o(We.UpdateSubscriptionsSucceeded,n)},new((r=void 0)||(r=Promise))(function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function s(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(o,s)}d((a=a.apply(n,i||[])).next())});var n,i,r,a})).pipe(Q(e=>vc(We.UpdateSubscriptionsFailed,new gl(e))))}}class yl{constructor(e){this._requestSender=e}updateSubscriptions(e,{timeout:t}={}){const n=Object.assign({Accept:gc.JsonV1},yc);return this._requestSender.post("/api/storefront/subscriptions",{body:e,headers:n,timeout:t})}}const fl=A(e=>Array.isArray(e)?e.map(e=>_l(e)):et(e)?Object.keys(e).reduce((t,n)=>Object.assign(Object.assign({},t),{[n]:_l(e[n])}),{}):e);fl.cache=new WeakMap;const _l=e=>"object"==typeof e&&null!==e?fl(e):e;function Sl(e){return(...t)=>_l(e(...t))}function vl({billingAddress:{getBillingAddress:e,getBillingAddressOrThrow:t},cart:{getCart:n,getCartOrThrow:i,getLocale:r},checkout:{getCheckout:o,getCheckoutOrThrow:a,getOutstandingBalance:s},config:{getContextConfig:d,getHost:c,getLocale:u,getStoreConfig:l,getStoreConfigOrThrow:h,getConfig:p},consignments:{getConsignments:g,getConsignmentsOrThrow:m},countries:{getCountries:y},customer:{getCustomer:f,getCustomerOrThrow:_},instruments:{getCardInstrument:S,getCardInstrumentOrThrow:v,getInstruments:C,getInstrumentsMeta:I},order:{getOrder:w,getOrderOrThrow:E,getOrderMeta:b},payment:{getPaymentToken:P,getPaymentTokenOrThrow:O,getPaymentId:A,getPaymentIdOrThrow:T,getPaymentStatus:k,getPaymentStatusOrThrow:R,getPaymentRedirectUrl:D,getPaymentRedirectUrlOrThrow:M,isPaymentDataRequired:N},paymentMethods:{getPaymentMethod:L,getPaymentMethodOrThrow:z,getPaymentMethodsMeta:U},paymentProviderCustomer:{getPaymentProviderCustomer:F,getPaymentProviderCustomerOrThrow:B},paymentStrategies:{isInitialized:x},shippingAddress:{getShippingAddress:q,getShippingAddressOrThrow:j,getShippingAddresses:G,getShippingAddressesOrThrow:V},shippingCountries:{getShippingCountries:H}}){return{getHost:Sl(c),getLocale:Sl(u),getCartLocale:Sl(r),getBillingAddress:Sl(e),getBillingAddressOrThrow:Sl(t),getCart:Sl(n),getCartOrThrow:Sl(i),getCheckout:Sl(o),getCheckoutOrThrow:Sl(a),getCountries:Sl(y),getStoreConfig:Sl(l),getStoreConfigOrThrow:Sl(h),getConfig:Sl(p),getConsignments:Sl(g),getConsignmentsOrThrow:Sl(m),getContextConfig:Sl(d),getCustomer:Sl(f),getCustomerOrThrow:Sl(_),getCardInstrument:Sl(S),getInstruments:Sl(C),getCardInstrumentOrThrow:Sl(v),getOrder:Sl(w),getOrderOrThrow:Sl(E),getOrderMeta:Sl(b),getInstrumentsMeta:Sl(I),getPaymentToken:P,getPaymentTokenOrThrow:O,getPaymentId:A,getPaymentIdOrThrow:T,getPaymentStatus:k,getPaymentStatusOrThrow:R,getPaymentRedirectUrl:D,getPaymentRedirectUrlOrThrow:M,getPaymentMethod:Sl(L),getPaymentMethodOrThrow:Sl(z),getPaymentMethodsMeta:Sl(U),getPaymentProviderCustomer:Sl(F),getPaymentProviderCustomerOrThrow:Sl(B),getShippingAddress:Sl(q),getShippingAddressOrThrow:Sl(j),getShippingAddresses:Sl(G),getShippingAddressesOrThrow:Sl(V),getShippingCountries:Sl(H),getOutstandingBalance:Sl(s),isPaymentDataRequired:N,isPaymentMethodInitialized:x}}var Cl,Il=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class wl{constructor(e,t,n,i,r,o,a,s,d,c,u,l,h,p,g,m,y,f,_,S){this._store=e,this._storeProjectionFactory=t,this._checkoutActionCreator=n,this._checkoutValidator=i,this._hostedFormFactory=r,this._orderActionCreator=o,this._billingAddressActionCreator=a,this._consignmentActionCreator=s,this._paymentMethodActionCreator=d,this._paymentActionCreator=c,this._paymentHumanVerificationHandler=u,this._customerActionCreator=l,this._cartRequestSender=h,this._storeCreditActionCreator=p,this._couponActionCreator=g,this._spamProtectionActionCreator=m,this._paymentProviderCustomerActionCreator=y,this._shippingCountryActionCreator=f,this._remoteCheckoutActionCreator=_,this._paymentStrategyWidgetActionCreator=S,this._storeProjection=this._storeProjectionFactory.create(this._store)}createHostedForm(e,t){const n=this._storeProjection.getState().getCheckoutOrThrow().id;return this._hostedFormFactory.create(e,t,n)}subscribe(e,...t){return this._storeProjection.subscribe(e,...t)}getState(){return this._storeProjection.getState()}initializeOffsitePayment(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentActionCreator.initializeOffsitePayment(e)),this._storeProjection.getState()})}loadCheckout(e){return Il(this,void 0,void 0,function*(){return e?yield this._store.dispatch(this._checkoutActionCreator.loadCheckout(e)):yield this._store.dispatch(this._checkoutActionCreator.loadCurrentCheckout()),this._storeProjection.getState()})}loadDefaultCheckout(){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout()),this._storeProjection.getState()})}loadPaymentMethod(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(e,t)),this._storeProjection.getState()})}loadPaymentMethods(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethods(e)),this._storeProjection.getState()})}submitOrder(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._orderActionCreator.submitOrder(e,t)),this._storeProjection.getState()})}submitPayment(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentActionCreator.submitPayment(e)),this._storeProjection.getState()})}finalizeOrder(e){return Il(this,void 0,void 0,function*(){const{order:{getOrderOrThrow:t}}=this._store.getState();return yield this._store.dispatch(this._orderActionCreator.finalizeOrder(t().orderId,e)),this._storeProjection.getState()})}updateBillingAddress(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._billingAddressActionCreator.updateAddress(e)),this._storeProjection.getState()})}updateShippingAddress(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._consignmentActionCreator.updateAddress(e)),this._storeProjection.getState()})}selectShippingOption(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._consignmentActionCreator.selectShippingOption(e,t)),this._storeProjection.getState()})}signInCustomer(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._customerActionCreator.signInCustomer(e,t)),this._storeProjection.getState()})}signOutCustomer(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._customerActionCreator.signOutCustomer(e)),this._storeProjection.getState()})}createBuyNowCart(e,t){return Il(this,void 0,void 0,function*(){const{body:n}=yield this._cartRequestSender.createBuyNowCart(e,t);return n})}applyStoreCredit(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._storeCreditActionCreator.applyStoreCredit(e,t)),this._storeProjection.getState()})}applyCoupon(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._couponActionCreator.applyCoupon(e,t)),this._storeProjection.getState()})}removeCoupon(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._couponActionCreator.removeCoupon(e,t)),this._storeProjection.getState()})}verifyCheckoutSpamProtection(){return Il(this,void 0,void 0,function*(){const{checkout:e}=this._store.getState(),{shouldExecuteSpamCheck:t}=e.getCheckoutOrThrow();return t&&(yield this._store.dispatch(this._spamProtectionActionCreator.verifyCheckoutSpamProtection())),this._storeProjection.getState()})}loadCurrentOrder(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._orderActionCreator.loadCurrentOrder(e)),this._storeProjection.getState()})}updatePaymentProviderCustomer(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentProviderCustomerActionCreator.updatePaymentProviderCustomer(e)),this._storeProjection.getState()})}loadShippingCountries(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._shippingCountryActionCreator.loadCountries(e)),this._storeProjection.getState()})}deleteConsignment(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._consignmentActionCreator.deleteConsignment(e,t)),this._storeProjection.getState()})}initializePayment(e,t,n){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._remoteCheckoutActionCreator.initializePayment(e,t,n)),this._storeProjection.getState()})}forgetCheckout(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._remoteCheckoutActionCreator.forgetCheckout(e,t)),this._storeProjection.getState()})}remoteCheckoutSignOut(e,t){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._remoteCheckoutActionCreator.signOut(e,t)),this._storeProjection.getState()})}validateCheckout(e,t){return Il(this,void 0,void 0,function*(){yield this._checkoutValidator.validate(e,t)})}handlePaymentHumanVerification(e,t){return Il(this,void 0,void 0,function*(){return"string"==typeof e?this._paymentHumanVerificationHandler.handle(e,null!=t?t:""):this._paymentHumanVerificationHandler.handle(e)})}widgetInteraction(e){return Il(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentStrategyWidgetActionCreator.widgetInteraction(e),{queueId:"widgetInteraction"}),this._storeProjection.getState()})}}!function(e){e.Synchronize="SYNCHRONIZE"}(Cl||(Cl={}));class El{constructor(e){this._transformSelectors=e}create(e){return function(e,t){const n=a((e,t)=>t.type===Cl.Synchronize?t.payload:e,e.getState(),{stateTransformer:t});return e.subscribe(e=>{n.dispatch(o(Cl.Synchronize,e))},{initial:!1}),n}(e,this._transformSelectors)}}const bl=e=>{const t=B(e);return document.getElementById(t)?bl(e):t};function Pl(e){return Object.prototype.hasOwnProperty.call(e,"cacheKey")}class Ol{constructor(e){this._lastId=0,this._map={maps:[]},this._usedMaps=[],this._options=Object.assign({maxSize:0,isEqual:fe,onExpire:T},e)}getKey(...e){const t=this._resolveMap(...e),{index:n,parentMap:i}=t;let{map:r}=t;return r&&r.cacheKey?r.usedCount++:r=this._generateMap(i,e.slice(n)),this._removeLeastUsedMap(r),r.cacheKey}getUsedCount(...e){const{map:t}=this._resolveMap(...e);return t?t.usedCount:0}_resolveMap(...e){let t=0,n=this._map;for(;n.maps.length;){let i=!1;for(let r=0;r<n.maps.length;r++){const o=n.maps[r];if(this._options.isEqual(o.value,e[t])){if(n.maps.unshift(...n.maps.splice(r,1)),(0===e.length||t===e.length-1)&&Pl(o))return{index:t,map:o,parentMap:n};i=!0,n=o,t++;break}}if(!i)break}return{index:t,parentMap:n}}_generateMap(e,t){let n,i=0,r=e;do{n={maps:[],parentMap:r,usedCount:1,value:t[i]},r.maps.unshift(n),r=n,i++}while(i<t.length);const o=n;return o.cacheKey=""+ ++this._lastId,o}_removeLeastUsedMap(e){if(!this._options.maxSize)return;const t=this._usedMaps.indexOf(e);if(this._usedMaps.splice(-1===t?0:t,-1===t?0:1,e),this._usedMaps.length<=this._options.maxSize)return;const n=this._usedMaps.pop();n&&(this._removeMap(n),this._options.onExpire(n.cacheKey))}_removeMap(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))}}function Al(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&"constructor"!==n&&Object.defineProperty(t.prototype,n,function(e,t,n){if("function"!=typeof n.value)return n;let i=new Ol,r=n.value,o=ae(r);return ka(e,t,{get(){const e=(...e)=>{const t=o.call(this,...e);if(1===i.getUsedCount(...e))return t;const n=r.call(this,...e);return Ue(n,t,{keyFilter:e=>!function(e){return 0===`${e}`.indexOf("$$")||0===`${e}`.indexOf("_")}(e)})?t:(o.cache.set(i.getKey(...e),n),n)};return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e},set(e){i=new Ol,r=e,o=ae(r)}})}(e.prototype,n,i))}),t}let Tl=class{constructor(e){this._checkoutButton=e.checkoutButton}getInitializeButtonError(e){return this._checkoutButton.getInitializeError(e)}getDeinitializeButtonError(e){return this._checkoutButton.getDeinitializeError(e)}};Tl=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([Al],Tl);const kl=Tl;let Rl=class{constructor(e){this._checkoutButton=e.checkoutButton}isInitializingButton(e){return this._checkoutButton.isInitializing(e)}isDeinitializingButton(e){return this._checkoutButton.isDeinitializing(e)}};Rl=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([Al],Rl);const Dl=Rl;function Ml(e){return{errors:new kl(e),statuses:new Dl(e)}}let Nl=class{constructor(e,t){this._store=e,this._buttonStrategyActionCreator=t,this._state=Ml(this._store.getState()),this._store.subscribe(e=>{this._state=Ml(e)})}getState(){return this._state}subscribe(e,...t){return this._store.subscribe(()=>e(this.getState()),e=>e.checkoutButton.getState(),...t.map(e=>t=>e(Ml(t))))}initializeButton(e){const t=(n=e.containerId,/^\w[\w\-\:\.]*$/.test(n)?[e.containerId]:function(e,t){const n=document.querySelectorAll(e);if(!n.length)throw new $c(`Unable to find any element with the specified selector: ${e}`);return Array.prototype.slice.call(n).map(e=>(e.id||(e.id=bl(t)),e.id))}(e.containerId,`${e.methodId}-container`));var n;return Promise.all(t.map(t=>{const n=this._buttonStrategyActionCreator.initialize(Object.assign(Object.assign({},e),{containerId:t})),i=`checkoutButtonStrategy:${e.methodId}:${t}`;return this._store.dispatch(n,{queueId:i})})).then(()=>this.getState())}deinitializeButton(e){const t=this._buttonStrategyActionCreator.deinitialize(e),n=`checkoutButtonStrategy:${e.methodId}`;return this._store.dispatch(t,{queueId:n}).then(()=>this.getState())}};Nl=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([ka],Nl);const Ll=Nl;class zl{constructor(e,t,n){this._registry=e,this._registryV2=t,this._paymentMethodActionCreator=n}initialize(e){return t=>{const n={methodId:e.methodId,containerId:e.containerId};if(t.getState().checkoutButton.isInitialized(e.methodId,e.containerId))return W();const i=e.currencyCode?{params:{currencyCode:e.currencyCode}}:{},r=Object.assign(Object.assign({},i),{timeout:e.timeout,useCache:!0});return V(Z(o(lt.InitializeButtonRequested,void 0,n)),this._paymentMethodActionCreator.loadPaymentMethod(e.methodId,r)(t),H(()=>this._getStrategy(e.methodId).initialize(e).then(()=>o(lt.InitializeButtonSucceeded,void 0,n)))).pipe(Q(e=>vc(lt.InitializeButtonFailed,e,n)))}}deinitialize(e){return t=>{const n={methodId:e.methodId};return t.getState().checkoutButton.isInitialized(e.methodId)?V(Z(o(lt.DeinitializeButtonRequested,void 0,n)),H(()=>this._getStrategy(e.methodId).deinitialize().then(()=>o(lt.DeinitializeButtonSucceeded,void 0,n)))).pipe(Q(e=>vc(lt.DeinitializeButtonFailed,e,n))):W()}}_getStrategy(e){let t;try{t=this._registryV2.get({id:e})}catch(n){t=this._registry.get(e)}return t}}class Ul{constructor(e){var t,n,i;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!==(i=null==e?void 0:e.tokenResolver)&&void 0!==i?i:e=>e}get(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)}}getFactory(e,t){const n=this._tokenResolver(e,Object.keys(this._factories),t);return n?this._factories[n]:void 0}register(e,t){if(this._hasFactory(e))throw new $c(`'${e}' is already registered.`);this._factories[e]=t}_hasFactory(e){return!!this._factories[e]}_hasInstance(e){return!!this._instances[e]}_getInstance(e,t){if(!this._hasInstance(t)){const n=this.getFactory(e);if(!n)throw new $c(`'${e}' is not registered.`);this._instances[t]=n()}return this._instances[t]}}class Fl extends Ee{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}var Bl,xl,ql,jl,Gl;class Vl{constructor(e){this._scriptLoader=e,this._window=window}loadPaypal(){return e=this,t=arguments,i=function*(e=""){const t="//www.paypalobjects.com/api/checkout.min.js",n={async:!0,attributes:{"data-merchant-id":e}};if(e?yield this._scriptLoader.loadScript(t,n):yield this._scriptLoader.loadScript(t),!this._window.paypal)throw new Fl;return this._window.paypal},new((n=void 0)||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())});var e,t,n,i}}!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(Bl||(Bl={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(xl||(xl={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white"}(ql||(ql={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(jl||(jl={})),function(e){e.PILL="pill",e.RECT="rect"}(Gl||(Gl={}));class Hl{constructor(e,t,n,i,r=""){this._store=e,this._checkoutActionCreator=t,this._paypalScriptLoader=n,this._formPoster=i,this._host=r}initialize(e){const t=e.paypal,n=this._store.getState(),i=this._paymentMethod=n.paymentMethods.getPaymentMethod(e.methodId);if(!t)throw new $c;if(!i)throw new nr(tr.MissingPaymentMethod);return this._paypalScriptLoader.loadPaypal(i.config.merchantId).then(n=>{var r,o;if(!i||!i.config.merchantId)throw new nr(tr.MissingPaymentMethod);const a=i.config.merchantId,s=i.config.testMode?"sandbox":"production",d={[s]:t.clientId},c=n.FUNDING.CREDIT||"credit",u=t.allowCredit?[c]:[],l=t.allowCredit?[]:[c];return n.Button.render({env:s,client:d,commit:t.shouldProcessPayment,funding:{allowed:u,disallowed:l},style:Object.assign(Object.assign({shape:Gl.RECT},D(t.style,"layout","color","label","shape","tagline","fundingicons")),{size:"paypalexpress"===i.id&&"small"===(null===(r=t.style)||void 0===r?void 0:r.size)?xl.RESPONSIVE:null===(o=t.style)||void 0===o?void 0:o.size}),payment:(e,n)=>this._setupPayment(a,n,t.onPaymentError),onAuthorize:(e,n)=>this._tokenizePayment(e,n,t.shouldProcessPayment,t.onAuthorizeError)},e.containerId)})}deinitialize(){return this._paymentMethod=void 0,Promise.resolve()}_setupPayment(e,t,n){if(!t)throw new du(iu.CheckoutButtonNotInitialized);return this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout()).then(n=>{const i=n.cart.getCart(),r=i?i.id:"";return t.request.post(`${this._host}/api/storefront/payment/paypalexpress`,{merchantId:e,cartId:r},{headers:Object.assign({"X-API-INTERNAL":mc},yc)})}).then(e=>e.id).catch(e=>{throw n&&n(e),e})}_tokenizePayment(e,t,n,i){if(!this._paymentMethod)throw new du(iu.CheckoutButtonNotInitialized);if(!t)throw new du(iu.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new nr(tr.MissingPayment);const r=this._paymentMethod.id;return t.payment.get(e.paymentID).then(t=>{this._formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:r,action:n?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(t.payer.payer_info)})})}}function Wl(e){return e&&"resolveIds"in e}function Yl(){try{return"production"}catch(e){return"development"}}class Kl{constructor(e){this._console=e}log(...e){this._logToConsole("log",...e)}info(...e){this._logToConsole("info",...e)}warn(...e){this._logToConsole("warn",...e)}error(...e){this._logToConsole("error",...e)}debug(...e){this._logToConsole("debug",...e)}_logToConsole(e,...t){this._console&&this._console[e]&&this._console[e].call(this._console,...t)}}class $l{log(){}info(){}warn(){}error(){}debug(){}}const Zl=function(e=!0){return e?new Kl(console):new $l}("test"!==Yl());class Jl{constructor(e=!1){this._useFallback=e,this._registry=new Ul({tokenResolver:this._resolveToken.bind(this),defaultToken:this._encodeToken({default:!0}),useFallback:this._useFallback})}get(e){return this._registry.get(this._encodeToken(e))}getFactory(e,t){try{return this._registry.getFactory(this._encodeToken(e),t)}catch(e){return}}getUseFallback(){return this._useFallback}register(e,t){this._registry.register(this._encodeToken(e),t)}_encodeToken(e){return btoa(JSON.stringify(e))}_decodeToken(e){return JSON.parse(atob(e))}_resolveToken(e,t,n){var i;const r=this._decodeToken(e),o=[];t.forEach(e=>{const t=this._decodeToken(e),n={token:e,matches:0,default:!1,totalKeys:Object.keys(t).length};for(const[e,i]of Object.entries(t)){if(e in r&&r[e]!==i){n.matches=0;break}e in r&&r[e]===i&&n.matches++,"default"===e&&!0===i&&(n.default=!0)}o.push(n)});const a=o.sort((e,t)=>t.matches-e.matches).filter(e=>e.matches>0);a.length>1&&a[0].matches===a[1].matches&&"development"===Yl()&&Zl.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.");const s=Object.keys(r).length;if(n){const e=a.find(e=>e.matches===s&&e.matches===e.totalKeys);if(!e)throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(r)} with exact match.`);return e.token}const d=a[0];if(d&&d.token)return d.token;if(this._useFallback){const e=null===(i=o.find(e=>e.default))||void 0===i?void 0:i.token;if(e)return e}throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(r)}.`)}}function Ql(t){const{host:i}=null!=t?t:{},r=lr({config:{meta:{host:null==t?void 0:t.host,locale:null==t?void 0:t.locale},errors:{},statuses:{}}}),o=e({host:i}),a=n({host:i}),s=function(e,t){const n=new Jl;for(const[,i]of Object.entries(t))if(Wl(i))for(const t of i.resolveIds)n.register(t,()=>i(e));return n}(function(t,n){const{config:{getHost:i,getLocale:r}}=t.getState();n||(n=e({host:i()}));const o=new El(vl),a=new Oc(new Dc(n),new Uc(new Fc(n)),new Vc(new Hc(n))),s=new Lc(new Dc(n)),d=new wu(t),c=new bu(new Ru(n),new Lc(new Dc(n))),u=new Ic(new bc(n),new ml(new yl(n))),l=new rl(new al(n),new Dc(n)),h=new hc(new fc(n),new Sc(n)),p=new Du(new Mu(function(e){const t=ge();return e.subscribe(e=>{const n=e.config.getStoreConfig();n&&t.setHost(n.paymentSettings.bigpayBaseUrl)},e=>e.config.getStoreConfig()),t}(t)),c,new Xu,new su(pu(ue()))),g=new su(pu(ue())),m=new jc(new Gc(n),a,new ul(pu(ue()),new ll(n))),y=new hl(new pl(n)),f=new Bc(new xc(n)),_=pu(ue()),S=new ll(n),v=new ul(_,S),C=new Pc(n),I=new tl,w=new sl(new dl(n,{locale:r()}),t),E=new nl(new il(n),a),b=new el;return new wl(t,o,a,s,d,c,u,l,h,p,g,m,C,y,f,v,I,w,E,b)}(r),Se);return new Ll(r,new zl(function(e,t,n,i){const r=new Ul,o=le(),a=new Dc(t),s=new Oc(a,new Uc(new Fc(t)),new Vc(new Hc(t)));return r.register(ju.PAYPALEXPRESS,()=>new Hl(e,s,new Vl(o),n,i)),r}(r,o,a,i),s,new hc(new fc(o),new Sc(o))))}export{Ql as createCheckoutButtonInitializer,t as createTimeout};
2
2
  //# sourceMappingURL=checkout-button.js.map