@zonos/elements 1.5.0 → 1.5.2
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-BJpqPdFU.js} +100 -64
- package/dist/cjs/{collect-DnrvaXUI.js → collect-CyUttsvB.js} +4 -4
- 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-DEbNbRAZ.js} +1 -1
- package/dist/cjs/{handleFetch-DQLhurnE.js → handleFetch-DVfjFTYO.js} +181 -71
- package/dist/cjs/{hasInclusivePrice-CPCoVeU3.js → hasInclusivePrice-CEPf3_FG.js} +1 -1
- package/dist/cjs/index.cjs.js +116 -13
- package/dist/cjs/{invoice-Cj8W7NW0.js → invoice-DzRkkpLu.js} +4 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{localization-BzNeXeDe.js → localization-BhNVhLZs.js} +725 -89
- package/dist/cjs/{paypal-CuKshRmZ.js → paypal-DCSqbdjW.js} +5 -5
- package/dist/cjs/{placeTestOrder-7czjwkjm.js → placeTestOrder-Bkip4PUT.js} +3 -3
- package/dist/cjs/{renderCheckoutCurrency-BH8t2b2x.js → renderCheckoutCurrency-BDvEZ3Hv.js} +2 -2
- package/dist/cjs/shouldRenderShortAddressCodeInput-gpu_bMfp.js +21 -0
- package/dist/cjs/{shouldShowLanguageSelect-yAbtCmd8.js → shouldShowLanguageSelect-NOVWOU53.js} +1 -1
- package/dist/cjs/{submitGtag-D79e8u6s.js → submitGtag-D4sB7w4z.js} +2 -2
- package/dist/cjs/{throttle-zSVRQLC0.js → taxIdFields-e4OCgr8K.js} +57 -2
- package/dist/cjs/taxIdRules-BBj8kQxJ.js +58 -0
- package/dist/cjs/{updateCheckoutSessionAttributes-jMtfOL2m.js → updateCheckoutSessionAttributes-KxwcsKhM.js} +2 -2
- package/dist/cjs/zonos-address-completion-dialog_7.cjs.entry.js +26 -31
- package/dist/cjs/zonos-address-display_2.cjs.entry.js +4 -4
- package/dist/cjs/zonos-address_4.cjs.entry.js +28 -31
- package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +8 -7
- 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 +9 -8
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +91 -86
- package/dist/cjs/zonos-checkbox_2.cjs.entry.js +2 -2
- package/dist/cjs/zonos-checkout.cjs.entry.js +15 -14
- package/dist/cjs/zonos-collapse.cjs.entry.js +1 -1
- package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +7 -6
- package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +13 -12
- package/dist/cjs/zonos-collect.cjs.entry.js +10 -9
- package/dist/cjs/zonos-controller.cjs.entry.js +10 -9
- package/dist/cjs/zonos-country-flag.cjs.entry.js +3 -3
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +4 -4
- package/dist/cjs/zonos-elements.cjs.js +1 -1
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +5 -5
- package/dist/cjs/zonos-hello.cjs.entry.js +5 -5
- package/dist/cjs/zonos-input.cjs.entry.js +2 -2
- package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +9 -8
- package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +13 -12
- package/dist/cjs/zonos-invoice.cjs.entry.js +10 -9
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +3 -3
- package/dist/cjs/zonos-logo.cjs.entry.js +1 -1
- package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +8 -7
- 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-checkout-finish/zonos-checkout-finish.js +8 -7
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +4 -3
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +12 -4
- package/dist/collection/components/main/zonos-controller.js +3 -2
- package/dist/collection/components/store/checkout/cart.js +3 -2
- package/dist/collection/components/store/checkout/stripe.js +20 -21
- package/dist/collection/components/store/storageStore.js +7 -6
- 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/__tests__/helpers/blockStorage.js +24 -0
- package/dist/collection/components/utils/api/getExchangeRate.js +2 -1
- 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/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/handleFetch.js +19 -9
- package/dist/collection/components/utils/hello/countryOverrideStorage.js +17 -40
- package/dist/collection/components/utils/logging/installConstructorCapture.js +58 -0
- package/dist/collection/components/utils/logging/reportBlockedStorage.js +34 -0
- package/dist/collection/components/utils/logging/sendErrorLog.js +8 -1
- package/dist/collection/components/utils/logging/startZonosInit.js +35 -0
- package/dist/collection/components/utils/logging/thrownMessage.js +16 -0
- package/dist/collection/components/utils/safeStorage.js +39 -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/scripts/_getZonosQaUrl.js +3 -2
- package/dist/collection/scripts/_zonosBase.js +6 -2
- package/dist/collection/types/checkout/TaxId.js +31 -0
- package/dist/collection/types/generated/graphql.frontend.types.js +0 -16
- package/dist/collection/types/generated/graphql.internal.types.js +215 -1
- package/dist/esm/{TaxId-Cye-evFK.js → TaxId-DMIgN_sT.js} +32 -1
- package/dist/esm/{cart-BoQp8Ema.js → cart-BS5mSI8x.js} +100 -65
- package/dist/esm/{collect-Eo4gtyql.js → collect-B9ZxDDl7.js} +4 -4
- 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-BkEV865q.js} +1 -1
- package/dist/esm/{handleFetch-D5GYDF-O.js → handleFetch-BFVO7oAR.js} +178 -72
- package/dist/esm/{hasInclusivePrice-CbEfIhI5.js → hasInclusivePrice-zSvDReDb.js} +1 -1
- package/dist/esm/index.js +106 -13
- package/dist/esm/{invoice-S1KahJ_Z.js → invoice-6iTuS6ek.js} +4 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{localization-BIh-4pc_.js → localization-CXHiWcJp.js} +725 -89
- package/dist/esm/{paypal-DNfvnuUU.js → paypal-BE_NVBoy.js} +5 -5
- package/dist/esm/{placeTestOrder-CQaMKFOg.js → placeTestOrder-BXA9K9Iy.js} +3 -3
- package/dist/esm/{renderCheckoutCurrency-C2Tw73uR.js → renderCheckoutCurrency-KMa4HlAf.js} +2 -2
- package/dist/esm/shouldRenderShortAddressCodeInput-Bc8k2vN0.js +19 -0
- package/dist/esm/{shouldShowLanguageSelect-CCD7gpSY.js → shouldShowLanguageSelect-BI_ApEsQ.js} +1 -1
- package/dist/esm/{submitGtag-df9AQ2zL.js → submitGtag-C5xzFHjG.js} +2 -2
- package/dist/esm/taxIdFields-BUKnHMaL.js +139 -0
- package/dist/esm/taxIdRules-xYlx7ZXW.js +47 -0
- package/dist/esm/{updateCheckoutSessionAttributes-4Jq6V4pO.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +2 -2
- package/dist/esm/zonos-address-completion-dialog_7.entry.js +24 -29
- package/dist/esm/zonos-address-display_2.entry.js +4 -4
- package/dist/esm/zonos-address_4.entry.js +26 -29
- package/dist/esm/zonos-airwallex-payment.entry.js +8 -7
- 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 +9 -8
- package/dist/esm/zonos-cart-items_12.entry.js +90 -85
- package/dist/esm/zonos-checkbox_2.entry.js +2 -2
- package/dist/esm/zonos-checkout.entry.js +15 -14
- package/dist/esm/zonos-collapse.entry.js +1 -1
- package/dist/esm/zonos-collect-cart-items_3.entry.js +7 -6
- package/dist/esm/zonos-collect-finish_6.entry.js +13 -12
- package/dist/esm/zonos-collect.entry.js +10 -9
- package/dist/esm/zonos-controller.entry.js +10 -9
- package/dist/esm/zonos-country-flag.entry.js +3 -3
- package/dist/esm/zonos-country-select_4.entry.js +4 -4
- package/dist/esm/zonos-elements.js +1 -1
- package/dist/esm/zonos-hello-dialog.entry.js +5 -5
- package/dist/esm/zonos-hello.entry.js +5 -5
- package/dist/esm/zonos-input.entry.js +2 -2
- package/dist/esm/zonos-invoice-cart-items_2.entry.js +9 -8
- package/dist/esm/zonos-invoice-finish_5.entry.js +13 -12
- package/dist/esm/zonos-invoice.entry.js +10 -9
- package/dist/esm/zonos-language-select_2.entry.js +3 -3
- package/dist/esm/zonos-logo.entry.js +1 -1
- package/dist/esm/zonos-policy-consent_2.entry.js +8 -7
- 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-BS5mSI8x.js} +42 -31
- package/dist/esm-es5/{collect-Eo4gtyql.js → collect-B9ZxDDl7.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-BkEV865q.js} +3 -3
- package/dist/esm-es5/handleFetch-BFVO7oAR.js +73 -0
- package/dist/esm-es5/{hasInclusivePrice-CbEfIhI5.js → hasInclusivePrice-zSvDReDb.js} +1 -1
- package/dist/esm-es5/index.js +30 -12
- package/dist/esm-es5/{invoice-S1KahJ_Z.js → invoice-6iTuS6ek.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/localization-CXHiWcJp.js +345 -0
- package/dist/esm-es5/{paypal-DNfvnuUU.js → paypal-BE_NVBoy.js} +1 -1
- package/dist/esm-es5/{placeTestOrder-CQaMKFOg.js → placeTestOrder-BXA9K9Iy.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-C2Tw73uR.js → renderCheckoutCurrency-KMa4HlAf.js} +1 -1
- package/dist/esm-es5/shouldRenderShortAddressCodeInput-Bc8k2vN0.js +8 -0
- package/dist/esm-es5/{shouldShowLanguageSelect-CCD7gpSY.js → shouldShowLanguageSelect-BI_ApEsQ.js} +1 -1
- package/dist/esm-es5/{submitGtag-df9AQ2zL.js → submitGtag-C5xzFHjG.js} +1 -1
- package/dist/esm-es5/taxIdFields-BUKnHMaL.js +46 -0
- package/dist/esm-es5/taxIdRules-xYlx7ZXW.js +6 -0
- package/dist/esm-es5/{updateCheckoutSessionAttributes-4Jq6V4pO.js → updateCheckoutSessionAttributes-C9bMKTjz.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 +6 -6
- package/dist/esm-es5/zonos-cart-items_12.entry.js +137 -136
- package/dist/esm-es5/zonos-checkbox_2.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +3 -3
- 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 +6 -6
- package/dist/esm-es5/zonos-controller.entry.js +5 -5
- 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 +3 -3
- 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 +103 -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/__tests__/helpers/blockStorage.d.ts +3 -0
- 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/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/logging/installConstructorCapture.d.ts +20 -0
- package/dist/types/components/utils/logging/reportBlockedStorage.d.ts +16 -0
- package/dist/types/components/utils/logging/startZonosInit.d.ts +5 -0
- package/dist/types/components/utils/logging/thrownMessage.d.ts +1 -0
- package/dist/types/components/utils/safeStorage.d.ts +4 -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/scripts/cart/_setupCartDataWithSettings.d.ts +5 -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/generated/graphql.frontend.types.d.ts +0 -22
- package/dist/types/types/generated/graphql.frontend.types.ts +0 -51
- package/dist/types/types/generated/graphql.internal.types.d.ts +270 -1
- package/dist/types/types/generated/graphql.internal.types.ts +341 -1
- package/dist/types/types/utils/ZonosSettings.d.ts +5 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-08b01c96.entry.js +1 -0
- package/dist/zonos-elements/{p-c961caaf.entry.js → p-0909ef77.entry.js} +1 -1
- package/dist/zonos-elements/{p-23352709.system.entry.js → p-13015d34.system.entry.js} +4 -4
- package/dist/zonos-elements/{p-6c41b00c.entry.js → p-13d5b2f9.entry.js} +1 -1
- package/dist/zonos-elements/{p-5b80aff2.system.entry.js → p-150047b3.system.entry.js} +25 -25
- package/dist/zonos-elements/p-1986cc37.entry.js +1 -0
- package/dist/zonos-elements/{p-CBx5nYet.system.js → p-1OG3IJgY.system.js} +1 -1
- package/dist/zonos-elements/{p-d3d0656a.entry.js → p-1a5acbcd.entry.js} +1 -1
- package/dist/zonos-elements/{p-756d303f.system.entry.js → p-20eb00de.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-9c33f7ed.system.entry.js → p-30bf4700.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d168023b.entry.js → p-3466bcba.entry.js} +1 -1
- package/dist/zonos-elements/p-383343c7.entry.js +1 -0
- package/dist/zonos-elements/{p-06030d3b.system.entry.js → p-3a506614.system.entry.js} +54 -54
- package/dist/zonos-elements/p-43c0ebe9.entry.js +1 -0
- package/dist/zonos-elements/{p-acd50b0b.entry.js → p-4612facd.entry.js} +1 -1
- package/dist/zonos-elements/{p-244e0302.system.entry.js → p-4715045c.system.entry.js} +1 -1
- package/dist/zonos-elements/p-4b65f192.entry.js +1 -0
- package/dist/zonos-elements/{p-5967a1c1.system.entry.js → p-573a4e7c.system.entry.js} +6 -6
- package/dist/zonos-elements/p-59fc32af.entry.js +1 -0
- package/dist/zonos-elements/{p-d82fd8a9.system.entry.js → p-5a296dbc.system.entry.js} +117 -116
- package/dist/zonos-elements/{p-193d9722.entry.js → p-61312d5b.entry.js} +1 -1
- package/dist/zonos-elements/{p-6abec43f.system.entry.js → p-68325c5a.system.entry.js} +4 -4
- package/dist/zonos-elements/{p-0b81f8b9.system.entry.js → p-6db7317a.system.entry.js} +6 -6
- package/dist/zonos-elements/{p-51400242.system.entry.js → p-709d1561.system.entry.js} +3 -3
- package/dist/zonos-elements/p-71d29603.entry.js +1 -0
- package/dist/zonos-elements/{p-7bd99479.system.entry.js → p-7214c953.system.entry.js} +21 -21
- package/dist/zonos-elements/p-74659d88.entry.js +1 -0
- package/dist/zonos-elements/{p-55916c90.entry.js → p-7f1bea9b.entry.js} +1 -1
- package/dist/zonos-elements/{p-0fca452b.entry.js → p-7fe83919.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-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-8ac26831.entry.js +1 -0
- package/dist/zonos-elements/{p-a40fd99b.system.entry.js → p-8f9f859f.system.entry.js} +39 -40
- 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-b5882fbb.system.entry.js → p-9449b4f4.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-31043c2e.system.entry.js → p-96b250d8.system.entry.js} +298 -299
- package/dist/zonos-elements/p-97729873.entry.js +1 -0
- package/dist/zonos-elements/{p-1bac5ac1.system.entry.js → p-990fcf81.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-7f031592.system.entry.js → p-9b3668a4.system.entry.js} +155 -155
- package/dist/zonos-elements/{p-249c1ee1.system.entry.js → p-9df31243.system.entry.js} +3 -3
- package/dist/zonos-elements/p-BD-9rD53.js +1 -0
- package/dist/zonos-elements/p-BI6VAB5B.js +1 -0
- package/dist/zonos-elements/p-BJFa5RwX.js +1 -0
- package/dist/zonos-elements/p-BJ_kE5rM.js +1 -0
- package/dist/zonos-elements/{p-Be3Hpms1.system.js → p-BKUlQxBd.system.js} +1 -1
- package/dist/zonos-elements/p-BUfCTQXY.system.js +528 -0
- package/dist/zonos-elements/{p-CZD8WvyY.system.js → p-BnQyot7Y.system.js} +23 -23
- package/dist/zonos-elements/p-Bu9WCfUC.system.js +2 -2
- package/dist/zonos-elements/{p-0mGRBGcf.js → p-C-zdj7MK.js} +1 -1
- package/dist/zonos-elements/p-C5fs3rIR.js +1 -0
- package/dist/zonos-elements/{p-sz4L-ZnB.js → p-CJmWr75U.js} +1 -1
- package/dist/zonos-elements/{p-XDxdMlQl.system.js → p-CMneHjck.system.js} +15 -15
- package/dist/zonos-elements/p-CP7KnfR3.system.js +245 -0
- package/dist/zonos-elements/p-CVRbGFV3.js +1 -0
- package/dist/zonos-elements/p-CYxMfUL7.system.js +1 -0
- package/dist/zonos-elements/p-Cl5yV0ak.js +1 -0
- package/dist/zonos-elements/{p-kaOxUR9u.system.js → p-Cp1IAJvW.system.js} +5 -5
- 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-D-Lnf8mS.system.js +345 -0
- package/dist/zonos-elements/p-D0DkOoAw.system.js +73 -0
- package/dist/zonos-elements/{p-c9QtIdJX.js → p-D4xpkSsK.js} +1 -1
- package/dist/zonos-elements/p-DATNIakn.js +1 -0
- package/dist/zonos-elements/{p-D4MevhAL.system.js → p-DC1OPJDq.system.js} +3 -3
- package/dist/zonos-elements/{p-8PPEbm_0.system.js → p-DIab60nK.system.js} +12 -12
- package/dist/zonos-elements/p-DKnphvmJ.js +1 -0
- package/dist/zonos-elements/{p-Cye-evFK.js → p-DMIgN_sT.js} +1 -1
- 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-DoEHepOc.system.js → p-DXlojp_Y.system.js} +1 -1
- package/dist/zonos-elements/p-DqVePqqx.system.js +8 -0
- package/dist/zonos-elements/{p-B4Ufchqh.system.js → p-DrS-0mk7.system.js} +3 -3
- package/dist/zonos-elements/{p-7abqRc9V.js → p-DrbN3rPL.js} +2 -2
- package/dist/zonos-elements/{p-Cby4EkFu.system.js → p-DsBuZ6ob.system.js} +2 -1
- package/dist/zonos-elements/{p-DI2vXnXc.system.js → p-Dv5a-V6w.system.js} +1 -1
- package/dist/zonos-elements/p-Dwg61Ft_.js +1 -0
- package/dist/zonos-elements/{p-474e8a92.system.entry.js → p-a1022808.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-17c7ea4a.system.entry.js → p-a3c147d2.system.entry.js} +3 -3
- package/dist/zonos-elements/p-aK18R41t.js +1 -0
- package/dist/zonos-elements/{p-83aa1c8c.entry.js → p-ad04bba2.entry.js} +1 -1
- package/dist/zonos-elements/p-af4ad54b.entry.js +1 -0
- package/dist/zonos-elements/p-af741506.entry.js +1 -0
- package/dist/zonos-elements/{p-a938c174.entry.js → p-b51010b9.entry.js} +1 -1
- package/dist/zonos-elements/{p-6db7c0b1.system.entry.js → p-b540c636.system.entry.js} +2 -2
- package/dist/zonos-elements/p-bac94956.entry.js +1 -0
- package/dist/zonos-elements/{p-69c3e367.system.entry.js → p-bb1b414a.system.entry.js} +9 -9
- package/dist/zonos-elements/{p-b79036fc.entry.js → p-bfa9e32a.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-cf6bf7a4.entry.js +1 -0
- package/dist/zonos-elements/{p-CEK_Wk6v.system.js → p-dJcbnNlE.system.js} +1 -1
- package/dist/zonos-elements/p-db40b9c3.entry.js +1 -0
- package/dist/zonos-elements/p-dd003161.entry.js +1 -0
- package/dist/zonos-elements/{p-2603dce0.entry.js → p-e216cc8c.entry.js} +1 -1
- package/dist/zonos-elements/p-e374aaa4.entry.js +1 -0
- package/dist/zonos-elements/{p-155ed3d3.system.entry.js → p-e43470f7.system.entry.js} +21 -21
- package/dist/zonos-elements/p-ebc7ea54.system.entry.js +13 -0
- package/dist/zonos-elements/{p-11defdca.system.entry.js → p-f2ed52bc.system.entry.js} +8 -8
- package/dist/zonos-elements/{p-d4d2b39e.entry.js → p-fddf3556.entry.js} +1 -1
- package/dist/zonos-elements/p-gEViRqvf.js +1 -0
- package/dist/zonos-elements/{p-BpDCLBwW.js → p-n5PZKz1k.js} +1 -1
- package/dist/zonos-elements/{p-C_z9WL8a.js → p-r-YGHhLa.js} +1 -1
- package/dist/zonos-elements/{p-XqkqjeNV.system.js → p-yv7ekcdG.system.js} +2 -2
- 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/package.json +1 -1
- 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/handleFetch-D5GYDF-O.js +0 -60
- 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-06fe2939.entry.js +0 -1
- package/dist/zonos-elements/p-24f3c547.entry.js +0 -1
- package/dist/zonos-elements/p-30b3c9d3.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-4679f0ec.entry.js +0 -1
- package/dist/zonos-elements/p-4806b264.system.entry.js +0 -13
- package/dist/zonos-elements/p-5873ab8e.entry.js +0 -1
- 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-CFbfEmjN.js +0 -1
- package/dist/zonos-elements/p-CUaf1cEg.js +0 -1
- package/dist/zonos-elements/p-CXxvn4GX.system.js +0 -227
- 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-DE4a-QD5.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
- package/dist/zonos-elements/p-zVLAvre1.system.js +0 -60
|
@@ -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-CXHiWcJp.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,c as safeGetItem,e as safeSetItem,b as safeRemoveItem,j as jsonParse}from"./handleFetch-BFVO7oAR.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()};
|
|
@@ -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,35 +87,35 @@ 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 c=t.value.address,l=c.city,u=c.country,S=c.line1,v=c.line2,p=c.postal_code,f=c.state;var
|
|
93
|
+
*/var getTranslatedAddress=function(e){var t=e.currentAddress,r=e.translatedAddress;var o,n,i,a,s,d;var c=t.value.address,l=c.city,u=c.country,S=c.line1,v=c.line2,p=c.postal_code,f=c.state;var m=t.value.name||[t.value.firstName,t.value.lastName].join(" ");return{city:((o=r.city)===null||o===void 0?void 0:o[l])||l,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[m])||m,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,c=s.lastName;var l=getTranslatedAddress({currentAddress:i,translatedAddress:stripeStore.translatedAddress.address});var u=extractName({name:l.name}),S=u.firstName,v=u.lastName;var p=getOverridenZCountry()||"US";return{billingAddress:{addressLine1:l.line1,addressLine2:l.line2||"",city:l.city,country:l.country,postalCode:l.postal_code,state:l.state},billingContact:{
|
|
100
|
+
var a=getTranslatedAddress({currentAddress:n,translatedAddress:stripeStore.translatedAddress.address});var s=extractName({name:a.name}),d=s.firstName,c=s.lastName;var l=getTranslatedAddress({currentAddress:i,translatedAddress:stripeStore.translatedAddress.address});var u=extractName({name:l.name}),S=u.firstName,v=u.lastName;var p=getOverridenZCountry()||"US";var f=shipToTaxIdFields(a.country);return Object.assign(Object.assign({billingAddress:{addressLine1:l.line1,addressLine2:l.line2||"",city:l.city,country:l.country,postalCode:l.postal_code,state:l.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
103
|
firstName:S,lastName:v,phone:l.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:c,phone:a.phone},isTest:!!r,landedCostAdjustments:cartStore.promoCode?[{amount:0,productId:null,promoCode:cartStore.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToShortAddressCode:stripeStore.shortAddressCode,
|
|
108
|
+
firstName:d,lastName:c,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 c=extractName({name:d.name}),l=c.firstName,u=c.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;return{billingAddress:{addressLine1:d.line1,addressLine2:d.line2||"",city:d.city,country:d.country,postalCode:d.postal_code,state:d.state},billingContact:{
|
|
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 c=extractName({name:d.name}),l=c.firstName,u=c.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
115
|
firstName:l,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,c,l;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
|
|
@@ -151,9 +162,9 @@ if(!a||!s){return null}
|
|
|
151
162
|
// only translate if there are invalid characters
|
|
152
163
|
if(!t&&!r){return null}var d=o.value;var c=(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 l=extractName({firstName:d.firstName,lastName:d.lastName,name:d.name}),u=l.firstName,S=l.lastName;var v="".concat(u," ").concat(S);var p=extractName({firstName:c===null||c===void 0?void 0:c.firstName,lastName:c===null||c===void 0?void 0:c.lastName,name:(c===null||c===void 0?void 0:c.name)||""}),f=p.firstName,
|
|
165
|
+
var l=extractName({firstName:d.firstName,lastName:d.lastName,name:d.name}),u=l.firstName,S=l.lastName;var v="".concat(u," ").concat(S);var p=extractName({firstName:c===null||c===void 0?void 0:c.firstName,lastName:c===null||c===void 0?void 0:c.lastName,name:(c===null||c===void 0?void 0:c.name)||""}),f=p.firstName,m=p.lastName;var h=f&&m?"".concat(f," ").concat(m):"";var g=d.address;var C=c===null||c===void 0?void 0:c.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
|
-
billingAddress:!i?getExcludeAddressFieldsObject({address:C?Object.assign(Object.assign({},C),{name:
|
|
167
|
+
billingAddress:!i?getExcludeAddressFieldsObject({address:C?Object.assign(Object.assign({},C),{name:h}):null,invalidAdddressList:r}):undefined,destinationCountry:g.country}};
|
|
157
168
|
/**
|
|
158
169
|
* Sorts service levels with lower cost first
|
|
159
170
|
*/var sortServiceLevelOptionsByAmount=function(e){var t=e.sort((function(e,t){return e.amount-t.amount}));return t};
|
|
@@ -163,12 +174,12 @@ billingAddress:!i?getExcludeAddressFieldsObject({address:C?Object.assign(Object.
|
|
|
163
174
|
// need to reset everything and the paddingTop to default, otherwise the paddingTop will not be updated.
|
|
164
175
|
padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",
|
|
165
176
|
// any value here will be add up to the default paddingTop (20px).
|
|
166
|
-
paddingTop:"6px"},".Label--resting":{fontSize:zonosStore.appearance.fontSizeInputLabel?"".concat(zonosStore.appearance.fontSizeInputLabel,"px"):undefined},".PickerItem--highlight":{boxShadow:"0 0 0 2px var(--colorBackground)"},".PickerItem--highlight:hover":{backgroundColor:"var(--colorBackground)",boxShadow:"none"},".PickerItem--new":{color:"var(--colorText)"},".Tab--selected":{borderStyle:"solid",borderWidth:"1px"}};switch(t){case"DARK":{return Object.assign(Object.assign({},r),{".Action":Object.assign(Object.assign({},r[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},r[".PickerItem--new"]),{color:"white"})})}default:return r}};var defaultVariable=function(e){var t=e.borderStyle,r=e.theme;switch(r){case"DARK":return{borderRadius:getBorderRadius({overrideBorderStyle:t}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:getBorderRadius({overrideBorderStyle:t}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"}}};var checkoutPaymentProcessorType={Airwallex:"AIRWALLEX",Paypal:"PAYPAL",Stripe:"STRIPE"};var _q=createStore((function(){return{checkoutSettlementCurrency:"USD",clientSecret:
|
|
177
|
+
paddingTop:"6px"},".Label--resting":{fontSize:zonosStore.appearance.fontSizeInputLabel?"".concat(zonosStore.appearance.fontSizeInputLabel,"px"):undefined},".PickerItem--highlight":{boxShadow:"0 0 0 2px var(--colorBackground)"},".PickerItem--highlight:hover":{backgroundColor:"var(--colorBackground)",boxShadow:"none"},".PickerItem--new":{color:"var(--colorText)"},".Tab--selected":{borderStyle:"solid",borderWidth:"1px"}};switch(t){case"DARK":{return Object.assign(Object.assign({},r),{".Action":Object.assign(Object.assign({},r[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},r[".PickerItem--new"]),{color:"white"})})}default:return r}};var defaultVariable=function(e){var t=e.borderStyle,r=e.theme;switch(r){case"DARK":return{borderRadius:getBorderRadius({overrideBorderStyle:t}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:getBorderRadius({overrideBorderStyle:t}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"}}};var checkoutPaymentProcessorType={Airwallex:"AIRWALLEX",Paypal:"PAYPAL",Stripe:"STRIPE"};var _q=createStore((function(){return{checkoutSettlementCurrency:"USD",clientSecret:safeGetItem("session","zonos--client-secret")||"",companyName:"",companyNameUsedWhenAsyncAddressUpdate:"",customAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:false,state:""},customBillingAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:false,state:""},customErrorMessage:null,customerProfile:null,fetchingLandedCostAbortController:null,hasPaymentError:false,isFetchingLandedCost:false,isFetchingSession:false,partyBillingId:null,partyShippingId:null,shortAddressCode:"",shouldInventoryRefund:false,shouldRenderPayInUsdButton:false,
|
|
167
178
|
/**
|
|
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 c=window.Zonos.isCollect||window.Zonos.isInvoice?zonosStore.appearance.theme==="DARK":s&&isDarkColor(s);var l=c?"night":"flat";
|
|
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 c=window.Zonos.isCollect||window.Zonos.isInvoice?zonosStore.appearance.theme==="DARK":s&&isDarkColor(s);var l=c?"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
|
|
@@ -178,9 +189,9 @@ theme:i?u:l,variables:Object.assign(Object.assign({},defaultVariable({borderStyl
|
|
|
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
|
|
181
|
-
clientSecret:v,customerSessionClientSecret:stripeStore.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],S,true),locale:localizationStore.selectedLocale}};var stripeStoreCleanupDomesticShippingSession=function(){
|
|
192
|
+
clientSecret:v,customerSessionClientSecret:stripeStore.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],S,true),locale:localizationStore.selectedLocale}};var stripeStoreCleanupDomesticShippingSession=function(){safeRemoveItem("session","zonos--bigcommerce-domestic-checkout-shipping")};
|
|
182
193
|
// Save shipping address to session storage
|
|
183
|
-
var stripeStoreSaveDomesticShippingSession=function(e){
|
|
194
|
+
var stripeStoreSaveDomesticShippingSession=function(e){safeSetItem("session","zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))};var stripeStoreGetDomesticShippingSession=function(){var e=safeGetItem("session","zonos--bigcommerce-domestic-checkout-shipping");return jsonParse(e)};var initStripeElements=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i;return __generator(this,(function(a){o=stripeStore.clientSecret;if(!stripeStore.stripe){log("Skip. Stripe is not initialized");return[2/*return*/]}n=getStripeOptions({clientSecret:o,overrideBorderRadius:e===null||e===void 0?void 0:e.overrideBorderRadius,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideSecondaryColor:e===null||e===void 0?void 0:e.overrideSecondaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme,paypalEnabled:e===null||e===void 0?void 0:e.paypalEnabled});i=JSON.stringify(n)===JSON.stringify(stripeStore.stripeElementsOptions);if(!stripeStore.stripeElements||!stripeStore.stripeElementsForBillingAddress){
|
|
184
195
|
// init stripe elements for billing address
|
|
185
196
|
stripeStore.stripeElementsForBillingAddress=(t=stripeStore.stripe)===null||t===void 0?void 0:t.elements(n);log("Stripe elements for billing address initialized");
|
|
186
197
|
// init stripe elements if it doesn't exist
|
|
@@ -194,7 +205,7 @@ stripeStore.stripeElementsForBillingAddress.update(n);
|
|
|
194
205
|
// save stripe elements options for later comparison
|
|
195
206
|
stripeStore.stripeElementsOptions=n;void stripeStore.stripeElements.fetchUpdates()}log("Stripe elements updated");return[2/*return*/]}))}))};var stripeStoreReset=function(){
|
|
196
207
|
// clean clientSecret so that we can start the new one.
|
|
197
|
-
|
|
208
|
+
safeRemoveItem("session","zonos--client-secret");
|
|
198
209
|
// cleanup stripe elements
|
|
199
210
|
reset$1();
|
|
200
211
|
// set stripe back to window.Zonos.stripe
|
|
@@ -206,13 +217,13 @@ stripeStore.stripe=window.Zonos.stripe};var checkIsAddressOutdatedForValidation=
|
|
|
206
217
|
// If haven't prefetched landed cost, there is no need to update address async
|
|
207
218
|
if(!d||!c){return false}
|
|
208
219
|
// If we don't have landed cost parties data, should way
|
|
209
|
-
if(stripeStore.partyShippingId!==d||stripeStore.partyBillingId!==c){return true}var l=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;var p=stripeStore.companyNameUsedWhenAsyncAddressUpdate!==stripeStore.companyName;return l||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,c,l,u;return __generator(this,(function(
|
|
220
|
+
if(stripeStore.partyShippingId!==d||stripeStore.partyBillingId!==c){return true}var l=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 l||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,c,l,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});c=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";l=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:c,rootId:i,shortAddressCode:stripeStore.shortAddressCode,taxId:(n=l===null||l===void 0?void 0:l.taxId)!==null&&n!==void 0?n:""},(l===null||l===void 0?void 0:l.taxIdType)?{taxIdType:l.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};
|
|
@@ -242,7 +253,7 @@ stripeStore.fetchingLandedCostAbortController=null;cartStore.partiesData=(s===nu
|
|
|
242
253
|
// update cart store with landed cost info
|
|
243
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))||[];c=storageStore.checkoutSessionId;if(o===null||o===void 0?void 0:o.length){void trackConversionEvent({checkoutSessionId:c,eventName:"checkout_quoteReceived"})}l=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=l;
|
|
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(!l){
|
|
256
|
+
if(!l){safeSetItem("session","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,c,l,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
|
|
@@ -270,7 +281,7 @@ if(cartStore.step==="payment"){cartStorePreviousStep()}
|
|
|
270
281
|
// async update address with new root id from the new quote
|
|
271
282
|
return[4/*yield*/,stripeStoreAsyncAddressUpdate()];case 2:
|
|
272
283
|
// async update address with new root id from the new quote
|
|
273
|
-
n.sent();r=(e=cartStore.shippingData)===null||e===void 0?void 0:e.find(Boolean);o=(t=cartStore.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCost.id===(r===null||r===void 0?void 0:r.id)}));if(!r||!o){return[2/*return*/]}return[4/*yield*/,cartStoreUpdateSelectedShippingOption({applySubtotalsOnly:false,landedCostId:o.landedCostId,selectedShippingOption:r})];case 3:n.sent();return[2/*return*/]}}))}))};var stripeStoreResetPromoCode=function(){cartStore.promoCode="";
|
|
284
|
+
n.sent();r=(e=cartStore.shippingData)===null||e===void 0?void 0:e.find(Boolean);o=(t=cartStore.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCost.id===(r===null||r===void 0?void 0:r.id)}));if(!r||!o){return[2/*return*/]}return[4/*yield*/,cartStoreUpdateSelectedShippingOption({applySubtotalsOnly:false,landedCostId:o.landedCostId,selectedShippingOption:r})];case 3:n.sent();return[2/*return*/]}}))}))};var stripeStoreResetPromoCode=function(){cartStore.promoCode="";safeRemoveItem("session","zonos--promo-code");
|
|
274
285
|
// reset promocode error state
|
|
275
286
|
cartStore.promoCodeError=false;cartStore.promoCodeApplied=false};var stripeStoreRemovePromoCode=function(){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:
|
|
276
287
|
// Go back to shipping step if we are in payment step so user can reselect shipping method
|
|
@@ -396,7 +407,7 @@ stripeStore.stripeAddressUsedWhenValidatingAddress=stripeStore.stripeAddressEven
|
|
|
396
407
|
// Set the translated address to the store so we can populate it to the address element for user to update
|
|
397
408
|
stripeStore.translatedAddress={address:l?buildTranslatedAddress({currentAddress:Object.assign(Object.assign({},l),{name:(o=stripeStore.stripeAddressEventData)===null||o===void 0?void 0:o.value.name}),translatedAddressResult:c.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:c.billingAddress||null}):{}};return[2/*return*/]}}))}))};stripeStoreOnChange("clientSecret",(function(e){
|
|
398
409
|
// update stripe elements when client secret changes
|
|
399
|
-
if(e&&stripeStore.stripe){
|
|
410
|
+
if(e&&stripeStore.stripe){safeSetItem("session","zonos--client-secret",e)}if(!e){safeRemoveItem("session","zonos--client-secret")}}));
|
|
400
411
|
/**
|
|
401
412
|
* EU 3-EUR cutover (05CHECK-893): when shipping to an EU country with a POSTAL
|
|
402
413
|
* service level whose DAP landed cost has remittance available, we keep treating
|
|
@@ -405,9 +416,9 @@ if(e&&stripeStore.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e
|
|
|
405
416
|
* estimated and paid on delivery.
|
|
406
417
|
*
|
|
407
418
|
* @see [[cartStoreGetMethod]] for the DAP/DDP conversion this guards.
|
|
408
|
-
*/var isEuDapRemittance=function(e){var t=e.deliveryType,r=e.landedCost,o=e.shipToCountry;return r.method==="DAP"&&t==="POSTAL"&&r.remittance.length>0&&!!o&&euCountryCodes.includes(o)};var _r=createStore((function(){return{addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:false,checkoutTimeoutInterval:null,currency:"USD",customMessage:[],customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:false,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,isStagingMode:getIsStagingMode(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:
|
|
419
|
+
*/var isEuDapRemittance=function(e){var t=e.deliveryType,r=e.landedCost,o=e.shipToCountry;return r.method==="DAP"&&t==="POSTAL"&&r.remittance.length>0&&!!o&&euCountryCodes.includes(o)};var _r=createStore((function(){return{addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:false,checkoutTimeoutInterval:null,currency:"USD",customMessage:[],customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:false,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,isStagingMode:getIsStagingMode(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:safeGetItem("session","zonos--promo-code")||"",
|
|
409
420
|
// When user clicked applied button, save promocode into session storage for later use. So if session has promocode, applied button is clicked
|
|
410
|
-
promoCodeApplied:!!
|
|
421
|
+
promoCodeApplied:!!safeGetItem("session","zonos--promo-code"),promoCodeError:false,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:false,step:"customer-info",storeCredit:0,subtotal:0,tabItems:{"customer-info":{index:1,isDone:false,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:false,label:"Shipping",value:"shipping"},
|
|
411
422
|
// eslint-disable-next-line sort-keys/sort-keys-fix
|
|
412
423
|
payment:{index:3,isDone:false,label:"Payment",value:"payment"}},total:0}})),cartStoreOnChange=_r.onChange,reset=_r.reset,cartStore=_r.state;var getTransitUnit=function(e){switch(e){case"DAYS":return translate("days");case"WEEKS":return translate("weeks");case"BUSINESS_DAYS":default:return translate("business days")}};
|
|
413
424
|
/**
|
|
@@ -474,17 +485,17 @@ 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,l,u,S,v,p,f,h,
|
|
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,c,l,u,S,v,p,f,m,h,g,C,y,w,b,A,I,O,_;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,m=v.unit;cartStore.selectedShippingOptionTransitTime="".concat(f,"-").concat(p," ").concat(m)}else{cartStore.selectedShippingOptionTransitTime=""}h=(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
|
-
cartStore.selectedLandedCost=
|
|
490
|
+
cartStore.selectedLandedCost=h||null;if(!h){
|
|
480
491
|
// do nothing if we can't find landed cost for selected shipping option
|
|
481
|
-
return[2/*return*/,false]}g=((r=
|
|
492
|
+
return[2/*return*/,false]}g=((r=h.landedCost.amountSubtotals)===null||r===void 0?void 0:r.landedCostTotal)||0;C=h.subtotals.exchangeRate.rate;y=g*C;if(y){log("DAP quote, using estimate: ".concat(y),"info")}cartStore.landedCostMethod=cartStoreGetMethod(h.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=
|
|
494
|
+
cartStore.shipping=h.subtotals.shipping;w=((n=h===null||h===void 0?void 0:h.landedCost)===null||n===void 0?void 0:n.landedCostGuaranteeCode)==="ZONOS";b=!!((a=(i=h===null||h===void 0?void 0:h.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];I=h.subtotals;cartStoreApplySubtotals({dutiesTaxesFeesEstimate:y,method:cartStore.landedCostMethod,subtotals:I});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=h.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:O=(d=cartStore.items.find(Boolean))===null||d===void 0?void 0:d.currencyCode;_=((c=stripeStore.stripeAddressEventData)===null||c===void 0?void 0:c.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=O==="USD"&&zonosStore.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((l=cartStore.checkoutSession)===null||l===void 0?void 0:l.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
|
|
@@ -514,4 +525,4 @@ cartStoreApplySubtotals({method:((t=d.checkoutSessionUpdate.landedCost)===null||
|
|
|
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-CXHiWcJp.js";import{l as logError$1,h as handleFetch,s as sendErrorLog}from"./handleFetch-BFVO7oAR.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-BS5mSI8x.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};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{U as extractName}from"./cart-
|
|
1
|
+
import{U as extractName}from"./cart-BS5mSI8x.js";
|
|
2
2
|
/**
|
|
3
3
|
* Minimum number of characters we treat as a valid postal code. Mirrors the
|
|
4
4
|
* landed-cost readiness check in `stripe.ts` (`isAddressReadyToRequestLandedCost`).
|
|
@@ -14,7 +14,7 @@ import{U as extractName}from"./cart-BoQp8Ema.js";
|
|
|
14
14
|
*
|
|
15
15
|
* Pure: the caller resolves `countryField` (via `getCountryField`) and passes it in, so
|
|
16
16
|
* this can be unit-tested without the stores.
|
|
17
|
-
*/var getMissingRequiredShippingFields=function(i){var
|
|
17
|
+
*/var getMissingRequiredShippingFields=function(i){var e=i.countryField,a=i.event;var r,t,v;if(!a){return[]}var l=a.value;var o=[];
|
|
18
18
|
// Last name is always required for international shipping. Link's single name input
|
|
19
19
|
// often provides only a first name, leaving the extracted last name empty.
|
|
20
|
-
var s=extractName({firstName:
|
|
20
|
+
var s=extractName({firstName:l.firstName,lastName:l.lastName,name:l.name}).lastName;if(!s.trim()){o.push({key:"lastName"})}if((e===null||e===void 0?void 0:e.stateRequired)&&!((r=l.address.state)===null||r===void 0?void 0:r.trim())){o.push({key:"state"})}if((e===null||e===void 0?void 0:e.zipRequired)&&((v=(t=l.address.postal_code)===null||t===void 0?void 0:t.trim().length)!==null&&v!==void 0?v:0)<MIN_POSTAL_CODE_LENGTH){o.push({key:"postal_code"})}return o};export{MIN_POSTAL_CODE_LENGTH as M,getMissingRequiredShippingFields as g};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,n,r,t){function o(e){return e instanceof r?e:new r((function(n){n(e)}))}return new(r||(r=Promise))((function(r,i){function a(e){try{u(t.next(e))}catch(e){i(e)}}function s(e){try{u(t["throw"](e))}catch(e){i(e)}}function u(e){e.done?r(e.value):o(e.value).then(a,s)}u((t=t.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,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(n){return u([e,n])}}function u(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(r=0)),r)try{if(t=1,o&&(i=s[0]&2?o["return"]:s[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;if(o=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++;o=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=n.call(e,r)}catch(e){s=[6,e];o=0}finally{t=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,n,r){if(r||arguments.length===2)for(var t=0,o=n.length,i;t<o;t++){if(i||!(t in n)){if(!i)i=Array.prototype.slice.call(n,0,t);i[t]=n[t]}}return e.concat(i||Array.prototype.slice.call(n))};import{l as log}from"./VarianceTest-BJmZPrZl.js";var fallbackApiType=["cloudflare","vercel"];var MAIN_BASE_API_TYPE=fallbackApiType[0];var fallbackApiList={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"};var MAIN_BASE_API=fallbackApiList[MAIN_BASE_API_TYPE];
|
|
2
|
+
/**
|
|
3
|
+
* Next available fallback api type
|
|
4
|
+
*/var getNextFallbackApiType=function(e){if(e===void 0){e=MAIN_BASE_API_TYPE}var n=fallbackApiType.indexOf(e);var r=fallbackApiType[n+1];if(!r){return null}return r};
|
|
5
|
+
/**
|
|
6
|
+
* This is the time in milliseconds after release time that we will start sending error logs to the new API
|
|
7
|
+
* @default 1 hour
|
|
8
|
+
*/var postReleaseReportingDuration=1*3600*1e3;// 1 hour
|
|
9
|
+
var loggedHref=function(){var e=new URL(window.location.href);e.searchParams.delete("payment_intent");e.searchParams.delete("payment_intent_client_secret");e.searchParams.delete("redirect_status");return e.toString()};var sendErrorLog=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,r,t,o,i;var a=e.endpoint,s=e.errors,u=e.metadata,d=e.shouldPostReleaseErrorReporting;return __generator(this,(function(e){log("sendErrorLog","warn",a,u,s);if(d){n=Number(window.Zonos.releaseDate);r=(new Date).getTime();if(r-n>postReleaseReportingDuration){return[2/*return*/]}}t="userAgentData"in window.navigator?// userAgentData is not yet supported in all browsers
|
|
10
|
+
window.navigator.userAgentData:null;o={endpoint:a,errors:s,href:loggedHref(),metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:t&&t.brands.length>0?t:window.navigator.userAgent},u)};try{
|
|
11
|
+
// use native fetch because in handleFetch also calls sendErrorLog and it will possibly cause circular dependencies issue
|
|
12
|
+
void fetch("".concat(MAIN_BASE_API,"/api/zonos-elements/log-error"),{body:JSON.stringify(o),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){i=getNextFallbackApiType();if(!i){return[2/*return*/]}
|
|
13
|
+
// request to the fallback API if the first one fails
|
|
14
|
+
void fetch("".concat(fallbackApiList[i],"/api/zonos-elements/log-error"),{body:JSON.stringify(o),method:"POST"})}return[2/*return*/]}))}))};var thrownMessage=function(e,n){if(typeof e==="string"&&e){return e}if(e instanceof Error&&e.message){return e.message}if(typeof e==="object"&&e!==null&&"message"in e&&typeof e.message==="string"&&e.message){return e.message}return n};var logError=function(e){var n=[];for(var r=1;r<arguments.length;r++){n[r-1]=arguments[r]}log.apply(void 0,__spreadArray([e,"error"],n,false))};var reportedIds=function(){if(!window.__zonosReportedBlockedStorage){window.__zonosReportedBlockedStorage=new Set}return window.__zonosReportedBlockedStorage};
|
|
15
|
+
/**
|
|
16
|
+
* Record a blocked storage read or write on the existing error log.
|
|
17
|
+
* A throw before `window.Zonos` exists is swallowed and does not use up
|
|
18
|
+
* the per-page dedupe slot, so the later startup read can still report it.
|
|
19
|
+
*/var reportBlockedStorage=function(e,n,r,t){if(typeof window.Zonos==="undefined"){return}var o="".concat(e,"\0").concat(n,"\0").concat(r);var i=reportedIds();if(i.has(o)){return}i.add(o);void sendErrorLog({endpoint:"storage://".concat(e,"/").concat(r),errors:[thrownMessage(t,"SecurityError")],metadata:{area:e,key:r,operation:n,shape:"blocked-storage"}})};
|
|
20
|
+
/**
|
|
21
|
+
* Touch `window.localStorage` / `window.sessionStorage` inside the try.
|
|
22
|
+
* Safari throws SecurityError on the getter itself when storage is blocked.
|
|
23
|
+
* A missing storage object is the same failure: calling `getItem` on it
|
|
24
|
+
* would report a TypeError instead of blocked storage.
|
|
25
|
+
*/var storageFor=function(e){var n=e==="local"?window.localStorage:window.sessionStorage;if(!n){throw new DOMException("","SecurityError")}return n};var safeGetItem=function(e,n){try{return storageFor(e).getItem(n)}catch(r){reportBlockedStorage(e,"getItem",n,r);return null}};var safeRemoveItem=function(e,n){try{storageFor(e).removeItem(n)}catch(r){reportBlockedStorage(e,"removeItem",n,r)}};var safeSetItem=function(e,n,r){try{storageFor(e).setItem(n,r)}catch(r){reportBlockedStorage(e,"setItem",n,r)}};var getIsStagingMode=function(){return window.location.search.includes("zonosStagingMode=1")};var getIsTestMode=function(){var e;return((e=window.Zonos.zonosApiKey)===null||e===void 0?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};var jsonParse=function(e){if(typeof e==="string"){try{
|
|
26
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
27
|
+
var n=JSON.parse(e);return n}catch(e){return null}}return null};var checkoutBreakpoint=890;var isCheckoutMobile=function(e){return e||window.innerWidth<checkoutBreakpoint};var getNavigatorConnection=function(){var e="connection"in window.navigator?// connection is not yet supported in all browsers
|
|
28
|
+
window.navigator.connection:null;var n="mozConnection"in window.navigator?// mozConnection is not yet supported in all browsers
|
|
29
|
+
window.navigator.mozConnection:null;var r="webkitConnection"in window.navigator?// webkitConnection is not yet supported in all browsers
|
|
30
|
+
window.navigator.webkitConnection:null;var t=e||n||r;return t};var getAdditionalLogMetadata=function(){var e="userAgentData"in window.navigator?// userAgentData is not yet supported in all browsers
|
|
31
|
+
window.navigator.userAgentData:null;var n=getNavigatorConnection();return{connectionDownlink:n===null||n===void 0?void 0:n.downlink,connectionEffectiveType:n===null||n===void 0?void 0:n.effectiveType,connectionRtt:n===null||n===void 0?void 0:n.rtt,connectionSaveData:n===null||n===void 0?void 0:n.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}};var blackListPaths=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"];
|
|
32
|
+
/**
|
|
33
|
+
* Prepares the load time api log for the given API call to send to the server later
|
|
34
|
+
* This function is used to prepare the load time api log for the given API call.
|
|
35
|
+
* It adds the load time api log to the loadTimeApiInfoList.
|
|
36
|
+
*/var prepLoadTimeApiLog=function(e){var n=e.apiPath,r=e.apiType,t=e.loadTimeInternal,o=e.loadTimeTotal;if(blackListPaths.includes(n)){return}var i=o-t;
|
|
37
|
+
// No need to record if the browser API load time is negative (cached)
|
|
38
|
+
if(i<0){return}
|
|
39
|
+
// e.g. /api/zonos-elements/log-script-load?zonosDebug=1 -> /api/zonos-elements/log-script-load
|
|
40
|
+
var a=n.split("?")[0]||n;var s=getAdditionalLogMetadata();var u=typeof s.userAgent==="object"&&s.userAgent.mobile;var d={apiType:r,connectionType:s.connectionEffectiveType,href:a,isHostedCheckout:window.Zonos.isLegacyCheckout,
|
|
41
|
+
// Use the isMobileAgent to determine if the checkout is mobile, if it's not availabe, use the logic from isCheckoutMobile
|
|
42
|
+
isMobile:isCheckoutMobile(u),loadTimeBrowserApi:i,loadTimeInternal:t,loadTimeTotal:o,metadata:Object.assign({},s),screenHeight:s.screenHeight,screenWidth:s.screenWidth,userAgent:typeof s.userAgent==="string"?s.userAgent:s.userAgent["brands"].map((function(e){return e.brand})).filter((function(e){return!/Not.*A.*Brand.*/.test(e)})).join(",")};window.Zonos.loadTimeApiInfoList.push(d)};var __rest=undefined&&undefined.__rest||function(e,n){var r={};for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0)r[t]=e[t];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,t=Object.getOwnPropertySymbols(e);o<t.length;o++){if(n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o]))r[t[o]]=e[t[o]]}return r};var isGatewayStatus=function(e){return e===502||e===503||e===504};var getResponseBody=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,r,t;var o=e.response,i=e.shouldLog,a=i===void 0?true:i,s=e.shouldThrow,u=s===void 0?false:s;return __generator(this,(function(e){switch(e.label){case 0:e.trys.push([0,2,,3]);return[4/*yield*/,o.text()];case 1:n=e.sent();r=jsonParse(n);if(!r){throw new Error("Failed to parse content: ".concat(n))}return[2/*return*/,r];case 2:t=e.sent();if(u){throw t}if(a){
|
|
43
|
+
// eslint-disable-next-line
|
|
44
|
+
console.error(t)}return[2/*return*/,null];case 3:return[2/*return*/]}}))}))};var encodeString=function(e){try{
|
|
45
|
+
// encode the string, remove the "=" at the end of the encoded string
|
|
46
|
+
var n=btoa(e).replace(/=/g,"");return n}catch(n){
|
|
47
|
+
// return the reverse string if the encoding failed
|
|
48
|
+
return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}};var handleRequest=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,r,t,o,i,a,s,u,d,l,c,l,f,v,s,w,s;var p=e.basePathType,g=e.options,h=e.path;return __generator(this,(function(e){switch(e.label){case 0:r=window.Zonos.zonosQaUrlApi||fallbackApiList[p]||MAIN_BASE_API_TYPE;t=r+h;o=new URL(t);i=window.Zonos.cartId?"".concat(window.location.hostname,"-").concat(window.Zonos.cartId):window.location.hostname;o.searchParams.set("zToken",encodeString(i));e.label=1;case 1:e.trys.push([1,3,,4]);return[4/*yield*/,fetch(o.toString(),g)];case 2:n=e.sent();return[3/*break*/,4];case 3:a=e.sent();if(a instanceof Error){return[2/*return*/,{baseUrl:r,errors:[{message:a.message,type:"unknown"}],json:null,response:null,zonosMode:null}]}s="Failed to fetch";return[2/*return*/,{baseUrl:r,errors:[{message:s,type:"unknown"}],json:null,response:null,zonosMode:null}];case 4:u=n.headers.get("Zonos-Mode");d=window.Zonos.zonosQaUrl;
|
|
49
|
+
// We only want to alert once if the user is in preview mode and it's also using production environment
|
|
50
|
+
if(!window.Zonos.modeAlerted&&u&&d){window.Zonos.modeAlerted=true}if(!n.ok)return[3/*break*/,6];return[4/*yield*/,getResponseBody({response:n})];case 5:l=e.sent();return[2/*return*/,{baseUrl:r,errors:[],json:l,response:n,zonosMode:u}];case 6:c=n.status.toString();e.label=7;case 7:e.trys.push([7,9,,10]);return[4/*yield*/,getResponseBody({response:n,shouldThrow:true})];case 8:l=e.sent();
|
|
51
|
+
// Parse and access "errors" from the response if possible
|
|
52
|
+
if(l&&"errors"in l&&Array.isArray(l.errors)){f=l.errors;v=f.map((function(e){if(typeof e==="string"){return{message:e,type:c}}return e}));return[2/*return*/,{baseUrl:r,errors:v,json:null,response:n,zonosMode:u}]}s=JSON.stringify(l);return[2/*return*/,{baseUrl:r,errors:[{message:s,type:c}],json:null,response:n,zonosMode:u}];case 9:w=e.sent();s="Unknown error";
|
|
53
|
+
// A gateway HTML or empty body still carries a status a GET can fail over
|
|
54
|
+
// on. Other non-JSON statuses, including 404 and 500, keep the previous
|
|
55
|
+
// null response so they do not fail over.
|
|
56
|
+
return[2/*return*/,{baseUrl:r,errors:[{message:"".concat(c,": ").concat(s),type:c}],json:null,response:isGatewayStatus(n.status)?n:null,zonosMode:u}];case 10:return[2/*return*/]}}))}))};var handleRequestWithFallback=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,r,t,o,i,a,s,u,d,l,c,f,v,w,p,g,h,b,y,m,_,A;var k=e.basePathType,T=e.options,I=e.path;return __generator(this,(function(e){switch(e.label){case 0:o=I.startsWith("/api/bigcommerce");i=o?"vercel":k;a=performance.now();return[4/*yield*/,handleRequest({basePathType:i,options:T,path:I})];case 1:s=e.sent(),u=s.errors,d=s.response,l=__rest(s,["errors","response"]);c=performance.now();f=c-a;
|
|
57
|
+
// Send the load time api log
|
|
58
|
+
log("".concat(I," (").concat(f.toFixed(2),"ms)"),"info");v=d===null||d===void 0?void 0:d.headers.get("Zonos-Duration");
|
|
59
|
+
// Only record if the response status is 200, some endpoint will return 200 with error
|
|
60
|
+
if((d===null||d===void 0?void 0:d.status)===200){prepLoadTimeApiLog({apiPath:I,apiType:i,loadTimeInternal:v?Number(v):0,loadTimeTotal:f})}w=getNextFallbackApiType(i);p=u.find((function(e){var n=e.type;return n==="unknown"}));g=u.find((function(e){var n=e.message;return typeof n==="string"&&(n.includes("signal is aborted")||n.includes("The operation was aborted")||n.includes("Fetch is aborted"))}));h=d===null||d===void 0?void 0:d.status;b=h!==undefined&&isGatewayStatus(h);y=((n=T===null||T===void 0?void 0:T.method)!==null&&n!==void 0?n:"GET").toUpperCase()==="GET";m=!!p||h===404||h===500;_=m||b;A=w&&(m||b&&y);
|
|
61
|
+
// Should log the error if it's unknown error
|
|
62
|
+
if(_&&!g){void sendErrorLog({endpoint:fallbackApiList[i]+I,errors:u.map((function(e){var n=e.message;return"API: ".concat(n)})),metadata:{currentBasePath:i,nextFallbackApiType:w,requestHeaders:T===null||T===void 0?void 0:T.headers,requestPayload:jsonParse((r=T===null||T===void 0?void 0:T.body)===null||r===void 0?void 0:r.toString())||((t=T===null||T===void 0?void 0:T.body)===null||t===void 0?void 0:t.toString()),shouldCallFallback:A,status:d===null||d===void 0?void 0:d.status,statusText:d===null||d===void 0?void 0:d.statusText},
|
|
63
|
+
// When the error is unknown, error reporting should be enabled for period of time after release, so we can monitor the error.
|
|
64
|
+
shouldPostReleaseErrorReporting:true})}if(A){log('=== "'.concat(I,'" failed to fetch, trying next fallback ').concat(w));return[2/*return*/,handleRequestWithFallback({basePathType:w,options:T,path:I})]}
|
|
65
|
+
// No more fallbacks, just return the result
|
|
66
|
+
return[2/*return*/,Object.assign({errors:u,response:d},l)]}}))}))};
|
|
67
|
+
/**
|
|
68
|
+
* Fetch request and will request to fallback API when the first one fails
|
|
69
|
+
* @param path Path name of the request (e.g. /api/something/com).
|
|
70
|
+
* @param _opts fetch options
|
|
71
|
+
*/var handleFetch=function(e,n){return __awaiter(void 0,void 0,void 0,(function(){var r,t,o,i,a,s;return __generator(this,(function(u){r=__rest(n||{},[]);t=r.body?JSON.stringify(r.body):undefined;o=r.method||"GET";i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":getIsStagingMode()?"1":undefined,"Zonos-Test-Mode":getIsTestMode()?"1":undefined,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},r.headers);
|
|
72
|
+
// filter all underfined headers
|
|
73
|
+
Object.keys(i).forEach((function(e){return i[e]===undefined&&delete i[e]}));a=Object.assign(Object.assign({},r),{body:o==="GET"?undefined:t,headers:i,method:o});s=new URLSearchParams(window.location.search).get("useFallbackApi");return[2/*return*/,handleRequestWithFallback({basePathType:s||MAIN_BASE_API_TYPE,options:a,path:e})]}))}))};export{getIsStagingMode as a,safeRemoveItem as b,safeGetItem as c,getAdditionalLogMetadata as d,safeSetItem as e,fallbackApiList as f,getIsTestMode as g,handleFetch as h,isCheckoutMobile as i,jsonParse as j,logError as l,sendErrorLog as s,thrownMessage as t};
|