@ubnt/store.core 9.40.0-beta.0 → 9.40.0-new-design
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -335
- package/lib/_virtual/_virtual_multi-entry.js +2 -15
- package/lib/_virtual/_virtual_multi-entry.js.map +1 -1
- package/lib/_virtual/_virtual_multi-entry.mjs +0 -2
- package/lib/_virtual/_virtual_multi-entry.mjs.map +1 -1
- package/lib/apis/smartcat.js.map +1 -1
- package/lib/apis/smartcat.mjs.map +1 -1
- package/lib/assets/attention.svg +5 -5
- package/lib/assets/attention2.svg +5 -5
- package/lib/assets/close2.svg +3 -2
- package/lib/assets/close3.svg +2 -3
- package/lib/assets/icon-location-pin.svg +5 -0
- package/lib/{components/ModelCompareV3/assets/crestron.svg.js → assets/icons/menu/icon-location-pin.svg.js} +6 -6
- package/lib/assets/icons/menu/icon-location-pin.svg.js.map +1 -0
- package/lib/assets/icons/menu/icon-location-pin.svg.mjs +3 -0
- package/lib/assets/icons/menu/icon-location-pin.svg.mjs.map +1 -0
- package/lib/assets/icons/wizard/plus.svg.js +1 -1
- package/lib/assets/icons/wizard/plus.svg.mjs +2 -2
- package/lib/assets/logoUnifi.svg +10 -2
- package/lib/assets/minus4.svg +8 -8
- package/lib/assets/minus5.svg +8 -8
- package/lib/assets/plus.svg +22 -4
- package/lib/assets/plus2.svg +4 -22
- package/lib/assets/plus5.svg +9 -9
- package/lib/assets/plus6.svg +9 -9
- package/lib/assets/port.svg +2 -4
- package/lib/assets/port2.svg +4 -2
- package/lib/components/Accordion/Accordion.js.map +1 -1
- package/lib/components/Accordion/Accordion.mjs.map +1 -1
- package/lib/components/Accordion/Accordion.styles.js.map +1 -1
- package/lib/components/Accordion/Accordion.styles.mjs.map +1 -1
- package/lib/components/Avatar/Avatar.js.map +1 -1
- package/lib/components/Avatar/Avatar.mjs.map +1 -1
- package/lib/components/Banner/Banner.styles.js.map +1 -1
- package/lib/components/Banner/Banner.styles.mjs.map +1 -1
- package/lib/components/ButtonGroup/ButtonGroup.js.map +1 -1
- package/lib/components/ButtonGroup/ButtonGroup.mjs.map +1 -1
- package/lib/components/ButtonGroup/ButtonGroup.styles.js.map +1 -1
- package/lib/components/ButtonGroup/ButtonGroup.styles.mjs.map +1 -1
- package/lib/components/ButtonGroupBasic/ButtonGroupBasic.js.map +1 -1
- package/lib/components/ButtonGroupBasic/ButtonGroupBasic.mjs.map +1 -1
- package/lib/components/CardSection/CardSection.styles.d.ts +1 -1
- package/lib/components/CategoryTabs/CategoryTabs.styles.d.ts +4 -2
- package/lib/components/CategoryTabs/CategoryTabs.styles.js +8 -5
- package/lib/components/CategoryTabs/CategoryTabs.styles.js.map +1 -1
- package/lib/components/CategoryTabs/CategoryTabs.styles.mjs +7 -6
- package/lib/components/CategoryTabs/CategoryTabs.styles.mjs.map +1 -1
- package/lib/components/CloserLookSection/CloserLookSection.js.map +1 -1
- package/lib/components/CloserLookSection/CloserLookSection.mjs.map +1 -1
- package/lib/components/CloserLookSection/CloserLookSection.styles.js.map +1 -1
- package/lib/components/CloserLookSection/CloserLookSection.styles.mjs.map +1 -1
- package/lib/components/Compare/Compare.styles.d.ts +5 -5
- package/lib/components/Container/Container.d.ts +1 -1
- package/lib/components/Container/Container.js +4 -3
- package/lib/components/Container/Container.js.map +1 -1
- package/lib/components/Container/Container.mjs +5 -4
- package/lib/components/Container/Container.mjs.map +1 -1
- package/lib/components/Container/Container.styles.js.map +1 -1
- package/lib/components/Container/Container.styles.mjs.map +1 -1
- package/lib/components/CustomImage/CustomImage.js +1 -1
- package/lib/components/CustomImage/CustomImage.js.map +1 -1
- package/lib/components/CustomImage/CustomImage.mjs +1 -1
- package/lib/components/CustomImage/CustomImage.mjs.map +1 -1
- package/lib/components/CustomImage/CustomImage.styles.js.map +1 -1
- package/lib/components/CustomImage/CustomImage.styles.mjs.map +1 -1
- package/lib/components/Explore/Explore.js.map +1 -1
- package/lib/components/Explore/Explore.mjs.map +1 -1
- package/lib/components/Explore/ExploreData.js.map +1 -1
- package/lib/components/Explore/ExploreData.mjs.map +1 -1
- package/lib/components/FeaturesSection_deprecated/AllFeaturesButton/AllFeaturesButton.js +1 -1
- package/lib/components/FeaturesSection_deprecated/AllFeaturesButton/AllFeaturesButton.mjs +1 -1
- package/lib/components/FeaturesSection_deprecated/FeaturesSection.js +1 -1
- package/lib/components/FeaturesSection_deprecated/FeaturesSection.js.map +1 -1
- package/lib/components/FeaturesSection_deprecated/FeaturesSection.mjs +1 -1
- package/lib/components/FeaturesSection_deprecated/FeaturesSection.mjs.map +1 -1
- package/lib/components/FeaturesSection_deprecated/FeaturesSection.styles.js.map +1 -1
- package/lib/components/FeaturesSection_deprecated/FeaturesSection.styles.mjs.map +1 -1
- package/lib/components/FeaturesSection_deprecated/assets/close.svg.js +1 -1
- package/lib/components/FeaturesSection_deprecated/assets/close.svg.mjs +2 -2
- package/lib/components/FeaturesSection_deprecated/assets/plus.svg.js +1 -1
- package/lib/components/FeaturesSection_deprecated/assets/plus.svg.mjs +2 -2
- package/lib/components/Footer/Footer.js +1 -1
- package/lib/components/Footer/Footer.js.map +1 -1
- package/lib/components/Footer/Footer.mjs +1 -1
- package/lib/components/Footer/Footer.mjs.map +1 -1
- package/lib/components/Footer/Footer.styles.js.map +1 -1
- package/lib/components/Footer/Footer.styles.mjs.map +1 -1
- package/lib/components/Gallery/Gallery.js.map +1 -1
- package/lib/components/Gallery/Gallery.mjs.map +1 -1
- package/lib/components/Gallery/Gallery.styles.js.map +1 -1
- package/lib/components/Gallery/Gallery.styles.mjs.map +1 -1
- package/lib/components/Gallery/GalleryThumbnails/GalleryThumbnails.js.map +1 -1
- package/lib/components/Gallery/GalleryThumbnails/GalleryThumbnails.mjs.map +1 -1
- package/lib/components/Gallery/GalleryThumbnails/GalleryThumbnails.styles.js.map +1 -1
- package/lib/components/Gallery/GalleryThumbnails/GalleryThumbnails.styles.mjs.map +1 -1
- package/lib/components/GradientButton/GradientButton.styles.js.map +1 -1
- package/lib/components/GradientButton/GradientButton.styles.mjs.map +1 -1
- package/lib/components/GridGallery/GridGallery.js.map +1 -1
- package/lib/components/GridGallery/GridGallery.mjs.map +1 -1
- package/lib/components/Header/AccountFrame/AccountFrame.js.map +1 -1
- package/lib/components/Header/AccountFrame/AccountFrame.mjs.map +1 -1
- package/lib/components/Header/AccountFrame/AccountFrame.styles.js.map +1 -1
- package/lib/components/Header/AccountFrame/AccountFrame.styles.mjs.map +1 -1
- package/lib/components/Header/AccountMenu/AccountMenu.js +11 -1
- package/lib/components/Header/AccountMenu/AccountMenu.js.map +1 -1
- package/lib/components/Header/AccountMenu/AccountMenu.mjs +13 -3
- package/lib/components/Header/AccountMenu/AccountMenu.mjs.map +1 -1
- package/lib/components/Header/AccountMenu/megaphone.http.service.js.map +1 -1
- package/lib/components/Header/AccountMenu/megaphone.http.service.mjs.map +1 -1
- package/lib/components/Header/CartModalV2/Item/Item.js.map +1 -1
- package/lib/components/Header/CartModalV2/Item/Item.mjs.map +1 -1
- package/lib/components/Header/Header.js +6 -6
- package/lib/components/Header/Header.js.map +1 -1
- package/lib/components/Header/Header.mjs +6 -6
- package/lib/components/Header/Header.mjs.map +1 -1
- package/lib/components/Header/Header.styles.d.ts +7 -12
- package/lib/components/Header/Header.styles.js +10 -32
- package/lib/components/Header/Header.styles.js.map +1 -1
- package/lib/components/Header/Header.styles.mjs +10 -31
- package/lib/components/Header/Header.styles.mjs.map +1 -1
- package/lib/components/Header/Header.types.d.ts +29 -5
- package/lib/components/Header/Header.types.js +2 -1
- package/lib/components/Header/Header.types.js.map +1 -1
- package/lib/components/Header/Header.types.mjs +2 -1
- package/lib/components/Header/Header.types.mjs.map +1 -1
- package/lib/components/Header/IsolatedHeader.d.ts +1 -0
- package/lib/components/Header/IsolatedHeader.js +44 -44
- package/lib/components/Header/IsolatedHeader.js.map +1 -1
- package/lib/components/Header/IsolatedHeader.mjs +47 -46
- package/lib/components/Header/IsolatedHeader.mjs.map +1 -1
- package/lib/components/Header/LanguageFrame/LanguageFrame.js.map +1 -1
- package/lib/components/Header/LanguageFrame/LanguageFrame.mjs.map +1 -1
- package/lib/components/Header/LanguageFrame/LanguageFrame.styles.js.map +1 -1
- package/lib/components/Header/LanguageFrame/LanguageFrame.styles.mjs.map +1 -1
- package/lib/components/Header/LogoIcon/LogoIcon.d.ts +7 -0
- package/lib/components/Header/LogoIcon/LogoIcon.js +46 -0
- package/lib/components/Header/LogoIcon/LogoIcon.js.map +1 -0
- package/lib/components/Header/LogoIcon/LogoIcon.mjs +36 -0
- package/lib/components/Header/LogoIcon/LogoIcon.mjs.map +1 -0
- package/lib/components/Header/LogoIcon/index.d.ts +1 -0
- package/lib/components/Header/LogoIcon/index.js +6 -0
- package/lib/components/Header/LogoIcon/index.js.map +1 -0
- package/lib/components/Header/LogoIcon/index.mjs +3 -0
- package/lib/components/Header/LogoIcon/index.mjs.map +1 -0
- package/lib/components/Header/MenuItem/MenuItem.styles.d.ts +1 -1
- package/lib/components/Header/MenuItem/MenuItem.styles.js +3 -3
- package/lib/components/Header/MenuItem/MenuItem.styles.js.map +1 -1
- package/lib/components/Header/MenuItem/MenuItem.styles.mjs +3 -3
- package/lib/components/Header/MenuItem/MenuItem.styles.mjs.map +1 -1
- package/lib/components/Header/MenuItem/MenuItem.types.d.ts +1 -0
- package/lib/components/Header/Navigation/Carousel/Carousel.js.map +1 -1
- package/lib/components/Header/Navigation/Carousel/Carousel.mjs.map +1 -1
- package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.d.ts +1 -1
- package/lib/components/Header/Navigation/MobileMenu/MobileMenu.styles.d.ts +1 -1
- package/lib/components/Header/Navigation/MobileMenu/MobileMenu.styles.js.map +1 -1
- package/lib/components/Header/Navigation/MobileMenu/MobileMenu.styles.mjs.map +1 -1
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.d.ts +1 -1
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.js +110 -103
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.js.map +1 -1
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.mjs +111 -104
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.mjs.map +1 -1
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.d.ts +9 -0
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.js +15 -1
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.js.map +1 -1
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.mjs +13 -2
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.mjs.map +1 -1
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.types.d.ts +12 -6
- package/lib/components/Header/ProHeader/ProHeader.d.ts +9 -5
- package/lib/components/Header/ProHeader/ProHeader.js +249 -168
- package/lib/components/Header/ProHeader/ProHeader.js.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.mjs +250 -170
- package/lib/components/Header/ProHeader/ProHeader.mjs.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.styles.d.ts +30 -25
- package/lib/components/Header/ProHeader/ProHeader.styles.js +119 -66
- package/lib/components/Header/ProHeader/ProHeader.styles.js.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.styles.mjs +112 -65
- package/lib/components/Header/ProHeader/ProHeader.styles.mjs.map +1 -1
- package/lib/components/Header/translations/ar.json.js +4 -1
- package/lib/components/Header/translations/ar.json.js.map +1 -1
- package/lib/components/Header/translations/ar.json.mjs +4 -2
- package/lib/components/Header/translations/ar.json.mjs.map +1 -1
- package/lib/components/Header/translations/de.json.js +4 -1
- package/lib/components/Header/translations/de.json.js.map +1 -1
- package/lib/components/Header/translations/de.json.mjs +4 -2
- package/lib/components/Header/translations/de.json.mjs.map +1 -1
- package/lib/components/Header/translations/el.json.js +4 -1
- package/lib/components/Header/translations/el.json.js.map +1 -1
- package/lib/components/Header/translations/el.json.mjs +4 -2
- package/lib/components/Header/translations/el.json.mjs.map +1 -1
- package/lib/components/Header/translations/en.json.js +7 -1
- package/lib/components/Header/translations/en.json.js.map +1 -1
- package/lib/components/Header/translations/en.json.mjs +6 -2
- package/lib/components/Header/translations/en.json.mjs.map +1 -1
- package/lib/components/Header/translations/es.json.js +4 -1
- package/lib/components/Header/translations/es.json.js.map +1 -1
- package/lib/components/Header/translations/es.json.mjs +4 -2
- package/lib/components/Header/translations/es.json.mjs.map +1 -1
- package/lib/components/Header/translations/fr.json.js +4 -1
- package/lib/components/Header/translations/fr.json.js.map +1 -1
- package/lib/components/Header/translations/fr.json.mjs +4 -2
- package/lib/components/Header/translations/fr.json.mjs.map +1 -1
- package/lib/components/Header/translations/it.json.js +4 -1
- package/lib/components/Header/translations/it.json.js.map +1 -1
- package/lib/components/Header/translations/it.json.mjs +4 -2
- package/lib/components/Header/translations/it.json.mjs.map +1 -1
- package/lib/components/Header/translations/ja.json.js +4 -1
- package/lib/components/Header/translations/ja.json.js.map +1 -1
- package/lib/components/Header/translations/ja.json.mjs +4 -2
- package/lib/components/Header/translations/ja.json.mjs.map +1 -1
- package/lib/components/Header/translations/pt-BR.json.js +4 -1
- package/lib/components/Header/translations/pt-BR.json.js.map +1 -1
- package/lib/components/Header/translations/pt-BR.json.mjs +4 -2
- package/lib/components/Header/translations/pt-BR.json.mjs.map +1 -1
- package/lib/components/Header/translations/zh-Hans.json.js +4 -1
- package/lib/components/Header/translations/zh-Hans.json.js.map +1 -1
- package/lib/components/Header/translations/zh-Hans.json.mjs +4 -2
- package/lib/components/Header/translations/zh-Hans.json.mjs.map +1 -1
- package/lib/components/Header/translations/zh-Hant-TW.json.js +4 -1
- package/lib/components/Header/translations/zh-Hant-TW.json.js.map +1 -1
- package/lib/components/Header/translations/zh-Hant-TW.json.mjs +4 -2
- package/lib/components/Header/translations/zh-Hant-TW.json.mjs.map +1 -1
- package/lib/components/Hero/Hero.js.map +1 -1
- package/lib/components/Hero/Hero.mjs.map +1 -1
- package/lib/components/Hero/Hero.styles.d.ts +2 -2
- package/lib/components/Hero/Hero.styles.js.map +1 -1
- package/lib/components/Hero/Hero.styles.mjs.map +1 -1
- package/lib/components/HeroFadeGallery/HeroFadeGallery.styles.d.ts +1 -1
- package/lib/components/HowToUseSection/HowToUseSection.styles.d.ts +2 -2
- package/lib/components/ImageCarousel/ImageCarousel.styles.js.map +1 -1
- package/lib/components/ImageCarousel/ImageCarousel.styles.mjs.map +1 -1
- package/lib/components/LandingPage/Cards/Card/Card.js.map +1 -1
- package/lib/components/LandingPage/Cards/Card/Card.mjs.map +1 -1
- package/lib/components/LandingPage/Cards/Cards.js.map +1 -1
- package/lib/components/LandingPage/Cards/Cards.mjs.map +1 -1
- package/lib/components/LandingPage/Cards/Cards.styles.js.map +1 -1
- package/lib/components/LandingPage/Cards/Cards.styles.mjs.map +1 -1
- package/lib/components/LandingPage/LandingPage.js.map +1 -1
- package/lib/components/LandingPage/LandingPage.mjs.map +1 -1
- package/lib/components/LandingPagePro/LandingPagePro.js.map +1 -1
- package/lib/components/LandingPagePro/LandingPagePro.mjs.map +1 -1
- package/lib/components/LandingPagePro/LandingPagePro.styles.d.ts +1 -1
- package/lib/components/LandingPageSearch/Modal/Modal.js.map +1 -1
- package/lib/components/LandingPageSearch/Modal/Modal.mjs.map +1 -1
- package/lib/components/LandingPageSidebar/LandingPageSidebar.js.map +1 -1
- package/lib/components/LandingPageSidebar/LandingPageSidebar.mjs.map +1 -1
- package/lib/components/LandingPageSidebar/LandingPageSidebar.styles.js.map +1 -1
- package/lib/components/LandingPageSidebar/LandingPageSidebar.styles.mjs.map +1 -1
- package/lib/components/LayoutRenderer/LayoutRenderer.styles.d.ts +1 -1
- package/lib/components/LayoutRendererV1/LayoutRenderer.styles.d.ts +3 -3
- package/lib/components/LayoutRendererV2/LayoutRenderer.styles.d.ts +3 -3
- package/lib/components/MeetUniFiVideoPlayer/MeetUniFiVideoPlayer.helpers.js.map +1 -1
- package/lib/components/MeetUniFiVideoPlayer/MeetUniFiVideoPlayer.helpers.mjs.map +1 -1
- package/lib/components/MeetUniFiVideoPlayer/MeetUniFiVideoPlayer.styles.d.ts +1 -1
- package/lib/components/MicrositeExploreCards/MicrositeExploreCards.styles.js.map +1 -1
- package/lib/components/MicrositeExploreCards/MicrositeExploreCards.styles.mjs.map +1 -1
- package/lib/components/MicrositeFeatureList/MicrositeFeatureList.styles.js.map +1 -1
- package/lib/components/MicrositeFeatureList/MicrositeFeatureList.styles.mjs.map +1 -1
- package/lib/components/MicrositeHero/MicrositeHero.js.map +1 -1
- package/lib/components/MicrositeHero/MicrositeHero.mjs.map +1 -1
- package/lib/components/MicrositeHero/MicrositeHero.styles.js.map +1 -1
- package/lib/components/MicrositeHero/MicrositeHero.styles.mjs.map +1 -1
- package/lib/components/MicrositeMediaGrid/MicrositeMediaGrid.styles.js.map +1 -1
- package/lib/components/MicrositeMediaGrid/MicrositeMediaGrid.styles.mjs.map +1 -1
- package/lib/components/MicrositeProductGrid/MicrositeProductGrid.styles.js.map +1 -1
- package/lib/components/MicrositeProductGrid/MicrositeProductGrid.styles.mjs.map +1 -1
- package/lib/components/MicrositeProductLearnMoreBlock/MicrositeProductLearnMoreBlockWrap.js.map +1 -1
- package/lib/components/MicrositeProductLearnMoreBlock/MicrositeProductLearnMoreBlockWrap.mjs.map +1 -1
- package/lib/components/MicrositeSectionWrap/MicrositeSectionWrap.styles.d.ts +1 -1
- package/lib/components/Microsites/MicrositeProductPage.js.map +1 -1
- package/lib/components/Microsites/MicrositeProductPage.mjs.map +1 -1
- package/lib/components/MobileModal/MobileModal.styles.js.map +1 -1
- package/lib/components/MobileModal/MobileModal.styles.mjs.map +1 -1
- package/lib/components/ModelCompareV3/HeaderShadow.js.map +1 -1
- package/lib/components/ModelCompareV3/HeaderShadow.mjs.map +1 -1
- package/lib/components/ModelCompareV3/ModelCompareV3.js.map +1 -1
- package/lib/components/ModelCompareV3/ModelCompareV3.mjs.map +1 -1
- package/lib/components/ModelCompareV3/ModelCompareV3.styles.js.map +1 -1
- package/lib/components/ModelCompareV3/ModelCompareV3.styles.mjs.map +1 -1
- package/lib/components/ModelCompareV3/ModelCompareV3.types.d.ts +2 -2
- package/lib/components/ModelCompareV3/assets/port.svg.js +1 -1
- package/lib/components/ModelCompareV3/assets/port.svg.mjs +2 -2
- package/lib/components/ModelCompareV3/data/EnterpriseSwitching.js +2 -3
- package/lib/components/ModelCompareV3/data/EnterpriseSwitching.js.map +1 -1
- package/lib/components/ModelCompareV3/data/EnterpriseSwitching.mjs +2 -3
- package/lib/components/ModelCompareV3/data/EnterpriseSwitching.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/EnterpriseWiFi.js +2 -2
- package/lib/components/ModelCompareV3/data/EnterpriseWiFi.js.map +1 -1
- package/lib/components/ModelCompareV3/data/EnterpriseWiFi.mjs +2 -2
- package/lib/components/ModelCompareV3/data/EnterpriseWiFi.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/MegaCapacityWiFI.js +4 -3
- package/lib/components/ModelCompareV3/data/MegaCapacityWiFI.js.map +1 -1
- package/lib/components/ModelCompareV3/data/MegaCapacityWiFI.mjs +4 -3
- package/lib/components/ModelCompareV3/data/MegaCapacityWiFI.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/ProfessionalMaxSwitching.js +3 -10
- package/lib/components/ModelCompareV3/data/ProfessionalMaxSwitching.js.map +1 -1
- package/lib/components/ModelCompareV3/data/ProfessionalMaxSwitching.mjs +3 -10
- package/lib/components/ModelCompareV3/data/ProfessionalMaxSwitching.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/Switching.js +2 -3
- package/lib/components/ModelCompareV3/data/Switching.js.map +1 -1
- package/lib/components/ModelCompareV3/data/Switching.mjs +2 -3
- package/lib/components/ModelCompareV3/data/Switching.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/UispRouter.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/UispRouter.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/UispRouterPro.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/UispRouterPro.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/aggregation.js +0 -7
- package/lib/components/ModelCompareV3/data/products/aggregation.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/aggregation.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/aggregation.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airFiber11.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airFiber11.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airFiber24.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airFiber24.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airFiber24HiDensity.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airFiber24HiDensity.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airFiber2X.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airFiber2X.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airFiber5.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airFiber5.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airMAX5GHz16dBi120Sector.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airMAX5GHz16dBi120Sector.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airMAX5GHz17dBi90Sector.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airMAX5GHz17dBi90Sector.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airMAX5GHz19dBi120Sector.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airMAX5GHz19dBi120Sector.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airMAX5GHz20dBi90Sector.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/airMAX5GHz20dBi90Sector.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/baseStationXG.js +7 -0
- package/lib/components/ModelCompareV3/data/products/baseStationXG.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/baseStationXG.mjs +7 -0
- package/lib/components/ModelCompareV3/data/products/baseStationXG.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/buildingBridge.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/buildingBridge.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/buildingBridgeXG.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/buildingBridgeXG.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/cloudKeyEnterprise.js +1 -1
- package/lib/components/ModelCompareV3/data/products/cloudKeyEnterprise.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/cloudKeyEnterprise.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/cloudKeyEnterprise.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/e7.js +10 -3
- package/lib/components/ModelCompareV3/data/products/e7.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/e7.mjs +10 -3
- package/lib/components/ModelCompareV3/data/products/e7.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/e7Audience.js +10 -3
- package/lib/components/ModelCompareV3/data/products/e7Audience.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/e7Audience.mjs +10 -3
- package/lib/components/ModelCompareV3/data/products/e7Audience.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/e7Campus.js +11 -3
- package/lib/components/ModelCompareV3/data/products/e7Campus.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/e7Campus.mjs +11 -3
- package/lib/components/ModelCompareV3/data/products/e7Campus.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgePointR6.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgePointR6.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgePointR8.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgePointR8.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgePointS16Switch.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgePointS16Switch.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeRouter10x.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeRouter10x.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeRouter12.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeRouter12.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeRouter12p.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeRouter12p.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeRouter4.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeRouter4.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeRouter6Poe.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeRouter6Poe.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeRouterInfinity.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeRouterInfinity.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeRouterX.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeRouterX.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeRouterXSfp.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeRouterXSfp.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch10x.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch10x.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch10xp.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch10xp.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch16xg.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch16xg.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch16xp.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch16xp.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch16xpoe150.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch16xpoe150.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch18x.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch18x.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch24lite.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch24lite.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch24poe-500.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch24poe-500.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch24poe.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch24poe.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch48lite.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch48lite.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch48poe.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeSwitch48poe.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeswitch48poe-750.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeswitch48poe-750.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeswitch5xp.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeswitch5xp.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeswitch8poe.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/edgeswitch8poe.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterpriseAggregation.js +0 -7
- package/lib/components/ModelCompareV3/data/products/enterpriseAggregation.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterpriseAggregation.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/enterpriseAggregation.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterpriseCampus24PoE.js +0 -7
- package/lib/components/ModelCompareV3/data/products/enterpriseCampus24PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterpriseCampus24PoE.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/enterpriseCampus24PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterpriseCampus48PoE.js +0 -7
- package/lib/components/ModelCompareV3/data/products/enterpriseCampus48PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterpriseCampus48PoE.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/enterpriseCampus48PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/fiberInstant.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/fiberInstant.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/fiberNanog.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/fiberNanog.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.js +0 -7
- package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/ltuExtremeRange.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/ltuExtremeRange.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/ltuLongRange.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/ltuLongRange.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/ltuPro.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/ltuPro.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/missionCritical.js +0 -7
- package/lib/components/ModelCompareV3/data/products/missionCritical.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/missionCritical.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/missionCritical.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/nanoStation5AC.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/nanoStation5AC.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/nanoStation5ACLoco.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/nanoStation5ACLoco.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/prismStation5AC.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/prismStation5AC.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax16.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax16.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax16.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax16.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax24.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax24.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax24.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax24.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax48.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax48.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax48.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax48.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesEnterprise.js +0 -8
- package/lib/components/ModelCompareV3/data/products/switchesEnterprise.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesEnterprise.mjs +0 -8
- package/lib/components/ModelCompareV3/data/products/switchesEnterprise.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesProfessional.js +0 -7
- package/lib/components/ModelCompareV3/data/products/switchesProfessional.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesProfessional.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/switchesProfessional.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.js +1 -10
- package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.mjs +1 -10
- package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesStandard.js +0 -7
- package/lib/components/ModelCompareV3/data/products/switchesStandard.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesStandard.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/switchesStandard.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/udb.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/udb.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/udbPro.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/udbPro.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/uispSwitch.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/uispSwitch.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/properties/{crestronNaxNvxCertified.d.ts → extendedRangeMode6Ghz.d.ts} +1 -1
- package/lib/components/ModelCompareV3/data/properties/extendedRangeMode6Ghz.js +18 -0
- package/lib/components/ModelCompareV3/data/properties/extendedRangeMode6Ghz.js.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/extendedRangeMode6Ghz.mjs +10 -0
- package/lib/components/ModelCompareV3/data/properties/extendedRangeMode6Ghz.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/index.d.ts +1 -1
- package/lib/components/ModelCompareV3/data/properties/index.js +2 -2
- package/lib/components/ModelCompareV3/data/properties/index.mjs +1 -1
- package/lib/components/ModelCompareV3/data/properties/redundantRj45Port.js +1 -1
- package/lib/components/ModelCompareV3/data/properties/redundantRj45Port.mjs +1 -1
- package/lib/components/ModelCompareV3/translations/ar.json.js +6 -5
- package/lib/components/ModelCompareV3/translations/ar.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/ar.json.mjs +6 -5
- package/lib/components/ModelCompareV3/translations/ar.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/de.json.js +6 -5
- package/lib/components/ModelCompareV3/translations/de.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/de.json.mjs +6 -5
- package/lib/components/ModelCompareV3/translations/de.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/el.json.js +6 -5
- package/lib/components/ModelCompareV3/translations/el.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/el.json.mjs +6 -5
- package/lib/components/ModelCompareV3/translations/el.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/en.json.js +6 -8
- package/lib/components/ModelCompareV3/translations/en.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/en.json.mjs +6 -8
- package/lib/components/ModelCompareV3/translations/en.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/es.json.js +6 -5
- package/lib/components/ModelCompareV3/translations/es.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/es.json.mjs +6 -5
- package/lib/components/ModelCompareV3/translations/es.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/fr.json.js +6 -5
- package/lib/components/ModelCompareV3/translations/fr.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/fr.json.mjs +6 -5
- package/lib/components/ModelCompareV3/translations/fr.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/it.json.js +6 -5
- package/lib/components/ModelCompareV3/translations/it.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/it.json.mjs +6 -5
- package/lib/components/ModelCompareV3/translations/it.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/ja.json.js +7 -6
- package/lib/components/ModelCompareV3/translations/ja.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/ja.json.mjs +7 -6
- package/lib/components/ModelCompareV3/translations/ja.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/pt-BR.json.js +6 -5
- package/lib/components/ModelCompareV3/translations/pt-BR.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/pt-BR.json.mjs +6 -5
- package/lib/components/ModelCompareV3/translations/pt-BR.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/useModelCompareTranslation.d.ts +2 -2
- package/lib/components/ModelCompareV3/translations/zh-Hans.json.js +6 -5
- package/lib/components/ModelCompareV3/translations/zh-Hans.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/zh-Hans.json.mjs +6 -5
- package/lib/components/ModelCompareV3/translations/zh-Hans.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.js +6 -5
- package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.mjs +6 -5
- package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.mjs.map +1 -1
- package/lib/components/Pagination/Pagination.js.map +1 -1
- package/lib/components/Pagination/Pagination.mjs.map +1 -1
- package/lib/components/PriceRangeSlider/PriceRangeSlider.js.map +1 -1
- package/lib/components/PriceRangeSlider/PriceRangeSlider.mjs.map +1 -1
- package/lib/components/ProductCard/ProductCard.js.map +1 -1
- package/lib/components/ProductCard/ProductCard.mjs.map +1 -1
- package/lib/components/ProductCardPopup/ProductCardPopup.js.map +1 -1
- package/lib/components/ProductCardPopup/ProductCardPopup.mjs.map +1 -1
- package/lib/components/ProductGrid/ProductGrid.js.map +1 -1
- package/lib/components/ProductGrid/ProductGrid.mjs.map +1 -1
- package/lib/components/ProductSectionNavigation/ProductSectionNavigation.styles.d.ts +1 -1
- package/lib/components/ProductSectionNavigationV2/ProductSectionNavigation.styles.d.ts +1 -1
- package/lib/components/ProductSectionTabs/ProductSectionTabs.js.map +1 -1
- package/lib/components/ProductSectionTabs/ProductSectionTabs.mjs.map +1 -1
- package/lib/components/ProductTechSpecs/ProductTechSpecs.styles.d.ts +2 -2
- package/lib/components/ProductTechSpecs/ProductTechSpecs.styles.js.map +1 -1
- package/lib/components/ProductTechSpecs/ProductTechSpecs.styles.mjs.map +1 -1
- package/lib/components/ProductWizard/ProductWizard.js +1 -1
- package/lib/components/ProductWizard/ProductWizard.mjs +1 -1
- package/lib/components/ProductWizardFootnotes/ProductWizardFootnotes.js.map +1 -1
- package/lib/components/ProductWizardFootnotes/ProductWizardFootnotes.mjs.map +1 -1
- package/lib/components/QuantityInput/QuantityInput.js +1 -1
- package/lib/components/QuantityInput/QuantityInput.mjs +1 -1
- package/lib/components/RelatedProducts/RelatedProducts.js.map +1 -1
- package/lib/components/RelatedProducts/RelatedProducts.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/HddSlots/HddSlots.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/HddSlots/HddSlots.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.js +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/Layout.styles.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/Layout.styles.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.js +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerConfigurator.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerConfigurator.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.js +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/RecommendedPoeSwitches.js +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/RecommendedPoeSwitches.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/RecommendedPoeSwitches.mjs +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/RecommendedPoeSwitches.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/assets/port.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/assets/port.svg.mjs +2 -2
- package/lib/components/ScrollWrapper/ScrollWrapper.d.ts +1 -1
- package/lib/components/ScrollWrapper/ScrollWrapper.js +16 -8
- package/lib/components/ScrollWrapper/ScrollWrapper.js.map +1 -1
- package/lib/components/ScrollWrapper/ScrollWrapper.mjs +16 -8
- package/lib/components/ScrollWrapper/ScrollWrapper.mjs.map +1 -1
- package/lib/components/ScrollWrapper/ScrollWrapper.styles.js.map +1 -1
- package/lib/components/ScrollWrapper/ScrollWrapper.styles.mjs.map +1 -1
- package/lib/components/ScrollWrapper/ScrollWrapper.types.d.ts +2 -0
- package/lib/components/Search/Input/Input.d.ts +1 -1
- package/lib/components/Search/Input/Input.js +4 -4
- package/lib/components/Search/Input/Input.js.map +1 -1
- package/lib/components/Search/Input/Input.mjs +4 -4
- package/lib/components/Search/Input/Input.mjs.map +1 -1
- package/lib/components/Search/Input/Input.styles.js +0 -1
- package/lib/components/Search/Input/Input.styles.js.map +1 -1
- package/lib/components/Search/Input/Input.styles.mjs +0 -1
- package/lib/components/Search/Input/Input.styles.mjs.map +1 -1
- package/lib/components/Search/Input/Input.types.d.ts +3 -2
- package/lib/components/Search/Modal/Modal.js.map +1 -1
- package/lib/components/Search/Modal/Modal.mjs.map +1 -1
- package/lib/components/SkeletonLoader/SkeletonLoaderTable/SkeletonLoaderTable.js.map +1 -1
- package/lib/components/SkeletonLoader/SkeletonLoaderTable/SkeletonLoaderTable.mjs.map +1 -1
- package/lib/components/StorageSliders/StorageSliders.utils.js.map +1 -1
- package/lib/components/StorageSliders/StorageSliders.utils.mjs.map +1 -1
- package/lib/components/StyleableSvgImage/StyleableSvgImage.js.map +1 -1
- package/lib/components/StyleableSvgImage/StyleableSvgImage.mjs.map +1 -1
- package/lib/components/VariantSelector/Variant/Compatibility/Compatibility.js.map +1 -1
- package/lib/components/VariantSelector/Variant/Compatibility/Compatibility.mjs.map +1 -1
- package/lib/components/VariantSelector/Variant/Compatibility/Compatibility.styles.js.map +1 -1
- package/lib/components/VariantSelector/Variant/Compatibility/Compatibility.styles.mjs.map +1 -1
- package/lib/components/VariantSelector/Variant/Variant.js.map +1 -1
- package/lib/components/VariantSelector/Variant/Variant.mjs.map +1 -1
- package/lib/components/VariantSelector/VariantSelector.constants.js.map +1 -1
- package/lib/components/VariantSelector/VariantSelector.constants.mjs.map +1 -1
- package/lib/components/VideoPlayerNew/VideoPlayer.js +1 -1
- package/lib/components/VideoPlayerNew/VideoPlayer.mjs +1 -1
- package/lib/components/VideoPlayerNew/assets/close.svg.js +1 -1
- package/lib/components/VideoPlayerNew/assets/close.svg.mjs +2 -2
- package/lib/constants/icons/options/colors/black.svg.js +5 -5
- package/lib/constants/icons/options/colors/index.js +3 -3
- package/lib/constants/icons/options/styles/black.svg.js +5 -5
- package/lib/constants/icons/options/styles/index.js +3 -3
- package/lib/constants/layout.js.map +1 -1
- package/lib/constants/layout.mjs.map +1 -1
- package/lib/constants/optionIcons.js +6 -6
- package/lib/constants/optionIcons.mjs +4 -4
- package/lib/constants/postalCode.js.map +1 -1
- package/lib/constants/postalCode.mjs.map +1 -1
- package/lib/constants/proStoreCategories/mapping/filters.d.ts +16 -0
- package/lib/constants/proStoreCategories/mapping/filters.js +16 -0
- package/lib/constants/proStoreCategories/mapping/filters.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/filters.mjs +16 -0
- package/lib/constants/proStoreCategories/mapping/filters.mjs.map +1 -1
- package/lib/constants/proStoreCategories/mapping/index.d.ts +1 -1
- package/lib/constants/proStoreCategories/mapping/index.js +15 -11
- package/lib/constants/proStoreCategories/mapping/index.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/index.mjs +15 -11
- package/lib/constants/proStoreCategories/mapping/index.mjs.map +1 -1
- package/lib/constants/proStoreCategories/mapping/mapping.d.ts +5 -0
- package/lib/constants/proStoreCategories/mapping/uisp.d.ts +0 -1
- package/lib/constants/proStoreCategories/mapping/uisp.js +0 -1
- package/lib/constants/proStoreCategories/mapping/uisp.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/uisp.mjs +0 -1
- package/lib/constants/proStoreCategories/mapping/uisp.mjs.map +1 -1
- package/lib/constants/proStoreCategories/mapping/unifi.d.ts +1 -0
- package/lib/constants/proStoreCategories/mapping/unifi.js +1 -0
- package/lib/constants/proStoreCategories/mapping/unifi.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/unifi.mjs +1 -0
- package/lib/constants/proStoreCategories/mapping/unifi.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/ar.json.js +2 -5
- package/lib/constants/proStoreCategories/translations/ar.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/ar.json.mjs +3 -5
- package/lib/constants/proStoreCategories/translations/ar.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/de.json.js +2 -5
- package/lib/constants/proStoreCategories/translations/de.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/de.json.mjs +3 -5
- package/lib/constants/proStoreCategories/translations/de.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/el.json.js +3 -6
- package/lib/constants/proStoreCategories/translations/el.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/el.json.mjs +4 -6
- package/lib/constants/proStoreCategories/translations/el.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/en.json.js +1 -1
- package/lib/constants/proStoreCategories/translations/en.json.mjs +1 -1
- package/lib/constants/proStoreCategories/translations/es.json.js +2 -5
- package/lib/constants/proStoreCategories/translations/es.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/es.json.mjs +3 -5
- package/lib/constants/proStoreCategories/translations/es.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/fr.json.js +2 -2
- package/lib/constants/proStoreCategories/translations/fr.json.mjs +2 -2
- package/lib/constants/proStoreCategories/translations/it.json.js +2 -5
- package/lib/constants/proStoreCategories/translations/it.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/it.json.mjs +3 -5
- package/lib/constants/proStoreCategories/translations/it.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/ja.json.js +2 -5
- package/lib/constants/proStoreCategories/translations/ja.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/ja.json.mjs +3 -5
- package/lib/constants/proStoreCategories/translations/ja.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/pt-BR.json.js +2 -5
- package/lib/constants/proStoreCategories/translations/pt-BR.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs +3 -5
- package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.js +2 -2
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs +2 -2
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js +2 -2
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs +2 -2
- package/lib/constants/proStoreFilters/mapping.d.ts +33 -7
- package/lib/constants/proStoreFilters/mapping.js +108 -14
- package/lib/constants/proStoreFilters/mapping.js.map +1 -1
- package/lib/constants/proStoreFilters/mapping.mjs +108 -14
- package/lib/constants/proStoreFilters/mapping.mjs.map +1 -1
- package/lib/constants/theme.js +4 -0
- package/lib/constants/theme.js.map +1 -1
- package/lib/constants/theme.mjs +4 -0
- package/lib/constants/theme.mjs.map +1 -1
- package/lib/contexts/MenuContext/context.js +1 -1
- package/lib/contexts/MenuContext/context.js.map +1 -1
- package/lib/contexts/MenuContext/context.mjs +1 -1
- package/lib/contexts/MenuContext/context.mjs.map +1 -1
- package/lib/contexts/MenuContext/mapping.js.map +1 -1
- package/lib/contexts/MenuContext/mapping.mjs.map +1 -1
- package/lib/contexts/MenuContext/utils.js.map +1 -1
- package/lib/contexts/MenuContext/utils.mjs.map +1 -1
- package/lib/helpers/index.d.ts +0 -1
- package/lib/helpers/index.js +0 -11
- package/lib/helpers/index.js.map +1 -1
- package/lib/helpers/index.mjs +0 -1
- package/lib/helpers/index.mjs.map +1 -1
- package/lib/helpers/time.js.map +1 -1
- package/lib/helpers/time.mjs.map +1 -1
- package/lib/helpers/ux.d.ts +9 -1
- package/lib/helpers/ux.js +15 -0
- package/lib/helpers/ux.js.map +1 -1
- package/lib/helpers/ux.mjs +15 -1
- package/lib/helpers/ux.mjs.map +1 -1
- package/lib/hooks/useTranslation.js.map +1 -1
- package/lib/hooks/useTranslation.mjs.map +1 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/index.js +0 -2
- package/lib/types/index.js.map +1 -1
- package/lib/types/index.mjs +0 -1
- package/lib/types/index.mjs.map +1 -1
- package/lib/utils/address.d.ts +62 -278
- package/lib/utils/address.js +8 -11
- package/lib/utils/address.js.map +1 -1
- package/lib/utils/address.mjs +8 -11
- package/lib/utils/address.mjs.map +1 -1
- package/lib/utils/array.d.ts +0 -4
- package/lib/utils/array.js +0 -10
- package/lib/utils/array.js.map +1 -1
- package/lib/utils/array.mjs +1 -10
- package/lib/utils/array.mjs.map +1 -1
- package/lib/utils/money/allocators/fixedAmount.js.map +1 -1
- package/lib/utils/money/allocators/fixedAmount.mjs.map +1 -1
- package/lib/utils/money/format.js +1 -2
- package/lib/utils/money/format.js.map +1 -1
- package/lib/utils/money/format.mjs +1 -2
- package/lib/utils/money/format.mjs.map +1 -1
- package/lib/utils/money/misc.js.map +1 -1
- package/lib/utils/money/misc.mjs.map +1 -1
- package/lib/utils/nextjs/createInlineScript.js.map +1 -1
- package/lib/utils/nextjs/createInlineScript.mjs.map +1 -1
- package/lib/utils/nextjs/index.d.ts +0 -3
- package/lib/utils/nextjs/index.js +0 -5
- package/lib/utils/nextjs/index.js.map +1 -1
- package/lib/utils/nextjs/index.mjs +0 -3
- package/lib/utils/nextjs/index.mjs.map +1 -1
- package/lib/utils/nextjs/stringifyForInject.js.map +1 -1
- package/lib/utils/nextjs/stringifyForInject.mjs.map +1 -1
- package/lib/utils/number.js.map +1 -1
- package/lib/utils/number.mjs.map +1 -1
- package/lib/utils/tax/brazil.js.map +1 -1
- package/lib/utils/tax/brazil.mjs.map +1 -1
- package/lib/utils/wattage.js.map +1 -1
- package/lib/utils/wattage.mjs.map +1 -1
- package/package.json +1 -3
- package/lib/assets/crestron.svg +0 -3
- package/lib/assets/icons/menu/icon-globe.svg.js +0 -27
- package/lib/assets/icons/menu/icon-globe.svg.js.map +0 -1
- package/lib/assets/icons/menu/icon-globe.svg.mjs +0 -3
- package/lib/assets/icons/menu/icon-globe.svg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/crestron.svg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/crestron.svg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/crestron.svg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/data/properties/crestronNaxNvxCertified.js +0 -18
- package/lib/components/ModelCompareV3/data/properties/crestronNaxNvxCertified.js.map +0 -1
- package/lib/components/ModelCompareV3/data/properties/crestronNaxNvxCertified.mjs +0 -10
- package/lib/components/ModelCompareV3/data/properties/crestronNaxNvxCertified.mjs.map +0 -1
- package/lib/helpers/product.d.ts +0 -87
- package/lib/helpers/product.js +0 -346
- package/lib/helpers/product.js.map +0 -1
- package/lib/helpers/product.mjs +0 -335
- package/lib/helpers/product.mjs.map +0 -1
- package/lib/helpers/product.test.d.ts +0 -1
- package/lib/types/product.d.ts +0 -87
- package/lib/types/product.js +0 -14
- package/lib/types/product.js.map +0 -1
- package/lib/types/product.mjs +0 -13
- package/lib/types/product.mjs.map +0 -1
- package/lib/utils/nextjs/patch.d.ts +0 -1
- package/lib/utils/nextjs/patch.js +0 -53
- package/lib/utils/nextjs/patch.js.map +0 -1
- package/lib/utils/nextjs/patch.mjs +0 -41
- package/lib/utils/nextjs/patch.mjs.map +0 -1
- package/lib/utils/nextjs/plugin.d.ts +0 -14
- package/lib/utils/nextjs/plugin.js +0 -41
- package/lib/utils/nextjs/plugin.js.map +0 -1
- package/lib/utils/nextjs/plugin.mjs +0 -39
- package/lib/utils/nextjs/plugin.mjs.map +0 -1
- package/lib/utils/nextjs/ssr/constants.d.ts +0 -8
- package/lib/utils/nextjs/ssr/constants.js +0 -8
- package/lib/utils/nextjs/ssr/constants.js.map +0 -1
- package/lib/utils/nextjs/ssr/constants.mjs +0 -6
- package/lib/utils/nextjs/ssr/constants.mjs.map +0 -1
- package/lib/utils/nextjs/ssr/registry.d.ts +0 -52
- package/lib/utils/nextjs/ssr/registry.js +0 -22
- package/lib/utils/nextjs/ssr/registry.js.map +0 -1
- package/lib/utils/nextjs/ssr/registry.mjs +0 -20
- package/lib/utils/nextjs/ssr/registry.mjs.map +0 -1
- package/lib/utils/nextjs/ssr/style-inject.d.ts +0 -21
- package/lib/utils/nextjs/ssr/style-inject.js +0 -47
- package/lib/utils/nextjs/ssr/style-inject.js.map +0 -1
- package/lib/utils/nextjs/ssr/style-inject.mjs +0 -43
- package/lib/utils/nextjs/ssr/style-inject.mjs.map +0 -1
- package/lib/utils/nextjs/ssr/transform-css-module.d.ts +0 -11
- package/lib/utils/nextjs/ssr/transform-css-module.js +0 -115
- package/lib/utils/nextjs/ssr/transform-css-module.js.map +0 -1
- package/lib/utils/nextjs/ssr/transform-css-module.mjs +0 -87
- package/lib/utils/nextjs/ssr/transform-css-module.mjs.map +0 -1
- package/lib/utils/nextjs/ssr/transform-css-module.test.d.ts +0 -1
- package/lib/utils/nextjs/ssr/types.d.ts +0 -10
- package/lib/utils/productSort.d.ts +0 -41
- package/lib/utils/productSort.js +0 -67
- package/lib/utils/productSort.js.map +0 -1
- package/lib/utils/productSort.mjs +0 -60
- package/lib/utils/productSort.mjs.map +0 -1
- package/lib/utils/validations/lastNameSuperRefinement.d.ts +0 -11
- package/lib/utils/validations/lastNameSuperRefinement.js +0 -25
- package/lib/utils/validations/lastNameSuperRefinement.js.map +0 -1
- package/lib/utils/validations/lastNameSuperRefinement.mjs +0 -21
- package/lib/utils/validations/lastNameSuperRefinement.mjs.map +0 -1
|
@@ -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;I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O,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.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,CA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pC,iBAAOH,OAAQ,EAAA;IAAEwC,QAAQ,CAAG;IAAAC,KAAA,EAAOH;GAAY,CAAA;EAElE,MAAAI,QAAA,GAAWvB,qBAAWnB,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 +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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AElE,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, 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,WAAY,CAAAD,KAAK,CAAG,EAAA;IAChB,OAAAA,KAAA;EACT;EAEM,MAAAE,SAAA,GAAYF,MAAMG,MAAO,EAAA;E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2C,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":"createInlineScript.js","sources":["../../../src/utils/nextjs/createInlineScript.ts"],"sourcesContent":["import { createHash } from \"crypto\";\nimport { minify } from \"terser\";\n\n/**\n * Returns a SHA256 hash using SHA-2 for the given `content`.\n * @private Internal library method!\n * @see https://en.wikipedia.org/wiki/SHA-2\n * @See https://futurestud.io/tutorials/node-js-calculate-a-sha256-hash\n */\nexport const _cspHash = (scriptContent: string): string => {\n if (\n // Naive approach but it sufficiernt for our use case\n scriptContent.startsWith(\"<script\") ||\n scriptContent.endsWith(\"</script>\")\n ) {\n throw new Error(\n \"Inline script should not be wrapped inside of <script><script/>\",\n );\n }\n const hash = createHash(\"sha256\").update(scriptContent).digest(\"base64\");\n return `'sha256-${hash}'`;\n};\n\n/**\n * Minifies the inline script for \"machine\" consumption\n * Uses `terser` (webpack minifier of choice) to minify the script\n * @private Internal library method!\n * @see https://github.com/terser/terser\n */\nexport const _minifyScript = async (scriptContent: string): Promise<string> => {\n const minifiedContent = (await minify(scriptContent, {})).code;\n if (!minifiedContent) {\n throw new Error(\n \"Missing minified code for some reason, check input for script content\",\n );\n }\n return minifiedContent;\n};\n\n/**\n * Utility to create safe & optimized inline-script\n * It does two things:\n * 1. Optimizes the minifies script as bundlers don't do that\n * 2. Creates `'sha256 ...'` (already escaped!) to use in CSP header\n */\nexport const createInlineScript = async (inlineScriptContent: string) => {\n const optimizedInlineScriptContent = await _minifyScript(inlineScriptContent);\n\n return {\n cspSha: _cspHash(optimizedInlineScriptContent),\n inlineScript: optimizedInlineScriptContent,\n };\n};\n"],"names":["_cspHash","scriptContent","startsWith","endsWith","Error","hash","createHash","update","digest","_minifyScript","minifiedContent","minify","code","createInlineScript","inlineScriptContent","optimizedInlineScriptContent","cspSha","inlineScript"],"mappings":";;;;;AASa,MAAAA,QAAA,GAAYC,aAAkC,IAAA;EACzD;EAAA;EAEEA,cAAcC,UAAW,CAAA,SAAS,CAClC,IAAAD,aAAA,CAAcE,SAAS,YAAW,CAAA,EAClC;IACA,MAAM,IAAIC,KAAA,CACR,iEAAA,CACF;EACF;EACM,MAAAC,IAAA,GAAOC,kBAAW,QAAQ,CAAA,CAAEC,OAAON,aAAa,CAAA,CAAEO,OAAO,QAAQ,CAAA;EACvE,
|
|
1
|
+
{"version":3,"file":"createInlineScript.js","sources":["../../../src/utils/nextjs/createInlineScript.ts"],"sourcesContent":["import { createHash } from \"crypto\";\nimport { minify } from \"terser\";\n\n/**\n * Returns a SHA256 hash using SHA-2 for the given `content`.\n * @private Internal library method!\n * @see https://en.wikipedia.org/wiki/SHA-2\n * @See https://futurestud.io/tutorials/node-js-calculate-a-sha256-hash\n */\nexport const _cspHash = (scriptContent: string): string => {\n if (\n // Naive approach but it sufficiernt for our use case\n scriptContent.startsWith(\"<script\") ||\n scriptContent.endsWith(\"</script>\")\n ) {\n throw new Error(\n \"Inline script should not be wrapped inside of <script><script/>\",\n );\n }\n const hash = createHash(\"sha256\").update(scriptContent).digest(\"base64\");\n return `'sha256-${hash}'`;\n};\n\n/**\n * Minifies the inline script for \"machine\" consumption\n * Uses `terser` (webpack minifier of choice) to minify the script\n * @private Internal library method!\n * @see https://github.com/terser/terser\n */\nexport const _minifyScript = async (scriptContent: string): Promise<string> => {\n const minifiedContent = (await minify(scriptContent, {})).code;\n if (!minifiedContent) {\n throw new Error(\n \"Missing minified code for some reason, check input for script content\",\n );\n }\n return minifiedContent;\n};\n\n/**\n * Utility to create safe & optimized inline-script\n * It does two things:\n * 1. Optimizes the minifies script as bundlers don't do that\n * 2. Creates `'sha256 ...'` (already escaped!) to use in CSP header\n */\nexport const createInlineScript = async (inlineScriptContent: string) => {\n const optimizedInlineScriptContent = await _minifyScript(inlineScriptContent);\n\n return {\n cspSha: _cspHash(optimizedInlineScriptContent),\n inlineScript: optimizedInlineScriptContent,\n };\n};\n"],"names":["_cspHash","scriptContent","startsWith","endsWith","Error","hash","createHash","update","digest","_minifyScript","minifiedContent","minify","code","createInlineScript","inlineScriptContent","optimizedInlineScriptContent","cspSha","inlineScript"],"mappings":";;;;;AASa,MAAAA,QAAA,GAAYC,aAAkC,IAAA;EACzD;EAAA;EAEEA,cAAcC,UAAW,CAAA,SAAS,CAClC,IAAAD,aAAA,CAAcE,SAAS,YAAW,CAAA,EAClC;IACA,MAAM,IAAIC,KAAA,CACR,iEAAA,CACF;EACF;EACM,MAAAC,IAAA,GAAOC,kBAAW,QAAQ,CAAA,CAAEC,OAAON,aAAa,CAAA,CAAEO,OAAO,QAAQ,CAAA;EACvE,kBAAkBH,IAAI,GAAA;AACxB,CAAA;AAQa,MAAAI,aAAA,GAAgB,MAAOR,aAA2C,IAAA;EAC7E,MAAMS,mBAAmB,MAAMC,MAAAA,CAAAA,MAAA,CAAOV,aAAe,EAAA,CAAA,CAAE,CAAG,EAAAW,IAAA;EAC1D,IAAI,CAACF,eAAiB,EAAA;IACpB,MAAM,IAAIN,KAAA,CACR,uEAAA,CACF;EACF;EACO,OAAAM,eAAA;AACT,CAAA;AAQa,MAAAG,kBAAA,GAAqB,MAAOC,mBAAgC,IAAA;EACjE,MAAAC,4BAAA,GAA+B,MAAMN,aAAA,CAAcK,mBAAmB,CAAA;EAErE,OAAA;IACLE,MAAA,EAAQhB,SAASe,4BAA4B,CAAA;IAC7CE,YAAc,EAAAF;EAAA,CAChB;AACF,CAAA;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInlineScript.mjs","sources":["../../../src/utils/nextjs/createInlineScript.ts"],"sourcesContent":["import { createHash } from \"crypto\";\nimport { minify } from \"terser\";\n\n/**\n * Returns a SHA256 hash using SHA-2 for the given `content`.\n * @private Internal library method!\n * @see https://en.wikipedia.org/wiki/SHA-2\n * @See https://futurestud.io/tutorials/node-js-calculate-a-sha256-hash\n */\nexport const _cspHash = (scriptContent: string): string => {\n if (\n // Naive approach but it sufficiernt for our use case\n scriptContent.startsWith(\"<script\") ||\n scriptContent.endsWith(\"</script>\")\n ) {\n throw new Error(\n \"Inline script should not be wrapped inside of <script><script/>\",\n );\n }\n const hash = createHash(\"sha256\").update(scriptContent).digest(\"base64\");\n return `'sha256-${hash}'`;\n};\n\n/**\n * Minifies the inline script for \"machine\" consumption\n * Uses `terser` (webpack minifier of choice) to minify the script\n * @private Internal library method!\n * @see https://github.com/terser/terser\n */\nexport const _minifyScript = async (scriptContent: string): Promise<string> => {\n const minifiedContent = (await minify(scriptContent, {})).code;\n if (!minifiedContent) {\n throw new Error(\n \"Missing minified code for some reason, check input for script content\",\n );\n }\n return minifiedContent;\n};\n\n/**\n * Utility to create safe & optimized inline-script\n * It does two things:\n * 1. Optimizes the minifies script as bundlers don't do that\n * 2. Creates `'sha256 ...'` (already escaped!) to use in CSP header\n */\nexport const createInlineScript = async (inlineScriptContent: string) => {\n const optimizedInlineScriptContent = await _minifyScript(inlineScriptContent);\n\n return {\n cspSha: _cspHash(optimizedInlineScriptContent),\n inlineScript: optimizedInlineScriptContent,\n };\n};\n"],"names":["_cspHash","scriptContent","startsWith","endsWith","Error","hash","createHash","update","digest","_minifyScript","minifiedContent","minify","code","createInlineScript","inlineScriptContent","optimizedInlineScriptContent","cspSha","inlineScript"],"mappings":";;;AASa,MAAAA,QAAA,GAAYC,aAAkC,IAAA;EACzD;EAAA;EAEEA,cAAcC,UAAW,CAAA,SAAS,CAClC,IAAAD,aAAA,CAAcE,SAAS,YAAW,CAAA,EAClC;IACA,MAAM,IAAIC,KAAA,CACR,iEAAA,CACF;EACF;EACM,MAAAC,IAAA,GAAOC,WAAW,QAAQ,CAAA,CAAEC,OAAON,aAAa,CAAA,CAAEO,OAAO,QAAQ,CAAA;EACvE,
|
|
1
|
+
{"version":3,"file":"createInlineScript.mjs","sources":["../../../src/utils/nextjs/createInlineScript.ts"],"sourcesContent":["import { createHash } from \"crypto\";\nimport { minify } from \"terser\";\n\n/**\n * Returns a SHA256 hash using SHA-2 for the given `content`.\n * @private Internal library method!\n * @see https://en.wikipedia.org/wiki/SHA-2\n * @See https://futurestud.io/tutorials/node-js-calculate-a-sha256-hash\n */\nexport const _cspHash = (scriptContent: string): string => {\n if (\n // Naive approach but it sufficiernt for our use case\n scriptContent.startsWith(\"<script\") ||\n scriptContent.endsWith(\"</script>\")\n ) {\n throw new Error(\n \"Inline script should not be wrapped inside of <script><script/>\",\n );\n }\n const hash = createHash(\"sha256\").update(scriptContent).digest(\"base64\");\n return `'sha256-${hash}'`;\n};\n\n/**\n * Minifies the inline script for \"machine\" consumption\n * Uses `terser` (webpack minifier of choice) to minify the script\n * @private Internal library method!\n * @see https://github.com/terser/terser\n */\nexport const _minifyScript = async (scriptContent: string): Promise<string> => {\n const minifiedContent = (await minify(scriptContent, {})).code;\n if (!minifiedContent) {\n throw new Error(\n \"Missing minified code for some reason, check input for script content\",\n );\n }\n return minifiedContent;\n};\n\n/**\n * Utility to create safe & optimized inline-script\n * It does two things:\n * 1. Optimizes the minifies script as bundlers don't do that\n * 2. Creates `'sha256 ...'` (already escaped!) to use in CSP header\n */\nexport const createInlineScript = async (inlineScriptContent: string) => {\n const optimizedInlineScriptContent = await _minifyScript(inlineScriptContent);\n\n return {\n cspSha: _cspHash(optimizedInlineScriptContent),\n inlineScript: optimizedInlineScriptContent,\n };\n};\n"],"names":["_cspHash","scriptContent","startsWith","endsWith","Error","hash","createHash","update","digest","_minifyScript","minifiedContent","minify","code","createInlineScript","inlineScriptContent","optimizedInlineScriptContent","cspSha","inlineScript"],"mappings":";;;AASa,MAAAA,QAAA,GAAYC,aAAkC,IAAA;EACzD;EAAA;EAEEA,cAAcC,UAAW,CAAA,SAAS,CAClC,IAAAD,aAAA,CAAcE,SAAS,YAAW,CAAA,EAClC;IACA,MAAM,IAAIC,KAAA,CACR,iEAAA,CACF;EACF;EACM,MAAAC,IAAA,GAAOC,WAAW,QAAQ,CAAA,CAAEC,OAAON,aAAa,CAAA,CAAEO,OAAO,QAAQ,CAAA;EACvE,kBAAkBH,IAAI,GAAA;AACxB,CAAA;AAQa,MAAAI,aAAA,GAAgB,MAAOR,aAA2C,IAAA;EAC7E,MAAMS,mBAAmB,MAAMC,MAAA,CAAOV,aAAe,EAAA,CAAA,CAAE,CAAG,EAAAW,IAAA;EAC1D,IAAI,CAACF,eAAiB,EAAA;IACpB,MAAM,IAAIN,KAAA,CACR,uEAAA,CACF;EACF;EACO,OAAAM,eAAA;AACT,CAAA;AAQa,MAAAG,kBAAA,GAAqB,MAAOC,mBAAgC,IAAA;EACjE,MAAAC,4BAAA,GAA+B,MAAMN,aAAA,CAAcK,mBAAmB,CAAA;EAErE,OAAA;IACLE,MAAA,EAAQhB,SAASe,4BAA4B,CAAA;IAC7CE,YAAc,EAAAF;EAAA,CAChB;AACF,CAAA;"}
|
|
@@ -2,7 +2,4 @@ export { createInlineScript } from "./createInlineScript";
|
|
|
2
2
|
export { stringifyForInject } from "./stringifyForInject";
|
|
3
3
|
export { mergeCspDirectives } from "./mergeCspDirectives";
|
|
4
4
|
export { sanitizeImageDomains } from "./sanitizeImageDomains";
|
|
5
|
-
export { withUbntLibraries } from "./plugin";
|
|
6
|
-
export { UiComponentsSsrStyleRegistryPagesRouter } from "./ssr/registry";
|
|
7
|
-
import "./ssr/style-inject";
|
|
8
5
|
export * from "./navigationPresets";
|
|
@@ -4,17 +4,12 @@ var createInlineScript = require('./createInlineScript.js');
|
|
|
4
4
|
var stringifyForInject = require('./stringifyForInject.js');
|
|
5
5
|
var mergeCspDirectives = require('./mergeCspDirectives.js');
|
|
6
6
|
var sanitizeImageDomains = require('./sanitizeImageDomains.js');
|
|
7
|
-
var plugin = require('./plugin.js');
|
|
8
|
-
var registry = require('./ssr/registry.js');
|
|
9
|
-
require('./ssr/style-inject.js');
|
|
10
7
|
var navigationPresets = require('./navigationPresets.js');
|
|
11
8
|
"use strict";
|
|
12
9
|
exports.createInlineScript = createInlineScript.createInlineScript;
|
|
13
10
|
exports.stringifyForInject = stringifyForInject.stringifyForInject;
|
|
14
11
|
exports.mergeCspDirectives = mergeCspDirectives.mergeCspDirectives;
|
|
15
12
|
exports.sanitizeImageDomains = sanitizeImageDomains.sanitizeImageDomains;
|
|
16
|
-
exports.withUbntLibraries = plugin.withUbntLibraries;
|
|
17
|
-
exports.UiComponentsSsrStyleRegistryPagesRouter = registry.UiComponentsSsrStyleRegistryPagesRouter;
|
|
18
13
|
exports.getGlobalSiteConfigByEnv = navigationPresets.getGlobalSiteConfigByEnv;
|
|
19
14
|
exports.getStoreRootUrlsByEnv = navigationPresets.getStoreRootUrlsByEnv;
|
|
20
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
|
@@ -2,9 +2,6 @@ export { createInlineScript } from './createInlineScript.mjs';
|
|
|
2
2
|
export { stringifyForInject } from './stringifyForInject.mjs';
|
|
3
3
|
export { mergeCspDirectives } from './mergeCspDirectives.mjs';
|
|
4
4
|
export { sanitizeImageDomains } from './sanitizeImageDomains.mjs';
|
|
5
|
-
export { withUbntLibraries } from './plugin.mjs';
|
|
6
|
-
export { UiComponentsSsrStyleRegistryPagesRouter } from './ssr/registry.mjs';
|
|
7
|
-
import './ssr/style-inject.mjs';
|
|
8
5
|
export { getGlobalSiteConfigByEnv, getStoreRootUrlsByEnv } from './navigationPresets.mjs';
|
|
9
6
|
"use strict";
|
|
10
7
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringifyForInject.js","sources":["../../../src/utils/nextjs/stringifyForInject.ts"],"sourcesContent":["/**\n * Utility to help escape variables for Webpack's DefinePlugin\n * @see https://webpack.js.org/plugins/define-plugin/#:~:text=The%20DefinePlugin%20replaces%20variables%20in,development%20builds%20and%20production%20builds.\n */\nexport const stringifyForInject = (val: unknown): unknown => {\n switch (typeof val) {\n case \"string\":\n return JSON.stringify(val);\n case \"bigint\":\n case \"boolean\":\n case \"function\":\n case \"number\":\n case \"undefined\":\n return val;\n case \"symbol\":\n throw new Error(`Can't inject Symbol`);\n case \"object\": {\n if (Array.isArray(val)) {\n return val.map((nestedVal) => stringifyForInject(nestedVal));\n }\n\n const stringifiedObject: { [key: string]: unknown } = {};\n for (const key in val) {\n // @ts-expect-error Expect to fail as we are working with unknowns\n const nestedVal = val[key];\n stringifiedObject[key] = stringifyForInject(nestedVal);\n }\n return stringifiedObject;\n }\n default: {\n throw new Error(\"Unsupported value type\");\n }\n }\n};\n"],"names":["stringifyForInject","val","JSON","stringify","Error","Array","isArray","map","nestedVal","stringifiedObject","key"],"mappings":";;;AAIa,MAAAA,kBAAA,GAAsBC,GAA0B,IAAA;EAC3D,QAAQ,OAAOA,GAAK;IAClB,KAAK,QAAA;MACI,OAAAC,IAAA,CAAKC,UAAUF,GAAG,CAAA;IAC3B,KAAK,QAAA;IACL,KAAK,SAAA;IACL,KAAK,UAAA;IACL,KAAK,QAAA;IACL,KAAK,WAAA;MACI,OAAAA,GAAA;IACT,KAAK,QAAA;MACG,MAAA,IAAIG,
|
|
1
|
+
{"version":3,"file":"stringifyForInject.js","sources":["../../../src/utils/nextjs/stringifyForInject.ts"],"sourcesContent":["/**\n * Utility to help escape variables for Webpack's DefinePlugin\n * @see https://webpack.js.org/plugins/define-plugin/#:~:text=The%20DefinePlugin%20replaces%20variables%20in,development%20builds%20and%20production%20builds.\n */\nexport const stringifyForInject = (val: unknown): unknown => {\n switch (typeof val) {\n case \"string\":\n return JSON.stringify(val);\n case \"bigint\":\n case \"boolean\":\n case \"function\":\n case \"number\":\n case \"undefined\":\n return val;\n case \"symbol\":\n throw new Error(`Can't inject Symbol`);\n case \"object\": {\n if (Array.isArray(val)) {\n return val.map((nestedVal) => stringifyForInject(nestedVal));\n }\n\n const stringifiedObject: { [key: string]: unknown } = {};\n for (const key in val) {\n // @ts-expect-error Expect to fail as we are working with unknowns\n const nestedVal = val[key];\n stringifiedObject[key] = stringifyForInject(nestedVal);\n }\n return stringifiedObject;\n }\n default: {\n throw new Error(\"Unsupported value type\");\n }\n }\n};\n"],"names":["stringifyForInject","val","JSON","stringify","Error","Array","isArray","map","nestedVal","stringifiedObject","key"],"mappings":";;;AAIa,MAAAA,kBAAA,GAAsBC,GAA0B,IAAA;EAC3D,QAAQ,OAAOA,GAAK;IAClB,KAAK,QAAA;MACI,OAAAC,IAAA,CAAKC,UAAUF,GAAG,CAAA;IAC3B,KAAK,QAAA;IACL,KAAK,SAAA;IACL,KAAK,UAAA;IACL,KAAK,QAAA;IACL,KAAK,WAAA;MACI,OAAAA,GAAA;IACT,KAAK,QAAA;MACG,MAAA,IAAIG,MAA2B,qBAAA,CAAA;IACvC,KAAK,QAAU;MAAA;QACT,IAAAC,KAAA,CAAMC,OAAQ,CAAAL,GAAG,CAAG,EAAA;UACtB,OAAOA,IAAIM,GAAI,CAACC,SAAc,IAAAR,kBAAA,CAAmBQ,SAAS,CAAC,CAAA;QAC7D;QAEA,MAAMC,oBAAgD,CAAA,CAAC;QACvD,KAAA,MAAWC,OAAOT,GAAK,EAAA;UAEf,MAAAO,SAAA,GAAYP,IAAIS,GAAG,CAAA;UACPD,iBAAA,CAAAC,GAAG,CAAI,GAAAV,kBAAA,CAAmBQ,SAAS,CAAA;QACvD;QACO,OAAAC,iBAAA;MACT;IACA;MAAS;QACD,MAAA,IAAIL,MAAM,wBAAwB,CAAA;MAC1C;EACF;AACF,CAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringifyForInject.mjs","sources":["../../../src/utils/nextjs/stringifyForInject.ts"],"sourcesContent":["/**\n * Utility to help escape variables for Webpack's DefinePlugin\n * @see https://webpack.js.org/plugins/define-plugin/#:~:text=The%20DefinePlugin%20replaces%20variables%20in,development%20builds%20and%20production%20builds.\n */\nexport const stringifyForInject = (val: unknown): unknown => {\n switch (typeof val) {\n case \"string\":\n return JSON.stringify(val);\n case \"bigint\":\n case \"boolean\":\n case \"function\":\n case \"number\":\n case \"undefined\":\n return val;\n case \"symbol\":\n throw new Error(`Can't inject Symbol`);\n case \"object\": {\n if (Array.isArray(val)) {\n return val.map((nestedVal) => stringifyForInject(nestedVal));\n }\n\n const stringifiedObject: { [key: string]: unknown } = {};\n for (const key in val) {\n // @ts-expect-error Expect to fail as we are working with unknowns\n const nestedVal = val[key];\n stringifiedObject[key] = stringifyForInject(nestedVal);\n }\n return stringifiedObject;\n }\n default: {\n throw new Error(\"Unsupported value type\");\n }\n }\n};\n"],"names":["stringifyForInject","val","JSON","stringify","Error","Array","isArray","map","nestedVal","stringifiedObject","key"],"mappings":";;AAIa,MAAAA,kBAAA,GAAsBC,GAA0B,IAAA;EAC3D,QAAQ,OAAOA,GAAK;IAClB,KAAK,QAAA;MACI,OAAAC,IAAA,CAAKC,UAAUF,GAAG,CAAA;IAC3B,KAAK,QAAA;IACL,KAAK,SAAA;IACL,KAAK,UAAA;IACL,KAAK,QAAA;IACL,KAAK,WAAA;MACI,OAAAA,GAAA;IACT,KAAK,QAAA;MACG,MAAA,IAAIG,
|
|
1
|
+
{"version":3,"file":"stringifyForInject.mjs","sources":["../../../src/utils/nextjs/stringifyForInject.ts"],"sourcesContent":["/**\n * Utility to help escape variables for Webpack's DefinePlugin\n * @see https://webpack.js.org/plugins/define-plugin/#:~:text=The%20DefinePlugin%20replaces%20variables%20in,development%20builds%20and%20production%20builds.\n */\nexport const stringifyForInject = (val: unknown): unknown => {\n switch (typeof val) {\n case \"string\":\n return JSON.stringify(val);\n case \"bigint\":\n case \"boolean\":\n case \"function\":\n case \"number\":\n case \"undefined\":\n return val;\n case \"symbol\":\n throw new Error(`Can't inject Symbol`);\n case \"object\": {\n if (Array.isArray(val)) {\n return val.map((nestedVal) => stringifyForInject(nestedVal));\n }\n\n const stringifiedObject: { [key: string]: unknown } = {};\n for (const key in val) {\n // @ts-expect-error Expect to fail as we are working with unknowns\n const nestedVal = val[key];\n stringifiedObject[key] = stringifyForInject(nestedVal);\n }\n return stringifiedObject;\n }\n default: {\n throw new Error(\"Unsupported value type\");\n }\n }\n};\n"],"names":["stringifyForInject","val","JSON","stringify","Error","Array","isArray","map","nestedVal","stringifiedObject","key"],"mappings":";;AAIa,MAAAA,kBAAA,GAAsBC,GAA0B,IAAA;EAC3D,QAAQ,OAAOA,GAAK;IAClB,KAAK,QAAA;MACI,OAAAC,IAAA,CAAKC,UAAUF,GAAG,CAAA;IAC3B,KAAK,QAAA;IACL,KAAK,SAAA;IACL,KAAK,UAAA;IACL,KAAK,QAAA;IACL,KAAK,WAAA;MACI,OAAAA,GAAA;IACT,KAAK,QAAA;MACG,MAAA,IAAIG,MAA2B,qBAAA,CAAA;IACvC,KAAK,QAAU;MAAA;QACT,IAAAC,KAAA,CAAMC,OAAQ,CAAAL,GAAG,CAAG,EAAA;UACtB,OAAOA,IAAIM,GAAI,CAACC,SAAc,IAAAR,kBAAA,CAAmBQ,SAAS,CAAC,CAAA;QAC7D;QAEA,MAAMC,oBAAgD,CAAA,CAAC;QACvD,KAAA,MAAWC,OAAOT,GAAK,EAAA;UAEf,MAAAO,SAAA,GAAYP,IAAIS,GAAG,CAAA;UACPD,iBAAA,CAAAC,GAAG,CAAI,GAAAV,kBAAA,CAAmBQ,SAAS,CAAA;QACvD;QACO,OAAAC,iBAAA;MACT;IACA;MAAS;QACD,MAAA,IAAIL,MAAM,wBAAwB,CAAA;MAC1C;EACF;AACF,CAAA;"}
|
package/lib/utils/number.js.map
CHANGED
|
@@ -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;EACzB,IAAI,OAAOH,KAAU,KAAA,QAAA,IAAYI,MAAO,CAAAC,KAAA,CAAML,KAAK,CAAG,EAAA;IACpD,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,qBAAqBD,
|
|
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;EACzB,IAAI,OAAOH,KAAU,KAAA,QAAA,IAAYI,MAAO,CAAAC,KAAA,CAAML,KAAK,CAAG,EAAA;IACpD,MAAM,IAAIE,UAAW,CAAA,GAAGD,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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;;;;;;;;;;"}
|
package/lib/utils/number.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 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,
|
|
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 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","to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Ac,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brazil.js","sources":["../../../src/utils/tax/brazil.ts"],"sourcesContent":["// #############################################################################\n// Taken from https://gist.github.com/alisterlf/4e7a0e4c0208659ea48909dc6bad14ed#file-cpf-cnpj-utils-ts\n// The logic hasn't been changed, only converted from class into regular functions.\n// #############################################################################\n\nimport type { CountryTaxIdValidationFn } from \"./types\";\n\nexport const isCpfValid: CountryTaxIdValidationFn = ({ taxId: cpf }) => {\n const cpfLength = 11;\n return isValid(cpf, cpfLength);\n};\n\nexport const isCnpjValid: CountryTaxIdValidationFn = ({ taxId: cnpj }) => {\n const cpfLength = 14;\n return isValid(cnpj, cpfLength);\n};\n\nexport const formatCpf = (cpf: string): string => {\n const correctDigitsLength = 11;\n const firstDotPosition = 2;\n const secondDotPosition = 5;\n const slashPosition = -1;\n const dashPosition = 8;\n return format(\n cpf,\n correctDigitsLength,\n firstDotPosition,\n secondDotPosition,\n slashPosition,\n dashPosition,\n );\n};\n\nexport const formatCnpj = (cnpj: string): string => {\n const correctDigitsLength = 14;\n const firstDotPosition = 1;\n const secondDotPosition = 4;\n const slashPosition = 7;\n const dashPosition = 11;\n return format(\n cnpj,\n correctDigitsLength,\n firstDotPosition,\n secondDotPosition,\n slashPosition,\n dashPosition,\n );\n};\n\nfunction format(\n digits: string,\n correctDigitsLength: number,\n firstDotPosition: number,\n secondDotPosition: number,\n slashPosition: number,\n dashPosition: number,\n): string {\n const cleanDigits = getOnlyNumbers(digits);\n return cleanDigits\n .slice(0, correctDigitsLength)\n .split(\"\")\n .reduce((acc, digit, idx) => {\n let result = `${acc}${digit}`;\n if (idx !== digits.length - 1) {\n if (idx === firstDotPosition || idx === secondDotPosition) {\n result += \".\";\n }\n if (idx === slashPosition) {\n result += \"/\";\n }\n if (idx === dashPosition) {\n result += \"-\";\n }\n }\n return result;\n }, \"\");\n}\n\nfunction isValid(digits: string, correctDigitsLength: number): boolean {\n const cleanDigits = getOnlyNumbers(digits);\n if (\n cleanDigits.length !== correctDigitsLength ||\n isAllTheSameDigits(cleanDigits)\n ) {\n return false;\n }\n const digitsWithoutChecker = cleanDigits.substring(\n 0,\n correctDigitsLength - 2,\n );\n const digitsChecker = cleanDigits.substring(\n correctDigitsLength - 2,\n correctDigitsLength,\n );\n const calculatedChecker = calcChecker(digitsWithoutChecker);\n return digitsChecker === calculatedChecker;\n}\n\nfunction getOnlyNumbers(digits: string): string {\n return digits.replace(/\\D/g, \"\");\n}\n\nfunction isAllTheSameDigits(digits: string): boolean {\n return !digits.split(\"\").some((digit) => digit !== digits[0]);\n}\n\nfunction calcChecker(digits: string): string {\n const digitsLength = digits.length;\n const digitsLengthWithoutChecker = digitsLength < 11 ? 9 : 12;\n const weight = digitsLength < 11 ? digitsLength + 1 : digitsLength - 7;\n\n const sum = digits.split(\"\").reduce((acc, digit, idx) => {\n const offsetValue = weight - idx >= 2 ? 0 : 8;\n return acc + +digit * (weight + offsetValue - idx);\n }, 0);\n\n const sumDivisionRemainder = sum % 11;\n const checker = sumDivisionRemainder < 2 ? 0 : 11 - sumDivisionRemainder;\n\n if (digitsLength === digitsLengthWithoutChecker) {\n return calcChecker(`${digits}${checker}`);\n }\n\n return `${digits[digitsLength - 1]}${checker}`;\n}\n"],"names":["isCpfValid","taxId","cpf","cpfLength","isValid","isCnpjValid","cnpj","formatCpf","correctDigitsLength","firstDotPosition","secondDotPosition","slashPosition","dashPosition","format","formatCnpj","digits","cleanDigits","getOnlyNumbers","slice","split","reduce","acc","digit","idx","result","length","isAllTheSameDigits","digitsWithoutChecker","substring","digitsChecker","calculatedChecker","calcChecker","replace","some","digitsLength","digitsLengthWithoutChecker","weight","sum","offsetValue","sumDivisionRemainder","checker"],"mappings":";;;AAOO,MAAMA,UAAuC,GAAAA,CAAC;EAAEC,KAAA,EAAOC;CAAU,KAAA;EACtE,MAAMC,SAAY,GAAA,EAAA;EACX,OAAAC,OAAA,CAAQF,KAAKC,SAAS,CAAA;AAC/B,CAAA;AAEO,MAAME,WAAwC,GAAAA,CAAC;EAAEJ,KAAA,EAAOK;CAAW,KAAA;EACxE,MAAMH,SAAY,GAAA,EAAA;EACX,OAAAC,OAAA,CAAQE,MAAMH,SAAS,CAAA;AAChC,CAAA;AAEa,MAAAI,SAAA,GAAaL,GAAwB,IAAA;EAChD,MAAMM,mBAAsB,GAAA,EAAA;EAC5B,MAAMC,gBAAmB,GAAA,CAAA;EACzB,MAAMC,iBAAoB,GAAA,CAAA;EAC1B,MAAMC,aAAgB,GAAA,CAAA,CAAA;EACtB,MAAMC,YAAe,GAAA,CAAA;EACd,OAAAC,MAAA,CACLX,GAAA,EACAM,mBAAA,EACAC,gBAAA,EACAC,iBAAA,EACAC,aAAA,EACAC,YAAA,CACF;AACF,CAAA;AAEa,MAAAE,UAAA,GAAcR,IAAyB,IAAA;EAClD,MAAME,mBAAsB,GAAA,EAAA;EAC5B,MAAMC,gBAAmB,GAAA,CAAA;EACzB,MAAMC,iBAAoB,GAAA,CAAA;EAC1B,MAAMC,aAAgB,GAAA,CAAA;EACtB,MAAMC,YAAe,GAAA,EAAA;EACd,OAAAC,MAAA,CACLP,IAAA,EACAE,mBAAA,EACAC,gBAAA,EACAC,iBAAA,EACAC,aAAA,EACAC,YAA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MAAA,CAAOiB,OAAQ,CAAA,KAAA,EAAO,EAAE,CAAA;AACjC;AAEA,SAASN,mBAAmBX,MAAyB,EAAA;EAC5C,OAAA,CAACA,MAAO,CAAAI,KAAA,CAAM,EAAE,CAAA,CAAEc,IAAK,CAACX,KAAU,IAAAA,KAAA,KAAUP,MAAO,CAAA,CAAC,CAAC,CAAA;AAC9D;AAEA,SAASgB,YAAYhB,MAAwB,EAAA;EAC3C,MAAMmB,eAAenB,MAAO,CAAAU,MAAA;EACtB,MAAAU,0BAAA,GAA6BD,YAAe,GAAA,EAAA,GAAK,CAAI,GAAA,EAAA;EAC3D,MAAME,MAAS,GAAAF,YAAA,GAAe,EAAK,GAAAA,YAAA,GAAe,IAAIA,YAAe,GAAA,CAAA;EAE/D,MAAAG,GAAA,GAAMtB,OAAOI,KAAM,CAAA,EAAE,EAAEC,MAAO,CAAA,CAACC,GAAK,EAAAC,KAAA,EAAOC,GAAQ,KAAA;IACvD,MAAMe,WAAc,GAAAF,MAAA,GAASb,GAAO,IAAA,CAAA,GAAI,CAAI,GAAA,CAAA;IAC5C,OAAOF,GAAM,GAAA,CAACC,KAAS,IAAAc,MAAA,GAASE,WAAc,GAAAf,GAAA,CAAA;KAC7C,CAAC,CAAA;EAEJ,MAAMgB,uBAAuBF,GAAM,GAAA,EAAA;EACnC,MAAMG,OAAU,GAAAD,oBAAA,GAAuB,CAAI,GAAA,CAAA,GAAI,EAAK,GAAAA,oBAAA;EAEpD,IAAIL,iBAAiBC,0BAA4B,EAAA;IAC/C,OAAOJ,WAAY,CAAA,GAAGhB,MAAM,GAAGyB,
|
|
1
|
+
{"version":3,"file":"brazil.js","sources":["../../../src/utils/tax/brazil.ts"],"sourcesContent":["// #############################################################################\n// Taken from https://gist.github.com/alisterlf/4e7a0e4c0208659ea48909dc6bad14ed#file-cpf-cnpj-utils-ts\n// The logic hasn't been changed, only converted from class into regular functions.\n// #############################################################################\n\nimport type { CountryTaxIdValidationFn } from \"./types\";\n\nexport const isCpfValid: CountryTaxIdValidationFn = ({ taxId: cpf }) => {\n const cpfLength = 11;\n return isValid(cpf, cpfLength);\n};\n\nexport const isCnpjValid: CountryTaxIdValidationFn = ({ taxId: cnpj }) => {\n const cpfLength = 14;\n return isValid(cnpj, cpfLength);\n};\n\nexport const formatCpf = (cpf: string): string => {\n const correctDigitsLength = 11;\n const firstDotPosition = 2;\n const secondDotPosition = 5;\n const slashPosition = -1;\n const dashPosition = 8;\n return format(\n cpf,\n correctDigitsLength,\n firstDotPosition,\n secondDotPosition,\n slashPosition,\n dashPosition,\n );\n};\n\nexport const formatCnpj = (cnpj: string): string => {\n const correctDigitsLength = 14;\n const firstDotPosition = 1;\n const secondDotPosition = 4;\n const slashPosition = 7;\n const dashPosition = 11;\n return format(\n cnpj,\n correctDigitsLength,\n firstDotPosition,\n secondDotPosition,\n slashPosition,\n dashPosition,\n );\n};\n\nfunction format(\n digits: string,\n correctDigitsLength: number,\n firstDotPosition: number,\n secondDotPosition: number,\n slashPosition: number,\n dashPosition: number,\n): string {\n const cleanDigits = getOnlyNumbers(digits);\n return cleanDigits\n .slice(0, correctDigitsLength)\n .split(\"\")\n .reduce((acc, digit, idx) => {\n let result = `${acc}${digit}`;\n if (idx !== digits.length - 1) {\n if (idx === firstDotPosition || idx === secondDotPosition) {\n result += \".\";\n }\n if (idx === slashPosition) {\n result += \"/\";\n }\n if (idx === dashPosition) {\n result += \"-\";\n }\n }\n return result;\n }, \"\");\n}\n\nfunction isValid(digits: string, correctDigitsLength: number): boolean {\n const cleanDigits = getOnlyNumbers(digits);\n if (\n cleanDigits.length !== correctDigitsLength ||\n isAllTheSameDigits(cleanDigits)\n ) {\n return false;\n }\n const digitsWithoutChecker = cleanDigits.substring(\n 0,\n correctDigitsLength - 2,\n );\n const digitsChecker = cleanDigits.substring(\n correctDigitsLength - 2,\n correctDigitsLength,\n );\n const calculatedChecker = calcChecker(digitsWithoutChecker);\n return digitsChecker === calculatedChecker;\n}\n\nfunction getOnlyNumbers(digits: string): string {\n return digits.replace(/\\D/g, \"\");\n}\n\nfunction isAllTheSameDigits(digits: string): boolean {\n return !digits.split(\"\").some((digit) => digit !== digits[0]);\n}\n\nfunction calcChecker(digits: string): string {\n const digitsLength = digits.length;\n const digitsLengthWithoutChecker = digitsLength < 11 ? 9 : 12;\n const weight = digitsLength < 11 ? digitsLength + 1 : digitsLength - 7;\n\n const sum = digits.split(\"\").reduce((acc, digit, idx) => {\n const offsetValue = weight - idx >= 2 ? 0 : 8;\n return acc + +digit * (weight + offsetValue - idx);\n }, 0);\n\n const sumDivisionRemainder = sum % 11;\n const checker = sumDivisionRemainder < 2 ? 0 : 11 - sumDivisionRemainder;\n\n if (digitsLength === digitsLengthWithoutChecker) {\n return calcChecker(`${digits}${checker}`);\n }\n\n return `${digits[digitsLength - 1]}${checker}`;\n}\n"],"names":["isCpfValid","taxId","cpf","cpfLength","isValid","isCnpjValid","cnpj","formatCpf","correctDigitsLength","firstDotPosition","secondDotPosition","slashPosition","dashPosition","format","formatCnpj","digits","cleanDigits","getOnlyNumbers","slice","split","reduce","acc","digit","idx","result","length","isAllTheSameDigits","digitsWithoutChecker","substring","digitsChecker","calculatedChecker","calcChecker","replace","some","digitsLength","digitsLengthWithoutChecker","weight","sum","offsetValue","sumDivisionRemainder","checker"],"mappings":";;;AAOO,MAAMA,UAAuC,GAAAA,CAAC;EAAEC,KAAA,EAAOC;CAAU,KAAA;EACtE,MAAMC,SAAY,GAAA,EAAA;EACX,OAAAC,OAAA,CAAQF,KAAKC,SAAS,CAAA;AAC/B,CAAA;AAEO,MAAME,WAAwC,GAAAA,CAAC;EAAEJ,KAAA,EAAOK;CAAW,KAAA;EACxE,MAAMH,SAAY,GAAA,EAAA;EACX,OAAAC,OAAA,CAAQE,MAAMH,SAAS,CAAA;AAChC,CAAA;AAEa,MAAAI,SAAA,GAAaL,GAAwB,IAAA;EAChD,MAAMM,mBAAsB,GAAA,EAAA;EAC5B,MAAMC,gBAAmB,GAAA,CAAA;EACzB,MAAM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,GAAAf,GAAA,CAAA;KAC7C,CAAC,CAAA;EAEJ,MAAMgB,uBAAuBF,GAAM,GAAA,EAAA;EACnC,MAAMG,OAAU,GAAAD,oBAAA,GAAuB,CAAI,GAAA,CAAA,GAAI,EAAK,GAAAA,oBAAA;EAEpD,IAAIL,iBAAiBC,0BAA4B,EAAA;IAC/C,OAAOJ,WAAY,CAAA,GAAGhB,MAAM,GAAGyB,OAAS,EAAA,CAAA;EAC1C;EAEA,UAAUzB,MAAO,CAAAmB,YAAA,GAAe,CAAC,IAAIM,OAAO,EAAA;AAC9C;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brazil.mjs","sources":["../../../src/utils/tax/brazil.ts"],"sourcesContent":["// #############################################################################\n// Taken from https://gist.github.com/alisterlf/4e7a0e4c0208659ea48909dc6bad14ed#file-cpf-cnpj-utils-ts\n// The logic hasn't been changed, only converted from class into regular functions.\n// #############################################################################\n\nimport type { CountryTaxIdValidationFn } from \"./types\";\n\nexport const isCpfValid: CountryTaxIdValidationFn = ({ taxId: cpf }) => {\n const cpfLength = 11;\n return isValid(cpf, cpfLength);\n};\n\nexport const isCnpjValid: CountryTaxIdValidationFn = ({ taxId: cnpj }) => {\n const cpfLength = 14;\n return isValid(cnpj, cpfLength);\n};\n\nexport const formatCpf = (cpf: string): string => {\n const correctDigitsLength = 11;\n const firstDotPosition = 2;\n const secondDotPosition = 5;\n const slashPosition = -1;\n const dashPosition = 8;\n return format(\n cpf,\n correctDigitsLength,\n firstDotPosition,\n secondDotPosition,\n slashPosition,\n dashPosition,\n );\n};\n\nexport const formatCnpj = (cnpj: string): string => {\n const correctDigitsLength = 14;\n const firstDotPosition = 1;\n const secondDotPosition = 4;\n const slashPosition = 7;\n const dashPosition = 11;\n return format(\n cnpj,\n correctDigitsLength,\n firstDotPosition,\n secondDotPosition,\n slashPosition,\n dashPosition,\n );\n};\n\nfunction format(\n digits: string,\n correctDigitsLength: number,\n firstDotPosition: number,\n secondDotPosition: number,\n slashPosition: number,\n dashPosition: number,\n): string {\n const cleanDigits = getOnlyNumbers(digits);\n return cleanDigits\n .slice(0, correctDigitsLength)\n .split(\"\")\n .reduce((acc, digit, idx) => {\n let result = `${acc}${digit}`;\n if (idx !== digits.length - 1) {\n if (idx === firstDotPosition || idx === secondDotPosition) {\n result += \".\";\n }\n if (idx === slashPosition) {\n result += \"/\";\n }\n if (idx === dashPosition) {\n result += \"-\";\n }\n }\n return result;\n }, \"\");\n}\n\nfunction isValid(digits: string, correctDigitsLength: number): boolean {\n const cleanDigits = getOnlyNumbers(digits);\n if (\n cleanDigits.length !== correctDigitsLength ||\n isAllTheSameDigits(cleanDigits)\n ) {\n return false;\n }\n const digitsWithoutChecker = cleanDigits.substring(\n 0,\n correctDigitsLength - 2,\n );\n const digitsChecker = cleanDigits.substring(\n correctDigitsLength - 2,\n correctDigitsLength,\n );\n const calculatedChecker = calcChecker(digitsWithoutChecker);\n return digitsChecker === calculatedChecker;\n}\n\nfunction getOnlyNumbers(digits: string): string {\n return digits.replace(/\\D/g, \"\");\n}\n\nfunction isAllTheSameDigits(digits: string): boolean {\n return !digits.split(\"\").some((digit) => digit !== digits[0]);\n}\n\nfunction calcChecker(digits: string): string {\n const digitsLength = digits.length;\n const digitsLengthWithoutChecker = digitsLength < 11 ? 9 : 12;\n const weight = digitsLength < 11 ? digitsLength + 1 : digitsLength - 7;\n\n const sum = digits.split(\"\").reduce((acc, digit, idx) => {\n const offsetValue = weight - idx >= 2 ? 0 : 8;\n return acc + +digit * (weight + offsetValue - idx);\n }, 0);\n\n const sumDivisionRemainder = sum % 11;\n const checker = sumDivisionRemainder < 2 ? 0 : 11 - sumDivisionRemainder;\n\n if (digitsLength === digitsLengthWithoutChecker) {\n return calcChecker(`${digits}${checker}`);\n }\n\n return `${digits[digitsLength - 1]}${checker}`;\n}\n"],"names":["isCpfValid","taxId","cpf","cpfLength","isValid","isCnpjValid","cnpj","formatCpf","correctDigitsLength","firstDotPosition","secondDotPosition","slashPosition","dashPosition","format","formatCnpj","digits","cleanDigits","getOnlyNumbers","slice","split","reduce","acc","digit","idx","result","length","isAllTheSameDigits","digitsWithoutChecker","substring","digitsChecker","calculatedChecker","calcChecker","replace","some","digitsLength","digitsLengthWithoutChecker","weight","sum","offsetValue","sumDivisionRemainder","checker"],"mappings":";;AAOO,MAAMA,UAAuC,GAAAA,CAAC;EAAEC,KAAA,EAAOC;CAAU,KAAA;EACtE,MAAMC,SAAY,GAAA,EAAA;EACX,OAAAC,OAAA,CAAQF,KAAKC,SAAS,CAAA;AAC/B,CAAA;AAEO,MAAME,WAAwC,GAAAA,CAAC;EAAEJ,KAAA,EAAOK;CAAW,KAAA;EACxE,MAAMH,SAAY,GAAA,EAAA;EACX,OAAAC,OAAA,CAAQE,MAAMH,SAAS,CAAA;AAChC,CAAA;AAEa,MAAAI,SAAA,GAAaL,GAAwB,IAAA;EAChD,MAAMM,mBAAsB,GAAA,EAAA;EAC5B,MAAMC,gBAAmB,GAAA,CAAA;EACzB,MAAMC,iBAAoB,GAAA,CAAA;EAC1B,MAAMC,aAAgB,GAAA,CAAA,CAAA;EACtB,MAAMC,YAAe,GAAA,CAAA;EACd,OAAAC,MAAA,CACLX,GAAA,EACAM,mBAAA,EACAC,gBAAA,EACAC,iBAAA,EACAC,aAAA,EACAC,YAAA,CACF;AACF,CAAA;AAEa,MAAAE,UAAA,GAAcR,IAAyB,IAAA;EAClD,MAAME,mBAAsB,GAAA,EAAA;EAC5B,MAAMC,gBAAmB,GAAA,CAAA;EACzB,MAAMC,iBAAoB,GAAA,CAAA;EAC1B,MAAMC,aAAgB,GAAA,CAAA;EACtB,MAAMC,YAAe,GAAA,EAAA;EACd,OAAAC,MAAA,CACLP,IAAA,EACAE,mBAAA,EACAC,gBAAA,EACAC,iBAAA,EACAC,aAAA,EACAC,YAAA,CACF;AACF,CAAA;AAEA,SAASC,OACPE,MACA,EAAAP,mBAAA,EACAC,gBACA,EAAAC,iBAAA,EACAC,eACAC,YACQ,EAA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A,CAACA,MAAO,CAAAI,KAAA,CAAM,EAAE,CAAA,CAAEc,IAAK,CAACX,KAAU,IAAAA,KAAA,KAAUP,MAAO,CAAA,CAAC,CAAC,CAAA;AAC9D;AAEA,SAASgB,YAAYhB,MAAwB,EAAA;EAC3C,MAAMmB,eAAenB,MAAO,CAAAU,MAAA;EACtB,MAAAU,0BAAA,GAA6BD,YAAe,GAAA,EAAA,GAAK,CAAI,GAAA,EAAA;EAC3D,MAAME,MAAS,GAAAF,YAAA,GAAe,EAAK,GAAAA,YAAA,GAAe,IAAIA,YAAe,GAAA,CAAA;EAE/D,MAAAG,GAAA,GAAMtB,OAAOI,KAAM,CAAA,EAAE,EAAEC,MAAO,CAAA,CAACC,GAAK,EAAAC,KAAA,EAAOC,GAAQ,KAAA;IACvD,MAAMe,WAAc,GAAAF,MAAA,GAASb,GAAO,IAAA,CAAA,GAAI,CAAI,GAAA,CAAA;IAC5C,OAAOF,GAAM,GAAA,CAACC,KAAS,IAAAc,MAAA,GAASE,WAAc,GAAAf,GAAA,CAAA;KAC7C,CAAC,CAAA;EAEJ,MAAMgB,uBAAuBF,GAAM,GAAA,EAAA;EACnC,MAAMG,OAAU,GAAAD,oBAAA,GAAuB,CAAI,GAAA,CAAA,GAAI,EAAK,GAAAA,oBAAA;EAEpD,IAAIL,iBAAiBC,0BAA4B,EAAA;IAC/C,OAAOJ,WAAY,CAAA,GAAGhB,MAAM,GAAGyB,
|
|
1
|
+
{"version":3,"file":"brazil.mjs","sources":["../../../src/utils/tax/brazil.ts"],"sourcesContent":["// #############################################################################\n// Taken from https://gist.github.com/alisterlf/4e7a0e4c0208659ea48909dc6bad14ed#file-cpf-cnpj-utils-ts\n// The logic hasn't been changed, only converted from class into regular functions.\n// #############################################################################\n\nimport type { CountryTaxIdValidationFn } from \"./types\";\n\nexport const isCpfValid: CountryTaxIdValidationFn = ({ taxId: cpf }) => {\n const cpfLength = 11;\n return isValid(cpf, cpfLength);\n};\n\nexport const isCnpjValid: CountryTaxIdValidationFn = ({ taxId: cnpj }) => {\n const cpfLength = 14;\n return isValid(cnpj, cpfLength);\n};\n\nexport const formatCpf = (cpf: string): string => {\n const correctDigitsLength = 11;\n const firstDotPosition = 2;\n const secondDotPosition = 5;\n const slashPosition = -1;\n const dashPosition = 8;\n return format(\n cpf,\n correctDigitsLength,\n firstDotPosition,\n secondDotPosition,\n slashPosition,\n dashPosition,\n );\n};\n\nexport const formatCnpj = (cnpj: string): string => {\n const correctDigitsLength = 14;\n const firstDotPosition = 1;\n const secondDotPosition = 4;\n const slashPosition = 7;\n const dashPosition = 11;\n return format(\n cnpj,\n correctDigitsLength,\n firstDotPosition,\n secondDotPosition,\n slashPosition,\n dashPosition,\n );\n};\n\nfunction format(\n digits: string,\n correctDigitsLength: number,\n firstDotPosition: number,\n secondDotPosition: number,\n slashPosition: number,\n dashPosition: number,\n): string {\n const cleanDigits = getOnlyNumbers(digits);\n return cleanDigits\n .slice(0, correctDigitsLength)\n .split(\"\")\n .reduce((acc, digit, idx) => {\n let result = `${acc}${digit}`;\n if (idx !== digits.length - 1) {\n if (idx === firstDotPosition || idx === secondDotPosition) {\n result += \".\";\n }\n if (idx === slashPosition) {\n result += \"/\";\n }\n if (idx === dashPosition) {\n result += \"-\";\n }\n }\n return result;\n }, \"\");\n}\n\nfunction isValid(digits: string, correctDigitsLength: number): boolean {\n const cleanDigits = getOnlyNumbers(digits);\n if (\n cleanDigits.length !== correctDigitsLength ||\n isAllTheSameDigits(cleanDigits)\n ) {\n return false;\n }\n const digitsWithoutChecker = cleanDigits.substring(\n 0,\n correctDigitsLength - 2,\n );\n const digitsChecker = cleanDigits.substring(\n correctDigitsLength - 2,\n correctDigitsLength,\n );\n const calculatedChecker = calcChecker(digitsWithoutChecker);\n return digitsChecker === calculatedChecker;\n}\n\nfunction getOnlyNumbers(digits: string): string {\n return digits.replace(/\\D/g, \"\");\n}\n\nfunction isAllTheSameDigits(digits: string): boolean {\n return !digits.split(\"\").some((digit) => digit !== digits[0]);\n}\n\nfunction calcChecker(digits: string): string {\n const digitsLength = digits.length;\n const digitsLengthWithoutChecker = digitsLength < 11 ? 9 : 12;\n const weight = digitsLength < 11 ? digitsLength + 1 : digitsLength - 7;\n\n const sum = digits.split(\"\").reduce((acc, digit, idx) => {\n const offsetValue = weight - idx >= 2 ? 0 : 8;\n return acc + +digit * (weight + offsetValue - idx);\n }, 0);\n\n const sumDivisionRemainder = sum % 11;\n const checker = sumDivisionRemainder < 2 ? 0 : 11 - sumDivisionRemainder;\n\n if (digitsLength === digitsLengthWithoutChecker) {\n return calcChecker(`${digits}${checker}`);\n }\n\n return `${digits[digitsLength - 1]}${checker}`;\n}\n"],"names":["isCpfValid","taxId","cpf","cpfLength","isValid","isCnpjValid","cnpj","formatCpf","correctDigitsLength","firstDotPosition","secondDotPosition","slashPosition","dashPosition","format","formatCnpj","digits","cleanDigits","getOnlyNumbers","slice","split","reduce","acc","digit","idx","result","length","isAllTheSameDigits","digitsWithoutChecker","substring","digitsChecker","calculatedChecker","calcChecker","replace","some","digitsLength","digitsLengthWithoutChecker","weight","sum","offsetValue","sumDivisionRemainder","checker"],"mappings":";;AAOO,MAAMA,UAAuC,GAAAA,CAAC;EAAEC,KAAA,EAAOC;CAAU,KAAA;EACtE,MAAMC,SAAY,GAAA,EAAA;EACX,OAAAC,OAAA,CAAQF,KAAKC,SAAS,CAAA;AAC/B,CAAA;AAEO,MAAME,WAAwC,GAAAA,CAAC;EAAEJ,KAAA,EAAOK;CAAW,KAAA;EACxE,MAAMH,SAAY,GAAA,EAAA;EACX,OAAAC,OAAA,CAAQE,MAAMH,SAAS,CAAA;AAChC,CAAA;AAEa,MAAAI,SAAA,GAAaL,GAAwB,IAAA;EAChD,MAAMM,mBAAsB,GAAA,EAAA;EAC5B,MAAMC,gBAAmB,GAAA,CAAA;EACzB,MAAMC,iBAAoB,GAAA,CAAA;EAC1B,MAAMC,aAAgB,GAAA,CAAA,CAAA;EACtB,MAAMC,YAAe,GAAA,CAAA;EACd,OAA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GAAAD,oBAAA,GAAuB,CAAI,GAAA,CAAA,GAAI,EAAK,GAAAA,oBAAA;EAEpD,IAAIL,iBAAiBC,0BAA4B,EAAA;IAC/C,OAAOJ,WAAY,CAAA,GAAGhB,MAAM,GAAGyB,OAAS,EAAA,CAAA;EAC1C;EAEA,UAAUzB,MAAO,CAAAmB,YAAA,GAAe,CAAC,IAAIM,OAAO,EAAA;AAC9C;"}
|
package/lib/utils/wattage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wattage.js","sources":["../../src/utils/wattage.ts"],"sourcesContent":["// #############################################################################\n// PoE Wattage Tags\n// #############################################################################\n\nconst POE_WATTAGE_REGEX = /poe:(\\d+)w/i;\n\n/**\n * Get the PoE wattage from a tag\n * @example \"poe:100w\" => \"100W\"\n */\nexport const getPoeWattageFromTag = (tagName: string | undefined) => {\n // If there is no wattage tag, return undefined\n if (!tagName) return undefined;\n\n // Get the wattage from the tag\n const wattage = POE_WATTAGE_REGEX.exec(tagName)?.[1];\n\n // If there is no wattage, return undefined\n if (!wattage?.length) return undefined;\n\n // Return the wattage\n return `${wattage}W`;\n};\n\n/**\n * Finds first PoE wattage tag and returns the wattage\n */\nexport const getPoeWattageFromTags = (\n tags: { name: string }[],\n): string | undefined => {\n for (const tag of tags) {\n const watts = getPoeWattageFromTag(tag.name);\n\n if (watts) return watts;\n }\n\n return undefined;\n};\n"],"names":["POE_WATTAGE_REGEX","getPoeWattageFromTag","tagName","wattage","exec","length","getPoeWattageFromTags","tags","tag","watts","name"],"mappings":";;;AAIA,MAAMA,iBAAoB,GAAA,aAAA;AAMb,MAAAC,oBAAA,GAAwBC,OAAgC,IAAA;EAE/D,IAAA,CAACA,SAAgB,OAAA,KAAA,CAAA;EAGrB,MAAMC,OAAU,GAAAH,iBAAA,CAAkBI,IAAK,CAAAF,OAAO,IAAI,CAAC,CAAA;EAG/C,IAAA,CAACC,OAAS,EAAAE,MAAA,EAAe,OAAA,KAAA,CAAA;EAG7B,
|
|
1
|
+
{"version":3,"file":"wattage.js","sources":["../../src/utils/wattage.ts"],"sourcesContent":["// #############################################################################\n// PoE Wattage Tags\n// #############################################################################\n\nconst POE_WATTAGE_REGEX = /poe:(\\d+)w/i;\n\n/**\n * Get the PoE wattage from a tag\n * @example \"poe:100w\" => \"100W\"\n */\nexport const getPoeWattageFromTag = (tagName: string | undefined) => {\n // If there is no wattage tag, return undefined\n if (!tagName) return undefined;\n\n // Get the wattage from the tag\n const wattage = POE_WATTAGE_REGEX.exec(tagName)?.[1];\n\n // If there is no wattage, return undefined\n if (!wattage?.length) return undefined;\n\n // Return the wattage\n return `${wattage}W`;\n};\n\n/**\n * Finds first PoE wattage tag and returns the wattage\n */\nexport const getPoeWattageFromTags = (\n tags: { name: string }[],\n): string | undefined => {\n for (const tag of tags) {\n const watts = getPoeWattageFromTag(tag.name);\n\n if (watts) return watts;\n }\n\n return undefined;\n};\n"],"names":["POE_WATTAGE_REGEX","getPoeWattageFromTag","tagName","wattage","exec","length","getPoeWattageFromTags","tags","tag","watts","name"],"mappings":";;;AAIA,MAAMA,iBAAoB,GAAA,aAAA;AAMb,MAAAC,oBAAA,GAAwBC,OAAgC,IAAA;EAE/D,IAAA,CAACA,SAAgB,OAAA,KAAA,CAAA;EAGrB,MAAMC,OAAU,GAAAH,iBAAA,CAAkBI,IAAK,CAAAF,OAAO,IAAI,CAAC,CAAA;EAG/C,IAAA,CAACC,OAAS,EAAAE,MAAA,EAAe,OAAA,KAAA,CAAA;EAG7B,UAAUF,OAAO,GAAA;AACnB,CAAA;AAKa,MAAAG,qBAAA,GACXC,IACuB,IAAA;EACvB,KAAA,MAAWC,OAAOD,IAAM,EAAA;IAChB,MAAAE,KAAA,GAAQR,oBAAqB,CAAAO,GAAA,CAAIE,IAAI,CAAA;IAE3C,IAAID,OAAc,OAAAA,KAAA;EACpB;EAEO,OAAA,KAAA,CAAA;AACT,CAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wattage.mjs","sources":["../../src/utils/wattage.ts"],"sourcesContent":["// #############################################################################\n// PoE Wattage Tags\n// #############################################################################\n\nconst POE_WATTAGE_REGEX = /poe:(\\d+)w/i;\n\n/**\n * Get the PoE wattage from a tag\n * @example \"poe:100w\" => \"100W\"\n */\nexport const getPoeWattageFromTag = (tagName: string | undefined) => {\n // If there is no wattage tag, return undefined\n if (!tagName) return undefined;\n\n // Get the wattage from the tag\n const wattage = POE_WATTAGE_REGEX.exec(tagName)?.[1];\n\n // If there is no wattage, return undefined\n if (!wattage?.length) return undefined;\n\n // Return the wattage\n return `${wattage}W`;\n};\n\n/**\n * Finds first PoE wattage tag and returns the wattage\n */\nexport const getPoeWattageFromTags = (\n tags: { name: string }[],\n): string | undefined => {\n for (const tag of tags) {\n const watts = getPoeWattageFromTag(tag.name);\n\n if (watts) return watts;\n }\n\n return undefined;\n};\n"],"names":["POE_WATTAGE_REGEX","getPoeWattageFromTag","tagName","wattage","exec","length","getPoeWattageFromTags","tags","tag","watts","name"],"mappings":";;AAIA,MAAMA,iBAAoB,GAAA,aAAA;AAMb,MAAAC,oBAAA,GAAwBC,OAAgC,IAAA;EAE/D,IAAA,CAACA,SAAgB,OAAA,KAAA,CAAA;EAGrB,MAAMC,OAAU,GAAAH,iBAAA,CAAkBI,IAAK,CAAAF,OAAO,IAAI,CAAC,CAAA;EAG/C,IAAA,CAACC,OAAS,EAAAE,MAAA,EAAe,OAAA,KAAA,CAAA;EAG7B,
|
|
1
|
+
{"version":3,"file":"wattage.mjs","sources":["../../src/utils/wattage.ts"],"sourcesContent":["// #############################################################################\n// PoE Wattage Tags\n// #############################################################################\n\nconst POE_WATTAGE_REGEX = /poe:(\\d+)w/i;\n\n/**\n * Get the PoE wattage from a tag\n * @example \"poe:100w\" => \"100W\"\n */\nexport const getPoeWattageFromTag = (tagName: string | undefined) => {\n // If there is no wattage tag, return undefined\n if (!tagName) return undefined;\n\n // Get the wattage from the tag\n const wattage = POE_WATTAGE_REGEX.exec(tagName)?.[1];\n\n // If there is no wattage, return undefined\n if (!wattage?.length) return undefined;\n\n // Return the wattage\n return `${wattage}W`;\n};\n\n/**\n * Finds first PoE wattage tag and returns the wattage\n */\nexport const getPoeWattageFromTags = (\n tags: { name: string }[],\n): string | undefined => {\n for (const tag of tags) {\n const watts = getPoeWattageFromTag(tag.name);\n\n if (watts) return watts;\n }\n\n return undefined;\n};\n"],"names":["POE_WATTAGE_REGEX","getPoeWattageFromTag","tagName","wattage","exec","length","getPoeWattageFromTags","tags","tag","watts","name"],"mappings":";;AAIA,MAAMA,iBAAoB,GAAA,aAAA;AAMb,MAAAC,oBAAA,GAAwBC,OAAgC,IAAA;EAE/D,IAAA,CAACA,SAAgB,OAAA,KAAA,CAAA;EAGrB,MAAMC,OAAU,GAAAH,iBAAA,CAAkBI,IAAK,CAAAF,OAAO,IAAI,CAAC,CAAA;EAG/C,IAAA,CAACC,OAAS,EAAAE,MAAA,EAAe,OAAA,KAAA,CAAA;EAG7B,UAAUF,OAAO,GAAA;AACnB,CAAA;AAKa,MAAAG,qBAAA,GACXC,IACuB,IAAA;EACvB,KAAA,MAAWC,OAAOD,IAAM,EAAA;IAChB,MAAAE,KAAA,GAAQR,oBAAqB,CAAAO,GAAA,CAAIE,IAAI,CAAA;IAE3C,IAAID,OAAc,OAAAA,KAAA;EACpB;EAEO,OAAA,KAAA,CAAA;AACT,CAAA;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ubnt/store.core",
|
|
3
|
-
"version": "9.40.0-
|
|
3
|
+
"version": "9.40.0-new-design",
|
|
4
4
|
"description": "",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"scripts": {
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"tldts": "6.1.64"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@babel/core": "7.26.0",
|
|
29
28
|
"@dinero.js/currencies": "2.0.0-alpha.8",
|
|
30
29
|
"@faker-js/faker": "^7.6.0",
|
|
31
30
|
"@formatjs/intl": "^2.10.5",
|
|
@@ -73,7 +72,6 @@
|
|
|
73
72
|
}
|
|
74
73
|
},
|
|
75
74
|
"devDependencies": {
|
|
76
|
-
"@babel/types": "7.26.0",
|
|
77
75
|
"@rollup/plugin-commonjs": "26.0.3",
|
|
78
76
|
"@rollup/plugin-json": "6.1.0",
|
|
79
77
|
"@rollup/plugin-multi-entry": "6.0.1",
|
package/lib/assets/crestron.svg
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.5934 11.5633C19.4108 10.4229 17.5851 9.44735 13.9717 8.42955H13.9722C13.8487 8.39472 13.8566 8.23964 13.9833 8.21735C14.0147 8.21191 14.0487 8.20558 14.0855 8.19871C14.2595 8.16626 14.4982 8.12174 14.84 8.1022C27.9265 7.34953 25.5408 17.5489 17.3014 17.5684C15.7747 17.5716 14.0534 17.4616 12.9242 16.187C12.8286 16.0788 12.9725 15.9372 13.0788 16.0343C14.9812 17.7625 20.1667 17.1171 21.3368 15.2964C22.2901 13.8115 21.6999 12.6312 20.5934 11.5633ZM25.8905 11.2872C26 11.3406 26.1236 11.4084 26.2508 11.4975L26.2512 11.4989C30.2602 14.3285 27.6438 16.6915 23.7773 17.8834V17.8852C23.7195 17.9014 23.6615 17.9186 23.6032 17.9358L23.6022 17.9361C23.589 17.94 23.5759 17.9439 23.5627 17.9478L23.5419 17.9539C19.9141 19.014 15.0503 19.1761 12.6284 17.8894C12.6284 17.8894 12.1121 17.5802 11.9059 17.3968C11.1217 16.6993 10.4066 15.7999 12.0104 14.6247C12.127 14.5393 12.2551 14.6981 12.1469 14.7947C10.8723 15.9272 12.3535 17.3745 14.7221 17.8829C15.5063 18.051 16.5283 18.1169 17.5428 18.0087C17.8776 17.9735 18.1971 17.9307 18.5012 17.882H18.5137C20.9839 17.4827 22.473 16.6729 23.5642 15.7577C24.8736 14.6586 25.5724 13.3701 25.467 11.27C25.4624 11.1799 25.5394 11.1279 25.6212 11.1655C25.647 11.1774 25.6757 11.19 25.7071 11.2038C25.7614 11.2276 25.8233 11.2548 25.8905 11.2872ZM3.34008 12.1588C6.84248 11.0453 9.39209 10.7087 11.9143 10.7482C14.2749 10.7849 16.636 11.1192 18.7004 12.3273C21.0025 13.6743 19.8041 16.2992 15.8128 16.289C15.6665 16.289 15.6609 16.4993 15.8072 16.5067C18.4422 16.6335 19.4976 15.9291 20.2777 15.221C22.3862 13.3057 19.2594 10.783 15.3614 9.58689C11.3631 8.35969 6.16085 8.34808 3.45663 11.5482C3.36701 11.6545 3.31315 11.7479 3.27647 11.8296C3.25423 11.8786 3.23919 11.9223 3.2261 11.9603C3.21923 11.9802 3.2129 11.9985 3.20636 12.0153C3.16875 12.1114 3.24304 12.1899 3.34055 12.1588H3.34008ZM12.2203 11.9816C9.15574 12.3071 7.4266 13.2028 6.19892 14.2331V14.2322C5.07294 15.1762 4.39874 16.2608 4.29844 17.8799L4.29241 17.8836H4.29844C4.28219 18.1451 4.28126 18.4237 4.29612 18.7199C4.30077 18.8095 4.23205 18.8648 4.13593 18.8397C4.07789 18.8246 4.0121 18.7916 3.93645 18.7536L3.93643 18.7536L3.93636 18.7536C3.914 18.7424 3.89077 18.7307 3.86662 18.719C3.75974 18.6667 3.64629 18.5863 3.52328 18.4992L3.51234 18.4914C3.22167 18.2867 2.96583 18.0842 2.74296 17.8841C-0.173466 15.2709 2.51172 13.1211 6.22121 12.0373C10.2594 10.857 15.8281 10.7902 17.8572 12.5945C18.6414 13.2919 19.357 14.1909 17.7527 15.3661C17.6362 15.4511 17.508 15.2932 17.6162 15.1971C19.3328 13.6713 16.1629 11.5633 12.2203 11.9816ZM26.4221 17.8312C26.3738 17.846 26.326 17.8618 26.2782 17.8795H26.267C22.8445 18.9544 20.333 19.2799 17.8479 19.2418C15.6396 19.207 13.4303 18.9117 11.4634 17.8841H11.4616C11.3274 17.8135 11.1941 17.7402 11.0623 17.6631C8.76014 16.3161 9.95856 13.6913 13.9499 13.7005C14.0962 13.7015 14.1017 13.4902 13.9555 13.4832C11.3204 13.356 10.265 14.0604 9.48495 14.769C8.42211 15.7348 8.68956 16.8547 9.71618 17.8841H9.71943C10.7298 18.8926 12.471 19.8101 14.4017 20.4031C18.4 21.6307 23.6023 21.6414 26.307 18.4413C26.3966 18.3354 26.4504 18.2416 26.4871 18.1604C26.509 18.1116 26.5241 18.0681 26.5372 18.0302L26.5372 18.0302C26.5442 18.0101 26.5506 17.9916 26.5572 17.9747C26.5702 17.9412 26.5698 17.9096 26.5591 17.8846C26.5396 17.8372 26.4862 17.8117 26.4226 17.8316L26.4221 17.8312ZM9.16923 18.4263C10.3514 19.5671 12.1776 20.5422 15.791 21.5605L15.7905 21.56C15.914 21.5948 15.9061 21.7494 15.7794 21.7717C15.7478 21.7772 15.7136 21.7836 15.6765 21.7905C15.5026 21.8229 15.2641 21.8674 14.9227 21.8873C8.7713 22.2412 6.03829 20.1749 5.72534 17.8835C5.37245 15.3004 8.09478 12.4309 12.4613 12.4207C13.988 12.4174 15.7092 12.5279 16.8385 13.8021C16.9346 13.9098 16.7907 14.0519 16.6839 13.9548C14.7815 12.2271 9.59594 12.8725 8.42585 14.6931C7.63092 15.9305 7.90859 16.9571 8.66405 17.8825V17.8839C8.81449 18.0678 8.98489 18.2484 9.16923 18.4263Z" fill="#212124"/>
|
|
3
|
-
</svg>
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var GlobeIcon = require("../../globe.svg");
|
|
7
|
-
function _interopDefault(e) {
|
|
8
|
-
return e && e.__esModule ? e : {
|
|
9
|
-
default: e
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
var GlobeIcon__default = /*#__PURE__*/_interopDefault(GlobeIcon);
|
|
13
|
-
Object.defineProperty(exports, "default", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return GlobeIcon__default["default"];
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Object.keys(GlobeIcon).forEach(function (k) {
|
|
20
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () {
|
|
23
|
-
return GlobeIcon[k];
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
//# sourceMappingURL=icon-globe.svg.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"icon-globe.svg.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"icon-globe.svg.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crestron.svg.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crestron.svg.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
require('../../assets/crestron.svg.js');
|
|
4
|
-
var icon = require("../../../../assets/crestron.svg");
|
|
5
|
-
function _interopDefault(e) {
|
|
6
|
-
return e && e.__esModule ? e : {
|
|
7
|
-
default: e
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
var icon__default = /*#__PURE__*/_interopDefault(icon);
|
|
11
|
-
"use strict";
|
|
12
|
-
const crestronNaxNvxCertified = {
|
|
13
|
-
id: "crestronNaxNvxCertified",
|
|
14
|
-
title: "crestronNaxNvxCertified.title",
|
|
15
|
-
icon: icon__default["default"]
|
|
16
|
-
};
|
|
17
|
-
exports.crestronNaxNvxCertified = crestronNaxNvxCertified;
|
|
18
|
-
//# sourceMappingURL=crestronNaxNvxCertified.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crestronNaxNvxCertified.js","sources":["../../../../../src/components/ModelCompareV3/data/properties/crestronNaxNvxCertified.tsx"],"sourcesContent":["import icon from \"../../assets/crestron.svg\";\nimport type { Property } from \"../../ModelCompareV3.types\";\n\nexport const crestronNaxNvxCertified: Property = {\n id: \"crestronNaxNvxCertified\",\n title: \"crestronNaxNvxCertified.title\",\n icon,\n};\n"],"names":["crestronNaxNvxCertified","id","title","icon"],"mappings":";;;;;;;;;;;AAGO,MAAMA,uBAAoC,GAAA;EAC/CC,EAAI,EAAA,yBAAA;EACJC,KAAO,EAAA,+BAAA;EAAAC,IAAA,EACPA,aAAA,CAAA,SAAA;AACF,CAAA;"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import '../../assets/crestron.svg.mjs';
|
|
2
|
-
import icon__default from "../../../../assets/crestron.svg";
|
|
3
|
-
"use strict";
|
|
4
|
-
const crestronNaxNvxCertified = {
|
|
5
|
-
id: "crestronNaxNvxCertified",
|
|
6
|
-
title: "crestronNaxNvxCertified.title",
|
|
7
|
-
icon: icon__default
|
|
8
|
-
};
|
|
9
|
-
export { crestronNaxNvxCertified };
|
|
10
|
-
//# sourceMappingURL=crestronNaxNvxCertified.mjs.map
|