@zonos/elements 1.3.208 → 1.3.210

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/dist/cjs/{cart-47c17ebf.js → cart-313bd2ff.js} +288 -40
  2. package/dist/cjs/{debounce-0b9c0f8a.js → debounce-465a4328.js} +1 -1
  3. package/dist/cjs/{getBorderRadius-c424eb05.js → getBorderRadius-1b5e33cf.js} +1 -1
  4. package/dist/cjs/{handleFetch-969d05d8.js → handleFetch-05227713.js} +2 -6
  5. package/dist/cjs/index.cjs.js +8 -8
  6. package/dist/cjs/{isDarkColor-35e8daec.js → isDarkColor-428965f4.js} +1 -1
  7. package/dist/cjs/loader.cjs.js +1 -1
  8. package/dist/cjs/{localization-e9089be5.js → localization-9b43376c.js} +2 -2
  9. package/dist/cjs/{paypal-3a803d21.js → paypal-67c96668.js} +5 -5
  10. package/dist/cjs/{updateCheckoutSessionAttributes-d0332530.js → updateCheckoutSessionAttributes-a31bb681.js} +2 -2
  11. package/dist/cjs/zonos-address_11.cjs.entry.js +104 -84
  12. package/dist/cjs/zonos-badge.cjs.entry.js +1 -1
  13. package/dist/cjs/zonos-banner.cjs.entry.js +1 -1
  14. package/dist/cjs/zonos-button_3.cjs.entry.js +3 -3
  15. package/dist/cjs/zonos-card.cjs.entry.js +2 -2
  16. package/dist/cjs/zonos-cart-items_14.cjs.entry.js +91 -41
  17. package/dist/cjs/zonos-checkout.cjs.entry.js +45 -21
  18. package/dist/cjs/zonos-collapse.cjs.entry.js +1 -1
  19. package/dist/cjs/zonos-controller.cjs.entry.js +6 -6
  20. package/dist/cjs/zonos-country-flag.cjs.entry.js +3 -3
  21. package/dist/cjs/zonos-country-select_4.cjs.entry.js +13 -9
  22. package/dist/cjs/zonos-elements.cjs.js +1 -1
  23. package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +7 -7
  24. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +3 -3
  25. package/dist/cjs/zonos-hello.cjs.entry.js +4 -4
  26. package/dist/cjs/zonos-input.cjs.entry.js +2 -2
  27. package/dist/cjs/zonos-language-select_2.cjs.entry.js +3 -3
  28. package/dist/cjs/zonos-logo.cjs.entry.js +1 -1
  29. package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +2 -2
  30. package/dist/cjs/zonos-stripe-input.cjs.entry.js +3 -3
  31. package/dist/cjs/zonos-text.cjs.entry.js +1 -1
  32. package/dist/cjs/zonos-toggle.cjs.entry.js +1 -1
  33. package/dist/cjs/zonos-v-stack.cjs.entry.js +1 -1
  34. package/dist/cjs/{zonosStore-7c1e1bc1.js → zonosStore-f8ee56aa.js} +1 -0
  35. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +36 -12
  36. package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +63 -25
  37. package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +33 -11
  38. package/dist/collection/components/common/zonos-checkout-progress-tabs/zonos-checkout-progress-tabs.js +2 -2
  39. package/dist/collection/components/common/zonos-country-select/zonos-country-select.js +9 -5
  40. package/dist/collection/components/store/checkout/cart.js +9 -2
  41. package/dist/collection/components/store/checkout/stripe.js +269 -31
  42. package/dist/collection/components/stripe/zonos-address/zonos-address.css +2 -1
  43. package/dist/collection/components/stripe/zonos-address/zonos-address.js +24 -3
  44. package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.css +2 -1
  45. package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +7 -5
  46. package/dist/collection/components/utils/api/cartCalculateLandedCost.js +3 -2
  47. package/dist/collection/components/utils/api/prepCalculateLandedCost.js +2 -2
  48. package/dist/collection/components/utils/handleFetch.js +2 -1
  49. package/dist/collection/components/utils/logging/log.js +0 -5
  50. package/dist/collection/types/checkout/api/CreateParty.js +1 -0
  51. package/dist/collection/types/generated/graphql.internal.types.js +3 -0
  52. package/dist/collection/types/index.js +1 -0
  53. package/dist/esm/{cart-5b417c0d.js → cart-e0703306.js} +287 -41
  54. package/dist/esm/{debounce-7ebfa15b.js → debounce-0e42da22.js} +1 -1
  55. package/dist/esm/{getBorderRadius-174305ff.js → getBorderRadius-71b3b8ab.js} +1 -1
  56. package/dist/esm/{handleFetch-621e45bc.js → handleFetch-7dd4622b.js} +2 -6
  57. package/dist/esm/index.js +8 -8
  58. package/dist/esm/{isDarkColor-915b06b8.js → isDarkColor-3a9d6108.js} +1 -1
  59. package/dist/esm/loader.js +1 -1
  60. package/dist/esm/{localization-669a1714.js → localization-e17c211b.js} +2 -2
  61. package/dist/esm/{paypal-3a0cf86b.js → paypal-dbaf76fd.js} +6 -6
  62. package/dist/esm/{updateCheckoutSessionAttributes-183ca6c1.js → updateCheckoutSessionAttributes-5097e715.js} +2 -2
  63. package/dist/esm/zonos-address_11.entry.js +104 -84
  64. package/dist/esm/zonos-badge.entry.js +1 -1
  65. package/dist/esm/zonos-banner.entry.js +1 -1
  66. package/dist/esm/zonos-button_3.entry.js +3 -3
  67. package/dist/esm/zonos-card.entry.js +2 -2
  68. package/dist/esm/zonos-cart-items_14.entry.js +91 -41
  69. package/dist/esm/zonos-checkout.entry.js +45 -21
  70. package/dist/esm/zonos-collapse.entry.js +1 -1
  71. package/dist/esm/zonos-controller.entry.js +6 -6
  72. package/dist/esm/zonos-country-flag.entry.js +3 -3
  73. package/dist/esm/zonos-country-select_4.entry.js +13 -9
  74. package/dist/esm/zonos-elements.js +1 -1
  75. package/dist/esm/zonos-empty-state-payment_4.entry.js +7 -7
  76. package/dist/esm/zonos-hello-dialog.entry.js +3 -3
  77. package/dist/esm/zonos-hello.entry.js +4 -4
  78. package/dist/esm/zonos-input.entry.js +2 -2
  79. package/dist/esm/zonos-language-select_2.entry.js +3 -3
  80. package/dist/esm/zonos-logo.entry.js +1 -1
  81. package/dist/esm/zonos-shipping-rich-radio.entry.js +2 -2
  82. package/dist/esm/zonos-stripe-input.entry.js +3 -3
  83. package/dist/esm/zonos-text.entry.js +1 -1
  84. package/dist/esm/zonos-toggle.entry.js +1 -1
  85. package/dist/esm/zonos-v-stack.entry.js +1 -1
  86. package/dist/esm/{zonosStore-504a7030.js → zonosStore-00975763.js} +1 -1
  87. package/dist/esm-es5/cart-e0703306.js +1 -0
  88. package/dist/esm-es5/{debounce-7ebfa15b.js → debounce-0e42da22.js} +1 -1
  89. package/dist/esm-es5/{getBorderRadius-174305ff.js → getBorderRadius-71b3b8ab.js} +1 -1
  90. package/dist/esm-es5/handleFetch-7dd4622b.js +1 -0
  91. package/dist/esm-es5/index.js +1 -1
  92. package/dist/esm-es5/{isDarkColor-915b06b8.js → isDarkColor-3a9d6108.js} +1 -1
  93. package/dist/esm-es5/loader.js +1 -1
  94. package/dist/esm-es5/{localization-669a1714.js → localization-e17c211b.js} +1 -1
  95. package/dist/esm-es5/{paypal-3a0cf86b.js → paypal-dbaf76fd.js} +2 -2
  96. package/dist/esm-es5/{updateCheckoutSessionAttributes-183ca6c1.js → updateCheckoutSessionAttributes-5097e715.js} +1 -1
  97. package/dist/esm-es5/zonos-address_11.entry.js +1 -1
  98. package/dist/esm-es5/zonos-badge.entry.js +1 -1
  99. package/dist/esm-es5/zonos-banner.entry.js +1 -1
  100. package/dist/esm-es5/zonos-button_3.entry.js +1 -1
  101. package/dist/esm-es5/zonos-card.entry.js +1 -1
  102. package/dist/esm-es5/zonos-cart-items_14.entry.js +1 -1
  103. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  104. package/dist/esm-es5/zonos-collapse.entry.js +1 -1
  105. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  106. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  107. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  108. package/dist/esm-es5/zonos-elements.js +1 -1
  109. package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
  110. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  111. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  112. package/dist/esm-es5/zonos-input.entry.js +1 -1
  113. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  114. package/dist/esm-es5/zonos-logo.entry.js +1 -1
  115. package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
  116. package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
  117. package/dist/esm-es5/zonos-text.entry.js +1 -1
  118. package/dist/esm-es5/zonos-toggle.entry.js +1 -1
  119. package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
  120. package/dist/esm-es5/{zonosStore-504a7030.js → zonosStore-00975763.js} +1 -1
  121. package/dist/scripts/index.d.ts +8 -0
  122. package/dist/scripts/index.js +1 -1
  123. package/dist/scripts/loadZonos.js +1 -1
  124. package/dist/scripts/zonos.js +1 -1
  125. package/dist/types/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.d.ts +8 -4
  126. package/dist/types/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.d.ts +3 -0
  127. package/dist/types/components/common/zonos-country-select/zonos-country-select.d.ts +1 -0
  128. package/dist/types/components/store/checkout/cart.d.ts +6 -2
  129. package/dist/types/components/store/checkout/stripe.d.ts +33 -6
  130. package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +6 -0
  131. package/dist/types/types/checkout/api/CheckoutSession.d.ts +2 -0
  132. package/dist/types/types/checkout/api/CreateParty.d.ts +34 -0
  133. package/dist/types/types/generated/graphql.internal.types.d.ts +21 -5
  134. package/dist/types/types/generated/graphql.internal.types.ts +26 -3
  135. package/dist/types/types/index.d.ts +1 -0
  136. package/dist/types/types/utils/ZonosSettings.d.ts +6 -0
  137. package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
  138. package/dist/zonos-elements/index.esm.js +1 -1
  139. package/dist/zonos-elements/p-03c060d3.entry.js +1 -0
  140. package/dist/zonos-elements/{p-c5455a34.system.js → p-0751b878.system.js} +1 -1
  141. package/dist/zonos-elements/{p-0731fbba.entry.js → p-0ca1d6dd.entry.js} +1 -1
  142. package/dist/zonos-elements/{p-e1c2b8f8.entry.js → p-144b5006.entry.js} +1 -1
  143. package/dist/zonos-elements/{p-d5bdbbb3.system.js → p-19182dc7.system.js} +1 -1
  144. package/dist/zonos-elements/{p-066afca1.system.entry.js → p-1dc78af3.system.entry.js} +1 -1
  145. package/dist/zonos-elements/{p-5f2a2ca7.js → p-207bd04a.js} +1 -1
  146. package/dist/zonos-elements/p-20839c46.js +1 -0
  147. package/dist/zonos-elements/p-20b702a7.system.entry.js +1 -0
  148. package/dist/zonos-elements/{p-63ca1242.system.entry.js → p-2122d2cc.system.entry.js} +1 -1
  149. package/dist/zonos-elements/p-23142862.entry.js +1 -0
  150. package/dist/zonos-elements/{p-a09bdd20.system.entry.js → p-239695e8.system.entry.js} +1 -1
  151. package/dist/zonos-elements/{p-6b406abd.entry.js → p-23fe7661.entry.js} +1 -1
  152. package/dist/zonos-elements/p-2652198d.js +1 -0
  153. package/dist/zonos-elements/{p-4451a598.system.js → p-3633a952.system.js} +1 -1
  154. package/dist/zonos-elements/{p-6be43ba8.entry.js → p-36b686b6.entry.js} +1 -1
  155. package/dist/zonos-elements/p-37058486.system.entry.js +1 -0
  156. package/dist/zonos-elements/{p-081fa4a8.entry.js → p-3934b38a.entry.js} +1 -1
  157. package/dist/zonos-elements/p-3ee44728.system.js +1 -1
  158. package/dist/zonos-elements/{p-cd376c7a.system.entry.js → p-45a2f9b1.system.entry.js} +1 -1
  159. package/dist/zonos-elements/{p-0d908c15.system.js → p-4a1b4a2d.system.js} +1 -1
  160. package/dist/zonos-elements/p-4c70fd75.entry.js +1 -0
  161. package/dist/zonos-elements/{p-07905246.entry.js → p-4d62f3de.entry.js} +1 -1
  162. package/dist/zonos-elements/{p-bb850bb7.entry.js → p-4dbaa2c2.entry.js} +1 -1
  163. package/dist/zonos-elements/{p-c607d026.entry.js → p-5956a9e0.entry.js} +1 -1
  164. package/dist/zonos-elements/{p-b7a5b367.js → p-5b3b58ef.js} +2 -2
  165. package/dist/zonos-elements/{p-d096d7f2.entry.js → p-5b7686f8.entry.js} +1 -1
  166. package/dist/zonos-elements/{p-67f807bc.entry.js → p-63a4dac5.entry.js} +1 -1
  167. package/dist/zonos-elements/{p-7f568108.system.js → p-68650f1e.system.js} +2 -2
  168. package/dist/zonos-elements/{p-51d596a0.system.entry.js → p-695bf400.system.entry.js} +1 -1
  169. package/dist/zonos-elements/{p-d35d17f3.js → p-6aa728f2.js} +1 -1
  170. package/dist/zonos-elements/{p-4bf54953.js → p-71c6bdc3.js} +1 -1
  171. package/dist/zonos-elements/{p-39039ab7.system.entry.js → p-7211cb9f.system.entry.js} +1 -1
  172. package/dist/zonos-elements/{p-0f368368.system.js → p-738a49c0.system.js} +1 -1
  173. package/dist/zonos-elements/{p-ef594c0c.entry.js → p-73ff25d8.entry.js} +1 -1
  174. package/dist/zonos-elements/{p-7e346632.system.entry.js → p-74276b82.system.entry.js} +1 -1
  175. package/dist/zonos-elements/{p-d1a31577.entry.js → p-77e22be4.entry.js} +1 -1
  176. package/dist/zonos-elements/{p-a3a8ba10.entry.js → p-78dd1c53.entry.js} +1 -1
  177. package/dist/zonos-elements/{p-0fb14108.entry.js → p-7b02b1f6.entry.js} +1 -1
  178. package/dist/zonos-elements/p-7ec1fecb.system.js +1 -0
  179. package/dist/zonos-elements/{p-3d6f6367.system.entry.js → p-7f9bbbb3.system.entry.js} +1 -1
  180. package/dist/zonos-elements/{p-a4d995a2.system.js → p-8d0e116f.system.js} +1 -1
  181. package/dist/zonos-elements/{p-a63bac79.system.entry.js → p-8f41d864.system.entry.js} +1 -1
  182. package/dist/zonos-elements/{p-1f706fc9.system.entry.js → p-964e2587.system.entry.js} +1 -1
  183. package/dist/zonos-elements/{p-1530f958.system.entry.js → p-97831744.system.entry.js} +1 -1
  184. package/dist/zonos-elements/p-992f0b96.js +1 -0
  185. package/dist/zonos-elements/{p-160da12a.system.entry.js → p-9d95c896.system.entry.js} +1 -1
  186. package/dist/zonos-elements/{p-5d909d3d.entry.js → p-a1137930.entry.js} +1 -1
  187. package/dist/zonos-elements/{p-4f04b499.entry.js → p-a24870af.entry.js} +1 -1
  188. package/dist/zonos-elements/p-a411ce2a.system.js +1 -0
  189. package/dist/zonos-elements/{p-5c772fab.system.entry.js → p-a4686344.system.entry.js} +1 -1
  190. package/dist/zonos-elements/{p-a158b406.js → p-a6f77d44.js} +1 -1
  191. package/dist/zonos-elements/{p-fc3a6495.entry.js → p-a8f421ac.entry.js} +1 -1
  192. package/dist/zonos-elements/{p-da304b78.entry.js → p-aa40d402.entry.js} +1 -1
  193. package/dist/zonos-elements/{p-6c991320.entry.js → p-ad1e1dbc.entry.js} +1 -1
  194. package/dist/zonos-elements/{p-ab6efb03.system.entry.js → p-baa88176.system.entry.js} +1 -1
  195. package/dist/zonos-elements/{p-02463cc1.system.entry.js → p-bf364990.system.entry.js} +1 -1
  196. package/dist/zonos-elements/{p-963fa567.system.entry.js → p-bf9cb85f.system.entry.js} +1 -1
  197. package/dist/zonos-elements/{p-803e59d2.system.entry.js → p-c345b306.system.entry.js} +1 -1
  198. package/dist/zonos-elements/{p-ea30d92d.system.entry.js → p-cf999a15.system.entry.js} +1 -1
  199. package/dist/zonos-elements/{p-a958c4f0.system.entry.js → p-d1697144.system.entry.js} +1 -1
  200. package/dist/zonos-elements/{p-b3fa7f19.js → p-d6a53ea6.js} +1 -1
  201. package/dist/zonos-elements/{p-39428328.system.js → p-eb77c0bf.system.js} +1 -1
  202. package/dist/zonos-elements/{p-f49834d4.system.entry.js → p-ef1ccec6.system.entry.js} +1 -1
  203. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  204. package/package.json +1 -1
  205. package/dist/esm-es5/cart-5b417c0d.js +0 -1
  206. package/dist/esm-es5/handleFetch-621e45bc.js +0 -1
  207. package/dist/zonos-elements/p-0794c530.entry.js +0 -1
  208. package/dist/zonos-elements/p-0fc02cde.js +0 -1
  209. package/dist/zonos-elements/p-1b3e92ea.system.entry.js +0 -1
  210. package/dist/zonos-elements/p-1b75aa35.system.js +0 -1
  211. package/dist/zonos-elements/p-2d4e0280.entry.js +0 -1
  212. package/dist/zonos-elements/p-40a2a649.js +0 -1
  213. package/dist/zonos-elements/p-5539386e.system.entry.js +0 -1
  214. package/dist/zonos-elements/p-91553cf0.system.js +0 -1
  215. package/dist/zonos-elements/p-c740353c.js +0 -1
  216. package/dist/zonos-elements/p-f1f3a846.entry.js +0 -1
@@ -33,7 +33,7 @@ export const prepCartCalculateLandedCost = (cartId) => {
33
33
  const stripeBillingAddressData = stripeStore.stripeShippingSameAsBilling
34
34
  ? stripeStore.stripeAddressEventData
35
35
  : stripeStore.stripeBillingAddressEventData;
36
- if (!(stripeAddressData === null || stripeAddressData === void 0 ? void 0 : stripeAddressData.complete) || !(stripeBillingAddressData === null || stripeBillingAddressData === void 0 ? void 0 : stripeBillingAddressData.complete)) {
36
+ if (!stripeAddressData || !stripeBillingAddressData) {
37
37
  throw new Error('Missing stripe address data');
38
38
  }
39
39
  // Attempt to get translated address if available
@@ -110,7 +110,7 @@ export const prepCalculateLandedCost = () => {
110
110
  ? stripeStore.stripeAddressEventData
111
111
  : stripeStore.stripeBillingAddressEventData;
112
112
  log({ stripeAddressData, stripeBillingAddressData }, 'info');
113
- if (!(stripeAddressData === null || stripeAddressData === void 0 ? void 0 : stripeAddressData.complete) || !(stripeBillingAddressData === null || stripeBillingAddressData === void 0 ? void 0 : stripeBillingAddressData.complete)) {
113
+ if (!stripeAddressData || !stripeBillingAddressData) {
114
114
  throw new Error('Missing stripe address data');
115
115
  }
116
116
  // Attempt to get translated address if available
@@ -176,12 +176,13 @@ const handleRequestWithFallback = async ({ basePathType: _basePathType, options,
176
176
  }
177
177
  const nextFallbackApiType = getNextFallbackApiType(basePathType);
178
178
  const unknownError = errors.find(({ type }) => type === 'unknown');
179
+ const isAbortError = errors.find(({ message }) => message.includes('signal is aborted'));
179
180
  const isUnknownError = !!unknownError || (response === null || response === void 0 ? void 0 : response.status) === 404;
180
181
  const shouldCallFallback =
181
182
  // If next fallback is available, and the error is unknown (Failed to fetch) or 404
182
183
  nextFallbackApiType && isUnknownError;
183
184
  // Should log the error if it's unknown error
184
- if (isUnknownError) {
185
+ if (isUnknownError || isAbortError) {
185
186
  void sendErrorLog({
186
187
  endpoint: fallbackApiList[basePathType] + path,
187
188
  errors: errors.map(({ message }) => `API: ${message}`),
@@ -35,11 +35,6 @@ export const log = (message, type, ..._additionalInfo) => {
35
35
  !!window.location.search.match(/\?.*(&*)zonosDebug=1/);
36
36
  // if debug is false, do not log
37
37
  if (!isDebug) {
38
- // log errors to the console if the type is error
39
- if (type === 'error') {
40
- // eslint-disable-next-line no-console
41
- console.error(message, ...additionalInfo);
42
- }
43
38
  return;
44
39
  }
45
40
  let loggingIframe = document.querySelector('iframe#zonos---debug-logging-iframe');
@@ -0,0 +1 @@
1
+ export {};
@@ -2952,6 +2952,9 @@ export function getSdk(client, withWrapper = defaultWrapper) {
2952
2952
  organizations(variables, requestHeaders) {
2953
2953
  return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'organizations', 'query');
2954
2954
  },
2955
+ partyCreate(variables, requestHeaders) {
2956
+ return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'partyCreate', 'mutation');
2957
+ },
2955
2958
  partyInfo(variables, requestHeaders) {
2956
2959
  return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'partyInfo', 'query');
2957
2960
  },
@@ -3,6 +3,7 @@ import "./global.d";
3
3
  export * from '../components.d';
4
4
  export * from './checkout/api/CalculateLandedCost';
5
5
  export * from './checkout/api/CheckoutSession';
6
+ export * from './checkout/api/CreateParty';
6
7
  export * from './checkout/api/legacy/InventoryCheck';
7
8
  export * from './checkout/api/NormalizedTempCart';
8
9
  export * from './checkout/api/Paypal';
@@ -1,8 +1,8 @@
1
- import { z as zonosStore, c as createStore } from './zonosStore-504a7030.js';
2
- import { s as storageStore, l as localizationStore, t as translate, f as filterValidTests, b as storageStoreSetEnabledVariantTestKeys } from './localization-669a1714.js';
3
- import { l as log, f as fallbackApiList, h as handleFetch, g as getIsTestMode, a as getIsStagingMode, s as sendErrorLog, d as allLogs, b as logError, j as jsonParse } from './handleFetch-621e45bc.js';
4
- import { i as isDarkColor } from './isDarkColor-915b06b8.js';
5
- import { g as getBorderRadius } from './getBorderRadius-174305ff.js';
1
+ import { z as zonosStore, c as createStore } from './zonosStore-00975763.js';
2
+ import { s as storageStore, l as localizationStore, t as translate, f as filterValidTests, b as storageStoreSetEnabledVariantTestKeys } from './localization-e17c211b.js';
3
+ import { l as log, f as fallbackApiList, h as handleFetch, g as getIsTestMode, a as getIsStagingMode, s as sendErrorLog, d as allLogs, b as logError, j as jsonParse } from './handleFetch-7dd4622b.js';
4
+ import { i as isDarkColor } from './isDarkColor-3a9d6108.js';
5
+ import { g as getBorderRadius } from './getBorderRadius-71b3b8ab.js';
6
6
 
7
7
  /**
8
8
  * Extract value from translated object
@@ -35,7 +35,7 @@ const prepCartCalculateLandedCost = (cartId) => {
35
35
  const stripeBillingAddressData = stripeStore.stripeShippingSameAsBilling
36
36
  ? stripeStore.stripeAddressEventData
37
37
  : stripeStore.stripeBillingAddressEventData;
38
- if (!(stripeAddressData === null || stripeAddressData === void 0 ? void 0 : stripeAddressData.complete) || !(stripeBillingAddressData === null || stripeBillingAddressData === void 0 ? void 0 : stripeBillingAddressData.complete)) {
38
+ if (!stripeAddressData || !stripeBillingAddressData) {
39
39
  throw new Error('Missing stripe address data');
40
40
  }
41
41
  // Attempt to get translated address if available
@@ -112,7 +112,7 @@ const prepCalculateLandedCost = () => {
112
112
  ? stripeStore.stripeAddressEventData
113
113
  : stripeStore.stripeBillingAddressEventData;
114
114
  log({ stripeAddressData, stripeBillingAddressData }, 'info');
115
- if (!(stripeAddressData === null || stripeAddressData === void 0 ? void 0 : stripeAddressData.complete) || !(stripeBillingAddressData === null || stripeBillingAddressData === void 0 ? void 0 : stripeBillingAddressData.complete)) {
115
+ if (!stripeAddressData || !stripeBillingAddressData) {
116
116
  throw new Error('Missing stripe address data');
117
117
  }
118
118
  // Attempt to get translated address if available
@@ -254,7 +254,7 @@ const calculateLandedCost = async (abortController) => {
254
254
  };
255
255
 
256
256
  const cartCalculateLandedCost = async ({ abortController, cartId, }) => {
257
- var _a;
257
+ var _a, _b;
258
258
  // request to get landed cost info
259
259
  const { errors, json } = await handleFetch('/api/zonos-elements/cart-calculate-landed-cost', {
260
260
  body: prepCartCalculateLandedCost(cartId),
@@ -262,7 +262,8 @@ const cartCalculateLandedCost = async ({ abortController, cartId, }) => {
262
262
  signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
263
263
  });
264
264
  if (errors.length || !json) {
265
- const isAbortedRequest = ((_a = errors[0]) === null || _a === void 0 ? void 0 : _a.message) === 'The user aborted a request.';
265
+ const isAbortedRequest = ((_a = errors[0]) === null || _a === void 0 ? void 0 : _a.message) === 'The user aborted a request.' ||
266
+ ((_b = errors[0]) === null || _b === void 0 ? void 0 : _b.message.includes('signal is aborted'));
266
267
  const errorMessage = isAbortedRequest
267
268
  ? 'The landed cost calculation request was aborted to initiate a new one.'
268
269
  : 'Failed to calculate landed cost';
@@ -597,6 +598,7 @@ const { onChange: stripeStoreOnChange, reset: reset$1, state: stripeStore, } = c
597
598
  checkoutSettlementCurrency: 'USD',
598
599
  clientSecret: sessionStorage.getItem('zonos--client-secret') || '',
599
600
  companyName: '',
601
+ companyNameUsedWhenAsyncAddressUpdate: '',
600
602
  customAddressErrors: {
601
603
  city: '',
602
604
  firstName: '',
@@ -623,6 +625,8 @@ const { onChange: stripeStoreOnChange, reset: reset$1, state: stripeStore, } = c
623
625
  hasPaymentError: false,
624
626
  isFetchingLandedCost: false,
625
627
  isFetchingSession: false,
628
+ partyBillingId: null,
629
+ partyShippingId: null,
626
630
  shouldInventoryRefund: false,
627
631
  shouldRenderPayInUsdButton: false,
628
632
  /**
@@ -635,10 +639,12 @@ const { onChange: stripeStoreOnChange, reset: reset$1, state: stripeStore, } = c
635
639
  stripe: null,
636
640
  stripeAddressElement: null,
637
641
  stripeAddressEventData: null,
642
+ stripeAddressUsedWhenAsyncAddressUpdate: null,
638
643
  stripeAddressUsedWhenFetchingLC: null,
639
644
  stripeAddressUsedWhenValidatingAddress: null,
640
645
  stripeBillingAddressElement: null,
641
646
  stripeBillingAddressEventData: null,
647
+ stripeBillingAddressUsedWhenAsyncAddressUpdate: null,
642
648
  stripeBillingAddressUsedWhenFetchingLC: null,
643
649
  stripeBillingAddressUsedWhenValidatingAddress: null,
644
650
  stripeCustomerSessionClientSecret: null,
@@ -652,7 +658,7 @@ const { onChange: stripeStoreOnChange, reset: reset$1, state: stripeStore, } = c
652
658
  stripePaymentEventData: null,
653
659
  stripeShippingSameAsBilling: true,
654
660
  taxId: '',
655
- taxIdUsedWhenFetchingLC: '',
661
+ taxIdUsedWhenAsyncAddressUpdate: '',
656
662
  translatedAddress: {
657
663
  address: {},
658
664
  billingAddress: {},
@@ -757,15 +763,178 @@ const checkIsAddressOutdatedForValidation = () => {
757
763
  JSON.stringify((_d = stripeStore.stripeBillingAddressUsedWhenValidatingAddress) === null || _d === void 0 ? void 0 : _d.value);
758
764
  return isAddressDataDirty || isBillingAddressDataDirty;
759
765
  };
760
- const checkIsAddressOutdatedForLCPrefetch = () => {
766
+ const checkIsAddressOutdatedForAsyncAddressUpdate = () => {
761
767
  var _a, _b, _c, _d, _e, _f;
762
768
  const isLinkDataDirty = JSON.stringify((_a = stripeStore.stripeLinkUsedWhenFetchingLC) === null || _a === void 0 ? void 0 : _a.value) !==
763
769
  JSON.stringify((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.value);
764
- const isAddressDataDirty = JSON.stringify((_c = stripeStore.stripeAddressUsedWhenFetchingLC) === null || _c === void 0 ? void 0 : _c.value) !==
765
- JSON.stringify((_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value);
770
+ const isAddressDataDirty = JSON.stringify((_c = stripeStore.stripeAddressUsedWhenAsyncAddressUpdate) === null || _c === void 0 ? void 0 : _c.value) !== JSON.stringify((_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value);
766
771
  const isBillingAddressDataDirty = !stripeStore.stripeShippingSameAsBilling &&
767
- JSON.stringify((_e = stripeStore.stripeBillingAddressEventData) === null || _e === void 0 ? void 0 : _e.value) !==
768
- JSON.stringify((_f = stripeStore.stripeBillingAddressUsedWhenFetchingLC) === null || _f === void 0 ? void 0 : _f.value);
772
+ JSON.stringify((_e = stripeStore.stripeBillingAddressUsedWhenAsyncAddressUpdate) === null || _e === void 0 ? void 0 : _e.value) !== JSON.stringify((_f = stripeStore.stripeBillingAddressEventData) === null || _f === void 0 ? void 0 : _f.value);
773
+ const isTaxIdDirty = stripeStore.taxIdUsedWhenAsyncAddressUpdate !== stripeStore.taxId;
774
+ const isCompanyNameDirty = stripeStore.companyNameUsedWhenAsyncAddressUpdate !==
775
+ stripeStore.companyName;
776
+ return (isLinkDataDirty ||
777
+ isAddressDataDirty ||
778
+ isBillingAddressDataDirty ||
779
+ isTaxIdDirty ||
780
+ isCompanyNameDirty);
781
+ };
782
+ const buildAddressForPartyCreate = ({ address, firstName, lastName, name, phone, }) => {
783
+ const _firstName = (name === null || name === void 0 ? void 0 : name.split(' ')[0]) || firstName || '';
784
+ const _lastName = (name === null || name === void 0 ? void 0 : name.split(' ')[1]) || lastName || '';
785
+ if (!_firstName || !_lastName) {
786
+ void sendErrorLog({
787
+ endpoint: 'PARTY_CREATE_NO_NAME_FOUND',
788
+ errors: ['No name found'],
789
+ metadata: {
790
+ allLogs,
791
+ cartId: window.Zonos.cartId,
792
+ checkoutSessionId: storageStore.checkoutSessionId,
793
+ firstName,
794
+ lastName,
795
+ name,
796
+ },
797
+ });
798
+ }
799
+ if (!phone) {
800
+ void sendErrorLog({
801
+ endpoint: 'PARTY_CREATE_NO_PHONE_FOUND',
802
+ errors: ['No phone found'],
803
+ metadata: {
804
+ allLogs,
805
+ cartId: window.Zonos.cartId,
806
+ checkoutSessionId: storageStore.checkoutSessionId,
807
+ phone,
808
+ },
809
+ });
810
+ }
811
+ return {
812
+ city: address.city,
813
+ country: address.country,
814
+ firstName: _firstName,
815
+ lastName: _lastName,
816
+ line1: address.line1,
817
+ line2: address.line2,
818
+ phone: phone || '',
819
+ postal_code: address.postal_code,
820
+ state: address.state,
821
+ };
822
+ };
823
+ const stripeStoreAsyncAddressUpdate = async () => {
824
+ var _a, _b, _c, _d;
825
+ if (!((_a = stripeStore.stripeAddressEventData) === null || _a === void 0 ? void 0 : _a.complete) ||
826
+ (!stripeStore.stripeShippingSameAsBilling &&
827
+ !((_b = stripeStore.stripeBillingAddressEventData) === null || _b === void 0 ? void 0 : _b.complete)) ||
828
+ !stripeStore.stripeBillingAddressEventData) {
829
+ return {
830
+ partiesCreated: false,
831
+ };
832
+ }
833
+ // If there is no landed cost data, no need to create parties
834
+ if (!cartStore.landedCostData) {
835
+ return {
836
+ partiesCreated: false,
837
+ };
838
+ }
839
+ const firstLandedCostRootId = (_c = cartStore.landedCostData.find(Boolean)) === null || _c === void 0 ? void 0 : _c.landedCost.rootId;
840
+ if (!firstLandedCostRootId) {
841
+ // do nothing if we don't have selected landed cost
842
+ void sendErrorLog({
843
+ endpoint: 'PF_NO_SELECTED_LANDED_COST',
844
+ errors: ['No selected landed cost'],
845
+ metadata: {
846
+ allLogs,
847
+ cartId: window.Zonos.cartId,
848
+ checkoutSessionId: storageStore.checkoutSessionId,
849
+ },
850
+ });
851
+ return {
852
+ partiesCreated: false,
853
+ };
854
+ }
855
+ const isAddressOutdated = checkIsAddressOutdatedForAsyncAddressUpdate();
856
+ if (!isAddressOutdated) {
857
+ return {
858
+ partiesCreated: false,
859
+ };
860
+ }
861
+ const address = buildAddressForPartyCreate({
862
+ address: stripeStore.stripeAddressEventData.value.address,
863
+ firstName: stripeStore.stripeAddressEventData.value.firstName,
864
+ lastName: stripeStore.stripeAddressEventData.value.lastName,
865
+ name: stripeStore.stripeAddressEventData.value.name,
866
+ phone: stripeStore.stripeAddressEventData.value.phone,
867
+ });
868
+ const billingAddress = stripeStore.stripeShippingSameAsBilling
869
+ ? address
870
+ : buildAddressForPartyCreate({
871
+ address: stripeStore.stripeBillingAddressEventData.value.address,
872
+ firstName: stripeStore.stripeBillingAddressEventData.value.firstName,
873
+ lastName: stripeStore.stripeBillingAddressEventData.value.lastName,
874
+ name: stripeStore.stripeBillingAddressEventData.value.name,
875
+ phone: stripeStore.stripeBillingAddressEventData.value.phone,
876
+ });
877
+ const isE2ETest = new URLSearchParams(window.location.search).get('zonosE2ETest') === '1';
878
+ const { errors, json } = await handleFetch('/api/zonos-elements/create-parties', {
879
+ body: {
880
+ address,
881
+ billingAddress,
882
+ companyName: stripeStore.companyName,
883
+ email: ((_d = stripeStore.stripeLinkEventData) === null || _d === void 0 ? void 0 : _d.value.email) || '',
884
+ isTest: isE2ETest,
885
+ rootId: firstLandedCostRootId,
886
+ taxId: stripeStore.taxId,
887
+ },
888
+ method: 'POST',
889
+ });
890
+ if (errors.length || !json) {
891
+ logError('Error occurs when creating parties', JSON.stringify(errors, null, 2));
892
+ void sendErrorLog({
893
+ endpoint: 'PF_PARTY_CREATE_FAILED',
894
+ errors: ['Failed to create parties'],
895
+ metadata: {
896
+ allLogs,
897
+ cartId: window.Zonos.cartId,
898
+ checkoutSessionId: storageStore.checkoutSessionId,
899
+ errors,
900
+ json,
901
+ },
902
+ });
903
+ return {
904
+ partiesCreated: false,
905
+ };
906
+ }
907
+ stripeStore.companyNameUsedWhenAsyncAddressUpdate = stripeStore.companyName;
908
+ stripeStore.stripeAddressUsedWhenAsyncAddressUpdate =
909
+ stripeStore.stripeAddressEventData;
910
+ stripeStore.stripeBillingAddressUsedWhenAsyncAddressUpdate =
911
+ stripeStore.stripeBillingAddressEventData;
912
+ stripeStore.taxIdUsedWhenAsyncAddressUpdate = stripeStore.taxId;
913
+ stripeStore.partyBillingId = json.billToPartyId;
914
+ stripeStore.partyShippingId = json.shipToPartyId;
915
+ return {
916
+ partiesCreated: true,
917
+ };
918
+ };
919
+ /**
920
+ * Extract only the necessary address info for landed cost prefetch
921
+ */
922
+ const buildAddressForLCPrefetch = (address) => {
923
+ return {
924
+ countryCode: address.address.country,
925
+ postalCode: address.address.postal_code,
926
+ state: address.address.state,
927
+ };
928
+ };
929
+ const checkIsAddressOutdatedForLCPrefetch = () => {
930
+ var _a, _b;
931
+ const isLinkDataDirty = JSON.stringify((_a = stripeStore.stripeLinkUsedWhenFetchingLC) === null || _a === void 0 ? void 0 : _a.value) !==
932
+ JSON.stringify((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.value);
933
+ const isAddressDataDirty = stripeStore.stripeAddressEventData &&
934
+ JSON.stringify(buildAddressForLCPrefetch(stripeStore.stripeAddressEventData.value)) !== JSON.stringify(stripeStore.stripeAddressUsedWhenFetchingLC);
935
+ const isBillingAddressDataDirty = !stripeStore.stripeShippingSameAsBilling &&
936
+ stripeStore.stripeBillingAddressEventData &&
937
+ JSON.stringify(buildAddressForLCPrefetch(stripeStore.stripeBillingAddressEventData.value)) !== JSON.stringify(stripeStore.stripeBillingAddressUsedWhenFetchingLC);
769
938
  return isLinkDataDirty || isAddressDataDirty || isBillingAddressDataDirty;
770
939
  };
771
940
  /**
@@ -779,14 +948,67 @@ const isPrefetchInfoOutdated = () => {
779
948
  ((_a = cartStore.landedCostData.find(Boolean)) === null || _a === void 0 ? void 0 : _a.subtotals.items) !==
780
949
  cartStore.subtotal;
781
950
  const isAddressOutdated = checkIsAddressOutdatedForLCPrefetch();
782
- // Auto prefetch landed cost if tax id is updated
783
- const isTaxIdDirty = stripeStore.taxIdUsedWhenFetchingLC !== stripeStore.taxId;
951
+ log('isPrefetchInfoOutdated', 'info', {
952
+ isAddressOutdated,
953
+ });
784
954
  return (
785
955
  // if landed cost data is not available, we need to fetch it
786
- !cartStore.landedCostData ||
956
+ (!cartStore.landedCostData && !stripeStore.isFetchingLandedCost) ||
787
957
  isAddressOutdated ||
788
- isTotalAmountChanged ||
789
- isTaxIdDirty);
958
+ isTotalAmountChanged);
959
+ };
960
+ const getCountryField = (country) => {
961
+ var _a, _b;
962
+ const countryFieldLabels = (_a = zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.countryFields;
963
+ const stripeCountryFieldLabels = (_b = zonosStore.genericSettings) === null || _b === void 0 ? void 0 : _b.stripeCountryFieldLabels;
964
+ const stripeFoundCountryField = stripeCountryFieldLabels && country in stripeCountryFieldLabels
965
+ ? stripeCountryFieldLabels[country]
966
+ : null;
967
+ const zonosFoundCountryField = countryFieldLabels && country in countryFieldLabels
968
+ ? countryFieldLabels[country]
969
+ : null;
970
+ /**
971
+ * If the address form is using Stripe component, use Stripe country field label if there is one, if not just use one from our countryFieldLabel data
972
+ * stripeCountryFieldLabels is the list we collect from Stripe, and extract only country that state/zip is required and different from what we have in our countryFieldLabel data
973
+ **/
974
+ if (cartStore.addressFormRenderType === 'stripe') {
975
+ return stripeFoundCountryField || zonosFoundCountryField;
976
+ }
977
+ return zonosFoundCountryField;
978
+ };
979
+ const isAddressReadyToRequestLandedCost = () => {
980
+ var _a, _b, _c, _d;
981
+ const linkReady = !!((_a = stripeStore.stripeLinkEventData) === null || _a === void 0 ? void 0 : _a.complete);
982
+ const shippingAddressReady = !!((_b = stripeStore.stripeAddressEventData) === null || _b === void 0 ? void 0 : _b.complete);
983
+ const billingAddressReady = stripeStore.stripeShippingSameAsBilling
984
+ ? shippingAddressReady
985
+ : !!((_c = stripeStore.stripeBillingAddressEventData) === null || _c === void 0 ? void 0 : _c.complete);
986
+ const shipToCountry = ((_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value.address.country) || 'US';
987
+ const countryField = getCountryField(shipToCountry);
988
+ if (shippingAddressReady && billingAddressReady && linkReady) {
989
+ return true;
990
+ }
991
+ // Only send landed cost request if the address is complete when we can't get the country field
992
+ if (!countryField || !stripeStore.stripeAddressEventData) {
993
+ return shippingAddressReady && billingAddressReady && linkReady;
994
+ }
995
+ const isValidLine1 = stripeStore.stripeAddressEventData.value.address.line1.length > 0;
996
+ const isValidName = stripeStore.stripeAddressEventData.value.firstName &&
997
+ stripeStore.stripeAddressEventData.value.lastName;
998
+ const isStateValid = !countryField.stateRequired ||
999
+ (countryField.stateRequired &&
1000
+ stripeStore.stripeAddressEventData.value.address.state.length > 0);
1001
+ const isPostalCodeValid = !countryField.zipRequired ||
1002
+ (countryField.zipRequired &&
1003
+ stripeStore.stripeAddressEventData.value.address.postal_code.length >= 3);
1004
+ const hasPhoneNumber = stripeStore.stripeAddressEventData.value.phone &&
1005
+ stripeStore.stripeAddressEventData.value.phone.length > 0;
1006
+ return (linkReady &&
1007
+ isValidName &&
1008
+ isValidLine1 &&
1009
+ isStateValid &&
1010
+ isPostalCodeValid &&
1011
+ hasPhoneNumber);
790
1012
  };
791
1013
  const stripeCalculateLandedCost = async () => {
792
1014
  var _a;
@@ -835,26 +1057,27 @@ const stripeCalculateLandedCost = async () => {
835
1057
  }
836
1058
  };
837
1059
  const stripeStorePrefetchLandedCost = async (params) => {
838
- var _a, _b, _c, _d, _e, _f, _g, _h;
1060
+ var _a, _b, _c, _d;
839
1061
  const retries = (params === null || params === void 0 ? void 0 : params.retries) || 0;
840
1062
  const applyingPromocode = !!(params === null || params === void 0 ? void 0 : params.applyingPromocode);
841
- const stripeAddressReady = !!((_a = stripeStore.stripeAddressEventData) === null || _a === void 0 ? void 0 : _a.complete);
842
- const stripeLinkReady = !!((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.complete);
843
- const stripeBillingAddressReady = stripeStore.stripeShippingSameAsBilling
844
- ? !!((_c = stripeStore.stripeLinkEventData) === null || _c === void 0 ? void 0 : _c.complete)
845
- : !!((_d = stripeStore.stripeBillingAddressEventData) === null || _d === void 0 ? void 0 : _d.complete);
846
1063
  const shouldRefetch = isPrefetchInfoOutdated();
1064
+ const isRequestReadyToPrefetch = isAddressReadyToRequestLandedCost();
1065
+ // Should not do anything if the address is not ready to request landed cost
1066
+ if (!isRequestReadyToPrefetch) {
1067
+ return {
1068
+ isRequestNotReady: true,
1069
+ };
1070
+ }
847
1071
  if (shouldRefetch) {
848
1072
  // if the info used when fetching landed cost is different from the current info, abort the previous request
849
- (_e = stripeStore.fetchingLandedCostAbortController) === null || _e === void 0 ? void 0 : _e.abort();
1073
+ (_a = stripeStore.fetchingLandedCostAbortController) === null || _a === void 0 ? void 0 : _a.abort();
850
1074
  stripeStore.fetchingLandedCostAbortController = null;
851
1075
  }
852
1076
  // Do not fetch if we are not ready or data is not outdated
853
- if ((!shouldRefetch && !applyingPromocode) ||
854
- !stripeAddressReady ||
855
- !stripeLinkReady ||
856
- !stripeBillingAddressReady) {
857
- return;
1077
+ if (!shouldRefetch && !applyingPromocode) {
1078
+ return {
1079
+ isRequestNotReady: false,
1080
+ };
858
1081
  }
859
1082
  // If there is retries, stop loading for a moment and then showing the spinner again (this is just so customer can see that checkout is doing something and not stuck)
860
1083
  if (retries) {
@@ -867,24 +1090,31 @@ const stripeStorePrefetchLandedCost = async (params) => {
867
1090
  stripeStore.isFetchingLandedCost = true;
868
1091
  }
869
1092
  if (stripeStore.stripeAddressEventData) {
870
- stripeStore.stripeAddressUsedWhenFetchingLC = Object.assign({}, stripeStore.stripeAddressEventData);
1093
+ stripeStore.stripeAddressUsedWhenFetchingLC = {
1094
+ countryCode: stripeStore.stripeAddressEventData.value.address.country,
1095
+ postalCode: stripeStore.stripeAddressEventData.value.address.postal_code,
1096
+ state: stripeStore.stripeAddressEventData.value.address.state,
1097
+ };
871
1098
  }
872
1099
  if (stripeStore.stripeBillingAddressEventData) {
873
- stripeStore.stripeBillingAddressUsedWhenFetchingLC = Object.assign({}, stripeStore.stripeBillingAddressEventData);
1100
+ stripeStore.stripeBillingAddressUsedWhenFetchingLC = {
1101
+ countryCode: stripeStore.stripeBillingAddressEventData.value.address.country,
1102
+ postalCode: stripeStore.stripeBillingAddressEventData.value.address.postal_code,
1103
+ state: stripeStore.stripeBillingAddressEventData.value.address.state,
1104
+ };
874
1105
  }
875
1106
  if (stripeStore.stripeLinkEventData) {
876
1107
  stripeStore.stripeLinkUsedWhenFetchingLC = Object.assign({}, stripeStore.stripeLinkEventData);
877
1108
  }
878
- stripeStore.taxIdUsedWhenFetchingLC = stripeStore.taxId;
879
1109
  try {
880
1110
  // Reset cart items to non-restricted state and restricted item list
881
1111
  cartStoreResetCartItems();
882
1112
  // fetch and apply landed cost
883
1113
  await stripeCalculateLandedCost();
884
1114
  // This is the cheapest service level since we already sorted them after fetching landed cost
885
- const cheapestServiceLevel = (_f = cartStore.shippingData) === null || _f === void 0 ? void 0 : _f.find(Boolean);
1115
+ const cheapestServiceLevel = (_b = cartStore.shippingData) === null || _b === void 0 ? void 0 : _b.find(Boolean);
886
1116
  // Landed cost that matches with service level
887
- const matchLandedCost = (_g = cartStore.landedCostData) === null || _g === void 0 ? void 0 : _g.find(x => x.landedCost.shipmentRating.id === (cheapestServiceLevel === null || cheapestServiceLevel === void 0 ? void 0 : cheapestServiceLevel.id));
1117
+ const matchLandedCost = (_c = cartStore.landedCostData) === null || _c === void 0 ? void 0 : _c.find(x => x.landedCost.shipmentRating.id === (cheapestServiceLevel === null || cheapestServiceLevel === void 0 ? void 0 : cheapestServiceLevel.id));
888
1118
  // apply new subtotal and total, this is mainly to show items in the presentment currency
889
1119
  const subtotals = !!matchLandedCost ? matchLandedCost.subtotals : null;
890
1120
  if (subtotals) {
@@ -908,9 +1138,11 @@ const stripeStorePrefetchLandedCost = async (params) => {
908
1138
  if (retries < 1) {
909
1139
  // retry fetching landed cost one more time
910
1140
  await stripeStorePrefetchLandedCost(Object.assign(Object.assign({}, params), { retries: (retries || 0) + 1 }));
911
- return;
1141
+ return {
1142
+ isRequestNotReady: false,
1143
+ };
912
1144
  }
913
- const shipToAddress = (_h = stripeStore.stripeAddressUsedWhenFetchingLC) === null || _h === void 0 ? void 0 : _h.value;
1145
+ const shipToAddress = (_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value;
914
1146
  void sendErrorLog({
915
1147
  endpoint: `Failed to fetch landed cost (${retries} retries)`,
916
1148
  errors: [err.message],
@@ -923,6 +1155,9 @@ const stripeStorePrefetchLandedCost = async (params) => {
923
1155
  logError(err);
924
1156
  }
925
1157
  stripeStore.isFetchingLandedCost = false;
1158
+ return {
1159
+ isRequestNotReady: false,
1160
+ };
926
1161
  };
927
1162
  const stripeStoreApplyPromoCode = async () => {
928
1163
  var _a, _b;
@@ -933,6 +1168,8 @@ const stripeStoreApplyPromoCode = async () => {
933
1168
  if (cartStore.step === 'payment') {
934
1169
  cartStorePreviousStep();
935
1170
  }
1171
+ // async update address with new root id from the new quote
1172
+ await stripeStoreAsyncAddressUpdate();
936
1173
  // This is the cheapest service level since we already sorted them after fetching landed cost
937
1174
  const cheapestServiceLevel = (_a = cartStore.shippingData) === null || _a === void 0 ? void 0 : _a.find(Boolean);
938
1175
  // Landed cost that matches with service level
@@ -1311,6 +1548,7 @@ const stripeStoreUpdateCheckoutSession = async ({ adjustmentsAmount, cartId, cur
1311
1548
  const { errors, json } = await handleFetch('/api/zonos-elements/update-checkout-session', {
1312
1549
  body: {
1313
1550
  adjustmentsAmount,
1551
+ billToPartyId: stripeStore.partyBillingId,
1314
1552
  cartId,
1315
1553
  currency,
1316
1554
  customerAuthenticationToken: cartStore.customerAuthenticationToken || undefined,
@@ -1324,6 +1562,7 @@ const stripeStoreUpdateCheckoutSession = async ({ adjustmentsAmount, cartId, cur
1324
1562
  },
1325
1563
  ],
1326
1564
  presentmentCountryCode,
1565
+ shipToPartyId: stripeStore.partyShippingId,
1327
1566
  skipPaymentIntent: stripeStore.skipPaymentIntent,
1328
1567
  varianceTestInput,
1329
1568
  },
@@ -1464,7 +1703,8 @@ stripeStoreOnChange('clientSecret', clientSecret => {
1464
1703
  }
1465
1704
  });
1466
1705
 
1467
- const { reset, state: cartStore } = createStore(() => ({
1706
+ const { onChange: cartStoreOnChange, reset, state: cartStore, } = createStore(() => ({
1707
+ addressFormRenderType: 'stripe',
1468
1708
  adjustmentTotal: 0,
1469
1709
  adjustments: [],
1470
1710
  checkoutSession: null,
@@ -1679,12 +1919,14 @@ const cartStoreReCalculateTotal = async ({ adjustmentsAmount, cartId, currency,
1679
1919
  }
1680
1920
  const { errors, json } = await stripeStoreUpdateCheckoutSession({
1681
1921
  adjustmentsAmount,
1922
+ billToPartyId: stripeStore.partyBillingId,
1682
1923
  cartId,
1683
1924
  currency,
1684
1925
  id: storageStore.checkoutSessionId,
1685
1926
  itemsAmount,
1686
1927
  landedCostId,
1687
1928
  presentmentCountryCode: localizationStore.selectedCountryCode,
1929
+ shipToPartyId: stripeStore.partyShippingId,
1688
1930
  varianceTestInput: storageStore.enabledVariantTestKeys || [],
1689
1931
  });
1690
1932
  if (errors.length > 0 || !json) {
@@ -1768,9 +2010,11 @@ const cartStoreUpdateSelectedShippingOption = async (selectedShippingOption, lan
1768
2010
  // update session with selected landed cost
1769
2011
  const updateCalculateStatus = await cartStoreReCalculateTotal({
1770
2012
  adjustmentsAmount: cartStore.adjustmentTotal,
2013
+ billToPartyId: stripeStore.partyBillingId,
1771
2014
  cartId: window.Zonos.cartId,
1772
2015
  dutiesTaxesFeesEstimate: dutiesTaxesFeesEstimate,
1773
2016
  landedCostId: (_f = selectedLandedCost.landedCost) === null || _f === void 0 ? void 0 : _f.id,
2017
+ shipToPartyId: stripeStore.partyShippingId,
1774
2018
  varianceTestInput: storageStore.enabledVariantTestKeys || [],
1775
2019
  });
1776
2020
  // update conditionally render pay in USD button
@@ -1833,10 +2077,12 @@ const cartStoreUpdateItems = async ({ adjustments, cartItems, }) => {
1833
2077
  stripeStore.isFetchingSession = true;
1834
2078
  await cartStoreReCalculateTotal({
1835
2079
  adjustmentsAmount: adjustmentTotal,
2080
+ billToPartyId: stripeStore.partyBillingId,
1836
2081
  cartId: window.Zonos.cartId,
1837
2082
  currency: currency,
1838
2083
  dutiesTaxesFeesEstimate: 0,
1839
2084
  itemsAmount: total,
2085
+ shipToPartyId: stripeStore.partyShippingId,
1840
2086
  // attempt to init session on failure to update checkout session
1841
2087
  shouldInitSessionOnFailure: true,
1842
2088
  varianceTestInput: storageStore.enabledVariantTestKeys || [],
@@ -1892,4 +2138,4 @@ const cartStoreResetTabItems = () => {
1892
2138
  cartStoreResetSelectedShippingOption();
1893
2139
  };
1894
2140
 
1895
- export { cartStoreHasOneEligibleItem as A, stripeStoreApplyPromoCode as B, stripeStoreRemovePromoCode as C, stripeStoreResetPromoCode as D, stripeStoreMessageBasedOnStatus as E, stripeStoreTranslateAddressToLatin as F, cartStoreUpdateSelectedShippingOption as G, cartStoreGetShippingTransitInfo as H, sortServiceLevelOptionsByAmount as I, cartStoreGetMethod as J, stripeStoreCleanupDomesticShippingSession as a, stripeStoreSaveDomesticShippingSession as b, stripeStore as c, stripeStoreRetrievePayment as d, cartStore as e, cartStoreUpdateItems as f, cartStoreReset as g, cartStoreResetTabItems as h, initStripeElements as i, cartStoreClearCheckoutInterval as j, stripeStoreInitCheckoutSession as k, stripeStoreGetPaymentIntent as l, cartStoreStartCheckoutInterval as m, getCheckoutSessionBody as n, cartStoreUpdateToErrorState as o, cartStoreSetCheckoutSession as p, stripeStorePrefetchLandedCost as q, cartStoreNextStep as r, stripeStoreGetDomesticShippingSession as s, trackConversionEvent as t, stripeStoreUpdateCheckoutSessionBaseCurrency as u, stripeStoreHandleInventoryCheck as v, stripeStoreConfirmPayment as w, stripeStoreHandleInventoryRefund as x, stripeStoreReset as y, validateCheckoutSession as z };
2141
+ export { cartStoreHasOneEligibleItem as A, stripeStoreApplyPromoCode as B, stripeStoreRemovePromoCode as C, stripeStoreResetPromoCode as D, stripeStoreMessageBasedOnStatus as E, stripeStoreTranslateAddressToLatin as F, cartStoreOnChange as G, stripeStoreAsyncAddressUpdate as H, cartStoreUpdateSelectedShippingOption as I, cartStoreGetShippingTransitInfo as J, sortServiceLevelOptionsByAmount as K, cartStoreGetMethod as L, stripeStoreCleanupDomesticShippingSession as a, stripeStoreSaveDomesticShippingSession as b, stripeStore as c, stripeStoreRetrievePayment as d, cartStore as e, cartStoreUpdateItems as f, cartStoreReset as g, cartStoreResetTabItems as h, initStripeElements as i, cartStoreClearCheckoutInterval as j, stripeStoreInitCheckoutSession as k, stripeStoreGetPaymentIntent as l, cartStoreStartCheckoutInterval as m, getCheckoutSessionBody as n, cartStoreUpdateToErrorState as o, cartStoreSetCheckoutSession as p, stripeStorePrefetchLandedCost as q, cartStoreNextStep as r, stripeStoreGetDomesticShippingSession as s, trackConversionEvent as t, stripeStoreUpdateCheckoutSessionBaseCurrency as u, stripeStoreHandleInventoryCheck as v, stripeStoreConfirmPayment as w, stripeStoreHandleInventoryRefund as x, stripeStoreReset as y, validateCheckoutSession as z };
@@ -1,4 +1,4 @@
1
- import { _ as _root, b as _baseGetTag, i as isObjectLike_1, d as isObject_1 } from './zonosStore-504a7030.js';
1
+ import { _ as _root, b as _baseGetTag, i as isObjectLike_1, d as isObject_1 } from './zonosStore-00975763.js';
2
2
 
3
3
  var root = _root;
4
4
 
@@ -1,4 +1,4 @@
1
- import { z as zonosStore } from './zonosStore-504a7030.js';
1
+ import { z as zonosStore } from './zonosStore-00975763.js';
2
2
 
3
3
  /**
4
4
  * Get the border radius for the elements based on the style
@@ -35,11 +35,6 @@ const log = (message, type, ..._additionalInfo) => {
35
35
  !!window.location.search.match(/\?.*(&*)zonosDebug=1/);
36
36
  // if debug is false, do not log
37
37
  if (!isDebug) {
38
- // log errors to the console if the type is error
39
- if (type === 'error') {
40
- // eslint-disable-next-line no-console
41
- console.error(message, ...additionalInfo);
42
- }
43
38
  return;
44
39
  }
45
40
  let loggingIframe = document.querySelector('iframe#zonos---debug-logging-iframe');
@@ -432,12 +427,13 @@ const handleRequestWithFallback = async ({ basePathType: _basePathType, options,
432
427
  }
433
428
  const nextFallbackApiType = getNextFallbackApiType(basePathType);
434
429
  const unknownError = errors.find(({ type }) => type === 'unknown');
430
+ const isAbortError = errors.find(({ message }) => message.includes('signal is aborted'));
435
431
  const isUnknownError = !!unknownError || (response === null || response === void 0 ? void 0 : response.status) === 404;
436
432
  const shouldCallFallback =
437
433
  // If next fallback is available, and the error is unknown (Failed to fetch) or 404
438
434
  nextFallbackApiType && isUnknownError;
439
435
  // Should log the error if it's unknown error
440
- if (isUnknownError) {
436
+ if (isUnknownError || isAbortError) {
441
437
  void sendErrorLog({
442
438
  endpoint: fallbackApiList[basePathType] + path,
443
439
  errors: errors.map(({ message }) => `API: ${message}`),