@wayke-se/components-react 3.0.0-beta.9 → 3.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +12 -3
  2. package/dist-node/index.js +3233 -1031
  3. package/dist-node/index.js.map +1 -1
  4. package/dist-src/State/CentralStorage/useCentralStorage.js +7 -8
  5. package/dist-src/State/Path/PathProvider.js +1 -1
  6. package/dist-src/State/RelatedSearch/RelatedSearchProvider.js +1 -1
  7. package/dist-src/State/Search/SearchProvider.js +7 -10
  8. package/dist-src/components/ActionList/index.js +2 -3
  9. package/dist-src/components/Checklist/index.js +1 -1
  10. package/dist-src/components/ExtendContent/index.js +1 -1
  11. package/dist-src/components/Filter/index.js +10 -7
  12. package/dist-src/components/FilterPanel/checkListFacet.js +1 -1
  13. package/dist-src/components/FilterPanel/colorFacet.js +1 -1
  14. package/dist-src/components/FilterPanel/index.js +1 -1
  15. package/dist-src/components/FilterPanel/rangeFacet.js +14 -16
  16. package/dist-src/components/FinancialOptions/LoanModal.js +27 -29
  17. package/dist-src/components/FinancialOptions/leasing.js +6 -6
  18. package/dist-src/components/FinancialOptions/loan.js +5 -6
  19. package/dist-src/components/Gallery/index.js +11 -16
  20. package/dist-src/components/Grid/index.js +19 -5
  21. package/dist-src/components/InputSelect/index.js +1 -1
  22. package/dist-src/components/InsuranceOptions/InsuranceFree.js +1 -2
  23. package/dist-src/components/InsuranceOptions/InsuranceFreeModal.js +4 -5
  24. package/dist-src/components/InsuranceOptions/InsuranceModal.js +3 -3
  25. package/dist-src/components/Lightbox/index.js +1 -1
  26. package/dist-src/components/OpeningHours/index.js +9 -9
  27. package/dist-src/components/ProductCard/index.js +6 -3
  28. package/dist-src/components/RangeSlider/SliderWithLabel.js +1 -1
  29. package/dist-src/components/Result/index.js +7 -6
  30. package/dist-src/components/Video/EmbededVideo.js +1 -1
  31. package/dist-src/components/Video/QuickNavEmbeded.js +2 -2
  32. package/dist-src/components/Video/useThumbnail.js +1 -1
  33. package/dist-src/components/Video/utils.js +2 -2
  34. package/dist-src/hooks/useFetch.js +1 -1
  35. package/dist-src/hooks/useVimeoThumbnail.js +1 -1
  36. package/dist-src/layouts/searchItem/Branch.js +9 -10
  37. package/dist-src/layouts/searchItem/BranchModal.js +1 -1
  38. package/dist-src/layouts/searchItem/CheckList.js +16 -16
  39. package/dist-src/layouts/searchItem/ManufacturerPackagesOption.js +1 -2
  40. package/dist-src/layouts/searchItem/PackageOptionModal.js +7 -10
  41. package/dist-src/layouts/searchItem/PackageOptions.js +11 -14
  42. package/dist-src/layouts/searchItem/Property.js +4 -6
  43. package/dist-src/layouts/searchItem/Related.js +5 -6
  44. package/dist-src/layouts/searchItem/index.js +15 -17
  45. package/dist-src/utils/phonenumbers.js +1 -1
  46. package/dist-src/utils/regex.js +1 -1
  47. package/dist-src/utils/specification.js +9 -13
  48. package/dist-src/utils/vehicle-properties/property-tree-creator.js +5 -5
  49. package/dist-types/components/InputSearch/index.d.ts +5 -3
  50. package/dist-types/components/RangeSlider/handle.d.ts +2 -2
  51. package/dist-types/components/RangeSlider/track.d.ts +2 -2
  52. package/dist-web/index.js +232 -241
  53. package/dist-web/index.js.map +1 -1
  54. package/package.json +18 -24
package/dist-web/index.js CHANGED
@@ -679,14 +679,15 @@ const getTranslatedSortOptionDisplayName = (str) => {
679
679
  };
680
680
 
681
681
  const Result = ({ children }) => {
682
- var _a;
683
682
  const { loading, response, documents, queryFilter, onLoadMore, onFilterUpdate } = useSearch();
684
683
  const onSortOptionChange = useCallback((e) => onFilterUpdate(e.currentTarget.value), []);
685
- const numberOfDocuments = (documents === null || documents === void 0 ? void 0 : documents.length) || 0;
686
- const numberOfHits = (response === null || response === void 0 ? void 0 : response.documentList.numberOfHits) || 0;
687
- const useSkeletons = !!(queryFilter === null || queryFilter === void 0 ? void 0 : queryFilter.concatResult);
688
- const selectedSortOption = (_a = response === null || response === void 0 ? void 0 : response.documentList.sortOptions.find((x) => x.selected)) === null || _a === void 0 ? void 0 : _a.query;
689
- const sortOptions = response === null || response === void 0 ? void 0 : response.documentList.sortOptions.filter((x) => x.displayName !== 'relevance').map((so) => ({
684
+ const numberOfDocuments = documents?.length || 0;
685
+ const numberOfHits = response?.documentList.numberOfHits || 0;
686
+ const useSkeletons = !!queryFilter?.concatResult;
687
+ const selectedSortOption = response?.documentList.sortOptions.find((x) => x.selected)?.query;
688
+ const sortOptions = response?.documentList.sortOptions
689
+ .filter((x) => x.displayName !== 'relevance')
690
+ .map((so) => ({
690
691
  value: so.query,
691
692
  displayName: getTranslatedSortOptionDisplayName(so.displayName),
692
693
  }));
@@ -1196,7 +1197,7 @@ const ChecklistItem = ({ label, onClick, active, radio }) => (React__default.cre
1196
1197
  active && React__default.createElement(ActionIcon, null, radio ? React__default.createElement(IconRadio, { block: true }) : React__default.createElement(IconCheck, { block: true })),
1197
1198
  React__default.createElement(ActionLabel, { className: active ? 'wayke__theme wayke__font--bold wayke__color--primary-text' : '' }, label))));
1198
1199
  const Checklist = ({ items, radio }) => {
1199
- if (!(items === null || items === void 0 ? void 0 : items.length)) {
1200
+ if (!items?.length) {
1200
1201
  return null;
1201
1202
  }
1202
1203
  return (React__default.createElement(List$2, null, items.map((item) => (React__default.createElement(ChecklistItem, { key: item.label, label: item.label, onClick: item.onClick, active: item.active, radio: radio })))));
@@ -1231,7 +1232,7 @@ const ChecklistFacet = ({ facet }) => {
1231
1232
  .map((f) => ({
1232
1233
  label: f.displayName,
1233
1234
  onClick: () => onClick(f),
1234
- active: (selected === null || selected === void 0 ? void 0 : selected[f.displayName]) !== undefined ? selected[f.displayName] : f.selected,
1235
+ active: selected?.[f.displayName] !== undefined ? selected[f.displayName] : f.selected,
1235
1236
  })) })));
1236
1237
  };
1237
1238
 
@@ -1369,7 +1370,7 @@ const ColorSelectFacet = ({ facet }) => {
1369
1370
  .map((f) => ({
1370
1371
  label: f.displayName,
1371
1372
  onClick: () => onClick(f),
1372
- active: (selected === null || selected === void 0 ? void 0 : selected[f.displayName]) !== undefined ? selected[f.displayName] : f.selected,
1373
+ active: selected?.[f.displayName] !== undefined ? selected[f.displayName] : f.selected,
1373
1374
  hex: [getHexColorFromDisplayName(f.displayName)],
1374
1375
  })) }));
1375
1376
  };
@@ -1514,9 +1515,9 @@ const RangeSlider = ({ loading, values, domain, steps, unit, formatValues, maxPr
1514
1515
 
1515
1516
  const getInitialValues = (domain, facet, searchParams) => {
1516
1517
  const facetMin = domain[0]; //parseInt(facet.filters[0].displayName, 10);
1517
- const _queryMin = (searchParams === null || searchParams === void 0 ? void 0 : searchParams.get(`${facet.id}.min`)) || null;
1518
+ const _queryMin = searchParams?.get(`${facet.id}.min`) || null;
1518
1519
  const facetMax = domain[domain.length - 1]; //parseInt(facet.filters[facet.filters.length - 1].displayName, 10);
1519
- const _queryMax = (searchParams === null || searchParams === void 0 ? void 0 : searchParams.get(`${facet.id}.max`)) || null;
1520
+ const _queryMax = searchParams?.get(`${facet.id}.max`) || null;
1520
1521
  const queryMin = parseInt(_queryMin === null ? `${facetMin}` : _queryMin, 10);
1521
1522
  const min = facetMin > queryMin ? facetMin : queryMin;
1522
1523
  const queryMax = parseInt(_queryMax === null ? `${facetMax}` : _queryMax, 10);
@@ -1538,41 +1539,39 @@ const getSteps$1 = (initialAllValues) => {
1538
1539
  return initialAllValues;
1539
1540
  };
1540
1541
  const RangeFacet = ({ facet, unit, formatValues }) => {
1541
- var _a, _b, _c;
1542
1542
  const { loading, queryFilter, initialFacets, onFilterUpdate } = useSearch();
1543
- const initialFacet = initialFacets === null || initialFacets === void 0 ? void 0 : initialFacets.find((x) => x.id === facet.id);
1544
- const maxPrefix = (_b = (_a = initialFacet === null || initialFacet === void 0 ? void 0 : initialFacet.filters[(initialFacet === null || initialFacet === void 0 ? void 0 : initialFacet.filters.length) - 1]) === null || _a === void 0 ? void 0 : _a.displayName) === null || _b === void 0 ? void 0 : _b.includes('+');
1543
+ const initialFacet = initialFacets?.find((x) => x.id === facet.id);
1544
+ const maxPrefix = initialFacet?.filters[initialFacet?.filters.length - 1]?.displayName?.includes('+');
1545
1545
  const [state, setValues] = useState(undefined);
1546
1546
  useEffect(() => {
1547
- const _initialAllValues = (initialFacet === null || initialFacet === void 0 ? void 0 : initialFacet.filters.map((f) => parseInt(f.displayName.replace(/[\<\>+-]+/g, ''), 10))) || [1, 2];
1547
+ const _initialAllValues = initialFacet?.filters.map((f) => parseInt(f.displayName.replace(/[\<\>+-]+/g, ''), 10)) || [1, 2];
1548
1548
  const _steps = getSteps$1(_initialAllValues);
1549
1549
  const domain = [_steps[0], _steps[_steps.length - 1]];
1550
1550
  setValues({
1551
- id: initialFacet === null || initialFacet === void 0 ? void 0 : initialFacet.id,
1551
+ id: initialFacet?.id,
1552
1552
  steps: _steps,
1553
1553
  domain: [_steps[0], _steps[_steps.length - 1]],
1554
- values: (initialFacet === null || initialFacet === void 0 ? void 0 : initialFacet.filters.length)
1554
+ values: initialFacet?.filters.length
1555
1555
  ? getInitialValues(domain, initialFacet, queryFilter.searchParams)
1556
1556
  : [0, 0],
1557
1557
  });
1558
- }, [initialFacet === null || initialFacet === void 0 ? void 0 : initialFacet.id]);
1558
+ }, [initialFacet?.id]);
1559
1559
  useEffect(() => {
1560
- var _a, _b;
1561
- if (state === null || state === void 0 ? void 0 : state.id) {
1562
- const init = (initialFacet === null || initialFacet === void 0 ? void 0 : initialFacet.filters.length)
1560
+ if (state?.id) {
1561
+ const init = initialFacet?.filters.length
1563
1562
  ? getInitialValues(state.domain, initialFacet, queryFilter.searchParams)
1564
1563
  : [0, 0];
1565
- const minStr = (_a = queryFilter.searchParams) === null || _a === void 0 ? void 0 : _a.get(`${facet.id}.min`);
1566
- const maxStr = (_b = queryFilter.searchParams) === null || _b === void 0 ? void 0 : _b.get(`${facet.id}.max`);
1564
+ const minStr = queryFilter.searchParams?.get(`${facet.id}.min`);
1565
+ const maxStr = queryFilter.searchParams?.get(`${facet.id}.max`);
1567
1566
  const min = minStr ? parseFloat(minStr) : init[0];
1568
1567
  const max = maxStr ? parseFloat(maxStr) : init[1];
1569
1568
  if (min !== state.values[0] || max !== state.values[1]) {
1570
1569
  onChange([min, max]);
1571
1570
  }
1572
1571
  }
1573
- }, [(_c = queryFilter.searchParams) === null || _c === void 0 ? void 0 : _c.toString()]);
1572
+ }, [queryFilter.searchParams?.toString()]);
1574
1573
  const onChange = useCallback((nextValues) => {
1575
- if (state === null || state === void 0 ? void 0 : state.id) {
1574
+ if (state?.id) {
1576
1575
  if (state.values[0] !== nextValues[0] || state.values[1] !== nextValues[1]) {
1577
1576
  setValues({ ...state, values: nextValues.slice() });
1578
1577
  const query = new URLSearchParams(queryFilter.searchParams);
@@ -1631,7 +1630,7 @@ const FilterPanel = ({ facet, filteredFacets, numberOfHits, loading, onFilterUpd
1631
1630
  React__default.createElement(ButtonContent, null, `Visa ${numberOfHits} ${numberOfHits === 1 ? 'bil' : 'bilar'}`))))) },
1632
1631
  React__default.createElement(Accordion, null, filteredFacets
1633
1632
  .filter((x) => x.filters.length)
1634
- .map((f) => (React__default.createElement(AccordionItem, { key: f.displayName, heading: f.displayName, isActive: f.id === (facet === null || facet === void 0 ? void 0 : facet.id) },
1633
+ .map((f) => (React__default.createElement(AccordionItem, { key: f.displayName, heading: f.displayName, isActive: f.id === facet?.id },
1635
1634
  React__default.createElement(Repeat, null,
1636
1635
  React__default.createElement(FacetSelector, { facet: f }))))))));
1637
1636
  };
@@ -1647,9 +1646,8 @@ const isSelected = (f, searchParams) => {
1647
1646
  }
1648
1647
  };
1649
1648
  const Filter = ({ filterList }) => {
1650
- var _a;
1651
1649
  const { queryFilter, initialFacets, loading, response, onFilterUpdate } = useSearch();
1652
- const facets = response === null || response === void 0 ? void 0 : response.facets;
1650
+ const facets = response?.facets;
1653
1651
  const [facet, setFacet] = useState();
1654
1652
  const onSelectFacet = useCallback((nextFacet) => setFacet(nextFacet), []);
1655
1653
  const onClose = useCallback(() => setFacet(undefined), []);
@@ -1657,12 +1655,16 @@ const Filter = ({ filterList }) => {
1657
1655
  return null;
1658
1656
  }
1659
1657
  const filterNames = filterList ? filterList.map((x) => x.filterName) : undefined;
1660
- const filteredFacets = (_a = facets === null || facets === void 0 ? void 0 : facets.filter((x) => x.id !== 'segment')) === null || _a === void 0 ? void 0 : _a.filter((f) => (filterNames ? filterNames.includes(f.id) : true)).sort((a, b) => filterNames
1658
+ const filteredFacets = facets
1659
+ ?.filter((x) => x.id !== 'segment')
1660
+ ?.filter((f) => (filterNames ? filterNames.includes(f.id) : true))
1661
+ .sort((a, b) => filterNames
1661
1662
  ? filterNames.indexOf(a.id) -
1662
1663
  filterNames.indexOf(b.id)
1663
- : 0).map((x) => {
1664
- const match = filterList === null || filterList === void 0 ? void 0 : filterList.find((y) => y.filterName === x.id);
1665
- if (match === null || match === void 0 ? void 0 : match.displayName) {
1664
+ : 0)
1665
+ .map((x) => {
1666
+ const match = filterList?.find((y) => y.filterName === x.id);
1667
+ if (match?.displayName) {
1666
1668
  return {
1667
1669
  ...x,
1668
1670
  displayName: match.displayName,
@@ -1674,7 +1676,7 @@ const Filter = ({ filterList }) => {
1674
1676
  };
1675
1677
  });
1676
1678
  return (React__default.createElement(React__default.Fragment, null,
1677
- initialFacets && facet && (React__default.createElement(FilterPanel, { filterList: filterList, facet: facet, loading: loading, filteredFacets: filteredFacets, numberOfHits: (response === null || response === void 0 ? void 0 : response.documentList.numberOfHits) || 0, onFilterUpdate: onFilterUpdate, onClose: onClose })),
1679
+ initialFacets && facet && (React__default.createElement(FilterPanel, { filterList: filterList, facet: facet, loading: loading, filteredFacets: filteredFacets, numberOfHits: response?.documentList.numberOfHits || 0, onFilterUpdate: onFilterUpdate, onClose: onClose })),
1678
1680
  React__default.createElement(List, null, filteredFacets
1679
1681
  .filter((x) => x.filters.length)
1680
1682
  .map((f) => {
@@ -1954,9 +1956,12 @@ const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, desc
1954
1956
  const { pushState } = usePath();
1955
1957
  const _onClick = useMemo(() => (onClick ? () => onClick(id) : undefined), [id]);
1956
1958
  const onHrefClick = useCallback((e) => {
1957
- if (!!pathRoute && href) {
1958
- e.preventDefault();
1959
- pushState(href);
1959
+ if (pathRoute && href) {
1960
+ const reg = new RegExp('^((http|https)://)|//');
1961
+ if (!pathRoute.match(reg) && !pathRoute.startsWith(location.origin)) {
1962
+ e.preventDefault();
1963
+ pushState(href);
1964
+ }
1960
1965
  }
1961
1966
  }, [id, pathRoute, href]);
1962
1967
  return (React__default.createElement(Wrapper$8, { onClick: _onClick },
@@ -1983,8 +1988,7 @@ const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, desc
1983
1988
  };
1984
1989
 
1985
1990
  const resolveImage = (document) => {
1986
- var _a, _b, _c;
1987
- const img = (_c = (_b = (_a = document.featuredImage) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.url;
1991
+ const img = document.featuredImage?.files?.[0]?.url;
1988
1992
  if (img) {
1989
1993
  return `${img}?w=567&q=72`;
1990
1994
  }
@@ -1996,13 +2000,28 @@ const Grid = ({ documents, placeholderImage, hashRoute, pathRoute, onClickItem }
1996
2000
  }
1997
2001
  return (React__default.createElement(Wrapper$7, null,
1998
2002
  React__default.createElement(List$4, null, documents.map((document) => {
1999
- const _path = pathRoute === null || pathRoute === void 0 ? void 0 : pathRoute.replace(/^\/|\/$/g, '');
2003
+ /*
2004
+ const _path = pathRoute?.replace(/^\/|\/$/g, '');
2005
+
2000
2006
  const prefix = _path ? `/${_path}/` : '/';
2001
- const pathRouteUrl = window.location.pathname === '/'
2007
+
2008
+ const pathRouteUrl =
2009
+ window.location.pathname === '/'
2002
2010
  ? `${prefix}${document._id}`
2003
2011
  : `${window.location.pathname}${prefix}${document._id}`;
2012
+ */
2013
+ /*
2014
+ const _pathRoute = pathRoute
2015
+ ? pathRoute.startsWith('/')
2016
+ ? `${location.pathname}${pathRoute}/${document._id}`
2017
+ : `${pathRoute}/${document._id}`
2018
+ : undefined;
2019
+
2020
+ console.log(_pathRoute);
2021
+ */
2022
+ const _pathRoute = pathRoute ? `${pathRoute}/${document._id}` : undefined;
2004
2023
  return (React__default.createElement(Item$4, { key: document._id },
2005
- React__default.createElement(ProductCard, { id: document._id, onClick: onClickItem, title: document.title, pathRoute: pathRoute, href: pathRoute ? pathRouteUrl : hashRoute ? `#${document._id}` : undefined, image: resolveImage(document), placeholderImage: placeholderImage, description: document.shortDescription, uspList: [
2024
+ React__default.createElement(ProductCard, { id: document._id, onClick: onClickItem, title: document.title, pathRoute: pathRoute, href: _pathRoute ? _pathRoute : hashRoute ? `#${document._id}` : undefined, image: resolveImage(document), placeholderImage: placeholderImage, description: document.shortDescription, uspList: [
2006
2025
  {
2007
2026
  title: document.modelYear,
2008
2027
  },
@@ -2668,7 +2687,7 @@ const ExtendContent = ({ children, actionTitle, onClick }) => {
2668
2687
  }
2669
2688
  }, []);
2670
2689
  const onRef = (ref) => {
2671
- const refHeight = (ref === null || ref === void 0 ? void 0 : ref.clientHeight) || 0;
2690
+ const refHeight = ref?.clientHeight || 0;
2672
2691
  if (refHeight < 207) {
2673
2692
  setExtend(true);
2674
2693
  }
@@ -3082,7 +3101,7 @@ const getYoutubeThumbnail = (url) => {
3082
3101
  };
3083
3102
  };
3084
3103
  const onImageLoad = (e, thumbnail) => {
3085
- if ((thumbnail === null || thumbnail === void 0 ? void 0 : thumbnail.length) === 2 &&
3104
+ if (thumbnail?.length === 2 &&
3086
3105
  e.currentTarget.src === thumbnail[0] &&
3087
3106
  e.currentTarget.naturalWidth === 120 &&
3088
3107
  e.currentTarget.naturalHeight === 90) {
@@ -3090,7 +3109,7 @@ const onImageLoad = (e, thumbnail) => {
3090
3109
  }
3091
3110
  };
3092
3111
  const onImageError = (e, thumbnail) => {
3093
- if ((thumbnail === null || thumbnail === void 0 ? void 0 : thumbnail.length) === 2) {
3112
+ if (thumbnail?.length === 2) {
3094
3113
  e.currentTarget.src = thumbnail[1];
3095
3114
  }
3096
3115
  };
@@ -3570,7 +3589,7 @@ const Lightbox = ({ index, media, onClose }) => {
3570
3589
  onClose();
3571
3590
  }
3572
3591
  };
3573
- return (React__default.createElement(Wrapper$h, { ref: (ref) => ref === null || ref === void 0 ? void 0 : ref.focus(), onKeyDown: onKeyDown, tabIndex: 0 },
3592
+ return (React__default.createElement(Wrapper$h, { ref: (ref) => ref?.focus(), onKeyDown: onKeyDown, tabIndex: 0 },
3574
3593
  React__default.createElement(UiBlock$1, { onClick: onClose, "aria-hidden": true }),
3575
3594
  media.map((m, i) => (React__default.createElement(Item$8, { key: i, ref: index === i ? onRef : undefined },
3576
3595
  m.type === 'image' && (React__default.createElement(Img$1, { id: `lightbox-image-${i}`, src: m.files[0].url, alt: `Bild ${i + 1}` })),
@@ -3582,7 +3601,7 @@ const Lightbox = ({ index, media, onClose }) => {
3582
3601
  };
3583
3602
 
3584
3603
  const cache = {};
3585
- const getCachedResult = (key) => (cache === null || cache === void 0 ? void 0 : cache[key]) || undefined;
3604
+ const getCachedResult = (key) => cache?.[key] || undefined;
3586
3605
  const setCachedResult = (key, value) => {
3587
3606
  cache[key] = value;
3588
3607
  };
@@ -3653,7 +3672,7 @@ const useVimeoThumbnail = (id, small) => {
3653
3672
  const [thumbnail, setThumbnail] = useState();
3654
3673
  const { data } = useFetch(`http://vimeo.com/api/v2/video/${id}.json`, {}, !id || !!thumbnail, true);
3655
3674
  useEffect(() => {
3656
- if (data === null || data === void 0 ? void 0 : data[0]) {
3675
+ if (data?.[0]) {
3657
3676
  if (small && data[0].thumbnail_small) {
3658
3677
  setThumbnail(data[0].thumbnail_small);
3659
3678
  }
@@ -3666,7 +3685,7 @@ const useVimeoThumbnail = (id, small) => {
3666
3685
  };
3667
3686
 
3668
3687
  const useThumbnail = (url, small) => {
3669
- if (url === null || url === void 0 ? void 0 : url.toLowerCase().endsWith('.mp4'))
3688
+ if (url?.toLowerCase().endsWith('.mp4'))
3670
3689
  return;
3671
3690
  const [thumbnail, setThumbnail] = useState();
3672
3691
  const vimeoId = url ? getVimeoId(url) : undefined;
@@ -3825,7 +3844,7 @@ const GalleryEmbed = ({ src, index }) => {
3825
3844
  const onError = useCallback((e) => onImageError(e, thumbnail), [thumbnail]);
3826
3845
  const onLoad = useCallback((e) => onImageLoad(e, thumbnail), [thumbnail]);
3827
3846
  const customVideo = src.toLowerCase().endsWith('.mp4');
3828
- if ((thumbnail === null || thumbnail === void 0 ? void 0 : thumbnail.length) && !customVideo) {
3847
+ if (thumbnail?.length && !customVideo) {
3829
3848
  return (React__default.createElement(React__default.Fragment, null,
3830
3849
  React__default.createElement(ImageFull, { onLoad: onLoad, src: thumbnail[0], onError: onError, alt: `Bild ${index + 1}` }),
3831
3850
  React__default.createElement(MediaButton, { text: "Spela video", onClick: onClick }),
@@ -3845,8 +3864,8 @@ const QuickNavEmbeded = ({ src, index }) => {
3845
3864
  const thumbnail = useThumbnail(src);
3846
3865
  const onError = useCallback((e) => onImageError(e, thumbnail), [thumbnail]);
3847
3866
  const onLoad = useCallback((e) => onImageLoad(e, thumbnail), [thumbnail]);
3848
- const customVideo = src === null || src === void 0 ? void 0 : src.toLowerCase().endsWith('.mp4');
3849
- if ((thumbnail === null || thumbnail === void 0 ? void 0 : thumbnail.length) && !customVideo)
3867
+ const customVideo = src?.toLowerCase().endsWith('.mp4');
3868
+ if (thumbnail?.length && !customVideo)
3850
3869
  return (React__default.createElement(QuickNavImg, { onLoad: onLoad, src: thumbnail[0], onError: onError, alt: `Bild ${index + 1}` }));
3851
3870
  if (customVideo)
3852
3871
  return React__default.createElement(CustomPlayer, { key: index, url: src, ratio: "66.66%" });
@@ -3907,8 +3926,7 @@ const Gallery = ({ media, placeholderImage }) => {
3907
3926
  const [lightbox, setLightbox] = useState(false);
3908
3927
  const [navigationDisabled, setNavigationDisabled] = useState(false);
3909
3928
  const beforeChange = useCallback((_, newIndex) => {
3910
- var _a, _b;
3911
- const element = (_b = (_a = quickNavRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('li')) === null || _b === void 0 ? void 0 : _b[newIndex];
3929
+ const element = quickNavRef.current?.querySelectorAll('li')?.[newIndex];
3912
3930
  if (element) {
3913
3931
  scrollIntoView(element, { scrollMode: 'if-needed', block: 'nearest', inline: 'nearest' });
3914
3932
  }
@@ -3926,7 +3944,7 @@ const Gallery = ({ media, placeholderImage }) => {
3926
3944
  }, []);
3927
3945
  const onClick = useCallback(() => {
3928
3946
  PubSub.publish('ImagesClick');
3929
- if (!isDragging.current && !lightbox && !!(media === null || media === void 0 ? void 0 : media.length)) {
3947
+ if (!isDragging.current && !lightbox && !!media?.length) {
3930
3948
  setLightbox(true);
3931
3949
  }
3932
3950
  }, [lightbox, media]);
@@ -3961,20 +3979,17 @@ const Gallery = ({ media, placeholderImage }) => {
3961
3979
  setNavigationDisabled(false);
3962
3980
  };
3963
3981
  const onToggleLightbox = useCallback(() => setLightbox(!lightbox), [lightbox]);
3964
- const mediaLength = (media === null || media === void 0 ? void 0 : media.length) || 0;
3982
+ const mediaLength = media?.length || 0;
3965
3983
  const placeholder = useMemo(() => placeholderImage || DEFAULT_PLACEHOLDER_IMAGE, [placeholderImage]);
3966
3984
  return (React__default.createElement(React__default.Fragment, null,
3967
3985
  React__default.createElement(Wrapper$g, null,
3968
3986
  React__default.createElement(Main, null,
3969
3987
  React__default.createElement(SliderWrapper, { onMouseDown: onMouseDown, onMouseMove: onMouseMove, onClick: onClick },
3970
- React__default.createElement(Slider$2, { ...sliderSettings, swipe: !navigationDisabled, touchMove: !navigationDisabled, swipeToSlide: !navigationDisabled, ref: slider, beforeChange: beforeChange }, !!(media === null || media === void 0 ? void 0 : media.length) ? (media.map((m, i) => {
3971
- var _a;
3972
- return (React__default.createElement(Item$7, { key: m.files[0].url || i },
3973
- m.type === 'image' && (React__default.createElement(Image$1, { src: (_a = m.files[0].formats.filter(notEmpty).find((x) => x.format === '1170x')) === null || _a === void 0 ? void 0 : _a.url, alt: `Bild ${i + 1}` })),
3974
- m.type === 'threesixty' && (React__default.createElement(ThreeSixty, { urls: m.files.map((x) => x.url), visible: i === index, onDisableNavigation: onDisableNavigation, navigationDisabled: navigationDisabled })),
3975
- m.type === 'embedded' && React__default.createElement(GalleryEmbed, { src: m.files[0].url, index: i + 1 }),
3976
- m.type === 'sphere' && (React__default.createElement(Sphere, { visible: i === index, url: m.files[0].url, preview: m.files[0].url, onDisableNavigation: onDisableNavigation, navigationDisabled: navigationDisabled }))));
3977
- })) : (React__default.createElement(Item$7, { key: placeholder },
3988
+ React__default.createElement(Slider$2, { ...sliderSettings, swipe: !navigationDisabled, touchMove: !navigationDisabled, swipeToSlide: !navigationDisabled, ref: slider, beforeChange: beforeChange }, !!media?.length ? (media.map((m, i) => (React__default.createElement(Item$7, { key: m.files[0].url || i },
3989
+ m.type === 'image' && (React__default.createElement(Image$1, { src: m.files[0].formats.filter(notEmpty).find((x) => x.format === '1170x')?.url, alt: `Bild ${i + 1}` })),
3990
+ m.type === 'threesixty' && (React__default.createElement(ThreeSixty, { urls: m.files.map((x) => x.url), visible: i === index, onDisableNavigation: onDisableNavigation, navigationDisabled: navigationDisabled })),
3991
+ m.type === 'embedded' && React__default.createElement(GalleryEmbed, { src: m.files[0].url, index: i + 1 }),
3992
+ m.type === 'sphere' && (React__default.createElement(Sphere, { visible: i === index, url: m.files[0].url, preview: m.files[0].url, onDisableNavigation: onDisableNavigation, navigationDisabled: navigationDisabled })))))) : (React__default.createElement(Item$7, { key: placeholder },
3978
3993
  React__default.createElement(Image$1, { src: placeholder, alt: `Bild 1` })))),
3979
3994
  navigationDisabled && mediaLength > 1 && (React__default.createElement(EnableNavigationButton, null,
3980
3995
  React__default.createElement(ButtonSecondary, { onClick: onEnableNavigation, title: "St\u00E4ng" },
@@ -3985,9 +4000,8 @@ const Gallery = ({ media, placeholderImage }) => {
3985
4000
  React__default.createElement(ArrowRight, { onClick: nextImage, title: "N\u00E4sta bild" },
3986
4001
  React__default.createElement(IconChevronRight, { block: true }))))),
3987
4002
  React__default.createElement(Alt, null,
3988
- React__default.createElement(QuickNav, { ref: quickNavRef }, !!(media === null || media === void 0 ? void 0 : media.length) ? (media.map((m, i) => {
3989
- var _a;
3990
- const src = ((_a = m.files[0].formats.filter(notEmpty).find((x) => x.format === '225x150')) === null || _a === void 0 ? void 0 : _a.url) ||
4003
+ React__default.createElement(QuickNav, { ref: quickNavRef }, !!media?.length ? (media.map((m, i) => {
4004
+ const src = m.files[0].formats.filter(notEmpty).find((x) => x.format === '225x150')?.url ||
3991
4005
  m.files[0].url;
3992
4006
  return (React__default.createElement(QuickNavItem, { key: src || i, active: index === i },
3993
4007
  React__default.createElement(QuickNavBtn, { onClick: () => goTo(i), title: `Gå till bild ${i + 1}` },
@@ -3998,7 +4012,7 @@ const Gallery = ({ media, placeholderImage }) => {
3998
4012
  })) : (React__default.createElement(QuickNavItem, { key: placeholder, active: true },
3999
4013
  React__default.createElement(QuickNavBtn, { onClick: () => goTo(0), title: `Gå till bild 0` },
4000
4014
  React__default.createElement(QuickNavImg, { src: placeholder, alt: `Bild 1` }))))))),
4001
- lightbox && !!(media === null || media === void 0 ? void 0 : media.length) && (React__default.createElement(Lightbox, { media: media, index: index, onClose: onToggleLightbox }))));
4015
+ lightbox && !!media?.length && (React__default.createElement(Lightbox, { media: media, index: index, onClose: onToggleLightbox }))));
4002
4016
  };
4003
4017
 
4004
4018
  const ProductPage = styled.div `
@@ -4418,11 +4432,11 @@ const Leasing = ({ financialOption }) => {
4418
4432
  },
4419
4433
  {
4420
4434
  label: 'Bindningstid',
4421
- value: `${duration === null || duration === void 0 ? void 0 : duration.current} månader`,
4435
+ value: `${duration?.current} månader`,
4422
4436
  },
4423
4437
  {
4424
4438
  label: 'Årlig körsträcka',
4425
- value: `${numberSeparator((mileage === null || mileage === void 0 ? void 0 : mileage.current) || 0)} mil/år`,
4439
+ value: `${numberSeparator(mileage?.current || 0)} mil/år`,
4426
4440
  },
4427
4441
  ] }))))),
4428
4442
  React__default.createElement(OptionBox, null,
@@ -4431,14 +4445,14 @@ const Leasing = ({ financialOption }) => {
4431
4445
  React__default.createElement("p", null,
4432
4446
  "Privatleasing",
4433
4447
  ' ',
4434
- (mileage === null || mileage === void 0 ? void 0 : mileage.current) && (duration === null || duration === void 0 ? void 0 : duration.current) && (React__default.createElement(React__default.Fragment, null,
4448
+ mileage?.current && duration?.current && (React__default.createElement(React__default.Fragment, null,
4435
4449
  React__default.createElement(UtilityTextPrimary, null,
4436
- numberSeparator(mileage === null || mileage === void 0 ? void 0 : mileage.current),
4450
+ numberSeparator(mileage?.current),
4437
4451
  " mil/\u00E5r"),
4438
4452
  ' ',
4439
4453
  "i ",
4440
- React__default.createElement(UtilityTextPrimary, null, duration === null || duration === void 0 ? void 0 :
4441
- duration.current,
4454
+ React__default.createElement(UtilityTextPrimary, null,
4455
+ duration?.current,
4442
4456
  " m\u00E5n"),
4443
4457
  ".",
4444
4458
  ' '))),
@@ -4569,7 +4583,7 @@ const SliderWithLabel = ({ label, values, domain, steps, loading, unit, formatVa
4569
4583
  }, [loading]);
4570
4584
  return (React__default.createElement(React__default.Fragment, null,
4571
4585
  React__default.createElement(RepeatTiny, null,
4572
- React__default.createElement(RangeSliderLabel, { label: label, value: `${numberSeparator((local === null || local === void 0 ? void 0 : local[0]) || values[0])}${unit ? ` ${unit}` : ''}` })),
4586
+ React__default.createElement(RangeSliderLabel, { label: label, value: `${numberSeparator(local?.[0] || values[0])}${unit ? ` ${unit}` : ''}` })),
4573
4587
  React__default.createElement(RepeatTiny, null,
4574
4588
  React__default.createElement(RangeSliderSimple, { loading: loading, values: values, domain: domain, steps: steps, onChange: onChange, onUpdate: onUpdate, unit: unit, formatValues: formatValues }))));
4575
4589
  };
@@ -4585,7 +4599,6 @@ const stepGenerator = (step, max, steps = [], current) => {
4585
4599
  return stepGenerator(step, max, steps, nextCurrent);
4586
4600
  };
4587
4601
  const LoanModal = ({ id, financialOption, onClose }) => {
4588
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
4589
4602
  const [tmp, setTmp] = useState();
4590
4603
  const [extend, setExtend] = React__default.useState(false);
4591
4604
  const onToggleExtend = React__default.useCallback(() => {
@@ -4595,60 +4608,59 @@ const LoanModal = ({ id, financialOption, onClose }) => {
4595
4608
  setExtend(!extend);
4596
4609
  }, [extend]);
4597
4610
  const [variables, setVariables] = useState({
4598
- duration: (_a = financialOption.duration) === null || _a === void 0 ? void 0 : _a.current,
4599
- downPayment: (_b = financialOption.downPayment) === null || _b === void 0 ? void 0 : _b.current,
4600
- residual: (_c = financialOption.residual) === null || _c === void 0 ? void 0 : _c.current,
4611
+ duration: financialOption.duration?.current,
4612
+ downPayment: financialOption.downPayment?.current,
4613
+ residual: financialOption.residual?.current,
4601
4614
  });
4602
4615
  const { duration, downPayment, residual } = variables;
4603
4616
  const { loading, data } = useLoanCalculation(id, duration, downPayment, residual);
4604
4617
  useEffect(() => {
4605
- var _a, _b, _c, _d, _e, _f;
4606
4618
  if (data) {
4607
4619
  setTmp(data);
4608
4620
  setVariables({
4609
- duration: ((_b = (_a = data === null || data === void 0 ? void 0 : data.loan) === null || _a === void 0 ? void 0 : _a.duration) === null || _b === void 0 ? void 0 : _b.current) || 0,
4610
- downPayment: ((_d = (_c = data === null || data === void 0 ? void 0 : data.loan) === null || _c === void 0 ? void 0 : _c.downPayment) === null || _d === void 0 ? void 0 : _d.current) || 0,
4611
- residual: ((_f = (_e = data === null || data === void 0 ? void 0 : data.loan) === null || _e === void 0 ? void 0 : _e.residual) === null || _f === void 0 ? void 0 : _f.current) || 0,
4621
+ duration: data?.loan?.duration?.current || 0,
4622
+ downPayment: data?.loan?.downPayment?.current || 0,
4623
+ residual: data?.loan?.residual?.current || 0,
4612
4624
  });
4613
4625
  }
4614
4626
  }, [data]);
4615
- const loan = (data === null || data === void 0 ? void 0 : data.loan) || (tmp === null || tmp === void 0 ? void 0 : tmp.loan);
4616
- const downPaymentCurrent = ((_d = loan === null || loan === void 0 ? void 0 : loan.downPayment) === null || _d === void 0 ? void 0 : _d.current) || 0;
4617
- const downPaymentMin = ((_e = loan === null || loan === void 0 ? void 0 : loan.downPayment) === null || _e === void 0 ? void 0 : _e.min) || 0;
4618
- const downPaymentMax = ((_f = loan === null || loan === void 0 ? void 0 : loan.downPayment) === null || _f === void 0 ? void 0 : _f.max) || 0;
4619
- const downPaymentStep = ((_g = loan === null || loan === void 0 ? void 0 : loan.downPayment) === null || _g === void 0 ? void 0 : _g.step) || 0;
4627
+ const loan = data?.loan || tmp?.loan;
4628
+ const downPaymentCurrent = loan?.downPayment?.current || 0;
4629
+ const downPaymentMin = loan?.downPayment?.min || 0;
4630
+ const downPaymentMax = loan?.downPayment?.max || 0;
4631
+ const downPaymentStep = loan?.downPayment?.step || 0;
4620
4632
  const downPaymentSteps = stepGenerator(downPaymentStep, downPaymentMax);
4621
4633
  const onDownPaymentChange = useCallback((values) => {
4622
4634
  PubSub.publish('FinanceInterest');
4623
4635
  setVariables({ ...variables, downPayment: values[0] });
4624
4636
  }, [variables]);
4625
- const durationCurrent = ((_h = loan === null || loan === void 0 ? void 0 : loan.duration) === null || _h === void 0 ? void 0 : _h.current) || 0;
4626
- const durationMin = ((_j = loan === null || loan === void 0 ? void 0 : loan.duration) === null || _j === void 0 ? void 0 : _j.min) || 0;
4627
- const durationMax = ((_k = loan === null || loan === void 0 ? void 0 : loan.duration) === null || _k === void 0 ? void 0 : _k.max) || 0;
4628
- const durationStep = ((_l = loan === null || loan === void 0 ? void 0 : loan.duration) === null || _l === void 0 ? void 0 : _l.step) || 0;
4637
+ const durationCurrent = loan?.duration?.current || 0;
4638
+ const durationMin = loan?.duration?.min || 0;
4639
+ const durationMax = loan?.duration?.max || 0;
4640
+ const durationStep = loan?.duration?.step || 0;
4629
4641
  const durationSteps = stepGenerator(durationStep, durationMax);
4630
4642
  const onDurationChange = useCallback((values) => {
4631
4643
  PubSub.publish('FinanceInterest');
4632
4644
  setVariables({ ...variables, duration: values[0] });
4633
4645
  }, [variables]);
4634
- const residualCurrent = (((_m = loan === null || loan === void 0 ? void 0 : loan.residual) === null || _m === void 0 ? void 0 : _m.current) || 0) * 100 || 0;
4635
- const residualMin = (((_o = loan === null || loan === void 0 ? void 0 : loan.residual) === null || _o === void 0 ? void 0 : _o.min) || 0) * 100 || 0;
4636
- const residualMax = (((_p = loan === null || loan === void 0 ? void 0 : loan.residual) === null || _p === void 0 ? void 0 : _p.max) || 0) * 100 || 0;
4637
- const residualStep = (((_q = loan === null || loan === void 0 ? void 0 : loan.residual) === null || _q === void 0 ? void 0 : _q.step) || 0) * 100 || 0;
4646
+ const residualCurrent = (loan?.residual?.current || 0) * 100 || 0;
4647
+ const residualMin = (loan?.residual?.min || 0) * 100 || 0;
4648
+ const residualMax = (loan?.residual?.max || 0) * 100 || 0;
4649
+ const residualStep = (loan?.residual?.step || 0) * 100 || 0;
4638
4650
  const residualSteps = stepGenerator(residualStep, residualMax);
4639
4651
  const onResidualChange = useCallback((values) => {
4640
4652
  PubSub.publish('FinanceInterest');
4641
4653
  setVariables({ ...variables, residual: values[0] / 100 });
4642
4654
  }, [variables]);
4643
- const interestText = (((loan === null || loan === void 0 ? void 0 : loan.interest) || 0) * 100).toFixed(2);
4644
- const effectiveInterestText = (((loan === null || loan === void 0 ? void 0 : loan.effectiveInterest) || 0) * 100).toFixed(2);
4655
+ const interestText = ((loan?.interest || 0) * 100).toFixed(2);
4656
+ const effectiveInterestText = ((loan?.effectiveInterest || 0) * 100).toFixed(2);
4645
4657
  return (React__default.createElement(Modal, { title: "L\u00E5nealternativ", onClose: onClose },
4646
4658
  React__default.createElement(Repeat, null,
4647
4659
  React__default.createElement(ContentLogo, null,
4648
- (financialOption === null || financialOption === void 0 ? void 0 : financialOption.description) && (React__default.createElement(ContentLogoText, null,
4660
+ financialOption?.description && (React__default.createElement(ContentLogoText, null,
4649
4661
  React__default.createElement(Content$2, null,
4650
4662
  React__default.createElement("p", null, financialOption.description)))),
4651
- (financialOption === null || financialOption === void 0 ? void 0 : financialOption.image) && (React__default.createElement(ContentLogoMedia, null,
4663
+ financialOption?.image && (React__default.createElement(ContentLogoMedia, null,
4652
4664
  React__default.createElement(LogoBox, { logo: financialOption.image, alt: financialOption.name || 'Logotyp', wide: true }))))),
4653
4665
  React__default.createElement(Repeat, null,
4654
4666
  React__default.createElement(RepeatSmall, null,
@@ -4660,7 +4672,7 @@ const LoanModal = ({ id, financialOption, onClose }) => {
4660
4672
  React__default.createElement(RepeatSmall, null,
4661
4673
  React__default.createElement(RepeatTiny, null,
4662
4674
  React__default.createElement(Content$2, { small: true },
4663
- React__default.createElement("p", null, `*Beräknat på ${interestText} % ränta (effektivt ${effectiveInterestText} %)${(loan === null || loan === void 0 ? void 0 : loan.mileage) !== null ? `och en årlig körsträcka om ${loan === null || loan === void 0 ? void 0 : loan.mileage} mil.` : ''}`)))),
4675
+ React__default.createElement("p", null, `*Beräknat på ${interestText} % ränta (effektivt ${effectiveInterestText} %)${loan?.mileage !== null ? `och en årlig körsträcka om ${loan?.mileage} mil.` : ''}`)))),
4664
4676
  React__default.createElement(RepeatSmall, null,
4665
4677
  React__default.createElement(ButtonClear, { onClick: onToggleExtend, title: extend ? 'Visa mindre information' : 'Visa mer information' },
4666
4678
  React__default.createElement(ButtonContent, null, extend ? 'Mindre information' : 'Mer information'))),
@@ -4677,28 +4689,27 @@ const LoanModal = ({ id, financialOption, onClose }) => {
4677
4689
  },
4678
4690
  {
4679
4691
  label: 'Uppläggningskostnad',
4680
- value: `${numberSeparator((financialOption === null || financialOption === void 0 ? void 0 : financialOption.setupFee) || 0)} kr`,
4692
+ value: `${numberSeparator(financialOption?.setupFee || 0)} kr`,
4681
4693
  },
4682
4694
  {
4683
4695
  label: 'Administrativa avgifter',
4684
- value: `${numberSeparator((financialOption === null || financialOption === void 0 ? void 0 : financialOption.administrationFee) || 0)} kr/mån`,
4696
+ value: `${numberSeparator(financialOption?.administrationFee || 0)} kr/mån`,
4685
4697
  },
4686
4698
  {
4687
4699
  label: 'Total kreditkostnad',
4688
- value: `${numberSeparator((loan === null || loan === void 0 ? void 0 : loan.totalCreditCost) || 0)} kr`,
4700
+ value: `${numberSeparator(loan?.totalCreditCost || 0)} kr`,
4689
4701
  },
4690
4702
  ] }))))))));
4691
4703
  };
4692
4704
 
4693
4705
  const Loan = ({ id, financialOption }) => {
4694
- var _a, _b, _c, _d, _e, _f, _g;
4695
4706
  const [modal, setModal] = useState(false);
4696
4707
  const toggleModal = useCallback(() => setModal(!modal), [modal]);
4697
- const { data } = useLoanCalculation(id, (_a = financialOption.duration) === null || _a === void 0 ? void 0 : _a.current, (_b = financialOption.downPayment) === null || _b === void 0 ? void 0 : _b.current, (_c = financialOption.residual) === null || _c === void 0 ? void 0 : _c.current);
4698
- const interest = (_d = data === null || data === void 0 ? void 0 : data.loan) === null || _d === void 0 ? void 0 : _d.interest;
4699
- const duration = (_f = (_e = data === null || data === void 0 ? void 0 : data.loan) === null || _e === void 0 ? void 0 : _e.duration) === null || _f === void 0 ? void 0 : _f.current;
4700
- const monthlyCost = (_g = data === null || data === void 0 ? void 0 : data.loan) === null || _g === void 0 ? void 0 : _g.monthlyCost;
4701
- const logo = (financialOption === null || financialOption === void 0 ? void 0 : financialOption.logotype) || 'https://placehold.it/67x10';
4708
+ const { data } = useLoanCalculation(id, financialOption.duration?.current, financialOption.downPayment?.current, financialOption.residual?.current);
4709
+ const interest = data?.loan?.interest;
4710
+ const duration = data?.loan?.duration?.current;
4711
+ const monthlyCost = data?.loan?.monthlyCost;
4712
+ const logo = financialOption?.logotype || 'https://placehold.it/67x10';
4702
4713
  // Skeleton?
4703
4714
  if (financialOption.loanAmount === undefined ||
4704
4715
  financialOption.loanAmount === null ||
@@ -5044,7 +5055,7 @@ const Icon$4 = styled.div `
5044
5055
  `;
5045
5056
 
5046
5057
  const InputSelect = ({ value, options, onChange, unit, title }) => (React__default.createElement(Wrapper$s, null,
5047
- React__default.createElement(Select$1, { value: value, onChange: onChange, title: title, "aria-label": title }, options === null || options === void 0 ? void 0 : options.map((option) => (React__default.createElement(Option$1, { key: option.value, value: option.value },
5058
+ React__default.createElement(Select$1, { value: value, onChange: onChange, title: title, "aria-label": title }, options?.map((option) => (React__default.createElement(Option$1, { key: option.value, value: option.value },
5048
5059
  option.displayName || option.value,
5049
5060
  unit ? ` ${unit}` : '')))),
5050
5061
  React__default.createElement(Icon$4, null,
@@ -5159,7 +5170,7 @@ const InsuranceModal = ({ id, branch, onClose, insuranceOptions }) => {
5159
5170
  drivingDistance: DrivingDistance.Between0And1000,
5160
5171
  });
5161
5172
  const [payload, setPayload] = useState();
5162
- const { loading, data, error } = useInsuranceCalculation(id, (branch === null || branch === void 0 ? void 0 : branch.id) ? branch === null || branch === void 0 ? void 0 : branch.id : undefined, ssnIsValid(payload === null || payload === void 0 ? void 0 : payload.ssn) ? payload === null || payload === void 0 ? void 0 : payload.ssn : undefined, payload === null || payload === void 0 ? void 0 : payload.drivingDistance);
5173
+ const { loading, data, error } = useInsuranceCalculation(id, branch?.id ? branch?.id : undefined, ssnIsValid(payload?.ssn) ? payload?.ssn : undefined, payload?.drivingDistance);
5163
5174
  const onChangeSsn = useCallback((e) => setForm({ ...form, ssn: e.currentTarget.value }), [form]);
5164
5175
  const onChangeDrivingDistance = useCallback((e) => setForm({ ...form, drivingDistance: e.currentTarget.value }), [form]);
5165
5176
  const onShowInsurances = useCallback(() => {
@@ -5179,7 +5190,7 @@ const InsuranceModal = ({ id, branch, onClose, insuranceOptions }) => {
5179
5190
  { value: DrivingDistance.Over2500, displayName: '2500+' },
5180
5191
  ];
5181
5192
  return (React__default.createElement(Modal, { title: "F\u00F6rs\u00E4kring", onClose: onClose },
5182
- ((insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.description) || (insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.logotype)) && (React__default.createElement(Repeat, null,
5193
+ (insuranceOptions?.description || insuranceOptions?.logotype) && (React__default.createElement(Repeat, null,
5183
5194
  React__default.createElement(ContentLogo, null,
5184
5195
  insuranceOptions.description && (React__default.createElement(ContentLogoText, null,
5185
5196
  React__default.createElement(Content$2, null,
@@ -5207,7 +5218,7 @@ const InsuranceModal = ({ id, branch, onClose, insuranceOptions }) => {
5207
5218
  React__default.createElement(Loader, null))),
5208
5219
  error && (React__default.createElement(Repeat, null,
5209
5220
  React__default.createElement(Snackbar, { severity: "error", icon: true, heading: "Ett fel har intr\u00E4ffat" }, "Kunde inte h\u00E4mta f\u00F6rs\u00E4kringar. V\u00E4nligen f\u00F6rs\u00F6k igen."))),
5210
- React__default.createElement(React__default.Fragment, null, (data === null || data === void 0 ? void 0 : data.insurances) && (React__default.createElement(Repeat, null, data === null || data === void 0 ? void 0 : data.insurances.map((insurance) => (React__default.createElement(Repeat, { key: insurance.name },
5221
+ React__default.createElement(React__default.Fragment, null, data?.insurances && (React__default.createElement(Repeat, null, data?.insurances.map((insurance) => (React__default.createElement(Repeat, { key: insurance.name },
5211
5222
  React__default.createElement(DetailBox, { heading: `${numberSeparator(insurance.price)} ${insurance.unit}`, description: insurance.name },
5212
5223
  React__default.createElement(Repeat, null,
5213
5224
  React__default.createElement(React__default.Fragment, null, insurance.description && (React__default.createElement(RepeatTiny, null,
@@ -5253,20 +5264,18 @@ const Insurance = ({ id, branch, insuranceOptions }) => {
5253
5264
  };
5254
5265
 
5255
5266
  const InsuranceFreeModal = ({ onClose, insuranceOptions }) => {
5256
- var _a;
5257
- return (React__default.createElement(Modal, { title: (_a = insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.insuranceHeader) !== null && _a !== void 0 ? _a : 'Försäkring', onClose: onClose },
5258
- (insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.longDescription) && (React__default.createElement(Repeat, null,
5267
+ return (React__default.createElement(Modal, { title: insuranceOptions?.insuranceHeader ?? 'Försäkring', onClose: onClose },
5268
+ insuranceOptions?.longDescription && (React__default.createElement(Repeat, null,
5259
5269
  React__default.createElement(Content$2, { dangerouslySetInnerHTML: {
5260
5270
  __html: marked(insuranceOptions.longDescription),
5261
5271
  } }))),
5262
- (insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.url) && (React__default.createElement(Repeat, null,
5272
+ insuranceOptions?.url && (React__default.createElement(Repeat, null,
5263
5273
  React__default.createElement(ButtonInline, { as: "a", href: insuranceOptions.url, target: "_blank", rel: "noopener noreferrer" }, "L\u00E4s mer om f\u00F6rs\u00E4kringen (\u00D6ppnas i ett nytt f\u00F6nster)"))),
5264
- (insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.logotype) && (React__default.createElement(Repeat, null,
5274
+ insuranceOptions?.logotype && (React__default.createElement(Repeat, null,
5265
5275
  React__default.createElement(LogoBox, { logo: insuranceOptions.logotype, alt: insuranceOptions.name || 'Logotyp', wide: true })))));
5266
5276
  };
5267
5277
 
5268
5278
  const Insurance$1 = ({ insuranceOptions }) => {
5269
- var _a, _b;
5270
5279
  const [modal, setModal] = useState(false);
5271
5280
  const toggleModal = useCallback(() => setModal(!modal), [modal]);
5272
5281
  if (!insuranceOptions.length) {
@@ -5276,7 +5285,7 @@ const Insurance$1 = ({ insuranceOptions }) => {
5276
5285
  modal && React__default.createElement(InsuranceFreeModal, { onClose: toggleModal, insuranceOptions: insuranceOptions[0] }),
5277
5286
  React__default.createElement(Repeat, null,
5278
5287
  React__default.createElement(RepeatTiny, null,
5279
- React__default.createElement(VisualHeading, null, (_b = (_a = insuranceOptions[0]) === null || _a === void 0 ? void 0 : _a.insuranceHeader) !== null && _b !== void 0 ? _b : 'Försäkring')),
5288
+ React__default.createElement(VisualHeading, null, insuranceOptions[0]?.insuranceHeader ?? 'Försäkring')),
5280
5289
  React__default.createElement(RepeatTiny, null,
5281
5290
  React__default.createElement(React__default.Fragment, null, insuranceOptions.map((insuranceOption, index) => (React__default.createElement(OptionBox, { key: `${insuranceOption.url}-${index}`, logo: insuranceOption.logotype || undefined, logoAlt: insuranceOption.name || 'Logotyp' },
5282
5291
  insuranceOption.description && (React__default.createElement(Content$2, { dangerouslySetInnerHTML: {
@@ -5300,7 +5309,6 @@ const InsuranceOptions = ({ id, branch, insuranceOptions }) => {
5300
5309
  };
5301
5310
 
5302
5311
  const ManufacturerPackageOption = ({ packageOption }) => {
5303
- var _a;
5304
5312
  if (!packageOption) {
5305
5313
  return null;
5306
5314
  }
@@ -5309,7 +5317,7 @@ const ManufacturerPackageOption = ({ packageOption }) => {
5309
5317
  React__default.createElement(H2, { noMargin: true }, packageOption.title)),
5310
5318
  packageOption.description && (React__default.createElement(Repeat, null,
5311
5319
  React__default.createElement(Content$2, { dangerouslySetInnerHTML: { __html: marked(packageOption.description) } }))),
5312
- ((_a = packageOption.link) === null || _a === void 0 ? void 0 : _a.url) && (React__default.createElement(Repeat, null,
5320
+ packageOption.link?.url && (React__default.createElement(Repeat, null,
5313
5321
  React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.url, target: "_blank", rel: "noopener noreferrer" }, packageOption.link.title
5314
5322
  ? packageOption.link.title
5315
5323
  : 'Läs mer (Öppnas i ett nytt fönster)'))),
@@ -5431,7 +5439,7 @@ const typedMetadata = Metadata;
5431
5439
  const formatPhonenumber = (text) => {
5432
5440
  try {
5433
5441
  const parsed = parsePhoneNumberFromString(text.replace('-', '').replace(/ /g, ''), typedMetadata);
5434
- return (parsed === null || parsed === void 0 ? void 0 : parsed.formatNational()) || text;
5442
+ return parsed?.formatNational() || text;
5435
5443
  }
5436
5444
  catch (e) {
5437
5445
  return text;
@@ -5439,9 +5447,8 @@ const formatPhonenumber = (text) => {
5439
5447
  };
5440
5448
 
5441
5449
  const ActionList = ({ contact, branch }) => {
5442
- var _a, _b;
5443
- const email = (contact === null || contact === void 0 ? void 0 : contact.email) || ((_a = branch === null || branch === void 0 ? void 0 : branch.contact) === null || _a === void 0 ? void 0 : _a.email);
5444
- const phonenumber = (contact === null || contact === void 0 ? void 0 : contact.phonenumber) || ((_b = branch === null || branch === void 0 ? void 0 : branch.contact) === null || _b === void 0 ? void 0 : _b.phonenumber);
5450
+ const email = contact?.email || branch?.contact?.email;
5451
+ const phonenumber = contact?.phonenumber || branch?.contact?.phonenumber;
5445
5452
  const onClickMailVisible = useCallback(() => PubSub.publish('MailVisible'), []);
5446
5453
  const onClickPhoneVisible = useCallback(() => PubSub.publish('PhonenumberVisible'), []);
5447
5454
  const onClickPhoneValue = useCallback(() => PubSub.publish('PhonenumberCall'), []);
@@ -5594,7 +5601,7 @@ const BranchModal = ({ loading, connections, onClose }) => {
5594
5601
  React__default.createElement("p", null, "V\u00E4lj den anl\u00E4ggning du vill visa kontaktuppgifter f\u00F6r."))),
5595
5602
  React__default.createElement(RepeatTiny, null,
5596
5603
  React__default.createElement(InputLabel, null, "V\u00E4lj anl\u00E4ggning"),
5597
- React__default.createElement(InputSelect, { value: localValue, onChange: onChange, options: connections === null || connections === void 0 ? void 0 : connections.map((x) => ({
5604
+ React__default.createElement(InputSelect, { value: localValue, onChange: onChange, options: connections?.map((x) => ({
5598
5605
  value: x.id,
5599
5606
  displayName: x.name,
5600
5607
  })), title: "V\u00E4lj anl\u00E4ggning" }))),
@@ -5603,16 +5610,13 @@ const BranchModal = ({ loading, connections, onClose }) => {
5603
5610
  React__default.createElement(ButtonContent, null, "V\u00E4lj")))));
5604
5611
  };
5605
5612
 
5606
- const PackageOptionModal = ({ packageOption, onClose }) => {
5607
- var _a;
5608
- return (React__default.createElement(Modal, { title: packageOption.title || '', onClose: onClose },
5609
- packageOption.image && (React__default.createElement(Repeat, null,
5610
- React__default.createElement(LogoBox, { logo: packageOption.image, alt: packageOption.title || undefined, wide: true }))),
5611
- packageOption.description && (React__default.createElement(Repeat, null,
5612
- React__default.createElement(Content$2, { dangerouslySetInnerHTML: { __html: marked(packageOption.description) } }))),
5613
- ((_a = packageOption.link) === null || _a === void 0 ? void 0 : _a.href) && packageOption.link.title && (React__default.createElement(Repeat, null,
5614
- React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.href, target: "_blank", rel: "noopener noreferrer nofollow" }, packageOption.link.title)))));
5615
- };
5613
+ const PackageOptionModal = ({ packageOption, onClose }) => (React__default.createElement(Modal, { title: packageOption.title || '', onClose: onClose },
5614
+ packageOption.image && (React__default.createElement(Repeat, null,
5615
+ React__default.createElement(LogoBox, { logo: packageOption.image, alt: packageOption.title || undefined, wide: true }))),
5616
+ packageOption.description && (React__default.createElement(Repeat, null,
5617
+ React__default.createElement(Content$2, { dangerouslySetInnerHTML: { __html: marked(packageOption.description) } }))),
5618
+ packageOption.link?.href && packageOption.link.title && (React__default.createElement(Repeat, null,
5619
+ React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.href, target: "_blank", rel: "noopener noreferrer nofollow" }, packageOption.link.title)))));
5616
5620
 
5617
5621
  const CheckList = ({ manufacturer, packageOptions, ecommerce, branch, contact, toggleEcomModal, loadingCentralStorageVehicle, }) => {
5618
5622
  const [modalBranch, setModalBranch] = useState(false);
@@ -5626,45 +5630,45 @@ const CheckList = ({ manufacturer, packageOptions, ecommerce, branch, contact, t
5626
5630
  setModalBranch(false);
5627
5631
  }
5628
5632
  }, [branch, contact]);
5629
- const packageOption = manufacturer === null || manufacturer === void 0 ? void 0 : manufacturer.packageOption;
5633
+ const packageOption = manufacturer?.packageOption;
5630
5634
  return (React__default.createElement(React__default.Fragment, null,
5631
- modalBranch && (React__default.createElement(BranchModal, { loading: loadingCentralStorageVehicle, connections: branch === null || branch === void 0 ? void 0 : branch.connections, onClose: closeModalBranch })),
5635
+ modalBranch && (React__default.createElement(BranchModal, { loading: loadingCentralStorageVehicle, connections: branch?.connections, onClose: closeModalBranch })),
5632
5636
  modal && React__default.createElement(PackageOptionModal, { packageOption: modal, onClose: onClose }),
5633
5637
  React__default.createElement(Repeat, null,
5634
5638
  React__default.createElement(CheckMarkList, null,
5635
- (packageOption === null || packageOption === void 0 ? void 0 : packageOption.title) && (React__default.createElement(CheckMarkListItem, null,
5639
+ packageOption?.title && (React__default.createElement(CheckMarkListItem, null,
5636
5640
  React__default.createElement(React__default.Fragment, null,
5637
5641
  "Inkl.",
5638
5642
  ' ',
5639
5643
  React__default.createElement(ButtonInline, { onClick: () => onOpen({
5640
- title: packageOption === null || packageOption === void 0 ? void 0 : packageOption.title,
5641
- image: packageOption === null || packageOption === void 0 ? void 0 : packageOption.image,
5642
- description: packageOption === null || packageOption === void 0 ? void 0 : packageOption.description,
5643
- link: packageOption === null || packageOption === void 0 ? void 0 : packageOption.link,
5644
+ title: packageOption?.title,
5645
+ image: packageOption?.image,
5646
+ description: packageOption?.description,
5647
+ link: packageOption?.link,
5644
5648
  }) }, packageOption.title),
5645
5649
  ' ',
5646
- "begagnatgaranti"))), packageOptions === null || packageOptions === void 0 ? void 0 :
5647
- packageOptions.map((packageOption, index) => (React__default.createElement(CheckMarkListItem, { key: packageOption.title || index },
5650
+ "begagnatgaranti"))),
5651
+ packageOptions?.map((packageOption, index) => (React__default.createElement(CheckMarkListItem, { key: packageOption.title || index },
5648
5652
  React__default.createElement(React__default.Fragment, null,
5649
5653
  "Inkl.",
5650
5654
  ' ',
5651
5655
  React__default.createElement(ButtonInline, { onClick: () => onOpen({
5652
- title: packageOption === null || packageOption === void 0 ? void 0 : packageOption.title,
5653
- image: packageOption === null || packageOption === void 0 ? void 0 : packageOption.image,
5654
- description: packageOption === null || packageOption === void 0 ? void 0 : packageOption.description,
5655
- link: packageOption === null || packageOption === void 0 ? void 0 : packageOption.link,
5656
+ title: packageOption?.title,
5657
+ image: packageOption?.image,
5658
+ description: packageOption?.description,
5659
+ link: packageOption?.link,
5656
5660
  }) }, packageOption.title))))),
5657
- (ecommerce === null || ecommerce === void 0 ? void 0 : ecommerce.withHomeDelivery) && React__default.createElement(CheckMarkListItem, null, "Hemleverans"))),
5661
+ ecommerce?.withHomeDelivery && React__default.createElement(CheckMarkListItem, null, "Hemleverans"))),
5658
5662
  React__default.createElement(Repeat, null,
5659
5663
  ecommerce && ecommerce.enabled && (React__default.createElement(RepeatTiny, null,
5660
5664
  React__default.createElement(ButtonPrimary, { disabled: !!ecommerce.reserved, fullWidth: true, onClick: toggleEcomModal },
5661
5665
  React__default.createElement(ButtonContent, null, "K\u00F6p bilen online")))),
5662
- (ecommerce === null || ecommerce === void 0 ? void 0 : ecommerce.reserved) && (React__default.createElement(RepeatTiny, null,
5666
+ ecommerce?.reserved && (React__default.createElement(RepeatTiny, null,
5663
5667
  React__default.createElement(SwitchBar, { title: "Bilen \u00E4r reserverad", body: "Denna bil \u00E4r reserverad av en annan k\u00F6pare." },
5664
5668
  React__default.createElement(Content$2, null,
5665
5669
  React__default.createElement("p", null, "Denna bil \u00E4r reserverad av en annan k\u00F6pare."))))),
5666
5670
  React__default.createElement(ActionList, { branch: branch, contact: contact })),
5667
- ((branch === null || branch === void 0 ? void 0 : branch.connections.length) || 0) > 1 && (React__default.createElement(Repeat, null,
5671
+ (branch?.connections.length || 0) > 1 && (React__default.createElement(Repeat, null,
5668
5672
  React__default.createElement(SwitchBar, { title: "Centrallagerbil", actionTitle: "Byt anl\u00E4ggning", onClick: openModalBranch },
5669
5673
  React__default.createElement(Content$2, null,
5670
5674
  React__default.createElement("p", null, "Denna bil tillh\u00F6r ett centrallager och g\u00E5r att k\u00F6pa genom flera anl\u00E4ggningar. Byt anl\u00E4ggning f\u00F6r att visa kontaktuppgifter till just den anl\u00E4ggningen.")))))));
@@ -5776,7 +5780,7 @@ const useRelatedSearch = (id) => {
5776
5780
  const regexEndGuid = /[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/;
5777
5781
  const escapeRegExpString = (s) => s.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
5778
5782
  const regexPathGuid = (path) => {
5779
- if (!path) {
5783
+ if (!path || path) {
5780
5784
  return regexEndGuid;
5781
5785
  }
5782
5786
  const r = new RegExp(`${escapeRegExpString(path)}${regexEndGuid.source}`, 'gi');
@@ -5791,7 +5795,7 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
5791
5795
  onClickSearchItem(id);
5792
5796
  }
5793
5797
  }, []);
5794
- if (!(response === null || response === void 0 ? void 0 : response.documentList.documents.length) || (response === null || response === void 0 ? void 0 : response.documentList.documents.length) === 0) {
5798
+ if (!response?.documentList.documents.length || response?.documentList.documents.length === 0) {
5795
5799
  return null;
5796
5800
  }
5797
5801
  if (loading) {
@@ -5806,17 +5810,16 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
5806
5810
  React__default.createElement(H2, { noMargin: true }, "Senast inkomna")))),
5807
5811
  React__default.createElement(Repeat, null,
5808
5812
  React__default.createElement(OverflowGrid, null,
5809
- React__default.createElement(OverflowGridList, null, response === null || response === void 0 ? void 0 : response.documentList.documents.map((document) => {
5810
- var _a, _b, _c;
5813
+ React__default.createElement(OverflowGridList, null, response?.documentList.documents.map((document) => {
5811
5814
  const prefix = pathRoute ? `/${pathRoute}` : '/';
5812
- const r = regexPathGuid(pathRoute);
5815
+ const r = regexPathGuid();
5813
5816
  const pathRouteUrl = window.location.pathname === '/'
5814
5817
  ? `${prefix}${document._id}`
5815
5818
  : r.test(`${pathRoute}${id}`)
5816
- ? window.location.pathname.replace(r, `${pathRoute}${document._id}`)
5819
+ ? window.location.pathname.replace(r, document._id)
5817
5820
  : `${window.location.pathname}${prefix}${document._id}`;
5818
5821
  return (React__default.createElement(OverflowGridItem, { key: document._id },
5819
- React__default.createElement(ProductCard, { id: document._id, onClick: onItemClicked, title: document.title, href: pathRoute ? pathRouteUrl : hashRoute ? `#${document._id}` : undefined, image: (_c = (_b = (_a = document.featuredImage) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.url, description: document.shortDescription, uspList: [
5822
+ React__default.createElement(ProductCard, { id: document._id, onClick: onItemClicked, title: document.title, href: pathRoute ? pathRouteUrl : hashRoute ? `#${document._id}` : undefined, image: document.featuredImage?.files?.[0]?.url, description: document.shortDescription, uspList: [
5820
5823
  {
5821
5824
  title: document.modelYear,
5822
5825
  },
@@ -5839,20 +5842,17 @@ const PackageOptions = ({ packageOptions }) => {
5839
5842
  if (!packageOptions) {
5840
5843
  return null;
5841
5844
  }
5842
- return (React__default.createElement(React__default.Fragment, null, packageOptions.map((packageOption, index) => {
5843
- var _a;
5844
- return (React__default.createElement(ProductPageMainSection, { key: packageOption.title || index },
5845
- React__default.createElement(Repeat, null,
5846
- React__default.createElement(H2, { noMargin: true }, packageOption.title)),
5847
- packageOption.description && (React__default.createElement(Repeat, null,
5848
- React__default.createElement(Content$2, { dangerouslySetInnerHTML: { __html: marked(packageOption.description) } }))),
5849
- ((_a = packageOption.link) === null || _a === void 0 ? void 0 : _a.url) && (React__default.createElement(Repeat, null,
5850
- React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.url, target: "_blank", rel: "noopener noreferrer" }, packageOption.link.title
5851
- ? packageOption.link.title
5852
- : 'Läs mer (Öppnas i ett nytt fönster)'))),
5853
- packageOption.image && (React__default.createElement(Repeat, null,
5854
- React__default.createElement(LogoBox, { logo: packageOption.image, alt: "Logotyp", wide: true })))));
5855
- })));
5845
+ return (React__default.createElement(React__default.Fragment, null, packageOptions.map((packageOption, index) => (React__default.createElement(ProductPageMainSection, { key: packageOption.title || index },
5846
+ React__default.createElement(Repeat, null,
5847
+ React__default.createElement(H2, { noMargin: true }, packageOption.title)),
5848
+ packageOption.description && (React__default.createElement(Repeat, null,
5849
+ React__default.createElement(Content$2, { dangerouslySetInnerHTML: { __html: marked(packageOption.description) } }))),
5850
+ packageOption.link?.url && (React__default.createElement(Repeat, null,
5851
+ React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.url, target: "_blank", rel: "noopener noreferrer" }, packageOption.link.title
5852
+ ? packageOption.link.title
5853
+ : 'Läs mer (Öppnas i ett nytt fönster)'))),
5854
+ packageOption.image && (React__default.createElement(Repeat, null,
5855
+ React__default.createElement(LogoBox, { logo: packageOption.image, alt: "Logotyp", wide: true }))))))));
5856
5856
  };
5857
5857
 
5858
5858
  const TableColumn = styled.div `
@@ -5923,15 +5923,15 @@ const arr = [];
5923
5923
  const GetOpeningHours = (o) => KeyOrder.reduce((prev, current) => {
5924
5924
  const title = TranslateWeekDays(current);
5925
5925
  const item = o[current];
5926
- const previous = prev === null || prev === void 0 ? void 0 : prev[prev.length - 1];
5927
- if (previous && previous.from == (item === null || item === void 0 ? void 0 : item.from) && previous.until === (item === null || item === void 0 ? void 0 : item.until)) {
5926
+ const previous = prev?.[prev.length - 1];
5927
+ if (previous && previous.from == item?.from && previous.until === item?.until) {
5928
5928
  prev[prev.length - 1].titleTo = title;
5929
5929
  }
5930
5930
  else {
5931
5931
  prev.push({
5932
5932
  titleFrom: title,
5933
- from: item === null || item === void 0 ? void 0 : item.from,
5934
- until: item === null || item === void 0 ? void 0 : item.until,
5933
+ from: item?.from,
5934
+ until: item?.until,
5935
5935
  });
5936
5936
  }
5937
5937
  return prev;
@@ -5942,8 +5942,8 @@ const GetOpeningHoursToday = (o) => {
5942
5942
  const current = o[day];
5943
5943
  return {
5944
5944
  title: current ? 'Öppetider idag' : 'Stängt idag',
5945
- from: current === null || current === void 0 ? void 0 : current.from,
5946
- until: current === null || current === void 0 ? void 0 : current.until,
5945
+ from: current?.from,
5946
+ until: current?.until,
5947
5947
  };
5948
5948
  };
5949
5949
  const valuOfDateString = (s) => {
@@ -5954,7 +5954,7 @@ const OpeningHours = ({ openingHours }) => {
5954
5954
  const today = useMemo(() => (openingHours ? GetOpeningHoursToday(openingHours) : null), [openingHours]);
5955
5955
  const currentlyOpen = useMemo(() => {
5956
5956
  try {
5957
- if ((today === null || today === void 0 ? void 0 : today.from) && (today === null || today === void 0 ? void 0 : today.until)) {
5957
+ if (today?.from && today?.until) {
5958
5958
  const currentDate = new Date().valueOf();
5959
5959
  const from = valuOfDateString(today.from);
5960
5960
  const until = valuOfDateString(today.until);
@@ -5976,9 +5976,9 @@ const OpeningHours = ({ openingHours }) => {
5976
5976
  React__default.createElement(TableColumn, null,
5977
5977
  React__default.createElement(TableColumnRow, null,
5978
5978
  React__default.createElement(TableColumnCell, null,
5979
- React__default.createElement(UtilityTextBold, null, today === null || today === void 0 ? void 0 : today.title)),
5979
+ React__default.createElement(UtilityTextBold, null, today?.title)),
5980
5980
  React__default.createElement(TableColumnCell, null,
5981
- React__default.createElement(UtilityTextBold, null, (today === null || today === void 0 ? void 0 : today.from) ? `${today.from}-${today.until}` : 'Stängt'))),
5981
+ React__default.createElement(UtilityTextBold, null, today?.from ? `${today.from}-${today.until}` : 'Stängt'))),
5982
5982
  oh.map((o) => (React__default.createElement(TableColumnRow, { key: o.titleFrom },
5983
5983
  React__default.createElement(TableColumnCell, null, o.titleTo ? `${o.titleFrom}-${o.titleTo}` : o.titleFrom),
5984
5984
  React__default.createElement(TableColumnCell, null, o.from ? `${o.from}-${o.until}` : 'Stängt'))))))));
@@ -6047,7 +6047,6 @@ const StaticMap = ({ position }) => {
6047
6047
  };
6048
6048
 
6049
6049
  const Branch = ({ branch, loading }) => {
6050
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6051
6050
  const [modal, setModal] = useState(false);
6052
6051
  const openModal = useCallback(() => setModal(true), []);
6053
6052
  const closeModal = useCallback(() => setModal(false), []);
@@ -6060,14 +6059,14 @@ const Branch = ({ branch, loading }) => {
6060
6059
  return null;
6061
6060
  }
6062
6061
  return (React__default.createElement(React__default.Fragment, null,
6063
- modal && (React__default.createElement(BranchModal, { loading: loading, connections: branch === null || branch === void 0 ? void 0 : branch.connections, onClose: closeModal })),
6062
+ modal && (React__default.createElement(BranchModal, { loading: loading, connections: branch?.connections, onClose: closeModal })),
6064
6063
  React__default.createElement(Repeat, null,
6065
- React__default.createElement(H2, { noMargin: true }, ((_a = branch === null || branch === void 0 ? void 0 : branch.location) === null || _a === void 0 ? void 0 : _a.city)
6066
- ? `Den här bilen finns på vår anläggning i ${(_b = branch === null || branch === void 0 ? void 0 : branch.location) === null || _b === void 0 ? void 0 : _b.city}`
6064
+ React__default.createElement(H2, { noMargin: true }, branch?.location?.city
6065
+ ? `Den här bilen finns på vår anläggning i ${branch?.location?.city}`
6067
6066
  : 'Kontakt')),
6068
6067
  React__default.createElement(Repeat, null,
6069
- React__default.createElement(StaticMap, { position: (_c = branch === null || branch === void 0 ? void 0 : branch.location) === null || _c === void 0 ? void 0 : _c.position })),
6070
- (((_d = branch === null || branch === void 0 ? void 0 : branch.connections) === null || _d === void 0 ? void 0 : _d.length) || 0) > 1 && (React__default.createElement(Repeat, null,
6068
+ React__default.createElement(StaticMap, { position: branch?.location?.position })),
6069
+ (branch?.connections?.length || 0) > 1 && (React__default.createElement(Repeat, null,
6071
6070
  React__default.createElement(Content$2, null,
6072
6071
  React__default.createElement("p", null,
6073
6072
  "Denna bil tillh\u00F6r ett centrallager och g\u00E5r att k\u00F6pa genom flera anl\u00E4ggningar.",
@@ -6078,13 +6077,13 @@ const Branch = ({ branch, loading }) => {
6078
6077
  React__default.createElement(ProductPageContentLimit, null,
6079
6078
  React__default.createElement(Repeat, null,
6080
6079
  React__default.createElement(TableColumn, null,
6081
- ((_e = branch === null || branch === void 0 ? void 0 : branch.location) === null || _e === void 0 ? void 0 : _e.streetAddress) && ((_f = branch === null || branch === void 0 ? void 0 : branch.location) === null || _f === void 0 ? void 0 : _f.city) && (React__default.createElement(TableColumnRow, null,
6080
+ branch?.location?.streetAddress && branch?.location?.city && (React__default.createElement(TableColumnRow, null,
6082
6081
  React__default.createElement(TableColumnCell, null, "Adress"),
6083
6082
  React__default.createElement(TableColumnCell, null,
6084
6083
  React__default.createElement(ButtonInlineBold, null,
6085
- React__default.createElement(ButtonContent, null, `${(_g = branch === null || branch === void 0 ? void 0 : branch.location) === null || _g === void 0 ? void 0 : _g.streetAddress}, ${(_h = branch === null || branch === void 0 ? void 0 : branch.location) === null || _h === void 0 ? void 0 : _h.city}`))))),
6086
- ((_j = branch === null || branch === void 0 ? void 0 : branch.contact) === null || _j === void 0 ? void 0 : _j.phonenumber) && (React__default.createElement(PhoneNumber, { phoneNumber: formatPhonenumber(branch.contact.phonenumber) })))),
6087
- (branch === null || branch === void 0 ? void 0 : branch.openingHours) && (React__default.createElement(Repeat, null,
6084
+ React__default.createElement(ButtonContent, null, `${branch?.location?.streetAddress}, ${branch?.location?.city}`))))),
6085
+ branch?.contact?.phonenumber && (React__default.createElement(PhoneNumber, { phoneNumber: formatPhonenumber(branch.contact.phonenumber) })))),
6086
+ branch?.openingHours && (React__default.createElement(Repeat, null,
6088
6087
  React__default.createElement(OpeningHours, { openingHours: branch.openingHours })))))));
6089
6088
  };
6090
6089
 
@@ -6210,20 +6209,19 @@ const useSearchItemBranch = (id, branch) => useQuery(SEARCH_ITEM_BRANCH_QUERY, {
6210
6209
  });
6211
6210
 
6212
6211
  const useCentralStorage = (vehicle) => {
6213
- var _a, _b;
6214
6212
  const { centralStorageId, setCentralStorageId } = useContext(CentralStorageContext);
6215
- const connections = (_a = vehicle === null || vehicle === void 0 ? void 0 : vehicle.branch) === null || _a === void 0 ? void 0 : _a.connections;
6213
+ const connections = vehicle?.branch?.connections;
6216
6214
  const branchId = centralStorageId
6217
- ? (_b = connections === null || connections === void 0 ? void 0 : connections.find((x) => x.id === centralStorageId)) === null || _b === void 0 ? void 0 : _b.id
6215
+ ? connections?.find((x) => x.id === centralStorageId)?.id
6218
6216
  : undefined;
6219
- const { data, loading } = useSearchItemBranch(vehicle === null || vehicle === void 0 ? void 0 : vehicle.id, branchId);
6217
+ const { data, loading } = useSearchItemBranch(vehicle?.id, branchId);
6220
6218
  useEffect(() => {
6221
- if (((connections === null || connections === void 0 ? void 0 : connections.length) || 0) > 0) {
6219
+ if ((connections?.length || 0) > 0) {
6222
6220
  const match = centralStorageId
6223
- ? connections === null || connections === void 0 ? void 0 : connections.find((x) => x.id === centralStorageId)
6221
+ ? connections?.find((x) => x.id === centralStorageId)
6224
6222
  : undefined;
6225
6223
  if (!match) {
6226
- const first = connections === null || connections === void 0 ? void 0 : connections[0];
6224
+ const first = connections?.[0];
6227
6225
  if (first) {
6228
6226
  setCentralStorageId(first.id);
6229
6227
  }
@@ -6231,7 +6229,7 @@ const useCentralStorage = (vehicle) => {
6231
6229
  }
6232
6230
  }, [connections]);
6233
6231
  return {
6234
- vehicle: ((connections === null || connections === void 0 ? void 0 : connections.length) || 0) > 0 ? data === null || data === void 0 ? void 0 : data.vehicle : vehicle,
6232
+ vehicle: (connections?.length || 0) > 0 ? data?.vehicle : vehicle,
6235
6233
  loading,
6236
6234
  };
6237
6235
  };
@@ -6248,14 +6246,14 @@ const PageLoading = () => (React__default.createElement(Page, null,
6248
6246
 
6249
6247
  class PropertyTreeCreator {
6250
6248
  constructor(properties) {
6251
- this.propertiesWithCategory = (propertyKey) => { var _a; return !!((_a = this.properties[propertyKey].category) === null || _a === void 0 ? void 0 : _a.id); };
6249
+ this.propertiesWithCategory = (propertyKey) => !!this.properties[propertyKey].category?.id;
6252
6250
  this.propertiesWithoutCategory = (propertyKey) => !this.propertiesWithCategory(propertyKey);
6253
6251
  this.isList = (property) => property.type === PropertyTreeCreator.TEXT_LIST_TYPE;
6254
6252
  this.isNonList = (property) => !this.isList(property);
6255
- this.hasCategoryWithId = (propertyKey, categoryId) => { var _a; return ((_a = this.properties[propertyKey].category) === null || _a === void 0 ? void 0 : _a.id) === categoryId; };
6256
- this.propertiesWithSubCategory = (propertyKey) => { var _a, _b; return !!((_b = (_a = this.properties[propertyKey].category) === null || _a === void 0 ? void 0 : _a.subCategory) === null || _b === void 0 ? void 0 : _b.id); };
6253
+ this.hasCategoryWithId = (propertyKey, categoryId) => this.properties[propertyKey].category?.id === categoryId;
6254
+ this.propertiesWithSubCategory = (propertyKey) => !!this.properties[propertyKey].category?.subCategory?.id;
6257
6255
  this.propertiesWithoutSubCategory = (propertyKey) => !this.propertiesWithSubCategory(propertyKey);
6258
- this.hasSubCategoryWithId = (propertyKey, categoryId) => { var _a, _b; return ((_b = (_a = this.properties[propertyKey].category) === null || _a === void 0 ? void 0 : _a.subCategory) === null || _b === void 0 ? void 0 : _b.id) === categoryId; };
6256
+ this.hasSubCategoryWithId = (propertyKey, categoryId) => this.properties[propertyKey].category?.subCategory?.id === categoryId;
6259
6257
  this.properties = properties;
6260
6258
  }
6261
6259
  create() {
@@ -6322,7 +6320,7 @@ class PropertyTreeCreator {
6322
6320
  const categories = Object.keys(this.properties)
6323
6321
  .filter((key) => this.hasCategoryWithId(key, id))
6324
6322
  .filter(this.propertiesWithSubCategory)
6325
- .map((key) => { var _a; return (_a = this.properties[key].category) === null || _a === void 0 ? void 0 : _a.subCategory; })
6323
+ .map((key) => this.properties[key].category?.subCategory)
6326
6324
  .filter(PropertyTreeCreator.distinctCategories);
6327
6325
  return categories;
6328
6326
  }
@@ -6951,7 +6949,6 @@ const MetadataCategory = ({ properties, subCategories }) => (React__default.crea
6951
6949
  !!subCategories.length &&
6952
6950
  subCategories.map((subCategory, index) => (React__default.createElement(MetadataSubCategory, { name: subCategory.name, properties: subCategory.properties, key: `${subCategory.name}-${index}` })))));
6953
6951
  const PropertySet = ({ propertySet, vehicleData }) => {
6954
- var _a, _b;
6955
6952
  const [activeCategoryId, setActiveCategoryId] = useState(-1);
6956
6953
  const mappedProperties = useMemo(() => {
6957
6954
  if (!propertySet) {
@@ -6965,20 +6962,19 @@ const PropertySet = ({ propertySet, vehicleData }) => {
6965
6962
  return tree;
6966
6963
  }, [propertySet]);
6967
6964
  useEffect(() => {
6968
- var _a;
6969
- const categories = ((_a = mappedProperties === null || mappedProperties === void 0 ? void 0 : mappedProperties.categories) === null || _a === void 0 ? void 0 : _a.length) !== undefined ? mappedProperties === null || mappedProperties === void 0 ? void 0 : mappedProperties.categories : undefined;
6965
+ const categories = mappedProperties?.categories?.length !== undefined ? mappedProperties?.categories : undefined;
6970
6966
  if (activeCategoryId < 0 && categories !== undefined && categories.length > 0) {
6971
6967
  setActiveCategoryId(categories[0].id);
6972
6968
  }
6973
6969
  }, [mappedProperties]);
6974
6970
  const onTab = useCallback((id) => setActiveCategoryId(parseInt(id, 10)), []);
6975
- const activeCategory = (_a = mappedProperties === null || mappedProperties === void 0 ? void 0 : mappedProperties.categories) === null || _a === void 0 ? void 0 : _a.find((category) => category.id === activeCategoryId);
6971
+ const activeCategory = mappedProperties?.categories?.find((category) => category.id === activeCategoryId);
6976
6972
  return (React__default.createElement(React__default.Fragment, null,
6977
6973
  React__default.createElement(Repeat, null,
6978
- React__default.createElement(Tabs, { tabs: ((_b = mappedProperties === null || mappedProperties === void 0 ? void 0 : mappedProperties.categories) === null || _b === void 0 ? void 0 : _b.map((category) => ({
6974
+ React__default.createElement(Tabs, { tabs: mappedProperties?.categories?.map((category) => ({
6979
6975
  name: `${category.id}`,
6980
6976
  displayName: category.name,
6981
- }))) || [], active: `${activeCategoryId}`, onClick: onTab })),
6977
+ })) || [], active: `${activeCategoryId}`, onClick: onTab })),
6982
6978
  activeCategory && (React__default.createElement(Repeat, null,
6983
6979
  React__default.createElement(MetadataCategory, { properties: activeCategory.properties, subCategories: activeCategory.subCategories })))));
6984
6980
  };
@@ -7047,11 +7043,10 @@ const PdfDownloadItem = ({ document }) => (React__default.createElement(PdfListI
7047
7043
  const PdfDownloadContainer = ({ documents }) => (React__default.createElement(PdfContainer, null, documents.map((document, i) => (React__default.createElement(PdfDownloadItem, { key: `${document.url}-${i}`, document: document })))));
7048
7044
 
7049
7045
  const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, placeholderImage, modifyDocumentTitleItem, onClickSearchItem, }) => {
7050
- var _a, _b, _c;
7051
7046
  const { ecomSettings } = useSettings();
7052
7047
  const ecomContext = useRef();
7053
7048
  const { loading, data: result } = useSearchItem(id);
7054
- const { vehicle: centralStorageVehicle, loading: loadingCentralStorageVehicle } = useCentralStorage(result === null || result === void 0 ? void 0 : result.vehicle);
7049
+ const { vehicle: centralStorageVehicle, loading: loadingCentralStorageVehicle } = useCentralStorage(result?.vehicle);
7055
7050
  useEffect(() => {
7056
7051
  if (ecomSettings) {
7057
7052
  ecomContext.current = new WaykeEcomWeb({
@@ -7060,7 +7055,7 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7060
7055
  api: {
7061
7056
  address: ecomSettings.url,
7062
7057
  },
7063
- bankIdThumbprint: ecomSettings === null || ecomSettings === void 0 ? void 0 : ecomSettings.bankIdThumbprint,
7058
+ bankIdThumbprint: ecomSettings?.bankIdThumbprint,
7064
7059
  },
7065
7060
  logo: ecomSettings.serviceLogotypeUrl,
7066
7061
  logoX2: ecomSettings.serviceLogotypeUrl,
@@ -7081,26 +7076,25 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7081
7076
  }
7082
7077
  }, []);
7083
7078
  useEffect(() => {
7084
- var _a;
7085
- if (((_a = result === null || result === void 0 ? void 0 : result.vehicle) === null || _a === void 0 ? void 0 : _a.data) && modifyDocumentTitleItem) {
7079
+ if (result?.vehicle?.data && modifyDocumentTitleItem) {
7086
7080
  const { vehicle } = result;
7087
7081
  const { registrationNumber } = vehicle.data;
7088
7082
  document.title = `${registrationNumber} | ${vehicle.title} | ${vehicle.shortDescription}`;
7089
7083
  }
7090
7084
  }, [result]);
7091
- const options = useMemo(() => { var _a, _b, _c; return (_c = (_b = (_a = result === null || result === void 0 ? void 0 : result.vehicle) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.filter(notEmpty).map((opt) => ({ title: opt })); }, [(_b = (_a = result === null || result === void 0 ? void 0 : result.vehicle) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.options]);
7085
+ const options = useMemo(() => result?.vehicle?.data?.options?.filter(notEmpty).map((opt) => ({ title: opt })), [result?.vehicle?.data?.options]);
7092
7086
  const onShowMoreOptionsClick = useCallback(() => PubSub.publish('OptionsClick'), []);
7093
7087
  if (loading) {
7094
7088
  return React__default.createElement(PageLoading, null);
7095
7089
  }
7096
- if (!((_c = result === null || result === void 0 ? void 0 : result.vehicle) === null || _c === void 0 ? void 0 : _c.data)) {
7090
+ if (!result?.vehicle?.data) {
7097
7091
  return React__default.createElement(Page404, null);
7098
7092
  }
7099
7093
  const { vehicle } = result;
7100
- const contact = centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.contact;
7101
- const branch = centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.branch;
7094
+ const contact = centralStorageVehicle?.contact;
7095
+ const branch = centralStorageVehicle?.branch;
7102
7096
  const { title, shortDescription, media, description, price, financialOptions, manufacturer, ecommerce, packageOptions, publishedAt, documents, } = vehicle;
7103
- const insuranceOptions = (centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.insuranceOptions)
7097
+ const insuranceOptions = centralStorageVehicle?.insuranceOptions
7104
7098
  ? centralStorageVehicle.insuranceOptions
7105
7099
  : vehicle.insuranceOptions;
7106
7100
  const { fuelType, mileage, gearbox, modelYear, propertySet } = vehicle.data;
@@ -7131,7 +7125,7 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7131
7125
  React__default.createElement(ButtonContent, null,
7132
7126
  React__default.createElement(IconChevronLeft, { block: true })),
7133
7127
  React__default.createElement(ButtonContent, null, "Tillbaka till bils\u00F6k"))))) : null,
7134
- (manufacturer === null || manufacturer === void 0 ? void 0 : manufacturer.logotype) && (React__default.createElement(Repeat, null,
7128
+ manufacturer?.logotype && (React__default.createElement(Repeat, null,
7135
7129
  React__default.createElement(LogoBox, { logo: manufacturer.logotype, alt: manufacturer.name }))),
7136
7130
  React__default.createElement(Repeat, null,
7137
7131
  React__default.createElement(RepeatSmall, null,
@@ -7144,9 +7138,9 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7144
7138
  React__default.createElement(PriceTable, { price: price })),
7145
7139
  (financialOptions.length > 0 || insuranceOptions.length > 0) && (React__default.createElement(ProductPageAsideSection, { mobileOrder: 4 },
7146
7140
  financialOptions.length > 0 && (React__default.createElement(FinancialOptions, { id: id, financialOptions: financialOptions })),
7147
- insuranceOptions.length > 0 && (React__default.createElement(InsuranceOptions, { id: id, branch: centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.branch, insuranceOptions: insuranceOptions })))),
7141
+ insuranceOptions.length > 0 && (React__default.createElement(InsuranceOptions, { id: id, branch: centralStorageVehicle?.branch, insuranceOptions: insuranceOptions })))),
7148
7142
  React__default.createElement(ProductPageAsideSection, { mobileOrder: 5 },
7149
- React__default.createElement(CheckList, { manufacturer: manufacturer, packageOptions: packageOptions, ecommerce: ecommerce, branch: branch, contact: centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.contact, loadingCentralStorageVehicle: loadingCentralStorageVehicle, toggleEcomModal: () => { var _a; return (_a = ecomContext.current) === null || _a === void 0 ? void 0 : _a.start(); } }))),
7143
+ React__default.createElement(CheckList, { manufacturer: manufacturer, packageOptions: packageOptions, ecommerce: ecommerce, branch: branch, contact: centralStorageVehicle?.contact, loadingCentralStorageVehicle: loadingCentralStorageVehicle, toggleEcomModal: () => ecomContext.current?.start() }))),
7150
7144
  React__default.createElement(ProductPageMain, null,
7151
7145
  React__default.createElement(ProductPageAsideSection, { mobileOrder: 3 },
7152
7146
  React__default.createElement(Gallery, { media: media, placeholderImage: placeholderImage })),
@@ -7161,8 +7155,8 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7161
7155
  description && (React__default.createElement(ProductPageMainSection, null,
7162
7156
  React__default.createElement(Blockquote, { author: contact && contact.name ? contact.name : null, date: publishedAt
7163
7157
  ? dateTimeFormat.format(publishedAt, dateTimeFormat.DayMonth)
7164
- : undefined, avatar: (contact === null || contact === void 0 ? void 0 : contact.avatar) || undefined }, !!description && React__default.createElement("p", null, description)))),
7165
- ((options === null || options === void 0 ? void 0 : options.length) || 0) > 0 && (React__default.createElement(ProductPageMainSection, null,
7158
+ : undefined, avatar: contact?.avatar || undefined }, !!description && React__default.createElement("p", null, description)))),
7159
+ (options?.length || 0) > 0 && (React__default.createElement(ProductPageMainSection, null,
7166
7160
  React__default.createElement(Repeat, null,
7167
7161
  React__default.createElement(H2, { noMargin: true }, "Utrustning")),
7168
7162
  React__default.createElement(Repeat, null,
@@ -7182,9 +7176,9 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7182
7176
  React__default.createElement(ProductPageMainSection, null,
7183
7177
  React__default.createElement(Branch, { branch: branch, loading: loadingCentralStorageVehicle }),
7184
7178
  ecommerce && ecommerce.enabled && (React__default.createElement(Repeat, null,
7185
- React__default.createElement(ButtonPrimary, { disabled: !!ecommerce.reserved, title: "K\u00F6p bilen online", onClick: () => { var _a; return (_a = ecomContext.current) === null || _a === void 0 ? void 0 : _a.start(); } }, "K\u00F6p bilen online")))),
7179
+ React__default.createElement(ButtonPrimary, { disabled: !!ecommerce.reserved, title: "K\u00F6p bilen online", onClick: () => ecomContext.current?.start() }, "K\u00F6p bilen online")))),
7186
7180
  React__default.createElement(PackageOptions, { packageOptions: packageOptions }),
7187
- React__default.createElement(ManufacturerPackageOption, { packageOption: manufacturer === null || manufacturer === void 0 ? void 0 : manufacturer.packageOption }))))),
7181
+ React__default.createElement(ManufacturerPackageOption, { packageOption: manufacturer?.packageOption }))))),
7188
7182
  React__default.createElement(Related, { id: id, hashRoute: hashRoute, pathRoute: pathRoute, onClickSearchItem: onClickSearchItem })),
7189
7183
  false ,
7190
7184
  React__default.createElement(PortalElement, { id: DefaultPortal })));
@@ -7224,7 +7218,7 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7224
7218
  'x-api-key': apiKey,
7225
7219
  }
7226
7220
  : {},
7227
- }, !initialize || !!(queryFilter === null || queryFilter === void 0 ? void 0 : queryFilter.block));
7221
+ }, !initialize || !!queryFilter?.block);
7228
7222
  const popStateEvent = (event) => {
7229
7223
  const { currentTarget } = event;
7230
7224
  if (currentTarget) {
@@ -7267,7 +7261,7 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7267
7261
  const nextSearch = nextSearchParams.toString() ? `?${nextSearchParams}` : '';
7268
7262
  if (initialize) {
7269
7263
  if (window.location.search.localeCompare(nextSearch) !== 0) {
7270
- const _path = pathRoute === null || pathRoute === void 0 ? void 0 : pathRoute.replace(/^\/|\/$/g, '');
7264
+ const _path = pathRoute?.replace(/^\/|\/$/g, '');
7271
7265
  const prefix = _path ? `/${_path}/` : '/';
7272
7266
  const index = _path ? window.location.pathname.indexOf(prefix) : -1;
7273
7267
  let pathname = window.location.pathname;
@@ -7280,12 +7274,11 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7280
7274
  }
7281
7275
  }, [queryFilter, initialize, useQueryParamsFromUrl]);
7282
7276
  useEffect(() => {
7283
- var _a;
7284
7277
  if (response) {
7285
7278
  if (!initialFacets && !useQueryParamsFromUrl) {
7286
7279
  setInitialFacets(response.facets);
7287
7280
  }
7288
- if (useQueryParamsFromUrl && ((_a = response.query) === null || _a === void 0 ? void 0 : _a.parameters)) {
7281
+ if (useQueryParamsFromUrl && response.query?.parameters) {
7289
7282
  const nextSearchParams = new URLSearchParams(response.query.parameters);
7290
7283
  nextSearchParams.delete('hits');
7291
7284
  nextSearchParams.delete('offset');
@@ -7298,7 +7291,7 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7298
7291
  });
7299
7292
  }
7300
7293
  }
7301
- if (queryFilter === null || queryFilter === void 0 ? void 0 : queryFilter.concatResult) {
7294
+ if (queryFilter?.concatResult) {
7302
7295
  setDocuments([...(documents || []), ...(response.documentList.documents || [])]);
7303
7296
  }
7304
7297
  else {
@@ -7317,10 +7310,9 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7317
7310
  }
7318
7311
  }, [initialize]);
7319
7312
  const onLoadMore = useCallback(() => {
7320
- var _a;
7321
7313
  if (response) {
7322
7314
  setQueryFilter({
7323
- searchParams: new URLSearchParams((_a = response === null || response === void 0 ? void 0 : response.documentList.pagination.nextPage) === null || _a === void 0 ? void 0 : _a.query),
7315
+ searchParams: new URLSearchParams(response?.documentList.pagination.nextPage?.query),
7324
7316
  concatResult: true,
7325
7317
  });
7326
7318
  }
@@ -7333,9 +7325,8 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
7333
7325
  : _initialQueryParams;
7334
7326
  if (useQueryParamsFromUrl && _initialQueryParams) {
7335
7327
  _initialQueryParams.forEach((value, key) => {
7336
- var _a;
7337
- if (!((_a = initialQueryParams === null || initialQueryParams === void 0 ? void 0 : initialQueryParams.getAll(key)) === null || _a === void 0 ? void 0 : _a.some((v) => v === value))) {
7338
- initialQueryParams === null || initialQueryParams === void 0 ? void 0 : initialQueryParams.append(key, value);
7328
+ if (!initialQueryParams?.getAll(key)?.some((v) => v === value)) {
7329
+ initialQueryParams?.append(key, value);
7339
7330
  }
7340
7331
  });
7341
7332
  }
@@ -7397,7 +7388,7 @@ const SettingsProvider = ({ googleMapsApiKey, googleMapsMarker, ecomSettings, ch
7397
7388
 
7398
7389
  const RelatedSearchProvider = ({ url, urlMlt, apiKey, children }) => {
7399
7390
  const [queryFilter, setQueryFilter] = useState();
7400
- const query = queryFilter === null || queryFilter === void 0 ? void 0 : queryFilter.searchParams.toString();
7391
+ const query = queryFilter?.searchParams.toString();
7401
7392
  const { loading, data: response, error, } = useFetch(`${urlMlt || url}${query ? `?${query}` : ''}`, {
7402
7393
  headers: apiKey
7403
7394
  ? {
@@ -7502,7 +7493,7 @@ const PathProvider = ({ children }) => {
7502
7493
  }
7503
7494
  dispatch({ type: SET_PATH, path });
7504
7495
  }, []);
7505
- const id = useMemo(() => { var _a; return (_a = state.path.match(regexGuidAnyWhere)) === null || _a === void 0 ? void 0 : _a.pop(); }, [state.path]);
7496
+ const id = useMemo(() => state.path.match(regexGuidAnyWhere)?.pop(), [state.path]);
7506
7497
  const value = useMemo(() => ({
7507
7498
  ...state,
7508
7499
  previousPath,