@bigcommerce/checkout-sdk 1.945.0 → 1.946.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 (32) 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/braintree.js +1 -1
  8. package/dist/cjs/integrations/google-pay.js +1 -1
  9. package/dist/cjs/integrations/klarna.js +1 -1
  10. package/dist/cjs/integrations/paypal-commerce.js +1 -1
  11. package/dist/cjs/integrations/paypal-commerce.js.map +1 -1
  12. package/dist/cjs/integrations/paypal-express.js +1 -1
  13. package/dist/cjs/integrations/zip.js +1 -1
  14. package/dist/cjs/wallet-button.js +1 -1
  15. package/dist/cjs/wallet-button.js.map +1 -1
  16. package/dist/esm/checkout-button.js +1 -1
  17. package/dist/esm/checkout-sdk-essential.js +1 -1
  18. package/dist/esm/checkout-sdk.js +1 -1
  19. package/dist/esm/hosted-form-v2-iframe-host.js +1 -1
  20. package/dist/esm/integrations/amazon-pay.js +1 -1
  21. package/dist/esm/integrations/bigcommerce-payments.js +1 -1
  22. package/dist/esm/integrations/braintree.js +1 -1
  23. package/dist/esm/integrations/google-pay.js +1 -1
  24. package/dist/esm/integrations/klarna.js +1 -1
  25. package/dist/esm/integrations/paypal-commerce.js +1 -1
  26. package/dist/esm/integrations/paypal-commerce.js.map +1 -1
  27. package/dist/esm/integrations/paypal-express.js +1 -1
  28. package/dist/esm/integrations/zip.js +1 -1
  29. package/dist/esm/wallet-button.js +1 -1
  30. package/dist/esm/wallet-button.js.map +1 -1
  31. package/dist/types/integrations/paypal-commerce.d.ts +27 -1
  32. 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 a 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 s,r,o,c,d,l,u,p;!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(s||(s={}));class h extends a{constructor(e){super(function(e){switch(e){case s.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case s.MissingCart:return"Unable to proceed because cart data is unavailable.";case s.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case s.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case s.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case s.MissingCheckoutConfig:case s.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case s.MissingOrder:return"Unable to proceed because order data is unavailable.";case s.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case s.MissingPayment:return"Unable to proceed because payment data is unavailable.";case s.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case s.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case s.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}!function(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"}(r||(r={}));class y extends a{constructor(e){super(function(e){switch(e){case r.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case r.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case r.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case r.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}class m extends a{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(o||(o={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(c||(c={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black"}(d||(d={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(l||(l={})),function(e){e.PILL="pill",e.RECT="rect"}(u||(u={})),function(e){e.ACKNOWLEDGE="ACKNOWLEDGE",e.FINALIZE="FINALIZE",e.INITIALIZE="INITIALIZE"}(p||(p={}));var g=function(e,t,n,i){return new(n||(n=Promise))(function(a,s){function r(e){try{c(i.next(e))}catch(e){s(e)}}function o(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,o)}c((i=i.apply(e,t||[])).next())})};class f{constructor(e,t){this.paymentIntegrationService=e,this.scriptLoader=t,this.useRedirectFlow=!1,this.window=window}initialize(e){return g(this,void 0,void 0,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 h(s.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 g(this,void 0,void 0,function*(){let i,a;const s=this.paypalSdk;if(!this.isAcknowledgedOrFinalized()){if(!this.isInContextEnabled()||this.useRedirectFlow)return i=yield this.paymentIntegrationService.submitOrder(e,n),a=i.getPaymentRedirectUrl(),a&&this.window.top&&(this.window.top.location.href=a),new Promise(t);if(!s)throw new y(r.PaymentNotInitialized);s.checkout.initXO();try{i=yield this.paymentIntegrationService.submitOrder(e,n)}catch(e){return s.checkout.closeFlow(),Promise.reject(e)}return a=i.getPaymentRedirectUrl(),a&&s.checkout.startFlow(a),new Promise(t)}yield this.paymentIntegrationService.submitOrder(e,n)})}finalize(e){return g(this,void 0,void 0,function*(){return this.paymentIntegrationService.getState().getOrder()&&this.isAcknowledgedOrFinalized()?(yield this.paymentIntegrationService.finalizeOrder(e),Promise.resolve()):Promise.reject(new m)})}isAcknowledgedOrFinalized(){const e=this.paymentIntegrationService.getState();return e.getPaymentStatus()===p.ACKNOWLEDGE||e.getPaymentStatus()===p.FINALIZE}isInContextEnabled(){return!(!this.paymentMethod||!this.paymentMethod.config.merchantId)}}class I extends a{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}class b{constructor(e){this.scriptLoader=e,this.window=window}loadPaypalSDK(){return e=this,t=arguments,i=function*(e=""){const t=Object.assign({async:!0,attributes:{"data-merchant-id":e}},e&&{attributes:{"data-merchant-id":e}});if(yield this.scriptLoader.loadScript("//www.paypalobjects.com/api/checkout.min.js",t),!this.window.paypal)throw new I;return this.window.paypal},new((n=void 0)||(n=Promise))(function(a,s){function r(e){try{c(i.next(e))}catch(e){s(e)}}function o(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,o)}c((i=i.apply(e,t||[])).next())});var e,t,n,i}}const w=i(t=>new f(t,new b(e())),[{id:"paypalexpress",type:"PAYMENT_TYPE_HOSTED"},{id:"paypalexpresscredit",type:"PAYMENT_TYPE_HOSTED"}]);class P extends a{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}const M={"X-Checkout-SDK-Version":"1.945.0"};var v=function(e,t,n,i){return new(n||(n=Promise))(function(a,s){function r(e){try{c(i.next(e))}catch(e){s(e)}}function o(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,o)}c((i=i.apply(e,t||[])).next())})};class S{constructor(e,t,n){this.paymentIntegrationService=e,this.paypalExpressScriptLoader=t,this.formPoster=n}initialize(e){return v(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!e.paypal)throw new P;if(!t.config.merchantId)throw new h(s.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:a}=e,{allowCredit:r,clientId:o,onPaymentError:c,shouldProcessPayment:d,style:l}=a,u=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!u.config.merchantId)throw new h(s.MissingPaymentMethod);const p=u.config.merchantId,y=u.config.testMode?"sandbox":"production",m={[y]:o},g=t.FUNDING.CREDIT||"credit",f=r?[g]:[],I=r?[]:[g];return t.Button.render({env:y,client:m,commit:d,funding:{allowed:f,disallowed:I},style:this.getStyle(l),payment:(e,t)=>this.setupPayment(p,t,c),onAuthorize:(e,t)=>this.tokenizePayment(e,i,t,d)},n)}getStyle(e){const{color:t,fundingicons:n,label:i,layout:a,shape:s,size:r,tagline:o}=e||{};return{color:t,fundingicons:n,label:i,layout:a,shape:s||u.RECT,size:"small"===r?c.RESPONSIVE:r,tagline:o}}setupPayment(e,t,n){return v(this,void 0,void 0,function*(){if(!t)throw new y(r.CheckoutButtonNotInitialized);try{const n=yield this.paymentIntegrationService.loadDefaultCheckout(),{id:i}=n.getCartOrThrow(),a=n.getHost()||"";return(yield t.request.post(`${a}/api/storefront/payment/paypalexpress`,{merchantId:e,cartId:i},{headers:Object.assign({"X-API-INTERNAL":"This API endpoint is for internal use only and may change in the future"},M)})).id}catch(e){throw n&&e instanceof a&&n(e),e}})}tokenizePayment(e,t,n,i){return v(this,void 0,void 0,function*(){if(!n)throw new y(r.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new h(s.MissingPayment);const a=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),o=yield n.payment.get(e.paymentID);return this.formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:a.id,action:i?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(o.payer.payer_info)})})}}const E=i(t=>new S(t,new b(e()),n()),[{id:"paypalexpress"}]);export{E as createPaypalExpressButtonStrategy,w 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 a 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 s,r,o,c,d,l,u,p;!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(s||(s={}));class h extends a{constructor(e){super(function(e){switch(e){case s.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case s.MissingCart:return"Unable to proceed because cart data is unavailable.";case s.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case s.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case s.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case s.MissingCheckoutConfig:case s.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case s.MissingOrder:return"Unable to proceed because order data is unavailable.";case s.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case s.MissingPayment:return"Unable to proceed because payment data is unavailable.";case s.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case s.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case s.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}!function(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"}(r||(r={}));class y extends a{constructor(e){super(function(e){switch(e){case r.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case r.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case r.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case r.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}class m extends a{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(o||(o={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(c||(c={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black"}(d||(d={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(l||(l={})),function(e){e.PILL="pill",e.RECT="rect"}(u||(u={})),function(e){e.ACKNOWLEDGE="ACKNOWLEDGE",e.FINALIZE="FINALIZE",e.INITIALIZE="INITIALIZE"}(p||(p={}));var g=function(e,t,n,i){return new(n||(n=Promise))(function(a,s){function r(e){try{c(i.next(e))}catch(e){s(e)}}function o(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,o)}c((i=i.apply(e,t||[])).next())})};class f{constructor(e,t){this.paymentIntegrationService=e,this.scriptLoader=t,this.useRedirectFlow=!1,this.window=window}initialize(e){return g(this,void 0,void 0,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 h(s.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 g(this,void 0,void 0,function*(){let i,a;const s=this.paypalSdk;if(!this.isAcknowledgedOrFinalized()){if(!this.isInContextEnabled()||this.useRedirectFlow)return i=yield this.paymentIntegrationService.submitOrder(e,n),a=i.getPaymentRedirectUrl(),a&&this.window.top&&(this.window.top.location.href=a),new Promise(t);if(!s)throw new y(r.PaymentNotInitialized);s.checkout.initXO();try{i=yield this.paymentIntegrationService.submitOrder(e,n)}catch(e){return s.checkout.closeFlow(),Promise.reject(e)}return a=i.getPaymentRedirectUrl(),a&&s.checkout.startFlow(a),new Promise(t)}yield this.paymentIntegrationService.submitOrder(e,n)})}finalize(e){return g(this,void 0,void 0,function*(){return this.paymentIntegrationService.getState().getOrder()&&this.isAcknowledgedOrFinalized()?(yield this.paymentIntegrationService.finalizeOrder(e),Promise.resolve()):Promise.reject(new m)})}isAcknowledgedOrFinalized(){const e=this.paymentIntegrationService.getState();return e.getPaymentStatus()===p.ACKNOWLEDGE||e.getPaymentStatus()===p.FINALIZE}isInContextEnabled(){return!(!this.paymentMethod||!this.paymentMethod.config.merchantId)}}class I extends a{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}class b{constructor(e){this.scriptLoader=e,this.window=window}loadPaypalSDK(){return e=this,t=arguments,i=function*(e=""){const t=Object.assign({async:!0,attributes:{"data-merchant-id":e}},e&&{attributes:{"data-merchant-id":e}});if(yield this.scriptLoader.loadScript("//www.paypalobjects.com/api/checkout.min.js",t),!this.window.paypal)throw new I;return this.window.paypal},new((n=void 0)||(n=Promise))(function(a,s){function r(e){try{c(i.next(e))}catch(e){s(e)}}function o(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,o)}c((i=i.apply(e,t||[])).next())});var e,t,n,i}}const w=i(t=>new f(t,new b(e())),[{id:"paypalexpress",type:"PAYMENT_TYPE_HOSTED"},{id:"paypalexpresscredit",type:"PAYMENT_TYPE_HOSTED"}]);class P extends a{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}const M={"X-Checkout-SDK-Version":"1.946.0"};var v=function(e,t,n,i){return new(n||(n=Promise))(function(a,s){function r(e){try{c(i.next(e))}catch(e){s(e)}}function o(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,o)}c((i=i.apply(e,t||[])).next())})};class S{constructor(e,t,n){this.paymentIntegrationService=e,this.paypalExpressScriptLoader=t,this.formPoster=n}initialize(e){return v(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!e.paypal)throw new P;if(!t.config.merchantId)throw new h(s.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:a}=e,{allowCredit:r,clientId:o,onPaymentError:c,shouldProcessPayment:d,style:l}=a,u=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!u.config.merchantId)throw new h(s.MissingPaymentMethod);const p=u.config.merchantId,y=u.config.testMode?"sandbox":"production",m={[y]:o},g=t.FUNDING.CREDIT||"credit",f=r?[g]:[],I=r?[]:[g];return t.Button.render({env:y,client:m,commit:d,funding:{allowed:f,disallowed:I},style:this.getStyle(l),payment:(e,t)=>this.setupPayment(p,t,c),onAuthorize:(e,t)=>this.tokenizePayment(e,i,t,d)},n)}getStyle(e){const{color:t,fundingicons:n,label:i,layout:a,shape:s,size:r,tagline:o}=e||{};return{color:t,fundingicons:n,label:i,layout:a,shape:s||u.RECT,size:"small"===r?c.RESPONSIVE:r,tagline:o}}setupPayment(e,t,n){return v(this,void 0,void 0,function*(){if(!t)throw new y(r.CheckoutButtonNotInitialized);try{const n=yield this.paymentIntegrationService.loadDefaultCheckout(),{id:i}=n.getCartOrThrow(),a=n.getHost()||"";return(yield t.request.post(`${a}/api/storefront/payment/paypalexpress`,{merchantId:e,cartId:i},{headers:Object.assign({"X-API-INTERNAL":"This API endpoint is for internal use only and may change in the future"},M)})).id}catch(e){throw n&&e instanceof a&&n(e),e}})}tokenizePayment(e,t,n,i){return v(this,void 0,void 0,function*(){if(!n)throw new y(r.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new h(s.MissingPayment);const a=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),o=yield n.payment.get(e.paymentID);return this.formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:a.id,action:i?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(o.payer.payer_info)})})}}const E=i(t=>new S(t,new b(e()),n()),[{id:"paypalexpress"}]);export{E as createPaypalExpressButtonStrategy,w as createPaypalExpressPaymentStrategy};
2
2
  //# sourceMappingURL=paypal-express.js.map
@@ -1,2 +1,2 @@
1
- import{createRequestSender as e}from"@bigcommerce/request-sender";var t;!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(t||(t={}));const n=t,i={"X-Checkout-SDK-Version":"1.945.0"};var r;class s{constructor(e){this._requestSender=e}saveExternalId(e,t){return r=this,s=void 0,o=function*(){const r=`/api/storefront/payment/${e}/save-external-id`,s={headers:Object.assign({Accept:n.JsonV1,"X-API-INTERNAL":"This API endpoint is for internal use only and may change in the future"},i),body:{externalId:t,provider:e}};yield this._requestSender.post(r,s)},new((a=void 0)||(a=Promise))(function(e,t){function n(e){try{c(o.next(e))}catch(e){t(e)}}function i(e){try{c(o.throw(e))}catch(e){t(e)}}function c(t){var r;t.done?e(t.value):(r=t.value,r instanceof a?r:new a(function(e){e(r)})).then(n,i)}c((o=o.apply(r,s||[])).next())});var r,s,a,o}}class a 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 o extends a{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class c extends o{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"}}!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(r||(r={}));class d extends a{constructor(e){super(function(e){switch(e){case r.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case r.MissingCart:return"Unable to proceed because cart data is unavailable.";case r.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case r.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case r.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case r.MissingCheckoutConfig:case r.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case r.MissingOrder:return"Unable to proceed because order data is unavailable.";case r.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case r.MissingPayment:return"Unable to proceed because payment data is unavailable.";case r.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case r.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case r.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}class u extends a{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}class l{constructor(e,t){this.paymentIntegrationService=e,this.storefrontPaymentRequestSender=t}initialize(){return Promise.resolve()}execute(e,t){return n=this,i=void 0,a=function*(){const{payment:n}=e,i=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["payment"]);if(!n)throw new c(["payment"]);const{methodId:s}=n,{getPaymentMethodOrThrow:a}=yield this.paymentIntegrationService.loadPaymentMethod(s,t),{clientToken:o,initializationData:u}=a(s),l=null==u?void 0:u.redirectUrl;if(!o||!l)throw new d(r.MissingPaymentMethod);const{id:g}=JSON.parse(o);if(!g)throw new d(r.MissingPaymentToken);const{isStoreCreditApplied:p}=this.paymentIntegrationService.getState().getCheckoutOrThrow();yield this.paymentIntegrationService.applyStoreCredit(p),yield this.paymentIntegrationService.initializePayment(s,{useStoreCredit:p}),yield this.paymentIntegrationService.submitOrder(i,t),yield this._prepareForReferredRegistration(s,g);try{yield this.paymentIntegrationService.submitPayment({methodId:s,paymentData:{nonce:g}})}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(l));throw e}},new((s=void 0)||(s=Promise))(function(e,t){function r(e){try{c(a.next(e))}catch(e){t(e)}}function o(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof s?n:new s(function(e){e(n)})).then(r,o)}c((a=a.apply(n,i||[])).next())});var n,i,s,a}finalize(){return Promise.reject(new u)}deinitialize(){return Promise.resolve()}_prepareForReferredRegistration(e,t){return this.storefrontPaymentRequestSender.saveExternalId(e,t)}}const g=(p=t=>{const{getHost:n}=t.getState(),i=e({host:n()}),r=new s(i);return new l(t,r)},y=[{id:"zip"},{id:"quadpay"}],Object.assign(p,{resolveIds:y}));var p,y;export{g as createZipPaymentStrategy};
1
+ import{createRequestSender as e}from"@bigcommerce/request-sender";var t;!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(t||(t={}));const n=t,i={"X-Checkout-SDK-Version":"1.946.0"};var r;class s{constructor(e){this._requestSender=e}saveExternalId(e,t){return r=this,s=void 0,o=function*(){const r=`/api/storefront/payment/${e}/save-external-id`,s={headers:Object.assign({Accept:n.JsonV1,"X-API-INTERNAL":"This API endpoint is for internal use only and may change in the future"},i),body:{externalId:t,provider:e}};yield this._requestSender.post(r,s)},new((a=void 0)||(a=Promise))(function(e,t){function n(e){try{c(o.next(e))}catch(e){t(e)}}function i(e){try{c(o.throw(e))}catch(e){t(e)}}function c(t){var r;t.done?e(t.value):(r=t.value,r instanceof a?r:new a(function(e){e(r)})).then(n,i)}c((o=o.apply(r,s||[])).next())});var r,s,a,o}}class a 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 o extends a{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class c extends o{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"}}!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(r||(r={}));class d extends a{constructor(e){super(function(e){switch(e){case r.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case r.MissingCart:return"Unable to proceed because cart data is unavailable.";case r.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case r.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case r.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case r.MissingCheckoutConfig:case r.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case r.MissingOrder:return"Unable to proceed because order data is unavailable.";case r.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case r.MissingPayment:return"Unable to proceed because payment data is unavailable.";case r.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case r.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case r.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}class u extends a{constructor(){super("The current order does not need to be finalized at this stage."),this.name="OrderFinalizationNotRequiredError",this.type="order_finalization_not_required"}}class l{constructor(e,t){this.paymentIntegrationService=e,this.storefrontPaymentRequestSender=t}initialize(){return Promise.resolve()}execute(e,t){return n=this,i=void 0,a=function*(){const{payment:n}=e,i=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["payment"]);if(!n)throw new c(["payment"]);const{methodId:s}=n,{getPaymentMethodOrThrow:a}=yield this.paymentIntegrationService.loadPaymentMethod(s,t),{clientToken:o,initializationData:u}=a(s),l=null==u?void 0:u.redirectUrl;if(!o||!l)throw new d(r.MissingPaymentMethod);const{id:g}=JSON.parse(o);if(!g)throw new d(r.MissingPaymentToken);const{isStoreCreditApplied:p}=this.paymentIntegrationService.getState().getCheckoutOrThrow();yield this.paymentIntegrationService.applyStoreCredit(p),yield this.paymentIntegrationService.initializePayment(s,{useStoreCredit:p}),yield this.paymentIntegrationService.submitOrder(i,t),yield this._prepareForReferredRegistration(s,g);try{yield this.paymentIntegrationService.submitPayment({methodId:s,paymentData:{nonce:g}})}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(l));throw e}},new((s=void 0)||(s=Promise))(function(e,t){function r(e){try{c(a.next(e))}catch(e){t(e)}}function o(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof s?n:new s(function(e){e(n)})).then(r,o)}c((a=a.apply(n,i||[])).next())});var n,i,s,a}finalize(){return Promise.reject(new u)}deinitialize(){return Promise.resolve()}_prepareForReferredRegistration(e,t){return this.storefrontPaymentRequestSender.saveExternalId(e,t)}}const g=(p=t=>{const{getHost:n}=t.getState(),i=e({host:n()}),r=new s(i);return new l(t,r)},y=[{id:"zip"},{id:"quadpay"}],Object.assign(p,{resolveIds:y}));var p,y;export{g as createZipPaymentStrategy};
2
2
  //# sourceMappingURL=zip.js.map
@@ -1,2 +1,2 @@
1
- import{createRequestSender as e}from"@bigcommerce/request-sender";import{getScriptLoader as t}from"@bigcommerce/script-loader";import{supportsPopups as n}from"@braintree/browser-detection";import{isEmpty as i,isNil as r,omitBy as o,uniqueId as a}from"lodash";var s={d:(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},c={};s.r(c),s.d(c,{createBraintreePaypalCreditWalletStrategy:()=>ae,createBraintreePaypalWalletStrategy:()=>ie,createBraintreeVenmoWalletStrategy:()=>ue,createPayPalCommerceCreditWalletStrategy:()=>be,createPayPalCommerceWalletStrategy:()=>ze});var l=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class d{constructor(e){this.requestSender=e}updateBillingAddress(e,t,n,i){return l(this,void 0,void 0,function*(){const{id:r}=n,o=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(n,["id"]),a={headers:Object.assign(Object.assign({},null==i?void 0:i.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:Object.assign({},o)}}}}},s=yield this.requestSender.post(`${window.location.origin}/${e}`,a),{billingAddress:c}=s.body.data.checkout.updateCheckoutBillingAddress.checkout;return Object.assign(Object.assign({},s),{body:c})})}addBillingAddress(e,t,n,i){return l(this,void 0,void 0,function*(){const r={headers:Object.assign(Object.assign({},null==i?void 0:i.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:Object.assign({},n)}}}}},o=yield this.requestSender.post(`${window.location.origin}/${e}`,r),{billingAddress:a}=o.body.data.checkout.addCheckoutBillingAddress.checkout;return Object.assign(Object.assign({},o),{body:a})})}}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 h extends u{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"}}class y{constructor(e){this.requestSender=e}getRedirectToCheckoutUrl(e,t,n){return i=this,r=void 0,a=function*(){var i;const r={headers:Object.assign(Object.assign({},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}`,r),{data:{cart:{createCartRedirectUrls:n}}}=t.body,o=null===(i=n.errors[0])||void 0===i?void 0:i.message;if(o)throw new h(o);if(n.errors.length>0)throw new h;return Object.assign(Object.assign({},t),{body:{redirectUrls:n.redirectUrls}})}catch(e){if(e instanceof Error)throw e;throw new Error("Checkout redirection failed")}},new((o=void 0)||(o=Promise))(function(e,t){function n(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof o?i:new o(function(e){e(i)})).then(n,s)}c((a=a.apply(i,r||[])).next())});var i,r,o,a}}class M extends u{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}class p extends u{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"}}class g{constructor(e){this.requestSender=e}createPaymentOrderIntent(e,t,n){return i=this,r=void 0,a=function*(){var i;const r={headers:Object.assign(Object.assign({},null==n?void 0:n.headers),{"Content-Type":"application/json","x-catalyst-graphql-proxy-requester":"checkout-sdk-js"}),body:{query:"\n mutation CreatePaymentWalletIntentMutation(\n $input: CreatePaymentWalletIntentInput!\n ) {\n payment {\n paymentWallet {\n createPaymentWalletIntent(input: $input) {\n paymentWalletIntentData {\n __typename\n ... on PayPalCommercePaymentWalletIntentData {\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 ",variables:{input:t}}};try{const t=yield this.requestSender.post(`${window.location.origin}/${e}`,r),{data:{payment:{paymentWallet:{createPaymentWalletIntent:{paymentWalletIntentData:n,errors:o}}}}}=t.body,a=null===(i=o[0])||void 0===i?void 0:i.message;if(a)throw new p(a);return Object.assign(Object.assign({},t),{body:Object.assign({},n)})}catch(e){if(!(e instanceof p))throw new M;throw e}},new((o=void 0)||(o=Promise))(function(e,t){function n(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof o?i:new o(function(e){e(i)})).then(n,s)}c((a=a.apply(i,r||[])).next())});var i,r,o,a}}var _=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class w{constructor(e,t,n,i){this.graphQLEndpoint=e,this.billingAddressRequestSender=t,this.paymentRequestSender=n,this.checkoutRequestSender=i}addBillingAddress(e,t,n){return _(this,void 0,void 0,function*(){return this.billingAddressRequestSender.addBillingAddress(this.graphQLEndpoint,e,t,n)})}updateBillingAddress(e,t,n){return _(this,void 0,void 0,function*(){return this.billingAddressRequestSender.updateBillingAddress(this.graphQLEndpoint,e,t,n)})}createPaymentOrderIntent(e,t){return _(this,void 0,void 0,function*(){return this.paymentRequestSender.createPaymentOrderIntent(this.graphQLEndpoint,e,t)})}getRedirectToCheckoutUrl(e,t){return _(this,void 0,void 0,function*(){return this.checkoutRequestSender.getRedirectToCheckoutUrl(this.graphQLEndpoint,e,t)})}}class C extends u{constructor(e){super(e||"Unsupported browser error"),this.name="UnsupportedBrowserError",this.type="unsupported_browser"}}class m extends u{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class f extends m{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 N extends u{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 v;!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(v||(v={}));class I extends u{constructor(e){super(function(e){switch(e){case v.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case v.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case v.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case v.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}let T=null;const z=["buttons","messages"];var L,D,b,A,j,O,S,E,P;function k(e){return Boolean("object"==typeof e&&null!==e&&("type"in e||"message"in e||"code"in e))}!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(L||(L={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(D||(D={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white"}(b||(b={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(A||(A={})),function(e){e.PILL="pill",e.RECT="rect"}(j||(j={})),function(e){e.CART="cart",e.HOME="homepage",e.PAYMENT="payment",e.PRODUCT="product"}(O||(O={})),function(e){e.Sandbox="sandbox",e.Production="production"}(S||(S={})),function(e){e.Client="client",e.DataCollector="dataCollector",e.Fastlane="fastlane",e.GooglePayment="googlePayment",e.HostedFields="hostedFields",e.LocalPayment="localPayment",e.Paypal="paypal",e.PaypalCheckout="paypalCheckout",e.ThreeDSecure="threeDSecure",e.UsBankAccount="usBankAccount",e.Venmo="venmo",e.VisaCheckout="visaCheckout"}(E||(E={})),function(e){e.CardCode="cardCode",e.CardCodeVerification="cardCodeVerification",e.CardExpiry="cardExpiry",e.CardName="cardName",e.CardNumber="cardNumber",e.CardNumberVerification="cardNumberVerification"}(P||(P={}));var x=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class U{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 x(this,void 0,void 0,function*(){if(t&&(window.localStorage.setItem("axoEnv","sandbox"),window.localStorage.setItem("fastlaneEnv","sandbox")),!this.braintreeHostWindow.braintreeFastlane){const t=this.getClientTokenOrThrow(),i=yield this.getClient(),r=yield this.getSessionId(e),o=yield this.braintreeScriptLoader.loadFastlane(),a={root:{backgroundColorPrimary:"transparent"}};this.braintreeHostWindow.braintreeFastlane=yield o.create({authorization:t,client:i,deviceData:r,styles:n||a})}return this.braintreeHostWindow.braintreeFastlane})}getClient(){return x(this,void 0,void 0,function*(){if(!this.client){const e=this.getClientTokenOrThrow(),t=yield this.braintreeScriptLoader.loadClient();this.client=t.create({authorization:e})}return this.client})}getPaypal(){return this.braintreePaypal||(this.braintreePaypal=Promise.all([this.getClient(),this.braintreeScriptLoader.loadPaypal()]).then(([e,t])=>t.create({client:e}))),this.braintreePaypal}paypal(e){var{shouldSaveInstrument:t}=e,i=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["shouldSaveInstrument"]);const r=n();return this.getPaypal().then(e=>{var n;return r&&(null===(n=this.overlay)||void 0===n||n.show({onClick:()=>e.focusWindow()})),e.tokenize(Object.assign({enableShippingAddress:!0,flow:t?"vault":"checkout",useraction:"commit"},i))}).then(e=>{var t;return null===(t=this.overlay)||void 0===t||t.remove(),e}).catch(e=>{var t;throw null===(t=this.overlay)||void 0===t||t.remove(),e})}getPaypalCheckout(e,t,n){return x(this,void 0,void 0,function*(){const i=yield this.getClient(),r=yield this.braintreeScriptLoader.loadPaypalCheckout(),o={client:i};return this.paypalCheckout=yield r.create(o,(i,r)=>{var o;if(i)return n(i);const a=Object.assign(Object.assign({currency:e.currency},e.isCreditEnabled&&{"enable-funding":"paylater"}),{components:z.toString(),intent:e.intent,commit:null===(o=e.commit)||void 0===o||o});this.braintreeHostWindow.paypal?t(r):function(e,t){return T||(T=new Promise((n,i)=>{e.loadPayPalSDK(t,t=>{t?(T=null,i(t)):n(e)})})),T}(r,a).then(()=>t(r))}),this.paypalCheckout})}getDataCollector(e){return x(this,void 0,void 0,function*(){const t=(null==e?void 0:e.paypal)?"paypal":"default";let n=this.dataCollectors[t];if(!n){try{const t=yield this.getClient(),i=yield this.braintreeScriptLoader.loadDataCollector(),r=Object.assign({client:t,kount:!0},e);n=yield i.create(r)}catch(e){if(!k(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?S.Sandbox:S.Production}mapToBraintreeShippingAddressOverride(e){return{recipientName:`${e.firstName} ${e.lastName}`,line1:e.address1,line2:e.address2,city:e.city,state:e.stateOrProvinceCode,postalCode:e.postalCode,countryCode:e.countryCode,phone:e.phone}}mapToLegacyShippingAddress(e){const{email:t,phone:n,shippingAddress:i}=e,r=(null==i?void 0:i.recipientName)||"",[o,a]=r.split(" ");return{email:t,first_name:o||"",last_name:a||"",phone_number:n,address_line_1:null==i?void 0:i.line1,address_line_2:null==i?void 0:i.line2,city:null==i?void 0:i.city,state:null==i?void 0:i.state,country_code:null==i?void 0:i.countryCode,postal_code:null==i?void 0:i.postalCode}}mapToLegacyBillingAddress(e){const{billingAddress:t,email:n,firstName:i,lastName:r,phone:o,shippingAddress:a}=e,s=t||a;return{email:n,first_name:i,last_name:r,phone_number:o,address_line_1:null==s?void 0:s.line1,address_line_2:null==s?void 0:s.line2,city:null==s?void 0:s.city,state:null==s?void 0:s.state,country_code:null==s?void 0:s.countryCode,postal_code:null==s?void 0:s.postalCode}}removeElement(e){const t=e&&document.getElementById(e);t&&t.remove()}getSessionId(e){return x(this,void 0,void 0,function*(){const{deviceData:t}=yield this.getDataCollector({riskCorrelationId:e});return t})}teardown(){return x(this,void 0,void 0,function*(){yield this.teardownModule(this.dataCollectors.default),yield this.teardownModule(this.dataCollectors.paypal),this.dataCollectors={},yield this.teardownModule(this.paypalCheckout),this.paypalCheckout=void 0})}get3DS(){return x(this,void 0,void 0,function*(){return this.threeDS||(this.threeDS=Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()]).then(([e,t])=>t.create({client:e,version:2}))),this.threeDS})}getVenmoCheckout(e){return x(this,void 0,void 0,function*(){if(!this.venmoCheckout){const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadVenmoCheckout(),i=Object.assign({client:t,allowDesktop:!0,paymentMethodUsage:"multi_use"},e||{});this.venmoCheckout=yield new Promise((e,t)=>{n.create(i,(n,i)=>n?t(n):i.isBrowserSupported()?void e(i):t(new C))})}return this.venmoCheckout})}verifyCard(e,t,n){return x(this,void 0,void 0,function*(){const i=yield this.tokenizeCard(e,t);return this.challenge3DSVerification(i,n)})}tokenizeCard(e,t){return x(this,void 0,void 0,function*(){const{paymentData:n}=e;if(!function(e){if("object"!=typeof e||null===e)return!1;const t=e;return"object"==typeof t.ccExpiry&&null!==t.ccExpiry&&"string"==typeof t.ccNumber&&"string"==typeof t.ccName}(n))throw new f(["payment.paymentData"]);const r=this.getErrorsRequiredFields(n);if(!i(r))throw new N(r);const o=this.mapToCreditCard(n,t),a=yield this.getClient(),{creditCards:s}=yield a.request(o);return{nonce:s[0].nonce,bin:s[0].details.bin}})}challenge3DSVerification(e,t){return x(this,void 0,void 0,function*(){const n=yield this.get3DS();return this.present3DSChallenge(n,t,e)})}teardownModule(e){return e?e.teardown():Promise.resolve()}getClientTokenOrThrow(){if(!this.clientToken)throw new I(v.PaymentNotInitialized);return this.clientToken}getErrorsRequiredFields(e){const{ccNumber:t,ccExpiry:n}=e,i={};return t||(i.ccNumber=[{message:"Credit card number is required",type:"required"}]),n||(i.ccExpiry=[{message:"Expiration date is required",type:"required"}]),i}mapToCreditCard(e,t){return{data:{creditCard:{cardholderName:e.ccName,number:e.ccNumber,cvv:e.ccCvv,expirationDate:`${e.ccExpiry.month}/${e.ccExpiry.year}`,options:{validate:!1},billingAddress:t&&{countryCodeAlpha2:t.countryCode,locality:t.city,countryName:t.country,postalCode:t.postalCode,streetAddress:t.address2?`${t.address1} ${t.address2}`:t.address1}}},endpoint:"payment_methods/credit_cards",method:"post"}}present3DSChallenge(e,t,n){const{nonce:i,bin:r}=n;if(!i)throw new I(v.PaymentNotInitialized);const{challengeRequested:o=!0,additionalInformation:a}=this.threeDSecureOptions||{},s=t.toFixed(2);return e.verifyCard({amount:Number(s),bin:r,challengeRequested:o,nonce:i,onLookupComplete:(e,t)=>{t()},collectDeviceData:!0,additionalInformation:a})}}class B extends u{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"}}const G="3.128.0",Y="3.123.2",W="3.106.0",R={[W]:{[E.Client]:"sha384-26BXDNnJI23JYRyFBj4xe4sVNrUSSiSSu11kxVXNM/vEPONm4LuL00w6ZaTgQewt",[E.PaypalCheckout]:"sha384-B+vzbZwnQtzWBthpkT4TXKUibO65tyeK7eCxSvpblgprTep2+IAXB2Cxxjrn710O",[E.Paypal]:"sha384-uyAGL1/3+XJAHnGoNy4eCoXdzJ4f7Ilzp+6w9PNnEjs6DCCz9WMyJjMN1gzc78U+",[E.LocalPayment]:"sha384-LIvOEMkIVEwVuYBdVOQc1AC5YbGGlwyfUheS0ACK218D2STuVYQlZ4FyEPowAEfT",[E.DataCollector]:"sha384-1bo9JDz+Kscthc085cCKWur8CLwUoBpoNyxsDi7932mCl0zFq3A5mv+FQLw9GHpV",[E.UsBankAccount]:"sha384-xmHBVaU+w74V+OebD3AaPONFxHUGMf+QRs8G/JxVPXNNP7MDa2jL0ICWHIe2tTfJ",[E.GooglePayment]:"sha384-WKDJl8mqoP82qZpMGH6AbZxnvXnSW8ILV4M64CyMLiugGMwu7LyP89wjCkHqsiBe",[E.ThreeDSecure]:"sha384-VQUlpGHzsGvs5XeiGFip7EXRsvoHWEXDVmgCacfbyieZI9mdBOqq3NSoyo28OCOB",[E.VisaCheckout]:"sha384-yx7mADfzTN0T43Q6rlH49LIg1EJ0iUZgBp/EczX9LXsUGkySgxrD+nWHQRBkyfoT",[E.Venmo]:"sha384-QX4rPjoj1ZDhuG0aSyKs56lEKDqTMTcjYxUHY1SzO5VZDsqIE2NTkqot7KNSCyov",[E.HostedFields]:"sha384-VvYBACfSu0Cr/J32uKmxG7AXcNOJE1AzIIL3kbikyS7YKp5fz5Is+NzNP/lyauNy",[E.Fastlane]:"sha384-9oGsZMRZwpGtDEDYa/dFt76dECqj1xAni9gIKgc3KfMIiRnR73nEeeUDLiBzxhFa"},[Y]:{[E.Client]:"sha384-o+nbQGcwNNxIBeXeu3+XmbSq+Cg8R3EN3N0l5hXCgMMU2RGY0t1z0LroSEIAbfAO",[E.PaypalCheckout]:"sha384-WrfbWPBS4mH86GAoycPSgiH8hQ8KH7A67C93Hjhunv/xhNk2YpBn3wbFA4Fhg9U/",[E.Paypal]:"sha384-VF389nvvrRUgDsTXMxTYORDtVegB9IQa3Cxr//DyJnLYnz8/X8VCzEvck2c+Megt",[E.LocalPayment]:"sha384-tZKx2rEQbfmZpoPSY5VPmJEhaq4X75dLvwHMs3VE9U+C8lPyw+hWTIL1+GPvWCIH",[E.DataCollector]:"sha384-E6k3wOpP7syCDDwaRDLF06942Y00NkbwJvWi2OQXwwKzGwG5fd3E7RFUvCCecfvO",[E.UsBankAccount]:"sha384-258FON8LZGG0W9Qaz4Jij83pZHu30YnKjJA7gNulLBh6CclkucgF+tHDQuYFRYfW",[E.GooglePayment]:"sha384-taJ2p/0+n0VH328POAoBiuEbL3tnHUTE9S42hK1V+Txs3X+QYjZOyKW35JgHRFfO",[E.ThreeDSecure]:"sha384-+NSZH4Zj3sO5bdWvPKhU5N16QDxeueTVTnUVeleeESkhLSaz4Ob1hh/5myecc9Ym",[E.VisaCheckout]:"sha384-66DiBjghxk1OmBj8aksN8gbQ+CwoQcx1vPfiXUN08g1iQVM+BwewF0p7toM3i7SS",[E.Venmo]:"sha384-B5UwY42kE4RoLoWbQ7YpqosUlUad2/DlGWiw0HhoZbSPk30CQAaSA10ohyLDTkDU",[E.HostedFields]:"sha384-Aw9EesSaUeWxe36PqEHiOyOyOq8M6CIb1gw7/yHNVPRzGtFXXcd2OQ8qXrIlOj2P",[E.Fastlane]:"sha384-rhBL1hpZ71JqG+2TsT0Dih47mbjx8cjJCpeZjk9tw3df1gFMKfCTmMyZunhr7H4Y"},[G]:{[E.Client]:"sha384-0WNxksIpRP+fYZiIdr12g6DBUQfLDzYCQJZtR/C8KkcwSGhPHfcFp3tTaGcMyFTq",[E.PaypalCheckout]:"sha384-lWM1jk4BOxoDNV6Kop7tVNvQgINlmEVz0c/OwM+HNHK3QC8xqwd54Ovrt2QRDTjh",[E.Paypal]:"sha384-fXUmVxC2EMZBDXZ7eTHSTL/LFBrHej/MSXT/vTBXvra4lzgLNGvREAp+x0GYObuH",[E.LocalPayment]:"sha384-pha1xGuGSkmZH5x9aqHvRaO4xLea7rmQ/79PFj9zxNzxuFcOWZg7gOP7FibygOEC",[E.DataCollector]:"sha384-Q6PI2F9eekWbAxhroybl+aEcvqhdowN/EQlGwBUyJOzPFn9982u9xl6SU6XfGKzc",[E.UsBankAccount]:"sha384-W3RLQSKJL1tQ3+Y7mP6tmkamtZ8bV4Yw/XxL9Jj5JtXHraD8loMF8hAIG5m2zK7F",[E.GooglePayment]:"sha384-TITQMsFWA3elDNGP2mWz2oKBo4qjt+TlqzovcaPoeBiAh/wPBi6nae50ADdgU1/i",[E.ThreeDSecure]:"sha384-YiycYN89ZlL/Evcaq4y1ajW1mhd7JYfZBDuOwHtIn4/Jnm20GL+/XCM+zYAwWD8D",[E.VisaCheckout]:"sha384-/OdaTv9qrkKzjObtUe6yzfDhHozFW/+uXlrSl736sOZRJpjGQETvpYXqMFFg69xv",[E.Venmo]:"sha384-dA+ojdW9vbJS4JavcXyOs9d5uZHJg5dNtYupoPSH2zsXIiYDVS5amLb/u8qmQ6oz",[E.HostedFields]:"sha384-31ZkS58+iaWsW06ftW52zzVZFp43WPd7pNYRiddYynSNg6Oh7WGbSFGorAUH6T1z",[E.Fastlane]:"sha384-jlbrwNvL3HvLAUCtLSmrnQ2GH1udCUrRS/bVmReAS5fuIVvcW8Pko/Gkg82tlgtr"}};var Q=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class H{constructor(e,t,n){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSDKVersionManager=n}loadClient(){return Q(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.Client,"client.min.js")})}loadFastlane(){return Q(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.Fastlane,"fastlane.min.js")})}loadPaypalCheckout(){return Q(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.PaypalCheckout,"paypal-checkout.min.js")})}loadPaypal(){return Q(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.Paypal,"paypal.min.js")})}loadLocalPayment(){return Q(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.LocalPayment,"local-payment.min.js")})}loadDataCollector(){return Q(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.DataCollector,"data-collector.min.js")})}loadUsBankAccount(){return Q(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.UsBankAccount,"us-bank-account.min.js")})}loadGooglePayment(){return Q(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.GooglePayment,"google-payment.min.js")})}load3DS(){return Q(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.ThreeDSecure,"three-d-secure.min.js")})}loadVisaCheckout(){return this.loadBraintreeModuleOrThrow(E.VisaCheckout,"visa-checkout.min.js")}loadVenmoCheckout(){return this.loadBraintreeModuleOrThrow(E.Venmo,"venmo.min.js")}loadHostedFields(){return Q(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.HostedFields,"hosted-fields.min.js")})}loadVisaCheckoutSdk(e){return Q(this,void 0,void 0,function*(){if(this.braintreeHostWindow.V)return this.braintreeHostWindow.V;const t=e?"sha384-0eu1s1GtqzXlL9DtLgmwzC5WWlEH/ADRM0n38cVQkvtT+W/gey96rcb1LwuUOPDm":"sha384-1f1csvP3ZFxg4dILH1GaY4LHlZ0oX7Rk83rxmLlwbnIi4TM0NYzXoev1VoEiVDS6";return this.scriptLoader.loadScript(`//${e?"sandbox-":""}assets.secure.checkout.visa.com/checkout-widget/resources/js/integration/v1/sdk.js`,{async:!0,attributes:{integrity:t,crossorigin:"anonymous"}}).then(()=>{if(!this.braintreeHostWindow.V)throw new B;return this.braintreeHostWindow.V})})}loadBraintreeModuleOrThrow(e,t){return Q(this,void 0,void 0,function*(){let n=this.getBraintreeModule(e);if(n)return n;const i=this.braintreeSDKVersionManager.getSDKVersion(),r=`//js.braintreegateway.com/web/${i}/js/${t}`,o=i in R?this.getIntegrityValuesByModuleName(e,i):void 0;if(yield this.scriptLoader.loadScript(r,o?{async:!0,attributes:{integrity:o,crossorigin:"anonymous"}}:void 0),n=this.getBraintreeModule(e),!n)throw new B;return n})}getBraintreeModule(e){var t;return null===(t=this.braintreeHostWindow.braintree)||void 0===t?void 0:t[e]}getIntegrityValuesByModuleName(e,t){const n=R[t][e];if(!n)throw new Error("Unexpected fileName value");return n}}class V{getSDKVersion(){return Y}}class Z extends u{constructor(e){super(e||"Failed to redirect to checkout page"),this.name="BraintreePaypalWalletError",this.type="braintree_paypal_wallet"}}var F,K=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class J{constructor(e,t){this.walletButtonIntegrationService=e,this.braintreeIntegrationService=t}initialize(e){this.braintreeIntegrationService.initialize(e)}loadPaypalCheckout(e,t,n){return K(this,void 0,void 0,function*(){return this.braintreePaypalCheckout=yield new Promise((i,r)=>{this.braintreeIntegrationService.getPaypalCheckout(e,i,e=>{this.removeElement(t),n&&k(e)&&n(e),r(e)})}),this.braintreePaypalCheckout})}loadVenmoCheckout(e){return K(this,void 0,void 0,function*(){try{this.braintreeVenmoCheckout=yield this.braintreeIntegrationService.getVenmoCheckout()}catch(t){throw this.removeElement(e),t}return this.braintreeVenmoCheckout})}getBraintreePaypalCheckoutOrThrow(){if(!this.braintreePaypalCheckout)throw new B;return this.braintreePaypalCheckout}getBraintreeVenmoCheckoutOrThrow(){if(!this.braintreeVenmoCheckout)throw new B;return this.braintreeVenmoCheckout}teardown(){return K(this,void 0,void 0,function*(){yield this.braintreeIntegrationService.teardown()})}proxyTokenizationPayment(e,t,n){return K(this,void 0,void 0,function*(){const i=this.getBraintreePaypalCheckoutOrThrow(),r=yield i.tokenizePayment(e);return this.redirectToExternalCheckout(r,t,n)})}proxyVenmoTokenizationPayment(e,t){return K(this,void 0,void 0,function*(){const n=yield this.tokenizeVenmo();return this.redirectToExternalCheckout(n,e,t)})}removeElement(e){this.braintreeIntegrationService.removeElement(e)}redirectToExternalCheckout(e,t,n){return K(this,void 0,void 0,function*(){var i;const{deviceData:r}=yield this.braintreeIntegrationService.getDataCollector({paypal:!0}),{details:o,nonce:a}=e,s=this.braintreeIntegrationService.mapToLegacyShippingAddress(o);yield this.walletButtonIntegrationService.addBillingAddress(n,this.mapToBillingAddress(o));const c={paymentWalletData:{providerId:t,providerOrderId:a},cartEntityId:n,queryParams:[{key:"payment_type",value:"paypal"},{key:"action",value:"set_external_checkout"},{key:"provider",value:t},{key:"nonce",value:a},{key:"shipping_address",value:encodeURIComponent(JSON.stringify(s))},...r?[{key:"device_data",value:r}]:[]]},l=null===(i=(yield this.walletButtonIntegrationService.getRedirectToCheckoutUrl(c)).body.redirectUrls)||void 0===i?void 0:i.externalCheckoutUrl;if(!l)throw new Z;return window.location.assign(l),e})}mapToBillingAddress(e){const{billingAddress:t,email:n,firstName:i,lastName:r,phone:o,shippingAddress:a}=e,s=t||a;return{firstName:i||"",lastName:r||"",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:o||"",shouldSaveAddress:!1}}tokenizeVenmo(){const e=this.getBraintreeVenmoCheckoutOrThrow();return new Promise((t,n)=>{e.tokenize((e,i)=>{if(e)return n(e);t(i)})})}}function q(e,t){return Object.assign(e,{resolveIds:t})}!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(F||(F={}));class X extends u{constructor(e){super(function(e){switch(e){case F.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case F.MissingCart:return"Unable to proceed because cart data is unavailable.";case F.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case F.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case F.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case F.MissingCheckoutConfig:case F.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case F.MissingOrder:return"Unable to proceed because order data is unavailable.";case F.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case F.MissingPayment:return"Unable to proceed because payment data is unavailable.";case F.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case F.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case F.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}function $(e){const{color:t,fundingicons:n,height:i=40,layout:a,shape:s,size:c,tagline:l}=e||{},d={color:t,fundingicons:n,height:ee(i),layout:a,shape:s||"rect",size:c,tagline:l};return o(d,r)}function ee(e){const t=Number(e);return!t||Number.isNaN(t)?40:t>55?55:t<25?25:t}var te=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class ne{constructor(e,t){this.braintreePaypalWalletService=e,this.braintreeHostWindow=t}initialize(e){return te(this,void 0,void 0,function*(){const{braintreepaypal:t,containerId:n,methodId:i}=e;if(!i)throw new m('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new m('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new m('Unable to initialize payment because "options.braintreepaypal" argument is not provided.');let r;try{r=JSON.parse(atob(t.initializationData))}catch(e){throw new m("Failed to parse payment method 'initializationData'.")}const{initializationData:o,config:a}=r;if(!t.clientToken||!o||!a)throw new X(F.MissingPaymentMethod);const s={currency:t.currency.code,intent:o.intent,isCreditEnabled:o.isCreditEnabled,commit:!1};this.braintreePaypalWalletService.initialize(t.clientToken),yield this.braintreePaypalWalletService.loadPaypalCheckout(s,n,t.onError),this.renderButton(t,n,i,!!a.testMode,o.intent)})}deinitialize(){return te(this,void 0,void 0,function*(){yield this.braintreePaypalWalletService.teardown()})}renderButton(e,t,n,i,r){const{style:o,onEligibilityFailure:a}=e,{paypal:s}=this.braintreeHostWindow;if(!s)return void this.braintreePaypalWalletService.removeElement(t);const c=s.Buttons({env:i?"sandbox":"production",fundingSource:s.FUNDING.PAYPAL,style:$(o),createOrder:()=>this.setupPayment(e,r),onApprove:t=>this.tokenizePayment(t,n,e.cartId,e.onAuthorizeError)});c.isEligible()?c.render(`#${t}`):a&&"function"==typeof a&&a()}setupPayment(e,t){return te(this,void 0,void 0,function*(){const{onPaymentError:n,amount:i,currency:r}=e,o=this.braintreePaypalWalletService.getBraintreePaypalCheckoutOrThrow();try{return yield o.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,amount:i,currency:r.code,offerCredit:!1,intent:t})}catch(e){throw(k(e)||e instanceof u)&&(null==n||n(e)),e}})}tokenizePayment(e,t,n,i){return te(this,void 0,void 0,function*(){try{yield this.braintreePaypalWalletService.proxyTokenizationPayment(e,t,n)}catch(e){throw(k(e)||e instanceof u)&&(null==i||i(e)),e}})}}const ie=q(e=>{const n=window,i=new U(new H(t(),n,new V),n);return new ne(new J(e,i),n)},[{id:"braintreepaypal"}]);var re=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class oe{constructor(e,t){this.braintreePaypalWalletService=e,this.braintreeHostWindow=t}initialize(e){return re(this,void 0,void 0,function*(){const{braintreepaypalcredit:t,containerId:n,methodId:i}=e;if(!i)throw new m('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new m('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new m('Unable to initialize payment because "options.braintreepaypalcredit" argument is not provided.');let r;try{r=JSON.parse(atob(t.initializationData))}catch(e){throw new m("Failed to parse payment method 'initializationData'.")}const{initializationData:o,config:a}=r;if(!t.clientToken||!o||!a)throw new X(F.MissingPaymentMethod);const s={currency:t.currency.code,intent:o.intent,isCreditEnabled:o.isCreditEnabled,commit:!1};this.braintreePaypalWalletService.initialize(t.clientToken),yield this.braintreePaypalWalletService.loadPaypalCheckout(s,n,t.onError),this.renderButton(t,n,i,!!a.testMode,o.intent)})}deinitialize(){return re(this,void 0,void 0,function*(){yield this.braintreePaypalWalletService.teardown()})}renderButton(e,t,n,i,r){const{style:o,onEligibilityFailure:a}=e,{paypal:s}=this.braintreeHostWindow;if(!s)return void this.braintreePaypalWalletService.removeElement(t);const c=s.Buttons({env:i?"sandbox":"production",fundingSource:s.FUNDING.PAYLATER,style:Object.assign(Object.assign({},$(o)),{color:b.GOLD}),createOrder:()=>this.setupPayment(e,r),onApprove:t=>this.tokenizePayment(t,n,e.cartId,e.onAuthorizeError)});c.isEligible()?c.render(`#${t}`):a&&"function"==typeof a&&a()}setupPayment(e,t){return re(this,void 0,void 0,function*(){const{onPaymentError:n,amount:i,currency:r}=e,o=this.braintreePaypalWalletService.getBraintreePaypalCheckoutOrThrow();try{return yield o.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,amount:i,currency:r.code,offerCredit:!0,intent:t})}catch(e){throw(k(e)||e instanceof u)&&(null==n||n(e)),e}})}tokenizePayment(e,t,n,i){return re(this,void 0,void 0,function*(){try{yield this.braintreePaypalWalletService.proxyTokenizationPayment(e,t,n)}catch(e){throw(k(e)||e instanceof u)&&(null==i||i(e)),e}})}}const ae=q(e=>{const n=window,i=new U(new H(t(),n,new V),n);return new oe(new J(e,i),n)},[{id:"braintreepaypalcredit"}]),se={[b.WHITE]:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTE4IiBoZWlnaHQ9IjI5IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiPgogICAgPGRlZnM+CiAgICAgICAgPGNsaXBQYXRoIGlkPSJjbGlwMCI+CiAgICAgICAgICAgIDxyZWN0IHdpZHRoPSIxOTgiIGhlaWdodD0iMzgiIGZpbGw9IndoaXRlIiBpZD0ic3ZnXzEiLz4KICAgICAgICA8L2NsaXBQYXRoPgogICAgPC9kZWZzPgogICAgPGc+CiAgICAgICAgPHRpdGxlPkxheWVyIDE8L3RpdGxlPgogICAgICAgIDxnIHN0cm9rZT0ibnVsbCIgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwKSIgaWQ9InN2Z18yIj4KICAgICAgICAgICAgPHBhdGggc3Ryb2tlPSJudWxsIiBkPSJtMjAuMDM2ODgsNGMwLjc1NDU4LDEuMjY3NTEgMS4wOTQ4NSwyLjU3Mjk0IDEuMDk0ODUsNC4yMjIwOGMwLDUuMjU5ODUgLTQuNDE0OTYsMTIuMDkyNzEgLTcuOTk4MjMsMTYuODkwNzVsLTguMTg0NDMsMGwtMy4yODI0LC0xOS45NjExN2w3LjE2NjM0LC0wLjY5MmwxLjczNTQ1LDE0LjIwMzY1YzEuNjIxNTQsLTIuNjg2NjQgMy42MjI1OSwtNi45MDg3MSAzLjYyMjU5LC05Ljc4NzMzYzAsL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b.WHITE?"#FFFFFF":"#3D95CE"),backgroundPosition:"50% 50%",backgroundSize:"80px auto",backgroundImage:`url("${se[t===b.WHITE?b.BLUE:b.WHITE]}")`,backgroundRepeat:"no-repeat",borderRadius:"4px",cursor:"pointer",transition:"0.2s ease",minHeight:`${n||40}px`,minWidth:"150px",height:"100%",border:t===b.WHITE?"1px solid black":"none"};var i};var le=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class de{constructor(e){this.braintreePaypalWalletService=e}initialize(e){return le(this,void 0,void 0,function*(){const{braintreevenmo:t,containerId:n,methodId:i}=e;if(!i)throw new m('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new m('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new m('Unable to initialize payment because "options.braintreevenmo" argument is not provided.');let r;try{r=JSON.parse(atob(t.initializationData))}catch(e){throw new m("Failed to parse payment method 'initializationData'.")}const{initializationData:o,config:a}=r;if(!t.clientToken||!o||!a)throw new X(F.MissingPaymentMethod);this.braintreePaypalWalletService.initialize(t.clientToken);try{yield this.braintreePaypalWalletService.loadVenmoCheckout(n)}catch(e){return void this.handleInitializationError(e,t)}this.renderButton(t,n,i,o)})}deinitialize(){return le(this,void 0,void 0,function*(){yield this.braintreePaypalWalletService.teardown()})}handleInitializationError(e,t){const{onError:n,onEligibilityFailure:i}=t;e instanceof C?null==i||i():(k(e)||e instanceof u)&&(null==n||n(e))}renderButton(e,t,n,i){const{style:r,onEligibilityFailure:o}=e,{cartButtonStyles:a}=i.paymentButtonStyles||{},s=r||a||{},{color:c}=s,l=document.getElementById(t);if(!l)return this.braintreePaypalWalletService.removeElement(t),void(null==o||o());l.setAttribute("aria-label","Venmo"),Object.assign(l.style,ce(s)),l.addEventListener("click",()=>le(this,void 0,void 0,function*(){var t;l.setAttribute("disabled","true");try{yield this.braintreePaypalWalletService.proxyVenmoTokenizationPayment(n,e.cartId)}catch(n){(k(n)||n instanceof u)&&(null===(t=e.onAuthorizeError)||void 0===t||t.call(e,n))}finally{l.removeAttribute("disabled")}})),c===b.BLUE&&(l.addEventListener("mouseenter",()=>{l.style.backgroundColor="#0a7fc2"}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor=ce(s).backgroundColor}))}}const ue=q(e=>{const n=window,i=new U(new H(t(),n,new V),n);return new de(new J(e,i))},[{id:"braintreevenmo"}]),he=["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"];var ye,Me,pe,ge,_e,we,Ce,me=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class fe{constructor(e){this.scriptLoader=e,this.window=window}getPayPalSDK(e,t,n,i,r){return me(this,void 0,void 0,function*(){const o=this.getPayPalSdkScriptConfigOrThrow(e,t,n,i);return this.loadPayPalSDK(o,r)})}loadPayPalSDK(e){return me(this,arguments,void 0,function*(e,t=!1){if(!this.window.paypal||t){const t=this.transformConfig(e.options),n=this.transformConfig(e.attributes),i=`https://www.paypal.com/sdk/js?${new URLSearchParams(t).toString()}`;yield this.scriptLoader.loadScript(i,{async:!0,attributes:n})}if(!this.window.paypal)throw new B;return this.window.paypal})}getPayPalSdkScriptConfigOrThrow(e,t,n,i=!0){const{id:r,clientToken:o,initializationData:a}=e;if(!(null==a?void 0:a.clientId))throw new X(F.MissingPaymentMethod);const{intent:s,clientId:c,merchantId:l,buyerCountry:d,attributionId:u,isVenmoEnabled:h,isHostedCheckoutEnabled:y,isPayPalCreditAvailable:M,isDeveloperModeApplicable:p,availableAlternativePaymentMethods:g=[],enabledAlternativePaymentMethods:_=[],isGooglePayEnabled:w}=a,C=y||i,m="paypalcommercecreditcards"===r,f=m?["card"]:[],N=M?["credit","paylater"]:[],v=h?["venmo"]:[],I=w?["googlepay"]:[],T=i?["card-fields"]:[],z=[...m?[]:["card"],...M?[]:["credit","paylater"],...h?[]:["venmo"],...g.filter(e=>!_.includes(e))],L=[...f,...N,...v,..._],D=function(e){if(!e)return;let t;if(e.includes("-")){const[n,i]=e.split("-");t=`${n}_${i.toUpperCase()}`}else t=`${e}_${e.toUpperCase()}`;return he.includes(t)?t:void 0}(n);return{options:Object.assign(Object.assign({"client-id":c,"merchant-id":l,"enable-funding":L.length>0?L:void 0,"disable-funding":z.length>0?z:void 0,commit:C,components:["buttons","hosted-fields","payment-fields","legal",...I,...T],currency:t,intent:s},p&&{"buyer-country":d}),D&&{locale:D}),attributes:{"data-partner-attribution-id":u,"data-client-token":o}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}!function(e){e.Possible="POSSIBLE",e.No="NO",e.Unknown="UNKNOWN",e.Yes="YES"}(ye||(ye={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(Me||(Me={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(pe||(pe={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(ge||(ge={})),function(e){e.pill="pill",e.rect="rect"}(_e||(_e={})),function(e){e.OXXO="oxxo",e.IDEAL="ideal"}(we||(we={})),function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(Ce||(Ce={}));var Ne=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class ve{constructor(e,t){this.walletButtonIntegrationService=e,this.paypalCommerceScriptLoader=t}loadPayPalSdk(e,t,n,i){return Ne(this,void 0,void 0,function*(){return this.paypalSdk=yield this.paypalCommerceScriptLoader.getPayPalSDK(e,t,void 0,n,i),this.paypalSdk})}getPayPalSdkOrThrow(){if(!this.paypalSdk)throw new B;return this.paypalSdk}proxyTokenizationPayment(e,t){return Ne(this,void 0,void 0,function*(){var n;if(!t)throw new X(F.MissingOrderId);const i={paymentWalletData:{providerId:"paypalcommerce",providerOrderId:t},cartEntityId:e,queryParams:[{key:"payment_type",value:"paypal"},{key:"action",value:"set_external_checkout"},{key:"provider",value:"paypalcommerce"}]},r=yield this.walletButtonIntegrationService.getRedirectToCheckoutUrl(i);if(!(null===(n=r.body.redirectUrls)||void 0===n?void 0:n.externalCheckoutUrl))throw new Error("Failed to redirection to checkout page");window.location.assign(r.body.redirectUrls.externalCheckoutUrl)})}createPaymentOrderIntent(e,t,n){return Ne(this,void 0,void 0,function*(){const i={cartEntityId:t,paymentWalletEntityId:e};return(yield this.walletButtonIntegrationService.createPaymentOrderIntent(i,n)).body.orderId})}addBillingAddress(e,t,n){return Ne(this,void 0,void 0,function*(){return this.walletButtonIntegrationService.addBillingAddress(e,t,n)})}getValidButtonStyle(e){const{color:t,height:n,label:i,shape:a}=e||{},s={color:t&&ge[t]?t:void 0,height:this.getValidHeight(n),label:i&&pe[i]?i:void 0,shape:a&&_e[a]?a:void 0};return o(s,r)}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 Ie=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Te{constructor(e){this.paypalCommerceHeadlessWalletButtonService=e}initialize(e){return Ie(this,void 0,void 0,function*(){const{paypalcommercepaypal:t,containerId:n,methodId:i}=e;if(!i)throw new m('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new m('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new m('Unable to initialize payment because "options.paypalcommercepaypal" argument is not provided.');let r;try{r=JSON.parse(atob(t.initializationData))}catch(e){throw new m("Failed to parse payment method 'initializationData'.")}yield this.paypalCommerceHeadlessWalletButtonService.loadPayPalSdk(r,t.currency.code,!1),this.renderButton(n,"paypalcommerce.paypal",t.cartId)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const i=this.paypalCommerceHeadlessWalletButtonService.getPayPalSdkOrThrow(),r={createOrder:()=>this.paypalCommerceHeadlessWalletButtonService.createPaymentOrderIntent(t,n),onApprove:(e,t)=>Ie(this,[e,t],void 0,function*({orderID:e},t){const i=yield t.order.get(),r=this.mapOrderDetailsToBillingAddress(i);yield this.paypalCommerceHeadlessWalletButtonService.addBillingAddress(n,r),yield this.paypalCommerceHeadlessWalletButtonService.proxyTokenizationPayment(n,e)})},o=Object.assign({fundingSource:i.FUNDING.PAYPAL,style:this.paypalCommerceHeadlessWalletButtonService.getValidButtonStyle()},r),a=i.Buttons(o);a.isEligible()?a.render(`#${e}`):this.paypalCommerceHeadlessWalletButtonService.removeElement(e)}mapOrderDetailsToBillingAddress(e){var t,n,i,r;const{payer:o}=e;return{firstName:o.name.given_name,lastName:o.name.surname,company:"",address1:o.address.address_line_1,address2:o.address.address_line_2,city:o.address.admin_area_2,email:o.email_address,stateOrProvince:null!==(t=o.address.admin_area_1)&&void 0!==t?t:"",stateOrProvinceCode:null!==(n=o.address.admin_area_1)&&void 0!==n?n:"",countryCode:o.address.country_code,postalCode:o.address.postal_code,phone:null!==(r=null===(i=o.phone)||void 0===i?void 0:i.phone_number.national_number)&&void 0!==r?r:"",shouldSaveAddress:!1}}}const ze=q(e=>new Te(new ve(e,new fe(t()))),[{id:"paypalcommercepaypal"}]);var Le=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class De{constructor(e){this.paypalCommerceHeadlessWalletButtonService=e}initialize(e){return Le(this,void 0,void 0,function*(){var t,n;const{paypalcommercepaypalcredit:i,containerId:r,methodId:o}=e;if(!o)throw new m('Unable to initialize payment because "options.methodId" argument is not provided.');if(!r)throw new m('Unable to initialize payment because "options.containerId" argument is not provided.');if(!i)throw new m('Unable to initialize payment because "options.paypalcommercepaypalcredit" argument is not provided.');let a;try{a=JSON.parse(atob(i.initializationData))}catch(e){throw new m("Failed to parse payment method 'initializationData'.")}yield this.paypalCommerceHeadlessWalletButtonService.loadPayPalSdk(a,i.currency.code,!1);const s=null===(n=null===(t=a.initializationData)||void 0===t?void 0:t.paymentButtonStyles)||void 0===n?void 0:n.cartButtonStyles;this.renderButton(r,"paypalcommerce.paypalcredit",i.cartId,s)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n,i){const r=this.paypalCommerceHeadlessWalletButtonService.getPayPalSdkOrThrow(),o=[r.FUNDING.PAYLATER,r.FUNDING.CREDIT],a={createOrder:()=>this.paypalCommerceHeadlessWalletButtonService.createPaymentOrderIntent(t,n),onApprove:(e,t)=>Le(this,[e,t],void 0,function*({orderID:e},t){const i=yield t.order.get(),r=this.mapOrderDetailsToBillingAddress(i);yield this.paypalCommerceHeadlessWalletButtonService.addBillingAddress(n,r),yield this.paypalCommerceHeadlessWalletButtonService.proxyTokenizationPayment(n,e)})};let s=!1;o.forEach(t=>{if(!s){const n=Object.assign({fundingSource:t,style:this.paypalCommerceHeadlessWalletButtonService.getValidButtonStyle(i)},a),o=r.Buttons(n);o.isEligible()&&(o.render(`#${e}`),s=!0)}}),s||this.paypalCommerceHeadlessWalletButtonService.removeElement(e)}mapOrderDetailsToBillingAddress(e){var t,n,i,r;const{payer:o}=e;return{firstName:o.name.given_name,lastName:o.name.surname,company:"",address1:o.address.address_line_1,address2:o.address.address_line_2,city:o.address.admin_area_2,email:o.email_address,stateOrProvince:null!==(t=o.address.admin_area_1)&&void 0!==t?t:"",stateOrProvinceCode:null!==(n=o.address.admin_area_1)&&void 0!==n?n:"",countryCode:o.address.country_code,postalCode:o.address.postal_code,phone:null!==(r=null===(i=o.phone)||void 0===i?void 0:i.phone_number.national_number)&&void 0!==r?r:"",shouldSaveAddress:!1}}}const be=q(e=>new De(new ve(e,new fe(t()))),[{id:"paypalcommercepaypalcredit"}]);function Ae(e){return e&&"resolveIds"in e}function je(){try{return"production"}catch(e){return"development"}}class Oe{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 Se{log(){}info(){}warn(){}error(){}debug(){}}const Ee=function(e=!0){return e?new Oe(console):new Se}("test"!==je());class Pe 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 ke extends Pe{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class xe{constructor(e){var t,n,i;this._factories={},this._instances={},this._defaultToken=null!==(t=null==e?void 0:e.defaultToken)&&void 0!==t?t:"default",this._useFallback=null===(n=null==e?void 0:e.useFallback)||void 0===n||n,this._tokenResolver=null!==(i=null==e?void 0:e.tokenResolver)&&void 0!==i?i:e=>e}get(e,t){try{return this._getInstance(e||this._defaultToken,t||e||this._defaultToken)}catch(e){if(!this._useFallback)throw e;return this._getInstance(this._defaultToken,t||this._defaultToken)}}getFactory(e,t){const n=this._tokenResolver(e,Object.keys(this._factories),t);return n?this._factories[n]:void 0}register(e,t){if(this._hasFactory(e))throw new ke(`'${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 ke(`'${e}' is not registered.`);this._instances[t]=n()}return this._instances[t]}}class Ue{constructor(e=!1){this._useFallback=e,this._registry=new xe({tokenResolver:this._resolveToken.bind(this),defaultToken:this._encodeToken({default:!0}),useFallback:this._useFallback})}get(e){return this._registry.get(this._encodeToken(e))}getFactory(e,t){try{return this._registry.getFactory(this._encodeToken(e),t)}catch(e){return}}getUseFallback(){return this._useFallback}register(e,t){this._registry.register(this._encodeToken(e),t)}_encodeToken(e){return btoa(JSON.stringify(e))}_decodeToken(e){return JSON.parse(atob(e))}_resolveToken(e,t,n){var i;const r=this._decodeToken(e),o=[];t.forEach(e=>{const t=this._decodeToken(e),n={token:e,matches:0,default:!1,totalKeys:Object.keys(t).length};for(const[e,i]of Object.entries(t)){if(e in r&&r[e]!==i){n.matches=0;break}e in r&&r[e]===i&&n.matches++,"default"===e&&!0===i&&(n.default=!0)}o.push(n)});const a=o.sort((e,t)=>t.matches-e.matches).filter(e=>e.matches>0);a.length>1&&a[0].matches===a[1].matches&&"development"===je()&&Ee.warn("The provided query matches at least two strategies with the same specificity. This warning can be resolved by making their resolve ID more specific.");const s=Object.keys(r).length;if(n){const e=a.find(e=>e.matches===s&&e.matches===e.totalKeys);if(!e)throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(r)} with exact match.`);return e.token}const c=a[0];if(c&&c.token)return c.token;if(this._useFallback){const e=null===(i=o.find(e=>e.default))||void 0===i?void 0:i.token;if(e)return e}throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(r)}.`)}}function Be(e,t,n){if("function"!=typeof n.value)return n;let i=n.value;return{get(){const e=i.bind(this);return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e},set(e){i=e}}}const Ge=e=>{const t=a(e);return document.getElementById(t)?Ge(e):t};let Ye=class{constructor(e){this._registryV2=e}initializeWalletButton(e){const t=this.getContainerIds(e);return Promise.all(t.map(t=>{return n=this,i=void 0,o=function*(){return this._registryV2.get({id:e.methodId}).initialize(Object.assign(Object.assign({},e),{containerId:t}))},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{c(o.next(e))}catch(e){t(e)}}function s(e){try{c(o.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}c((o=o.apply(n,i||[])).next())});var n,i,r,o}))}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 ke(`Unable to find any element with the specified selector: ${e}`);return Array.prototype.slice.call(n).map(e=>(e.id||(e.id=Ge(t)),e.id))}(e.containerId,`${e.methodId}-container`);var t}};Ye=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([function(e,t,n){return t&&n?Be(0,t,n):function(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&"constructor"!==n&&Object.defineProperty(t.prototype,n,Be(e.prototype,n,i))}),t}(e)}],Ye);const We=Ye;function Re(t){const{graphQLEndpoint:n}=t,i=function(e,t){const n=new Ue;for(const[,i]of Object.entries(t))if(Ae(i))for(const t of i.resolveIds)n.register(t,()=>i(e));return n}((t=>{const n=e();return new w(t,new d(n),new g(n),new y(n))})(n),c);return new We(i)}export{Re as createWalletButtonInitializer};
1
+ import{createRequestSender as e}from"@bigcommerce/request-sender";import{getScriptLoader as t}from"@bigcommerce/script-loader";import{supportsPopups as n}from"@braintree/browser-detection";import{isEmpty as i,isNil as r,omitBy as o,uniqueId as a}from"lodash";var s={d:(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},c={};s.r(c),s.d(c,{createBraintreePaypalCreditWalletStrategy:()=>ae,createBraintreePaypalWalletStrategy:()=>ie,createBraintreeVenmoWalletStrategy:()=>ue,createPayPalCommerceCreditWalletStrategy:()=>Le,createPayPalCommerceVenmoWalletStrategy:()=>Se,createPayPalCommerceWalletStrategy:()=>Te});var l=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class d{constructor(e){this.requestSender=e}updateBillingAddress(e,t,n,i){return l(this,void 0,void 0,function*(){const{id:r}=n,o=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(n,["id"]),a={headers:Object.assign(Object.assign({},null==i?void 0:i.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:Object.assign({},o)}}}}},s=yield this.requestSender.post(`${window.location.origin}/${e}`,a),{billingAddress:c}=s.body.data.checkout.updateCheckoutBillingAddress.checkout;return Object.assign(Object.assign({},s),{body:c})})}addBillingAddress(e,t,n,i){return l(this,void 0,void 0,function*(){const r={headers:Object.assign(Object.assign({},null==i?void 0:i.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:Object.assign({},n)}}}}},o=yield this.requestSender.post(`${window.location.origin}/${e}`,r),{billingAddress:a}=o.body.data.checkout.addCheckoutBillingAddress.checkout;return Object.assign(Object.assign({},o),{body:a})})}}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 h extends u{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"}}class y{constructor(e){this.requestSender=e}getRedirectToCheckoutUrl(e,t,n){return i=this,r=void 0,a=function*(){var i;const r={headers:Object.assign(Object.assign({},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}`,r),{data:{cart:{createCartRedirectUrls:n}}}=t.body,o=null===(i=n.errors[0])||void 0===i?void 0:i.message;if(o)throw new h(o);if(n.errors.length>0)throw new h;return Object.assign(Object.assign({},t),{body:{redirectUrls:n.redirectUrls}})}catch(e){if(e instanceof Error)throw e;throw new Error("Checkout redirection failed")}},new((o=void 0)||(o=Promise))(function(e,t){function n(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof o?i:new o(function(e){e(i)})).then(n,s)}c((a=a.apply(i,r||[])).next())});var i,r,o,a}}class M extends u{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}class p extends u{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"}}class g{constructor(e){this.requestSender=e}createPaymentOrderIntent(e,t,n){return i=this,r=void 0,a=function*(){var i;const r={headers:Object.assign(Object.assign({},null==n?void 0:n.headers),{"Content-Type":"application/json","x-catalyst-graphql-proxy-requester":"checkout-sdk-js"}),body:{query:"\n mutation CreatePaymentWalletIntentMutation(\n $input: CreatePaymentWalletIntentInput!\n ) {\n payment {\n paymentWallet {\n createPaymentWalletIntent(input: $input) {\n paymentWalletIntentData {\n __typename\n ... on PayPalCommercePaymentWalletIntentData {\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 ",variables:{input:t}}};try{const t=yield this.requestSender.post(`${window.location.origin}/${e}`,r),{data:{payment:{paymentWallet:{createPaymentWalletIntent:{paymentWalletIntentData:n,errors:o}}}}}=t.body,a=null===(i=o[0])||void 0===i?void 0:i.message;if(a)throw new p(a);return Object.assign(Object.assign({},t),{body:Object.assign({},n)})}catch(e){if(!(e instanceof p))throw new M;throw e}},new((o=void 0)||(o=Promise))(function(e,t){function n(e){try{c(a.next(e))}catch(e){t(e)}}function s(e){try{c(a.throw(e))}catch(e){t(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof o?i:new o(function(e){e(i)})).then(n,s)}c((a=a.apply(i,r||[])).next())});var i,r,o,a}}var _=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class m{constructor(e,t,n,i){this.graphQLEndpoint=e,this.billingAddressRequestSender=t,this.paymentRequestSender=n,this.checkoutRequestSender=i}addBillingAddress(e,t,n){return _(this,void 0,void 0,function*(){return this.billingAddressRequestSender.addBillingAddress(this.graphQLEndpoint,e,t,n)})}updateBillingAddress(e,t,n){return _(this,void 0,void 0,function*(){return this.billingAddressRequestSender.updateBillingAddress(this.graphQLEndpoint,e,t,n)})}createPaymentOrderIntent(e,t){return _(this,void 0,void 0,function*(){return this.paymentRequestSender.createPaymentOrderIntent(this.graphQLEndpoint,e,t)})}getRedirectToCheckoutUrl(e,t){return _(this,void 0,void 0,function*(){return this.checkoutRequestSender.getRedirectToCheckoutUrl(this.graphQLEndpoint,e,t)})}}class w extends u{constructor(e){super(e||"Unsupported browser error"),this.name="UnsupportedBrowserError",this.type="unsupported_browser"}}class C extends u{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class f extends C{constructor(e){let t="Unable to submit payment for the order because the payload is invalid.";e&&(t=`${t} Make sure the following fields are provided correctly: ${e.join(", ")}.`),super(t),this.name="PaymentArgumentInvalidError"}}class v extends u{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 N;!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(N||(N={}));class I extends u{constructor(e){super(function(e){switch(e){case N.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case N.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case N.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case N.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}let z=null;const T=["buttons","messages"];var D,b,L,A,j,S,O,E,P;function k(e){return Boolean("object"==typeof e&&null!==e&&("type"in e||"message"in e||"code"in e))}!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(D||(D={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(b||(b={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white"}(L||(L={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(A||(A={})),function(e){e.PILL="pill",e.RECT="rect"}(j||(j={})),function(e){e.CART="cart",e.HOME="homepage",e.PAYMENT="payment",e.PRODUCT="product"}(S||(S={})),function(e){e.Sandbox="sandbox",e.Production="production"}(O||(O={})),function(e){e.Client="client",e.DataCollector="dataCollector",e.Fastlane="fastlane",e.GooglePayment="googlePayment",e.HostedFields="hostedFields",e.LocalPayment="localPayment",e.Paypal="paypal",e.PaypalCheckout="paypalCheckout",e.ThreeDSecure="threeDSecure",e.UsBankAccount="usBankAccount",e.Venmo="venmo",e.VisaCheckout="visaCheckout"}(E||(E={})),function(e){e.CardCode="cardCode",e.CardCodeVerification="cardCodeVerification",e.CardExpiry="cardExpiry",e.CardName="cardName",e.CardNumber="cardNumber",e.CardNumberVerification="cardNumberVerification"}(P||(P={}));var x=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class U{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 x(this,void 0,void 0,function*(){if(t&&(window.localStorage.setItem("axoEnv","sandbox"),window.localStorage.setItem("fastlaneEnv","sandbox")),!this.braintreeHostWindow.braintreeFastlane){const t=this.getClientTokenOrThrow(),i=yield this.getClient(),r=yield this.getSessionId(e),o=yield this.braintreeScriptLoader.loadFastlane(),a={root:{backgroundColorPrimary:"transparent"}};this.braintreeHostWindow.braintreeFastlane=yield o.create({authorization:t,client:i,deviceData:r,styles:n||a})}return this.braintreeHostWindow.braintreeFastlane})}getClient(){return x(this,void 0,void 0,function*(){if(!this.client){const e=this.getClientTokenOrThrow(),t=yield this.braintreeScriptLoader.loadClient();this.client=t.create({authorization:e})}return this.client})}getPaypal(){return this.braintreePaypal||(this.braintreePaypal=Promise.all([this.getClient(),this.braintreeScriptLoader.loadPaypal()]).then(([e,t])=>t.create({client:e}))),this.braintreePaypal}paypal(e){var{shouldSaveInstrument:t}=e,i=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["shouldSaveInstrument"]);const r=n();return this.getPaypal().then(e=>{var n;return r&&(null===(n=this.overlay)||void 0===n||n.show({onClick:()=>e.focusWindow()})),e.tokenize(Object.assign({enableShippingAddress:!0,flow:t?"vault":"checkout",useraction:"commit"},i))}).then(e=>{var t;return null===(t=this.overlay)||void 0===t||t.remove(),e}).catch(e=>{var t;throw null===(t=this.overlay)||void 0===t||t.remove(),e})}getPaypalCheckout(e,t,n){return x(this,void 0,void 0,function*(){const i=yield this.getClient(),r=yield this.braintreeScriptLoader.loadPaypalCheckout(),o={client:i};return this.paypalCheckout=yield r.create(o,(i,r)=>{var o;if(i)return n(i);const a=Object.assign(Object.assign({currency:e.currency},e.isCreditEnabled&&{"enable-funding":"paylater"}),{components:T.toString(),intent:e.intent,commit:null===(o=e.commit)||void 0===o||o});this.braintreeHostWindow.paypal?t(r):function(e,t){return z||(z=new Promise((n,i)=>{e.loadPayPalSDK(t,t=>{t?(z=null,i(t)):n(e)})})),z}(r,a).then(()=>t(r))}),this.paypalCheckout})}getDataCollector(e){return x(this,void 0,void 0,function*(){const t=(null==e?void 0:e.paypal)?"paypal":"default";let n=this.dataCollectors[t];if(!n){try{const t=yield this.getClient(),i=yield this.braintreeScriptLoader.loadDataCollector(),r=Object.assign({client:t,kount:!0},e);n=yield i.create(r)}catch(e){if(!k(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?O.Sandbox:O.Production}mapToBraintreeShippingAddressOverride(e){return{recipientName:`${e.firstName} ${e.lastName}`,line1:e.address1,line2:e.address2,city:e.city,state:e.stateOrProvinceCode,postalCode:e.postalCode,countryCode:e.countryCode,phone:e.phone}}mapToLegacyShippingAddress(e){const{email:t,phone:n,shippingAddress:i}=e,r=(null==i?void 0:i.recipientName)||"",[o,a]=r.split(" ");return{email:t,first_name:o||"",last_name:a||"",phone_number:n,address_line_1:null==i?void 0:i.line1,address_line_2:null==i?void 0:i.line2,city:null==i?void 0:i.city,state:null==i?void 0:i.state,country_code:null==i?void 0:i.countryCode,postal_code:null==i?void 0:i.postalCode}}mapToLegacyBillingAddress(e){const{billingAddress:t,email:n,firstName:i,lastName:r,phone:o,shippingAddress:a}=e,s=t||a;return{email:n,first_name:i,last_name:r,phone_number:o,address_line_1:null==s?void 0:s.line1,address_line_2:null==s?void 0:s.line2,city:null==s?void 0:s.city,state:null==s?void 0:s.state,country_code:null==s?void 0:s.countryCode,postal_code:null==s?void 0:s.postalCode}}removeElement(e){const t=e&&document.getElementById(e);t&&t.remove()}getSessionId(e){return x(this,void 0,void 0,function*(){const{deviceData:t}=yield this.getDataCollector({riskCorrelationId:e});return t})}teardown(){return x(this,void 0,void 0,function*(){yield this.teardownModule(this.dataCollectors.default),yield this.teardownModule(this.dataCollectors.paypal),this.dataCollectors={},yield this.teardownModule(this.paypalCheckout),this.paypalCheckout=void 0})}get3DS(){return x(this,void 0,void 0,function*(){return this.threeDS||(this.threeDS=Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()]).then(([e,t])=>t.create({client:e,version:2}))),this.threeDS})}getVenmoCheckout(e){return x(this,void 0,void 0,function*(){if(!this.venmoCheckout){const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadVenmoCheckout(),i=Object.assign({client:t,allowDesktop:!0,paymentMethodUsage:"multi_use"},e||{});this.venmoCheckout=yield new Promise((e,t)=>{n.create(i,(n,i)=>n?t(n):i.isBrowserSupported()?void e(i):t(new w))})}return this.venmoCheckout})}verifyCard(e,t,n){return x(this,void 0,void 0,function*(){const i=yield this.tokenizeCard(e,t);return this.challenge3DSVerification(i,n)})}tokenizeCard(e,t){return x(this,void 0,void 0,function*(){const{paymentData:n}=e;if(!function(e){if("object"!=typeof e||null===e)return!1;const t=e;return"object"==typeof t.ccExpiry&&null!==t.ccExpiry&&"string"==typeof t.ccNumber&&"string"==typeof t.ccName}(n))throw new f(["payment.paymentData"]);const r=this.getErrorsRequiredFields(n);if(!i(r))throw new v(r);const o=this.mapToCreditCard(n,t),a=yield this.getClient(),{creditCards:s}=yield a.request(o);return{nonce:s[0].nonce,bin:s[0].details.bin}})}challenge3DSVerification(e,t){return x(this,void 0,void 0,function*(){const n=yield this.get3DS();return this.present3DSChallenge(n,t,e)})}teardownModule(e){return e?e.teardown():Promise.resolve()}getClientTokenOrThrow(){if(!this.clientToken)throw new I(N.PaymentNotInitialized);return this.clientToken}getErrorsRequiredFields(e){const{ccNumber:t,ccExpiry:n}=e,i={};return t||(i.ccNumber=[{message:"Credit card number is required",type:"required"}]),n||(i.ccExpiry=[{message:"Expiration date is required",type:"required"}]),i}mapToCreditCard(e,t){return{data:{creditCard:{cardholderName:e.ccName,number:e.ccNumber,cvv:e.ccCvv,expirationDate:`${e.ccExpiry.month}/${e.ccExpiry.year}`,options:{validate:!1},billingAddress:t&&{countryCodeAlpha2:t.countryCode,locality:t.city,countryName:t.country,postalCode:t.postalCode,streetAddress:t.address2?`${t.address1} ${t.address2}`:t.address1}}},endpoint:"payment_methods/credit_cards",method:"post"}}present3DSChallenge(e,t,n){const{nonce:i,bin:r}=n;if(!i)throw new I(N.PaymentNotInitialized);const{challengeRequested:o=!0,additionalInformation:a}=this.threeDSecureOptions||{},s=t.toFixed(2);return e.verifyCard({amount:Number(s),bin:r,challengeRequested:o,nonce:i,onLookupComplete:(e,t)=>{t()},collectDeviceData:!0,additionalInformation:a})}}class B extends u{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"}}const G="3.128.0",Y="3.123.2",W="3.106.0",R={[W]:{[E.Client]:"sha384-26BXDNnJI23JYRyFBj4xe4sVNrUSSiSSu11kxVXNM/vEPONm4LuL00w6ZaTgQewt",[E.PaypalCheckout]:"sha384-B+vzbZwnQtzWBthpkT4TXKUibO65tyeK7eCxSvpblgprTep2+IAXB2Cxxjrn710O",[E.Paypal]:"sha384-uyAGL1/3+XJAHnGoNy4eCoXdzJ4f7Ilzp+6w9PNnEjs6DCCz9WMyJjMN1gzc78U+",[E.LocalPayment]:"sha384-LIvOEMkIVEwVuYBdVOQc1AC5YbGGlwyfUheS0ACK218D2STuVYQlZ4FyEPowAEfT",[E.DataCollector]:"sha384-1bo9JDz+Kscthc085cCKWur8CLwUoBpoNyxsDi7932mCl0zFq3A5mv+FQLw9GHpV",[E.UsBankAccount]:"sha384-xmHBVaU+w74V+OebD3AaPONFxHUGMf+QRs8G/JxVPXNNP7MDa2jL0ICWHIe2tTfJ",[E.GooglePayment]:"sha384-WKDJl8mqoP82qZpMGH6AbZxnvXnSW8ILV4M64CyMLiugGMwu7LyP89wjCkHqsiBe",[E.ThreeDSecure]:"sha384-VQUlpGHzsGvs5XeiGFip7EXRsvoHWEXDVmgCacfbyieZI9mdBOqq3NSoyo28OCOB",[E.VisaCheckout]:"sha384-yx7mADfzTN0T43Q6rlH49LIg1EJ0iUZgBp/EczX9LXsUGkySgxrD+nWHQRBkyfoT",[E.Venmo]:"sha384-QX4rPjoj1ZDhuG0aSyKs56lEKDqTMTcjYxUHY1SzO5VZDsqIE2NTkqot7KNSCyov",[E.HostedFields]:"sha384-VvYBACfSu0Cr/J32uKmxG7AXcNOJE1AzIIL3kbikyS7YKp5fz5Is+NzNP/lyauNy",[E.Fastlane]:"sha384-9oGsZMRZwpGtDEDYa/dFt76dECqj1xAni9gIKgc3KfMIiRnR73nEeeUDLiBzxhFa"},[Y]:{[E.Client]:"sha384-o+nbQGcwNNxIBeXeu3+XmbSq+Cg8R3EN3N0l5hXCgMMU2RGY0t1z0LroSEIAbfAO",[E.PaypalCheckout]:"sha384-WrfbWPBS4mH86GAoycPSgiH8hQ8KH7A67C93Hjhunv/xhNk2YpBn3wbFA4Fhg9U/",[E.Paypal]:"sha384-VF389nvvrRUgDsTXMxTYORDtVegB9IQa3Cxr//DyJnLYnz8/X8VCzEvck2c+Megt",[E.LocalPayment]:"sha384-tZKx2rEQbfmZpoPSY5VPmJEhaq4X75dLvwHMs3VE9U+C8lPyw+hWTIL1+GPvWCIH",[E.DataCollector]:"sha384-E6k3wOpP7syCDDwaRDLF06942Y00NkbwJvWi2OQXwwKzGwG5fd3E7RFUvCCecfvO",[E.UsBankAccount]:"sha384-258FON8LZGG0W9Qaz4Jij83pZHu30YnKjJA7gNulLBh6CclkucgF+tHDQuYFRYfW",[E.GooglePayment]:"sha384-taJ2p/0+n0VH328POAoBiuEbL3tnHUTE9S42hK1V+Txs3X+QYjZOyKW35JgHRFfO",[E.ThreeDSecure]:"sha384-+NSZH4Zj3sO5bdWvPKhU5N16QDxeueTVTnUVeleeESkhLSaz4Ob1hh/5myecc9Ym",[E.VisaCheckout]:"sha384-66DiBjghxk1OmBj8aksN8gbQ+CwoQcx1vPfiXUN08g1iQVM+BwewF0p7toM3i7SS",[E.Venmo]:"sha384-B5UwY42kE4RoLoWbQ7YpqosUlUad2/DlGWiw0HhoZbSPk30CQAaSA10ohyLDTkDU",[E.HostedFields]:"sha384-Aw9EesSaUeWxe36PqEHiOyOyOq8M6CIb1gw7/yHNVPRzGtFXXcd2OQ8qXrIlOj2P",[E.Fastlane]:"sha384-rhBL1hpZ71JqG+2TsT0Dih47mbjx8cjJCpeZjk9tw3df1gFMKfCTmMyZunhr7H4Y"},[G]:{[E.Client]:"sha384-0WNxksIpRP+fYZiIdr12g6DBUQfLDzYCQJZtR/C8KkcwSGhPHfcFp3tTaGcMyFTq",[E.PaypalCheckout]:"sha384-lWM1jk4BOxoDNV6Kop7tVNvQgINlmEVz0c/OwM+HNHK3QC8xqwd54Ovrt2QRDTjh",[E.Paypal]:"sha384-fXUmVxC2EMZBDXZ7eTHSTL/LFBrHej/MSXT/vTBXvra4lzgLNGvREAp+x0GYObuH",[E.LocalPayment]:"sha384-pha1xGuGSkmZH5x9aqHvRaO4xLea7rmQ/79PFj9zxNzxuFcOWZg7gOP7FibygOEC",[E.DataCollector]:"sha384-Q6PI2F9eekWbAxhroybl+aEcvqhdowN/EQlGwBUyJOzPFn9982u9xl6SU6XfGKzc",[E.UsBankAccount]:"sha384-W3RLQSKJL1tQ3+Y7mP6tmkamtZ8bV4Yw/XxL9Jj5JtXHraD8loMF8hAIG5m2zK7F",[E.GooglePayment]:"sha384-TITQMsFWA3elDNGP2mWz2oKBo4qjt+TlqzovcaPoeBiAh/wPBi6nae50ADdgU1/i",[E.ThreeDSecure]:"sha384-YiycYN89ZlL/Evcaq4y1ajW1mhd7JYfZBDuOwHtIn4/Jnm20GL+/XCM+zYAwWD8D",[E.VisaCheckout]:"sha384-/OdaTv9qrkKzjObtUe6yzfDhHozFW/+uXlrSl736sOZRJpjGQETvpYXqMFFg69xv",[E.Venmo]:"sha384-dA+ojdW9vbJS4JavcXyOs9d5uZHJg5dNtYupoPSH2zsXIiYDVS5amLb/u8qmQ6oz",[E.HostedFields]:"sha384-31ZkS58+iaWsW06ftW52zzVZFp43WPd7pNYRiddYynSNg6Oh7WGbSFGorAUH6T1z",[E.Fastlane]:"sha384-jlbrwNvL3HvLAUCtLSmrnQ2GH1udCUrRS/bVmReAS5fuIVvcW8Pko/Gkg82tlgtr"}};var H=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Q{constructor(e,t,n){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSDKVersionManager=n}loadClient(){return H(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.Client,"client.min.js")})}loadFastlane(){return H(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.Fastlane,"fastlane.min.js")})}loadPaypalCheckout(){return H(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.PaypalCheckout,"paypal-checkout.min.js")})}loadPaypal(){return H(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.Paypal,"paypal.min.js")})}loadLocalPayment(){return H(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.LocalPayment,"local-payment.min.js")})}loadDataCollector(){return H(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.DataCollector,"data-collector.min.js")})}loadUsBankAccount(){return H(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.UsBankAccount,"us-bank-account.min.js")})}loadGooglePayment(){return H(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.GooglePayment,"google-payment.min.js")})}load3DS(){return H(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.ThreeDSecure,"three-d-secure.min.js")})}loadVisaCheckout(){return this.loadBraintreeModuleOrThrow(E.VisaCheckout,"visa-checkout.min.js")}loadVenmoCheckout(){return this.loadBraintreeModuleOrThrow(E.Venmo,"venmo.min.js")}loadHostedFields(){return H(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(E.HostedFields,"hosted-fields.min.js")})}loadVisaCheckoutSdk(e){return H(this,void 0,void 0,function*(){if(this.braintreeHostWindow.V)return this.braintreeHostWindow.V;const t=e?"sha384-0eu1s1GtqzXlL9DtLgmwzC5WWlEH/ADRM0n38cVQkvtT+W/gey96rcb1LwuUOPDm":"sha384-1f1csvP3ZFxg4dILH1GaY4LHlZ0oX7Rk83rxmLlwbnIi4TM0NYzXoev1VoEiVDS6";return this.scriptLoader.loadScript(`//${e?"sandbox-":""}assets.secure.checkout.visa.com/checkout-widget/resources/js/integration/v1/sdk.js`,{async:!0,attributes:{integrity:t,crossorigin:"anonymous"}}).then(()=>{if(!this.braintreeHostWindow.V)throw new B;return this.braintreeHostWindow.V})})}loadBraintreeModuleOrThrow(e,t){return H(this,void 0,void 0,function*(){let n=this.getBraintreeModule(e);if(n)return n;const i=this.braintreeSDKVersionManager.getSDKVersion(),r=`//js.braintreegateway.com/web/${i}/js/${t}`,o=i in R?this.getIntegrityValuesByModuleName(e,i):void 0;if(yield this.scriptLoader.loadScript(r,o?{async:!0,attributes:{integrity:o,crossorigin:"anonymous"}}:void 0),n=this.getBraintreeModule(e),!n)throw new B;return n})}getBraintreeModule(e){var t;return null===(t=this.braintreeHostWindow.braintree)||void 0===t?void 0:t[e]}getIntegrityValuesByModuleName(e,t){const n=R[t][e];if(!n)throw new Error("Unexpected fileName value");return n}}class V{getSDKVersion(){return Y}}class Z extends u{constructor(e){super(e||"Failed to redirect to checkout page"),this.name="BraintreePaypalWalletError",this.type="braintree_paypal_wallet"}}var F,K=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class J{constructor(e,t){this.walletButtonIntegrationService=e,this.braintreeIntegrationService=t}initialize(e){this.braintreeIntegrationService.initialize(e)}loadPaypalCheckout(e,t,n){return K(this,void 0,void 0,function*(){return this.braintreePaypalCheckout=yield new Promise((i,r)=>{this.braintreeIntegrationService.getPaypalCheckout(e,i,e=>{this.removeElement(t),n&&k(e)&&n(e),r(e)})}),this.braintreePaypalCheckout})}loadVenmoCheckout(e){return K(this,void 0,void 0,function*(){try{this.braintreeVenmoCheckout=yield this.braintreeIntegrationService.getVenmoCheckout()}catch(t){throw this.removeElement(e),t}return this.braintreeVenmoCheckout})}getBraintreePaypalCheckoutOrThrow(){if(!this.braintreePaypalCheckout)throw new B;return this.braintreePaypalCheckout}getBraintreeVenmoCheckoutOrThrow(){if(!this.braintreeVenmoCheckout)throw new B;return this.braintreeVenmoCheckout}teardown(){return K(this,void 0,void 0,function*(){yield this.braintreeIntegrationService.teardown()})}proxyTokenizationPayment(e,t,n){return K(this,void 0,void 0,function*(){const i=this.getBraintreePaypalCheckoutOrThrow(),r=yield i.tokenizePayment(e);return this.redirectToExternalCheckout(r,t,n)})}proxyVenmoTokenizationPayment(e,t){return K(this,void 0,void 0,function*(){const n=yield this.tokenizeVenmo();return this.redirectToExternalCheckout(n,e,t)})}removeElement(e){this.braintreeIntegrationService.removeElement(e)}redirectToExternalCheckout(e,t,n){return K(this,void 0,void 0,function*(){var i;const{deviceData:r}=yield this.braintreeIntegrationService.getDataCollector({paypal:!0}),{details:o,nonce:a}=e,s=this.braintreeIntegrationService.mapToLegacyShippingAddress(o);yield this.walletButtonIntegrationService.addBillingAddress(n,this.mapToBillingAddress(o));const c={paymentWalletData:{providerId:t,providerOrderId:a},cartEntityId:n,queryParams:[{key:"payment_type",value:"paypal"},{key:"action",value:"set_external_checkout"},{key:"provider",value:t},{key:"nonce",value:a},{key:"shipping_address",value:encodeURIComponent(JSON.stringify(s))},...r?[{key:"device_data",value:r}]:[]]},l=null===(i=(yield this.walletButtonIntegrationService.getRedirectToCheckoutUrl(c)).body.redirectUrls)||void 0===i?void 0:i.externalCheckoutUrl;if(!l)throw new Z;return window.location.assign(l),e})}mapToBillingAddress(e){const{billingAddress:t,email:n,firstName:i,lastName:r,phone:o,shippingAddress:a}=e,s=t||a;return{firstName:i||"",lastName:r||"",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:o||"",shouldSaveAddress:!1}}tokenizeVenmo(){const e=this.getBraintreeVenmoCheckoutOrThrow();return new Promise((t,n)=>{e.tokenize((e,i)=>{if(e)return n(e);t(i)})})}}function q(e,t){return Object.assign(e,{resolveIds:t})}!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(F||(F={}));class X extends u{constructor(e){super(function(e){switch(e){case F.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case F.MissingCart:return"Unable to proceed because cart data is unavailable.";case F.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case F.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case F.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case F.MissingCheckoutConfig:case F.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case F.MissingOrder:return"Unable to proceed because order data is unavailable.";case F.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case F.MissingPayment:return"Unable to proceed because payment data is unavailable.";case F.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case F.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case F.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}function $(e){const{color:t,fundingicons:n,height:i=40,layout:a,shape:s,size:c,tagline:l}=e||{},d={color:t,fundingicons:n,height:ee(i),layout:a,shape:s||"rect",size:c,tagline:l};return o(d,r)}function ee(e){const t=Number(e);return!t||Number.isNaN(t)?40:t>55?55:t<25?25:t}var te=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class ne{constructor(e,t){this.braintreePaypalWalletService=e,this.braintreeHostWindow=t}initialize(e){return te(this,void 0,void 0,function*(){const{braintreepaypal:t,containerId:n,methodId:i}=e;if(!i)throw new C('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new C('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new C('Unable to initialize payment because "options.braintreepaypal" argument is not provided.');let r;try{r=JSON.parse(atob(t.initializationData))}catch(e){throw new C("Failed to parse payment method 'initializationData'.")}const{initializationData:o,config:a}=r;if(!t.clientToken||!o||!a)throw new X(F.MissingPaymentMethod);const s={currency:t.currency.code,intent:o.intent,isCreditEnabled:o.isCreditEnabled,commit:!1};this.braintreePaypalWalletService.initialize(t.clientToken),yield this.braintreePaypalWalletService.loadPaypalCheckout(s,n,t.onError),this.renderButton(t,n,i,!!a.testMode,o.intent)})}deinitialize(){return te(this,void 0,void 0,function*(){yield this.braintreePaypalWalletService.teardown()})}renderButton(e,t,n,i,r){const{style:o,onEligibilityFailure:a}=e,{paypal:s}=this.braintreeHostWindow;if(!s)return void this.braintreePaypalWalletService.removeElement(t);const c=s.Buttons({env:i?"sandbox":"production",fundingSource:s.FUNDING.PAYPAL,style:$(o),createOrder:()=>this.setupPayment(e,r),onApprove:t=>this.tokenizePayment(t,n,e.cartId,e.onAuthorizeError)});c.isEligible()?c.render(`#${t}`):a&&"function"==typeof a&&a()}setupPayment(e,t){return te(this,void 0,void 0,function*(){const{onPaymentError:n,amount:i,currency:r}=e,o=this.braintreePaypalWalletService.getBraintreePaypalCheckoutOrThrow();try{return yield o.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,amount:i,currency:r.code,offerCredit:!1,intent:t})}catch(e){throw(k(e)||e instanceof u)&&(null==n||n(e)),e}})}tokenizePayment(e,t,n,i){return te(this,void 0,void 0,function*(){try{yield this.braintreePaypalWalletService.proxyTokenizationPayment(e,t,n)}catch(e){throw(k(e)||e instanceof u)&&(null==i||i(e)),e}})}}const ie=q(e=>{const n=window,i=new U(new Q(t(),n,new V),n);return new ne(new J(e,i),n)},[{id:"braintreepaypal"}]);var re=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class oe{constructor(e,t){this.braintreePaypalWalletService=e,this.braintreeHostWindow=t}initialize(e){return re(this,void 0,void 0,function*(){const{braintreepaypalcredit:t,containerId:n,methodId:i}=e;if(!i)throw new C('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new C('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new C('Unable to initialize payment because "options.braintreepaypalcredit" argument is not provided.');let r;try{r=JSON.parse(atob(t.initializationData))}catch(e){throw new C("Failed to parse payment method 'initializationData'.")}const{initializationData:o,config:a}=r;if(!t.clientToken||!o||!a)throw new X(F.MissingPaymentMethod);const s={currency:t.currency.code,intent:o.intent,isCreditEnabled:o.isCreditEnabled,commit:!1};this.braintreePaypalWalletService.initialize(t.clientToken),yield this.braintreePaypalWalletService.loadPaypalCheckout(s,n,t.onError),this.renderButton(t,n,i,!!a.testMode,o.intent)})}deinitialize(){return re(this,void 0,void 0,function*(){yield this.braintreePaypalWalletService.teardown()})}renderButton(e,t,n,i,r){const{style:o,onEligibilityFailure:a}=e,{paypal:s}=this.braintreeHostWindow;if(!s)return void this.braintreePaypalWalletService.removeElement(t);const c=s.Buttons({env:i?"sandbox":"production",fundingSource:s.FUNDING.PAYLATER,style:Object.assign(Object.assign({},$(o)),{color:L.GOLD}),createOrder:()=>this.setupPayment(e,r),onApprove:t=>this.tokenizePayment(t,n,e.cartId,e.onAuthorizeError)});c.isEligible()?c.render(`#${t}`):a&&"function"==typeof a&&a()}setupPayment(e,t){return re(this,void 0,void 0,function*(){const{onPaymentError:n,amount:i,currency:r}=e,o=this.braintreePaypalWalletService.getBraintreePaypalCheckoutOrThrow();try{return yield o.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,amount:i,currency:r.code,offerCredit:!0,intent:t})}catch(e){throw(k(e)||e instanceof u)&&(null==n||n(e)),e}})}tokenizePayment(e,t,n,i){return re(this,void 0,void 0,function*(){try{yield this.braintreePaypalWalletService.proxyTokenizationPayment(e,t,n)}catch(e){throw(k(e)||e instanceof u)&&(null==i||i(e)),e}})}}const ae=q(e=>{const n=window,i=new U(new Q(t(),n,new V),n);return new oe(new J(e,i),n)},[{id:"braintreepaypalcredit"}]),se={[L.WHITE]:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTE4IiBoZWlnaHQ9IjI5IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiPgogICAgPGRlZnM+CiAgICAgICAgPGNsaXBQYXRoIGlkPSJjbGlwMCI+CiAgICAgICAgICAgIDxyZWN0IHdpZHRoPSIxOTgiIGhlaWdodD0iMzgiIGZpbGw9IndoaXRlIiBpZD0ic3ZnXzEiLz4KICAgICAgICA8L2NsaXBQYXRoPgogICAgPC9kZWZzPgogICAgPGc+CiAgICAgICAgPHRpdGxlPkxheWVyIDE8L3RpdGxlPgogICAgICAgIDxnIHN0cm9rZT0ibnVsbCIgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwKSIgaWQ9InN2Z18yIj4KICAgICAgICAgICAgPHBhdGggc3Ryb2tlPSJudWxsIiBkPSJtMjAuMDM2ODgsNGMwLjc1NDU4LDEuMjY3NTEgMS4wOTQ4NSwyLjU3Mjk0IDEuMDk0ODUsNC4yMjIwOGMwLDUuMjU5ODUgLTQuNDE0OTYsMTIuMDkyNzEgLTcuOTk4MjMsMTYuODkwNzVsLTguMTg0NDMsMGwtMy4yODI0LC0xOS45NjExN2w3LjE2NjM0LC0wLjY5MmwxLjczNTQ1LDE0LjIwMzY1YzEuNjIxNTQsLTIuNjg2NjQgMy42MjI1OSwtNi45MDg3MSAzLjYyMjU5LC05Ljc4NzMzYzAsLTEuNTc1NjMgLTAuMjY1NCwtMi42NDg4IC0wLjY4MDE3LC0zLjUzMjQzbDYuNTI2LC0xLjM0MzU0eiIgZmlsbD0id2hpdGUiIGlkPSJzdmdfMyIvPgogICAgICAgICAgICA8cGF0aCBzdHJva2U9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Tg4NTUsMS43MjczNGMxLjM5NTY1LC0xLjAzNTE2IDMuMjgwODQsLTIuMDcyODQgNS44MDgwOSwtMi4wNzI4NGMyLjE4ODE2LC0wLjAwMDgxIDMuNjIwODMsMC45NTg4NSA0LjMzOTAyLDIuMjY0MTlsMC4wMDAwMSwwLjAwMDAxeiIgZmlsbD0iIzAwOENGRiIgaWQ9InN2Z182Ii8+CiAgICAgICAgICAgIDxwYXRoIHN0cm9rZT0ibnVsbCIgZD0ibTEwNi4yNjA3NSwxMi4zNjgzYzAsLTEuNjg5MTQgLTAuNDE1NCwtMi44NDA2OSAtMS42NTg4OCwtMi44NDA2OWMtMi43NTQyNywwIC0zLjMxOTU4LDQuOTUxNDcgLTMuMzE5NTgsNy40ODQ0YzAsMS45MjE2NyAwLjUyODI4LDMuMTEwODggMS43NzE3NiwzLjExMDg4YzIuNjAzNDcsMCAzLjIwNjcsLTUuMjIxODQgMy4yMDY3LC03Ljc1NDU5em0tMTIuMDcwMDQsNC4zMzc5NGMwLC02LjUyNDkyIDMuMzk0NTMsLTEyLjYzMDM4IDExLjIwMzEzLC0xMi42MzAzOGM1Ljg4NTEyLDAgOC4wMzYxNiwzLjUzMjUxIDguMDM2MTYsOC40MDgzMWMwLDYuNDQ5MzQgLTMuMzU3NTEsMTMuMTI4MTMgLTExLjM1NTczLDEzLjEyODEzYy01LjkyMjE0LDAgLTcuODgzNTUsLTMuOTU0MzMgLTcuODgzNTUsLTguOTA2MDZsLTAuMDAwMDEsMHoiIGZpbGw9IiMwMDhDRkYiIGlkPSJzdmdfNyIvPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+Cg=="},ce=e=>{const{color:t,height:n}=e;return{backgroundColor:(i=t||"",i===L.WHITE?"#FFFFFF":"#3D95CE"),backgroundPosition:"50% 50%",backgroundSize:"80px auto",backgroundImage:`url("${se[t===L.WHITE?L.BLUE:L.WHITE]}")`,backgroundRepeat:"no-repeat",borderRadius:"4px",cursor:"pointer",transition:"0.2s ease",minHeight:`${n||40}px`,minWidth:"150px",height:"100%",border:t===L.WHITE?"1px solid black":"none"};var i};var le=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class de{constructor(e){this.braintreePaypalWalletService=e}initialize(e){return le(this,void 0,void 0,function*(){const{braintreevenmo:t,containerId:n,methodId:i}=e;if(!i)throw new C('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new C('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new C('Unable to initialize payment because "options.braintreevenmo" argument is not provided.');let r;try{r=JSON.parse(atob(t.initializationData))}catch(e){throw new C("Failed to parse payment method 'initializationData'.")}const{initializationData:o,config:a}=r;if(!t.clientToken||!o||!a)throw new X(F.MissingPaymentMethod);this.braintreePaypalWalletService.initialize(t.clientToken);try{yield this.braintreePaypalWalletService.loadVenmoCheckout(n)}catch(e){return void this.handleInitializationError(e,t)}this.renderButton(t,n,i,o)})}deinitialize(){return le(this,void 0,void 0,function*(){yield this.braintreePaypalWalletService.teardown()})}handleInitializationError(e,t){const{onError:n,onEligibilityFailure:i}=t;e instanceof w?null==i||i():(k(e)||e instanceof u)&&(null==n||n(e))}renderButton(e,t,n,i){const{style:r,onEligibilityFailure:o}=e,{cartButtonStyles:a}=i.paymentButtonStyles||{},s=r||a||{},{color:c}=s,l=document.getElementById(t);if(!l)return this.braintreePaypalWalletService.removeElement(t),void(null==o||o());l.setAttribute("aria-label","Venmo"),Object.assign(l.style,ce(s)),l.addEventListener("click",()=>le(this,void 0,void 0,function*(){var t;l.setAttribute("disabled","true");try{yield this.braintreePaypalWalletService.proxyVenmoTokenizationPayment(n,e.cartId)}catch(n){(k(n)||n instanceof u)&&(null===(t=e.onAuthorizeError)||void 0===t||t.call(e,n))}finally{l.removeAttribute("disabled")}})),c===L.BLUE&&(l.addEventListener("mouseenter",()=>{l.style.backgroundColor="#0a7fc2"}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor=ce(s).backgroundColor}))}}const ue=q(e=>{const n=window,i=new U(new Q(t(),n,new V),n);return new de(new J(e,i))},[{id:"braintreevenmo"}]),he=["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"];var ye,Me,pe,ge,_e,me,we,Ce=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class fe{constructor(e){this.scriptLoader=e,this.window=window}getPayPalSDK(e,t,n,i,r){return Ce(this,void 0,void 0,function*(){const o=this.getPayPalSdkScriptConfigOrThrow(e,t,n,i);return this.loadPayPalSDK(o,r)})}loadPayPalSDK(e){return Ce(this,arguments,void 0,function*(e,t=!1){if(!this.window.paypal||t){const t=this.transformConfig(e.options),n=this.transformConfig(e.attributes),i=`https://www.paypal.com/sdk/js?${new URLSearchParams(t).toString()}`;yield this.scriptLoader.loadScript(i,{async:!0,attributes:n})}if(!this.window.paypal)throw new B;return this.window.paypal})}getPayPalSdkScriptConfigOrThrow(e,t,n,i=!0){const{id:r,clientToken:o,initializationData:a}=e;if(!(null==a?void 0:a.clientId))throw new X(F.MissingPaymentMethod);const{intent:s,clientId:c,merchantId:l,buyerCountry:d,attributionId:u,isVenmoEnabled:h,isHostedCheckoutEnabled:y,isPayPalCreditAvailable:M,isDeveloperModeApplicable:p,availableAlternativePaymentMethods:g=[],enabledAlternativePaymentMethods:_=[],isGooglePayEnabled:m}=a,w=y||i,C="paypalcommercecreditcards"===r,f=C?["card"]:[],v=M?["credit","paylater"]:[],N=h?["venmo"]:[],I=m?["googlepay"]:[],z=i?["card-fields"]:[],T=[...C?[]:["card"],...M?[]:["credit","paylater"],...h?[]:["venmo"],...g.filter(e=>!_.includes(e))],D=[...f,...v,...N,..._],b=function(e){if(!e)return;let t;if(e.includes("-")){const[n,i]=e.split("-");t=`${n}_${i.toUpperCase()}`}else t=`${e}_${e.toUpperCase()}`;return he.includes(t)?t:void 0}(n);return{options:Object.assign(Object.assign({"client-id":c,"merchant-id":l,"enable-funding":D.length>0?D:void 0,"disable-funding":T.length>0?T:void 0,commit:w,components:["buttons","hosted-fields","payment-fields","legal",...I,...z],currency:t,intent:s},p&&{"buyer-country":d}),b&&{locale:b}),attributes:{"data-partner-attribution-id":u,"data-client-token":o}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}!function(e){e.Possible="POSSIBLE",e.No="NO",e.Unknown="UNKNOWN",e.Yes="YES"}(ye||(ye={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(Me||(Me={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(pe||(pe={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(ge||(ge={})),function(e){e.pill="pill",e.rect="rect"}(_e||(_e={})),function(e){e.OXXO="oxxo",e.IDEAL="ideal"}(me||(me={})),function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(we||(we={}));var ve=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class Ne{constructor(e,t){this.walletButtonIntegrationService=e,this.paypalCommerceScriptLoader=t}loadPayPalSdk(e,t,n,i){return ve(this,void 0,void 0,function*(){return this.paypalSdk=yield this.paypalCommerceScriptLoader.getPayPalSDK(e,t,void 0,n,i),this.paypalSdk})}getPayPalSdkOrThrow(){if(!this.paypalSdk)throw new B;return this.paypalSdk}proxyTokenizationPayment(e,t,n,i){return ve(this,void 0,void 0,function*(){var r;if(!i)throw new X(F.MissingOrderId);const o={paymentWalletData:{providerId:t,providerOrderId:i},cartEntityId:e,queryParams:[{key:"payment_type",value:"paypal"},{key:"action",value:"set_external_checkout"},{key:"provider",value:n}]},a=yield this.walletButtonIntegrationService.getRedirectToCheckoutUrl(o);if(!(null===(r=a.body.redirectUrls)||void 0===r?void 0:r.externalCheckoutUrl))throw new Error("Failed to redirection to checkout page");window.location.assign(a.body.redirectUrls.externalCheckoutUrl)})}createPaymentOrderIntent(e,t,n){return ve(this,void 0,void 0,function*(){const i={cartEntityId:t,paymentWalletEntityId:e};return(yield this.walletButtonIntegrationService.createPaymentOrderIntent(i,n)).body.orderId})}addBillingAddress(e,t,n){return ve(this,void 0,void 0,function*(){return this.walletButtonIntegrationService.addBillingAddress(e,t,n)})}getValidButtonStyle(e){const{color:t,height:n,label:i,shape:a}=e||{},s={color:t&&ge[t]?t:void 0,height:this.getValidHeight(n),label:i&&pe[i]?i:void 0,shape:a&&_e[a]?a:void 0};return o(s,r)}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 Ie=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class ze{constructor(e){this.paypalCommerceHeadlessWalletButtonService=e}initialize(e){return Ie(this,void 0,void 0,function*(){var t,n;const{paypalcommercepaypal:i,containerId:r,methodId:o}=e;if(!o)throw new C('Unable to initialize payment because "options.methodId" argument is not provided.');if(!r)throw new C('Unable to initialize payment because "options.containerId" argument is not provided.');if(!i)throw new C('Unable to initialize payment because "options.paypalcommercepaypal" argument is not provided.');let a;try{a=JSON.parse(atob(i.initializationData))}catch(e){throw new C("Failed to parse payment method 'initializationData'.")}const s=null===(n=null===(t=a.initializationData)||void 0===t?void 0:t.paymentButtonStyles)||void 0===n?void 0:n.cartButtonStyles;yield this.paypalCommerceHeadlessWalletButtonService.loadPayPalSdk(a,i.currency.code,!1),this.renderButton(r,"paypalcommerce.paypal",i.cartId,s)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n,i){const r=this.paypalCommerceHeadlessWalletButtonService.getPayPalSdkOrThrow(),o={createOrder:()=>this.paypalCommerceHeadlessWalletButtonService.createPaymentOrderIntent(t,n),onApprove:(e,i)=>Ie(this,[e,i],void 0,function*({orderID:e},i){const r=yield i.order.get(),o=this.mapOrderDetailsToBillingAddress(r);yield this.paypalCommerceHeadlessWalletButtonService.addBillingAddress(n,o),yield this.paypalCommerceHeadlessWalletButtonService.proxyTokenizationPayment(n,t,"paypalcommerce",e)})},a=Object.assign({fundingSource:r.FUNDING.PAYPAL,style:this.paypalCommerceHeadlessWalletButtonService.getValidButtonStyle(i)},o),s=r.Buttons(a);s.isEligible()?s.render(`#${e}`):this.paypalCommerceHeadlessWalletButtonService.removeElement(e)}mapOrderDetailsToBillingAddress(e){var t,n,i,r;const{payer:o}=e;return{firstName:o.name.given_name,lastName:o.name.surname,company:"",address1:o.address.address_line_1,address2:o.address.address_line_2,city:o.address.admin_area_2,email:o.email_address,stateOrProvince:null!==(t=o.address.admin_area_1)&&void 0!==t?t:"",stateOrProvinceCode:null!==(n=o.address.admin_area_1)&&void 0!==n?n:"",countryCode:o.address.country_code,postalCode:o.address.postal_code,phone:null!==(r=null===(i=o.phone)||void 0===i?void 0:i.phone_number.national_number)&&void 0!==r?r:"",shouldSaveAddress:!1}}}const Te=q(e=>new ze(new Ne(e,new fe(t()))),[{id:"paypalcommercepaypal"}]);var De=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class be{constructor(e){this.paypalCommerceHeadlessWalletButtonService=e}initialize(e){return De(this,void 0,void 0,function*(){var t,n;const{paypalcommercepaypalcredit:i,containerId:r,methodId:o}=e;if(!o)throw new C('Unable to initialize payment because "options.methodId" argument is not provided.');if(!r)throw new C('Unable to initialize payment because "options.containerId" argument is not provided.');if(!i)throw new C('Unable to initialize payment because "options.paypalcommercepaypalcredit" argument is not provided.');let a;try{a=JSON.parse(atob(i.initializationData))}catch(e){throw new C("Failed to parse payment method 'initializationData'.")}yield this.paypalCommerceHeadlessWalletButtonService.loadPayPalSdk(a,i.currency.code,!1);const s=null===(n=null===(t=a.initializationData)||void 0===t?void 0:t.paymentButtonStyles)||void 0===n?void 0:n.cartButtonStyles;this.renderButton(r,"paypalcommerce.paypalcredit",i.cartId,s)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n,i){const r=this.paypalCommerceHeadlessWalletButtonService.getPayPalSdkOrThrow(),o=[r.FUNDING.PAYLATER,r.FUNDING.CREDIT],a={createOrder:()=>this.paypalCommerceHeadlessWalletButtonService.createPaymentOrderIntent(t,n),onApprove:(e,i)=>De(this,[e,i],void 0,function*({orderID:e},i){const r=yield i.order.get(),o=this.mapOrderDetailsToBillingAddress(r);yield this.paypalCommerceHeadlessWalletButtonService.addBillingAddress(n,o),yield this.paypalCommerceHeadlessWalletButtonService.proxyTokenizationPayment(n,t,"paypalcommercecredit",e)})};let s=!1;o.forEach(t=>{if(!s){const n=Object.assign({fundingSource:t,style:this.paypalCommerceHeadlessWalletButtonService.getValidButtonStyle(i)},a),o=r.Buttons(n);o.isEligible()&&(o.render(`#${e}`),s=!0)}}),s||this.paypalCommerceHeadlessWalletButtonService.removeElement(e)}mapOrderDetailsToBillingAddress(e){var t,n,i,r;const{payer:o}=e;return{firstName:o.name.given_name,lastName:o.name.surname,company:"",address1:o.address.address_line_1,address2:o.address.address_line_2,city:o.address.admin_area_2,email:o.email_address,stateOrProvince:null!==(t=o.address.admin_area_1)&&void 0!==t?t:"",stateOrProvinceCode:null!==(n=o.address.admin_area_1)&&void 0!==n?n:"",countryCode:o.address.country_code,postalCode:o.address.postal_code,phone:null!==(r=null===(i=o.phone)||void 0===i?void 0:i.phone_number.national_number)&&void 0!==r?r:"",shouldSaveAddress:!1}}}const Le=q(e=>new be(new Ne(e,new fe(t()))),[{id:"paypalcommercepaypalcredit"}]);var Ae=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})};class je{constructor(e){this.paypalCommerceHeadlessWalletButtonService=e}initialize(e){return Ae(this,void 0,void 0,function*(){var t,n;const{paypalcommercevenmo:i,containerId:r,methodId:o}=e;if(!o)throw new C('Unable to initialize payment because "options.methodId" argument is not provided.');if(!r)throw new C('Unable to initialize payment because "options.containerId" argument is not provided.');if(!i)throw new C('Unable to initialize payment because "options.paypalcommercevenmo" argument is not provided.');let a;try{a=JSON.parse(atob(i.initializationData))}catch(e){throw new C("Failed to parse payment method 'initializationData'.")}const s=null===(n=null===(t=a.initializationData)||void 0===t?void 0:t.paymentButtonStyles)||void 0===n?void 0:n.cartButtonStyles;yield this.paypalCommerceHeadlessWalletButtonService.loadPayPalSdk(a,i.currency.code,!1),this.renderButton(r,"paypalcommerce.venmo",i.cartId,s)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n,i){const r=this.paypalCommerceHeadlessWalletButtonService.getPayPalSdkOrThrow(),o={createOrder:()=>this.paypalCommerceHeadlessWalletButtonService.createPaymentOrderIntent(t,n),onApprove:e=>Ae(this,[e],void 0,function*({orderID:e}){yield this.paypalCommerceHeadlessWalletButtonService.proxyTokenizationPayment(n,t,"paypalcommercevenmo",e)})},a=Object.assign({fundingSource:r.FUNDING.VENMO,style:this.getValidVenmoButtonStyles(i)},o),s=r.Buttons(a);s.isEligible()?s.render(`#${e}`):this.paypalCommerceHeadlessWalletButtonService.removeElement(e)}getValidVenmoButtonStyles(e){const t=this.paypalCommerceHeadlessWalletButtonService.getValidButtonStyle(e);return t.color===ge.gold?Object.assign(Object.assign({},t),{color:void 0}):t}}const Se=q(e=>new je(new Ne(e,new fe(t()))),[{id:"paypalcommercevenmo"}]);function Oe(e){return e&&"resolveIds"in e}function Ee(){try{return"production"}catch(e){return"development"}}class Pe{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 ke{log(){}info(){}warn(){}error(){}debug(){}}const xe=function(e=!0){return e?new Pe(console):new ke}("test"!==Ee());class Ue 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 Be extends Ue{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class Ge{constructor(e){var t,n,i;this._factories={},this._instances={},this._defaultToken=null!==(t=null==e?void 0:e.defaultToken)&&void 0!==t?t:"default",this._useFallback=null===(n=null==e?void 0:e.useFallback)||void 0===n||n,this._tokenResolver=null!==(i=null==e?void 0:e.tokenResolver)&&void 0!==i?i:e=>e}get(e,t){try{return this._getInstance(e||this._defaultToken,t||e||this._defaultToken)}catch(e){if(!this._useFallback)throw e;return this._getInstance(this._defaultToken,t||this._defaultToken)}}getFactory(e,t){const n=this._tokenResolver(e,Object.keys(this._factories),t);return n?this._factories[n]:void 0}register(e,t){if(this._hasFactory(e))throw new Be(`'${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 Be(`'${e}' is not registered.`);this._instances[t]=n()}return this._instances[t]}}class Ye{constructor(e=!1){this._useFallback=e,this._registry=new Ge({tokenResolver:this._resolveToken.bind(this),defaultToken:this._encodeToken({default:!0}),useFallback:this._useFallback})}get(e){return this._registry.get(this._encodeToken(e))}getFactory(e,t){try{return this._registry.getFactory(this._encodeToken(e),t)}catch(e){return}}getUseFallback(){return this._useFallback}register(e,t){this._registry.register(this._encodeToken(e),t)}_encodeToken(e){return btoa(JSON.stringify(e))}_decodeToken(e){return JSON.parse(atob(e))}_resolveToken(e,t,n){var i;const r=this._decodeToken(e),o=[];t.forEach(e=>{const t=this._decodeToken(e),n={token:e,matches:0,default:!1,totalKeys:Object.keys(t).length};for(const[e,i]of Object.entries(t)){if(e in r&&r[e]!==i){n.matches=0;break}e in r&&r[e]===i&&n.matches++,"default"===e&&!0===i&&(n.default=!0)}o.push(n)});const a=o.sort((e,t)=>t.matches-e.matches).filter(e=>e.matches>0);a.length>1&&a[0].matches===a[1].matches&&"development"===Ee()&&xe.warn("The provided query matches at least two strategies with the same specificity. This warning can be resolved by making their resolve ID more specific.");const s=Object.keys(r).length;if(n){const e=a.find(e=>e.matches===s&&e.matches===e.totalKeys);if(!e)throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(r)} with exact match.`);return e.token}const c=a[0];if(c&&c.token)return c.token;if(this._useFallback){const e=null===(i=o.find(e=>e.default))||void 0===i?void 0:i.token;if(e)return e}throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(r)}.`)}}function We(e,t,n){if("function"!=typeof n.value)return n;let i=n.value;return{get(){const e=i.bind(this);return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e},set(e){i=e}}}const Re=e=>{const t=a(e);return document.getElementById(t)?Re(e):t};let He=class{constructor(e){this._registryV2=e}initializeWalletButton(e){const t=this.getContainerIds(e);return Promise.all(t.map(t=>{return n=this,i=void 0,o=function*(){return this._registryV2.get({id:e.methodId}).initialize(Object.assign(Object.assign({},e),{containerId:t}))},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{c(o.next(e))}catch(e){t(e)}}function s(e){try{c(o.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}c((o=o.apply(n,i||[])).next())});var n,i,r,o}))}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 Be(`Unable to find any element with the specified selector: ${e}`);return Array.prototype.slice.call(n).map(e=>(e.id||(e.id=Re(t)),e.id))}(e.containerId,`${e.methodId}-container`);var t}};He=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([function(e,t,n){return t&&n?We(0,t,n):function(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&"constructor"!==n&&Object.defineProperty(t.prototype,n,We(e.prototype,n,i))}),t}(e)}],He);const Qe=He;function Ve(t){const{graphQLEndpoint:n}=t,i=function(e,t){const n=new Ye;for(const[,i]of Object.entries(t))if(Oe(i))for(const t of i.resolveIds)n.register(t,()=>i(e));return n}((t=>{const n=e();return new m(t,new d(n),new g(n),new y(n))})(n),c);return new Qe(i)}export{Ve as createWalletButtonInitializer};
2
2
  //# sourceMappingURL=wallet-button.js.map