@bigcommerce/checkout-sdk 1.980.0 → 1.981.0

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.
Files changed (34) hide show
  1. package/dist/cjs/checkout-button.js +1 -1
  2. package/dist/cjs/checkout-sdk-essential.js +1 -1
  3. package/dist/cjs/checkout-sdk.js +1 -1
  4. package/dist/cjs/hosted-form-v2-iframe-host.js +1 -1
  5. package/dist/cjs/integrations/amazon-pay.js +1 -1
  6. package/dist/cjs/integrations/bigcommerce-payments.js +1 -1
  7. package/dist/cjs/integrations/bigcommerce-payments.js.map +1 -1
  8. package/dist/cjs/integrations/braintree.js +1 -1
  9. package/dist/cjs/integrations/google-pay.js +1 -1
  10. package/dist/cjs/integrations/klarna.js +1 -1
  11. package/dist/cjs/integrations/paypal-commerce.js +1 -1
  12. package/dist/cjs/integrations/paypal-commerce.js.map +1 -1
  13. package/dist/cjs/integrations/paypal-express.js +1 -1
  14. package/dist/cjs/integrations/zip.js +1 -1
  15. package/dist/cjs/wallet-button.js +1 -1
  16. package/dist/cjs/wallet-button.js.map +1 -1
  17. package/dist/esm/checkout-button.js +1 -1
  18. package/dist/esm/checkout-sdk-essential.js +1 -1
  19. package/dist/esm/checkout-sdk.js +1 -1
  20. package/dist/esm/hosted-form-v2-iframe-host.js +1 -1
  21. package/dist/esm/integrations/amazon-pay.js +1 -1
  22. package/dist/esm/integrations/bigcommerce-payments.js +1 -1
  23. package/dist/esm/integrations/bigcommerce-payments.js.map +1 -1
  24. package/dist/esm/integrations/braintree.js +1 -1
  25. package/dist/esm/integrations/google-pay.js +1 -1
  26. package/dist/esm/integrations/klarna.js +1 -1
  27. package/dist/esm/integrations/paypal-commerce.js +1 -1
  28. package/dist/esm/integrations/paypal-commerce.js.map +1 -1
  29. package/dist/esm/integrations/paypal-express.js +1 -1
  30. package/dist/esm/integrations/zip.js +1 -1
  31. package/dist/esm/wallet-button.js +1 -1
  32. package/dist/esm/wallet-button.js.map +1 -1
  33. package/dist/types/integrations/bigcommerce-payments.d.ts +26 -0
  34. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- import{getScriptLoader as e}from"@bigcommerce/script-loader";import{noop as t}from"lodash";import{createFormPoster as n}from"@bigcommerce/form-poster";function i(e,t){return Object.assign(e,{resolveIds:t})}class r 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}}var a=(e=>(e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress",e))(a||{});class s extends r{constructor(e){super(function(e){switch(e){case 0:return"Unable to proceed because billing address data is unavailable.";case 1:return"Unable to proceed because cart data is unavailable.";case 3:return"Unable to proceed because consignments data is unavailable.";case 2:return"Unable to proceed because checkout data is unavailable.";case 4:return"Unable to proceed because customer data is unavailable.";case 5:case 7:return"Unable to proceed because configuration data is unavailable.";case 6:return"Unable to proceed because order data is unavailable.";case 8:return"Unable to proceed because order ID is unavailable or not generated yet.";case 9:return"Unable to proceed because payment data is unavailable.";case 15:return"Unable to proceed because the token required to submit a payment is missing.";case 12:return"Unable to proceed because payment method data is unavailable or not properly configured.";case 16:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}var o=(e=>(e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized",e))(o||{});class c extends r{constructor(e){super(function(e){switch(e){case 1:return"Unable to proceed because the customer step of checkout has not been initialized.";case 2:return"Unable to proceed because the payment step of checkout has not been initialized.";case 3:return"Unable to proceed because the shipping step of checkout has not been initialized.";case 4:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}class d extends r{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}var l=(e=>(e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive",e))(l||{}),p=(e=>(e.PILL="pill",e.RECT="rect",e))(p||{}),u=(e=>(e.ACKNOWLEDGE="ACKNOWLEDGE",e.FINALIZE="FINALIZE",e.INITIALIZE="INITIALIZE",e))(u||{}),h=(e,t,n)=>new Promise((i,r)=>{var a=e=>{try{o(n.next(e))}catch(e){r(e)}},s=e=>{try{o(n.throw(e))}catch(e){r(e)}},o=e=>e.done?i(e.value):Promise.resolve(e.value).then(a,s);o((n=n.apply(e,t)).next())});class y{constructor(e,t){this.paymentIntegrationService=e,this.scriptLoader=t,this.useRedirectFlow=!1,this.window=window}initialize(e){return h(this,null,function*(){const t=this.paymentIntegrationService.getState();this.paymentMethod=t.getPaymentMethodOrThrow(e.methodId),this.useRedirectFlow=!0===(e.paypalexpress&&e.paypalexpress.useRedirectFlow);const n=this.paymentMethod.config.merchantId;if(!this.isInContextEnabled()||!n)throw new s(a.MissingPaymentMethod);const i=yield this.scriptLoader.loadPaypalSDK();this.paypalSdk=i,this.paypalSdk.checkout.setup(n,{button:"paypal-button",environment:this.paymentMethod.config.testMode?"sandbox":"production"})})}deinitialize(){return this.isInContextEnabled()&&this.paypalSdk&&(this.paypalSdk.checkout.closeFlow(),this.paypalSdk=void 0),Promise.resolve()}execute(e,n){return h(this,null,function*(){let i,r;const a=this.paypalSdk;if(!this.isAcknowledgedOrFinalized()){if(!this.isInContextEnabled()||this.useRedirectFlow)return i=yield this.paymentIntegrationService.submitOrder(e,n),r=i.getPaymentRedirectUrl(),r&&this.window.top&&(this.window.top.location.href=r),new Promise(t);if(!a)throw new c(o.PaymentNotInitialized);a.checkout.initXO();try{i=yield this.paymentIntegrationService.submitOrder(e,n)}catch(e){return a.checkout.closeFlow(),Promise.reject(e)}return r=i.getPaymentRedirectUrl(),r&&a.checkout.startFlow(r),new Promise(t)}yield this.paymentIntegrationService.submitOrder(e,n)})}finalize(e){return h(this,null,function*(){return this.paymentIntegrationService.getState().getOrder()&&this.isAcknowledgedOrFinalized()?(yield this.paymentIntegrationService.finalizeOrder(e),Promise.resolve()):Promise.reject(new d)})}isAcknowledgedOrFinalized(){const e=this.paymentIntegrationService.getState();return e.getPaymentStatus()===u.ACKNOWLEDGE||e.getPaymentStatus()===u.FINALIZE}isInContextEnabled(){return!(!this.paymentMethod||!this.paymentMethod.config.merchantId)}}class m extends r{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 g=Object.defineProperty,b=Object.getOwnPropertySymbols,I=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class P{constructor(e){this.scriptLoader=e,this.window=window}loadPaypalSDK(e=""){return t=this,n=function*(){const t=((e,t)=>{for(var n in t||(t={}))I.call(t,n)&&f(e,n,t[n]);if(b)for(var n of b(t))w.call(t,n)&&f(e,n,t[n]);return e})({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 m;return this.window.paypal},new Promise((e,i)=>{var r=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,a);s((n=n.apply(t,null)).next())});var t,n}}const v=i(t=>new y(t,new P(e())),[{id:"paypalexpress",type:"PAYMENT_TYPE_HOSTED"},{id:"paypalexpresscredit",type:"PAYMENT_TYPE_HOSTED"}]);class M extends r{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}const S={"X-Checkout-SDK-Version":"1.980.0"};var E=Object.defineProperty,O=Object.getOwnPropertySymbols,k=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable,C=(e,t,n)=>t in e?E(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))k.call(t,n)&&C(e,n,t[n]);if(O)for(var n of O(t))z.call(t,n)&&C(e,n,t[n]);return e},N=(e,t,n)=>new Promise((i,r)=>{var a=e=>{try{o(n.next(e))}catch(e){r(e)}},s=e=>{try{o(n.throw(e))}catch(e){r(e)}},o=e=>e.done?i(e.value):Promise.resolve(e.value).then(a,s);o((n=n.apply(e,t)).next())});class U{constructor(e,t,n){this.paymentIntegrationService=e,this.paypalExpressScriptLoader=t,this.formPoster=n}initialize(e){return N(this,null,function*(){const t=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!e.paypal)throw new M;if(!t.config.merchantId)throw new s(a.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:c,onPaymentError:d,shouldProcessPayment:l,style:p}=r,u=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!u.config.merchantId)throw new s(a.MissingPaymentMethod);const h=u.config.merchantId,y=u.config.testMode?"sandbox":"production",m={[y]:c},g=t.FUNDING.CREDIT||"credit",b=o?[g]:[],I=o?[]:[g];return t.Button.render({env:y,client:m,commit:l,funding:{allowed:b,disallowed:I},style:this.getStyle(p),payment:(e,t)=>this.setupPayment(h,t,d),onAuthorize:(e,t)=>this.tokenizePayment(e,i,t,l)},n)}getStyle(e){const{color:t,fundingicons:n,label:i,layout:r,shape:a,size:s,tagline:o}=e||{};return{color:t,fundingicons:n,label:i,layout:r,shape:a||p.RECT,size:"small"===s?l.RESPONSIVE:s,tagline:o}}setupPayment(e,t,n){return N(this,null,function*(){if(!t)throw new c(o.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:x({"X-API-INTERNAL":"This API endpoint is for internal use only and may change in the future"},S)})).id}catch(e){throw n&&e instanceof r&&n(e),e}})}tokenizePayment(e,t,n,i){return N(this,null,function*(){if(!n)throw new c(o.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new s(a.MissingPayment);const r=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),d=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(d.payer.payer_info)})})}}const A=i(t=>new U(t,new P(e()),n()),[{id:"paypalexpress"}]);export{A as createPaypalExpressButtonStrategy,v as createPaypalExpressPaymentStrategy};
1
+ import{getScriptLoader as e}from"@bigcommerce/script-loader";import{noop as t}from"lodash";import{createFormPoster as n}from"@bigcommerce/form-poster";function i(e,t){return Object.assign(e,{resolveIds:t})}class r 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}}var a=(e=>(e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress",e))(a||{});class s extends r{constructor(e){super(function(e){switch(e){case 0:return"Unable to proceed because billing address data is unavailable.";case 1:return"Unable to proceed because cart data is unavailable.";case 3:return"Unable to proceed because consignments data is unavailable.";case 2:return"Unable to proceed because checkout data is unavailable.";case 4:return"Unable to proceed because customer data is unavailable.";case 5:case 7:return"Unable to proceed because configuration data is unavailable.";case 6:return"Unable to proceed because order data is unavailable.";case 8:return"Unable to proceed because order ID is unavailable or not generated yet.";case 9:return"Unable to proceed because payment data is unavailable.";case 15:return"Unable to proceed because the token required to submit a payment is missing.";case 12:return"Unable to proceed because payment method data is unavailable or not properly configured.";case 16:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}var o=(e=>(e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized",e))(o||{});class c extends r{constructor(e){super(function(e){switch(e){case 1:return"Unable to proceed because the customer step of checkout has not been initialized.";case 2:return"Unable to proceed because the payment step of checkout has not been initialized.";case 3:return"Unable to proceed because the shipping step of checkout has not been initialized.";case 4:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}class d extends r{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}var l=(e=>(e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive",e))(l||{}),p=(e=>(e.PILL="pill",e.RECT="rect",e))(p||{}),u=(e=>(e.ACKNOWLEDGE="ACKNOWLEDGE",e.FINALIZE="FINALIZE",e.INITIALIZE="INITIALIZE",e))(u||{}),h=(e,t,n)=>new Promise((i,r)=>{var a=e=>{try{o(n.next(e))}catch(e){r(e)}},s=e=>{try{o(n.throw(e))}catch(e){r(e)}},o=e=>e.done?i(e.value):Promise.resolve(e.value).then(a,s);o((n=n.apply(e,t)).next())});class y{constructor(e,t){this.paymentIntegrationService=e,this.scriptLoader=t,this.useRedirectFlow=!1,this.window=window}initialize(e){return h(this,null,function*(){const t=this.paymentIntegrationService.getState();this.paymentMethod=t.getPaymentMethodOrThrow(e.methodId),this.useRedirectFlow=!0===(e.paypalexpress&&e.paypalexpress.useRedirectFlow);const n=this.paymentMethod.config.merchantId;if(!this.isInContextEnabled()||!n)throw new s(a.MissingPaymentMethod);const i=yield this.scriptLoader.loadPaypalSDK();this.paypalSdk=i,this.paypalSdk.checkout.setup(n,{button:"paypal-button",environment:this.paymentMethod.config.testMode?"sandbox":"production"})})}deinitialize(){return this.isInContextEnabled()&&this.paypalSdk&&(this.paypalSdk.checkout.closeFlow(),this.paypalSdk=void 0),Promise.resolve()}execute(e,n){return h(this,null,function*(){let i,r;const a=this.paypalSdk;if(!this.isAcknowledgedOrFinalized()){if(!this.isInContextEnabled()||this.useRedirectFlow)return i=yield this.paymentIntegrationService.submitOrder(e,n),r=i.getPaymentRedirectUrl(),r&&this.window.top&&(this.window.top.location.href=r),new Promise(t);if(!a)throw new c(o.PaymentNotInitialized);a.checkout.initXO();try{i=yield this.paymentIntegrationService.submitOrder(e,n)}catch(e){return a.checkout.closeFlow(),Promise.reject(e)}return r=i.getPaymentRedirectUrl(),r&&a.checkout.startFlow(r),new Promise(t)}yield this.paymentIntegrationService.submitOrder(e,n)})}finalize(e){return h(this,null,function*(){return this.paymentIntegrationService.getState().getOrder()&&this.isAcknowledgedOrFinalized()?(yield this.paymentIntegrationService.finalizeOrder(e),Promise.resolve()):Promise.reject(new d)})}isAcknowledgedOrFinalized(){const e=this.paymentIntegrationService.getState();return e.getPaymentStatus()===u.ACKNOWLEDGE||e.getPaymentStatus()===u.FINALIZE}isInContextEnabled(){return!(!this.paymentMethod||!this.paymentMethod.config.merchantId)}}class m extends r{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 g=Object.defineProperty,b=Object.getOwnPropertySymbols,I=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable,f=(e,t,n)=>t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class P{constructor(e){this.scriptLoader=e,this.window=window}loadPaypalSDK(e=""){return t=this,n=function*(){const t=((e,t)=>{for(var n in t||(t={}))I.call(t,n)&&f(e,n,t[n]);if(b)for(var n of b(t))w.call(t,n)&&f(e,n,t[n]);return e})({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 m;return this.window.paypal},new Promise((e,i)=>{var r=e=>{try{s(n.next(e))}catch(e){i(e)}},a=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,a);s((n=n.apply(t,null)).next())});var t,n}}const v=i(t=>new y(t,new P(e())),[{id:"paypalexpress",type:"PAYMENT_TYPE_HOSTED"},{id:"paypalexpresscredit",type:"PAYMENT_TYPE_HOSTED"}]);class M extends r{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}const S={"X-Checkout-SDK-Version":"1.981.0"};var E=Object.defineProperty,O=Object.getOwnPropertySymbols,k=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable,C=(e,t,n)=>t in e?E(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))k.call(t,n)&&C(e,n,t[n]);if(O)for(var n of O(t))z.call(t,n)&&C(e,n,t[n]);return e},N=(e,t,n)=>new Promise((i,r)=>{var a=e=>{try{o(n.next(e))}catch(e){r(e)}},s=e=>{try{o(n.throw(e))}catch(e){r(e)}},o=e=>e.done?i(e.value):Promise.resolve(e.value).then(a,s);o((n=n.apply(e,t)).next())});class U{constructor(e,t,n){this.paymentIntegrationService=e,this.paypalExpressScriptLoader=t,this.formPoster=n}initialize(e){return N(this,null,function*(){const t=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!e.paypal)throw new M;if(!t.config.merchantId)throw new s(a.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:c,onPaymentError:d,shouldProcessPayment:l,style:p}=r,u=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!u.config.merchantId)throw new s(a.MissingPaymentMethod);const h=u.config.merchantId,y=u.config.testMode?"sandbox":"production",m={[y]:c},g=t.FUNDING.CREDIT||"credit",b=o?[g]:[],I=o?[]:[g];return t.Button.render({env:y,client:m,commit:l,funding:{allowed:b,disallowed:I},style:this.getStyle(p),payment:(e,t)=>this.setupPayment(h,t,d),onAuthorize:(e,t)=>this.tokenizePayment(e,i,t,l)},n)}getStyle(e){const{color:t,fundingicons:n,label:i,layout:r,shape:a,size:s,tagline:o}=e||{};return{color:t,fundingicons:n,label:i,layout:r,shape:a||p.RECT,size:"small"===s?l.RESPONSIVE:s,tagline:o}}setupPayment(e,t,n){return N(this,null,function*(){if(!t)throw new c(o.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:x({"X-API-INTERNAL":"This API endpoint is for internal use only and may change in the future"},S)})).id}catch(e){throw n&&e instanceof r&&n(e),e}})}tokenizePayment(e,t,n,i){return N(this,null,function*(){if(!n)throw new c(o.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new s(a.MissingPayment);const r=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),d=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(d.payer.payer_info)})})}}const A=i(t=>new U(t,new P(e()),n()),[{id:"paypalexpress"}]);export{A as createPaypalExpressButtonStrategy,v as createPaypalExpressPaymentStrategy};
2
2
  //# sourceMappingURL=paypal-express.js.map
@@ -1,2 +1,2 @@
1
- import{createRequestSender as e}from"@bigcommerce/request-sender";var t=(e=>(e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json",e))(t||{});const r=t,n={"X-Checkout-SDK-Version":"1.980.0"};var a=Object.defineProperty,i=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,c=(e,t,r)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,d=(e,t)=>{for(var r in t||(t={}))s.call(t,r)&&c(e,r,t[r]);if(i)for(var r of i(t))o.call(t,r)&&c(e,r,t[r]);return e};class l{constructor(e){this._requestSender=e}saveExternalId(e,t){return a=this,i=function*(){const a=`/api/storefront/payment/${e}/save-external-id`,i={headers:d({Accept:r.JsonV1,"X-API-INTERNAL":"This API endpoint is for internal use only and may change in the future"},n),body:{externalId:t,provider:e}};yield this._requestSender.post(a,i)},new Promise((e,t)=>{var r=e=>{try{s(i.next(e))}catch(e){t(e)}},n=e=>{try{s(i.throw(e))}catch(e){t(e)}},s=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,n);s((i=i.apply(a,null)).next())});var a,i}}class u extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}class p extends u{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class y extends p{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"}}var g=(e=>(e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress",e))(g||{});class m extends u{constructor(e){super(function(e){switch(e){case 0:return"Unable to proceed because billing address data is unavailable.";case 1:return"Unable to proceed because cart data is unavailable.";case 3:return"Unable to proceed because consignments data is unavailable.";case 2:return"Unable to proceed because checkout data is unavailable.";case 4:return"Unable to proceed because customer data is unavailable.";case 5:case 7:return"Unable to proceed because configuration data is unavailable.";case 6:return"Unable to proceed because order data is unavailable.";case 8:return"Unable to proceed because order ID is unavailable or not generated yet.";case 9:return"Unable to proceed because payment data is unavailable.";case 15:return"Unable to proceed because the token required to submit a payment is missing.";case 12:return"Unable to proceed because payment method data is unavailable or not properly configured.";case 16:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}class h extends u{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}var b=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable;class M{constructor(e,t){this.paymentIntegrationService=e,this.storefrontPaymentRequestSender=t}initialize(){return Promise.resolve()}execute(e,t){return r=this,n=function*(){const r=e,{payment:n}=r,a=((e,t)=>{var r={};for(var n in e)v.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&b)for(var n of b(e))t.indexOf(n)<0&&f.call(e,n)&&(r[n]=e[n]);return r})(r,["payment"]);if(!n)throw new y(["payment"]);const{methodId:i}=n,{getPaymentMethodOrThrow:s}=yield this.paymentIntegrationService.loadPaymentMethod(i,t),{clientToken:o,initializationData:c}=s(i),d=null==c?void 0:c.redirectUrl;if(!o||!d)throw new m(g.MissingPaymentMethod);const{id:l}=JSON.parse(o);if(!l)throw new m(g.MissingPaymentToken);const{isStoreCreditApplied:u}=this.paymentIntegrationService.getState().getCheckoutOrThrow();yield this.paymentIntegrationService.applyStoreCredit(u),yield this.paymentIntegrationService.initializePayment(i,{useStoreCredit:u}),yield this.paymentIntegrationService.submitOrder(a,t),yield this._prepareForReferredRegistration(i,l);try{yield this.paymentIntegrationService.submitPayment({methodId:i,paymentData:{nonce:l}})}catch(e){if((e=>"object"==typeof e&&null!==e&&"body"in e)(e)&&"additional_action_required"===e.body.status)return new Promise(()=>window.location.replace(d));throw e}},new Promise((e,t)=>{var a=e=>{try{s(n.next(e))}catch(e){t(e)}},i=e=>{try{s(n.throw(e))}catch(e){t(e)}},s=t=>t.done?e(t.value):Promise.resolve(t.value).then(a,i);s((n=n.apply(r,null)).next())});var r,n}finalize(){return Promise.reject(new h)}deinitialize(){return Promise.resolve()}_prepareForReferredRegistration(e,t){return this.storefrontPaymentRequestSender.saveExternalId(e,t)}}const P=(w=t=>{const{getHost:r}=t.getState(),n=e({host:r()}),a=new l(n);return new M(t,a)},O=[{id:"zip"},{id:"quadpay"}],Object.assign(w,{resolveIds:O}));var w,O;export{P as createZipPaymentStrategy};
1
+ import{createRequestSender as e}from"@bigcommerce/request-sender";var t=(e=>(e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json",e))(t||{});const r=t,n={"X-Checkout-SDK-Version":"1.981.0"};var a=Object.defineProperty,i=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,c=(e,t,r)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,d=(e,t)=>{for(var r in t||(t={}))s.call(t,r)&&c(e,r,t[r]);if(i)for(var r of i(t))o.call(t,r)&&c(e,r,t[r]);return e};class l{constructor(e){this._requestSender=e}saveExternalId(e,t){return a=this,i=function*(){const a=`/api/storefront/payment/${e}/save-external-id`,i={headers:d({Accept:r.JsonV1,"X-API-INTERNAL":"This API endpoint is for internal use only and may change in the future"},n),body:{externalId:t,provider:e}};yield this._requestSender.post(a,i)},new Promise((e,t)=>{var r=e=>{try{s(i.next(e))}catch(e){t(e)}},n=e=>{try{s(i.throw(e))}catch(e){t(e)}},s=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,n);s((i=i.apply(a,null)).next())});var a,i}}class u extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}class p extends u{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class y extends p{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"}}var g=(e=>(e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress",e))(g||{});class m extends u{constructor(e){super(function(e){switch(e){case 0:return"Unable to proceed because billing address data is unavailable.";case 1:return"Unable to proceed because cart data is unavailable.";case 3:return"Unable to proceed because consignments data is unavailable.";case 2:return"Unable to proceed because checkout data is unavailable.";case 4:return"Unable to proceed because customer data is unavailable.";case 5:case 7:return"Unable to proceed because configuration data is unavailable.";case 6:return"Unable to proceed because order data is unavailable.";case 8:return"Unable to proceed because order ID is unavailable or not generated yet.";case 9:return"Unable to proceed because payment data is unavailable.";case 15:return"Unable to proceed because the token required to submit a payment is missing.";case 12:return"Unable to proceed because payment method data is unavailable or not properly configured.";case 16:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}class h extends u{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}var b=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable;class M{constructor(e,t){this.paymentIntegrationService=e,this.storefrontPaymentRequestSender=t}initialize(){return Promise.resolve()}execute(e,t){return r=this,n=function*(){const r=e,{payment:n}=r,a=((e,t)=>{var r={};for(var n in e)v.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&b)for(var n of b(e))t.indexOf(n)<0&&f.call(e,n)&&(r[n]=e[n]);return r})(r,["payment"]);if(!n)throw new y(["payment"]);const{methodId:i}=n,{getPaymentMethodOrThrow:s}=yield this.paymentIntegrationService.loadPaymentMethod(i,t),{clientToken:o,initializationData:c}=s(i),d=null==c?void 0:c.redirectUrl;if(!o||!d)throw new m(g.MissingPaymentMethod);const{id:l}=JSON.parse(o);if(!l)throw new m(g.MissingPaymentToken);const{isStoreCreditApplied:u}=this.paymentIntegrationService.getState().getCheckoutOrThrow();yield this.paymentIntegrationService.applyStoreCredit(u),yield this.paymentIntegrationService.initializePayment(i,{useStoreCredit:u}),yield this.paymentIntegrationService.submitOrder(a,t),yield this._prepareForReferredRegistration(i,l);try{yield this.paymentIntegrationService.submitPayment({methodId:i,paymentData:{nonce:l}})}catch(e){if((e=>"object"==typeof e&&null!==e&&"body"in e)(e)&&"additional_action_required"===e.body.status)return new Promise(()=>window.location.replace(d));throw e}},new Promise((e,t)=>{var a=e=>{try{s(n.next(e))}catch(e){t(e)}},i=e=>{try{s(n.throw(e))}catch(e){t(e)}},s=t=>t.done?e(t.value):Promise.resolve(t.value).then(a,i);s((n=n.apply(r,null)).next())});var r,n}finalize(){return Promise.reject(new h)}deinitialize(){return Promise.resolve()}_prepareForReferredRegistration(e,t){return this.storefrontPaymentRequestSender.saveExternalId(e,t)}}const P=(w=t=>{const{getHost:r}=t.getState(),n=e({host:r()}),a=new l(n);return new M(t,a)},O=[{id:"zip"},{id:"quadpay"}],Object.assign(w,{resolveIds:O}));var w,O;export{P as createZipPaymentStrategy};
2
2
  //# sourceMappingURL=zip.js.map
@@ -1,2 +1,2 @@
1
- import{createRequestSender as e}from"@bigcommerce/request-sender";import{isEmpty as t,isNil as n,omitBy as r,uniqueId as i}from"lodash";import{getScriptLoader as a}from"@bigcommerce/script-loader";import{supportsPopups as o}from"@braintree/browser-detection";const s={d:(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var r=t[n++],i=t[n++];s.o(e,r)?0===i&&n++:0===i?Object.defineProperty(e,r,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,r,{enumerable:!0,get:i})}else for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};var l={};s.r(l),s.d(l,{createBigCommercePaymentsPayLaterWalletStrategy:()=>Oe,createBigCommercePaymentsWalletStrategy:()=>ve,createBraintreePaypalCreditWalletStrategy:()=>Pt,createBraintreePaypalWalletStrategy:()=>mt,createBraintreeVenmoWalletStrategy:()=>St,createPayPalCommerceCreditWalletStrategy:()=>Vt,createPayPalCommerceVenmoWalletStrategy:()=>on,createPayPalCommerceWalletStrategy:()=>Ut});var c=Object.defineProperty,d=Object.defineProperties,u=Object.getOwnPropertyDescriptors,y=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,m=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,M=(e,t)=>{for(var n in t||(t={}))h.call(t,n)&&m(e,n,t[n]);if(y)for(var n of y(t))p.call(t,n)&&m(e,n,t[n]);return e},g=(e,t)=>d(e,u(t)),w=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class _{constructor(e){this.requestSender=e}updateBillingAddress(e,t,n,r){return w(this,null,function*(){const i=n,{id:a}=i,o=((e,t)=>{var n={};for(var r in e)h.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&y)for(var r of y(e))t.indexOf(r)<0&&p.call(e,r)&&(n[r]=e[r]);return n})(i,["id"]),s={headers:g(M({},null==r?void 0:r.headers),{"Content-Type":"application/json","x-catalyst-graphql-proxy-requester":"checkout-sdk-js"}),body:{query:"\n mutation UpdateCheckoutBillingAddressMutation(\n $input: UpdateCheckoutBillingAddressInput!\n ) {\n checkout {\n updateCheckoutBillingAddress(input: $input) {\n checkout {\n billingAddress {\n address1\n address2\n city\n company\n countryCode\n email\n entityId\n firstName\n lastName\n phone\n postalCode\n stateOrProvince\n stateOrProvinceCode\n }\n }\n }\n }\n }\n ",variables:{input:{checkoutEntityId:t,addressEntityId:n.id,data:{address:M({},o)}}}}},l=yield this.requestSender.post(`${window.location.origin}/${e}`,s),{billingAddress:c}=l.body.data.checkout.updateCheckoutBillingAddress.checkout;return g(M({},l),{body:c})})}addBillingAddress(e,t,n,r){return w(this,null,function*(){const i={headers:g(M({},null==r?void 0:r.headers),{"Content-Type":"application/json","x-catalyst-graphql-proxy-requester":"checkout-sdk-js"}),body:{query:"\n mutation AddCheckoutBillingAddressMutation(\n $input: AddCheckoutBillingAddressInput!\n ) {\n checkout {\n addCheckoutBillingAddress(input: $input) {\n checkout {\n billingAddress {\n address1\n address2\n city\n company\n countryCode\n email\n entityId\n firstName\n lastName\n phone\n postalCode\n stateOrProvince\n stateOrProvinceCode\n }\n }\n }\n }\n }\n ",variables:{input:{checkoutEntityId:t,data:{address:M({},n)}}}}},a=yield this.requestSender.post(`${window.location.origin}/${e}`,i),{billingAddress:o}=a.body.data.checkout.addCheckoutBillingAddress.checkout;return g(M({},a),{body:o})})}}class C extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}class b extends C{constructor(e){super(e||"An unexpected error has occurred during checkout redirection process. Please try again later."),this.name="CheckoutRedirectError",this.type="checkout_redirect_error"}}var f=Object.defineProperty,I=Object.defineProperties,N=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,P=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable,D=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,T=(e,t)=>{for(var n in t||(t={}))P.call(t,n)&&D(e,n,t[n]);if(v)for(var n of v(t))z.call(t,n)&&D(e,n,t[n]);return e},L=(e,t)=>I(e,N(t));class S{constructor(e){this.requestSender=e}getRedirectToCheckoutUrl(e,t,n){return r=this,i=function*(){var r;const i={headers:L(T({},null==n?void 0:n.headers),{"Content-Type":"application/json","x-catalyst-graphql-proxy-requester":"checkout-sdk-js"}),body:{query:"\n mutation CheckoutRedirectMutation($input: CreateCartRedirectUrlsInput!) {\n cart {\n createCartRedirectUrls(input: $input) {\n errors {\n __typename\n ... on NotFoundError {\n message \n }\n ... on CreateRedirectUrlsCurrencyNotAllowed {\n message\n }\n }\n redirectUrls {\n externalCheckoutUrl\n }\n }\n }\n }\n ",variables:{input:t}}};try{const t=yield this.requestSender.post(`${window.location.origin}/${e}`,i),{data:{cart:{createCartRedirectUrls:n}}}=t.body,a=null==(r=n.errors[0])?void 0:r.message;if(a)throw new b(a);if(n.errors.length>0)throw new b;return L(T({},t),{body:{redirectUrls:n.redirectUrls}})}catch(e){if(e instanceof Error)throw e;throw new Error("Checkout redirection failed")}},new Promise((e,t)=>{var n=e=>{try{o(i.next(e))}catch(e){t(e)}},a=e=>{try{o(i.throw(e))}catch(e){t(e)}},o=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,a);o((i=i.apply(r,null)).next())});var r,i}}class j extends C{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}class O extends C{constructor(e){super(e||"An unexpected error has occurred during payment order creation process. Please try again later."),this.name="PaymentOrderCreationError",this.type="payment_order_creation_error"}}var A=Object.defineProperty,k=Object.defineProperties,E=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,B=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,G=(e,t,n)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,W=(e,t)=>{for(var n in t||(t={}))B.call(t,n)&&G(e,n,t[n]);if(x)for(var n of x(t))U.call(t,n)&&G(e,n,t[n]);return e},Y=(e,t)=>k(e,E(t));class F{constructor(e){this.requestSender=e}createPaymentOrderIntent(e,t,n="PayPalCommercePaymentWalletIntentData",r){return i=this,a=function*(){var i;const a=`\n mutation CreatePaymentWalletIntentMutation(\n $input: CreatePaymentWalletIntentInput!\n ) {\n payment {\n paymentWallet {\n createPaymentWalletIntent(input: $input) {\n paymentWalletIntentData {\n __typename\n ... on ${n} {\n orderId\n approvalUrl\n initializationEntityId\n }\n }\n errors {\n __typename\n ... on CreatePaymentWalletIntentGenericError {\n message\n }\n ... on Error {\n message\n }\n }\n }\n }\n }\n }\n `,o={headers:Y(W({},null==r?void 0:r.headers),{"Content-Type":"application/json","x-catalyst-graphql-proxy-requester":"checkout-sdk-js"}),body:{query:a,variables:{input:t}}};try{const t=yield this.requestSender.post(`${window.location.origin}/${e}`,o),{data:{payment:{paymentWallet:{createPaymentWalletIntent:{paymentWalletIntentData:n,errors:r}}}}}=t.body,a=null==(i=r[0])?void 0:i.message;if(a)throw new O(a);return Y(W({},t),{body:W({},n)})}catch(e){if(!(e instanceof O))throw new j;throw e}},new Promise((e,t)=>{var n=e=>{try{o(a.next(e))}catch(e){t(e)}},r=e=>{try{o(a.throw(e))}catch(e){t(e)}},o=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,r);o((a=a.apply(i,null)).next())});var i,a}}var H=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class Q{constructor(e,t,n,r){this.graphQLEndpoint=e,this.billingAddressRequestSender=t,this.paymentRequestSender=n,this.checkoutRequestSender=r}addBillingAddress(e,t,n){return H(this,null,function*(){return this.billingAddressRequestSender.addBillingAddress(this.graphQLEndpoint,e,t,n)})}updateBillingAddress(e,t,n){return H(this,null,function*(){return this.billingAddressRequestSender.updateBillingAddress(this.graphQLEndpoint,e,t,n)})}createPaymentOrderIntent(e,t,n){return H(this,null,function*(){return this.paymentRequestSender.createPaymentOrderIntent(this.graphQLEndpoint,e,t,n)})}getRedirectToCheckoutUrl(e,t){return H(this,null,function*(){return this.checkoutRequestSender.getRedirectToCheckoutUrl(this.graphQLEndpoint,e,t)})}}function R(e,t){return Object.assign(e,{resolveIds:t})}class V extends C{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 Z=(e=>(e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress",e))(Z||{});class K extends C{constructor(e){super(function(e){switch(e){case 0:return"Unable to proceed because billing address data is unavailable.";case 1:return"Unable to proceed because cart data is unavailable.";case 3:return"Unable to proceed because consignments data is unavailable.";case 2:return"Unable to proceed because checkout data is unavailable.";case 4:return"Unable to proceed because customer data is unavailable.";case 5:case 7:return"Unable to proceed because configuration data is unavailable.";case 6:return"Unable to proceed because order data is unavailable.";case 8:return"Unable to proceed because order ID is unavailable or not generated yet.";case 9:return"Unable to proceed because payment data is unavailable.";case 15:return"Unable to proceed because the token required to submit a payment is missing.";case 12:return"Unable to proceed because payment method data is unavailable or not properly configured.";case 16:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}var J=(e=>(e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment",e))(J||{}),q=(e=>(e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white",e))(q||{}),X=(e=>(e.pill="pill",e.rect="rect",e))(X||{}),$=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class ee{constructor(e,t,n="PayPalCommercePaymentWalletIntentData"){this.walletButtonIntegrationService=e,this.scriptLoader=t,this.intentTypename=n}loadPayPalSdk(e,t,n,r){return $(this,null,function*(){return this.paypalSdk=yield this.scriptLoader.getPayPalSDK(e,t,void 0,n,r),this.paypalSdk})}getPayPalSdkOrThrow(){if(!this.paypalSdk)throw new V;return this.paypalSdk}proxyTokenizationPayment(e,t,n,r){return $(this,null,function*(){var i;if(!r)throw new K(Z.MissingOrderId);const a={paymentWalletData:{providerId:t,providerOrderId:r},cartEntityId:e,queryParams:[{key:"payment_type",value:"paypal"},{key:"action",value:"set_external_checkout"},{key:"provider",value:n},{key:"order_id",value:r}]},o=yield this.walletButtonIntegrationService.getRedirectToCheckoutUrl(a);if(!(null==(i=o.body.redirectUrls)?void 0:i.externalCheckoutUrl))throw new Error("Failed to redirection to checkout page");window.location.assign(o.body.redirectUrls.externalCheckoutUrl)})}createPaymentOrderIntent(e,t,n){return $(this,null,function*(){const r={cartEntityId:t,paymentWalletEntityId:e};return(yield this.walletButtonIntegrationService.createPaymentOrderIntent(r,this.intentTypename,n)).body.orderId})}addBillingAddress(e,t,n){return $(this,null,function*(){return this.walletButtonIntegrationService.addBillingAddress(e,t,n)})}mapOrderDetailsToBillingAddress({payer:e}){var t,n,r,i;return{firstName:e.name.given_name,lastName:e.name.surname,company:"",address1:e.address.address_line_1,address2:e.address.address_line_2,city:e.address.admin_area_2,email:e.email_address,stateOrProvince:null!=(t=e.address.admin_area_1)?t:"",stateOrProvinceCode:null!=(n=e.address.admin_area_1)?n:"",countryCode:e.address.country_code,postalCode:e.address.postal_code,phone:null!=(i=null==(r=e.phone)?void 0:r.phone_number.national_number)?i:"",shouldSaveAddress:!1}}getValidButtonStyle(e={}){const{color:t,height:i,label:a,shape:o}=e,s={color:t&&q[t]?t:void 0,height:this.getValidHeight(i),label:a&&J[a]?a:void 0,shape:o&&X[o]?o:void 0};return r(s,n)}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 te=(e=>(e.PayPal="paypal",e.BigCommercePaymentsPayPalSDK="bigCommercePaymentsPayPalSDK",e.PayPalFastlaneSdk="paypalFastlaneSdk",e.PayPalFastlane="paypalFastlane",e.PayPalGooglePay="paypalGooglePay",e.PayPalApms="paypalApms",e.PayPalMessages="paypalMessages",e))(te||{});const ne=["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 re(e){return window[e]}function ie(e){if(!e)return;let t;if(e.includes("-")){const[n,r]=e.split("-");t=`${n}_${r.toUpperCase()}`}else t=`${e}_${e.toUpperCase()}`;return ne.includes(t)?t:void 0}var ae=Object.defineProperty,oe=Object.defineProperties,se=Object.getOwnPropertyDescriptors,le=Object.getOwnPropertySymbols,ce=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,ue=(e,t,n)=>t in e?ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ye=(e,t)=>{for(var n in t||(t={}))ce.call(t,n)&&ue(e,n,t[n]);if(le)for(var n of le(t))de.call(t,n)&&ue(e,n,t[n]);return e},he=(e,t)=>oe(e,se(t)),pe=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class me{constructor(e){this.scriptLoader=e,this.window=window}getPayPalSDK(e,t,n,r,i){return pe(this,null,function*(){const a=this.isBigCommercePaymentsMethod(e.id)?te.BigCommercePaymentsPayPalSDK:te.PayPal;if(!re(a)||i){const i=this.getPayPalSdkScriptConfigOrThrow(e,t,n,r);yield this.loadPayPalSdk(i)}const o=re(a);if(!o)throw new V;return o})}getPayPalFastlaneSdk(e,t,n,r){return pe(this,null,function*(){if(!this.window.paypalFastlaneSdk){const i=this.getPayPalFastlaneSdkConfiguration(e,t,n,r);if(yield this.loadPayPalSdk(i),!this.window.paypalFastlaneSdk)throw new V}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,r,i){return pe(this,null,function*(){if(!this.window.paypalGooglePay||i){const i=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,r);yield this.loadPayPalSdk(i)}if(!this.window.paypalGooglePay)throw new V;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t,n){return pe(this,null,function*(){if(!this.window.paypalApms){const r=this.getPayPalApmSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(r),!this.window.paypalApms)throw new V}return this.window.paypalApms})}getPayPalMessages(e,t,n){return pe(this,null,function*(){if(!this.window.paypalMessages){const r=this.getPayPalSdkMessagesConfiguration(e,t,n);yield this.loadPayPalSdk(r)}if(!this.window.paypalMessages)throw new V;return this.window.paypalMessages})}isBigCommercePaymentsMethod(e){return e.startsWith("bigcommerce_payments")}loadPayPalSdk(e){return pe(this,arguments,function*({options:e,attributes:t}){const n=this.transformConfig(e),r=this.transformConfig(t),i=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(i,{async:!0,attributes:r})})}getPayPalSdkScriptConfigOrThrow(e,t,n,r=!0){const{id:i,clientToken:a,initializationData:o}=e;if(!o||!o.clientId)throw new K(Z.MissingPaymentMethod);const{intent:s,clientId:l,merchantId:c,buyerCountry:d,attributionId:u,isVenmoEnabled:y,isHostedCheckoutEnabled:h,isPayPalCreditAvailable:p,isDeveloperModeApplicable:m,availableAlternativePaymentMethods:M=[],enabledAlternativePaymentMethods:g=[],isGooglePayEnabled:w}=o,_=h||r,C="paypalcommercecreditcards"===i||"bigcommerce_payments_creditcards"===i,b=C?["card"]:[],f=C?[]:["card"],I=p?["credit","paylater"]:[],N=p?[]:["credit","paylater"],v=y?["venmo"]:[],P=y?[]:["venmo"],z=M.filter(e=>!g.includes(e)),D=w?["googlepay"]:[],T=r?["card-fields"]:[],L=this.filterFundingOptions([...f,...N,...P,...z]),S=this.filterFundingOptions([...b,...I,...v,...g]),j=ie(n);return{options:ye(ye({"client-id":l,"merchant-id":c,"enable-funding":S.length>0?S:void 0,"disable-funding":L.length>0?L:void 0,commit:_,components:["buttons","hosted-fields","payment-fields","legal",...D,...T],currency:t,intent:s},m&&{"buyer-country":d}),j&&{locale:j}),attributes:ye({"data-partner-attribution-id":u,"data-client-token":a},this.isBigCommercePaymentsMethod(i)&&{"data-namespace":te.BigCommercePaymentsPayPalSDK})}}getPayPalFastlaneSdkConfiguration(e,t,n,r){const{clientToken:i,initializationData:a}=e;if(!a||!a.clientId)throw new K(Z.MissingPaymentMethod);const{intent:o,clientId:s,merchantId:l,attributionId:c}=a,d=ie(r);return{options:he(ye({"client-id":s,"merchant-id":l,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t},d&&{locale:d}),{intent:o}),attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":te.PayPalFastlaneSdk,"data-partner-attribution-id":c,"data-sdk-client-token":i}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,r=!0){const{clientToken:i,initializationData:a}=e;if(!a||!a.clientId)throw new K(Z.MissingPaymentMethod);const{intent:o,clientId:s,merchantId:l,buyerCountry:c,attributionId:d,isHostedCheckoutEnabled:u,isDeveloperModeApplicable:y}=a,h=u||r,p=ie(n);return{options:ye(ye({"client-id":s,"merchant-id":l,commit:h,components:["googlepay"],currency:t,intent:o},y&&{"buyer-country":c}),p&&{locale:p}),attributes:{"data-partner-attribution-id":d,"data-client-token":i,"data-namespace":te.PayPalGooglePay}}}getPayPalApmSdkConfiguration(e,t,n){const{initializationData:r}=e;if(!r||!r.clientId)throw new K(Z.MissingPaymentMethod);const{intent:i,clientId:a,merchantId:o,buyerCountry:s,attributionId:l,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:d=[],enabledAlternativePaymentMethods:u=[]}=r,y=this.filterFundingOptions(u),h=this.filterFundingOptions(d.filter(e=>!u.includes(e))),p=ie(n);return{options:ye(ye({"client-id":a,"merchant-id":o,"enable-funding":y.length>0?y:void 0,"disable-funding":h.length>0?h:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:i},c&&{"buyer-country":s}),p&&{locale:p}),attributes:{"data-partner-attribution-id":l,"data-namespace":te.PayPalApms}}}getPayPalSdkMessagesConfiguration(e,t,n){const{initializationData:r}=e;if(!r||!r.clientId)throw new K(Z.MissingPaymentMethod);const{clientId:i,merchantId:a,attributionId:o,isDeveloperModeApplicable:s,buyerCountry:l}=r,c=ie(n);return{options:ye(ye({"client-id":i,"merchant-id":a,components:["messages"],currency:t},s&&{"buyer-country":l}),c&&{locale:c}),attributes:{"data-namespace":te.PayPalMessages,"data-partner-attribution-id":o}}}filterFundingOptions(e){const t=["klarna","afterpay"];return e?e.filter(e=>!t.includes(e)):[]}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const r=e[n];null==r||""===r||Array.isArray(r)&&0===r.length||(t=he(ye({},t),{[n]:Array.isArray(r)?r.join(","):r}))}),t}}function Me(){return new me(a())}class ge extends C{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}var we=Object.defineProperty,_e=Object.getOwnPropertySymbols,Ce=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable,fe=(e,t,n)=>t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ie=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class Ne{constructor(e){this.bigCommercePaymentsWalletService=e}initialize(e){return Ie(this,null,function*(){var t,n;const{bigcommerce_paymentspaypal:r,containerId:i,methodId:a}=e;if(!a)throw new ge('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new ge('Unable to initialize payment because "options.containerId" argument is not provided.');if(!r)throw new ge('Unable to initialize payment because "options.bigcommerce_paymentspaypal" argument is not provided.');let o;try{o=JSON.parse(atob(r.initializationData))}catch(e){throw new ge("Failed to parse payment method 'initializationData'.")}const s=null==(n=null==(t=o.initializationData)?void 0:t.paymentButtonStyles)?void 0:n.cartButtonStyles;yield this.bigCommercePaymentsWalletService.loadPayPalSdk(o,r.currency.code,!1),this.renderButton(i,"bigcommerce_payments.paypal",r.cartId,s)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n,r){const i=this.bigCommercePaymentsWalletService.getPayPalSdkOrThrow(),a={createOrder:()=>this.bigCommercePaymentsWalletService.createPaymentOrderIntent(t,n),onApprove:(e,r)=>Ie(this,[e,r],function*({orderID:e},r){const i=yield r.order.get(),a=this.bigCommercePaymentsWalletService.mapOrderDetailsToBillingAddress(i);yield this.bigCommercePaymentsWalletService.addBillingAddress(n,a),yield this.bigCommercePaymentsWalletService.proxyTokenizationPayment(n,t,"bigcommerce_payments",e)})},o=((e,t)=>{for(var n in t||(t={}))Ce.call(t,n)&&fe(e,n,t[n]);if(_e)for(var n of _e(t))be.call(t,n)&&fe(e,n,t[n]);return e})({fundingSource:i.FUNDING.PAYPAL,style:this.bigCommercePaymentsWalletService.getValidButtonStyle(r)},a),s=i.Buttons(o);s.isEligible()?s.render(`#${e}`):this.bigCommercePaymentsWalletService.removeElement(e)}}const ve=R(e=>new Ne(new ee(e,Me(),"BigcommercePaymentWalletIntentData")),[{id:"bigcommerce_paymentspaypal"}]);var Pe=Object.defineProperty,ze=Object.getOwnPropertySymbols,De=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable,Le=(e,t,n)=>t in e?Pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Se=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class je{constructor(e){this.bigCommercePaymentsPayLaterWalletService=e}initialize(e){return Se(this,null,function*(){var t,n;const{bigcommerce_paymentspaypalcredit:r,containerId:i,methodId:a}=e;if(!a)throw new ge('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new ge('Unable to initialize payment because "options.containerId" argument is not provided.');if(!r)throw new ge('Unable to initialize payment because "options.bigcommerce_paymentspaypalcredit" argument is not provided.');let o;try{o=JSON.parse(atob(r.initializationData))}catch(e){throw new ge("Failed to parse payment method 'initializationData'.")}const s=null==(n=null==(t=o.initializationData)?void 0:t.paymentButtonStyles)?void 0:n.cartButtonStyles;yield this.bigCommercePaymentsPayLaterWalletService.loadPayPalSdk(o,r.currency.code,!1),this.renderButton(i,"bigcommerce_payments.paypalcredit",r.cartId,s)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n,r){const i=this.bigCommercePaymentsPayLaterWalletService.getPayPalSdkOrThrow(),a=[i.FUNDING.PAYLATER,i.FUNDING.CREDIT],o={createOrder:()=>this.bigCommercePaymentsPayLaterWalletService.createPaymentOrderIntent(t,n),onApprove:(e,r)=>Se(this,[e,r],function*({orderID:e},r){const i=yield r.order.get(),a=this.bigCommercePaymentsPayLaterWalletService.mapOrderDetailsToBillingAddress(i);yield this.bigCommercePaymentsPayLaterWalletService.addBillingAddress(n,a),yield this.bigCommercePaymentsPayLaterWalletService.proxyTokenizationPayment(n,t,"bigcommerce_payments_paylater",e)})};let s=!1;a.forEach(t=>{if(!s){const n=((e,t)=>{for(var n in t||(t={}))De.call(t,n)&&Le(e,n,t[n]);if(ze)for(var n of ze(t))Te.call(t,n)&&Le(e,n,t[n]);return e})({fundingSource:t,style:this.bigCommercePaymentsPayLaterWalletService.getValidButtonStyle(r)},o),a=i.Buttons(n);a.isEligible()&&(a.render(`#${e}`),s=!0)}}),s||this.bigCommercePaymentsPayLaterWalletService.removeElement(e)}}const Oe=R(e=>new je(new ee(e,Me(),"BigcommercePaymentWalletIntentData")),[{id:"bigcommerce_paymentspaypalcredit"}]);class Ae extends C{constructor(e){super(e||"Unsupported browser error"),this.name="UnsupportedBrowserError",this.type="unsupported_browser"}}class ke extends ge{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 Ee extends C{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"}}var xe=(e=>(e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized",e))(xe||{});class Be extends C{constructor(e){super(function(e){switch(e){case 1:return"Unable to proceed because the customer step of checkout has not been initialized.";case 2:return"Unable to proceed because the payment step of checkout has not been initialized.";case 3:return"Unable to proceed because the shipping step of checkout has not been initialized.";case 4:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}let Ue=null;const Ge=["buttons","messages"];var We=(e=>(e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white",e))(We||{}),Ye=(e=>(e.Sandbox="sandbox",e.Production="production",e))(Ye||{}),Fe=(e=>(e.Client="client",e.DataCollector="dataCollector",e.Fastlane="fastlane",e.GooglePayment="googlePayment",e.HostedFields="hostedFields",e.LocalPayment="localPayment",e.Paypal="paypal",e.PaypalCheckout="paypalCheckout",e.ThreeDSecure="threeDSecure",e.UsBankAccount="usBankAccount",e.Venmo="venmo",e.VisaCheckout="visaCheckout",e))(Fe||{});function He(e){return Boolean("object"==typeof e&&null!==e&&("type"in e||"message"in e||"code"in e))}var Qe=Object.defineProperty,Re=Object.defineProperties,Ve=Object.getOwnPropertyDescriptors,Ze=Object.getOwnPropertySymbols,Ke=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,qe=(e,t,n)=>t in e?Qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xe=(e,t)=>{for(var n in t||(t={}))Ke.call(t,n)&&qe(e,n,t[n]);if(Ze)for(var n of Ze(t))Je.call(t,n)&&qe(e,n,t[n]);return e},$e=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class et{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 $e(this,null,function*(){if(t&&(window.localStorage.setItem("axoEnv","sandbox"),window.localStorage.setItem("fastlaneEnv","sandbox")),!this.braintreeHostWindow.braintreeFastlane){const t=this.getClientTokenOrThrow(),r=yield this.getClient(),i=yield this.getSessionId(e),a=yield this.braintreeScriptLoader.loadFastlane(),o={root:{backgroundColorPrimary:"transparent"}};this.braintreeHostWindow.braintreeFastlane=yield a.create({authorization:t,client:r,deviceData:i,styles:n||o})}return this.braintreeHostWindow.braintreeFastlane})}getClient(){return $e(this,null,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 t=e,{shouldSaveInstrument:n}=t,r=((e,t)=>{var n={};for(var r in e)Ke.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&Ze)for(var r of Ze(e))t.indexOf(r)<0&&Je.call(e,r)&&(n[r]=e[r]);return n})(t,["shouldSaveInstrument"]);const i=o();return this.getPaypal().then(e=>{var t;return i&&(null==(t=this.overlay)||t.show({onClick:()=>e.focusWindow()})),e.tokenize(Xe({enableShippingAddress:!0,flow:n?"vault":"checkout",useraction:"commit"},r))}).then(e=>{var t;return null==(t=this.overlay)||t.remove(),e}).catch(e=>{var t;throw null==(t=this.overlay)||t.remove(),e})}getPaypalCheckout(e,t,n){return $e(this,null,function*(){const r=yield this.getClient(),i=yield this.braintreeScriptLoader.loadPaypalCheckout(),a={client:r};return this.paypalCheckout=yield i.create(a,(r,i)=>{var a;if(r)return n(r);const o=(s=Xe({currency:e.currency},e.isCreditEnabled&&{"enable-funding":"paylater"}),l={components:Ge.toString(),intent:e.intent,commit:null==(a=e.commit)||a},Re(s,Ve(l)));var s,l;this.braintreeHostWindow.paypal?t(i):function(e,t){return Ue||(Ue=new Promise((n,r)=>{e.loadPayPalSDK(t,t=>{t?(Ue=null,r(t)):n(e)})})),Ue}(i,o).then(()=>t(i))}),this.paypalCheckout})}getDataCollector(e){return $e(this,null,function*(){const t=(null==e?void 0:e.paypal)?"paypal":"default";let n=this.dataCollectors[t];if(!n){try{const t=yield this.getClient(),r=yield this.braintreeScriptLoader.loadDataCollector(),i=Xe({client:t,kount:!0},e);n=yield r.create(i)}catch(e){if(!He(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?Ye.Sandbox:Ye.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:r}=e,i=(null==r?void 0:r.recipientName)||"",[a,o]=i.split(" ");return{email:t,first_name:a||"",last_name:o||"",phone_number:n,address_line_1:null==r?void 0:r.line1,address_line_2:null==r?void 0:r.line2,city:null==r?void 0:r.city,state:null==r?void 0:r.state,country_code:null==r?void 0:r.countryCode,postal_code:null==r?void 0:r.postalCode}}mapToLegacyBillingAddress(e){const{billingAddress:t,email:n,firstName:r,lastName:i,phone:a,shippingAddress:o}=e,s=t||o;return{email:n,first_name:r,last_name:i,phone_number:a,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 $e(this,null,function*(){const{deviceData:t}=yield this.getDataCollector({riskCorrelationId:e});return t})}teardown(){return $e(this,null,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 $e(this,null,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 $e(this,null,function*(){if(!this.venmoCheckout){const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadVenmoCheckout(),r=Xe({client:t,allowDesktop:!0,paymentMethodUsage:"multi_use"},e||{});this.venmoCheckout=yield new Promise((e,t)=>{n.create(r,(n,r)=>n?t(n):r.isBrowserSupported()?void e(r):t(new Ae))})}return this.venmoCheckout})}verifyCard(e,t,n){return $e(this,null,function*(){const r=yield this.tokenizeCard(e,t);return this.challenge3DSVerification(r,n)})}tokenizeCard(e,n){return $e(this,null,function*(){const{paymentData:r}=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}(r))throw new ke(["payment.paymentData"]);const i=this.getErrorsRequiredFields(r);if(!t(i))throw new Ee(i);const a=this.mapToCreditCard(r,n),o=yield this.getClient(),{creditCards:s}=yield o.request(a);return{nonce:s[0].nonce,bin:s[0].details.bin}})}challenge3DSVerification(e,t){return $e(this,null,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 Be(xe.PaymentNotInitialized);return this.clientToken}getErrorsRequiredFields(e){const{ccNumber:t,ccExpiry:n}=e,r={};return t||(r.ccNumber=[{message:"Credit card number is required",type:"required"}]),n||(r.ccExpiry=[{message:"Expiration date is required",type:"required"}]),r}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:r,bin:i}=n;if(!r)throw new Be(xe.PaymentNotInitialized);const{challengeRequested:a=!0,additionalInformation:o}=this.threeDSecureOptions||{},s=t.toFixed(2);return e.verifyCard({amount:Number(s),bin:i,challengeRequested:a,nonce:r,onLookupComplete:(e,t)=>{t()},collectDeviceData:!0,additionalInformation:o})}}const tt="3.128.0",nt="3.123.2",rt="3.106.0",it={[rt]:{[Fe.Client]:"sha384-26BXDNnJI23JYRyFBj4xe4sVNrUSSiSSu11kxVXNM/vEPONm4LuL00w6ZaTgQewt",[Fe.PaypalCheckout]:"sha384-B+vzbZwnQtzWBthpkT4TXKUibO65tyeK7eCxSvpblgprTep2+IAXB2Cxxjrn710O",[Fe.Paypal]:"sha384-uyAGL1/3+XJAHnGoNy4eCoXdzJ4f7Ilzp+6w9PNnEjs6DCCz9WMyJjMN1gzc78U+",[Fe.LocalPayment]:"sha384-LIvOEMkIVEwVuYBdVOQc1AC5YbGGlwyfUheS0ACK218D2STuVYQlZ4FyEPowAEfT",[Fe.DataCollector]:"sha384-1bo9JDz+Kscthc085cCKWur8CLwUoBpoNyxsDi7932mCl0zFq3A5mv+FQLw9GHpV",[Fe.UsBankAccount]:"sha384-xmHBVaU+w74V+OebD3AaPONFxHUGMf+QRs8G/JxVPXNNP7MDa2jL0ICWHIe2tTfJ",[Fe.GooglePayment]:"sha384-WKDJl8mqoP82qZpMGH6AbZxnvXnSW8ILV4M64CyMLiugGMwu7LyP89wjCkHqsiBe",[Fe.ThreeDSecure]:"sha384-VQUlpGHzsGvs5XeiGFip7EXRsvoHWEXDVmgCacfbyieZI9mdBOqq3NSoyo28OCOB",[Fe.VisaCheckout]:"sha384-yx7mADfzTN0T43Q6rlH49LIg1EJ0iUZgBp/EczX9LXsUGkySgxrD+nWHQRBkyfoT",[Fe.Venmo]:"sha384-QX4rPjoj1ZDhuG0aSyKs56lEKDqTMTcjYxUHY1SzO5VZDsqIE2NTkqot7KNSCyov",[Fe.HostedFields]:"sha384-VvYBACfSu0Cr/J32uKmxG7AXcNOJE1AzIIL3kbikyS7YKp5fz5Is+NzNP/lyauNy",[Fe.Fastlane]:"sha384-9oGsZMRZwpGtDEDYa/dFt76dECqj1xAni9gIKgc3KfMIiRnR73nEeeUDLiBzxhFa"},[nt]:{[Fe.Client]:"sha384-o+nbQGcwNNxIBeXeu3+XmbSq+Cg8R3EN3N0l5hXCgMMU2RGY0t1z0LroSEIAbfAO",[Fe.PaypalCheckout]:"sha384-WrfbWPBS4mH86GAoycPSgiH8hQ8KH7A67C93Hjhunv/xhNk2YpBn3wbFA4Fhg9U/",[Fe.Paypal]:"sha384-VF389nvvrRUgDsTXMxTYORDtVegB9IQa3Cxr//DyJnLYnz8/X8VCzEvck2c+Megt",[Fe.LocalPayment]:"sha384-tZKx2rEQbfmZpoPSY5VPmJEhaq4X75dLvwHMs3VE9U+C8lPyw+hWTIL1+GPvWCIH",[Fe.DataCollector]:"sha384-E6k3wOpP7syCDDwaRDLF06942Y00NkbwJvWi2OQXwwKzGwG5fd3E7RFUvCCecfvO",[Fe.UsBankAccount]:"sha384-258FON8LZGG0W9Qaz4Jij83pZHu30YnKjJA7gNulLBh6CclkucgF+tHDQuYFRYfW",[Fe.GooglePayment]:"sha384-taJ2p/0+n0VH328POAoBiuEbL3tnHUTE9S42hK1V+Txs3X+QYjZOyKW35JgHRFfO",[Fe.ThreeDSecure]:"sha384-+NSZH4Zj3sO5bdWvPKhU5N16QDxeueTVTnUVeleeESkhLSaz4Ob1hh/5myecc9Ym",[Fe.VisaCheckout]:"sha384-66DiBjghxk1OmBj8aksN8gbQ+CwoQcx1vPfiXUN08g1iQVM+BwewF0p7toM3i7SS",[Fe.Venmo]:"sha384-B5UwY42kE4RoLoWbQ7YpqosUlUad2/DlGWiw0HhoZbSPk30CQAaSA10ohyLDTkDU",[Fe.HostedFields]:"sha384-Aw9EesSaUeWxe36PqEHiOyOyOq8M6CIb1gw7/yHNVPRzGtFXXcd2OQ8qXrIlOj2P",[Fe.Fastlane]:"sha384-rhBL1hpZ71JqG+2TsT0Dih47mbjx8cjJCpeZjk9tw3df1gFMKfCTmMyZunhr7H4Y"},[tt]:{[Fe.Client]:"sha384-0WNxksIpRP+fYZiIdr12g6DBUQfLDzYCQJZtR/C8KkcwSGhPHfcFp3tTaGcMyFTq",[Fe.PaypalCheckout]:"sha384-lWM1jk4BOxoDNV6Kop7tVNvQgINlmEVz0c/OwM+HNHK3QC8xqwd54Ovrt2QRDTjh",[Fe.Paypal]:"sha384-fXUmVxC2EMZBDXZ7eTHSTL/LFBrHej/MSXT/vTBXvra4lzgLNGvREAp+x0GYObuH",[Fe.LocalPayment]:"sha384-pha1xGuGSkmZH5x9aqHvRaO4xLea7rmQ/79PFj9zxNzxuFcOWZg7gOP7FibygOEC",[Fe.DataCollector]:"sha384-Q6PI2F9eekWbAxhroybl+aEcvqhdowN/EQlGwBUyJOzPFn9982u9xl6SU6XfGKzc",[Fe.UsBankAccount]:"sha384-W3RLQSKJL1tQ3+Y7mP6tmkamtZ8bV4Yw/XxL9Jj5JtXHraD8loMF8hAIG5m2zK7F",[Fe.GooglePayment]:"sha384-TITQMsFWA3elDNGP2mWz2oKBo4qjt+TlqzovcaPoeBiAh/wPBi6nae50ADdgU1/i",[Fe.ThreeDSecure]:"sha384-YiycYN89ZlL/Evcaq4y1ajW1mhd7JYfZBDuOwHtIn4/Jnm20GL+/XCM+zYAwWD8D",[Fe.VisaCheckout]:"sha384-/OdaTv9qrkKzjObtUe6yzfDhHozFW/+uXlrSl736sOZRJpjGQETvpYXqMFFg69xv",[Fe.Venmo]:"sha384-dA+ojdW9vbJS4JavcXyOs9d5uZHJg5dNtYupoPSH2zsXIiYDVS5amLb/u8qmQ6oz",[Fe.HostedFields]:"sha384-31ZkS58+iaWsW06ftW52zzVZFp43WPd7pNYRiddYynSNg6Oh7WGbSFGorAUH6T1z",[Fe.Fastlane]:"sha384-jlbrwNvL3HvLAUCtLSmrnQ2GH1udCUrRS/bVmReAS5fuIVvcW8Pko/Gkg82tlgtr"}};var at=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class ot{constructor(e,t,n){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSDKVersionManager=n}loadClient(){return at(this,null,function*(){return this.loadBraintreeModuleOrThrow(Fe.Client,"client.min.js")})}loadFastlane(){return at(this,null,function*(){return this.loadBraintreeModuleOrThrow(Fe.Fastlane,"fastlane.min.js")})}loadPaypalCheckout(){return at(this,null,function*(){return this.loadBraintreeModuleOrThrow(Fe.PaypalCheckout,"paypal-checkout.min.js")})}loadPaypal(){return at(this,null,function*(){return this.loadBraintreeModuleOrThrow(Fe.Paypal,"paypal.min.js")})}loadLocalPayment(){return at(this,null,function*(){return this.loadBraintreeModuleOrThrow(Fe.LocalPayment,"local-payment.min.js")})}loadDataCollector(){return at(this,null,function*(){return this.loadBraintreeModuleOrThrow(Fe.DataCollector,"data-collector.min.js")})}loadUsBankAccount(){return at(this,null,function*(){return this.loadBraintreeModuleOrThrow(Fe.UsBankAccount,"us-bank-account.min.js")})}loadGooglePayment(){return at(this,null,function*(){return this.loadBraintreeModuleOrThrow(Fe.GooglePayment,"google-payment.min.js")})}load3DS(){return at(this,null,function*(){return this.loadBraintreeModuleOrThrow(Fe.ThreeDSecure,"three-d-secure.min.js")})}loadVisaCheckout(){return this.loadBraintreeModuleOrThrow(Fe.VisaCheckout,"visa-checkout.min.js")}loadVenmoCheckout(){return this.loadBraintreeModuleOrThrow(Fe.Venmo,"venmo.min.js")}loadHostedFields(){return at(this,null,function*(){return this.loadBraintreeModuleOrThrow(Fe.HostedFields,"hosted-fields.min.js")})}loadVisaCheckoutSdk(e){return at(this,null,function*(){if(this.braintreeHostWindow.V)return this.braintreeHostWindow.V;const t=e?"sha384-0eu1s1GtqzXlL9DtLgmwzC5WWlEH/ADRM0n38cVQkvtT+W/gey96rcb1LwuUOPDm":"sha384-1f1csvP3ZFxg4dILH1GaY4LHlZ0oX7Rk83rxmLlwbnIi4TM0NYzXoev1VoEiVDS6";return this.scriptLoader.loadScript(`//${e?"sandbox-":""}assets.secure.checkout.visa.com/checkout-widget/resources/js/integration/v1/sdk.js`,{async:!0,attributes:{integrity:t,crossorigin:"anonymous"}}).then(()=>{if(!this.braintreeHostWindow.V)throw new V;return this.braintreeHostWindow.V})})}loadBraintreeModuleOrThrow(e,t){return at(this,null,function*(){let n=this.getBraintreeModule(e);if(n)return n;const r=this.braintreeSDKVersionManager.getSDKVersion(),i=`//js.braintreegateway.com/web/${r}/js/${t}`,a=r in it?this.getIntegrityValuesByModuleName(e,r):void 0;if(yield this.scriptLoader.loadScript(i,a?{async:!0,attributes:{integrity:a,crossorigin:"anonymous"}}:void 0),n=this.getBraintreeModule(e),!n)throw new V;return n})}getBraintreeModule(e){var t;return null==(t=this.braintreeHostWindow.braintree)?void 0:t[e]}getIntegrityValuesByModuleName(e,t){const n=it[t][e];if(!n)throw new Error("Unexpected fileName value");return n}}class st{getSDKVersion(){return nt}}class lt extends C{constructor(e){super(e||"Failed to redirect to checkout page"),this.name="BraintreePaypalWalletError",this.type="braintree_paypal_wallet"}}var ct=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class dt{constructor(e,t){this.walletButtonIntegrationService=e,this.braintreeIntegrationService=t}initialize(e){this.braintreeIntegrationService.initialize(e)}loadPaypalCheckout(e,t,n){return ct(this,null,function*(){return this.braintreePaypalCheckout=yield new Promise((r,i)=>{this.braintreeIntegrationService.getPaypalCheckout(e,r,e=>{this.removeElement(t),n&&He(e)&&n(e),i(e)})}),this.braintreePaypalCheckout})}loadVenmoCheckout(e){return ct(this,null,function*(){try{this.braintreeVenmoCheckout=yield this.braintreeIntegrationService.getVenmoCheckout()}catch(t){throw this.removeElement(e),t}return this.braintreeVenmoCheckout})}getBraintreePaypalCheckoutOrThrow(){if(!this.braintreePaypalCheckout)throw new V;return this.braintreePaypalCheckout}getBraintreeVenmoCheckoutOrThrow(){if(!this.braintreeVenmoCheckout)throw new V;return this.braintreeVenmoCheckout}teardown(){return ct(this,null,function*(){yield this.braintreeIntegrationService.teardown()})}proxyTokenizationPayment(e,t,n){return ct(this,null,function*(){const r=this.getBraintreePaypalCheckoutOrThrow(),i=yield r.tokenizePayment(e);return this.redirectToExternalCheckout(i,t,n)})}proxyVenmoTokenizationPayment(e,t){return ct(this,null,function*(){const n=yield this.tokenizeVenmo();return this.redirectToExternalCheckout(n,e,t)})}removeElement(e){this.braintreeIntegrationService.removeElement(e)}redirectToExternalCheckout(e,t,n){return ct(this,null,function*(){var r;const{deviceData:i}=yield this.braintreeIntegrationService.getDataCollector({paypal:!0}),{details:a,nonce:o}=e,s=this.braintreeIntegrationService.mapToLegacyShippingAddress(a);yield this.walletButtonIntegrationService.addBillingAddress(n,this.mapToBillingAddress(a));const l={paymentWalletData:{providerId:t,providerOrderId:o},cartEntityId:n,queryParams:[{key:"payment_type",value:"paypal"},{key:"action",value:"set_external_checkout"},{key:"provider",value:t},{key:"nonce",value:o},{key:"shipping_address",value:encodeURIComponent(JSON.stringify(s))},...i?[{key:"device_data",value:i}]:[]]},c=null==(r=(yield this.walletButtonIntegrationService.getRedirectToCheckoutUrl(l)).body.redirectUrls)?void 0:r.externalCheckoutUrl;if(!c)throw new lt;return window.location.assign(c),e})}mapToBillingAddress(e){const{billingAddress:t,email:n,firstName:r,lastName:i,phone:a,shippingAddress:o}=e,s=t||o;return{firstName:r||"",lastName:i||"",company:"",address1:(null==s?void 0:s.line1)||"",address2:(null==s?void 0:s.line2)||"",city:(null==s?void 0:s.city)||"",email:n||"",stateOrProvince:(null==s?void 0:s.state)||"",stateOrProvinceCode:(null==s?void 0:s.state)||"",countryCode:(null==s?void 0:s.countryCode)||"",postalCode:(null==s?void 0:s.postalCode)||"",phone:a||"",shouldSaveAddress:!1}}tokenizeVenmo(){const e=this.getBraintreeVenmoCheckoutOrThrow();return new Promise((t,n)=>{e.tokenize((e,r)=>{if(e)return n(e);t(r)})})}}function ut(e){const{color:t,fundingicons:i,height:a=40,layout:o,shape:s,size:l,tagline:c}=e||{},d={color:t,fundingicons:i,height:yt(a),layout:o,shape:s||"rect",size:l,tagline:c};return r(d,n)}function yt(e){const t=Number(e);return!t||Number.isNaN(t)?40:t>55?55:t<25?25:t}var ht=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class pt{constructor(e,t){this.braintreePaypalWalletService=e,this.braintreeHostWindow=t}initialize(e){return ht(this,null,function*(){const{braintreepaypal:t,containerId:n,methodId:r}=e;if(!r)throw new ge('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new ge('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new ge('Unable to initialize payment because "options.braintreepaypal" argument is not provided.');let i;try{i=JSON.parse(atob(t.initializationData))}catch(e){throw new ge("Failed to parse payment method 'initializationData'.")}const{initializationData:a,config:o}=i;if(!t.clientToken||!a||!o)throw new K(Z.MissingPaymentMethod);const s={currency:t.currency.code,intent:a.intent,isCreditEnabled:a.isCreditEnabled,commit:!1};this.braintreePaypalWalletService.initialize(t.clientToken),yield this.braintreePaypalWalletService.loadPaypalCheckout(s,n,t.onError),this.renderButton(t,n,r,!!o.testMode,a.intent)})}deinitialize(){return ht(this,null,function*(){yield this.braintreePaypalWalletService.teardown()})}renderButton(e,t,n,r,i){const{style:a,onEligibilityFailure:o}=e,{paypal:s}=this.braintreeHostWindow;if(!s)return void this.braintreePaypalWalletService.removeElement(t);const l=s.Buttons({env:r?"sandbox":"production",fundingSource:s.FUNDING.PAYPAL,style:ut(a),createOrder:()=>this.setupPayment(e,i),onApprove:t=>this.tokenizePayment(t,n,e.cartId,e.onAuthorizeError)});l.isEligible()?l.render(`#${t}`):o&&"function"==typeof o&&o()}setupPayment(e,t){return ht(this,null,function*(){const{onPaymentError:n,amount:r,currency:i}=e,a=this.braintreePaypalWalletService.getBraintreePaypalCheckoutOrThrow();try{return yield a.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,amount:r,currency:i.code,offerCredit:!1,intent:t})}catch(e){throw(He(e)||e instanceof C)&&(null==n||n(e)),e}})}tokenizePayment(e,t,n,r){return ht(this,null,function*(){try{yield this.braintreePaypalWalletService.proxyTokenizationPayment(e,t,n)}catch(e){throw(He(e)||e instanceof C)&&(null==r||r(e)),e}})}}const mt=R(e=>{const t=window,n=new et(new ot(a(),t,new st),t);return new pt(new dt(e,n),t)},[{id:"braintreepaypal"}]);var Mt=Object.defineProperty,gt=Object.defineProperties,wt=Object.getOwnPropertyDescriptors,_t=Object.getOwnPropertySymbols,Ct=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable,ft=(e,t,n)=>t in e?Mt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,It=(e,t)=>{for(var n in t||(t={}))Ct.call(t,n)&&ft(e,n,t[n]);if(_t)for(var n of _t(t))bt.call(t,n)&&ft(e,n,t[n]);return e},Nt=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class vt{constructor(e,t){this.braintreePaypalWalletService=e,this.braintreeHostWindow=t}initialize(e){return Nt(this,null,function*(){const{braintreepaypalcredit:t,containerId:n,methodId:r}=e;if(!r)throw new ge('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new ge('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new ge('Unable to initialize payment because "options.braintreepaypalcredit" argument is not provided.');let i;try{i=JSON.parse(atob(t.initializationData))}catch(e){throw new ge("Failed to parse payment method 'initializationData'.")}const{initializationData:a,config:o}=i;if(!t.clientToken||!a||!o)throw new K(Z.MissingPaymentMethod);const s={currency:t.currency.code,intent:a.intent,isCreditEnabled:a.isCreditEnabled,commit:!1};this.braintreePaypalWalletService.initialize(t.clientToken),yield this.braintreePaypalWalletService.loadPaypalCheckout(s,n,t.onError),this.renderButton(t,n,r,!!o.testMode,a.intent)})}deinitialize(){return Nt(this,null,function*(){yield this.braintreePaypalWalletService.teardown()})}renderButton(e,t,n,r,i){const{style:a,onEligibilityFailure:o}=e,{paypal:s}=this.braintreeHostWindow;if(!s)return void this.braintreePaypalWalletService.removeElement(t);const l=s.Buttons({env:r?"sandbox":"production",fundingSource:s.FUNDING.PAYLATER,style:(c=It({},ut(a)),d={color:We.GOLD},gt(c,wt(d))),createOrder:()=>this.setupPayment(e,i),onApprove:t=>this.tokenizePayment(t,n,e.cartId,e.onAuthorizeError)});var c,d;l.isEligible()?l.render(`#${t}`):o&&"function"==typeof o&&o()}setupPayment(e,t){return Nt(this,null,function*(){const{onPaymentError:n,amount:r,currency:i}=e,a=this.braintreePaypalWalletService.getBraintreePaypalCheckoutOrThrow();try{return yield a.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,amount:r,currency:i.code,offerCredit:!0,intent:t})}catch(e){throw(He(e)||e instanceof C)&&(null==n||n(e)),e}})}tokenizePayment(e,t,n,r){return Nt(this,null,function*(){try{yield this.braintreePaypalWalletService.proxyTokenizationPayment(e,t,n)}catch(e){throw(He(e)||e instanceof C)&&(null==r||r(e)),e}})}}const Pt=R(e=>{const t=window,n=new et(new ot(a(),t,new st),t);return new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LjAwMDgxIDMuNjIwODMsMC45NTg4NSA0LjMzOTAyLDIuMjY0MTlsMC4wMDAwMSwwLjAwMDAxeiIgZmlsbD0iIzAwOENGRiIgaWQ9InN2Z182Ii8+CiAgICAgICAgICAgIDxwYXRoIHN0cm9rZT0ibnVsbCIgZD0ibTEwNi4yNjA3NSwxMi4zNjgzYzAsLTEuNjg5MTQgLTAuNDE1NCwtMi44NDA2OSAtMS42NTg4OCwtMi44NDA2OWMtMi43NTQyNywwIC0zLjMxOTU4LDQuOTUxNDcgLTMuMzE5NTgsNy40ODQ0YzAsMS45MjE2NyAwLjUyODI4LDMuMTEwODggMS43NzE3NiwzLjExMDg4YzIuNjAzNDcsMCAzLjIwNjcsLTUuMjIxODQgMy4yMDY3LC03Ljc1NDU5em0tMTIuMDcwMDQsNC4zMzc5NGMwLC02LjUyNDkyIDMuMzk0NTMsLTEyLjYzMDM4IDExLjIwMzEzLC0xMi42MzAzOGM1Ljg4NTEyLDAgOC4wMzYxNiwzLjUzMjUxIDguMDM2MTYsOC40MDgzMWMwLDYuNDQ5MzQgLTMuMzU3NTEsMTMuMTI4MTMgLTExLjM1NTczLDEzLjEyODEzYy01LjkyMjE0LDAgLTcuODgzNTUsLTMuOTU0MzMgLTcuODgzNTUsLTguOTA2MDZsLTAuMDAwMDEsMHoiIGZpbGw9IiMwMDhDRkYiIGlkPSJzdmdfNyIvPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+Cg=="},Dt=e=>{const{color:t,height:n}=e;return{backgroundColor:(r=t||"",r===We.WHITE?"#FFFFFF":"#3D95CE"),backgroundPosition:"50% 50%",backgroundSize:"80px auto",backgroundImage:`url("${zt[t===We.WHITE?We.BLUE:We.WHITE]}")`,backgroundRepeat:"no-repeat",borderRadius:"4px",cursor:"pointer",transition:"0.2s ease",minHeight:`${n||40}px`,minWidth:"150px",height:"100%",border:t===We.WHITE?"1px solid black":"none"};var r};var Tt=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class Lt{constructor(e){this.braintreePaypalWalletService=e}initialize(e){return Tt(this,null,function*(){const{braintreevenmo:t,containerId:n,methodId:r}=e;if(!r)throw new ge('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new ge('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new ge('Unable to initialize payment because "options.braintreevenmo" argument is not provided.');let i;try{i=JSON.parse(atob(t.initializationData))}catch(e){throw new ge("Failed to parse payment method 'initializationData'.")}const{initializationData:a,config:o}=i;if(!t.clientToken||!a||!o)throw new K(Z.MissingPaymentMethod);this.braintreePaypalWalletService.initialize(t.clientToken);try{yield this.braintreePaypalWalletService.loadVenmoCheckout(n)}catch(e){return void this.handleInitializationError(e,t)}this.renderButton(t,n,r,a)})}deinitialize(){return Tt(this,null,function*(){yield this.braintreePaypalWalletService.teardown()})}handleInitializationError(e,t){const{onError:n,onEligibilityFailure:r}=t;e instanceof Ae?null==r||r():(He(e)||e instanceof C)&&(null==n||n(e))}renderButton(e,t,n,r){const{style:i,onEligibilityFailure:a}=e,{cartButtonStyles:o}=r.paymentButtonStyles||{},s=i||o||{},{color:l}=s,c=document.getElementById(t);if(!c)return this.braintreePaypalWalletService.removeElement(t),void(null==a||a());c.setAttribute("aria-label","Venmo"),Object.assign(c.style,Dt(s)),c.addEventListener("click",()=>Tt(this,null,function*(){var t;c.setAttribute("disabled","true");try{yield this.braintreePaypalWalletService.proxyVenmoTokenizationPayment(n,e.cartId)}catch(n){(He(n)||n instanceof C)&&(null==(t=e.onAuthorizeError)||t.call(e,n))}finally{c.removeAttribute("disabled")}})),l===We.BLUE&&(c.addEventListener("mouseenter",()=>{c.style.backgroundColor="#0a7fc2"}),c.addEventListener("mouseleave",()=>{c.style.backgroundColor=Dt(s).backgroundColor}))}}const St=R(e=>{const t=window,n=new et(new ot(a(),t,new st),t);return new Lt(new dt(e,n))},[{id:"braintreevenmo"}]);var jt=Object.defineProperty,Ot=Object.getOwnPropertySymbols,At=Object.prototype.hasOwnProperty,kt=Object.prototype.propertyIsEnumerable,Et=(e,t,n)=>t in e?jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xt=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class Bt{constructor(e){this.paypalCommerceHeadlessWalletButtonService=e}initialize(e){return xt(this,null,function*(){var t,n;const{paypalcommercepaypal:r,containerId:i,methodId:a}=e;if(!a)throw new ge('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new ge('Unable to initialize payment because "options.containerId" argument is not provided.');if(!r)throw new ge('Unable to initialize payment because "options.paypalcommercepaypal" argument is not provided.');let o;try{o=JSON.parse(atob(r.initializationData))}catch(e){throw new ge("Failed to parse payment method 'initializationData'.")}const s=null==(n=null==(t=o.initializationData)?void 0:t.paymentButtonStyles)?void 0:n.cartButtonStyles;yield this.paypalCommerceHeadlessWalletButtonService.loadPayPalSdk(o,r.currency.code,!1),this.renderButton(i,"paypalcommerce.paypal",r.cartId,s)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n,r){const i=this.paypalCommerceHeadlessWalletButtonService.getPayPalSdkOrThrow(),a={createOrder:()=>this.paypalCommerceHeadlessWalletButtonService.createPaymentOrderIntent(t,n),onApprove:(e,r)=>xt(this,[e,r],function*({orderID:e},r){const i=yield r.order.get(),a=this.paypalCommerceHeadlessWalletButtonService.mapOrderDetailsToBillingAddress(i);yield this.paypalCommerceHeadlessWalletButtonService.addBillingAddress(n,a),yield this.paypalCommerceHeadlessWalletButtonService.proxyTokenizationPayment(n,t,"paypalcommerce",e)})},o=((e,t)=>{for(var n in t||(t={}))At.call(t,n)&&Et(e,n,t[n]);if(Ot)for(var n of Ot(t))kt.call(t,n)&&Et(e,n,t[n]);return e})({fundingSource:i.FUNDING.PAYPAL,style:this.paypalCommerceHeadlessWalletButtonService.getValidButtonStyle(r)},a),s=i.Buttons(o);s.isEligible()?s.render(`#${e}`):this.paypalCommerceHeadlessWalletButtonService.removeElement(e)}}const Ut=R(e=>new Bt(new ee(e,Me())),[{id:"paypalcommercepaypal"}]);var Gt=Object.defineProperty,Wt=Object.getOwnPropertySymbols,Yt=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable,Ht=(e,t,n)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qt=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class Rt{constructor(e){this.paypalCommerceHeadlessWalletButtonService=e}initialize(e){return Qt(this,null,function*(){var t,n;const{paypalcommercepaypalcredit:r,containerId:i,methodId:a}=e;if(!a)throw new ge('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new ge('Unable to initialize payment because "options.containerId" argument is not provided.');if(!r)throw new ge('Unable to initialize payment because "options.paypalcommercepaypalcredit" argument is not provided.');let o;try{o=JSON.parse(atob(r.initializationData))}catch(e){throw new ge("Failed to parse payment method 'initializationData'.")}yield this.paypalCommerceHeadlessWalletButtonService.loadPayPalSdk(o,r.currency.code,!1);const s=null==(n=null==(t=o.initializationData)?void 0:t.paymentButtonStyles)?void 0:n.cartButtonStyles;this.renderButton(i,"paypalcommerce.paypalcredit",r.cartId,s)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n,r){const i=this.paypalCommerceHeadlessWalletButtonService.getPayPalSdkOrThrow(),a=[i.FUNDING.PAYLATER,i.FUNDING.CREDIT],o={createOrder:()=>this.paypalCommerceHeadlessWalletButtonService.createPaymentOrderIntent(t,n),onApprove:(e,r)=>Qt(this,[e,r],function*({orderID:e},r){const i=yield r.order.get(),a=this.paypalCommerceHeadlessWalletButtonService.mapOrderDetailsToBillingAddress(i);yield this.paypalCommerceHeadlessWalletButtonService.addBillingAddress(n,a),yield this.paypalCommerceHeadlessWalletButtonService.proxyTokenizationPayment(n,t,"paypalcommercecredit",e)})};let s=!1;a.forEach(t=>{if(!s){const n=((e,t)=>{for(var n in t||(t={}))Yt.call(t,n)&&Ht(e,n,t[n]);if(Wt)for(var n of Wt(t))Ft.call(t,n)&&Ht(e,n,t[n]);return e})({fundingSource:t,style:this.paypalCommerceHeadlessWalletButtonService.getValidButtonStyle(r)},o),a=i.Buttons(n);a.isEligible()&&(a.render(`#${e}`),s=!0)}}),s||this.paypalCommerceHeadlessWalletButtonService.removeElement(e)}}const Vt=R(e=>new Rt(new ee(e,Me())),[{id:"paypalcommercepaypalcredit"}]);var Zt=(e=>(e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white",e))(Zt||{}),Kt=Object.defineProperty,Jt=Object.defineProperties,qt=Object.getOwnPropertyDescriptors,Xt=Object.getOwnPropertySymbols,$t=Object.prototype.hasOwnProperty,en=Object.prototype.propertyIsEnumerable,tn=(e,t,n)=>t in e?Kt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nn=(e,t)=>{for(var n in t||(t={}))$t.call(t,n)&&tn(e,n,t[n]);if(Xt)for(var n of Xt(t))en.call(t,n)&&tn(e,n,t[n]);return e},rn=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class an{constructor(e){this.paypalCommerceHeadlessWalletButtonService=e}initialize(e){return rn(this,null,function*(){var t,n;const{paypalcommercevenmo:r,containerId:i,methodId:a}=e;if(!a)throw new ge('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new ge('Unable to initialize payment because "options.containerId" argument is not provided.');if(!r)throw new ge('Unable to initialize payment because "options.paypalcommercevenmo" argument is not provided.');let o;try{o=JSON.parse(atob(r.initializationData))}catch(e){throw new ge("Failed to parse payment method 'initializationData'.")}const s=null==(n=null==(t=o.initializationData)?void 0:t.paymentButtonStyles)?void 0:n.cartButtonStyles;yield this.paypalCommerceHeadlessWalletButtonService.loadPayPalSdk(o,r.currency.code,!1),this.renderButton(i,"paypalcommerce.venmo",r.cartId,s)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n,r){const i=this.paypalCommerceHeadlessWalletButtonService.getPayPalSdkOrThrow(),a={createOrder:()=>this.paypalCommerceHeadlessWalletButtonService.createPaymentOrderIntent(t,n),onApprove:e=>rn(this,[e],function*({orderID:e}){yield this.paypalCommerceHeadlessWalletButtonService.proxyTokenizationPayment(n,t,"paypalcommercevenmo",e)})},o=nn({fundingSource:i.FUNDING.VENMO,style:this.getValidVenmoButtonStyles(r)},a),s=i.Buttons(o);s.isEligible()?s.render(`#${e}`):this.paypalCommerceHeadlessWalletButtonService.removeElement(e)}getValidVenmoButtonStyles(e){const t=this.paypalCommerceHeadlessWalletButtonService.getValidButtonStyle(e);return t.color===Zt.gold?(n=nn({},t),Jt(n,qt({color:void 0}))):t;var n}}const on=R(e=>new an(new ee(e,Me())),[{id:"paypalcommercevenmo"}]);function sn(e){return e&&"resolveIds"in e}function ln(){try{return"production"}catch(e){return"development"}}class cn{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 dn{log(){}info(){}warn(){}error(){}debug(){}}const un=function(e=!0){return e?new cn(console):new dn}("test"!==ln());class yn extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}class hn extends yn{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class pn{constructor(e){var t,n,r;this._factories={},this._instances={},this._defaultToken=null!=(t=null==e?void 0:e.defaultToken)?t:"default",this._useFallback=null==(n=null==e?void 0:e.useFallback)||n,this._tokenResolver=null!=(r=null==e?void 0:e.tokenResolver)?r: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 hn(`'${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 hn(`'${e}' is not registered.`);this._instances[t]=n()}return this._instances[t]}}class mn{constructor(e=!1){this._useFallback=e,this._registry=new pn({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 r;const i=this._decodeToken(e),a=[];t.forEach(e=>{const t=this._decodeToken(e),n={token:e,matches:0,default:!1,totalKeys:Object.keys(t).length};for(const[e,r]of Object.entries(t)){if(e in i&&i[e]!==r){n.matches=0;break}e in i&&i[e]===r&&n.matches++,"default"===e&&!0===r&&(n.default=!0)}a.push(n)});const o=a.sort((e,t)=>t.matches-e.matches).filter(e=>e.matches>0);o.length>1&&o[0].matches===o[1].matches&&"development"===ln()&&un.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(i).length;if(n){const e=o.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(i)} with exact match.`);return e.token}const l=o[0];if(l&&l.token)return l.token;if(this._useFallback){const e=null==(r=a.find(e=>e.default))?void 0:r.token;if(e)return e}throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(i)}.`)}}var Mn=Object.defineProperty,gn=Object.defineProperties,wn=Object.getOwnPropertyDescriptors,_n=Object.getOwnPropertySymbols,Cn=Object.prototype.hasOwnProperty,bn=Object.prototype.propertyIsEnumerable,fn=(e,t,n)=>t in e?Mn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function In(e,t,n){if("function"!=typeof n.value)return n;let r=n.value;return{get(){const e=r.bind(this);var i;return Object.defineProperty(this,t,(i=((e,t)=>{for(var n in t||(t={}))Cn.call(t,n)&&fn(e,n,t[n]);if(_n)for(var n of _n(t))bn.call(t,n)&&fn(e,n,t[n]);return e})({},n),gn(i,wn({value:e})))),e},set(e){r=e}}}const Nn=e=>{const t=i(e);return document.getElementById(t)?Nn(e):t};var vn=Object.defineProperty,Pn=Object.defineProperties,zn=(Object.getOwnPropertyDescriptor,Object.getOwnPropertyDescriptors),Dn=Object.getOwnPropertySymbols,Tn=Object.prototype.hasOwnProperty,Ln=Object.prototype.propertyIsEnumerable,Sn=(e,t,n)=>t in e?vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;let jn=class{constructor(e){this._registryV2=e}initializeWalletButton(e){const t=this.getContainerIds(e);return Promise.all(t.map(t=>{return n=this,r=function*(){return this._registryV2.get({id:e.methodId}).initialize((n=((e,t)=>{for(var n in t||(t={}))Tn.call(t,n)&&Sn(e,n,t[n]);if(Dn)for(var n of Dn(t))Ln.call(t,n)&&Sn(e,n,t[n]);return e})({},e),Pn(n,zn({containerId:t}))));var n},new Promise((e,t)=>{var i=e=>{try{o(r.next(e))}catch(e){t(e)}},a=e=>{try{o(r.throw(e))}catch(e){t(e)}},o=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,a);o((r=r.apply(n,null)).next())});var n,r}))}deinitializeWalletButton(e){return this._registryV2.get({id:e.methodId}).deinitialize()}getContainerIds(e){return t=e.containerId,/^\w[\w\-\:\.]*$/.test(t)?[e.containerId]:function(e,t){const n=document.querySelectorAll(e);if(!n.length)throw new hn(`Unable to find any element with the specified selector: ${e}`);return Array.prototype.slice.call(n).map(e=>(e.id||(e.id=Nn(t)),e.id))}(e.containerId,`${e.methodId}-container`);var t}};function On(t){const{graphQLEndpoint:n}=t,r=function(e,t){const n=new mn;for(const[,r]of Object.entries(t))if(sn(r))for(const t of r.resolveIds)n.register(t,()=>r(e));return n}((t=>{const n=e();return new Q(t,new _(n),new F(n),new S(n))})(n),l);return new jn(r)}jn=((e,t)=>{for(var n,r=t,i=e.length-1;i>=0;i--)(n=e[i])&&(r=n(r)||r);return r})([function(e,t,n){return t&&n?In(0,t,n):function(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const r=Object.getOwnPropertyDescriptor(e.prototype,n);r&&"constructor"!==n&&Object.defineProperty(t.prototype,n,In(e.prototype,n,r))}),t}(e)}],jn);export{On as createWalletButtonInitializer};
1
+ import{createRequestSender as e}from"@bigcommerce/request-sender";import{isEmpty as t,isNil as n,omitBy as r,uniqueId as i}from"lodash";import{getScriptLoader as a}from"@bigcommerce/script-loader";import{supportsPopups as o}from"@braintree/browser-detection";const s={d:(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var r=t[n++],i=t[n++];s.o(e,r)?0===i&&n++:0===i?Object.defineProperty(e,r,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,r,{enumerable:!0,get:i})}else for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};var l={};s.r(l),s.d(l,{createBigCommercePaymentsPayLaterWalletStrategy:()=>je,createBigCommercePaymentsVenmoWalletStrategy:()=>He,createBigCommercePaymentsWalletStrategy:()=>Pe,createBraintreePaypalCreditWalletStrategy:()=>Bt,createBraintreePaypalWalletStrategy:()=>zt,createBraintreeVenmoWalletStrategy:()=>Vt,createPayPalCommerceCreditWalletStrategy:()=>on,createPayPalCommerceVenmoWalletStrategy:()=>wn,createPayPalCommerceWalletStrategy:()=>qt});var c=Object.defineProperty,d=Object.defineProperties,u=Object.getOwnPropertyDescriptors,y=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,m=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))h.call(t,n)&&m(e,n,t[n]);if(y)for(var n of y(t))p.call(t,n)&&m(e,n,t[n]);return e},M=(e,t)=>d(e,u(t)),w=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class _{constructor(e){this.requestSender=e}updateBillingAddress(e,t,n,r){return w(this,null,function*(){const i=n,{id:a}=i,o=((e,t)=>{var n={};for(var r in e)h.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&y)for(var r of y(e))t.indexOf(r)<0&&p.call(e,r)&&(n[r]=e[r]);return n})(i,["id"]),s={headers:M(g({},null==r?void 0:r.headers),{"Content-Type":"application/json","x-catalyst-graphql-proxy-requester":"checkout-sdk-js"}),body:{query:"\n mutation UpdateCheckoutBillingAddressMutation(\n $input: UpdateCheckoutBillingAddressInput!\n ) {\n checkout {\n updateCheckoutBillingAddress(input: $input) {\n checkout {\n billingAddress {\n address1\n address2\n city\n company\n countryCode\n email\n entityId\n firstName\n lastName\n phone\n postalCode\n stateOrProvince\n stateOrProvinceCode\n }\n }\n }\n }\n }\n ",variables:{input:{checkoutEntityId:t,addressEntityId:n.id,data:{address:g({},o)}}}}},l=yield this.requestSender.post(`${window.location.origin}/${e}`,s),{billingAddress:c}=l.body.data.checkout.updateCheckoutBillingAddress.checkout;return M(g({},l),{body:c})})}addBillingAddress(e,t,n,r){return w(this,null,function*(){const i={headers:M(g({},null==r?void 0:r.headers),{"Content-Type":"application/json","x-catalyst-graphql-proxy-requester":"checkout-sdk-js"}),body:{query:"\n mutation AddCheckoutBillingAddressMutation(\n $input: AddCheckoutBillingAddressInput!\n ) {\n checkout {\n addCheckoutBillingAddress(input: $input) {\n checkout {\n billingAddress {\n address1\n address2\n city\n company\n countryCode\n email\n entityId\n firstName\n lastName\n phone\n postalCode\n stateOrProvince\n stateOrProvinceCode\n }\n }\n }\n }\n }\n ",variables:{input:{checkoutEntityId:t,data:{address:g({},n)}}}}},a=yield this.requestSender.post(`${window.location.origin}/${e}`,i),{billingAddress:o}=a.body.data.checkout.addCheckoutBillingAddress.checkout;return M(g({},a),{body:o})})}}class b extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}class C extends b{constructor(e){super(e||"An unexpected error has occurred during checkout redirection process. Please try again later."),this.name="CheckoutRedirectError",this.type="checkout_redirect_error"}}var f=Object.defineProperty,I=Object.defineProperties,v=Object.getOwnPropertyDescriptors,P=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable,D=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,T=(e,t)=>{for(var n in t||(t={}))N.call(t,n)&&D(e,n,t[n]);if(P)for(var n of P(t))z.call(t,n)&&D(e,n,t[n]);return e},S=(e,t)=>I(e,v(t));class L{constructor(e){this.requestSender=e}getRedirectToCheckoutUrl(e,t,n){return r=this,i=function*(){var r;const i={headers:S(T({},null==n?void 0:n.headers),{"Content-Type":"application/json","x-catalyst-graphql-proxy-requester":"checkout-sdk-js"}),body:{query:"\n mutation CheckoutRedirectMutation($input: CreateCartRedirectUrlsInput!) {\n cart {\n createCartRedirectUrls(input: $input) {\n errors {\n __typename\n ... on NotFoundError {\n message \n }\n ... on CreateRedirectUrlsCurrencyNotAllowed {\n message\n }\n }\n redirectUrls {\n externalCheckoutUrl\n }\n }\n }\n }\n ",variables:{input:t}}};try{const t=yield this.requestSender.post(`${window.location.origin}/${e}`,i),{data:{cart:{createCartRedirectUrls:n}}}=t.body,a=null==(r=n.errors[0])?void 0:r.message;if(a)throw new C(a);if(n.errors.length>0)throw new C;return S(T({},t),{body:{redirectUrls:n.redirectUrls}})}catch(e){if(e instanceof Error)throw e;throw new Error("Checkout redirection failed")}},new Promise((e,t)=>{var n=e=>{try{o(i.next(e))}catch(e){t(e)}},a=e=>{try{o(i.throw(e))}catch(e){t(e)}},o=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,a);o((i=i.apply(r,null)).next())});var r,i}}class O extends b{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}class j extends b{constructor(e){super(e||"An unexpected error has occurred during payment order creation process. Please try again later."),this.name="PaymentOrderCreationError",this.type="payment_order_creation_error"}}var A=Object.defineProperty,k=Object.defineProperties,E=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,B=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,W=(e,t,n)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,G=(e,t)=>{for(var n in t||(t={}))B.call(t,n)&&W(e,n,t[n]);if(x)for(var n of x(t))U.call(t,n)&&W(e,n,t[n]);return e},Y=(e,t)=>k(e,E(t));class V{constructor(e){this.requestSender=e}createPaymentOrderIntent(e,t,n="PayPalCommercePaymentWalletIntentData",r){return i=this,a=function*(){var i;const a=`\n mutation CreatePaymentWalletIntentMutation(\n $input: CreatePaymentWalletIntentInput!\n ) {\n payment {\n paymentWallet {\n createPaymentWalletIntent(input: $input) {\n paymentWalletIntentData {\n __typename\n ... on ${n} {\n orderId\n approvalUrl\n initializationEntityId\n }\n }\n errors {\n __typename\n ... on CreatePaymentWalletIntentGenericError {\n message\n }\n ... on Error {\n message\n }\n }\n }\n }\n }\n }\n `,o={headers:Y(G({},null==r?void 0:r.headers),{"Content-Type":"application/json","x-catalyst-graphql-proxy-requester":"checkout-sdk-js"}),body:{query:a,variables:{input:t}}};try{const t=yield this.requestSender.post(`${window.location.origin}/${e}`,o),{data:{payment:{paymentWallet:{createPaymentWalletIntent:{paymentWalletIntentData:n,errors:r}}}}}=t.body,a=null==(i=r[0])?void 0:i.message;if(a)throw new j(a);return Y(G({},t),{body:G({},n)})}catch(e){if(!(e instanceof j))throw new O;throw e}},new Promise((e,t)=>{var n=e=>{try{o(a.next(e))}catch(e){t(e)}},r=e=>{try{o(a.throw(e))}catch(e){t(e)}},o=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,r);o((a=a.apply(i,null)).next())});var i,a}}var F=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class H{constructor(e,t,n,r){this.graphQLEndpoint=e,this.billingAddressRequestSender=t,this.paymentRequestSender=n,this.checkoutRequestSender=r}addBillingAddress(e,t,n){return F(this,null,function*(){return this.billingAddressRequestSender.addBillingAddress(this.graphQLEndpoint,e,t,n)})}updateBillingAddress(e,t,n){return F(this,null,function*(){return this.billingAddressRequestSender.updateBillingAddress(this.graphQLEndpoint,e,t,n)})}createPaymentOrderIntent(e,t,n){return F(this,null,function*(){return this.paymentRequestSender.createPaymentOrderIntent(this.graphQLEndpoint,e,t,n)})}getRedirectToCheckoutUrl(e,t){return F(this,null,function*(){return this.checkoutRequestSender.getRedirectToCheckoutUrl(this.graphQLEndpoint,e,t)})}}function Q(e,t){return Object.assign(e,{resolveIds:t})}class R extends b{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 Z=(e=>(e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress",e))(Z||{});class K extends b{constructor(e){super(function(e){switch(e){case 0:return"Unable to proceed because billing address data is unavailable.";case 1:return"Unable to proceed because cart data is unavailable.";case 3:return"Unable to proceed because consignments data is unavailable.";case 2:return"Unable to proceed because checkout data is unavailable.";case 4:return"Unable to proceed because customer data is unavailable.";case 5:case 7:return"Unable to proceed because configuration data is unavailable.";case 6:return"Unable to proceed because order data is unavailable.";case 8:return"Unable to proceed because order ID is unavailable or not generated yet.";case 9:return"Unable to proceed because payment data is unavailable.";case 15:return"Unable to proceed because the token required to submit a payment is missing.";case 12:return"Unable to proceed because payment method data is unavailable or not properly configured.";case 16:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}var J=(e=>(e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment",e))(J||{}),q=(e=>(e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white",e))(q||{}),X=(e=>(e.pill="pill",e.rect="rect",e))(X||{}),$=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class ee{constructor(e,t,n="PayPalCommercePaymentWalletIntentData"){this.walletButtonIntegrationService=e,this.scriptLoader=t,this.intentTypename=n}loadPayPalSdk(e,t,n,r){return $(this,null,function*(){return this.paypalSdk=yield this.scriptLoader.getPayPalSDK(e,t,void 0,n,r),this.paypalSdk})}getPayPalSdkOrThrow(){if(!this.paypalSdk)throw new R;return this.paypalSdk}proxyTokenizationPayment(e,t,n,r){return $(this,null,function*(){var i;if(!r)throw new K(Z.MissingOrderId);const a={paymentWalletData:{providerId:t,providerOrderId:r},cartEntityId:e,queryParams:[{key:"payment_type",value:"paypal"},{key:"action",value:"set_external_checkout"},{key:"provider",value:n},{key:"order_id",value:r}]},o=yield this.walletButtonIntegrationService.getRedirectToCheckoutUrl(a);if(!(null==(i=o.body.redirectUrls)?void 0:i.externalCheckoutUrl))throw new Error("Failed to redirection to checkout page");window.location.assign(o.body.redirectUrls.externalCheckoutUrl)})}createPaymentOrderIntent(e,t,n){return $(this,null,function*(){const r={cartEntityId:t,paymentWalletEntityId:e};return(yield this.walletButtonIntegrationService.createPaymentOrderIntent(r,this.intentTypename,n)).body.orderId})}addBillingAddress(e,t,n){return $(this,null,function*(){return this.walletButtonIntegrationService.addBillingAddress(e,t,n)})}mapOrderDetailsToBillingAddress({payer:e}){var t,n,r,i;return{firstName:e.name.given_name,lastName:e.name.surname,company:"",address1:e.address.address_line_1,address2:e.address.address_line_2,city:e.address.admin_area_2,email:e.email_address,stateOrProvince:null!=(t=e.address.admin_area_1)?t:"",stateOrProvinceCode:null!=(n=e.address.admin_area_1)?n:"",countryCode:e.address.country_code,postalCode:e.address.postal_code,phone:null!=(i=null==(r=e.phone)?void 0:r.phone_number.national_number)?i:"",shouldSaveAddress:!1}}getValidButtonStyle(e={}){const{color:t,height:i,label:a,shape:o}=e,s={color:t&&q[t]?t:void 0,height:this.getValidHeight(i),label:a&&J[a]?a:void 0,shape:o&&X[o]?o:void 0};return r(s,n)}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 te=(e=>(e.PayPal="paypal",e.BigCommercePaymentsPayPalSDK="bigCommercePaymentsPayPalSDK",e.PayPalFastlaneSdk="paypalFastlaneSdk",e.PayPalFastlane="paypalFastlane",e.PayPalGooglePay="paypalGooglePay",e.PayPalApms="paypalApms",e.PayPalMessages="paypalMessages",e))(te||{});const ne=["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 re(e){return window[e]}function ie(e){if(!e)return;let t;if(e.includes("-")){const[n,r]=e.split("-");t=`${n}_${r.toUpperCase()}`}else t=`${e}_${e.toUpperCase()}`;return ne.includes(t)?t:void 0}var ae=Object.defineProperty,oe=Object.defineProperties,se=Object.getOwnPropertyDescriptors,le=Object.getOwnPropertySymbols,ce=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,ue=(e,t,n)=>t in e?ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ye=(e,t)=>{for(var n in t||(t={}))ce.call(t,n)&&ue(e,n,t[n]);if(le)for(var n of le(t))de.call(t,n)&&ue(e,n,t[n]);return e},he=(e,t)=>oe(e,se(t)),pe=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class me{constructor(e){this.scriptLoader=e,this.window=window}getPayPalSDK(e,t,n,r,i){return pe(this,null,function*(){const a=this.isBigCommercePaymentsMethod(e.id)?te.BigCommercePaymentsPayPalSDK:te.PayPal;if(!re(a)||i){const i=this.getPayPalSdkScriptConfigOrThrow(e,t,n,r);yield this.loadPayPalSdk(i)}const o=re(a);if(!o)throw new R;return o})}getPayPalFastlaneSdk(e,t,n,r){return pe(this,null,function*(){if(!this.window.paypalFastlaneSdk){const i=this.getPayPalFastlaneSdkConfiguration(e,t,n,r);if(yield this.loadPayPalSdk(i),!this.window.paypalFastlaneSdk)throw new R}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,r,i){return pe(this,null,function*(){if(!this.window.paypalGooglePay||i){const i=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,r);yield this.loadPayPalSdk(i)}if(!this.window.paypalGooglePay)throw new R;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t,n){return pe(this,null,function*(){if(!this.window.paypalApms){const r=this.getPayPalApmSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(r),!this.window.paypalApms)throw new R}return this.window.paypalApms})}getPayPalMessages(e,t,n){return pe(this,null,function*(){if(!this.window.paypalMessages){const r=this.getPayPalSdkMessagesConfiguration(e,t,n);yield this.loadPayPalSdk(r)}if(!this.window.paypalMessages)throw new R;return this.window.paypalMessages})}isBigCommercePaymentsMethod(e){return e.startsWith("bigcommerce_payments")}loadPayPalSdk(e){return pe(this,arguments,function*({options:e,attributes:t}){const n=this.transformConfig(e),r=this.transformConfig(t),i=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(i,{async:!0,attributes:r})})}getPayPalSdkScriptConfigOrThrow(e,t,n,r=!0){const{id:i,clientToken:a,initializationData:o}=e;if(!o||!o.clientId)throw new K(Z.MissingPaymentMethod);const{intent:s,clientId:l,merchantId:c,buyerCountry:d,attributionId:u,isVenmoEnabled:y,isHostedCheckoutEnabled:h,isPayPalCreditAvailable:p,isDeveloperModeApplicable:m,availableAlternativePaymentMethods:g=[],enabledAlternativePaymentMethods:M=[],isGooglePayEnabled:w}=o,_=h||r,b="paypalcommercecreditcards"===i||"bigcommerce_payments_creditcards"===i,C=b?["card"]:[],f=b?[]:["card"],I=p?["credit","paylater"]:[],v=p?[]:["credit","paylater"],P=y?["venmo"]:[],N=y?[]:["venmo"],z=g.filter(e=>!M.includes(e)),D=w?["googlepay"]:[],T=r?["card-fields"]:[],S=this.filterFundingOptions([...f,...v,...N,...z]),L=this.filterFundingOptions([...C,...I,...P,...M]),O=ie(n);return{options:ye(ye({"client-id":l,"merchant-id":c,"enable-funding":L.length>0?L:void 0,"disable-funding":S.length>0?S:void 0,commit:_,components:["buttons","hosted-fields","payment-fields","legal",...D,...T],currency:t,intent:s},m&&{"buyer-country":d}),O&&{locale:O}),attributes:ye({"data-partner-attribution-id":u,"data-client-token":a},this.isBigCommercePaymentsMethod(i)&&{"data-namespace":te.BigCommercePaymentsPayPalSDK})}}getPayPalFastlaneSdkConfiguration(e,t,n,r){const{clientToken:i,initializationData:a}=e;if(!a||!a.clientId)throw new K(Z.MissingPaymentMethod);const{intent:o,clientId:s,merchantId:l,attributionId:c}=a,d=ie(r);return{options:he(ye({"client-id":s,"merchant-id":l,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t},d&&{locale:d}),{intent:o}),attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":te.PayPalFastlaneSdk,"data-partner-attribution-id":c,"data-sdk-client-token":i}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,r=!0){const{clientToken:i,initializationData:a}=e;if(!a||!a.clientId)throw new K(Z.MissingPaymentMethod);const{intent:o,clientId:s,merchantId:l,buyerCountry:c,attributionId:d,isHostedCheckoutEnabled:u,isDeveloperModeApplicable:y}=a,h=u||r,p=ie(n);return{options:ye(ye({"client-id":s,"merchant-id":l,commit:h,components:["googlepay"],currency:t,intent:o},y&&{"buyer-country":c}),p&&{locale:p}),attributes:{"data-partner-attribution-id":d,"data-client-token":i,"data-namespace":te.PayPalGooglePay}}}getPayPalApmSdkConfiguration(e,t,n){const{initializationData:r}=e;if(!r||!r.clientId)throw new K(Z.MissingPaymentMethod);const{intent:i,clientId:a,merchantId:o,buyerCountry:s,attributionId:l,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:d=[],enabledAlternativePaymentMethods:u=[]}=r,y=this.filterFundingOptions(u),h=this.filterFundingOptions(d.filter(e=>!u.includes(e))),p=ie(n);return{options:ye(ye({"client-id":a,"merchant-id":o,"enable-funding":y.length>0?y:void 0,"disable-funding":h.length>0?h:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:i},c&&{"buyer-country":s}),p&&{locale:p}),attributes:{"data-partner-attribution-id":l,"data-namespace":te.PayPalApms}}}getPayPalSdkMessagesConfiguration(e,t,n){const{initializationData:r}=e;if(!r||!r.clientId)throw new K(Z.MissingPaymentMethod);const{clientId:i,merchantId:a,attributionId:o,isDeveloperModeApplicable:s,buyerCountry:l}=r,c=ie(n);return{options:ye(ye({"client-id":i,"merchant-id":a,components:["messages"],currency:t},s&&{"buyer-country":l}),c&&{locale:c}),attributes:{"data-namespace":te.PayPalMessages,"data-partner-attribution-id":o}}}filterFundingOptions(e){const t=["klarna","afterpay"];return e?e.filter(e=>!t.includes(e)):[]}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const r=e[n];null==r||""===r||Array.isArray(r)&&0===r.length||(t=he(ye({},t),{[n]:Array.isArray(r)?r.join(","):r}))}),t}}function ge(){return new me(a())}class Me extends b{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}var we=Object.defineProperty,_e=Object.getOwnPropertySymbols,be=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable,fe=(e,t,n)=>t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ie=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class ve{constructor(e){this.bigCommercePaymentsWalletService=e}initialize(e){return Ie(this,null,function*(){var t,n;const{bigcommerce_paymentspaypal:r,containerId:i,methodId:a}=e;if(!a)throw new Me('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new Me('Unable to initialize payment because "options.containerId" argument is not provided.');if(!r)throw new Me('Unable to initialize payment because "options.bigcommerce_paymentspaypal" argument is not provided.');let o;try{o=JSON.parse(atob(r.initializationData))}catch(e){throw new Me("Failed to parse payment method 'initializationData'.")}o.id=o.id||a;const s=null==(n=null==(t=o.initializationData)?void 0:t.paymentButtonStyles)?void 0:n.cartButtonStyles;yield this.bigCommercePaymentsWalletService.loadPayPalSdk(o,r.currency.code,!1),this.renderButton(i,"bigcommerce_payments.paypal",r.cartId,s)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n,r){const i=this.bigCommercePaymentsWalletService.getPayPalSdkOrThrow(),a={createOrder:()=>this.bigCommercePaymentsWalletService.createPaymentOrderIntent(t,n),onApprove:(e,r)=>Ie(this,[e,r],function*({orderID:e},r){const i=yield r.order.get(),a=this.bigCommercePaymentsWalletService.mapOrderDetailsToBillingAddress(i);yield this.bigCommercePaymentsWalletService.addBillingAddress(n,a),yield this.bigCommercePaymentsWalletService.proxyTokenizationPayment(n,t,"bigcommerce_payments",e)})},o=((e,t)=>{for(var n in t||(t={}))be.call(t,n)&&fe(e,n,t[n]);if(_e)for(var n of _e(t))Ce.call(t,n)&&fe(e,n,t[n]);return e})({fundingSource:i.FUNDING.PAYPAL,style:this.bigCommercePaymentsWalletService.getValidButtonStyle(r)},a),s=i.Buttons(o);s.isEligible()?s.render(`#${e}`):this.bigCommercePaymentsWalletService.removeElement(e)}}const Pe=Q(e=>new ve(new ee(e,ge(),"BigcommercePaymentWalletIntentData")),[{id:"bigcommerce_paymentspaypal"}]);var Ne=Object.defineProperty,ze=Object.getOwnPropertySymbols,De=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable,Se=(e,t,n)=>t in e?Ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Le=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class Oe{constructor(e){this.bigCommercePaymentsPayLaterWalletService=e}initialize(e){return Le(this,null,function*(){var t,n;const{bigcommerce_paymentspaypalcredit:r,containerId:i,methodId:a}=e;if(!a)throw new Me('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new Me('Unable to initialize payment because "options.containerId" argument is not provided.');if(!r)throw new Me('Unable to initialize payment because "options.bigcommerce_paymentspaypalcredit" argument is not provided.');let o;try{o=JSON.parse(atob(r.initializationData))}catch(e){throw new Me("Failed to parse payment method 'initializationData'.")}o.id=o.id||a;const s=null==(n=null==(t=o.initializationData)?void 0:t.paymentButtonStyles)?void 0:n.cartButtonStyles;yield this.bigCommercePaymentsPayLaterWalletService.loadPayPalSdk(o,r.currency.code,!1),this.renderButton(i,"bigcommerce_payments.paypalcredit",r.cartId,s)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n,r){const i=this.bigCommercePaymentsPayLaterWalletService.getPayPalSdkOrThrow(),a=[i.FUNDING.PAYLATER,i.FUNDING.CREDIT],o={createOrder:()=>this.bigCommercePaymentsPayLaterWalletService.createPaymentOrderIntent(t,n),onApprove:(e,r)=>Le(this,[e,r],function*({orderID:e},r){const i=yield r.order.get(),a=this.bigCommercePaymentsPayLaterWalletService.mapOrderDetailsToBillingAddress(i);yield this.bigCommercePaymentsPayLaterWalletService.addBillingAddress(n,a),yield this.bigCommercePaymentsPayLaterWalletService.proxyTokenizationPayment(n,t,"bigcommerce_payments_paylater",e)})};let s=!1;a.forEach(t=>{if(!s){const n=((e,t)=>{for(var n in t||(t={}))De.call(t,n)&&Se(e,n,t[n]);if(ze)for(var n of ze(t))Te.call(t,n)&&Se(e,n,t[n]);return e})({fundingSource:t,style:this.bigCommercePaymentsPayLaterWalletService.getValidButtonStyle(r)},o),a=i.Buttons(n);a.isEligible()&&(a.render(`#${e}`),s=!0)}}),s||this.bigCommercePaymentsPayLaterWalletService.removeElement(e)}}const je=Q(e=>new Oe(new ee(e,ge(),"BigcommercePaymentWalletIntentData")),[{id:"bigcommerce_paymentspaypalcredit"}]);var Ae=(e=>(e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white",e))(Ae||{}),ke=Object.defineProperty,Ee=Object.defineProperties,xe=Object.getOwnPropertyDescriptors,Be=Object.getOwnPropertySymbols,Ue=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable,Ge=(e,t,n)=>t in e?ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ye=(e,t)=>{for(var n in t||(t={}))Ue.call(t,n)&&Ge(e,n,t[n]);if(Be)for(var n of Be(t))We.call(t,n)&&Ge(e,n,t[n]);return e},Ve=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class Fe{constructor(e){this.bigCommercePaymentsVenmoWalletService=e}initialize(e){return Ve(this,null,function*(){var t,n;const{bigcommerce_paymentsvenmo:r,containerId:i,methodId:a}=e;if(!a)throw new Me('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new Me('Unable to initialize payment because "options.containerId" argument is not provided.');if(!r)throw new Me('Unable to initialize payment because "options.bigcommerce_paymentsvenmo" argument is not provided.');let o;try{o=JSON.parse(atob(r.initializationData))}catch(e){throw new Me("Failed to parse payment method 'initializationData'.")}o.id=o.id||a;const s=null==(n=null==(t=o.initializationData)?void 0:t.paymentButtonStyles)?void 0:n.cartButtonStyles;yield this.bigCommercePaymentsVenmoWalletService.loadPayPalSdk(o,r.currency.code,!1),this.renderButton(i,"bigcommerce_payments.venmo",r.cartId,s)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n,r){const i=this.bigCommercePaymentsVenmoWalletService.getPayPalSdkOrThrow(),a={createOrder:()=>this.bigCommercePaymentsVenmoWalletService.createPaymentOrderIntent(t,n),onApprove:e=>Ve(this,[e],function*({orderID:e}){yield this.bigCommercePaymentsVenmoWalletService.proxyTokenizationPayment(n,t,"bigcommerce_payments_venmo",e)})},o=Ye({fundingSource:i.FUNDING.VENMO,style:this.getValidVenmoButtonStyles(r)},a),s=i.Buttons(o);s.isEligible()?s.render(`#${e}`):this.bigCommercePaymentsVenmoWalletService.removeElement(e)}getValidVenmoButtonStyles(e){const t=this.bigCommercePaymentsVenmoWalletService.getValidButtonStyle(e);return t.color===Ae.gold?(n=Ye({},t),Ee(n,xe({color:void 0}))):t;var n}}const He=Q(e=>new Fe(new ee(e,ge(),"BigcommercePaymentWalletIntentData")),[{id:"bigcommerce_paymentsvenmo"}]);class Qe extends b{constructor(e){super(e||"Unsupported browser error"),this.name="UnsupportedBrowserError",this.type="unsupported_browser"}}class Re extends Me{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 Ze extends b{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"}}var Ke=(e=>(e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized",e))(Ke||{});class Je extends b{constructor(e){super(function(e){switch(e){case 1:return"Unable to proceed because the customer step of checkout has not been initialized.";case 2:return"Unable to proceed because the payment step of checkout has not been initialized.";case 3:return"Unable to proceed because the shipping step of checkout has not been initialized.";case 4:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}let qe=null;const Xe=["buttons","messages"];var $e=(e=>(e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white",e))($e||{}),et=(e=>(e.Sandbox="sandbox",e.Production="production",e))(et||{}),tt=(e=>(e.Client="client",e.DataCollector="dataCollector",e.Fastlane="fastlane",e.GooglePayment="googlePayment",e.HostedFields="hostedFields",e.LocalPayment="localPayment",e.Paypal="paypal",e.PaypalCheckout="paypalCheckout",e.ThreeDSecure="threeDSecure",e.UsBankAccount="usBankAccount",e.Venmo="venmo",e.VisaCheckout="visaCheckout",e))(tt||{});function nt(e){return Boolean("object"==typeof e&&null!==e&&("type"in e||"message"in e||"code"in e))}var rt=Object.defineProperty,it=Object.defineProperties,at=Object.getOwnPropertyDescriptors,ot=Object.getOwnPropertySymbols,st=Object.prototype.hasOwnProperty,lt=Object.prototype.propertyIsEnumerable,ct=(e,t,n)=>t in e?rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dt=(e,t)=>{for(var n in t||(t={}))st.call(t,n)&&ct(e,n,t[n]);if(ot)for(var n of ot(t))lt.call(t,n)&&ct(e,n,t[n]);return e},ut=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class yt{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 ut(this,null,function*(){if(t&&(window.localStorage.setItem("axoEnv","sandbox"),window.localStorage.setItem("fastlaneEnv","sandbox")),!this.braintreeHostWindow.braintreeFastlane){const t=this.getClientTokenOrThrow(),r=yield this.getClient(),i=yield this.getSessionId(e),a=yield this.braintreeScriptLoader.loadFastlane(),o={root:{backgroundColorPrimary:"transparent"}};this.braintreeHostWindow.braintreeFastlane=yield a.create({authorization:t,client:r,deviceData:i,styles:n||o})}return this.braintreeHostWindow.braintreeFastlane})}getClient(){return ut(this,null,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 t=e,{shouldSaveInstrument:n}=t,r=((e,t)=>{var n={};for(var r in e)st.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&ot)for(var r of ot(e))t.indexOf(r)<0&&lt.call(e,r)&&(n[r]=e[r]);return n})(t,["shouldSaveInstrument"]);const i=o();return this.getPaypal().then(e=>{var t;return i&&(null==(t=this.overlay)||t.show({onClick:()=>e.focusWindow()})),e.tokenize(dt({enableShippingAddress:!0,flow:n?"vault":"checkout",useraction:"commit"},r))}).then(e=>{var t;return null==(t=this.overlay)||t.remove(),e}).catch(e=>{var t;throw null==(t=this.overlay)||t.remove(),e})}getPaypalCheckout(e,t,n){return ut(this,null,function*(){const r=yield this.getClient(),i=yield this.braintreeScriptLoader.loadPaypalCheckout(),a={client:r};return this.paypalCheckout=yield i.create(a,(r,i)=>{var a;if(r)return n(r);const o=(s=dt({currency:e.currency},e.isCreditEnabled&&{"enable-funding":"paylater"}),l={components:Xe.toString(),intent:e.intent,commit:null==(a=e.commit)||a},it(s,at(l)));var s,l;this.braintreeHostWindow.paypal?t(i):function(e,t){return qe||(qe=new Promise((n,r)=>{e.loadPayPalSDK(t,t=>{t?(qe=null,r(t)):n(e)})})),qe}(i,o).then(()=>t(i))}),this.paypalCheckout})}getDataCollector(e){return ut(this,null,function*(){const t=(null==e?void 0:e.paypal)?"paypal":"default";let n=this.dataCollectors[t];if(!n){try{const t=yield this.getClient(),r=yield this.braintreeScriptLoader.loadDataCollector(),i=dt({client:t,kount:!0},e);n=yield r.create(i)}catch(e){if(!nt(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?et.Sandbox:et.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:r}=e,i=(null==r?void 0:r.recipientName)||"",[a,o]=i.split(" ");return{email:t,first_name:a||"",last_name:o||"",phone_number:n,address_line_1:null==r?void 0:r.line1,address_line_2:null==r?void 0:r.line2,city:null==r?void 0:r.city,state:null==r?void 0:r.state,country_code:null==r?void 0:r.countryCode,postal_code:null==r?void 0:r.postalCode}}mapToLegacyBillingAddress(e){const{billingAddress:t,email:n,firstName:r,lastName:i,phone:a,shippingAddress:o}=e,s=t||o;return{email:n,first_name:r,last_name:i,phone_number:a,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 ut(this,null,function*(){const{deviceData:t}=yield this.getDataCollector({riskCorrelationId:e});return t})}teardown(){return ut(this,null,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 ut(this,null,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 ut(this,null,function*(){if(!this.venmoCheckout){const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadVenmoCheckout(),r=dt({client:t,allowDesktop:!0,paymentMethodUsage:"multi_use"},e||{});this.venmoCheckout=yield new Promise((e,t)=>{n.create(r,(n,r)=>n?t(n):r.isBrowserSupported()?void e(r):t(new Qe))})}return this.venmoCheckout})}verifyCard(e,t,n){return ut(this,null,function*(){const r=yield this.tokenizeCard(e,t);return this.challenge3DSVerification(r,n)})}tokenizeCard(e,n){return ut(this,null,function*(){const{paymentData:r}=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}(r))throw new Re(["payment.paymentData"]);const i=this.getErrorsRequiredFields(r);if(!t(i))throw new Ze(i);const a=this.mapToCreditCard(r,n),o=yield this.getClient(),{creditCards:s}=yield o.request(a);return{nonce:s[0].nonce,bin:s[0].details.bin}})}challenge3DSVerification(e,t){return ut(this,null,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 Je(Ke.PaymentNotInitialized);return this.clientToken}getErrorsRequiredFields(e){const{ccNumber:t,ccExpiry:n}=e,r={};return t||(r.ccNumber=[{message:"Credit card number is required",type:"required"}]),n||(r.ccExpiry=[{message:"Expiration date is required",type:"required"}]),r}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:r,bin:i}=n;if(!r)throw new Je(Ke.PaymentNotInitialized);const{challengeRequested:a=!0,additionalInformation:o}=this.threeDSecureOptions||{},s=t.toFixed(2);return e.verifyCard({amount:Number(s),bin:i,challengeRequested:a,nonce:r,onLookupComplete:(e,t)=>{t()},collectDeviceData:!0,additionalInformation:o})}}const ht="3.128.0",pt="3.123.2",mt="3.106.0",gt={[mt]:{[tt.Client]:"sha384-26BXDNnJI23JYRyFBj4xe4sVNrUSSiSSu11kxVXNM/vEPONm4LuL00w6ZaTgQewt",[tt.PaypalCheckout]:"sha384-B+vzbZwnQtzWBthpkT4TXKUibO65tyeK7eCxSvpblgprTep2+IAXB2Cxxjrn710O",[tt.Paypal]:"sha384-uyAGL1/3+XJAHnGoNy4eCoXdzJ4f7Ilzp+6w9PNnEjs6DCCz9WMyJjMN1gzc78U+",[tt.LocalPayment]:"sha384-LIvOEMkIVEwVuYBdVOQc1AC5YbGGlwyfUheS0ACK218D2STuVYQlZ4FyEPowAEfT",[tt.DataCollector]:"sha384-1bo9JDz+Kscthc085cCKWur8CLwUoBpoNyxsDi7932mCl0zFq3A5mv+FQLw9GHpV",[tt.UsBankAccount]:"sha384-xmHBVaU+w74V+OebD3AaPONFxHUGMf+QRs8G/JxVPXNNP7MDa2jL0ICWHIe2tTfJ",[tt.GooglePayment]:"sha384-WKDJl8mqoP82qZpMGH6AbZxnvXnSW8ILV4M64CyMLiugGMwu7LyP89wjCkHqsiBe",[tt.ThreeDSecure]:"sha384-VQUlpGHzsGvs5XeiGFip7EXRsvoHWEXDVmgCacfbyieZI9mdBOqq3NSoyo28OCOB",[tt.VisaCheckout]:"sha384-yx7mADfzTN0T43Q6rlH49LIg1EJ0iUZgBp/EczX9LXsUGkySgxrD+nWHQRBkyfoT",[tt.Venmo]:"sha384-QX4rPjoj1ZDhuG0aSyKs56lEKDqTMTcjYxUHY1SzO5VZDsqIE2NTkqot7KNSCyov",[tt.HostedFields]:"sha384-VvYBACfSu0Cr/J32uKmxG7AXcNOJE1AzIIL3kbikyS7YKp5fz5Is+NzNP/lyauNy",[tt.Fastlane]:"sha384-9oGsZMRZwpGtDEDYa/dFt76dECqj1xAni9gIKgc3KfMIiRnR73nEeeUDLiBzxhFa"},[pt]:{[tt.Client]:"sha384-o+nbQGcwNNxIBeXeu3+XmbSq+Cg8R3EN3N0l5hXCgMMU2RGY0t1z0LroSEIAbfAO",[tt.PaypalCheckout]:"sha384-WrfbWPBS4mH86GAoycPSgiH8hQ8KH7A67C93Hjhunv/xhNk2YpBn3wbFA4Fhg9U/",[tt.Paypal]:"sha384-VF389nvvrRUgDsTXMxTYORDtVegB9IQa3Cxr//DyJnLYnz8/X8VCzEvck2c+Megt",[tt.LocalPayment]:"sha384-tZKx2rEQbfmZpoPSY5VPmJEhaq4X75dLvwHMs3VE9U+C8lPyw+hWTIL1+GPvWCIH",[tt.DataCollector]:"sha384-E6k3wOpP7syCDDwaRDLF06942Y00NkbwJvWi2OQXwwKzGwG5fd3E7RFUvCCecfvO",[tt.UsBankAccount]:"sha384-258FON8LZGG0W9Qaz4Jij83pZHu30YnKjJA7gNulLBh6CclkucgF+tHDQuYFRYfW",[tt.GooglePayment]:"sha384-taJ2p/0+n0VH328POAoBiuEbL3tnHUTE9S42hK1V+Txs3X+QYjZOyKW35JgHRFfO",[tt.ThreeDSecure]:"sha384-+NSZH4Zj3sO5bdWvPKhU5N16QDxeueTVTnUVeleeESkhLSaz4Ob1hh/5myecc9Ym",[tt.VisaCheckout]:"sha384-66DiBjghxk1OmBj8aksN8gbQ+CwoQcx1vPfiXUN08g1iQVM+BwewF0p7toM3i7SS",[tt.Venmo]:"sha384-B5UwY42kE4RoLoWbQ7YpqosUlUad2/DlGWiw0HhoZbSPk30CQAaSA10ohyLDTkDU",[tt.HostedFields]:"sha384-Aw9EesSaUeWxe36PqEHiOyOyOq8M6CIb1gw7/yHNVPRzGtFXXcd2OQ8qXrIlOj2P",[tt.Fastlane]:"sha384-rhBL1hpZ71JqG+2TsT0Dih47mbjx8cjJCpeZjk9tw3df1gFMKfCTmMyZunhr7H4Y"},[ht]:{[tt.Client]:"sha384-0WNxksIpRP+fYZiIdr12g6DBUQfLDzYCQJZtR/C8KkcwSGhPHfcFp3tTaGcMyFTq",[tt.PaypalCheckout]:"sha384-lWM1jk4BOxoDNV6Kop7tVNvQgINlmEVz0c/OwM+HNHK3QC8xqwd54Ovrt2QRDTjh",[tt.Paypal]:"sha384-fXUmVxC2EMZBDXZ7eTHSTL/LFBrHej/MSXT/vTBXvra4lzgLNGvREAp+x0GYObuH",[tt.LocalPayment]:"sha384-pha1xGuGSkmZH5x9aqHvRaO4xLea7rmQ/79PFj9zxNzxuFcOWZg7gOP7FibygOEC",[tt.DataCollector]:"sha384-Q6PI2F9eekWbAxhroybl+aEcvqhdowN/EQlGwBUyJOzPFn9982u9xl6SU6XfGKzc",[tt.UsBankAccount]:"sha384-W3RLQSKJL1tQ3+Y7mP6tmkamtZ8bV4Yw/XxL9Jj5JtXHraD8loMF8hAIG5m2zK7F",[tt.GooglePayment]:"sha384-TITQMsFWA3elDNGP2mWz2oKBo4qjt+TlqzovcaPoeBiAh/wPBi6nae50ADdgU1/i",[tt.ThreeDSecure]:"sha384-YiycYN89ZlL/Evcaq4y1ajW1mhd7JYfZBDuOwHtIn4/Jnm20GL+/XCM+zYAwWD8D",[tt.VisaCheckout]:"sha384-/OdaTv9qrkKzjObtUe6yzfDhHozFW/+uXlrSl736sOZRJpjGQETvpYXqMFFg69xv",[tt.Venmo]:"sha384-dA+ojdW9vbJS4JavcXyOs9d5uZHJg5dNtYupoPSH2zsXIiYDVS5amLb/u8qmQ6oz",[tt.HostedFields]:"sha384-31ZkS58+iaWsW06ftW52zzVZFp43WPd7pNYRiddYynSNg6Oh7WGbSFGorAUH6T1z",[tt.Fastlane]:"sha384-jlbrwNvL3HvLAUCtLSmrnQ2GH1udCUrRS/bVmReAS5fuIVvcW8Pko/Gkg82tlgtr"}};var Mt=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class wt{constructor(e,t,n){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSDKVersionManager=n}loadClient(){return Mt(this,null,function*(){return this.loadBraintreeModuleOrThrow(tt.Client,"client.min.js")})}loadFastlane(){return Mt(this,null,function*(){return this.loadBraintreeModuleOrThrow(tt.Fastlane,"fastlane.min.js")})}loadPaypalCheckout(){return Mt(this,null,function*(){return this.loadBraintreeModuleOrThrow(tt.PaypalCheckout,"paypal-checkout.min.js")})}loadPaypal(){return Mt(this,null,function*(){return this.loadBraintreeModuleOrThrow(tt.Paypal,"paypal.min.js")})}loadLocalPayment(){return Mt(this,null,function*(){return this.loadBraintreeModuleOrThrow(tt.LocalPayment,"local-payment.min.js")})}loadDataCollector(){return Mt(this,null,function*(){return this.loadBraintreeModuleOrThrow(tt.DataCollector,"data-collector.min.js")})}loadUsBankAccount(){return Mt(this,null,function*(){return this.loadBraintreeModuleOrThrow(tt.UsBankAccount,"us-bank-account.min.js")})}loadGooglePayment(){return Mt(this,null,function*(){return this.loadBraintreeModuleOrThrow(tt.GooglePayment,"google-payment.min.js")})}load3DS(){return Mt(this,null,function*(){return this.loadBraintreeModuleOrThrow(tt.ThreeDSecure,"three-d-secure.min.js")})}loadVisaCheckout(){return this.loadBraintreeModuleOrThrow(tt.VisaCheckout,"visa-checkout.min.js")}loadVenmoCheckout(){return this.loadBraintreeModuleOrThrow(tt.Venmo,"venmo.min.js")}loadHostedFields(){return Mt(this,null,function*(){return this.loadBraintreeModuleOrThrow(tt.HostedFields,"hosted-fields.min.js")})}loadVisaCheckoutSdk(e){return Mt(this,null,function*(){if(this.braintreeHostWindow.V)return this.braintreeHostWindow.V;const t=e?"sha384-0eu1s1GtqzXlL9DtLgmwzC5WWlEH/ADRM0n38cVQkvtT+W/gey96rcb1LwuUOPDm":"sha384-1f1csvP3ZFxg4dILH1GaY4LHlZ0oX7Rk83rxmLlwbnIi4TM0NYzXoev1VoEiVDS6";return this.scriptLoader.loadScript(`//${e?"sandbox-":""}assets.secure.checkout.visa.com/checkout-widget/resources/js/integration/v1/sdk.js`,{async:!0,attributes:{integrity:t,crossorigin:"anonymous"}}).then(()=>{if(!this.braintreeHostWindow.V)throw new R;return this.braintreeHostWindow.V})})}loadBraintreeModuleOrThrow(e,t){return Mt(this,null,function*(){let n=this.getBraintreeModule(e);if(n)return n;const r=this.braintreeSDKVersionManager.getSDKVersion(),i=`//js.braintreegateway.com/web/${r}/js/${t}`,a=r in gt?this.getIntegrityValuesByModuleName(e,r):void 0;if(yield this.scriptLoader.loadScript(i,a?{async:!0,attributes:{integrity:a,crossorigin:"anonymous"}}:void 0),n=this.getBraintreeModule(e),!n)throw new R;return n})}getBraintreeModule(e){var t;return null==(t=this.braintreeHostWindow.braintree)?void 0:t[e]}getIntegrityValuesByModuleName(e,t){const n=gt[t][e];if(!n)throw new Error("Unexpected fileName value");return n}}class _t{getSDKVersion(){return pt}}class bt extends b{constructor(e){super(e||"Failed to redirect to checkout page"),this.name="BraintreePaypalWalletError",this.type="braintree_paypal_wallet"}}var Ct=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class ft{constructor(e,t){this.walletButtonIntegrationService=e,this.braintreeIntegrationService=t}initialize(e){this.braintreeIntegrationService.initialize(e)}loadPaypalCheckout(e,t,n){return Ct(this,null,function*(){return this.braintreePaypalCheckout=yield new Promise((r,i)=>{this.braintreeIntegrationService.getPaypalCheckout(e,r,e=>{this.removeElement(t),n&&nt(e)&&n(e),i(e)})}),this.braintreePaypalCheckout})}loadVenmoCheckout(e){return Ct(this,null,function*(){try{this.braintreeVenmoCheckout=yield this.braintreeIntegrationService.getVenmoCheckout()}catch(t){throw this.removeElement(e),t}return this.braintreeVenmoCheckout})}getBraintreePaypalCheckoutOrThrow(){if(!this.braintreePaypalCheckout)throw new R;return this.braintreePaypalCheckout}getBraintreeVenmoCheckoutOrThrow(){if(!this.braintreeVenmoCheckout)throw new R;return this.braintreeVenmoCheckout}teardown(){return Ct(this,null,function*(){yield this.braintreeIntegrationService.teardown()})}proxyTokenizationPayment(e,t,n){return Ct(this,null,function*(){const r=this.getBraintreePaypalCheckoutOrThrow(),i=yield r.tokenizePayment(e);return this.redirectToExternalCheckout(i,t,n)})}proxyVenmoTokenizationPayment(e,t){return Ct(this,null,function*(){const n=yield this.tokenizeVenmo();return this.redirectToExternalCheckout(n,e,t)})}removeElement(e){this.braintreeIntegrationService.removeElement(e)}redirectToExternalCheckout(e,t,n){return Ct(this,null,function*(){var r;const{deviceData:i}=yield this.braintreeIntegrationService.getDataCollector({paypal:!0}),{details:a,nonce:o}=e,s=this.braintreeIntegrationService.mapToLegacyShippingAddress(a);yield this.walletButtonIntegrationService.addBillingAddress(n,this.mapToBillingAddress(a));const l={paymentWalletData:{providerId:t,providerOrderId:o},cartEntityId:n,queryParams:[{key:"payment_type",value:"paypal"},{key:"action",value:"set_external_checkout"},{key:"provider",value:t},{key:"nonce",value:o},{key:"shipping_address",value:encodeURIComponent(JSON.stringify(s))},...i?[{key:"device_data",value:i}]:[]]},c=null==(r=(yield this.walletButtonIntegrationService.getRedirectToCheckoutUrl(l)).body.redirectUrls)?void 0:r.externalCheckoutUrl;if(!c)throw new bt;return window.location.assign(c),e})}mapToBillingAddress(e){const{billingAddress:t,email:n,firstName:r,lastName:i,phone:a,shippingAddress:o}=e,s=t||o;return{firstName:r||"",lastName:i||"",company:"",address1:(null==s?void 0:s.line1)||"",address2:(null==s?void 0:s.line2)||"",city:(null==s?void 0:s.city)||"",email:n||"",stateOrProvince:(null==s?void 0:s.state)||"",stateOrProvinceCode:(null==s?void 0:s.state)||"",countryCode:(null==s?void 0:s.countryCode)||"",postalCode:(null==s?void 0:s.postalCode)||"",phone:a||"",shouldSaveAddress:!1}}tokenizeVenmo(){const e=this.getBraintreeVenmoCheckoutOrThrow();return new Promise((t,n)=>{e.tokenize((e,r)=>{if(e)return n(e);t(r)})})}}function It(e){const{color:t,fundingicons:i,height:a=40,layout:o,shape:s,size:l,tagline:c}=e||{},d={color:t,fundingicons:i,height:vt(a),layout:o,shape:s||"rect",size:l,tagline:c};return r(d,n)}function vt(e){const t=Number(e);return!t||Number.isNaN(t)?40:t>55?55:t<25?25:t}var Pt=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class Nt{constructor(e,t){this.braintreePaypalWalletService=e,this.braintreeHostWindow=t}initialize(e){return Pt(this,null,function*(){const{braintreepaypal:t,containerId:n,methodId:r}=e;if(!r)throw new Me('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Me('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Me('Unable to initialize payment because "options.braintreepaypal" argument is not provided.');let i;try{i=JSON.parse(atob(t.initializationData))}catch(e){throw new Me("Failed to parse payment method 'initializationData'.")}const{initializationData:a,config:o}=i;if(!t.clientToken||!a||!o)throw new K(Z.MissingPaymentMethod);const s={currency:t.currency.code,intent:a.intent,isCreditEnabled:a.isCreditEnabled,commit:!1};this.braintreePaypalWalletService.initialize(t.clientToken),yield this.braintreePaypalWalletService.loadPaypalCheckout(s,n,t.onError),this.renderButton(t,n,r,!!o.testMode,a.intent)})}deinitialize(){return Pt(this,null,function*(){yield this.braintreePaypalWalletService.teardown()})}renderButton(e,t,n,r,i){const{style:a,onEligibilityFailure:o}=e,{paypal:s}=this.braintreeHostWindow;if(!s)return void this.braintreePaypalWalletService.removeElement(t);const l=s.Buttons({env:r?"sandbox":"production",fundingSource:s.FUNDING.PAYPAL,style:It(a),createOrder:()=>this.setupPayment(e,i),onApprove:t=>this.tokenizePayment(t,n,e.cartId,e.onAuthorizeError)});l.isEligible()?l.render(`#${t}`):o&&"function"==typeof o&&o()}setupPayment(e,t){return Pt(this,null,function*(){const{onPaymentError:n,amount:r,currency:i}=e,a=this.braintreePaypalWalletService.getBraintreePaypalCheckoutOrThrow();try{return yield a.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,amount:r,currency:i.code,offerCredit:!1,intent:t})}catch(e){throw(nt(e)||e instanceof b)&&(null==n||n(e)),e}})}tokenizePayment(e,t,n,r){return Pt(this,null,function*(){try{yield this.braintreePaypalWalletService.proxyTokenizationPayment(e,t,n)}catch(e){throw(nt(e)||e instanceof b)&&(null==r||r(e)),e}})}}const zt=Q(e=>{const t=window,n=new yt(new wt(a(),t,new _t),t);return new Nt(new ft(e,n),t)},[{id:"braintreepaypal"}]);var Dt=Object.defineProperty,Tt=Object.defineProperties,St=Object.getOwnPropertyDescriptors,Lt=Object.getOwnPropertySymbols,Ot=Object.prototype.hasOwnProperty,jt=Object.prototype.propertyIsEnumerable,At=(e,t,n)=>t in e?Dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,kt=(e,t)=>{for(var n in t||(t={}))Ot.call(t,n)&&At(e,n,t[n]);if(Lt)for(var n of Lt(t))jt.call(t,n)&&At(e,n,t[n]);return e},Et=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class xt{constructor(e,t){this.braintreePaypalWalletService=e,this.braintreeHostWindow=t}initialize(e){return Et(this,null,function*(){const{braintreepaypalcredit:t,containerId:n,methodId:r}=e;if(!r)throw new Me('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Me('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Me('Unable to initialize payment because "options.braintreepaypalcredit" argument is not provided.');let i;try{i=JSON.parse(atob(t.initializationData))}catch(e){throw new Me("Failed to parse payment method 'initializationData'.")}const{initializationData:a,config:o}=i;if(!t.clientToken||!a||!o)throw new K(Z.MissingPaymentMethod);const s={currency:t.currency.code,intent:a.intent,isCreditEnabled:a.isCreditEnabled,commit:!1};this.braintreePaypalWalletService.initialize(t.clientToken),yield this.braintreePaypalWalletService.loadPaypalCheckout(s,n,t.onError),this.renderButton(t,n,r,!!o.testMode,a.intent)})}deinitialize(){return Et(this,null,function*(){yield this.braintreePaypalWalletService.teardown()})}renderButton(e,t,n,r,i){const{style:a,onEligibilityFailure:o}=e,{paypal:s}=this.braintreeHostWindow;if(!s)return void this.braintreePaypalWalletService.removeElement(t);const l=s.Buttons({env:r?"sandbox":"production",fundingSource:s.FUNDING.PAYLATER,style:(c=kt({},It(a)),d={color:$e.GOLD},Tt(c,St(d))),createOrder:()=>this.setupPayment(e,i),onApprove:t=>this.tokenizePayment(t,n,e.cartId,e.onAuthorizeError)});var c,d;l.isEligible()?l.render(`#${t}`):o&&"function"==typeof o&&o()}setupPayment(e,t){return Et(this,null,function*(){const{onPaymentError:n,amount:r,currency:i}=e,a=this.braintreePaypalWalletService.getBraintreePaypalCheckoutOrThrow();try{return yield a.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,amount:r,currency:i.code,offerCredit:!0,intent:t})}catch(e){throw(nt(e)||e instanceof b)&&(null==n||n(e)),e}})}tokenizePayment(e,t,n,r){return Et(this,null,function*(){try{yield this.braintreePaypalWalletService.proxyTokenizationPayment(e,t,n)}catch(e){throw(nt(e)||e instanceof b)&&(null==r||r(e)),e}})}}const Bt=Q(e=>{const t=window,n=new yt(new wt(a(),t,new _t),t);return new xt(new ft(e,n),t)},[{id:"braintreepaypalcredit"}]),Ut={[$e.WHITE]:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTE4IiBoZWlnaHQ9IjI5IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiPgogICAgPGRlZnM+CiAgICAgICAgPGNsaXBQYXRoIGlkPSJjbGlwMCI+CiAgICAgICAgICAgIDxyZWN0IHdpZHRoPSIxOTgiIGhlaWdodD0iMzgiIGZpbGw9IndoaXRlIiBpZD0ic3ZnXzEiLz4KICAgICAgICA8L2NsaXBQYXRoPgogICAgPC9kZWZzPgogICAgPGc+CiAgICAgICAgPHRpdGxlPkxheWVyIDE8L3RpdGxlPgogICAgICAgIDxnIHN0cm9rZT0ibnVsbCIgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwKSIgaWQ9InN2Z18yIj4KICAgICAgICAgICAgPHBhdGggc3Ryb2tlPSJudWxsIiBkPSJtMjAuMDM2OD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jUzMjUxIDguMDM2MTYsOC40MDgzMWMwLDYuNDQ5MzQgLTMuMzU3NTEsMTMuMTI4MTMgLTExLjM1NTczLDEzLjEyODEzYy01LjkyMjE0LDAgLTcuODgzNTUsLTMuOTU0MzMgLTcuODgzNTUsLTguOTA2MDZsLTAuMDAwMDEsMHoiIGZpbGw9IiMwMDhDRkYiIGlkPSJzdmdfNyIvPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+Cg=="},Wt=e=>{const{color:t,height:n}=e;return{backgroundColor:(r=t||"",r===$e.WHITE?"#FFFFFF":"#3D95CE"),backgroundPosition:"50% 50%",backgroundSize:"80px auto",backgroundImage:`url("${Ut[t===$e.WHITE?$e.BLUE:$e.WHITE]}")`,backgroundRepeat:"no-repeat",borderRadius:"4px",cursor:"pointer",transition:"0.2s ease",minHeight:`${n||40}px`,minWidth:"150px",height:"100%",border:t===$e.WHITE?"1px solid black":"none"};var r};var Gt=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class Yt{constructor(e){this.braintreePaypalWalletService=e}initialize(e){return Gt(this,null,function*(){const{braintreevenmo:t,containerId:n,methodId:r}=e;if(!r)throw new Me('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Me('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Me('Unable to initialize payment because "options.braintreevenmo" argument is not provided.');let i;try{i=JSON.parse(atob(t.initializationData))}catch(e){throw new Me("Failed to parse payment method 'initializationData'.")}const{initializationData:a,config:o}=i;if(!t.clientToken||!a||!o)throw new K(Z.MissingPaymentMethod);this.braintreePaypalWalletService.initialize(t.clientToken);try{yield this.braintreePaypalWalletService.loadVenmoCheckout(n)}catch(e){return void this.handleInitializationError(e,t)}this.renderButton(t,n,r,a)})}deinitialize(){return Gt(this,null,function*(){yield this.braintreePaypalWalletService.teardown()})}handleInitializationError(e,t){const{onError:n,onEligibilityFailure:r}=t;e instanceof Qe?null==r||r():(nt(e)||e instanceof b)&&(null==n||n(e))}renderButton(e,t,n,r){const{style:i,onEligibilityFailure:a}=e,{cartButtonStyles:o}=r.paymentButtonStyles||{},s=i||o||{},{color:l}=s,c=document.getElementById(t);if(!c)return this.braintreePaypalWalletService.removeElement(t),void(null==a||a());c.setAttribute("aria-label","Venmo"),Object.assign(c.style,Wt(s)),c.addEventListener("click",()=>Gt(this,null,function*(){var t;c.setAttribute("disabled","true");try{yield this.braintreePaypalWalletService.proxyVenmoTokenizationPayment(n,e.cartId)}catch(n){(nt(n)||n instanceof b)&&(null==(t=e.onAuthorizeError)||t.call(e,n))}finally{c.removeAttribute("disabled")}})),l===$e.BLUE&&(c.addEventListener("mouseenter",()=>{c.style.backgroundColor="#0a7fc2"}),c.addEventListener("mouseleave",()=>{c.style.backgroundColor=Wt(s).backgroundColor}))}}const Vt=Q(e=>{const t=window,n=new yt(new wt(a(),t,new _t),t);return new Yt(new ft(e,n))},[{id:"braintreevenmo"}]);var Ft=Object.defineProperty,Ht=Object.getOwnPropertySymbols,Qt=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable,Zt=(e,t,n)=>t in e?Ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Kt=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class Jt{constructor(e){this.paypalCommerceHeadlessWalletButtonService=e}initialize(e){return Kt(this,null,function*(){var t,n;const{paypalcommercepaypal:r,containerId:i,methodId:a}=e;if(!a)throw new Me('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new Me('Unable to initialize payment because "options.containerId" argument is not provided.');if(!r)throw new Me('Unable to initialize payment because "options.paypalcommercepaypal" argument is not provided.');let o;try{o=JSON.parse(atob(r.initializationData))}catch(e){throw new Me("Failed to parse payment method 'initializationData'.")}o.id=o.id||a;const s=null==(n=null==(t=o.initializationData)?void 0:t.paymentButtonStyles)?void 0:n.cartButtonStyles;yield this.paypalCommerceHeadlessWalletButtonService.loadPayPalSdk(o,r.currency.code,!1),this.renderButton(i,"paypalcommerce.paypal",r.cartId,s)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n,r){const i=this.paypalCommerceHeadlessWalletButtonService.getPayPalSdkOrThrow(),a={createOrder:()=>this.paypalCommerceHeadlessWalletButtonService.createPaymentOrderIntent(t,n),onApprove:(e,r)=>Kt(this,[e,r],function*({orderID:e},r){const i=yield r.order.get(),a=this.paypalCommerceHeadlessWalletButtonService.mapOrderDetailsToBillingAddress(i);yield this.paypalCommerceHeadlessWalletButtonService.addBillingAddress(n,a),yield this.paypalCommerceHeadlessWalletButtonService.proxyTokenizationPayment(n,t,"paypalcommerce",e)})},o=((e,t)=>{for(var n in t||(t={}))Qt.call(t,n)&&Zt(e,n,t[n]);if(Ht)for(var n of Ht(t))Rt.call(t,n)&&Zt(e,n,t[n]);return e})({fundingSource:i.FUNDING.PAYPAL,style:this.paypalCommerceHeadlessWalletButtonService.getValidButtonStyle(r)},a),s=i.Buttons(o);s.isEligible()?s.render(`#${e}`):this.paypalCommerceHeadlessWalletButtonService.removeElement(e)}}const qt=Q(e=>new Jt(new ee(e,ge())),[{id:"paypalcommercepaypal"}]);var Xt=Object.defineProperty,$t=Object.getOwnPropertySymbols,en=Object.prototype.hasOwnProperty,tn=Object.prototype.propertyIsEnumerable,nn=(e,t,n)=>t in e?Xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rn=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class an{constructor(e){this.paypalCommerceHeadlessWalletButtonService=e}initialize(e){return rn(this,null,function*(){var t,n;const{paypalcommercepaypalcredit:r,containerId:i,methodId:a}=e;if(!a)throw new Me('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new Me('Unable to initialize payment because "options.containerId" argument is not provided.');if(!r)throw new Me('Unable to initialize payment because "options.paypalcommercepaypalcredit" argument is not provided.');let o;try{o=JSON.parse(atob(r.initializationData))}catch(e){throw new Me("Failed to parse payment method 'initializationData'.")}o.id=o.id||a,yield this.paypalCommerceHeadlessWalletButtonService.loadPayPalSdk(o,r.currency.code,!1);const s=null==(n=null==(t=o.initializationData)?void 0:t.paymentButtonStyles)?void 0:n.cartButtonStyles;this.renderButton(i,"paypalcommerce.paypalcredit",r.cartId,s)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n,r){const i=this.paypalCommerceHeadlessWalletButtonService.getPayPalSdkOrThrow(),a=[i.FUNDING.PAYLATER,i.FUNDING.CREDIT],o={createOrder:()=>this.paypalCommerceHeadlessWalletButtonService.createPaymentOrderIntent(t,n),onApprove:(e,r)=>rn(this,[e,r],function*({orderID:e},r){const i=yield r.order.get(),a=this.paypalCommerceHeadlessWalletButtonService.mapOrderDetailsToBillingAddress(i);yield this.paypalCommerceHeadlessWalletButtonService.addBillingAddress(n,a),yield this.paypalCommerceHeadlessWalletButtonService.proxyTokenizationPayment(n,t,"paypalcommercecredit",e)})};let s=!1;a.forEach(t=>{if(!s){const n=((e,t)=>{for(var n in t||(t={}))en.call(t,n)&&nn(e,n,t[n]);if($t)for(var n of $t(t))tn.call(t,n)&&nn(e,n,t[n]);return e})({fundingSource:t,style:this.paypalCommerceHeadlessWalletButtonService.getValidButtonStyle(r)},o),a=i.Buttons(n);a.isEligible()&&(a.render(`#${e}`),s=!0)}}),s||this.paypalCommerceHeadlessWalletButtonService.removeElement(e)}}const on=Q(e=>new an(new ee(e,ge())),[{id:"paypalcommercepaypalcredit"}]);var sn=(e=>(e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white",e))(sn||{}),ln=Object.defineProperty,cn=Object.defineProperties,dn=Object.getOwnPropertyDescriptors,un=Object.getOwnPropertySymbols,yn=Object.prototype.hasOwnProperty,hn=Object.prototype.propertyIsEnumerable,pn=(e,t,n)=>t in e?ln(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mn=(e,t)=>{for(var n in t||(t={}))yn.call(t,n)&&pn(e,n,t[n]);if(un)for(var n of un(t))hn.call(t,n)&&pn(e,n,t[n]);return e},gn=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});class Mn{constructor(e){this.paypalCommerceHeadlessWalletButtonService=e}initialize(e){return gn(this,null,function*(){var t,n;const{paypalcommercevenmo:r,containerId:i,methodId:a}=e;if(!a)throw new Me('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new Me('Unable to initialize payment because "options.containerId" argument is not provided.');if(!r)throw new Me('Unable to initialize payment because "options.paypalcommercevenmo" argument is not provided.');let o;try{o=JSON.parse(atob(r.initializationData))}catch(e){throw new Me("Failed to parse payment method 'initializationData'.")}o.id=o.id||a;const s=null==(n=null==(t=o.initializationData)?void 0:t.paymentButtonStyles)?void 0:n.cartButtonStyles;yield this.paypalCommerceHeadlessWalletButtonService.loadPayPalSdk(o,r.currency.code,!1),this.renderButton(i,"paypalcommerce.venmo",r.cartId,s)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n,r){const i=this.paypalCommerceHeadlessWalletButtonService.getPayPalSdkOrThrow(),a={createOrder:()=>this.paypalCommerceHeadlessWalletButtonService.createPaymentOrderIntent(t,n),onApprove:e=>gn(this,[e],function*({orderID:e}){yield this.paypalCommerceHeadlessWalletButtonService.proxyTokenizationPayment(n,t,"paypalcommercevenmo",e)})},o=mn({fundingSource:i.FUNDING.VENMO,style:this.getValidVenmoButtonStyles(r)},a),s=i.Buttons(o);s.isEligible()?s.render(`#${e}`):this.paypalCommerceHeadlessWalletButtonService.removeElement(e)}getValidVenmoButtonStyles(e){const t=this.paypalCommerceHeadlessWalletButtonService.getValidButtonStyle(e);return t.color===sn.gold?(n=mn({},t),cn(n,dn({color:void 0}))):t;var n}}const wn=Q(e=>new Mn(new ee(e,ge())),[{id:"paypalcommercevenmo"}]);function _n(e){return e&&"resolveIds"in e}function bn(){try{return"production"}catch(e){return"development"}}class Cn{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 fn{log(){}info(){}warn(){}error(){}debug(){}}const In=function(e=!0){return e?new Cn(console):new fn}("test"!==bn());class vn extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}class Pn extends vn{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class Nn{constructor(e){var t,n,r;this._factories={},this._instances={},this._defaultToken=null!=(t=null==e?void 0:e.defaultToken)?t:"default",this._useFallback=null==(n=null==e?void 0:e.useFallback)||n,this._tokenResolver=null!=(r=null==e?void 0:e.tokenResolver)?r: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 Pn(`'${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 Pn(`'${e}' is not registered.`);this._instances[t]=n()}return this._instances[t]}}class zn{constructor(e=!1){this._useFallback=e,this._registry=new Nn({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 r;const i=this._decodeToken(e),a=[];t.forEach(e=>{const t=this._decodeToken(e),n={token:e,matches:0,default:!1,totalKeys:Object.keys(t).length};for(const[e,r]of Object.entries(t)){if(e in i&&i[e]!==r){n.matches=0;break}e in i&&i[e]===r&&n.matches++,"default"===e&&!0===r&&(n.default=!0)}a.push(n)});const o=a.sort((e,t)=>t.matches-e.matches).filter(e=>e.matches>0);o.length>1&&o[0].matches===o[1].matches&&"development"===bn()&&In.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(i).length;if(n){const e=o.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(i)} with exact match.`);return e.token}const l=o[0];if(l&&l.token)return l.token;if(this._useFallback){const e=null==(r=a.find(e=>e.default))?void 0:r.token;if(e)return e}throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(i)}.`)}}var Dn=Object.defineProperty,Tn=Object.defineProperties,Sn=Object.getOwnPropertyDescriptors,Ln=Object.getOwnPropertySymbols,On=Object.prototype.hasOwnProperty,jn=Object.prototype.propertyIsEnumerable,An=(e,t,n)=>t in e?Dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function kn(e,t,n){if("function"!=typeof n.value)return n;let r=n.value;return{get(){const e=r.bind(this);var i;return Object.defineProperty(this,t,(i=((e,t)=>{for(var n in t||(t={}))On.call(t,n)&&An(e,n,t[n]);if(Ln)for(var n of Ln(t))jn.call(t,n)&&An(e,n,t[n]);return e})({},n),Tn(i,Sn({value:e})))),e},set(e){r=e}}}const En=e=>{const t=i(e);return document.getElementById(t)?En(e):t};var xn=Object.defineProperty,Bn=Object.defineProperties,Un=(Object.getOwnPropertyDescriptor,Object.getOwnPropertyDescriptors),Wn=Object.getOwnPropertySymbols,Gn=Object.prototype.hasOwnProperty,Yn=Object.prototype.propertyIsEnumerable,Vn=(e,t,n)=>t in e?xn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;let Fn=class{constructor(e){this._registryV2=e}initializeWalletButton(e){const t=this.getContainerIds(e);return Promise.all(t.map(t=>{return n=this,r=function*(){return this._registryV2.get({id:e.methodId}).initialize((n=((e,t)=>{for(var n in t||(t={}))Gn.call(t,n)&&Vn(e,n,t[n]);if(Wn)for(var n of Wn(t))Yn.call(t,n)&&Vn(e,n,t[n]);return e})({},e),Bn(n,Un({containerId:t}))));var n},new Promise((e,t)=>{var i=e=>{try{o(r.next(e))}catch(e){t(e)}},a=e=>{try{o(r.throw(e))}catch(e){t(e)}},o=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,a);o((r=r.apply(n,null)).next())});var n,r}))}deinitializeWalletButton(e){return this._registryV2.get({id:e.methodId}).deinitialize()}getContainerIds(e){return t=e.containerId,/^\w[\w\-\:\.]*$/.test(t)?[e.containerId]:function(e,t){const n=document.querySelectorAll(e);if(!n.length)throw new Pn(`Unable to find any element with the specified selector: ${e}`);return Array.prototype.slice.call(n).map(e=>(e.id||(e.id=En(t)),e.id))}(e.containerId,`${e.methodId}-container`);var t}};function Hn(t){const{graphQLEndpoint:n}=t,r=function(e,t){const n=new zn;for(const[,r]of Object.entries(t))if(_n(r))for(const t of r.resolveIds)n.register(t,()=>r(e));return n}((t=>{const n=e();return new H(t,new _(n),new V(n),new L(n))})(n),l);return new Fn(r)}Fn=((e,t)=>{for(var n,r=t,i=e.length-1;i>=0;i--)(n=e[i])&&(r=n(r)||r);return r})([function(e,t,n){return t&&n?kn(0,t,n):function(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const r=Object.getOwnPropertyDescriptor(e.prototype,n);r&&"constructor"!==n&&Object.defineProperty(t.prototype,n,kn(e.prototype,n,r))}),t}(e)}],Fn);export{Hn as createWalletButtonInitializer};
2
2
  //# sourceMappingURL=wallet-button.js.map