@ubnt/store.core 9.44.2 → 9.45.0-alpha.0

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 (916) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/lib/_virtual/_virtual_multi-entry.js +44 -40
  3. package/lib/_virtual/_virtual_multi-entry.js.map +1 -1
  4. package/lib/_virtual/_virtual_multi-entry.mjs +44 -40
  5. package/lib/_virtual/_virtual_multi-entry.mjs.map +1 -1
  6. package/lib/apis/smartcat.d.ts +4 -4
  7. package/lib/apis/smartcat.js +1 -1
  8. package/lib/apis/smartcat.js.map +1 -1
  9. package/lib/apis/smartcat.mjs +1 -1
  10. package/lib/apis/smartcat.mjs.map +1 -1
  11. package/lib/assets/attention.svg +5 -5
  12. package/lib/assets/attention2.svg +5 -5
  13. package/lib/assets/cart-secondary.svg +5 -0
  14. package/lib/assets/consolidatedSpecialDevices.svg +5 -0
  15. package/lib/assets/doorAccess.svg +5 -0
  16. package/lib/assets/education.jpg +0 -0
  17. package/lib/assets/enterprise.jpg +0 -0
  18. package/lib/assets/flagship.jpg +0 -0
  19. package/lib/assets/flexible-outdoor.jpg +0 -0
  20. package/lib/assets/hospitality.jpg +0 -0
  21. package/lib/assets/how-it-works.jpg +0 -0
  22. package/lib/assets/icon-location-pin.svg +5 -0
  23. package/lib/{components/MobileModal/assets → assets/icons}/arrowDown.svg.js +1 -1
  24. package/lib/assets/icons/arrowDown.svg.mjs +3 -0
  25. package/lib/assets/icons/cart-secondary.svg.js +27 -0
  26. package/lib/assets/icons/cart-secondary.svg.js.map +1 -0
  27. package/lib/assets/icons/cart-secondary.svg.mjs +3 -0
  28. package/lib/assets/icons/cart-secondary.svg.mjs.map +1 -0
  29. package/lib/assets/icons/menu/icon-location-pin.svg.js +27 -0
  30. package/lib/assets/icons/menu/icon-location-pin.svg.js.map +1 -0
  31. package/lib/assets/icons/menu/icon-location-pin.svg.mjs +3 -0
  32. package/lib/assets/icons/menu/icon-location-pin.svg.mjs.map +1 -0
  33. package/lib/assets/icons/zoomOut.svg.js +27 -0
  34. package/lib/assets/icons/zoomOut.svg.js.map +1 -0
  35. package/lib/assets/icons/zoomOut.svg.mjs +3 -0
  36. package/lib/assets/icons/zoomOut.svg.mjs.map +1 -0
  37. package/lib/assets/industrial.jpg +0 -0
  38. package/lib/assets/industrial2.jpg +0 -0
  39. package/lib/assets/logoUnifi.svg +10 -2
  40. package/lib/assets/mega-capacity.jpg +0 -0
  41. package/lib/assets/nextai-camera.jpg +0 -0
  42. package/lib/assets/nextai-cyber.jpg +0 -0
  43. package/lib/assets/overview.svg +3 -0
  44. package/lib/assets/pause.svg +3 -3
  45. package/lib/assets/pause2.svg +3 -3
  46. package/lib/assets/plus2.svg +1 -4
  47. package/lib/assets/plus3.svg +4 -1
  48. package/lib/assets/port.svg +4 -2
  49. package/lib/assets/port2.svg +2 -4
  50. package/lib/assets/retail.jpg +0 -0
  51. package/lib/assets/sd-wan-sase.jpg +0 -0
  52. package/lib/assets/site-manager.jpg +0 -0
  53. package/lib/assets/stadium.jpg +0 -0
  54. package/lib/assets/tco-calculator.jpg +0 -0
  55. package/lib/assets/wall.jpg +0 -0
  56. package/lib/assets/zoomOut.svg +3 -0
  57. package/lib/components/Accordion/Accordion.js +2 -2
  58. package/lib/components/Accordion/Accordion.js.map +1 -1
  59. package/lib/components/Accordion/Accordion.mjs +2 -2
  60. package/lib/components/Accordion/Accordion.mjs.map +1 -1
  61. package/lib/components/BackInStock/BackInStock.types.d.ts +1 -0
  62. package/lib/components/Button/Button.js +7 -0
  63. package/lib/components/Button/Button.js.map +1 -1
  64. package/lib/components/Button/Button.mjs +8 -1
  65. package/lib/components/Button/Button.mjs.map +1 -1
  66. package/lib/components/Button/CartButton.d.ts +3 -1
  67. package/lib/components/Button/CartButton.js +9 -4
  68. package/lib/components/Button/CartButton.js.map +1 -1
  69. package/lib/components/Button/CartButton.mjs +8 -4
  70. package/lib/components/Button/CartButton.mjs.map +1 -1
  71. package/lib/components/ButtonGroup/ButtonGroup.d.ts +1 -1
  72. package/lib/components/ButtonGroup/ButtonGroup.js +16 -9
  73. package/lib/components/ButtonGroup/ButtonGroup.js.map +1 -1
  74. package/lib/components/ButtonGroup/ButtonGroup.mjs +16 -9
  75. package/lib/components/ButtonGroup/ButtonGroup.mjs.map +1 -1
  76. package/lib/components/ButtonGroup/ButtonGroup.styles.d.ts +10 -6
  77. package/lib/components/ButtonGroup/ButtonGroup.styles.js +60 -20
  78. package/lib/components/ButtonGroup/ButtonGroup.styles.js.map +1 -1
  79. package/lib/components/ButtonGroup/ButtonGroup.styles.mjs +60 -20
  80. package/lib/components/ButtonGroup/ButtonGroup.styles.mjs.map +1 -1
  81. package/lib/components/ButtonGroup/ButtonGroup.types.d.ts +5 -0
  82. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.d.ts +1 -1
  83. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.js +16 -4
  84. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.js.map +1 -1
  85. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.mjs +17 -5
  86. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.mjs.map +1 -1
  87. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.styles.d.ts +5 -1
  88. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.styles.js +82 -17
  89. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.styles.js.map +1 -1
  90. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.styles.mjs +82 -17
  91. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.styles.mjs.map +1 -1
  92. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.types.d.ts +4 -0
  93. package/lib/components/CardSection/CardSection.styles.d.ts +1 -1
  94. package/lib/components/CategoryTabs/CategoryTabs.styles.d.ts +4 -2
  95. package/lib/components/CategoryTabs/CategoryTabs.styles.js +8 -5
  96. package/lib/components/CategoryTabs/CategoryTabs.styles.js.map +1 -1
  97. package/lib/components/CategoryTabs/CategoryTabs.styles.mjs +7 -6
  98. package/lib/components/CategoryTabs/CategoryTabs.styles.mjs.map +1 -1
  99. package/lib/components/Compare/Compare.styles.d.ts +5 -5
  100. package/lib/components/Container/Container.d.ts +1 -1
  101. package/lib/components/Container/Container.js +4 -3
  102. package/lib/components/Container/Container.js.map +1 -1
  103. package/lib/components/Container/Container.mjs +5 -4
  104. package/lib/components/Container/Container.mjs.map +1 -1
  105. package/lib/components/CustomImage/CustomImage.js +4 -4
  106. package/lib/components/CustomImage/CustomImage.js.map +1 -1
  107. package/lib/components/CustomImage/CustomImage.mjs +4 -4
  108. package/lib/components/CustomImage/CustomImage.mjs.map +1 -1
  109. package/lib/components/Explore/ExploreData.js +12 -12
  110. package/lib/components/Explore/ExploreData.js.map +1 -1
  111. package/lib/components/Explore/ExploreData.mjs +12 -12
  112. package/lib/components/Explore/ExploreData.mjs.map +1 -1
  113. package/lib/components/FeaturesSection_deprecated/AllFeaturesButton/AllFeaturesButton.js +1 -1
  114. package/lib/components/FeaturesSection_deprecated/AllFeaturesButton/AllFeaturesButton.mjs +1 -1
  115. package/lib/components/FeaturesSection_deprecated/FeaturesSection.js +1 -1
  116. package/lib/components/FeaturesSection_deprecated/FeaturesSection.js.map +1 -1
  117. package/lib/components/FeaturesSection_deprecated/FeaturesSection.mjs +1 -1
  118. package/lib/components/FeaturesSection_deprecated/FeaturesSection.mjs.map +1 -1
  119. package/lib/components/FeaturesSection_deprecated/assets/plus.svg.js +1 -1
  120. package/lib/components/FeaturesSection_deprecated/assets/plus.svg.mjs +2 -2
  121. package/lib/components/Gallery/Gallery.context.js.map +1 -1
  122. package/lib/components/Gallery/Gallery.context.mjs.map +1 -1
  123. package/lib/components/Gallery/GalleryItem/GalleryItem.js +3 -1
  124. package/lib/components/Gallery/GalleryItem/GalleryItem.js.map +1 -1
  125. package/lib/components/Gallery/GalleryItem/GalleryItem.mjs +3 -1
  126. package/lib/components/Gallery/GalleryItem/GalleryItem.mjs.map +1 -1
  127. package/lib/components/Header/AccountFrame/AccountFrame.js +3 -3
  128. package/lib/components/Header/AccountFrame/AccountFrame.js.map +1 -1
  129. package/lib/components/Header/AccountFrame/AccountFrame.mjs +3 -3
  130. package/lib/components/Header/AccountFrame/AccountFrame.mjs.map +1 -1
  131. package/lib/components/Header/AccountMenu/AccountMenu.js +14 -4
  132. package/lib/components/Header/AccountMenu/AccountMenu.js.map +1 -1
  133. package/lib/components/Header/AccountMenu/AccountMenu.mjs +15 -5
  134. package/lib/components/Header/AccountMenu/AccountMenu.mjs.map +1 -1
  135. package/lib/components/Header/CartModalV2/Item/Item.js +3 -3
  136. package/lib/components/Header/CartModalV2/Item/Item.mjs +2 -2
  137. package/lib/components/Header/CartModalV2/Item/Item.styles.d.ts +1 -1
  138. package/lib/components/Header/Header.js +22 -21
  139. package/lib/components/Header/Header.js.map +1 -1
  140. package/lib/components/Header/Header.mjs +19 -18
  141. package/lib/components/Header/Header.mjs.map +1 -1
  142. package/lib/components/Header/Header.styles.d.ts +7 -12
  143. package/lib/components/Header/Header.styles.js +10 -32
  144. package/lib/components/Header/Header.styles.js.map +1 -1
  145. package/lib/components/Header/Header.styles.mjs +10 -31
  146. package/lib/components/Header/Header.styles.mjs.map +1 -1
  147. package/lib/components/Header/Header.types.d.ts +30 -6
  148. package/lib/components/Header/Header.types.js +2 -1
  149. package/lib/components/Header/Header.types.js.map +1 -1
  150. package/lib/components/Header/Header.types.mjs +2 -1
  151. package/lib/components/Header/Header.types.mjs.map +1 -1
  152. package/lib/components/Header/IsolatedHeader.d.ts +1 -0
  153. package/lib/components/Header/IsolatedHeader.js +47 -47
  154. package/lib/components/Header/IsolatedHeader.js.map +1 -1
  155. package/lib/components/Header/IsolatedHeader.mjs +49 -48
  156. package/lib/components/Header/IsolatedHeader.mjs.map +1 -1
  157. package/lib/components/Header/LanguageFrame/LanguageFrame.js.map +1 -1
  158. package/lib/components/Header/LanguageFrame/LanguageFrame.mjs.map +1 -1
  159. package/lib/components/Header/LogoIcon/LogoIcon.d.ts +7 -0
  160. package/lib/components/Header/LogoIcon/LogoIcon.js +46 -0
  161. package/lib/components/Header/LogoIcon/LogoIcon.js.map +1 -0
  162. package/lib/components/Header/LogoIcon/LogoIcon.mjs +36 -0
  163. package/lib/components/Header/LogoIcon/LogoIcon.mjs.map +1 -0
  164. package/lib/components/Header/LogoIcon/index.d.ts +1 -0
  165. package/lib/components/Header/LogoIcon/index.js +6 -0
  166. package/lib/components/Header/LogoIcon/index.js.map +1 -0
  167. package/lib/components/Header/LogoIcon/index.mjs +3 -0
  168. package/lib/components/Header/LogoIcon/index.mjs.map +1 -0
  169. package/lib/components/Header/MenuItem/MenuItem.styles.d.ts +1 -1
  170. package/lib/components/Header/MenuItem/MenuItem.styles.js +3 -3
  171. package/lib/components/Header/MenuItem/MenuItem.styles.js.map +1 -1
  172. package/lib/components/Header/MenuItem/MenuItem.styles.mjs +3 -3
  173. package/lib/components/Header/MenuItem/MenuItem.styles.mjs.map +1 -1
  174. package/lib/components/Header/MenuItem/MenuItem.types.d.ts +1 -0
  175. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.js +2 -2
  176. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.js.map +1 -1
  177. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.mjs +2 -2
  178. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.mjs.map +1 -1
  179. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.d.ts +1 -1
  180. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.js +7 -5
  181. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.js.map +1 -1
  182. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.mjs +7 -5
  183. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.mjs.map +1 -1
  184. package/lib/components/Header/Navigation/MobileMenu/MobileMenu.styles.d.ts +1 -1
  185. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.d.ts +1 -1
  186. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.js +110 -103
  187. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.js.map +1 -1
  188. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.mjs +111 -104
  189. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.mjs.map +1 -1
  190. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.d.ts +9 -0
  191. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.js +15 -1
  192. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.js.map +1 -1
  193. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.mjs +13 -2
  194. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.mjs.map +1 -1
  195. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.types.d.ts +12 -6
  196. package/lib/components/Header/ProHeader/ProHeader.d.ts +9 -5
  197. package/lib/components/Header/ProHeader/ProHeader.js +265 -180
  198. package/lib/components/Header/ProHeader/ProHeader.js.map +1 -1
  199. package/lib/components/Header/ProHeader/ProHeader.mjs +264 -180
  200. package/lib/components/Header/ProHeader/ProHeader.mjs.map +1 -1
  201. package/lib/components/Header/ProHeader/ProHeader.styles.d.ts +30 -25
  202. package/lib/components/Header/ProHeader/ProHeader.styles.js +119 -66
  203. package/lib/components/Header/ProHeader/ProHeader.styles.js.map +1 -1
  204. package/lib/components/Header/ProHeader/ProHeader.styles.mjs +112 -65
  205. package/lib/components/Header/ProHeader/ProHeader.styles.mjs.map +1 -1
  206. package/lib/components/Header/translations/ar.json.js +4 -1
  207. package/lib/components/Header/translations/ar.json.js.map +1 -1
  208. package/lib/components/Header/translations/ar.json.mjs +4 -2
  209. package/lib/components/Header/translations/ar.json.mjs.map +1 -1
  210. package/lib/components/Header/translations/de.json.js +4 -1
  211. package/lib/components/Header/translations/de.json.js.map +1 -1
  212. package/lib/components/Header/translations/de.json.mjs +4 -2
  213. package/lib/components/Header/translations/de.json.mjs.map +1 -1
  214. package/lib/components/Header/translations/el.json.js +4 -1
  215. package/lib/components/Header/translations/el.json.js.map +1 -1
  216. package/lib/components/Header/translations/el.json.mjs +4 -2
  217. package/lib/components/Header/translations/el.json.mjs.map +1 -1
  218. package/lib/components/Header/translations/en.json.js +7 -1
  219. package/lib/components/Header/translations/en.json.js.map +1 -1
  220. package/lib/components/Header/translations/en.json.mjs +6 -2
  221. package/lib/components/Header/translations/en.json.mjs.map +1 -1
  222. package/lib/components/Header/translations/es.json.js +4 -1
  223. package/lib/components/Header/translations/es.json.js.map +1 -1
  224. package/lib/components/Header/translations/es.json.mjs +4 -2
  225. package/lib/components/Header/translations/es.json.mjs.map +1 -1
  226. package/lib/components/Header/translations/fr.json.js +4 -1
  227. package/lib/components/Header/translations/fr.json.js.map +1 -1
  228. package/lib/components/Header/translations/fr.json.mjs +4 -2
  229. package/lib/components/Header/translations/fr.json.mjs.map +1 -1
  230. package/lib/components/Header/translations/it.json.js +4 -1
  231. package/lib/components/Header/translations/it.json.js.map +1 -1
  232. package/lib/components/Header/translations/it.json.mjs +4 -2
  233. package/lib/components/Header/translations/it.json.mjs.map +1 -1
  234. package/lib/components/Header/translations/ja.json.js +4 -1
  235. package/lib/components/Header/translations/ja.json.js.map +1 -1
  236. package/lib/components/Header/translations/ja.json.mjs +4 -2
  237. package/lib/components/Header/translations/ja.json.mjs.map +1 -1
  238. package/lib/components/Header/translations/pt-BR.json.js +4 -1
  239. package/lib/components/Header/translations/pt-BR.json.js.map +1 -1
  240. package/lib/components/Header/translations/pt-BR.json.mjs +4 -2
  241. package/lib/components/Header/translations/pt-BR.json.mjs.map +1 -1
  242. package/lib/components/Header/translations/zh-Hans.json.js +4 -1
  243. package/lib/components/Header/translations/zh-Hans.json.js.map +1 -1
  244. package/lib/components/Header/translations/zh-Hans.json.mjs +4 -2
  245. package/lib/components/Header/translations/zh-Hans.json.mjs.map +1 -1
  246. package/lib/components/Header/translations/zh-Hant-TW.json.js +4 -1
  247. package/lib/components/Header/translations/zh-Hant-TW.json.js.map +1 -1
  248. package/lib/components/Header/translations/zh-Hant-TW.json.mjs +4 -2
  249. package/lib/components/Header/translations/zh-Hant-TW.json.mjs.map +1 -1
  250. package/lib/components/Hero/Hero.js +1 -1
  251. package/lib/components/Hero/Hero.js.map +1 -1
  252. package/lib/components/Hero/Hero.mjs +1 -1
  253. package/lib/components/Hero/Hero.mjs.map +1 -1
  254. package/lib/components/Hero/Hero.styles.d.ts +2 -2
  255. package/lib/components/HeroFadeGallery/HeroFadeGallery.styles.d.ts +1 -1
  256. package/lib/components/HeroVideo/HeroVideo.js +5 -5
  257. package/lib/components/HeroVideo/HeroVideo.js.map +1 -1
  258. package/lib/components/HeroVideo/HeroVideo.mjs +5 -5
  259. package/lib/components/HeroVideo/HeroVideo.mjs.map +1 -1
  260. package/lib/components/HowToUseSection/HowToUseSection.styles.d.ts +2 -2
  261. package/lib/components/ImageCarousel/ImageCarousel.js.map +1 -1
  262. package/lib/components/ImageCarousel/ImageCarousel.mjs.map +1 -1
  263. package/lib/components/LandingPage/Cards/Cards.js +4 -4
  264. package/lib/components/LandingPage/Cards/Cards.js.map +1 -1
  265. package/lib/components/LandingPage/Cards/Cards.mjs +3 -3
  266. package/lib/components/LandingPage/Cards/Cards.mjs.map +1 -1
  267. package/lib/components/LandingPagePro/LandingPagePro.js +4 -1
  268. package/lib/components/LandingPagePro/LandingPagePro.js.map +1 -1
  269. package/lib/components/LandingPagePro/LandingPagePro.mjs +4 -1
  270. package/lib/components/LandingPagePro/LandingPagePro.mjs.map +1 -1
  271. package/lib/components/LandingPagePro/LandingPagePro.styles.d.ts +1 -1
  272. package/lib/components/LandingPageSidebar/LandingPageSidebar.js +8 -8
  273. package/lib/components/LandingPageSidebar/LandingPageSidebar.js.map +1 -1
  274. package/lib/components/LandingPageSidebar/LandingPageSidebar.mjs +8 -8
  275. package/lib/components/LandingPageSidebar/LandingPageSidebar.mjs.map +1 -1
  276. package/lib/components/LayoutRenderer/LayoutRenderer.styles.d.ts +1 -1
  277. package/lib/components/LayoutRendererV1/LayoutRenderer.styles.d.ts +3 -3
  278. package/lib/components/LayoutRendererV2/LayoutRenderer.styles.d.ts +3 -3
  279. package/lib/components/LoaderDots/LoaderDots.d.ts +1 -1
  280. package/lib/components/LoaderDots/LoaderDots.js +3 -1
  281. package/lib/components/LoaderDots/LoaderDots.js.map +1 -1
  282. package/lib/components/LoaderDots/LoaderDots.mjs +3 -1
  283. package/lib/components/LoaderDots/LoaderDots.mjs.map +1 -1
  284. package/lib/components/LoaderDots/LoaderDots.styles.d.ts +2 -1
  285. package/lib/components/LoaderDots/LoaderDots.styles.js +11 -1
  286. package/lib/components/LoaderDots/LoaderDots.styles.js.map +1 -1
  287. package/lib/components/LoaderDots/LoaderDots.styles.mjs +11 -1
  288. package/lib/components/LoaderDots/LoaderDots.styles.mjs.map +1 -1
  289. package/lib/components/LoaderDots/LoaderDots.types.d.ts +2 -0
  290. package/lib/components/MeetUniFiVideoPlayer/MeetUniFiVideoPlayer.js +4 -4
  291. package/lib/components/MeetUniFiVideoPlayer/MeetUniFiVideoPlayer.js.map +1 -1
  292. package/lib/components/MeetUniFiVideoPlayer/MeetUniFiVideoPlayer.mjs +4 -4
  293. package/lib/components/MeetUniFiVideoPlayer/MeetUniFiVideoPlayer.mjs.map +1 -1
  294. package/lib/components/MeetUniFiVideoPlayer/MeetUniFiVideoPlayer.styles.d.ts +1 -1
  295. package/lib/components/MicrositeHeader/MicrositeHeader.d.ts +2 -0
  296. package/lib/components/MicrositeHeader/MicrositeHeader.js +35 -0
  297. package/lib/components/MicrositeHeader/MicrositeHeader.js.map +1 -0
  298. package/lib/components/MicrositeHeader/MicrositeHeader.mjs +33 -0
  299. package/lib/components/MicrositeHeader/MicrositeHeader.mjs.map +1 -0
  300. package/lib/components/MicrositeHeader/MicrositeHeader.styles.d.ts +2 -0
  301. package/lib/components/MicrositeHeader/MicrositeHeader.styles.js +29 -0
  302. package/lib/components/MicrositeHeader/MicrositeHeader.styles.js.map +1 -0
  303. package/lib/components/MicrositeHeader/MicrositeHeader.styles.mjs +20 -0
  304. package/lib/components/MicrositeHeader/MicrositeHeader.styles.mjs.map +1 -0
  305. package/lib/components/MicrositeHeader/MicrositeHeader.types.d.ts +5 -0
  306. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.d.ts +2 -0
  307. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.js +185 -0
  308. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.js.map +1 -0
  309. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.mjs +176 -0
  310. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.mjs.map +1 -0
  311. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.styles.d.ts +52 -0
  312. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.styles.js +425 -0
  313. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.styles.js.map +1 -0
  314. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.styles.mjs +391 -0
  315. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.styles.mjs.map +1 -0
  316. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.types.d.ts +20 -0
  317. package/lib/components/MicrositeHeader/components/DropdownMenu/index.d.ts +1 -0
  318. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.d.ts +2 -0
  319. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.js +209 -0
  320. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.js.map +1 -0
  321. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.mjs +198 -0
  322. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.mjs.map +1 -0
  323. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.styles.d.ts +22 -0
  324. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.styles.js +148 -0
  325. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.styles.js.map +1 -0
  326. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.styles.mjs +126 -0
  327. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.styles.mjs.map +1 -0
  328. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.types.d.ts +10 -0
  329. package/lib/components/MicrositeHeader/components/FirstLevelMenu/index.d.ts +1 -0
  330. package/lib/components/MicrositeHeader/components/FirstLevelMenu/index.js +6 -0
  331. package/lib/components/MicrositeHeader/components/FirstLevelMenu/index.js.map +1 -0
  332. package/lib/components/MicrositeHeader/components/FirstLevelMenu/index.mjs +3 -0
  333. package/lib/components/MicrositeHeader/components/FirstLevelMenu/index.mjs.map +1 -0
  334. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.d.ts +2 -0
  335. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.js +71 -0
  336. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.js.map +1 -0
  337. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.mjs +69 -0
  338. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.mjs.map +1 -0
  339. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.styles.d.ts +13 -0
  340. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.styles.js +104 -0
  341. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.styles.js.map +1 -0
  342. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.styles.mjs +89 -0
  343. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.styles.mjs.map +1 -0
  344. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.types.d.ts +11 -0
  345. package/lib/components/MicrositeHeader/components/SecondLevelMenu/index.d.ts +1 -0
  346. package/lib/components/MicrositeHeader/components/SecondLevelMenu/index.js +6 -0
  347. package/lib/components/MicrositeHeader/components/SecondLevelMenu/index.js.map +1 -0
  348. package/lib/components/MicrositeHeader/components/SecondLevelMenu/index.mjs +3 -0
  349. package/lib/components/MicrositeHeader/components/SecondLevelMenu/index.mjs.map +1 -0
  350. package/lib/components/MicrositeHeader/components/SiteMapColumns/SiteMapColumns.d.ts +17 -0
  351. package/lib/components/MicrositeHeader/components/SiteMapColumns/SiteMapColumns.styles.d.ts +13 -0
  352. package/lib/components/MicrositeHeader/components/SiteMapColumns/index.d.ts +1 -0
  353. package/lib/components/MicrositeHeader/index.d.ts +1 -0
  354. package/lib/components/MicrositeHeader/index.js +6 -0
  355. package/lib/components/MicrositeHeader/index.js.map +1 -0
  356. package/lib/components/MicrositeHeader/index.mjs +3 -0
  357. package/lib/components/MicrositeHeader/index.mjs.map +1 -0
  358. package/lib/components/MicrositeHero/MicrositeHero.js +2 -2
  359. package/lib/components/MicrositeHero/MicrositeHero.js.map +1 -1
  360. package/lib/components/MicrositeHero/MicrositeHero.mjs +2 -2
  361. package/lib/components/MicrositeHero/MicrositeHero.mjs.map +1 -1
  362. package/lib/components/MicrositeSectionWrap/MicrositeSectionWrap.styles.d.ts +1 -1
  363. package/lib/components/MicrositeVideoSlideshow/MicrositeVideoSlideshow.js +1 -1
  364. package/lib/components/MicrositeVideoSlideshow/MicrositeVideoSlideshow.mjs +1 -1
  365. package/lib/components/MicrositeVideoSlideshow/assets/pause.svg.js +1 -1
  366. package/lib/components/MicrositeVideoSlideshow/assets/pause.svg.mjs +2 -2
  367. package/lib/components/Microsites/Microsites.types.js.map +1 -1
  368. package/lib/components/Microsites/Microsites.types.mjs.map +1 -1
  369. package/lib/components/MobileModal/MobileModal.js +1 -1
  370. package/lib/components/MobileModal/MobileModal.js.map +1 -1
  371. package/lib/components/MobileModal/MobileModal.mjs +1 -1
  372. package/lib/components/MobileModal/MobileModal.mjs.map +1 -1
  373. package/lib/components/ModelCompareV3/ModelComparePropertyValueGridItem.js +37 -26
  374. package/lib/components/ModelCompareV3/ModelComparePropertyValueGridItem.js.map +1 -1
  375. package/lib/components/ModelCompareV3/ModelComparePropertyValueGridItem.mjs +37 -26
  376. package/lib/components/ModelCompareV3/ModelComparePropertyValueGridItem.mjs.map +1 -1
  377. package/lib/components/ModelCompareV3/ModelCompareV3.types.d.ts +5 -1
  378. package/lib/components/ModelCompareV3/StickyGrid/StickyGridItem.js +16 -8
  379. package/lib/components/ModelCompareV3/StickyGrid/StickyGridItem.js.map +1 -1
  380. package/lib/components/ModelCompareV3/StickyGrid/StickyGridItem.mjs +16 -8
  381. package/lib/components/ModelCompareV3/StickyGrid/StickyGridItem.mjs.map +1 -1
  382. package/lib/components/ModelCompareV3/StickyGrid/context.d.ts +3 -3
  383. package/lib/components/ModelCompareV3/StickyGrid/context.js.map +1 -1
  384. package/lib/components/ModelCompareV3/StickyGrid/context.mjs.map +1 -1
  385. package/lib/components/ModelCompareV3/assets/Switching/industrial.jpg.js +1 -1
  386. package/lib/components/ModelCompareV3/assets/Switching/industrial.jpg.mjs +2 -2
  387. package/lib/{assets/icons/menu/icon-globe.svg.js → components/ModelCompareV3/assets/WiFi/flagship.jpg.js} +6 -6
  388. package/lib/components/ModelCompareV3/assets/WiFi/flagship.jpg.js.map +1 -0
  389. package/lib/components/ModelCompareV3/assets/WiFi/flagship.jpg.mjs +3 -0
  390. package/lib/components/ModelCompareV3/assets/WiFi/flagship.jpg.mjs.map +1 -0
  391. package/lib/components/ModelCompareV3/assets/WiFi/flexible-outdoor.jpg.js +27 -0
  392. package/lib/components/ModelCompareV3/assets/WiFi/flexible-outdoor.jpg.js.map +1 -0
  393. package/lib/components/ModelCompareV3/assets/WiFi/flexible-outdoor.jpg.mjs +3 -0
  394. package/lib/components/ModelCompareV3/assets/WiFi/flexible-outdoor.jpg.mjs.map +1 -0
  395. package/lib/components/ModelCompareV3/assets/WiFi/mega-capacity.jpg.js +27 -0
  396. package/lib/components/ModelCompareV3/assets/WiFi/mega-capacity.jpg.js.map +1 -0
  397. package/lib/components/ModelCompareV3/assets/WiFi/mega-capacity.jpg.mjs +3 -0
  398. package/lib/components/ModelCompareV3/assets/WiFi/mega-capacity.jpg.mjs.map +1 -0
  399. package/lib/components/ModelCompareV3/assets/WiFi/wall.jpg.js +27 -0
  400. package/lib/components/ModelCompareV3/assets/WiFi/wall.jpg.js.map +1 -0
  401. package/lib/components/ModelCompareV3/assets/WiFi/wall.jpg.mjs +3 -0
  402. package/lib/components/ModelCompareV3/assets/WiFi/wall.jpg.mjs.map +1 -0
  403. package/lib/components/ModelCompareV3/assets/port.svg.js +1 -1
  404. package/lib/components/ModelCompareV3/assets/port.svg.mjs +2 -2
  405. package/lib/components/ModelCompareV3/data/Ptz.d.ts +2 -0
  406. package/lib/components/ModelCompareV3/data/Ptz.js +13 -0
  407. package/lib/components/ModelCompareV3/data/Ptz.js.map +1 -0
  408. package/lib/components/ModelCompareV3/data/Ptz.mjs +11 -0
  409. package/lib/components/ModelCompareV3/data/Ptz.mjs.map +1 -0
  410. package/lib/components/ModelCompareV3/data/WiFi.d.ts +2 -0
  411. package/lib/components/ModelCompareV3/data/WiFi.js +23 -0
  412. package/lib/components/ModelCompareV3/data/WiFi.js.map +1 -0
  413. package/lib/components/ModelCompareV3/data/WiFi.mjs +21 -0
  414. package/lib/components/ModelCompareV3/data/WiFi.mjs.map +1 -0
  415. package/lib/components/ModelCompareV3/data/index.d.ts +50 -48
  416. package/lib/components/ModelCompareV3/data/index.js +102 -96
  417. package/lib/components/ModelCompareV3/data/index.js.map +1 -1
  418. package/lib/components/ModelCompareV3/data/index.mjs +102 -96
  419. package/lib/components/ModelCompareV3/data/index.mjs.map +1 -1
  420. package/lib/components/ModelCompareV3/data/products/cloudKeyEnterprise.js +4 -2
  421. package/lib/components/ModelCompareV3/data/products/cloudKeyEnterprise.js.map +1 -1
  422. package/lib/components/ModelCompareV3/data/products/cloudKeyEnterprise.mjs +4 -2
  423. package/lib/components/ModelCompareV3/data/products/cloudKeyEnterprise.mjs.map +1 -1
  424. package/lib/components/ModelCompareV3/data/products/cloudKeyG2Plus.js +2 -2
  425. package/lib/components/ModelCompareV3/data/products/cloudKeyG2Plus.js.map +1 -1
  426. package/lib/components/ModelCompareV3/data/products/cloudKeyG2Plus.mjs +2 -2
  427. package/lib/components/ModelCompareV3/data/products/cloudKeyG2Plus.mjs.map +1 -1
  428. package/lib/components/ModelCompareV3/data/products/express.js +3 -3
  429. package/lib/components/ModelCompareV3/data/products/express.js.map +1 -1
  430. package/lib/components/ModelCompareV3/data/products/express.mjs +3 -3
  431. package/lib/components/ModelCompareV3/data/products/express.mjs.map +1 -1
  432. package/lib/components/ModelCompareV3/data/products/gatewayEnterprise.js +4 -2
  433. package/lib/components/ModelCompareV3/data/products/gatewayEnterprise.js.map +1 -1
  434. package/lib/components/ModelCompareV3/data/products/gatewayEnterprise.mjs +4 -2
  435. package/lib/components/ModelCompareV3/data/products/gatewayEnterprise.mjs.map +1 -1
  436. package/lib/components/ModelCompareV3/data/products/gatewayLite.js +4 -2
  437. package/lib/components/ModelCompareV3/data/products/gatewayLite.js.map +1 -1
  438. package/lib/components/ModelCompareV3/data/products/gatewayLite.mjs +4 -2
  439. package/lib/components/ModelCompareV3/data/products/gatewayLite.mjs.map +1 -1
  440. package/lib/components/ModelCompareV3/data/products/gatewayMax.js +4 -2
  441. package/lib/components/ModelCompareV3/data/products/gatewayMax.js.map +1 -1
  442. package/lib/components/ModelCompareV3/data/products/gatewayMax.mjs +4 -2
  443. package/lib/components/ModelCompareV3/data/products/gatewayMax.mjs.map +1 -1
  444. package/lib/components/ModelCompareV3/data/products/gatewayProfessional.js +4 -2
  445. package/lib/components/ModelCompareV3/data/products/gatewayProfessional.js.map +1 -1
  446. package/lib/components/ModelCompareV3/data/products/gatewayProfessional.mjs +4 -2
  447. package/lib/components/ModelCompareV3/data/products/gatewayProfessional.mjs.map +1 -1
  448. package/lib/components/ModelCompareV3/data/products/industrial.js +1 -1
  449. package/lib/components/ModelCompareV3/data/products/industrial.mjs +1 -1
  450. package/lib/components/ModelCompareV3/data/products/officialUniFiHosting.js +3 -1
  451. package/lib/components/ModelCompareV3/data/products/officialUniFiHosting.js.map +1 -1
  452. package/lib/components/ModelCompareV3/data/products/officialUniFiHosting.mjs +3 -1
  453. package/lib/components/ModelCompareV3/data/products/officialUniFiHosting.mjs.map +1 -1
  454. package/lib/components/ModelCompareV3/data/products/ucgMax.js +1 -1
  455. package/lib/components/ModelCompareV3/data/products/ucgMax.js.map +1 -1
  456. package/lib/components/ModelCompareV3/data/products/ucgMax.mjs +1 -1
  457. package/lib/components/ModelCompareV3/data/products/ucgMax.mjs.map +1 -1
  458. package/lib/components/ModelCompareV3/data/products/ucgUltra.js +3 -3
  459. package/lib/components/ModelCompareV3/data/products/ucgUltra.js.map +1 -1
  460. package/lib/components/ModelCompareV3/data/products/ucgUltra.mjs +3 -3
  461. package/lib/components/ModelCompareV3/data/products/ucgUltra.mjs.map +1 -1
  462. package/lib/components/ModelCompareV3/data/products/udmPro.js +3 -3
  463. package/lib/components/ModelCompareV3/data/products/udmPro.js.map +1 -1
  464. package/lib/components/ModelCompareV3/data/products/udmPro.mjs +3 -3
  465. package/lib/components/ModelCompareV3/data/products/udmPro.mjs.map +1 -1
  466. package/lib/components/ModelCompareV3/data/products/udmProMax.js +3 -3
  467. package/lib/components/ModelCompareV3/data/products/udmProMax.js.map +1 -1
  468. package/lib/components/ModelCompareV3/data/products/udmProMax.mjs +3 -3
  469. package/lib/components/ModelCompareV3/data/products/udmProMax.mjs.map +1 -1
  470. package/lib/components/ModelCompareV3/data/products/udmProSpecial.js +3 -3
  471. package/lib/components/ModelCompareV3/data/products/udmProSpecial.js.map +1 -1
  472. package/lib/components/ModelCompareV3/data/products/udmProSpecial.mjs +3 -3
  473. package/lib/components/ModelCompareV3/data/products/udmProSpecial.mjs.map +1 -1
  474. package/lib/components/ModelCompareV3/data/products/udr.js +5 -41
  475. package/lib/components/ModelCompareV3/data/products/udr.js.map +1 -1
  476. package/lib/components/ModelCompareV3/data/products/udr.mjs +5 -21
  477. package/lib/components/ModelCompareV3/data/products/udr.mjs.map +1 -1
  478. package/lib/components/ModelCompareV3/data/products/udw.js +4 -3
  479. package/lib/components/ModelCompareV3/data/products/udw.js.map +1 -1
  480. package/lib/components/ModelCompareV3/data/products/udw.mjs +4 -3
  481. package/lib/components/ModelCompareV3/data/products/udw.mjs.map +1 -1
  482. package/lib/components/ModelCompareV3/data/products/wifiFlagship.d.ts +2 -0
  483. package/lib/components/ModelCompareV3/data/products/wifiFlagship.js +70 -0
  484. package/lib/components/ModelCompareV3/data/products/wifiFlagship.js.map +1 -0
  485. package/lib/components/ModelCompareV3/data/products/wifiFlagship.mjs +62 -0
  486. package/lib/components/ModelCompareV3/data/products/wifiFlagship.mjs.map +1 -0
  487. package/lib/components/ModelCompareV3/data/products/wifiFlexibleOutdoor.d.ts +2 -0
  488. package/lib/components/ModelCompareV3/data/products/wifiFlexibleOutdoor.js +73 -0
  489. package/lib/components/ModelCompareV3/data/products/wifiFlexibleOutdoor.js.map +1 -0
  490. package/lib/components/ModelCompareV3/data/products/wifiFlexibleOutdoor.mjs +65 -0
  491. package/lib/components/ModelCompareV3/data/products/wifiFlexibleOutdoor.mjs.map +1 -0
  492. package/lib/components/ModelCompareV3/data/products/wifiMegaCapacity.d.ts +2 -0
  493. package/lib/components/ModelCompareV3/data/products/wifiMegaCapacity.js +73 -0
  494. package/lib/components/ModelCompareV3/data/products/wifiMegaCapacity.js.map +1 -0
  495. package/lib/components/ModelCompareV3/data/products/wifiMegaCapacity.mjs +65 -0
  496. package/lib/components/ModelCompareV3/data/products/wifiMegaCapacity.mjs.map +1 -0
  497. package/lib/components/ModelCompareV3/data/products/wifiWall.d.ts +2 -0
  498. package/lib/components/ModelCompareV3/data/products/wifiWall.js +74 -0
  499. package/lib/components/ModelCompareV3/data/products/wifiWall.js.map +1 -0
  500. package/lib/components/ModelCompareV3/data/products/wifiWall.mjs +66 -0
  501. package/lib/components/ModelCompareV3/data/products/wifiWall.mjs.map +1 -0
  502. package/lib/components/ModelCompareV3/data/properties/redundantRj45Port.js +1 -1
  503. package/lib/components/ModelCompareV3/data/properties/redundantRj45Port.mjs +1 -1
  504. package/lib/components/ModelCompareV3/translations/ar.json.js +1 -1
  505. package/lib/components/ModelCompareV3/translations/ar.json.mjs +1 -1
  506. package/lib/components/ModelCompareV3/translations/de.json.js +1 -1
  507. package/lib/components/ModelCompareV3/translations/de.json.mjs +1 -1
  508. package/lib/components/ModelCompareV3/translations/el.json.js +1 -1
  509. package/lib/components/ModelCompareV3/translations/el.json.mjs +1 -1
  510. package/lib/components/ModelCompareV3/translations/en.json.js +61 -6
  511. package/lib/components/ModelCompareV3/translations/en.json.js.map +1 -1
  512. package/lib/components/ModelCompareV3/translations/en.json.mjs +61 -6
  513. package/lib/components/ModelCompareV3/translations/en.json.mjs.map +1 -1
  514. package/lib/components/ModelCompareV3/translations/es.json.js +1 -1
  515. package/lib/components/ModelCompareV3/translations/es.json.mjs +1 -1
  516. package/lib/components/ModelCompareV3/translations/fr.json.js +1 -1
  517. package/lib/components/ModelCompareV3/translations/fr.json.mjs +1 -1
  518. package/lib/components/ModelCompareV3/translations/it.json.js +1 -1
  519. package/lib/components/ModelCompareV3/translations/it.json.mjs +1 -1
  520. package/lib/components/ModelCompareV3/translations/ja.json.js +1 -1
  521. package/lib/components/ModelCompareV3/translations/ja.json.mjs +1 -1
  522. package/lib/components/ModelCompareV3/translations/pt-BR.json.js +1 -1
  523. package/lib/components/ModelCompareV3/translations/pt-BR.json.mjs +1 -1
  524. package/lib/components/ModelCompareV3/translations/useModelCompareTranslation.d.ts +2 -2
  525. package/lib/components/ModelCompareV3/translations/zh-Hans.json.js +1 -1
  526. package/lib/components/ModelCompareV3/translations/zh-Hans.json.mjs +1 -1
  527. package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.js +1 -1
  528. package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.mjs +1 -1
  529. package/lib/components/PriceRangeSlider/PriceRangeSlider.types.d.ts +2 -2
  530. package/lib/components/PriceRangeSlider/PriceRangeSlider.types.js.map +1 -1
  531. package/lib/components/PriceRangeSlider/PriceRangeSlider.types.mjs.map +1 -1
  532. package/lib/components/ProductCard/ProductCard.js +1 -1
  533. package/lib/components/ProductCard/ProductCard.js.map +1 -1
  534. package/lib/components/ProductCard/ProductCard.mjs +2 -2
  535. package/lib/components/ProductCard/ProductCard.mjs.map +1 -1
  536. package/lib/components/ProductCardPopup/ProductCardPopup.js +2 -2
  537. package/lib/components/ProductCardPopup/ProductCardPopup.js.map +1 -1
  538. package/lib/components/ProductCardPopup/ProductCardPopup.mjs +2 -2
  539. package/lib/components/ProductCardPopup/ProductCardPopup.mjs.map +1 -1
  540. package/lib/components/ProductSectionNavigation/ProductSectionNavigation.styles.d.ts +1 -1
  541. package/lib/components/ProductSectionNavigationV2/ProductSectionNavigation.styles.d.ts +1 -1
  542. package/lib/components/ProductSectionTabs/ProductSectionTabs.js +6 -1
  543. package/lib/components/ProductSectionTabs/ProductSectionTabs.js.map +1 -1
  544. package/lib/components/ProductSectionTabs/ProductSectionTabs.mjs +6 -1
  545. package/lib/components/ProductSectionTabs/ProductSectionTabs.mjs.map +1 -1
  546. package/lib/components/ProductTechSpecs/ProductTechSpecs.styles.d.ts +2 -2
  547. package/lib/components/ProductWizard/ProductWizard.js +3 -3
  548. package/lib/components/ProductWizard/ProductWizard.js.map +1 -1
  549. package/lib/components/ProductWizard/ProductWizard.mjs +3 -3
  550. package/lib/components/ProductWizard/ProductWizard.mjs.map +1 -1
  551. package/lib/components/ProductWizardFootnotes/ProductWizardFootnotes.js +17 -4
  552. package/lib/components/ProductWizardFootnotes/ProductWizardFootnotes.js.map +1 -1
  553. package/lib/components/ProductWizardFootnotes/ProductWizardFootnotes.mjs +17 -4
  554. package/lib/components/ProductWizardFootnotes/ProductWizardFootnotes.mjs.map +1 -1
  555. package/lib/components/QuantityControls/QuantityControls.js +2 -2
  556. package/lib/components/QuantityControls/QuantityControls.js.map +1 -1
  557. package/lib/components/QuantityControls/QuantityControls.mjs +2 -2
  558. package/lib/components/QuantityControls/QuantityControls.mjs.map +1 -1
  559. package/lib/components/QuantityControls/QuantityControls.types.d.ts +1 -1
  560. package/lib/components/QuantityInput/QuantityInput.js +6 -1
  561. package/lib/components/QuantityInput/QuantityInput.js.map +1 -1
  562. package/lib/components/QuantityInput/QuantityInput.mjs +6 -1
  563. package/lib/components/QuantityInput/QuantityInput.mjs.map +1 -1
  564. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.js +4 -4
  565. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.js.map +1 -1
  566. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.mjs +4 -4
  567. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.mjs.map +1 -1
  568. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js +1 -1
  569. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs +1 -1
  570. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.js +1 -1
  571. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.mjs +2 -2
  572. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.js +1 -1
  573. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.mjs +1 -1
  574. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.js +1 -1
  575. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.mjs +2 -2
  576. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/RecommendedPoeSwitches.js +1 -1
  577. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/RecommendedPoeSwitches.mjs +1 -1
  578. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/assets/port.svg.js +1 -1
  579. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/assets/port.svg.mjs +2 -2
  580. package/lib/components/ScrollWrapper/ScrollWrapper.d.ts +1 -1
  581. package/lib/components/ScrollWrapper/ScrollWrapper.js +16 -8
  582. package/lib/components/ScrollWrapper/ScrollWrapper.js.map +1 -1
  583. package/lib/components/ScrollWrapper/ScrollWrapper.mjs +16 -8
  584. package/lib/components/ScrollWrapper/ScrollWrapper.mjs.map +1 -1
  585. package/lib/components/ScrollWrapper/ScrollWrapper.styles.js +87 -64
  586. package/lib/components/ScrollWrapper/ScrollWrapper.styles.js.map +1 -1
  587. package/lib/components/ScrollWrapper/ScrollWrapper.styles.mjs +87 -64
  588. package/lib/components/ScrollWrapper/ScrollWrapper.styles.mjs.map +1 -1
  589. package/lib/components/ScrollWrapper/ScrollWrapper.types.d.ts +2 -0
  590. package/lib/components/Search/Input/Input.d.ts +1 -1
  591. package/lib/components/Search/Input/Input.js +4 -4
  592. package/lib/components/Search/Input/Input.js.map +1 -1
  593. package/lib/components/Search/Input/Input.mjs +4 -4
  594. package/lib/components/Search/Input/Input.mjs.map +1 -1
  595. package/lib/components/Search/Input/Input.styles.js +0 -1
  596. package/lib/components/Search/Input/Input.styles.js.map +1 -1
  597. package/lib/components/Search/Input/Input.styles.mjs +0 -1
  598. package/lib/components/Search/Input/Input.styles.mjs.map +1 -1
  599. package/lib/components/Search/Input/Input.types.d.ts +3 -2
  600. package/lib/components/StorageSliders/StorageSliders.context.js +17 -14
  601. package/lib/components/StorageSliders/StorageSliders.context.js.map +1 -1
  602. package/lib/components/StorageSliders/StorageSliders.context.mjs +17 -14
  603. package/lib/components/StorageSliders/StorageSliders.context.mjs.map +1 -1
  604. package/lib/components/StorybookUtils/StoryFaker.js.map +1 -1
  605. package/lib/components/StorybookUtils/StoryFaker.mjs.map +1 -1
  606. package/lib/components/VariantSelector/VariantSelector.js +4 -4
  607. package/lib/components/VariantSelector/VariantSelector.js.map +1 -1
  608. package/lib/components/VariantSelector/VariantSelector.mjs +4 -4
  609. package/lib/components/VariantSelector/VariantSelector.mjs.map +1 -1
  610. package/lib/components/VideoPlayerNew/VideoPlayer.js +13 -15
  611. package/lib/components/VideoPlayerNew/VideoPlayer.js.map +1 -1
  612. package/lib/components/VideoPlayerNew/VideoPlayer.mjs +13 -15
  613. package/lib/components/VideoPlayerNew/VideoPlayer.mjs.map +1 -1
  614. package/lib/components/VideoPlayerNew/assets/pause.svg.js +1 -1
  615. package/lib/components/VideoPlayerNew/assets/pause.svg.mjs +2 -2
  616. package/lib/components/index.d.ts +1 -0
  617. package/lib/components/index.js +32 -30
  618. package/lib/components/index.js.map +1 -1
  619. package/lib/components/index.mjs +32 -30
  620. package/lib/components/index.mjs.map +1 -1
  621. package/lib/constants/address.d.ts +1 -1
  622. package/lib/constants/address.js +34 -34
  623. package/lib/constants/address.js.map +1 -1
  624. package/lib/constants/address.mjs +34 -34
  625. package/lib/constants/address.mjs.map +1 -1
  626. package/lib/constants/icons/generic/carouselArrowRight.svg.js +5 -5
  627. package/lib/constants/icons/generic/index.js +6 -6
  628. package/lib/constants/icons/generic/index.mjs +1 -1
  629. package/lib/constants/icons/generic/plus.svg.js +5 -5
  630. package/lib/constants/icons/generic/plus.svg.mjs +2 -2
  631. package/lib/constants/icons/header/account.svg.js +5 -5
  632. package/lib/constants/icons/header/globe.svg.js +5 -5
  633. package/lib/constants/icons/header/index.js +9 -9
  634. package/lib/constants/icons/header/logoUnifi.svg.js +5 -5
  635. package/lib/constants/icons/menu/consolidatedSpecialDevices.svg.js +27 -0
  636. package/lib/constants/icons/menu/consolidatedSpecialDevices.svg.js.map +1 -0
  637. package/lib/constants/icons/menu/consolidatedSpecialDevices.svg.mjs +3 -0
  638. package/lib/constants/icons/menu/consolidatedSpecialDevices.svg.mjs.map +1 -0
  639. package/lib/constants/icons/menu/doorAccess.svg.js +27 -0
  640. package/lib/constants/icons/menu/doorAccess.svg.js.map +1 -0
  641. package/lib/constants/icons/menu/doorAccess.svg.mjs +3 -0
  642. package/lib/constants/icons/menu/doorAccess.svg.mjs.map +1 -0
  643. package/lib/constants/icons/menu/index.d.ts +3 -0
  644. package/lib/constants/icons/menu/index.js +27 -0
  645. package/lib/constants/icons/menu/index.js.map +1 -1
  646. package/lib/constants/icons/menu/index.mjs +6 -0
  647. package/lib/constants/icons/menu/index.mjs.map +1 -1
  648. package/lib/constants/icons/menu/overview.svg.js +27 -0
  649. package/lib/constants/icons/menu/overview.svg.js.map +1 -0
  650. package/lib/constants/icons/menu/overview.svg.mjs +3 -0
  651. package/lib/constants/icons/menu/overview.svg.mjs.map +1 -0
  652. package/lib/constants/icons/options/colors/black.svg.js +5 -5
  653. package/lib/constants/icons/options/colors/index.js +3 -3
  654. package/lib/constants/icons/options/styles/black.svg.js +5 -5
  655. package/lib/constants/icons/options/styles/index.js +3 -3
  656. package/lib/constants/optionIcons.js +6 -6
  657. package/lib/constants/optionIcons.mjs +4 -4
  658. package/lib/constants/postalCode.js +10 -10
  659. package/lib/constants/postalCode.js.map +1 -1
  660. package/lib/constants/postalCode.mjs +10 -10
  661. package/lib/constants/postalCode.mjs.map +1 -1
  662. package/lib/constants/proStoreCategories/mapping/filters.d.ts +16 -0
  663. package/lib/constants/proStoreCategories/mapping/filters.js +16 -0
  664. package/lib/constants/proStoreCategories/mapping/filters.js.map +1 -1
  665. package/lib/constants/proStoreCategories/mapping/filters.mjs +16 -0
  666. package/lib/constants/proStoreCategories/mapping/filters.mjs.map +1 -1
  667. package/lib/constants/proStoreCategories/mapping/index.d.ts +4 -2
  668. package/lib/constants/proStoreCategories/mapping/index.js +50 -51
  669. package/lib/constants/proStoreCategories/mapping/index.js.map +1 -1
  670. package/lib/constants/proStoreCategories/mapping/index.mjs +49 -49
  671. package/lib/constants/proStoreCategories/mapping/index.mjs.map +1 -1
  672. package/lib/constants/proStoreCategories/mapping/mapping.d.ts +5 -0
  673. package/lib/constants/proStoreCategories/mapping/redirects.js +18 -3
  674. package/lib/constants/proStoreCategories/mapping/redirects.js.map +1 -1
  675. package/lib/constants/proStoreCategories/mapping/redirects.mjs +18 -3
  676. package/lib/constants/proStoreCategories/mapping/redirects.mjs.map +1 -1
  677. package/lib/constants/proStoreCategories/mapping/unifi.d.ts +9 -9
  678. package/lib/constants/proStoreCategories/mapping/unifi.js +9 -9
  679. package/lib/constants/proStoreCategories/mapping/unifi.js.map +1 -1
  680. package/lib/constants/proStoreCategories/mapping/unifi.mjs +9 -9
  681. package/lib/constants/proStoreCategories/mapping/unifi.mjs.map +1 -1
  682. package/lib/constants/proStoreCategories/translations/ar.json.js +7 -3
  683. package/lib/constants/proStoreCategories/translations/ar.json.js.map +1 -1
  684. package/lib/constants/proStoreCategories/translations/ar.json.mjs +7 -4
  685. package/lib/constants/proStoreCategories/translations/ar.json.mjs.map +1 -1
  686. package/lib/constants/proStoreCategories/translations/de.json.js +7 -3
  687. package/lib/constants/proStoreCategories/translations/de.json.js.map +1 -1
  688. package/lib/constants/proStoreCategories/translations/de.json.mjs +7 -4
  689. package/lib/constants/proStoreCategories/translations/de.json.mjs.map +1 -1
  690. package/lib/constants/proStoreCategories/translations/el.json.js +7 -3
  691. package/lib/constants/proStoreCategories/translations/el.json.js.map +1 -1
  692. package/lib/constants/proStoreCategories/translations/el.json.mjs +7 -4
  693. package/lib/constants/proStoreCategories/translations/el.json.mjs.map +1 -1
  694. package/lib/constants/proStoreCategories/translations/en.json.js +7 -3
  695. package/lib/constants/proStoreCategories/translations/en.json.js.map +1 -1
  696. package/lib/constants/proStoreCategories/translations/en.json.mjs +7 -4
  697. package/lib/constants/proStoreCategories/translations/en.json.mjs.map +1 -1
  698. package/lib/constants/proStoreCategories/translations/es.json.js +7 -3
  699. package/lib/constants/proStoreCategories/translations/es.json.js.map +1 -1
  700. package/lib/constants/proStoreCategories/translations/es.json.mjs +7 -4
  701. package/lib/constants/proStoreCategories/translations/es.json.mjs.map +1 -1
  702. package/lib/constants/proStoreCategories/translations/fr.json.js +7 -3
  703. package/lib/constants/proStoreCategories/translations/fr.json.js.map +1 -1
  704. package/lib/constants/proStoreCategories/translations/fr.json.mjs +7 -4
  705. package/lib/constants/proStoreCategories/translations/fr.json.mjs.map +1 -1
  706. package/lib/constants/proStoreCategories/translations/it.json.js +7 -3
  707. package/lib/constants/proStoreCategories/translations/it.json.js.map +1 -1
  708. package/lib/constants/proStoreCategories/translations/it.json.mjs +7 -4
  709. package/lib/constants/proStoreCategories/translations/it.json.mjs.map +1 -1
  710. package/lib/constants/proStoreCategories/translations/ja.json.js +7 -3
  711. package/lib/constants/proStoreCategories/translations/ja.json.js.map +1 -1
  712. package/lib/constants/proStoreCategories/translations/ja.json.mjs +7 -4
  713. package/lib/constants/proStoreCategories/translations/ja.json.mjs.map +1 -1
  714. package/lib/constants/proStoreCategories/translations/pt-BR.json.js +7 -3
  715. package/lib/constants/proStoreCategories/translations/pt-BR.json.js.map +1 -1
  716. package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs +7 -4
  717. package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs.map +1 -1
  718. package/lib/constants/proStoreCategories/translations/zh-Hans.json.js +7 -3
  719. package/lib/constants/proStoreCategories/translations/zh-Hans.json.js.map +1 -1
  720. package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs +7 -4
  721. package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs.map +1 -1
  722. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js +7 -3
  723. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js.map +1 -1
  724. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs +7 -4
  725. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs.map +1 -1
  726. package/lib/constants/proStoreFilters/mapping.d.ts +45 -3
  727. package/lib/constants/proStoreFilters/mapping.js +119 -9
  728. package/lib/constants/proStoreFilters/mapping.js.map +1 -1
  729. package/lib/constants/proStoreFilters/mapping.mjs +119 -9
  730. package/lib/constants/proStoreFilters/mapping.mjs.map +1 -1
  731. package/lib/constants/theme.js +4 -0
  732. package/lib/constants/theme.js.map +1 -1
  733. package/lib/constants/theme.mjs +4 -0
  734. package/lib/constants/theme.mjs.map +1 -1
  735. package/lib/contexts/MenuContext/context.js +28 -27
  736. package/lib/contexts/MenuContext/context.js.map +1 -1
  737. package/lib/contexts/MenuContext/context.mjs +28 -27
  738. package/lib/contexts/MenuContext/context.mjs.map +1 -1
  739. package/lib/contexts/MenuContext/mapping.js.map +1 -1
  740. package/lib/contexts/MenuContext/mapping.mjs.map +1 -1
  741. package/lib/contexts/MenuContext/types.js.map +1 -1
  742. package/lib/contexts/MenuContext/types.mjs.map +1 -1
  743. package/lib/contexts/MenuContext/utils.d.ts +6 -1
  744. package/lib/contexts/MenuContext/utils.js +16 -0
  745. package/lib/contexts/MenuContext/utils.js.map +1 -1
  746. package/lib/contexts/MenuContext/utils.mjs +16 -1
  747. package/lib/contexts/MenuContext/utils.mjs.map +1 -1
  748. package/lib/contexts/MicrositeMenuContext/assets/education.jpg.js +27 -0
  749. package/lib/contexts/MicrositeMenuContext/assets/education.jpg.js.map +1 -0
  750. package/lib/contexts/MicrositeMenuContext/assets/education.jpg.mjs +3 -0
  751. package/lib/contexts/MicrositeMenuContext/assets/education.jpg.mjs.map +1 -0
  752. package/lib/contexts/MicrositeMenuContext/assets/enterprise.jpg.js +27 -0
  753. package/lib/contexts/MicrositeMenuContext/assets/enterprise.jpg.js.map +1 -0
  754. package/lib/contexts/MicrositeMenuContext/assets/enterprise.jpg.mjs +3 -0
  755. package/lib/contexts/MicrositeMenuContext/assets/enterprise.jpg.mjs.map +1 -0
  756. package/lib/contexts/MicrositeMenuContext/assets/hospitality.jpg.js +27 -0
  757. package/lib/contexts/MicrositeMenuContext/assets/hospitality.jpg.js.map +1 -0
  758. package/lib/contexts/MicrositeMenuContext/assets/hospitality.jpg.mjs +3 -0
  759. package/lib/contexts/MicrositeMenuContext/assets/hospitality.jpg.mjs.map +1 -0
  760. package/lib/contexts/MicrositeMenuContext/assets/how-it-works.jpg.js +27 -0
  761. package/lib/contexts/MicrositeMenuContext/assets/how-it-works.jpg.js.map +1 -0
  762. package/lib/contexts/MicrositeMenuContext/assets/how-it-works.jpg.mjs +3 -0
  763. package/lib/contexts/MicrositeMenuContext/assets/how-it-works.jpg.mjs.map +1 -0
  764. package/lib/contexts/MicrositeMenuContext/assets/index.d.ts +12 -0
  765. package/lib/contexts/MicrositeMenuContext/assets/index.js +16 -0
  766. package/lib/contexts/MicrositeMenuContext/assets/index.js.map +1 -0
  767. package/lib/contexts/MicrositeMenuContext/assets/index.mjs +14 -0
  768. package/lib/contexts/MicrositeMenuContext/assets/index.mjs.map +1 -0
  769. package/lib/contexts/MicrositeMenuContext/assets/industrial.jpg.js +27 -0
  770. package/lib/contexts/MicrositeMenuContext/assets/industrial.jpg.js.map +1 -0
  771. package/lib/contexts/MicrositeMenuContext/assets/industrial.jpg.mjs +3 -0
  772. package/lib/contexts/MicrositeMenuContext/assets/industrial.jpg.mjs.map +1 -0
  773. package/lib/contexts/MicrositeMenuContext/assets/nextai-camera.jpg.js +27 -0
  774. package/lib/contexts/MicrositeMenuContext/assets/nextai-camera.jpg.js.map +1 -0
  775. package/lib/contexts/MicrositeMenuContext/assets/nextai-camera.jpg.mjs +3 -0
  776. package/lib/contexts/MicrositeMenuContext/assets/nextai-camera.jpg.mjs.map +1 -0
  777. package/lib/contexts/MicrositeMenuContext/assets/nextai-cyber.jpg.js +27 -0
  778. package/lib/contexts/MicrositeMenuContext/assets/nextai-cyber.jpg.js.map +1 -0
  779. package/lib/contexts/MicrositeMenuContext/assets/nextai-cyber.jpg.mjs +3 -0
  780. package/lib/contexts/MicrositeMenuContext/assets/nextai-cyber.jpg.mjs.map +1 -0
  781. package/lib/contexts/MicrositeMenuContext/assets/retail.jpg.js +27 -0
  782. package/lib/contexts/MicrositeMenuContext/assets/retail.jpg.js.map +1 -0
  783. package/lib/contexts/MicrositeMenuContext/assets/retail.jpg.mjs +3 -0
  784. package/lib/contexts/MicrositeMenuContext/assets/retail.jpg.mjs.map +1 -0
  785. package/lib/contexts/MicrositeMenuContext/assets/sd-wan-sase.jpg.js +27 -0
  786. package/lib/contexts/MicrositeMenuContext/assets/sd-wan-sase.jpg.js.map +1 -0
  787. package/lib/contexts/MicrositeMenuContext/assets/sd-wan-sase.jpg.mjs +3 -0
  788. package/lib/contexts/MicrositeMenuContext/assets/sd-wan-sase.jpg.mjs.map +1 -0
  789. package/lib/contexts/MicrositeMenuContext/assets/site-manager.jpg.js +27 -0
  790. package/lib/contexts/MicrositeMenuContext/assets/site-manager.jpg.js.map +1 -0
  791. package/lib/contexts/MicrositeMenuContext/assets/site-manager.jpg.mjs +3 -0
  792. package/lib/contexts/MicrositeMenuContext/assets/site-manager.jpg.mjs.map +1 -0
  793. package/lib/contexts/MicrositeMenuContext/assets/stadium.jpg.js +27 -0
  794. package/lib/contexts/MicrositeMenuContext/assets/stadium.jpg.js.map +1 -0
  795. package/lib/contexts/MicrositeMenuContext/assets/stadium.jpg.mjs +3 -0
  796. package/lib/contexts/MicrositeMenuContext/assets/stadium.jpg.mjs.map +1 -0
  797. package/lib/contexts/MicrositeMenuContext/assets/tco-calculator.jpg.js +27 -0
  798. package/lib/contexts/MicrositeMenuContext/assets/tco-calculator.jpg.js.map +1 -0
  799. package/lib/contexts/MicrositeMenuContext/assets/tco-calculator.jpg.mjs +3 -0
  800. package/lib/contexts/MicrositeMenuContext/assets/tco-calculator.jpg.mjs.map +1 -0
  801. package/lib/contexts/MicrositeMenuContext/context.d.ts +36 -0
  802. package/lib/contexts/MicrositeMenuContext/context.js +100 -0
  803. package/lib/contexts/MicrositeMenuContext/context.js.map +1 -0
  804. package/lib/contexts/MicrositeMenuContext/context.mjs +96 -0
  805. package/lib/contexts/MicrositeMenuContext/context.mjs.map +1 -0
  806. package/lib/contexts/MicrositeMenuContext/index.d.ts +1 -0
  807. package/lib/contexts/MicrositeMenuContext/index.js +8 -0
  808. package/lib/contexts/MicrositeMenuContext/index.js.map +1 -0
  809. package/lib/contexts/MicrositeMenuContext/index.mjs +3 -0
  810. package/lib/contexts/MicrositeMenuContext/index.mjs.map +1 -0
  811. package/lib/contexts/MicrositeMenuContext/mapping.d.ts +8 -0
  812. package/lib/contexts/MicrositeMenuContext/mapping.js +513 -0
  813. package/lib/contexts/MicrositeMenuContext/mapping.js.map +1 -0
  814. package/lib/contexts/MicrositeMenuContext/mapping.mjs +468 -0
  815. package/lib/contexts/MicrositeMenuContext/mapping.mjs.map +1 -0
  816. package/lib/contexts/MicrositeMenuContext/translations/ar.json.js +8 -0
  817. package/lib/contexts/MicrositeMenuContext/translations/ar.json.js.map +1 -0
  818. package/lib/contexts/MicrositeMenuContext/translations/ar.json.mjs +3 -0
  819. package/lib/contexts/MicrositeMenuContext/translations/ar.json.mjs.map +1 -0
  820. package/lib/contexts/MicrositeMenuContext/translations/de.json.js +8 -0
  821. package/lib/contexts/MicrositeMenuContext/translations/de.json.js.map +1 -0
  822. package/lib/contexts/MicrositeMenuContext/translations/de.json.mjs +3 -0
  823. package/lib/contexts/MicrositeMenuContext/translations/de.json.mjs.map +1 -0
  824. package/lib/contexts/MicrositeMenuContext/translations/el.json.js +8 -0
  825. package/lib/contexts/MicrositeMenuContext/translations/el.json.js.map +1 -0
  826. package/lib/contexts/MicrositeMenuContext/translations/el.json.mjs +3 -0
  827. package/lib/contexts/MicrositeMenuContext/translations/el.json.mjs.map +1 -0
  828. package/lib/contexts/MicrositeMenuContext/translations/en.json.js +84 -0
  829. package/lib/contexts/MicrositeMenuContext/translations/en.json.js.map +1 -0
  830. package/lib/contexts/MicrositeMenuContext/translations/en.json.mjs +79 -0
  831. package/lib/contexts/MicrositeMenuContext/translations/en.json.mjs.map +1 -0
  832. package/lib/contexts/MicrositeMenuContext/translations/es.json.js +8 -0
  833. package/lib/contexts/MicrositeMenuContext/translations/es.json.js.map +1 -0
  834. package/lib/contexts/MicrositeMenuContext/translations/es.json.mjs +3 -0
  835. package/lib/contexts/MicrositeMenuContext/translations/es.json.mjs.map +1 -0
  836. package/lib/contexts/MicrositeMenuContext/translations/fr.json.js +8 -0
  837. package/lib/contexts/MicrositeMenuContext/translations/fr.json.js.map +1 -0
  838. package/lib/contexts/MicrositeMenuContext/translations/fr.json.mjs +3 -0
  839. package/lib/contexts/MicrositeMenuContext/translations/fr.json.mjs.map +1 -0
  840. package/lib/contexts/MicrositeMenuContext/translations/it.json.js +8 -0
  841. package/lib/contexts/MicrositeMenuContext/translations/it.json.js.map +1 -0
  842. package/lib/contexts/MicrositeMenuContext/translations/it.json.mjs +3 -0
  843. package/lib/contexts/MicrositeMenuContext/translations/it.json.mjs.map +1 -0
  844. package/lib/contexts/MicrositeMenuContext/translations/ja.json.js +8 -0
  845. package/lib/contexts/MicrositeMenuContext/translations/ja.json.js.map +1 -0
  846. package/lib/contexts/MicrositeMenuContext/translations/ja.json.mjs +3 -0
  847. package/lib/contexts/MicrositeMenuContext/translations/ja.json.mjs.map +1 -0
  848. package/lib/contexts/MicrositeMenuContext/translations/pt-BR.json.js +8 -0
  849. package/lib/contexts/MicrositeMenuContext/translations/pt-BR.json.js.map +1 -0
  850. package/lib/contexts/MicrositeMenuContext/translations/pt-BR.json.mjs +3 -0
  851. package/lib/contexts/MicrositeMenuContext/translations/pt-BR.json.mjs.map +1 -0
  852. package/lib/contexts/MicrositeMenuContext/translations/zh-Hans.json.js +8 -0
  853. package/lib/contexts/MicrositeMenuContext/translations/zh-Hans.json.js.map +1 -0
  854. package/lib/contexts/MicrositeMenuContext/translations/zh-Hans.json.mjs +3 -0
  855. package/lib/contexts/MicrositeMenuContext/translations/zh-Hans.json.mjs.map +1 -0
  856. package/lib/contexts/MicrositeMenuContext/translations/zh-Hant-TW.json.js +8 -0
  857. package/lib/contexts/MicrositeMenuContext/translations/zh-Hant-TW.json.js.map +1 -0
  858. package/lib/contexts/MicrositeMenuContext/translations/zh-Hant-TW.json.mjs +3 -0
  859. package/lib/contexts/MicrositeMenuContext/translations/zh-Hant-TW.json.mjs.map +1 -0
  860. package/lib/contexts/MicrositeMenuContext/translations.d.ts +7 -0
  861. package/lib/contexts/MicrositeMenuContext/translations.js +47 -0
  862. package/lib/contexts/MicrositeMenuContext/translations.js.map +1 -0
  863. package/lib/contexts/MicrositeMenuContext/translations.mjs +25 -0
  864. package/lib/contexts/MicrositeMenuContext/translations.mjs.map +1 -0
  865. package/lib/contexts/MicrositeMenuContext/types.d.ts +100 -0
  866. package/lib/contexts/MicrositeMenuContext/types.js +16 -0
  867. package/lib/contexts/MicrositeMenuContext/types.js.map +1 -0
  868. package/lib/contexts/MicrositeMenuContext/types.mjs +15 -0
  869. package/lib/contexts/MicrositeMenuContext/types.mjs.map +1 -0
  870. package/lib/contexts/index.d.ts +1 -0
  871. package/lib/contexts/index.js +2 -0
  872. package/lib/contexts/index.js.map +1 -1
  873. package/lib/contexts/index.mjs +2 -0
  874. package/lib/contexts/index.mjs.map +1 -1
  875. package/lib/helpers/ux.d.ts +8 -11
  876. package/lib/helpers/ux.js +15 -4
  877. package/lib/helpers/ux.js.map +1 -1
  878. package/lib/helpers/ux.mjs +15 -4
  879. package/lib/helpers/ux.mjs.map +1 -1
  880. package/lib/hooks/useScrollToY.js.map +1 -1
  881. package/lib/hooks/useScrollToY.mjs.map +1 -1
  882. package/lib/utils/collectionSlug.js +2 -2
  883. package/lib/utils/collectionSlug.js.map +1 -1
  884. package/lib/utils/collectionSlug.mjs +2 -2
  885. package/lib/utils/collectionSlug.mjs.map +1 -1
  886. package/lib/utils/errors.js.map +1 -1
  887. package/lib/utils/errors.mjs.map +1 -1
  888. package/lib/utils/measures.js +1 -0
  889. package/lib/utils/measures.js.map +1 -1
  890. package/lib/utils/measures.mjs +1 -0
  891. package/lib/utils/measures.mjs.map +1 -1
  892. package/lib/utils/money/format.js.map +1 -1
  893. package/lib/utils/money/format.mjs.map +1 -1
  894. package/lib/utils/money/misc.js +1 -1
  895. package/lib/utils/money/misc.js.map +1 -1
  896. package/lib/utils/money/misc.mjs +1 -1
  897. package/lib/utils/money/misc.mjs.map +1 -1
  898. package/lib/utils/nextjs/ssr/transform-css-module.js.map +1 -1
  899. package/lib/utils/nextjs/ssr/transform-css-module.mjs.map +1 -1
  900. package/lib/utils/number.js.map +1 -1
  901. package/lib/utils/number.mjs.map +1 -1
  902. package/lib/utils/product.js +4 -4
  903. package/lib/utils/product.js.map +1 -1
  904. package/lib/utils/product.mjs +4 -4
  905. package/lib/utils/product.mjs.map +1 -1
  906. package/lib/utils/tags.js +2 -2
  907. package/lib/utils/tags.js.map +1 -1
  908. package/lib/utils/tags.mjs +2 -2
  909. package/lib/utils/tags.mjs.map +1 -1
  910. package/package.json +1 -1
  911. package/lib/assets/icons/menu/icon-globe.svg.js.map +0 -1
  912. package/lib/assets/icons/menu/icon-globe.svg.mjs +0 -3
  913. package/lib/assets/icons/menu/icon-globe.svg.mjs.map +0 -1
  914. package/lib/components/MobileModal/assets/arrowDown.svg.mjs +0 -3
  915. /package/lib/{components/MobileModal/assets → assets/icons}/arrowDown.svg.js.map +0 -0
  916. /package/lib/{components/MobileModal/assets → assets/icons}/arrowDown.svg.mjs.map +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"misc.js","sources":["../../../src/utils/money/misc.ts"],"sourcesContent":["import {\n add,\n dinero,\n hasSubUnits,\n multiply,\n subtract,\n toSnapshot,\n toUnit,\n transformScale,\n} from \"dinero.js\";\n\nimport { Currency } from \"../../types\";\nimport { assert } from \"../errors\";\nimport { isFloat, isInt } from \"../number\";\nimport { capitalize } from \"../string\";\nimport { smallestSubunitLookup } from \"./constants\";\nimport {\n currencyLookup,\n dineroCurrenciesLookup,\n floatToInt,\n} from \"./misc.private\";\nimport type { Cents, Dino, DinoCurrency, Money, RoundingFn } from \"./types\";\n\n/**\n * Some currencies have subunits in their currency spec that are not used in reality. This causes Dinero to return incorrect subunit values for those currencies.\n * This util rounds down any unused subunits to closest subunit resolution.\n *\n * ! Not to be confused with prettifyTotal\n */\nexport const toSmallestSubunit = (total: Dino): Dino => {\n // Nothing to round\n if (!hasSubUnits(total)) {\n return total;\n }\n\n const totalJson = total.toJSON();\n\n const [roundToDigits, roundingMode] =\n smallestSubunitLookup.get(totalJson.currency.code) ?? [];\n\n if (roundToDigits == null || roundingMode == null) {\n return total;\n }\n\n return roundDinero(total, roundingMode);\n};\n\n/**\n * Find Dinero.js currency instance from our Currency enum.\n * @throws Throws an error if currency is not found!\n *\n * @example\n * getDineroCurrency(Currency.Usd); // => Dinero.js currency instance\n * getDineroCurrency(\"invalid\"); // => throws AssertionError\n */\nexport const getDineroCurrency = (currency: Currency): DinoCurrency => {\n const dineroCurrency = dineroCurrenciesLookup.get(currency);\n assert(!!dineroCurrency, `Unsupported currency: \"${currency}\"`);\n return dineroCurrency;\n};\n\n/**\n * Convert Dinero currency (case-insensitive) to local currency type\n * @throws Throws an error if currency is not found!\n *\n * @example\n * parseCurrencyCode('usd') // Currency.Usd\n * parseCurrencyCode('JPY') // Currency.Jpy\n * parseCurrencyCode('invalid') // throws AssertionError\n */\nexport const parseCurrencyCode = (code: string): Currency => {\n const normalizedCode = capitalize(code.toLowerCase());\n assert(\n currencyLookup.has(normalizedCode),\n `Invalid currency code: ${normalizedCode}`,\n );\n return Currency[normalizedCode as keyof typeof Currency];\n};\n\n/**\n * Utility to quickly convert cents to a to currency float amount number\n *\n * @example\n * centsToCurrencyUnit(100, \"USD\") // 1\n * centsToCurrencyUnit(1, \"USD\") // 0.01\n * centsToCurrencyUnit(420, \"USD\") // 4.2\n * centsToCurrencyUnit(420, \"JPY\") // 420\n * FIXME: worth moving to a combined method of centsToCurrencyUnit & dineroToCurrencyUnit that accepts Money|Dino as input\n */\nexport const centsToCurrencyUnit = (\n centsAmount: Cents,\n currency: Currency,\n): number => {\n const dineroCurrency = getDineroCurrency(currency);\n const dineroObj = dinero({ amount: centsAmount, currency: dineroCurrency });\n return dineroToCurrencyUnit(dineroObj);\n};\n\n/**\n * Utility to quickly convert dinero instance to a to currency amount number\n *\n * @example\n * dineroToCurrencyUnit(getDinero(100, Currency.Usd)) // 1\n * dineroToCurrencyUnit(getDinero(1, Currency.Usd)) // 0.01\n * dineroToCurrencyUnit(getDinero(420, Currency.Usd)) // 4.2\n */\nexport const dineroToCurrencyUnit = (dineroObj: Dino): number => {\n return toUnit(dineroObj);\n};\n\n/**\n * Parse arbitrary float amount in a given currency to a dinero object.\n * Wrapper around `parseFloatToDineroRaw` for easier usage.\n *\n * Doesn't work on string float amounts!\n * @example\n * parseFloatToDinero(420, Currency.Usd); // => Dinero.js instance\n */\nexport const parseFloatToDinero = (floatAmount: number, currency: Currency) => {\n const dineroCurrency = getDineroCurrency(currency);\n return parseFloatToDineroRaw(floatAmount, dineroCurrency);\n};\n\n/**\n * Parse arbitrary float amount in a given dinero like currency object to a dinero object.\n * ! Typically use `parseFloatToDinero` instead of this method ! But this one is useful for custom currencies (e.g. custom exchange rates)\n */\nexport const parseFloatToDineroRaw = (\n floatAmount: number,\n dineroCurrency: DinoCurrency,\n) => {\n isFloat(floatAmount, \"Amount\");\n\n /**\n * Try to determine given input scale after comma, if not found, use currency default as that would indicate that\n * given input was an integer instead of a float\n *\n * FIXME: Won't work correctly if some currencies use dot/comma separation for decimal digits:\n * At least MacOS shows 4 different kind of formats to numbers.\n * 1. \"1234567,89\"\n * 2. \"1,234,567,89\"\n * 3. \"1.234.567,89\"\n * 4. \"1 234 567,89\"\n * Have to research if there are any more standards we should try to parse support\n */\n const scaleOfGivenAmount =\n String(floatAmount).split(\".\")[1]?.length ?? dineroCurrency.exponent;\n\n if (\n scaleOfGivenAmount == null ||\n scaleOfGivenAmount > dineroCurrency.exponent\n ) {\n throw new Error(`scaleOfGivenAmount is unsupported ${scaleOfGivenAmount}`);\n }\n const rateInt = floatToInt(\n floatAmount,\n dineroCurrency.base,\n dineroCurrency.exponent,\n );\n return dinero({\n amount: rateInt,\n currency: dineroCurrency,\n });\n};\n\n/**\n * Shorthand for dinero constructor\n *\n * @example\n * getDinero(100, Currency.Usd); // => Dinero.js instance (representing $1)\n */\nexport const getDinero = (amount: Cents, currency: Currency): Dino => {\n // TODO: verify if this is even needed, as dinero might already handle this\n isInt(amount, \"Amount\");\n return dinero({ amount, currency: getDineroCurrency(currency) });\n};\n\n/**\n * Shorthand to get amount from dinero instance\n *\n * FIXME: There is potential issue because we are not trimming scale:\n * multiply(getDinero(100, Currency.Usd), { amount: 100 + percentIncrease, scale: 2 })\n * will result in amount:10600, scale:4 (2*2), because dinero is rounding to safest scale.\n * @see https://v2.dinerojs.com/docs/core-concepts/scale#trimming-scale\n *\n * We should call something like: transformScale(d, currency.exponent)\n * @see https://v2.dinerojs.com/docs/api/conversions/transform-scale\n *\n * @example\n * amount(getDinero(100, Currency.Usd)); // 100\n */\nexport const amount = (dinero: Dino): Cents => {\n return toSnapshot(dinero).amount;\n};\n\n/**\n * Method to multiply dinero amount by full percent.\n * It also transforms scale back to currency exponent.\n * Where in case 20.34*1.06=21,5604, it will round to 21.56\n *\n * Will convert 0.01 - 12% to 0, but thats edge case we can tolerate, because\n * of dinero version we do not control rounding\n */\nexport const multiplyByFullPercent = (\n dinero: Dino,\n percentIncrease: number,\n): Dino => {\n assert(\n percentIncrease >= -100 && percentIncrease <= 100,\n \"Range should be in [-100, 100]\",\n );\n // (106 / 10^2 = 1.06)\n const multiplyResult = multiply(dinero, {\n amount: 100 + percentIncrease,\n scale: 2,\n });\n return transformScale(\n multiplyResult,\n multiplyResult.toJSON().currency.exponent,\n );\n};\n\n/**\n * Shorthand to get currency from dinero instance\n *\n * @example\n * currency(getDinero(100, Currency.Usd)); // Currency.Usd\n */\nexport const currency = (dinero: Dino): Currency => {\n return parseCurrencyCode(toSnapshot(dinero).currency.code);\n};\n\n/**\n * Shorthand to get our GraphQL Money type from dinero instance\n *\n * @example\n * money(getDinero(100, Currency.Usd)); // { amount: 100, currency: Currency.Usd }\n */\nexport const money = (dinero: Dino): Money => {\n const { amount, currency } = toSnapshot(dinero);\n\n return {\n amount,\n currency: parseCurrencyCode(currency.code),\n };\n};\n\n/**\n * Helper to quickly add multiple dinero instances with same currency\n *\n * @example\n * addMany([getDinero(100, Currency.Usd), getDinero(200, Currency.Usd)], Currency.Usd); // => Dinero.js instance (representing $3)\n */\nexport const addMany = (addends: Array<Dino>, defaultCurrency: Currency) =>\n [...addends, getDinero(0, defaultCurrency)].reduce(add);\n\n/**\n * Helper to quickly subtract multiple dinero instances with same currency\n */\nexport const subtractMany = (\n subtractions: Array<Dino>,\n defaultCurrency: Currency,\n) => [...subtractions, getDinero(0, defaultCurrency)].reduce(subtract);\n\n/**\n * Helper to quickly get dinero object from string\n */\nexport const stringAmountToDinero = (price: string, currency: Currency) =>\n // FIXME: parseFloat seems dangerous O_O\n parseFloatToDinero(parseFloat(price), currency);\n\n/**\n * Helper to quickly round dinero object to closest integer by a given rounding function\n * FIXME: add tests\n *\n * @example\n * roundDinero(getDinero(120, Currency.Usd), Math.floor); // => Dinero.js instance (representing $1)\n * roundDinero(getDinero(120, Currency.Usd), Math.ceil); // => Dinero.js instance (representing $2)\n */\nexport const roundDinero = (dinero: Dino, roundingFn: RoundingFn): Dino => {\n const roundedUnitPrice = toUnit(dinero, { digits: 0, round: roundingFn });\n\n const snapshot = toSnapshot(dinero);\n\n return dinero.create({\n /**\n * Rounding to mitigate floating precision errors:\n *\n * 8.2 * 10 ** 2 = 819.9999999999999\n * 2.2 * 10 ** 2 = 220.00000000000003\n */\n amount: Math.round(\n roundedUnitPrice * snapshot.currency.base ** snapshot.currency.exponent,\n ),\n currency: snapshot.currency,\n });\n};\n"],"names":["toSmallestSubunit","total","hasSubUnits","totalJson","toJSON","roundToDigits","roundingMode","smallestSubunitLookup","get","currency","code","roundDinero","getDineroCurrency","dineroCurrency","dineroCurrenciesLookup","assert","parseCurrencyCode","normalizedCode","capitalize","toLowerCase","currencyLookup","has","Currency","centsToCurrencyUnit","centsAmount","dineroObj","dinero","amount","dineroToCurrencyUnit","toUnit","parseFloatToDinero","floatAmount","parseFloatToDineroRaw","isFloat","scaleOfGivenAmount","String","split","length","exponent","Error","rateInt","floatToInt","base","getDinero","isInt","toSnapshot","multiplyByFullPercent","percentIncrease","multiplyResult","multiply","scale","transformScale","money","addMany","addends","defaultCurrency","reduce","add","subtractMany","subtractions","subtract","stringAmountToDinero","price","parseFloat","roundingFn","roundedUnitPrice","digits","round","snapshot","create","Math"],"mappings":";;;;;;;;;;;AA6Ba,MAAAA,iBAAA,GAAqBC,KAAsB,IAAA;EAElD,IAAA,CAACC,SAAAA,CAAAA,WAAY,CAAAD,KAAK,CAAG,EAAA;IAChB,OAAAA,KAAA;EACT;EAEM,MAAAE,SAAA,GAAYF,MAAMG,MAAO,EAAA;EAEzB,MAAA,CAACC,aAAe,EAAAC,YAAY,CAChC,GAAAC,SAAA,CAAAA,qBAAA,CAAsBC,IAAIL,SAAU,CAAAM,QAAA,CAASC,IAAI,CAAA,IAAK,EAAC;EAErD,IAAAL,aAAA,IAAiB,IAAQ,IAAAC,YAAA,IAAgB,IAAM,EAAA;IAC1C,OAAAL,KAAA;EACT;EAEO,OAAAU,WAAA,CAAYV,OAAOK,YAAY,CAAA;AACxC,CAAA;AAUa,MAAAM,iBAAA,GAAqBH,SAAqC,IAAA;EAC/D,MAAAI,cAAA,GAAiBC,YAAAA,CAAAA,sBAAuB,CAAAN,GAAA,CAAIC,SAAQ,CAAA;EAC1DM,MAAA,CAAAA,MAAA,CAAO,CAAC,CAACF,cAAgB,EAAA,0BAA0BJ,SAAQ,GAAG,CAAA;EACvD,OAAAI,cAAA;AACT,CAAA;AA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\n dinero,\n hasSubUnits,\n multiply,\n subtract,\n toSnapshot,\n toUnit,\n transformScale,\n} from \"dinero.js\";\n\nimport { Currency } from \"../../types\";\nimport { assert } from \"../errors\";\nimport { isFloat, isInt } from \"../number\";\nimport { capitalize } from \"../string\";\nimport { smallestSubunitLookup } from \"./constants\";\nimport {\n currencyLookup,\n dineroCurrenciesLookup,\n floatToInt,\n} from \"./misc.private\";\nimport type { Cents, Dino, DinoCurrency, Money, RoundingFn } from \"./types\";\n\n/**\n * Some currencies have subunits in their currency spec that are not used in reality. This causes Dinero to return incorrect subunit values for those currencies.\n * This util rounds down any unused subunits to closest subunit resolution.\n *\n * ! Not to be confused with prettifyTotal\n */\nexport const toSmallestSubunit = (total: Dino): Dino => {\n // Nothing to round\n if (!hasSubUnits(total)) {\n return total;\n }\n\n const totalJson = total.toJSON();\n\n const [roundToDigits, roundingMode] =\n smallestSubunitLookup.get(totalJson.currency.code) ?? [];\n\n if (roundToDigits == null || roundingMode == null) {\n return total;\n }\n\n return roundDinero(total, roundingMode);\n};\n\n/**\n * Find Dinero.js currency instance from our Currency enum.\n * @throws Throws an error if currency is not found!\n *\n * @example\n * getDineroCurrency(Currency.Usd); // => Dinero.js currency instance\n * getDineroCurrency(\"invalid\"); // => throws AssertionError\n */\nexport const getDineroCurrency = (currency: Currency): DinoCurrency => {\n const dineroCurrency = dineroCurrenciesLookup.get(currency);\n assert(!!dineroCurrency, `Unsupported currency: \"${currency}\"`);\n return dineroCurrency;\n};\n\n/**\n * Convert Dinero currency (case-insensitive) to local currency type\n * @throws Throws an error if currency is not found!\n *\n * @example\n * parseCurrencyCode('usd') // Currency.Usd\n * parseCurrencyCode('JPY') // Currency.Jpy\n * parseCurrencyCode('invalid') // throws AssertionError\n */\nexport const parseCurrencyCode = (code: string): Currency => {\n const normalizedCode = capitalize(code.toLowerCase());\n assert(\n currencyLookup.has(normalizedCode),\n `Invalid currency code: ${normalizedCode}`,\n );\n return Currency[normalizedCode as keyof typeof Currency];\n};\n\n/**\n * Utility to quickly convert cents to a to currency float amount number\n *\n * @example\n * centsToCurrencyUnit(100, \"USD\") // 1\n * centsToCurrencyUnit(1, \"USD\") // 0.01\n * centsToCurrencyUnit(420, \"USD\") // 4.2\n * centsToCurrencyUnit(420, \"JPY\") // 420\n * FIXME: worth moving to a combined method of centsToCurrencyUnit & dineroToCurrencyUnit that accepts Money|Dino as input\n */\nexport const centsToCurrencyUnit = (\n centsAmount: Cents,\n currency: Currency,\n): number => {\n const dineroCurrency = getDineroCurrency(currency);\n const dineroObj = dinero({ amount: centsAmount, currency: dineroCurrency });\n return dineroToCurrencyUnit(dineroObj);\n};\n\n/**\n * Utility to quickly convert dinero instance to a to currency amount number\n *\n * @example\n * dineroToCurrencyUnit(getDinero(100, Currency.Usd)) // 1\n * dineroToCurrencyUnit(getDinero(1, Currency.Usd)) // 0.01\n * dineroToCurrencyUnit(getDinero(420, Currency.Usd)) // 4.2\n */\nexport const dineroToCurrencyUnit = (dineroObj: Dino): number => {\n return toUnit(dineroObj);\n};\n\n/**\n * Parse arbitrary float amount in a given currency to a dinero object.\n * Wrapper around `parseFloatToDineroRaw` for easier usage.\n *\n * Doesn't work on string float amounts!\n * @example\n * parseFloatToDinero(420, Currency.Usd); // => Dinero.js instance\n */\nexport const parseFloatToDinero = (floatAmount: number, currency: Currency) => {\n const dineroCurrency = getDineroCurrency(currency);\n return parseFloatToDineroRaw(floatAmount, dineroCurrency);\n};\n\n/**\n * Parse arbitrary float amount in a given dinero like currency object to a dinero object.\n * ! Typically use `parseFloatToDinero` instead of this method ! But this one is useful for custom currencies (e.g. custom exchange rates)\n */\nexport const parseFloatToDineroRaw = (\n floatAmount: number,\n dineroCurrency: DinoCurrency,\n) => {\n isFloat(floatAmount, \"Amount\");\n\n /**\n * Try to determine given input scale after comma, if not found, use currency default as that would indicate that\n * given input was an integer instead of a float\n *\n * FIXME: Won't work correctly if some currencies use dot/comma separation for decimal digits:\n * At least MacOS shows 4 different kind of formats to numbers.\n * 1. \"1234567,89\"\n * 2. \"1,234,567,89\"\n * 3. \"1.234.567,89\"\n * 4. \"1 234 567,89\"\n * Have to research if there are any more standards we should try to parse support\n */\n const scaleOfGivenAmount =\n String(floatAmount).split(\".\")[1]?.length ?? dineroCurrency.exponent;\n\n if (\n scaleOfGivenAmount == null ||\n scaleOfGivenAmount > dineroCurrency.exponent\n ) {\n throw new Error(`scaleOfGivenAmount is unsupported ${scaleOfGivenAmount}`);\n }\n const rateInt = floatToInt(\n floatAmount,\n dineroCurrency.base,\n dineroCurrency.exponent,\n );\n return dinero({\n amount: rateInt,\n currency: dineroCurrency,\n });\n};\n\n/**\n * Shorthand for dinero constructor\n *\n * @example\n * getDinero(100, Currency.Usd); // => Dinero.js instance (representing $1)\n */\nexport const getDinero = (amount: Cents, currency: Currency): Dino => {\n // TODO: verify if this is even needed, as dinero might already handle this\n isInt(amount, \"Amount\");\n return dinero({ amount, currency: getDineroCurrency(currency) });\n};\n\n/**\n * Shorthand to get amount from dinero instance\n *\n * FIXME: There is potential issue because we are not trimming scale:\n * multiply(getDinero(100, Currency.Usd), { amount: 100 + percentIncrease, scale: 2 })\n * will result in amount:10600, scale:4 (2*2), because dinero is rounding to safest scale.\n * @see https://v2.dinerojs.com/docs/core-concepts/scale#trimming-scale\n *\n * We should call something like: transformScale(d, currency.exponent)\n * @see https://v2.dinerojs.com/docs/api/conversions/transform-scale\n *\n * @example\n * amount(getDinero(100, Currency.Usd)); // 100\n */\nexport const amount = (dinero: Dino): Cents => {\n return toSnapshot(dinero).amount;\n};\n\n/**\n * Method to multiply dinero amount by full percent.\n * It also transforms scale back to currency exponent.\n * Where in case 20.34*1.06=21,5604, it will round to 21.56\n *\n * Will convert 0.01 - 12% to 0, but thats edge case we can tolerate, because\n * of dinero version we do not control rounding\n */\nexport const multiplyByFullPercent = (\n dinero: Dino,\n percentIncrease: number,\n): Dino => {\n assert(\n percentIncrease >= -100 && percentIncrease <= 100,\n \"Range should be in [-100, 100]\",\n );\n // (106 / 10^2 = 1.06)\n const multiplyResult = multiply(dinero, {\n amount: 100 + percentIncrease,\n scale: 2,\n });\n return transformScale(\n multiplyResult,\n multiplyResult.toJSON().currency.exponent,\n );\n};\n\n/**\n * Shorthand to get currency from dinero instance\n *\n * @example\n * currency(getDinero(100, Currency.Usd)); // Currency.Usd\n */\nexport const currency = (dinero: Dino): Currency => {\n return parseCurrencyCode(toSnapshot(dinero).currency.code);\n};\n\n/**\n * Shorthand to get our GraphQL Money type from dinero instance\n *\n * @example\n * money(getDinero(100, Currency.Usd)); // { amount: 100, currency: Currency.Usd }\n */\nexport const money = (dinero: Dino): Money => {\n const { amount, currency } = toSnapshot(dinero);\n\n return {\n amount,\n currency: parseCurrencyCode(currency.code),\n };\n};\n\n/**\n * Helper to quickly add multiple dinero instances with same currency\n *\n * @example\n * addMany([getDinero(100, Currency.Usd), getDinero(200, Currency.Usd)], Currency.Usd); // => Dinero.js instance (representing $3)\n */\nexport const addMany = (addends: Array<Dino>, defaultCurrency: Currency) =>\n addends.reduce(add, getDinero(0, defaultCurrency));\n\n/**\n * Helper to quickly subtract multiple dinero instances with same currency\n */\nexport const subtractMany = (\n subtractions: Array<Dino>,\n defaultCurrency: Currency,\n // eslint-disable-next-line sonarjs/reduce-initial-value\n) => [...subtractions, getDinero(0, defaultCurrency)].reduce(subtract);\n\n/**\n * Helper to quickly get dinero object from string\n */\nexport const stringAmountToDinero = (price: string, currency: Currency) =>\n // FIXME: parseFloat seems dangerous O_O\n parseFloatToDinero(parseFloat(price), currency);\n\n/**\n * Helper to quickly round dinero object to closest integer by a given rounding function\n * FIXME: add tests\n *\n * @example\n * roundDinero(getDinero(120, Currency.Usd), Math.floor); // => Dinero.js instance (representing $1)\n * roundDinero(getDinero(120, Currency.Usd), Math.ceil); // => Dinero.js instance (representing $2)\n */\nexport const roundDinero = (dinero: Dino, roundingFn: RoundingFn): Dino => {\n const roundedUnitPrice = toUnit(dinero, { digits: 0, round: roundingFn });\n\n const snapshot = toSnapshot(dinero);\n\n return dinero.create({\n /**\n * Rounding to mitigate floating precision errors:\n *\n * 8.2 * 10 ** 2 = 819.9999999999999\n * 2.2 * 10 ** 2 = 220.00000000000003\n */\n amount: Math.round(\n roundedUnitPrice * snapshot.currency.base ** snapshot.currency.exponent,\n ),\n currency: snapshot.currency,\n });\n};\n"],"names":["toSmallestSubunit","total","hasSubUnits","totalJson","toJSON","roundToDigits","roundingMode","smallestSubunitLookup","get","currency","code","roundDinero","getDineroCurrency","dineroCurrency","dineroCurrenciesLookup","assert","parseCurrencyCode","normalizedCode","capitalize","toLowerCase","currencyLookup","has","Currency","centsToCurrencyUnit","centsAmount","dineroObj","dinero","amount","dineroToCurrencyUnit","toUnit","parseFloatToDinero","floatAmount","parseFloatToDineroRaw","isFloat","scaleOfGivenAmount","String","split","length","exponent","Error","rateInt","floatToInt","base","getDinero","isInt","toSnapshot","multiplyByFullPercent","percentIncrease","multiplyResult","multiply","scale","transformScale","money","addMany","addends","defaultCurrency","reduce","add","subtractMany","subtractions","subtract","stringAmountToDinero","price","parseFloat","roundingFn","roundedUnitPrice","digits","round","snapshot","create","Math"],"mappings":";;;;;;;;;;;AA6Ba,MAAAA,iBAAA,GAAqBC,KAAsB,IAAA;EAElD,IAAA,CAACC,SAAAA,CAAAA,WAAY,CAAAD,KAAK,CAAG,EAAA;IAChB,OAAAA,KAAA;EACT;EAEM,MAAAE,SAAA,GAAYF,MAAMG,MAAO,EAAA;EAEzB,MAAA,CAACC,aAAe,EAAAC,YAAY,CAChC,GAAAC,SAAA,CAAAA,qBAAA,CAAsBC,IAAIL,SAAU,CAAAM,QAAA,CAASC,IAAI,CAAA,IAAK,EAAC;EAErD,IAAAL,aAAA,IAAiB,IAAQ,IAAAC,YAAA,IAAgB,IAAM,EAAA;IAC1C,OAAAL,KAAA;EACT;EAEO,OAAAU,WAAA,CAAYV,OAAOK,YAAY,CAAA;AACxC,CAAA;AAUa,MAAAM,iBAAA,GAAqBH,SAAqC,IAAA;EAC/D,MAAAI,cAAA,G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,CAAA6B,QACjE,CAAA;IACA7B,UAAU2D,QAAS,CAAA3D;EAAA,CACpB,CAAA;AACH,CAAA;;;;;;;;;;;;;;;;"}
@@ -86,7 +86,7 @@ const money = dinero2 => {
86
86
  currency: parseCurrencyCode(currency2.code)
87
87
  };
88
88
  };
89
- const addMany = (addends, defaultCurrency) => [...addends, getDinero(0, defaultCurrency)].reduce(add);
89
+ const addMany = (addends, defaultCurrency) => addends.reduce(add, getDinero(0, defaultCurrency));
90
90
  const subtractMany = (subtractions, defaultCurrency) => [...subtractions, getDinero(0, defaultCurrency)].reduce(subtract);
91
91
  const stringAmountToDinero = (price, currency2) =>
92
92
  // FIXME: parseFloat seems dangerous O_O
@@ -1 +1 @@
1
- {"version":3,"file":"misc.mjs","sources":["../../../src/utils/money/misc.ts"],"sourcesContent":["import {\n add,\n dinero,\n hasSubUnits,\n multiply,\n subtract,\n toSnapshot,\n toUnit,\n transformScale,\n} from \"dinero.js\";\n\nimport { Currency } from \"../../types\";\nimport { assert } from \"../errors\";\nimport { isFloat, isInt } from \"../number\";\nimport { capitalize } from \"../string\";\nimport { smallestSubunitLookup } from \"./constants\";\nimport {\n currencyLookup,\n dineroCurrenciesLookup,\n floatToInt,\n} from \"./misc.private\";\nimport type { Cents, Dino, DinoCurrency, Money, RoundingFn } from \"./types\";\n\n/**\n * Some currencies have subunits in their currency spec that are not used in reality. This causes Dinero to return incorrect subunit values for those currencies.\n * This util rounds down any unused subunits to closest subunit resolution.\n *\n * ! Not to be confused with prettifyTotal\n */\nexport const toSmallestSubunit = (total: Dino): Dino => {\n // Nothing to round\n if (!hasSubUnits(total)) {\n return total;\n }\n\n const totalJson = total.toJSON();\n\n const [roundToDigits, roundingMode] =\n smallestSubunitLookup.get(totalJson.currency.code) ?? [];\n\n if (roundToDigits == null || roundingMode == null) {\n return total;\n }\n\n return roundDinero(total, roundingMode);\n};\n\n/**\n * Find Dinero.js currency instance from our Currency enum.\n * @throws Throws an error if currency is not found!\n *\n * @example\n * getDineroCurrency(Currency.Usd); // => Dinero.js currency instance\n * getDineroCurrency(\"invalid\"); // => throws AssertionError\n */\nexport const getDineroCurrency = (currency: Currency): DinoCurrency => {\n const dineroCurrency = dineroCurrenciesLookup.get(currency);\n assert(!!dineroCurrency, `Unsupported currency: \"${currency}\"`);\n return dineroCurrency;\n};\n\n/**\n * Convert Dinero currency (case-insensitive) to local currency type\n * @throws Throws an error if currency is not found!\n *\n * @example\n * parseCurrencyCode('usd') // Currency.Usd\n * parseCurrencyCode('JPY') // Currency.Jpy\n * parseCurrencyCode('invalid') // throws AssertionError\n */\nexport const parseCurrencyCode = (code: string): Currency => {\n const normalizedCode = capitalize(code.toLowerCase());\n assert(\n currencyLookup.has(normalizedCode),\n `Invalid currency code: ${normalizedCode}`,\n );\n return Currency[normalizedCode as keyof typeof Currency];\n};\n\n/**\n * Utility to quickly convert cents to a to currency float amount number\n *\n * @example\n * centsToCurrencyUnit(100, \"USD\") // 1\n * centsToCurrencyUnit(1, \"USD\") // 0.01\n * centsToCurrencyUnit(420, \"USD\") // 4.2\n * centsToCurrencyUnit(420, \"JPY\") // 420\n * FIXME: worth moving to a combined method of centsToCurrencyUnit & dineroToCurrencyUnit that accepts Money|Dino as input\n */\nexport const centsToCurrencyUnit = (\n centsAmount: Cents,\n currency: Currency,\n): number => {\n const dineroCurrency = getDineroCurrency(currency);\n const dineroObj = dinero({ amount: centsAmount, currency: dineroCurrency });\n return dineroToCurrencyUnit(dineroObj);\n};\n\n/**\n * Utility to quickly convert dinero instance to a to currency amount number\n *\n * @example\n * dineroToCurrencyUnit(getDinero(100, Currency.Usd)) // 1\n * dineroToCurrencyUnit(getDinero(1, Currency.Usd)) // 0.01\n * dineroToCurrencyUnit(getDinero(420, Currency.Usd)) // 4.2\n */\nexport const dineroToCurrencyUnit = (dineroObj: Dino): number => {\n return toUnit(dineroObj);\n};\n\n/**\n * Parse arbitrary float amount in a given currency to a dinero object.\n * Wrapper around `parseFloatToDineroRaw` for easier usage.\n *\n * Doesn't work on string float amounts!\n * @example\n * parseFloatToDinero(420, Currency.Usd); // => Dinero.js instance\n */\nexport const parseFloatToDinero = (floatAmount: number, currency: Currency) => {\n const dineroCurrency = getDineroCurrency(currency);\n return parseFloatToDineroRaw(floatAmount, dineroCurrency);\n};\n\n/**\n * Parse arbitrary float amount in a given dinero like currency object to a dinero object.\n * ! Typically use `parseFloatToDinero` instead of this method ! But this one is useful for custom currencies (e.g. custom exchange rates)\n */\nexport const parseFloatToDineroRaw = (\n floatAmount: number,\n dineroCurrency: DinoCurrency,\n) => {\n isFloat(floatAmount, \"Amount\");\n\n /**\n * Try to determine given input scale after comma, if not found, use currency default as that would indicate that\n * given input was an integer instead of a float\n *\n * FIXME: Won't work correctly if some currencies use dot/comma separation for decimal digits:\n * At least MacOS shows 4 different kind of formats to numbers.\n * 1. \"1234567,89\"\n * 2. \"1,234,567,89\"\n * 3. \"1.234.567,89\"\n * 4. \"1 234 567,89\"\n * Have to research if there are any more standards we should try to parse support\n */\n const scaleOfGivenAmount =\n String(floatAmount).split(\".\")[1]?.length ?? dineroCurrency.exponent;\n\n if (\n scaleOfGivenAmount == null ||\n scaleOfGivenAmount > dineroCurrency.exponent\n ) {\n throw new Error(`scaleOfGivenAmount is unsupported ${scaleOfGivenAmount}`);\n }\n const rateInt = floatToInt(\n floatAmount,\n dineroCurrency.base,\n dineroCurrency.exponent,\n );\n return dinero({\n amount: rateInt,\n currency: dineroCurrency,\n });\n};\n\n/**\n * Shorthand for dinero constructor\n *\n * @example\n * getDinero(100, Currency.Usd); // => Dinero.js instance (representing $1)\n */\nexport const getDinero = (amount: Cents, currency: Currency): Dino => {\n // TODO: verify if this is even needed, as dinero might already handle this\n isInt(amount, \"Amount\");\n return dinero({ amount, currency: getDineroCurrency(currency) });\n};\n\n/**\n * Shorthand to get amount from dinero instance\n *\n * FIXME: There is potential issue because we are not trimming scale:\n * multiply(getDinero(100, Currency.Usd), { amount: 100 + percentIncrease, scale: 2 })\n * will result in amount:10600, scale:4 (2*2), because dinero is rounding to safest scale.\n * @see https://v2.dinerojs.com/docs/core-concepts/scale#trimming-scale\n *\n * We should call something like: transformScale(d, currency.exponent)\n * @see https://v2.dinerojs.com/docs/api/conversions/transform-scale\n *\n * @example\n * amount(getDinero(100, Currency.Usd)); // 100\n */\nexport const amount = (dinero: Dino): Cents => {\n return toSnapshot(dinero).amount;\n};\n\n/**\n * Method to multiply dinero amount by full percent.\n * It also transforms scale back to currency exponent.\n * Where in case 20.34*1.06=21,5604, it will round to 21.56\n *\n * Will convert 0.01 - 12% to 0, but thats edge case we can tolerate, because\n * of dinero version we do not control rounding\n */\nexport const multiplyByFullPercent = (\n dinero: Dino,\n percentIncrease: number,\n): Dino => {\n assert(\n percentIncrease >= -100 && percentIncrease <= 100,\n \"Range should be in [-100, 100]\",\n );\n // (106 / 10^2 = 1.06)\n const multiplyResult = multiply(dinero, {\n amount: 100 + percentIncrease,\n scale: 2,\n });\n return transformScale(\n multiplyResult,\n multiplyResult.toJSON().currency.exponent,\n );\n};\n\n/**\n * Shorthand to get currency from dinero instance\n *\n * @example\n * currency(getDinero(100, Currency.Usd)); // Currency.Usd\n */\nexport const currency = (dinero: Dino): Currency => {\n return parseCurrencyCode(toSnapshot(dinero).currency.code);\n};\n\n/**\n * Shorthand to get our GraphQL Money type from dinero instance\n *\n * @example\n * money(getDinero(100, Currency.Usd)); // { amount: 100, currency: Currency.Usd }\n */\nexport const money = (dinero: Dino): Money => {\n const { amount, currency } = toSnapshot(dinero);\n\n return {\n amount,\n currency: parseCurrencyCode(currency.code),\n };\n};\n\n/**\n * Helper to quickly add multiple dinero instances with same currency\n *\n * @example\n * addMany([getDinero(100, Currency.Usd), getDinero(200, Currency.Usd)], Currency.Usd); // => Dinero.js instance (representing $3)\n */\nexport const addMany = (addends: Array<Dino>, defaultCurrency: Currency) =>\n [...addends, getDinero(0, defaultCurrency)].reduce(add);\n\n/**\n * Helper to quickly subtract multiple dinero instances with same currency\n */\nexport const subtractMany = (\n subtractions: Array<Dino>,\n defaultCurrency: Currency,\n) => [...subtractions, getDinero(0, defaultCurrency)].reduce(subtract);\n\n/**\n * Helper to quickly get dinero object from string\n */\nexport const stringAmountToDinero = (price: string, currency: Currency) =>\n // FIXME: parseFloat seems dangerous O_O\n parseFloatToDinero(parseFloat(price), currency);\n\n/**\n * Helper to quickly round dinero object to closest integer by a given rounding function\n * FIXME: add tests\n *\n * @example\n * roundDinero(getDinero(120, Currency.Usd), Math.floor); // => Dinero.js instance (representing $1)\n * roundDinero(getDinero(120, Currency.Usd), Math.ceil); // => Dinero.js instance (representing $2)\n */\nexport const roundDinero = (dinero: Dino, roundingFn: RoundingFn): Dino => {\n const roundedUnitPrice = toUnit(dinero, { digits: 0, round: roundingFn });\n\n const snapshot = toSnapshot(dinero);\n\n return dinero.create({\n /**\n * Rounding to mitigate floating precision errors:\n *\n * 8.2 * 10 ** 2 = 819.9999999999999\n * 2.2 * 10 ** 2 = 220.00000000000003\n */\n amount: Math.round(\n roundedUnitPrice * snapshot.currency.base ** snapshot.currency.exponent,\n ),\n currency: snapshot.currency,\n });\n};\n"],"names":["toSmallestSubunit","total","hasSubUnits","totalJson","toJSON","roundToDigits","roundingMode","smallestSubunitLookup","get","currency","code","roundDinero","getDineroCurrency","dineroCurrency","dineroCurrenciesLookup","assert","parseCurrencyCode","normalizedCode","capitalize","toLowerCase","currencyLookup","has","Currency","centsToCurrencyUnit","centsAmount","dineroObj","dinero","amount","dineroToCurrencyUnit","toUnit","parseFloatToDinero","floatAmount","parseFloatToDineroRaw","isFloat","scaleOfGivenAmount","String","split","length","exponent","Error","rateInt","floatToInt","base","getDinero","isInt","toSnapshot","multiplyByFullPercent","percentIncrease","multiplyResult","multiply","scale","transformScale","money","addMany","addends","defaultCurrency","reduce","add","subtractMany","subtractions","subtract","stringAmountToDinero","price","parseFloat","roundingFn","roundedUnitPrice","digits","round","snapshot","create","Math"],"mappings":";;;;;;;;;AA6Ba,MAAAA,iBAAA,GAAqBC,KAAsB,IAAA;EA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,MAAAI,QAAA,GAAWvB,WAAWnB,OAAM,CAAA;EAElC,OAAOA,QAAO2C,MAAO,CAAA;IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;IAOnB1C,QAAQ2C,IAAK,CAAAH,KAAA,CACXF,gBAAmB,GAAAG,QAAA,CAAS3D,QAAS,CAAAiC,IAAA,IAAQ0B,SAAS3D,QAAS,CAAA6B,QACjE,CAAA;IACA7B,UAAU2D,QAAS,CAAA3D;EAAA,CACpB,CAAA;AACH,CAAA;"}
1
+ {"version":3,"file":"misc.mjs","sources":["../../../src/utils/money/misc.ts"],"sourcesContent":["import {\n add,\n dinero,\n hasSubUnits,\n multiply,\n subtract,\n toSnapshot,\n toUnit,\n transformScale,\n} from \"dinero.js\";\n\nimport { Currency } from \"../../types\";\nimport { assert } from \"../errors\";\nimport { isFloat, isInt } from \"../number\";\nimport { capitalize } from \"../string\";\nimport { smallestSubunitLookup } from \"./constants\";\nimport {\n currencyLookup,\n dineroCurrenciesLookup,\n floatToInt,\n} from \"./misc.private\";\nimport type { Cents, Dino, DinoCurrency, Money, RoundingFn } from \"./types\";\n\n/**\n * Some currencies have subunits in their currency spec that are not used in reality. This causes Dinero to return incorrect subunit values for those currencies.\n * This util rounds down any unused subunits to closest subunit resolution.\n *\n * ! Not to be confused with prettifyTotal\n */\nexport const toSmallestSubunit = (total: Dino): Dino => {\n // Nothing to round\n if (!hasSubUnits(total)) {\n return total;\n }\n\n const totalJson = total.toJSON();\n\n const [roundToDigits, roundingMode] =\n smallestSubunitLookup.get(totalJson.currency.code) ?? [];\n\n if (roundToDigits == null || roundingMode == null) {\n return total;\n }\n\n return roundDinero(total, roundingMode);\n};\n\n/**\n * Find Dinero.js currency instance from our Currency enum.\n * @throws Throws an error if currency is not found!\n *\n * @example\n * getDineroCurrency(Currency.Usd); // => Dinero.js currency instance\n * getDineroCurrency(\"invalid\"); // => throws AssertionError\n */\nexport const getDineroCurrency = (currency: Currency): DinoCurrency => {\n const dineroCurrency = dineroCurrenciesLookup.get(currency);\n assert(!!dineroCurrency, `Unsupported currency: \"${currency}\"`);\n return dineroCurrency;\n};\n\n/**\n * Convert Dinero currency (case-insensitive) to local currency type\n * @throws Throws an error if currency is not found!\n *\n * @example\n * parseCurrencyCode('usd') // Currency.Usd\n * parseCurrencyCode('JPY') // Currency.Jpy\n * parseCurrencyCode('invalid') // throws AssertionError\n */\nexport const parseCurrencyCode = (code: string): Currency => {\n const normalizedCode = capitalize(code.toLowerCase());\n assert(\n currencyLookup.has(normalizedCode),\n `Invalid currency code: ${normalizedCode}`,\n );\n return Currency[normalizedCode as keyof typeof Currency];\n};\n\n/**\n * Utility to quickly convert cents to a to currency float amount number\n *\n * @example\n * centsToCurrencyUnit(100, \"USD\") // 1\n * centsToCurrencyUnit(1, \"USD\") // 0.01\n * centsToCurrencyUnit(420, \"USD\") // 4.2\n * centsToCurrencyUnit(420, \"JPY\") // 420\n * FIXME: worth moving to a combined method of centsToCurrencyUnit & dineroToCurrencyUnit that accepts Money|Dino as input\n */\nexport const centsToCurrencyUnit = (\n centsAmount: Cents,\n currency: Currency,\n): number => {\n const dineroCurrency = getDineroCurrency(currency);\n const dineroObj = dinero({ amount: centsAmount, currency: dineroCurrency });\n return dineroToCurrencyUnit(dineroObj);\n};\n\n/**\n * Utility to quickly convert dinero instance to a to currency amount number\n *\n * @example\n * dineroToCurrencyUnit(getDinero(100, Currency.Usd)) // 1\n * dineroToCurrencyUnit(getDinero(1, Currency.Usd)) // 0.01\n * dineroToCurrencyUnit(getDinero(420, Currency.Usd)) // 4.2\n */\nexport const dineroToCurrencyUnit = (dineroObj: Dino): number => {\n return toUnit(dineroObj);\n};\n\n/**\n * Parse arbitrary float amount in a given currency to a dinero object.\n * Wrapper around `parseFloatToDineroRaw` for easier usage.\n *\n * Doesn't work on string float amounts!\n * @example\n * parseFloatToDinero(420, Currency.Usd); // => Dinero.js instance\n */\nexport const parseFloatToDinero = (floatAmount: number, currency: Currency) => {\n const dineroCurrency = getDineroCurrency(currency);\n return parseFloatToDineroRaw(floatAmount, dineroCurrency);\n};\n\n/**\n * Parse arbitrary float amount in a given dinero like currency object to a dinero object.\n * ! Typically use `parseFloatToDinero` instead of this method ! But this one is useful for custom currencies (e.g. custom exchange rates)\n */\nexport const parseFloatToDineroRaw = (\n floatAmount: number,\n dineroCurrency: DinoCurrency,\n) => {\n isFloat(floatAmount, \"Amount\");\n\n /**\n * Try to determine given input scale after comma, if not found, use currency default as that would indicate that\n * given input was an integer instead of a float\n *\n * FIXME: Won't work correctly if some currencies use dot/comma separation for decimal digits:\n * At least MacOS shows 4 different kind of formats to numbers.\n * 1. \"1234567,89\"\n * 2. \"1,234,567,89\"\n * 3. \"1.234.567,89\"\n * 4. \"1 234 567,89\"\n * Have to research if there are any more standards we should try to parse support\n */\n const scaleOfGivenAmount =\n String(floatAmount).split(\".\")[1]?.length ?? dineroCurrency.exponent;\n\n if (\n scaleOfGivenAmount == null ||\n scaleOfGivenAmount > dineroCurrency.exponent\n ) {\n throw new Error(`scaleOfGivenAmount is unsupported ${scaleOfGivenAmount}`);\n }\n const rateInt = floatToInt(\n floatAmount,\n dineroCurrency.base,\n dineroCurrency.exponent,\n );\n return dinero({\n amount: rateInt,\n currency: dineroCurrency,\n });\n};\n\n/**\n * Shorthand for dinero constructor\n *\n * @example\n * getDinero(100, Currency.Usd); // => Dinero.js instance (representing $1)\n */\nexport const getDinero = (amount: Cents, currency: Currency): Dino => {\n // TODO: verify if this is even needed, as dinero might already handle this\n isInt(amount, \"Amount\");\n return dinero({ amount, currency: getDineroCurrency(currency) });\n};\n\n/**\n * Shorthand to get amount from dinero instance\n *\n * FIXME: There is potential issue because we are not trimming scale:\n * multiply(getDinero(100, Currency.Usd), { amount: 100 + percentIncrease, scale: 2 })\n * will result in amount:10600, scale:4 (2*2), because dinero is rounding to safest scale.\n * @see https://v2.dinerojs.com/docs/core-concepts/scale#trimming-scale\n *\n * We should call something like: transformScale(d, currency.exponent)\n * @see https://v2.dinerojs.com/docs/api/conversions/transform-scale\n *\n * @example\n * amount(getDinero(100, Currency.Usd)); // 100\n */\nexport const amount = (dinero: Dino): Cents => {\n return toSnapshot(dinero).amount;\n};\n\n/**\n * Method to multiply dinero amount by full percent.\n * It also transforms scale back to currency exponent.\n * Where in case 20.34*1.06=21,5604, it will round to 21.56\n *\n * Will convert 0.01 - 12% to 0, but thats edge case we can tolerate, because\n * of dinero version we do not control rounding\n */\nexport const multiplyByFullPercent = (\n dinero: Dino,\n percentIncrease: number,\n): Dino => {\n assert(\n percentIncrease >= -100 && percentIncrease <= 100,\n \"Range should be in [-100, 100]\",\n );\n // (106 / 10^2 = 1.06)\n const multiplyResult = multiply(dinero, {\n amount: 100 + percentIncrease,\n scale: 2,\n });\n return transformScale(\n multiplyResult,\n multiplyResult.toJSON().currency.exponent,\n );\n};\n\n/**\n * Shorthand to get currency from dinero instance\n *\n * @example\n * currency(getDinero(100, Currency.Usd)); // Currency.Usd\n */\nexport const currency = (dinero: Dino): Currency => {\n return parseCurrencyCode(toSnapshot(dinero).currency.code);\n};\n\n/**\n * Shorthand to get our GraphQL Money type from dinero instance\n *\n * @example\n * money(getDinero(100, Currency.Usd)); // { amount: 100, currency: Currency.Usd }\n */\nexport const money = (dinero: Dino): Money => {\n const { amount, currency } = toSnapshot(dinero);\n\n return {\n amount,\n currency: parseCurrencyCode(currency.code),\n };\n};\n\n/**\n * Helper to quickly add multiple dinero instances with same currency\n *\n * @example\n * addMany([getDinero(100, Currency.Usd), getDinero(200, Currency.Usd)], Currency.Usd); // => Dinero.js instance (representing $3)\n */\nexport const addMany = (addends: Array<Dino>, defaultCurrency: Currency) =>\n addends.reduce(add, getDinero(0, defaultCurrency));\n\n/**\n * Helper to quickly subtract multiple dinero instances with same currency\n */\nexport const subtractMany = (\n subtractions: Array<Dino>,\n defaultCurrency: Currency,\n // eslint-disable-next-line sonarjs/reduce-initial-value\n) => [...subtractions, getDinero(0, defaultCurrency)].reduce(subtract);\n\n/**\n * Helper to quickly get dinero object from string\n */\nexport const stringAmountToDinero = (price: string, currency: Currency) =>\n // FIXME: parseFloat seems dangerous O_O\n parseFloatToDinero(parseFloat(price), currency);\n\n/**\n * Helper to quickly round dinero object to closest integer by a given rounding function\n * FIXME: add tests\n *\n * @example\n * roundDinero(getDinero(120, Currency.Usd), Math.floor); // => Dinero.js instance (representing $1)\n * roundDinero(getDinero(120, Currency.Usd), Math.ceil); // => Dinero.js instance (representing $2)\n */\nexport const roundDinero = (dinero: Dino, roundingFn: RoundingFn): Dino => {\n const roundedUnitPrice = toUnit(dinero, { digits: 0, round: roundingFn });\n\n const snapshot = toSnapshot(dinero);\n\n return dinero.create({\n /**\n * Rounding to mitigate floating precision errors:\n *\n * 8.2 * 10 ** 2 = 819.9999999999999\n * 2.2 * 10 ** 2 = 220.00000000000003\n */\n amount: Math.round(\n roundedUnitPrice * snapshot.currency.base ** snapshot.currency.exponent,\n ),\n currency: snapshot.currency,\n });\n};\n"],"names":["toSmallestSubunit","total","hasSubUnits","totalJson","toJSON","roundToDigits","roundingMode","smallestSubunitLookup","get","currency","code","roundDinero","getDineroCurrency","dineroCurrency","dineroCurrenciesLookup","assert","parseCurrencyCode","normalizedCode","capitalize","toLowerCase","currencyLookup","has","Currency","centsToCurrencyUnit","centsAmount","dineroObj","dinero","amount","dineroToCurrencyUnit","toUnit","parseFloatToDinero","floatAmount","parseFloatToDineroRaw","isFloat","scaleOfGivenAmount","String","split","length","exponent","Error","rateInt","floatToInt","base","getDinero","isInt","toSnapshot","multiplyByFullPercent","percentIncrease","multiplyResult","multiply","scale","transformScale","money","addMany","addends","defaultCurrency","reduce","add","subtractMany","subtractions","subtract","stringAmountToDinero","price","parseFloat","roundingFn","roundedUnitPrice","digits","round","snapshot","create","Math"],"mappings":";;;;;;;;;AA6Ba,MAAAA,iBAAA,GAAqBC,KAAsB,IAAA;EAElD,IAAA,CAACC,WAAY,CAAAD,KAAK,CAAG,EAAA;IAChB,OAAAA,KAAA;EACT;EAEM,MAAAE,SAAA,GAAYF,MA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nB1C,QAAQ2C,IAAK,CAAAH,KAAA,CACXF,gBAAmB,GAAAG,QAAA,CAAS3D,QAAS,CAAAiC,IAAA,IAAQ0B,SAAS3D,QAAS,CAAA6B,QACjE,CAAA;IACA7B,UAAU2D,QAAS,CAAA3D;EAAA,CACpB,CAAA;AACH,CAAA;"}
@@ -1 +1 @@
1
- {"version":3,"file":"transform-css-module.js","sources":["../../../../src/utils/nextjs/ssr/transform-css-module.ts"],"sourcesContent":["import type { PluginObj } from \"@babel/core\";\nimport * as t from \"@babel/types\";\nimport crypto from \"node:crypto\";\n\nfunction generateMd5(input: string): string {\n return crypto.createHash(\"md5\").update(input).digest(\"hex\");\n}\n\ntype Plugin = PluginObj<{\n // Store the name of the default import identifier for \"style-inject.es.js\"\n defaultImportName: null | string;\n}>;\n\n/**\n * FIXME: Currently this plugin won't:\n * - Handle existing source maps correctly and would strip from the output: \"//#\n * sourceMappingURL=BubbleContainer.module.css.js.map\"\n */\nexport const transformCssModule = (): Plugin => {\n return {\n visitor: {\n // Step 0: Setup state\n Program(_path, state) {\n state[\"defaultImportName\"] = null;\n },\n // Step 1: Find the default import from \"style-inject.es.js\"\n ImportDeclaration(path, state) {\n // Skip, if the default import name is already found (assuming there is only one per-file)\n if (state[\"defaultImportName\"]) {\n return;\n }\n\n // Look for imports for \"style-inject.es.js\" file\n const importSource = path.node.source.value;\n if (!importSource.endsWith(\"style-inject.es.js\")) {\n return;\n }\n\n // Check for default import specifier\n const defaultSpecifier = path.node.specifiers.find((specifier) =>\n t.isImportDefaultSpecifier(specifier),\n ) as t.ImportDefaultSpecifier | undefined;\n\n // Store the default import name\n if (defaultSpecifier) {\n // Fail if two instances of file is found\n state[\"defaultImportName\"] = defaultSpecifier.local.name;\n } else {\n throw new Error(\n \"Import for `style-inject.es.js` file not found in file\",\n );\n }\n },\n\n // Step 2: Find all calls to the imported identifier\n CallExpression(path, state) {\n // Ignore if the default import name is not found\n if (!state[\"defaultImportName\"]) {\n return;\n }\n\n // Check if the callee is the default import identifier\n const callee = path.node.callee;\n if (\n t.isIdentifier(callee) &&\n callee.name === state[\"defaultImportName\"]\n ) {\n const args = path.node.arguments;\n\n // If arguments are not between 1 and 2, fail\n if (!(args.length >= 1 && args.length <= 2)) {\n throw new Error(\"Unexpected number of arguments\");\n }\n\n /**\n * Validates that the function arguments are:\n * 1. needs to be a string literal or variable holding string\n * 2. (optional) string literal\n */\n if (\n !(\n (t.isStringLiteral(args[0]) || t.isIdentifier(args[0])) &&\n (!args[1] || t.isStringLiteral(args[1]))\n )\n ) {\n throw new Error(\"Unexpected argument types\");\n }\n\n // CSS string\n let cssString: string = \"\";\n\n // Try to remove duplicate string literal as first argument and instead re-use the a already generated variable\n if (t.isStringLiteral(args[0])) {\n cssString = args[0].value;\n\n let reusedVariable = null;\n path.scope.path.traverse({\n VariableDeclarator(variablePath) {\n const { id, init } = variablePath.node;\n\n // Match variables initialized with the same string value.\n if (t.isStringLiteral(init, { value: cssString })) {\n reusedVariable = id;\n variablePath.stop(); // Stop traversing once a match is found.\n }\n },\n });\n\n // Replace the string literal with the existing variable reference.\n if (reusedVariable) {\n path.node.arguments[0] = reusedVariable;\n }\n } else if (t.isIdentifier(args[0])) {\n // Extract value from variable\n const binding = path.scope.getBinding(args[0].name);\n if (\n binding &&\n t.isVariableDeclarator(binding.path.node) &&\n t.isStringLiteral(binding.path.node.init)\n ) {\n cssString = binding.path.node.init.value;\n }\n }\n\n if (!cssString) {\n throw new Error(\"Invalid first argument value\");\n }\n\n // Generate MD5 hash of the first argument's value\n // TODO: Looked into that styled-components use murmurhash. Also it's possible to use sha1 for longer key\n // (less % of collision)\n const hash = generateMd5(cssString);\n\n // Add the hash as the second argument\n const hashArg = t.stringLiteral(hash);\n if (args.length > 1) {\n // If a second argument exists, replace it\n args[1] = hashArg;\n } else {\n // Otherwise, add it as a new second argument\n args.push(hashArg);\n }\n }\n },\n },\n } satisfies Plugin;\n};\n"],"names":["generateMd5","input","crypto","createHash","update","digest","transformCssModule","visitor","Program","_path","state","ImportDeclaration","path","importSource","node","source","value","endsWith","defaultSpecifier","specifiers","find","specifier","t","isImportDefaultSpecifier","local","name","Error","CallExpression","callee","isIdentifier","args","arguments","length","isStringLiteral","cssString","reusedVariable","scope","traverse","VariableDeclarator","variablePath","id","init","stop","binding","getBinding","isVariableDeclarator","hash","hashArg","stringLiteral","push"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAASA,YAAYC,KAAuB,EAAA;EACnC,OAAAC,eAAA,CAAA,SAAA,CAAA,CAAOC,WAAW,KAAK,CAAA,CAAEC,OAAOH,KAAK,CAAA,CAAEI,OAAO,KAAK,CAAA;AAC5D;AAYO,MAAMC,qBAAqBA,CAAA,KAAc;EACvC,OAAA;IACLC,OAAS,EAAA;MAAA;MAEPC,OAAAA,CAAQC,OAAOC,KAAO,EAAA;QACpBA,KAAA,CAAM,mBAAmB,CAAI,GAAA,IAAA;MAC/B,CAAA;MAAA;MAEAC,iBAAAA,CAAkBC,MAAMF,KAAO,EAAA;QAEzB,IAAAA,KAAA,CAAM,mBAAmB,CAAG,EAAA;UAC9B;QACF;QAGM,MAAAG,YAAA,GAAeD,IAAK,CAAAE,IAAA,CAAKC,MAAO,CAAAC,KAAA;QACtC,IAAI,CAACH,YAAA,CAAaI,QAAS,CAAA,oBAAoB,CAAG,EAAA;UAChD;QACF;QAGM,MAAAC,gBAAA,GAAmBN,IAAK,CAAAE,IAAA,CAAKK,UAAW,CAAAC,IAAA,CAAMC,SAAA,IAClDC,YAAE,CAAAC,wBAAA,CAAyBF,SAAS,CAAA,CACtC;QAGA,IAAIH,gBAAkB,EAAA;UAEdR,KAAA,CAAA,mBAAmB,CAAI,GAAAQ,gBAAA,CAAiBM,KAAM,CAAAC,IAAA;QAAA,CAC/C,MAAA;UACL,MAAM,IAAIC,KAAA,CACR,wDAAA,CACF;QACF;MACF,CAAA;MAAA;MAGAC,cAAAA,CAAef,MAAMF,KAAO,EAAA;QAEtB,IAAA,CAACA,K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pB;cACF;YAAA,CACD,CAAA;YAGD,IAAIP,cAAgB,EAAA;cACbvB,IAAA,CAAAE,IAAA,CAAKiB,SAAU,CAAA,CAAC,CAAI,GAAAI,cAAA;YAC3B;qBACSb,YAAE,CAAAO,YAAA,CAAaC,IAAK,CAAA,CAAC,CAAC,CAAG,EAAA;YAElC,MAAMa,UAAU/B,IAAK,CAAAwB,KAAA,CAAMQ,WAAWd,IAAK,CAAA,CAAC,EAAEL,IAAI,CAAA;YAClD,IACEkB,OACA,IAAArB,YAAA,CAAEuB,oBAAqB,CAAAF,OAAA,CAAQ/B,IAAK,CAAAE,IAAI,CACxC,IAAAQ,YAAA,CAAEW,eAAgB,CAAAU,OAAA,CAAQ/B,IAAK,CAAAE,IAAA,CAAK2B,IAAI,CACxC,EAAA;cACYP,SAAA,GAAAS,OAAA,CAAQ/B,IAAK,CAAAE,IAAA,CAAK2B,IAAK,CAAAzB,KAAA;YACrC;UACF;UAEA,IAAI,CAACkB,SAAW,EAAA;YACR,MAAA,IAAIR,MAAM,8BAA8B,CAAA;UAChD;UAKM,MAAAoB,IAAA,GAAO9C,YAAYkC,SAAS,CAAA;UAG5B,MAAAa,OAAA,GAAUzB,YAAE,CAAA0B,aAAA,CAAcF,IAAI,CAAA;UAChC,IAAAhB,IAAA,CAAKE,SAAS,CAAG,EAAA;YAEnBF,IAAA,CAAK,CAAC,CAAI,GAAAiB,OAAA;UAAA,CACL,MAAA;YAELjB,IAAA,CAAKmB,KAAKF,OAAO,CAAA;UACnB;QACF;MACF;IACF;EAAA,CACF;AACF,CAAA;"}
1
+ {"version":3,"file":"transform-css-module.js","sources":["../../../../src/utils/nextjs/ssr/transform-css-module.ts"],"sourcesContent":["import type { PluginObj } from \"@babel/core\";\nimport * as t from \"@babel/types\";\nimport crypto from \"node:crypto\";\n\nfunction generateMd5(input: string): string {\n // eslint-disable-next-line sonarjs/hashing\n return crypto.createHash(\"md5\").update(input).digest(\"hex\");\n}\n\ntype Plugin = PluginObj<{\n // Store the name of the default import identifier for \"style-inject.es.js\"\n defaultImportName: null | string;\n}>;\n\n/**\n * FIXME: Currently this plugin won't:\n * - Handle existing source maps correctly and would strip from the output: \"//#\n * sourceMappingURL=BubbleContainer.module.css.js.map\"\n */\nexport const transformCssModule = (): Plugin => {\n return {\n visitor: {\n // Step 0: Setup state\n Program(_path, state) {\n state[\"defaultImportName\"] = null;\n },\n // Step 1: Find the default import from \"style-inject.es.js\"\n ImportDeclaration(path, state) {\n // Skip, if the default import name is already found (assuming there is only one per-file)\n if (state[\"defaultImportName\"]) {\n return;\n }\n\n // Look for imports for \"style-inject.es.js\" file\n const importSource = path.node.source.value;\n if (!importSource.endsWith(\"style-inject.es.js\")) {\n return;\n }\n\n // Check for default import specifier\n const defaultSpecifier = path.node.specifiers.find((specifier) =>\n t.isImportDefaultSpecifier(specifier),\n ) as t.ImportDefaultSpecifier | undefined;\n\n // Store the default import name\n if (defaultSpecifier) {\n // Fail if two instances of file is found\n state[\"defaultImportName\"] = defaultSpecifier.local.name;\n } else {\n throw new Error(\n \"Import for `style-inject.es.js` file not found in file\",\n );\n }\n },\n\n // Step 2: Find all calls to the imported identifier\n CallExpression(path, state) {\n // Ignore if the default import name is not found\n if (!state[\"defaultImportName\"]) {\n return;\n }\n\n // Check if the callee is the default import identifier\n const callee = path.node.callee;\n if (\n t.isIdentifier(callee) &&\n callee.name === state[\"defaultImportName\"]\n ) {\n const args = path.node.arguments;\n\n // If arguments are not between 1 and 2, fail\n if (!(args.length >= 1 && args.length <= 2)) {\n throw new Error(\"Unexpected number of arguments\");\n }\n\n /**\n * Validates that the function arguments are:\n * 1. needs to be a string literal or variable holding string\n * 2. (optional) string literal\n */\n if (\n !(\n (t.isStringLiteral(args[0]) || t.isIdentifier(args[0])) &&\n (!args[1] || t.isStringLiteral(args[1]))\n )\n ) {\n throw new Error(\"Unexpected argument types\");\n }\n\n // CSS string\n let cssString: string = \"\";\n\n // Try to remove duplicate string literal as first argument and instead re-use the a already generated variable\n if (t.isStringLiteral(args[0])) {\n cssString = args[0].value;\n\n let reusedVariable = null;\n path.scope.path.traverse({\n VariableDeclarator(variablePath) {\n const { id, init } = variablePath.node;\n\n // Match variables initialized with the same string value.\n if (t.isStringLiteral(init, { value: cssString })) {\n reusedVariable = id;\n variablePath.stop(); // Stop traversing once a match is found.\n }\n },\n });\n\n // Replace the string literal with the existing variable reference.\n if (reusedVariable) {\n path.node.arguments[0] = reusedVariable;\n }\n } else if (t.isIdentifier(args[0])) {\n // Extract value from variable\n const binding = path.scope.getBinding(args[0].name);\n if (\n binding &&\n t.isVariableDeclarator(binding.path.node) &&\n t.isStringLiteral(binding.path.node.init)\n ) {\n cssString = binding.path.node.init.value;\n }\n }\n\n if (!cssString) {\n throw new Error(\"Invalid first argument value\");\n }\n\n // Generate MD5 hash of the first argument's value\n // TODO: Looked into that styled-components use murmurhash. Also it's possible to use sha1 for longer key\n // (less % of collision)\n const hash = generateMd5(cssString);\n\n // Add the hash as the second argument\n const hashArg = t.stringLiteral(hash);\n if (args.length > 1) {\n // If a second argument exists, replace it\n args[1] = hashArg;\n } else {\n // Otherwise, add it as a new second argument\n args.push(hashArg);\n }\n }\n },\n },\n } satisfies Plugin;\n};\n"],"names":["generateMd5","input","crypto","createHash","update","digest","transformCssModule","visitor","Program","_path","state","ImportDeclaration","path","importSource","node","source","value","endsWith","defaultSpecifier","specifiers","find","specifier","t","isImportDefaultSpecifier","local","name","Error","CallExpression","callee","isIdentifier","args","arguments","length","isStringLiteral","cssString","reusedVariable","scope","traverse","VariableDeclarator","variablePath","id","init","stop","binding","getBinding","isVariableDeclarator","hash","hashArg","stringLiteral","push"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAASA,YAAYC,KAAuB,EAAA;EAEnC,OAAAC,eAAA,CAAA,SAAA,CAAA,CAAOC,WAAW,KAAK,CAAA,CAAEC,OAAOH,KAAK,CAAA,CAAEI,OAAO,KAAK,CAAA;AAC5D;AAYO,MAAMC,qBAAqBA,CA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,IAAK,CAAAE,IAAA,CAAK2B,IAAI,CACxC,EAAA;cACYP,SAAA,GAAAS,OAAA,CAAQ/B,IAAK,CAAAE,IAAA,CAAK2B,IAAK,CAAAzB,KAAA;YACrC;UACF;UAEA,IAAI,CAACkB,SAAW,EAAA;YACR,MAAA,IAAIR,MAAM,8BAA8B,CAAA;UAChD;UAKM,MAAAoB,IAAA,GAAO9C,YAAYkC,SAAS,CAAA;UAG5B,MAAAa,OAAA,GAAUzB,YAAE,CAAA0B,aAAA,CAAcF,IAAI,CAAA;UAChC,IAAAhB,IAAA,CAAKE,SAAS,CAAG,EAAA;YAEnBF,IAAA,CAAK,CAAC,CAAI,GAAAiB,OAAA;UAAA,CACL,MAAA;YAELjB,IAAA,CAAKmB,KAAKF,OAAO,CAAA;UACnB;QACF;MACF;IACF;EAAA,CACF;AACF,CAAA;"}
@@ -1 +1 @@
1
- {"version":3,"file":"transform-css-module.mjs","sources":["../../../../src/utils/nextjs/ssr/transform-css-module.ts"],"sourcesContent":["import type { PluginObj } from \"@babel/core\";\nimport * as t from \"@babel/types\";\nimport crypto from \"node:crypto\";\n\nfunction generateMd5(input: string): string {\n return crypto.createHash(\"md5\").update(input).digest(\"hex\");\n}\n\ntype Plugin = PluginObj<{\n // Store the name of the default import identifier for \"style-inject.es.js\"\n defaultImportName: null | string;\n}>;\n\n/**\n * FIXME: Currently this plugin won't:\n * - Handle existing source maps correctly and would strip from the output: \"//#\n * sourceMappingURL=BubbleContainer.module.css.js.map\"\n */\nexport const transformCssModule = (): Plugin => {\n return {\n visitor: {\n // Step 0: Setup state\n Program(_path, state) {\n state[\"defaultImportName\"] = null;\n },\n // Step 1: Find the default import from \"style-inject.es.js\"\n ImportDeclaration(path, state) {\n // Skip, if the default import name is already found (assuming there is only one per-file)\n if (state[\"defaultImportName\"]) {\n return;\n }\n\n // Look for imports for \"style-inject.es.js\" file\n const importSource = path.node.source.value;\n if (!importSource.endsWith(\"style-inject.es.js\")) {\n return;\n }\n\n // Check for default import specifier\n const defaultSpecifier = path.node.specifiers.find((specifier) =>\n t.isImportDefaultSpecifier(specifier),\n ) as t.ImportDefaultSpecifier | undefined;\n\n // Store the default import name\n if (defaultSpecifier) {\n // Fail if two instances of file is found\n state[\"defaultImportName\"] = defaultSpecifier.local.name;\n } else {\n throw new Error(\n \"Import for `style-inject.es.js` file not found in file\",\n );\n }\n },\n\n // Step 2: Find all calls to the imported identifier\n CallExpression(path, state) {\n // Ignore if the default import name is not found\n if (!state[\"defaultImportName\"]) {\n return;\n }\n\n // Check if the callee is the default import identifier\n const callee = path.node.callee;\n if (\n t.isIdentifier(callee) &&\n callee.name === state[\"defaultImportName\"]\n ) {\n const args = path.node.arguments;\n\n // If arguments are not between 1 and 2, fail\n if (!(args.length >= 1 && args.length <= 2)) {\n throw new Error(\"Unexpected number of arguments\");\n }\n\n /**\n * Validates that the function arguments are:\n * 1. needs to be a string literal or variable holding string\n * 2. (optional) string literal\n */\n if (\n !(\n (t.isStringLiteral(args[0]) || t.isIdentifier(args[0])) &&\n (!args[1] || t.isStringLiteral(args[1]))\n )\n ) {\n throw new Error(\"Unexpected argument types\");\n }\n\n // CSS string\n let cssString: string = \"\";\n\n // Try to remove duplicate string literal as first argument and instead re-use the a already generated variable\n if (t.isStringLiteral(args[0])) {\n cssString = args[0].value;\n\n let reusedVariable = null;\n path.scope.path.traverse({\n VariableDeclarator(variablePath) {\n const { id, init } = variablePath.node;\n\n // Match variables initialized with the same string value.\n if (t.isStringLiteral(init, { value: cssString })) {\n reusedVariable = id;\n variablePath.stop(); // Stop traversing once a match is found.\n }\n },\n });\n\n // Replace the string literal with the existing variable reference.\n if (reusedVariable) {\n path.node.arguments[0] = reusedVariable;\n }\n } else if (t.isIdentifier(args[0])) {\n // Extract value from variable\n const binding = path.scope.getBinding(args[0].name);\n if (\n binding &&\n t.isVariableDeclarator(binding.path.node) &&\n t.isStringLiteral(binding.path.node.init)\n ) {\n cssString = binding.path.node.init.value;\n }\n }\n\n if (!cssString) {\n throw new Error(\"Invalid first argument value\");\n }\n\n // Generate MD5 hash of the first argument's value\n // TODO: Looked into that styled-components use murmurhash. Also it's possible to use sha1 for longer key\n // (less % of collision)\n const hash = generateMd5(cssString);\n\n // Add the hash as the second argument\n const hashArg = t.stringLiteral(hash);\n if (args.length > 1) {\n // If a second argument exists, replace it\n args[1] = hashArg;\n } else {\n // Otherwise, add it as a new second argument\n args.push(hashArg);\n }\n }\n },\n },\n } satisfies Plugin;\n};\n"],"names":["generateMd5","input","crypto","createHash","update","digest","transformCssModule","visitor","Program","_path","state","ImportDeclaration","path","importSource","node","source","value","endsWith","defaultSpecifier","specifiers","find","specifier","t","isImportDefaultSpecifier","local","name","Error","CallExpression","callee","isIdentifier","args","arguments","length","isStringLiteral","cssString","reusedVariable","scope","traverse","VariableDeclarator","variablePath","id","init","stop","binding","getBinding","isVariableDeclarator","hash","hashArg","stringLiteral","push"],"mappings":";;;AAIA,SAASA,YAAYC,KAAuB,EAAA;EACnC,OAAAC,MAAA,CAAOC,WAAW,KAAK,CAAA,CAAEC,OAAOH,KAAK,CAAA,CAAEI,OAAO,KAAK,CAAA;AAC5D;AAYO,MAAMC,qBAAqBA,CAAA,KAAc;EACvC,OAAA;IACLC,OAAS,EAAA;MAAA;MAEPC,OAAAA,CAAQC,OAAOC,KAAO,EAAA;QACpBA,KAAA,CAAM,mBAAmB,CAAI,GAAA,IAAA;MAC/B,CAAA;MAAA;MAEAC,iBAAAA,CAAkBC,MAAMF,KAAO,EAAA;QAEzB,IAAAA,KAAA,CAAM,mBAAmB,CAAG,EAAA;UAC9B;QACF;QAGM,MAAAG,YAAA,GAAeD,IAAK,CAAAE,IAAA,CAAKC,MAAO,CAAAC,KAAA;QACtC,IAAI,CAACH,YAAA,CAAaI,QAAS,CAAA,oBAAoB,CAAG,EAAA;UAChD;QACF;QAGM,MAAAC,gBAAA,GAAmBN,IAAK,CAAAE,IAAA,CAAKK,UAAW,CAAAC,IAAA,CAAMC,SAAA,IAClDC,CAAE,CAAA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AAA,CACF;AACF,CAAA;"}
1
+ {"version":3,"file":"transform-css-module.mjs","sources":["../../../../src/utils/nextjs/ssr/transform-css-module.ts"],"sourcesContent":["import type { PluginObj } from \"@babel/core\";\nimport * as t from \"@babel/types\";\nimport crypto from \"node:crypto\";\n\nfunction generateMd5(input: string): string {\n // eslint-disable-next-line sonarjs/hashing\n return crypto.createHash(\"md5\").update(input).digest(\"hex\");\n}\n\ntype Plugin = PluginObj<{\n // Store the name of the default import identifier for \"style-inject.es.js\"\n defaultImportName: null | string;\n}>;\n\n/**\n * FIXME: Currently this plugin won't:\n * - Handle existing source maps correctly and would strip from the output: \"//#\n * sourceMappingURL=BubbleContainer.module.css.js.map\"\n */\nexport const transformCssModule = (): Plugin => {\n return {\n visitor: {\n // Step 0: Setup state\n Program(_path, state) {\n state[\"defaultImportName\"] = null;\n },\n // Step 1: Find the default import from \"style-inject.es.js\"\n ImportDeclaration(path, state) {\n // Skip, if the default import name is already found (assuming there is only one per-file)\n if (state[\"defaultImportName\"]) {\n return;\n }\n\n // Look for imports for \"style-inject.es.js\" file\n const importSource = path.node.source.value;\n if (!importSource.endsWith(\"style-inject.es.js\")) {\n return;\n }\n\n // Check for default import specifier\n const defaultSpecifier = path.node.specifiers.find((specifier) =>\n t.isImportDefaultSpecifier(specifier),\n ) as t.ImportDefaultSpecifier | undefined;\n\n // Store the default import name\n if (defaultSpecifier) {\n // Fail if two instances of file is found\n state[\"defaultImportName\"] = defaultSpecifier.local.name;\n } else {\n throw new Error(\n \"Import for `style-inject.es.js` file not found in file\",\n );\n }\n },\n\n // Step 2: Find all calls to the imported identifier\n CallExpression(path, state) {\n // Ignore if the default import name is not found\n if (!state[\"defaultImportName\"]) {\n return;\n }\n\n // Check if the callee is the default import identifier\n const callee = path.node.callee;\n if (\n t.isIdentifier(callee) &&\n callee.name === state[\"defaultImportName\"]\n ) {\n const args = path.node.arguments;\n\n // If arguments are not between 1 and 2, fail\n if (!(args.length >= 1 && args.length <= 2)) {\n throw new Error(\"Unexpected number of arguments\");\n }\n\n /**\n * Validates that the function arguments are:\n * 1. needs to be a string literal or variable holding string\n * 2. (optional) string literal\n */\n if (\n !(\n (t.isStringLiteral(args[0]) || t.isIdentifier(args[0])) &&\n (!args[1] || t.isStringLiteral(args[1]))\n )\n ) {\n throw new Error(\"Unexpected argument types\");\n }\n\n // CSS string\n let cssString: string = \"\";\n\n // Try to remove duplicate string literal as first argument and instead re-use the a already generated variable\n if (t.isStringLiteral(args[0])) {\n cssString = args[0].value;\n\n let reusedVariable = null;\n path.scope.path.traverse({\n VariableDeclarator(variablePath) {\n const { id, init } = variablePath.node;\n\n // Match variables initialized with the same string value.\n if (t.isStringLiteral(init, { value: cssString })) {\n reusedVariable = id;\n variablePath.stop(); // Stop traversing once a match is found.\n }\n },\n });\n\n // Replace the string literal with the existing variable reference.\n if (reusedVariable) {\n path.node.arguments[0] = reusedVariable;\n }\n } else if (t.isIdentifier(args[0])) {\n // Extract value from variable\n const binding = path.scope.getBinding(args[0].name);\n if (\n binding &&\n t.isVariableDeclarator(binding.path.node) &&\n t.isStringLiteral(binding.path.node.init)\n ) {\n cssString = binding.path.node.init.value;\n }\n }\n\n if (!cssString) {\n throw new Error(\"Invalid first argument value\");\n }\n\n // Generate MD5 hash of the first argument's value\n // TODO: Looked into that styled-components use murmurhash. Also it's possible to use sha1 for longer key\n // (less % of collision)\n const hash = generateMd5(cssString);\n\n // Add the hash as the second argument\n const hashArg = t.stringLiteral(hash);\n if (args.length > 1) {\n // If a second argument exists, replace it\n args[1] = hashArg;\n } else {\n // Otherwise, add it as a new second argument\n args.push(hashArg);\n }\n }\n },\n },\n } satisfies Plugin;\n};\n"],"names":["generateMd5","input","crypto","createHash","update","digest","transformCssModule","visitor","Program","_path","state","ImportDeclaration","path","importSource","node","source","value","endsWith","defaultSpecifier","specifiers","find","specifier","t","isImportDefaultSpecifier","local","name","Error","CallExpression","callee","isIdentifier","args","arguments","length","isStringLiteral","cssString","reusedVariable","scope","traverse","VariableDeclarator","variablePath","id","init","stop","binding","getBinding","isVariableDeclarator","hash","hashArg","stringLiteral","push"],"mappings":";;;AAIA,SAASA,YAAYC,KAAuB,EAAA;EAEnC,OAAAC,MAAA,CAAOC,WAAW,KAAK,CAAA,CAAEC,OAAOH,KAAK,CAAA,CAAEI,OAAO,KAAK,CAAA;AAC5D;AAYO,MAAMC,qBAAqBA,CAAA,KAAc;EACvC,OAAA;IACLC,OAAS,EAAA;MAAA;MAEPC,OAAAA,CAAQC,OAAOC,KAAO,EAAA;QACpBA,KAAA,CAAM,mBAAmB,CAAI,GAAA,IAAA;MAC/B,CAAA;MAAA;MAEAC,iBAAAA,CAAkBC,MAAMF,KAAO,EAAA;QAEzB,IAAAA,KAAA,CAAM,mBAAmB,CAAG,EAAA;UAC9B;QACF;QAGM,MAAAG,YAAA,GAAeD,IAAK,CAAAE,IAAA,CAAKC,MAAO,CAAAC,KAAA;QACtC,IAAI,CAACH,YAAA,CAAaI,QAAS,CAAA,oBAAoB,CAAG,EAAA;UAChD;QACF;QAGM,MAAAC,gBAAA,GAAmBN,IAAK,CAAAE,IAAA,CAAKK,UAAW,CAAAC,IAAA,CAAMC,SAAA,IAClDC,CAAE,CAAAC,wBAAA,CAAyBF,SAAS,CAAA,CACtC;QAGA,IAAIH,gBAAkB,EAAA;UAEdR,KAAA,CAAA,mBAAmB,CAAI,GAAAQ,gBAAA,CAAiBM,KAAM,CAAAC,IAAA;QAAA,CAC/C,MAAA;UACL,MAAM,IAAIC,KAAA,CACR,wDAAA,CACF;QACF;MACF,CAAA;MAAA;MAGAC,cAAAA,CAAef,MAAMF,KAAO,EAAA;QAEtB,IAAA,CAACA,KAAM,CAAA,mBAAmB,CAAG,EAAA;UAC/B;QACF;QAGM,MAAAkB,MAAA,GAAShB,KAAKE,IAAK,CAAAc,MAAA;QAEvB,IAAAN,CAAA,CAAEO,aAAaD,MAAM,CAAA,IACrBA,OAAOH,IAAS,KAAAf,KAAA,CAAM,mBAAmB,CACzC,EAAA;UACM,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AMa,UAAU/B,IAAK,CAAAwB,KAAA,CAAMQ,WAAWd,IAAK,CAAA,CAAC,EAAEL,IAAI,CAAA;YAClD,IACEkB,OACA,IAAArB,CAAA,CAAEuB,oBAAqB,CAAAF,OAAA,CAAQ/B,IAAK,CAAAE,IAAI,CACxC,IAAAQ,CAAA,CAAEW,eAAgB,CAAAU,OAAA,CAAQ/B,IAAK,CAAAE,IAAA,CAAK2B,IAAI,CACxC,EAAA;cACYP,SAAA,GAAAS,OAAA,CAAQ/B,IAAK,CAAAE,IAAA,CAAK2B,IAAK,CAAAzB,KAAA;YACrC;UACF;UAEA,IAAI,CAACkB,SAAW,EAAA;YACR,MAAA,IAAIR,MAAM,8BAA8B,CAAA;UAChD;UAKM,MAAAoB,IAAA,GAAO9C,YAAYkC,SAAS,CAAA;UAG5B,MAAAa,OAAA,GAAUzB,CAAE,CAAA0B,aAAA,CAAcF,IAAI,CAAA;UAChC,IAAAhB,IAAA,CAAKE,SAAS,CAAG,EAAA;YAEnBF,IAAA,CAAK,CAAC,CAAI,GAAAiB,OAAA;UAAA,CACL,MAAA;YAELjB,IAAA,CAAKmB,KAAKF,OAAO,CAAA;UACnB;QACF;MACF;IACF;EAAA,CACF;AACF,CAAA;"}
@@ -1 +1 @@
1
- {"version":3,"file":"number.js","sources":["../../src/utils/number.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n\n/**\n * Custom isFloat validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.parseFloat would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L34-L38\n * @throws If given input is not a valid float\n */\nexport function isFloat(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n}\n\n/**\n * Returns a string representing a number in fixed-point notation.\n * Overload: Returns the rate parsed as a number\n * @example\n * toFixed(1.2345, 2) // => \"1.23\"\n * toFixed(1.2345, 0) // => \"1\"\n * toFixed(1.23, 4) // => \"1.2300\"\n */\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber?: boolean,\n): string;\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber: true,\n): number;\nexport function toFixedRate(rate: number, scale: number, asNumber?: boolean) {\n // Verify rate\n isFloat(rate, \"Rate\");\n\n const fixedRate = rate.toFixed(scale);\n\n return asNumber ? +fixedRate : fixedRate;\n}\n\n/**\n * Util to convert a float number to a string. Using this rather than simple template string to have a consistent way of\n * doing it. Removes any redundant trailing zeros.\n * @example\n * numberToString(1.23) // => \"1.23\"\n * numberToString(10.00) // => \"10\"\n * @throws If given input is not a valid number\n */\nexport const numberToString = (num: number): string => {\n isFloat(num);\n return num.toString(10);\n};\n\n/**\n * @see https://stackoverflow.com/a/35000557\n */\nexport const findClosestNumber = <T extends number>(\n haystack: T[],\n needle: number,\n): T => {\n return haystack.reduce((prev, curr) =>\n Math.abs(curr - needle) < Math.abs(prev - needle) ? curr : prev,\n );\n};\n\n/**\n * Splits number into array by max value provided.\n * E.g. splitNumberBy(100, 30) => [30, 30, 30, 10]\n */\nexport const splitNumberBy = (value: number, by: number) => {\n const chunks = new Array(Math.floor(value / by)).fill(by);\n const remainder = value % by;\n\n if (remainder > 0) {\n chunks.push(remainder);\n }\n\n return chunks;\n};\n\n/**\n * Clamp value to a given range\n */\nexport const clamp = (val: number, min: number, max: number) => {\n const trueMin = Math.min(min, max);\n const trueMax = Math.max(min, max);\n\n return Math.min(trueMax, Math.max(trueMin, val));\n};\n\n/**\n * Interpolate a number to a new range\n *\n * @example\n * linearInterpolate(5, [0, 10], [0, 100]); // 50\n */\nexport const linearInterpolate = (\n inputY: number,\n [fromMin, fromMax]: [number, number],\n [toMin, toMax]: [number, number],\n clampResult = true,\n) => {\n const percent = (inputY - fromMin) / (fromMax - fromMin);\n const outputX = percent * (toMax - toMin) + toMin;\n\n return clampResult ? clamp(outputX, toMin, toMax) : outputX;\n};\n\n/**\n * Increase value and start over once the range is overflown\n */\nexport const incrementLoopValue = (\n value: number,\n [min, max]: [number, number],\n) => {\n if (value === max) {\n return min;\n }\n return value + 1;\n};\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger","isFloat","toFixedRate","rate","scale","asNumber","fixedRate","toFixed","numberToString","num","toString","findClosestNumber","haystack","needle","reduce","prev","curr","Math","abs","splitNumberBy","by","chunks","Array","floor","fill","remainder","push","clamp","val","min","max","trueMin","trueMax","linearInterpolate","inputY","fromMin","fromMax","toMin","toMax","clampResult","percent","outputX","incrementLoopValue"],"mappings":";;;AAIO,SAASA,cACdA,CAAAC,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA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AAUD,OAAW,IAAAF,KAAA,GAAQD,KAAS,CAAA,GAAAA,KAAA;EAE5C,OAAOE,WAAc,GAAAZ,KAAA,CAAMc,OAAS,EAAAJ,KAAA,EAAOC,KAAK,CAAI,GAAAG,OAAA;AACtD,CAAA;AAKO,MAAMC,qBAAqBA,CAChCnD,KAAA,EACA,CAACsC,GAAA,EAAKC,GAAG,CACN,KAAA;EACH,IAAIvC,UAAUuC,GAAK,EAAA;IACV,OAAAD,GAAA;EACT;EACA,OAAOtC,KAAQ,GAAA,CAAA;AACjB,CAAA;;;;;;;;;;"}
1
+ {"version":3,"file":"number.js","sources":["../../src/utils/number.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n\n/**\n * Custom isFloat validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.parseFloat would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L34-L38\n * @throws If given input is not a valid float\n */\nexport function isFloat(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n}\n\n/**\n * Returns a string representing a number in fixed-point notation.\n * Overload: Returns the rate parsed as a number\n * @example\n * toFixed(1.2345, 2) // => \"1.23\"\n * toFixed(1.2345, 0) // => \"1\"\n * toFixed(1.23, 4) // => \"1.2300\"\n */\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber?: boolean,\n): string;\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber: true,\n): number;\nexport function toFixedRate(rate: number, scale: number, asNumber?: boolean) {\n // Verify rate\n isFloat(rate, \"Rate\");\n\n const fixedRate = rate.toFixed(scale);\n\n return asNumber ? +fixedRate : fixedRate;\n}\n\n/**\n * Util to convert a float number to a string. Using this rather than simple template string to have a consistent way of\n * doing it. Removes any redundant trailing zeros.\n * @example\n * numberToString(1.23) // => \"1.23\"\n * numberToString(10.00) // => \"10\"\n * @throws If given input is not a valid number\n */\nexport const numberToString = (num: number): string => {\n isFloat(num);\n return num.toString(10);\n};\n\n/**\n * @see https://stackoverflow.com/a/35000557\n */\nexport const findClosestNumber = <T extends number>(\n haystack: T[],\n needle: number,\n): T => {\n // eslint-disable-next-line sonarjs/reduce-initial-value\n return haystack.reduce((prev, curr) =>\n Math.abs(curr - needle) < Math.abs(prev - needle) ? curr : prev,\n );\n};\n\n/**\n * Splits number into array by max value provided.\n * E.g. splitNumberBy(100, 30) => [30, 30, 30, 10]\n */\nexport const splitNumberBy = (value: number, by: number) => {\n const chunks = new Array(Math.floor(value / by)).fill(by);\n const remainder = value % by;\n\n if (remainder > 0) {\n chunks.push(remainder);\n }\n\n return chunks;\n};\n\n/**\n * Clamp value to a given range\n */\nexport const clamp = (val: number, min: number, max: number) => {\n const trueMin = Math.min(min, max);\n const trueMax = Math.max(min, max);\n\n return Math.min(trueMax, Math.max(trueMin, val));\n};\n\n/**\n * Interpolate a number to a new range\n *\n * @example\n * linearInterpolate(5, [0, 10], [0, 100]); // 50\n */\nexport const linearInterpolate = (\n inputY: number,\n [fromMin, fromMax]: [number, number],\n [toMin, toMax]: [number, number],\n clampResult = true,\n) => {\n const percent = (inputY - fromMin) / (fromMax - fromMin);\n const outputX = percent * (toMax - toMin) + toMin;\n\n return clampResult ? clamp(outputX, toMin, toMax) : outputX;\n};\n\n/**\n * Increase value and start over once the range is overflown\n */\nexport const incrementLoopValue = (\n value: number,\n [min, max]: [number, number],\n) => {\n if (value === max) {\n return min;\n }\n return value + 1;\n};\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger","isFloat","toFixedRate","rate","scale","asNumber","fixedRate","toFixed","numberToString","num","toString","findClosestNumber","haystack","needle","reduce","prev","curr","Math","abs","splitNumberBy","by","chunks","Array","floor","fill","remainder","push","clamp","val","min","max","trueMin","trueMax","linearInterpolate","inputY","fromMin","fromMax","toMin","toMax","clampResult","percent","outputX","incrementLoopValue"],"mappings":";;;AAIO,SAASA,cACdA,CAAAC,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACzB,IAAI,OAAOH,KAAU,KAAA,QAAA,IAAYI,MAAO,CAAAC,KAAA,CAAML,KAAK,CAAG,EAAA;IACpD,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,qBAAqBD,KAAK,EAAE,CAAA;EAC5D;EAEA,IAAI,CAACI,MAAA,CAAOE,QAAS,CAAAN,KAAK,CAAG,EAAA;IAC3B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,4BAA4BD,KAAK,EAAE,CAAA;EACnE;AACF;AAWO,SAASO,KACdA,CAAAP,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,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,"file":"number.mjs","sources":["../../src/utils/number.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n\n/**\n * Custom isFloat validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.parseFloat would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L34-L38\n * @throws If given input is not a valid float\n */\nexport function isFloat(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n}\n\n/**\n * Returns a string representing a number in fixed-point notation.\n * Overload: Returns the rate parsed as a number\n * @example\n * toFixed(1.2345, 2) // => \"1.23\"\n * toFixed(1.2345, 0) // => \"1\"\n * toFixed(1.23, 4) // => \"1.2300\"\n */\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber?: boolean,\n): string;\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber: true,\n): number;\nexport function toFixedRate(rate: number, scale: number, asNumber?: boolean) {\n // Verify rate\n isFloat(rate, \"Rate\");\n\n const fixedRate = rate.toFixed(scale);\n\n return asNumber ? +fixedRate : fixedRate;\n}\n\n/**\n * Util to convert a float number to a string. Using this rather than simple template string to have a consistent way of\n * doing it. Removes any redundant trailing zeros.\n * @example\n * numberToString(1.23) // => \"1.23\"\n * numberToString(10.00) // => \"10\"\n * @throws If given input is not a valid number\n */\nexport const numberToString = (num: number): string => {\n isFloat(num);\n return num.toString(10);\n};\n\n/**\n * @see https://stackoverflow.com/a/35000557\n */\nexport const findClosestNumber = <T extends number>(\n haystack: T[],\n needle: number,\n): T => {\n return haystack.reduce((prev, curr) =>\n Math.abs(curr - needle) < Math.abs(prev - needle) ? curr : prev,\n );\n};\n\n/**\n * Splits number into array by max value provided.\n * E.g. splitNumberBy(100, 30) => [30, 30, 30, 10]\n */\nexport const splitNumberBy = (value: number, by: number) => {\n const chunks = new Array(Math.floor(value / by)).fill(by);\n const remainder = value % by;\n\n if (remainder > 0) {\n chunks.push(remainder);\n }\n\n return chunks;\n};\n\n/**\n * Clamp value to a given range\n */\nexport const clamp = (val: number, min: number, max: number) => {\n const trueMin = Math.min(min, max);\n const trueMax = Math.max(min, max);\n\n return Math.min(trueMax, Math.max(trueMin, val));\n};\n\n/**\n * Interpolate a number to a new range\n *\n * @example\n * linearInterpolate(5, [0, 10], [0, 100]); // 50\n */\nexport const linearInterpolate = (\n inputY: number,\n [fromMin, fromMax]: [number, number],\n [toMin, toMax]: [number, number],\n clampResult = true,\n) => {\n const percent = (inputY - fromMin) / (fromMax - fromMin);\n const outputX = percent * (toMax - toMin) + toMin;\n\n return clampResult ? clamp(outputX, toMin, toMax) : outputX;\n};\n\n/**\n * Increase value and start over once the range is overflown\n */\nexport const incrementLoopValue = (\n value: number,\n [min, max]: [number, number],\n) => {\n if (value === max) {\n return min;\n }\n return value + 1;\n};\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger","isFloat","toFixedRate","rate","scale","asNumber","fixedRate","toFixed","numberToString","num","toString","findClosestNumber","haystack","needle","reduce","prev","curr","Math","abs","splitNumberBy","by","chunks","Array","floor","fill","remainder","push","clamp","val","min","max","trueMin","trueMax","linearInterpolate","inputY","fromMin","fromMax","toMin","toMax","clampResult","percent","outputX","incrementLoopValue"],"mappings":";;AAIO,SAASA,cACdA,CAAAC,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACzB,IAAI,OAAOH,KAAU,KAAA,QAAA,IAAYI,MAAO,CAAAC,KAAA,CAAML,KAAK,CAAG,EAAA;IACpD,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,qBAAqBD,KAAK,EAAE,CAAA;EAC5D;EAEA,IAAI,CAACI,MAAA,CAAOE,QAAS,CAAAN,KAAK,CAAG,EAAA;IAC3B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,4BAA4BD,KAAK,EAAE,CAAA;EACnE;AACF;AAWO,SAASO,KACdA,CAAAP,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACVJ,cAAA,CAAAC,KAAA,EAAOC,QAAQC,UAAU,CAAA;EAExC,IAAI,CAACE,MAAA,CAAOI,SAAU,CAAAR,KAAK,CAAG,EAAA;IAC5B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,uBAAuBD,KAAK,EAAE,CAAA;EAC9D;EAEA,IAAI,CAACI,MAAA,CAAOK,aAAc,CAAAT,KAAK,CAAG,EAAA;IAChC,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,2BAA2BD,KAAK,EAAE,CAAA;EAClE;AACF;AAWO,SAASU,OACdA,CAAAV,KAAA,EACAC,MAAS,GAAA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G,CAAA;EACjC,MAAME,OAAU,GAAAf,IAAA,CAAKa,GAAI,CAAAD,GAAA,EAAKC,GAAG,CAAA;EAEjC,OAAOb,KAAKY,GAAI,CAAAG,OAAA,EAASf,KAAKa,GAAI,CAAAC,OAAA,EAASH,GAAG,CAAC,CAAA;AACjD,CAAA;AAQO,MAAMK,iBAAoB,GAAAA,CAC/BC,MACA,EAAA,CAACC,OAAS,EAAAC,OAAO,CACjB,EAAA,CAACC,KAAO,EAAAC,KAAK,CACb,EAAAC,WAAA,GAAc,IACX,KAAA;EACG,MAAAC,OAAA,GAAA,CAAWN,MAAS,GAAAC,OAAA,KAAYC,OAAU,GAAAD,OAAA,CAAA;EAC1C,MAAAM,OAAA,GAAUD,OAAW,IAAAF,KAAA,GAAQD,KAAS,CAAA,GAAAA,KAAA;EAE5C,OAAOE,WAAc,GAAAZ,KAAA,CAAMc,OAAS,EAAAJ,KAAA,EAAOC,KAAK,CAAI,GAAAG,OAAA;AACtD,CAAA;AAKO,MAAMC,qBAAqBA,CAChCnD,KAAA,EACA,CAACsC,GAAA,EAAKC,GAAG,CACN,KAAA;EACH,IAAIvC,UAAUuC,GAAK,EAAA;IACV,OAAAD,GAAA;EACT;EACA,OAAOtC,KAAQ,GAAA,CAAA;AACjB,CAAA;"}
1
+ {"version":3,"file":"number.mjs","sources":["../../src/utils/number.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n\n/**\n * Custom isFloat validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.parseFloat would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L34-L38\n * @throws If given input is not a valid float\n */\nexport function isFloat(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n}\n\n/**\n * Returns a string representing a number in fixed-point notation.\n * Overload: Returns the rate parsed as a number\n * @example\n * toFixed(1.2345, 2) // => \"1.23\"\n * toFixed(1.2345, 0) // => \"1\"\n * toFixed(1.23, 4) // => \"1.2300\"\n */\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber?: boolean,\n): string;\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber: true,\n): number;\nexport function toFixedRate(rate: number, scale: number, asNumber?: boolean) {\n // Verify rate\n isFloat(rate, \"Rate\");\n\n const fixedRate = rate.toFixed(scale);\n\n return asNumber ? +fixedRate : fixedRate;\n}\n\n/**\n * Util to convert a float number to a string. Using this rather than simple template string to have a consistent way of\n * doing it. Removes any redundant trailing zeros.\n * @example\n * numberToString(1.23) // => \"1.23\"\n * numberToString(10.00) // => \"10\"\n * @throws If given input is not a valid number\n */\nexport const numberToString = (num: number): string => {\n isFloat(num);\n return num.toString(10);\n};\n\n/**\n * @see https://stackoverflow.com/a/35000557\n */\nexport const findClosestNumber = <T extends number>(\n haystack: T[],\n needle: number,\n): T => {\n // eslint-disable-next-line sonarjs/reduce-initial-value\n return haystack.reduce((prev, curr) =>\n Math.abs(curr - needle) < Math.abs(prev - needle) ? curr : prev,\n );\n};\n\n/**\n * Splits number into array by max value provided.\n * E.g. splitNumberBy(100, 30) => [30, 30, 30, 10]\n */\nexport const splitNumberBy = (value: number, by: number) => {\n const chunks = new Array(Math.floor(value / by)).fill(by);\n const remainder = value % by;\n\n if (remainder > 0) {\n chunks.push(remainder);\n }\n\n return chunks;\n};\n\n/**\n * Clamp value to a given range\n */\nexport const clamp = (val: number, min: number, max: number) => {\n const trueMin = Math.min(min, max);\n const trueMax = Math.max(min, max);\n\n return Math.min(trueMax, Math.max(trueMin, val));\n};\n\n/**\n * Interpolate a number to a new range\n *\n * @example\n * linearInterpolate(5, [0, 10], [0, 100]); // 50\n */\nexport const linearInterpolate = (\n inputY: number,\n [fromMin, fromMax]: [number, number],\n [toMin, toMax]: [number, number],\n clampResult = true,\n) => {\n const percent = (inputY - fromMin) / (fromMax - fromMin);\n const outputX = percent * (toMax - toMin) + toMin;\n\n return clampResult ? clamp(outputX, toMin, toMax) : outputX;\n};\n\n/**\n * Increase value and start over once the range is overflown\n */\nexport const incrementLoopValue = (\n value: number,\n [min, max]: [number, number],\n) => {\n if (value === max) {\n return min;\n }\n return value + 1;\n};\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger","isFloat","toFixedRate","rate","scale","asNumber","fixedRate","toFixed","numberToString","num","toString","findClosestNumber","haystack","needle","reduce","prev","curr","Math","abs","splitNumberBy","by","chunks","Array","floor","fill","remainder","push","clamp","val","min","max","trueMin","trueMax","linearInterpolate","inputY","fromMin","fromMax","toMin","toMax","clampResult","percent","outputX","incrementLoopValue"],"mappings":";;AAIO,SAASA,cACdA,CAAAC,KAAA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AYC,OAAU,GAAAD,OAAA,CAAA;EAC1C,MAAAM,OAAA,GAAUD,OAAW,IAAAF,KAAA,GAAQD,KAAS,CAAA,GAAAA,KAAA;EAE5C,OAAOE,WAAc,GAAAZ,KAAA,CAAMc,OAAS,EAAAJ,KAAA,EAAOC,KAAK,CAAI,GAAAG,OAAA;AACtD,CAAA;AAKO,MAAMC,qBAAqBA,CAChCnD,KAAA,EACA,CAACsC,GAAA,EAAKC,GAAG,CACN,KAAA;EACH,IAAIvC,UAAUuC,GAAK,EAAA;IACV,OAAAD,GAAA;EACT;EACA,OAAOtC,KAAQ,GAAA,CAAA;AACjB,CAAA;"}
@@ -14,13 +14,13 @@ const getSortWeightTagRegex = (site, store) => {
14
14
  switch (site) {
15
15
  case "techspecs" /* Techspecs */:
16
16
  {
17
- return /techspecs-sort-weight:(-?[0-9]+)/;
17
+ return /techspecs-sort-weight:(-?\d+)/;
18
18
  }
19
19
  case "store" /* Store */:
20
20
  {
21
21
  switch (store) {
22
22
  case generated.StoreId.Us:
23
- return /pro-sort-weight:(-?[0-9]+)/;
23
+ return /pro-sort-weight:(-?\d+)/;
24
24
  case generated.StoreId.Ca:
25
25
  case generated.StoreId.Eu:
26
26
  case generated.StoreId.Me:
@@ -33,7 +33,7 @@ const getSortWeightTagRegex = (site, store) => {
33
33
  case generated.StoreId.Tw:
34
34
  case generated.StoreId.Mx:
35
35
  case generated.StoreId.Ph:
36
- return /pro-sort-weight:(-?[0-9]+):other/;
36
+ return /pro-sort-weight:(-?\d+):other/;
37
37
  case null:
38
38
  case void 0:
39
39
  {
@@ -64,7 +64,7 @@ const getTagsSortWeight = (tags, site, store) => {
64
64
  if (!tag || !regExp) {
65
65
  return void 0;
66
66
  }
67
- const match = tag?.name.match(regExp)?.[1];
67
+ const match = regExp.exec(tag.name)?.[1];
68
68
  return match ? parseInt(match) : void 0;
69
69
  };
70
70
  const sortByTagWeight = (site, store) => (current, next) => {
@@ -1 +1 @@
1
- {"version":3,"file":"product.js","sources":["../../src/utils/product.ts"],"sourcesContent":["import type { Nullish } from \"../types\";\nimport { StoreId } from \"../types\";\nimport { normalizeSortResult } from \"./array\";\nimport { checkUnreachable } from \"./errors\";\n\nexport enum SortSiteId {\n /**\n * Store.ui.com\n */\n Store = \"store\",\n /**\n * Techspecs.ui.com\n */\n Techspecs = \"techspecs\",\n}\n\n/**\n * Get correct sort weight tag regex based on site in which\n * the product is being displayed and the store\n */\nconst getSortWeightTagRegex = (\n site: SortSiteId,\n store: Nullish<StoreId>,\n): RegExp | null => {\n switch (site) {\n case SortSiteId.Techspecs: {\n return /techspecs-sort-weight:(-?[0-9]+)/;\n }\n case SortSiteId.Store: {\n // eslint-disable-next-line sonarjs/no-nested-switch\n switch (store) {\n case StoreId.Us:\n return /pro-sort-weight:(-?[0-9]+)/;\n case StoreId.Ca:\n case StoreId.Eu:\n case StoreId.Me:\n case StoreId.Uk:\n case StoreId.Za:\n case StoreId.In:\n case StoreId.Sg:\n case StoreId.Jp:\n case StoreId.Br:\n case StoreId.Tw:\n case StoreId.Mx:\n case StoreId.Ph:\n return /pro-sort-weight:(-?[0-9]+):other/;\n case null:\n case undefined: {\n return null;\n }\n default:\n checkUnreachable(store);\n return null;\n }\n }\n\n default: {\n checkUnreachable(site);\n return null;\n }\n }\n};\n\n/**\n * Get sort weight from product tags\n */\nexport const getTagsSortWeight = <\n T extends {\n name: string;\n },\n>(\n tags: T[],\n site: SortSiteId,\n store: Nullish<StoreId>,\n): number | undefined => {\n let regExp = getSortWeightTagRegex(site, store);\n\n // Attempt to find a tag matching the regular expression\n let tag = regExp ? tags.find((tag) => regExp?.test(tag.name)) : undefined;\n\n // If no tag is found and store is not US, retry with StoreId.Us\n if (!tag && store !== StoreId.Us) {\n regExp = getSortWeightTagRegex(site, StoreId.Us);\n\n // If no regular expression is returned, exit early\n if (!regExp) {\n return undefined;\n }\n\n tag = tags.find((tag) => regExp?.test(tag.name));\n }\n\n if (!tag || !regExp) {\n return undefined;\n }\n\n const match = tag?.name.match(regExp)?.[1];\n\n return match ? parseInt(match) : undefined;\n};\n\n/**\n * Sort by tag weight which can be used in `Array.sort(sortByTagWeight(site, store))`\n */\nexport const sortByTagWeight =\n (site: SortSiteId, store?: Nullish<StoreId>) =>\n <T extends { tags: { name: string }[] }>(current: T, next: T): number => {\n // Fallback to \"-1\" to group them in to the back\n const currentSortWeight =\n getTagsSortWeight(current.tags, site, store) ?? -1;\n const nextSortWeight = getTagsSortWeight(next.tags, site, store) ?? -1;\n return normalizeSortResult(nextSortWeight - currentSortWeight);\n };\n"],"names":["SortSiteId","getSortWeightTagRegex","site","store","StoreId","Us","Ca","Eu","Me","Uk","Za","In","Sg","Jp","Br","Tw","Mx","Ph","checkUnreachable","getTagsSortWeight","tags","regExp","tag","find","test","name","match","parseInt","sortByTagWeight","current","next","currentSortWeight","nextSortWeight","normalizeSortResult"],"mappings":";;;;;;;AAKY,IAAAA,UAAA,GAAA,gBAAAA,WAAL,IAAA;EAILA,YAAA,OAAQ,CAAA,GAAA,OAAA;EAIRA,YAAA,WAAY,CAAA,GAAA,WAAA;EARFA,OAAAA,WAAAA;AAAA,CAAA,EAAAA,UAAA,IAAA,CAAA,CAAA,CAAA;AAeZ,MAAMC,qBAAA,GAAwBA,CAC5BC,IAAA,EACAC,KACkB,KAAA;EAClB,QAAQD,IAAM;IACZ,KAAK,WAAsB,CAAA;MAAA;QAClB,OAAA,kCAAA;MACT;IACA,KAAK,OAAkB,CAAA;MAAA;QAErB,QAAQC,KAAO;UACb,KAAKC,SAAQ,CAAAA,OAAA,CAAAC,EAAA;YACJ,OAAA,4BAAA;UACT,KAAKD,SAAAA,CAAAA,OAAQ,CAAAE,EAAA;UACb,KAAKF,SAAAA,CAAAA,OAAQ,CAAAG,EAAA;UACb,KAAKH,SAAAA,CAAAA,OAAQ,CAAAI,EAAA;UACb,KAAKJ,SAAAA,CAAAA,OAAQ,CAAAK,EAAA;UACb,KAAKL,SAAAA,CAAAA,OAAQ,CAAAM,EAAA;UACb,KAAK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A;EACjD;EAEI,IAAA,CAACH,GAAO,IAAA,CAACD,MAAQ,EAAA;IACZ,OAAA,KAAA,CAAA;EACT;EAEA,MAAMK,QAAQJ,GAAK,EAAAG,IAAA,CAAKC,KAAM,CAAAL,MAAM,IAAI,CAAC,CAAA;EAElC,OAAAK,KAAA,GAAQC,QAAS,CAAAD,KAAK,CAAI,GAAA,KAAA,CAAA;AACnC,CAAA;AAKO,MAAME,kBACXA,CAAC1B,IAAA,EAAkBC,KACnB,KAAA,CAAyC0B,SAAYC,IAAoB,KAAA;EAEvE,MAAMC,oBACJZ,iBAAkB,CAAAU,OAAA,CAAQT,IAAM,EAAAlB,IAAA,EAAMC,KAAK,CAAK,IAAA,CAAA,CAAA;EAClD,MAAM6B,iBAAiBb,iBAAkB,CAAAW,IAAA,CAAKV,IAAM,EAAAlB,IAAA,EAAMC,KAAK,CAAK,IAAA,CAAA,CAAA;EAC7D,OAAA8B,KAAA,CAAAA,mBAAA,CAAoBD,iBAAiBD,iBAAiB,CAAA;AAC/D,CAAA;;;"}
1
+ {"version":3,"file":"product.js","sources":["../../src/utils/product.ts"],"sourcesContent":["import type { Nullish } from \"../types\";\nimport { StoreId } from \"../types\";\nimport { normalizeSortResult } from \"./array\";\nimport { checkUnreachable } from \"./errors\";\n\nexport enum SortSiteId {\n /**\n * Store.ui.com\n */\n Store = \"store\",\n /**\n * Techspecs.ui.com\n */\n Techspecs = \"techspecs\",\n}\n\n/**\n * Get correct sort weight tag regex based on site in which\n * the product is being displayed and the store\n */\nconst getSortWeightTagRegex = (\n site: SortSiteId,\n store: Nullish<StoreId>,\n): RegExp | null => {\n switch (site) {\n case SortSiteId.Techspecs: {\n return /techspecs-sort-weight:(-?\\d+)/;\n }\n case SortSiteId.Store: {\n // eslint-disable-next-line sonarjs/no-nested-switch\n switch (store) {\n case StoreId.Us:\n return /pro-sort-weight:(-?\\d+)/;\n case StoreId.Ca:\n case StoreId.Eu:\n case StoreId.Me:\n case StoreId.Uk:\n case StoreId.Za:\n case StoreId.In:\n case StoreId.Sg:\n case StoreId.Jp:\n case StoreId.Br:\n case StoreId.Tw:\n case StoreId.Mx:\n case StoreId.Ph:\n return /pro-sort-weight:(-?\\d+):other/;\n case null:\n case undefined: {\n return null;\n }\n default:\n checkUnreachable(store);\n return null;\n }\n }\n\n default: {\n checkUnreachable(site);\n return null;\n }\n }\n};\n\n/**\n * Get sort weight from product tags\n */\nexport const getTagsSortWeight = <\n T extends {\n name: string;\n },\n>(\n tags: T[],\n site: SortSiteId,\n store: Nullish<StoreId>,\n): number | undefined => {\n let regExp = getSortWeightTagRegex(site, store);\n\n // Attempt to find a tag matching the regular expression\n let tag = regExp ? tags.find((tag) => regExp?.test(tag.name)) : undefined;\n\n // If no tag is found and store is not US, retry with StoreId.Us\n if (!tag && store !== StoreId.Us) {\n regExp = getSortWeightTagRegex(site, StoreId.Us);\n\n // If no regular expression is returned, exit early\n if (!regExp) {\n return undefined;\n }\n\n tag = tags.find((tag) => regExp?.test(tag.name));\n }\n\n if (!tag || !regExp) {\n return undefined;\n }\n\n const match = regExp.exec(tag.name)?.[1];\n\n return match ? parseInt(match) : undefined;\n};\n\n/**\n * Sort by tag weight which can be used in `Array.sort(sortByTagWeight(site, store))`\n */\nexport const sortByTagWeight =\n (site: SortSiteId, store?: Nullish<StoreId>) =>\n <T extends { tags: { name: string }[] }>(current: T, next: T): number => {\n // Fallback to \"-1\" to group them in to the back\n const currentSortWeight =\n getTagsSortWeight(current.tags, site, store) ?? -1;\n const nextSortWeight = getTagsSortWeight(next.tags, site, store) ?? -1;\n return normalizeSortResult(nextSortWeight - currentSortWeight);\n };\n"],"names":["SortSiteId","getSortWeightTagRegex","site","store","StoreId","Us","Ca","Eu","Me","Uk","Za","In","Sg","Jp","Br","Tw","Mx","Ph","checkUnreachable","getTagsSortWeight","tags","regExp","tag","find","test","name","match","exec","parseInt","sortByTagWeight","current","next","currentSortWeight","nextSortWeight","normalizeSortResult"],"mappings":";;;;;;;AAKY,IAAAA,UAAA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D,OAAA+B,KAAA,CAAAA,mBAAA,CAAoBD,iBAAiBD,iBAAiB,CAAA;AAC/D,CAAA;;;"}
@@ -12,13 +12,13 @@ const getSortWeightTagRegex = (site, store) => {
12
12
  switch (site) {
13
13
  case "techspecs" /* Techspecs */:
14
14
  {
15
- return /techspecs-sort-weight:(-?[0-9]+)/;
15
+ return /techspecs-sort-weight:(-?\d+)/;
16
16
  }
17
17
  case "store" /* Store */:
18
18
  {
19
19
  switch (store) {
20
20
  case StoreId.Us:
21
- return /pro-sort-weight:(-?[0-9]+)/;
21
+ return /pro-sort-weight:(-?\d+)/;
22
22
  case StoreId.Ca:
23
23
  case StoreId.Eu:
24
24
  case StoreId.Me:
@@ -31,7 +31,7 @@ const getSortWeightTagRegex = (site, store) => {
31
31
  case StoreId.Tw:
32
32
  case StoreId.Mx:
33
33
  case StoreId.Ph:
34
- return /pro-sort-weight:(-?[0-9]+):other/;
34
+ return /pro-sort-weight:(-?\d+):other/;
35
35
  case null:
36
36
  case void 0:
37
37
  {
@@ -62,7 +62,7 @@ const getTagsSortWeight = (tags, site, store) => {
62
62
  if (!tag || !regExp) {
63
63
  return void 0;
64
64
  }
65
- const match = tag?.name.match(regExp)?.[1];
65
+ const match = regExp.exec(tag.name)?.[1];
66
66
  return match ? parseInt(match) : void 0;
67
67
  };
68
68
  const sortByTagWeight = (site, store) => (current, next) => {
@@ -1 +1 @@
1
- {"version":3,"file":"product.mjs","sources":["../../src/utils/product.ts"],"sourcesContent":["import type { Nullish } from \"../types\";\nimport { StoreId } from \"../types\";\nimport { normalizeSortResult } from \"./array\";\nimport { checkUnreachable } from \"./errors\";\n\nexport enum SortSiteId {\n /**\n * Store.ui.com\n */\n Store = \"store\",\n /**\n * Techspecs.ui.com\n */\n Techspecs = \"techspecs\",\n}\n\n/**\n * Get correct sort weight tag regex based on site in which\n * the product is being displayed and the store\n */\nconst getSortWeightTagRegex = (\n site: SortSiteId,\n store: Nullish<StoreId>,\n): RegExp | null => {\n switch (site) {\n case SortSiteId.Techspecs: {\n return /techspecs-sort-weight:(-?[0-9]+)/;\n }\n case SortSiteId.Store: {\n // eslint-disable-next-line sonarjs/no-nested-switch\n switch (store) {\n case StoreId.Us:\n return /pro-sort-weight:(-?[0-9]+)/;\n case StoreId.Ca:\n case StoreId.Eu:\n case StoreId.Me:\n case StoreId.Uk:\n case StoreId.Za:\n case StoreId.In:\n case StoreId.Sg:\n case StoreId.Jp:\n case StoreId.Br:\n case StoreId.Tw:\n case StoreId.Mx:\n case StoreId.Ph:\n return /pro-sort-weight:(-?[0-9]+):other/;\n case null:\n case undefined: {\n return null;\n }\n default:\n checkUnreachable(store);\n return null;\n }\n }\n\n default: {\n checkUnreachable(site);\n return null;\n }\n }\n};\n\n/**\n * Get sort weight from product tags\n */\nexport const getTagsSortWeight = <\n T extends {\n name: string;\n },\n>(\n tags: T[],\n site: SortSiteId,\n store: Nullish<StoreId>,\n): number | undefined => {\n let regExp = getSortWeightTagRegex(site, store);\n\n // Attempt to find a tag matching the regular expression\n let tag = regExp ? tags.find((tag) => regExp?.test(tag.name)) : undefined;\n\n // If no tag is found and store is not US, retry with StoreId.Us\n if (!tag && store !== StoreId.Us) {\n regExp = getSortWeightTagRegex(site, StoreId.Us);\n\n // If no regular expression is returned, exit early\n if (!regExp) {\n return undefined;\n }\n\n tag = tags.find((tag) => regExp?.test(tag.name));\n }\n\n if (!tag || !regExp) {\n return undefined;\n }\n\n const match = tag?.name.match(regExp)?.[1];\n\n return match ? parseInt(match) : undefined;\n};\n\n/**\n * Sort by tag weight which can be used in `Array.sort(sortByTagWeight(site, store))`\n */\nexport const sortByTagWeight =\n (site: SortSiteId, store?: Nullish<StoreId>) =>\n <T extends { tags: { name: string }[] }>(current: T, next: T): number => {\n // Fallback to \"-1\" to group them in to the back\n const currentSortWeight =\n getTagsSortWeight(current.tags, site, store) ?? -1;\n const nextSortWeight = getTagsSortWeight(next.tags, site, store) ?? -1;\n return normalizeSortResult(nextSortWeight - currentSortWeight);\n };\n"],"names":["SortSiteId","getSortWeightTagRegex","site","store","StoreId","Us","Ca","Eu","Me","Uk","Za","In","Sg","Jp","Br","Tw","Mx","Ph","checkUnreachable","getTagsSortWeight","tags","regExp","tag","find","test","name","match","parseInt","sortByTagWeight","current","next","currentSortWeight","nextSortWeight","normalizeSortResult"],"mappings":";;;;;AAKY,IAAAA,UAAA,GAAA,gBAAAA,WAAL,IAAA;EAILA,YAAA,OAAQ,CAAA,GAAA,OAAA;EAIRA,YAAA,WAAY,CAAA,GAAA,WAAA;EARFA,OAAAA,WAAAA;AAAA,CAAA,EAAAA,UAAA,IAAA,CAAA,CAAA,CAAA;AAeZ,MAAMC,qBAAA,GAAwBA,CAC5BC,IAAA,EACAC,KACkB,KAAA;EAClB,QAAQD,IAAM;IACZ,KAAK,WAAsB,CAAA;MAAA;QAClB,OAAA,kCAAA;MACT;IACA,KAAK,OAAkB,CAAA;MAAA;QAErB,QAAQC,KAAO;UACb,KAAKC,OAAQ,CAAAC,EAAA;YACJ,OAAA,4BAAA;UACT,KAAKD,OAAQ,CAAAE,EAAA;UACb,KAAKF,OAAQ,CAAAG,EAAA;UACb,KAAKH,OAAQ,CAAAI,EAAA;UACb,KAAKJ,OAAQ,CAAAK,EAAA;UACb,KAAKL,OAAQ,CAAAM,EAAA;UACb,KAAKN,OAAQ,CAAAO,EAAA;UACb,KAAKP,OAAQ,CAAAQ,EAAA;UACb,KAAKR,OAAQ,CAAAS,EAAA;UACb,KAAKT,OAAQ,CAAAU,EAAA;UACb,KAAKV,OAAQ,CAAAW,EAAA;UACb,KAAKX,OAAQ,CAAAY,EAAA;UACb,KAAKZ,OAAQ,CAAAa,EAAA;YACJ,OAAA,kCAAA;UACT,KAAK,IAAA;UACL,KAAK,KAAW,CAAA;YAAA;cACP,OAAA,IAAA;YACT;UACA;YACEC,gBAAA,CAAiBf,KAAK,CAAA;YACf,OAAA,IAAA;QACX;MACF;IAEA;MAAS;QACPe,gBAAA,CAAiBhB,IAAI,CAAA;QACd,OAAA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AAoBD,iBAAiBD,iBAAiB,CAAA;AAC/D,CAAA;"}
1
+ {"version":3,"file":"product.mjs","sources":["../../src/utils/product.ts"],"sourcesContent":["import type { Nullish } from \"../types\";\nimport { StoreId } from \"../types\";\nimport { normalizeSortResult } from \"./array\";\nimport { checkUnreachable } from \"./errors\";\n\nexport enum SortSiteId {\n /**\n * Store.ui.com\n */\n Store = \"store\",\n /**\n * Techspecs.ui.com\n */\n Techspecs = \"techspecs\",\n}\n\n/**\n * Get correct sort weight tag regex based on site in which\n * the product is being displayed and the store\n */\nconst getSortWeightTagRegex = (\n site: SortSiteId,\n store: Nullish<StoreId>,\n): RegExp | null => {\n switch (site) {\n case SortSiteId.Techspecs: {\n return /techspecs-sort-weight:(-?\\d+)/;\n }\n case SortSiteId.Store: {\n // eslint-disable-next-line sonarjs/no-nested-switch\n switch (store) {\n case StoreId.Us:\n return /pro-sort-weight:(-?\\d+)/;\n case StoreId.Ca:\n case StoreId.Eu:\n case StoreId.Me:\n case StoreId.Uk:\n case StoreId.Za:\n case StoreId.In:\n case StoreId.Sg:\n case StoreId.Jp:\n case StoreId.Br:\n case StoreId.Tw:\n case StoreId.Mx:\n case StoreId.Ph:\n return /pro-sort-weight:(-?\\d+):other/;\n case null:\n case undefined: {\n return null;\n }\n default:\n checkUnreachable(store);\n return null;\n }\n }\n\n default: {\n checkUnreachable(site);\n return null;\n }\n }\n};\n\n/**\n * Get sort weight from product tags\n */\nexport const getTagsSortWeight = <\n T extends {\n name: string;\n },\n>(\n tags: T[],\n site: SortSiteId,\n store: Nullish<StoreId>,\n): number | undefined => {\n let regExp = getSortWeightTagRegex(site, store);\n\n // Attempt to find a tag matching the regular expression\n let tag = regExp ? tags.find((tag) => regExp?.test(tag.name)) : undefined;\n\n // If no tag is found and store is not US, retry with StoreId.Us\n if (!tag && store !== StoreId.Us) {\n regExp = getSortWeightTagRegex(site, StoreId.Us);\n\n // If no regular expression is returned, exit early\n if (!regExp) {\n return undefined;\n }\n\n tag = tags.find((tag) => regExp?.test(tag.name));\n }\n\n if (!tag || !regExp) {\n return undefined;\n }\n\n const match = regExp.exec(tag.name)?.[1];\n\n return match ? parseInt(match) : undefined;\n};\n\n/**\n * Sort by tag weight which can be used in `Array.sort(sortByTagWeight(site, store))`\n */\nexport const sortByTagWeight =\n (site: SortSiteId, store?: Nullish<StoreId>) =>\n <T extends { tags: { name: string }[] }>(current: T, next: T): number => {\n // Fallback to \"-1\" to group them in to the back\n const currentSortWeight =\n getTagsSortWeight(current.tags, site, store) ?? -1;\n const nextSortWeight = getTagsSortWeight(next.tags, site, store) ?? -1;\n return normalizeSortResult(nextSortWeight - currentSortWeight);\n };\n"],"names":["SortSiteId","getSortWeightTagRegex","site","store","StoreId","Us","Ca","Eu","Me","Uk","Za","In","Sg","Jp","Br","Tw","Mx","Ph","checkUnreachable","getTagsSortWeight","tags","regExp","tag","find","test","name","match","exec","parseInt","sortByTagWeight","current","next","currentSortWeight","nextSortWeight","normalizeSortResult"],"mappings":";;;;;AAKY,IAAAA,UAAA,GAAA,gBAAAA,WAAL,IAAA;EAILA,YAAA,OAAQ,CAAA,GAAA,OAAA;EAIRA,YAAA,WAAY,CAAA,GAAA,WAAA;EARFA,OAAAA,WAAAA;AAAA,CAAA,EAAAA,UAAA,IAAA,CAAA,CAAA,CAAA;AAeZ,MAAMC,qBAAA,GAAwBA,CAC5BC,IAAA,EACAC,KACkB,KAAA;EAClB,QAAQD,IAAM;IACZ,KAAK,WAAsB,CAAA;MAAA;QAClB,OAAA,+BAAA;MACT;IACA,KAAK,OAAkB,CAAA;MAAA;QAErB,QAAQC,KAAO;UACb,KAAKC,OAAQ,CAAAC,EAAA;YACJ,OAAA,yBAAA;UACT,KAAKD,OAAQ,CAAAE,EAAA;UACb,KAAKF,OAAQ,CAAAG,EAAA;UACb,KAAKH,OAAQ,CAAAI,EAAA;UACb,KAAKJ,OAAQ,CAAAK,EAAA;UACb,KAAKL,OAAQ,CAAAM,EAAA;UACb,KAAKN,OAAQ,CAAA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A;EAEhC,OAAAC,KAAA,GAAQE,QAAS,CAAAF,KAAK,CAAI,GAAA,KAAA,CAAA;AACnC,CAAA;AAKO,MAAMG,kBACXA,CAAC3B,IAAA,EAAkBC,KACnB,KAAA,CAAyC2B,SAAYC,IAAoB,KAAA;EAEvE,MAAMC,oBACJb,iBAAkB,CAAAW,OAAA,CAAQV,IAAM,EAAAlB,IAAA,EAAMC,KAAK,CAAK,IAAA,CAAA,CAAA;EAClD,MAAM8B,iBAAiBd,iBAAkB,CAAAY,IAAA,CAAKX,IAAM,EAAAlB,IAAA,EAAMC,KAAK,CAAK,IAAA,CAAA,CAAA;EAC7D,OAAA+B,mBAAA,CAAoBD,iBAAiBD,iBAAiB,CAAA;AAC/D,CAAA;"}
package/lib/utils/tags.js CHANGED
@@ -4,9 +4,9 @@
4
4
  const formatTag = str => {
5
5
  let formattedString = str.trim();
6
6
  formattedString = formattedString.replaceAll(/\s/g, ":");
7
- formattedString = formattedString.replaceAll(/[^a-zA-Z0-90:-]/g, "").toLowerCase();
7
+ formattedString = formattedString.replaceAll(/[^a-zA-Z0-9:-]/g, "").toLowerCase();
8
8
  formattedString = formattedString.replace(/[:|-]+/g, match => match.charAt(0));
9
- return formattedString.replaceAll(/^[:-]+|[:-]+$/g, "");
9
+ return formattedString.replace(/^[:-]+/, "").replace(/[:-]+$/, "");
10
10
  };
11
11
  exports.formatTag = formatTag;
12
12
  //# sourceMappingURL=tags.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tags.js","sources":["../../src/utils/tags.ts"],"sourcesContent":["export const formatTag = (str: string): string => {\n // Remove leading/trailing whitespace\n let formattedString = str.trim();\n // Replace spaces with \":\"\n formattedString = formattedString.replaceAll(/\\s/g, \":\");\n // Only allow alphanumeric characters and \":\", \"-\"\n formattedString = formattedString\n .replaceAll(/[^a-zA-Z0-90:-]/g, \"\")\n .toLowerCase();\n // Replace multiple \":-\" adjacent combinations with the first instance so:\n // \":--\" becomes \":\"\n // \":--:\" becomes \":\"\n // \"-:-:\" becomes \"-\"\n formattedString = formattedString.replace(/[:|-]+/g, (match) =>\n match.charAt(0),\n );\n // Remove leading and trailing \":\", \"-\"\n return formattedString.replaceAll(/^[:-]+|[:-]+$/g, \"\");\n};\n"],"names":["formatTag","str","formattedString","trim","replaceAll","toLowerCase","replace","match","charAt"],"mappings":";;;AAAa,MAAAA,SAAA,GAAaC,GAAwB,IAAA;EAE5C,IAAAC,eAAA,GAAkBD,IAAIE,IAAK,EAAA;EAEbD,eAAA,GAAAA,eAAA,CAAgBE,UAAW,CAAA,KAAA,EAAO,GAAG,CAAA;EAEvDF,eAAA,GAAkBA,eACf,CAAAE,UAAA,CAAW,kBAAoB,EAAA,EAAE,EACjCC,WAAY,EAAA;EAKfH,eAAA,GAAkBA,eAAgB,CAAAI,OAAA,CAAQ,SAAA,EAAYC,KAAA,IACpDA,KAAM,CAAAC,MAAA,CAAO,CAAC,CAAA,CAChB;EAEO,OAAAN,eAAA,CAAgBE,UAAW,CAAA,gBAAA,EAAkB,EAAE,CAAA;AACxD,CAAA;"}
1
+ {"version":3,"file":"tags.js","sources":["../../src/utils/tags.ts"],"sourcesContent":["export const formatTag = (str: string): string => {\n // Remove leading/trailing whitespace\n let formattedString = str.trim();\n // Replace spaces with \":\"\n formattedString = formattedString.replaceAll(/\\s/g, \":\");\n // Only allow alphanumeric characters and \":\", \"-\"\n formattedString = formattedString\n .replaceAll(/[^a-zA-Z0-9:-]/g, \"\")\n .toLowerCase();\n // Replace multiple \":-\" adjacent combinations with the first instance so:\n // \":--\" becomes \":\"\n // \":--:\" becomes \":\"\n // \"-:-:\" becomes \"-\"\n formattedString = formattedString.replace(/[:|-]+/g, (match) =>\n match.charAt(0),\n );\n // Remove leading and trailing \":\", \"-\"\n\n return (\n formattedString\n .replace(/^[:-]+/, \"\")\n // Ignore slow regex warning as this is only called from internal source that are have certain max-length\n // eslint-disable-next-line sonarjs/slow-regex\n .replace(/[:-]+$/, \"\")\n );\n};\n"],"names":["formatTag","str","formattedString","trim","replaceAll","toLowerCase","replace","match","charAt"],"mappings":";;;AAAa,MAAAA,SAAA,GAAaC,GAAwB,IAAA;EAE5C,IAAAC,eAAA,GAAkBD,IAAIE,IAAK,EAAA;EAEbD,eAAA,GAAAA,eAAA,CAAgBE,UAAW,CAAA,KAAA,EAAO,GAAG,CAAA;EAEvDF,eAAA,GAAkBA,eACf,CAAAE,UAAA,CAAW,iBAAmB,EAAA,EAAE,EAChCC,WAAY,EAAA;EAKfH,eAAA,GAAkBA,eAAgB,CAAAI,OAAA,CAAQ,SAAA,EAAYC,KAAA,IACpDA,KAAM,CAAAC,MAAA,CAAO,CAAC,CAAA,CAChB;EAGA,OACEN,gBACGI,OAAQ,CAAA,QAAA,EAAU,EAAE,CAGpB,CAAAA,OAAA,CAAQ,UAAU,EAAE,CAAA;AAE3B,CAAA;"}
@@ -3,9 +3,9 @@
3
3
  const formatTag = str => {
4
4
  let formattedString = str.trim();
5
5
  formattedString = formattedString.replaceAll(/\s/g, ":");
6
- formattedString = formattedString.replaceAll(/[^a-zA-Z0-90:-]/g, "").toLowerCase();
6
+ formattedString = formattedString.replaceAll(/[^a-zA-Z0-9:-]/g, "").toLowerCase();
7
7
  formattedString = formattedString.replace(/[:|-]+/g, match => match.charAt(0));
8
- return formattedString.replaceAll(/^[:-]+|[:-]+$/g, "");
8
+ return formattedString.replace(/^[:-]+/, "").replace(/[:-]+$/, "");
9
9
  };
10
10
  export { formatTag };
11
11
  //# sourceMappingURL=tags.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tags.mjs","sources":["../../src/utils/tags.ts"],"sourcesContent":["export const formatTag = (str: string): string => {\n // Remove leading/trailing whitespace\n let formattedString = str.trim();\n // Replace spaces with \":\"\n formattedString = formattedString.replaceAll(/\\s/g, \":\");\n // Only allow alphanumeric characters and \":\", \"-\"\n formattedString = formattedString\n .replaceAll(/[^a-zA-Z0-90:-]/g, \"\")\n .toLowerCase();\n // Replace multiple \":-\" adjacent combinations with the first instance so:\n // \":--\" becomes \":\"\n // \":--:\" becomes \":\"\n // \"-:-:\" becomes \"-\"\n formattedString = formattedString.replace(/[:|-]+/g, (match) =>\n match.charAt(0),\n );\n // Remove leading and trailing \":\", \"-\"\n return formattedString.replaceAll(/^[:-]+|[:-]+$/g, \"\");\n};\n"],"names":["formatTag","str","formattedString","trim","replaceAll","toLowerCase","replace","match","charAt"],"mappings":";;AAAa,MAAAA,SAAA,GAAaC,GAAwB,IAAA;EAE5C,IAAAC,eAAA,GAAkBD,IAAIE,IAAK,EAAA;EAEbD,eAAA,GAAAA,eAAA,CAAgBE,UAAW,CAAA,KAAA,EAAO,GAAG,CAAA;EAEvDF,eAAA,GAAkBA,eACf,CAAAE,UAAA,CAAW,kBAAoB,EAAA,EAAE,EACjCC,WAAY,EAAA;EAKfH,eAAA,GAAkBA,eAAgB,CAAAI,OAAA,CAAQ,SAAA,EAAYC,KAAA,IACpDA,KAAM,CAAAC,MAAA,CAAO,CAAC,CAAA,CAChB;EAEO,OAAAN,eAAA,CAAgBE,UAAW,CAAA,gBAAA,EAAkB,EAAE,CAAA;AACxD,CAAA;"}
1
+ {"version":3,"file":"tags.mjs","sources":["../../src/utils/tags.ts"],"sourcesContent":["export const formatTag = (str: string): string => {\n // Remove leading/trailing whitespace\n let formattedString = str.trim();\n // Replace spaces with \":\"\n formattedString = formattedString.replaceAll(/\\s/g, \":\");\n // Only allow alphanumeric characters and \":\", \"-\"\n formattedString = formattedString\n .replaceAll(/[^a-zA-Z0-9:-]/g, \"\")\n .toLowerCase();\n // Replace multiple \":-\" adjacent combinations with the first instance so:\n // \":--\" becomes \":\"\n // \":--:\" becomes \":\"\n // \"-:-:\" becomes \"-\"\n formattedString = formattedString.replace(/[:|-]+/g, (match) =>\n match.charAt(0),\n );\n // Remove leading and trailing \":\", \"-\"\n\n return (\n formattedString\n .replace(/^[:-]+/, \"\")\n // Ignore slow regex warning as this is only called from internal source that are have certain max-length\n // eslint-disable-next-line sonarjs/slow-regex\n .replace(/[:-]+$/, \"\")\n );\n};\n"],"names":["formatTag","str","formattedString","trim","replaceAll","toLowerCase","replace","match","charAt"],"mappings":";;AAAa,MAAAA,SAAA,GAAaC,GAAwB,IAAA;EAE5C,IAAAC,eAAA,GAAkBD,IAAIE,IAAK,EAAA;EAEbD,eAAA,GAAAA,eAAA,CAAgBE,UAAW,CAAA,KAAA,EAAO,GAAG,CAAA;EAEvDF,eAAA,GAAkBA,eACf,CAAAE,UAAA,CAAW,iBAAmB,EAAA,EAAE,EAChCC,WAAY,EAAA;EAKfH,eAAA,GAAkBA,eAAgB,CAAAI,OAAA,CAAQ,SAAA,EAAYC,KAAA,IACpDA,KAAM,CAAAC,MAAA,CAAO,CAAC,CAAA,CAChB;EAGA,OACEN,gBACGI,OAAQ,CAAA,QAAA,EAAU,EAAE,CAGpB,CAAAA,OAAA,CAAQ,UAAU,EAAE,CAAA;AAE3B,CAAA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubnt/store.core",
3
- "version": "9.44.2",
3
+ "version": "9.45.0-alpha.0",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "scripts": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"icon-globe.svg.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,3 +0,0 @@
1
- export * from "../../globe.svg";
2
- export { default } from "../../globe.svg";
3
- //# sourceMappingURL=icon-globe.svg.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"icon-globe.svg.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,3 +0,0 @@
1
- export * from "../../../assets/arrowDown.svg";
2
- export { default } from "../../../assets/arrowDown.svg";
3
- //# sourceMappingURL=arrowDown.svg.mjs.map