@zonos/elements 1.4.2 → 1.5.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.
- package/dist/cjs/{TaxId-Q6aDqqWv.js → TaxId-ChhNwG04.js} +36 -0
- package/dist/cjs/{cart-B6Aty-21.js → cart-CiXlehwQ.js} +88 -52
- package/dist/cjs/{collect-DnrvaXUI.js → collect-Drr8fY-q.js} +3 -3
- package/dist/cjs/{debounce-Cd2emZPn.js → debounce-BhgA8_3W.js} +2 -2
- package/dist/cjs/{debounce-vY0QYT6o.js → debounce-DRPMxNew.js} +1 -1
- package/dist/cjs/{getBorderRadius-CyYZw4qq.js → getBorderRadius-CJ_95w3o.js} +1 -1
- package/dist/cjs/{getMissingRequiredShippingFields-D03ICqss.js → getMissingRequiredShippingFields-DI6qF1z3.js} +1 -1
- package/dist/cjs/{hasInclusivePrice-CPCoVeU3.js → hasInclusivePrice-84KS94yH.js} +1 -1
- package/dist/cjs/index.cjs.js +19 -8
- package/dist/cjs/{invoice-Cj8W7NW0.js → invoice-5hVfSXpb.js} +3 -3
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{localization-BzNeXeDe.js → localization-B2mjW0Xa.js} +701 -41
- package/dist/cjs/{paypal-CuKshRmZ.js → paypal-pd8Nz_R_.js} +4 -4
- package/dist/cjs/{placeTestOrder-7czjwkjm.js → placeTestOrder-DrI8rD9o.js} +2 -2
- package/dist/cjs/{renderCheckoutCurrency-BH8t2b2x.js → renderCheckoutCurrency-u5q8YdUb.js} +2 -2
- package/dist/cjs/shouldRenderShortAddressCodeInput-gpu_bMfp.js +21 -0
- package/dist/cjs/{shouldShowLanguageSelect-yAbtCmd8.js → shouldShowLanguageSelect-gBg4KeTQ.js} +1 -1
- package/dist/cjs/{submitGtag-D79e8u6s.js → submitGtag-Rc-S3PnH.js} +1 -1
- package/dist/cjs/{throttle-zSVRQLC0.js → taxIdFields-BrIaPTcd.js} +57 -2
- package/dist/cjs/taxIdRules-BBj8kQxJ.js +58 -0
- package/dist/cjs/{updateCheckoutSessionAttributes-jMtfOL2m.js → updateCheckoutSessionAttributes-d0IKpwW8.js} +1 -1
- package/dist/cjs/zonos-address-completion-dialog_7.cjs.entry.js +25 -30
- package/dist/cjs/zonos-address-display_2.cjs.entry.js +3 -3
- package/dist/cjs/zonos-address_4.cjs.entry.js +27 -30
- package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +7 -6
- package/dist/cjs/zonos-badge.cjs.entry.js +1 -1
- package/dist/cjs/zonos-banner.cjs.entry.js +1 -1
- package/dist/cjs/zonos-button_3.cjs.entry.js +2 -2
- package/dist/cjs/zonos-card_5.cjs.entry.js +8 -7
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +148 -80
- package/dist/cjs/zonos-checkbox_2.cjs.entry.js +2 -2
- package/dist/cjs/zonos-checkout.cjs.entry.js +31 -20
- package/dist/cjs/zonos-collapse.cjs.entry.js +1 -1
- package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +6 -5
- package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +12 -11
- package/dist/cjs/zonos-collect.cjs.entry.js +9 -8
- package/dist/cjs/zonos-controller.cjs.entry.js +7 -6
- package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +3 -3
- package/dist/cjs/zonos-elements.cjs.js +1 -1
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +4 -4
- package/dist/cjs/zonos-hello.cjs.entry.js +4 -4
- package/dist/cjs/zonos-input.cjs.entry.js +2 -2
- package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +8 -7
- package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +12 -11
- package/dist/cjs/zonos-invoice.cjs.entry.js +9 -8
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
- package/dist/cjs/zonos-logo.cjs.entry.js +1 -1
- package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +7 -6
- package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +2 -2
- package/dist/cjs/zonos-stripe-input.cjs.entry.js +2 -2
- package/dist/cjs/zonos-text.cjs.entry.js +1 -1
- package/dist/cjs/zonos-v-stack.cjs.entry.js +1 -1
- package/dist/cjs/{zonosStore-Bx9jK82G.js → zonosStore-CDV83QyK.js} +2 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-cart-items/zonos-cart-items.css +10 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-cart-items/zonos-cart-items.js +6 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +7 -10
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +12 -4
- package/dist/collection/components/store/checkout/stripe.js +10 -12
- package/dist/collection/components/store/translationStore/strings.arabic.js +35 -2
- package/dist/collection/components/store/translationStore/strings.base.js +35 -2
- package/dist/collection/components/store/translationStore/strings.chinese.js +35 -2
- package/dist/collection/components/store/translationStore/strings.danish.js +35 -2
- package/dist/collection/components/store/translationStore/strings.dutch.js +35 -2
- package/dist/collection/components/store/translationStore/strings.french.js +35 -2
- package/dist/collection/components/store/translationStore/strings.german.js +35 -2
- package/dist/collection/components/store/translationStore/strings.hebrew.js +35 -2
- package/dist/collection/components/store/translationStore/strings.indonesian.js +35 -2
- package/dist/collection/components/store/translationStore/strings.italian.js +35 -2
- package/dist/collection/components/store/translationStore/strings.japanese.js +35 -2
- package/dist/collection/components/store/translationStore/strings.korean.js +35 -2
- package/dist/collection/components/store/translationStore/strings.norwegian.js +35 -2
- package/dist/collection/components/store/translationStore/strings.polish.js +35 -2
- package/dist/collection/components/store/translationStore/strings.portuguese.js +35 -2
- package/dist/collection/components/store/translationStore/strings.russian.js +35 -2
- package/dist/collection/components/store/translationStore/strings.spanish.js +35 -2
- package/dist/collection/components/store/translationStore/strings.swedish.js +35 -2
- package/dist/collection/components/store/translationStore/strings.turkish.js +35 -2
- package/dist/collection/components/store/translationStore/strings.vietnamese.js +35 -2
- package/dist/collection/components/store/zonosStore.js +2 -1
- package/dist/collection/components/stripe/zonos-address/zonos-address.css +5 -0
- package/dist/collection/components/stripe/zonos-address/zonos-address.js +37 -22
- package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.css +5 -0
- package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +34 -21
- package/dist/collection/components/utils/api/prepCalculateLandedCost.js +24 -35
- package/dist/collection/components/utils/checkout/getCheckoutTaxIdPayload.js +16 -0
- package/dist/collection/components/utils/checkout/getTaxIdFieldState.js +26 -0
- package/dist/collection/components/utils/checkout/isHostedVsNativeTestAllowed.js +13 -0
- package/dist/collection/components/utils/checkout/itemCustomization.js +53 -0
- package/dist/collection/components/utils/checkout/parseItemCustomizations.js +6 -0
- package/dist/collection/components/utils/checkout/resolveTaxIdSelection.js +23 -0
- package/dist/collection/components/utils/checkout/shouldRenderTaxIdInput.js +7 -11
- package/dist/collection/components/utils/checkout/taxIdFields.js +29 -0
- package/dist/collection/components/utils/taxId/taxIdRules.js +44 -0
- package/dist/collection/components/utils/taxIdValidationResult.js +57 -58
- package/dist/collection/index.js +1 -0
- package/dist/collection/types/checkout/TaxId.js +31 -0
- package/dist/collection/types/checkout/itemCustomization.js +1 -0
- package/dist/collection/types/index.js +1 -0
- package/dist/esm/{TaxId-Cye-evFK.js → TaxId-DMIgN_sT.js} +32 -1
- package/dist/esm/{cart-BoQp8Ema.js → cart-DmJkjiDE.js} +88 -53
- package/dist/esm/{collect-Eo4gtyql.js → collect-BV5GTPmh.js} +3 -3
- package/dist/esm/{debounce-BR3PaG8X.js → debounce-DHj2iHA1.js} +1 -1
- package/dist/esm/{debounce-CrmpwbEE.js → debounce-DWqMT4lo.js} +2 -2
- package/dist/esm/{getBorderRadius-DYfkeXdx.js → getBorderRadius-BiGd45jw.js} +1 -1
- package/dist/esm/{getMissingRequiredShippingFields-Ks6_tpjn.js → getMissingRequiredShippingFields-DljgpDZe.js} +1 -1
- package/dist/esm/{hasInclusivePrice-CbEfIhI5.js → hasInclusivePrice-DhGXpH2D.js} +1 -1
- package/dist/esm/index.js +9 -8
- package/dist/esm/{invoice-S1KahJ_Z.js → invoice-CO-iqlni.js} +3 -3
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{localization-BIh-4pc_.js → localization-DHM91diu.js} +701 -41
- package/dist/esm/{paypal-DNfvnuUU.js → paypal-BfW5aLJw.js} +4 -4
- package/dist/esm/{placeTestOrder-CQaMKFOg.js → placeTestOrder-CyWUFhxD.js} +2 -2
- package/dist/esm/{renderCheckoutCurrency-C2Tw73uR.js → renderCheckoutCurrency-B31ZNkUv.js} +2 -2
- package/dist/esm/shouldRenderShortAddressCodeInput-Bc8k2vN0.js +19 -0
- package/dist/esm/{shouldShowLanguageSelect-CCD7gpSY.js → shouldShowLanguageSelect-DwSfSHar.js} +1 -1
- package/dist/esm/{submitGtag-df9AQ2zL.js → submitGtag-BEFrutel.js} +1 -1
- package/dist/esm/taxIdFields-ByEYfsO5.js +139 -0
- package/dist/esm/taxIdRules-xYlx7ZXW.js +47 -0
- package/dist/esm/{updateCheckoutSessionAttributes-4Jq6V4pO.js → updateCheckoutSessionAttributes-B0bQH0uw.js} +1 -1
- package/dist/esm/zonos-address-completion-dialog_7.entry.js +23 -28
- package/dist/esm/zonos-address-display_2.entry.js +3 -3
- package/dist/esm/zonos-address_4.entry.js +25 -28
- package/dist/esm/zonos-airwallex-payment.entry.js +7 -6
- package/dist/esm/zonos-badge.entry.js +1 -1
- package/dist/esm/zonos-banner.entry.js +1 -1
- package/dist/esm/zonos-button_3.entry.js +2 -2
- package/dist/esm/zonos-card_5.entry.js +8 -7
- package/dist/esm/zonos-cart-items_12.entry.js +147 -79
- package/dist/esm/zonos-checkbox_2.entry.js +2 -2
- package/dist/esm/zonos-checkout.entry.js +31 -20
- package/dist/esm/zonos-collapse.entry.js +1 -1
- package/dist/esm/zonos-collect-cart-items_3.entry.js +6 -5
- package/dist/esm/zonos-collect-finish_6.entry.js +12 -11
- package/dist/esm/zonos-collect.entry.js +9 -8
- package/dist/esm/zonos-controller.entry.js +7 -6
- package/dist/esm/zonos-country-flag.entry.js +2 -2
- package/dist/esm/zonos-country-select_4.entry.js +3 -3
- package/dist/esm/zonos-elements.js +1 -1
- package/dist/esm/zonos-hello-dialog.entry.js +4 -4
- package/dist/esm/zonos-hello.entry.js +4 -4
- package/dist/esm/zonos-input.entry.js +2 -2
- package/dist/esm/zonos-invoice-cart-items_2.entry.js +8 -7
- package/dist/esm/zonos-invoice-finish_5.entry.js +12 -11
- package/dist/esm/zonos-invoice.entry.js +9 -8
- package/dist/esm/zonos-language-select_2.entry.js +2 -2
- package/dist/esm/zonos-logo.entry.js +1 -1
- package/dist/esm/zonos-policy-consent_2.entry.js +7 -6
- package/dist/esm/zonos-shipping-rich-radio.entry.js +2 -2
- package/dist/esm/zonos-stripe-input.entry.js +2 -2
- package/dist/esm/zonos-text.entry.js +1 -1
- package/dist/esm/zonos-v-stack.entry.js +1 -1
- package/dist/esm/{zonosStore-msUlqmSD.js → zonosStore-BXP9FvIt.js} +2 -1
- package/dist/esm-es5/{TaxId-Cye-evFK.js → TaxId-DMIgN_sT.js} +2 -1
- package/dist/esm-es5/{cart-BoQp8Ema.js → cart-DmJkjiDE.js} +64 -53
- package/dist/esm-es5/{collect-Eo4gtyql.js → collect-BV5GTPmh.js} +1 -1
- package/dist/esm-es5/{debounce-BR3PaG8X.js → debounce-DHj2iHA1.js} +7 -7
- package/dist/esm-es5/debounce-DWqMT4lo.js +1 -0
- package/dist/esm-es5/getBorderRadius-BiGd45jw.js +8 -0
- package/dist/esm-es5/{getMissingRequiredShippingFields-Ks6_tpjn.js → getMissingRequiredShippingFields-DljgpDZe.js} +3 -3
- package/dist/esm-es5/{hasInclusivePrice-CbEfIhI5.js → hasInclusivePrice-DhGXpH2D.js} +1 -1
- package/dist/esm-es5/index.js +11 -11
- package/dist/esm-es5/{invoice-S1KahJ_Z.js → invoice-CO-iqlni.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/localization-DHM91diu.js +348 -0
- package/dist/esm-es5/{paypal-DNfvnuUU.js → paypal-BfW5aLJw.js} +1 -1
- package/dist/esm-es5/{placeTestOrder-CQaMKFOg.js → placeTestOrder-CyWUFhxD.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-C2Tw73uR.js → renderCheckoutCurrency-B31ZNkUv.js} +2 -2
- package/dist/esm-es5/shouldRenderShortAddressCodeInput-Bc8k2vN0.js +8 -0
- package/dist/esm-es5/{shouldShowLanguageSelect-CCD7gpSY.js → shouldShowLanguageSelect-DwSfSHar.js} +1 -1
- package/dist/esm-es5/{submitGtag-df9AQ2zL.js → submitGtag-BEFrutel.js} +1 -1
- package/dist/esm-es5/taxIdFields-ByEYfsO5.js +46 -0
- package/dist/esm-es5/taxIdRules-xYlx7ZXW.js +6 -0
- package/dist/esm-es5/{updateCheckoutSessionAttributes-4Jq6V4pO.js → updateCheckoutSessionAttributes-B0bQH0uw.js} +1 -1
- package/dist/esm-es5/zonos-address-completion-dialog_7.entry.js +253 -254
- package/dist/esm-es5/zonos-address-display_2.entry.js +1 -1
- package/dist/esm-es5/zonos-address_4.entry.js +8 -9
- package/dist/esm-es5/zonos-airwallex-payment.entry.js +1 -1
- package/dist/esm-es5/zonos-badge.entry.js +1 -1
- package/dist/esm-es5/zonos-banner.entry.js +1 -1
- package/dist/esm-es5/zonos-button_3.entry.js +1 -1
- package/dist/esm-es5/zonos-card_5.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_12.entry.js +40 -26
- package/dist/esm-es5/zonos-checkbox_2.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +7 -7
- package/dist/esm-es5/zonos-collapse.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
- package/dist/esm-es5/zonos-collect.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +2 -2
- package/dist/esm-es5/zonos-elements.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-input.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +2 -2
- package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice.entry.js +1 -1
- package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
- package/dist/esm-es5/zonos-logo.entry.js +1 -1
- package/dist/esm-es5/zonos-policy-consent_2.entry.js +1 -1
- package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
- package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
- package/dist/esm-es5/zonos-text.entry.js +1 -1
- package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
- package/dist/esm-es5/{zonosStore-msUlqmSD.js → zonosStore-BXP9FvIt.js} +1 -1
- package/dist/scripts/index.d.ts +97 -1
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.d.ts +4 -0
- package/dist/types/components/store/checkout/stripe.d.ts +9 -0
- package/dist/types/components/store/translationStore/strings.arabic.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.base.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.chinese.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.danish.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.dutch.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.french.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.german.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.hebrew.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.indonesian.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.italian.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.japanese.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.korean.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.norwegian.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.polish.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.portuguese.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.russian.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.spanish.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.swedish.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.turkish.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +34 -1
- package/dist/types/components/store/zonosStore.d.ts +2 -1
- package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +4 -1
- package/dist/types/components/stripe/zonos-custom-address/zonos-custom-address.d.ts +4 -1
- package/dist/types/components/utils/checkout/getCheckoutTaxIdPayload.d.ts +6 -0
- package/dist/types/components/utils/checkout/getTaxIdFieldState.d.ts +18 -0
- package/dist/types/components/utils/checkout/isHostedVsNativeTestAllowed.d.ts +11 -0
- package/dist/types/components/utils/checkout/itemCustomization.d.ts +23 -0
- package/dist/types/components/utils/checkout/parseItemCustomizations.d.ts +7 -0
- package/dist/types/components/utils/checkout/resolveTaxIdSelection.d.ts +12 -0
- package/dist/types/components/utils/checkout/shouldRenderTaxIdInput.d.ts +2 -1
- package/dist/types/components/utils/checkout/taxIdFields.d.ts +11 -0
- package/dist/types/components/utils/taxId/taxIdRules.d.ts +37 -0
- package/dist/types/components/utils/taxIdValidationResult.d.ts +8 -2
- package/dist/types/components.d.ts +22 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types/checkout/TaxId.d.ts +45 -0
- package/dist/types/types/checkout/api/CalculateLandedCost.d.ts +11 -0
- package/dist/types/types/checkout/api/CreateParty.d.ts +2 -0
- package/dist/types/types/checkout/itemCustomization.d.ts +4 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/utils/ZonosSettings.d.ts +5 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-7bd99479.system.entry.js → p-064d8829.system.entry.js} +26 -26
- package/dist/zonos-elements/p-107f287b.entry.js +1 -0
- package/dist/zonos-elements/{p-51400242.system.entry.js → p-1199baef.system.entry.js} +3 -3
- package/dist/zonos-elements/p-12b24ebb.entry.js +1 -0
- package/dist/zonos-elements/{p-9c33f7ed.system.entry.js → p-189cc594.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d3d0656a.entry.js → p-1a5acbcd.entry.js} +1 -1
- package/dist/zonos-elements/{p-11defdca.system.entry.js → p-1cc42a98.system.entry.js} +18 -18
- package/dist/zonos-elements/p-1e6db427.entry.js +1 -0
- package/dist/zonos-elements/{p-5016d71b.system.entry.js → p-1fda4aec.system.entry.js} +132 -117
- package/dist/zonos-elements/{p-756d303f.system.entry.js → p-20eb00de.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-5967a1c1.system.entry.js → p-216a908d.system.entry.js} +5 -5
- package/dist/zonos-elements/p-25eb99d4.entry.js +1 -0
- package/dist/zonos-elements/{p-23352709.system.entry.js → p-2b63865a.system.entry.js} +4 -4
- package/dist/zonos-elements/{p-6db7c0b1.system.entry.js → p-2ca826b9.system.entry.js} +2 -2
- package/dist/zonos-elements/{p-6c41b00c.entry.js → p-2d513aa3.entry.js} +1 -1
- package/dist/zonos-elements/{p-c961caaf.entry.js → p-3e705c9b.entry.js} +1 -1
- package/dist/zonos-elements/{p-acd50b0b.entry.js → p-4612facd.entry.js} +1 -1
- package/dist/zonos-elements/{p-5b80aff2.system.entry.js → p-46a839d2.system.entry.js} +24 -24
- package/dist/zonos-elements/p-46b9f0cf.entry.js +1 -0
- package/dist/zonos-elements/{p-244e0302.system.entry.js → p-4715045c.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d168023b.entry.js → p-4917b74d.entry.js} +1 -1
- package/dist/zonos-elements/{p-0b81f8b9.system.entry.js → p-53eac12f.system.entry.js} +14 -14
- package/dist/zonos-elements/{p-17c7ea4a.system.entry.js → p-55813e9f.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-06030d3b.system.entry.js → p-5585db86.system.entry.js} +45 -45
- package/dist/zonos-elements/p-59fc32af.entry.js +1 -0
- package/dist/zonos-elements/{p-193d9722.entry.js → p-61312d5b.entry.js} +1 -1
- package/dist/zonos-elements/p-636b71d4.entry.js +1 -0
- package/dist/zonos-elements/{p-155ed3d3.system.entry.js → p-6410fa11.system.entry.js} +24 -24
- package/dist/zonos-elements/{p-0fca452b.entry.js → p-65817880.entry.js} +1 -1
- package/dist/zonos-elements/p-678b9214.entry.js +1 -0
- package/dist/zonos-elements/p-6e691736.entry.js +1 -0
- package/dist/zonos-elements/p-6vSUiBfr.system.js +348 -0
- package/dist/zonos-elements/p-74659d88.entry.js +1 -0
- package/dist/zonos-elements/p-7dc7f328.entry.js +1 -0
- package/dist/zonos-elements/{p-55916c90.entry.js → p-7f1bea9b.entry.js} +1 -1
- package/dist/zonos-elements/{p-1c150f26.entry.js → p-821e413a.entry.js} +1 -1
- package/dist/zonos-elements/{p-c403f004.system.entry.js → p-82e45d0c.system.entry.js} +1 -1
- package/dist/zonos-elements/p-84e76348.entry.js +1 -0
- package/dist/zonos-elements/{p-1409de3b.system.entry.js → p-88e20e99.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-195f6e38.system.entry.js → p-89a3c4db.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-4679f0ec.entry.js → p-8f9d8795.entry.js} +1 -1
- package/dist/zonos-elements/p-8fa6cfff.entry.js +1 -0
- package/dist/zonos-elements/{p-92fe9a1f.system.entry.js → p-902cca23.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-0a4a7742.system.entry.js → p-93860183.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-69c3e367.system.entry.js → p-941a95a1.system.entry.js} +10 -10
- package/dist/zonos-elements/{p-b5882fbb.system.entry.js → p-9449b4f4.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-6abec43f.system.entry.js → p-960070d0.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-1bac5ac1.system.entry.js → p-990fcf81.system.entry.js} +1 -1
- package/dist/zonos-elements/p-BD-9rD53.js +1 -0
- package/dist/zonos-elements/p-BMPYH-LT.js +1 -0
- package/dist/zonos-elements/{p-DI2vXnXc.system.js → p-BrQ8n8NS.system.js} +3 -3
- package/dist/zonos-elements/p-Bu9WCfUC.system.js +2 -2
- package/dist/zonos-elements/{p-CUaf1cEg.js → p-C70h5mKA.js} +1 -1
- package/dist/zonos-elements/{p-B4Ufchqh.system.js → p-C9XLkmmb.system.js} +3 -3
- package/dist/zonos-elements/{p-CZD8WvyY.system.js → p-CBUz18kA.system.js} +1 -1
- package/dist/zonos-elements/{p-kaOxUR9u.system.js → p-CGNVm52g.system.js} +6 -6
- package/dist/zonos-elements/p-CHKKvuiz.js +1 -0
- package/dist/zonos-elements/{p-0mGRBGcf.js → p-CMo3ZweU.js} +1 -1
- package/dist/zonos-elements/p-CTiqplrr.js +1 -0
- package/dist/zonos-elements/p-CYxMfUL7.system.js +1 -0
- package/dist/zonos-elements/{p-D4MevhAL.system.js → p-CbhN65lj.system.js} +3 -3
- package/dist/zonos-elements/p-Ch1w0Lr7.js +1 -0
- package/dist/zonos-elements/{p-W82paT5F.js → p-CqB9AfBf.js} +1 -1
- package/dist/zonos-elements/p-CzKlS3E-.system.js +6 -0
- package/dist/zonos-elements/p-D1SmY_fZ.js +1 -0
- package/dist/zonos-elements/{p-sz4L-ZnB.js → p-D1e9zNDA.js} +1 -1
- package/dist/zonos-elements/{p-c9QtIdJX.js → p-D6xXnsM_.js} +1 -1
- package/dist/zonos-elements/{p-8PPEbm_0.system.js → p-DIab60nK.system.js} +12 -12
- package/dist/zonos-elements/{p-Cye-evFK.js → p-DMIgN_sT.js} +1 -1
- package/dist/zonos-elements/{p-DCS8qcL6.system.js → p-DQrMfUzi.system.js} +41 -41
- package/dist/zonos-elements/{p-BuU_p5DP.system.js → p-DTgUqgwV.system.js} +2 -2
- package/dist/zonos-elements/p-DW7I0zOF.js +1 -0
- package/dist/zonos-elements/p-DZdkJHK9.system.js +7 -0
- package/dist/zonos-elements/{p-XqkqjeNV.system.js → p-DgUrB-1a.system.js} +1 -1
- package/dist/zonos-elements/p-DiMEP3mh.js +1 -0
- package/dist/zonos-elements/p-DprOoI2W.system.js +528 -0
- package/dist/zonos-elements/{p-7abqRc9V.js → p-DpwmHU8R.js} +2 -2
- package/dist/zonos-elements/p-DqVePqqx.system.js +8 -0
- package/dist/zonos-elements/{p-Cby4EkFu.system.js → p-DsBuZ6ob.system.js} +2 -1
- package/dist/zonos-elements/{p-XDxdMlQl.system.js → p-Dtu_Japy.system.js} +39 -39
- package/dist/zonos-elements/p-Dwg61Ft_.js +1 -0
- package/dist/zonos-elements/p-U33isUJG.js +1 -0
- package/dist/zonos-elements/{p-Be3Hpms1.system.js → p-XoQH3S7Z.system.js} +1 -1
- package/dist/zonos-elements/{p-474e8a92.system.entry.js → p-a1022808.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-83aa1c8c.entry.js → p-ad04bba2.entry.js} +1 -1
- package/dist/zonos-elements/{p-a938c174.entry.js → p-b51010b9.entry.js} +1 -1
- package/dist/zonos-elements/{p-dfc87b10.system.entry.js → p-c33b8f6a.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-a40fd99b.system.entry.js → p-cccaad60.system.entry.js} +39 -40
- package/dist/zonos-elements/p-d3345b2c.entry.js +1 -0
- package/dist/zonos-elements/{p-249c1ee1.system.entry.js → p-d8f375da.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-2603dce0.entry.js → p-e216cc8c.entry.js} +1 -1
- package/dist/zonos-elements/{p-b79036fc.entry.js → p-e7fdb2c9.entry.js} +1 -1
- package/dist/zonos-elements/p-ebe157b5.entry.js +1 -0
- package/dist/zonos-elements/p-ef5344ea.entry.js +1 -0
- package/dist/zonos-elements/{p-be1237fc.system.entry.js → p-f3d9a380.system.entry.js} +97 -97
- package/dist/zonos-elements/{p-31043c2e.system.entry.js → p-f5f95990.system.entry.js} +296 -297
- package/dist/zonos-elements/p-fda89981.system.entry.js +13 -0
- package/dist/zonos-elements/{p-d4d2b39e.entry.js → p-fddf3556.entry.js} +1 -1
- package/dist/zonos-elements/p-iAIzUA4k.js +1 -0
- package/dist/zonos-elements/{p-BpDCLBwW.js → p-n5PZKz1k.js} +1 -1
- package/dist/zonos-elements/{p-DoEHepOc.system.js → p-ojtNq-r5.system.js} +1 -1
- package/dist/zonos-elements/{p-C_z9WL8a.js → p-r-YGHhLa.js} +1 -1
- package/dist/zonos-elements/{p-CBx5nYet.system.js → p-vTIygnHq.system.js} +1 -1
- package/dist/zonos-elements/{p-DQZncB2d.system.js → p-zsTASoh2.system.js} +3 -3
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/item-customization.d.ts +25 -0
- package/item-customization.js +52 -0
- package/package.json +7 -4
- package/dist/cjs/shouldRenderTaxIdInput-TxekHCp7.js +0 -43
- package/dist/esm/shouldRenderTaxIdInput-CKyZ6Zni.js +0 -40
- package/dist/esm/throttle-Cvlvb-dm.js +0 -85
- package/dist/esm-es5/debounce-CrmpwbEE.js +0 -1
- package/dist/esm-es5/getBorderRadius-DYfkeXdx.js +0 -8
- package/dist/esm-es5/localization-BIh-4pc_.js +0 -348
- package/dist/esm-es5/shouldRenderTaxIdInput-CKyZ6Zni.js +0 -17
- package/dist/esm-es5/throttle-Cvlvb-dm.js +0 -46
- package/dist/zonos-elements/p-0457f579.entry.js +0 -1
- package/dist/zonos-elements/p-06fe2939.entry.js +0 -1
- package/dist/zonos-elements/p-24f3c547.entry.js +0 -1
- package/dist/zonos-elements/p-34656e6c.entry.js +0 -1
- package/dist/zonos-elements/p-39ee1558.entry.js +0 -1
- package/dist/zonos-elements/p-3a2da031.entry.js +0 -1
- package/dist/zonos-elements/p-4806b264.system.entry.js +0 -13
- package/dist/zonos-elements/p-725e29bb.entry.js +0 -1
- package/dist/zonos-elements/p-BGktDPwA.system.js +0 -1
- package/dist/zonos-elements/p-Bi-s0fp_.system.js +0 -17
- package/dist/zonos-elements/p-CEK_Wk6v.system.js +0 -7
- package/dist/zonos-elements/p-CFbfEmjN.js +0 -1
- package/dist/zonos-elements/p-CcJF6xhQ.js +0 -1
- package/dist/zonos-elements/p-Cxuiqv1I.js +0 -1
- package/dist/zonos-elements/p-D-bZg-Pc.js +0 -1
- package/dist/zonos-elements/p-DOD2I44l.system.js +0 -348
- package/dist/zonos-elements/p-DS-qw_qc.system.js +0 -517
- package/dist/zonos-elements/p-DZ2mevDK.js +0 -1
- package/dist/zonos-elements/p-DnjGkbEy.js +0 -1
- package/dist/zonos-elements/p-FRWZayxL.js +0 -1
- package/dist/zonos-elements/p-Mrz_lnC1.js +0 -1
- package/dist/zonos-elements/p-ad9ff14c.entry.js +0 -1
- package/dist/zonos-elements/p-bb3546c0.entry.js +0 -1
- package/dist/zonos-elements/p-c1cbfdba.entry.js +0 -1
- package/dist/zonos-elements/p-c47ce656.entry.js +0 -1
- package/dist/zonos-elements/p-c9d5d8f1.entry.js +0 -1
- package/dist/zonos-elements/p-clDfq9AL.js +0 -1
- package/dist/zonos-elements/p-d74bc3e8.entry.js +0 -1
- package/dist/zonos-elements/p-d8b312e5.entry.js +0 -1
- package/dist/zonos-elements/p-db87b0dd.entry.js +0 -1
- package/dist/zonos-elements/p-defc2d18.entry.js +0 -1
- package/dist/zonos-elements/p-rVp8hgWw.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
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{d(o.next(e))}catch(e){i(e)}}function s(e){try{d(o["throw"](e))}catch(e){i(e)}}function d(e){e.done?r(e.value):n(e.value).then(a,s)}d((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=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(t){return d([e,t])}}function d(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}}};var __spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++){if(i||!(o in t)){if(!i)i=Array.prototype.slice.call(t,0,o);i[o]=t[o]}}return e.concat(i||Array.prototype.slice.call(t))};import{c as createStore,z as zonosStore}from"./zonosStore-
|
|
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{d(o.next(e))}catch(e){i(e)}}function s(e){try{d(o["throw"](e))}catch(e){i(e)}}function d(e){e.done?r(e.value):n(e.value).then(a,s)}d((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=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(t){return d([e,t])}}function d(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}}};var __spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++){if(i||!(o in t)){if(!i)i=Array.prototype.slice.call(t,0,o);i[o]=t[o]}}return e.concat(i||Array.prototype.slice.call(t))};import{c as createStore,z as zonosStore,e as getShouldRequirePeruTaxId}from"./zonosStore-BXP9FvIt.js";import{s as storageStore,t as translate,m as getOverridenZCountry,l as localizationStore,f as filterValidTests,e as storageStoreSetEnabledVariantTestKeys}from"./localization-DHM91diu.js";import{b as isPeruTaxIdActive,e as taxIdTypeOptionsForCheckout}from"./taxIdRules-xYlx7ZXW.js";import{e as euCountryCodes,i as isCountryRequireTaxId}from"./TaxId-DMIgN_sT.js";import{l as log,b as allLogs}from"./VarianceTest-BJmZPrZl.js";import{h as handleFetch,l as logError,f as fallbackApiList,g as getIsTestMode,a as getIsStagingMode,s as sendErrorLog,j as jsonParse}from"./handleFetch-D5GYDF-O.js";import{i as isDarkColor}from"./isDarkColor-YdrG78th.js";import{g as getBorderRadius}from"./getBorderRadius-BiGd45jw.js";var getCheckoutSession=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o;return __generator(this,(function(n){switch(n.label){case 0:if(!storageStore.checkoutSessionId){return[2/*return*/,{errors:[{message:"No checkout session id found"}],json:null}]}e=new URLSearchParams;e.set("checkoutSessionId",storageStore.checkoutSessionId);return[4/*yield*/,handleFetch("/api/zonos-elements/get-checkout-session?".concat(e.toString()))];case 1:t=n.sent(),r=t.errors,o=t.json;return[2/*return*/,{errors:r,json:o}]}}))}))};var _o=createStore((function(){return{amountToApply:null,appliedAmount:null,availableBalance:null,error:null,isApplying:false,isEnabled:false,orderIdCreated:null,remainingBalance:null,useFullBalance:true}})),reset$2=_o.reset,storeCreditStore=_o.state;
|
|
2
2
|
/**
|
|
3
3
|
* Reset store credit store to initial state
|
|
4
4
|
*/var storeCreditStoreReset=function(){reset$2()};
|
|
@@ -53,7 +53,7 @@ return storeCreditStore.amountToApply!==null&&storeCreditStore.amountToApply>0&&
|
|
|
53
53
|
/**
|
|
54
54
|
* Create an order paid entirely by store credit.
|
|
55
55
|
* Should only be called when `storeCreditStoreCoversFullAmount()` is true.
|
|
56
|
-
*/var storeCreditStoreCreateOrder=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,d,c,
|
|
56
|
+
*/var storeCreditStoreCreateOrder=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,d,l,c,d;return __generator(this,(function(u){switch(u.label){case 0:o=storageStore.checkoutSessionId;if(!o){n="No checkout session found";logError(n);storeCreditStore.error=n;return[2/*return*/,{error:n,orderId:null,success:false}]}log("Creating store credit order","info",{checkoutSessionId:o});u.label=1;case 1:u.trys.push([1,3,,4]);return[4/*yield*/,handleFetch("/api/zonos-elements/store-credit/order-create",{body:{checkoutSessionId:o},method:"POST"})];case 2:i=u.sent(),a=i.errors,s=i.json;if(a.length>0||!s){d=((e=a[0])===null||e===void 0?void 0:e.message)||"Failed to create store credit order";logError(d);storeCreditStore.error=d;return[2/*return*/,{error:d,orderId:null,success:false}]}l=((r=(t=s.checkoutSessionStoreCreditOrderCreate)===null||t===void 0?void 0:t.order)===null||r===void 0?void 0:r.id)||null;storeCreditStore.orderIdCreated=l;log("Store credit order created","info",{orderId:l});return[2/*return*/,{error:null,orderId:l,success:true}];case 3:c=u.sent();d=c instanceof Error?c.message:"Failed to create store credit order";logError(d);storeCreditStore.error=d;return[2/*return*/,{error:d,orderId:null,success:false}];case 4:return[2/*return*/]}}))}))};var POLICY_ORDER=["termsAndConditions","privacyPolicy","refundPolicy","shippingPolicy","warrantyPolicy"];
|
|
57
57
|
// Reuses the lowercase `'Privacy policy'` key already translated in 19 locales
|
|
58
58
|
// (also used by the checkout footer) — the other four are new keys that follow
|
|
59
59
|
// the same lowercase convention for visual consistency in the joined consent line.
|
|
@@ -69,6 +69,17 @@ var POLICY_NAME_KEY={privacyPolicy:"Privacy policy",refundPolicy:"Refund policy"
|
|
|
69
69
|
* so the consent UI works when zonos-elements is consumed via the npm package,
|
|
70
70
|
* where `cartSettings` is not populated.
|
|
71
71
|
*/var getEnabledPolicies=function(){var e=zonosStore.checkoutSettings.merchantPolicyLinks;if(!e){return[]}return POLICY_ORDER.reduce((function(t,r){var o,n;var i=(n=(o=e[r])===null||o===void 0?void 0:o.link)===null||n===void 0?void 0:n.trim();if(!i||!/^https?:\/\//i.test(i)){return t}t.push({key:r,name:translate(POLICY_NAME_KEY[r]),url:i});return t}),[])};var isPolicyConsentRequired=function(){return getEnabledPolicies().length>0};
|
|
72
|
+
/**
|
|
73
|
+
* Checks if the tax ID input should be rendered based on the company name and country code.
|
|
74
|
+
*/var shouldRenderTaxIdInput=function(e){var t=e.companyName,r=e.countryCode,o=e.shouldRequirePeruTaxId;if(isPeruTaxIdActive({countryCode:r,shouldRequirePeruTaxId:o})){return true}
|
|
75
|
+
// Only show the tax ID input if the country is in the EU and the company name is provided
|
|
76
|
+
if(euCountryCodes.includes(r)){return t.trim().length>0}
|
|
77
|
+
// If country require tax id, show the input
|
|
78
|
+
return isCountryRequireTaxId(r)};
|
|
79
|
+
/** Whether the field is showing, and which of this country's types is selected. */var resolveTaxIdSelection=function(e){var t=e.companyName,r=e.countryCode,o=e.shouldRequirePeruTaxId,n=e.taxIdType;var i;var a=taxIdTypeOptionsForCheckout({countryCode:r,shouldRequirePeruTaxId:o});var s=(i=a===null||a===void 0?void 0:a.find((function(e){return e.value===n})))!==null&&i!==void 0?i:null;var d=shouldRenderTaxIdInput({companyName:t,countryCode:r,shouldRequirePeruTaxId:o});return{rendered:d,selectedType:s,
|
|
80
|
+
// A multi-type country sends a number only after the shopper picks a type.
|
|
81
|
+
send:d&&(!a||!!s),typeOptions:a}};
|
|
82
|
+
/** Tax id to send for the destination, or null while the field is hidden. */var getCheckoutTaxIdPayload=function(e){var t=resolveTaxIdSelection({companyName:stripeStore.companyName,countryCode:e,shouldRequirePeruTaxId:getShouldRequirePeruTaxId(),taxIdType:stripeStore.taxIdType}),r=t.selectedType,o=t.send;if(!o){return null}return Object.assign({taxId:stripeStore.taxId},r?{taxIdType:r.value}:{})};
|
|
72
83
|
/**
|
|
73
84
|
* Extract first name and last name from the name string
|
|
74
85
|
* If first name and last name are provided, use them
|
|
@@ -76,49 +87,49 @@ var POLICY_NAME_KEY={privacyPolicy:"Privacy policy",refundPolicy:"Refund policy"
|
|
|
76
87
|
* If neither are provided, return an empty object
|
|
77
88
|
*/var extractName=function(e){var t=e.firstName,r=e.lastName,o=e.name;var n;if(!o&&!t&&!r){return{firstName:"",lastName:""}}
|
|
78
89
|
// Use first name and last name if they are provided
|
|
79
|
-
var i=(o===null||o===void 0?void 0:o.split(/\s+/))||[];var a=(t===null||t===void 0?void 0:t.trim())||((n=i[0])===null||n===void 0?void 0:n.trim())||"";var s=(r===null||r===void 0?void 0:r.trim())||i.slice(1).join(" ").trim()||"";return{firstName:a,lastName:s}};
|
|
90
|
+
var i=(o===null||o===void 0?void 0:o.split(/\s+/))||[];var a=(t===null||t===void 0?void 0:t.trim())||((n=i[0])===null||n===void 0?void 0:n.trim())||"";var s=(r===null||r===void 0?void 0:r.trim())||i.slice(1).join(" ").trim()||"";return{firstName:a,lastName:s}};var shipToTaxIdFields=function(e){var t=getCheckoutTaxIdPayload(e);if(!t){return{}}return Object.assign({shipToTaxId:t.taxId},t.taxIdType?{shipToTaxIdType:t.taxIdType}:{})};
|
|
80
91
|
/**
|
|
81
92
|
* Extract value from translated object
|
|
82
|
-
*/var getTranslatedAddress=function(e){var t=e.currentAddress,r=e.translatedAddress;var o,n,i,a,s,d;var
|
|
93
|
+
*/var getTranslatedAddress=function(e){var t=e.currentAddress,r=e.translatedAddress;var o,n,i,a,s,d;var l=t.value.address,c=l.city,u=l.country,S=l.line1,v=l.line2,p=l.postal_code,f=l.state;var h=t.value.name||[t.value.firstName,t.value.lastName].join(" ");return{city:((o=r.city)===null||o===void 0?void 0:o[c])||c,country:u,line1:((n=r.line1)===null||n===void 0?void 0:n[S])||S,line2:((i=r.line2)===null||i===void 0?void 0:i[v||""])||v||"",name:((a=r.name)===null||a===void 0?void 0:a[h])||h,phone:t.value.phone||"",postal_code:((s=r.postal_code)===null||s===void 0?void 0:s[p])||p,state:((d=r.state)===null||d===void 0?void 0:d[f])||f}};
|
|
83
94
|
/**
|
|
84
95
|
* Similar to prepCalculateLandedCost except it only uses cart ID
|
|
85
96
|
*/var prepCartCalculateLandedCost=function(e){var t;var r=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";
|
|
86
97
|
// maybe we don't need email now for prefetch the landed cost
|
|
87
98
|
var o=stripeStore.stripeLinkEventData;var n=stripeStore.stripeAddressEventData;var i=stripeStore.stripeShippingSameAsBilling?stripeStore.stripeAddressEventData:stripeStore.stripeBillingAddressEventData;if(!n||!i){throw new Error("Missing stripe address data")}
|
|
88
99
|
// Attempt to get translated address if available
|
|
89
|
-
var a=getTranslatedAddress({currentAddress:n,translatedAddress:stripeStore.translatedAddress.address});var s=extractName({name:a.name}),d=s.firstName,
|
|
100
|
+
var a=getTranslatedAddress({currentAddress:n,translatedAddress:stripeStore.translatedAddress.address});var s=extractName({name:a.name}),d=s.firstName,l=s.lastName;var c=getTranslatedAddress({currentAddress:i,translatedAddress:stripeStore.translatedAddress.address});var u=extractName({name:c.name}),S=u.firstName,v=u.lastName;var p=getOverridenZCountry()||"US";var f=shipToTaxIdFields(a.country);return Object.assign(Object.assign({billingAddress:{addressLine1:c.line1,addressLine2:c.line2||"",city:c.city,country:c.country,postalCode:c.postal_code,state:c.state},billingContact:{
|
|
90
101
|
// firstName and lastName should be valid now since stripe only mark
|
|
91
102
|
// the address as complete when both fields are filled.
|
|
92
|
-
firstName:S,lastName:v,phone:
|
|
103
|
+
firstName:S,lastName:v,phone:c.phone},
|
|
93
104
|
// Use the first item's currency code
|
|
94
|
-
cartCurrencyCode:(t=cartStore.items[0])===null||t===void 0?void 0:t.currencyCode,cartId:e,checkoutSessionCountry:p
|
|
105
|
+
cartCurrencyCode:(t=cartStore.items[0])===null||t===void 0?void 0:t.currencyCode,cartId:e,checkoutSessionCountry:p,checkoutSessionId:storageStore.checkoutSessionId||"",contact:{companyName:stripeStore.companyName,email:o===null||o===void 0?void 0:o.value.email,
|
|
95
106
|
// firstName and lastName should be valid now since stripe only mark
|
|
96
107
|
// the address as complete when both fields are filled.
|
|
97
|
-
firstName:d,lastName:
|
|
108
|
+
firstName:d,lastName:l,phone:a.phone},isTest:!!r,landedCostAdjustments:cartStore.promoCode?[{amount:0,productId:null,promoCode:cartStore.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToShortAddressCode:stripeStore.shortAddressCode},f),{shippingAddress:{addressLine1:a.line1,addressLine2:a.line2,city:a.city,country:a.country,postalCode:a.postal_code,state:a.state}})};var prepCalculateLandedCost=function(){var e=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";
|
|
98
109
|
// maybe we don't need email now for prefetch the landed cost
|
|
99
110
|
var t=stripeStore.stripeLinkEventData;var r=stripeStore.stripeAddressEventData;var o=stripeStore.stripeShippingSameAsBilling?stripeStore.stripeAddressEventData:stripeStore.stripeBillingAddressEventData;log({stripeAddressData:r,stripeBillingAddressData:o},"info");if(!r||!o){throw new Error("Missing stripe address data")}
|
|
100
111
|
// Attempt to get translated address if available
|
|
101
|
-
var n=getTranslatedAddress({currentAddress:r,translatedAddress:stripeStore.translatedAddress.address});var i=extractName({name:n.name}),a=i.firstName,s=i.lastName;var d=getTranslatedAddress({currentAddress:o,translatedAddress:stripeStore.translatedAddress.address});var
|
|
112
|
+
var n=getTranslatedAddress({currentAddress:r,translatedAddress:stripeStore.translatedAddress.address});var i=extractName({name:n.name}),a=i.firstName,s=i.lastName;var d=getTranslatedAddress({currentAddress:o,translatedAddress:stripeStore.translatedAddress.address});var l=extractName({name:d.name}),c=l.firstName,u=l.lastName;var S=cartStore.adjustments.map((function(e){return{amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}}));var v=cartStore.promoCode?__spreadArray([{amount:0,productId:null,promoCode:cartStore.promoCode,sku:null,type:"PROMO_CODE"}],S,true):S;var p=shipToTaxIdFields(n.country);return Object.assign(Object.assign({billingAddress:{addressLine1:d.line1,addressLine2:d.line2||"",city:d.city,country:d.country,postalCode:d.postal_code,state:d.state},billingContact:{
|
|
102
113
|
// firstName and lastName should be valid now since stripe only mark
|
|
103
114
|
// the address as complete when both fields are filled.
|
|
104
|
-
firstName:
|
|
115
|
+
firstName:c,lastName:u,phone:d.phone},checkoutSessionId:storageStore.checkoutSessionId||"",contact:{companyName:stripeStore.companyName,email:t===null||t===void 0?void 0:t.value.email,
|
|
105
116
|
// firstName and lastName should be valid now since stripe only mark
|
|
106
117
|
// the address as complete when both fields are filled.
|
|
107
|
-
firstName:a,lastName:s,phone:n.phone},isTest:e,items:cartStore.items,landedCostAdjustments:v,shipToShortAddressCode:stripeStore.shortAddressCode,
|
|
118
|
+
firstName:a,lastName:s,phone:n.phone},isTest:e,items:cartStore.items,landedCostAdjustments:v,shipToShortAddressCode:stripeStore.shortAddressCode},p),{shippingAddress:{addressLine1:n.line1,addressLine2:n.line2,city:n.city,country:n.country,postalCode:n.postal_code,state:n.state}})};var triggerBuildLandedCost=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a,s,d,l,c;return __generator(this,(function(u){switch(u.label){case 0:a=prepCalculateLandedCost();return[4/*yield*/,e({billingAddress:a.billingAddress,billingContact:a.billingContact,checkoutSessionId:a.checkoutSessionId,contact:a.contact,landedCostAdjustments:a.landedCostAdjustments,
|
|
108
119
|
// zonosApiKey should always be available
|
|
109
120
|
publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:a.shippingAddress,zonosApiRoute:fallbackApiList["vercel"]},{promoCode:cartStore.promoCode})];case 1:s=u.sent();if(!s||
|
|
110
121
|
// Only show errors if there are no rate back (checkoutSessionWorkflow) and there are errors
|
|
111
|
-
!((t=s.checkoutSessionWorkflow)===null||t===void 0?void 0:t.length)&&((r=s.errors)===null||r===void 0?void 0:r.length)){throw new Error("Failed to build landed cost: ".concat(((n=(o=s===null||s===void 0?void 0:s.errors)===null||o===void 0?void 0:o[0])===null||n===void 0?void 0:n.message)||"Unknown error"))}return[4/*yield*/,handleFetch("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:d=u.sent(),
|
|
122
|
+
!((t=s.checkoutSessionWorkflow)===null||t===void 0?void 0:t.length)&&((r=s.errors)===null||r===void 0?void 0:r.length)){throw new Error("Failed to build landed cost: ".concat(((n=(o=s===null||s===void 0?void 0:s.errors)===null||o===void 0?void 0:o[0])===null||n===void 0?void 0:n.message)||"Unknown error"))}return[4/*yield*/,handleFetch("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:d=u.sent(),l=d.errors,c=d.json;if(!c||l.length){throw new Error("Invalid landed cost object: ".concat(((i=l.find(Boolean))===null||i===void 0?void 0:i.message)||"Unknown error"))}return[2/*return*/,s]}}))}))};var calculateLandedCost=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a,s;return __generator(this,(function(d){switch(d.label){case 0:r=zonosStore.checkoutSettings.buildLandedCost;if(!r)return[3/*break*/,2];return[4/*yield*/,triggerBuildLandedCost(r)];case 1:o=d.sent();return[2/*return*/,o];case 2:return[4/*yield*/,handleFetch("/api/zonos-elements/calculate-landed-cost",{body:prepCalculateLandedCost(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:n=d.sent(),i=n.errors,a=n.json;if(i.length||!a){s=((t=i[0])===null||t===void 0?void 0:t.message)==="The user aborted a request.";if(s){throw new Error("The landed cost calculation request was aborted to initiate a new one.")}
|
|
112
123
|
// We want to show any successful quotes even if there are errors
|
|
113
124
|
i.forEach((function(e){
|
|
114
125
|
// eslint-disable-next-line no-console
|
|
115
|
-
console.warn("Error calculating landed cost: ".concat(e.message))}));if(!a){throw new Error("Failed to calculate landed cost")}return[2/*return*/,a]}return[2/*return*/,a]}}))}))};var cartCalculateLandedCost=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,c
|
|
126
|
+
console.warn("Error calculating landed cost: ".concat(e.message))}));if(!a){throw new Error("Failed to calculate landed cost")}return[2/*return*/,a]}return[2/*return*/,a]}}))}))};var cartCalculateLandedCost=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,l,c;var u=e.abortController,S=e.cartId;return __generator(this,(function(e){switch(e.label){case 0:return[4/*yield*/,handleFetch("/api/zonos-elements/cart-calculate-landed-cost",{body:prepCartCalculateLandedCost(S),method:"POST",signal:u===null||u===void 0?void 0:u.signal})];case 1:a=e.sent(),s=a.errors,d=a.json;if(s.length||!d){l=typeof((t=s[0])===null||t===void 0?void 0:t.message)==="string"&&(((r=s[0])===null||r===void 0?void 0:r.message)==="The user aborted a request."||((o=s[0])===null||o===void 0?void 0:o.message.includes("signal is aborted"))||((n=s[0])===null||n===void 0?void 0:n.message.includes("The operation was aborted"))||((i=s[0])===null||i===void 0?void 0:i.message.includes("Fetch is aborted")));c=l?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost";throw new Error(c)}return[2/*return*/,d]}}))}))};var __rest=undefined&&undefined.__rest||function(e,t){var r={};for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0)r[o]=e[o];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var n=0,o=Object.getOwnPropertySymbols(e);n<o.length;n++){if(t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n]))r[o[n]]=e[o[n]]}return r};var calculateLandedCostNormalized=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i;return __generator(this,(function(a){switch(a.label){case 0:t=window.Zonos.cartId;if(!!t)return[3/*break*/,2];return[4/*yield*/,calculateLandedCost(e)];case 1:r=a.sent();return[2/*return*/,r];case 2:return[4/*yield*/,cartCalculateLandedCost({abortController:e,cartId:t})];case 3:o=a.sent(),n=o.cartWorkflow,i=__rest(o,["cartWorkflow"]);return[2/*return*/,Object.assign(Object.assign({},i),{itemCreateWorkflow:n.items})]}}))}))};var trackConversionEvent=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,l;var c=e.checkoutSessionId,u=e.eventName,S=e.metadata;return __generator(this,(function(e){switch(e.label){case 0:o=Date.now();n=__spreadArray([],window.Zonos.trackEventLogs,true);window.Zonos.trackEventLogs.push({checkoutSessionId:c,eventCreated:o,eventName:u});i=
|
|
116
127
|
// if the url includes zonos.com and not hosted checkout (checkout.zonos.com), it means we are on the development site (dashboard, preview zonos domain or main zonos.com)
|
|
117
128
|
window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!((t=window.Zonos)===null||t===void 0?void 0:t.zonosQaUrl)||!!((r=window.Zonos)===null||r===void 0?void 0:r.debug);a=getIsTestMode()||getIsStagingMode();if((a||i)&&
|
|
118
129
|
// if found, it means we want to test the conversion event in development site, or test mode and staging mode
|
|
119
|
-
!window.Zonos.zonosConversionTest){return[2/*return*/]}s=localizationStore.selectedCountryCode;d=zonosStore.organizationId;if(!
|
|
130
|
+
!window.Zonos.zonosConversionTest){return[2/*return*/]}s=localizationStore.selectedCountryCode;d=zonosStore.organizationId;if(!c){void sendErrorLog({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(u,'" - No checkout session id found')],metadata:{allLogs:allLogs,checkoutSessionId:c,eventName:u,metadata:S,organizationId:d,trackEventLogs:n}});
|
|
120
131
|
// checkoutSessionId is required for tracking conversion events to work properly
|
|
121
|
-
return[2/*return*/]}if(!d){void sendErrorLog({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(u,'" - No organization id found')],metadata:{allLogs:allLogs,checkoutSessionId:
|
|
132
|
+
return[2/*return*/]}if(!d){void sendErrorLog({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(u,'" - No organization id found')],metadata:{allLogs:allLogs,checkoutSessionId:c,eventName:u,metadata:S,organizationId:d,trackEventLogs:n}})}l={checkoutSessionId:c,countryCode:s,eventCreated:o,eventName:u,metadata:Object.assign(Object.assign({},S),{trackEventLogs:n}),organizationId:d};return[4/*yield*/,handleFetch("/api/zonos-elements/track-conversion-event",{body:l,method:"POST"})];case 1:e.sent();return[2/*return*/]}}))}))};
|
|
122
133
|
/**
|
|
123
134
|
* This function generates an object that contains the fields of an address that have invalid characters.
|
|
124
135
|
*
|
|
@@ -149,9 +160,9 @@ return Object.keys(o).length?o:undefined};
|
|
|
149
160
|
// only translate if both address and billing address are ready
|
|
150
161
|
if(!a||!s){return null}
|
|
151
162
|
// only translate if there are invalid characters
|
|
152
|
-
if(!t&&!r){return null}var d=o.value;var
|
|
163
|
+
if(!t&&!r){return null}var d=o.value;var l=(n===null||n===void 0?void 0:n.value)||null;
|
|
153
164
|
// Returns undefined if the name is Latin so it won't be included in the request body
|
|
154
|
-
var
|
|
165
|
+
var c=extractName({firstName:d.firstName,lastName:d.lastName,name:d.name}),u=c.firstName,S=c.lastName;var v="".concat(u," ").concat(S);var p=extractName({firstName:l===null||l===void 0?void 0:l.firstName,lastName:l===null||l===void 0?void 0:l.lastName,name:(l===null||l===void 0?void 0:l.name)||""}),f=p.firstName,h=p.lastName;var m=f&&h?"".concat(f," ").concat(h):"";var g=d.address;var C=l===null||l===void 0?void 0:l.address;return{address:getExcludeAddressFieldsObject({address:Object.assign(Object.assign({},g),{name:v}),invalidAdddressList:t}),
|
|
155
166
|
// only include billing address if it's different from the shipping address
|
|
156
167
|
billingAddress:!i?getExcludeAddressFieldsObject({address:C?Object.assign(Object.assign({},C),{name:m}):null,invalidAdddressList:r}):undefined,destinationCountry:g.country}};
|
|
157
168
|
/**
|
|
@@ -168,13 +179,13 @@ paddingTop:"6px"},".Label--resting":{fontSize:zonosStore.appearance.fontSizeInpu
|
|
|
168
179
|
* Default to skip payment intent, only create payment intent when "skipPaymentIntent" in url's query params is set "0"
|
|
169
180
|
* @default true
|
|
170
181
|
*/
|
|
171
|
-
skipPaymentIntent:new URLSearchParams(window.location.search).get("skipPaymentIntent")==="0"?false:true,stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenAsyncAddressUpdate:null,stripeAddressUsedWhenFetchingLC:null,stripeAddressUsedWhenValidatingAddress:null,stripeBillingAddressElement:null,stripeBillingAddressEventData:null,stripeBillingAddressUsedWhenAsyncAddressUpdate:null,stripeBillingAddressUsedWhenFetchingLC:null,stripeBillingAddressUsedWhenValidatingAddress:null,stripeCustomerSessionClientSecret:null,stripeElements:null,stripeElementsForBillingAddress:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null,stripeShippingSameAsBilling:true,taxId:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}})),stripeStoreOnChange=_q.onChange,reset$1=_q.reset,stripeStore=_q.state;var getStripeOptions=function(e){var t=e.clientSecret,r=e.overrideBorderRadius,o=e.overridePrimaryColor,n=e.overrideSecondaryColor,i=e.overrideTheme,a=e.paypalEnabled;var s=o||zonosStore.appearance.colorPrimary;var d=n||zonosStore.appearance.colorSecondary;var
|
|
182
|
+
skipPaymentIntent:new URLSearchParams(window.location.search).get("skipPaymentIntent")==="0"?false:true,stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenAsyncAddressUpdate:null,stripeAddressUsedWhenFetchingLC:null,stripeAddressUsedWhenValidatingAddress:null,stripeBillingAddressElement:null,stripeBillingAddressEventData:null,stripeBillingAddressUsedWhenAsyncAddressUpdate:null,stripeBillingAddressUsedWhenFetchingLC:null,stripeBillingAddressUsedWhenValidatingAddress:null,stripeCustomerSessionClientSecret:null,stripeElements:null,stripeElementsForBillingAddress:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null,stripeShippingSameAsBilling:true,taxId:"",taxIdType:"",taxIdTypeUsedWhenAsyncAddressUpdate:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}})),stripeStoreOnChange=_q.onChange,reset$1=_q.reset,stripeStore=_q.state;var getStripeOptions=function(e){var t=e.clientSecret,r=e.overrideBorderRadius,o=e.overridePrimaryColor,n=e.overrideSecondaryColor,i=e.overrideTheme,a=e.paypalEnabled;var s=o||zonosStore.appearance.colorPrimary;var d=n||zonosStore.appearance.colorSecondary;var l=window.Zonos.isCollect||window.Zonos.isInvoice?zonosStore.appearance.theme==="DARK":s&&isDarkColor(s);var c=l?"night":"flat";
|
|
172
183
|
// if overrideTheme is provided, use it. Otherwise, use theme based on primary color
|
|
173
184
|
var u=i==="DARK"?"night":"flat";var S=a?["external_paypal"]:[];
|
|
174
185
|
// If client secret is Stripe format, use it
|
|
175
186
|
var v=(t===null||t===void 0?void 0:t.includes("_secret_"))?t:undefined;return{appearance:{labels:"floating",rules:Object.assign({},addressRuleStyle({theme:i||"LIGHT"})),
|
|
176
187
|
// get contrast theme color base on primary color
|
|
177
|
-
theme:i?u:
|
|
188
|
+
theme:i?u:c,variables:Object.assign(Object.assign({},defaultVariable({borderStyle:r,theme:"LIGHT"})),{
|
|
178
189
|
// use the button background color for input glow color
|
|
179
190
|
colorPrimary:d})},
|
|
180
191
|
// Client secret can be undefined since we will load other elements that doesn't require client secret first, then load client secret and render one that requires it later
|
|
@@ -202,17 +213,17 @@ stripeStore.stripe=window.Zonos.stripe};var checkIsAddressOutdatedForValidation=
|
|
|
202
213
|
/**
|
|
203
214
|
* If user updates the address after prefetching the landed cost, should always create and attach
|
|
204
215
|
* @caveat this will cause the scenario goes wrong after prefetching landed cost, with the current logic, it won't create party because nothing change after the prefetch happened
|
|
205
|
-
*/var d=(e=cartStore.partiesData.find((function(e){return e.type==="DESTINATION"})))===null||e===void 0?void 0:e.id;var
|
|
216
|
+
*/var d=(e=cartStore.partiesData.find((function(e){return e.type==="DESTINATION"})))===null||e===void 0?void 0:e.id;var l=(t=cartStore.partiesData.find((function(e){return e.type==="PAYOR"})))===null||t===void 0?void 0:t.id;
|
|
206
217
|
// If haven't prefetched landed cost, there is no need to update address async
|
|
207
|
-
if(!d||!
|
|
218
|
+
if(!d||!l){return false}
|
|
208
219
|
// If we don't have landed cost parties data, should way
|
|
209
|
-
if(stripeStore.partyShippingId!==d||stripeStore.partyBillingId!==
|
|
220
|
+
if(stripeStore.partyShippingId!==d||stripeStore.partyBillingId!==l){return true}var c=JSON.stringify((r=stripeStore.stripeLinkUsedWhenFetchingLC)===null||r===void 0?void 0:r.value)!==JSON.stringify((o=stripeStore.stripeLinkEventData)===null||o===void 0?void 0:o.value);var u=JSON.stringify((n=stripeStore.stripeAddressUsedWhenAsyncAddressUpdate)===null||n===void 0?void 0:n.value)!==JSON.stringify((i=stripeStore.stripeAddressEventData)===null||i===void 0?void 0:i.value);var S=!stripeStore.stripeShippingSameAsBilling&&JSON.stringify((a=stripeStore.stripeBillingAddressUsedWhenAsyncAddressUpdate)===null||a===void 0?void 0:a.value)!==JSON.stringify((s=stripeStore.stripeBillingAddressEventData)===null||s===void 0?void 0:s.value);var v=stripeStore.taxIdUsedWhenAsyncAddressUpdate!==stripeStore.taxId||stripeStore.taxIdTypeUsedWhenAsyncAddressUpdate!==stripeStore.taxIdType;var p=stripeStore.companyNameUsedWhenAsyncAddressUpdate!==stripeStore.companyName;return c||u||S||v||p};var stripeStoreBuildAddressForPartyCreate=function(e){var t=e.address,r=e.firstName,o=e.lastName,n=e.name,i=e.phone;var a=extractName({firstName:r,lastName:o,name:n}),s=a.firstName,d=a.lastName;if(!s||!d){void sendErrorLog({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId,firstName:r,lastName:o,name:n}})}if(!i){void sendErrorLog({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId,phone:i}})}return{city:t.city,country:t.country,firstName:s,lastName:d,line1:t.line1,line2:t.line2,phone:i||"",postal_code:t.postal_code,state:t.state}};var stripeStoreAsyncAddressUpdate=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,d,l,c,u,S,v;return __generator(this,(function(p){switch(p.label){case 0:if(!((e=stripeStore.stripeAddressEventData)===null||e===void 0?void 0:e.complete)||!stripeStore.stripeShippingSameAsBilling&&!((t=stripeStore.stripeBillingAddressEventData)===null||t===void 0?void 0:t.complete)||!stripeStore.stripeBillingAddressEventData){return[2/*return*/,{partiesCreated:false}]}
|
|
210
221
|
// If there is no landed cost data, no need to create parties
|
|
211
|
-
if(!cartStore.landedCostData){return[2/*return*/,{partiesCreated:false}]}
|
|
222
|
+
if(!cartStore.landedCostData){return[2/*return*/,{partiesCreated:false}]}i=(r=cartStore.landedCostData.find(Boolean))===null||r===void 0?void 0:r.landedCost.rootId;if(!i){
|
|
212
223
|
// do nothing if we don't have selected landed cost
|
|
213
|
-
void sendErrorLog({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId}});return[2/*return*/,{partiesCreated:false}]}
|
|
224
|
+
void sendErrorLog({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId}});return[2/*return*/,{partiesCreated:false}]}a=checkIsAddressOutdatedForAsyncAddressUpdate();if(!a){return[2/*return*/,{partiesCreated:false}]}s=stripeStoreBuildAddressForPartyCreate({address:stripeStore.stripeAddressEventData.value.address,firstName:stripeStore.stripeAddressEventData.value.firstName,lastName:stripeStore.stripeAddressEventData.value.lastName,name:stripeStore.stripeAddressEventData.value.name,phone:stripeStore.stripeAddressEventData.value.phone});d=stripeStore.stripeShippingSameAsBilling?s:stripeStoreBuildAddressForPartyCreate({address:stripeStore.stripeBillingAddressEventData.value.address,firstName:stripeStore.stripeBillingAddressEventData.value.firstName,lastName:stripeStore.stripeBillingAddressEventData.value.lastName,name:stripeStore.stripeBillingAddressEventData.value.name,phone:stripeStore.stripeBillingAddressEventData.value.phone});l=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";c=getCheckoutTaxIdPayload(s.country);return[4/*yield*/,handleFetch("/api/zonos-elements/create-parties",{body:Object.assign({address:s,billingAddress:d,companyName:stripeStore.companyName,email:((o=stripeStore.stripeLinkEventData)===null||o===void 0?void 0:o.value.email)||"",isTest:l,rootId:i,shortAddressCode:stripeStore.shortAddressCode,taxId:(n=c===null||c===void 0?void 0:c.taxId)!==null&&n!==void 0?n:""},(c===null||c===void 0?void 0:c.taxIdType)?{taxIdType:c.taxIdType}:{}),method:"POST"})];case 1:u=p.sent(),S=u.errors,v=u.json;if(S.length||!v){logError("Error occurs when creating parties",JSON.stringify(S,null,2));void sendErrorLog({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId,errors:S,json:v}});return[2/*return*/,{partiesCreated:false}]}stripeStore.companyNameUsedWhenAsyncAddressUpdate=stripeStore.companyName;stripeStore.stripeAddressUsedWhenAsyncAddressUpdate=stripeStore.stripeAddressEventData;stripeStore.stripeBillingAddressUsedWhenAsyncAddressUpdate=stripeStore.stripeBillingAddressEventData;stripeStore.taxIdTypeUsedWhenAsyncAddressUpdate=stripeStore.taxIdType;stripeStore.taxIdUsedWhenAsyncAddressUpdate=stripeStore.taxId;stripeStore.partyBillingId=v.billToPartyId;stripeStore.partyShippingId=v.shipToPartyId;
|
|
214
225
|
// Update parties data with the new parties id
|
|
215
|
-
cartStore.partiesData=cartStore.partiesData.map((function(e){if(e.type==="DESTINATION"&&e.id!==
|
|
226
|
+
cartStore.partiesData=cartStore.partiesData.map((function(e){if(e.type==="DESTINATION"&&e.id!==v.shipToPartyId){return Object.assign(Object.assign({},e),{id:v.shipToPartyId})}if(e.type==="PAYOR"&&e.id!==v.billToPartyId){return Object.assign(Object.assign({},e),{id:v.billToPartyId})}return e}));return[2/*return*/,{partiesCreated:true}]}}))}))};
|
|
216
227
|
/**
|
|
217
228
|
* Extract only the necessary address info for landed cost prefetch
|
|
218
229
|
*/var buildAddressForLCPrefetch=function(e){return{countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}};var checkIsAddressOutdatedForLCPrefetch=function(){var e,t;var r=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 o=stripeStore.stripeAddressEventData&&JSON.stringify(buildAddressForLCPrefetch(stripeStore.stripeAddressEventData.value))!==JSON.stringify(stripeStore.stripeAddressUsedWhenFetchingLC);var n=!stripeStore.stripeShippingSameAsBilling&&stripeStore.stripeBillingAddressEventData&&JSON.stringify(buildAddressForLCPrefetch(stripeStore.stripeBillingAddressEventData.value))!==JSON.stringify(stripeStore.stripeBillingAddressUsedWhenFetchingLC);return r||o||n};
|
|
@@ -229,7 +240,7 @@ return!cartStore.landedCostData&&!stripeStore.isFetchingLandedCost||r||t};var ge
|
|
|
229
240
|
* stripeCountryFieldLabels is the list we collect from Stripe, and extract only country that state/zip is required and different from what we have in our countryFieldLabel data
|
|
230
241
|
**/if(cartStore.addressFormRenderType==="stripe"){return i||a}return a};var isAddressReadyToRequestLandedCost=function(){var e,t,r,o;var n=!!((e=stripeStore.stripeLinkEventData)===null||e===void 0?void 0:e.complete);var i=!!((t=stripeStore.stripeAddressEventData)===null||t===void 0?void 0:t.complete);var a=stripeStore.stripeShippingSameAsBilling?i:!!((r=stripeStore.stripeBillingAddressEventData)===null||r===void 0?void 0:r.complete);var s=((o=stripeStore.stripeAddressEventData)===null||o===void 0?void 0:o.value.address.country)||"US";var d=getCountryField(s);if(i&&a&&n){return true}
|
|
231
242
|
// Only send landed cost request if the address is complete when we can't get the country field
|
|
232
|
-
if(!d||!stripeStore.stripeAddressEventData){return i&&a&&n}var
|
|
243
|
+
if(!d||!stripeStore.stripeAddressEventData){return i&&a&&n}var l=stripeStore.stripeAddressEventData.value.address.line1.length>0;var c=stripeStore.stripeAddressEventData.value.firstName&&stripeStore.stripeAddressEventData.value.lastName;var u=!d.stateRequired||d.stateRequired&&stripeStore.stripeAddressEventData.value.address.state.length>0;var S=!d.zipRequired||d.zipRequired&&stripeStore.stripeAddressEventData.value.address.postal_code.length>=3;var v=stripeStore.stripeAddressEventData.value.phone&&stripeStore.stripeAddressEventData.value.phone.length>0;return n&&c&&l&&u&&S&&v};var stripeCalculateLandedCost=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,d,l,c;return __generator(this,(function(u){switch(u.label){case 0:t=new AbortController;stripeStore.fetchingLandedCostAbortController=t;
|
|
233
244
|
// Reset cart items to non-restricted state and restricted item list
|
|
234
245
|
cartStoreResetCartItems();return[4/*yield*/,calculateLandedCostNormalized(t)];case 1:r=u.sent(),o=r.checkoutSessionWorkflow,n=r.errors,i=r.itemCreateWorkflow,a=r.landedCostCalculateWorkflow,s=r.partyCreateWorkflow,d=r.shipmentRatingCalculateWorkflow;
|
|
235
246
|
// Surface a custom "no quote" message when either a rule (ruleMessageType CUSTOM) or a country
|
|
@@ -240,9 +251,9 @@ cartStoreCheckItemRestrictions(i);
|
|
|
240
251
|
// reset abort controller after we are done
|
|
241
252
|
stripeStore.fetchingLandedCostAbortController=null;cartStore.partiesData=(s===null||s===void 0?void 0:s.filter(Boolean))||[];
|
|
242
253
|
// update cart store with landed cost info
|
|
243
|
-
cartStore.landedCostData=(o===null||o===void 0?void 0:o.map((function(e){var t=a===null||a===void 0?void 0:a.find((function(t){return(t===null||t===void 0?void 0:t.id)===e.landedCostId}));if(!t){return null}return Object.assign(Object.assign({},e),{landedCost:t})})).filter(Boolean))||[];
|
|
254
|
+
cartStore.landedCostData=(o===null||o===void 0?void 0:o.map((function(e){var t=a===null||a===void 0?void 0:a.find((function(t){return(t===null||t===void 0?void 0:t.id)===e.landedCostId}));if(!t){return null}return Object.assign(Object.assign({},e),{landedCost:t})})).filter(Boolean))||[];l=storageStore.checkoutSessionId;if(o===null||o===void 0?void 0:o.length){void trackConversionEvent({checkoutSessionId:l,eventName:"checkout_quoteReceived"})}c=cartStore.promoCodeApplied&&!cartStore.landedCostData.find((function(e){var t;return(t=e.landedCost.appliedAdjustments)===null||t===void 0?void 0:t.find((function(e){return e.type==="PROMO_CODE"}))}));cartStore.promoCodeError=c;
|
|
244
255
|
// When promocode is valid, set promoCode to session storage so if user close the modal, we can still reapply for them
|
|
245
|
-
if(!
|
|
256
|
+
if(!c){sessionStorage.setItem("zonos--promo-code",cartStore.promoCode)}return[2/*return*/]}}))}))};var stripeStorePrefetchLandedCost=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a,s,d,l,c,u,S,v,p;return __generator(this,(function(f){switch(f.label){case 0:i=(e===null||e===void 0?void 0:e.retries)||0;a=!!(e===null||e===void 0?void 0:e.applyingPromocode);s=isPrefetchInfoOutdated();d=isAddressReadyToRequestLandedCost();
|
|
246
257
|
// Should not do anything if the address is not ready to request landed cost
|
|
247
258
|
if(!d){return[2/*return*/,{isRequestNotReady:true}]}if(s){
|
|
248
259
|
// if the info used when fetching landed cost is different from the current info, abort the previous request
|
|
@@ -256,9 +267,9 @@ cartStoreResetCartItems();
|
|
|
256
267
|
// fetch and apply landed cost
|
|
257
268
|
return[4/*yield*/,stripeCalculateLandedCost()];case 2:
|
|
258
269
|
// fetch and apply landed cost
|
|
259
|
-
f.sent();
|
|
270
|
+
f.sent();l=(r=cartStore.shippingData)===null||r===void 0?void 0:r.find(Boolean);c=(o=cartStore.landedCostData)===null||o===void 0?void 0:o.find((function(e){return e.landedCost.shipmentRating.id===(l===null||l===void 0?void 0:l.id)}));u=!!c?c.subtotals:null;if(u){
|
|
260
271
|
// prefetch landed cost will not update shipping and taxes since we haven't selected shipping method yet
|
|
261
|
-
cartStoreApplySubtotals({method:(
|
|
272
|
+
cartStoreApplySubtotals({method:(c===null||c===void 0?void 0:c.landedCost.method)||"DDP",subtotals:u})}return[3/*break*/,7];case 3:S=f.sent();
|
|
262
273
|
// default to empty array if we failed to fetch landed cost, so we can show the error message
|
|
263
274
|
cartStore.landedCostData=[];cartStore.shippingData=[];v=["The landed cost calculation request was aborted to initiate a new one."];if(!(S instanceof Error&&S.message&&!v.includes(S.message)))return[3/*break*/,6];if(!(i<1))return[3/*break*/,5];
|
|
264
275
|
// retry fetching landed cost one more time
|
|
@@ -285,9 +296,9 @@ if(cartStore.step==="payment"){cartStorePreviousStep()}stripeStoreResetPromoCode
|
|
|
285
296
|
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.")];if(o||n){t=[translate("Thank you for submitting your payment. We appreciate your prompt attention."),"",translate("A confirmation email with your payment details has been sent for your records. If you have any questions or need support, our team is here to help.")]}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.")];if(o){t=[translate("Payment failed. Please reload the page and try another payment method.")]}break}case"requires_action":{r=false;t=[translate("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]}default:{t=[translate("Something went wrong.")];break}}return{isError:r,messages:t}};
|
|
286
297
|
/**
|
|
287
298
|
* Handle inventory check and returns error message if the callback provided.
|
|
288
|
-
*/var stripeStoreHandleInventoryCheck=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,d,s;return __generator(this,(function(
|
|
299
|
+
*/var stripeStoreHandleInventoryCheck=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,d,s;return __generator(this,(function(l){switch(l.label){case 0:r=zonosStore.checkoutSettings.onInventoryCheck;o=!!((t=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||t===void 0?void 0:t.value);if(!(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o))return[3/*break*/,2];return[4/*yield*/,handleFetch("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:n=l.sent(),i=n.errors,a=n.json;if(i.length||!a){logError("Error occurs when handling inventory refund","warn",JSON.stringify(i));return[2/*return*/,null]}
|
|
289
300
|
// Proceed if the item is available
|
|
290
|
-
if(!a.available||a.status===204){return[2/*return*/,translate("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")]}if(a.available||a.status===200){stripeStore.shouldInventoryRefund=true;return[2/*return*/,null]}return[2/*return*/,null];case 2:if(typeof r!=="function"){return[2/*return*/,null]}
|
|
301
|
+
if(!a.available||a.status===204){return[2/*return*/,translate("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")]}if(a.available||a.status===200){stripeStore.shouldInventoryRefund=true;return[2/*return*/,null]}return[2/*return*/,null];case 2:if(typeof r!=="function"){return[2/*return*/,null]}l.label=3;case 3:l.trys.push([3,5,,6]);return[4/*yield*/,r({items:cartStore.items},{translate:translate,zonosApiRoute:fallbackApiList["vercel"]})];case 4:s=l.sent();return[2/*return*/,s];case 5:d=l.sent();s=d instanceof Error?d.message:"Unknown error";void sendErrorLog({endpoint:"onInventoryCheck",errors:["cartId: ".concat(window.Zonos.cartId," - ").concat(s)],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:cartStore.items}});throw d;case 6:return[2/*return*/]}}))}))};
|
|
291
302
|
/**
|
|
292
303
|
* Handle inventory check and returns error message if the callback provided.
|
|
293
304
|
*/var stripeStoreHandleInventoryRefund=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r;return __generator(this,(function(o){switch(o.label){case 0:r=!!((t=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||t===void 0?void 0:t.value);
|
|
@@ -296,12 +307,12 @@ if(!window.Zonos.isLegacyCheckout||!window.Zonos.cartData||!r){return[2/*return*
|
|
|
296
307
|
// handle inventory check on legacy checkout
|
|
297
308
|
return[4/*yield*/,handleFetch("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:
|
|
298
309
|
// handle inventory check on legacy checkout
|
|
299
|
-
o.sent();return[2/*return*/]}}))}))};var stripeStoreRetrievePayment=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,
|
|
310
|
+
o.sent();return[2/*return*/]}}))}))};var stripeStoreRetrievePayment=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,l;var c=e.clientSecret,u=e.storybookForceStatus;return __generator(this,(function(e){switch(e.label){case 0:if(u){t=stripeStoreMessageBasedOnStatus(u),r=t.isError,o=t.messages;return[2/*return*/,{error:r,messages:o}]}n=c||stripeStore.clientSecret;if(!stripeStore.stripe||!n){logError("Failed to retrieve payment intent. Stripe is not initialized");return[2/*return*/,{error:true,message:[translate("Something went wrong.")]}]}
|
|
300
311
|
// A client secret that isn't a Stripe payment intent secret (e.g. an Airwallex
|
|
301
312
|
// secret) can't be evaluated by Stripe. Do not treat it as a successful Stripe
|
|
302
313
|
// payment — return an error so callers don't run success analytics / order
|
|
303
314
|
// polling off a secret Stripe never confirmed.
|
|
304
|
-
if(!n.includes("_secret_")){return[2/*return*/,{error:true,messages:[translate("Something went wrong.")]}]}return[4/*yield*/,stripeStore.stripe.retrievePaymentIntent(n)];case 1:i=e.sent().paymentIntent;a=i===null||i===void 0?void 0:i.status;s=stripeStoreMessageBasedOnStatus(a),d=s.isError,
|
|
315
|
+
if(!n.includes("_secret_")){return[2/*return*/,{error:true,messages:[translate("Something went wrong.")]}]}return[4/*yield*/,stripeStore.stripe.retrievePaymentIntent(n)];case 1:i=e.sent().paymentIntent;a=i===null||i===void 0?void 0:i.status;s=stripeStoreMessageBasedOnStatus(a),d=s.isError,l=s.messages;return[2/*return*/,{amount:i===null||i===void 0?void 0:i.amount,currency:i===null||i===void 0?void 0:i.currency,error:d,messages:l,paymentIntentId:i===null||i===void 0?void 0:i.id,paymentMethod:i===null||i===void 0?void 0:i.payment_method,status:a}]}}))}))};var stripeStoreConfirmPayment=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a,s,d,l,c,u,S;return __generator(this,(function(v){switch(v.label){case 0:o=!!((t=stripeStore.stripePaymentEventData)===null||t===void 0?void 0:t.complete);n=stripeStore.stripeElements;i=stripeStore.stripe;a=stripeStore.clientSecret;stripeStore.customErrorMessage=null;if(!((r=cartStore.selectedLandedCost)===null||r===void 0?void 0:r.landedCost.id)&&!(e===null||e===void 0?void 0:e.noLandedCostCheck)){throw new Error("Attempted to confirm the payment when no landed cost is found in store")}return[4/*yield*/,validateCheckoutSession()];case 1:s=v.sent();if(!s.valid){stripeStore.customErrorMessage=s.errorMessage;throw new Error(s.errorMessage)}d=storageStore.checkoutSessionId;if(!(i&&n&&o&&a&&d))return[3/*break*/,3];l=new URL(window.location.href);l.searchParams.set("payment_intent_client_secret",a);l.searchParams.set("zonosCheckoutSessionId",d);void trackConversionEvent({checkoutSessionId:d,eventName:"checkout_paymentInfoCompleted"});return[4/*yield*/,i.confirmPayment({confirmParams:{return_url:l.toString()},elements:n,redirect:"if_required"})];case 2:c=v.sent(),u=c.error,S=c.paymentIntent;log("Payment intent confirmed","info",{error:u,paymentIntent:S});if((S===null||S===void 0?void 0:S.status)==="requires_action"){throw new Error(translate("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."))}if(u){if(u.type==="card_error"||u.type==="validation_error"){throw new Error(u.message)}if(u.type==="invalid_request_error"){if(u.code==="payment_intent_unexpected_state"){
|
|
305
316
|
// PaymentIntent was canceled or expired, or status is `require_capture`.
|
|
306
317
|
// don't throw error here because we will reset the checkout session last step
|
|
307
318
|
return[2/*return*/]}}throw new Error("An unexpected error occurred.")}if(S.status==="requires_payment_method"){
|
|
@@ -349,7 +360,7 @@ if(zonosStore.checkoutSettings.allowedSettlementCurrencies==="LOCAL"){log('allow
|
|
|
349
360
|
if(!t||r!==stripeStore.checkoutSettlementCurrency){logError("Failed to update checkout session base currency");return[2/*return*/,false]}log('Updated checkout session to settlement currency "'.concat(r,'".'));return[2/*return*/,true]}}))}))};
|
|
350
361
|
/**
|
|
351
362
|
* Update checkout session. Use for updating amount with landed cost id, or update session when cart items change
|
|
352
|
-
*/var stripeStoreUpdateCheckoutSession=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n;var i=e.adjustmentsAmount,a=e.cartId,s=e.currency,d=e.id,
|
|
363
|
+
*/var stripeStoreUpdateCheckoutSession=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n;var i=e.adjustmentsAmount,a=e.cartId,s=e.currency,d=e.id,l=e.itemsAmount,c=e.landedCostId,u=e.presentmentCountryCode,S=e.storeCreditApplication;return __generator(this,(function(e){switch(e.label){case 0:t=storageStore.enabledVariantTestKeys||[];return[4/*yield*/,handleFetch("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:i,billToPartyId:stripeStore.partyBillingId,cartId:a,currency:s,customerAuthenticationToken:cartStore.customerAuthenticationToken||undefined,id:d,itemsAmount:l,landedCostId:c,metadata:[{key:"language",value:localizationStore.selectedLocale}],presentmentCountryCode:u,shipToPartyId:stripeStore.partyShippingId,skipPaymentIntent:stripeStore.skipPaymentIntent,storeCreditApplication:S,varianceTestInput:t},method:"POST"})];case 1:r=e.sent(),o=r.errors,n=r.json;if(o.length||!n){logError("Error occurs when updating checkout session",JSON.stringify(o,null,2));return[2/*return*/,{errors:o,json:n}]}return[2/*return*/,{errors:[],json:n}]}}))}))};
|
|
353
364
|
/**
|
|
354
365
|
* Pushes the buyer's policy consent into the checkout session's metadata via the
|
|
355
366
|
* dedicated metadata-only mutation. Called from the payment continue handler so
|
|
@@ -373,9 +384,9 @@ logError("Failed to record merchant policy consent on checkout session",JSON.str
|
|
|
373
384
|
* @param {Address} params.translatedAddressResult - The translated address result.
|
|
374
385
|
*
|
|
375
386
|
* @returns {TranslatedAddress} - An object containing the translated address. Each field is an object with the current address's field value as the key and the translated address's field value as the value.
|
|
376
|
-
*/var buildTranslatedAddress=function(e){var t,r,o,n,i,a;var s=e.currentAddress,d=e.translatedAddressResult;var
|
|
387
|
+
*/var buildTranslatedAddress=function(e){var t,r,o,n,i,a;var s=e.currentAddress,d=e.translatedAddressResult;var l={};if(!d){return l}var c=d.city,u=d.line1,S=d.line2,v=d.name,p=d.postal_code,f=d.state;
|
|
377
388
|
// If we have translated address, add it to the translated address object
|
|
378
|
-
if(s.city&&
|
|
389
|
+
if(s.city&&c){l.city=(t={},t[s.city]=c,t)}if(s.line1&&u){l.line1=(r={},r[s.line1]=u,r)}if(s.line2&&S){l.line2=(o={},o[s.line2]=S,o)}if(s.postal_code&&p){l.postal_code=(n={},n[s.postal_code]=p,n)}if(s.state&&f){l.state=(i={},i[s.state]=f,i)}if(s.name&&v){l.name=(a={},a[s.name]=v,a)}return l};
|
|
379
390
|
/**
|
|
380
391
|
* This function translates an address to Latin characters using the Zonos API.
|
|
381
392
|
* It first builds the request body for the API call. If there's no request body, it resets the translated address in the store and returns.
|
|
@@ -386,15 +397,15 @@ if(s.city&&l){c.city=(t={},t[s.city]=l,t)}if(s.line1&&u){c.line1=(r={},r[s.line1
|
|
|
386
397
|
* @param {Object} params - The parameters for the function.
|
|
387
398
|
* @param {ReturnType<typeof containsNonLatinChars> | null} params.addressInvalidCharactersList - The list of address fields that contain invalid characters.
|
|
388
399
|
* @param {ReturnType<typeof containsNonLatinChars> | null} params.billingAddressInvalidCharactersList - The list of billing address fields that contain invalid characters.
|
|
389
|
-
*/var stripeStoreTranslateAddressToLatin=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,c,
|
|
400
|
+
*/var stripeStoreTranslateAddressToLatin=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,l,c,u;var S=e.addressInvalidCharactersList,v=e.billingAddressInvalidCharactersList;return __generator(this,(function(e){switch(e.label){case 0:i=buildTranslateRequest({addressInvalidCharactersList:S,billingAddressInvalidCharactersList:v,stripeAddressEventData:stripeStore.stripeAddressEventData,stripeBillingAddressEventData:stripeStore.stripeBillingAddressEventData,stripeShippingSameAsBilling:stripeStore.stripeShippingSameAsBilling});if(!i){
|
|
390
401
|
// reset translated address if we don't have any address to translate
|
|
391
|
-
stripeStore.translatedAddress={address:{},billingAddress:{}};return[2/*return*/]}a=checkIsAddressOutdatedForValidation();if(!a){return[2/*return*/]}return[4/*yield*/,handleFetch("/api/zonos-elements/validate-address",{body:i,method:"POST"})];case 1:s=e.sent(),d=s.errors,
|
|
402
|
+
stripeStore.translatedAddress={address:{},billingAddress:{}};return[2/*return*/]}a=checkIsAddressOutdatedForValidation();if(!a){return[2/*return*/]}return[4/*yield*/,handleFetch("/api/zonos-elements/validate-address",{body:i,method:"POST"})];case 1:s=e.sent(),d=s.errors,l=s.json;if(d.length||!l){logError("Error occurs when translating address to latin",JSON.stringify(d,null,2));
|
|
392
403
|
// reset translated address if we Failed to translate and let user manually fix it
|
|
393
404
|
stripeStore.translatedAddress={address:{},billingAddress:{}};return[2/*return*/]}
|
|
394
405
|
// Set current address to the store so we can compare it later to determine if we need to re-translate the address
|
|
395
|
-
stripeStore.stripeAddressUsedWhenValidatingAddress=stripeStore.stripeAddressEventData;stripeStore.stripeBillingAddressUsedWhenValidatingAddress=stripeStore.stripeBillingAddressEventData;
|
|
406
|
+
stripeStore.stripeAddressUsedWhenValidatingAddress=stripeStore.stripeAddressEventData;stripeStore.stripeBillingAddressUsedWhenValidatingAddress=stripeStore.stripeBillingAddressEventData;c=(t=stripeStore.stripeAddressEventData)===null||t===void 0?void 0:t.value.address;u=(r=stripeStore.stripeBillingAddressEventData)===null||r===void 0?void 0:r.value.address;
|
|
396
407
|
// Set the translated address to the store so we can populate it to the address element for user to update
|
|
397
|
-
stripeStore.translatedAddress={address:
|
|
408
|
+
stripeStore.translatedAddress={address:c?buildTranslatedAddress({currentAddress:Object.assign(Object.assign({},c),{name:(o=stripeStore.stripeAddressEventData)===null||o===void 0?void 0:o.value.name}),translatedAddressResult:l.address||null}):{},billingAddress:!stripeStore.stripeShippingSameAsBilling?buildTranslatedAddress({currentAddress:Object.assign(Object.assign({},u),{name:(n=stripeStore.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value.name}),translatedAddressResult:l.billingAddress||null}):{}};return[2/*return*/]}}))}))};stripeStoreOnChange("clientSecret",(function(e){
|
|
398
409
|
// update stripe elements when client secret changes
|
|
399
410
|
if(e&&stripeStore.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));
|
|
400
411
|
/**
|
|
@@ -459,11 +470,11 @@ if(e.id){storageStore.checkoutSessionId=e.id}
|
|
|
459
470
|
// Filter the response to only include test keys that we support and then save it to the session
|
|
460
471
|
var d=filterValidTests(e.varianceTestResults||[]);storageStoreSetEnabledVariantTestKeys(d);
|
|
461
472
|
// Check if there is a redirect URL in the metadata to override
|
|
462
|
-
var
|
|
473
|
+
var l=((i=(n=(o=cartStore.checkoutSession)===null||o===void 0?void 0:o.metadata)===null||n===void 0?void 0:n.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||i===void 0?void 0:i.value)||(
|
|
463
474
|
// Sometimes externalConfirmationPageURL is not in checkoutSession create/update, check if there is a redirect URL in the cart metadata to override
|
|
464
|
-
(s=(a=window.Zonos.cartData)===null||a===void 0?void 0:a.metadata.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||s===void 0?void 0:s.value)||null;if(
|
|
475
|
+
(s=(a=window.Zonos.cartData)===null||a===void 0?void 0:a.metadata.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||s===void 0?void 0:s.value)||null;if(l){log("Found externalConfirmationPageURL: ".concat(l));cartStore.externalConfirmationPageURL=l}};var cartStoreReCalculateTotal=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a;var s=e.adjustmentsAmount,d=e.cartId,l=e.currency,c=e.dutiesTaxesFeesEstimate,u=e.itemsAmount,S=e.landedCostId,v=e.shouldInitSessionOnFailure;return __generator(this,(function(e){switch(e.label){case 0:if(S&&cartStore.selectedLandedCost){r=cartStore.selectedLandedCost.subtotals;cartStoreApplySubtotals({dutiesTaxesFeesEstimate:c,method:cartStore.landedCostMethod,subtotals:r});log("Exchange rate updated for cart items (landed cost subtotal)","info",cartStore.exchangeRate)}
|
|
465
476
|
// update checkout session
|
|
466
|
-
if(!storageStore.checkoutSessionId){log("Could not update cart total without checkout session id","info");return[2/*return*/,false]}return[4/*yield*/,stripeStoreUpdateCheckoutSession({adjustmentsAmount:s,cartId:d,currency:
|
|
477
|
+
if(!storageStore.checkoutSessionId){log("Could not update cart total without checkout session id","info");return[2/*return*/,false]}return[4/*yield*/,stripeStoreUpdateCheckoutSession({adjustmentsAmount:s,cartId:d,currency:l,id:storageStore.checkoutSessionId,itemsAmount:u,landedCostId:S,presentmentCountryCode:localizationStore.selectedCountryCode})];case 1:o=e.sent(),n=o.errors,i=o.json;if(!(n.length>0||!i))return[3/*break*/,4];logError("Error occurs when updating checkout session.");if(!v)return[3/*break*/,3];log("Initiating checkout session on failure","info");return[4/*yield*/,stripeStoreInitCheckoutSession()];case 2:a=e.sent();log("stripeStoreInitCheckoutSession: ".concat(a));if(!a){cartStoreUpdateToErrorState({messages:[translate("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error creating Checkout")});return[2/*return*/,false]}return[2/*return*/,true];case 3:return[2/*return*/,false];case 4:if(!S){
|
|
467
478
|
// This is when we first open the checkout modal and we just want to get info from the old cart session.
|
|
468
479
|
// use subtotals from checkout session to update cart total
|
|
469
480
|
cartStoreApplySubtotals({method:((t=i.checkoutSessionUpdate.landedCost)===null||t===void 0?void 0:t.method)||"DDP",subtotals:i.checkoutSessionUpdate.subtotals});log("Exchange rate updated for cart items (checkout session update)","info",cartStore.exchangeRate)}cartStoreSetCheckoutSession(i.checkoutSessionUpdate);return[2/*return*/,true]}}))}))};
|
|
@@ -474,29 +485,29 @@ cartStoreApplySubtotals({method:((t=i.checkoutSessionUpdate.landedCost)===null||
|
|
|
474
485
|
if(e.method==="DAP"&&((o=(r=zonosStore.genericSettings)===null||r===void 0?void 0:r.domesticCountries)===null||o===void 0?void 0:o.includes(((n=stripeStore.stripeAddressEventData)===null||n===void 0?void 0:n.value.address.country)||"US"))){return"DDP"}
|
|
475
486
|
// EU 3-EUR cutover (05CHECK-893): keep EU POSTAL remittance quotes as DAP so
|
|
476
487
|
// the shopper is told duties are paid upon delivery, even though we remit.
|
|
477
|
-
if(isEuDapRemittance({deliveryType:t,landedCost:e,shipToCountry:(i=stripeStore.stripeAddressEventData)===null||i===void 0?void 0:i.value.address.country})){return"DAP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method};var cartStoreUpdateSelectedShippingOption=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,c,
|
|
488
|
+
if(isEuDapRemittance({deliveryType:t,landedCost:e,shipToCountry:(i=stripeStore.stripeAddressEventData)===null||i===void 0?void 0:i.value.address.country})){return"DAP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method};var cartStoreUpdateSelectedShippingOption=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,l,c,u,S,v,p,f,h,m,g,C,y,w,b,A,O,I,_;var T=e.applySubtotalsOnly,k=e.landedCostId,E=e.selectedShippingOption;return __generator(this,(function(e){switch(e.label){case 0:log("Updating selected shipping option","info",{landedCostId:k,selectedShippingOption:E});cartStore.selectedShippingOption=E;v=cartStoreGetShippingTransitInfo(cartStore.selectedShippingOption);if(v){p=v.maxTransit,f=v.minTransit,h=v.unit;cartStore.selectedShippingOptionTransitTime="".concat(f,"-").concat(p," ").concat(h)}else{cartStore.selectedShippingOptionTransitTime=""}m=(t=cartStore.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCostId===k}));
|
|
478
489
|
// save selected landed cost for later use
|
|
479
490
|
cartStore.selectedLandedCost=m||null;if(!m){
|
|
480
491
|
// do nothing if we can't find landed cost for selected shipping option
|
|
481
|
-
return[2/*return*/,false]}g=((r=m.landedCost.amountSubtotals)===null||r===void 0?void 0:r.landedCostTotal)||0;C=m.subtotals.exchangeRate.rate;y=g*C;if(y){log("DAP quote, using estimate: ".concat(y),"info")}cartStore.landedCostMethod=cartStoreGetMethod(m.landedCost,(o=
|
|
492
|
+
return[2/*return*/,false]}g=((r=m.landedCost.amountSubtotals)===null||r===void 0?void 0:r.landedCostTotal)||0;C=m.subtotals.exchangeRate.rate;y=g*C;if(y){log("DAP quote, using estimate: ".concat(y),"info")}cartStore.landedCostMethod=cartStoreGetMethod(m.landedCost,(o=E.shippingProfile)===null||o===void 0?void 0:o.serviceLevel.deliveryType);
|
|
482
493
|
// update shipping value and dutiesTaxFees on selectedShippingOption change
|
|
483
|
-
cartStore.shipping=m.subtotals.shipping;w=((n=m===null||m===void 0?void 0:m.landedCost)===null||n===void 0?void 0:n.landedCostGuaranteeCode)==="ZONOS";b=!!((a=(i=m===null||m===void 0?void 0:m.landedCost)===null||i===void 0?void 0:i.deMinimis)===null||a===void 0?void 0:a.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));cartStore.isSelectedShippingAboveDeminimis=b;cartStore.isSelectedShippingGuarantee=w;A=false;if(!
|
|
494
|
+
cartStore.shipping=m.subtotals.shipping;w=((n=m===null||m===void 0?void 0:m.landedCost)===null||n===void 0?void 0:n.landedCostGuaranteeCode)==="ZONOS";b=!!((a=(i=m===null||m===void 0?void 0:m.landedCost)===null||i===void 0?void 0:i.deMinimis)===null||a===void 0?void 0:a.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));cartStore.isSelectedShippingAboveDeminimis=b;cartStore.isSelectedShippingGuarantee=w;A=false;if(!T)return[3/*break*/,1];O=m.subtotals;cartStoreApplySubtotals({dutiesTaxesFeesEstimate:y,method:cartStore.landedCostMethod,subtotals:O});log("Exchange rate updated for cart items (landed cost subtotal)","info",cartStore.exchangeRate);A=true;return[3/*break*/,3];case 1:return[4/*yield*/,cartStoreReCalculateTotal({adjustmentsAmount:cartStore.adjustmentTotal,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:y,landedCostId:(s=m.landedCost)===null||s===void 0?void 0:s.id})];case 2:
|
|
484
495
|
// update session with selected landed cost
|
|
485
|
-
A=e.sent();e.label=3;case 3:
|
|
496
|
+
A=e.sent();e.label=3;case 3:I=(d=cartStore.items.find(Boolean))===null||d===void 0?void 0:d.currencyCode;_=((l=stripeStore.stripeAddressEventData)===null||l===void 0?void 0:l.value.address.country)||"US";
|
|
486
497
|
// Only show pay in USD button if item's currency is in USD, the setting is enabled and the order presentment currency is not USD, also only in USD settlement ship to country list
|
|
487
|
-
stripeStore.shouldRenderPayInUsdButton=
|
|
498
|
+
stripeStore.shouldRenderPayInUsdButton=I==="USD"&&zonosStore.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((c=cartStore.checkoutSession)===null||c===void 0?void 0:c.subtotals.presentmentCurrencyCode)!=="USD"&&!!((S=(u=zonosStore.genericSettings)===null||u===void 0?void 0:u.usdSettlementCountryEnabled)===null||S===void 0?void 0:S.includes(_));return[2/*return*/,A]}}))}))};var cartStoreStartCheckoutInterval=function(e){var t=e.isPreview,r=e.sessionTimeout;
|
|
488
499
|
// do nothing if in preview mode
|
|
489
500
|
if(t){return}var o=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout");var n=
|
|
490
501
|
// timeout query is mainly for testing purpose
|
|
491
502
|
o&&!isNaN(parseInt(o,10))?parseInt(o,10):r;log("==START CHECKOUT TIMEOUT - ".concat(n,"=="));cartStore.checkoutTimeoutInterval=setTimeout((function(){cartStore.checkoutSessionTimeoutShow=true}),n)};var cartStoreClearCheckoutInterval=function(){if(cartStore.checkoutTimeoutInterval){clearTimeout(cartStore.checkoutTimeoutInterval);cartStore.checkoutTimeoutInterval=null}};var getCartItemToUse=function(e){return e.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}))};var cartStoreResetCartItems=function(){
|
|
492
503
|
// mark all items as not restricted
|
|
493
|
-
cartStore.items=cartStore.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}));cartStore.restrictedItems=[]};var cartStoreUpdateItems=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n;var i=e.adjustments,a=e.cartItems,s=e.landedCostId,d=e.shouldInitSessionOnFailure,
|
|
504
|
+
cartStore.items=cartStore.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}));cartStore.restrictedItems=[]};var cartStoreUpdateItems=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n;var i=e.adjustments,a=e.cartItems,s=e.landedCostId,d=e.shouldInitSessionOnFailure,l=d===void 0?true:d;return __generator(this,(function(e){switch(e.label){case 0:
|
|
494
505
|
// Update adjustments and items
|
|
495
506
|
cartStore.adjustments=i;cartStore.items=getCartItemToUse(a);r=(t=a.find(Boolean))===null||t===void 0?void 0:t.currencyCode;o=a.reduce((function(e,t){return e+t.amount*t.quantity}),0);n=i.reduce((function(e,t){return e+t.amount}),0);if(!r||!o){
|
|
496
507
|
// do nothing if we can't get currency or total
|
|
497
508
|
return[2/*return*/]}cartStore.currency=r;
|
|
498
509
|
// set loading state here because this is the first load checkout session when we already have checkout session id stored
|
|
499
|
-
stripeStore.isFetchingSession=true;return[4/*yield*/,cartStoreReCalculateTotal({adjustmentsAmount:n,cartId:window.Zonos.cartId,currency:r,dutiesTaxesFeesEstimate:0,itemsAmount:o,landedCostId:s,shouldInitSessionOnFailure:
|
|
510
|
+
stripeStore.isFetchingSession=true;return[4/*yield*/,cartStoreReCalculateTotal({adjustmentsAmount:n,cartId:window.Zonos.cartId,currency:r,dutiesTaxesFeesEstimate:0,itemsAmount:o,landedCostId:s,shouldInitSessionOnFailure:l})];case 1:e.sent();stripeStore.isFetchingSession=false;return[2/*return*/]}}))}))};var cartStoreResetSelectedShippingOption=function(){cartStore.selectedShippingOption=null;cartStore.isSelectedShippingAboveDeminimis=false;cartStore.isSelectedShippingGuarantee=false;cartStore.selectedShippingOptionTransitTime="";cartStore.dutiesTaxesFees=0;cartStore.dutiesTaxesFeesEstimate=0;cartStore.shipping=0;
|
|
500
511
|
// reset total to subtotal
|
|
501
512
|
cartStore.total=cartStore.subtotal};var cartStorePreviousStep=function(){if(cartStore.step==="shipping"){cartStore.step="customer-info";
|
|
502
513
|
// set shipping step to done
|
|
@@ -508,10 +519,10 @@ cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{payment:O
|
|
|
508
519
|
// set customer-info step to done
|
|
509
520
|
cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{"customer-info":Object.assign(Object.assign({},cartStore.tabItems["customer-info"]),{isDone:true})})}else if(cartStore.step==="shipping"){cartStore.step="payment";
|
|
510
521
|
// set shipping step to done
|
|
511
|
-
cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{shipping:Object.assign(Object.assign({},cartStore.tabItems.shipping),{isDone:true})})}else if(cartStore.step==="payment"){cartStore.step="finish"}};var cartStoreResetTabItems=function(){cartStore.step="customer-info";cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{"customer-info":Object.assign(Object.assign({},cartStore.tabItems["customer-info"]),{isDone:false}),payment:Object.assign(Object.assign({},cartStore.tabItems.payment),{isDone:false}),shipping:Object.assign(Object.assign({},cartStore.tabItems.shipping),{isDone:false})});cartStoreResetSelectedShippingOption()};var cartStoreUpdateStoreCreditImmediate=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,d;return __generator(this,(function(
|
|
522
|
+
cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{shipping:Object.assign(Object.assign({},cartStore.tabItems.shipping),{isDone:true})})}else if(cartStore.step==="payment"){cartStore.step="finish"}};var cartStoreResetTabItems=function(){cartStore.step="customer-info";cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{"customer-info":Object.assign(Object.assign({},cartStore.tabItems["customer-info"]),{isDone:false}),payment:Object.assign(Object.assign({},cartStore.tabItems.payment),{isDone:false}),shipping:Object.assign(Object.assign({},cartStore.tabItems.shipping),{isDone:false})});cartStoreResetSelectedShippingOption()};var cartStoreUpdateStoreCreditImmediate=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,d;return __generator(this,(function(l){switch(l.label){case 0:if(!storageStore.checkoutSessionId){log("Could not update store credit without checkout session id","info");return[2/*return*/]}r=cartStore.selectedLandedCost;o=cartStore.currency||((e=cartStore.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"";n=cartStore.adjustments.reduce((function(e,t){return e+t.amount}),0);i=cartStore.items.reduce((function(e,t){return e+t.amount*t.quantity}),0);return[4/*yield*/,stripeStoreUpdateCheckoutSession({adjustmentsAmount:n,cartId:window.Zonos.cartId,currency:o,id:storageStore.checkoutSessionId,itemsAmount:i,landedCostId:r===null||r===void 0?void 0:r.landedCostId,presentmentCountryCode:localizationStore.selectedCountryCode,storeCreditApplication:storeCreditStoreGetInput()})];case 1:a=l.sent(),s=a.errors,d=a.json;if(s.length>0||!d){logError("Error updating checkout session with store credit");return[2/*return*/]}
|
|
512
523
|
// Apply updated subtotals from the response
|
|
513
524
|
cartStoreApplySubtotals({method:((t=d.checkoutSessionUpdate.landedCost)===null||t===void 0?void 0:t.method)||"DDP",subtotals:d.checkoutSessionUpdate.subtotals});cartStoreSetCheckoutSession(d.checkoutSessionUpdate);return[2/*return*/]}}))}))};
|
|
514
525
|
/**
|
|
515
526
|
* Update the checkout session with the current store credit selection.
|
|
516
527
|
* Debounced to prevent multiple rapid requests when store changes cascade.
|
|
517
|
-
*/var cartStoreUpdateStoreCredit=function(){if(storeCreditUpdateTimeout){clearTimeout(storeCreditUpdateTimeout)}storeCreditUpdateTimeout=setTimeout((function(){storeCreditUpdateTimeout=null;void cartStoreUpdateStoreCreditImmediate()}),300)};export{
|
|
528
|
+
*/var cartStoreUpdateStoreCredit=function(){if(storeCreditUpdateTimeout){clearTimeout(storeCreditUpdateTimeout)}storeCreditUpdateTimeout=setTimeout((function(){storeCreditUpdateTimeout=null;void cartStoreUpdateStoreCreditImmediate()}),300)};export{cartStoreGetMethod as $,storeCreditStoreApplyCredit as A,storeCreditStoreCoversFullAmount as B,validateCheckoutSession as C,storeCreditStoreCreateOrder as D,stripeStoreConfirmPayment as E,stripeStoreHandleInventoryRefund as F,policyConsentStore as G,stripeStoreReset as H,cartStoreOnChange as I,stripeStoreOnChange as J,storeCreditStoreGetEffectiveAmount as K,cartStoreHasOneEligibleItem as L,isEuDapRemittance as M,stripeStoreApplyPromoCode as N,stripeStoreRemovePromoCode as O,stripeStoreResetPromoCode as P,stripeStoreMessageBasedOnStatus as Q,storeCreditStore as R,storeCreditStoreReset as S,stripeStoreRecordPolicyConsent as T,extractName as U,resolveTaxIdSelection as V,stripeStoreTranslateAddressToLatin as W,getCountryField as X,stripeStoreAsyncAddressUpdate as Y,cartStoreUpdateSelectedShippingOption as Z,cartStoreGetShippingTransitInfo as _,stripeStoreSaveDomesticShippingSession as a,sortServiceLevelOptionsByAmount as a0,stripeStoreBuildAddressForPartyCreate as a1,getEnabledPolicies as a2,storeCreditStoreSetEnabled as a3,storeCreditStoreSetUseFullBalance as a4,cartStoreUpdateStoreCredit as a5,storeCreditStoreSetAmount as a6,storeCreditStoreRefreshBalance as a7,stripeStore as b,stripeStoreRetrievePayment as c,cartStore as d,cartStoreUpdateItems as e,cartStoreReset as f,getCheckoutSession as g,cartStoreResetTabItems as h,initStripeElements as i,cartStoreClearCheckoutInterval as j,stripeStoreInitCheckoutSession as k,stripeStoreGetPaymentIntent as l,cartStoreIsOrderModificationPaymentOnlySession as m,stripeStoreHandleInventoryCheck as n,cartStoreStartCheckoutInterval as o,policyConsentStoreReset as p,getCheckoutSessionBody as q,cartStoreUpdateToErrorState as r,stripeStoreGetDomesticShippingSession as s,trackConversionEvent as t,stripeStoreCleanupDomesticShippingSession as u,cartStoreSetCheckoutSession as v,stripeStorePrefetchLandedCost as w,cartStoreNextStep as x,isPolicyConsentRequired as y,stripeStoreUpdateCheckoutSessionBaseCurrency as z};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,r,t,n){function i(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(t,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n["throw"](e))}catch(e){o(e)}}function u(e){e.done?t(e.value):i(e.value).then(a,s)}u((n=n.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(n)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(n=1,i&&(o=s[0]&2?i["return"]:s[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;if(i=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;i=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(o=t.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){t.label=s[1];break}if(s[0]===6&&t.label<o[1]){t.label=o[1];o=s;break}if(o&&t.label<o[2]){t.label=o[2];t.ops.push(s);break}if(o[2])t.ops.pop();t.trys.pop();continue}s=r.call(e,t)}catch(e){s=[6,e];i=0}finally{n=o=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-
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,r,t,n){function i(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(t,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n["throw"](e))}catch(e){o(e)}}function u(e){e.done?t(e.value):i(e.value).then(a,s)}u((n=n.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["return"]=s(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(n)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(n=1,i&&(o=s[0]&2?i["return"]:s[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;if(i=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;i=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(o=t.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){t.label=s[1];break}if(s[0]===6&&t.label<o[1]){t.label=o[1];o=s;break}if(o&&t.label<o[2]){t.label=o[2];t.ops.push(s);break}if(o[2])t.ops.pop();t.trys.pop();continue}s=r.call(e,t)}catch(e){s=[6,e];i=0}finally{n=o=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-BXP9FvIt.js";import{t as translate,l as localizationStore,s as storageStore}from"./localization-DHM91diu.js";import{l as logError$1,h as handleFetch,s as sendErrorLog}from"./handleFetch-D5GYDF-O.js";import{l as log,b as allLogs}from"./VarianceTest-BJmZPrZl.js";import{d as cartStore,Z as cartStoreUpdateSelectedShippingOption,b as stripeStore,a1 as stripeStoreBuildAddressForPartyCreate}from"./cart-DmJkjiDE.js";
|
|
2
2
|
// src/constant/common.ts
|
|
3
3
|
function _array_like_to_array(e,r){if(r==null||r>e.length)r=e.length;for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _array_with_holes(e){if(Array.isArray(e))return e}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function asyncGeneratorStep(e,r,t,n,i,o,a){try{var s=e[o](a);var u=s.value}catch(e){t(e);return}if(s.done){r(u)}else{Promise.resolve(u).then(n,i)}}function _async_to_generator(e){return function(){var r=this,t=arguments;return new Promise((function(n,i){var o=e.apply(r,t);function a(e){asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(undefined)}))}}function _class_call_check(e,r){if(!(e instanceof r)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _create_class(e,r,t){if(r)_defineProperties(e.prototype,r);return e}function _define_property(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function _instanceof(e,r){if(r!=null&&typeof Symbol!=="undefined"&&r[Symbol.hasInstance]){return!!r[Symbol.hasInstance](e)}else{return e instanceof r}}function _iterable_to_array(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function _iterable_to_array_limit(e,r){var t=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t==null)return;var n=[];var i=true;var o=false;var a,s;try{for(t=t.call(e);!(i=(a=t.next()).done);i=true){n.push(a.value);if(n.length===r)break}}catch(e){o=true;s=e}finally{try{if(!i&&t["return"]!=null)t["return"]()}finally{if(o)throw s}}return n}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};var n=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){n=n.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))}n.forEach((function(r){_define_property(e,r,t[r])}))}return e}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}function _object_spread_props(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _sliced_to_array(e,r){return _array_with_holes(e)||_iterable_to_array_limit(e,r)||_unsupported_iterable_to_array(e,r)||_non_iterable_rest()}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,r){if(!e)return;if(typeof e==="string")return _array_like_to_array(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor)t=e.constructor.name;if(t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return _array_like_to_array(e,r)}function _ts_generator(e,r){var t,n,i,o,a={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(r){return u([e,r])}}function u(o){if(t)throw new TypeError("Generator is already executing.");while(a)try{if(t=1,n&&(i=o[0]&2?n["return"]:o[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;if(n=0,i)o=[o[0]&2,i.value];switch(o[0]){case 0:case 1:i=o;break;case 4:a.label++;return{value:o[1],done:false};case 5:a.label++;n=o[1];o=[0];continue;case 7:o=a.ops.pop();a.trys.pop();continue;default:if(!(i=a.trys,i=i.length>0&&i[i.length-1])&&(o[0]===6||o[0]===2)){a=0;continue}if(o[0]===3&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(o[0]===6&&a.label<i[1]){a.label=i[1];i=o;break}if(i&&a.label<i[2]){a.label=i[2];a.ops.push(o);break}if(i[2])a.ops.pop();a.trys.pop();continue}o=r.call(e,a)}catch(e){o=[6,e];n=0}finally{t=i=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}}var Environment=function(e){e["production"]="prod";e["demo"]="demo";e["staging"]="staging";return e}(Environment||{});
|
|
4
4
|
// src/constant/config.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as require_root,i as require_baseGetTag,j as requireIsObjectLike,r as requireIsObject}from"./zonosStore-BXP9FvIt.js";var now_1;var hasRequiredNow;function requireNow(){if(hasRequiredNow)return now_1;hasRequiredNow=1;var e=require_root();
|
|
2
2
|
/**
|
|
3
3
|
* Gets the timestamp of the number of milliseconds that have elapsed since
|
|
4
4
|
* the Unix epoch (1 January 1970 00:00:00 UTC).
|
|
@@ -133,21 +133,21 @@ import{f as require_root,h as require_baseGetTag,i as requireIsObjectLike,r as r
|
|
|
133
133
|
*
|
|
134
134
|
* // Cancel the trailing debounced invocation.
|
|
135
135
|
* jQuery(window).on('popstate', debounced.cancel);
|
|
136
|
-
*/function o(o,a,d){var s,f,m,b,c,q,
|
|
136
|
+
*/function o(o,a,d){var s,f,m,b,c,q,v=0,_=false,h=false,T=true;if(typeof o!="function"){throw new TypeError(i)}a=n(a)||0;if(e(d)){_=!!d.leading;h="maxWait"in d;m=h?u(n(d.maxWait)||0,a):m;T="trailing"in d?!!d.trailing:T}function I(e){var r=s,n=f;s=f=undefined;v=e;b=o.apply(n,r);return b}function R(e){
|
|
137
137
|
// Reset any `maxWait` timer.
|
|
138
|
-
|
|
138
|
+
v=e;
|
|
139
139
|
// Start the timer for the trailing edge.
|
|
140
140
|
c=setTimeout(N,a);
|
|
141
141
|
// Invoke the leading edge.
|
|
142
|
-
return
|
|
142
|
+
return _?I(e):b}function l(e){var r=e-q,n=e-v,i=a-r;return h?t(i,m-n):i}function y(e){var r=e-q,n=e-v;
|
|
143
143
|
// Either this is the first call, activity has stopped and we're at the
|
|
144
144
|
// trailing edge, the system time has gone backwards and we're treating
|
|
145
145
|
// it as the trailing edge, or we've hit the `maxWait` limit.
|
|
146
146
|
return q===undefined||r>=a||r<0||h&&n>=m}function N(){var e=r();if(y(e)){return x(e)}
|
|
147
147
|
// Restart the timer.
|
|
148
|
-
c=setTimeout(N,
|
|
148
|
+
c=setTimeout(N,l(e))}function x(e){c=undefined;
|
|
149
149
|
// Only invoke if we have `lastArgs` which means `func` has been
|
|
150
150
|
// debounced at least once.
|
|
151
|
-
if(T&&s){return I(e)}s=f=undefined;return b}function w(){if(c!==undefined){clearTimeout(c)}
|
|
151
|
+
if(T&&s){return I(e)}s=f=undefined;return b}function w(){if(c!==undefined){clearTimeout(c)}v=0;s=q=f=c=undefined}function E(){return c===undefined?b:x(r())}function S(){var e=r(),n=y(e);s=arguments;f=this;q=e;if(n){if(c===undefined){return R(q)}if(h){
|
|
152
152
|
// Handle invocations in a tight loop.
|
|
153
|
-
clearTimeout(c);c=setTimeout(N,a);return I(q)}}if(c===undefined){c=setTimeout(N,a)}return b}
|
|
153
|
+
clearTimeout(c);c=setTimeout(N,a);return I(q)}}if(c===undefined){c=setTimeout(N,a)}return b}S.cancel=w;S.flush=E;return S}debounce_1=o;return debounce_1}export{requireDebounce as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as getDefaultExportFromCjs}from"./zonosStore-BXP9FvIt.js";import{r as requireDebounce}from"./debounce-DHj2iHA1.js";var debounceExports=requireDebounce();var debounce=getDefaultExportFromCjs(debounceExports);export{debounce as d};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{z as zonosStore}from"./zonosStore-BXP9FvIt.js";
|
|
2
|
+
/**
|
|
3
|
+
* Get the border radius for the elements based on the style
|
|
4
|
+
* @param overrideBorderStyle
|
|
5
|
+
* @returns
|
|
6
|
+
*/var getBorderRadius=function(o){var r=(o===null||o===void 0?void 0:o.customRoundRadius)||"10px";var t=o===null||o===void 0?void 0:o.overrideBorderStyle;if(t){
|
|
7
|
+
// If the override is set, use that, otherwise use the default radius style
|
|
8
|
+
return t==="SHARP"?"0px":r}return zonosStore.appearance.style==="SHARP"?"0px":r};export{getBorderRadius as g};
|