@zonos/elements 1.0.16 → 1.0.17-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/cjs/{cart-e27fd17c.js → cart-108bc407.js} +8 -1
  2. package/dist/cjs/cart-108bc407.js.map +1 -0
  3. package/dist/cjs/zonos-address_2.cjs.entry.js +1 -1
  4. package/dist/cjs/zonos-banner_2.cjs.entry.js +1 -1
  5. package/dist/cjs/zonos-cart-items_10.cjs.entry.js +5 -3
  6. package/dist/cjs/zonos-cart-items_10.cjs.entry.js.map +1 -1
  7. package/dist/cjs/zonos-checkout.cjs.entry.js +6 -2
  8. package/dist/cjs/zonos-checkout.cjs.entry.js.map +1 -1
  9. package/dist/cjs/zonos-controller.cjs.entry.js +1 -1
  10. package/dist/collection/components/checkout/zonos-checkout/zonos-cart-items/zonos-cart-items.js +3 -1
  11. package/dist/collection/components/checkout/zonos-checkout/zonos-cart-items/zonos-cart-items.js.map +1 -1
  12. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +1 -1
  13. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js.map +1 -1
  14. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +5 -1
  15. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js.map +1 -1
  16. package/dist/collection/components/store/checkout/cart.js +6 -0
  17. package/dist/collection/components/store/checkout/cart.js.map +1 -1
  18. package/dist/collection/components/store/checkout/stripe.js +2 -0
  19. package/dist/collection/components/store/checkout/stripe.js.map +1 -1
  20. package/dist/collection/environment.js +9 -1
  21. package/dist/collection/environment.js.map +1 -1
  22. package/dist/collection/scripts/loadStripe.js +3 -3
  23. package/dist/collection/scripts/loadStripe.js.map +1 -1
  24. package/dist/collection/scripts/stripe.js +6 -6
  25. package/dist/collection/scripts/stripe.js.map +1 -1
  26. package/dist/collection/scripts/zonos.js +2 -2
  27. package/dist/collection/scripts/zonos.js.map +1 -1
  28. package/dist/collection/types/generated/graphql.customer.types.js +5 -0
  29. package/dist/collection/types/generated/graphql.customer.types.js.map +1 -1
  30. package/dist/components/stripe.js +8 -1
  31. package/dist/components/stripe.js.map +1 -1
  32. package/dist/components/zonos-cart-items2.js +3 -1
  33. package/dist/components/zonos-cart-items2.js.map +1 -1
  34. package/dist/components/zonos-checkout-finish2.js +1 -1
  35. package/dist/components/zonos-checkout-finish2.js.map +1 -1
  36. package/dist/components/zonos-checkout.js +5 -1
  37. package/dist/components/zonos-checkout.js.map +1 -1
  38. package/dist/esm/{cart-36c33342.js → cart-2f83e048.js} +8 -1
  39. package/dist/esm/cart-2f83e048.js.map +1 -0
  40. package/dist/esm/zonos-address_2.entry.js +1 -1
  41. package/dist/esm/zonos-banner_2.entry.js +1 -1
  42. package/dist/esm/zonos-cart-items_10.entry.js +5 -3
  43. package/dist/esm/zonos-cart-items_10.entry.js.map +1 -1
  44. package/dist/esm/zonos-checkout.entry.js +6 -2
  45. package/dist/esm/zonos-checkout.entry.js.map +1 -1
  46. package/dist/esm/zonos-controller.entry.js +1 -1
  47. package/dist/esm-es5/cart-2f83e048.js +2 -0
  48. package/dist/esm-es5/cart-2f83e048.js.map +1 -0
  49. package/dist/esm-es5/zonos-address_2.entry.js +1 -1
  50. package/dist/esm-es5/zonos-banner_2.entry.js +1 -1
  51. package/dist/esm-es5/zonos-cart-items_10.entry.js +1 -1
  52. package/dist/esm-es5/zonos-cart-items_10.entry.js.map +1 -1
  53. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  54. package/dist/esm-es5/zonos-checkout.entry.js.map +1 -1
  55. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  56. package/dist/scripts/loadStripe.js +118 -0
  57. package/dist/scripts/loadZonos.js +300 -0
  58. package/dist/scripts/stripe.js +126 -0
  59. package/dist/scripts/zonos.js +300 -0
  60. package/dist/types/components/store/checkout/cart.d.ts +14 -0
  61. package/dist/types/components/store/checkout/stripe.d.ts +1 -1
  62. package/dist/types/scripts/loadStripe.d.ts +1 -1
  63. package/dist/types/scripts/stripe.d.ts +2 -2
  64. package/dist/types/types/generated/graphql.customer.types.d.ts +48 -0
  65. package/dist/types/types/generated/graphql.customer.types.ts +50 -0
  66. package/dist/zonos-elements/{cart-36c33342.js → cart-2f83e048.js} +8 -1
  67. package/dist/zonos-elements/cart-2f83e048.js.map +1 -0
  68. package/dist/zonos-elements/cart-9780fa28.system.js +2 -0
  69. package/dist/zonos-elements/cart-9780fa28.system.js.map +1 -0
  70. package/dist/zonos-elements/zonos-address_2.entry.js +1 -1
  71. package/dist/zonos-elements/zonos-address_2.system.entry.js +1 -1
  72. package/dist/zonos-elements/zonos-banner_2.entry.js +1 -1
  73. package/dist/zonos-elements/zonos-banner_2.system.entry.js +1 -1
  74. package/dist/zonos-elements/zonos-cart-items_10.entry.js +5 -3
  75. package/dist/zonos-elements/zonos-cart-items_10.entry.js.map +1 -1
  76. package/dist/zonos-elements/zonos-cart-items_10.system.entry.js +1 -1
  77. package/dist/zonos-elements/zonos-cart-items_10.system.entry.js.map +1 -1
  78. package/dist/zonos-elements/zonos-checkout.entry.js +6 -2
  79. package/dist/zonos-elements/zonos-checkout.entry.js.map +1 -1
  80. package/dist/zonos-elements/zonos-checkout.system.entry.js +1 -1
  81. package/dist/zonos-elements/zonos-checkout.system.entry.js.map +1 -1
  82. package/dist/zonos-elements/zonos-controller.entry.js +1 -1
  83. package/dist/zonos-elements/zonos-controller.system.entry.js +1 -1
  84. package/package.json +2 -2
  85. package/dist/cjs/cart-e27fd17c.js.map +0 -1
  86. package/dist/esm/cart-36c33342.js.map +0 -1
  87. package/dist/esm-es5/cart-36c33342.js +0 -2
  88. package/dist/esm-es5/cart-36c33342.js.map +0 -1
  89. package/dist/zonos-elements/cart-36c33342.js.map +0 -1
  90. package/dist/zonos-elements/cart-ecd9011b.system.js +0 -2
  91. package/dist/zonos-elements/cart-ecd9011b.system.js.map +0 -1
@@ -1 +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,CAAC;QACb,iCAAiC;QACjC,SAAS,IAAI,YAAY;QACzB,IAAI,CAAC,OAAO,IAAI,SAAS;QACzB,IAAI,CAAC,QAAQ,IAAI,QAAQ;OAC1B,CAAC,IAED,IAAI,CAAC,OAAO,IACX,aAAa,EAAE,KAEf,oBACE,WAAW,EAAE,KAAK,gBACN,cAAc,EAC1B,MAAM,EAAC,OAAO,EACd,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,IAAI,CAAC,QAAQ,EACrB,aAAa,QACb,QAAQ,QACR,cAAc,QACd,aAAa,QACb,aAAa,EAAE,MAAM,IAAI,CAAC,kBAAkB,EAAE,EAC9C,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAC,QAAQ,IAEb,aAAa,EAAE,CACH,CAChB,CACI,EACP;GACH;;;;;;;;;;;","names":[],"sources":["src/components/checkout/zonos-checkout/zonos-checkout.scss?tag=zonos-checkout&encapsulation=scoped","src/components/checkout/zonos-checkout/zonos-checkout.tsx"],"sourcesContent":["$primary-color: var(--primary-color, $amino-gray-0);\n$border-radius: var(--border-radius, $amino-radius-10);\n\n:host {\n * {\n @include zonos--scrollbar;\n }\n .zonos--content {\n display: flex;\n height: 100%;\n overflow: hidden;\n border-radius: $border-radius;\n .zonos--left,\n .zonos--right {\n flex: 1;\n padding: $amino-space-48 $amino-space-56;\n }\n .zonos--left {\n background-color: $primary-color;\n border-right: 1px solid $amino-gray-200;\n }\n .zonos--right {\n background-color: $amino-gray-0;\n padding-bottom: $amino-space-80;\n }\n\n .zonos--done {\n width: 100%;\n max-height: 100%;\n height: 100%;\n overflow: auto;\n flex-direction: column;\n background-color: $amino-gray-0;\n align-items: center;\n justify-content: center;\n padding: $amino-space-24;\n padding-bottom: 50px;\n .zonos--header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n img {\n width: 150px;\n min-width: 150px;\n }\n }\n .zonos--logo {\n margin-bottom: 0;\n }\n\n zonos-checkout-finish {\n flex: 1;\n }\n }\n }\n\n .zonos--left {\n display: flex;\n flex-direction: column;\n .zonos--back-button {\n margin-bottom: $amino-space-24;\n }\n .zonos--wrapper {\n padding: 0 $amino-space-8 $amino-space-8;\n }\n .zonos--payment-error-banner {\n margin-top: $amino-space-24;\n }\n }\n\n .zonos--right {\n position: relative;\n .zonos--close-button {\n position: absolute;\n right: $amino-space-32;\n top: $amino-space-32;\n }\n }\n .zonos--footer {\n display: flex;\n justify-content: flex-end;\n align-items: center;\n position: absolute;\n bottom: $amino-space-32;\n right: $amino-space-56;\n gap: $amino-space-8;\n }\n\n .zonos--wrapper {\n overflow: auto;\n max-height: 100%;\n position: relative;\n }\n\n .flex--wrapper {\n display: flex;\n flex-direction: column;\n max-height: 100%;\n }\n\n .zonos--logo {\n display: flex;\n align-items: center;\n }\n\n .zonos--checkout-default-message {\n margin-left: $amino-space-76;\n margin-bottom: $amino-space-8;\n }\n}\n\n:host(.preview) {\n min-width: 500px;\n margin: auto;\n .zonos--content {\n border: $amino-border;\n .zonos--done {\n padding: $amino-space-32;\n }\n }\n}\n\n:host(.mobile) {\n @include checkout-mobile;\n}\n","import {\n Component,\n Fragment,\n h,\n Host,\n Listen,\n Method,\n Prop,\n State,\n Watch,\n} from '@stencil/core';\nimport type { PaymentIntent, Stripe } from '@stripe/stripe-js';\n\nimport {\n type CartItem,\n cartStore,\n cartStoreNextStep,\n cartStorePreviousStep,\n cartStoreReset,\n cartStoreUpdateItems,\n cartStoreUpdateToErrorState,\n} from 'src/components/store/checkout/cart';\nimport {\n type ContactOption,\n initStripeElements,\n stripeStore,\n stripeStoreConfirmPayment,\n stripeStoreInitCheckoutSession,\n stripeStorePrefetchLandedCost,\n stripeStoreReset,\n} from 'src/components/store/checkout/stripe';\nimport { localizationStore } from 'src/components/store/hello/localization';\nimport { translate } from 'src/components/store/translationStore';\nimport {\n type AppearanceConfig,\n zonosStore,\n} from 'src/components/store/zonosStore';\nimport { isCheckoutMobile } from 'src/components/utils/checkout/isCheckoutMobile';\nimport { classes } from 'src/components/utils/classes';\nimport { getBorderRadius } from 'src/components/utils/getBorderRadius';\nimport { isDarkColor } from 'src/components/utils/isDarkColor';\nimport { log } from 'src/components/utils/logging/log';\nimport { mergeConfig } from 'src/components/utils/mergeConfig';\nimport { submitGtag } from 'src/components/utils/submitGtag';\nimport type { ElementsUiTheme } from 'src/types/generated/graphql.customer.types';\nimport type { Locale_PageName_Enum } from 'src/types/generated/graphql.frontend.types';\n\n/** These assets neet to be in relative path as https://www.npmjs.com/package/stencil-inline-svg suggested */\n// eslint-disable-next-line no-relative-import-paths/no-relative-import-paths\nimport LeftArrow from './assets/LeftArrow.svg';\n// eslint-disable-next-line no-relative-import-paths/no-relative-import-paths\nimport MessageIcon from './assets/MessageIcon.svg';\n// eslint-disable-next-line no-relative-import-paths/no-relative-import-paths\nimport RemoveIcon from './assets/RemoveIcon.svg';\n\n@Component({\n /**\n * Use `scope` here just because this component is `zonos-address` which is using stripe elements and stripe\n * need to be able to inject iframe into this component from the DOM\n */\n assetsDirs: ['assets'],\n scoped: true,\n styleUrl: 'zonos-checkout.scss',\n tag: 'zonos-checkout',\n})\nexport class ZonosCheckout {\n /**\n * Override appearance config\n */\n @Prop() appearanceSettingsOverride?: Partial<AppearanceConfig>;\n /**\n * Preview checkout without needing to click on the button. This would be useful for demo purpose\n */\n @Prop() preview: boolean = false;\n\n /**\n * Flag to determine if the checkout is on mobile\n */\n @Prop() mobile: boolean = false;\n\n /**\n * The button element that will open the dialog\n */\n @Prop() buttonAnchorElements: HTMLElement[] | null = null;\n\n /**\n * Default address to use for the checkout (preview mode)\n */\n @Prop() defaultAddress: ContactOption | null = null;\n\n /**\n * Force dialog to be open\n */\n @Prop() forceDialogOpen: boolean = false;\n\n /**\n * Whether or not the dialog is open\n */\n @State() open: boolean = this.forceDialogOpen;\n\n /**\n * The stripe instance\n */\n @State() stripe: Stripe | null = window.Zonos.stripe;\n\n /**\n * Whether or not the submit button is loading in `step` component\n */\n @State() submitLoading: boolean = false;\n\n /**\n * Error when submitting payment\n */\n @State() paymentError: boolean = false;\n\n @State() collapseReviewMobile: boolean = false;\n\n /**\n * Determine if we should skip and not hijack the Checkout button click event\n * Sometimes stripe or our api has error, we don't want to hijack the click event.\n */\n @State() isAttachError = false;\n\n @State() isMobile: boolean = false;\n\n @State() zonosReviewRef?: HTMLZonosReviewElement;\n\n @State() storybookPaymentStatusOverride?: PaymentIntent['status'];\n\n /**\n * Init cart info handler event\n */\n @Listen('zonos--init-cart-info', { target: 'body' })\n async initCartInfoHandler(e: CustomEvent<CartItem[]>) {\n const cartItems = e.detail;\n void cartStoreUpdateItems(cartItems);\n }\n\n /**\n * Close dialog action\n */\n @Method()\n async closeDialogHandler() {\n submitGtag('zonos-checkout-close');\n this.open = this.forceDialogOpen || false;\n\n if (!this.preview && cartStore.step === 'finish') {\n // reset cart store if it's not preview mode and only when checkout is in the finish step.\n cartStoreReset();\n }\n // reset step to customer info\n cartStore.step = 'customer-info';\n }\n\n private applyStripeTheme = async () => {\n const theme =\n this.appearanceSettingsOverride?.theme || zonosStore.appearance.theme;\n\n await initStripeElements({\n overrideBorderRaidus: this.appearanceSettingsOverride?.style,\n overridePrimaryColor: this.appearanceSettingsOverride?.colorPrimary,\n // only override theme or theme from appearance if it's mobile\n overrideTheme: this.isMobile ? theme : undefined,\n });\n };\n\n private async buildCartAndInit() {\n if (zonosStore.checkoutSettings.buildCartDetail) {\n log('build cart detail');\n const cartItems = await zonosStore.checkoutSettings.buildCartDetail();\n await cartStoreUpdateItems(cartItems);\n }\n\n // if client secret doesn't exist, request a new one.\n if (!stripeStore.clientSecret) {\n const success = await stripeStoreInitCheckoutSession();\n if (!success) {\n return false;\n }\n }\n\n // apply theme to stripe elements\n await this.applyStripeTheme();\n return true;\n }\n\n private attachCheckout() {\n if (!this.buttonAnchorElements) {\n // do nothing if button element is not found\n return;\n }\n // only attach event once, and looping through all of the button elements\n this.buttonAnchorElements.forEach(button => {\n const isEventAttached = button.getAttribute(\n 'data-zonos-checkout-attached',\n );\n if (!isEventAttached) {\n button.addEventListener('click', async e => {\n if (!localizationStore.localizationLoaded) {\n return;\n }\n // if localization is loaded and the localization is not a shippable country, keep the original click event\n if (!localizationStore.isShippableCountry) {\n log(`not shippable country`);\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n log('zonos checkout button clicked');\n this.open = true;\n\n const result = await this.buildCartAndInit();\n if (!result) {\n cartStoreUpdateToErrorState({\n messages: [\n translate(\n \"There's been an error creating your checkout session. Please reload and try again or contact support if the error persists\",\n ),\n ],\n title: translate('Error creating Checkout'),\n });\n return;\n }\n submitGtag('zonos-checkout-start');\n });\n button.setAttribute('data-zonos-checkout-attached', 'true');\n }\n });\n }\n\n @Watch('appearanceSettingsOverride')\n appearanceSettingsOverrideChanged() {\n if (!this.appearanceSettingsOverride) {\n return;\n }\n\n // apply theme to stripe elements\n void this.applyStripeTheme();\n }\n\n /**\n * Setup all of the event listeners for the component on first load\n */\n @Method()\n public async init() {\n stripeStore.stripe = window.Zonos.stripe;\n this.stripe = window.Zonos.stripe;\n\n // only init checkout if visitor's country is in the shipping zones.\n const interval = setInterval(() => {\n stripeStore.stripe = window.Zonos.stripe;\n this.stripe = window.Zonos.stripe;\n\n if (!localizationStore.localizationLoaded) {\n return;\n }\n // if localization is loaded and the localization is not a shippable country, stop the interval and don't init checkout\n // No need to check localization if it's preview mode\n if (!localizationStore.isShippableCountry && !this.preview) {\n log('not shippable country');\n clearInterval(interval);\n return;\n }\n\n if (!this.stripe) {\n log('waiting for stripe to be loaded');\n return;\n }\n\n log('init checkout');\n if (this.preview || this.forceDialogOpen) {\n void this.buildCartAndInit();\n } else {\n this.attachCheckout();\n }\n clearInterval(interval);\n }, 100);\n\n setTimeout(() => {\n // if localization is not loaded after 10 seconds, stop the interval and don't init checkout\n clearInterval(interval);\n }, 10_000);\n }\n\n /**\n * For storybook to set to finish step, this is to trigger in the story for zonos-checkout-finish\n */\n @Method()\n public async setToFinishStep(forcePaymentStatus?: PaymentIntent['status']) {\n cartStore.step = 'finish';\n this.storybookPaymentStatusOverride = forcePaymentStatus;\n }\n\n private async handleCustomerInfoContinue() {\n this.submitLoading = true;\n\n // fetch landed cost data if we not fetching.\n await stripeStorePrefetchLandedCost();\n\n // keep checking landed cost data until it's ready to move to next screen\n const interval = setInterval(() => {\n if (cartStore.landedCostData || !stripeStore.isFetchingLandedCost) {\n if (cartStore.landedCostData) {\n // only go to next step if landed cost data is ready\n cartStoreNextStep();\n }\n this.submitLoading = false;\n clearInterval(interval);\n }\n }, 500);\n }\n\n private async handleShippingContinue() {\n this.submitLoading = true;\n // show loading for the button for a bit\n setTimeout(() => {\n cartStoreNextStep();\n this.submitLoading = false;\n }, 500);\n }\n\n private async handleCheckoutPaymentContinue() {\n // reset error state\n this.paymentError = false;\n this.submitLoading = true;\n try {\n await stripeStoreConfirmPayment();\n cartStoreNextStep();\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(err);\n this.paymentError = true;\n }\n this.submitLoading = false;\n }\n\n private async handleFinishClick() {\n // reset stripe store\n stripeStoreReset();\n\n if (this.preview) {\n cartStore.step = 'customer-info';\n await this.init();\n return;\n }\n // reset cart store\n cartStoreReset();\n\n // reset url\n const url = window.location.href;\n\n // Remove query parameters\n const cleanUrl = url.split('?')[0];\n\n // Update the URL without query parameters\n window.history.replaceState({}, document.title, cleanUrl);\n this.open = false;\n }\n\n private async handleBackClick() {\n // close the modal if back button is clicked on customer info step\n if (cartStore.step === 'customer-info') {\n await this.closeDialogHandler();\n return;\n }\n cartStorePreviousStep();\n }\n\n private getCurrentLocalePageEnum = (): Locale_PageName_Enum | null => {\n switch (cartStore.step) {\n case 'customer-info':\n return 'checkout_customer_info';\n case 'shipping':\n return 'checkout_shipping_info';\n case 'payment':\n return 'checkout_payment_info';\n\n default:\n return null;\n }\n };\n\n @Listen('resize', { target: 'window' })\n handleWindowResize() {\n this.isMobile = isCheckoutMobile(this.mobile);\n // apply theme to stripe elements\n void this.applyStripeTheme();\n log(`mobile: ${this.isMobile}`);\n }\n\n @Watch('mobile')\n handleMobileChange() {\n this.isMobile = isCheckoutMobile(this.mobile);\n // apply theme to stripe elements\n void this.applyStripeTheme();\n log(`mobile: ${this.isMobile}`);\n }\n\n componentWillLoad() {\n void this.init();\n this.isMobile = isCheckoutMobile(this.mobile);\n log(`mobile: ${this.isMobile}`);\n }\n\n // do clean up when component is unmounted\n disconnectedCallback() {\n // reset stripe store\n stripeStoreReset();\n // reset cart store\n cartStoreReset();\n }\n\n render() {\n const dialogLoading =\n // if it's last step, don't need to check stripe elements\n (cartStore.step !== 'finish' && !stripeStore.stripeElements) ||\n stripeStore.isFetchingSession;\n\n const { colorPrimary, colorSecondary, logoUrl, style } = mergeConfig(\n zonosStore.appearance,\n this.appearanceSettingsOverride,\n );\n\n const hasFooter = zonosStore.appearance.zonosAttribution === 'ENABLED';\n\n const rightSideTheme = zonosStore.appearance.theme;\n\n const themePrimaryColorBased: ElementsUiTheme =\n colorPrimary && isDarkColor(colorPrimary) ? 'DARK' : 'LIGHT';\n\n // use right side theme if it's mobile, otherwise use themePrimaryColorBased\n const leftSideTheme: ElementsUiTheme = this.isMobile\n ? rightSideTheme\n : themePrimaryColorBased;\n\n // only use submit button color if it's on desktop\n const submitButtonColor = !this.isMobile ? colorSecondary : undefined;\n\n const { customMessages } = localizationStore;\n const defaultMessage =\n customMessages.find(x => x.pageName === 'checkout_default')?.message ||\n 'Know about duties and taxes before you buy. Shop with confidence!';\n\n const localePageEnum = this.getCurrentLocalePageEnum();\n const filteredMessages = customMessages.filter(\n x => x.pageName === localePageEnum,\n );\n\n const renderLogo = () => (\n <div class=\"zonos--logo\">\n {logoUrl && (\n <img\n alt={`${zonosStore.organizationName} logo`}\n src={logoUrl}\n width={100}\n />\n )}\n </div>\n );\n\n const renderTopHeader = () => (\n <zonos-v-stack>\n {renderLogo()}\n\n {filteredMessages.map(x => (\n <zonos-custom-message\n icon={MessageIcon}\n message={x.message}\n ></zonos-custom-message>\n ))}\n\n <div>\n <zonos-button\n class=\"zonos--back-button\"\n icon={<zonos-icon content={LeftArrow}></zonos-icon>}\n noBackground\n noPaddingLeft\n noPaddingRight\n onClick={() => this.handleBackClick()}\n theme={leftSideTheme}\n >\n {translate('Back')}\n </zonos-button>\n </div>\n </zonos-v-stack>\n );\n\n const renderFooter = () =>\n hasFooter && (\n <div class=\"zonos--footer\" data-theme={rightSideTheme}>\n <zonos-text type=\"hintText\">{translate('Powered by')}</zonos-text>\n <zonos-logo theme={rightSideTheme} width=\"100px\"></zonos-logo>\n </div>\n );\n\n const renderContent = () => {\n const submitBtnType = this.isMobile ? 'primary' : undefined;\n const reviewElementSize = this.zonosReviewRef?.scrollHeight;\n return (\n <div\n class={'zonos--content'}\n style={{\n '--border-radius': getBorderRadius(style),\n }}\n >\n {cartStore.step !== 'finish' && (\n <>\n <div\n class=\"zonos--left\"\n data-theme={leftSideTheme}\n style={{\n '--primary-color': !this.isMobile ? colorPrimary : '',\n }}\n >\n {!this.isMobile && renderTopHeader()}\n {cartStore.step === 'customer-info' && (\n <zonos-customer-info\n continueLoading={this.submitLoading}\n defaultAddress={this.defaultAddress}\n onContinueClicked={() => this.handleCustomerInfoContinue()}\n submitBtnColor={submitButtonColor}\n submitBtnType={submitBtnType}\n ></zonos-customer-info>\n )}\n {cartStore.step === 'shipping' && (\n <zonos-shipping\n continueLoading={this.submitLoading}\n onContinueClicked={() => this.handleShippingContinue()}\n submitBtnColor={submitButtonColor}\n submitBtnType={submitBtnType}\n ></zonos-shipping>\n )}\n {cartStore.step === 'payment' && (\n <zonos-checkout-payment\n continueLoading={this.submitLoading}\n onContinueClicked={() =>\n this.handleCheckoutPaymentContinue()\n }\n paymentError={this.paymentError}\n submitBtnColor={submitButtonColor}\n submitBtnType={submitBtnType}\n ></zonos-checkout-payment>\n )}\n </div>\n <div class=\"zonos--right\" data-theme={rightSideTheme}>\n {this.isMobile && renderTopHeader()}\n {!this.isMobile && (\n <zonos-button\n class=\"zonos--close-button\"\n icon={<zonos-icon content={RemoveIcon}></zonos-icon>}\n noBackground\n onClick={() => this.closeDialogHandler()}\n ></zonos-button>\n )}\n <div class=\"flex--wrapper\">\n <div class=\"zonos--wrapper\">\n <zonos-collapse\n collapseSize={reviewElementSize}\n collapsed={this.collapseReviewMobile}\n >\n <zonos-review\n collapsed={this.collapseReviewMobile}\n mobile={this.isMobile}\n onClick={() => {\n this.collapseReviewMobile =\n !this.collapseReviewMobile;\n }}\n ref={el => (this.zonosReviewRef = el)}\n ></zonos-review>\n {/* Cart item rows */}\n <zonos-cart-items></zonos-cart-items>\n </zonos-collapse>\n </div>\n\n <zonos-v-stack spacing={16}>\n {/* Cart subtotal row */}\n <zonos-cart-subtotal></zonos-cart-subtotal>\n\n <zonos-custom-message\n class=\"zonos--checkout-default-message\"\n icon={MessageIcon}\n message={defaultMessage}\n ></zonos-custom-message>\n </zonos-v-stack>\n </div>\n\n {/* Only show footer on desktop */}\n {!this.isMobile && renderFooter()}\n </div>\n {/* Only show footer on mobile */}\n {this.isMobile && renderFooter()}\n </>\n )}\n\n {(cartStore.step === 'finish' || cartStore.step === 'error') && (\n <div class=\"zonos--done\" data-theme={rightSideTheme}>\n <div class=\"zonos--header\">\n {renderLogo()}\n <zonos-button\n class=\"zonos--close-button\"\n icon={<zonos-icon content={RemoveIcon}></zonos-icon>}\n noBackground\n onClick={() => this.handleFinishClick()}\n theme={rightSideTheme}\n ></zonos-button>\n </div>\n <zonos-checkout-finish\n borderRadius={style}\n onCloseClick={() => this.handleFinishClick()}\n overrideNotification={\n cartStore.step === 'error' && !!cartStore.error\n ? {\n ...cartStore.error,\n type: 'error',\n }\n : undefined\n }\n storybookForceStatus={this.storybookPaymentStatusOverride}\n ></zonos-checkout-finish>\n </div>\n )}\n </div>\n );\n };\n\n return (\n <Host\n class={classes([\n 'zonos--checkout zonos--elements',\n hasFooter && 'has-footer',\n this.preview && 'preview',\n this.isMobile && 'mobile',\n ])}\n >\n {this.preview ? (\n renderContent()\n ) : (\n <zonos-dialog\n borderStyle={style}\n data-theme={rightSideTheme}\n height=\"980px\"\n isLoading={dialogLoading}\n mobile={this.isMobile}\n noBodyPadding\n noBorder\n noClickOutside\n noCloseButton\n onCloseDialog={() => this.closeDialogHandler()}\n open={this.open}\n width=\"1200px\"\n >\n {renderContent()}\n </zonos-dialog>\n )}\n </Host>\n );\n }\n}\n"],"version":3}
1
+ {"file":"zonos-checkout.entry.js","mappings":";;;;;;;;;;;;;;;;;;AAAA,MAAM,gBAAgB,GAAG,+hNAA+hN;;MCiE3iN,aAAa;;;IAyFhB,qBAAgB,GAAG;;MACzB,MAAM,KAAK,GACT,CAAA,MAAA,IAAI,CAAC,0BAA0B,0CAAE,KAAK,KAAI,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC;MAExE,MAAM,kBAAkB,CAAC;QACvB,oBAAoB,EAAE,MAAA,IAAI,CAAC,0BAA0B,0CAAE,KAAK;QAC5D,oBAAoB,EAAE,MAAA,IAAI,CAAC,0BAA0B,0CAAE,YAAY;;QAEnE,aAAa,EAAE,IAAI,CAAC,QAAQ,GAAG,KAAK,GAAG,SAAS;OACjD,CAAC,CAAC;KACJ,CAAC;IAiNM,6BAAwB,GAAG;MACjC,QAAQ,SAAS,CAAC,IAAI;QACpB,KAAK,eAAe;UAClB,OAAO,wBAAwB,CAAC;QAClC,KAAK,UAAU;UACb,OAAO,wBAAwB,CAAC;QAClC,KAAK,SAAS;UACZ,OAAO,uBAAuB,CAAC;QAEjC;UACE,OAAO,IAAI,CAAC;OACf;KACF,CAAC;;mBAxTyB,KAAK;kBAKN,KAAK;gCAKsB,IAAI;0BAKV,IAAI;2BAKhB,KAAK;gBAKf,IAAI,CAAC,eAAe;kBAKZ,MAAM,CAAC,KAAK,CAAC,MAAM;yBAKlB,KAAK;wBAKN,KAAK;gCAEG,KAAK;yBAMrB,KAAK;oBAED,KAAK;;;;;;;EAUlC,MAAM,mBAAmB,CAAC,CAA0B;IAClD,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,KAAK,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KAAK,EACnB,YAAY,EAAE,MAAM,IAAI,CAAC,iBAAiB,EAAE,EAC5C,oBAAoB,EAClB,SAAS,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,CAAC,SAAS,CAAC,KAAK;4CAEtC,SAAS,CAAC,KAAK,KAClB,IAAI,EAAE,OAAO,MAEf,SAAS,EAEf,oBAAoB,EAAE,IAAI,CAAC,8BAA8B,GAClC,CACrB,CACP,CACG,EACN;KACH,CAAC;IAEF,QACE,EAAC,IAAI,IACH,KAAK,EAAE,OAAO,CAAC;QACb,iCAAiC;QACjC,SAAS,IAAI,YAAY;QACzB,IAAI,CAAC,OAAO,IAAI,SAAS;QACzB,IAAI,CAAC,QAAQ,IAAI,QAAQ;OAC1B,CAAC,IAED,IAAI,CAAC,OAAO,IACX,aAAa,EAAE,KAEf,oBACE,WAAW,EAAE,KAAK,gBACN,cAAc,EAC1B,MAAM,EAAC,OAAO,EACd,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,IAAI,CAAC,QAAQ,EACrB,aAAa,QACb,QAAQ,QACR,cAAc,QACd,aAAa,QACb,aAAa,EAAE,MAAM,IAAI,CAAC,kBAAkB,EAAE,EAC9C,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAC,QAAQ,IAEb,aAAa,EAAE,CACH,CAChB,CACI,EACP;GACH;;;;;;;;;;;","names":[],"sources":["src/components/checkout/zonos-checkout/zonos-checkout.scss?tag=zonos-checkout&encapsulation=scoped","src/components/checkout/zonos-checkout/zonos-checkout.tsx"],"sourcesContent":["$primary-color: var(--primary-color, $amino-gray-0);\n$border-radius: var(--border-radius, $amino-radius-10);\n\n:host {\n * {\n @include zonos--scrollbar;\n }\n .zonos--content {\n display: flex;\n height: 100%;\n overflow: hidden;\n border-radius: $border-radius;\n .zonos--left,\n .zonos--right {\n flex: 1;\n padding: $amino-space-48 $amino-space-56;\n }\n .zonos--left {\n background-color: $primary-color;\n border-right: 1px solid $amino-gray-200;\n }\n .zonos--right {\n background-color: $amino-gray-0;\n padding-bottom: $amino-space-80;\n }\n\n .zonos--done {\n width: 100%;\n max-height: 100%;\n height: 100%;\n overflow: auto;\n flex-direction: column;\n background-color: $amino-gray-0;\n align-items: center;\n justify-content: center;\n padding: $amino-space-24;\n padding-bottom: 50px;\n .zonos--header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n img {\n width: 150px;\n min-width: 150px;\n }\n }\n .zonos--logo {\n margin-bottom: 0;\n }\n\n zonos-checkout-finish {\n flex: 1;\n }\n }\n }\n\n .zonos--left {\n display: flex;\n flex-direction: column;\n .zonos--back-button {\n margin-bottom: $amino-space-24;\n }\n .zonos--wrapper {\n padding: 0 $amino-space-8 $amino-space-8;\n }\n .zonos--payment-error-banner {\n margin-top: $amino-space-24;\n }\n }\n\n .zonos--right {\n position: relative;\n .zonos--close-button {\n position: absolute;\n right: $amino-space-32;\n top: $amino-space-32;\n }\n }\n .zonos--footer {\n display: flex;\n justify-content: flex-end;\n align-items: center;\n position: absolute;\n bottom: $amino-space-32;\n right: $amino-space-56;\n gap: $amino-space-8;\n }\n\n .zonos--wrapper {\n overflow: auto;\n max-height: 100%;\n position: relative;\n }\n\n .flex--wrapper {\n display: flex;\n flex-direction: column;\n max-height: 100%;\n }\n\n .zonos--logo {\n display: flex;\n align-items: center;\n }\n\n .zonos--checkout-default-message {\n margin-left: $amino-space-76;\n margin-bottom: $amino-space-8;\n }\n}\n\n:host(.preview) {\n min-width: 500px;\n margin: auto;\n .zonos--content {\n border: $amino-border;\n .zonos--done {\n padding: $amino-space-32;\n }\n }\n}\n\n:host(.mobile) {\n @include checkout-mobile;\n}\n","import {\n Component,\n Fragment,\n h,\n Host,\n Listen,\n Method,\n Prop,\n State,\n Watch,\n} from '@stencil/core';\nimport type { PaymentIntent, Stripe } from '@stripe/stripe-js';\n\nimport {\n type CartItem,\n cartStore,\n cartStoreNextStep,\n cartStorePreviousStep,\n cartStoreReset,\n cartStoreUpdateItems,\n cartStoreUpdateToErrorState,\n} from 'src/components/store/checkout/cart';\nimport {\n type ContactOption,\n initStripeElements,\n stripeStore,\n stripeStoreConfirmPayment,\n stripeStoreInitCheckoutSession,\n stripeStorePrefetchLandedCost,\n stripeStoreReset,\n} from 'src/components/store/checkout/stripe';\nimport { localizationStore } from 'src/components/store/hello/localization';\nimport { translate } from 'src/components/store/translationStore';\nimport {\n type AppearanceConfig,\n zonosStore,\n} from 'src/components/store/zonosStore';\nimport { isCheckoutMobile } from 'src/components/utils/checkout/isCheckoutMobile';\nimport { classes } from 'src/components/utils/classes';\nimport { getBorderRadius } from 'src/components/utils/getBorderRadius';\nimport { isDarkColor } from 'src/components/utils/isDarkColor';\nimport { log } from 'src/components/utils/logging/log';\nimport { mergeConfig } from 'src/components/utils/mergeConfig';\nimport { submitGtag } from 'src/components/utils/submitGtag';\nimport type { ElementsUiTheme } from 'src/types/generated/graphql.customer.types';\nimport type { Locale_PageName_Enum } from 'src/types/generated/graphql.frontend.types';\n\n/** These assets neet to be in relative path as https://www.npmjs.com/package/stencil-inline-svg suggested */\n// eslint-disable-next-line no-relative-import-paths/no-relative-import-paths\nimport LeftArrow from './assets/LeftArrow.svg';\n// eslint-disable-next-line no-relative-import-paths/no-relative-import-paths\nimport MessageIcon from './assets/MessageIcon.svg';\n// eslint-disable-next-line no-relative-import-paths/no-relative-import-paths\nimport RemoveIcon from './assets/RemoveIcon.svg';\n\n@Component({\n /**\n * Use `scope` here just because this component is `zonos-address` which is using stripe elements and stripe\n * need to be able to inject iframe into this component from the DOM\n */\n assetsDirs: ['assets'],\n scoped: true,\n styleUrl: 'zonos-checkout.scss',\n tag: 'zonos-checkout',\n})\nexport class ZonosCheckout {\n /**\n * Override appearance config\n */\n @Prop() appearanceSettingsOverride?: Partial<AppearanceConfig>;\n /**\n * Preview checkout without needing to click on the button. This would be useful for demo purpose\n */\n @Prop() preview: boolean = false;\n\n /**\n * Flag to determine if the checkout is on mobile\n */\n @Prop() mobile: boolean = false;\n\n /**\n * The button element that will open the dialog\n */\n @Prop() buttonAnchorElements: HTMLElement[] | null = null;\n\n /**\n * Default address to use for the checkout (preview mode)\n */\n @Prop() defaultAddress: ContactOption | null = null;\n\n /**\n * Force dialog to be open\n */\n @Prop() forceDialogOpen: boolean = false;\n\n /**\n * Whether or not the dialog is open\n */\n @State() open: boolean = this.forceDialogOpen;\n\n /**\n * The stripe instance\n */\n @State() stripe: Stripe | null = window.Zonos.stripe;\n\n /**\n * Whether or not the submit button is loading in `step` component\n */\n @State() submitLoading: boolean = false;\n\n /**\n * Error when submitting payment\n */\n @State() paymentError: boolean = false;\n\n @State() collapseReviewMobile: boolean = false;\n\n /**\n * Determine if we should skip and not hijack the Checkout button click event\n * Sometimes stripe or our api has error, we don't want to hijack the click event.\n */\n @State() isAttachError = false;\n\n @State() isMobile: boolean = false;\n\n @State() zonosReviewRef?: HTMLZonosReviewElement;\n\n @State() storybookPaymentStatusOverride?: PaymentIntent['status'];\n\n /**\n * Init cart info handler event\n */\n @Listen('zonos--init-cart-info', { target: 'body' })\n async initCartInfoHandler(e: CustomEvent<CartItem[]>) {\n const cartItems = e.detail;\n void cartStoreUpdateItems(cartItems);\n }\n\n /**\n * Close dialog action\n */\n @Method()\n async closeDialogHandler() {\n submitGtag('zonos-checkout-close');\n this.open = this.forceDialogOpen || false;\n\n if (!this.preview && cartStore.step === 'finish') {\n // reset cart store if it's not preview mode and only when checkout is in the finish step.\n cartStoreReset();\n }\n // reset step to customer info\n cartStore.step = 'customer-info';\n }\n\n private applyStripeTheme = async () => {\n const theme =\n this.appearanceSettingsOverride?.theme || zonosStore.appearance.theme;\n\n await initStripeElements({\n overrideBorderRaidus: this.appearanceSettingsOverride?.style,\n overridePrimaryColor: this.appearanceSettingsOverride?.colorPrimary,\n // only override theme or theme from appearance if it's mobile\n overrideTheme: this.isMobile ? theme : undefined,\n });\n };\n\n private async buildCartAndInit() {\n if (zonosStore.checkoutSettings.buildCartDetail) {\n log('build cart detail');\n const cartItems = await zonosStore.checkoutSettings.buildCartDetail();\n await cartStoreUpdateItems(cartItems);\n }\n\n // if client secret doesn't exist, request a new one.\n if (!stripeStore.clientSecret) {\n const success = await stripeStoreInitCheckoutSession();\n if (!success) {\n return false;\n }\n }\n\n // apply theme to stripe elements\n await this.applyStripeTheme();\n return true;\n }\n\n private attachCheckout() {\n if (!this.buttonAnchorElements) {\n // do nothing if button element is not found\n return;\n }\n // only attach event once, and looping through all of the button elements\n this.buttonAnchorElements.forEach(button => {\n const isEventAttached = button.getAttribute(\n 'data-zonos-checkout-attached',\n );\n if (!isEventAttached) {\n button.addEventListener('click', async e => {\n if (!localizationStore.localizationLoaded) {\n return;\n }\n // if localization is loaded and the localization is not a shippable country, keep the original click event\n if (!localizationStore.isShippableCountry) {\n log(`not shippable country`);\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n log('zonos checkout button clicked');\n this.open = true;\n\n const result = await this.buildCartAndInit();\n if (!result) {\n cartStoreUpdateToErrorState({\n messages: [\n translate(\n \"There's been an error creating your checkout session. Please reload and try again or contact support if the error persists\",\n ),\n ],\n title: translate('Error creating Checkout'),\n });\n return;\n }\n submitGtag('zonos-checkout-start');\n });\n button.setAttribute('data-zonos-checkout-attached', 'true');\n }\n });\n }\n\n @Watch('appearanceSettingsOverride')\n appearanceSettingsOverrideChanged() {\n if (!this.appearanceSettingsOverride) {\n return;\n }\n\n // apply theme to stripe elements\n void this.applyStripeTheme();\n }\n\n /**\n * Setup all of the event listeners for the component on first load\n */\n @Method()\n public async init() {\n stripeStore.stripe = window.Zonos.stripe;\n this.stripe = window.Zonos.stripe;\n\n // only init checkout if visitor's country is in the shipping zones.\n const interval = setInterval(() => {\n stripeStore.stripe = window.Zonos.stripe;\n this.stripe = window.Zonos.stripe;\n\n if (!localizationStore.localizationLoaded) {\n return;\n }\n // if localization is loaded and the localization is not a shippable country, stop the interval and don't init checkout\n // No need to check localization if it's preview mode\n if (!localizationStore.isShippableCountry && !this.preview) {\n log('not shippable country');\n clearInterval(interval);\n return;\n }\n\n if (!this.stripe) {\n log('waiting for stripe to be loaded');\n return;\n }\n\n if (this.storybookPaymentStatusOverride) {\n clearInterval(interval);\n return;\n }\n\n log('init checkout');\n if (this.preview || this.forceDialogOpen) {\n void this.buildCartAndInit();\n } else {\n this.attachCheckout();\n }\n clearInterval(interval);\n }, 100);\n\n setTimeout(() => {\n // if localization is not loaded after 10 seconds, stop the interval and don't init checkout\n clearInterval(interval);\n }, 10_000);\n }\n\n /**\n * For storybook to set to finish step, this is to trigger in the story for zonos-checkout-finish\n */\n @Method()\n public async setToFinishStep(forcePaymentStatus?: PaymentIntent['status']) {\n cartStore.step = 'finish';\n this.storybookPaymentStatusOverride = forcePaymentStatus;\n }\n\n private async handleCustomerInfoContinue() {\n this.submitLoading = true;\n\n // fetch landed cost data if we not fetching.\n await stripeStorePrefetchLandedCost();\n\n // keep checking landed cost data until it's ready to move to next screen\n const interval = setInterval(() => {\n if (cartStore.landedCostData || !stripeStore.isFetchingLandedCost) {\n if (cartStore.landedCostData) {\n // only go to next step if landed cost data is ready\n cartStoreNextStep();\n }\n this.submitLoading = false;\n clearInterval(interval);\n }\n }, 500);\n }\n\n private async handleShippingContinue() {\n this.submitLoading = true;\n // show loading for the button for a bit\n setTimeout(() => {\n cartStoreNextStep();\n this.submitLoading = false;\n }, 500);\n }\n\n private async handleCheckoutPaymentContinue() {\n // reset error state\n this.paymentError = false;\n this.submitLoading = true;\n try {\n await stripeStoreConfirmPayment();\n cartStoreNextStep();\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(err);\n this.paymentError = true;\n }\n this.submitLoading = false;\n }\n\n private async handleFinishClick() {\n // reset stripe store\n stripeStoreReset();\n\n if (this.preview) {\n cartStore.step = 'customer-info';\n await this.init();\n return;\n }\n // reset cart store\n cartStoreReset();\n\n // reset url\n const url = window.location.href;\n\n // Remove query parameters\n const cleanUrl = url.split('?')[0];\n\n // Update the URL without query parameters\n window.history.replaceState({}, document.title, cleanUrl);\n this.open = false;\n }\n\n private async handleBackClick() {\n // close the modal if back button is clicked on customer info step\n if (cartStore.step === 'customer-info') {\n await this.closeDialogHandler();\n return;\n }\n cartStorePreviousStep();\n }\n\n private getCurrentLocalePageEnum = (): Locale_PageName_Enum | null => {\n switch (cartStore.step) {\n case 'customer-info':\n return 'checkout_customer_info';\n case 'shipping':\n return 'checkout_shipping_info';\n case 'payment':\n return 'checkout_payment_info';\n\n default:\n return null;\n }\n };\n\n @Listen('resize', { target: 'window' })\n handleWindowResize() {\n this.isMobile = isCheckoutMobile(this.mobile);\n // apply theme to stripe elements\n void this.applyStripeTheme();\n log(`mobile: ${this.isMobile}`);\n }\n\n @Watch('mobile')\n handleMobileChange() {\n this.isMobile = isCheckoutMobile(this.mobile);\n // apply theme to stripe elements\n void this.applyStripeTheme();\n log(`mobile: ${this.isMobile}`);\n }\n\n componentWillLoad() {\n void this.init();\n this.isMobile = isCheckoutMobile(this.mobile);\n log(`mobile: ${this.isMobile}`);\n }\n\n // do clean up when component is unmounted\n disconnectedCallback() {\n // reset stripe store\n stripeStoreReset();\n // reset cart store\n cartStoreReset();\n }\n\n render() {\n const dialogLoading =\n // if it's last step, don't need to check stripe elements\n (cartStore.step !== 'finish' && !stripeStore.stripeElements) ||\n stripeStore.isFetchingSession;\n\n const { colorPrimary, colorSecondary, logoUrl, style } = mergeConfig(\n zonosStore.appearance,\n this.appearanceSettingsOverride,\n );\n\n const hasFooter = zonosStore.appearance.zonosAttribution === 'ENABLED';\n\n const rightSideTheme = zonosStore.appearance.theme;\n\n const themePrimaryColorBased: ElementsUiTheme =\n colorPrimary && isDarkColor(colorPrimary) ? 'DARK' : 'LIGHT';\n\n // use right side theme if it's mobile, otherwise use themePrimaryColorBased\n const leftSideTheme: ElementsUiTheme = this.isMobile\n ? rightSideTheme\n : themePrimaryColorBased;\n\n // only use submit button color if it's on desktop\n const submitButtonColor = !this.isMobile ? colorSecondary : undefined;\n\n const { customMessages } = localizationStore;\n const defaultMessage =\n customMessages.find(x => x.pageName === 'checkout_default')?.message ||\n 'Know about duties and taxes before you buy. Shop with confidence!';\n\n const localePageEnum = this.getCurrentLocalePageEnum();\n const filteredMessages = customMessages.filter(\n x => x.pageName === localePageEnum,\n );\n\n const renderLogo = () => (\n <div class=\"zonos--logo\">\n {logoUrl && (\n <img\n alt={`${zonosStore.organizationName} logo`}\n src={logoUrl}\n width={100}\n />\n )}\n </div>\n );\n\n const renderTopHeader = () => (\n <zonos-v-stack>\n {renderLogo()}\n\n {filteredMessages.map(x => (\n <zonos-custom-message\n icon={MessageIcon}\n message={x.message}\n ></zonos-custom-message>\n ))}\n\n <div>\n <zonos-button\n class=\"zonos--back-button\"\n icon={<zonos-icon content={LeftArrow}></zonos-icon>}\n noBackground\n noPaddingLeft\n noPaddingRight\n onClick={() => this.handleBackClick()}\n theme={leftSideTheme}\n >\n {translate('Back')}\n </zonos-button>\n </div>\n </zonos-v-stack>\n );\n\n const renderFooter = () =>\n hasFooter && (\n <div class=\"zonos--footer\" data-theme={rightSideTheme}>\n <zonos-text type=\"hintText\">{translate('Powered by')}</zonos-text>\n <zonos-logo theme={rightSideTheme} width=\"100px\"></zonos-logo>\n </div>\n );\n\n const renderContent = () => {\n const submitBtnType = this.isMobile ? 'primary' : undefined;\n const reviewElementSize = this.zonosReviewRef?.scrollHeight;\n return (\n <div\n class={'zonos--content'}\n style={{\n '--border-radius': getBorderRadius(style),\n }}\n >\n {cartStore.step !== 'finish' && cartStore.step !== 'error' && (\n <>\n <div\n class=\"zonos--left\"\n data-theme={leftSideTheme}\n style={{\n '--primary-color': !this.isMobile ? colorPrimary : '',\n }}\n >\n {!this.isMobile && renderTopHeader()}\n {cartStore.step === 'customer-info' && (\n <zonos-customer-info\n continueLoading={this.submitLoading}\n defaultAddress={this.defaultAddress}\n onContinueClicked={() => this.handleCustomerInfoContinue()}\n submitBtnColor={submitButtonColor}\n submitBtnType={submitBtnType}\n ></zonos-customer-info>\n )}\n {cartStore.step === 'shipping' && (\n <zonos-shipping\n continueLoading={this.submitLoading}\n onContinueClicked={() => this.handleShippingContinue()}\n submitBtnColor={submitButtonColor}\n submitBtnType={submitBtnType}\n ></zonos-shipping>\n )}\n {cartStore.step === 'payment' && (\n <zonos-checkout-payment\n continueLoading={this.submitLoading}\n onContinueClicked={() =>\n this.handleCheckoutPaymentContinue()\n }\n paymentError={this.paymentError}\n submitBtnColor={submitButtonColor}\n submitBtnType={submitBtnType}\n ></zonos-checkout-payment>\n )}\n </div>\n <div class=\"zonos--right\" data-theme={rightSideTheme}>\n {this.isMobile && renderTopHeader()}\n {!this.isMobile && (\n <zonos-button\n class=\"zonos--close-button\"\n icon={<zonos-icon content={RemoveIcon}></zonos-icon>}\n noBackground\n onClick={() => this.closeDialogHandler()}\n ></zonos-button>\n )}\n <div class=\"flex--wrapper\">\n <div class=\"zonos--wrapper\">\n <zonos-collapse\n collapseSize={reviewElementSize}\n collapsed={this.collapseReviewMobile}\n >\n <zonos-review\n collapsed={this.collapseReviewMobile}\n mobile={this.isMobile}\n onClick={() => {\n this.collapseReviewMobile =\n !this.collapseReviewMobile;\n }}\n ref={el => (this.zonosReviewRef = el)}\n ></zonos-review>\n {/* Cart item rows */}\n <zonos-cart-items></zonos-cart-items>\n </zonos-collapse>\n </div>\n\n <zonos-v-stack spacing={16}>\n {/* Cart subtotal row */}\n <zonos-cart-subtotal></zonos-cart-subtotal>\n\n <zonos-custom-message\n class=\"zonos--checkout-default-message\"\n icon={MessageIcon}\n message={defaultMessage}\n ></zonos-custom-message>\n </zonos-v-stack>\n </div>\n\n {/* Only show footer on desktop */}\n {!this.isMobile && renderFooter()}\n </div>\n {/* Only show footer on mobile */}\n {this.isMobile && renderFooter()}\n </>\n )}\n\n {(cartStore.step === 'finish' || cartStore.step === 'error') && (\n <div class=\"zonos--done\" data-theme={rightSideTheme}>\n <div class=\"zonos--header\">\n {renderLogo()}\n <zonos-button\n class=\"zonos--close-button\"\n icon={<zonos-icon content={RemoveIcon}></zonos-icon>}\n noBackground\n onClick={() => this.handleFinishClick()}\n theme={rightSideTheme}\n ></zonos-button>\n </div>\n <zonos-checkout-finish\n borderRadius={style}\n onCloseClick={() => this.handleFinishClick()}\n overrideNotification={\n cartStore.step === 'error' && !!cartStore.error\n ? {\n ...cartStore.error,\n type: 'error',\n }\n : undefined\n }\n storybookForceStatus={this.storybookPaymentStatusOverride}\n ></zonos-checkout-finish>\n </div>\n )}\n </div>\n );\n };\n\n return (\n <Host\n class={classes([\n 'zonos--checkout zonos--elements',\n hasFooter && 'has-footer',\n this.preview && 'preview',\n this.isMobile && 'mobile',\n ])}\n >\n {this.preview ? (\n renderContent()\n ) : (\n <zonos-dialog\n borderStyle={style}\n data-theme={rightSideTheme}\n height=\"980px\"\n isLoading={dialogLoading}\n mobile={this.isMobile}\n noBodyPadding\n noBorder\n noClickOutside\n noCloseButton\n onCloseDialog={() => this.closeDialogHandler()}\n open={this.open}\n width=\"1200px\"\n >\n {renderContent()}\n </zonos-dialog>\n )}\n </Host>\n );\n }\n}\n"],"version":3}
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host } from './index-d1aa9293.js';
2
- import { s as stripeStore } from './cart-36c33342.js';
2
+ import { s as stripeStore } from './cart-2f83e048.js';
3
3
  import { h as handleFetch, b as logError, i as isValidSelector, l as log, c as initLocalizationStore, d as localizationStoreUpdateSelectedCountryCode } from './localization-4a424f49.js';
4
4
  import { z as zonosStore, d as zonosStoreInitSetting } from './zonosStore-13a7b534.js';
5
5
  import './isDarkColor-b21326ae.js';
@@ -0,0 +1,2 @@
1
+ var __awaiter=this&&this.__awaiter||function(e,t,r,o){function n(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function a(e){try{c(o.next(e))}catch(e){i(e)}}function s(e){try{c(o["throw"](e))}catch(e){i(e)}}function c(e){e.done?r(e.value):n(e.value).then(a,s)}c((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(t){return c([e,t])}}function c(s){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(r=0)),r)try{if(o=1,n&&(i=s[0]&2?n["return"]:s[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;if(n=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:r.label++;return{value:s[1],done:false};case 5:r.label++;n=s[1];s=[0];continue;case 7:s=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){r=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){r.label=s[1];break}if(s[0]===6&&r.label<i[1]){r.label=i[1];i=s;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(s);break}if(i[2])r.ops.pop();r.trys.pop();continue}s=t.call(e,r)}catch(e){s=[6,e];n=0}finally{o=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{c as createStore,z as zonosStore}from"./zonosStore-13a7b534.js";import{h as handleFetch,l as log,a as localizationStore,b as logError,t as translate}from"./localization-4a424f49.js";import{i as isDarkColor}from"./isDarkColor-b21326ae.js";import{g as getBorderRadius}from"./getBorderRadius-82fbaf25.js";var prepCalculateLandedCost=function(){var e=stripeStore.stripeLinkEventData;var t=stripeStore.stripeAddressEventData;if(!t||!t.complete){throw new Error("Missing stripe address data")}return{checkoutSessionId:cartStore.checkoutSessionId||"",contact:{email:(e===null||e===void 0?void 0:e.value.email)||"",firstName:t.value.firstName||"",lastName:t.value.lastName||"",phone:t.value.phone||""},items:cartStore.items.map((function(e){return{amount:e.amount,countryOfOrigin:e.countryOfOrigin,currencyCode:e.currencyCode,imageUrl:e.imageUrl,name:e.name,productId:e.productId,quantity:e.quantity}})),shippingAddress:{addressLine1:t.value.address.line1,addressLine2:t.value.address.line2||"",city:t.value.address.city,country:t.value.address.country,postalCode:t.value.address.postal_code,state:t.value.address.state}}};var calculateLandedCost=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n;return __generator(this,(function(i){switch(i.label){case 0:t="".concat("https://route.js.zonos.com","/api/calculate-landed-cost");return[4,handleFetch(t,{body:prepCalculateLandedCost(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 1:r=i.sent(),o=r.errors,n=r.json;if(o.length||!n){throw new Error("Failed to calculate landed cost")}return[2,n]}}))}))};var addressRuleStyle=function(e){var t=e.theme;switch(t){default:return{".Input":{padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"}}}};var defaultVariable=function(e){var t=e.borderStyle,r=e.theme;switch(r){case"DARK":return{borderRadius:getBorderRadius(t),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:getBorderRadius(t)}}};var _f=createStore((function(){return{clientSecret:sessionStorage.getItem("zonos--client-secret")||null,fetchingLandedCostAbordController:null,isFetchingLandedCost:false,isFetchingSession:false,stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenFetchingLC:null,stripeElements:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null}})),onChange$1=_f.onChange,reset$1=_f.reset,stripeStore=_f.state;var getStripeOptions=function(e){var t=e.clientSecret,r=e.overrideBorderRaidus,o=e.overridePrimaryColor,n=e.overrideTheme;var i=o||zonosStore.appearance.colorPrimary;var a=i&&isDarkColor(i)?"night":"flat";var s=n==="DARK"?"night":"flat";return{appearance:{labels:"floating",rules:Object.assign({},addressRuleStyle({theme:"LIGHT"})),theme:n?s:a,variables:Object.assign({},defaultVariable({borderStyle:r,theme:"LIGHT"}))},clientSecret:t,locale:localizationStore.selectedLocale}};var initStripeElements=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o;return __generator(this,(function(n){r=stripeStore.clientSecret;if(!stripeStore.stripe){log("Skip. Stripe is not initialized");return[2]}if(r){o=getStripeOptions({clientSecret:r,overrideBorderRaidus:e===null||e===void 0?void 0:e.overrideBorderRaidus,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme});if(!stripeStore.stripeElements){stripeStore.stripeElements=(t=stripeStore.stripe)===null||t===void 0?void 0:t.elements(o)}else{stripeStore.stripeElements.update(o)}log("Stripe elements initialized")}return[2]}))}))};var stripeStoreReset=function(){sessionStorage.removeItem("zonos--client-secret");reset$1();stripeStore.stripe=window.Zonos.stripe};var isPrefetchInfoOutdated=function(){var e,t,r,o;var n=stripeStore.fetchingLandedCostAbordController;if(!n){return false}var i=JSON.stringify((e=stripeStore.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((t=stripeStore.stripeLinkEventData)===null||t===void 0?void 0:t.value);var a=JSON.stringify((r=stripeStore.stripeAddressUsedWhenFetchingLC)===null||r===void 0?void 0:r.value)!==JSON.stringify((o=stripeStore.stripeAddressEventData)===null||o===void 0?void 0:o.value);return i||a};var stripeStorePrefetchLandedCost=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,c,l,d,u,p,S;return __generator(this,(function(v){switch(v.label){case 0:n=!!((e=stripeStore.stripeAddressEventData)===null||e===void 0?void 0:e.complete);i=!!((t=stripeStore.stripeLinkEventData)===null||t===void 0?void 0:t.complete);a=isPrefetchInfoOutdated();if(a){(r=stripeStore.fetchingLandedCostAbordController)===null||r===void 0?void 0:r.abort();stripeStore.fetchingLandedCostAbordController=null}if(!(n&&i&&(a||!stripeStore.isFetchingLandedCost)))return[3,5];stripeStore.isFetchingLandedCost=true;if(stripeStore.stripeAddressEventData){stripeStore.stripeAddressUsedWhenFetchingLC=Object.assign({},stripeStore.stripeAddressEventData)}if(stripeStore.stripeLinkEventData){stripeStore.stripeLinkUsedWhenFetchingLC=Object.assign({},stripeStore.stripeLinkEventData)}v.label=1;case 1:v.trys.push([1,3,,4]);s=new AbortController;stripeStore.fetchingLandedCostAbordController=s;return[4,calculateLandedCost(s)];case 2:c=v.sent(),l=c.checkoutSessionWorkflow,d=c.shipmentRatingCalculateWorkflow;stripeStore.fetchingLandedCostAbordController=null;cartStore.landedCostData=(l===null||l===void 0?void 0:l.filter(Boolean))||null;cartStore.shippingData=(d===null||d===void 0?void 0:d.filter(Boolean))||null;u=(o=cartStore.landedCostData)===null||o===void 0?void 0:o.find(Boolean);p=!!u?u.subtotals:null;if(p){cartStoreApplySubtotals({exchangeRate:p.exchangeRate,items:p.items,landedCostTotal:0,presentmentCurrencyCode:p.presentmentCurrencyCode,shipping:0,total:p.items})}return[3,4];case 3:S=v.sent();logError(S);return[3,4];case 4:stripeStore.isFetchingLandedCost=false;v.label=5;case 5:return[2]}}))}))};var getStripeMessageBasedOnStatus=function(e){var t=[];var r=true;switch(e){case"succeeded":{t=[translate("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"","",translate("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")];r=false;break}case"requires_capture":case"processing":{t=[translate("Payment processing. We'll update you when payment is received.")];r=false;break}case"requires_payment_method":{t=[translate("Payment failed. Please try another payment method.")];break}default:{t=[translate("Something went wrong.")];break}}return{isError:r,messages:t}};var stripeStoreRetrievePayment=function(e){var t=e.clientSecret,r=e.storybookForceStatus;return __awaiter(void 0,void 0,void 0,(function(){var e,o,n,i,a,s,c,l,d;return __generator(this,(function(u){switch(u.label){case 0:if(r){e=getStripeMessageBasedOnStatus(r),o=e.isError,n=e.messages;return[2,{error:o,messages:n}]}i=t||stripeStore.clientSecret;if(!stripeStore.stripe||!i){logError("Failed to retrieve payment intent. Stripe is not initialized");return[2,{error:true,message:[translate("Something went wrong.")]}]}return[4,stripeStore.stripe.retrievePaymentIntent(i)];case 1:a=u.sent().paymentIntent;s=a===null||a===void 0?void 0:a.status;c=getStripeMessageBasedOnStatus(s),l=c.isError,d=c.messages;return[2,{error:l,messages:d}]}}))}))};var stripeStoreConfirmPayment=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s;return __generator(this,(function(c){switch(c.label){case 0:o=!!((e=stripeStore.stripePaymentEventData)===null||e===void 0?void 0:e.complete);n=stripeStore.stripeElements;i=stripeStore.stripe;a=stripeStore.clientSecret;if(!(i&&n&&o&&a))return[3,2];return[4,i.confirmPayment({confirmParams:{receipt_email:(r=(t=stripeStore.stripeLinkEventData)===null||t===void 0?void 0:t.value)===null||r===void 0?void 0:r.email,return_url:window.location.href},elements:n,redirect:"if_required"})];case 1:s=c.sent().error;if(s){if(s.type==="card_error"||s.type==="validation_error"){throw new Error(s.message)}if(s.type==="invalid_request_error"){if(s.code==="payment_intent_unexpected_state"){return[2]}}throw new Error("An unexpected error occurred.")}c.label=2;case 2:return[2]}}))}))};var stripeStoreInitCheckoutSession=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i;return __generator(this,(function(a){switch(a.label){case 0:t=cartStore.items.reduce((function(e,t){return e+t.amount*t.quantity}),0);if(!t||!localizationStore.targetCurrency){logError("Fail to create checkout session - invalid total or currency");return[2,false]}stripeStore.isFetchingSession=true;return[4,handleFetch("".concat("https://route.js.zonos.com","/api/create-checkout-session"),{body:{currency:((e=cartStore.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",itemsAmount:t,presentmentCountryCode:localizationStore.selectedCountryCode||null},method:"POST"})];case 1:r=a.sent(),o=r.errors,n=r.json;stripeStore.isFetchingSession=false;if(o.length||!n){logError("Error occurs when creating checkout session",JSON.stringify(o,null,2));return[2,false]}i=n.checkoutSessionCreate;stripeStore.clientSecret=i.clientSecret;cartStore.checkoutSessionId=i.id;cartStoreApplySubtotals(Object.assign(Object.assign({},i.subtotals),{landedCostTotal:0,shipping:0,total:i.subtotals.items}));log("Exchange rate updated for cart items (checkout session create)","info",cartStore.exchangeRate);log("done-init-checkout-session");return[2,true]}}))}))};var stripeStoreUpdateCheckoutSession=function(e){var t=e.currency,r=e.id,o=e.itemsAmount,n=e.landedCostId,i=e.presentmentCountryCode;return __awaiter(void 0,void 0,void 0,(function(){var e,a,s;return __generator(this,(function(c){switch(c.label){case 0:return[4,handleFetch("".concat("https://route.js.zonos.com","/api/update-checkout-session"),{body:{currency:t,id:r,itemsAmount:o,landedCostId:n,presentmentCountryCode:i},method:"POST"})];case 1:e=c.sent(),a=e.errors,s=e.json;if(a.length||!s){logError("Error occurs when updating checkout session",JSON.stringify(a,null,2));return[2,{errors:a,json:s}]}return[2,{errors:[],json:s}]}}))}))};onChange$1("clientSecret",(function(e){if(e&&stripeStore.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));var formatDate=function(e){var t=e.date,r=e.formatOptions,o=r===void 0?{day:"numeric",weekday:"long",year:"numeric"}:r;return new Intl.DateTimeFormat("en-US",o).format(t)};var getDaysDifference=function(e){var t=new Date;var r=e.getTime()-t.getTime();var o=Math.floor(r/(1e3*60*60*24));return o};var _g=createStore((function(){return{checkoutSessionId:sessionStorage.getItem("zonos--checkout-session-id")||null,currency:"USD",dutiesTaxFees:0,error:null,exchangeRate:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,items:[],landedCostData:null,selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,step:"customer-info",subtotal:0,total:0}})),onChange=_g.onChange,reset=_g.reset,cartStore=_g.state;var cartStoreGetShippingTransitInfo=function(e){var t=e.minTransitAt?getDaysDifference(new Date(e.minTransitAt)):"";var r=e.maxTransitAt?getDaysDifference(new Date(e.maxTransitAt)):"";var o=e.minTransitAt?formatDate({date:new Date(e.minTransitAt)}):"";return{expectedDate:o,maxTransit:r,minTransit:t}};var cartStoreReset=function(){sessionStorage.removeItem("zonos--checkout-session-id");reset()};var cartStoreUpdateToErrorState=function(e){var t=e.messages,r=e.title;cartStore.step="error";cartStore.error={messages:t,title:r}};var cartStoreApplySubtotals=function(e){cartStore.exchangeRate=e.exchangeRate;cartStore.dutiesTaxFees=e.landedCostTotal;cartStore.subtotal=e.items;cartStore.total=e.total;cartStore.currency=e.presentmentCurrencyCode};var cartStoreReCalculateTotal=function(e){var t=e.currency,r=e.itemsAmount,o=e.landedCostId;return __awaiter(void 0,void 0,void 0,(function(){var e,n;return __generator(this,(function(i){switch(i.label){case 0:if(o&&cartStore.selectedLandedCost){e=cartStore.selectedLandedCost.subtotals;cartStoreApplySubtotals(e);log("Exchange rate updated for cart items (landed cost subtotal)","info",cartStore.exchangeRate)}if(!cartStore.checkoutSessionId){logError("Could update cart total without checkout session id");return[2,false]}return[4,stripeStoreUpdateCheckoutSession({currency:t,id:cartStore.checkoutSessionId,itemsAmount:r,landedCostId:o,presentmentCountryCode:localizationStore.selectedCountryCode})];case 1:n=i.sent().json;if(!n){logError("Error occurs when updating checkout session");cartStoreUpdateToErrorState({messages:[translate("There's been an error updating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error updating Checkout")});return[2,false]}if(!o){cartStoreApplySubtotals(n.checkoutSessionUpdate.subtotals);log("Exchange rate updated for cart items (checkout session update)","info",cartStore.exchangeRate)}return[2,true]}}))}))};var cartStoreUpdateSelectedShippingOption=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a,s,c,l,d,u,p,S;return __generator(this,(function(v){switch(v.label){case 0:cartStore.selectedShippingOption=e;a=cartStoreGetShippingTransitInfo(cartStore.selectedShippingOption),s=a.expectedDate,c=a.maxTransit,l=a.minTransit;cartStore.selectedShippingOptionExpectedDate=s;cartStore.selectedShippingOptionTransitTime=l&&c?"".concat(l,"-").concat(c):"".concat(l||c);d=(t=cartStore.landedCostData)===null||t===void 0?void 0:t.find((function(e){var t,r,o;return((r=(t=e.landedCost)===null||t===void 0?void 0:t.shipmentRating)===null||r===void 0?void 0:r.id)===((o=cartStore.selectedShippingOption)===null||o===void 0?void 0:o.id)}));cartStore.selectedLandedCost=d||null;if(!d){return[2,false]}cartStore.shipping=d.subtotals.shipping;u=((r=d===null||d===void 0?void 0:d.landedCost)===null||r===void 0?void 0:r.landedCostGuaranteeCode)==="ZONOS";p=!!((n=(o=d===null||d===void 0?void 0:d.landedCost)===null||o===void 0?void 0:o.deMinimis)===null||n===void 0?void 0:n.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));cartStore.isSelectedShippingAboveDeminimis=p;cartStore.isSelectedShippingGuarantee=u;return[4,cartStoreReCalculateTotal({landedCostId:(i=d.landedCost)===null||i===void 0?void 0:i.id})];case 1:S=v.sent();return[2,S]}}))}))};onChange("checkoutSessionId",(function(){if(!cartStore.checkoutSessionId){sessionStorage.removeItem("zonos--checkout-session-id");return}sessionStorage.setItem("zonos--checkout-session-id",cartStore.checkoutSessionId)}));var cartStoreUpdateItems=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o;return __generator(this,(function(n){switch(n.label){case 0:cartStore.items=e;r=(t=e.find(Boolean))===null||t===void 0?void 0:t.currencyCode;o=e.reduce((function(e,t){return e+t.amount*t.quantity}),0);if(!r||!o){return[2]}cartStore.currency=r;stripeStore.isFetchingSession=true;return[4,cartStoreReCalculateTotal({currency:r,itemsAmount:o})];case 1:n.sent();stripeStore.isFetchingSession=false;return[2]}}))}))};var cartStoreResetSelectedShippingOption=function(){cartStore.selectedShippingOption=null;cartStore.isSelectedShippingAboveDeminimis=false;cartStore.isSelectedShippingGuarantee=false;cartStore.selectedShippingOptionExpectedDate="";cartStore.selectedShippingOptionTransitTime="";cartStore.shipping=0};var cartStoreNextStep=function(){if(cartStore.step==="customer-info"){cartStore.step="shipping"}else if(cartStore.step==="shipping"){cartStore.step="payment"}else if(cartStore.step==="payment"){cartStore.step="finish"}};var cartStorePreviousStep=function(){if(cartStore.step==="payment"){cartStore.step="shipping"}else if(cartStore.step==="shipping"){cartStore.step="customer-info";cartStoreResetSelectedShippingOption()}};export{cartStoreUpdateItems as a,cartStoreReset as b,cartStore as c,stripeStoreInitCheckoutSession as d,cartStoreUpdateToErrorState as e,stripeStorePrefetchLandedCost as f,cartStoreNextStep as g,stripeStoreConfirmPayment as h,initStripeElements as i,stripeStoreReset as j,cartStorePreviousStep as k,stripeStoreRetrievePayment as l,cartStoreUpdateSelectedShippingOption as m,cartStoreGetShippingTransitInfo as n,stripeStore as s};
2
+ //# sourceMappingURL=cart-2f83e048.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["prepCalculateLandedCost","stripeLinkData","stripeStore","stripeLinkEventData","stripeAddressData","stripeAddressEventData","complete","Error","checkoutSessionId","cartStore","contact","email","value","firstName","lastName","phone","items","map","item","amount","countryOfOrigin","currencyCode","imageUrl","name","productId","quantity","shippingAddress","addressLine1","address","line1","addressLine2","line2","city","country","postalCode","postal_code","state","calculateLandedCost","abortController","__awaiter","url","concat","handleFetch","body","method","signal","_f","_g","sent","errors","json","length","addressRuleStyle","theme","padding","paddingBottom","paddingLeft","paddingRight","paddingTop","defaultVariable","borderStyle","borderRadius","getBorderRadius","colorBackground","colorBackgroundText","colorText","colorTextPlaceholder","createStore","clientSecret","sessionStorage","getItem","fetchingLandedCostAbordController","isFetchingLandedCost","isFetchingSession","stripe","stripeAddressElement","stripeAddressUsedWhenFetchingLC","stripeElements","stripeLinkElement","stripeLinkUsedWhenFetchingLC","stripePaymentElement","stripePaymentEventData","onChange","reset","getStripeOptions","overrideBorderRaidus","overridePrimaryColor","overrideTheme","primaryColor","zonosStore","appearance","colorPrimary","themeBasedColor","isDarkColor","labels","rules","Object","assign","variables","locale","localizationStore","selectedLocale","initStripeElements","props","log","stripeOptions","_a","elements","update","stripeStoreReset","removeItem","window","Zonos","isPrefetchInfoOutdated","hasAbortController","isLinkDataDirty","JSON","stringify","_b","isAddressDataDirty","_c","_d","stripeStorePrefetchLandedCost","stripeAddressReady","stripeLinkReady","shouldRefetch","abort","AbortController","checkoutSessionWorkflow","shipmentRatingCalculateWorkflow","landedCostData","filter","Boolean","shippingData","firstLandedCostData","find","subtotals","cartStoreApplySubtotals","exchangeRate","landedCostTotal","presentmentCurrencyCode","shipping","total","logError","err_1","getStripeMessageBasedOnStatus","status","messages","isError","translate","stripeStoreRetrievePayment","_clientSecret","storybookForceStatus","isError_1","messages_1","error","message","retrievePaymentIntent","paymentIntent","_j","_h","stripeStoreConfirmPayment","stripePaymentReady","stripeClientSecret","confirmPayment","confirmParams","receipt_email","return_url","location","href","redirect","type","code","stripeStoreInitCheckoutSession","reduce","targetCurrency","currency","itemsAmount","presentmentCountryCode","selectedCountryCode","result","checkoutSessionCreate","id","stripeStoreUpdateCheckoutSession","landedCostId","setItem","formatDate","date","formatOptions","day","weekday","year","Intl","DateTimeFormat","format","getDaysDifference","targetDate","currentDate","Date","timeDifference","getTime","daysDifference","Math","floor","dutiesTaxFees","isSelectedShippingAboveDeminimis","isSelectedShippingGuarantee","selectedLandedCost","selectedShippingOption","selectedShippingOptionExpectedDate","selectedShippingOptionTransitTime","step","subtotal","cartStoreGetShippingTransitInfo","minTransit","minTransitAt","maxTransit","maxTransitAt","expectedDate","cartStoreReset","cartStoreUpdateToErrorState","title","cartStoreReCalculateTotal","checkoutSessionUpdate","cartStoreUpdateSelectedShippingOption","checkoutSessionPresentment","landedCost","shipmentRating","isGuarantee","landedCostGuaranteeCode","isAboveDeminimis","deMinimis","includes","threshold","_e","updateCalulateStatus","cartStoreUpdateItems","amt","cartStoreResetSelectedShippingOption","cartStoreNextStep","cartStorePreviousStep"],"sources":["src/components/utils/api/prepCalculateLandedCost.ts","src/components/utils/api/calculateLandedCost.ts","src/styles/stripe/addressRuleStyle.ts","src/styles/stripe/defaultVariable.ts","src/components/store/checkout/stripe.ts","src/components/utils/formatDate.ts","src/components/utils/getDaysDifference.ts","src/components/store/checkout/cart.ts"],"sourcesContent":["import { cartStore } from 'src/components/store/checkout/cart';\nimport { stripeStore } from 'src/components/store/checkout/stripe';\nimport type { CalculateLandedCostRequest } from 'src/types/checkout/api/CalculateLandedCostRequest';\n\nexport const prepCalculateLandedCost = (): CalculateLandedCostRequest => {\n // maybe we don't need email now for prefetch the landed cost\n const stripeLinkData = stripeStore.stripeLinkEventData;\n\n const stripeAddressData = stripeStore.stripeAddressEventData;\n if (!stripeAddressData || !stripeAddressData.complete) {\n throw new Error('Missing stripe address data');\n }\n\n return {\n checkoutSessionId: cartStore.checkoutSessionId || '',\n contact: {\n email: stripeLinkData?.value.email || '',\n // firstName and lastName should be valid now since stripe only mark\n // the address as complete when both fields are filled.\n firstName: stripeAddressData.value.firstName || '',\n lastName: stripeAddressData.value.lastName || '',\n phone: stripeAddressData.value.phone || '',\n },\n items: cartStore.items.map(item => ({\n amount: item.amount,\n countryOfOrigin: item.countryOfOrigin,\n currencyCode: item.currencyCode,\n imageUrl: item.imageUrl,\n name: item.name,\n productId: item.productId,\n quantity: item.quantity,\n })),\n shippingAddress: {\n addressLine1: stripeAddressData.value.address.line1,\n addressLine2: stripeAddressData.value.address.line2 || '',\n city: stripeAddressData.value.address.city,\n country: stripeAddressData.value.address.country,\n postalCode: stripeAddressData.value.address.postal_code,\n state: stripeAddressData.value.address.state,\n },\n };\n};\n","import { prepCalculateLandedCost } from 'src/components/utils/api/prepCalculateLandedCost';\nimport { handleFetch } from 'src/components/utils/handleFetch';\nimport type { CalculateLandedCostRequest } from 'src/types/checkout/api/CalculateLandedCostRequest';\nimport type { CalculateLandedCostMutation } from 'src/types/generated/graphql.customer.types';\n\nexport const calculateLandedCost = async (\n abortController?: AbortController,\n) => {\n // request to get landed cost info\n const url = `${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/calculate-landed-cost`;\n const { errors, json } = await handleFetch<\n CalculateLandedCostMutation,\n CalculateLandedCostRequest\n >(url, {\n body: prepCalculateLandedCost(),\n method: 'POST',\n signal: abortController?.signal,\n });\n if (errors.length || !json) {\n throw new Error('Failed to calculate landed cost');\n }\n\n return json;\n};\n","import type { ElementsUiTheme, StripeRuleType } from 'src/types';\n\nexport const addressRuleStyle = ({\n theme,\n}: {\n theme: ElementsUiTheme;\n}): StripeRuleType => {\n switch (theme) {\n default:\n return {\n '.Input': {\n // need to reset everything and the paddingTop to default, otherwise the paddingTop will not be updated.\n padding: '0',\n paddingBottom: '8px',\n paddingLeft: '16px',\n paddingRight: '8px',\n // any value here will be add up to the default paddingTop (20px).\n paddingTop: '6px',\n },\n };\n }\n};\n","import type { Appearance } from '@stripe/stripe-js';\n\nimport { getBorderRadius } from 'src/components/utils/getBorderRadius';\nimport type {\n ElementsUiStyle,\n ElementsUiTheme,\n} from 'src/types/generated/graphql.customer.types';\n\nexport const defaultVariable = ({\n borderStyle,\n theme,\n}: {\n borderStyle?: ElementsUiStyle;\n theme: ElementsUiTheme;\n}): Appearance['variables'] => {\n switch (theme) {\n case 'DARK':\n return {\n borderRadius: getBorderRadius(borderStyle),\n colorBackground: '#101117',\n colorBackgroundText: '#C5C6CA',\n colorText: '#C5C6CA',\n colorTextPlaceholder: '#C5C6CA',\n };\n default:\n return {\n borderRadius: getBorderRadius(borderStyle),\n };\n }\n};\n","import { createStore } from '@stencil/store';\nimport type {\n PaymentIntent,\n Stripe,\n StripeAddressElement,\n StripeAddressElementChangeEvent,\n StripeElements,\n StripeElementsOptionsClientSecret,\n StripeLinkAuthenticationElement,\n StripeLinkAuthenticationElementChangeEvent,\n StripePaymentElement,\n StripePaymentElementChangeEvent,\n} from '@stripe/stripe-js';\n\nimport {\n cartStore,\n cartStoreApplySubtotals,\n} from 'src/components/store/checkout/cart';\nimport { localizationStore } from 'src/components/store/hello/localization';\nimport { translate } from 'src/components/store/translationStore';\nimport { zonosStore } from 'src/components/store/zonosStore';\nimport { calculateLandedCost } from 'src/components/utils/api/calculateLandedCost';\nimport { handleFetch } from 'src/components/utils/handleFetch';\nimport { isDarkColor } from 'src/components/utils/isDarkColor';\nimport { log } from 'src/components/utils/logging/log';\nimport { logError } from 'src/components/utils/logging/logError';\nimport { addressRuleStyle } from 'src/styles/stripe/addressRuleStyle';\nimport { defaultVariable } from 'src/styles/stripe/defaultVariable';\nimport type {\n CheckoutSessionCreateMutation,\n CheckoutSessionUpdateMutation,\n CountryCode,\n ElementsUiStyle,\n ElementsUiTheme,\n} from 'src/types/generated/graphql.customer.types';\n\nexport type ContactOption = {\n address: {\n city: string;\n country: string;\n line1: string;\n line2?: string;\n postal_code: string;\n state: string;\n };\n name: string;\n phone?: string;\n};\n\ntype StripeStore = {\n // client secret is used to render link and payment elements\n clientSecret: string | null;\n fetchingLandedCostAbordController: AbortController | null;\n // toggle to indicate if we are pre-fetching/fetching landed cost\n isFetchingLandedCost: boolean;\n // toggle to indicate if we are fetching checkout session\n isFetchingSession: boolean;\n stripe: Stripe | null;\n stripeAddressElement: StripeAddressElement | null;\n stripeAddressEventData: StripeAddressElementChangeEvent | null;\n stripeAddressUsedWhenFetchingLC: StripeAddressElementChangeEvent | null;\n stripeElements: StripeElements | null;\n stripeLinkElement: StripeLinkAuthenticationElement | null;\n stripeLinkEventData: StripeLinkAuthenticationElementChangeEvent | null;\n stripeLinkUsedWhenFetchingLC: StripeLinkAuthenticationElementChangeEvent | null;\n stripePaymentElement: StripePaymentElement | null;\n stripePaymentEventData: StripePaymentElementChangeEvent | null;\n};\n\nconst {\n onChange,\n reset,\n state: stripeStore,\n} = createStore<StripeStore>(() => ({\n clientSecret: sessionStorage.getItem('zonos--client-secret') || null,\n fetchingLandedCostAbordController: null,\n isFetchingLandedCost: false,\n isFetchingSession: false,\n stripe: null,\n stripeAddressElement: null,\n stripeAddressEventData: null,\n stripeAddressUsedWhenFetchingLC: null,\n stripeElements: null,\n stripeLinkElement: null,\n stripeLinkEventData: null,\n stripeLinkUsedWhenFetchingLC: null,\n stripePaymentElement: null,\n stripePaymentEventData: null,\n}));\n\nconst getStripeOptions = ({\n clientSecret,\n overrideBorderRaidus,\n overridePrimaryColor,\n overrideTheme,\n}: {\n clientSecret?: string;\n overrideBorderRaidus?: ElementsUiStyle;\n overridePrimaryColor?: string;\n overrideTheme?: ElementsUiTheme;\n}): StripeElementsOptionsClientSecret => {\n const primaryColor =\n overridePrimaryColor || zonosStore.appearance.colorPrimary;\n const themeBasedColor =\n primaryColor && isDarkColor(primaryColor) ? 'night' : 'flat';\n // if overrideTheme is provided, use it. Otherwise, use theme based on primary color\n const theme = overrideTheme === 'DARK' ? 'night' : 'flat';\n return {\n appearance: {\n labels: 'floating',\n rules: {\n ...addressRuleStyle({ theme: 'LIGHT' }),\n },\n // get contrast theme color base on primary color\n theme: overrideTheme ? theme : themeBasedColor,\n variables: {\n ...defaultVariable({\n borderStyle: overrideBorderRaidus,\n theme: 'LIGHT',\n }),\n },\n },\n clientSecret,\n locale: localizationStore.selectedLocale,\n };\n};\n\nconst initStripeElements = async (props?: {\n overrideBorderRaidus?: ElementsUiStyle;\n overridePrimaryColor?: string;\n overrideTheme?: ElementsUiTheme;\n}) => {\n const clientSecret = stripeStore.clientSecret;\n\n if (!stripeStore.stripe) {\n log('Skip. Stripe is not initialized');\n return;\n }\n if (clientSecret) {\n const stripeOptions = getStripeOptions({\n clientSecret,\n overrideBorderRaidus: props?.overrideBorderRaidus,\n overridePrimaryColor: props?.overridePrimaryColor,\n overrideTheme: props?.overrideTheme,\n });\n\n if (!stripeStore.stripeElements) {\n // init stripe elements if it doesn't exist\n stripeStore.stripeElements = stripeStore.stripe?.elements(stripeOptions);\n } else {\n // update elements with new option if it already exists\n stripeStore.stripeElements.update(stripeOptions);\n }\n log('Stripe elements initialized');\n }\n};\n\nconst stripeStoreReset = () => {\n // clean clientSecret so that we can start the new one.\n sessionStorage.removeItem('zonos--client-secret');\n\n // cleanup stripe elements\n reset();\n // set stripe back to window.Zonos.stripe\n stripeStore.stripe = window.Zonos.stripe;\n};\n\n/**\n * Check if the address and email info used when fetching landed cost with the current email and address info are different\n * Purpose is to resend the request if the info used when fetching landed cost is different from the current info\n */\nconst isPrefetchInfoOutdated = () => {\n const hasAbortController = stripeStore.fetchingLandedCostAbordController;\n if (!hasAbortController) {\n // if there is no abort controller, this is a new request\n return false;\n }\n\n const isLinkDataDirty =\n JSON.stringify(stripeStore.stripeLinkUsedWhenFetchingLC?.value) !==\n JSON.stringify(stripeStore.stripeLinkEventData?.value);\n const isAddressDataDirty =\n JSON.stringify(stripeStore.stripeAddressUsedWhenFetchingLC?.value) !==\n JSON.stringify(stripeStore.stripeAddressEventData?.value);\n\n return isLinkDataDirty || isAddressDataDirty;\n};\n\nconst stripeStorePrefetchLandedCost = async () => {\n const stripeAddressReady = !!stripeStore.stripeAddressEventData?.complete;\n const stripeLinkReady = !!stripeStore.stripeLinkEventData?.complete;\n const shouldRefetch = isPrefetchInfoOutdated();\n\n if (shouldRefetch) {\n // if the info used when fetching landed cost is different from the current info, abort the previous request\n stripeStore.fetchingLandedCostAbordController?.abort();\n stripeStore.fetchingLandedCostAbordController = null;\n }\n\n // only fetch if we are not fetching or we need to refetch\n if (\n stripeAddressReady &&\n stripeLinkReady &&\n (shouldRefetch || !stripeStore.isFetchingLandedCost)\n ) {\n stripeStore.isFetchingLandedCost = true;\n if (stripeStore.stripeAddressEventData) {\n stripeStore.stripeAddressUsedWhenFetchingLC = {\n ...stripeStore.stripeAddressEventData,\n };\n }\n if (stripeStore.stripeLinkEventData) {\n stripeStore.stripeLinkUsedWhenFetchingLC = {\n ...stripeStore.stripeLinkEventData,\n };\n }\n try {\n const abortController = new AbortController();\n stripeStore.fetchingLandedCostAbordController = abortController;\n const { checkoutSessionWorkflow, shipmentRatingCalculateWorkflow } =\n await calculateLandedCost(abortController);\n\n // reset abort controller after we are done\n stripeStore.fetchingLandedCostAbordController = null;\n\n // update cart store with landed cost info\n cartStore.landedCostData =\n checkoutSessionWorkflow?.filter(Boolean) || null;\n\n cartStore.shippingData =\n shipmentRatingCalculateWorkflow?.filter(Boolean) || null;\n // apply new subtotal and total, this is mainly to show items in the presentment currency\n const firstLandedCostData = cartStore.landedCostData?.find(Boolean);\n const subtotals = !!firstLandedCostData\n ? firstLandedCostData.subtotals\n : null;\n if (subtotals) {\n // prefetch landed cost will not update shipping and taxes since we haven't selected shipping method yet\n cartStoreApplySubtotals({\n exchangeRate: subtotals.exchangeRate,\n items: subtotals.items,\n landedCostTotal: 0,\n presentmentCurrencyCode: subtotals.presentmentCurrencyCode,\n shipping: 0,\n total: subtotals.items,\n });\n }\n } catch (err) {\n logError(err);\n }\n stripeStore.isFetchingLandedCost = false;\n }\n};\n\nconst getStripeMessageBasedOnStatus = (status?: PaymentIntent['status']) => {\n let messages: string[] = [];\n let isError = true;\n // Inspect the PaymentIntent `status` to indicate the status of the payment\n // to your customer.\n //\n // Some payment methods will [immediately succeed or fail][0] upon\n // confirmation, while others will first enter a `processing` state.\n //\n // [0]: https://stripe.com/docs/payments/payment-methods#payment-notification\n switch (status) {\n case 'succeeded': {\n messages = [\n translate(\n 'Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us.',\n ),\n '',\n '',\n translate(\n \"We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.\",\n ),\n ];\n isError = false;\n break;\n }\n case 'requires_capture':\n case 'processing': {\n messages = [\n translate(\n \"Payment processing. We'll update you when payment is received.\",\n ),\n ];\n isError = false;\n break;\n }\n\n case 'requires_payment_method': {\n messages = [\n translate('Payment failed. Please try another payment method.'),\n ];\n break;\n }\n\n default: {\n messages = [translate('Something went wrong.')];\n break;\n }\n }\n return {\n isError,\n messages,\n };\n};\n\nconst stripeStoreRetrievePayment = async ({\n clientSecret: _clientSecret,\n storybookForceStatus,\n}: {\n clientSecret: string | null;\n storybookForceStatus?: PaymentIntent['status'];\n}) => {\n if (storybookForceStatus) {\n // return status right away if we are in storybook mode\n const { isError, messages } =\n getStripeMessageBasedOnStatus(storybookForceStatus);\n\n return { error: isError, messages };\n }\n const clientSecret = _clientSecret || stripeStore.clientSecret;\n if (!stripeStore.stripe || !clientSecret) {\n logError('Failed to retrieve payment intent. Stripe is not initialized');\n return { error: true, message: [translate('Something went wrong.')] };\n }\n const { paymentIntent } = await stripeStore.stripe.retrievePaymentIntent(\n clientSecret,\n );\n\n const status = paymentIntent?.status;\n\n const { isError, messages } = getStripeMessageBasedOnStatus(status);\n\n return { error: isError, messages };\n};\n\nconst stripeStoreConfirmPayment = async () => {\n const stripePaymentReady = !!stripeStore.stripePaymentEventData?.complete;\n const stripeElements = stripeStore.stripeElements;\n const stripe = stripeStore.stripe;\n const stripeClientSecret = stripeStore.clientSecret;\n if (stripe && stripeElements && stripePaymentReady && stripeClientSecret) {\n const { error } = await stripe.confirmPayment({\n confirmParams: {\n receipt_email: stripeStore.stripeLinkEventData?.value?.email,\n return_url: window.location.href,\n },\n elements: stripeElements,\n redirect: 'if_required',\n });\n\n if (error) {\n if (error.type === 'card_error' || error.type === 'validation_error') {\n throw new Error(error.message);\n }\n if (error.type === 'invalid_request_error') {\n if (error.code === 'payment_intent_unexpected_state') {\n // PaymentIntent was canceled or expired, or status is `require_capture`.\n // don't throw error here because we will reset the checkout session last step\n return;\n }\n }\n throw new Error('An unexpected error occurred.');\n }\n }\n};\n\ntype CheckoutSessionCreateRequest = {\n currency: string;\n itemsAmount: number;\n presentmentCountryCode: CountryCode | null;\n};\n\n/**\n * Init checkout session\n * @returns {boolean} whether or not the checkout session is successfully created\n */\nconst stripeStoreInitCheckoutSession = async () => {\n const total = cartStore.items.reduce(\n (amount, item) => amount + item.amount * item.quantity,\n 0,\n );\n\n if (!total || !localizationStore.targetCurrency) {\n logError('Fail to create checkout session - invalid total or currency');\n return false;\n }\n\n stripeStore.isFetchingSession = true;\n\n const { errors, json } = await handleFetch<\n CheckoutSessionCreateMutation,\n CheckoutSessionCreateRequest\n >(`${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/create-checkout-session`, {\n body: {\n currency: cartStore.items.find(Boolean)?.currencyCode || '',\n itemsAmount: total,\n presentmentCountryCode: localizationStore.selectedCountryCode || null,\n },\n method: 'POST',\n });\n\n stripeStore.isFetchingSession = false;\n\n if (errors.length || !json) {\n logError(\n 'Error occurs when creating checkout session',\n JSON.stringify(errors, null, 2),\n );\n\n return false;\n }\n const result = json.checkoutSessionCreate;\n\n stripeStore.clientSecret = result.clientSecret;\n // update cart store with updated informations\n cartStore.checkoutSessionId = result.id;\n cartStoreApplySubtotals({\n ...result.subtotals,\n landedCostTotal: 0,\n shipping: 0,\n total: result.subtotals.items,\n });\n log(\n 'Exchange rate updated for cart items (checkout session create)',\n 'info',\n cartStore.exchangeRate,\n );\n\n log('done-init-checkout-session');\n return true;\n};\n\ntype CheckoutSessionUpdateRequest = {\n currency?: string;\n id: string;\n itemsAmount?: number;\n landedCostId?: string;\n presentmentCountryCode: CountryCode | null;\n};\n/**\n * Update checkout session. Use for updating amount with landed cost id, or update session when cart items change\n */\nconst stripeStoreUpdateCheckoutSession = async ({\n currency,\n id,\n itemsAmount,\n landedCostId,\n presentmentCountryCode,\n}: CheckoutSessionUpdateRequest) => {\n // No need to set loading state here because this function will be called under the hood to update\n // landed cost id for the section.\n const { errors, json } = await handleFetch<\n CheckoutSessionUpdateMutation,\n CheckoutSessionUpdateRequest\n >(`${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/update-checkout-session`, {\n body: {\n currency,\n id,\n itemsAmount,\n landedCostId,\n presentmentCountryCode,\n },\n method: 'POST',\n });\n\n if (errors.length || !json) {\n logError(\n 'Error occurs when updating checkout session',\n JSON.stringify(errors, null, 2),\n );\n return { errors, json };\n }\n\n return { errors: [], json };\n};\n\nonChange('clientSecret', clientSecret => {\n // update stripe elements when client secret changes\n if (clientSecret && stripeStore.stripe) {\n sessionStorage.setItem('zonos--client-secret', clientSecret);\n }\n\n if (!clientSecret) {\n sessionStorage.removeItem('zonos--client-secret');\n }\n});\n\nexport {\n initStripeElements,\n stripeStore,\n stripeStoreConfirmPayment,\n stripeStoreInitCheckoutSession,\n stripeStorePrefetchLandedCost,\n stripeStoreReset,\n stripeStoreRetrievePayment,\n stripeStoreUpdateCheckoutSession,\n};\n","type Params = {\n date: Date;\n /**\n * Format options for Intl.DateTimeFormat\n * @default {day:'numeric',weekday:'long',year:'numeric'} Thursday 3, 2023\n */\n formatOptions?: Intl.DateTimeFormatOptions;\n};\n\nexport const formatDate = ({\n date,\n formatOptions = { day: 'numeric', weekday: 'long', year: 'numeric' },\n}: Params): string => {\n // format date to Thursday 3, 2023\n return new Intl.DateTimeFormat('en-US', formatOptions).format(date);\n};\n","export const getDaysDifference = (targetDate: Date) => {\n const currentDate = new Date();\n const timeDifference = targetDate.getTime() - currentDate.getTime();\n const daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24)); // Convert milliseconds to days\n return daysDifference;\n};\n","import { createStore } from '@stencil/store';\n\nimport {\n stripeStore,\n stripeStoreUpdateCheckoutSession,\n} from 'src/components/store/checkout/stripe';\nimport { localizationStore } from 'src/components/store/hello/localization';\nimport { translate } from 'src/components/store/translationStore';\nimport { formatDate } from 'src/components/utils/formatDate';\nimport { getDaysDifference } from 'src/components/utils/getDaysDifference';\nimport { log } from 'src/components/utils/logging/log';\nimport { logError } from 'src/components/utils/logging/logError';\nimport type {\n CheckoutPresentmentFragment,\n CurrencyCode,\n ShipmentRatingFragment,\n} from 'src/types/generated/graphql.customer.types';\n\nexport type CartItem = {\n amount: number;\n countryOfOrigin?: string;\n currencyCode: string;\n description?: string;\n hsCode?: string;\n imageUrl?: string;\n name: string;\n productId?: string;\n quantity: number;\n};\n\ntype CartStore = {\n checkoutSessionId: string | null;\n currency: CurrencyCode;\n dutiesTaxFees: number;\n error: {\n messages: string[];\n title: string;\n } | null;\n exchangeRate: {\n id: string;\n rate: number;\n sourceCurrencyCode: CurrencyCode;\n targetCurrencyCode: CurrencyCode;\n type: string;\n } | null;\n isSelectedShippingAboveDeminimis: boolean;\n isSelectedShippingGuarantee: boolean;\n items: CartItem[];\n landedCostData: CheckoutPresentmentFragment[] | null;\n selectedLandedCost: CheckoutPresentmentFragment | null;\n selectedShippingOption: ShipmentRatingFragment | null;\n selectedShippingOptionExpectedDate: string;\n selectedShippingOptionTransitTime: string;\n shipping: number;\n shippingData: ShipmentRatingFragment[] | null;\n step: 'customer-info' | 'shipping' | 'payment' | 'finish' | 'error';\n subtotal: number;\n total: number;\n};\n\nconst {\n onChange,\n reset,\n state: cartStore,\n} = createStore<CartStore>(() => ({\n checkoutSessionId:\n sessionStorage.getItem('zonos--checkout-session-id') || null,\n currency: 'USD',\n dutiesTaxFees: 0,\n error: null,\n exchangeRate: null,\n isSelectedShippingAboveDeminimis: false,\n isSelectedShippingGuarantee: false,\n items: [],\n landedCostData: null,\n selectedLandedCost: null,\n selectedShippingOption: null,\n selectedShippingOptionExpectedDate: '',\n selectedShippingOptionTransitTime: '',\n shipping: 0,\n shippingData: null,\n step: 'customer-info',\n subtotal: 0,\n total: 0,\n}));\n\n/**\n * Format shipping transit info to be displayed on UI\n * @returns\n * - expectedDate: Thursday, Aug 12\n * - maxTransit: 5\n * - minTransit: 3\n */\nconst cartStoreGetShippingTransitInfo = (item: ShipmentRatingFragment) => {\n const minTransit = item.minTransitAt\n ? getDaysDifference(new Date(item.minTransitAt))\n : '';\n const maxTransit = item.maxTransitAt\n ? getDaysDifference(new Date(item.maxTransitAt))\n : '';\n const expectedDate = item.minTransitAt\n ? formatDate({\n date: new Date(item.minTransitAt),\n })\n : '';\n return {\n expectedDate,\n maxTransit,\n minTransit,\n };\n};\n\nconst cartStoreReset = () => {\n sessionStorage.removeItem('zonos--checkout-session-id');\n\n // reset cart store\n reset();\n};\n\nconst cartStoreUpdateToErrorState = ({\n messages,\n title,\n}: {\n messages: string[];\n title: string;\n}) => {\n cartStore.step = 'error';\n cartStore.error = {\n messages,\n title,\n };\n};\n\ntype CartSubtotals = {\n exchangeRate: {\n id: string;\n rate: number;\n sourceCurrencyCode: CurrencyCode;\n targetCurrencyCode: CurrencyCode;\n type: string;\n };\n items: number;\n landedCostTotal: number;\n presentmentCurrencyCode: CurrencyCode;\n shipping: number;\n total: number;\n};\n\nconst cartStoreApplySubtotals = (subtotals: CartSubtotals) => {\n // update exchange rate so we can use it to display cart items\n cartStore.exchangeRate = subtotals.exchangeRate;\n cartStore.dutiesTaxFees = subtotals.landedCostTotal;\n cartStore.subtotal = subtotals.items;\n cartStore.total = subtotals.total;\n cartStore.currency = subtotals.presentmentCurrencyCode;\n};\n\ntype CartStoreRecalculateTotalParams = Omit<\n Parameters<typeof stripeStoreUpdateCheckoutSession>[0],\n 'id' | 'presentmentCountryCode'\n>;\n\nconst cartStoreReCalculateTotal = async ({\n currency,\n itemsAmount,\n landedCostId,\n}: CartStoreRecalculateTotalParams) => {\n if (landedCostId && cartStore.selectedLandedCost) {\n // update cart total right away if we have landed cost id to avoid order total flickering\n const subtotals = cartStore.selectedLandedCost.subtotals;\n cartStoreApplySubtotals(subtotals);\n log(\n 'Exchange rate updated for cart items (landed cost subtotal)',\n 'info',\n cartStore.exchangeRate,\n );\n }\n // update checkout session\n if (!cartStore.checkoutSessionId) {\n logError('Could update cart total without checkout session id');\n return false;\n }\n const { json } = await stripeStoreUpdateCheckoutSession({\n currency,\n id: cartStore.checkoutSessionId,\n itemsAmount,\n landedCostId,\n presentmentCountryCode: localizationStore.selectedCountryCode,\n });\n if (!json) {\n // do nothing if we can't get checkout session\n logError('Error occurs when updating checkout session');\n cartStoreUpdateToErrorState({\n messages: [\n translate(\n \"There's been an error updating your checkout session. Please reload and try again or contact support if the error persists\",\n ),\n ],\n title: translate('Error updating Checkout'),\n });\n return false;\n }\n if (!landedCostId) {\n // This is when first open the checkout modal and we just want to get info from the old cart session.\n // use subtotals from checkout session to update cart total\n cartStoreApplySubtotals(json.checkoutSessionUpdate.subtotals);\n log(\n 'Exchange rate updated for cart items (checkout session update)',\n 'info',\n cartStore.exchangeRate,\n );\n }\n return true;\n};\n\nconst cartStoreUpdateSelectedShippingOption = async (\n selectedShippingOption: ShipmentRatingFragment,\n) => {\n cartStore.selectedShippingOption = selectedShippingOption;\n\n // update shipping transit info\n const { expectedDate, maxTransit, minTransit } =\n cartStoreGetShippingTransitInfo(cartStore.selectedShippingOption);\n cartStore.selectedShippingOptionExpectedDate = expectedDate;\n cartStore.selectedShippingOptionTransitTime =\n minTransit && maxTransit\n ? `${minTransit}-${maxTransit}`\n : `${minTransit || maxTransit}`;\n\n const selectedLandedCost = cartStore.landedCostData?.find(\n checkoutSessionPresentment =>\n checkoutSessionPresentment.landedCost?.shipmentRating?.id ===\n cartStore.selectedShippingOption?.id,\n );\n // save selected landed cost for later use\n cartStore.selectedLandedCost = selectedLandedCost || null;\n\n if (!selectedLandedCost) {\n // do nothing if we can't find landed cost for selected shipping option\n return false;\n }\n\n // update shipping value and dutiesTaxFees on selectedShippingOption change\n cartStore.shipping = selectedLandedCost.subtotals.shipping;\n\n // update deminimis status\n const isGuarantee =\n selectedLandedCost?.landedCost?.landedCostGuaranteeCode === 'ZONOS';\n // one item in deminimis with type of duty and tax has threshold value is \"ABOVE\"\n const isAboveDeminimis = !!selectedLandedCost?.landedCost?.deMinimis?.find(\n item => ['DUTY', 'TAX'].includes(item.type) && item.threshold === 'ABOVE',\n );\n cartStore.isSelectedShippingAboveDeminimis = isAboveDeminimis;\n cartStore.isSelectedShippingGuarantee = isGuarantee;\n // update session with selected landed cost\n const updateCalulateStatus = await cartStoreReCalculateTotal({\n landedCostId: selectedLandedCost.landedCost?.id,\n });\n return updateCalulateStatus;\n};\n\nonChange('checkoutSessionId', () => {\n if (!cartStore.checkoutSessionId) {\n sessionStorage.removeItem('zonos--checkout-session-id');\n return;\n }\n sessionStorage.setItem(\n 'zonos--checkout-session-id',\n cartStore.checkoutSessionId,\n );\n});\n\nconst cartStoreUpdateItems = async (items: CartItem[]) => {\n cartStore.items = items;\n const currency = items.find(Boolean)?.currencyCode as CurrencyCode;\n const total = items.reduce((amt, item) => {\n return amt + item.amount * item.quantity;\n }, 0);\n if (!currency || !total) {\n // do nothing if we can't get currency or total\n return;\n }\n cartStore.currency = currency;\n // set loading state here because this is first load checkout session when we already have checkout session id stored\n stripeStore.isFetchingSession = true;\n await cartStoreReCalculateTotal({\n currency: currency,\n itemsAmount: total,\n });\n stripeStore.isFetchingSession = false;\n};\n\nconst cartStoreResetSelectedShippingOption = () => {\n cartStore.selectedShippingOption = null;\n cartStore.isSelectedShippingAboveDeminimis = false;\n cartStore.isSelectedShippingGuarantee = false;\n cartStore.selectedShippingOptionExpectedDate = '';\n cartStore.selectedShippingOptionTransitTime = '';\n cartStore.shipping = 0;\n};\n\nconst cartStoreNextStep = () => {\n if (cartStore.step === 'customer-info') {\n cartStore.step = 'shipping';\n } else if (cartStore.step === 'shipping') {\n cartStore.step = 'payment';\n } else if (cartStore.step === 'payment') {\n cartStore.step = 'finish';\n }\n};\n\nconst cartStorePreviousStep = () => {\n if (cartStore.step === 'payment') {\n cartStore.step = 'shipping';\n } else if (cartStore.step === 'shipping') {\n cartStore.step = 'customer-info';\n // reset selected shipping option\n cartStoreResetSelectedShippingOption();\n }\n};\n\nexport {\n cartStore,\n cartStoreApplySubtotals,\n cartStoreGetShippingTransitInfo,\n cartStoreNextStep,\n cartStorePreviousStep,\n cartStoreReCalculateTotal,\n cartStoreReset,\n cartStoreUpdateItems,\n cartStoreUpdateSelectedShippingOption,\n cartStoreUpdateToErrorState,\n};\n"],"mappings":"mwDAIO,IAAMA,wBAA0B,WAErC,IAAMC,EAAiBC,YAAYC,oBAEnC,IAAMC,EAAoBF,YAAYG,uBACtC,IAAKD,IAAsBA,EAAkBE,SAAU,CACrD,MAAM,IAAIC,MAAM,8B,CAGlB,MAAO,CACLC,kBAAmBC,UAAUD,mBAAqB,GAClDE,QAAS,CACPC,OAAOV,IAAc,MAAdA,SAAc,SAAdA,EAAgBW,MAAMD,QAAS,GAGtCE,UAAWT,EAAkBQ,MAAMC,WAAa,GAChDC,SAAUV,EAAkBQ,MAAME,UAAY,GAC9CC,MAAOX,EAAkBQ,MAAMG,OAAS,IAE1CC,MAAOP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0M,OAAS,WAAY,CACxC1M,UAAU0M,KAAO,gBAEjB2B,sC,CAEJ,S"}
@@ -1,2 +1,2 @@
1
- var __awaiter=this&&this.__awaiter||function(t,e,n,s){function o(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,i){function r(t){try{c(s.next(t))}catch(t){i(t)}}function a(t){try{c(s["throw"](t))}catch(t){i(t)}}function c(t){t.done?n(t.value):o(t.value).then(r,a)}c((s=s.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},s,o,i,r;return r={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(r[Symbol.iterator]=function(){return this}),r;function a(t){return function(e){return c([t,e])}}function c(a){if(s)throw new TypeError("Generator is already executing.");while(r&&(r=0,a[0]&&(n=0)),n)try{if(s=1,o&&(i=a[0]&2?o["return"]:a[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;if(o=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;o=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){n.label=a[1];break}if(a[0]===6&&n.label<i[1]){n.label=i[1];i=a;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(a);break}if(i[2])n.ops.pop();n.trys.pop();continue}a=e.call(t,n)}catch(t){a=[6,t];o=0}finally{s=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,h,H as Host,d as getElement}from"./index-d1aa9293.js";import{s as stripeStore,f as stripeStorePrefetchLandedCost}from"./cart-36c33342.js";import{b as logError,a as localizationStore}from"./localization-4a424f49.js";import"./zonosStore-13a7b534.js";import"./isDarkColor-b21326ae.js";import"./getBorderRadius-82fbaf25.js";var zonosAddressCss=".sc-zonos-address-h{font-family:Inter;display:block}.sc-zonos-address-h img.sc-zonos-address{max-width:100%}.sc-zonos-address-h dl.sc-zonos-address,.sc-zonos-address-h dd.sc-zonos-address,.sc-zonos-address-h h1.sc-zonos-address,.sc-zonos-address-h h2.sc-zonos-address,.sc-zonos-address-h h3.sc-zonos-address,.sc-zonos-address-h h4.sc-zonos-address,.sc-zonos-address-h h5.sc-zonos-address,.sc-zonos-address-h h6.sc-zonos-address,.sc-zonos-address-h hr.sc-zonos-address,.sc-zonos-address-h figure.sc-zonos-address,.sc-zonos-address-h p.sc-zonos-address,.sc-zonos-address-h pre.sc-zonos-address{margin:0}.sc-zonos-address-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-address-h .zonos--title.sc-zonos-address{margin-bottom:var(--amino-space-16)}";var ZonosAddress=function(){function t(t){registerInstance(this,t);this.type=undefined;this.titleText=undefined;this.defaultAddress=null;this.stripe=window.Zonos.stripe}t.prototype.watchInitStripe=function(){return __awaiter(this,void 0,void 0,(function(){var t,e,n,s,o;return __generator(this,(function(i){this.stripe=window.Zonos.stripe;if(!this.stripe||!stripeStore.stripeElements){logError("Stripe is not initialized. Couldn't load stripe element.");return[2]}n=(t=this.defaultAddress)===null||t===void 0?void 0:t.phone;if(!n){(e=this.defaultAddress)===null||e===void 0?true:delete e.phone}s=localizationStore.shippingZoneCountries;o=stripeStore.stripeAddressElement||stripeStore.stripeElements.create("address",{allowedCountries:s?Object.values(s).map((function(t){return t.code})):[],contacts:this.defaultAddress?[this.defaultAddress]:undefined,display:{name:"split"},fields:{phone:"always"},mode:this.type,validation:{phone:{required:"always"}}});o.mount(this.el.querySelector(".zonos--address-component"));o.on("change",(function(t){var e=t.value;stripeStore.stripeAddressEventData=Object.assign(Object.assign({},t),{elementMode:"shipping",elementType:"address",empty:false,value:Object.assign(Object.assign({},e),{firstName:e.firstName||e.name.split(" ")[0],lastName:e.lastName||e.name.split(" ").pop()})});void stripeStorePrefetchLandedCost()}));stripeStore.stripeAddressElement=o;return[2]}))}))};t.prototype.componentDidLoad=function(){void this.watchInitStripe()};t.prototype.render=function(){return h(Host,{class:"zonos--address zonos--elements"},h("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),h("div",{class:"zonos--address-component"}))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return t}();ZonosAddress.style=zonosAddressCss;var zonosLinkAuthenticationCss=".sc-zonos-link-authentication-h{font-family:Inter;display:block}.sc-zonos-link-authentication-h img.sc-zonos-link-authentication{max-width:100%}.sc-zonos-link-authentication-h dl.sc-zonos-link-authentication,.sc-zonos-link-authentication-h dd.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h1.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h2.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h3.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h4.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h5.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h6.sc-zonos-link-authentication,.sc-zonos-link-authentication-h hr.sc-zonos-link-authentication,.sc-zonos-link-authentication-h figure.sc-zonos-link-authentication,.sc-zonos-link-authentication-h p.sc-zonos-link-authentication,.sc-zonos-link-authentication-h pre.sc-zonos-link-authentication{margin:0}.sc-zonos-link-authentication-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-link-authentication-h .zonos--title.sc-zonos-link-authentication{margin-bottom:var(--amino-space-16)}";var ZonosLinkAuthentication=function(){function t(t){registerInstance(this,t);this.titleText=undefined;this.stripe=stripeStore.stripe}t.prototype.watchInitStripe=function(){if(!this.stripe||!stripeStore.stripeElements){return}var t=stripeStore.stripeLinkElement||stripeStore.stripeElements.create("linkAuthentication");var e=this.el.querySelector(".zonos--link-authentication-component");if(!e){console.error("Cannot find container element for linkAuthenticationElement");return}t.mount(e);t.on("change",(function(t){stripeStore.stripeLinkEventData=t;void stripeStorePrefetchLandedCost()}));stripeStore.stripeLinkElement=t};t.prototype.componentDidLoad=function(){this.watchInitStripe()};t.prototype.render=function(){return h(Host,{class:"zonos--link-authentication zonos--elements"},h("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),h("div",{class:"zonos--link-authentication-component"}))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return t}();ZonosLinkAuthentication.style=zonosLinkAuthenticationCss;export{ZonosAddress as zonos_address,ZonosLinkAuthentication as zonos_link_authentication};
1
+ var __awaiter=this&&this.__awaiter||function(t,e,n,s){function o(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,i){function r(t){try{c(s.next(t))}catch(t){i(t)}}function a(t){try{c(s["throw"](t))}catch(t){i(t)}}function c(t){t.done?n(t.value):o(t.value).then(r,a)}c((s=s.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},s,o,i,r;return r={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(r[Symbol.iterator]=function(){return this}),r;function a(t){return function(e){return c([t,e])}}function c(a){if(s)throw new TypeError("Generator is already executing.");while(r&&(r=0,a[0]&&(n=0)),n)try{if(s=1,o&&(i=a[0]&2?o["return"]:a[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;if(o=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;o=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){n.label=a[1];break}if(a[0]===6&&n.label<i[1]){n.label=i[1];i=a;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(a);break}if(i[2])n.ops.pop();n.trys.pop();continue}a=e.call(t,n)}catch(t){a=[6,t];o=0}finally{s=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,h,H as Host,d as getElement}from"./index-d1aa9293.js";import{s as stripeStore,f as stripeStorePrefetchLandedCost}from"./cart-2f83e048.js";import{b as logError,a as localizationStore}from"./localization-4a424f49.js";import"./zonosStore-13a7b534.js";import"./isDarkColor-b21326ae.js";import"./getBorderRadius-82fbaf25.js";var zonosAddressCss=".sc-zonos-address-h{font-family:Inter;display:block}.sc-zonos-address-h img.sc-zonos-address{max-width:100%}.sc-zonos-address-h dl.sc-zonos-address,.sc-zonos-address-h dd.sc-zonos-address,.sc-zonos-address-h h1.sc-zonos-address,.sc-zonos-address-h h2.sc-zonos-address,.sc-zonos-address-h h3.sc-zonos-address,.sc-zonos-address-h h4.sc-zonos-address,.sc-zonos-address-h h5.sc-zonos-address,.sc-zonos-address-h h6.sc-zonos-address,.sc-zonos-address-h hr.sc-zonos-address,.sc-zonos-address-h figure.sc-zonos-address,.sc-zonos-address-h p.sc-zonos-address,.sc-zonos-address-h pre.sc-zonos-address{margin:0}.sc-zonos-address-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-address-h .zonos--title.sc-zonos-address{margin-bottom:var(--amino-space-16)}";var ZonosAddress=function(){function t(t){registerInstance(this,t);this.type=undefined;this.titleText=undefined;this.defaultAddress=null;this.stripe=window.Zonos.stripe}t.prototype.watchInitStripe=function(){return __awaiter(this,void 0,void 0,(function(){var t,e,n,s,o;return __generator(this,(function(i){this.stripe=window.Zonos.stripe;if(!this.stripe||!stripeStore.stripeElements){logError("Stripe is not initialized. Couldn't load stripe element.");return[2]}n=(t=this.defaultAddress)===null||t===void 0?void 0:t.phone;if(!n){(e=this.defaultAddress)===null||e===void 0?true:delete e.phone}s=localizationStore.shippingZoneCountries;o=stripeStore.stripeAddressElement||stripeStore.stripeElements.create("address",{allowedCountries:s?Object.values(s).map((function(t){return t.code})):[],contacts:this.defaultAddress?[this.defaultAddress]:undefined,display:{name:"split"},fields:{phone:"always"},mode:this.type,validation:{phone:{required:"always"}}});o.mount(this.el.querySelector(".zonos--address-component"));o.on("change",(function(t){var e=t.value;stripeStore.stripeAddressEventData=Object.assign(Object.assign({},t),{elementMode:"shipping",elementType:"address",empty:false,value:Object.assign(Object.assign({},e),{firstName:e.firstName||e.name.split(" ")[0],lastName:e.lastName||e.name.split(" ").pop()})});void stripeStorePrefetchLandedCost()}));stripeStore.stripeAddressElement=o;return[2]}))}))};t.prototype.componentDidLoad=function(){void this.watchInitStripe()};t.prototype.render=function(){return h(Host,{class:"zonos--address zonos--elements"},h("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),h("div",{class:"zonos--address-component"}))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return t}();ZonosAddress.style=zonosAddressCss;var zonosLinkAuthenticationCss=".sc-zonos-link-authentication-h{font-family:Inter;display:block}.sc-zonos-link-authentication-h img.sc-zonos-link-authentication{max-width:100%}.sc-zonos-link-authentication-h dl.sc-zonos-link-authentication,.sc-zonos-link-authentication-h dd.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h1.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h2.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h3.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h4.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h5.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h6.sc-zonos-link-authentication,.sc-zonos-link-authentication-h hr.sc-zonos-link-authentication,.sc-zonos-link-authentication-h figure.sc-zonos-link-authentication,.sc-zonos-link-authentication-h p.sc-zonos-link-authentication,.sc-zonos-link-authentication-h pre.sc-zonos-link-authentication{margin:0}.sc-zonos-link-authentication-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-link-authentication-h .zonos--title.sc-zonos-link-authentication{margin-bottom:var(--amino-space-16)}";var ZonosLinkAuthentication=function(){function t(t){registerInstance(this,t);this.titleText=undefined;this.stripe=stripeStore.stripe}t.prototype.watchInitStripe=function(){if(!this.stripe||!stripeStore.stripeElements){return}var t=stripeStore.stripeLinkElement||stripeStore.stripeElements.create("linkAuthentication");var e=this.el.querySelector(".zonos--link-authentication-component");if(!e){console.error("Cannot find container element for linkAuthenticationElement");return}t.mount(e);t.on("change",(function(t){stripeStore.stripeLinkEventData=t;void stripeStorePrefetchLandedCost()}));stripeStore.stripeLinkElement=t};t.prototype.componentDidLoad=function(){this.watchInitStripe()};t.prototype.render=function(){return h(Host,{class:"zonos--link-authentication zonos--elements"},h("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),h("div",{class:"zonos--link-authentication-component"}))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return t}();ZonosLinkAuthentication.style=zonosLinkAuthenticationCss;export{ZonosAddress as zonos_address,ZonosLinkAuthentication as zonos_link_authentication};
2
2
  //# sourceMappingURL=zonos-address_2.entry.js.map
@@ -1,2 +1,2 @@
1
- import{r as registerInstance,h,H as Host,d as getElement}from"./index-d1aa9293.js";import{c as classes}from"./classes-0d95c529.js";import{s as stripeStore}from"./cart-36c33342.js";import"./zonosStore-13a7b534.js";import"./localization-4a424f49.js";import"./isDarkColor-b21326ae.js";import"./getBorderRadius-82fbaf25.js";var zonosBannerCss=':host{font-family:Inter;display:block}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{border-radius:var(--amino-radius-10);padding:var(--amino-space-16);background:var(--amino-gray-100)}:host .zonos--container{display:grid;-ms-flex-align:center;align-items:center;grid-template-areas:"icon header" ". content";grid-template-columns:32px auto 0}:host .zonos--icon-wrapper{grid-area:icon;display:-ms-flexbox;display:flex;justify-self:start}:host .zonos--header-wrapper{grid-area:header}:host .zonos--content-wrapper{grid-area:content;margin-top:8px}:host(.info){background-color:var(--amino-blue-100)}:host(.success){background-color:var(--amino-green-100)}:host(.error){background-color:var(--amino-red-100)}:host(.warning){background-color:var(--amino-orange-100)}';var ZonosBanner=function(){function o(o){var e=this;registerInstance(this,o);this.handleSlotChange=function(){e.hasContent=true};this.bannerTitle=undefined;this.intent=undefined;this.class="";this.hasContent=false}o.prototype.render=function(){var o=this;var e=function(e){var t=e.color;var n="var(--amino-".concat(t,"-800)");var s="var(--amino-".concat(t,"-300)");var a=[o.bannerTitle,h("slot",{onSlotchange:o.handleSlotChange})].filter(Boolean),r=a[0],i=a[1];var c=t==="gray"?"gray-1200":"".concat(t,"-800");return h("div",{class:classes(["zonos--container"])},h("div",{class:"zonos--icon-wrapper"},h("svg",{color:n,fill:"none",height:"20",viewBox:"0 0 24 24",width:"20",xmlns:"http://www.w3.org/2000/svg"},h("path",{"clip-rule":"evenodd",d:"M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12Z","data-is-secondary-color":"true",fill:s,"fill-rule":"evenodd"}),h("path",{"clip-rule":"evenodd",d:"M12 6.99a1 1 0 0 1 1 1V8a1 1 0 1 1-2 0v-.01a1 1 0 0 1 1-1ZM12 11a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0v-4a1 1 0 0 1 1-1Z",fill:"currentColor","fill-rule":"evenodd"}))),h("div",{class:"zonos--header-wrapper"},h("zonos-text",{color:c,type:"label",weight:600},r)),i&&h("div",{class:"zonos--content-wrapper"},h("zonos-text",{color:c},i)))};var t=classes(["zonos--elements zonos--banner",this.class,this.intent]);switch(this.intent){case"error":return h(Host,{class:t},e({color:"red"}));case"info":return h(Host,{class:t},e({color:"blue"}));case"success":return h(Host,{class:t},e({color:"green"}));case"warning":return h(Host,{class:t},e({color:"orange"}));default:return h(Host,{class:t},e({color:"gray"}))}};return o}();ZonosBanner.style=zonosBannerCss;var zonosPaymentCss=".sc-zonos-payment-h{font-family:Inter;display:block}.sc-zonos-payment-h img.sc-zonos-payment{max-width:100%}.sc-zonos-payment-h dl.sc-zonos-payment,.sc-zonos-payment-h dd.sc-zonos-payment,.sc-zonos-payment-h h1.sc-zonos-payment,.sc-zonos-payment-h h2.sc-zonos-payment,.sc-zonos-payment-h h3.sc-zonos-payment,.sc-zonos-payment-h h4.sc-zonos-payment,.sc-zonos-payment-h h5.sc-zonos-payment,.sc-zonos-payment-h h6.sc-zonos-payment,.sc-zonos-payment-h hr.sc-zonos-payment,.sc-zonos-payment-h figure.sc-zonos-payment,.sc-zonos-payment-h p.sc-zonos-payment,.sc-zonos-payment-h pre.sc-zonos-payment{margin:0}.sc-zonos-payment-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-payment-h .zonos--title.sc-zonos-payment{margin-bottom:var(--amino-space-16)}";var ZonosPayment=function(){function o(o){registerInstance(this,o);this.titleText=undefined;this.stripe=stripeStore.stripe;this.stripeElements=stripeStore.stripeElements}o.prototype.watchInitStripe=function(){if(!this.stripeElements){return}var o=stripeStore.stripePaymentElement||this.stripeElements.create("payment",{layout:"tabs"});var e=this.el.querySelector(".zonos--payment-component");if(!e){console.error("Cannot find container element for paymentElement");return}o.mount(e);o.on("change",(function(o){stripeStore.stripePaymentEventData=o}));stripeStore.stripePaymentElement=o};o.prototype.componentDidLoad=function(){this.watchInitStripe()};o.prototype.render=function(){return h(Host,{class:"zonos--payment zonos--elements"},this.titleText&&h("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),h("div",{class:"zonos--payment-component"}))};Object.defineProperty(o.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(o,"watchers",{get:function(){return{stripeElements:["watchInitStripe"],stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return o}();ZonosPayment.style=zonosPaymentCss;export{ZonosBanner as zonos_banner,ZonosPayment as zonos_payment};
1
+ import{r as registerInstance,h,H as Host,d as getElement}from"./index-d1aa9293.js";import{c as classes}from"./classes-0d95c529.js";import{s as stripeStore}from"./cart-2f83e048.js";import"./zonosStore-13a7b534.js";import"./localization-4a424f49.js";import"./isDarkColor-b21326ae.js";import"./getBorderRadius-82fbaf25.js";var zonosBannerCss=':host{font-family:Inter;display:block}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{border-radius:var(--amino-radius-10);padding:var(--amino-space-16);background:var(--amino-gray-100)}:host .zonos--container{display:grid;-ms-flex-align:center;align-items:center;grid-template-areas:"icon header" ". content";grid-template-columns:32px auto 0}:host .zonos--icon-wrapper{grid-area:icon;display:-ms-flexbox;display:flex;justify-self:start}:host .zonos--header-wrapper{grid-area:header}:host .zonos--content-wrapper{grid-area:content;margin-top:8px}:host(.info){background-color:var(--amino-blue-100)}:host(.success){background-color:var(--amino-green-100)}:host(.error){background-color:var(--amino-red-100)}:host(.warning){background-color:var(--amino-orange-100)}';var ZonosBanner=function(){function o(o){var e=this;registerInstance(this,o);this.handleSlotChange=function(){e.hasContent=true};this.bannerTitle=undefined;this.intent=undefined;this.class="";this.hasContent=false}o.prototype.render=function(){var o=this;var e=function(e){var t=e.color;var n="var(--amino-".concat(t,"-800)");var s="var(--amino-".concat(t,"-300)");var a=[o.bannerTitle,h("slot",{onSlotchange:o.handleSlotChange})].filter(Boolean),r=a[0],i=a[1];var c=t==="gray"?"gray-1200":"".concat(t,"-800");return h("div",{class:classes(["zonos--container"])},h("div",{class:"zonos--icon-wrapper"},h("svg",{color:n,fill:"none",height:"20",viewBox:"0 0 24 24",width:"20",xmlns:"http://www.w3.org/2000/svg"},h("path",{"clip-rule":"evenodd",d:"M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12Z","data-is-secondary-color":"true",fill:s,"fill-rule":"evenodd"}),h("path",{"clip-rule":"evenodd",d:"M12 6.99a1 1 0 0 1 1 1V8a1 1 0 1 1-2 0v-.01a1 1 0 0 1 1-1ZM12 11a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0v-4a1 1 0 0 1 1-1Z",fill:"currentColor","fill-rule":"evenodd"}))),h("div",{class:"zonos--header-wrapper"},h("zonos-text",{color:c,type:"label",weight:600},r)),i&&h("div",{class:"zonos--content-wrapper"},h("zonos-text",{color:c},i)))};var t=classes(["zonos--elements zonos--banner",this.class,this.intent]);switch(this.intent){case"error":return h(Host,{class:t},e({color:"red"}));case"info":return h(Host,{class:t},e({color:"blue"}));case"success":return h(Host,{class:t},e({color:"green"}));case"warning":return h(Host,{class:t},e({color:"orange"}));default:return h(Host,{class:t},e({color:"gray"}))}};return o}();ZonosBanner.style=zonosBannerCss;var zonosPaymentCss=".sc-zonos-payment-h{font-family:Inter;display:block}.sc-zonos-payment-h img.sc-zonos-payment{max-width:100%}.sc-zonos-payment-h dl.sc-zonos-payment,.sc-zonos-payment-h dd.sc-zonos-payment,.sc-zonos-payment-h h1.sc-zonos-payment,.sc-zonos-payment-h h2.sc-zonos-payment,.sc-zonos-payment-h h3.sc-zonos-payment,.sc-zonos-payment-h h4.sc-zonos-payment,.sc-zonos-payment-h h5.sc-zonos-payment,.sc-zonos-payment-h h6.sc-zonos-payment,.sc-zonos-payment-h hr.sc-zonos-payment,.sc-zonos-payment-h figure.sc-zonos-payment,.sc-zonos-payment-h p.sc-zonos-payment,.sc-zonos-payment-h pre.sc-zonos-payment{margin:0}.sc-zonos-payment-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-payment-h .zonos--title.sc-zonos-payment{margin-bottom:var(--amino-space-16)}";var ZonosPayment=function(){function o(o){registerInstance(this,o);this.titleText=undefined;this.stripe=stripeStore.stripe;this.stripeElements=stripeStore.stripeElements}o.prototype.watchInitStripe=function(){if(!this.stripeElements){return}var o=stripeStore.stripePaymentElement||this.stripeElements.create("payment",{layout:"tabs"});var e=this.el.querySelector(".zonos--payment-component");if(!e){console.error("Cannot find container element for paymentElement");return}o.mount(e);o.on("change",(function(o){stripeStore.stripePaymentEventData=o}));stripeStore.stripePaymentElement=o};o.prototype.componentDidLoad=function(){this.watchInitStripe()};o.prototype.render=function(){return h(Host,{class:"zonos--payment zonos--elements"},this.titleText&&h("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),h("div",{class:"zonos--payment-component"}))};Object.defineProperty(o.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(o,"watchers",{get:function(){return{stripeElements:["watchInitStripe"],stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return o}();ZonosPayment.style=zonosPaymentCss;export{ZonosBanner as zonos_banner,ZonosPayment as zonos_payment};
2
2
  //# sourceMappingURL=zonos-banner_2.entry.js.map