@zonos/elements 1.3.51 → 1.3.52

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 (207) hide show
  1. package/dist/cjs/CheckoutConfig-65376e00.js +40 -0
  2. package/dist/cjs/{cart-546d1602.js → cart-61a8983d.js} +238 -375
  3. package/dist/cjs/{createCustomEvent-9b91480b.js → createCustomEvent-228027b5.js} +3 -2
  4. package/dist/cjs/handleFetch-842c95b0.js +322 -0
  5. package/dist/cjs/index.cjs.js +75 -35
  6. package/dist/cjs/loader.cjs.js +1 -1
  7. package/dist/cjs/{paypal-83f49f9a.js → paypal-f1eb6621.js} +16 -16
  8. package/dist/cjs/zonos-address_8.cjs.entry.js +4 -4
  9. package/dist/cjs/{zonos-cart-items_12.cjs.entry.js → zonos-badge_13.cjs.entry.js} +41 -9
  10. package/dist/cjs/zonos-checkout.cjs.entry.js +75 -174
  11. package/dist/cjs/zonos-controller.cjs.entry.js +27 -25
  12. package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
  13. package/dist/cjs/zonos-country-select_4.cjs.entry.js +2 -2
  14. package/dist/cjs/zonos-elements.cjs.js +1 -1
  15. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
  16. package/dist/cjs/zonos-hello.cjs.entry.js +11 -11
  17. package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
  18. package/dist/cjs/zonos-notification_3.cjs.entry.js +9 -9
  19. package/dist/cjs/zonos-tooltip.cjs.entry.js +27 -0
  20. package/dist/collection/components/checkout/zonos-checkout/zonos-cart-subtotal/zonos-cart-subtotal.js +5 -2
  21. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +44 -20
  22. package/dist/collection/components/store/checkout/cart.js +14 -2
  23. package/dist/collection/components/store/checkout/stripe.js +9 -4
  24. package/dist/collection/components/store/translationStore/strings.arabic.js +3 -3
  25. package/dist/collection/components/store/translationStore/strings.base.js +3 -3
  26. package/dist/collection/components/store/translationStore/strings.chinese.js +3 -3
  27. package/dist/collection/components/store/translationStore/strings.danish.js +3 -3
  28. package/dist/collection/components/store/translationStore/strings.dutch.js +3 -3
  29. package/dist/collection/components/store/translationStore/strings.french.js +3 -3
  30. package/dist/collection/components/store/translationStore/strings.german.js +3 -3
  31. package/dist/collection/components/store/translationStore/strings.hebrew.js +3 -3
  32. package/dist/collection/components/store/translationStore/strings.indonesian.js +3 -3
  33. package/dist/collection/components/store/translationStore/strings.italian.js +3 -3
  34. package/dist/collection/components/store/translationStore/strings.japanese.js +3 -3
  35. package/dist/collection/components/store/translationStore/strings.korean.js +3 -3
  36. package/dist/collection/components/store/translationStore/strings.norwegian.js +3 -3
  37. package/dist/collection/components/store/translationStore/strings.polish.js +3 -3
  38. package/dist/collection/components/store/translationStore/strings.portuguese.js +3 -3
  39. package/dist/collection/components/store/translationStore/strings.russian.js +3 -3
  40. package/dist/collection/components/store/translationStore/strings.spanish.js +3 -3
  41. package/dist/collection/components/store/translationStore/strings.swedish.js +3 -3
  42. package/dist/collection/components/store/translationStore/strings.turkish.js +3 -3
  43. package/dist/collection/components/store/translationStore/strings.vietnamese.js +3 -3
  44. package/dist/collection/components/utils/api/buildCartItemsByTempCart.js +14 -14
  45. package/dist/collection/components/utils/api/calculateLandedCostNormalized.js +28 -0
  46. package/dist/collection/components/utils/api/cartCalculateLandedCost.js +19 -0
  47. package/dist/collection/components/utils/api/prepCalculateLandedCost.js +65 -0
  48. package/dist/collection/components/utils/checkout/initCheckout.js +4 -2
  49. package/dist/collection/environment.js +1 -1
  50. package/dist/collection/scripts/_getNextFallbackUrl.js +1 -0
  51. package/dist/collection/scripts/_getTempCartById.js +14 -0
  52. package/dist/collection/scripts/_zonosBase.js +39 -10
  53. package/dist/collection/scripts/cart/_getCartIdFromParam.js +9 -0
  54. package/dist/collection/scripts/cart/_setupCartData.js +18 -0
  55. package/dist/collection/types/checkout/CheckoutConfig.js +2 -1
  56. package/dist/collection/types/generated/graphql.customer.types.js +12 -0
  57. package/dist/collection/utils/formattedCloudflareApiUrl.js +8 -2
  58. package/dist/collection/utils/generateCloudflareDeployUrl.js +3 -0
  59. package/dist/esm/CheckoutConfig-57350b28.js +36 -0
  60. package/dist/esm/{cart-51529af2.js → cart-45d2861f.js} +193 -327
  61. package/dist/esm/{createCustomEvent-b8bbdf5e.js → createCustomEvent-3fcc948a.js} +2 -1
  62. package/dist/esm/handleFetch-37cea185.js +315 -0
  63. package/dist/esm/index.js +56 -17
  64. package/dist/esm/loader.js +1 -1
  65. package/dist/esm/{paypal-905325d0.js → paypal-ee310945.js} +2 -2
  66. package/dist/esm/zonos-address_8.entry.js +2 -2
  67. package/dist/esm/{zonos-cart-items_12.entry.js → zonos-badge_13.entry.js} +40 -9
  68. package/dist/esm/zonos-checkout.entry.js +61 -160
  69. package/dist/esm/zonos-controller.entry.js +6 -4
  70. package/dist/esm/zonos-country-flag.entry.js +2 -2
  71. package/dist/esm/zonos-country-select_4.entry.js +2 -2
  72. package/dist/esm/zonos-elements.js +1 -1
  73. package/dist/esm/zonos-hello-dialog.entry.js +2 -2
  74. package/dist/esm/zonos-hello.entry.js +2 -2
  75. package/dist/esm/zonos-language-select_2.entry.js +2 -2
  76. package/dist/esm/zonos-notification_3.entry.js +3 -3
  77. package/dist/esm/zonos-tooltip.entry.js +23 -0
  78. package/dist/esm-es5/CheckoutConfig-57350b28.js +1 -0
  79. package/dist/esm-es5/cart-45d2861f.js +1 -0
  80. package/dist/esm-es5/{createCustomEvent-b8bbdf5e.js → createCustomEvent-3fcc948a.js} +1 -1
  81. package/dist/esm-es5/handleFetch-37cea185.js +1 -0
  82. package/dist/esm-es5/index.js +1 -1
  83. package/dist/esm-es5/loader.js +1 -1
  84. package/dist/esm-es5/{paypal-905325d0.js → paypal-ee310945.js} +1 -1
  85. package/dist/esm-es5/zonos-address_8.entry.js +1 -1
  86. package/dist/esm-es5/zonos-badge_13.entry.js +1 -0
  87. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  88. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  89. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  90. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  91. package/dist/esm-es5/zonos-elements.js +1 -1
  92. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  93. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  94. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  95. package/dist/esm-es5/zonos-notification_3.entry.js +1 -1
  96. package/dist/esm-es5/zonos-tooltip.entry.js +1 -0
  97. package/dist/scripts/index.d.ts +74 -87
  98. package/dist/scripts/index.js +1 -1
  99. package/dist/scripts/loadZonos.js +1 -1
  100. package/dist/scripts/zonos.js +1 -1
  101. package/dist/types/components/checkout/zonos-checkout/zonos-checkout.d.ts +0 -2
  102. package/dist/types/components/store/checkout/cart.d.ts +13 -3
  103. package/dist/types/components/store/checkout/stripe.d.ts +3 -1
  104. package/dist/types/components/store/translationStore/strings.arabic.d.ts +3 -3
  105. package/dist/types/components/store/translationStore/strings.base.d.ts +3 -3
  106. package/dist/types/components/store/translationStore/strings.chinese.d.ts +3 -3
  107. package/dist/types/components/store/translationStore/strings.danish.d.ts +3 -3
  108. package/dist/types/components/store/translationStore/strings.dutch.d.ts +3 -3
  109. package/dist/types/components/store/translationStore/strings.french.d.ts +3 -3
  110. package/dist/types/components/store/translationStore/strings.german.d.ts +3 -3
  111. package/dist/types/components/store/translationStore/strings.hebrew.d.ts +3 -3
  112. package/dist/types/components/store/translationStore/strings.indonesian.d.ts +3 -3
  113. package/dist/types/components/store/translationStore/strings.italian.d.ts +3 -3
  114. package/dist/types/components/store/translationStore/strings.japanese.d.ts +3 -3
  115. package/dist/types/components/store/translationStore/strings.korean.d.ts +3 -3
  116. package/dist/types/components/store/translationStore/strings.norwegian.d.ts +3 -3
  117. package/dist/types/components/store/translationStore/strings.polish.d.ts +3 -3
  118. package/dist/types/components/store/translationStore/strings.portuguese.d.ts +3 -3
  119. package/dist/types/components/store/translationStore/strings.russian.d.ts +3 -3
  120. package/dist/types/components/store/translationStore/strings.spanish.d.ts +3 -3
  121. package/dist/types/components/store/translationStore/strings.swedish.d.ts +3 -3
  122. package/dist/types/components/store/translationStore/strings.turkish.d.ts +3 -3
  123. package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +3 -3
  124. package/dist/types/components/store/translationStore.d.ts +1 -1
  125. package/dist/types/components/utils/api/buildCartItemsByTempCart.d.ts +8 -3
  126. package/dist/types/components/utils/api/calculateLandedCostNormalized.d.ts +2 -0
  127. package/dist/types/components/utils/api/cartCalculateLandedCost.d.ts +5 -0
  128. package/dist/types/components/utils/api/prepCalculateLandedCost.d.ts +5 -1
  129. package/dist/types/components/utils/checkout/getIsTestMode.d.ts +1 -1
  130. package/dist/types/scripts/_getNextFallbackUrl.d.ts +1 -0
  131. package/dist/types/scripts/_getTempCartById.d.ts +8 -0
  132. package/dist/types/scripts/_zonosBase.d.ts +15 -12
  133. package/dist/types/scripts/cart/_getCartIdFromParam.d.ts +4 -0
  134. package/dist/types/scripts/cart/_setupCartData.d.ts +7 -0
  135. package/dist/types/types/checkout/CheckoutConfig.d.ts +18 -3
  136. package/dist/types/types/checkout/api/CalculateLandedCostRequest.d.ts +42 -1
  137. package/dist/types/types/checkout/api/NormalizedTempCart.d.ts +37 -0
  138. package/dist/types/types/generated/graphql.customer.types.d.ts +249 -2
  139. package/dist/types/types/generated/graphql.customer.types.ts +251 -3
  140. package/dist/types/utils/formattedCloudflareApiUrl.d.ts +2 -2
  141. package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
  142. package/dist/zonos-elements/index.esm.js +1 -1
  143. package/dist/zonos-elements/p-042c466d.system.entry.js +1 -0
  144. package/dist/zonos-elements/p-10cb0064.entry.js +1 -0
  145. package/dist/zonos-elements/{p-5e56828a.entry.js → p-259ccf8d.entry.js} +1 -1
  146. package/dist/zonos-elements/p-2a47d2cc.system.entry.js +1 -0
  147. package/dist/zonos-elements/{p-ffd76226.entry.js → p-31eb835c.entry.js} +1 -1
  148. package/dist/zonos-elements/{p-58d9803d.entry.js → p-36360905.entry.js} +1 -1
  149. package/dist/zonos-elements/{p-1828a4ff.system.entry.js → p-3703b814.system.entry.js} +1 -1
  150. package/dist/zonos-elements/p-4146feec.js +1 -0
  151. package/dist/zonos-elements/p-446c8f02.system.entry.js +1 -0
  152. package/dist/zonos-elements/{p-2c323311.system.js → p-5590f90c.system.js} +1 -1
  153. package/dist/zonos-elements/p-588396df.js +1 -0
  154. package/dist/zonos-elements/{p-aa5d669b.js → p-6e59c6e4.js} +2 -2
  155. package/dist/zonos-elements/p-6eedc3f8.entry.js +1 -0
  156. package/dist/zonos-elements/p-747eed39.entry.js +1 -0
  157. package/dist/zonos-elements/{p-00100b17.system.entry.js → p-8228e87c.system.entry.js} +1 -1
  158. package/dist/zonos-elements/p-827868e6.entry.js +1 -0
  159. package/dist/zonos-elements/{p-cc7a4fca.entry.js → p-88005b94.entry.js} +1 -1
  160. package/dist/zonos-elements/p-895fdefb.js +1 -0
  161. package/dist/zonos-elements/p-8f7773b0.system.js +1 -0
  162. package/dist/zonos-elements/{p-9a0401fd.entry.js → p-8fa49d94.entry.js} +1 -1
  163. package/dist/zonos-elements/p-a74a7afa.system.js +1 -0
  164. package/dist/zonos-elements/p-b1861e64.system.js +1 -0
  165. package/dist/zonos-elements/{p-8473f99a.system.entry.js → p-b842b96a.system.entry.js} +1 -1
  166. package/dist/zonos-elements/{p-9e976332.entry.js → p-bb186075.entry.js} +1 -1
  167. package/dist/zonos-elements/{p-b1a8b874.system.entry.js → p-c008648a.system.entry.js} +1 -1
  168. package/dist/zonos-elements/p-c78dd680.system.js +1 -1
  169. package/dist/zonos-elements/{p-6b42fa1b.system.entry.js → p-cd4ad1be.system.entry.js} +1 -1
  170. package/dist/zonos-elements/{p-59e85369.system.entry.js → p-d62e6bb0.system.entry.js} +1 -1
  171. package/dist/zonos-elements/{p-496e040f.system.entry.js → p-dc12f30a.system.entry.js} +1 -1
  172. package/dist/zonos-elements/p-eb2aedd0.js +1 -0
  173. package/dist/zonos-elements/{p-c89859cf.system.js → p-f124e459.system.js} +2 -2
  174. package/dist/zonos-elements/p-f527cd5b.entry.js +1 -0
  175. package/dist/zonos-elements/p-f826b979.system.entry.js +1 -0
  176. package/dist/zonos-elements/p-f87a635b.system.js +1 -0
  177. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  178. package/package.json +1 -1
  179. package/dist/cjs/logError-4e2f2020.js +0 -58
  180. package/dist/cjs/zonos-badge_2.cjs.entry.js +0 -57
  181. package/dist/collection/components/utils/api/tempCartItem/getAttributes.js +0 -66
  182. package/dist/collection/components/utils/api/tempCartItem/getMeasurements.js +0 -58
  183. package/dist/esm/logError-c456c092.js +0 -55
  184. package/dist/esm/zonos-badge_2.entry.js +0 -52
  185. package/dist/esm-es5/cart-51529af2.js +0 -1
  186. package/dist/esm-es5/logError-c456c092.js +0 -1
  187. package/dist/esm-es5/zonos-badge_2.entry.js +0 -1
  188. package/dist/esm-es5/zonos-cart-items_12.entry.js +0 -1
  189. package/dist/types/components/utils/api/tempCartItem/getAttributes.d.ts +0 -11
  190. package/dist/types/components/utils/api/tempCartItem/getMeasurements.d.ts +0 -7
  191. package/dist/types/types/checkout/api/TempCart.d.ts +0 -80
  192. package/dist/zonos-elements/p-101c41bf.entry.js +0 -1
  193. package/dist/zonos-elements/p-3c4eec63.system.entry.js +0 -1
  194. package/dist/zonos-elements/p-47945026.system.entry.js +0 -1
  195. package/dist/zonos-elements/p-47c72c50.system.entry.js +0 -1
  196. package/dist/zonos-elements/p-4e77ed65.system.entry.js +0 -1
  197. package/dist/zonos-elements/p-6013e370.entry.js +0 -1
  198. package/dist/zonos-elements/p-63db40b9.system.js +0 -1
  199. package/dist/zonos-elements/p-8b8ef484.entry.js +0 -1
  200. package/dist/zonos-elements/p-b57d24f2.entry.js +0 -1
  201. package/dist/zonos-elements/p-ba0289f9.entry.js +0 -1
  202. package/dist/zonos-elements/p-c8a3303b.js +0 -1
  203. package/dist/zonos-elements/p-d413cd13.js +0 -1
  204. package/dist/zonos-elements/p-e758ec31.system.js +0 -1
  205. package/dist/zonos-elements/p-eaa335e1.js +0 -1
  206. package/dist/zonos-elements/p-fcfde531.system.js +0 -1
  207. /package/dist/collection/types/checkout/api/{TempCart.js → NormalizedTempCart.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const zonosStore = require('./zonosStore-67139f0e.js');
4
- const logError = require('./logError-4e2f2020.js');
4
+ const handleFetch = require('./handleFetch-842c95b0.js');
5
5
  const isDarkColor = require('./isDarkColor-7a056d05.js');
6
6
  const getBorderRadius = require('./getBorderRadius-a6a3b35e.js');
7
7
 
@@ -75,6 +75,9 @@ const stringsArabic = {
75
75
  'Delivery options': {
76
76
  value: 'خيارات التوصيل',
77
77
  },
78
+ Discounts: {
79
+ value: 'خصومات',
80
+ },
78
81
  "Don't close": {
79
82
  value: 'لا تغلق',
80
83
  },
@@ -153,9 +156,6 @@ const stringsArabic = {
153
156
  'Nothing due at the door': {
154
157
  value: 'لا شيء مستحق عند الباب',
155
158
  },
156
- 'Order is over the de minimis threshold for both duty and tax': {
157
- value: 'الطلبية أعلى من الحد الأدنى لكل من الرسوم والضرائب',
158
- },
159
159
  'Order total': {
160
160
  value: 'إجمالي الطلبية',
161
161
  },
@@ -429,6 +429,9 @@ const stringsBase = {
429
429
  'Delivery options': {
430
430
  value: 'Delivery options',
431
431
  },
432
+ Discounts: {
433
+ value: 'Discounts',
434
+ },
432
435
  "Don't close": {
433
436
  value: "Don't close",
434
437
  },
@@ -507,9 +510,6 @@ const stringsBase = {
507
510
  'Nothing due at the door': {
508
511
  value: 'Nothing due at the door',
509
512
  },
510
- 'Order is over the de minimis threshold for both duty and tax': {
511
- value: 'Order is over the de minimis threshold for both duty and tax',
512
- },
513
513
  'Order total': {
514
514
  value: 'Order total',
515
515
  },
@@ -783,6 +783,9 @@ const stringsChinese = {
783
783
  'Delivery options': {
784
784
  value: '送货选项',
785
785
  },
786
+ Discounts: {
787
+ value: '折扣',
788
+ },
786
789
  "Don't close": {
787
790
  value: '不要关',
788
791
  },
@@ -861,9 +864,6 @@ const stringsChinese = {
861
864
  'Nothing due at the door': {
862
865
  value: '门口无需付款',
863
866
  },
864
- 'Order is over the de minimis threshold for both duty and tax': {
865
- value: '订单超过关税和税款的最低征税门槛',
866
- },
867
867
  'Order total': {
868
868
  value: '订单总计',
869
869
  },
@@ -1137,6 +1137,9 @@ const stringsDanish = {
1137
1137
  'Delivery options': {
1138
1138
  value: 'Leveringsmuligheder',
1139
1139
  },
1140
+ Discounts: {
1141
+ value: 'Rabat',
1142
+ },
1140
1143
  "Don't close": {
1141
1144
  value: 'Luk ikke',
1142
1145
  },
@@ -1215,9 +1218,6 @@ const stringsDanish = {
1215
1218
  'Nothing due at the door': {
1216
1219
  value: 'Intet at betale ved døren',
1217
1220
  },
1218
- 'Order is over the de minimis threshold for both duty and tax': {
1219
- value: 'Ordre er over de minimis-grænsen for både told og skat',
1220
- },
1221
1221
  'Order total': {
1222
1222
  value: 'Ordresum',
1223
1223
  },
@@ -1491,6 +1491,9 @@ const stringsDutch = {
1491
1491
  'Delivery options': {
1492
1492
  value: 'Bezorgopties',
1493
1493
  },
1494
+ Discounts: {
1495
+ value: 'Kortingen',
1496
+ },
1494
1497
  "Don't close": {
1495
1498
  value: 'Niet sluiten',
1496
1499
  },
@@ -1569,9 +1572,6 @@ const stringsDutch = {
1569
1572
  'Nothing due at the door': {
1570
1573
  value: 'Niets te betalen aan de deur',
1571
1574
  },
1572
- 'Order is over the de minimis threshold for both duty and tax': {
1573
- value: 'Bestelling overschrijdt de minimale drempel voor zowel heffing als belasting',
1574
- },
1575
1575
  'Order total': {
1576
1576
  value: 'Totaal bestelling',
1577
1577
  },
@@ -1845,6 +1845,9 @@ const stringsFrench = {
1845
1845
  'Delivery options': {
1846
1846
  value: 'Options de livraison',
1847
1847
  },
1848
+ Discounts: {
1849
+ value: 'Réductions',
1850
+ },
1848
1851
  "Don't close": {
1849
1852
  value: 'Ne pas fermer',
1850
1853
  },
@@ -1923,9 +1926,6 @@ const stringsFrench = {
1923
1926
  'Nothing due at the door': {
1924
1927
  value: 'Rien à payer à la porte',
1925
1928
  },
1926
- 'Order is over the de minimis threshold for both duty and tax': {
1927
- value: 'La commande dépasse le seuil de minimis pour les droits et les taxes',
1928
- },
1929
1929
  'Order total': {
1930
1930
  value: 'Total de la commande',
1931
1931
  },
@@ -2199,6 +2199,9 @@ const stringsGerman = {
2199
2199
  'Delivery options': {
2200
2200
  value: 'Lieferoptionen',
2201
2201
  },
2202
+ Discounts: {
2203
+ value: 'Rabatte',
2204
+ },
2202
2205
  "Don't close": {
2203
2206
  value: 'Nicht schließen',
2204
2207
  },
@@ -2277,9 +2280,6 @@ const stringsGerman = {
2277
2280
  'Nothing due at the door': {
2278
2281
  value: 'An der Tür nichts zu bezahlen',
2279
2282
  },
2280
- 'Order is over the de minimis threshold for both duty and tax': {
2281
- value: 'Bestellung überschreitet Mindestgrenze sowohl für Zoll als auch Steuer',
2282
- },
2283
2283
  'Order total': {
2284
2284
  value: 'Bestellsumme',
2285
2285
  },
@@ -2553,6 +2553,9 @@ const stringsHebrew = {
2553
2553
  'Delivery options': {
2554
2554
  value: 'אפשרויות משלוח',
2555
2555
  },
2556
+ Discounts: {
2557
+ value: 'הנחות',
2558
+ },
2556
2559
  "Don't close": {
2557
2560
  value: 'אל תסגור',
2558
2561
  },
@@ -2631,9 +2634,6 @@ const stringsHebrew = {
2631
2634
  'Nothing due at the door': {
2632
2635
  value: 'אין כלום לשלם בדלת',
2633
2636
  },
2634
- 'Order is over the de minimis threshold for both duty and tax': {
2635
- value: 'ההזמנה חורגת מסף המינימום גם למכס וגם למס',
2636
- },
2637
2637
  'Order total': {
2638
2638
  value: 'סה"כ ההזמנה',
2639
2639
  },
@@ -2907,6 +2907,9 @@ const stringsIndonesian = {
2907
2907
  'Delivery options': {
2908
2908
  value: 'Opsi pengiriman',
2909
2909
  },
2910
+ Discounts: {
2911
+ value: 'Diskon',
2912
+ },
2910
2913
  "Don't close": {
2911
2914
  value: 'Jangan tutup',
2912
2915
  },
@@ -2985,9 +2988,6 @@ const stringsIndonesian = {
2985
2988
  'Nothing due at the door': {
2986
2989
  value: 'Tidak ada yang harus dibayar di pintu',
2987
2990
  },
2988
- 'Order is over the de minimis threshold for both duty and tax': {
2989
- value: 'Pesanan melebihi ambang batas de minimis untuk bea masuk dan pajak',
2990
- },
2991
2991
  'Order total': {
2992
2992
  value: 'Total pesanan',
2993
2993
  },
@@ -3261,6 +3261,9 @@ const stringsItalian = {
3261
3261
  'Delivery options': {
3262
3262
  value: 'Opzioni di consegna',
3263
3263
  },
3264
+ Discounts: {
3265
+ value: 'Sconti',
3266
+ },
3264
3267
  "Don't close": {
3265
3268
  value: 'Non chiudere',
3266
3269
  },
@@ -3339,9 +3342,6 @@ const stringsItalian = {
3339
3342
  'Nothing due at the door': {
3340
3343
  value: 'Nulla da pagare alla porta',
3341
3344
  },
3342
- 'Order is over the de minimis threshold for both duty and tax': {
3343
- value: "L'ordine supera la soglia di minimis sia per i dazi che per le tasse",
3344
- },
3345
3345
  'Order total': {
3346
3346
  value: 'Totale ordine',
3347
3347
  },
@@ -3615,6 +3615,9 @@ const stringsJapanese = {
3615
3615
  'Delivery options': {
3616
3616
  value: '配送オプション',
3617
3617
  },
3618
+ Discounts: {
3619
+ value: '割引',
3620
+ },
3618
3621
  "Don't close": {
3619
3622
  value: '閉めないでください',
3620
3623
  },
@@ -3693,9 +3696,6 @@ const stringsJapanese = {
3693
3696
  'Nothing due at the door': {
3694
3697
  value: 'ドアでの支払いはありません',
3695
3698
  },
3696
- 'Order is over the de minimis threshold for both duty and tax': {
3697
- value: '注文が関税と税金のデミニマス閾値を超えています',
3698
- },
3699
3699
  'Order total': {
3700
3700
  value: 'ご注文合計',
3701
3701
  },
@@ -3969,6 +3969,9 @@ const stringsKorean = {
3969
3969
  'Delivery options': {
3970
3970
  value: '배송 옵션',
3971
3971
  },
3972
+ Discounts: {
3973
+ value: '할인',
3974
+ },
3972
3975
  "Don't close": {
3973
3976
  value: '닫지 마세요',
3974
3977
  },
@@ -4047,9 +4050,6 @@ const stringsKorean = {
4047
4050
  'Nothing due at the door': {
4048
4051
  value: '문 앞에 납부할 것이 없습니다',
4049
4052
  },
4050
- 'Order is over the de minimis threshold for both duty and tax': {
4051
- value: '주문 금액이 관세와 세금의 최저 임계값을 초과합니다',
4052
- },
4053
4053
  'Order total': {
4054
4054
  value: '주문 총액',
4055
4055
  },
@@ -4323,6 +4323,9 @@ const stringsNorwegian = {
4323
4323
  'Delivery options': {
4324
4324
  value: 'Leveringsalternativer',
4325
4325
  },
4326
+ Discounts: {
4327
+ value: 'Rabatter',
4328
+ },
4326
4329
  "Don't close": {
4327
4330
  value: 'Ikke lukk',
4328
4331
  },
@@ -4401,9 +4404,6 @@ const stringsNorwegian = {
4401
4404
  'Nothing due at the door': {
4402
4405
  value: 'Ingenting å betale ved døren',
4403
4406
  },
4404
- 'Order is over the de minimis threshold for both duty and tax': {
4405
- value: 'Bestillingen er over minstegrensen for både avgift og skatt',
4406
- },
4407
4407
  'Order total': {
4408
4408
  value: 'Totalt beløp',
4409
4409
  },
@@ -4677,6 +4677,9 @@ const stringsPolish = {
4677
4677
  'Delivery options': {
4678
4678
  value: 'Opcje dostawy',
4679
4679
  },
4680
+ Discounts: {
4681
+ value: 'Zniżki',
4682
+ },
4680
4683
  "Don't close": {
4681
4684
  value: 'Nie zamykaj',
4682
4685
  },
@@ -4755,9 +4758,6 @@ const stringsPolish = {
4755
4758
  'Nothing due at the door': {
4756
4759
  value: 'Nic do zapłacenia przy drzwiach',
4757
4760
  },
4758
- 'Order is over the de minimis threshold for both duty and tax': {
4759
- value: 'Zamówienie przekracza próg minimalny zarówno dla cła, jak i podatku',
4760
- },
4761
4761
  'Order total': {
4762
4762
  value: 'Łączna kwota zamówienia',
4763
4763
  },
@@ -5031,6 +5031,9 @@ const stringsPortuguese = {
5031
5031
  'Delivery options': {
5032
5032
  value: 'Opções de entrega',
5033
5033
  },
5034
+ Discounts: {
5035
+ value: 'Descontos',
5036
+ },
5034
5037
  "Don't close": {
5035
5038
  value: 'Não fechar',
5036
5039
  },
@@ -5109,9 +5112,6 @@ const stringsPortuguese = {
5109
5112
  'Nothing due at the door': {
5110
5113
  value: 'Nada a pagar na porta',
5111
5114
  },
5112
- 'Order is over the de minimis threshold for both duty and tax': {
5113
- value: 'O pedido ultrapassa o limite de isenção tanto para impostos quanto para taxas',
5114
- },
5115
5115
  'Order total': {
5116
5116
  value: 'Total do pedido',
5117
5117
  },
@@ -5385,6 +5385,9 @@ const stringsRussian = {
5385
5385
  'Delivery options': {
5386
5386
  value: 'Варианты доставки',
5387
5387
  },
5388
+ Discounts: {
5389
+ value: 'Скидки',
5390
+ },
5388
5391
  "Don't close": {
5389
5392
  value: 'Не закрывайте',
5390
5393
  },
@@ -5463,9 +5466,6 @@ const stringsRussian = {
5463
5466
  'Nothing due at the door': {
5464
5467
  value: 'На двери ничего не должно',
5465
5468
  },
5466
- 'Order is over the de minimis threshold for both duty and tax': {
5467
- value: 'Заказ превышает минимальный порог как для пошлины, так и для налога',
5468
- },
5469
5469
  'Order total': {
5470
5470
  value: 'Итого',
5471
5471
  },
@@ -5739,6 +5739,9 @@ const stringsSpanish = {
5739
5739
  'Delivery options': {
5740
5740
  value: 'Opciones de entrega',
5741
5741
  },
5742
+ Discounts: {
5743
+ value: 'Descuentos',
5744
+ },
5742
5745
  "Don't close": {
5743
5746
  value: 'No cerrar',
5744
5747
  },
@@ -5817,9 +5820,6 @@ const stringsSpanish = {
5817
5820
  'Nothing due at the door': {
5818
5821
  value: 'Nada debido en la puerta',
5819
5822
  },
5820
- 'Order is over the de minimis threshold for both duty and tax': {
5821
- value: 'El pedido supera el umbral mínimo tanto para impuestos como para aranceles',
5822
- },
5823
5823
  'Order total': {
5824
5824
  value: 'Total del pedido',
5825
5825
  },
@@ -6093,6 +6093,9 @@ const stringsSwedish = {
6093
6093
  'Delivery options': {
6094
6094
  value: 'Leveransalternativ',
6095
6095
  },
6096
+ Discounts: {
6097
+ value: 'Rabatter',
6098
+ },
6096
6099
  "Don't close": {
6097
6100
  value: 'Stäng inte',
6098
6101
  },
@@ -6171,9 +6174,6 @@ const stringsSwedish = {
6171
6174
  'Nothing due at the door': {
6172
6175
  value: 'Ingenting att betala vid dörren',
6173
6176
  },
6174
- 'Order is over the de minimis threshold for both duty and tax': {
6175
- value: 'Beställningen överstiger minimibeloppet för både tull och skatt',
6176
- },
6177
6177
  'Order total': {
6178
6178
  value: 'Totalt belopp för beställningen',
6179
6179
  },
@@ -6447,6 +6447,9 @@ const stringsTurkish = {
6447
6447
  'Delivery options': {
6448
6448
  value: 'Teslimat seçenekleri',
6449
6449
  },
6450
+ Discounts: {
6451
+ value: 'İndirimler',
6452
+ },
6450
6453
  "Don't close": {
6451
6454
  value: 'Kapatma',
6452
6455
  },
@@ -6525,9 +6528,6 @@ const stringsTurkish = {
6525
6528
  'Nothing due at the door': {
6526
6529
  value: 'Kapıda ödenecek bir şey yok',
6527
6530
  },
6528
- 'Order is over the de minimis threshold for both duty and tax': {
6529
- value: 'Sipariş hem gümrük hem vergi için minimum sınırın üzerinde',
6530
- },
6531
6531
  'Order total': {
6532
6532
  value: 'Sipariş toplamı',
6533
6533
  },
@@ -6801,6 +6801,9 @@ const stringsVietnamese = {
6801
6801
  'Delivery options': {
6802
6802
  value: 'Tùy chọn giao hàng',
6803
6803
  },
6804
+ Discounts: {
6805
+ value: 'Giảm giá',
6806
+ },
6804
6807
  "Don't close": {
6805
6808
  value: 'Đừng đóng',
6806
6809
  },
@@ -6879,9 +6882,6 @@ const stringsVietnamese = {
6879
6882
  'Nothing due at the door': {
6880
6883
  value: 'Không có gì phải trả tại cửa',
6881
6884
  },
6882
- 'Order is over the de minimis threshold for both duty and tax': {
6883
- value: 'Đơn hàng vượt ngưỡng miễn thuế cho cả thuế nhập khẩu và thuế',
6884
- },
6885
6885
  'Order total': {
6886
6886
  value: 'Tổng đơn hàng',
6887
6887
  },
@@ -7173,269 +7173,9 @@ const translate = (...[key, replacement]) => {
7173
7173
  return ((_b = translationStore.translatedChunks[key]) === null || _b === void 0 ? void 0 : _b.value) || key;
7174
7174
  };
7175
7175
 
7176
- const fallbackApiType = ['cloudflare', 'vercel'];
7177
- const MAIN_BASE_API_TYPE = fallbackApiType[0];
7178
- const fallbackApiList = {
7179
- cloudflare: "https://route.elements.zonos.com",
7180
- vercel: "https://v1.route.js.zonos.com",
7181
- };
7182
- const MAIN_BASE_API = fallbackApiList[MAIN_BASE_API_TYPE];
7183
- /**
7184
- * Next available fallback api type
7185
- */
7186
- const getNextFallbackApiType = (currentApiType = MAIN_BASE_API_TYPE) => {
7187
- const currentIndex = fallbackApiType.indexOf(currentApiType);
7188
- const nextFallbackApiType = fallbackApiType[currentIndex + 1];
7189
- if (!nextFallbackApiType) {
7190
- return null;
7191
- }
7192
- return nextFallbackApiType;
7193
- };
7194
-
7195
- const jsonParse = (_data) => {
7196
- if (typeof _data === 'string') {
7197
- try {
7198
- // eslint-disable-next-line no-restricted-syntax
7199
- const json = JSON.parse(_data);
7200
- return json;
7201
- }
7202
- catch (_error) {
7203
- return null;
7204
- }
7205
- }
7206
- return null;
7207
- };
7208
-
7209
- /**
7210
- * This is the time in milliseconds after release time that we will start sending error logs to the new API
7211
- * @default 1 hour
7212
- */
7213
- const postReleaseReportingDuration = 1 * 3600 * 1000; // 1 hour
7214
- const sendErrorLog = async ({ endpoint, errors, metadata, shouldPostReleaseErrorReporting, }) => {
7215
- if (shouldPostReleaseErrorReporting) {
7216
- // We only want to report errors that happened if current time is less than 2 hours after release time
7217
- const releaseTime = Number(window.Zonos.releaseDate);
7218
- const currentTime = new Date().getTime();
7219
- if (currentTime - releaseTime > postReleaseReportingDuration) {
7220
- return;
7221
- }
7222
- }
7223
- const userAgentData = 'userAgentData' in window.navigator
7224
- ? // userAgentData is not yet supported in all browsers
7225
- window.navigator.userAgentData
7226
- : null;
7227
- const errorObject = {
7228
- endpoint,
7229
- errors,
7230
- metadata: Object.assign({ href: window.location.href, userAgent: userAgentData && userAgentData.brands.length > 0
7231
- ? userAgentData
7232
- : window.navigator.userAgent }, metadata),
7233
- };
7234
- try {
7235
- // use native fetch because in handleFetch also calls sendErrorLog and it will possibly cause circular dependencies issue
7236
- void fetch(`${MAIN_BASE_API}/api/zonos-elements/log-error`, {
7237
- body: JSON.stringify(errorObject),
7238
- method: 'POST',
7239
- });
7240
- }
7241
- catch (_err) {
7242
- const nextFallbackApi = getNextFallbackApiType();
7243
- if (!nextFallbackApi) {
7244
- return;
7245
- }
7246
- // request to the fallback API if the first one fails
7247
- void fetch(`${fallbackApiList[nextFallbackApi]}/api/zonos-elements/log-error`, {
7248
- body: JSON.stringify(errorObject),
7249
- method: 'POST',
7250
- });
7251
- }
7252
- };
7253
-
7254
- var __rest = (undefined && undefined.__rest) || function (s, e) {
7255
- var t = {};
7256
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
7257
- t[p] = s[p];
7258
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7259
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7260
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
7261
- t[p[i]] = s[p[i]];
7262
- }
7263
- return t;
7264
- };
7265
- const getResponseBody = async ({ response, shouldLog = true, shouldThrow = false, }) => {
7266
- try {
7267
- const json = await response.json();
7268
- return json;
7269
- }
7270
- catch (e) {
7271
- if (shouldThrow) {
7272
- throw e;
7273
- }
7274
- if (shouldLog) {
7275
- // eslint-disable-next-line
7276
- console.error(e);
7277
- }
7278
- return null;
7279
- }
7280
- };
7281
- const encodeString = (text) => {
7282
- try {
7283
- // encode the string, remove the "=" at the end of the encoded string
7284
- const encodedString = btoa(text).replace(/=/g, '');
7285
- return encodedString;
7286
- }
7287
- catch (error) {
7288
- // return the reverse string if the encoding failed
7289
- return text
7290
- .replace(/[^A-Za-z0-9]/g, '')
7291
- .split('')
7292
- .reverse()
7293
- .join('');
7294
- }
7295
- };
7296
- const handleRequest = async ({ basePathType, options, path, }) => {
7297
- let response;
7298
- // fallback to the main base API if the passed in base path is not available
7299
- const baseUrl = fallbackApiList[basePathType] || MAIN_BASE_API_TYPE;
7300
- const url = baseUrl + path;
7301
- // adding random encoded token to the url so that the request will be cached differently for each store
7302
- const modifiedUrl = new URL(url);
7303
- modifiedUrl.searchParams.set('zToken', encodeString(window.location.hostname));
7304
- try {
7305
- response = await fetch(modifiedUrl.toString(), options);
7306
- }
7307
- catch (e) {
7308
- if (e instanceof Error) {
7309
- return {
7310
- baseUrl,
7311
- errors: [{ message: e.message, type: 'unknown' }],
7312
- json: null,
7313
- response: null,
7314
- zonosMode: null,
7315
- };
7316
- }
7317
- const message = 'Fail to fetch';
7318
- return {
7319
- baseUrl,
7320
- errors: [{ message, type: 'unknown' }],
7321
- json: null,
7322
- response: null,
7323
- zonosMode: null,
7324
- };
7325
- }
7326
- const zonosMode = response.headers.get('Zonos-Mode');
7327
- const usingZonosPreview = window.Zonos.zonosQaUrl;
7328
- // We only want to alert once if the user is in preview mode and it's also using production environment
7329
- if (!window.Zonos.modeAlerted && zonosMode && usingZonosPreview) {
7330
- window.Zonos.modeAlerted = true;
7331
- }
7332
- if (response.ok) {
7333
- const data = await getResponseBody({ response });
7334
- return {
7335
- baseUrl,
7336
- errors: [],
7337
- json: data,
7338
- response,
7339
- zonosMode,
7340
- };
7341
- }
7342
- const status = response.status.toString();
7343
- try {
7344
- const data = await getResponseBody({
7345
- response,
7346
- shouldThrow: true,
7347
- });
7348
- const message = JSON.stringify(data);
7349
- return {
7350
- baseUrl,
7351
- errors: [{ message, type: status }],
7352
- json: null,
7353
- response,
7354
- zonosMode,
7355
- };
7356
- }
7357
- catch (e) {
7358
- const message = 'Unknown error';
7359
- return {
7360
- baseUrl,
7361
- errors: [{ message: `${status}: ${message}`, type: status }],
7362
- json: null,
7363
- response: null,
7364
- zonosMode,
7365
- };
7366
- }
7367
- };
7368
- const handleRequestWithFallback = async ({ basePathType: _basePathType, options, path, }) => {
7369
- var _a, _b;
7370
- // use vercel API if the path is `/api/bigcommerce`
7371
- const isBigcommerceEndpoint = path.startsWith('/api/bigcommerce');
7372
- const basePathType = isBigcommerceEndpoint
7373
- ? 'vercel'
7374
- : _basePathType;
7375
- const _c = await handleRequest({
7376
- basePathType,
7377
- options,
7378
- path,
7379
- }), { errors, response } = _c, rest = __rest(_c, ["errors", "response"]);
7380
- const nextFallbackApiType = getNextFallbackApiType(basePathType);
7381
- const unknownError = errors.find(({ type }) => type === 'unknown');
7382
- const isUnknownError = !!unknownError || (response === null || response === void 0 ? void 0 : response.status) === 404;
7383
- const shouldCallFallback =
7384
- // If next fallback is available, and the error is unknown (fail to fetch) or 404
7385
- nextFallbackApiType && isUnknownError;
7386
- // Should log the error if it's unknown error
7387
- if (isUnknownError) {
7388
- void sendErrorLog({
7389
- endpoint: fallbackApiList[basePathType] + path,
7390
- errors: errors.map(({ message }) => message),
7391
- metadata: {
7392
- currentBasePath: basePathType,
7393
- nextFallbackApiType,
7394
- requestHeaders: options === null || options === void 0 ? void 0 : options.headers,
7395
- requestPayload: jsonParse((_a = options === null || options === void 0 ? void 0 : options.body) === null || _a === void 0 ? void 0 : _a.toString()) || ((_b = options === null || options === void 0 ? void 0 : options.body) === null || _b === void 0 ? void 0 : _b.toString()),
7396
- status: response === null || response === void 0 ? void 0 : response.status,
7397
- statusText: response === null || response === void 0 ? void 0 : response.statusText,
7398
- },
7399
- // When the error is unknown, error reporting should be enabled for period of time after release, so we can monitor the error.
7400
- shouldPostReleaseErrorReporting: true,
7401
- });
7402
- }
7403
- if (shouldCallFallback) {
7404
- logError.log(`=== "${path}" failed to fetch, trying next fallback ${nextFallbackApiType}`);
7405
- return handleRequestWithFallback({
7406
- basePathType: nextFallbackApiType,
7407
- options,
7408
- path,
7409
- });
7410
- }
7411
- // No more fallbacks, just return the result
7412
- return Object.assign({ errors, response }, rest);
7413
- };
7414
- /**
7415
- * Fetch request and will request to fallback API when the first one fails
7416
- * @param path Path name of the request (e.g. /api/something/com).
7417
- * @param _opts fetch options
7418
- */
7419
- const handleFetch = async (path, _opts) => {
7420
- const opts = __rest(_opts || {}, []);
7421
- const body = opts.body ? JSON.stringify(opts.body) : undefined;
7422
- const method = opts.method || 'GET';
7423
- // headers content type
7424
- const headers = Object.assign({ 'Content-Type': 'application/json', 'Zonos-Is-BigCommerce': window.Zonos.isBigCommerce.toString(), 'Zonos-Referer': window.location.hostname, 'Zonos-Version': window.Zonos.version, credentialtoken: window.Zonos.zonosApiKey || 'Empty credential token from zonos-elements' }, opts.headers);
7425
- const options = Object.assign(Object.assign({}, opts), { body: method === 'GET' ? undefined : body, headers,
7426
- method });
7427
- // This is for testing fallback API, set fallback API type to start with
7428
- const useFallbackApi = new URLSearchParams(window.location.search).get('useFallbackApi');
7429
- return handleRequestWithFallback({
7430
- basePathType: useFallbackApi || MAIN_BASE_API_TYPE,
7431
- options,
7432
- path,
7433
- });
7434
- };
7435
-
7436
7176
  const getCountries = async () => {
7437
7177
  try {
7438
- const { errors, json } = await handleFetch('/api/zonos-elements/get-countries', {
7178
+ const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/get-countries', {
7439
7179
  method: 'GET',
7440
7180
  });
7441
7181
  if (errors.length || !json) {
@@ -7454,9 +7194,9 @@ const getCountryLandedCost = async (countryCode) => {
7454
7194
  return null;
7455
7195
  }
7456
7196
  const url = `/api/zonos-elements/country-landed-cost/${countryCode}`;
7457
- const { errors, json } = await handleFetch(url);
7197
+ const { errors, json } = await handleFetch.handleFetch(url);
7458
7198
  if (errors.length || !json) {
7459
- logError.logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
7199
+ handleFetch.logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
7460
7200
  return null;
7461
7201
  }
7462
7202
  return json || null;
@@ -7487,9 +7227,9 @@ const getExchangeRate = async ({ country, isGuaranteed, sourceCurrency, targetCu
7487
7227
  searchParams.set('targetCurrency', targetCurrency);
7488
7228
  searchParams.set('isGuaranteed', String(isGuaranteed));
7489
7229
  searchParams.set('country', country || '');
7490
- const { errors, json } = await handleFetch(`/api/zonos-elements/exchange-rates?${searchParams.toString()}`);
7230
+ const { errors, json } = await handleFetch.handleFetch(`/api/zonos-elements/exchange-rates?${searchParams.toString()}`);
7491
7231
  if (errors.length || !json) {
7492
- logError.logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
7232
+ handleFetch.logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
7493
7233
  return defaultUsExchangeRate;
7494
7234
  }
7495
7235
  const { rate, targetFormat } = json.exchangeRateCreate;
@@ -7507,9 +7247,9 @@ const getInclusivePricing = async (countryCode) => {
7507
7247
  if (!countryCode) {
7508
7248
  return null;
7509
7249
  }
7510
- const { errors, json } = await handleFetch(`/api/zonos-elements/inclusive-prices/${countryCode}`);
7250
+ const { errors, json } = await handleFetch.handleFetch(`/api/zonos-elements/inclusive-prices/${countryCode}`);
7511
7251
  if (errors.length || !json) {
7512
- logError.logError(`Error fetching country inclusive price setting: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
7252
+ handleFetch.logError(`Error fetching country inclusive price setting: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
7513
7253
  return null;
7514
7254
  }
7515
7255
  return json || null;
@@ -7523,9 +7263,9 @@ const getLocaleMessages = async ({ countryCode, localeTo, storeId, }) => {
7523
7263
  if (localeTo) {
7524
7264
  searchParams.set('localeTo', localeTo);
7525
7265
  }
7526
- const { errors, json } = await handleFetch(`/api/zonos-elements/locale-messages?${searchParams.toString()}`);
7266
+ const { errors, json } = await handleFetch.handleFetch(`/api/zonos-elements/locale-messages?${searchParams.toString()}`);
7527
7267
  if (errors.length || !json) {
7528
- logError.logError('Error fetching exchange rate', (_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message);
7268
+ handleFetch.logError('Error fetching exchange rate', (_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message);
7529
7269
  return [];
7530
7270
  }
7531
7271
  return json.locale_countryCodesPage;
@@ -7547,7 +7287,7 @@ const getLocalization = async () => {
7547
7287
  if (zCountry) {
7548
7288
  searchParams.set('zCountry', zCountry);
7549
7289
  }
7550
- const { errors, json } = await handleFetch(`/api/zonos-elements/localization?${searchParams.toString()}`);
7290
+ const { errors, json } = await handleFetch.handleFetch(`/api/zonos-elements/localization?${searchParams.toString()}`);
7551
7291
  if (errors.length || !json) {
7552
7292
  return { country: null, locale: null };
7553
7293
  }
@@ -7563,9 +7303,9 @@ const getLocalization = async () => {
7563
7303
 
7564
7304
  const getShippingZones = async () => {
7565
7305
  var _a, _b;
7566
- const { errors, json } = await handleFetch('/api/zonos-elements/shipping-zones');
7306
+ const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/shipping-zones');
7567
7307
  if (errors.length || !json) {
7568
- logError.logError(`Error fetching shipping zones: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
7308
+ handleFetch.logError(`Error fetching shipping zones: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
7569
7309
  return null;
7570
7310
  }
7571
7311
  const shippingZones = (_b = json === null || json === void 0 ? void 0 : json.shippingZones) === null || _b === void 0 ? void 0 : _b.flatMap(zone => zone === null || zone === void 0 ? void 0 : zone.countryCodes).filter(Boolean);
@@ -7688,12 +7428,12 @@ const isValidSelector = (selector) => {
7688
7428
  const getCurrencyElements = (selector) => {
7689
7429
  const currencySelector = selector || '.money';
7690
7430
  if (!isValidSelector(currencySelector)) {
7691
- logError.logError(`Currency element selector "${currencySelector}" is not valid.`);
7431
+ handleFetch.logError(`Currency element selector "${currencySelector}" is not valid.`);
7692
7432
  return null;
7693
7433
  }
7694
7434
  const currencyElements = document.querySelectorAll(currencySelector);
7695
7435
  if (!currencyElements.length) {
7696
- logError.log(`No currency elements found with selector "${currencySelector}"`, 'warn');
7436
+ handleFetch.log(`No currency elements found with selector "${currencySelector}"`, 'warn');
7697
7437
  return null;
7698
7438
  }
7699
7439
  // return array of currency elements instead of a NodeList
@@ -7771,7 +7511,7 @@ const defaultCurrencyConverter = () => {
7771
7511
  return;
7772
7512
  }
7773
7513
  if (!localizationStore.exchangeRate) {
7774
- logError.logError('Could not display currency. Exchange rate and format data is not available.');
7514
+ handleFetch.logError('Could not display currency. Exchange rate and format data is not available.');
7775
7515
  return;
7776
7516
  }
7777
7517
  currencyElements.forEach(element => {
@@ -7858,13 +7598,13 @@ const startExchangeRateTimeout = ({ isGuaranteed, maxAge, }) => {
7858
7598
  };
7859
7599
  const getNewLocalization = async () => {
7860
7600
  var _a;
7861
- logError.log('get new localization store');
7601
+ handleFetch.log('get new localization store');
7862
7602
  const { isShippableCountry, selectedCountryCode } = localizationStore;
7863
7603
  localizationStore.countryLandedCost = await getCountryLandedCost(localizationStore.selectedCountryCode);
7864
7604
  localizationStore.inclusivePricing =
7865
7605
  ((_a = (await getInclusivePricing(selectedCountryCode))) === null || _a === void 0 ? void 0 : _a.setting) || null;
7866
7606
  if (localizationStore.inclusivePricing) {
7867
- logError.log(`Inclusive price setting found for this country (${selectedCountryCode}) ${JSON.stringify(localizationStore.inclusivePricing, null, 2)}`);
7607
+ handleFetch.log(`Inclusive price setting found for this country (${selectedCountryCode}) ${JSON.stringify(localizationStore.inclusivePricing, null, 2)}`);
7868
7608
  }
7869
7609
  if (zonosStore.zonosStore.helloSettings.currencyBehavior === 'DISABLED' ||
7870
7610
  !isShippableCountry ||
@@ -7909,7 +7649,7 @@ const addInternationalHideClass = () => {
7909
7649
  };
7910
7650
  const localizationStoreUpdateSelectedCountryCode = (newSelectedCountryCode) => {
7911
7651
  var _a, _b;
7912
- logError.log(`Updating selected country code to ${newSelectedCountryCode}`);
7652
+ handleFetch.log(`Updating selected country code to ${newSelectedCountryCode}`);
7913
7653
  const isFirstTime = !localizationStore.selectedCountryCode;
7914
7654
  localizationStore.selectedCountryCode = newSelectedCountryCode;
7915
7655
  const { selectedCountryCode, shippingZoneCountries } = localizationStore;
@@ -7918,7 +7658,7 @@ const localizationStoreUpdateSelectedCountryCode = (newSelectedCountryCode) => {
7918
7658
  !!shippingZoneCountries[selectedCountryCode];
7919
7659
  // update shippable country
7920
7660
  localizationStore.isShippableCountry = !!isShippableCountry;
7921
- logError.log(`${localizationStore.selectedCountryCode} is shippable country: ${localizationStore.isShippableCountry}`);
7661
+ handleFetch.log(`${localizationStore.selectedCountryCode} is shippable country: ${localizationStore.isShippableCountry}`);
7922
7662
  addInternationalHideClass();
7923
7663
  if (!selectedCountryCode) {
7924
7664
  return;
@@ -8002,7 +7742,7 @@ const updateCheckoutSessionLanguage = async () => {
8002
7742
  if (!cartStore.checkoutSessionId) {
8003
7743
  return null;
8004
7744
  }
8005
- const { errors, json } = await handleFetch('/api/zonos-elements/update-checkout-session-metadata', {
7745
+ const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/update-checkout-session-metadata', {
8006
7746
  body: {
8007
7747
  id: cartStore.checkoutSessionId,
8008
7748
  metadata: [
@@ -8015,7 +7755,7 @@ const updateCheckoutSessionLanguage = async () => {
8015
7755
  method: 'POST',
8016
7756
  });
8017
7757
  if (errors.length || !json) {
8018
- logError.logError('Error occurs when updating checkout session', JSON.stringify(errors, null, 2));
7758
+ handleFetch.logError('Error occurs when updating checkout session', JSON.stringify(errors, null, 2));
8019
7759
  return { errors, json };
8020
7760
  }
8021
7761
  return { errors: [], json };
@@ -8045,6 +7785,71 @@ const getTranslatedAddress = ({ currentAddress, translatedAddress, }) => {
8045
7785
  state: ((_f = translatedAddress.state) === null || _f === void 0 ? void 0 : _f[state]) || state,
8046
7786
  };
8047
7787
  };
7788
+ /**
7789
+ * Similar to prepCalculateLandedCost except it only uses
7790
+ */
7791
+ const prepCartCalculateLandedCost = (cartId) => {
7792
+ var _a;
7793
+ // maybe we don't need email now for prefetch the landed cost
7794
+ const stripeLinkData = stripeStore.stripeLinkEventData;
7795
+ const stripeAddressData = stripeStore.stripeAddressEventData;
7796
+ const stripeBillingAddressData = stripeStore.stripeShippingSameAsBilling
7797
+ ? stripeStore.stripeAddressEventData
7798
+ : stripeStore.stripeBillingAddressEventData;
7799
+ if (!(stripeAddressData === null || stripeAddressData === void 0 ? void 0 : stripeAddressData.complete) || !(stripeBillingAddressData === null || stripeBillingAddressData === void 0 ? void 0 : stripeBillingAddressData.complete)) {
7800
+ throw new Error('Missing stripe address data');
7801
+ }
7802
+ // Attempt to get translated address if available
7803
+ const translatedShippingAddress = getTranslatedAddress({
7804
+ currentAddress: stripeAddressData,
7805
+ translatedAddress: stripeStore.translatedAddress.address,
7806
+ });
7807
+ const shippingFirstName = translatedShippingAddress.name.split(' ')[0] || '';
7808
+ const shippingLastName = translatedShippingAddress.name.split(' ').splice(1).join(' ') || '';
7809
+ const translatedBillingAddress = getTranslatedAddress({
7810
+ currentAddress: stripeBillingAddressData,
7811
+ translatedAddress: stripeStore.translatedAddress.address,
7812
+ });
7813
+ const billingFirstName = translatedBillingAddress.name.split(' ')[0] || '';
7814
+ const billingLastName = translatedBillingAddress.name.split(' ').splice(1).join(' ') || '';
7815
+ return {
7816
+ billingAddress: {
7817
+ addressLine1: translatedBillingAddress.line1,
7818
+ addressLine2: translatedBillingAddress.line2 || '',
7819
+ city: translatedBillingAddress.city,
7820
+ country: translatedBillingAddress.country,
7821
+ postalCode: translatedBillingAddress.postal_code,
7822
+ state: translatedBillingAddress.state,
7823
+ },
7824
+ billingContact: {
7825
+ // firstName and lastName should be valid now since stripe only mark
7826
+ // the address as complete when both fields are filled.
7827
+ firstName: billingFirstName,
7828
+ lastName: billingLastName,
7829
+ phone: translatedBillingAddress.phone,
7830
+ },
7831
+ // Use the first item's currency code
7832
+ cartCurrencyCode: (_a = cartStore.items[0]) === null || _a === void 0 ? void 0 : _a.currencyCode,
7833
+ cartId,
7834
+ checkoutSessionId: cartStore.checkoutSessionId || '',
7835
+ contact: {
7836
+ email: stripeLinkData === null || stripeLinkData === void 0 ? void 0 : stripeLinkData.value.email,
7837
+ // firstName and lastName should be valid now since stripe only mark
7838
+ // the address as complete when both fields are filled.
7839
+ firstName: shippingFirstName,
7840
+ lastName: shippingLastName,
7841
+ phone: translatedShippingAddress.phone,
7842
+ },
7843
+ shippingAddress: {
7844
+ addressLine1: translatedShippingAddress.line1,
7845
+ addressLine2: translatedShippingAddress.line2,
7846
+ city: translatedShippingAddress.city,
7847
+ country: translatedShippingAddress.country,
7848
+ postalCode: translatedShippingAddress.postal_code,
7849
+ state: translatedShippingAddress.state,
7850
+ },
7851
+ };
7852
+ };
8048
7853
  const prepCalculateLandedCost = () => {
8049
7854
  // maybe we don't need email now for prefetch the landed cost
8050
7855
  const stripeLinkData = stripeStore.stripeLinkEventData;
@@ -8114,13 +7919,13 @@ const triggerBuildLandedCost = async (buildLandedCost) => {
8114
7919
  checkoutSessionId: data.checkoutSessionId,
8115
7920
  contact: data.contact,
8116
7921
  shippingAddress: data.shippingAddress,
8117
- zonosApiRoute: fallbackApiList['vercel'],
7922
+ zonosApiRoute: handleFetch.fallbackApiList['vercel'],
8118
7923
  });
8119
7924
  if (!landedCost || ((_a = landedCost.errors) === null || _a === void 0 ? void 0 : _a.length)) {
8120
7925
  throw new Error(`Failed to build landed cost: ${((_c = (_b = landedCost === null || landedCost === void 0 ? void 0 : landedCost.errors) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.message) || 'Unknown error'}`);
8121
7926
  }
8122
7927
  // Validate the landed cost object to make sure the returned value from buildLandedCost has a valid schema
8123
- const { errors, json } = await handleFetch('/api/zonos-elements/validate-landed-cost', {
7928
+ const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/validate-landed-cost', {
8124
7929
  body: landedCost,
8125
7930
  headers: {
8126
7931
  'Content-Type': 'application/json',
@@ -8142,7 +7947,7 @@ const calculateLandedCost = async (abortController) => {
8142
7947
  return json;
8143
7948
  }
8144
7949
  // request to get landed cost info
8145
- const { errors, json } = await handleFetch('/api/zonos-elements/calculate-landed-cost', {
7950
+ const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/calculate-landed-cost', {
8146
7951
  body: prepCalculateLandedCost(),
8147
7952
  method: 'POST',
8148
7953
  signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
@@ -8157,6 +7962,50 @@ const calculateLandedCost = async (abortController) => {
8157
7962
  return json;
8158
7963
  };
8159
7964
 
7965
+ const cartCalculateLandedCost = async ({ abortController, cartId, }) => {
7966
+ var _a;
7967
+ // request to get landed cost info
7968
+ const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/cart-calculate-landed-cost', {
7969
+ body: prepCartCalculateLandedCost(cartId),
7970
+ method: 'POST',
7971
+ signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
7972
+ });
7973
+ if (errors.length || !json) {
7974
+ const isAbortedRequest = ((_a = errors[0]) === null || _a === void 0 ? void 0 : _a.message) === 'The user aborted a request.';
7975
+ const errorMessage = isAbortedRequest
7976
+ ? 'The landed cost calculation request was aborted to initiate a new one.'
7977
+ : 'Failed to calculate landed cost';
7978
+ throw new Error(errorMessage);
7979
+ }
7980
+ return json;
7981
+ };
7982
+
7983
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
7984
+ var t = {};
7985
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
7986
+ t[p] = s[p];
7987
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7988
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7989
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
7990
+ t[p[i]] = s[p[i]];
7991
+ }
7992
+ return t;
7993
+ };
7994
+ const calculateLandedCostNormalized = async (abortController) => {
7995
+ const cartId = window.Zonos.cartId;
7996
+ // Calculate landed cost as usual if no cartId is available
7997
+ if (!cartId) {
7998
+ const landedCostResult = await calculateLandedCost(abortController);
7999
+ return landedCostResult;
8000
+ }
8001
+ // Calculate landed cost using cartId
8002
+ const _a = await cartCalculateLandedCost({
8003
+ abortController,
8004
+ cartId,
8005
+ }), { cartWorkflow } = _a, rest = __rest(_a, ["cartWorkflow"]);
8006
+ return Object.assign(Object.assign({}, rest), { itemCreateWorkflow: cartWorkflow.items });
8007
+ };
8008
+
8160
8009
  /**
8161
8010
  * This function generates an object that contains the fields of an address that have invalid characters.
8162
8011
  *
@@ -8378,13 +8227,13 @@ const stripeStoreSaveDomesticShippingSession = (props) => {
8378
8227
  };
8379
8228
  const stripeStoreGetDomesticShippingSession = () => {
8380
8229
  const session = window.sessionStorage.getItem('zonos--bigcommerce-domestic-checkout-shipping');
8381
- return jsonParse(session);
8230
+ return handleFetch.jsonParse(session);
8382
8231
  };
8383
8232
  const initStripeElements = async (props) => {
8384
8233
  var _a, _b;
8385
8234
  const clientSecret = stripeStore.clientSecret;
8386
8235
  if (!stripeStore.stripe) {
8387
- logError.log('Skip. Stripe is not initialized');
8236
+ handleFetch.log('Skip. Stripe is not initialized');
8388
8237
  return;
8389
8238
  }
8390
8239
  if (clientSecret) {
@@ -8404,11 +8253,11 @@ const initStripeElements = async (props) => {
8404
8253
  stripeStore.stripeElements = (_a = stripeStore.stripe) === null || _a === void 0 ? void 0 : _a.elements(stripeOptions);
8405
8254
  // save stripe elements options for later comparison
8406
8255
  stripeStore.stripeElementsOptions = stripeOptions;
8407
- logError.log('Stripe elements initialized');
8256
+ handleFetch.log('Stripe elements initialized');
8408
8257
  // init stripe elements for billing address
8409
8258
  stripeStore.stripeElementsForBillingAddress =
8410
8259
  (_b = stripeStore.stripe) === null || _b === void 0 ? void 0 : _b.elements(stripeOptions);
8411
- logError.log('Stripe elements for billing address initialized');
8260
+ handleFetch.log('Stripe elements for billing address initialized');
8412
8261
  return;
8413
8262
  }
8414
8263
  if (!isSameOptions) {
@@ -8419,7 +8268,7 @@ const initStripeElements = async (props) => {
8419
8268
  // save stripe elements options for later comparison
8420
8269
  stripeStore.stripeElementsOptions = stripeOptions;
8421
8270
  }
8422
- logError.log('Stripe elements initialized');
8271
+ handleFetch.log('Stripe elements initialized');
8423
8272
  }
8424
8273
  };
8425
8274
  const stripeStoreReset = () => {
@@ -8497,13 +8346,13 @@ const stripeStorePrefetchLandedCost = async () => {
8497
8346
  stripeStore.fetchingLandedCostAbordController = abortController;
8498
8347
  // Reset cart items to non-restricted state and restricted item list
8499
8348
  cartStoreResetCartItems();
8500
- const { checkoutSessionWorkflow, itemCreateWorkflow, landedCostCalculateWorkflow, shipmentRatingCalculateWorkflow, } = await calculateLandedCost(abortController);
8349
+ const { checkoutSessionWorkflow, itemCreateWorkflow, landedCostCalculateWorkflow, shipmentRatingCalculateWorkflow, } = await calculateLandedCostNormalized(abortController);
8501
8350
  // reset abort controller after we are done
8502
8351
  stripeStore.fetchingLandedCostAbordController = null;
8503
8352
  // update cart store with landed cost info
8504
8353
  cartStore.landedCostData =
8505
8354
  (checkoutSessionWorkflow === null || checkoutSessionWorkflow === void 0 ? void 0 : checkoutSessionWorkflow.map(checkoutSession => {
8506
- const foundLandedCost = landedCostCalculateWorkflow === null || landedCostCalculateWorkflow === void 0 ? void 0 : landedCostCalculateWorkflow.find(item => { var _a; return (item === null || item === void 0 ? void 0 : item.id) === ((_a = checkoutSession.landedCost) === null || _a === void 0 ? void 0 : _a.id); });
8355
+ const foundLandedCost = landedCostCalculateWorkflow === null || landedCostCalculateWorkflow === void 0 ? void 0 : landedCostCalculateWorkflow.find(item => (item === null || item === void 0 ? void 0 : item.id) === checkoutSession.landedCostId);
8507
8356
  if (!foundLandedCost) {
8508
8357
  return null;
8509
8358
  }
@@ -8521,6 +8370,7 @@ const stripeStorePrefetchLandedCost = async () => {
8521
8370
  if (subtotals) {
8522
8371
  // prefetch landed cost will not update shipping and taxes since we haven't selected shipping method yet
8523
8372
  cartStoreApplySubtotals({
8373
+ adjustments: subtotals.adjustments,
8524
8374
  exchangeRate: subtotals.exchangeRate,
8525
8375
  items: subtotals.items,
8526
8376
  landedCostTotal: 0,
@@ -8534,7 +8384,7 @@ const stripeStorePrefetchLandedCost = async () => {
8534
8384
  // default to empty array if we fail to fetch landed cost, so we can show the error message
8535
8385
  cartStore.landedCostData = [];
8536
8386
  cartStore.shippingData = [];
8537
- logError.logError(err);
8387
+ handleFetch.logError(err);
8538
8388
  }
8539
8389
  stripeStore.isFetchingLandedCost = false;
8540
8390
  }
@@ -8602,7 +8452,7 @@ const stripeStoreRetrievePayment = async ({ clientSecret: _clientSecret, storybo
8602
8452
  }
8603
8453
  const clientSecret = _clientSecret || stripeStore.clientSecret;
8604
8454
  if (!stripeStore.stripe || !clientSecret) {
8605
- logError.logError('Failed to retrieve payment intent. Stripe is not initialized');
8455
+ handleFetch.logError('Failed to retrieve payment intent. Stripe is not initialized');
8606
8456
  return { error: true, message: [translate('Something went wrong.')] };
8607
8457
  }
8608
8458
  const { paymentIntent } = await stripeStore.stripe.retrievePaymentIntent(clientSecret);
@@ -8655,12 +8505,14 @@ const stripeStoreInitCheckoutSession = async () => {
8655
8505
  var _a;
8656
8506
  const total = cartStore.items.reduce((amount, item) => amount + item.amount * item.quantity, 0);
8657
8507
  if (!total || !localizationStore.targetCurrency) {
8658
- logError.logError('Fail to create checkout session - invalid total or currency');
8508
+ handleFetch.logError('Fail to create checkout session - invalid total or currency');
8659
8509
  return false;
8660
8510
  }
8661
8511
  stripeStore.isFetchingSession = true;
8662
- const { errors, json } = await handleFetch('/api/zonos-elements/create-checkout-session', {
8512
+ const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/create-checkout-session', {
8663
8513
  body: {
8514
+ adjustmentAmount: cartStore.adjustments.reduce((prev, adj) => prev + adj.amount, 0),
8515
+ cartId: window.Zonos.cartId,
8664
8516
  currency: ((_a = cartStore.items.find(Boolean)) === null || _a === void 0 ? void 0 : _a.currencyCode) || '',
8665
8517
  itemsAmount: total,
8666
8518
  metadata: [{ key: 'language', value: localizationStore.selectedLocale }],
@@ -8670,7 +8522,7 @@ const stripeStoreInitCheckoutSession = async () => {
8670
8522
  });
8671
8523
  stripeStore.isFetchingSession = false;
8672
8524
  if (errors.length || !json) {
8673
- logError.logError('Error occurs when creating checkout session', JSON.stringify(errors, null, 2));
8525
+ handleFetch.logError('Error occurs when creating checkout session', JSON.stringify(errors, null, 2));
8674
8526
  return false;
8675
8527
  }
8676
8528
  const result = json.checkoutSessionCreate;
@@ -8678,18 +8530,20 @@ const stripeStoreInitCheckoutSession = async () => {
8678
8530
  // update cart store with updated informations
8679
8531
  cartStore.checkoutSessionId = result.id;
8680
8532
  cartStoreApplySubtotals(Object.assign(Object.assign({}, result.subtotals), { landedCostTotal: 0, shipping: 0, total: result.subtotals.items }));
8681
- logError.log('Exchange rate updated for cart items (checkout session create)', 'info', cartStore.exchangeRate);
8682
- logError.log('done-init-checkout-session');
8533
+ handleFetch.log('Exchange rate updated for cart items (checkout session create)', 'info', cartStore.exchangeRate);
8534
+ handleFetch.log('done-init-checkout-session');
8683
8535
  return true;
8684
8536
  };
8685
8537
  /**
8686
8538
  * Update checkout session. Use for updating amount with landed cost id, or update session when cart items change
8687
8539
  */
8688
- const stripeStoreUpdateCheckoutSession = async ({ currency, id, itemsAmount, landedCostId, presentmentCountryCode, }) => {
8540
+ const stripeStoreUpdateCheckoutSession = async ({ adjustmentAmount, cartId, currency, id, itemsAmount, landedCostId, presentmentCountryCode, }) => {
8689
8541
  // No need to set loading state here because this function will be called under the hood to update
8690
8542
  // landed cost id for the section.
8691
- const { errors, json } = await handleFetch('/api/zonos-elements/update-checkout-session', {
8543
+ const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/update-checkout-session', {
8692
8544
  body: {
8545
+ adjustmentAmount,
8546
+ cartId,
8693
8547
  currency,
8694
8548
  id,
8695
8549
  itemsAmount,
@@ -8699,7 +8553,7 @@ const stripeStoreUpdateCheckoutSession = async ({ currency, id, itemsAmount, lan
8699
8553
  method: 'POST',
8700
8554
  });
8701
8555
  if (errors.length || !json) {
8702
- logError.logError('Error occurs when updating checkout session', JSON.stringify(errors, null, 2));
8556
+ handleFetch.logError('Error occurs when updating checkout session', JSON.stringify(errors, null, 2));
8703
8557
  return { errors, json };
8704
8558
  }
8705
8559
  return { errors: [], json };
@@ -8787,12 +8641,12 @@ const stripeStoreTranslateAddressToLatin = async ({ addressInvalidCharactersList
8787
8641
  if (!isAddressOutdated) {
8788
8642
  return;
8789
8643
  }
8790
- const { errors, json } = await handleFetch('/api/zonos-elements/validate-address', {
8644
+ const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/validate-address', {
8791
8645
  body: requestBody,
8792
8646
  method: 'POST',
8793
8647
  });
8794
8648
  if (errors.length || !json) {
8795
- logError.logError('Error occurs when translating address to latin', JSON.stringify(errors, null, 2));
8649
+ handleFetch.logError('Error occurs when translating address to latin', JSON.stringify(errors, null, 2));
8796
8650
  // reset translated address if we fail to translate and let user manually fix it
8797
8651
  stripeStore.translatedAddress = {
8798
8652
  address: {},
@@ -8850,6 +8704,8 @@ const getDaysDifference = (targetDate) => {
8850
8704
  };
8851
8705
 
8852
8706
  const { onChange, reset, state: cartStore, } = zonosStore.createStore(() => ({
8707
+ adjustmentTotal: 0,
8708
+ adjustments: [],
8853
8709
  checkoutSessionId: sessionStorage.getItem('zonos--checkout-session-id') || null,
8854
8710
  checkoutSessionTimeoutShow: false,
8855
8711
  checkoutTimeoutInterval: null,
@@ -8934,7 +8790,7 @@ const getMatchItem = ({ item1, item2, }) => {
8934
8790
  * Check and set restricted items in cart
8935
8791
  */
8936
8792
  const cartStoreCheckItemRestrictions = (itemsWorkflow) => {
8937
- logError.log('Checking item restrictions');
8793
+ handleFetch.log('Checking item restrictions');
8938
8794
  const mappedRestrictedItems = itemsWorkflow
8939
8795
  .map(item => {
8940
8796
  if (!item.restriction) {
@@ -8970,6 +8826,7 @@ const cartStoreUpdateToErrorState = ({ messages, title, }) => {
8970
8826
  const cartStoreApplySubtotals = (subtotals) => {
8971
8827
  // update exchange rate so we can use it to display cart items
8972
8828
  cartStore.exchangeRate = subtotals.exchangeRate;
8829
+ cartStore.adjustmentTotal = subtotals.adjustments;
8973
8830
  cartStore.dutiesTaxFees = subtotals.landedCostTotal;
8974
8831
  cartStore.subtotal = subtotals.items;
8975
8832
  cartStore.total = subtotals.total;
@@ -8985,19 +8842,21 @@ const cartStoreHasOneEligibleItem = () => {
8985
8842
  // if there is no item restricted found => all items are restricted
8986
8843
  return !!checkItems.find(item => !item.isRestricted);
8987
8844
  };
8988
- const cartStoreReCalculateTotal = async ({ currency, itemsAmount, landedCostId, }) => {
8845
+ const cartStoreReCalculateTotal = async ({ adjustmentAmount, cartId, currency, itemsAmount, landedCostId, }) => {
8989
8846
  if (landedCostId && cartStore.selectedLandedCost) {
8990
8847
  // update cart total right away if we have landed cost id to avoid order total flickering
8991
8848
  const subtotals = cartStore.selectedLandedCost.subtotals;
8992
8849
  cartStoreApplySubtotals(subtotals);
8993
- logError.log('Exchange rate updated for cart items (landed cost subtotal)', 'info', cartStore.exchangeRate);
8850
+ handleFetch.log('Exchange rate updated for cart items (landed cost subtotal)', 'info', cartStore.exchangeRate);
8994
8851
  }
8995
8852
  // update checkout session
8996
8853
  if (!cartStore.checkoutSessionId) {
8997
- logError.logError('Could not update cart total without checkout session id');
8854
+ handleFetch.logError('Could not update cart total without checkout session id');
8998
8855
  return false;
8999
8856
  }
9000
8857
  const { errors, json } = await stripeStoreUpdateCheckoutSession({
8858
+ adjustmentAmount,
8859
+ cartId,
9001
8860
  currency,
9002
8861
  id: cartStore.checkoutSessionId,
9003
8862
  itemsAmount,
@@ -9006,7 +8865,7 @@ const cartStoreReCalculateTotal = async ({ currency, itemsAmount, landedCostId,
9006
8865
  });
9007
8866
  if (errors.length > 0 || !json) {
9008
8867
  // do nothing if we can't get checkout session
9009
- logError.logError('Error occurs when updating checkout session');
8868
+ handleFetch.logError('Error occurs when updating checkout session');
9010
8869
  cartStoreUpdateToErrorState({
9011
8870
  messages: [
9012
8871
  translate("There's been an error updating your checkout session. Please reload and try again or contact support if the error persists"),
@@ -9019,7 +8878,7 @@ const cartStoreReCalculateTotal = async ({ currency, itemsAmount, landedCostId,
9019
8878
  // This is when first open the checkout modal and we just want to get info from the old cart session.
9020
8879
  // use subtotals from checkout session to update cart total
9021
8880
  cartStoreApplySubtotals(json.checkoutSessionUpdate.subtotals);
9022
- logError.log('Exchange rate updated for cart items (checkout session update)', 'info', cartStore.exchangeRate);
8881
+ handleFetch.log('Exchange rate updated for cart items (checkout session update)', 'info', cartStore.exchangeRate);
9023
8882
  }
9024
8883
  return true;
9025
8884
  };
@@ -9054,6 +8913,8 @@ const cartStoreUpdateSelectedShippingOption = async (selectedShippingOption) =>
9054
8913
  cartStore.isSelectedShippingGuarantee = isGuarantee;
9055
8914
  // update session with selected landed cost
9056
8915
  const updateCalulateStatus = await cartStoreReCalculateTotal({
8916
+ adjustmentAmount: cartStore.adjustmentTotal,
8917
+ cartId: window.Zonos.cartId,
9057
8918
  landedCostId: (_e = selectedLandedCost.landedCost) === null || _e === void 0 ? void 0 : _e.id,
9058
8919
  });
9059
8920
  return updateCalulateStatus;
@@ -9076,7 +8937,7 @@ const cartStoreStartCheckoutInterval = ({ isPreview, sessionTimeout, }) => {
9076
8937
  timeoutQuery && !isNaN(parseInt(timeoutQuery, 10))
9077
8938
  ? parseInt(timeoutQuery, 10)
9078
8939
  : sessionTimeout;
9079
- logError.log(`==START CHECKOUT TIMEOUT - ${timeout}==`);
8940
+ handleFetch.log(`==START CHECKOUT TIMEOUT - ${timeout}==`);
9080
8941
  cartStore.checkoutTimeoutInterval = setTimeout(() => {
9081
8942
  cartStore.checkoutSessionTimeoutShow = true;
9082
8943
  }, timeout);
@@ -9093,13 +8954,16 @@ const cartStoreResetCartItems = () => {
9093
8954
  cartStore.items = cartStore.items.map(item => (Object.assign(Object.assign({}, item), { isRestricted: false })));
9094
8955
  cartStore.restrictedItems = [];
9095
8956
  };
9096
- const cartStoreUpdateItems = async (cartItems) => {
8957
+ const cartStoreUpdateItems = async ({ adjustments, cartItems, }) => {
9097
8958
  var _a;
8959
+ // Update adjustments and items
8960
+ cartStore.adjustments = adjustments;
9098
8961
  cartStore.items = getCartItemToUse(cartItems);
9099
8962
  const currency = (_a = cartItems.find(Boolean)) === null || _a === void 0 ? void 0 : _a.currencyCode;
9100
8963
  const total = cartItems.reduce((amt, item) => {
9101
8964
  return amt + item.amount * item.quantity;
9102
8965
  }, 0);
8966
+ const adjustmenTotal = adjustments.reduce((amt, adjustment) => amt + adjustment.amount, 0);
9103
8967
  if (!currency || !total) {
9104
8968
  // do nothing if we can't get currency or total
9105
8969
  return;
@@ -9108,6 +8972,8 @@ const cartStoreUpdateItems = async (cartItems) => {
9108
8972
  // set loading state here because this is first load checkout session when we already have checkout session id stored
9109
8973
  stripeStore.isFetchingSession = true;
9110
8974
  await cartStoreReCalculateTotal({
8975
+ adjustmentAmount: adjustmenTotal,
8976
+ cartId: window.Zonos.cartId,
9111
8977
  currency: currency,
9112
8978
  itemsAmount: total,
9113
8979
  });
@@ -9161,16 +9027,13 @@ exports.currencyConvertAndFormat = currencyConvertAndFormat;
9161
9027
  exports.currencyDisplay = currencyDisplay;
9162
9028
  exports.currencyFormat = currencyFormat;
9163
9029
  exports.getZCountryUrlParam = getZCountryUrlParam;
9164
- exports.handleFetch = handleFetch;
9165
9030
  exports.initLocalizationStore = initLocalizationStore;
9166
9031
  exports.initStripeElements = initStripeElements;
9167
9032
  exports.isValidSelector = isValidSelector;
9168
- exports.jsonParse = jsonParse;
9169
9033
  exports.localizationStore = localizationStore;
9170
9034
  exports.localizationStoreOnUpdate = localizationStoreOnUpdate;
9171
9035
  exports.localizationStoreUpdateSelectedCountryCode = localizationStoreUpdateSelectedCountryCode;
9172
9036
  exports.localizationStoreUpdateSelectedLocale = localizationStoreUpdateSelectedLocale;
9173
- exports.sendErrorLog = sendErrorLog;
9174
9037
  exports.setZCountryUrlParam = setZCountryUrlParam;
9175
9038
  exports.stripeStore = stripeStore;
9176
9039
  exports.stripeStoreCleanupDomesticShippingSession = stripeStoreCleanupDomesticShippingSession;