@sledge-app/react-instant-search 1.0.74 → 1.0.75

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.
@@ -1,5 +1,5 @@
1
- import { j as jsxRuntimeExports, $ as $cb5cc270b50c6fcd$export$be92b6f5f03c0fe9, a as $cb5cc270b50c6fcd$export$41fb9f06171c75f4, b as $cb5cc270b50c6fcd$export$602eac185826482c, c as $cb5cc270b50c6fcd$export$7c6e2c02157bb7d2, d as $cb5cc270b50c6fcd$export$f39c2d165cd861fe, e as $cb5cc270b50c6fcd$export$21b07c8f274aebd5, f as $67824d98245208a0$export$be92b6f5f03c0fe9, g as $67824d98245208a0$export$adb584737d712b70, h as $e698a72e93240346$export$be92b6f5f03c0fe9, i as $e698a72e93240346$export$adb584737d712b70, k as $faa2e61a3361514f$export$be92b6f5f03c0fe9, l as $faa2e61a3361514f$export$13921ac0cc260818, m as $faa2e61a3361514f$export$9a58ef0d7ad3278c, n as $faa2e61a3361514f$export$6521433ed15a34db, o as $f99a8c78507165f7$export$be92b6f5f03c0fe9, p as $f99a8c78507165f7$export$6d08773d2e66f8f2, q as $f99a8c78507165f7$export$adb584737d712b70, r as $cc7e05a45900e73f$export$6d08773d2e66f8f2, s as $cc7e05a45900e73f$export$d6e5bf9c43ea9319, t as $cc7e05a45900e73f$export$c3468e2714d175fa, u as $cc7e05a45900e73f$export$be92b6f5f03c0fe9, v as $cc7e05a45900e73f$export$41fb9f06171c75f4, w as $cc7e05a45900e73f$export$4c8d1a57a761ef94, x as $cc7e05a45900e73f$export$f04a61298a47a40f, y as $cc7e05a45900e73f$export$602eac185826482c, z as $cc7e05a45900e73f$export$7c6e2c02157bb7d2, A as $cc7e05a45900e73f$export$2f60d3ec9ad468f2, B as $cc7e05a45900e73f$export$d5c6c08dc2d3ca7, C as $cc7e05a45900e73f$export$bf1aedc3039c8d63, D as motion, E as client, F as $a093c7e1ec25a057$export$2881499e37b75b9a, G as $a093c7e1ec25a057$export$be92b6f5f03c0fe9, H as $a093c7e1ec25a057$export$41fb9f06171c75f4, I as $a093c7e1ec25a057$export$602eac185826482c, J as $a093c7e1ec25a057$export$7c6e2c02157bb7d2, K as $a093c7e1ec25a057$export$21b07c8f274aebd5, L as $57acba87d6e25586$export$be92b6f5f03c0fe9, M as $57acba87d6e25586$export$d5c6c08dc2d3ca7, N as $57acba87d6e25586$export$9a4e88b92edfce6b, O as $57acba87d6e25586$export$6521433ed15a34db, P as MasonryResponsive, Q as Masonry, R as useEmblaCarousel, W as WindowScroller, S as List, T as $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9, U as $5d3850c4d0b4e6c7$export$602eac185826482c, V as $5d3850c4d0b4e6c7$export$c6fdb837b070b4ff, X as $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2 } from "./vendor-4bab83cd.js";
2
- import React__default, { createElement, useState } from "react";
1
+ import { j as jsxRuntimeExports, $ as $cb5cc270b50c6fcd$export$be92b6f5f03c0fe9, a as $cb5cc270b50c6fcd$export$41fb9f06171c75f4, b as $cb5cc270b50c6fcd$export$602eac185826482c, c as $cb5cc270b50c6fcd$export$7c6e2c02157bb7d2, d as $cb5cc270b50c6fcd$export$f39c2d165cd861fe, e as $cb5cc270b50c6fcd$export$21b07c8f274aebd5, f as $67824d98245208a0$export$be92b6f5f03c0fe9, g as $67824d98245208a0$export$adb584737d712b70, h as $e698a72e93240346$export$be92b6f5f03c0fe9, i as $e698a72e93240346$export$adb584737d712b70, k as $faa2e61a3361514f$export$be92b6f5f03c0fe9, l as $faa2e61a3361514f$export$13921ac0cc260818, m as $faa2e61a3361514f$export$9a58ef0d7ad3278c, n as $faa2e61a3361514f$export$6521433ed15a34db, o as $f99a8c78507165f7$export$be92b6f5f03c0fe9, p as $f99a8c78507165f7$export$6d08773d2e66f8f2, q as $f99a8c78507165f7$export$adb584737d712b70, r as $cc7e05a45900e73f$export$6d08773d2e66f8f2, s as $cc7e05a45900e73f$export$d6e5bf9c43ea9319, t as $cc7e05a45900e73f$export$c3468e2714d175fa, u as $cc7e05a45900e73f$export$be92b6f5f03c0fe9, v as $cc7e05a45900e73f$export$41fb9f06171c75f4, w as $cc7e05a45900e73f$export$4c8d1a57a761ef94, x as $cc7e05a45900e73f$export$f04a61298a47a40f, y as $cc7e05a45900e73f$export$602eac185826482c, z as $cc7e05a45900e73f$export$7c6e2c02157bb7d2, A as $cc7e05a45900e73f$export$2f60d3ec9ad468f2, B as $cc7e05a45900e73f$export$d5c6c08dc2d3ca7, C as $cc7e05a45900e73f$export$bf1aedc3039c8d63, D as motion, E as client, F as $a093c7e1ec25a057$export$2881499e37b75b9a, G as $a093c7e1ec25a057$export$be92b6f5f03c0fe9, H as $a093c7e1ec25a057$export$41fb9f06171c75f4, I as $a093c7e1ec25a057$export$602eac185826482c, J as $a093c7e1ec25a057$export$7c6e2c02157bb7d2, K as $a093c7e1ec25a057$export$21b07c8f274aebd5, L as $57acba87d6e25586$export$be92b6f5f03c0fe9, M as $57acba87d6e25586$export$d5c6c08dc2d3ca7, N as $57acba87d6e25586$export$9a4e88b92edfce6b, O as $57acba87d6e25586$export$6521433ed15a34db, P as MasonryResponsive, Q as Masonry, R as useEmblaCarousel, S as useVirtualizer, T as $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9, U as $5d3850c4d0b4e6c7$export$602eac185826482c, V as $5d3850c4d0b4e6c7$export$c6fdb837b070b4ff, W as $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2 } from "./vendor-dc719d80.js";
2
+ import React__default, { createElement } from "react";
3
3
  import { SledgeContext } from "@sledge-app/core";
4
4
  import "react-dom";
5
5
  const ProductFilterWidget = (props) => {
@@ -724,16 +724,16 @@ const Pagination = (props) => {
724
724
  ] });
725
725
  };
726
726
  const RadioGroup$1 = "";
727
- const rowRenderer = ({ virtualized, item, id, labelStyle, useVirtualized }) => {
728
- const { index, key = "", style = {} } = virtualized || {};
727
+ const rowRenderer = ({ virtualized, item, id, labelStyle }) => {
728
+ const { index, key = "" } = virtualized || {};
729
729
  const { label, value } = item;
730
730
  const content = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
731
731
  /* @__PURE__ */ jsxRuntimeExports.jsx($f99a8c78507165f7$export$6d08773d2e66f8f2, { className: "sledge__radio-group-item", value, id: `${id}${index}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx($f99a8c78507165f7$export$adb584737d712b70, { className: "sledge__radio-group-indicator" }) }),
732
732
  /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "sledge__radio-group-label", htmlFor: `${id}${index}`, style: labelStyle, children: label })
733
733
  ] });
734
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__radio-group-item-flex", style, children: content }, key || index);
734
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__radio-group-item-flex", children: content }, key || index);
735
735
  };
736
- const RadioGroup = ({ id, name, required, defaultValue, items, labelStyle = {}, onValueChange, scrollElement, useVirtualized = false }) => {
736
+ const RadioGroup = ({ id, name, required, defaultValue, items, labelStyle = {}, onValueChange, useVirtualized = false, scrollElementRef }) => {
737
737
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__radio-group-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx("form", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
738
738
  $f99a8c78507165f7$export$be92b6f5f03c0fe9,
739
739
  {
@@ -747,22 +747,17 @@ const RadioGroup = ({ id, name, required, defaultValue, items, labelStyle = {},
747
747
  children: useVirtualized ? /* @__PURE__ */ jsxRuntimeExports.jsx(
748
748
  VirtualizedList,
749
749
  {
750
- ...scrollElement && {
751
- scrollElement
752
- },
753
750
  rowCount: items == null ? void 0 : items.length,
754
- rowHeight: 36,
755
- rowRenderer: ({ index, key, style }) => rowRenderer({
751
+ rowRenderer: ({ index, key }) => rowRenderer({
756
752
  virtualized: {
757
753
  index,
758
- key,
759
- style
754
+ key
760
755
  },
761
756
  item: items[index],
762
757
  id,
763
- labelStyle,
764
- useVirtualized
765
- })
758
+ labelStyle
759
+ }),
760
+ scrollElementRef
766
761
  }
767
762
  ) : items.map(
768
763
  (item, index) => rowRenderer({
@@ -771,8 +766,7 @@ const RadioGroup = ({ id, name, required, defaultValue, items, labelStyle = {},
771
766
  },
772
767
  item,
773
768
  id,
774
- labelStyle,
775
- useVirtualized
769
+ labelStyle
776
770
  })
777
771
  )
778
772
  }
@@ -2815,10 +2809,14 @@ const ProductCard = (props) => {
2815
2809
  } = (variants == null ? void 0 : variants.length) ? variants[0] : {};
2816
2810
  const defaultSelectedVariantId = variant_admin_graphql_api_id ? variant_admin_graphql_api_id : "";
2817
2811
  const defaultSelectedVariantStock = (variants == null ? void 0 : variants.length) && Object.hasOwn(variants[0], "inventory_quantity") ? variants[0].inventory_quantity : 0;
2812
+ const defaultSelectedVariantInventoryManagement = (variants == null ? void 0 : variants.length) && Object.hasOwn(variants[0], "inventory_management") ? variants[0].inventory_management : null;
2813
+ const defaultSelectedVariantInventoryPolicy = (variants == null ? void 0 : variants.length) && Object.hasOwn(variants[0], "inventory_policy") ? variants[0].inventory_policy : "";
2818
2814
  const [selectedVariantId, setSelectedVariantId] = React__default.useState(defaultSelectedVariantId);
2819
2815
  const [selectedVariantStock, setSelectedVariantStock] = React__default.useState(defaultSelectedVariantStock);
2816
+ const [selectedVariantInventoryManagement, setSelectedVariantInventoryManagement] = React__default.useState(defaultSelectedVariantInventoryManagement);
2817
+ const [selectedVariantInventoryPolicy, setSelectedVariantInventoryPolicy] = React__default.useState(defaultSelectedVariantInventoryPolicy);
2820
2818
  let isLoadingAddToCart = clickedAddToCartId == selectedVariantId;
2821
- let isOutOfStock = (variants == null ? void 0 : variants.length) && Object.hasOwn(variants[0], "inventory_quantity") ? !Number(selectedVariantStock) && showOptionOutOfStock : false;
2819
+ let isOutOfStock = showOptionOutOfStock ? !Boolean(selectedVariantStock > 0 || selectedVariantInventoryManagement === null || selectedVariantInventoryPolicy === "continue") : false;
2822
2820
  let isOnSale = parseFloat(String(compare_at_price)) ? parseFloat(String(compare_at_price)) > parseFloat(String(price)) : false;
2823
2821
  const { money_format } = generalDataSettings || {};
2824
2822
  let component = null;
@@ -2828,10 +2826,12 @@ const ProductCard = (props) => {
2828
2826
  ...product,
2829
2827
  ...{
2830
2828
  variants: variants.map((variant, index) => {
2831
- const { inventory_quantity } = variant || {};
2829
+ const isInventoryQuantity = Object.hasOwn(variants[index], "inventory_quantity") ? variants[index].inventory_quantity > 0 : false;
2830
+ const isInventoryManagement = Object.hasOwn(variants[index], "inventory_management") ? variants[index].inventory_management === null : false;
2831
+ const isInventoryPolicy = Object.hasOwn(variants[index], "inventory_policy") ? variants[index].inventory_policy === "continue" : false;
2832
2832
  return {
2833
2833
  ...variant,
2834
- is_out_of_stock: Object.hasOwn(variants[index], "inventory_quantity") ? !inventory_quantity : false
2834
+ is_out_of_stock: !Boolean(isInventoryQuantity || isInventoryManagement || isInventoryPolicy)
2835
2835
  };
2836
2836
  })
2837
2837
  },
@@ -2859,6 +2859,8 @@ const ProductCard = (props) => {
2859
2859
  }
2860
2860
  defaultSelected["data-variant-id"] = variants[0].admin_graphql_api_id;
2861
2861
  defaultSelected["data-inventory-quantity"] = variants[0].inventory_quantity;
2862
+ defaultSelected["data-inventory-management"] = variants[0].inventory_management;
2863
+ defaultSelected["data-inventory-policy"] = variants[0].inventory_policy;
2862
2864
  }, setSelectedOption = function(element, optionName) {
2863
2865
  const optionsButton = element.target.offsetParent.querySelector(`.options-button-${stringToSlug(optionName)}`).querySelectorAll(`button`);
2864
2866
  const defaultSelectedClassChanger = () => {
@@ -2884,7 +2886,7 @@ const ProductCard = (props) => {
2884
2886
  defaultSelectedClassChanger();
2885
2887
  }
2886
2888
  }, setSelectedVariant = function(element, value, optionIndex) {
2887
- var _a2, _b2;
2889
+ var _a2, _b2, _c2, _d;
2888
2890
  const parentCard = element.target.offsetParent;
2889
2891
  const selectedInput = parentCard.querySelector(`.sledge__product-grid-card-selected-option[data-product-id='${id}']`);
2890
2892
  const setOptionAttribute = () => {
@@ -2897,13 +2899,21 @@ const ProductCard = (props) => {
2897
2899
  const variantId = selectOption.attributes["data-graphql-id"].value;
2898
2900
  const imageId = (_a2 = selectOption.attributes["data-image-id"]) == null ? void 0 : _a2.value;
2899
2901
  const inventoryQuantity = (_b2 = selectOption.attributes["data-inventory-quantity"]) == null ? void 0 : _b2.value;
2902
+ const inventoryManagement = (_c2 = selectOption.attributes["data-inventory-management"]) == null ? void 0 : _c2.value;
2903
+ const inventoryPolicy = (_d = selectOption.attributes["data-inventory-policy"]) == null ? void 0 : _d.value;
2900
2904
  const setOther = () => {
2901
2905
  selectedInput.attributes[`data-variant-id`].value = selectOption.attributes["data-graphql-id"].value;
2902
2906
  selectedInput.attributes[`data-inventory-quantity`].value = inventoryQuantity;
2907
+ selectedInput.attributes[`data-inventory-management`].value = inventoryManagement;
2908
+ selectedInput.attributes[`data-inventory-policy`].value = inventoryPolicy;
2903
2909
  if (variantId)
2904
2910
  setSelectedVariantId(variantId);
2905
2911
  if (inventoryQuantity)
2906
2912
  setSelectedVariantStock(inventoryQuantity);
2913
+ if (inventoryManagement)
2914
+ setSelectedVariantInventoryManagement(inventoryManagement);
2915
+ if (inventoryPolicy)
2916
+ setSelectedVariantInventoryPolicy(inventoryPolicy);
2907
2917
  if (imageId)
2908
2918
  parentCard.querySelector(`img.sledge__product-grid-card-image-featured-image`).src = parentCard.querySelector(
2909
2919
  `div.sledge__product-grid-card-variant-images img[id="${imageId}"]`
@@ -3046,11 +3056,13 @@ const ProductCard = (props) => {
3046
3056
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-variant-swatch", children: [
3047
3057
  /* @__PURE__ */ jsxRuntimeExports.jsx("input", { type: "hidden", ...defaultSelected, className: "sledge__product-grid-card-selected-option" }),
3048
3058
  /* @__PURE__ */ jsxRuntimeExports.jsx("select", { className: "variant-picker sledge__product-grid-card-variant-picker", children: variants == null ? void 0 : variants.map((variant) => {
3049
- const { title: title2, option1, option2, position, id: id2, admin_graphql_api_id, image_id, inventory_quantity } = variant;
3059
+ const { title: title2, option1, option2, position, id: id2, admin_graphql_api_id, image_id, inventory_quantity, inventory_management, inventory_policy } = variant;
3050
3060
  let optionAttributes = {
3051
3061
  "data-option-1": option1,
3052
3062
  "data-option-2": option2,
3053
3063
  "data-inventory-quantity": inventory_quantity,
3064
+ "data-inventory-management": inventory_management,
3065
+ "data-inventory-policy": inventory_policy,
3054
3066
  "data-position": position,
3055
3067
  "data-id": id2,
3056
3068
  "data-graphql-id": admin_graphql_api_id,
@@ -3727,37 +3739,35 @@ const FlyoutSidebar = ({ title, content, open, setOpen }) => {
3727
3739
  }
3728
3740
  );
3729
3741
  };
3730
- const getElement = ({ selector, setUsedScrollElement }) => {
3731
- const element = document.querySelector(selector);
3732
- if (!element)
3733
- setTimeout(() => {
3734
- getElement({ selector, setUsedScrollElement });
3735
- }, 1e3);
3736
- else
3737
- setUsedScrollElement(element);
3738
- };
3739
- const VirtualizedList = ({ selector, scrollElement, rowCount, rowHeight, rowRenderer: rowRenderer2, minHeight = 72 }) => {
3740
- const [usedScrollElement, setUsedScrollElement] = useState(scrollElement);
3741
- if (!usedScrollElement && selector)
3742
- getElement({ selector, setUsedScrollElement });
3742
+ const VirtualizedList = ({ rowCount, rowRenderer: rowRenderer2, scrollElementRef }) => {
3743
+ var _a;
3744
+ const virtualizer = useVirtualizer({
3745
+ count: rowCount,
3746
+ getScrollElement: () => scrollElementRef.current,
3747
+ estimateSize: () => 45
3748
+ });
3749
+ const items = virtualizer.getVirtualItems();
3743
3750
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
3744
- WindowScroller,
3751
+ "div",
3745
3752
  {
3746
- ...usedScrollElement && {
3747
- scrollElement: usedScrollElement
3753
+ style: {
3754
+ height: virtualizer.getTotalSize(),
3755
+ width: "100%",
3756
+ position: "relative"
3748
3757
  },
3749
- children: ({ width, height, isScrolling, onChildScroll, scrollTop }) => /* @__PURE__ */ jsxRuntimeExports.jsx(
3750
- List,
3758
+ className: "sledge__virtualized-wrapper",
3759
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3760
+ "div",
3751
3761
  {
3752
- autoHeight: true,
3753
- height: height || minHeight,
3754
- isScrolling,
3755
- onScroll: onChildScroll,
3756
- scrollTop,
3757
- width,
3758
- rowCount,
3759
- rowHeight,
3760
- rowRenderer: rowRenderer2
3762
+ style: {
3763
+ position: "absolute",
3764
+ top: 0,
3765
+ left: 0,
3766
+ width: "100%",
3767
+ transform: `translateY(${((_a = items[0]) == null ? void 0 : _a.start) ?? 0}px)`
3768
+ },
3769
+ className: "sledge__virtualized-list",
3770
+ children: items.map((virtualRow) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-index": virtualRow.index, ref: virtualizer.measureElement, className: "sledge__virtualized-measure-element", children: rowRenderer2(virtualRow) }, virtualRow.key))
3761
3771
  }
3762
3772
  )
3763
3773
  }
@@ -3897,6 +3907,7 @@ const SearchViewMoreResult = ({
3897
3907
  showPopupComponent,
3898
3908
  setShowPopupComponent,
3899
3909
  urlSearchResult = "",
3910
+ redirectObjectDirection = "",
3900
3911
  query,
3901
3912
  languageSettings
3902
3913
  }) => {
@@ -3908,11 +3919,18 @@ const SearchViewMoreResult = ({
3908
3919
  if (triggerRenderInstantSearchResult)
3909
3920
  triggerRenderInstantSearchResult(value);
3910
3921
  };
3911
- const ComponentProps = { keyword, showPopupComponent, setShowPopupComponent, setRenderSearchResult };
3922
+ const ComponentProps = { keyword, showPopupComponent, setShowPopupComponent, setRenderSearchResult, redirectObjectDirection };
3912
3923
  return /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: isComponentJsVersion ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: Component({ ...ComponentProps }) } }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Component, { ...ComponentProps }) });
3913
3924
  } else {
3914
3925
  const queryKeyword = (query == null ? void 0 : query.keyword) ? query.keyword : DEFAULT_QUERY_PARAM.KEYWORD;
3915
- return /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: `${urlSearchResult || DEFAULT_SEARCH_RESULT_URL}?${queryKeyword}=${keyword}`, className: "sledge-instant-search__icon-widget-button-more", children: (languageSettings == null ? void 0 : languageSettings.view_more_result) || "View More Result" });
3926
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
3927
+ "a",
3928
+ {
3929
+ href: redirectObjectDirection ? redirectObjectDirection : `${urlSearchResult || DEFAULT_SEARCH_RESULT_URL}?${queryKeyword}=${keyword}`,
3930
+ className: "sledge-instant-search__icon-widget-button-more",
3931
+ children: (languageSettings == null ? void 0 : languageSettings.view_more_result) || "View More Result"
3932
+ }
3933
+ );
3916
3934
  }
3917
3935
  };
3918
3936
  const Global = {
@@ -3935,6 +3953,9 @@ const SearchIconWidgetPopup = () => {
3935
3953
  const [suggestionIndex, setSuggestionIndex] = React__default.useState("");
3936
3954
  const [urlSearchResult, setUrlSearchResult] = React__default.useState("");
3937
3955
  const [languageSettings, setLanguageSettings] = React__default.useState({});
3956
+ const [redirectsSettings, setRedirectsSettings] = React__default.useState([]);
3957
+ const [redirectObject, setRedirectObject] = React__default.useState({});
3958
+ const [isRedirect, setIsRedirect] = React__default.useState(false);
3938
3959
  const [handleFunctions, setHandleFunctions] = React__default.useState({
3939
3960
  onAfterAddToCart: (state) => {
3940
3961
  },
@@ -3953,12 +3974,20 @@ const SearchIconWidgetPopup = () => {
3953
3974
  });
3954
3975
  const searchFieldRef = React__default.useRef(null);
3955
3976
  const previousState = usePrevious({ keyword });
3977
+ const { direction: redirectObjectDirection } = redirectObject || {};
3956
3978
  const handleMultiSearch = async (params) => {
3957
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2;
3979
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2;
3958
3980
  const { data, onSearch = false, withFetchReviewInfo = false } = params;
3981
+ const valueRedirectObject = redirectsSettings.find(({ keyword: redirectKeyword }) => {
3982
+ var _a3;
3983
+ return ((_a3 = String(redirectKeyword)) == null ? void 0 : _a3.toLowerCase()) === keyword;
3984
+ });
3985
+ const valueIsRedirect = Boolean((_a2 = valueRedirectObject == null ? void 0 : valueRedirectObject.direction) == null ? void 0 : _a2.length);
3986
+ setRedirectObject(valueRedirectObject);
3987
+ setIsRedirect(valueIsRedirect);
3959
3988
  setIsLoading(true);
3960
3989
  const { index_product, tabs, hidden_tags, display, show_out_of_stock } = data;
3961
- const suggestion = ((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion) || {};
3990
+ const suggestion = ((_b2 = display == null ? void 0 : display.search) == null ? void 0 : _b2.suggestion) || {};
3962
3991
  let response;
3963
3992
  let body = {
3964
3993
  queries: tabs.map((tab) => {
@@ -3985,10 +4014,10 @@ const SearchIconWidgetPopup = () => {
3985
4014
  if (onSearch && (keyword == null ? void 0 : keyword.length)) {
3986
4015
  searchTrigger({
3987
4016
  keyword,
3988
- resultCount: ((_b2 = valueSearchResultProduct[0]) == null ? void 0 : _b2.totalHits) || 0
4017
+ resultCount: ((_c2 = valueSearchResultProduct[0]) == null ? void 0 : _c2.totalHits) || 0
3989
4018
  });
3990
4019
  }
3991
- let valueSearchResultOther = ((_c2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(index_product)))) == null ? void 0 : _c2.map((result) => {
4020
+ let valueSearchResultOther = ((_d2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(index_product)))) == null ? void 0 : _d2.map((result) => {
3992
4021
  const { indexUid } = result;
3993
4022
  const { name, type } = tabs == null ? void 0 : tabs.find(({ index }) => index.includes(indexUid));
3994
4023
  return {
@@ -3999,16 +4028,16 @@ const SearchIconWidgetPopup = () => {
3999
4028
  }
4000
4029
  };
4001
4030
  })) || [];
4002
- let getValueSearchResultProduct = (valueSearchResultProduct == null ? void 0 : valueSearchResultProduct.length) ? (_d2 = valueSearchResultProduct[0]) == null ? void 0 : _d2.hits : [];
4031
+ let getValueSearchResultProduct = (valueSearchResultProduct == null ? void 0 : valueSearchResultProduct.length) ? (_e2 = valueSearchResultProduct[0]) == null ? void 0 : _e2.hits : [];
4003
4032
  let valueSuggestionIndex = !keyword.length ? "zero_character" : !(getValueSearchResultProduct == null ? void 0 : getValueSearchResultProduct.length) ? "no_result" : "";
4004
4033
  let isPriorityZeroCharacter = Boolean(
4005
- !keyword.length && Object.keys(suggestion).length && ((_f2 = (_e2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _e2.products) == null ? void 0 : _f2.active) && ((_i2 = (_h2 = (_g2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _g2.products) == null ? void 0 : _h2.list) == null ? void 0 : _i2.length)
4034
+ !keyword.length && Object.keys(suggestion).length && ((_g2 = (_f2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _f2.products) == null ? void 0 : _g2.active) && ((_j2 = (_i2 = (_h2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _h2.products) == null ? void 0 : _i2.list) == null ? void 0 : _j2.length)
4006
4035
  );
4007
- let dataSearchResultProduct = isPriorityZeroCharacter ? (_k2 = (_j2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _j2.products) == null ? void 0 : _k2.list : getValueSearchResultProduct;
4036
+ let dataSearchResultProduct = isPriorityZeroCharacter ? (_l2 = (_k2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _k2.products) == null ? void 0 : _l2.list : getValueSearchResultProduct;
4008
4037
  if (withFetchReviewInfo) {
4009
4038
  let searchResultProductIds = dataSearchResultProduct.map(({ id }) => id);
4010
4039
  let valueDataReviews = await getProductsReviewInfo(searchResultProductIds);
4011
- if (((_l2 = valueDataReviews == null ? void 0 : valueDataReviews.status) == null ? void 0 : _l2.code) === 200)
4040
+ if (((_m2 = valueDataReviews == null ? void 0 : valueDataReviews.status) == null ? void 0 : _m2.code) === 200)
4012
4041
  setDataReviews(valueDataReviews == null ? void 0 : valueDataReviews.data);
4013
4042
  } else {
4014
4043
  setDataReviews({});
@@ -4024,10 +4053,11 @@ const SearchIconWidgetPopup = () => {
4024
4053
  response = JSON.parse(LOCAL_STORAGE_INSTANT_SEARCH_SETTING);
4025
4054
  if (!response)
4026
4055
  return;
4027
- const { display, languages } = response;
4056
+ const { display, languages, redirects } = response;
4028
4057
  setDisplaySettings(display);
4029
4058
  setSuggestionSettings((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion);
4030
4059
  setLanguageSettings(languages);
4060
+ setRedirectsSettings(redirects);
4031
4061
  await handleMultiSearch({
4032
4062
  data: response,
4033
4063
  withFetchReviewInfo: true
@@ -4109,7 +4139,7 @@ const SearchIconWidgetPopup = () => {
4109
4139
  if (event.key === "Enter") {
4110
4140
  const query = handleFunctions.query;
4111
4141
  const queryKeyword = (query == null ? void 0 : query.keyword) ? query.keyword : DEFAULT_QUERY_PARAM.KEYWORD;
4112
- const urlToSearchResult = `${urlSearchResult || DEFAULT_SEARCH_RESULT_URL}?${queryKeyword}=${keyword}`;
4142
+ const urlToSearchResult = isRedirect ? redirectObjectDirection : `${urlSearchResult || DEFAULT_SEARCH_RESULT_URL}?${queryKeyword}=${keyword}`;
4113
4143
  window.location.href = urlToSearchResult;
4114
4144
  }
4115
4145
  },
@@ -4270,6 +4300,7 @@ const SearchIconWidgetPopup = () => {
4270
4300
  showPopupComponent: showInfo,
4271
4301
  setShowPopupComponent: setShowInfo,
4272
4302
  urlSearchResult,
4303
+ redirectObjectDirection,
4273
4304
  query: handleFunctions.query,
4274
4305
  languageSettings
4275
4306
  }
@@ -4468,7 +4499,7 @@ const FacetComponent = (props) => {
4468
4499
  separatedFilterItem,
4469
4500
  setSeparatedFilterItem,
4470
4501
  settings,
4471
- scrollElementSelector
4502
+ virtualizedScrollRef
4472
4503
  } = props;
4473
4504
  let aliases = {};
4474
4505
  if (filter.value === "hierarchicalProductType")
@@ -4565,7 +4596,7 @@ const FacetComponent = (props) => {
4565
4596
  const handleFacetCheckbox = (props2) => {
4566
4597
  var _a2, _b2;
4567
4598
  const { facetValues, virtualized } = props2;
4568
- const { index, key, style } = virtualized || {};
4599
+ const { index, key } = virtualized || {};
4569
4600
  return (_b2 = handleFacetValues(virtualized && ((_a2 = Object.keys(virtualized)) == null ? void 0 : _a2.length) ? [facetValues[index]] : facetValues)) == null ? void 0 : _b2.map((facetValue) => {
4570
4601
  var _a3;
4571
4602
  const { labelName, value: itemValue, counter, children, level } = facetValue;
@@ -4610,7 +4641,6 @@ const FacetComponent = (props) => {
4610
4641
  "li",
4611
4642
  {
4612
4643
  className: `sledge-instant-search__result-filter-checkbox-item ${isFacetHierarchical ? `sledge-instant-search__result-filter-checkbox-item-level sledge-instant-search__result-filter-checkbox-item-level-${level}` : ""}`,
4613
- style,
4614
4644
  children: content
4615
4645
  },
4616
4646
  key
@@ -4624,7 +4654,6 @@ const FacetComponent = (props) => {
4624
4654
  ] });
4625
4655
  });
4626
4656
  };
4627
- let scrollElement = document.querySelector(scrollElementSelector || `#filter-component-standard-${stringToSlug(value)} .sledge-instant-search__result-filter-item-list`);
4628
4657
  if (isDisplaySlider) {
4629
4658
  items = (defaultFacetStats == null ? void 0 : defaultFacetStats[value]) && Object.keys(defaultFacetStats[value]).length ? defaultFacetStats[value] : {};
4630
4659
  let defaultValueMin = valueFilterPriceChange[0] || (items == null ? void 0 : items.min);
@@ -4655,16 +4684,12 @@ const FacetComponent = (props) => {
4655
4684
  blockComponent = display.toLowerCase() === "checkbox" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
4656
4685
  VirtualizedList,
4657
4686
  {
4658
- selector: scrollElementSelector,
4659
- ...scrollElement && {
4660
- scrollElement
4661
- },
4662
4687
  rowCount: currentItems == null ? void 0 : currentItems.length,
4663
- rowHeight: 36,
4664
4688
  rowRenderer: (props2) => handleFacetCheckbox({
4665
4689
  facetValues: currentItems,
4666
4690
  virtualized: props2
4667
- })
4691
+ }),
4692
+ scrollElementRef: virtualizedScrollRef
4668
4693
  }
4669
4694
  ) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: handleFacetCheckbox({
4670
4695
  facetValues: currentItems
@@ -4689,10 +4714,8 @@ const FacetComponent = (props) => {
4689
4714
  }),
4690
4715
  defaultValue: clickedFacets && ((_d = clickedFacets[value]) == null ? void 0 : _d.length) ? clickedFacets[value][0] : "",
4691
4716
  labelStyle: filter_option_style,
4692
- ...scrollElement && {
4693
- scrollElement
4694
- },
4695
- useVirtualized: true
4717
+ useVirtualized: true,
4718
+ scrollElementRef: virtualizedScrollRef
4696
4719
  }
4697
4720
  ) });
4698
4721
  } else if (display.toLowerCase() === "select" && (currentItems == null ? void 0 : currentItems.length)) {
@@ -4749,6 +4772,80 @@ const FacetComponent = (props) => {
4749
4772
  }
4750
4773
  return blockComponent;
4751
4774
  };
4775
+ const FilterVerticalComponent = (props) => {
4776
+ const { filter, filterSettings, indexFilter, filterTitleStyle = {}, handleOpenFilterVertical, clickedOpenFilters } = props;
4777
+ const filterItemRef = React__default.useRef(null);
4778
+ const { value, label } = filter;
4779
+ const { isRender, classesUlElement, getFacetComponent } = filterSettings({
4780
+ filter,
4781
+ virtualizedScrollRef: filterItemRef
4782
+ });
4783
+ return isRender ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item", children: [
4784
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-title", onClick: () => handleOpenFilterVertical(value), children: [
4785
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-filter-title", style: filterTitleStyle, children: label }),
4786
+ /* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: false, animate: clickedOpenFilters.includes(value) ? "open" : "closed", variants: ROTATE_FILTER_ARROW_ANIMATION, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowDownIcon, { width: 15, height: 15, color: "#000000" }) })
4787
+ ] }),
4788
+ clickedOpenFilters.includes(value) && /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: classesUlElement.join(" "), ref: filterItemRef, children: getFacetComponent() })
4789
+ ] }, indexFilter) : null;
4790
+ };
4791
+ const FilterHorizontalComponent = (props) => {
4792
+ const {
4793
+ filter,
4794
+ filterSettings,
4795
+ indexFilter,
4796
+ deviceType,
4797
+ clickedOpenFilterHorizontalId,
4798
+ setClickedOpenFilterHorizontalId,
4799
+ clickedOpenFilterHorizontalMobileId,
4800
+ setClickedOpenFilterHorizontalMobileId,
4801
+ allowedFilter = []
4802
+ } = props;
4803
+ const { value, label } = filter;
4804
+ const filterItemRef = React__default.useRef(null);
4805
+ const getValueOpenFilterId = deviceType === "mobile" ? clickedOpenFilterHorizontalMobileId : clickedOpenFilterHorizontalId;
4806
+ const isOpenFilterHorizontal = getValueOpenFilterId === value;
4807
+ const { isRender, classesUlElement, getFacetComponent, isLastIndex } = filterSettings({
4808
+ filter,
4809
+ virtualizedScrollRef: filterItemRef
4810
+ });
4811
+ return isRender ? /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4812
+ Popover,
4813
+ {
4814
+ trigger: /* @__PURE__ */ jsxRuntimeExports.jsxs(
4815
+ Button,
4816
+ {
4817
+ type: "button",
4818
+ onClick: () => {
4819
+ if (deviceType === "mobile") {
4820
+ setClickedOpenFilterHorizontalMobileId == null ? void 0 : setClickedOpenFilterHorizontalMobileId(value);
4821
+ } else {
4822
+ setClickedOpenFilterHorizontalId == null ? void 0 : setClickedOpenFilterHorizontalId(value);
4823
+ }
4824
+ },
4825
+ className: `${isLastIndex ? (allowedFilter == null ? void 0 : allowedFilter.length) % 2 ? "sledge-instant-search__result-filter-trigger-odd" : "sledge-instant-search__result-filter-trigger-even" : ""}`,
4826
+ children: [
4827
+ label,
4828
+ /* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: "closed", animate: isOpenFilterHorizontal ? "open" : "closed", variants: ROTATE_FILTER_ARROW_ANIMATION, className: "sort-trigger-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowDownIcon, { width: 20, height: 20, color: "#000000" }) })
4829
+ ]
4830
+ }
4831
+ ),
4832
+ content: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-facet", children: isOpenFilterHorizontal && /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: classesUlElement.join(" "), ref: filterItemRef, children: getFacetComponent() }) }),
4833
+ withOpenState: true,
4834
+ isOpen: isOpenFilterHorizontal,
4835
+ setIsOpen: (open) => {
4836
+ if (deviceType === "mobile") {
4837
+ setClickedOpenFilterHorizontalMobileId == null ? void 0 : setClickedOpenFilterHorizontalMobileId(!open ? "" : value);
4838
+ } else {
4839
+ setClickedOpenFilterHorizontalId == null ? void 0 : setClickedOpenFilterHorizontalId(!open ? "" : value);
4840
+ }
4841
+ },
4842
+ hideCloseIcon: true,
4843
+ align: "center",
4844
+ className: "sledge-instant-search__filter-horizontal-facet-content",
4845
+ customArrow: `<svg style="transform: rotate(180deg); margin-bottom: 3px; stroke-dasharray: 0,0,36;" width="44" height="12" viewBox="0 0 44 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M23.2222 1.99825e-06C23.2222 11.9998 4.88979 11.9999 0.000354767 12L23.2222 12L44 12C23.2222 12 23.2222 1.99825e-06 23.2222 1.99825e-06Z" fill="white" stroke="#393d4e" stroke-width="1px" /></svg>`
4846
+ }
4847
+ ) }, indexFilter) : null;
4848
+ };
4752
4849
  const ButtonLoadMore = ({ text, onClick, isInfiniteScroll, currentPage, totalPage, totalResult, pageInfo: pageInfoProp, isVisibleLoadMore, ...otherProps }) => {
4753
4850
  const [ref, entry] = useIntersectionObserver({
4754
4851
  threshold: 0,
@@ -5888,7 +5985,7 @@ const ResultProduct = (props) => {
5888
5985
  };
5889
5986
  const filterSettings = ({
5890
5987
  filter,
5891
- scrollElementSelector
5988
+ virtualizedScrollRef
5892
5989
  }) => {
5893
5990
  var _a2;
5894
5991
  const { value, display, indexFilter } = filter;
@@ -5931,7 +6028,7 @@ const ResultProduct = (props) => {
5931
6028
  setValueFilterPriceChange,
5932
6029
  separatedFilterItem,
5933
6030
  setSeparatedFilterItem,
5934
- scrollElementSelector
6031
+ virtualizedScrollRef
5935
6032
  }
5936
6033
  );
5937
6034
  if (display.toLowerCase() === "swatch" && (items == null ? void 0 : items.length))
@@ -5958,65 +6055,31 @@ const ResultProduct = (props) => {
5958
6055
  });
5959
6056
  }) })
5960
6057
  ] }) : null;
5961
- const filterVerticalComponents = ({ filterLayoutType }) => allowedFilter == null ? void 0 : allowedFilter.map((filter, indexFilter) => {
5962
- const { value, label } = filter;
5963
- const filterItemId = `filter-component-${filterLayoutType}-${stringToSlug(value)}`;
5964
- const { isRender, classesUlElement, getFacetComponent } = filterSettings({ filter, scrollElementSelector: `#${filterItemId} .sledge-instant-search__result-filter-item-list` });
5965
- return isRender ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item", id: filterItemId, children: [
5966
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-title", onClick: () => handleOpenFilterVertical(value), children: [
5967
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-filter-title", style: filter_title_style, children: label }),
5968
- /* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: false, animate: clickedOpenFilters.includes(value) ? "open" : "closed", variants: ROTATE_FILTER_ARROW_ANIMATION, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowDownIcon, { width: 15, height: 15, color: "#000000" }) })
5969
- ] }),
5970
- clickedOpenFilters.includes(value) && /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: classesUlElement.join(" "), children: getFacetComponent() })
5971
- ] }, indexFilter) : null;
5972
- });
5973
- const filterHorizontalComponents = ({ deviceType }) => allowedFilter == null ? void 0 : allowedFilter.map((filter, indexFilter) => {
5974
- const { value, label } = filter;
5975
- const filterItemId = `filter-component-${deviceType}-${stringToSlug(value)}`;
5976
- const getValueOpenFilterId = deviceType === "mobile" ? clickedOpenFilterHorizontalMobileId : clickedOpenFilterHorizontalId;
5977
- const isOpenFilterHorizontal = getValueOpenFilterId === value;
5978
- const { isRender, classesUlElement, getFacetComponent, isLastIndex } = filterSettings({
6058
+ const filterVerticalComponents = () => allowedFilter == null ? void 0 : allowedFilter.map((filter, indexFilter) => /* @__PURE__ */ jsxRuntimeExports.jsx(
6059
+ FilterVerticalComponent,
6060
+ {
5979
6061
  filter,
5980
- scrollElementSelector: `#${filterItemId} .sledge-instant-search__result-filter-item-list`
5981
- });
5982
- return isRender ? /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5983
- Popover,
5984
- {
5985
- trigger: /* @__PURE__ */ jsxRuntimeExports.jsxs(
5986
- Button,
5987
- {
5988
- type: "button",
5989
- onClick: () => {
5990
- if (deviceType === "mobile") {
5991
- setClickedOpenFilterHorizontalMobileId == null ? void 0 : setClickedOpenFilterHorizontalMobileId(value);
5992
- } else {
5993
- setClickedOpenFilterHorizontalId == null ? void 0 : setClickedOpenFilterHorizontalId(value);
5994
- }
5995
- },
5996
- className: `${isLastIndex ? (allowedFilter == null ? void 0 : allowedFilter.length) % 2 ? "sledge-instant-search__result-filter-trigger-odd" : "sledge-instant-search__result-filter-trigger-even" : ""}`,
5997
- children: [
5998
- label,
5999
- /* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: "closed", animate: isOpenFilterHorizontal ? "open" : "closed", variants: ROTATE_FILTER_ARROW_ANIMATION, className: "sort-trigger-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowDownIcon, { width: 20, height: 20, color: "#000000" }) })
6000
- ]
6001
- }
6002
- ),
6003
- content: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-facet", id: filterItemId, children: isOpenFilterHorizontal && /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: classesUlElement.join(" "), children: getFacetComponent() }) }),
6004
- withOpenState: true,
6005
- isOpen: isOpenFilterHorizontal,
6006
- setIsOpen: (open) => {
6007
- if (deviceType === "mobile") {
6008
- setClickedOpenFilterHorizontalMobileId == null ? void 0 : setClickedOpenFilterHorizontalMobileId(!open ? "" : value);
6009
- } else {
6010
- setClickedOpenFilterHorizontalId == null ? void 0 : setClickedOpenFilterHorizontalId(!open ? "" : value);
6011
- }
6012
- },
6013
- hideCloseIcon: true,
6014
- align: "center",
6015
- className: "sledge-instant-search__filter-horizontal-facet-content",
6016
- customArrow: `<svg style="transform: rotate(180deg); margin-bottom: 3px; stroke-dasharray: 0,0,36;" width="44" height="12" viewBox="0 0 44 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M23.2222 1.99825e-06C23.2222 11.9998 4.88979 11.9999 0.000354767 12L23.2222 12L44 12C23.2222 12 23.2222 1.99825e-06 23.2222 1.99825e-06Z" fill="white" stroke="#393d4e" stroke-width="1px" /></svg>`
6017
- }
6018
- ) }, indexFilter) : null;
6019
- });
6062
+ filterSettings,
6063
+ indexFilter,
6064
+ filterTitleStyle: filter_title_style,
6065
+ handleOpenFilterVertical,
6066
+ clickedOpenFilters
6067
+ }
6068
+ ));
6069
+ const filterHorizontalComponents = ({ deviceType }) => allowedFilter == null ? void 0 : allowedFilter.map((filter, indexFilter) => /* @__PURE__ */ jsxRuntimeExports.jsx(
6070
+ FilterHorizontalComponent,
6071
+ {
6072
+ filter,
6073
+ filterSettings,
6074
+ indexFilter,
6075
+ deviceType,
6076
+ clickedOpenFilterHorizontalId,
6077
+ setClickedOpenFilterHorizontalId,
6078
+ clickedOpenFilterHorizontalMobileId,
6079
+ setClickedOpenFilterHorizontalMobileId,
6080
+ allowedFilter
6081
+ }
6082
+ ));
6020
6083
  const paginationComponent = isLoadMore ? /* @__PURE__ */ jsxRuntimeExports.jsx(
6021
6084
  ButtonLoadMore,
6022
6085
  {
@@ -6098,11 +6161,7 @@ const ResultProduct = (props) => {
6098
6161
  title: language_filter || "Filter",
6099
6162
  content: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6100
6163
  filterVerticalSelected,
6101
- ((_o = (_n = filterVerticalComponents({
6102
- filterLayoutType: "flyout"
6103
- })) == null ? void 0 : _n.filter((item) => item)) == null ? void 0 : _o.length) ? filterVerticalComponents({
6104
- filterLayoutType: "flyout"
6105
- }) : null
6164
+ ((_o = (_n = filterVerticalComponents()) == null ? void 0 : _n.filter((item) => item)) == null ? void 0 : _o.length) ? filterVerticalComponents() : null
6106
6165
  ] }),
6107
6166
  open: openFilterFlyoutMobile,
6108
6167
  setOpen: setOpenFilterFlyoutMobile
@@ -6112,9 +6171,7 @@ const ResultProduct = (props) => {
6112
6171
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-wrapper", "data-filter-layout": (_r = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _r.layout, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6113
6172
  /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: ((_s = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _s.enable_on_search) && ((_t = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _t.layout) === "vertical" && !hideFilterWhenOneValue ? !(allowedFilter == null ? void 0 : allowedFilter.find(({ display }) => (display == null ? void 0 : display.toLowerCase()) === "tree")) && isFirstLoading || (allowedFilter == null ? void 0 : allowedFilter.find(({ display }) => (display == null ? void 0 : display.toLowerCase()) === "tree")) && isLoadingProduct ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter sledge__hide-element-lg-on-mobile", children: filterVerticalSkeleton }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter sledge__hide-element-lg-on-mobile", children: isLoadingSetting ? filterVerticalSkeleton : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6114
6173
  filterVerticalSelected,
6115
- filterVerticalComponents({
6116
- filterLayoutType: "standard"
6117
- })
6174
+ filterVerticalComponents()
6118
6175
  ] }) }) : null }),
6119
6176
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data", children: [
6120
6177
  isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
@@ -6426,15 +6483,26 @@ const SearchWidget = (props) => {
6426
6483
  const [suggestionIndex, setSuggestionIndex] = React__default.useState("");
6427
6484
  const [showSearchResult, setShowSearchResult] = React__default.useState(false);
6428
6485
  const [languageSettings, setLanguageSettings] = React__default.useState({});
6486
+ const [redirectsSettings, setRedirectsSettings] = React__default.useState([]);
6487
+ const [redirectObject, setRedirectObject] = React__default.useState({});
6488
+ const [isRedirect, setIsRedirect] = React__default.useState(false);
6429
6489
  const previousState = usePrevious({ keyword });
6430
6490
  const searchFieldRef = React__default.useRef(null);
6491
+ const { direction: redirectObjectDirection } = redirectObject || {};
6431
6492
  const handleMultiSearch = async (data, onSearch = false) => {
6432
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2;
6493
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2;
6433
6494
  if (!keyword.length)
6434
6495
  return;
6496
+ const valueRedirectObject = redirectsSettings.find(({ keyword: redirectKeyword }) => {
6497
+ var _a3;
6498
+ return ((_a3 = String(redirectKeyword)) == null ? void 0 : _a3.toLowerCase()) === keyword;
6499
+ });
6500
+ const valueIsRedirect = Boolean((_a2 = valueRedirectObject == null ? void 0 : valueRedirectObject.direction) == null ? void 0 : _a2.length);
6501
+ setRedirectObject(valueRedirectObject);
6502
+ setIsRedirect(valueIsRedirect);
6435
6503
  setIsLoading(true);
6436
6504
  const { index_product, tabs, hidden_tags, display, show_out_of_stock } = data;
6437
- const suggestion = ((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion) || {};
6505
+ const suggestion = ((_b2 = display == null ? void 0 : display.search) == null ? void 0 : _b2.suggestion) || {};
6438
6506
  let response;
6439
6507
  let body = {
6440
6508
  queries: tabs.map((tab) => {
@@ -6461,10 +6529,10 @@ const SearchWidget = (props) => {
6461
6529
  if (onSearch && (keyword == null ? void 0 : keyword.length)) {
6462
6530
  searchTrigger({
6463
6531
  keyword,
6464
- resultCount: ((_b2 = valueSearchResultProduct[0]) == null ? void 0 : _b2.totalHits) || 0
6532
+ resultCount: ((_c2 = valueSearchResultProduct[0]) == null ? void 0 : _c2.totalHits) || 0
6465
6533
  });
6466
6534
  }
6467
- let valueSearchResultOther = ((_c2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(index_product)))) == null ? void 0 : _c2.map((result) => {
6535
+ let valueSearchResultOther = ((_d2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(index_product)))) == null ? void 0 : _d2.map((result) => {
6468
6536
  const { indexUid } = result;
6469
6537
  const { name, type } = tabs == null ? void 0 : tabs.find(({ index }) => index.includes(indexUid));
6470
6538
  return {
@@ -6475,12 +6543,12 @@ const SearchWidget = (props) => {
6475
6543
  }
6476
6544
  };
6477
6545
  })) || [];
6478
- let getValueSearchResultProduct = (valueSearchResultProduct == null ? void 0 : valueSearchResultProduct.length) ? (_d2 = valueSearchResultProduct[0]) == null ? void 0 : _d2.hits : [];
6546
+ let getValueSearchResultProduct = (valueSearchResultProduct == null ? void 0 : valueSearchResultProduct.length) ? (_e2 = valueSearchResultProduct[0]) == null ? void 0 : _e2.hits : [];
6479
6547
  let valueSuggestionIndex = !keyword.length ? "zero_character" : !(getValueSearchResultProduct == null ? void 0 : getValueSearchResultProduct.length) ? "no_result" : "";
6480
6548
  let isPriorityZeroCharacter = Boolean(
6481
- !keyword.length && Object.keys(suggestion).length && ((_f2 = (_e2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _e2.products) == null ? void 0 : _f2.active) && ((_i2 = (_h2 = (_g2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _g2.products) == null ? void 0 : _h2.list) == null ? void 0 : _i2.length)
6549
+ !keyword.length && Object.keys(suggestion).length && ((_g2 = (_f2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _f2.products) == null ? void 0 : _g2.active) && ((_j2 = (_i2 = (_h2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _h2.products) == null ? void 0 : _i2.list) == null ? void 0 : _j2.length)
6482
6550
  );
6483
- setSearchResultProduct(isPriorityZeroCharacter ? (_k2 = (_j2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _j2.products) == null ? void 0 : _k2.list : getValueSearchResultProduct);
6551
+ setSearchResultProduct(isPriorityZeroCharacter ? (_l2 = (_k2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _k2.products) == null ? void 0 : _l2.list : getValueSearchResultProduct);
6484
6552
  setSearchResultOther(valueSearchResultOther);
6485
6553
  setSuggestionIndex(valueSuggestionIndex);
6486
6554
  setIsLoading(false);
@@ -6491,10 +6559,11 @@ const SearchWidget = (props) => {
6491
6559
  response = JSON.parse(LOCAL_STORAGE_INSTANT_SEARCH_SETTING);
6492
6560
  if (!response)
6493
6561
  return;
6494
- const { display, languages } = response;
6562
+ const { display, languages, redirects } = response;
6495
6563
  setDisplaySettings(display);
6496
6564
  setSuggestionSettings((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion);
6497
6565
  setLanguageSettings(languages);
6566
+ setRedirectsSettings(redirects);
6498
6567
  if (keyword.length)
6499
6568
  await handleMultiSearch(response);
6500
6569
  };
@@ -6537,7 +6606,7 @@ const SearchWidget = (props) => {
6537
6606
  onKeyDown: (event) => {
6538
6607
  if (event.key === "Enter") {
6539
6608
  const queryKeyword = (query == null ? void 0 : query.keyword) ? query.keyword : DEFAULT_QUERY_PARAM.KEYWORD;
6540
- const urlToSearchResult = `${urlSearchResult || DEFAULT_SEARCH_RESULT_URL}?${queryKeyword}=${keyword}`;
6609
+ const urlToSearchResult = isRedirect ? redirectObjectDirection : `${urlSearchResult || DEFAULT_SEARCH_RESULT_URL}?${queryKeyword}=${keyword}`;
6541
6610
  window.location.href = urlToSearchResult;
6542
6611
  }
6543
6612
  },
@@ -6693,6 +6762,7 @@ const SearchWidget = (props) => {
6693
6762
  keyword,
6694
6763
  isComponentJsVersion: isJsVersion,
6695
6764
  urlSearchResult,
6765
+ redirectObjectDirection,
6696
6766
  query,
6697
6767
  languageSettings
6698
6768
  }