@ubnt/store.core 10.3.0-beta.6 → 10.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (379) hide show
  1. package/CHANGELOG.md +9 -142
  2. package/lib/assets/attention.svg +5 -5
  3. package/lib/assets/attention2.svg +5 -5
  4. package/lib/assets/minus4.svg +8 -8
  5. package/lib/assets/minus5.svg +8 -8
  6. package/lib/assets/plus3.svg +9 -9
  7. package/lib/assets/plus4.svg +9 -9
  8. package/lib/assets/ucgUltra.jpg +0 -0
  9. package/lib/assets/ucgUltra2.jpg +0 -0
  10. package/lib/assets/udmPro.jpg +0 -0
  11. package/lib/assets/udmPro2.jpg +0 -0
  12. package/lib/assets/udmProMax.jpg +0 -0
  13. package/lib/assets/udmProMax2.jpg +0 -0
  14. package/lib/assets/udmProSpecial.jpg +0 -0
  15. package/lib/assets/udmProSpecial2.jpg +0 -0
  16. package/lib/components/ButtonGroup/ButtonGroup.js +1 -7
  17. package/lib/components/ButtonGroup/ButtonGroup.js.map +1 -1
  18. package/lib/components/ButtonGroup/ButtonGroup.mjs +1 -7
  19. package/lib/components/ButtonGroup/ButtonGroup.mjs.map +1 -1
  20. package/lib/components/ButtonGroup/ButtonGroup.styles.js +6 -12
  21. package/lib/components/ButtonGroup/ButtonGroup.styles.js.map +1 -1
  22. package/lib/components/ButtonGroup/ButtonGroup.styles.mjs +6 -12
  23. package/lib/components/ButtonGroup/ButtonGroup.styles.mjs.map +1 -1
  24. package/lib/components/Footer/hooks/useFooterContent.d.ts +1 -3
  25. package/lib/components/Footer/hooks/useFooterContent.js +0 -12
  26. package/lib/components/Footer/hooks/useFooterContent.js.map +1 -1
  27. package/lib/components/Footer/hooks/useFooterContent.mjs +0 -12
  28. package/lib/components/Footer/hooks/useFooterContent.mjs.map +1 -1
  29. package/lib/components/Footer/translations/ar.json.js +0 -2
  30. package/lib/components/Footer/translations/ar.json.js.map +1 -1
  31. package/lib/components/Footer/translations/ar.json.mjs +0 -2
  32. package/lib/components/Footer/translations/ar.json.mjs.map +1 -1
  33. package/lib/components/Footer/translations/de.json.js +0 -2
  34. package/lib/components/Footer/translations/de.json.js.map +1 -1
  35. package/lib/components/Footer/translations/de.json.mjs +0 -2
  36. package/lib/components/Footer/translations/de.json.mjs.map +1 -1
  37. package/lib/components/Footer/translations/el.json.js +0 -2
  38. package/lib/components/Footer/translations/el.json.js.map +1 -1
  39. package/lib/components/Footer/translations/el.json.mjs +0 -2
  40. package/lib/components/Footer/translations/el.json.mjs.map +1 -1
  41. package/lib/components/Footer/translations/en.json.js +0 -2
  42. package/lib/components/Footer/translations/en.json.js.map +1 -1
  43. package/lib/components/Footer/translations/en.json.mjs +0 -2
  44. package/lib/components/Footer/translations/en.json.mjs.map +1 -1
  45. package/lib/components/Footer/translations/es.json.js +0 -2
  46. package/lib/components/Footer/translations/es.json.js.map +1 -1
  47. package/lib/components/Footer/translations/es.json.mjs +0 -2
  48. package/lib/components/Footer/translations/es.json.mjs.map +1 -1
  49. package/lib/components/Footer/translations/fr.json.js +0 -2
  50. package/lib/components/Footer/translations/fr.json.js.map +1 -1
  51. package/lib/components/Footer/translations/fr.json.mjs +0 -2
  52. package/lib/components/Footer/translations/fr.json.mjs.map +1 -1
  53. package/lib/components/Footer/translations/it.json.js +0 -2
  54. package/lib/components/Footer/translations/it.json.js.map +1 -1
  55. package/lib/components/Footer/translations/it.json.mjs +0 -2
  56. package/lib/components/Footer/translations/it.json.mjs.map +1 -1
  57. package/lib/components/Footer/translations/ja.json.js +0 -2
  58. package/lib/components/Footer/translations/ja.json.js.map +1 -1
  59. package/lib/components/Footer/translations/ja.json.mjs +0 -2
  60. package/lib/components/Footer/translations/ja.json.mjs.map +1 -1
  61. package/lib/components/Footer/translations/pt-BR.json.js +0 -2
  62. package/lib/components/Footer/translations/pt-BR.json.js.map +1 -1
  63. package/lib/components/Footer/translations/pt-BR.json.mjs +0 -2
  64. package/lib/components/Footer/translations/pt-BR.json.mjs.map +1 -1
  65. package/lib/components/Footer/translations/zh-Hans.json.js +0 -2
  66. package/lib/components/Footer/translations/zh-Hans.json.js.map +1 -1
  67. package/lib/components/Footer/translations/zh-Hans.json.mjs +0 -2
  68. package/lib/components/Footer/translations/zh-Hans.json.mjs.map +1 -1
  69. package/lib/components/Footer/translations/zh-Hant-TW.json.js +0 -2
  70. package/lib/components/Footer/translations/zh-Hant-TW.json.js.map +1 -1
  71. package/lib/components/Footer/translations/zh-Hant-TW.json.mjs +0 -2
  72. package/lib/components/Footer/translations/zh-Hant-TW.json.mjs.map +1 -1
  73. package/lib/components/Header/AccountMenu/AccountMenu.js +2 -14
  74. package/lib/components/Header/AccountMenu/AccountMenu.js.map +1 -1
  75. package/lib/components/Header/AccountMenu/AccountMenu.mjs +2 -14
  76. package/lib/components/Header/AccountMenu/AccountMenu.mjs.map +1 -1
  77. package/lib/components/Header/CartIcon/CartIcon.d.ts +1 -1
  78. package/lib/components/Header/CartIcon/CartIcon.js +1 -5
  79. package/lib/components/Header/CartIcon/CartIcon.js.map +1 -1
  80. package/lib/components/Header/CartIcon/CartIcon.mjs +1 -5
  81. package/lib/components/Header/CartIcon/CartIcon.mjs.map +1 -1
  82. package/lib/components/Header/CartIcon/CartIcon.types.d.ts +0 -2
  83. package/lib/components/Header/Header.stories.d.ts +0 -2
  84. package/lib/components/Header/Header.styles.d.ts +2 -5
  85. package/lib/components/Header/Header.styles.js +1 -10
  86. package/lib/components/Header/Header.styles.js.map +1 -1
  87. package/lib/components/Header/Header.styles.mjs +1 -10
  88. package/lib/components/Header/Header.styles.mjs.map +1 -1
  89. package/lib/components/Header/Header.types.d.ts +0 -8
  90. package/lib/components/Header/Header.types.js.map +1 -1
  91. package/lib/components/Header/Header.types.mjs.map +1 -1
  92. package/lib/components/Header/ProHeader/ProHeader.d.ts +0 -2
  93. package/lib/components/Header/ProHeader/ProHeader.js +30 -63
  94. package/lib/components/Header/ProHeader/ProHeader.js.map +1 -1
  95. package/lib/components/Header/ProHeader/ProHeader.mjs +32 -64
  96. package/lib/components/Header/ProHeader/ProHeader.mjs.map +1 -1
  97. package/lib/components/Header/ProHeader/ProHeader.styles.d.ts +0 -7
  98. package/lib/components/Header/ProHeader/ProHeader.styles.js +1 -51
  99. package/lib/components/Header/ProHeader/ProHeader.styles.js.map +1 -1
  100. package/lib/components/Header/ProHeader/ProHeader.styles.mjs +2 -47
  101. package/lib/components/Header/ProHeader/ProHeader.styles.mjs.map +1 -1
  102. package/lib/components/ModelCompareV3/ModelCompareV3.types.d.ts +0 -1
  103. package/lib/components/ModelCompareV3/assets/CameraSecurity/g5-pro.jpg.js +5 -5
  104. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgUltra.jpg.js +5 -5
  105. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgUltra.jpg.mjs +2 -2
  106. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.js +5 -5
  107. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.mjs +2 -2
  108. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProMax.jpg.js +5 -5
  109. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProMax.jpg.mjs +2 -2
  110. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProSpecial.jpg.js +5 -5
  111. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProSpecial.jpg.mjs +2 -2
  112. package/lib/components/ModelCompareV3/assets/Consoles/ucgUltra.jpg.js +1 -1
  113. package/lib/components/ModelCompareV3/assets/Consoles/ucgUltra.jpg.mjs +2 -2
  114. package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.js +1 -1
  115. package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.mjs +2 -2
  116. package/lib/components/ModelCompareV3/assets/Consoles/udmProMax.jpg.js +1 -1
  117. package/lib/components/ModelCompareV3/assets/Consoles/udmProMax.jpg.mjs +2 -2
  118. package/lib/components/ModelCompareV3/assets/Consoles/udmProSpecial.jpg.js +1 -1
  119. package/lib/components/ModelCompareV3/assets/Consoles/udmProSpecial.jpg.mjs +2 -2
  120. package/lib/components/ModelCompareV3/data/CameraSecurity.js +3 -3
  121. package/lib/components/ModelCompareV3/data/CameraSecurity.mjs +2 -2
  122. package/lib/components/ModelCompareV3/data/CloudGateways.js +12 -12
  123. package/lib/components/ModelCompareV3/data/CloudGateways.mjs +8 -8
  124. package/lib/components/ModelCompareV3/data/EnterpriseSwitching.js +2 -3
  125. package/lib/components/ModelCompareV3/data/EnterpriseSwitching.js.map +1 -1
  126. package/lib/components/ModelCompareV3/data/EnterpriseSwitching.mjs +2 -3
  127. package/lib/components/ModelCompareV3/data/EnterpriseSwitching.mjs.map +1 -1
  128. package/lib/components/ModelCompareV3/data/ProfessionalMaxSwitching.js +3 -10
  129. package/lib/components/ModelCompareV3/data/ProfessionalMaxSwitching.js.map +1 -1
  130. package/lib/components/ModelCompareV3/data/ProfessionalMaxSwitching.mjs +3 -10
  131. package/lib/components/ModelCompareV3/data/ProfessionalMaxSwitching.mjs.map +1 -1
  132. package/lib/components/ModelCompareV3/data/Switching.js +1 -2
  133. package/lib/components/ModelCompareV3/data/Switching.js.map +1 -1
  134. package/lib/components/ModelCompareV3/data/Switching.mjs +1 -2
  135. package/lib/components/ModelCompareV3/data/Switching.mjs.map +1 -1
  136. package/lib/components/ModelCompareV3/data/products/enterpriseAggregation.js +0 -7
  137. package/lib/components/ModelCompareV3/data/products/enterpriseAggregation.js.map +1 -1
  138. package/lib/components/ModelCompareV3/data/products/enterpriseAggregation.mjs +0 -7
  139. package/lib/components/ModelCompareV3/data/products/enterpriseAggregation.mjs.map +1 -1
  140. package/lib/components/ModelCompareV3/data/products/enterpriseCampus24PoE.js +0 -7
  141. package/lib/components/ModelCompareV3/data/products/enterpriseCampus24PoE.js.map +1 -1
  142. package/lib/components/ModelCompareV3/data/products/enterpriseCampus24PoE.mjs +0 -7
  143. package/lib/components/ModelCompareV3/data/products/enterpriseCampus24PoE.mjs.map +1 -1
  144. package/lib/components/ModelCompareV3/data/products/enterpriseCampus48PoE.js +0 -7
  145. package/lib/components/ModelCompareV3/data/products/enterpriseCampus48PoE.js.map +1 -1
  146. package/lib/components/ModelCompareV3/data/products/enterpriseCampus48PoE.mjs +0 -7
  147. package/lib/components/ModelCompareV3/data/products/enterpriseCampus48PoE.mjs.map +1 -1
  148. package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.js +0 -7
  149. package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.js.map +1 -1
  150. package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.mjs +0 -7
  151. package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.mjs.map +1 -1
  152. package/lib/components/ModelCompareV3/data/products/missionCritical.js +0 -7
  153. package/lib/components/ModelCompareV3/data/products/missionCritical.js.map +1 -1
  154. package/lib/components/ModelCompareV3/data/products/missionCritical.mjs +0 -7
  155. package/lib/components/ModelCompareV3/data/products/missionCritical.mjs.map +1 -1
  156. package/lib/components/ModelCompareV3/data/products/professionalMax16.js +0 -7
  157. package/lib/components/ModelCompareV3/data/products/professionalMax16.js.map +1 -1
  158. package/lib/components/ModelCompareV3/data/products/professionalMax16.mjs +0 -7
  159. package/lib/components/ModelCompareV3/data/products/professionalMax16.mjs.map +1 -1
  160. package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.js +0 -7
  161. package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.js.map +1 -1
  162. package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.mjs +0 -7
  163. package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.mjs.map +1 -1
  164. package/lib/components/ModelCompareV3/data/products/professionalMax24.js +0 -7
  165. package/lib/components/ModelCompareV3/data/products/professionalMax24.js.map +1 -1
  166. package/lib/components/ModelCompareV3/data/products/professionalMax24.mjs +0 -7
  167. package/lib/components/ModelCompareV3/data/products/professionalMax24.mjs.map +1 -1
  168. package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.js +0 -7
  169. package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.js.map +1 -1
  170. package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.mjs +0 -7
  171. package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.mjs.map +1 -1
  172. package/lib/components/ModelCompareV3/data/products/professionalMax48.js +0 -7
  173. package/lib/components/ModelCompareV3/data/products/professionalMax48.js.map +1 -1
  174. package/lib/components/ModelCompareV3/data/products/professionalMax48.mjs +0 -7
  175. package/lib/components/ModelCompareV3/data/products/professionalMax48.mjs.map +1 -1
  176. package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.js +0 -7
  177. package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.js.map +1 -1
  178. package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.mjs +0 -7
  179. package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.mjs.map +1 -1
  180. package/lib/components/ModelCompareV3/data/products/switchesEnterprise.js +0 -8
  181. package/lib/components/ModelCompareV3/data/products/switchesEnterprise.js.map +1 -1
  182. package/lib/components/ModelCompareV3/data/products/switchesEnterprise.mjs +0 -8
  183. package/lib/components/ModelCompareV3/data/products/switchesEnterprise.mjs.map +1 -1
  184. package/lib/components/ModelCompareV3/data/products/switchesProfessional.js +0 -7
  185. package/lib/components/ModelCompareV3/data/products/switchesProfessional.js.map +1 -1
  186. package/lib/components/ModelCompareV3/data/products/switchesProfessional.mjs +0 -7
  187. package/lib/components/ModelCompareV3/data/products/switchesProfessional.mjs.map +1 -1
  188. package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.js +1 -10
  189. package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.js.map +1 -1
  190. package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.mjs +1 -10
  191. package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.mjs.map +1 -1
  192. package/lib/components/ModelCompareV3/data/products/switchesStandard.js +0 -7
  193. package/lib/components/ModelCompareV3/data/products/switchesStandard.js.map +1 -1
  194. package/lib/components/ModelCompareV3/data/products/switchesStandard.mjs +0 -7
  195. package/lib/components/ModelCompareV3/data/products/switchesStandard.mjs.map +1 -1
  196. package/lib/components/ModelCompareV3/data/products/ucgUltra.js +1 -1
  197. package/lib/components/ModelCompareV3/data/products/ucgUltra.mjs +1 -1
  198. package/lib/components/ModelCompareV3/data/products/udmPro.js +1 -1
  199. package/lib/components/ModelCompareV3/data/products/udmPro.mjs +1 -1
  200. package/lib/components/ModelCompareV3/data/products/udmProMax.js +1 -1
  201. package/lib/components/ModelCompareV3/data/products/udmProMax.mjs +1 -1
  202. package/lib/components/ModelCompareV3/data/products/udmProSpecial.js +1 -1
  203. package/lib/components/ModelCompareV3/data/products/udmProSpecial.mjs +1 -1
  204. package/lib/components/ModelCompareV3/data/properties/index.d.ts +0 -1
  205. package/lib/components/ModelCompareV3/data/properties/index.js +0 -2
  206. package/lib/components/ModelCompareV3/data/properties/index.js.map +1 -1
  207. package/lib/components/ModelCompareV3/data/properties/index.mjs +0 -1
  208. package/lib/components/ModelCompareV3/data/properties/index.mjs.map +1 -1
  209. package/lib/components/ModelCompareV3/translations/en.json.js +0 -2
  210. package/lib/components/ModelCompareV3/translations/en.json.js.map +1 -1
  211. package/lib/components/ModelCompareV3/translations/en.json.mjs +0 -2
  212. package/lib/components/ModelCompareV3/translations/en.json.mjs.map +1 -1
  213. package/lib/components/ModelCompareV3/translations/useModelCompareTranslation.d.ts +2 -2
  214. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js +0 -600
  215. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js.map +1 -1
  216. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs +0 -596
  217. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs.map +1 -1
  218. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.d.ts +1 -5
  219. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.js +0 -4
  220. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.js.map +1 -1
  221. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.mjs +0 -4
  222. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.mjs.map +1 -1
  223. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js +1 -1
  224. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs +1 -1
  225. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.js +2 -2
  226. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.mjs +2 -2
  227. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.js +1 -1
  228. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.mjs +2 -2
  229. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.js +1 -1
  230. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.mjs +2 -2
  231. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.js +1 -1
  232. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.mjs +2 -2
  233. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.js +1 -1
  234. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.mjs +1 -1
  235. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.js +1 -1
  236. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.mjs +2 -2
  237. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.js +2 -2
  238. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.mjs +2 -2
  239. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.js +1 -1
  240. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.mjs +2 -2
  241. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.js +1 -1
  242. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.mjs +2 -2
  243. package/lib/components/ResourceCalculatorV1/translations/en.json.js +0 -4
  244. package/lib/components/ResourceCalculatorV1/translations/en.json.js.map +1 -1
  245. package/lib/components/ResourceCalculatorV1/translations/en.json.mjs +0 -4
  246. package/lib/components/ResourceCalculatorV1/translations/en.json.mjs.map +1 -1
  247. package/lib/components/ResourceCalculatorV1/translations/useResourceCalculatorTranslation.d.ts +2 -2
  248. package/lib/constants/proStoreCategories/mapping/filters.d.ts +0 -3
  249. package/lib/constants/proStoreCategories/mapping/filters.js +0 -3
  250. package/lib/constants/proStoreCategories/mapping/filters.js.map +1 -1
  251. package/lib/constants/proStoreCategories/mapping/filters.mjs +0 -3
  252. package/lib/constants/proStoreCategories/mapping/filters.mjs.map +1 -1
  253. package/lib/constants/proStoreCategories/mapping/index.d.ts +0 -3
  254. package/lib/constants/proStoreCategories/mapping/index.js +9 -34
  255. package/lib/constants/proStoreCategories/mapping/index.js.map +1 -1
  256. package/lib/constants/proStoreCategories/mapping/index.mjs +9 -34
  257. package/lib/constants/proStoreCategories/mapping/index.mjs.map +1 -1
  258. package/lib/constants/proStoreCategories/mapping/mapping.d.ts +0 -6
  259. package/lib/constants/proStoreCategories/mapping/unifi.d.ts +1 -4
  260. package/lib/constants/proStoreCategories/mapping/unifi.js +0 -3
  261. package/lib/constants/proStoreCategories/mapping/unifi.js.map +1 -1
  262. package/lib/constants/proStoreCategories/mapping/unifi.mjs +0 -3
  263. package/lib/constants/proStoreCategories/mapping/unifi.mjs.map +1 -1
  264. package/lib/constants/proStoreCategories/translations/ar.json.js +1 -8
  265. package/lib/constants/proStoreCategories/translations/ar.json.js.map +1 -1
  266. package/lib/constants/proStoreCategories/translations/ar.json.mjs +2 -7
  267. package/lib/constants/proStoreCategories/translations/ar.json.mjs.map +1 -1
  268. package/lib/constants/proStoreCategories/translations/de.json.js +1 -8
  269. package/lib/constants/proStoreCategories/translations/de.json.js.map +1 -1
  270. package/lib/constants/proStoreCategories/translations/de.json.mjs +2 -7
  271. package/lib/constants/proStoreCategories/translations/de.json.mjs.map +1 -1
  272. package/lib/constants/proStoreCategories/translations/el.json.js +1 -8
  273. package/lib/constants/proStoreCategories/translations/el.json.js.map +1 -1
  274. package/lib/constants/proStoreCategories/translations/el.json.mjs +2 -7
  275. package/lib/constants/proStoreCategories/translations/el.json.mjs.map +1 -1
  276. package/lib/constants/proStoreCategories/translations/en.json.js +1 -8
  277. package/lib/constants/proStoreCategories/translations/en.json.js.map +1 -1
  278. package/lib/constants/proStoreCategories/translations/en.json.mjs +2 -7
  279. package/lib/constants/proStoreCategories/translations/en.json.mjs.map +1 -1
  280. package/lib/constants/proStoreCategories/translations/es.json.js +1 -8
  281. package/lib/constants/proStoreCategories/translations/es.json.js.map +1 -1
  282. package/lib/constants/proStoreCategories/translations/es.json.mjs +2 -7
  283. package/lib/constants/proStoreCategories/translations/es.json.mjs.map +1 -1
  284. package/lib/constants/proStoreCategories/translations/fr.json.js +1 -8
  285. package/lib/constants/proStoreCategories/translations/fr.json.js.map +1 -1
  286. package/lib/constants/proStoreCategories/translations/fr.json.mjs +2 -7
  287. package/lib/constants/proStoreCategories/translations/fr.json.mjs.map +1 -1
  288. package/lib/constants/proStoreCategories/translations/it.json.js +1 -8
  289. package/lib/constants/proStoreCategories/translations/it.json.js.map +1 -1
  290. package/lib/constants/proStoreCategories/translations/it.json.mjs +2 -7
  291. package/lib/constants/proStoreCategories/translations/it.json.mjs.map +1 -1
  292. package/lib/constants/proStoreCategories/translations/ja.json.js +1 -8
  293. package/lib/constants/proStoreCategories/translations/ja.json.js.map +1 -1
  294. package/lib/constants/proStoreCategories/translations/ja.json.mjs +2 -7
  295. package/lib/constants/proStoreCategories/translations/ja.json.mjs.map +1 -1
  296. package/lib/constants/proStoreCategories/translations/pt-BR.json.js +1 -8
  297. package/lib/constants/proStoreCategories/translations/pt-BR.json.js.map +1 -1
  298. package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs +2 -7
  299. package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs.map +1 -1
  300. package/lib/constants/proStoreCategories/translations/zh-Hans.json.js +1 -8
  301. package/lib/constants/proStoreCategories/translations/zh-Hans.json.js.map +1 -1
  302. package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs +2 -7
  303. package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs.map +1 -1
  304. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js +1 -8
  305. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js.map +1 -1
  306. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs +2 -7
  307. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs.map +1 -1
  308. package/lib/constants/proStoreFilters/mapping.d.ts +2 -8
  309. package/lib/constants/proStoreFilters/mapping.js +0 -19
  310. package/lib/constants/proStoreFilters/mapping.js.map +1 -1
  311. package/lib/constants/proStoreFilters/mapping.mjs +0 -19
  312. package/lib/constants/proStoreFilters/mapping.mjs.map +1 -1
  313. package/lib/contexts/MenuContext/context.js +0 -1
  314. package/lib/contexts/MenuContext/context.js.map +1 -1
  315. package/lib/contexts/MenuContext/context.mjs +0 -1
  316. package/lib/contexts/MenuContext/context.mjs.map +1 -1
  317. package/lib/contexts/MenuContext/mapping.d.ts +1 -3
  318. package/lib/contexts/MenuContext/mapping.js +1 -2
  319. package/lib/contexts/MenuContext/mapping.js.map +1 -1
  320. package/lib/contexts/MenuContext/mapping.mjs +1 -2
  321. package/lib/contexts/MenuContext/mapping.mjs.map +1 -1
  322. package/lib/contexts/MenuContext/presets.d.ts +0 -11
  323. package/lib/contexts/MenuContext/presets.js +4 -16
  324. package/lib/contexts/MenuContext/presets.js.map +1 -1
  325. package/lib/contexts/MenuContext/presets.mjs +5 -13
  326. package/lib/contexts/MenuContext/presets.mjs.map +1 -1
  327. package/lib/contexts/MenuContext/types.d.ts +0 -3
  328. package/lib/contexts/MenuContext/types.js +0 -1
  329. package/lib/contexts/MenuContext/types.js.map +1 -1
  330. package/lib/contexts/MenuContext/types.mjs +0 -1
  331. package/lib/contexts/MenuContext/types.mjs.map +1 -1
  332. package/lib/contexts/MenuContext/utils.js +7 -8
  333. package/lib/contexts/MenuContext/utils.js.map +1 -1
  334. package/lib/contexts/MenuContext/utils.mjs +7 -8
  335. package/lib/contexts/MenuContext/utils.mjs.map +1 -1
  336. package/lib/utils/money/constants.d.ts +0 -6
  337. package/lib/utils/money/constants.js +1 -23
  338. package/lib/utils/money/constants.js.map +1 -1
  339. package/lib/utils/money/constants.mjs +2 -23
  340. package/lib/utils/money/constants.mjs.map +1 -1
  341. package/lib/utils/money/index.js +0 -1
  342. package/lib/utils/money/index.js.map +1 -1
  343. package/lib/utils/money/index.mjs +1 -1
  344. package/lib/utils/nextjs/navigationPresets.d.ts +4 -14
  345. package/lib/utils/nextjs/navigationPresets.js +6 -22
  346. package/lib/utils/nextjs/navigationPresets.js.map +1 -1
  347. package/lib/utils/nextjs/navigationPresets.mjs +7 -23
  348. package/lib/utils/nextjs/navigationPresets.mjs.map +1 -1
  349. package/package.json +26 -26
  350. package/lib/assets/crestron.svg +0 -3
  351. package/lib/assets/ucg-fiber.png +0 -0
  352. package/lib/assets/udr7.png +0 -0
  353. package/lib/assets/ux.png +0 -0
  354. package/lib/assets/ux7.png +0 -0
  355. package/lib/components/ModelCompareV3/assets/crestron.svg.js +0 -27
  356. package/lib/components/ModelCompareV3/assets/crestron.svg.js.map +0 -1
  357. package/lib/components/ModelCompareV3/assets/crestron.svg.mjs +0 -3
  358. package/lib/components/ModelCompareV3/assets/crestron.svg.mjs.map +0 -1
  359. package/lib/components/ModelCompareV3/data/properties/crestronNaxNvxCertified.d.ts +0 -2
  360. package/lib/components/ModelCompareV3/data/properties/crestronNaxNvxCertified.js +0 -18
  361. package/lib/components/ModelCompareV3/data/properties/crestronNaxNvxCertified.js.map +0 -1
  362. package/lib/components/ModelCompareV3/data/properties/crestronNaxNvxCertified.mjs +0 -10
  363. package/lib/components/ModelCompareV3/data/properties/crestronNaxNvxCertified.mjs.map +0 -1
  364. package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-fiber.png.js +0 -27
  365. package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-fiber.png.js.map +0 -1
  366. package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-fiber.png.mjs +0 -3
  367. package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-fiber.png.mjs.map +0 -1
  368. package/lib/components/ResourceCalculatorV1/assets/consoles/udr7.png.js +0 -27
  369. package/lib/components/ResourceCalculatorV1/assets/consoles/udr7.png.js.map +0 -1
  370. package/lib/components/ResourceCalculatorV1/assets/consoles/udr7.png.mjs +0 -3
  371. package/lib/components/ResourceCalculatorV1/assets/consoles/udr7.png.mjs.map +0 -1
  372. package/lib/components/ResourceCalculatorV1/assets/consoles/ux.png.js +0 -27
  373. package/lib/components/ResourceCalculatorV1/assets/consoles/ux.png.js.map +0 -1
  374. package/lib/components/ResourceCalculatorV1/assets/consoles/ux.png.mjs +0 -3
  375. package/lib/components/ResourceCalculatorV1/assets/consoles/ux.png.mjs.map +0 -1
  376. package/lib/components/ResourceCalculatorV1/assets/consoles/ux7.png.js +0 -27
  377. package/lib/components/ResourceCalculatorV1/assets/consoles/ux7.png.js.map +0 -1
  378. package/lib/components/ResourceCalculatorV1/assets/consoles/ux7.png.mjs +0 -3
  379. package/lib/components/ResourceCalculatorV1/assets/consoles/ux7.png.mjs.map +0 -1
@@ -22,18 +22,17 @@ const parseSiteUrl = ({
22
22
  const url = new URL(baseUrl);
23
23
  const pathnameParts = pathnameToParts(pathname);
24
24
  const includeStoreIdAndLanguage = !(context && GENERIC_SITE_IDS.includes(context));
25
- const basePathname = url.pathname.replace(/\/$/, "");
26
25
  switch (siteId) {
27
26
  case SiteId.Store:
28
27
  {
29
- url.pathname = `${basePathname}${partsToPathname(targetSiteSupportedLanguage ? [targetSiteSupportedLanguage, ...pathnameParts] : pathnameParts
28
+ url.pathname = `${url.pathname.replace(/\/$/, "")}${partsToPathname(targetSiteSupportedLanguage ? [targetSiteSupportedLanguage, ...pathnameParts] : pathnameParts
30
29
  // Shopify stores
31
30
  )}`;
32
31
  break;
33
32
  }
34
33
  case SiteId.Ui:
35
34
  {
36
- url.pathname = `${basePathname}${partsToPathname(targetSiteSupportedLanguage &&
35
+ url.pathname = `${url.pathname.replace(/\/$/, "")}${partsToPathname(targetSiteSupportedLanguage &&
37
36
  // Do not add storeId and language if language is not supported
38
37
  includeStoreIdAndLanguage ? [slugify(storeId), targetSiteSupportedLanguage, ...pathnameParts] : pathnameParts
39
38
  // To "root" page
@@ -42,7 +41,7 @@ const parseSiteUrl = ({
42
41
  }
43
42
  case SiteId.Uisp:
44
43
  {
45
- url.pathname = `${basePathname}${partsToPathname(includeStoreIdAndLanguage ? [slugify(storeId), ...pathnameParts] : pathnameParts
44
+ url.pathname = `${url.pathname.replace(/\/$/, "")}${partsToPathname(includeStoreIdAndLanguage ? [slugify(storeId), ...pathnameParts] : pathnameParts
46
45
  // To "root" page
47
46
  )}`;
48
47
  break;
@@ -53,19 +52,19 @@ const parseSiteUrl = ({
53
52
  case SiteId.Blog:
54
53
  case SiteId.ExpertsUisp:
55
54
  {
56
- url.pathname = `${basePathname}${pathname}`;
55
+ url.pathname = `${url.pathname.replace(/\/$/, "")}${pathname}`;
57
56
  break;
58
57
  }
58
+ // eslint-disable-next-line sonarjs/no-duplicated-branches
59
59
  case SiteId.Uwc:
60
- case SiteId.CaseStudies:
61
60
  {
62
- url.pathname = `${basePathname}${partsToPathname(targetSiteSupportedLanguage ? [targetSiteSupportedLanguage, ...pathnameParts] : pathnameParts)}`;
61
+ url.pathname = `${url.pathname.replace(/\/$/, "")}${partsToPathname(targetSiteSupportedLanguage ? [targetSiteSupportedLanguage, ...pathnameParts] : pathnameParts)}`;
63
62
  break;
64
63
  }
65
64
  default:
66
65
  {
67
66
  checkUnreachable(siteId);
68
- url.pathname = `${basePathname}${pathname}`;
67
+ url.pathname = `${url.pathname.replace(/\/$/, "")}${pathname}`;
69
68
  break;
70
69
  }
71
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","sources":["../../../src/contexts/MenuContext/utils.ts"],"sourcesContent":["/* eslint-disable sonarjs/no-duplicated-branches */\nimport type { GlobalStoreId, StoreId } from \"../../types\";\nimport {\n assert,\n assertUnreachable,\n checkUnreachable,\n} from \"../../utils/errors\";\nimport { partsToPathname, pathnameToParts, slugify } from \"../../utils/url\";\nimport type {\n NavigationInvisibleItem,\n NavigationSubItem,\n NavigationSubSubItem,\n SiteUrl,\n} from \"./mapping\";\nimport { GENERIC_SITE_IDS, Language, SiteId } from \"./mapping\";\nimport type {\n BasicSiteConfig,\n GlobalSiteConfig,\n ParsedNavigationItem,\n ParsedNavigationSubItem,\n ParsedNavigationSubSubItem,\n} from \"./types\";\nimport { SiteConfigType } from \"./types\";\n\nexport const parseSiteUrl = ({\n siteUrl: [siteId, pathname, searchParams, fragment],\n storeId,\n addSiteConfigReferenceSearchParams,\n language,\n targetSiteConfig,\n context,\n}: {\n siteUrl: SiteUrl;\n storeId: GlobalStoreId;\n addSiteConfigReferenceSearchParams: boolean;\n language: `${Language}`;\n targetSiteConfig: BasicSiteConfig;\n /** Current context where this function is called */\n context?: SiteId;\n}): string => {\n const { baseUrl, languages } = targetSiteConfig;\n\n const targetSiteSupportedLanguage =\n // OK to cast as we are verifying `languages` is type of Language[]\n languages?.includes(language as Language)\n ? language\n : targetSiteConfig.defaultLanguage;\n\n /**\n * Dynamic based url based on which side it is\n */\n const url = new URL(baseUrl);\n\n const pathnameParts = pathnameToParts(pathname);\n\n /**\n * Flag to include storeId and language in the URL\n *\n * If context is generic, we don't need to include storeId and language and we want\n * to allow the target site to handle the language and storeId\n */\n const includeStoreIdAndLanguage = !(\n context && GENERIC_SITE_IDS.includes(context)\n );\n\n const basePathname = url.pathname.replace(/\\/$/, \"\");\n\n switch (siteId) {\n case SiteId.Store: {\n url.pathname = `${basePathname}${partsToPathname(\n targetSiteSupportedLanguage\n ? [targetSiteSupportedLanguage, ...pathnameParts] // New platform stores (FUN-FACT: base urls already include store id)\n : pathnameParts, // Shopify stores\n )}`;\n break;\n }\n case SiteId.Ui: {\n url.pathname = `${basePathname}${partsToPathname(\n targetSiteSupportedLanguage && // Do not add storeId and language if language is not supported\n includeStoreIdAndLanguage // Do not add storeId and language if context is generic\n ? [slugify(storeId), targetSiteSupportedLanguage, ...pathnameParts] // URL to specific region + language combo\n : pathnameParts, // To \"root\" page\n )}`;\n break;\n }\n case SiteId.Uisp: {\n url.pathname = `${basePathname}${partsToPathname(\n includeStoreIdAndLanguage // Do not add storeId and language if context is generic\n ? [slugify(storeId), ...pathnameParts] // URL to specific region\n : pathnameParts, // To \"root\" page\n )}`;\n break;\n }\n case SiteId.Amplifi:\n case SiteId.TechSpecs:\n case SiteId.ExpertsUi:\n case SiteId.Blog:\n case SiteId.ExpertsUisp: {\n url.pathname = `${basePathname}${pathname}`;\n break;\n }\n\n case SiteId.Uwc:\n case SiteId.CaseStudies: {\n url.pathname = `${basePathname}${partsToPathname(\n targetSiteSupportedLanguage\n ? [targetSiteSupportedLanguage, ...pathnameParts]\n : pathnameParts,\n )}`;\n break;\n }\n default: {\n checkUnreachable(siteId);\n url.pathname = `${basePathname}${pathname}`;\n break;\n }\n }\n\n if (searchParams) {\n for (const [key, value] of Object.entries(searchParams)) {\n /**\n * Although we don't allow \"empty\" values, in runtime we had an issue if passing it, which failed this function,\n * seemed to be to dramatic so add actual runtime check if value is not null|undefined\n */\n if (value != null) {\n url.searchParams.set(key, value.toString());\n }\n }\n }\n\n /**\n * Add query parameters to force target site to use the correct store and language\n */\n if (addSiteConfigReferenceSearchParams) {\n // Add `s` for store query param\n if (storeId) {\n url.searchParams.set(\"s\", storeId);\n }\n\n // Add `l` for language query param\n if (targetSiteSupportedLanguage) {\n url.searchParams.set(\"l\", targetSiteSupportedLanguage);\n }\n }\n\n /**\n * Add fragment (a.k.a. hash #) if defined\n */\n if (fragment !== undefined) {\n url.hash = slugify(fragment.toString());\n }\n\n return url.toString();\n};\n\nexport const getSubItemUrl = (\n subItem: NavigationSubItem | NavigationSubSubItem,\n isSubitemUrlActive: (siteUrl: SiteUrl) => boolean,\n): SiteUrl | null => {\n if (!subItem.url) {\n const urls = (subItem.items ?? [])\n .map((item) => getSubItemUrl(item, isSubitemUrlActive))\n .filter((el): el is SiteUrl => !!el);\n\n const activeUrl = urls.find(isSubitemUrlActive);\n\n return activeUrl ?? urls[0] ?? null;\n }\n\n return subItem.url ?? null;\n};\n\n/**\n * Util to check if given pathname (needle) is a subset of another path (haystack)\n */\nexport const isPartOfUrlPathname = (\n haystackPathname: string,\n needlePathname: string,\n): boolean => {\n /**\n * Ensure all paths end with a slash\n * This ensures \"some-path\" doesn't match \"some-path-extra\"\n * Since \"some-path/\" is not included in \"some-path-extra/\"\n */\n const normalisedHaystackPathname = ensureTrailingSlash(haystackPathname);\n const normalisedNeedlePathname = ensureTrailingSlash(needlePathname);\n return normalisedHaystackPathname.includes(normalisedNeedlePathname);\n};\n\n/**\n * Util that ensures given pathname ends with trailing slash\n * @example\n * ensureTrailingSlash('/a'); // '/a/'\n * ensureTrailingSlash('/a/'); // '/a/'\n */\nexport const ensureTrailingSlash = (pathname: string) =>\n pathname.replace(/\\/$/, \"\") + \"/\";\n\n/**\n * Util to easily find first possible link from nested \"subitem\"\n * @param items\n * @returns\n */\nexport const findFirstPossibleDeepNestedItemUrl = <\n Item extends\n | ParsedNavigationSubItem\n | ParsedNavigationItem\n | ParsedNavigationSubSubItem,\n>(\n items: Item[],\n): string | undefined => {\n return items.find((item) => item.possible)?.url;\n};\n\n/**\n * Filter out invisible products\n */\nexport const filterOutUnrenderableItems = <T extends NavigationInvisibleItem>(\n items: T[],\n) => {\n return items.filter((item) => !item.invisible);\n};\n\n// #############################################################################\n// Language\n// #############################################################################\n\nexport enum LanguageDirectionType {\n ltr = \"ltr\",\n rtl = \"rtl\",\n}\n\n/**\n * Get language direction from language\n */\nexport const getLanguageDirection = (language: Language) => {\n return language === Language.Ar\n ? LanguageDirectionType.rtl\n : LanguageDirectionType.ltr;\n};\n\n// #############################################################################\n// Global Site config\n// #############################################################################\nexport const getGlobalSiteConfig = (\n globalSiteConfig: GlobalSiteConfig,\n siteId: SiteId,\n storeId: GlobalStoreId | StoreId,\n): BasicSiteConfig => {\n const siteConfig = globalSiteConfig[siteId];\n\n assert(!!siteConfig, \"Missing SiteId in globalSiteConfig\");\n\n switch (siteConfig.type) {\n case SiteConfigType.Regional:\n return siteConfig.regions[storeId] ?? siteConfig.defaultRegion;\n case SiteConfigType.Basic:\n return siteConfig;\n default:\n assertUnreachable(siteConfig);\n }\n};\n"],"names":["parseSiteUrl","siteUrl","siteId","pathname","searchParams","fragment","storeId","addSiteConfigReferenceSearchParams","language","targetSiteConfig","context","baseUrl","languages","targetSiteSupportedLanguage","includes","defaultLanguage","url","URL","pathnameParts","pathnameToParts","includeStoreIdAndLanguage","GENERIC_SITE_IDS","basePathname","replace","SiteId","Store","partsToPathname","Ui","slugify","Uisp","Amplifi","TechSpecs","ExpertsUi","Blog","ExpertsUisp","Uwc","CaseStudies","checkUnreachable","key","value","Object","entries","set","toString","hash","getSubItemUrl","subItem","isSubitemUrlActive","urls","items","map","item","filter","el","activeUrl","find","isPartOfUrlPathname","haystackPathname","needlePathname","normalisedHaystackPathname","ensureTrailingSlash","normalisedNeedlePathname","findFirstPossibleDeepNestedItemUrl","possible","filterOutUnrenderableItems","invisible","LanguageDirectionType","getLanguageDirection","Language","Ar","getGlobalSiteConfig","globalSiteConfig","siteConfig","assert","type","SiteConfigType","Regional","regions","defaultRegion","Basic","assertUnreachable"],"mappings":";;;;;;AAwBO,MAAMA,eAAeA,CAAC;EAC3BC,OAAS,EAAA,CAACC,MAAQ,EAAAC,QAAA,EAAUC,cAAcC,QAAQ,CAAA;EAClDC,OAAA;EACAC,kCAAA;EACAC,QAAA;EACAC,gBAAA;EACAC;AACF,CAQc,KAAA;EACN,MAAA;IAAEC,OAAS;IAAAC;EAAA,CAAc,GAAAH,gBAAA;EAEzB,MAAAI,2BAAA;EAAA;EAEJD,SAAW,EAAAE,QAAA,CAASN,QAAoB,CAAA,GACpCA,WACAC,gBAAiB,CAAAM,eAAA;EAKjB,MAAAC,GAAA,GAAM,IAAIC,GAAA,CAAIN,OAAO,CAAA;EAErB,MAAAO,aAAA,GAAgBC,gBAAgBhB,QAAQ,CAAA;EAQ9C,MAAMiB,yBAA4B,GAAA,EAChCV,OAAW,IAAAW,gBAAA,CAAiBP,SAASJ,OAAO,CAAA,CAAA;EAG9C,MAAMY,YAAe,GAAAN,GAAA,CAAIb,QAAS,CAAAoB,OAAA,CAAQ,OAAO,EAAE,CAAA;EAEnD,QAAQrB,MAAQ;IACd,KAAKsB,OAAOC,KAAO;MAAA;QACbT,GAAA,CAAAb,QAAA,GAAW,GAAGmB,YAAY,GAAGI,eAAA,CAC/Bb,2BACI,GAAA,CAACA,2BAA6B,EAAA,GAAGK,aAAa,CAC9C,GAAAA;QAAA;QAAA,CACL,EAAA;QACD;MAAA;IAEF,KAAKM,OAAOG,EAAI;MAAA;QACVX,GAAA,CAAAb,QAAA,GAAW,GA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AAA,EAAO,EAAE,CAAI,GAAA,GAAA;AAOnB,MAAAuC,kCAAA,GAMXb,KACuB,IAAA;EACvB,OAAOA,MAAMM,IAAK,CAACJ,IAAS,IAAAA,IAAA,CAAKY,QAAQ,CAAG,EAAA/C,GAAA;AAC9C,CAAA;AAKa,MAAAgD,0BAAA,GACXf,KACG,IAAA;EACH,OAAOA,MAAMG,MAAO,CAACD,IAAS,IAAA,CAACA,KAAKc,SAAS,CAAA;AAC/C,CAAA;AAMY,IAAAC,qBAAA,GAAA,gBAAAA,sBAAL,IAAA;EACLA,uBAAA,KAAM,CAAA,GAAA,KAAA;EACNA,uBAAA,KAAM,CAAA,GAAA,KAAA;EAFIA,OAAAA,sBAAAA;AAAA,CAAA,EAAAA,qBAAA,IAAA,CAAA,CAAA,CAAA;AAQC,MAAAC,oBAAA,GAAwB3D,QAAuB,IAAA;EACnD,OAAAA,QAAA,KAAa4D,QAAS,CAAAC,EAAA,GACzB,KACA,CAAA,YAAA,KAAA,CAAA;AACN,CAAA;AAKO,MAAMC,mBAAsB,GAAAA,CACjCC,gBACA,EAAArE,MAAA,EACAI,OACoB,KAAA;EACd,MAAAkE,UAAA,GAAaD,iBAAiBrE,MAAM,CAAA;EAEnCuE,MAAA,CAAA,CAAC,CAACD,UAAA,EAAY,oCAAoC,CAAA;EAEzD,QAAQA,WAAWE,IAAM;IACvB,KAAKC,cAAe,CAAAC,QAAA;MAClB,OAAOJ,UAAW,CAAAK,OAAA,CAAQvE,OAAO,CAAA,IAAKkE,UAAW,CAAAM,aAAA;IACnD,KAAKH,cAAe,CAAAI,KAAA;MACX,OAAAP,UAAA;IACT;MACEQ,iBAAA,CAAkBR,UAAU,CAAA;EAAA;AAElC,CAAA;"}
1
+ {"version":3,"file":"utils.mjs","sources":["../../../src/contexts/MenuContext/utils.ts"],"sourcesContent":["import type { GlobalStoreId, StoreId } from \"../../types\";\nimport {\n assert,\n assertUnreachable,\n checkUnreachable,\n} from \"../../utils/errors\";\nimport { partsToPathname, pathnameToParts, slugify } from \"../../utils/url\";\nimport type {\n NavigationInvisibleItem,\n NavigationSubItem,\n NavigationSubSubItem,\n SiteUrl,\n} from \"./mapping\";\nimport { GENERIC_SITE_IDS, Language, SiteId } from \"./mapping\";\nimport type {\n BasicSiteConfig,\n GlobalSiteConfig,\n ParsedNavigationItem,\n ParsedNavigationSubItem,\n ParsedNavigationSubSubItem,\n} from \"./types\";\nimport { SiteConfigType } from \"./types\";\n\nexport const parseSiteUrl = ({\n siteUrl: [siteId, pathname, searchParams, fragment],\n storeId,\n addSiteConfigReferenceSearchParams,\n language,\n targetSiteConfig,\n context,\n}: {\n siteUrl: SiteUrl;\n storeId: GlobalStoreId;\n addSiteConfigReferenceSearchParams: boolean;\n language: `${Language}`;\n targetSiteConfig: BasicSiteConfig;\n /** Current context where this function is called */\n context?: SiteId;\n}): string => {\n const { baseUrl, languages } = targetSiteConfig;\n\n const targetSiteSupportedLanguage =\n // OK to cast as we are verifying `languages` is type of Language[]\n languages?.includes(language as Language)\n ? language\n : targetSiteConfig.defaultLanguage;\n\n /**\n * Dynamic based url based on which side it is\n */\n const url = new URL(baseUrl);\n\n const pathnameParts = pathnameToParts(pathname);\n\n /**\n * Flag to include storeId and language in the URL\n *\n * If context is generic, we don't need to include storeId and language and we want\n * to allow the target site to handle the language and storeId\n */\n const includeStoreIdAndLanguage = !(\n context && GENERIC_SITE_IDS.includes(context)\n );\n\n switch (siteId) {\n case SiteId.Store: {\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${partsToPathname(\n targetSiteSupportedLanguage\n ? [targetSiteSupportedLanguage, ...pathnameParts] // New platform stores (FUN-FACT: base urls already include store id)\n : pathnameParts, // Shopify stores\n )}`;\n break;\n }\n case SiteId.Ui: {\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${partsToPathname(\n targetSiteSupportedLanguage && // Do not add storeId and language if language is not supported\n includeStoreIdAndLanguage // Do not add storeId and language if context is generic\n ? [slugify(storeId), targetSiteSupportedLanguage, ...pathnameParts] // URL to specific region + language combo\n : pathnameParts, // To \"root\" page\n )}`;\n break;\n }\n case SiteId.Uisp: {\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${partsToPathname(\n includeStoreIdAndLanguage // Do not add storeId and language if context is generic\n ? [slugify(storeId), ...pathnameParts] // URL to specific region\n : pathnameParts, // To \"root\" page\n )}`;\n break;\n }\n case SiteId.Amplifi:\n case SiteId.TechSpecs:\n case SiteId.ExpertsUi:\n case SiteId.Blog:\n case SiteId.ExpertsUisp: {\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${pathname}`;\n break;\n }\n // eslint-disable-next-line sonarjs/no-duplicated-branches\n case SiteId.Uwc: {\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${partsToPathname(\n targetSiteSupportedLanguage\n ? [targetSiteSupportedLanguage, ...pathnameParts]\n : pathnameParts,\n )}`;\n break;\n }\n default: {\n checkUnreachable(siteId);\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${pathname}`;\n break;\n }\n }\n\n if (searchParams) {\n for (const [key, value] of Object.entries(searchParams)) {\n /**\n * Although we don't allow \"empty\" values, in runtime we had an issue if passing it, which failed this function,\n * seemed to be to dramatic so add actual runtime check if value is not null|undefined\n */\n if (value != null) {\n url.searchParams.set(key, value.toString());\n }\n }\n }\n\n /**\n * Add query parameters to force target site to use the correct store and language\n */\n if (addSiteConfigReferenceSearchParams) {\n // Add `s` for store query param\n if (storeId) {\n url.searchParams.set(\"s\", storeId);\n }\n\n // Add `l` for language query param\n if (targetSiteSupportedLanguage) {\n url.searchParams.set(\"l\", targetSiteSupportedLanguage);\n }\n }\n\n /**\n * Add fragment (a.k.a. hash #) if defined\n */\n if (fragment !== undefined) {\n url.hash = slugify(fragment.toString());\n }\n\n return url.toString();\n};\n\nexport const getSubItemUrl = (\n subItem: NavigationSubItem | NavigationSubSubItem,\n isSubitemUrlActive: (siteUrl: SiteUrl) => boolean,\n): SiteUrl | null => {\n if (!subItem.url) {\n const urls = (subItem.items ?? [])\n .map((item) => getSubItemUrl(item, isSubitemUrlActive))\n .filter((el): el is SiteUrl => !!el);\n\n const activeUrl = urls.find(isSubitemUrlActive);\n\n return activeUrl ?? urls[0] ?? null;\n }\n\n return subItem.url ?? null;\n};\n\n/**\n * Util to check if given pathname (needle) is a subset of another path (haystack)\n */\nexport const isPartOfUrlPathname = (\n haystackPathname: string,\n needlePathname: string,\n): boolean => {\n /**\n * Ensure all paths end with a slash\n * This ensures \"some-path\" doesn't match \"some-path-extra\"\n * Since \"some-path/\" is not included in \"some-path-extra/\"\n */\n const normalisedHaystackPathname = ensureTrailingSlash(haystackPathname);\n const normalisedNeedlePathname = ensureTrailingSlash(needlePathname);\n return normalisedHaystackPathname.includes(normalisedNeedlePathname);\n};\n\n/**\n * Util that ensures given pathname ends with trailing slash\n * @example\n * ensureTrailingSlash('/a'); // '/a/'\n * ensureTrailingSlash('/a/'); // '/a/'\n */\nexport const ensureTrailingSlash = (pathname: string) =>\n pathname.replace(/\\/$/, \"\") + \"/\";\n\n/**\n * Util to easily find first possible link from nested \"subitem\"\n * @param items\n * @returns\n */\nexport const findFirstPossibleDeepNestedItemUrl = <\n Item extends\n | ParsedNavigationSubItem\n | ParsedNavigationItem\n | ParsedNavigationSubSubItem,\n>(\n items: Item[],\n): string | undefined => {\n return items.find((item) => item.possible)?.url;\n};\n\n/**\n * Filter out invisible products\n */\nexport const filterOutUnrenderableItems = <T extends NavigationInvisibleItem>(\n items: T[],\n) => {\n return items.filter((item) => !item.invisible);\n};\n\n// #############################################################################\n// Language\n// #############################################################################\n\nexport enum LanguageDirectionType {\n ltr = \"ltr\",\n rtl = \"rtl\",\n}\n\n/**\n * Get language direction from language\n */\nexport const getLanguageDirection = (language: Language) => {\n return language === Language.Ar\n ? LanguageDirectionType.rtl\n : LanguageDirectionType.ltr;\n};\n\n// #############################################################################\n// Global Site config\n// #############################################################################\nexport const getGlobalSiteConfig = (\n globalSiteConfig: GlobalSiteConfig,\n siteId: SiteId,\n storeId: GlobalStoreId | StoreId,\n): BasicSiteConfig => {\n const siteConfig = globalSiteConfig[siteId];\n\n assert(!!siteConfig, \"Missing SiteId in globalSiteConfig\");\n\n switch (siteConfig.type) {\n case SiteConfigType.Regional:\n return siteConfig.regions[storeId] ?? siteConfig.defaultRegion;\n case SiteConfigType.Basic:\n return siteConfig;\n default:\n assertUnreachable(siteConfig);\n }\n};\n"],"names":["parseSiteUrl","siteUrl","siteId","pathname","searchParams","fragment","storeId","addSiteConfigReferenceSearchParams","language","targetSiteConfig","context","baseUrl","languages","targetSiteSupportedLanguage","includes","defaultLanguage","url","URL","pathnameParts","pathnameToParts","includeStoreIdAndLanguage","GENERIC_SITE_IDS","SiteId","Store","replace","partsToPathname","Ui","slugify","Uisp","Amplifi","TechSpecs","ExpertsUi","Blog","ExpertsUisp","Uwc","checkUnreachable","key","value","Object","entries","set","toString","hash","getSubItemUrl","subItem","isSubitemUrlActive","urls","items","map","item","filter","el","activeUrl","find","isPartOfUrlPathname","haystackPathname","needlePathname","normalisedHaystackPathname","ensureTrailingSlash","normalisedNeedlePathname","findFirstPossibleDeepNestedItemUrl","possible","filterOutUnrenderableItems","invisible","LanguageDirectionType","getLanguageDirection","Language","Ar","getGlobalSiteConfig","globalSiteConfig","siteConfig","assert","type","SiteConfigType","Regional","regions","defaultRegion","Basic","assertUnreachable"],"mappings":";;;;;;AAuBO,MAAMA,eAAeA,CAAC;EAC3BC,OAAS,EAAA,CAACC,MAAQ,EAAAC,QAAA,EAAUC,cAAcC,QAAQ,CAAA;EAClDC,OAAA;EACAC,kCAAA;EACAC,QAAA;EACAC,gBAAA;EACAC;AACF,CAQc,KAAA;EACN,MAAA;IAAEC,OAAS;IAAAC;EAAA,CAAc,GAAAH,gBAAA;EAEzB,MAAAI,2BAAA;EAAA;EAEJD,SAAW,EAAAE,QAAA,CAASN,QAAoB,CAAA,GACpCA,WACAC,gBAAiB,CAAAM,eAAA;EAKjB,MAAAC,GAAA,GAAM,IAAIC,GAAA,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,GAAwBzD,QAAuB,IAAA;EACnD,OAAAA,QAAA,KAAa0D,QAAS,CAAAC,EAAA,GACzB,KACA,CAAA,YAAA,KAAA,CAAA;AACN,CAAA;AAKO,MAAMC,mBAAsB,GAAAA,CACjCC,gBACA,EAAAnE,MAAA,EACAI,OACoB,KAAA;EACd,MAAAgE,UAAA,GAAaD,iBAAiBnE,MAAM,CAAA;EAEnCqE,MAAA,CAAA,CAAC,CAACD,UAAA,EAAY,oCAAoC,CAAA;EAEzD,QAAQA,WAAWE,IAAM;IACvB,KAAKC,cAAe,CAAAC,QAAA;MAClB,OAAOJ,UAAW,CAAAK,OAAA,CAAQrE,OAAO,CAAA,IAAKgE,UAAW,CAAAM,aAAA;IACnD,KAAKH,cAAe,CAAAI,KAAA;MACX,OAAAP,UAAA;IACT;MACEQ,iBAAA,CAAkBR,UAAU,CAAA;EAAA;AAElC,CAAA;"}
@@ -8,7 +8,6 @@ import type { LocalizedCurrency, RoundingFn } from "./types";
8
8
  * @see: https://ubiquiti.atlassian.net/browse/NEP-3846
9
9
  */
10
10
  export declare const roundToNearestFull059: RoundingFn;
11
- export declare const roundToNearestValidUiCarePrice: RoundingFn;
12
11
  /**
13
12
  * Custom rounding method to be used with dinero.js
14
13
  * This rounding method will round to
@@ -67,11 +66,6 @@ export declare const Round: {
67
66
  */
68
67
  PrettifyHalfUnitCents: RoundingFn;
69
68
  Subunit: import("@dinero.js/core").RoundingMode;
70
- /**
71
- * ! Disclaimer may not work for "weird" currencies as expected
72
- * ! For correct rounding UI Care prices, used for auto managed UI Care products.
73
- */
74
- ValidUiCarePrice: RoundingFn;
75
69
  };
76
70
  /**
77
71
  * Mapping of how prices should be rounded down to "whole numbers" after certain threshold
@@ -22,22 +22,6 @@ const roundToNearestFull059 = input => {
22
22
  return roundedNumber - remainder + 9;
23
23
  }
24
24
  };
25
- const roundToNearestValidUiCarePrice = input => {
26
- if (input === 0) {
27
- return 0;
28
- }
29
- if (input <= 5) {
30
- return 5;
31
- }
32
- const remainder = input % 10;
33
- if (remainder <= 2) {
34
- return input - remainder - 1;
35
- } else if (remainder <= 5) {
36
- return input - remainder + 5;
37
- } else {
38
- return input - remainder + 9;
39
- }
40
- };
41
25
  const roundToNearestDecimalCent = input => {
42
26
  if (input === 0) {
43
27
  return 0;
@@ -102,12 +86,7 @@ const Round = {
102
86
  * ! Disclaimer may not work for "weird" currencies as expected
103
87
  */
104
88
  PrettifyHalfUnitCents: roundToNearestHalfUnitCent,
105
- Subunit: dinero_js.halfUp,
106
- /**
107
- * ! Disclaimer may not work for "weird" currencies as expected
108
- * ! For correct rounding UI Care prices, used for auto managed UI Care products.
109
- */
110
- ValidUiCarePrice: roundToNearestValidUiCarePrice
89
+ Subunit: dinero_js.halfUp
111
90
  };
112
91
  const prettifyPriceLookup = /* @__PURE__ */new Map([[currencies.USD.code, 20], [currencies.AED.code, 50],
113
92
  // Approximately every price above ~1.1 usd will be rounded in ZAR
@@ -239,7 +218,6 @@ exports.prettifyPriceLookup = prettifyPriceLookup;
239
218
  exports.roundToNearestDecimalCent = roundToNearestDecimalCent;
240
219
  exports.roundToNearestFull059 = roundToNearestFull059;
241
220
  exports.roundToNearestHalfUnitCent = roundToNearestHalfUnitCent;
242
- exports.roundToNearestValidUiCarePrice = roundToNearestValidUiCarePrice;
243
221
  exports.smallestSubunitLookup = smallestSubunitLookup;
244
222
  exports.storesWithPerItemTaxRate = storesWithPerItemTaxRate;
245
223
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../src/utils/money/constants.ts"],"sourcesContent":["import {\n AED,\n BGN,\n BRL,\n CAD,\n CHF,\n CNY,\n CZK,\n DKK,\n EUR,\n GBP,\n HRK,\n HUF,\n INR,\n JPY,\n MXN,\n NOK,\n PHP,\n PLN,\n RON,\n SEK,\n SGD,\n TWD,\n USD,\n ZAR,\n} from \"@dinero.js/currencies\";\nimport { down, halfAwayFromZero, halfUp } from \"dinero.js\";\n\nimport type { StoreId } from \"../../types\";\nimport { Currency } from \"../../types\";\nimport type {\n Cents,\n DinoCurrency,\n LocalizedCurrency,\n RoundingFn,\n} from \"./types\";\n\n// #############################################################################\n// Constants\n// #############################################################################\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to nearest FULL 0/5/9 (and strip cents)\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestFull059: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-5.00\n if (input <= 5) {\n return 5;\n }\n\n /**\n * Input comes as float, for this rounding we don't need cents, so round\n * to nearest full number\n */\n const roundedNumber = Math.round(input);\n\n // Determine nearest rounding value\n const remainder = roundedNumber % 10;\n if (remainder <= 2) {\n // Round down to nearest 0\n return roundedNumber - remainder;\n } else if (remainder <= 7) {\n // Round to nearest 5\n return roundedNumber - remainder + 5;\n } else {\n // Round up to nearest 9\n return roundedNumber - remainder + 9;\n }\n};\n\nexport const roundToNearestValidUiCarePrice: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-5.00\n if (input <= 5) {\n return 5;\n }\n\n // Determine nearest rounding value\n const remainder = input % 10;\n if (remainder <= 2) {\n // Round down to nearest 9\n return input - remainder - 1;\n } else if (remainder <= 5) {\n // Round to nearest 5\n return input - remainder + 5;\n } else {\n // Round up to nearest 9\n return input - remainder + 9;\n }\n};\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to\n * nearest decimal cent. e.g. 1.53 = 1.50 / 1.57 = 1.60\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestDecimalCent: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-0.09\n if (input <= 0.1) {\n return 0.1;\n }\n\n /**\n * Input comes as float, just to be on the safe side use toFixed to mitigate\n * risk of running to floating point precision issues\n */\n return parseFloat((Math.round(input * 10) / 10).toFixed(1));\n};\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to\n * nearest .50 or .00. e.g. 11.22 = 11 / 11.55 = 11.50 / 11.90 = 12\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestHalfUnitCent: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-0.5\n if (input <= 0.5) {\n return 0.5;\n }\n\n /**\n * Input comes as float, just to be on the safe side use toFixed to mitigate\n * risk of running to floating point precision issues\n *\n * Multiply by 2, round to the nearest integer, then divide by 2 to get the nearest .5 or .0\n * Return with fixed precision to avoid floating-point artifacts\n */\n return parseFloat((Math.round(input * 2) / 2).toFixed(2));\n};\n\nexport const Round = {\n /**\n * !!!!!!!!!!!!!!\n * ! Update 2024\n * ! We ar changing from `halfEven` (bankers rounding) to `halfAwayFromZero` (symmetric rounding) to match Avalara tax\n * @see https://knowledge.avalara.com/bundle/dqa1657870670369_dqa1657870670369/page/Change_how_AvaTax_rounds_the_tax_amount.html\n * @see https://ui.slack.com/archives/C07P7L7S3CP/p1728313196140639\n * !!!!!!!!!!!!!!\n *\n * OLD: halfEven docs\n * ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T\n * deal with dinero.js (Dinero.js should be the priority). But often for converting from API requests we have to\n * normalize the values so we use this method.\n *\n * It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.\n * @see https://github.com/dinerojs/dinero.js/blob/v2.0.0-alpha.8/packages/core/src/round/halfEven.ts\n *\n * Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behavior\n * based on if the rounded number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.\n * See the youtube link below for a brief exclamation on why it's important to use this method over regular rounding\n * (half-up):\n * https://youtu.be/yuRdYlZvs1E\n *\n * If you really want to get knee-deep in the rounding subject, you can read the following:\n * https://en.wikipedia.org/wiki/Rounding#Round_half_toward_zero\n */\n Financial: halfAwayFromZero,\n // https://ui.slack.com/archives/C07P7L7S3CP/p1728313196140639\n // TODO: maybe we should have separate rounding functions depending on the input value?\n // Reading from wiki \"Round half toward zero\" is better if the value is already \"normalized to cents\"\n // But the \"Round half to even\" seems better for when working with float like values\n // financialRound = Math.round;\n Shipping: roundToNearestDecimalCent,\n Prettify: down,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyFull059: roundToNearestFull059,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyDecimalCents: roundToNearestDecimalCent,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyHalfUnitCents: roundToNearestHalfUnitCent,\n Subunit: halfUp,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n * ! For correct rounding UI Care prices, used for auto managed UI Care products.\n */\n ValidUiCarePrice: roundToNearestValidUiCarePrice,\n} satisfies Record<string, RoundingFn>;\n\n/**\n * Mapping of how prices should be rounded down to \"whole numbers\" after certain threshold\n */\nexport const prettifyPriceLookup = new Map([\n [USD.code, 20],\n [AED.code, 50],\n // Approximately every price above ~1.1 usd will be rounded in ZAR\n [ZAR.code, 20],\n [MXN.code, 20],\n]);\n\n/**\n * Map of dinero code to subunit digit count.\n */\nexport const smallestSubunitLookup = new Map<string, [Cents, RoundingFn]>([\n /**\n * TWD does not use subunits at all in day to day transactions.\n */\n [TWD.code, [0, Round.Subunit]],\n]);\n\n/**\n * Precompiled list for faster currency and locale lookups\n */\nexport const localizedCurrencyLookup = new Map<Currency, LocalizedCurrency>([\n [Currency.Aed, { currency: AED, locale: \"ar-AE\" }],\n [Currency.Bgn, { currency: BGN, locale: \"bg-BG\" }],\n [Currency.Cad, { currency: CAD, locale: \"en-CA\" }],\n [Currency.Chf, { currency: CHF, locale: \"it-CH\" }],\n [Currency.Czk, { currency: CZK, locale: \"cs-CZ\" }],\n [Currency.Dkk, { currency: DKK, locale: \"da-DK\" }],\n [Currency.Eur, { currency: EUR, locale: \"de-DE\" }],\n [Currency.Gbp, { currency: GBP, locale: \"en-GB\" }],\n [Currency.Hrk, { currency: HRK, locale: \"hr-HR\" }],\n [Currency.Huf, { currency: HUF, locale: \"hu-HU\" }],\n [Currency.Nok, { currency: NOK, locale: \"no-NO\" }],\n [Currency.Pln, { currency: PLN, locale: \"pl-PL\" }],\n [Currency.Ron, { currency: RON, locale: \"ro-RO\" }],\n [Currency.Sek, { currency: SEK, locale: \"sv-SE\" }],\n [Currency.Usd, { currency: USD, locale: \"en-US\" }],\n [Currency.Zar, { currency: ZAR, locale: \"en-ZA\" }],\n [Currency.Inr, { currency: INR, locale: \"en-IN\" }],\n [Currency.Sgd, { currency: SGD, locale: \"en-SG\" }],\n [Currency.Brl, { currency: BRL, locale: \"pt-BR\" }],\n // NOTE: en-JP Doesn't exist\n [Currency.Jpy, { currency: JPY, locale: \"en-JP\" }],\n // NOTE: en-TW Doesn't exist\n [Currency.Twd, { currency: TWD, locale: \"en-TW\" }],\n [Currency.Mxn, { currency: MXN, locale: \"es-MX\" }],\n [Currency.Php, { currency: PHP, locale: \"en-PH\" }],\n [Currency.Cny, { currency: CNY, locale: \"zh-CN\" }],\n]);\n\n// #############################################################################\n// Tax Rate\n// #############################################################################\n/**\n * List of stores that require calculating per single item qty and then combining them to get the total tax amount for a\n * single line. Rest of the stores inherit default behavior that tax calculated on whole line item\n *\n * ! IMPORTANT: When changing need to sync that store.backend `AVATAX_CUSTOM_COMPANY_CODES` is updated to reflect the change\n *\n * FIXME: as PR for the change as unfinished currently disabled to enable the functionality that calculates tax per single item as requires\n * specific testing both for our custom tax and Avalara stores that use custom company codes. So the groundwork for\n * different tax calculations is there just need to enable on the share side and test if it works\n */\nexport const storesWithPerItemTaxRate = new Set([\n // #############################################################################\n // Stores with custom tax rates\n // #############################################################################\n // StoreId.Br,\n // StoreId.Tw,\n // #############################################################################\n // Stores with Avalara, but will have custom company codes to handle per-item tax rate\n // #############################################################################\n // StoreId.Jp,\n // StoreId.Sg,\n] as StoreId[]);\n\n/**\n * Dinero currency option block for working with tax rates within dinero\n */\nexport const TAX_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We expect the tax rate to be in the range of 0..1\n * 0 --> 0%\n * 1 --> 100%\n * 0.21 --> 21%\n * 0.2169 --> 21.69%\n * 0.12345678 --> 12.345678%\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 8,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n\n// #############################################################################\n// Exchange Rate\n// #############################################################################\n\nexport const EXCHANGE_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We support having certain decimal places for exchange rates\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 6,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n"],"names":["roundToNearestFull059","input","roundedNumber","Math","round","remainder","roundToNearestValidUiCarePrice","roundToNearestDecimalCent","parseFloat","toFixed","roundToNearestHalfUnitCent","Round","Financial","halfAwayFromZero","Shipping","Prettify","down","PrettifyFull059","PrettifyDecimalCents","PrettifyHalfUnitCents","Subunit","halfUp","ValidUiCarePrice","prettifyPriceLookup","Map","USD","code","AED","ZAR","MXN","smallestSubunitLookup","TWD","localizedCurrencyLookup","Currency","Aed","currency","locale","Bgn","BGN","Cad","CAD","Chf","CHF","Czk","CZK","Dkk","DKK","Eur","EUR","Gbp","GBP","Hrk","HRK","Huf","HUF","Nok","NOK","Pln","PLN","Ron","RON","Sek","SEK","Usd","Zar","Inr","INR","Sgd","SGD","Brl","BRL","Jpy","JPY","Twd","Mxn","Php","PHP","Cny","CNY","storesWithPerItemTaxRate","Set","TAX_RATE_DINERO_CURRENCY","base","exponent","EXCHANGE_RATE_DINERO_CURRENCY"],"mappings":";;;;;;;AA+Ca,MAAAA,qBAAA,GAAqCC,KAAkB,IAAA;EAClE,IAAIA,UAAU,CAAG,EAAA;IACR,OAAA,CAAA;EAAA;EAIT,IAAIA,SAAS,CAAG,EAAA;IACP,OAAA,CAAA;EAAA;EAOH,MAAAC,aAAA,GAAgBC,IA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AA,GAAK;EAAAO,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAAAA,CAAAA,SAAS0C,GAAK,EAAA;EAAExC,UAAUyC,UAAAA,CAAAA,GAAK;EAAAxC,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAAAA,CAAAA,SAAS4C,GAAK,EAAA;EAAE1C,UAAU2C,UAAK,CAAAA,GAAA;EAAA1C,MAAA,EAAQ;AAAS,CAAA,CAAA,CAClD,CAAA;AAeY,MAAA2C,wBAAA,GAAA,mBAA+BC,GAAI,CAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA,CAWlC,CAAA;AAKP,MAAMC,wBAA2B,GAAA;EACtCC,IAAM,EAAA,EAAA;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAUNC,QAAU,EAAA,CAAA;EACVzD,IAAM,EAAA;EAAA;AACR,CAAA;AAMO,MAAM0D,6BAAgC,GAAA;EAC3CF,IAAM,EAAA,EAAA;EAAA;AAAA;AAAA;AAAA;EAKNC,QAAU,EAAA,CAAA;EACVzD,IAAM,EAAA;EAAA;AACR,CAAA;;;;;;;;;;;"}
1
+ {"version":3,"file":"constants.js","sources":["../../../src/utils/money/constants.ts"],"sourcesContent":["import {\n AED,\n BGN,\n BRL,\n CAD,\n CHF,\n CNY,\n CZK,\n DKK,\n EUR,\n GBP,\n HRK,\n HUF,\n INR,\n JPY,\n MXN,\n NOK,\n PHP,\n PLN,\n RON,\n SEK,\n SGD,\n TWD,\n USD,\n ZAR,\n} from \"@dinero.js/currencies\";\nimport { down, halfAwayFromZero, halfUp } from \"dinero.js\";\n\nimport type { StoreId } from \"../../types\";\nimport { Currency } from \"../../types\";\nimport type {\n Cents,\n DinoCurrency,\n LocalizedCurrency,\n RoundingFn,\n} from \"./types\";\n\n// #############################################################################\n// Constants\n// #############################################################################\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to nearest FULL 0/5/9 (and strip cents)\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestFull059: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-5.00\n if (input <= 5) {\n return 5;\n }\n\n /**\n * Input comes as float, for this rounding we don't need cents, so round\n * to nearest full number\n */\n const roundedNumber = Math.round(input);\n\n // Determine nearest rounding value\n const remainder = roundedNumber % 10;\n if (remainder <= 2) {\n // Round down to nearest 0\n return roundedNumber - remainder;\n } else if (remainder <= 7) {\n // Round to nearest 5\n return roundedNumber - remainder + 5;\n } else {\n // Round up to nearest 9\n return roundedNumber - remainder + 9;\n }\n};\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to\n * nearest decimal cent. e.g. 1.53 = 1.50 / 1.57 = 1.60\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestDecimalCent: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-0.09\n if (input <= 0.1) {\n return 0.1;\n }\n\n /**\n * Input comes as float, just to be on the safe side use toFixed to mitigate\n * risk of running to floating point precision issues\n */\n return parseFloat((Math.round(input * 10) / 10).toFixed(1));\n};\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to\n * nearest .50 or .00. e.g. 11.22 = 11 / 11.55 = 11.50 / 11.90 = 12\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestHalfUnitCent: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-0.5\n if (input <= 0.5) {\n return 0.5;\n }\n\n /**\n * Input comes as float, just to be on the safe side use toFixed to mitigate\n * risk of running to floating point precision issues\n *\n * Multiply by 2, round to the nearest integer, then divide by 2 to get the nearest .5 or .0\n * Return with fixed precision to avoid floating-point artifacts\n */\n return parseFloat((Math.round(input * 2) / 2).toFixed(2));\n};\n\nexport const Round = {\n /**\n * !!!!!!!!!!!!!!\n * ! Update 2024\n * ! We ar changing from `halfEven` (bankers rounding) to `halfAwayFromZero` (symmetric rounding) to match Avalara tax\n * @see https://knowledge.avalara.com/bundle/dqa1657870670369_dqa1657870670369/page/Change_how_AvaTax_rounds_the_tax_amount.html\n * @see https://ui.slack.com/archives/C07P7L7S3CP/p1728313196140639\n * !!!!!!!!!!!!!!\n *\n * OLD: halfEven docs\n * ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T\n * deal with dinero.js (Dinero.js should be the priority). But often for converting from API requests we have to\n * normalize the values so we use this method.\n *\n * It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.\n * @see https://github.com/dinerojs/dinero.js/blob/v2.0.0-alpha.8/packages/core/src/round/halfEven.ts\n *\n * Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behavior\n * based on if the rounded number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.\n * See the youtube link below for a brief exclamation on why it's important to use this method over regular rounding\n * (half-up):\n * https://youtu.be/yuRdYlZvs1E\n *\n * If you really want to get knee-deep in the rounding subject, you can read the following:\n * https://en.wikipedia.org/wiki/Rounding#Round_half_toward_zero\n */\n Financial: halfAwayFromZero,\n // https://ui.slack.com/archives/C07P7L7S3CP/p1728313196140639\n // TODO: maybe we should have separate rounding functions depending on the input value?\n // Reading from wiki \"Round half toward zero\" is better if the value is already \"normalized to cents\"\n // But the \"Round half to even\" seems better for when working with float like values\n // financialRound = Math.round;\n Shipping: roundToNearestDecimalCent,\n Prettify: down,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyFull059: roundToNearestFull059,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyDecimalCents: roundToNearestDecimalCent,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyHalfUnitCents: roundToNearestHalfUnitCent,\n Subunit: halfUp,\n} satisfies Record<string, RoundingFn>;\n\n/**\n * Mapping of how prices should be rounded down to \"whole numbers\" after certain threshold\n */\nexport const prettifyPriceLookup = new Map([\n [USD.code, 20],\n [AED.code, 50],\n // Approximately every price above ~1.1 usd will be rounded in ZAR\n [ZAR.code, 20],\n [MXN.code, 20],\n]);\n\n/**\n * Map of dinero code to subunit digit count.\n */\nexport const smallestSubunitLookup = new Map<string, [Cents, RoundingFn]>([\n /**\n * TWD does not use subunits at all in day to day transactions.\n */\n [TWD.code, [0, Round.Subunit]],\n]);\n\n/**\n * Precompiled list for faster currency and locale lookups\n */\nexport const localizedCurrencyLookup = new Map<Currency, LocalizedCurrency>([\n [Currency.Aed, { currency: AED, locale: \"ar-AE\" }],\n [Currency.Bgn, { currency: BGN, locale: \"bg-BG\" }],\n [Currency.Cad, { currency: CAD, locale: \"en-CA\" }],\n [Currency.Chf, { currency: CHF, locale: \"it-CH\" }],\n [Currency.Czk, { currency: CZK, locale: \"cs-CZ\" }],\n [Currency.Dkk, { currency: DKK, locale: \"da-DK\" }],\n [Currency.Eur, { currency: EUR, locale: \"de-DE\" }],\n [Currency.Gbp, { currency: GBP, locale: \"en-GB\" }],\n [Currency.Hrk, { currency: HRK, locale: \"hr-HR\" }],\n [Currency.Huf, { currency: HUF, locale: \"hu-HU\" }],\n [Currency.Nok, { currency: NOK, locale: \"no-NO\" }],\n [Currency.Pln, { currency: PLN, locale: \"pl-PL\" }],\n [Currency.Ron, { currency: RON, locale: \"ro-RO\" }],\n [Currency.Sek, { currency: SEK, locale: \"sv-SE\" }],\n [Currency.Usd, { currency: USD, locale: \"en-US\" }],\n [Currency.Zar, { currency: ZAR, locale: \"en-ZA\" }],\n [Currency.Inr, { currency: INR, locale: \"en-IN\" }],\n [Currency.Sgd, { currency: SGD, locale: \"en-SG\" }],\n [Currency.Brl, { currency: BRL, locale: \"pt-BR\" }],\n // NOTE: en-JP Doesn't exist\n [Currency.Jpy, { currency: JPY, locale: \"en-JP\" }],\n // NOTE: en-TW Doesn't exist\n [Currency.Twd, { currency: TWD, locale: \"en-TW\" }],\n [Currency.Mxn, { currency: MXN, locale: \"es-MX\" }],\n [Currency.Php, { currency: PHP, locale: \"en-PH\" }],\n [Currency.Cny, { currency: CNY, locale: \"zh-CN\" }],\n]);\n\n// #############################################################################\n// Tax Rate\n// #############################################################################\n/**\n * List of stores that require calculating per single item qty and then combining them to get the total tax amount for a\n * single line. Rest of the stores inherit default behavior that tax calculated on whole line item\n *\n * ! IMPORTANT: When changing need to sync that store.backend `AVATAX_CUSTOM_COMPANY_CODES` is updated to reflect the change\n *\n * FIXME: as PR for the change as unfinished currently disabled to enable the functionality that calculates tax per single item as requires\n * specific testing both for our custom tax and Avalara stores that use custom company codes. So the groundwork for\n * different tax calculations is there just need to enable on the share side and test if it works\n */\nexport const storesWithPerItemTaxRate = new Set([\n // #############################################################################\n // Stores with custom tax rates\n // #############################################################################\n // StoreId.Br,\n // StoreId.Tw,\n // #############################################################################\n // Stores with Avalara, but will have custom company codes to handle per-item tax rate\n // #############################################################################\n // StoreId.Jp,\n // StoreId.Sg,\n] as StoreId[]);\n\n/**\n * Dinero currency option block for working with tax rates within dinero\n */\nexport const TAX_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We expect the tax rate to be in the range of 0..1\n * 0 --> 0%\n * 1 --> 100%\n * 0.21 --> 21%\n * 0.2169 --> 21.69%\n * 0.12345678 --> 12.345678%\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 8,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n\n// #############################################################################\n// Exchange Rate\n// #############################################################################\n\nexport const EXCHANGE_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We support having certain decimal places for exchange rates\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 6,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n"],"names":["roundToNearestFull059","input","roundedNumber","Math","round","remainder","roundToNearestDecimalCent","parseFloat","toFixed","roundToNearestHalfUnitCent","Round","Financial","halfAwayFromZero","Shipping","Prettify","down","PrettifyFull059","PrettifyDecimalCents","PrettifyHalfUnitCents","Subunit","halfUp","prettifyPriceLookup","Map","USD","code","AED","ZAR","MXN","smallestSubunitLookup","TWD","localizedCurrencyLookup","Currency","Aed","currency","locale","Bgn","BGN","Cad","CAD","Chf","CHF","Czk","CZK","Dkk","DKK","Eur","EUR","Gbp","GBP","Hrk","HRK","Huf","HUF","Nok","NOK","Pln","PLN","Ron","RON","Sek","SEK","Usd","Zar","Inr","INR","Sgd","SGD","Brl","BRL","Jpy","JPY","Twd","Mxn","Php","PHP","Cny","CNY","storesWithPerItemTaxRate","Set","TAX_RATE_DINERO_CURRENCY","base","exponent","EXCHANGE_RATE_DINERO_CURRENCY"],"mappings":";;;;;;;AA+Ca,MAAAA,qBAAA,GAAqCC,KAAkB,IAAA;EAClE,IAAIA,UAAU,CAAG,EAAA;IACR,OAAA,CAAA;EAAA;EAIT,IAAIA,SAAS,CAAG,EAAA;IACP,OAAA,CAAA;EAAA;EAOH,MAAAC,aAAA,GAAgBC,IAAK,CAAAC,KAAA,CAAMH,KAAK,CAAA;EAGtC,MAAMI,YAAYH,aAAgB,GAAA,EAAA;EAClC,IAAIG,aAAa,CAAG,EAAA;IAElB,OAAOH,aAAgB,GAAAG,SAAA;EAAA,CACzB,MAAA,IAAWA,aAAa,CAAG,EAAA;IAEzB,OAAOH,gBAAgBG,SAAY,GAAA,CAAA;EAAA,CAC9B,MAAA;IAEL,OAAOH,gBAAgBG,SAAY,GAAA,CAAA;EAAA;AAEvC,CAAA;AASa,MAAAC,yBAAA,GAAyCL,KAAkB,IAAA;EACtE,IAAIA,UAAU,CAAG,EAAA;IACR,OAAA,CAAA;EAAA;EAIT,IAAIA,SAAS,GAAK,EAAA;IACT,OAAA,GAAA;EAAA;EAOF,OAAAM,UAAA,CAAA,CAAYJ,KAAKC,KAAM,CAAAH,KAAA,GAAQ,EAAE,CAAI,GAAA,EAAA,EAAIO,OAAQ,CAAA,CAAC,CAAC,CAAA;AAC5D,CAA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GAAK,EAAA;EAAEtC,UAAUJ,UAAAA,CAAAA,GAAK;EAAAK,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAAAA,CAAAA,SAASyC,GAAK,EAAA;EAAEvC,UAAUN,UAAAA,CAAAA,GAAK;EAAAO,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAAAA,CAAAA,SAAS0C,GAAK,EAAA;EAAExC,UAAUyC,UAAAA,CAAAA,GAAK;EAAAxC,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAAAA,CAAAA,SAAS4C,GAAK,EAAA;EAAE1C,UAAU2C,UAAK,CAAAA,GAAA;EAAA1C,MAAA,EAAQ;AAAS,CAAA,CAAA,CAClD,CAAA;AAeY,MAAA2C,wBAAA,GAAA,mBAA+BC,GAAI,CAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA,CAWlC,CAAA;AAKP,MAAMC,wBAA2B,GAAA;EACtCC,IAAM,EAAA,EAAA;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAUNC,QAAU,EAAA,CAAA;EACVzD,IAAM,EAAA;EAAA;AACR,CAAA;AAMO,MAAM0D,6BAAgC,GAAA;EAC3CF,IAAM,EAAA,EAAA;EAAA;AAAA;AAAA;AAAA;EAKNC,QAAU,EAAA,CAAA;EACVzD,IAAM,EAAA;EAAA;AACR,CAAA;;;;;;;;;;"}
@@ -20,22 +20,6 @@ const roundToNearestFull059 = input => {
20
20
  return roundedNumber - remainder + 9;
21
21
  }
22
22
  };
23
- const roundToNearestValidUiCarePrice = input => {
24
- if (input === 0) {
25
- return 0;
26
- }
27
- if (input <= 5) {
28
- return 5;
29
- }
30
- const remainder = input % 10;
31
- if (remainder <= 2) {
32
- return input - remainder - 1;
33
- } else if (remainder <= 5) {
34
- return input - remainder + 5;
35
- } else {
36
- return input - remainder + 9;
37
- }
38
- };
39
23
  const roundToNearestDecimalCent = input => {
40
24
  if (input === 0) {
41
25
  return 0;
@@ -100,12 +84,7 @@ const Round = {
100
84
  * ! Disclaimer may not work for "weird" currencies as expected
101
85
  */
102
86
  PrettifyHalfUnitCents: roundToNearestHalfUnitCent,
103
- Subunit: halfUp,
104
- /**
105
- * ! Disclaimer may not work for "weird" currencies as expected
106
- * ! For correct rounding UI Care prices, used for auto managed UI Care products.
107
- */
108
- ValidUiCarePrice: roundToNearestValidUiCarePrice
87
+ Subunit: halfUp
109
88
  };
110
89
  const prettifyPriceLookup = /* @__PURE__ */new Map([[USD.code, 20], [AED.code, 50],
111
90
  // Approximately every price above ~1.1 usd will be rounded in ZAR
@@ -229,5 +208,5 @@ const EXCHANGE_RATE_DINERO_CURRENCY = {
229
208
  code: ""
230
209
  // Not important
231
210
  };
232
- export { EXCHANGE_RATE_DINERO_CURRENCY, Round, TAX_RATE_DINERO_CURRENCY, localizedCurrencyLookup, prettifyPriceLookup, roundToNearestDecimalCent, roundToNearestFull059, roundToNearestHalfUnitCent, roundToNearestValidUiCarePrice, smallestSubunitLookup, storesWithPerItemTaxRate };
211
+ export { EXCHANGE_RATE_DINERO_CURRENCY, Round, TAX_RATE_DINERO_CURRENCY, localizedCurrencyLookup, prettifyPriceLookup, roundToNearestDecimalCent, roundToNearestFull059, roundToNearestHalfUnitCent, smallestSubunitLookup, storesWithPerItemTaxRate };
233
212
  //# sourceMappingURL=constants.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.mjs","sources":["../../../src/utils/money/constants.ts"],"sourcesContent":["import {\n AED,\n BGN,\n BRL,\n CAD,\n CHF,\n CNY,\n CZK,\n DKK,\n EUR,\n GBP,\n HRK,\n HUF,\n INR,\n JPY,\n MXN,\n NOK,\n PHP,\n PLN,\n RON,\n SEK,\n SGD,\n TWD,\n USD,\n ZAR,\n} from \"@dinero.js/currencies\";\nimport { down, halfAwayFromZero, halfUp } from \"dinero.js\";\n\nimport type { StoreId } from \"../../types\";\nimport { Currency } from \"../../types\";\nimport type {\n Cents,\n DinoCurrency,\n LocalizedCurrency,\n RoundingFn,\n} from \"./types\";\n\n// #############################################################################\n// Constants\n// #############################################################################\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to nearest FULL 0/5/9 (and strip cents)\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestFull059: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-5.00\n if (input <= 5) {\n return 5;\n }\n\n /**\n * Input comes as float, for this rounding we don't need cents, so round\n * to nearest full number\n */\n const roundedNumber = Math.round(input);\n\n // Determine nearest rounding value\n const remainder = roundedNumber % 10;\n if (remainder <= 2) {\n // Round down to nearest 0\n return roundedNumber - remainder;\n } else if (remainder <= 7) {\n // Round to nearest 5\n return roundedNumber - remainder + 5;\n } else {\n // Round up to nearest 9\n return roundedNumber - remainder + 9;\n }\n};\n\nexport const roundToNearestValidUiCarePrice: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-5.00\n if (input <= 5) {\n return 5;\n }\n\n // Determine nearest rounding value\n const remainder = input % 10;\n if (remainder <= 2) {\n // Round down to nearest 9\n return input - remainder - 1;\n } else if (remainder <= 5) {\n // Round to nearest 5\n return input - remainder + 5;\n } else {\n // Round up to nearest 9\n return input - remainder + 9;\n }\n};\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to\n * nearest decimal cent. e.g. 1.53 = 1.50 / 1.57 = 1.60\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestDecimalCent: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-0.09\n if (input <= 0.1) {\n return 0.1;\n }\n\n /**\n * Input comes as float, just to be on the safe side use toFixed to mitigate\n * risk of running to floating point precision issues\n */\n return parseFloat((Math.round(input * 10) / 10).toFixed(1));\n};\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to\n * nearest .50 or .00. e.g. 11.22 = 11 / 11.55 = 11.50 / 11.90 = 12\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestHalfUnitCent: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-0.5\n if (input <= 0.5) {\n return 0.5;\n }\n\n /**\n * Input comes as float, just to be on the safe side use toFixed to mitigate\n * risk of running to floating point precision issues\n *\n * Multiply by 2, round to the nearest integer, then divide by 2 to get the nearest .5 or .0\n * Return with fixed precision to avoid floating-point artifacts\n */\n return parseFloat((Math.round(input * 2) / 2).toFixed(2));\n};\n\nexport const Round = {\n /**\n * !!!!!!!!!!!!!!\n * ! Update 2024\n * ! We ar changing from `halfEven` (bankers rounding) to `halfAwayFromZero` (symmetric rounding) to match Avalara tax\n * @see https://knowledge.avalara.com/bundle/dqa1657870670369_dqa1657870670369/page/Change_how_AvaTax_rounds_the_tax_amount.html\n * @see https://ui.slack.com/archives/C07P7L7S3CP/p1728313196140639\n * !!!!!!!!!!!!!!\n *\n * OLD: halfEven docs\n * ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T\n * deal with dinero.js (Dinero.js should be the priority). But often for converting from API requests we have to\n * normalize the values so we use this method.\n *\n * It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.\n * @see https://github.com/dinerojs/dinero.js/blob/v2.0.0-alpha.8/packages/core/src/round/halfEven.ts\n *\n * Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behavior\n * based on if the rounded number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.\n * See the youtube link below for a brief exclamation on why it's important to use this method over regular rounding\n * (half-up):\n * https://youtu.be/yuRdYlZvs1E\n *\n * If you really want to get knee-deep in the rounding subject, you can read the following:\n * https://en.wikipedia.org/wiki/Rounding#Round_half_toward_zero\n */\n Financial: halfAwayFromZero,\n // https://ui.slack.com/archives/C07P7L7S3CP/p1728313196140639\n // TODO: maybe we should have separate rounding functions depending on the input value?\n // Reading from wiki \"Round half toward zero\" is better if the value is already \"normalized to cents\"\n // But the \"Round half to even\" seems better for when working with float like values\n // financialRound = Math.round;\n Shipping: roundToNearestDecimalCent,\n Prettify: down,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyFull059: roundToNearestFull059,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyDecimalCents: roundToNearestDecimalCent,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyHalfUnitCents: roundToNearestHalfUnitCent,\n Subunit: halfUp,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n * ! For correct rounding UI Care prices, used for auto managed UI Care products.\n */\n ValidUiCarePrice: roundToNearestValidUiCarePrice,\n} satisfies Record<string, RoundingFn>;\n\n/**\n * Mapping of how prices should be rounded down to \"whole numbers\" after certain threshold\n */\nexport const prettifyPriceLookup = new Map([\n [USD.code, 20],\n [AED.code, 50],\n // Approximately every price above ~1.1 usd will be rounded in ZAR\n [ZAR.code, 20],\n [MXN.code, 20],\n]);\n\n/**\n * Map of dinero code to subunit digit count.\n */\nexport const smallestSubunitLookup = new Map<string, [Cents, RoundingFn]>([\n /**\n * TWD does not use subunits at all in day to day transactions.\n */\n [TWD.code, [0, Round.Subunit]],\n]);\n\n/**\n * Precompiled list for faster currency and locale lookups\n */\nexport const localizedCurrencyLookup = new Map<Currency, LocalizedCurrency>([\n [Currency.Aed, { currency: AED, locale: \"ar-AE\" }],\n [Currency.Bgn, { currency: BGN, locale: \"bg-BG\" }],\n [Currency.Cad, { currency: CAD, locale: \"en-CA\" }],\n [Currency.Chf, { currency: CHF, locale: \"it-CH\" }],\n [Currency.Czk, { currency: CZK, locale: \"cs-CZ\" }],\n [Currency.Dkk, { currency: DKK, locale: \"da-DK\" }],\n [Currency.Eur, { currency: EUR, locale: \"de-DE\" }],\n [Currency.Gbp, { currency: GBP, locale: \"en-GB\" }],\n [Currency.Hrk, { currency: HRK, locale: \"hr-HR\" }],\n [Currency.Huf, { currency: HUF, locale: \"hu-HU\" }],\n [Currency.Nok, { currency: NOK, locale: \"no-NO\" }],\n [Currency.Pln, { currency: PLN, locale: \"pl-PL\" }],\n [Currency.Ron, { currency: RON, locale: \"ro-RO\" }],\n [Currency.Sek, { currency: SEK, locale: \"sv-SE\" }],\n [Currency.Usd, { currency: USD, locale: \"en-US\" }],\n [Currency.Zar, { currency: ZAR, locale: \"en-ZA\" }],\n [Currency.Inr, { currency: INR, locale: \"en-IN\" }],\n [Currency.Sgd, { currency: SGD, locale: \"en-SG\" }],\n [Currency.Brl, { currency: BRL, locale: \"pt-BR\" }],\n // NOTE: en-JP Doesn't exist\n [Currency.Jpy, { currency: JPY, locale: \"en-JP\" }],\n // NOTE: en-TW Doesn't exist\n [Currency.Twd, { currency: TWD, locale: \"en-TW\" }],\n [Currency.Mxn, { currency: MXN, locale: \"es-MX\" }],\n [Currency.Php, { currency: PHP, locale: \"en-PH\" }],\n [Currency.Cny, { currency: CNY, locale: \"zh-CN\" }],\n]);\n\n// #############################################################################\n// Tax Rate\n// #############################################################################\n/**\n * List of stores that require calculating per single item qty and then combining them to get the total tax amount for a\n * single line. Rest of the stores inherit default behavior that tax calculated on whole line item\n *\n * ! IMPORTANT: When changing need to sync that store.backend `AVATAX_CUSTOM_COMPANY_CODES` is updated to reflect the change\n *\n * FIXME: as PR for the change as unfinished currently disabled to enable the functionality that calculates tax per single item as requires\n * specific testing both for our custom tax and Avalara stores that use custom company codes. So the groundwork for\n * different tax calculations is there just need to enable on the share side and test if it works\n */\nexport const storesWithPerItemTaxRate = new Set([\n // #############################################################################\n // Stores with custom tax rates\n // #############################################################################\n // StoreId.Br,\n // StoreId.Tw,\n // #############################################################################\n // Stores with Avalara, but will have custom company codes to handle per-item tax rate\n // #############################################################################\n // StoreId.Jp,\n // StoreId.Sg,\n] as StoreId[]);\n\n/**\n * Dinero currency option block for working with tax rates within dinero\n */\nexport const TAX_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We expect the tax rate to be in the range of 0..1\n * 0 --> 0%\n * 1 --> 100%\n * 0.21 --> 21%\n * 0.2169 --> 21.69%\n * 0.12345678 --> 12.345678%\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 8,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n\n// #############################################################################\n// Exchange Rate\n// #############################################################################\n\nexport const EXCHANGE_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We support having certain decimal places for exchange rates\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 6,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n"],"names":["roundToNearestFull059","input","roundedNumber","Math","round","remainder","roundToNearestValidUiCarePrice","roundToNearestDecimalCent","parseFloat","toFixed","roundToNearestHalfUnitCent","Round","Financial","halfAwayFromZero","Shipping","Prettify","down","PrettifyFull059","PrettifyDecimalCents","PrettifyHalfUnitCents","Subunit","halfUp","ValidUiCarePrice","prettifyPriceLookup","Map","USD","code","AED","ZAR","MXN","smallestSubunitLookup","TWD","localizedCurrencyLookup","Currency","Aed","currency","locale","Bgn","BGN","Cad","CAD","Chf","CHF","Czk","CZK","Dkk","DKK","Eur","EUR","Gbp","GBP","Hrk","HRK","Huf","HUF","Nok","NOK","Pln","PLN","Ron","RON","Sek","SEK","Usd","Zar","Inr","INR","Sgd","SGD","Brl","BRL","Jpy","JPY","Twd","Mxn","Php","PHP","Cny","CNY","storesWithPerItemTaxRate","Set","TAX_RATE_DINERO_CURRENCY","base","exponent","EXCHANGE_RATE_DINERO_CURRENCY"],"mappings":";;;;;AA+Ca,MAAAA,qBAAA,GAAqCC,KAAkB,IAAA;EAClE,IAAIA,UAAU,CAAG,EAAA;IACR,OAAA,CAAA;EAAA;EAIT,IAAIA,SAAS,CAAG,EAAA;IACP,OAAA,CAAA;EAAA;EAOH,MAAAC,aAAA,GAAgBC,IAAK,CAAAC,KAAA,CAAMH,KAAK,CAAA;EAGtC,M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CZK,\n DKK,\n EUR,\n GBP,\n HRK,\n HUF,\n INR,\n JPY,\n MXN,\n NOK,\n PHP,\n PLN,\n RON,\n SEK,\n SGD,\n TWD,\n USD,\n ZAR,\n} from \"@dinero.js/currencies\";\nimport { down, halfAwayFromZero, halfUp } from \"dinero.js\";\n\nimport type { StoreId } from \"../../types\";\nimport { Currency } from \"../../types\";\nimport type {\n Cents,\n DinoCurrency,\n LocalizedCurrency,\n RoundingFn,\n} from \"./types\";\n\n// #############################################################################\n// Constants\n// #############################################################################\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to nearest FULL 0/5/9 (and strip cents)\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestFull059: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-5.00\n if (input <= 5) {\n return 5;\n }\n\n /**\n * Input comes as float, for this rounding we don't need cents, so round\n * to nearest full number\n */\n const roundedNumber = Math.round(input);\n\n // Determine nearest rounding value\n const remainder = roundedNumber % 10;\n if (remainder <= 2) {\n // Round down to nearest 0\n return roundedNumber - remainder;\n } else if (remainder <= 7) {\n // Round to nearest 5\n return roundedNumber - remainder + 5;\n } else {\n // Round up to nearest 9\n return roundedNumber - remainder + 9;\n }\n};\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to\n * nearest decimal cent. e.g. 1.53 = 1.50 / 1.57 = 1.60\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestDecimalCent: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-0.09\n if (input <= 0.1) {\n return 0.1;\n }\n\n /**\n * Input comes as float, just to be on the safe side use toFixed to mitigate\n * risk of running to floating point precision issues\n */\n return parseFloat((Math.round(input * 10) / 10).toFixed(1));\n};\n\n/**\n * Custom rounding method to be used with dinero.js\n * This rounding method will round to\n * nearest .50 or .00. e.g. 11.22 = 11 / 11.55 = 11.50 / 11.90 = 12\n *\n * @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n */\nexport const roundToNearestHalfUnitCent: RoundingFn = (input: number) => {\n if (input === 0) {\n return 0;\n }\n\n // Special handling of 0.01-0.5\n if (input <= 0.5) {\n return 0.5;\n }\n\n /**\n * Input comes as float, just to be on the safe side use toFixed to mitigate\n * risk of running to floating point precision issues\n *\n * Multiply by 2, round to the nearest integer, then divide by 2 to get the nearest .5 or .0\n * Return with fixed precision to avoid floating-point artifacts\n */\n return parseFloat((Math.round(input * 2) / 2).toFixed(2));\n};\n\nexport const Round = {\n /**\n * !!!!!!!!!!!!!!\n * ! Update 2024\n * ! We ar changing from `halfEven` (bankers rounding) to `halfAwayFromZero` (symmetric rounding) to match Avalara tax\n * @see https://knowledge.avalara.com/bundle/dqa1657870670369_dqa1657870670369/page/Change_how_AvaTax_rounds_the_tax_amount.html\n * @see https://ui.slack.com/archives/C07P7L7S3CP/p1728313196140639\n * !!!!!!!!!!!!!!\n *\n * OLD: halfEven docs\n * ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T\n * deal with dinero.js (Dinero.js should be the priority). But often for converting from API requests we have to\n * normalize the values so we use this method.\n *\n * It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.\n * @see https://github.com/dinerojs/dinero.js/blob/v2.0.0-alpha.8/packages/core/src/round/halfEven.ts\n *\n * Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behavior\n * based on if the rounded number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.\n * See the youtube link below for a brief exclamation on why it's important to use this method over regular rounding\n * (half-up):\n * https://youtu.be/yuRdYlZvs1E\n *\n * If you really want to get knee-deep in the rounding subject, you can read the following:\n * https://en.wikipedia.org/wiki/Rounding#Round_half_toward_zero\n */\n Financial: halfAwayFromZero,\n // https://ui.slack.com/archives/C07P7L7S3CP/p1728313196140639\n // TODO: maybe we should have separate rounding functions depending on the input value?\n // Reading from wiki \"Round half toward zero\" is better if the value is already \"normalized to cents\"\n // But the \"Round half to even\" seems better for when working with float like values\n // financialRound = Math.round;\n Shipping: roundToNearestDecimalCent,\n Prettify: down,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyFull059: roundToNearestFull059,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyDecimalCents: roundToNearestDecimalCent,\n /**\n * ! Disclaimer may not work for \"weird\" currencies as expected\n */\n PrettifyHalfUnitCents: roundToNearestHalfUnitCent,\n Subunit: halfUp,\n} satisfies Record<string, RoundingFn>;\n\n/**\n * Mapping of how prices should be rounded down to \"whole numbers\" after certain threshold\n */\nexport const prettifyPriceLookup = new Map([\n [USD.code, 20],\n [AED.code, 50],\n // Approximately every price above ~1.1 usd will be rounded in ZAR\n [ZAR.code, 20],\n [MXN.code, 20],\n]);\n\n/**\n * Map of dinero code to subunit digit count.\n */\nexport const smallestSubunitLookup = new Map<string, [Cents, RoundingFn]>([\n /**\n * TWD does not use subunits at all in day to day transactions.\n */\n [TWD.code, [0, Round.Subunit]],\n]);\n\n/**\n * Precompiled list for faster currency and locale lookups\n */\nexport const localizedCurrencyLookup = new Map<Currency, LocalizedCurrency>([\n [Currency.Aed, { currency: AED, locale: \"ar-AE\" }],\n [Currency.Bgn, { currency: BGN, locale: \"bg-BG\" }],\n [Currency.Cad, { currency: CAD, locale: \"en-CA\" }],\n [Currency.Chf, { currency: CHF, locale: \"it-CH\" }],\n [Currency.Czk, { currency: CZK, locale: \"cs-CZ\" }],\n [Currency.Dkk, { currency: DKK, locale: \"da-DK\" }],\n [Currency.Eur, { currency: EUR, locale: \"de-DE\" }],\n [Currency.Gbp, { currency: GBP, locale: \"en-GB\" }],\n [Currency.Hrk, { currency: HRK, locale: \"hr-HR\" }],\n [Currency.Huf, { currency: HUF, locale: \"hu-HU\" }],\n [Currency.Nok, { currency: NOK, locale: \"no-NO\" }],\n [Currency.Pln, { currency: PLN, locale: \"pl-PL\" }],\n [Currency.Ron, { currency: RON, locale: \"ro-RO\" }],\n [Currency.Sek, { currency: SEK, locale: \"sv-SE\" }],\n [Currency.Usd, { currency: USD, locale: \"en-US\" }],\n [Currency.Zar, { currency: ZAR, locale: \"en-ZA\" }],\n [Currency.Inr, { currency: INR, locale: \"en-IN\" }],\n [Currency.Sgd, { currency: SGD, locale: \"en-SG\" }],\n [Currency.Brl, { currency: BRL, locale: \"pt-BR\" }],\n // NOTE: en-JP Doesn't exist\n [Currency.Jpy, { currency: JPY, locale: \"en-JP\" }],\n // NOTE: en-TW Doesn't exist\n [Currency.Twd, { currency: TWD, locale: \"en-TW\" }],\n [Currency.Mxn, { currency: MXN, locale: \"es-MX\" }],\n [Currency.Php, { currency: PHP, locale: \"en-PH\" }],\n [Currency.Cny, { currency: CNY, locale: \"zh-CN\" }],\n]);\n\n// #############################################################################\n// Tax Rate\n// #############################################################################\n/**\n * List of stores that require calculating per single item qty and then combining them to get the total tax amount for a\n * single line. Rest of the stores inherit default behavior that tax calculated on whole line item\n *\n * ! IMPORTANT: When changing need to sync that store.backend `AVATAX_CUSTOM_COMPANY_CODES` is updated to reflect the change\n *\n * FIXME: as PR for the change as unfinished currently disabled to enable the functionality that calculates tax per single item as requires\n * specific testing both for our custom tax and Avalara stores that use custom company codes. So the groundwork for\n * different tax calculations is there just need to enable on the share side and test if it works\n */\nexport const storesWithPerItemTaxRate = new Set([\n // #############################################################################\n // Stores with custom tax rates\n // #############################################################################\n // StoreId.Br,\n // StoreId.Tw,\n // #############################################################################\n // Stores with Avalara, but will have custom company codes to handle per-item tax rate\n // #############################################################################\n // StoreId.Jp,\n // StoreId.Sg,\n] as StoreId[]);\n\n/**\n * Dinero currency option block for working with tax rates within dinero\n */\nexport const TAX_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We expect the tax rate to be in the range of 0..1\n * 0 --> 0%\n * 1 --> 100%\n * 0.21 --> 21%\n * 0.2169 --> 21.69%\n * 0.12345678 --> 12.345678%\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 8,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n\n// #############################################################################\n// Exchange Rate\n// #############################################################################\n\nexport const EXCHANGE_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We support having certain decimal places for exchange rates\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 6,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n"],"names":["roundToNearestFull059","input","roundedNumber","Math","round","remainder","roundToNearestDecimalCent","parseFloat","toFixed","roundToNearestHalfUnitCent","Round","Financial","halfAwayFromZero","Shipping","Prettify","down","PrettifyFull059","PrettifyDecimalCents","PrettifyHalfUnitCents","Subunit","halfUp","prettifyPriceLookup","Map","USD","code","AED","ZAR","MXN","smallestSubunitLookup","TWD","localizedCurrencyLookup","Currency","Aed","currency","locale","Bgn","BGN","Cad","CAD","Chf","CHF","Czk","CZK","Dkk","DKK","Eur","EUR","Gbp","GBP","Hrk","HRK","Huf","HUF","Nok","NOK","Pln","PLN","Ron","RON","Sek","SEK","Usd","Zar","Inr","INR","Sgd","SGD","Brl","BRL","Jpy","JPY","Twd","Mxn","Php","PHP","Cny","CNY","storesWithPerItemTaxRate","Set","TAX_RATE_DINERO_CURRENCY","base","exponent","EXCHANGE_RATE_DINERO_CURRENCY"],"mappings":";;;;;AA+Ca,MAAAA,qBAAA,GAAqCC,KAAkB,IAAA;EAClE,IAAIA,UAAU,CAAG,EAAA;IACR,OAAA,CAAA;EAAA;EAIT,IAAIA,SAAS,CAAG,EAAA;IACP,OAAA,CAAA;EAAA;EAOH,MAAAC,aAAA,GAAgBC,IAAK,CAAAC,KAAA,CAAMH,KAAK,CAAA;EAGtC,MAAMI,YAAYH,aAAgB,GAAA,EAAA;EAClC,IAAIG,aAAa,CAAG,EAAA;IAElB,OAAOH,aAAgB,GAAAG,SAAA;EAAA,CACzB,MAAA,IAAWA,aAAa,CAAG,EAAA;IAEzB,OAAOH,gBAAgBG,SAAY,GAAA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CAAA,CAAA,CAClD,CAAA;AAeY,MAAA2C,wBAAA,GAAA,mBAA+BC,GAAI,CAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA,CAWlC,CAAA;AAKP,MAAMC,wBAA2B,GAAA;EACtCC,IAAM,EAAA,EAAA;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAUNC,QAAU,EAAA,CAAA;EACVzD,IAAM,EAAA;EAAA;AACR,CAAA;AAMO,MAAM0D,6BAAgC,GAAA;EAC3CF,IAAM,EAAA,EAAA;EAAA;AAAA;AAAA;AAAA;EAKNC,QAAU,EAAA,CAAA;EACVzD,IAAM,EAAA;EAAA;AACR,CAAA;"}
@@ -20,7 +20,6 @@ exports.prettifyPriceLookup = constants.prettifyPriceLookup;
20
20
  exports.roundToNearestDecimalCent = constants.roundToNearestDecimalCent;
21
21
  exports.roundToNearestFull059 = constants.roundToNearestFull059;
22
22
  exports.roundToNearestHalfUnitCent = constants.roundToNearestHalfUnitCent;
23
- exports.roundToNearestValidUiCarePrice = constants.roundToNearestValidUiCarePrice;
24
23
  exports.smallestSubunitLookup = constants.smallestSubunitLookup;
25
24
  exports.storesWithPerItemTaxRate = constants.storesWithPerItemTaxRate;
26
25
  exports.invertExchangeRate = exchangeRate.invertExchangeRate;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  export { FixedAmountAllocator } from './allocators/fixedAmount.mjs';
2
2
  export { ProductAmountAllocator } from './allocators/productAmount.mjs';
3
- export { EXCHANGE_RATE_DINERO_CURRENCY, Round, TAX_RATE_DINERO_CURRENCY, localizedCurrencyLookup, prettifyPriceLookup, roundToNearestDecimalCent, roundToNearestFull059, roundToNearestHalfUnitCent, roundToNearestValidUiCarePrice, smallestSubunitLookup, storesWithPerItemTaxRate } from './constants.mjs';
3
+ export { EXCHANGE_RATE_DINERO_CURRENCY, Round, TAX_RATE_DINERO_CURRENCY, localizedCurrencyLookup, prettifyPriceLookup, roundToNearestDecimalCent, roundToNearestFull059, roundToNearestHalfUnitCent, smallestSubunitLookup, storesWithPerItemTaxRate } from './constants.mjs';
4
4
  export { invertExchangeRate, toFixedExchangeRate, toSnapshotExchangeRate } from './exchangeRate.mjs';
5
5
  export { formatPrice, formatPriceRaw, getLocalizedCurrency, prettifyTotal } from './format.mjs';
6
6
  export { addMany, amount, centsToCurrencyUnit, currency, dineroToCurrencyUnit, getDinero, getDineroCurrency, money, multiplyByFullPercent, parseCurrencyCode, parseFloatToDinero, parseFloatToDineroRaw, roundDinero, stringAmountToDinero, subtractMany, toSmallestSubunit } from './misc.mjs';
@@ -1,7 +1,7 @@
1
1
  import type { DeployedLanguages } from "../../contexts/MenuContext/mapping";
2
2
  import type { BasicSiteConfig } from "../../contexts/MenuContext/types";
3
3
  import { SiteConfigType } from "../../contexts/MenuContext/types";
4
- import { GlobalStoreId, Language } from "../../types";
4
+ import { GlobalStoreId } from "../../types";
5
5
  /**
6
6
  * Values that indicate what kind of target build environment it is
7
7
  */
@@ -35,7 +35,7 @@ export declare const getGlobalSiteConfigByEnv: (buildEnv: BuildEnv) => {
35
35
  type: SiteConfigType.Regional;
36
36
  defaultRegion: {
37
37
  languages?: DeployedLanguages | undefined;
38
- defaultLanguage?: Language | undefined;
38
+ defaultLanguage?: import("../../types").Language | undefined;
39
39
  type: SiteConfigType.Basic;
40
40
  baseUrl: string;
41
41
  };
@@ -48,14 +48,14 @@ export declare const getGlobalSiteConfigByEnv: (buildEnv: BuildEnv) => {
48
48
  type: SiteConfigType.Regional;
49
49
  defaultRegion: {
50
50
  languages?: DeployedLanguages | undefined;
51
- defaultLanguage?: Language | undefined;
51
+ defaultLanguage?: import("../../types").Language | undefined;
52
52
  type: SiteConfigType.Basic;
53
53
  baseUrl: string;
54
54
  };
55
55
  regions: Record<GlobalStoreId, BasicSiteConfig | null>;
56
56
  };
57
57
  /**
58
- * "uisp.com" site config
58
+ * "uisp.ui.com" site config
59
59
  */
60
60
  uisp: {
61
61
  type: SiteConfigType.Regional;
@@ -86,7 +86,6 @@ export declare const getGlobalSiteConfigByEnv: (buildEnv: BuildEnv) => {
86
86
  uwc: {
87
87
  type: SiteConfigType.Basic;
88
88
  baseUrl: string;
89
- defaultLanguage: Language.En;
90
89
  languages: DeployedLanguages;
91
90
  };
92
91
  /**
@@ -110,13 +109,4 @@ export declare const getGlobalSiteConfigByEnv: (buildEnv: BuildEnv) => {
110
109
  type: SiteConfigType.Basic;
111
110
  baseUrl: string;
112
111
  };
113
- /**
114
- * "casestudies.ui.com" site config
115
- */
116
- caseStudies: {
117
- type: SiteConfigType.Basic;
118
- baseUrl: string;
119
- defaultLanguage: Language.En;
120
- languages: DeployedLanguages;
121
- };
122
112
  };
@@ -6,7 +6,6 @@ require('../../types/index.js');
6
6
  var errors = require('../errors.js');
7
7
  var storeId = require('../storeId.js');
8
8
  var generated = require('../../types/generated.js');
9
- var constants = require('../../types/constants.js');
10
9
  "use strict";
11
10
  const getStoreRootUrlsByEnv = buildEnv => {
12
11
  switch (buildEnv) {
@@ -75,8 +74,7 @@ const getDeployedLanguagesBySiteByEnv = buildEnv => {
75
74
  return {
76
75
  store: presets.STORE_DEPLOYED_LANGUAGES_LOCAL,
77
76
  ui: presets.UI_COM_DEPLOYED_LANGUAGES_LOCAL,
78
- uwc: presets.UWC_UI_COM_DEPLOYED_LANGUAGES_LOCAL,
79
- caseStudies: presets.CASESTUDIES_UI_COM_DEPLOYED_LANGUAGES_LOCAL
77
+ uwc: presets.UWC_UI_COM_DEPLOYED_LANGUAGES_LOCAL
80
78
  };
81
79
  }
82
80
  case "proto":
@@ -84,8 +82,7 @@ const getDeployedLanguagesBySiteByEnv = buildEnv => {
84
82
  return {
85
83
  store: presets.STORE_DEPLOYED_LANGUAGES_PROTO,
86
84
  ui: presets.UI_COM_DEPLOYED_LANGUAGES_PROTO,
87
- uwc: presets.UWC_UI_COM_DEPLOYED_LANGUAGES_PROTO,
88
- caseStudies: presets.CASESTUDIES_UI_COM_DEPLOYED_LANGUAGES_PROTO
85
+ uwc: presets.UWC_UI_COM_DEPLOYED_LANGUAGES_PROTO
89
86
  };
90
87
  }
91
88
  case "qa":
@@ -93,8 +90,7 @@ const getDeployedLanguagesBySiteByEnv = buildEnv => {
93
90
  return {
94
91
  store: presets.STORE_DEPLOYED_LANGUAGES_QA,
95
92
  ui: presets.UI_COM_DEPLOYED_LANGUAGES_QA,
96
- uwc: presets.UWC_UI_COM_DEPLOYED_LANGUAGES_QA,
97
- caseStudies: presets.CASESTUDIES_UI_COM_DEPLOYED_LANGUAGES_QA
93
+ uwc: presets.UWC_UI_COM_DEPLOYED_LANGUAGES_QA
98
94
  };
99
95
  }
100
96
  case void 0:
@@ -104,8 +100,7 @@ const getDeployedLanguagesBySiteByEnv = buildEnv => {
104
100
  return {
105
101
  store: presets.STORE_DEPLOYED_LANGUAGES_PROD,
106
102
  ui: presets.UI_COM_DEPLOYED_LANGUAGES_PROD,
107
- uwc: presets.UWC_UI_COM_DEPLOYED_LANGUAGES_PROD,
108
- caseStudies: presets.CASESTUDIES_UI_COM_DEPLOYED_LANGUAGES_PROD
103
+ uwc: presets.UWC_UI_COM_DEPLOYED_LANGUAGES_PROD
109
104
  };
110
105
  }
111
106
  default:
@@ -114,8 +109,7 @@ const getDeployedLanguagesBySiteByEnv = buildEnv => {
114
109
  return {
115
110
  store: presets.STORE_DEPLOYED_LANGUAGES_PROD,
116
111
  ui: presets.UI_COM_DEPLOYED_LANGUAGES_PROD,
117
- uwc: presets.UWC_UI_COM_DEPLOYED_LANGUAGES_PROD,
118
- caseStudies: presets.CASESTUDIES_UI_COM_DEPLOYED_LANGUAGES_PROD
112
+ uwc: presets.UWC_UI_COM_DEPLOYED_LANGUAGES_PROD
119
113
  };
120
114
  }
121
115
  }
@@ -203,7 +197,7 @@ const getGlobalSiteConfigByEnv = buildEnv => {
203
197
  }))()
204
198
  },
205
199
  /**
206
- * "uisp.com" site config
200
+ * "uisp.ui.com" site config
207
201
  */
208
202
  uisp: {
209
203
  type: types.SiteConfigType.Regional,
@@ -242,7 +236,6 @@ const getGlobalSiteConfigByEnv = buildEnv => {
242
236
  uwc: {
243
237
  type: types.SiteConfigType.Basic,
244
238
  baseUrl: micrositeRootUrls.uwc,
245
- defaultLanguage: constants.Language.En,
246
239
  languages: deployedLanguages.uwc
247
240
  },
248
241
  /**
@@ -265,15 +258,6 @@ const getGlobalSiteConfigByEnv = buildEnv => {
265
258
  blog: {
266
259
  type: types.SiteConfigType.Basic,
267
260
  baseUrl: micrositeRootUrls.blog
268
- },
269
- /**
270
- * "casestudies.ui.com" site config
271
- */
272
- caseStudies: {
273
- type: types.SiteConfigType.Basic,
274
- baseUrl: micrositeRootUrls.caseStudies,
275
- defaultLanguage: constants.Language.En,
276
- languages: deployedLanguages.caseStudies
277
261
  }
278
262
  };
279
263
  };