@getlupa/vue 0.17.7 → 0.17.9

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.
@@ -1759,1319 +1759,36 @@ const LupaSearchSdk = {
1759
1759
  return loadRedirectionRules(queryKey, (options === null || options === void 0 ? void 0 : options.environment) || "production", options === null || options === void 0 ? void 0 : options.customBaseUrl);
1760
1760
  }
1761
1761
  };
1762
- const getNormalizedString = (str) => {
1763
- var _a, _b;
1764
- if (!str) {
1765
- return "";
1766
- }
1767
- const transformedStr = typeof str === "string" ? str : str.toString();
1768
- return transformedStr.normalize === void 0 ? (_a = transformedStr.toLocaleLowerCase()) == null ? void 0 : _a.trim() : (_b = transformedStr.toLocaleLowerCase().normalize("NFKD").replace(/[^\w\s.-_/]/g, "")) == null ? void 0 : _b.trim();
1769
- };
1770
- const getTransformedString = (str) => {
1771
- var _a, _b;
1772
- if (!str) {
1773
- return "";
1774
- }
1775
- const transformedStr = typeof str === "string" ? str : str.toString();
1776
- return transformedStr.normalize === void 0 ? (_a = transformedStr.toLocaleLowerCase()) == null ? void 0 : _a.trim() : (_b = transformedStr.toLocaleLowerCase().normalize("NFKD")) == null ? void 0 : _b.trim();
1777
- };
1778
- const capitalize$1 = (str) => {
1779
- if (!str) {
1780
- return "";
1781
- }
1782
- return str[0].toLocaleUpperCase() + str.slice(1);
1783
- };
1784
- const addParamsToLabel = (label, ...params) => {
1785
- if (!params || params.length < 1) {
1786
- return label;
1787
- }
1788
- const paramKeys = Array.from(Array(params.length).keys());
1789
- return paramKeys.reduce((a, c2) => a.replace(`{${c2 + 1}}`, params[c2]), label);
1790
- };
1791
- const getRandomString = (length) => {
1792
- const chars = "0123456789abcdefghijklmnopqrstuvwxyz";
1793
- let result2 = "";
1794
- for (let i = length; i > 0; --i) {
1795
- result2 += chars[Math.floor(Math.random() * chars.length)];
1796
- }
1797
- return result2;
1798
- };
1799
- const toFixedIfNecessary = (value, precision = 2) => {
1800
- return (+parseFloat(value).toFixed(precision)).toString();
1801
- };
1802
- const getDisplayValue = (value) => {
1803
- if (value === void 0) {
1804
- return "";
1805
- }
1806
- if (typeof value === "string") {
1807
- return value;
1808
- }
1809
- return toFixedIfNecessary(value.toString());
1810
- };
1811
- const getProductKey = (index, product, idKey) => {
1812
- if (!idKey) {
1813
- return index;
1814
- }
1815
- if (product[idKey]) {
1816
- return product[idKey];
1817
- }
1818
- return index;
1819
- };
1820
- const normalizeFloat = (value) => {
1821
- var _a;
1822
- if (!value) {
1823
- return 0;
1824
- }
1825
- return +((_a = value == null ? void 0 : value.replace(/[^0-9,.]/g, "")) == null ? void 0 : _a.replace(",", "."));
1826
- };
1827
- const escapeHtml$1 = (value) => {
1828
- if (!value) {
1829
- return "";
1830
- }
1831
- let output = "";
1832
- let isSkip = false;
1833
- value.split(/(<del>.*?<\/del>)/g).forEach((segment) => {
1834
- if (segment.startsWith("<del>") && segment.endsWith("</del>")) {
1835
- output += segment;
1836
- isSkip = true;
1837
- }
1838
- if (!isSkip) {
1839
- output += segment.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
1840
- }
1841
- if (isSkip) {
1842
- isSkip = false;
1843
- }
1844
- });
1845
- return output;
1846
- };
1847
- const inputsAreEqual = (input2, possibleValues) => {
1848
- if (!input2) {
1849
- return false;
1850
- }
1851
- const normalizedInput = getTransformedString(input2);
1852
- return possibleValues.some((v) => getTransformedString(v) === normalizedInput);
1853
- };
1854
- const levenshteinDistance = (s = "", t = "") => {
1855
- if (!(s == null ? void 0 : s.length)) {
1856
- return t.length;
1857
- }
1858
- if (!(t == null ? void 0 : t.length)) {
1859
- return s.length;
1860
- }
1861
- const arr = [];
1862
- for (let i = 0; i <= t.length; i++) {
1863
- arr[i] = [i];
1864
- for (let j = 1; j <= s.length; j++) {
1865
- arr[i][j] = i === 0 ? j : Math.min(
1866
- arr[i - 1][j] + 1,
1867
- arr[i][j - 1] + 1,
1868
- arr[i - 1][j - 1] + (s[j - 1] === t[i - 1] ? 0 : 1)
1869
- );
1870
- }
1871
- }
1872
- return arr[t.length][s.length];
1873
- };
1874
- const findClosestStringValue = (input2, possibleValues, key) => {
1875
- var _a;
1876
- const directMatch = possibleValues.find((v) => v[key] === input2);
1877
- if (directMatch) {
1878
- return directMatch;
1879
- }
1880
- const distances = possibleValues.map((v) => levenshteinDistance(`${v[key]}`, input2));
1881
- const minDistance = Math.min(...distances);
1882
- const closestValue = (_a = possibleValues.filter((_, i) => distances[i] === minDistance)) == null ? void 0 : _a[0];
1883
- return closestValue;
1884
- };
1885
- const DEFAULT_SEARCH_BOX_OPTIONS = {
1886
- inputSelector: "#searchBox",
1887
- options: {
1888
- environment: "production"
1889
- },
1890
- showTotalCount: false,
1891
- minInputLength: 1,
1892
- inputAttributes: {
1893
- name: "q"
1894
- },
1895
- debounce: 0,
1896
- labels: {
1897
- placeholder: "Search for products...",
1898
- noResults: "There are no results found.",
1899
- moreResults: "Show more results",
1900
- currency: "€",
1901
- defaultFacetLabel: "Category:"
1902
- },
1903
- links: {
1904
- searchResults: "/search"
1905
- },
1906
- panels: [
1907
- {
1908
- type: "suggestion",
1909
- queryKey: "",
1910
- highlight: true,
1911
- limit: 5
1912
- },
1913
- {
1914
- type: "document",
1915
- queryKey: "",
1916
- limit: 5,
1917
- searchBySuggestion: false,
1918
- links: {
1919
- details: "{url}"
1920
- },
1921
- titleKey: "name",
1922
- elements: []
1923
- }
1924
- ],
1925
- history: {
1926
- labels: {
1927
- clear: "Clear History"
1928
- }
1929
- }
1930
- };
1931
- const DEFAULT_OPTIONS_RESULTS = {
1932
- options: {
1933
- environment: "production"
1934
- },
1935
- queryKey: "",
1936
- containerSelector: "#searchResultsContainer",
1937
- searchTitlePosition: "page-top",
1938
- labels: {
1939
- pageSize: "Page size:",
1940
- sortBy: "Sort by:",
1941
- itemCount: "Items {1} of {2}",
1942
- filteredItemCount: "",
1943
- currency: "€",
1944
- showMore: "Show more",
1945
- searchResults: "Search Query: ",
1946
- emptyResults: "There are no results for the query:",
1947
- mobileFilterButton: "Filter",
1948
- htmlTitleTemplate: "Search Query: '{1}'",
1949
- noResultsSuggestion: "No results found for this query: {1}",
1950
- didYouMean: "Did you mean to search: {1}",
1951
- similarQuery: "Search results for phrase {1}",
1952
- similarQueries: "Similar queries:",
1953
- similarResultsLabel: "Related to your query:"
1954
- },
1955
- grid: {
1956
- columns: {
1957
- xl: 4,
1958
- l: 3,
1959
- md: 2,
1960
- sm: 2,
1961
- xs: 1
1962
- }
1963
- },
1964
- pagination: {
1965
- sizeSelection: {
1966
- position: {
1967
- top: false,
1968
- bottom: true
1969
- },
1970
- sizes: [10, 20, 25]
1971
- },
1972
- pageSelection: {
1973
- position: {
1974
- top: false,
1975
- bottom: true
1976
- },
1977
- display: 5,
1978
- displayMobile: 3
1979
- }
1980
- },
1981
- sort: [],
1982
- filters: {
1983
- currentFilters: {
1984
- visibility: {
1985
- mobileSidebar: true,
1986
- mobileToolbar: true
1987
- },
1988
- labels: {
1989
- title: "Current filters:",
1990
- clearAll: "Clear all"
1762
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1763
+ function getDefaultExportFromCjs(x2) {
1764
+ return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
1765
+ }
1766
+ function getAugmentedNamespace(n) {
1767
+ if (n.__esModule)
1768
+ return n;
1769
+ var f2 = n.default;
1770
+ if (typeof f2 == "function") {
1771
+ var a = function a2() {
1772
+ if (this instanceof a2) {
1773
+ var args = [null];
1774
+ args.push.apply(args, arguments);
1775
+ var Ctor = Function.bind.apply(f2, args);
1776
+ return new Ctor();
1991
1777
  }
1992
- },
1993
- facets: {
1994
- labels: {
1995
- title: "Filters:",
1996
- showAll: "Show more",
1997
- facetFilter: "Filter...",
1998
- facetClear: "Clear"
1999
- },
2000
- filterable: {
2001
- minValues: 5
2002
- },
2003
- hierarchy: {
2004
- maxInitialLevel: 2,
2005
- topLevelValueCountLimit: 5,
2006
- filterable: true
2007
- },
2008
- facetValueCountLimit: 20,
2009
- showDocumentCount: true,
2010
- style: {
2011
- type: "sidebar"
2012
- }
2013
- }
2014
- },
2015
- toolbar: {
2016
- layoutSelector: true,
2017
- itemSummary: true,
2018
- clearFilters: false
2019
- },
2020
- isInStock: () => {
2021
- return true;
2022
- },
2023
- badges: {
2024
- anchor: "tr",
2025
- elements: []
2026
- },
2027
- links: {
2028
- details: "/{id}"
2029
- },
2030
- elements: [],
2031
- breadcrumbs: []
2032
- };
2033
- const useScreenStore = defineStore("screen", () => {
2034
- const measuredScreenWidth = ref(1e3);
2035
- const optionsStore = useOptionsStore();
2036
- const screenWidth = computed(() => {
2037
- var _a, _b;
2038
- const { searchResultOptions } = storeToRefs(optionsStore);
2039
- return (_b = (_a = searchResultOptions.value.grid) == null ? void 0 : _a.forcedScreenWidth) != null ? _b : measuredScreenWidth.value;
2040
- });
2041
- const configuredGridSizes = computed(() => {
2042
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
2043
- const { searchResultOptions } = storeToRefs(optionsStore);
2044
- return {
2045
- smMin: (_d = (_c = (_b = (_a = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _a.grid) == null ? void 0 : _b.sizes) == null ? void 0 : _c.sm) != null ? _d : S_MIN_WIDTH,
2046
- mdMin: (_h = (_g = (_f = (_e = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _e.grid) == null ? void 0 : _f.sizes) == null ? void 0 : _g.md) != null ? _h : MD_MIN_WIDTH,
2047
- lMin: (_l = (_k = (_j = (_i = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _i.grid) == null ? void 0 : _j.sizes) == null ? void 0 : _k.l) != null ? _l : L_MIN_WIDTH,
2048
- xlMin: (_p = (_o = (_n = (_m = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _m.grid) == null ? void 0 : _n.sizes) == null ? void 0 : _o.xl) != null ? _p : XL_MIN_WIDTH
1778
+ return f2.apply(this, arguments);
2049
1779
  };
2050
- });
2051
- const currentScreenWidth = computed(() => {
2052
- const width = screenWidth.value;
2053
- if (width <= configuredGridSizes.value.smMin) {
2054
- return "xs";
2055
- } else if (width > configuredGridSizes.value.smMin && width <= configuredGridSizes.value.mdMin) {
2056
- return "sm";
2057
- } else if (width > configuredGridSizes.value.mdMin && width <= configuredGridSizes.value.lMin) {
2058
- return "md";
2059
- } else if (width > configuredGridSizes.value.lMin && width <= configuredGridSizes.value.xlMin) {
2060
- return "l";
2061
- } else {
2062
- return "xl";
2063
- }
2064
- });
2065
- const isMobileWidth = computed(() => {
2066
- var _a;
2067
- return (_a = ["xs", "sm"]) == null ? void 0 : _a.includes(currentScreenWidth.value);
2068
- });
2069
- const setScreenWidth = ({ width }) => {
2070
- measuredScreenWidth.value = width;
2071
- };
2072
- return { screenWidth, currentScreenWidth, isMobileWidth, setScreenWidth };
2073
- });
2074
- const useOptionsStore = defineStore("options", () => {
2075
- const searchBoxOptions = ref(
2076
- DEFAULT_SEARCH_BOX_OPTIONS
2077
- );
2078
- const searchResultOptions = ref(
2079
- DEFAULT_OPTIONS_RESULTS
2080
- );
2081
- const trackingOptions = ref({});
2082
- const searchResultInitialFilters = ref({});
2083
- const productRecommendationOptions = ref({});
2084
- const screenStore = useScreenStore();
2085
- const envOptions = computed(
2086
- () => {
2087
- var _a;
2088
- return (_a = searchBoxOptions.value.options) != null ? _a : searchResultOptions.value.options;
2089
- }
2090
- );
2091
- const classMap = computed(() => {
2092
- var _a;
2093
- return (_a = searchResultOptions.value.classMap) != null ? _a : {};
2094
- });
2095
- const initialFilters = computed(() => searchResultInitialFilters.value);
2096
- const boxRoutingBehavior = computed(() => {
2097
- var _a;
2098
- return (_a = searchBoxOptions.value.routingBehavior) != null ? _a : "direct-link";
2099
- });
2100
- const searchResultsRoutingBehavior = computed(
2101
- () => {
2102
- var _a;
2103
- return (_a = searchResultOptions.value.routingBehavior) != null ? _a : "direct-link";
2104
- }
2105
- );
2106
- const defaultSearchResultPageSize = computed(
2107
- () => {
2108
- var _a, _b;
2109
- return (_b = (_a = currentResolutionPageSizes.value) == null ? void 0 : _a[0]) != null ? _b : DEFAULT_PAGE_SIZE;
2110
- }
2111
- );
2112
- const currentResolutionPageSizes = computed(() => {
2113
- var _a, _b, _c, _d;
2114
- const pageSizes = (_d = (_c = (_b = (_a = searchResultOptions.value) == null ? void 0 : _a.pagination) == null ? void 0 : _b.sizeSelection) == null ? void 0 : _c.sizes) != null ? _d : DEFAULT_PAGE_SIZE_SELECTION;
2115
- if (Array.isArray(pageSizes)) {
2116
- return pageSizes;
2117
- }
2118
- const screenSize = screenStore.currentScreenWidth;
2119
- switch (screenSize) {
2120
- case "xs":
2121
- return pageSizes.xs;
2122
- case "sm":
2123
- return pageSizes.sm;
2124
- case "md":
2125
- return pageSizes.md;
2126
- case "l":
2127
- return pageSizes.l;
2128
- case "xl":
2129
- return pageSizes.xl;
2130
- }
2131
- });
2132
- const setSearchBoxOptions = ({ options }) => {
2133
- searchBoxOptions.value = options;
2134
- };
2135
- const setTrackingOptions = ({ options }) => {
2136
- trackingOptions.value = options;
2137
- };
2138
- const setSearchResultOptions = ({ options }) => {
2139
- searchResultOptions.value = options;
2140
- };
2141
- const setInitialFilters = ({ initialFilters: initialFilters2 }) => {
2142
- searchResultInitialFilters.value = initialFilters2;
2143
- };
2144
- const setProductRecommendationOptions = ({
2145
- options
2146
- }) => {
2147
- productRecommendationOptions.value = options;
2148
- };
2149
- const getQueryParamName = (param) => {
2150
- var _a;
2151
- const nameMap = searchBoxOptions.value.queryParameterNames;
2152
- return (_a = nameMap == null ? void 0 : nameMap[param]) != null ? _a : param;
2153
- };
2154
- return {
2155
- searchBoxOptions,
2156
- searchResultOptions,
2157
- trackingOptions,
2158
- envOptions,
2159
- classMap,
2160
- initialFilters,
2161
- boxRoutingBehavior,
2162
- searchResultsRoutingBehavior,
2163
- defaultSearchResultPageSize,
2164
- currentResolutionPageSizes,
2165
- productRecommendationOptions,
2166
- setSearchBoxOptions,
2167
- setTrackingOptions,
2168
- setSearchResultOptions,
2169
- setInitialFilters,
2170
- setProductRecommendationOptions,
2171
- getQueryParamName
2172
- };
2173
- });
2174
- const initAnalyticsTracking = (analyticsOptions) => {
2175
- try {
2176
- if (analyticsOptions == null ? void 0 : analyticsOptions.enabled) {
2177
- window.sessionStorage.setItem(TRACKING_ANALYTICS_KEY, JSON.stringify(analyticsOptions));
2178
- } else {
2179
- window.sessionStorage.removeItem(TRACKING_ANALYTICS_KEY);
2180
- }
2181
- } catch (e2) {
2182
- }
2183
- };
2184
- const initBaseTracking = (enabled) => {
2185
- try {
2186
- if (enabled) {
2187
- window.sessionStorage.setItem(TRACKING_STORAGE_KEY_BASE, "1");
2188
- } else {
2189
- window.sessionStorage.removeItem(TRACKING_STORAGE_KEY_BASE);
2190
- clearSessionTracking();
2191
- clearUserTracking();
2192
- }
2193
- } catch (e2) {
2194
- }
2195
- };
2196
- const clearSessionTracking = () => {
2197
- try {
2198
- window.sessionStorage.removeItem(TRACKING_STORAGE_KEY);
2199
- } catch (e2) {
2200
- }
2201
- };
2202
- const initSessionTracking = () => {
2203
- try {
2204
- if (getSessionKey()) {
2205
- return;
2206
- }
2207
- const key = getRandomString(TRACKING_KEY_LENGTH);
2208
- window.sessionStorage.setItem(TRACKING_STORAGE_KEY, key);
2209
- } catch (e2) {
2210
- }
2211
- };
2212
- const initUserTracking = (userKey) => {
2213
- try {
2214
- if (getUserKey()) {
2215
- return;
2216
- }
2217
- const key = userKey || getRandomString(TRACKING_KEY_LENGTH);
2218
- window.localStorage.setItem(TRACKING_STORAGE_KEY, key);
2219
- } catch (e2) {
2220
- }
2221
- };
2222
- const clearUserTracking = () => {
2223
- try {
2224
- window.localStorage.removeItem(TRACKING_STORAGE_KEY);
2225
- } catch (e2) {
2226
- }
2227
- };
2228
- const isTrackingEnabled = () => {
2229
- try {
2230
- return Boolean(window.sessionStorage.getItem(TRACKING_STORAGE_KEY_BASE));
2231
- } catch (e2) {
2232
- return false;
2233
- }
2234
- };
2235
- const isDelayedClickTracking = () => {
2236
- try {
2237
- return Boolean(window.localStorage.getItem(TRACKING_CLICK_DELAYED));
2238
- } catch (e2) {
2239
- return false;
2240
- }
2241
- };
2242
- const getSessionKey = () => {
2243
- var _a;
2244
- try {
2245
- return (_a = window.sessionStorage.getItem(TRACKING_STORAGE_KEY)) != null ? _a : void 0;
2246
- } catch (e2) {
2247
- return void 0;
2248
- }
2249
- };
2250
- const getUserKey = () => {
2251
- var _a;
2252
- try {
2253
- return (_a = window.localStorage.getItem(TRACKING_STORAGE_KEY)) != null ? _a : void 0;
2254
- } catch (e2) {
2255
- return void 0;
2256
- }
2257
- };
2258
- const initTracking = (options) => {
2259
- initBaseTracking(Boolean(options.trackBase));
2260
- if (options.trackSession) {
2261
- initSessionTracking();
2262
- } else {
2263
- clearSessionTracking();
2264
- }
2265
- if (options.trackUser) {
2266
- initUserTracking(options.userKey);
2267
- } else {
2268
- clearUserTracking();
2269
- }
2270
- if (options.analytics) {
2271
- initAnalyticsTracking(options.analytics);
2272
- }
2273
- if (options.delayedClickTracking) {
2274
- window.localStorage.setItem(TRACKING_CLICK_DELAYED, "1");
2275
- checkAndDispatchDelayedEvents();
2276
- } else {
2277
- window.localStorage.removeItem(TRACKING_CLICK_DELAYED);
2278
- }
2279
- };
2280
- const getLupaTrackingContext = () => {
2281
- if (!isTrackingEnabled()) {
2282
- return {};
2283
- }
2284
- return {
2285
- userId: getUserKey(),
2286
- sessionId: getSessionKey()
2287
- };
2288
- };
2289
- const trackLupaEvent = (queryKey, data = {}, options) => {
2290
- var _a, _b;
2291
- if (!queryKey || !data.type) {
2292
- return;
2293
- }
2294
- const eventData = {
2295
- searchQuery: (_a = data.searchQuery) != null ? _a : "",
2296
- itemId: (_b = data.itemId) != null ? _b : "",
2297
- name: data.type,
2298
- userId: getUserKey(),
2299
- sessionId: getSessionKey(),
2300
- filters: data.filters,
2301
- metadata: data.metadata,
2302
- sourceItemId: data.sourceItemId
2303
- };
2304
- LupaSearchSdk.track(queryKey, eventData, options);
2305
- };
2306
- const sendGa = (name, ...args) => {
2307
- window.ga(() => {
2308
- const trackers = window.ga.getAll();
2309
- const firstTracker = trackers[0];
2310
- if (!firstTracker) {
2311
- console.error("GA tracker not found");
2312
- }
2313
- const trackerName = firstTracker.get("name");
2314
- window.ga(`${trackerName}.${name}`, ...args);
2315
- });
2316
- };
2317
- const trackAnalyticsEvent = (data) => {
2318
- var _a, _b, _c;
2319
- try {
2320
- const options = JSON.parse(
2321
- (_a = window.sessionStorage.getItem(TRACKING_ANALYTICS_KEY)) != null ? _a : "{}"
2322
- );
2323
- if (!data.analytics || !options.enabled || ((_c = options.ignoreEvents) == null ? void 0 : _c.includes((_b = data.analytics) == null ? void 0 : _b.type))) {
2324
- return;
2325
- }
2326
- switch (options.type) {
2327
- case "ua":
2328
- sendUaAnalyticsEvent(data, options);
2329
- break;
2330
- case "ga4":
2331
- sendGa4AnalyticsEvent(data, options);
2332
- break;
2333
- case "debug":
2334
- processDebugEvent(data);
2335
- break;
2336
- default:
2337
- sendUaAnalyticsEvent(data, options);
2338
- }
2339
- } catch (e2) {
2340
- console.error("Unable to send an event to google analytics");
2341
- }
2342
- };
2343
- const parseEcommerceData = (data, title) => {
2344
- var _a, _b;
2345
- return ((_a = data.analytics) == null ? void 0 : _a.items) ? {
2346
- item_list_name: title,
2347
- items: (_b = data.analytics) == null ? void 0 : _b.items
2348
- } : void 0;
2349
- };
2350
- const sendUaAnalyticsEvent = (data, options) => {
2351
- var _a, _b, _c, _d;
2352
- const ga = window.ga;
2353
- if (!ga) {
2354
- console.error("Google Analytics object not found");
2355
- return;
2356
- }
2357
- sendGa(
2358
- "send",
2359
- "event",
2360
- options.parentEventName,
2361
- (_b = (_a = data.analytics) == null ? void 0 : _a.type) != null ? _b : "",
2362
- (_d = (_c = data.analytics) == null ? void 0 : _c.label) != null ? _d : ""
2363
- );
2364
- };
2365
- const sendGa4AnalyticsEvent = (data, options) => {
2366
- var _a, _b, _c, _d, _e, _f, _g;
2367
- if (!window || !window.dataLayer) {
2368
- console.error("dataLayer object not found.");
2369
- return;
2370
- }
2371
- const sendItemTitle = data.searchQuery !== ((_a = data.analytics) == null ? void 0 : _a.label);
2372
- const title = sendItemTitle ? (_b = data.analytics) == null ? void 0 : _b.label : void 0;
2373
- const params = __spreadValues({
2374
- search_text: data.searchQuery,
2375
- item_title: title,
2376
- item_id: data.itemId,
2377
- ecommerce: parseEcommerceData(data, (_c = data.analytics) == null ? void 0 : _c.listLabel)
2378
- }, (_e = (_d = data.analytics) == null ? void 0 : _d.additionalParams) != null ? _e : {});
2379
- window.dataLayer.push(__spreadValues({
2380
- event: (_g = (_f = data.analytics) == null ? void 0 : _f.type) != null ? _g : options.parentEventName
2381
- }, params));
2382
- };
2383
- const processDebugEvent = (data) => {
2384
- var _a, _b, _c, _d;
2385
- const sendItemTitle = data.searchQuery !== ((_a = data.analytics) == null ? void 0 : _a.label);
2386
- const title = sendItemTitle ? (_b = data.analytics) == null ? void 0 : _b.label : void 0;
2387
- const params = {
2388
- event: (_c = data.analytics) == null ? void 0 : _c.type,
2389
- search_text: data.searchQuery,
2390
- item_title: title,
2391
- item_id: data.itemId,
2392
- ecommerce: parseEcommerceData(data, (_d = data.analytics) == null ? void 0 : _d.listLabel)
2393
- };
2394
- console.debug("Analytics debug event:", params);
2395
- };
2396
- const getDelayedEventsCache = () => {
2397
- var _a;
2398
- try {
2399
- return JSON.parse((_a = window.localStorage.getItem(DELAYED_TRACKING_EVENTS_CACHE)) != null ? _a : "{}");
2400
- } catch (e2) {
2401
- return {};
2402
- }
2403
- };
2404
- const storeDelayedEventCache = (cache) => {
2405
- try {
2406
- window.localStorage.setItem(DELAYED_TRACKING_EVENTS_CACHE, JSON.stringify(cache));
2407
- } catch (e2) {
2408
- }
2409
- };
2410
- const checkAndDispatchDelayedEvents = () => {
2411
- var _a, _b;
2412
- const optionsStore = useOptionsStore();
2413
- const eventCache = getDelayedEventsCache();
2414
- const urls = Object.keys(eventCache);
2415
- for (const url of urls) {
2416
- if ((_a = window.location.href) == null ? void 0 : _a.includes(url)) {
2417
- const options = (_b = optionsStore.envOptions) != null ? _b : { environment: "production" };
2418
- const { queryKey, data } = eventCache[url];
2419
- track(queryKey, data, options);
2420
- }
2421
- }
2422
- storeDelayedEventCache({});
2423
- };
2424
- const track = (queryKey, data = {}, options) => {
2425
- var _a;
2426
- if (!isTrackingEnabled()) {
2427
- return;
2428
- }
2429
- const hasSearchQuery = data.searchQuery;
2430
- if (!hasSearchQuery && !((_a = data.options) == null ? void 0 : _a.allowEmptySearchQuery)) {
2431
- return;
2432
- }
2433
- trackAnalyticsEvent(data);
2434
- trackLupaEvent(queryKey, data, options);
2435
- };
2436
- var DocumentElementType = /* @__PURE__ */ ((DocumentElementType2) => {
2437
- DocumentElementType2["IMAGE"] = "image";
2438
- DocumentElementType2["TITLE"] = "title";
2439
- DocumentElementType2["CUSTOM"] = "custom";
2440
- DocumentElementType2["DESCRIPTION"] = "description";
2441
- DocumentElementType2["PRICE"] = "price";
2442
- DocumentElementType2["REGULARPRICE"] = "regularPrice";
2443
- DocumentElementType2["RATING"] = "rating";
2444
- DocumentElementType2["SINGLE_STAR_RATING"] = "singleStarRating";
2445
- DocumentElementType2["ADDTOCART"] = "addToCart";
2446
- DocumentElementType2["CUSTOM_HTML"] = "customHtml";
2447
- return DocumentElementType2;
2448
- })(DocumentElementType || {});
2449
- var SearchBoxPanelType = /* @__PURE__ */ ((SearchBoxPanelType2) => {
2450
- SearchBoxPanelType2["SUGGESTION"] = "suggestion";
2451
- SearchBoxPanelType2["DOCUMENT"] = "document";
2452
- SearchBoxPanelType2["RELATED_SOURCE"] = "related-source";
2453
- return SearchBoxPanelType2;
2454
- })(SearchBoxPanelType || {});
2455
- var BadgeType = /* @__PURE__ */ ((BadgeType2) => {
2456
- BadgeType2["NEWITEM"] = "newItem";
2457
- BadgeType2["TEXT"] = "text";
2458
- BadgeType2["IMAGE"] = "image";
2459
- BadgeType2["CUSTOM_HTML"] = "customHtml";
2460
- BadgeType2["DISCOUNT"] = "discount";
2461
- return BadgeType2;
2462
- })(BadgeType || {});
2463
- const retrieveHistory = () => {
2464
- try {
2465
- const historyString = window.localStorage.getItem(HISTORY_LOCAL_STORAGE_KEY);
2466
- return historyString ? JSON.parse(historyString) : [];
2467
- } catch (e2) {
2468
- return [];
2469
- }
2470
- };
2471
- const saveHistory = (items) => {
2472
- try {
2473
- window.localStorage.setItem(
2474
- HISTORY_LOCAL_STORAGE_KEY,
2475
- JSON.stringify(items.slice(0, HISTORY_MAX_ITEMS))
2476
- );
2477
- } catch (e2) {
2478
- }
2479
- };
2480
- const useHistoryStore = defineStore("history", () => {
2481
- const items = ref(retrieveHistory());
2482
- const count = computed(() => items.value.length);
2483
- const add = ({ item }) => {
2484
- if (!item) {
2485
- return items.value;
2486
- }
2487
- const newItems = items.value ? [item, ...items.value] : [item];
2488
- const uniqueItems = Array.from(new Set(newItems));
2489
- items.value = uniqueItems;
2490
- saveHistory(uniqueItems);
2491
- return uniqueItems;
2492
- };
2493
- const remove = ({ item }) => {
2494
- var _a, _b;
2495
- const tempItems = (_b = (_a = items.value) == null ? void 0 : _a.filter((i) => i !== item)) != null ? _b : [];
2496
- saveHistory(tempItems);
2497
- items.value = tempItems;
2498
- return tempItems;
2499
- };
2500
- const clear = () => {
2501
- saveHistory([]);
2502
- items.value = [];
2503
- };
2504
- return { items, count, add, remove, clear };
2505
- });
2506
- const QUERY_PARAMS = {
2507
- QUERY: "q",
2508
- PAGE: "p",
2509
- LIMIT: "l",
2510
- SORT: "s"
2511
- };
2512
- const QUERY_PARAMS_PARSED = {
2513
- QUERY: "query",
2514
- PAGE: "page",
2515
- LIMIT: "limit",
2516
- SORT: "sort"
2517
- };
2518
- const FACET_PARAMS_TYPE = {
2519
- TERMS: "f.",
2520
- RANGE: "fr.",
2521
- HIERARCHY: "fh."
2522
- };
2523
- const FACET_FILTER_MAP = {
2524
- terms: FACET_PARAMS_TYPE.TERMS,
2525
- range: FACET_PARAMS_TYPE.RANGE,
2526
- hierarchy: FACET_PARAMS_TYPE.HIERARCHY
2527
- };
2528
- const FACET_KEY_SEPARATOR = ".";
2529
- const FACET_RANGE_SEPARATOR = ":";
2530
- const HIERARCHY_SEPARATOR = ">";
2531
- const FACET_TERM_RANGE_SEPARATOR = "-";
2532
- const getAmount = (price, separator = ".") => {
2533
- var _a, _b;
2534
- if (typeof price === "number") {
2535
- return `${(_a = price.toFixed(2)) == null ? void 0 : _a.replace(".", separator)}`;
2536
- }
2537
- const value = parseFloat(price);
2538
- if (isNaN(value)) {
2539
- return "";
2540
- }
2541
- return (_b = value.toFixed(2)) == null ? void 0 : _b.replace(".", separator);
2542
- };
2543
- const formatPrice = (price, currency = "€", separator = ",", currencyTemplate = "") => {
2544
- if (price !== 0 && !price) {
2545
- return "";
2546
- }
2547
- const amount = getAmount(price, separator);
2548
- if (!amount) {
2549
- return "";
2550
- }
2551
- if (currencyTemplate) {
2552
- return addParamsToLabel(currencyTemplate, amount);
2553
- }
2554
- return `${amount} ${currency}`;
2555
- };
2556
- const formatPriceSummary = ([min, max], currency, separator = ",", currencyTemplate = "") => {
2557
- if (min !== void 0 && max !== void 0) {
2558
- return `${formatPrice(min, currency, separator, currencyTemplate)} - ${formatPrice(
2559
- max,
2560
- currency,
2561
- separator,
2562
- currencyTemplate
2563
- )}`;
2564
- }
2565
- if (min !== void 0) {
2566
- return `> ${formatPrice(min, currency, separator, currencyTemplate)}`;
2567
- }
2568
- return `< ${formatPrice(max, currency, separator, currencyTemplate)}`;
2569
- };
2570
- const getTranslatedFacetKey = (facet, translations) => {
2571
- var _a, _b;
2572
- return (_b = (_a = translations == null ? void 0 : translations.keyTranslations) == null ? void 0 : _a[facet.key]) != null ? _b : facet.label;
2573
- };
2574
- const getTranslatedFacetValue = (facet, value, translations) => {
2575
- var _a, _b, _c;
2576
- return (_c = (_b = (_a = translations == null ? void 0 : translations.valueTranslations) == null ? void 0 : _a[facet.key]) == null ? void 0 : _b[value == null ? void 0 : value.title]) != null ? _c : value.title;
2577
- };
2578
- const formatRange = (filter2) => {
2579
- var _a, _b;
2580
- const lt = (_a = filter2.lt) != null ? _a : filter2.lte;
2581
- const gt = (_b = filter2.gt) != null ? _b : filter2.gte;
2582
- if (gt !== void 0 && lt !== void 0) {
2583
- return `${gt} - ${lt}`;
2584
- }
2585
- if (lt !== void 0) {
2586
- return `<${filter2.lte !== void 0 ? "=" : ""} ${lt}`;
2587
- }
2588
- return `>${filter2.gte !== void 0 ? "=" : ""} ${gt}`;
2589
- };
2590
- const unfoldTermFilter = (key, filter2) => {
2591
- const seed = [];
2592
- return filter2.reduce((a, c2) => [...a, { key, value: c2, type: "terms" }], seed);
2593
- };
2594
- const unfoldHierarchyFilter = (key, filter2) => {
2595
- const seed = [];
2596
- return filter2.terms.reduce((a, c2) => [...a, { key, value: c2, type: "hierarchy" }], seed);
2597
- };
2598
- const unfoldRangeFilter = (key, filter2, price = {}) => {
2599
- var _a;
2600
- const gt = filter2.gte || filter2.gt;
2601
- const lt = filter2.lte || filter2.lt;
2602
- if (key.includes(CURRENCY_KEY_INDICATOR) || ((_a = price == null ? void 0 : price.keys) == null ? void 0 : _a.includes(key))) {
2603
- return [
2604
- {
2605
- key,
2606
- value: formatPriceSummary(
2607
- [gt, lt],
2608
- price.currency,
2609
- price.separator,
2610
- price.currencyTemplate
2611
- ),
2612
- type: "range"
2613
- }
2614
- ];
2615
- }
2616
- return [{ key, value: `${gt} - ${lt}`, type: "range" }];
2617
- };
2618
- const unfoldFilter = (key, filter2, price = {}) => {
2619
- if (Array.isArray(filter2)) {
2620
- return unfoldTermFilter(key, filter2);
2621
- }
2622
- if (filter2.gte) {
2623
- return unfoldRangeFilter(key, filter2, price);
2624
- }
2625
- if (filter2.terms) {
2626
- return unfoldHierarchyFilter(key, filter2);
2627
- }
2628
- return [];
2629
- };
2630
- const unfoldFilters = (filters, price = {}) => {
2631
- if (!filters) {
2632
- return [];
2633
- }
2634
- const seed = [];
2635
- return Object.entries(filters).reduce((a, c2) => [...a, ...unfoldFilter(...c2, price)], seed);
2636
- };
2637
- const getLabeledFilters = (filters, facets2, translations) => {
2638
- return filters.map((f2) => {
2639
- var _a, _b, _c, _d;
2640
- return __spreadProps(__spreadValues({}, f2), {
2641
- label: (_d = (_c = (_a = translations == null ? void 0 : translations.keyTranslations) == null ? void 0 : _a[f2.key]) != null ? _c : (_b = facets2 == null ? void 0 : facets2.find((ft) => ft.key === f2.key)) == null ? void 0 : _b.label) != null ? _d : capitalize$1(f2.key),
2642
- value: getTranslatedFacetValue({ key: f2.key }, { title: f2.value }, translations)
2643
- });
2644
- });
2645
- };
2646
- const isFacetKey = (key) => key.startsWith(FACET_PARAMS_TYPE.RANGE) || key.startsWith(FACET_PARAMS_TYPE.TERMS) || key.startsWith(FACET_PARAMS_TYPE.HIERARCHY);
2647
- const getMostSpecificHierarchyTerms = (terms) => {
2648
- const specificTerms = [];
2649
- for (const term of terms) {
2650
- if (!terms.some((t) => t.startsWith(term) && t !== term)) {
2651
- specificTerms.push(term);
2652
- }
2653
- }
2654
- return Array.from(new Set(specificTerms));
2655
- };
2656
- const recursiveFilter = (items, query = "") => {
2657
- if (!query) {
2658
- return items;
2659
- }
2660
- return items.map((i) => recursiveFilterItem(i, query)).filter(Boolean);
2661
- };
2662
- const recursiveFilterItem = (item, query = "") => {
2663
- const filterable = getNormalizedString(item.title).includes(getNormalizedString(query)) ? item : void 0;
2664
- if (!item.children) {
2665
- return filterable;
2666
- }
2667
- const children = recursiveFilter(item.children, query).filter(Boolean);
2668
- const include = children.length > 0 || filterable;
2669
- return include ? __spreadProps(__spreadValues({}, item), {
2670
- children
2671
- }) : void 0;
2672
- };
2673
- const rangeFilterToString = (rangeFilter, separator) => {
2674
- separator = separator || FACET_TERM_RANGE_SEPARATOR;
2675
- return rangeFilter && Object.keys(rangeFilter).length ? rangeFilter.gte + separator + (rangeFilter.lte || rangeFilter.lt) : "";
2676
- };
2677
- const pick = (obj, keys) => {
2678
- const ret = /* @__PURE__ */ Object.create({});
2679
- for (const k of keys) {
2680
- ret[k] = obj[k];
2681
- }
2682
- return ret;
2683
- };
2684
- const getHint = (suggestion, inputValue) => {
2685
- var _a;
2686
- if (!inputValue) {
2687
- return escapeHtml$1(suggestion);
2688
- }
2689
- return (_a = suggestion == null ? void 0 : suggestion.replace(
2690
- inputValue == null ? void 0 : inputValue.toLocaleLowerCase(),
2691
- `<strong>${escapeHtml$1(inputValue == null ? void 0 : inputValue.toLocaleLowerCase())}</strong>`
2692
- )) != null ? _a : "";
2693
- };
2694
- const reverseKeyValue = (obj) => {
2695
- return Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k.toLowerCase()]));
2696
- };
2697
- const getPageCount = (total, limit) => {
2698
- return Math.ceil(total / limit) || 0;
2699
- };
2700
- const isObject$1 = (value) => {
2701
- return value !== null && typeof value === "object" && !Array.isArray(value);
2702
- };
2703
- const parseParam = (key, params) => {
2704
- const value = params.get(key);
2705
- if (!value) {
2706
- return void 0;
2707
- }
2708
- try {
2709
- return decodeURIComponent(value);
2710
- } catch (e2) {
2711
- return void 0;
2712
- }
2713
- };
2714
- const parseRegularKeys = (regularKeys, searchParams, getQueryParamName) => {
2715
- const params = /* @__PURE__ */ Object.create({});
2716
- const keys = reverseKeyValue({
2717
- QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS.QUERY) : QUERY_PARAMS.QUERY,
2718
- LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS.LIMIT) : QUERY_PARAMS.LIMIT,
2719
- PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE,
2720
- SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS.SORT) : QUERY_PARAMS.SORT
2721
- });
2722
- for (const key of regularKeys) {
2723
- const rawKey = keys[key] || key;
2724
- params[rawKey] = parseParam(key, searchParams);
2725
- }
2726
- return params;
2727
- };
2728
- const parseFacetKey = (key, searchParams) => {
2729
- var _a, _b, _c, _d;
2730
- if (key.startsWith(FACET_PARAMS_TYPE.TERMS)) {
2731
- return (_b = (_a = searchParams.getAll(key)) == null ? void 0 : _a.map((v) => decodeURIComponent(v))) != null ? _b : [];
2732
- }
2733
- if (key.startsWith(FACET_PARAMS_TYPE.RANGE)) {
2734
- const range = searchParams.get(key);
2735
- if (!range) {
2736
- return {};
2737
- }
2738
- const [min, max] = range.split(FACET_RANGE_SEPARATOR);
2739
- return {
2740
- gte: min,
2741
- lte: max
2742
- };
2743
- }
2744
- if (key.startsWith(FACET_PARAMS_TYPE.HIERARCHY)) {
2745
- return {
2746
- level: 0,
2747
- terms: (_d = (_c = searchParams.getAll(key)) == null ? void 0 : _c.map((v) => decodeURIComponent(v))) != null ? _d : []
2748
- };
2749
- }
2750
- return [];
2751
- };
2752
- const parseFacetKeys = (facetKeys, searchParams) => {
2753
- const params = {};
2754
- params.filters = {};
2755
- for (const key of facetKeys) {
2756
- const parsedKey = key.slice(key.indexOf(FACET_KEY_SEPARATOR) + 1);
2757
- params.filters = __spreadProps(__spreadValues({}, params.filters), {
2758
- [parsedKey]: parseFacetKey(key, searchParams)
2759
- });
2760
- }
2761
- return params;
2762
- };
2763
- const parseParams = (getQueryParamName, searchParams) => {
2764
- const params = /* @__PURE__ */ Object.create({});
2765
- if (!searchParams)
2766
- return params;
2767
- const paramKeys = Array.from(searchParams.keys());
2768
- const facetKeys = paramKeys.filter((k) => isFacetKey(k));
2769
- const regularKeys = paramKeys.filter((k) => !isFacetKey(k));
2770
- const r = __spreadValues(__spreadValues({
2771
- [QUERY_PARAMS_PARSED.QUERY]: ""
2772
- }, parseRegularKeys(regularKeys, searchParams, getQueryParamName)), parseFacetKeys(facetKeys, searchParams));
2773
- return r;
2774
- };
2775
- const appendParam = (url, { name, value }, encode2 = true) => {
2776
- if (Array.isArray(value)) {
2777
- appendArrayParams(url, { name, value });
2778
- } else {
2779
- appendSingleParam(url, { name, value }, encode2);
2780
- }
2781
- };
2782
- const appendSingleParam = (url, param, encode2 = true) => {
2783
- const valueToAppend = encode2 ? encodeParam(param.value) : param.value;
2784
- if (url.searchParams.has(param.name)) {
2785
- url.searchParams.set(param.name, valueToAppend);
2786
- } else {
2787
- url.searchParams.append(param.name, valueToAppend);
2788
- }
2789
- };
2790
- const appendArrayParams = (url, param) => {
2791
- url.searchParams.delete(param.name);
2792
- param.value.forEach((v) => url.searchParams.append(param.name, encodeParam(v)));
2793
- };
2794
- const getRemovableParams = (url, getQueryParamName, paramsToRemove) => {
2795
- if (paramsToRemove === "all") {
2796
- const params = {
2797
- QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS.QUERY) : QUERY_PARAMS.QUERY,
2798
- LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS.LIMIT) : QUERY_PARAMS.LIMIT,
2799
- PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE,
2800
- SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS.SORT) : QUERY_PARAMS.SORT
2801
- };
2802
- return [
2803
- ...Object.values(params),
2804
- ...Array.from(url.searchParams.keys()).filter((k) => isFacetKey(k))
2805
- ];
2806
- }
2807
- return paramsToRemove;
2808
- };
2809
- const removeParams = (url, params = []) => {
2810
- for (const param of params) {
2811
- if (url.searchParams.has(param)) {
2812
- url.searchParams.delete(param);
2813
- }
2814
- }
2815
- };
2816
- const encodeParam = (param) => {
2817
- const encoded = encodeURIComponent(param);
2818
- return encoded.replace(/%C4%85/g, "ą").replace(/%C4%8D/g, "č").replace(/%C4%99/g, "ę").replace(/%C4%97/g, "ė").replace(/%C4%AF/g, "į").replace(/%C5%A1/g, "š").replace(/%C5%B3/g, "ų").replace(/%C5%AB/g, "ū").replace(/%C5%BE/g, "ž").replace(/%20/g, " ");
2819
- };
2820
- const getQueryParam = (name) => {
2821
- try {
2822
- const urlParams = new URLSearchParams(window.location.search);
2823
- return urlParams.get(name);
2824
- } catch (e2) {
2825
- return null;
2826
- }
2827
- };
2828
- const PATH_REPLACE_REGEXP = /{(.*?)}/gm;
2829
- const generateLink = (linkPattern, document2) => {
2830
- const matches = linkPattern.match(PATH_REPLACE_REGEXP);
2831
- if (!matches) {
2832
- return linkPattern;
2833
- }
2834
- let link = linkPattern;
2835
- for (const match of matches) {
2836
- const propertyKey = match.slice(1, match.length - 1);
2837
- const property = document2[propertyKey] || "";
2838
- link = link.replace(match, property);
2839
- }
2840
- return link;
2841
- };
2842
- const generateResultLink = (link, getQueryParamName, searchText, facet) => {
2843
- if (!searchText) {
2844
- return link;
2845
- }
2846
- const facetParam = facet ? `&${FACET_PARAMS_TYPE.TERMS}${encodeParam(facet.key)}=${encodeParam(facet.title)}` : "";
2847
- const queryParam = `?${getQueryParamName ? getQueryParamName(QUERY_PARAMS.QUERY) : QUERY_PARAMS.QUERY}=${encodeParam(searchText)}`;
2848
- return `${link}${queryParam}${facetParam}`;
2849
- };
2850
- const getRelativePath = (link) => {
2851
- try {
2852
- const url = new URL(link);
2853
- const partialUrl = url.toString().substring(url.origin.length);
2854
- return partialUrl.endsWith("/") ? partialUrl.slice(0, partialUrl.length - 1) : partialUrl;
2855
- } catch (e2) {
2856
- return (link == null ? void 0 : link.endsWith("/")) ? link.slice(0, link.length - 1) : link;
2857
- }
2858
- };
2859
- const linksMatch = (link1, link2) => {
2860
- if (!link1 || !link2) {
2861
- return false;
2862
- }
2863
- return link1 === link2 || getRelativePath(link1) === getRelativePath(link2);
2864
- };
2865
- const emitRoutingEvent = (url) => {
2866
- const event = new CustomEvent(LUPA_ROUTING_EVENT, { detail: url });
2867
- window.dispatchEvent(event);
2868
- };
2869
- const handleRoutingEvent = (link, event, hasEventRouting = false) => {
2870
- if (!hasEventRouting) {
2871
- return;
2872
- }
2873
- event == null ? void 0 : event.preventDefault();
2874
- emitRoutingEvent(link);
2875
- };
2876
- const redirectToResultsPage = (link, searchText, getQueryParamName, facet, routingBehavior = "direct-link") => {
2877
- const url = generateResultLink(link, getQueryParamName, searchText, facet);
2878
- if (routingBehavior === "event") {
2879
- emitRoutingEvent(url);
2880
- } else {
2881
- window.location.assign(url);
2882
- }
2883
- };
2884
- const getPageUrl = (pathnameOverride, ssr) => {
2885
- if (typeof window !== "undefined") {
2886
- const pathname = pathnameOverride || window.location.pathname;
2887
- const origin = window.location.origin;
2888
- const search2 = window.location.search;
2889
- return new URL(origin + pathname + search2);
2890
- }
2891
- return new URL(ssr.url, ssr.baseUrl);
2892
- };
2893
- const getFacetKey = (key, type) => {
2894
- return `${FACET_FILTER_MAP[type]}${key}`;
2895
- };
2896
- const getFacetParam = (key, value, type = FACET_PARAMS_TYPE.TERMS) => {
2897
- return {
2898
- name: `${type}${key}`,
2899
- value
2900
- };
2901
- };
2902
- const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentFilters, paramsToRemove = []) => {
2903
- const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
2904
- const newParams = toggleTermParam(currentFilter, facetAction.value);
2905
- appendParams({
2906
- params: [getFacetParam(facetAction.key, newParams)],
2907
- paramsToRemove: [
2908
- ...paramsToRemove,
2909
- ...[getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE]
2910
- ]
2911
- });
2912
- };
2913
- const replaceHierarchyParam = (params = [], param = "") => {
2914
- if (params.some((p2) => p2.startsWith(param))) {
2915
- return toggleLastPram(params, param);
2916
- }
2917
- return [param];
2918
- };
2919
- const toggleHierarchyFilter = (appendParams, facetAction, getQueryParamName, currentFilters, removeAllLevels = false) => {
2920
- var _a, _b;
2921
- const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
2922
- const newParams = facetAction.behavior === "replace" ? replaceHierarchyParam((_a = currentFilter == null ? void 0 : currentFilter.terms) != null ? _a : [], facetAction.value) : toggleHierarchyParam((_b = currentFilter == null ? void 0 : currentFilter.terms) != null ? _b : [], facetAction.value, removeAllLevels);
2923
- appendParams({
2924
- params: [getFacetParam(facetAction.key, newParams, FACET_PARAMS_TYPE.HIERARCHY)],
2925
- paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE]
2926
- });
2927
- };
2928
- const toggleRangeFilter = (appendParams, facetAction, getQueryParamName, currentFilters) => {
2929
- const currentFilter = rangeFilterToString(
2930
- currentFilters == null ? void 0 : currentFilters[facetAction.key],
2931
- FACET_RANGE_SEPARATOR
2932
- );
2933
- let facetValue = facetAction.value.join(FACET_RANGE_SEPARATOR);
2934
- facetValue = currentFilter === facetValue ? "" : facetValue;
2935
- appendParams({
2936
- params: [getFacetParam(facetAction.key, facetValue, FACET_PARAMS_TYPE.RANGE)],
2937
- paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE],
2938
- encode: false
2939
- });
2940
- };
2941
- const toggleTermParam = (params = [], param = "") => {
2942
- if (params == null ? void 0 : params.includes(param)) {
2943
- return params.filter((p2) => p2 !== param);
2944
- }
2945
- return [param, ...params];
2946
- };
2947
- const toggleLastPram = (params = [], param = "") => {
2948
- const paramLevel = param.split(">").length;
2949
- return getMostSpecificHierarchyTerms(
2950
- params.map(
2951
- (p2) => p2.startsWith(param) ? p2.split(HIERARCHY_SEPARATOR).slice(0, paramLevel - 1).join(HIERARCHY_SEPARATOR).trim() : p2
2952
- ).filter(Boolean)
2953
- );
2954
- };
2955
- const toggleHierarchyParam = (params = [], param = "", removeAllLevels = false) => {
2956
- if (params == null ? void 0 : params.some((p2) => p2.startsWith(param))) {
2957
- return removeAllLevels ? getMostSpecificHierarchyTerms(params.filter((p2) => !p2.startsWith(param))) : toggleLastPram(params, param);
2958
- }
2959
- return getMostSpecificHierarchyTerms([param, ...params]);
2960
- };
2961
- const CACHE_KEY = "lupasearch-client-redirections";
2962
- const useRedirectionStore = defineStore("redirections", () => {
2963
- const redirections = ref({ rules: [] });
2964
- const redirectionOptions = ref({ enabled: false, queryKey: "" });
2965
- const saveToLocalStorage = () => {
2966
- try {
2967
- localStorage.setItem(
2968
- CACHE_KEY,
2969
- JSON.stringify({
2970
- redirections: redirections.value,
2971
- savedAt: Date.now(),
2972
- queryKey: redirectionOptions.value.queryKey
2973
- })
2974
- );
2975
- } catch (e2) {
2976
- }
2977
- };
2978
- const tryLoadFromLocalStorage = (config) => {
2979
- var _a;
2980
- if (!config.cacheSeconds)
2981
- return false;
2982
- try {
2983
- const data = JSON.parse((_a = localStorage.getItem(CACHE_KEY)) != null ? _a : "");
2984
- if (data.queryKey !== config.queryKey) {
2985
- return false;
2986
- }
2987
- if ((data == null ? void 0 : data.redirections) && Date.now() - data.savedAt < 1e3 * config.cacheSeconds) {
2988
- redirections.value = data.redirections;
2989
- return true;
2990
- }
2991
- } catch (e2) {
2992
- }
2993
- return false;
2994
- };
2995
- const initiate = (config, options) => __async(void 0, null, function* () {
2996
- var _a, _b, _c, _d;
2997
- if ((_a = redirectionOptions.value) == null ? void 0 : _a.enabled) {
2998
- return;
2999
- }
3000
- redirectionOptions.value = config;
3001
- if (!(config == null ? void 0 : config.enabled)) {
3002
- return;
3003
- }
3004
- const loaded = tryLoadFromLocalStorage(config);
3005
- if (loaded || ((_c = (_b = redirections.value) == null ? void 0 : _b.rules) == null ? void 0 : _c.length) > 0) {
3006
- return;
3007
- }
3008
- try {
3009
- const result2 = yield LupaSearchSdk.loadRedirectionRules(config.queryKey, options);
3010
- if (!((_d = result2 == null ? void 0 : result2.rules) == null ? void 0 : _d.length)) {
3011
- redirections.value = { rules: [] };
3012
- return;
3013
- }
3014
- redirections.value = result2;
3015
- saveToLocalStorage();
3016
- } catch (e2) {
3017
- }
3018
- });
3019
- const redirectOnKeywordIfConfigured = (input2, routingBehavior = "direct-link") => {
3020
- var _a, _b, _c, _d;
3021
- if (!((_b = (_a = redirections.value) == null ? void 0 : _a.rules) == null ? void 0 : _b.length)) {
3022
- return false;
3023
- }
3024
- const redirectTo = redirections.value.rules.find((r) => inputsAreEqual(input2, r.sources));
3025
- if (!redirectTo) {
3026
- return false;
3027
- }
3028
- const url = ((_c = redirectionOptions.value) == null ? void 0 : _c.urlTransformer) ? (_d = redirectionOptions.value) == null ? void 0 : _d.urlTransformer(redirectTo == null ? void 0 : redirectTo.target) : redirectTo == null ? void 0 : redirectTo.target;
3029
- if (url === void 0 || url === null || url === "") {
3030
- return false;
3031
- }
3032
- if (routingBehavior === "event") {
3033
- emitRoutingEvent(url);
3034
- } else {
3035
- window.location.assign(url);
3036
- }
3037
- return true;
3038
- };
3039
- return {
3040
- redirections,
3041
- redirectOnKeywordIfConfigured,
3042
- initiate
3043
- };
3044
- });
3045
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
3046
- function getDefaultExportFromCjs(x2) {
3047
- return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
3048
- }
3049
- function getAugmentedNamespace(n) {
3050
- if (n.__esModule)
3051
- return n;
3052
- var f2 = n.default;
3053
- if (typeof f2 == "function") {
3054
- var a = function a2() {
3055
- if (this instanceof a2) {
3056
- var args = [null];
3057
- args.push.apply(args, arguments);
3058
- var Ctor = Function.bind.apply(f2, args);
3059
- return new Ctor();
3060
- }
3061
- return f2.apply(this, arguments);
3062
- };
3063
- a.prototype = f2.prototype;
3064
- } else
3065
- a = {};
3066
- Object.defineProperty(a, "__esModule", { value: true });
3067
- Object.keys(n).forEach(function(k) {
3068
- var d2 = Object.getOwnPropertyDescriptor(n, k);
3069
- Object.defineProperty(a, k, d2.get ? d2 : {
3070
- enumerable: true,
3071
- get: function() {
3072
- return n[k];
3073
- }
3074
- });
1780
+ a.prototype = f2.prototype;
1781
+ } else
1782
+ a = {};
1783
+ Object.defineProperty(a, "__esModule", { value: true });
1784
+ Object.keys(n).forEach(function(k) {
1785
+ var d2 = Object.getOwnPropertyDescriptor(n, k);
1786
+ Object.defineProperty(a, k, d2.get ? d2 : {
1787
+ enumerable: true,
1788
+ get: function() {
1789
+ return n[k];
1790
+ }
1791
+ });
3075
1792
  });
3076
1793
  return a;
3077
1794
  }
@@ -8545,18 +7262,1309 @@ lodash.exports;
8545
7262
  if (symIterator) {
8546
7263
  lodash2.prototype[symIterator] = wrapperToIterator;
8547
7264
  }
8548
- return lodash2;
8549
- };
8550
- var _ = runInContext();
8551
- if (freeModule) {
8552
- (freeModule.exports = _)._ = _;
8553
- freeExports._ = _;
7265
+ return lodash2;
7266
+ };
7267
+ var _ = runInContext();
7268
+ if (freeModule) {
7269
+ (freeModule.exports = _)._ = _;
7270
+ freeExports._ = _;
7271
+ } else {
7272
+ root2._ = _;
7273
+ }
7274
+ }).call(commonjsGlobal);
7275
+ })(lodash, lodash.exports);
7276
+ var lodashExports = lodash.exports;
7277
+ const getNormalizedString = (str) => {
7278
+ var _a, _b;
7279
+ if (!str) {
7280
+ return "";
7281
+ }
7282
+ const transformedStr = typeof str === "string" ? str : str.toString();
7283
+ return transformedStr.normalize === void 0 ? (_a = transformedStr.toLocaleLowerCase()) == null ? void 0 : _a.trim() : (_b = transformedStr.toLocaleLowerCase().normalize("NFKD").replace(/[^\w\s.-_/]/g, "")) == null ? void 0 : _b.trim();
7284
+ };
7285
+ const getTransformedString = (str) => {
7286
+ var _a, _b;
7287
+ if (!str) {
7288
+ return "";
7289
+ }
7290
+ const transformedStr = typeof str === "string" ? str : str.toString();
7291
+ return transformedStr.normalize === void 0 ? (_a = transformedStr.toLocaleLowerCase()) == null ? void 0 : _a.trim() : (_b = transformedStr.toLocaleLowerCase().normalize("NFKD")) == null ? void 0 : _b.trim();
7292
+ };
7293
+ const capitalize$1 = (str) => {
7294
+ if (!str) {
7295
+ return "";
7296
+ }
7297
+ return str[0].toLocaleUpperCase() + str.slice(1);
7298
+ };
7299
+ const addParamsToLabel = (label, ...params) => {
7300
+ if (!params || params.length < 1) {
7301
+ return label;
7302
+ }
7303
+ const paramKeys = Array.from(Array(params.length).keys());
7304
+ return paramKeys.reduce((a, c2) => a.replace(`{${c2 + 1}}`, params[c2]), label);
7305
+ };
7306
+ const getRandomString = (length) => {
7307
+ const chars = "0123456789abcdefghijklmnopqrstuvwxyz";
7308
+ let result2 = "";
7309
+ for (let i = length; i > 0; --i) {
7310
+ result2 += chars[Math.floor(Math.random() * chars.length)];
7311
+ }
7312
+ return result2;
7313
+ };
7314
+ const toFixedIfNecessary = (value, precision = 2) => {
7315
+ return (+parseFloat(value).toFixed(precision)).toString();
7316
+ };
7317
+ const getDisplayValue = (value) => {
7318
+ if (value === void 0) {
7319
+ return "";
7320
+ }
7321
+ if (typeof value === "string") {
7322
+ return value;
7323
+ }
7324
+ return toFixedIfNecessary(value.toString());
7325
+ };
7326
+ const getProductKey = (index, product, idKey) => {
7327
+ if (!idKey) {
7328
+ return index;
7329
+ }
7330
+ if (product[idKey]) {
7331
+ return product[idKey];
7332
+ }
7333
+ return index;
7334
+ };
7335
+ const normalizeFloat = (value) => {
7336
+ var _a;
7337
+ if (!value) {
7338
+ return 0;
7339
+ }
7340
+ return +((_a = value == null ? void 0 : value.replace(/[^0-9,.]/g, "")) == null ? void 0 : _a.replace(",", "."));
7341
+ };
7342
+ const escapeHtml$1 = (value) => {
7343
+ if (!value) {
7344
+ return "";
7345
+ }
7346
+ let output = "";
7347
+ let isSkip = false;
7348
+ value.split(/(<del>.*?<\/del>)/g).forEach((segment) => {
7349
+ if (segment.startsWith("<del>") && segment.endsWith("</del>")) {
7350
+ output += segment;
7351
+ isSkip = true;
7352
+ }
7353
+ if (!isSkip) {
7354
+ output += segment.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
7355
+ }
7356
+ if (isSkip) {
7357
+ isSkip = false;
7358
+ }
7359
+ });
7360
+ return output;
7361
+ };
7362
+ const inputsAreEqual = (input2, possibleValues) => {
7363
+ if (!input2) {
7364
+ return false;
7365
+ }
7366
+ const normalizedInput = getTransformedString(input2);
7367
+ return possibleValues.some((v) => getTransformedString(v) === normalizedInput);
7368
+ };
7369
+ const levenshteinDistance = (s = "", t = "") => {
7370
+ if (!(s == null ? void 0 : s.length)) {
7371
+ return t.length;
7372
+ }
7373
+ if (!(t == null ? void 0 : t.length)) {
7374
+ return s.length;
7375
+ }
7376
+ const arr = [];
7377
+ for (let i = 0; i <= t.length; i++) {
7378
+ arr[i] = [i];
7379
+ for (let j = 1; j <= s.length; j++) {
7380
+ arr[i][j] = i === 0 ? j : Math.min(
7381
+ arr[i - 1][j] + 1,
7382
+ arr[i][j - 1] + 1,
7383
+ arr[i - 1][j - 1] + (s[j - 1] === t[i - 1] ? 0 : 1)
7384
+ );
7385
+ }
7386
+ }
7387
+ return arr[t.length][s.length];
7388
+ };
7389
+ const findClosestStringValue = (input2, possibleValues, key) => {
7390
+ var _a;
7391
+ const directMatch = possibleValues.find((v) => v[key] === input2);
7392
+ if (directMatch) {
7393
+ return directMatch;
7394
+ }
7395
+ const distances = possibleValues.map((v) => levenshteinDistance(`${v[key]}`, input2));
7396
+ const minDistance = Math.min(...distances);
7397
+ const closestValue = (_a = possibleValues.filter((_, i) => distances[i] === minDistance)) == null ? void 0 : _a[0];
7398
+ return closestValue;
7399
+ };
7400
+ const slugifyClass = (s) => {
7401
+ let slug = lodashExports.kebabCase(s);
7402
+ if (!slug || /^[0-9-]/.test(slug)) {
7403
+ slug = `c-${slug}`;
7404
+ }
7405
+ return slug;
7406
+ };
7407
+ const DEFAULT_SEARCH_BOX_OPTIONS = {
7408
+ inputSelector: "#searchBox",
7409
+ options: {
7410
+ environment: "production"
7411
+ },
7412
+ showTotalCount: false,
7413
+ minInputLength: 1,
7414
+ inputAttributes: {
7415
+ name: "q"
7416
+ },
7417
+ debounce: 0,
7418
+ labels: {
7419
+ placeholder: "Search for products...",
7420
+ noResults: "There are no results found.",
7421
+ moreResults: "Show more results",
7422
+ currency: "€",
7423
+ defaultFacetLabel: "Category:"
7424
+ },
7425
+ links: {
7426
+ searchResults: "/search"
7427
+ },
7428
+ panels: [
7429
+ {
7430
+ type: "suggestion",
7431
+ queryKey: "",
7432
+ highlight: true,
7433
+ limit: 5
7434
+ },
7435
+ {
7436
+ type: "document",
7437
+ queryKey: "",
7438
+ limit: 5,
7439
+ searchBySuggestion: false,
7440
+ links: {
7441
+ details: "{url}"
7442
+ },
7443
+ titleKey: "name",
7444
+ elements: []
7445
+ }
7446
+ ],
7447
+ history: {
7448
+ labels: {
7449
+ clear: "Clear History"
7450
+ }
7451
+ }
7452
+ };
7453
+ const DEFAULT_OPTIONS_RESULTS = {
7454
+ options: {
7455
+ environment: "production"
7456
+ },
7457
+ queryKey: "",
7458
+ containerSelector: "#searchResultsContainer",
7459
+ searchTitlePosition: "page-top",
7460
+ labels: {
7461
+ pageSize: "Page size:",
7462
+ sortBy: "Sort by:",
7463
+ itemCount: "Items {1} of {2}",
7464
+ filteredItemCount: "",
7465
+ currency: "€",
7466
+ showMore: "Show more",
7467
+ searchResults: "Search Query: ",
7468
+ emptyResults: "There are no results for the query:",
7469
+ mobileFilterButton: "Filter",
7470
+ htmlTitleTemplate: "Search Query: '{1}'",
7471
+ noResultsSuggestion: "No results found for this query: {1}",
7472
+ didYouMean: "Did you mean to search: {1}",
7473
+ similarQuery: "Search results for phrase {1}",
7474
+ similarQueries: "Similar queries:",
7475
+ similarResultsLabel: "Related to your query:"
7476
+ },
7477
+ grid: {
7478
+ columns: {
7479
+ xl: 4,
7480
+ l: 3,
7481
+ md: 2,
7482
+ sm: 2,
7483
+ xs: 1
7484
+ }
7485
+ },
7486
+ pagination: {
7487
+ sizeSelection: {
7488
+ position: {
7489
+ top: false,
7490
+ bottom: true
7491
+ },
7492
+ sizes: [10, 20, 25]
7493
+ },
7494
+ pageSelection: {
7495
+ position: {
7496
+ top: false,
7497
+ bottom: true
7498
+ },
7499
+ display: 5,
7500
+ displayMobile: 3
7501
+ }
7502
+ },
7503
+ sort: [],
7504
+ filters: {
7505
+ currentFilters: {
7506
+ visibility: {
7507
+ mobileSidebar: true,
7508
+ mobileToolbar: true
7509
+ },
7510
+ labels: {
7511
+ title: "Current filters:",
7512
+ clearAll: "Clear all"
7513
+ }
7514
+ },
7515
+ facets: {
7516
+ labels: {
7517
+ title: "Filters:",
7518
+ showAll: "Show more",
7519
+ facetFilter: "Filter...",
7520
+ facetClear: "Clear"
7521
+ },
7522
+ filterable: {
7523
+ minValues: 5
7524
+ },
7525
+ hierarchy: {
7526
+ maxInitialLevel: 2,
7527
+ topLevelValueCountLimit: 5,
7528
+ filterable: true
7529
+ },
7530
+ facetValueCountLimit: 20,
7531
+ showDocumentCount: true,
7532
+ style: {
7533
+ type: "sidebar"
7534
+ }
7535
+ }
7536
+ },
7537
+ toolbar: {
7538
+ layoutSelector: true,
7539
+ itemSummary: true,
7540
+ clearFilters: false
7541
+ },
7542
+ isInStock: () => {
7543
+ return true;
7544
+ },
7545
+ badges: {
7546
+ anchor: "tr",
7547
+ elements: []
7548
+ },
7549
+ links: {
7550
+ details: "/{id}"
7551
+ },
7552
+ elements: [],
7553
+ breadcrumbs: []
7554
+ };
7555
+ const useScreenStore = defineStore("screen", () => {
7556
+ const measuredScreenWidth = ref(1e3);
7557
+ const optionsStore = useOptionsStore();
7558
+ const screenWidth = computed(() => {
7559
+ var _a, _b;
7560
+ const { searchResultOptions } = storeToRefs(optionsStore);
7561
+ return (_b = (_a = searchResultOptions.value.grid) == null ? void 0 : _a.forcedScreenWidth) != null ? _b : measuredScreenWidth.value;
7562
+ });
7563
+ const configuredGridSizes = computed(() => {
7564
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
7565
+ const { searchResultOptions } = storeToRefs(optionsStore);
7566
+ return {
7567
+ smMin: (_d = (_c = (_b = (_a = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _a.grid) == null ? void 0 : _b.sizes) == null ? void 0 : _c.sm) != null ? _d : S_MIN_WIDTH,
7568
+ mdMin: (_h = (_g = (_f = (_e = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _e.grid) == null ? void 0 : _f.sizes) == null ? void 0 : _g.md) != null ? _h : MD_MIN_WIDTH,
7569
+ lMin: (_l = (_k = (_j = (_i = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _i.grid) == null ? void 0 : _j.sizes) == null ? void 0 : _k.l) != null ? _l : L_MIN_WIDTH,
7570
+ xlMin: (_p = (_o = (_n = (_m = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _m.grid) == null ? void 0 : _n.sizes) == null ? void 0 : _o.xl) != null ? _p : XL_MIN_WIDTH
7571
+ };
7572
+ });
7573
+ const currentScreenWidth = computed(() => {
7574
+ const width = screenWidth.value;
7575
+ if (width <= configuredGridSizes.value.smMin) {
7576
+ return "xs";
7577
+ } else if (width > configuredGridSizes.value.smMin && width <= configuredGridSizes.value.mdMin) {
7578
+ return "sm";
7579
+ } else if (width > configuredGridSizes.value.mdMin && width <= configuredGridSizes.value.lMin) {
7580
+ return "md";
7581
+ } else if (width > configuredGridSizes.value.lMin && width <= configuredGridSizes.value.xlMin) {
7582
+ return "l";
7583
+ } else {
7584
+ return "xl";
7585
+ }
7586
+ });
7587
+ const isMobileWidth = computed(() => {
7588
+ var _a;
7589
+ return (_a = ["xs", "sm"]) == null ? void 0 : _a.includes(currentScreenWidth.value);
7590
+ });
7591
+ const setScreenWidth = ({ width }) => {
7592
+ measuredScreenWidth.value = width;
7593
+ };
7594
+ return { screenWidth, currentScreenWidth, isMobileWidth, setScreenWidth };
7595
+ });
7596
+ const useOptionsStore = defineStore("options", () => {
7597
+ const searchBoxOptions = ref(
7598
+ DEFAULT_SEARCH_BOX_OPTIONS
7599
+ );
7600
+ const searchResultOptions = ref(
7601
+ DEFAULT_OPTIONS_RESULTS
7602
+ );
7603
+ const trackingOptions = ref({});
7604
+ const searchResultInitialFilters = ref({});
7605
+ const productRecommendationOptions = ref({});
7606
+ const screenStore = useScreenStore();
7607
+ const envOptions = computed(
7608
+ () => {
7609
+ var _a;
7610
+ return (_a = searchBoxOptions.value.options) != null ? _a : searchResultOptions.value.options;
7611
+ }
7612
+ );
7613
+ const classMap = computed(() => {
7614
+ var _a;
7615
+ return (_a = searchResultOptions.value.classMap) != null ? _a : {};
7616
+ });
7617
+ const initialFilters = computed(() => searchResultInitialFilters.value);
7618
+ const boxRoutingBehavior = computed(() => {
7619
+ var _a;
7620
+ return (_a = searchBoxOptions.value.routingBehavior) != null ? _a : "direct-link";
7621
+ });
7622
+ const searchResultsRoutingBehavior = computed(
7623
+ () => {
7624
+ var _a;
7625
+ return (_a = searchResultOptions.value.routingBehavior) != null ? _a : "direct-link";
7626
+ }
7627
+ );
7628
+ const defaultSearchResultPageSize = computed(
7629
+ () => {
7630
+ var _a, _b;
7631
+ return (_b = (_a = currentResolutionPageSizes.value) == null ? void 0 : _a[0]) != null ? _b : DEFAULT_PAGE_SIZE;
7632
+ }
7633
+ );
7634
+ const currentResolutionPageSizes = computed(() => {
7635
+ var _a, _b, _c, _d;
7636
+ const pageSizes = (_d = (_c = (_b = (_a = searchResultOptions.value) == null ? void 0 : _a.pagination) == null ? void 0 : _b.sizeSelection) == null ? void 0 : _c.sizes) != null ? _d : DEFAULT_PAGE_SIZE_SELECTION;
7637
+ if (Array.isArray(pageSizes)) {
7638
+ return pageSizes;
7639
+ }
7640
+ const screenSize = screenStore.currentScreenWidth;
7641
+ switch (screenSize) {
7642
+ case "xs":
7643
+ return pageSizes.xs;
7644
+ case "sm":
7645
+ return pageSizes.sm;
7646
+ case "md":
7647
+ return pageSizes.md;
7648
+ case "l":
7649
+ return pageSizes.l;
7650
+ case "xl":
7651
+ return pageSizes.xl;
7652
+ }
7653
+ });
7654
+ const setSearchBoxOptions = ({ options }) => {
7655
+ searchBoxOptions.value = options;
7656
+ };
7657
+ const setTrackingOptions = ({ options }) => {
7658
+ trackingOptions.value = options;
7659
+ };
7660
+ const setSearchResultOptions = ({ options }) => {
7661
+ searchResultOptions.value = options;
7662
+ };
7663
+ const setInitialFilters = ({ initialFilters: initialFilters2 }) => {
7664
+ searchResultInitialFilters.value = initialFilters2;
7665
+ };
7666
+ const setProductRecommendationOptions = ({
7667
+ options
7668
+ }) => {
7669
+ productRecommendationOptions.value = options;
7670
+ };
7671
+ const getQueryParamName = (param) => {
7672
+ var _a;
7673
+ const nameMap = searchBoxOptions.value.queryParameterNames;
7674
+ return (_a = nameMap == null ? void 0 : nameMap[param]) != null ? _a : param;
7675
+ };
7676
+ return {
7677
+ searchBoxOptions,
7678
+ searchResultOptions,
7679
+ trackingOptions,
7680
+ envOptions,
7681
+ classMap,
7682
+ initialFilters,
7683
+ boxRoutingBehavior,
7684
+ searchResultsRoutingBehavior,
7685
+ defaultSearchResultPageSize,
7686
+ currentResolutionPageSizes,
7687
+ productRecommendationOptions,
7688
+ setSearchBoxOptions,
7689
+ setTrackingOptions,
7690
+ setSearchResultOptions,
7691
+ setInitialFilters,
7692
+ setProductRecommendationOptions,
7693
+ getQueryParamName
7694
+ };
7695
+ });
7696
+ const initAnalyticsTracking = (analyticsOptions) => {
7697
+ try {
7698
+ if (analyticsOptions == null ? void 0 : analyticsOptions.enabled) {
7699
+ window.sessionStorage.setItem(TRACKING_ANALYTICS_KEY, JSON.stringify(analyticsOptions));
7700
+ } else {
7701
+ window.sessionStorage.removeItem(TRACKING_ANALYTICS_KEY);
7702
+ }
7703
+ } catch (e2) {
7704
+ }
7705
+ };
7706
+ const initBaseTracking = (enabled) => {
7707
+ try {
7708
+ if (enabled) {
7709
+ window.sessionStorage.setItem(TRACKING_STORAGE_KEY_BASE, "1");
7710
+ } else {
7711
+ window.sessionStorage.removeItem(TRACKING_STORAGE_KEY_BASE);
7712
+ clearSessionTracking();
7713
+ clearUserTracking();
7714
+ }
7715
+ } catch (e2) {
7716
+ }
7717
+ };
7718
+ const clearSessionTracking = () => {
7719
+ try {
7720
+ window.sessionStorage.removeItem(TRACKING_STORAGE_KEY);
7721
+ } catch (e2) {
7722
+ }
7723
+ };
7724
+ const initSessionTracking = () => {
7725
+ try {
7726
+ if (getSessionKey()) {
7727
+ return;
7728
+ }
7729
+ const key = getRandomString(TRACKING_KEY_LENGTH);
7730
+ window.sessionStorage.setItem(TRACKING_STORAGE_KEY, key);
7731
+ } catch (e2) {
7732
+ }
7733
+ };
7734
+ const initUserTracking = (userKey) => {
7735
+ try {
7736
+ if (getUserKey()) {
7737
+ return;
7738
+ }
7739
+ const key = userKey || getRandomString(TRACKING_KEY_LENGTH);
7740
+ window.localStorage.setItem(TRACKING_STORAGE_KEY, key);
7741
+ } catch (e2) {
7742
+ }
7743
+ };
7744
+ const clearUserTracking = () => {
7745
+ try {
7746
+ window.localStorage.removeItem(TRACKING_STORAGE_KEY);
7747
+ } catch (e2) {
7748
+ }
7749
+ };
7750
+ const isTrackingEnabled = () => {
7751
+ try {
7752
+ return Boolean(window.sessionStorage.getItem(TRACKING_STORAGE_KEY_BASE));
7753
+ } catch (e2) {
7754
+ return false;
7755
+ }
7756
+ };
7757
+ const isDelayedClickTracking = () => {
7758
+ try {
7759
+ return Boolean(window.localStorage.getItem(TRACKING_CLICK_DELAYED));
7760
+ } catch (e2) {
7761
+ return false;
7762
+ }
7763
+ };
7764
+ const getSessionKey = () => {
7765
+ var _a;
7766
+ try {
7767
+ return (_a = window.sessionStorage.getItem(TRACKING_STORAGE_KEY)) != null ? _a : void 0;
7768
+ } catch (e2) {
7769
+ return void 0;
7770
+ }
7771
+ };
7772
+ const getUserKey = () => {
7773
+ var _a;
7774
+ try {
7775
+ return (_a = window.localStorage.getItem(TRACKING_STORAGE_KEY)) != null ? _a : void 0;
7776
+ } catch (e2) {
7777
+ return void 0;
7778
+ }
7779
+ };
7780
+ const initTracking = (options) => {
7781
+ initBaseTracking(Boolean(options.trackBase));
7782
+ if (options.trackSession) {
7783
+ initSessionTracking();
7784
+ } else {
7785
+ clearSessionTracking();
7786
+ }
7787
+ if (options.trackUser) {
7788
+ initUserTracking(options.userKey);
7789
+ } else {
7790
+ clearUserTracking();
7791
+ }
7792
+ if (options.analytics) {
7793
+ initAnalyticsTracking(options.analytics);
7794
+ }
7795
+ if (options.delayedClickTracking) {
7796
+ window.localStorage.setItem(TRACKING_CLICK_DELAYED, "1");
7797
+ checkAndDispatchDelayedEvents();
7798
+ } else {
7799
+ window.localStorage.removeItem(TRACKING_CLICK_DELAYED);
7800
+ }
7801
+ };
7802
+ const getLupaTrackingContext = () => {
7803
+ if (!isTrackingEnabled()) {
7804
+ return {};
7805
+ }
7806
+ return {
7807
+ userId: getUserKey(),
7808
+ sessionId: getSessionKey()
7809
+ };
7810
+ };
7811
+ const trackLupaEvent = (queryKey, data = {}, options) => {
7812
+ var _a, _b;
7813
+ if (!queryKey || !data.type) {
7814
+ return;
7815
+ }
7816
+ const eventData = {
7817
+ searchQuery: (_a = data.searchQuery) != null ? _a : "",
7818
+ itemId: (_b = data.itemId) != null ? _b : "",
7819
+ name: data.type,
7820
+ userId: getUserKey(),
7821
+ sessionId: getSessionKey(),
7822
+ filters: data.filters,
7823
+ metadata: data.metadata,
7824
+ sourceItemId: data.sourceItemId
7825
+ };
7826
+ LupaSearchSdk.track(queryKey, eventData, options);
7827
+ };
7828
+ const sendGa = (name, ...args) => {
7829
+ window.ga(() => {
7830
+ const trackers = window.ga.getAll();
7831
+ const firstTracker = trackers[0];
7832
+ if (!firstTracker) {
7833
+ console.error("GA tracker not found");
7834
+ }
7835
+ const trackerName = firstTracker.get("name");
7836
+ window.ga(`${trackerName}.${name}`, ...args);
7837
+ });
7838
+ };
7839
+ const trackAnalyticsEvent = (data) => {
7840
+ var _a, _b, _c;
7841
+ try {
7842
+ const options = JSON.parse(
7843
+ (_a = window.sessionStorage.getItem(TRACKING_ANALYTICS_KEY)) != null ? _a : "{}"
7844
+ );
7845
+ if (!data.analytics || !options.enabled || ((_c = options.ignoreEvents) == null ? void 0 : _c.includes((_b = data.analytics) == null ? void 0 : _b.type))) {
7846
+ return;
7847
+ }
7848
+ switch (options.type) {
7849
+ case "ua":
7850
+ sendUaAnalyticsEvent(data, options);
7851
+ break;
7852
+ case "ga4":
7853
+ sendGa4AnalyticsEvent(data, options);
7854
+ break;
7855
+ case "debug":
7856
+ processDebugEvent(data);
7857
+ break;
7858
+ default:
7859
+ sendUaAnalyticsEvent(data, options);
7860
+ }
7861
+ } catch (e2) {
7862
+ console.error("Unable to send an event to google analytics");
7863
+ }
7864
+ };
7865
+ const parseEcommerceData = (data, title) => {
7866
+ var _a, _b;
7867
+ return ((_a = data.analytics) == null ? void 0 : _a.items) ? {
7868
+ item_list_name: title,
7869
+ items: (_b = data.analytics) == null ? void 0 : _b.items
7870
+ } : void 0;
7871
+ };
7872
+ const sendUaAnalyticsEvent = (data, options) => {
7873
+ var _a, _b, _c, _d;
7874
+ const ga = window.ga;
7875
+ if (!ga) {
7876
+ console.error("Google Analytics object not found");
7877
+ return;
7878
+ }
7879
+ sendGa(
7880
+ "send",
7881
+ "event",
7882
+ options.parentEventName,
7883
+ (_b = (_a = data.analytics) == null ? void 0 : _a.type) != null ? _b : "",
7884
+ (_d = (_c = data.analytics) == null ? void 0 : _c.label) != null ? _d : ""
7885
+ );
7886
+ };
7887
+ const sendGa4AnalyticsEvent = (data, options) => {
7888
+ var _a, _b, _c, _d, _e, _f, _g;
7889
+ if (!window || !window.dataLayer) {
7890
+ console.error("dataLayer object not found.");
7891
+ return;
7892
+ }
7893
+ const sendItemTitle = data.searchQuery !== ((_a = data.analytics) == null ? void 0 : _a.label);
7894
+ const title = sendItemTitle ? (_b = data.analytics) == null ? void 0 : _b.label : void 0;
7895
+ const params = __spreadValues({
7896
+ search_text: data.searchQuery,
7897
+ item_title: title,
7898
+ item_id: data.itemId,
7899
+ ecommerce: parseEcommerceData(data, (_c = data.analytics) == null ? void 0 : _c.listLabel)
7900
+ }, (_e = (_d = data.analytics) == null ? void 0 : _d.additionalParams) != null ? _e : {});
7901
+ window.dataLayer.push(__spreadValues({
7902
+ event: (_g = (_f = data.analytics) == null ? void 0 : _f.type) != null ? _g : options.parentEventName
7903
+ }, params));
7904
+ };
7905
+ const processDebugEvent = (data) => {
7906
+ var _a, _b, _c, _d;
7907
+ const sendItemTitle = data.searchQuery !== ((_a = data.analytics) == null ? void 0 : _a.label);
7908
+ const title = sendItemTitle ? (_b = data.analytics) == null ? void 0 : _b.label : void 0;
7909
+ const params = {
7910
+ event: (_c = data.analytics) == null ? void 0 : _c.type,
7911
+ search_text: data.searchQuery,
7912
+ item_title: title,
7913
+ item_id: data.itemId,
7914
+ ecommerce: parseEcommerceData(data, (_d = data.analytics) == null ? void 0 : _d.listLabel)
7915
+ };
7916
+ console.debug("Analytics debug event:", params);
7917
+ };
7918
+ const getDelayedEventsCache = () => {
7919
+ var _a;
7920
+ try {
7921
+ return JSON.parse((_a = window.localStorage.getItem(DELAYED_TRACKING_EVENTS_CACHE)) != null ? _a : "{}");
7922
+ } catch (e2) {
7923
+ return {};
7924
+ }
7925
+ };
7926
+ const storeDelayedEventCache = (cache) => {
7927
+ try {
7928
+ window.localStorage.setItem(DELAYED_TRACKING_EVENTS_CACHE, JSON.stringify(cache));
7929
+ } catch (e2) {
7930
+ }
7931
+ };
7932
+ const checkAndDispatchDelayedEvents = () => {
7933
+ var _a, _b;
7934
+ const optionsStore = useOptionsStore();
7935
+ const eventCache = getDelayedEventsCache();
7936
+ const urls = Object.keys(eventCache);
7937
+ for (const url of urls) {
7938
+ if ((_a = window.location.href) == null ? void 0 : _a.includes(url)) {
7939
+ const options = (_b = optionsStore.envOptions) != null ? _b : { environment: "production" };
7940
+ const { queryKey, data } = eventCache[url];
7941
+ track(queryKey, data, options);
7942
+ }
7943
+ }
7944
+ storeDelayedEventCache({});
7945
+ };
7946
+ const track = (queryKey, data = {}, options) => {
7947
+ var _a;
7948
+ if (!isTrackingEnabled()) {
7949
+ return;
7950
+ }
7951
+ const hasSearchQuery = data.searchQuery;
7952
+ if (!hasSearchQuery && !((_a = data.options) == null ? void 0 : _a.allowEmptySearchQuery)) {
7953
+ return;
7954
+ }
7955
+ trackAnalyticsEvent(data);
7956
+ trackLupaEvent(queryKey, data, options);
7957
+ };
7958
+ var DocumentElementType = /* @__PURE__ */ ((DocumentElementType2) => {
7959
+ DocumentElementType2["IMAGE"] = "image";
7960
+ DocumentElementType2["TITLE"] = "title";
7961
+ DocumentElementType2["CUSTOM"] = "custom";
7962
+ DocumentElementType2["DESCRIPTION"] = "description";
7963
+ DocumentElementType2["PRICE"] = "price";
7964
+ DocumentElementType2["REGULARPRICE"] = "regularPrice";
7965
+ DocumentElementType2["RATING"] = "rating";
7966
+ DocumentElementType2["SINGLE_STAR_RATING"] = "singleStarRating";
7967
+ DocumentElementType2["ADDTOCART"] = "addToCart";
7968
+ DocumentElementType2["CUSTOM_HTML"] = "customHtml";
7969
+ return DocumentElementType2;
7970
+ })(DocumentElementType || {});
7971
+ var SearchBoxPanelType = /* @__PURE__ */ ((SearchBoxPanelType2) => {
7972
+ SearchBoxPanelType2["SUGGESTION"] = "suggestion";
7973
+ SearchBoxPanelType2["DOCUMENT"] = "document";
7974
+ SearchBoxPanelType2["RELATED_SOURCE"] = "related-source";
7975
+ return SearchBoxPanelType2;
7976
+ })(SearchBoxPanelType || {});
7977
+ var BadgeType = /* @__PURE__ */ ((BadgeType2) => {
7978
+ BadgeType2["NEWITEM"] = "newItem";
7979
+ BadgeType2["TEXT"] = "text";
7980
+ BadgeType2["IMAGE"] = "image";
7981
+ BadgeType2["CUSTOM_HTML"] = "customHtml";
7982
+ BadgeType2["DISCOUNT"] = "discount";
7983
+ return BadgeType2;
7984
+ })(BadgeType || {});
7985
+ const retrieveHistory = () => {
7986
+ try {
7987
+ const historyString = window.localStorage.getItem(HISTORY_LOCAL_STORAGE_KEY);
7988
+ return historyString ? JSON.parse(historyString) : [];
7989
+ } catch (e2) {
7990
+ return [];
7991
+ }
7992
+ };
7993
+ const saveHistory = (items) => {
7994
+ try {
7995
+ window.localStorage.setItem(
7996
+ HISTORY_LOCAL_STORAGE_KEY,
7997
+ JSON.stringify(items.slice(0, HISTORY_MAX_ITEMS))
7998
+ );
7999
+ } catch (e2) {
8000
+ }
8001
+ };
8002
+ const useHistoryStore = defineStore("history", () => {
8003
+ const items = ref(retrieveHistory());
8004
+ const count = computed(() => items.value.length);
8005
+ const add = ({ item }) => {
8006
+ if (!item) {
8007
+ return items.value;
8008
+ }
8009
+ const newItems = items.value ? [item, ...items.value] : [item];
8010
+ const uniqueItems = Array.from(new Set(newItems));
8011
+ items.value = uniqueItems;
8012
+ saveHistory(uniqueItems);
8013
+ return uniqueItems;
8014
+ };
8015
+ const remove = ({ item }) => {
8016
+ var _a, _b;
8017
+ const tempItems = (_b = (_a = items.value) == null ? void 0 : _a.filter((i) => i !== item)) != null ? _b : [];
8018
+ saveHistory(tempItems);
8019
+ items.value = tempItems;
8020
+ return tempItems;
8021
+ };
8022
+ const clear = () => {
8023
+ saveHistory([]);
8024
+ items.value = [];
8025
+ };
8026
+ return { items, count, add, remove, clear };
8027
+ });
8028
+ const QUERY_PARAMS = {
8029
+ QUERY: "q",
8030
+ PAGE: "p",
8031
+ LIMIT: "l",
8032
+ SORT: "s"
8033
+ };
8034
+ const QUERY_PARAMS_PARSED = {
8035
+ QUERY: "query",
8036
+ PAGE: "page",
8037
+ LIMIT: "limit",
8038
+ SORT: "sort"
8039
+ };
8040
+ const FACET_PARAMS_TYPE = {
8041
+ TERMS: "f.",
8042
+ RANGE: "fr.",
8043
+ HIERARCHY: "fh."
8044
+ };
8045
+ const FACET_FILTER_MAP = {
8046
+ terms: FACET_PARAMS_TYPE.TERMS,
8047
+ range: FACET_PARAMS_TYPE.RANGE,
8048
+ hierarchy: FACET_PARAMS_TYPE.HIERARCHY
8049
+ };
8050
+ const FACET_KEY_SEPARATOR = ".";
8051
+ const FACET_RANGE_SEPARATOR = ":";
8052
+ const HIERARCHY_SEPARATOR = ">";
8053
+ const FACET_TERM_RANGE_SEPARATOR = "-";
8054
+ const getAmount = (price, separator = ".") => {
8055
+ var _a, _b;
8056
+ if (typeof price === "number") {
8057
+ return `${(_a = price.toFixed(2)) == null ? void 0 : _a.replace(".", separator)}`;
8058
+ }
8059
+ const value = parseFloat(price);
8060
+ if (isNaN(value)) {
8061
+ return "";
8062
+ }
8063
+ return (_b = value.toFixed(2)) == null ? void 0 : _b.replace(".", separator);
8064
+ };
8065
+ const formatPrice = (price, currency = "€", separator = ",", currencyTemplate = "") => {
8066
+ if (price !== 0 && !price) {
8067
+ return "";
8068
+ }
8069
+ const amount = getAmount(price, separator);
8070
+ if (!amount) {
8071
+ return "";
8072
+ }
8073
+ if (currencyTemplate) {
8074
+ return addParamsToLabel(currencyTemplate, amount);
8075
+ }
8076
+ return `${amount} ${currency}`;
8077
+ };
8078
+ const formatPriceSummary = ([min, max], currency, separator = ",", currencyTemplate = "") => {
8079
+ if (min !== void 0 && max !== void 0) {
8080
+ return `${formatPrice(min, currency, separator, currencyTemplate)} - ${formatPrice(
8081
+ max,
8082
+ currency,
8083
+ separator,
8084
+ currencyTemplate
8085
+ )}`;
8086
+ }
8087
+ if (min !== void 0) {
8088
+ return `> ${formatPrice(min, currency, separator, currencyTemplate)}`;
8089
+ }
8090
+ return `< ${formatPrice(max, currency, separator, currencyTemplate)}`;
8091
+ };
8092
+ const getTranslatedFacetKey = (facet, translations) => {
8093
+ var _a, _b;
8094
+ return (_b = (_a = translations == null ? void 0 : translations.keyTranslations) == null ? void 0 : _a[facet.key]) != null ? _b : facet.label;
8095
+ };
8096
+ const getTranslatedFacetValue = (facet, value, translations) => {
8097
+ var _a, _b, _c;
8098
+ return (_c = (_b = (_a = translations == null ? void 0 : translations.valueTranslations) == null ? void 0 : _a[facet.key]) == null ? void 0 : _b[value == null ? void 0 : value.title]) != null ? _c : value.title;
8099
+ };
8100
+ const formatRange = (filter2) => {
8101
+ var _a, _b;
8102
+ const lt = (_a = filter2.lt) != null ? _a : filter2.lte;
8103
+ const gt = (_b = filter2.gt) != null ? _b : filter2.gte;
8104
+ if (gt !== void 0 && lt !== void 0) {
8105
+ return `${gt} - ${lt}`;
8106
+ }
8107
+ if (lt !== void 0) {
8108
+ return `<${filter2.lte !== void 0 ? "=" : ""} ${lt}`;
8109
+ }
8110
+ return `>${filter2.gte !== void 0 ? "=" : ""} ${gt}`;
8111
+ };
8112
+ const unfoldTermFilter = (key, filter2) => {
8113
+ const seed = [];
8114
+ return filter2.reduce((a, c2) => [...a, { key, value: c2, type: "terms" }], seed);
8115
+ };
8116
+ const unfoldHierarchyFilter = (key, filter2) => {
8117
+ const seed = [];
8118
+ return filter2.terms.reduce((a, c2) => [...a, { key, value: c2, type: "hierarchy" }], seed);
8119
+ };
8120
+ const unfoldRangeFilter = (key, filter2, price = {}) => {
8121
+ var _a;
8122
+ const gt = filter2.gte || filter2.gt;
8123
+ const lt = filter2.lte || filter2.lt;
8124
+ if (key.includes(CURRENCY_KEY_INDICATOR) || ((_a = price == null ? void 0 : price.keys) == null ? void 0 : _a.includes(key))) {
8125
+ return [
8126
+ {
8127
+ key,
8128
+ value: formatPriceSummary(
8129
+ [gt, lt],
8130
+ price.currency,
8131
+ price.separator,
8132
+ price.currencyTemplate
8133
+ ),
8134
+ type: "range"
8135
+ }
8136
+ ];
8137
+ }
8138
+ return [{ key, value: `${gt} - ${lt}`, type: "range" }];
8139
+ };
8140
+ const unfoldFilter = (key, filter2, price = {}) => {
8141
+ if (Array.isArray(filter2)) {
8142
+ return unfoldTermFilter(key, filter2);
8143
+ }
8144
+ if (filter2.gte) {
8145
+ return unfoldRangeFilter(key, filter2, price);
8146
+ }
8147
+ if (filter2.terms) {
8148
+ return unfoldHierarchyFilter(key, filter2);
8149
+ }
8150
+ return [];
8151
+ };
8152
+ const unfoldFilters = (filters, price = {}) => {
8153
+ if (!filters) {
8154
+ return [];
8155
+ }
8156
+ const seed = [];
8157
+ return Object.entries(filters).reduce((a, c2) => [...a, ...unfoldFilter(...c2, price)], seed);
8158
+ };
8159
+ const getLabeledFilters = (filters, facets2, translations) => {
8160
+ return filters.map((f2) => {
8161
+ var _a, _b, _c, _d;
8162
+ return __spreadProps(__spreadValues({}, f2), {
8163
+ label: (_d = (_c = (_a = translations == null ? void 0 : translations.keyTranslations) == null ? void 0 : _a[f2.key]) != null ? _c : (_b = facets2 == null ? void 0 : facets2.find((ft) => ft.key === f2.key)) == null ? void 0 : _b.label) != null ? _d : capitalize$1(f2.key),
8164
+ value: getTranslatedFacetValue({ key: f2.key }, { title: f2.value }, translations),
8165
+ originalValue: f2.value
8166
+ });
8167
+ });
8168
+ };
8169
+ const isFacetKey = (key) => key.startsWith(FACET_PARAMS_TYPE.RANGE) || key.startsWith(FACET_PARAMS_TYPE.TERMS) || key.startsWith(FACET_PARAMS_TYPE.HIERARCHY);
8170
+ const getMostSpecificHierarchyTerms = (terms) => {
8171
+ const specificTerms = [];
8172
+ for (const term of terms) {
8173
+ if (!terms.some((t) => t.startsWith(term) && t !== term)) {
8174
+ specificTerms.push(term);
8175
+ }
8176
+ }
8177
+ return Array.from(new Set(specificTerms));
8178
+ };
8179
+ const recursiveFilter = (items, query = "") => {
8180
+ if (!query) {
8181
+ return items;
8182
+ }
8183
+ return items.map((i) => recursiveFilterItem(i, query)).filter(Boolean);
8184
+ };
8185
+ const recursiveFilterItem = (item, query = "") => {
8186
+ const filterable = getNormalizedString(item.title).includes(getNormalizedString(query)) ? item : void 0;
8187
+ if (!item.children) {
8188
+ return filterable;
8189
+ }
8190
+ const children = recursiveFilter(item.children, query).filter(Boolean);
8191
+ const include = children.length > 0 || filterable;
8192
+ return include ? __spreadProps(__spreadValues({}, item), {
8193
+ children
8194
+ }) : void 0;
8195
+ };
8196
+ const rangeFilterToString = (rangeFilter, separator) => {
8197
+ separator = separator || FACET_TERM_RANGE_SEPARATOR;
8198
+ return rangeFilter && Object.keys(rangeFilter).length ? rangeFilter.gte + separator + (rangeFilter.lte || rangeFilter.lt) : "";
8199
+ };
8200
+ const pick = (obj, keys) => {
8201
+ const ret = /* @__PURE__ */ Object.create({});
8202
+ for (const k of keys) {
8203
+ ret[k] = obj[k];
8204
+ }
8205
+ return ret;
8206
+ };
8207
+ const getHint = (suggestion, inputValue) => {
8208
+ var _a;
8209
+ if (!inputValue) {
8210
+ return escapeHtml$1(suggestion);
8211
+ }
8212
+ return (_a = suggestion == null ? void 0 : suggestion.replace(
8213
+ inputValue == null ? void 0 : inputValue.toLocaleLowerCase(),
8214
+ `<strong>${escapeHtml$1(inputValue == null ? void 0 : inputValue.toLocaleLowerCase())}</strong>`
8215
+ )) != null ? _a : "";
8216
+ };
8217
+ const reverseKeyValue = (obj) => {
8218
+ return Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k.toLowerCase()]));
8219
+ };
8220
+ const getPageCount = (total, limit) => {
8221
+ return Math.ceil(total / limit) || 0;
8222
+ };
8223
+ const isObject$1 = (value) => {
8224
+ return value !== null && typeof value === "object" && !Array.isArray(value);
8225
+ };
8226
+ const parseParam = (key, params) => {
8227
+ const value = params.get(key);
8228
+ if (!value) {
8229
+ return void 0;
8230
+ }
8231
+ try {
8232
+ return decodeURIComponent(value);
8233
+ } catch (e2) {
8234
+ return void 0;
8235
+ }
8236
+ };
8237
+ const parseRegularKeys = (regularKeys, searchParams, getQueryParamName) => {
8238
+ const params = /* @__PURE__ */ Object.create({});
8239
+ const keys = reverseKeyValue({
8240
+ QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS.QUERY) : QUERY_PARAMS.QUERY,
8241
+ LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS.LIMIT) : QUERY_PARAMS.LIMIT,
8242
+ PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE,
8243
+ SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS.SORT) : QUERY_PARAMS.SORT
8244
+ });
8245
+ for (const key of regularKeys) {
8246
+ const rawKey = keys[key] || key;
8247
+ params[rawKey] = parseParam(key, searchParams);
8248
+ }
8249
+ return params;
8250
+ };
8251
+ const parseFacetKey = (key, searchParams) => {
8252
+ var _a, _b, _c, _d;
8253
+ if (key.startsWith(FACET_PARAMS_TYPE.TERMS)) {
8254
+ return (_b = (_a = searchParams.getAll(key)) == null ? void 0 : _a.map((v) => decodeURIComponent(v))) != null ? _b : [];
8255
+ }
8256
+ if (key.startsWith(FACET_PARAMS_TYPE.RANGE)) {
8257
+ const range = searchParams.get(key);
8258
+ if (!range) {
8259
+ return {};
8260
+ }
8261
+ const [min, max] = range.split(FACET_RANGE_SEPARATOR);
8262
+ return {
8263
+ gte: min,
8264
+ lte: max
8265
+ };
8266
+ }
8267
+ if (key.startsWith(FACET_PARAMS_TYPE.HIERARCHY)) {
8268
+ return {
8269
+ level: 0,
8270
+ terms: (_d = (_c = searchParams.getAll(key)) == null ? void 0 : _c.map((v) => decodeURIComponent(v))) != null ? _d : []
8271
+ };
8272
+ }
8273
+ return [];
8274
+ };
8275
+ const parseFacetKeys = (facetKeys, searchParams) => {
8276
+ const params = {};
8277
+ params.filters = {};
8278
+ for (const key of facetKeys) {
8279
+ const parsedKey = key.slice(key.indexOf(FACET_KEY_SEPARATOR) + 1);
8280
+ params.filters = __spreadProps(__spreadValues({}, params.filters), {
8281
+ [parsedKey]: parseFacetKey(key, searchParams)
8282
+ });
8283
+ }
8284
+ return params;
8285
+ };
8286
+ const parseParams = (getQueryParamName, searchParams) => {
8287
+ const params = /* @__PURE__ */ Object.create({});
8288
+ if (!searchParams)
8289
+ return params;
8290
+ const paramKeys = Array.from(searchParams.keys());
8291
+ const facetKeys = paramKeys.filter((k) => isFacetKey(k));
8292
+ const regularKeys = paramKeys.filter((k) => !isFacetKey(k));
8293
+ const r = __spreadValues(__spreadValues({
8294
+ [QUERY_PARAMS_PARSED.QUERY]: ""
8295
+ }, parseRegularKeys(regularKeys, searchParams, getQueryParamName)), parseFacetKeys(facetKeys, searchParams));
8296
+ return r;
8297
+ };
8298
+ const appendParam = (url, { name, value }, encode2 = true) => {
8299
+ if (Array.isArray(value)) {
8300
+ appendArrayParams(url, { name, value });
8301
+ } else {
8302
+ appendSingleParam(url, { name, value }, encode2);
8303
+ }
8304
+ };
8305
+ const appendSingleParam = (url, param, encode2 = true) => {
8306
+ const valueToAppend = encode2 ? encodeParam(param.value) : param.value;
8307
+ if (url.searchParams.has(param.name)) {
8308
+ url.searchParams.set(param.name, valueToAppend);
8309
+ } else {
8310
+ url.searchParams.append(param.name, valueToAppend);
8311
+ }
8312
+ };
8313
+ const appendArrayParams = (url, param) => {
8314
+ url.searchParams.delete(param.name);
8315
+ param.value.forEach((v) => url.searchParams.append(param.name, encodeParam(v)));
8316
+ };
8317
+ const getRemovableParams = (url, getQueryParamName, paramsToRemove) => {
8318
+ if (paramsToRemove === "all") {
8319
+ const params = {
8320
+ QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS.QUERY) : QUERY_PARAMS.QUERY,
8321
+ LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS.LIMIT) : QUERY_PARAMS.LIMIT,
8322
+ PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE,
8323
+ SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS.SORT) : QUERY_PARAMS.SORT
8324
+ };
8325
+ return [
8326
+ ...Object.values(params),
8327
+ ...Array.from(url.searchParams.keys()).filter((k) => isFacetKey(k))
8328
+ ];
8329
+ }
8330
+ return paramsToRemove;
8331
+ };
8332
+ const removeParams = (url, params = []) => {
8333
+ for (const param of params) {
8334
+ if (url.searchParams.has(param)) {
8335
+ url.searchParams.delete(param);
8336
+ }
8337
+ }
8338
+ };
8339
+ const encodeParam = (param) => {
8340
+ const encoded = encodeURIComponent(param);
8341
+ return encoded.replace(/%C4%85/g, "ą").replace(/%C4%8D/g, "č").replace(/%C4%99/g, "ę").replace(/%C4%97/g, "ė").replace(/%C4%AF/g, "į").replace(/%C5%A1/g, "š").replace(/%C5%B3/g, "ų").replace(/%C5%AB/g, "ū").replace(/%C5%BE/g, "ž").replace(/%20/g, " ");
8342
+ };
8343
+ const getQueryParam = (name) => {
8344
+ try {
8345
+ const urlParams = new URLSearchParams(window.location.search);
8346
+ return urlParams.get(name);
8347
+ } catch (e2) {
8348
+ return null;
8349
+ }
8350
+ };
8351
+ const PATH_REPLACE_REGEXP = /{(.*?)}/gm;
8352
+ const generateLink = (linkPattern, document2) => {
8353
+ const matches = linkPattern.match(PATH_REPLACE_REGEXP);
8354
+ if (!matches) {
8355
+ return linkPattern;
8356
+ }
8357
+ let link = linkPattern;
8358
+ for (const match of matches) {
8359
+ const propertyKey = match.slice(1, match.length - 1);
8360
+ const property = document2[propertyKey] || "";
8361
+ link = link.replace(match, property);
8362
+ }
8363
+ return link;
8364
+ };
8365
+ const generateResultLink = (link, getQueryParamName, searchText, facet) => {
8366
+ if (!searchText) {
8367
+ return link;
8368
+ }
8369
+ const facetParam = facet ? `&${FACET_PARAMS_TYPE.TERMS}${encodeParam(facet.key)}=${encodeParam(facet.title)}` : "";
8370
+ const queryParam = `?${getQueryParamName ? getQueryParamName(QUERY_PARAMS.QUERY) : QUERY_PARAMS.QUERY}=${encodeParam(searchText)}`;
8371
+ return `${link}${queryParam}${facetParam}`;
8372
+ };
8373
+ const getRelativePath = (link) => {
8374
+ try {
8375
+ const url = new URL(link);
8376
+ const partialUrl = url.toString().substring(url.origin.length);
8377
+ return partialUrl.endsWith("/") ? partialUrl.slice(0, partialUrl.length - 1) : partialUrl;
8378
+ } catch (e2) {
8379
+ return (link == null ? void 0 : link.endsWith("/")) ? link.slice(0, link.length - 1) : link;
8380
+ }
8381
+ };
8382
+ const linksMatch = (link1, link2) => {
8383
+ if (!link1 || !link2) {
8384
+ return false;
8385
+ }
8386
+ return link1 === link2 || getRelativePath(link1) === getRelativePath(link2);
8387
+ };
8388
+ const emitRoutingEvent = (url) => {
8389
+ const event = new CustomEvent(LUPA_ROUTING_EVENT, { detail: url });
8390
+ window.dispatchEvent(event);
8391
+ };
8392
+ const handleRoutingEvent = (link, event, hasEventRouting = false) => {
8393
+ if (!hasEventRouting) {
8394
+ return;
8395
+ }
8396
+ event == null ? void 0 : event.preventDefault();
8397
+ emitRoutingEvent(link);
8398
+ };
8399
+ const redirectToResultsPage = (link, searchText, getQueryParamName, facet, routingBehavior = "direct-link") => {
8400
+ const url = generateResultLink(link, getQueryParamName, searchText, facet);
8401
+ if (routingBehavior === "event") {
8402
+ emitRoutingEvent(url);
8403
+ } else {
8404
+ window.location.assign(url);
8405
+ }
8406
+ };
8407
+ const getPageUrl = (pathnameOverride, ssr) => {
8408
+ if (typeof window !== "undefined") {
8409
+ const pathname = pathnameOverride || window.location.pathname;
8410
+ const origin = window.location.origin;
8411
+ const search2 = window.location.search;
8412
+ return new URL(origin + pathname + search2);
8413
+ }
8414
+ return new URL(ssr.url, ssr.baseUrl);
8415
+ };
8416
+ const getFacetKey = (key, type) => {
8417
+ return `${FACET_FILTER_MAP[type]}${key}`;
8418
+ };
8419
+ const getFacetParam = (key, value, type = FACET_PARAMS_TYPE.TERMS) => {
8420
+ return {
8421
+ name: `${type}${key}`,
8422
+ value
8423
+ };
8424
+ };
8425
+ const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentFilters, paramsToRemove = []) => {
8426
+ const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
8427
+ const newParams = toggleTermParam(currentFilter, facetAction.value);
8428
+ appendParams({
8429
+ params: [getFacetParam(facetAction.key, newParams)],
8430
+ paramsToRemove: [
8431
+ ...paramsToRemove,
8432
+ ...[getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE]
8433
+ ]
8434
+ });
8435
+ };
8436
+ const replaceHierarchyParam = (params = [], param = "") => {
8437
+ if (params.some((p2) => p2.startsWith(param))) {
8438
+ return toggleLastPram(params, param);
8439
+ }
8440
+ return [param];
8441
+ };
8442
+ const toggleHierarchyFilter = (appendParams, facetAction, getQueryParamName, currentFilters, removeAllLevels = false) => {
8443
+ var _a, _b;
8444
+ const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
8445
+ const newParams = facetAction.behavior === "replace" ? replaceHierarchyParam((_a = currentFilter == null ? void 0 : currentFilter.terms) != null ? _a : [], facetAction.value) : toggleHierarchyParam((_b = currentFilter == null ? void 0 : currentFilter.terms) != null ? _b : [], facetAction.value, removeAllLevels);
8446
+ appendParams({
8447
+ params: [getFacetParam(facetAction.key, newParams, FACET_PARAMS_TYPE.HIERARCHY)],
8448
+ paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE]
8449
+ });
8450
+ };
8451
+ const toggleRangeFilter = (appendParams, facetAction, getQueryParamName, currentFilters) => {
8452
+ const currentFilter = rangeFilterToString(
8453
+ currentFilters == null ? void 0 : currentFilters[facetAction.key],
8454
+ FACET_RANGE_SEPARATOR
8455
+ );
8456
+ let facetValue = facetAction.value.join(FACET_RANGE_SEPARATOR);
8457
+ facetValue = currentFilter === facetValue ? "" : facetValue;
8458
+ appendParams({
8459
+ params: [getFacetParam(facetAction.key, facetValue, FACET_PARAMS_TYPE.RANGE)],
8460
+ paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE],
8461
+ encode: false
8462
+ });
8463
+ };
8464
+ const toggleTermParam = (params = [], param = "") => {
8465
+ if (params == null ? void 0 : params.includes(param)) {
8466
+ return params.filter((p2) => p2 !== param);
8467
+ }
8468
+ return [param, ...params];
8469
+ };
8470
+ const toggleLastPram = (params = [], param = "") => {
8471
+ const paramLevel = param.split(">").length;
8472
+ return getMostSpecificHierarchyTerms(
8473
+ params.map(
8474
+ (p2) => p2.startsWith(param) ? p2.split(HIERARCHY_SEPARATOR).slice(0, paramLevel - 1).join(HIERARCHY_SEPARATOR).trim() : p2
8475
+ ).filter(Boolean)
8476
+ );
8477
+ };
8478
+ const toggleHierarchyParam = (params = [], param = "", removeAllLevels = false) => {
8479
+ if (params == null ? void 0 : params.some((p2) => p2.startsWith(param))) {
8480
+ return removeAllLevels ? getMostSpecificHierarchyTerms(params.filter((p2) => !p2.startsWith(param))) : toggleLastPram(params, param);
8481
+ }
8482
+ return getMostSpecificHierarchyTerms([param, ...params]);
8483
+ };
8484
+ const CACHE_KEY = "lupasearch-client-redirections";
8485
+ const useRedirectionStore = defineStore("redirections", () => {
8486
+ const redirections = ref({ rules: [] });
8487
+ const redirectionOptions = ref({ enabled: false, queryKey: "" });
8488
+ const saveToLocalStorage = () => {
8489
+ try {
8490
+ localStorage.setItem(
8491
+ CACHE_KEY,
8492
+ JSON.stringify({
8493
+ redirections: redirections.value,
8494
+ savedAt: Date.now(),
8495
+ queryKey: redirectionOptions.value.queryKey
8496
+ })
8497
+ );
8498
+ } catch (e2) {
8499
+ }
8500
+ };
8501
+ const tryLoadFromLocalStorage = (config) => {
8502
+ var _a;
8503
+ if (!config.cacheSeconds)
8504
+ return false;
8505
+ try {
8506
+ const data = JSON.parse((_a = localStorage.getItem(CACHE_KEY)) != null ? _a : "");
8507
+ if (data.queryKey !== config.queryKey) {
8508
+ return false;
8509
+ }
8510
+ if ((data == null ? void 0 : data.redirections) && Date.now() - data.savedAt < 1e3 * config.cacheSeconds) {
8511
+ redirections.value = data.redirections;
8512
+ return true;
8513
+ }
8514
+ } catch (e2) {
8515
+ }
8516
+ return false;
8517
+ };
8518
+ const initiate = (config, options) => __async(void 0, null, function* () {
8519
+ var _a, _b, _c, _d;
8520
+ if ((_a = redirectionOptions.value) == null ? void 0 : _a.enabled) {
8521
+ return;
8522
+ }
8523
+ redirectionOptions.value = config;
8524
+ if (!(config == null ? void 0 : config.enabled)) {
8525
+ return;
8526
+ }
8527
+ const loaded = tryLoadFromLocalStorage(config);
8528
+ if (loaded || ((_c = (_b = redirections.value) == null ? void 0 : _b.rules) == null ? void 0 : _c.length) > 0) {
8529
+ return;
8530
+ }
8531
+ try {
8532
+ const result2 = yield LupaSearchSdk.loadRedirectionRules(config.queryKey, options);
8533
+ if (!((_d = result2 == null ? void 0 : result2.rules) == null ? void 0 : _d.length)) {
8534
+ redirections.value = { rules: [] };
8535
+ return;
8536
+ }
8537
+ redirections.value = result2;
8538
+ saveToLocalStorage();
8539
+ } catch (e2) {
8540
+ }
8541
+ });
8542
+ const redirectOnKeywordIfConfigured = (input2, routingBehavior = "direct-link") => {
8543
+ var _a, _b, _c, _d;
8544
+ if (!((_b = (_a = redirections.value) == null ? void 0 : _a.rules) == null ? void 0 : _b.length)) {
8545
+ return false;
8546
+ }
8547
+ const redirectTo = redirections.value.rules.find((r) => inputsAreEqual(input2, r.sources));
8548
+ if (!redirectTo) {
8549
+ return false;
8550
+ }
8551
+ const url = ((_c = redirectionOptions.value) == null ? void 0 : _c.urlTransformer) ? (_d = redirectionOptions.value) == null ? void 0 : _d.urlTransformer(redirectTo == null ? void 0 : redirectTo.target) : redirectTo == null ? void 0 : redirectTo.target;
8552
+ if (url === void 0 || url === null || url === "") {
8553
+ return false;
8554
+ }
8555
+ if (routingBehavior === "event") {
8556
+ emitRoutingEvent(url);
8554
8557
  } else {
8555
- root2._ = _;
8558
+ window.location.assign(url);
8556
8559
  }
8557
- }).call(commonjsGlobal);
8558
- })(lodash, lodash.exports);
8559
- var lodashExports = lodash.exports;
8560
+ return true;
8561
+ };
8562
+ return {
8563
+ redirections,
8564
+ redirectOnKeywordIfConfigured,
8565
+ initiate
8566
+ };
8567
+ });
8560
8568
  const joinUrlParts = (...parts) => {
8561
8569
  var _a, _b, _c;
8562
8570
  if (parts.length === 1) {
@@ -8995,7 +9003,7 @@ const _hoisted_1$1i = { id: "lupa-search-box-input-container" };
8995
9003
  const _hoisted_2$T = { class: "lupa-input-clear" };
8996
9004
  const _hoisted_3$C = { id: "lupa-search-box-input" };
8997
9005
  const _hoisted_4$s = ["value"];
8998
- const _hoisted_5$j = ["aria-label", "placeholder"];
9006
+ const _hoisted_5$i = ["aria-label", "placeholder"];
8999
9007
  const _hoisted_6$9 = /* @__PURE__ */ createElementVNode("span", { class: "lupa-search-submit-icon" }, null, -1);
9000
9008
  const _hoisted_7$7 = [
9001
9009
  _hoisted_6$9
@@ -9115,7 +9123,7 @@ const _sfc_main$1v = /* @__PURE__ */ defineComponent({
9115
9123
  placeholder: labels.value.placeholder,
9116
9124
  onInput: handleInput,
9117
9125
  onFocus: handleFocus
9118
- }), null, 16, _hoisted_5$j), [
9126
+ }), null, 16, _hoisted_5$i), [
9119
9127
  [vModelText, inputValue.value]
9120
9128
  ]),
9121
9129
  _ctx.options.showSubmitButton ? (openBlock(), createElementBlock("button", {
@@ -9331,7 +9339,7 @@ const _hoisted_4$r = {
9331
9339
  class: "lupa-suggestion-facet-label",
9332
9340
  "data-cy": "lupa-suggestion-facet-label"
9333
9341
  };
9334
- const _hoisted_5$i = {
9342
+ const _hoisted_5$h = {
9335
9343
  class: "lupa-suggestion-facet-value",
9336
9344
  "data-cy": "lupa-suggestion-facet-value"
9337
9345
  };
@@ -9374,7 +9382,7 @@ const _sfc_main$1q = /* @__PURE__ */ defineComponent({
9374
9382
  }, null, 8, _hoisted_1$1e)) : (openBlock(), createElementBlock("div", _hoisted_2$R, toDisplayString(_ctx.suggestion.display), 1)),
9375
9383
  _ctx.suggestion.facet ? (openBlock(), createElementBlock("div", _hoisted_3$B, [
9376
9384
  createElementVNode("span", _hoisted_4$r, toDisplayString(facetLabel.value), 1),
9377
- createElementVNode("span", _hoisted_5$i, toDisplayString(_ctx.suggestion.facet.title), 1)
9385
+ createElementVNode("span", _hoisted_5$h, toDisplayString(_ctx.suggestion.facet.title), 1)
9378
9386
  ])) : createCommentVNode("", true)
9379
9387
  ]);
9380
9388
  };
@@ -18918,7 +18926,7 @@ const _hoisted_1$18 = ["innerHTML"];
18918
18926
  const _hoisted_2$N = { key: 0 };
18919
18927
  const _hoisted_3$A = { key: 1 };
18920
18928
  const _hoisted_4$q = { class: "lupa-search-box-custom-label" };
18921
- const _hoisted_5$h = { class: "lupa-search-box-custom-text" };
18929
+ const _hoisted_5$g = { class: "lupa-search-box-custom-text" };
18922
18930
  const _sfc_main$1h = /* @__PURE__ */ defineComponent({
18923
18931
  __name: "SearchBoxProductCustom",
18924
18932
  props: {
@@ -18951,7 +18959,7 @@ const _sfc_main$1h = /* @__PURE__ */ defineComponent({
18951
18959
  }, toHandlers(_ctx.options.action ? { click: handleClick } : {}, true)), [
18952
18960
  !label.value ? (openBlock(), createElementBlock("div", _hoisted_2$N, toDisplayString(text.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$A, [
18953
18961
  createElementVNode("div", _hoisted_4$q, toDisplayString(label.value), 1),
18954
- createElementVNode("div", _hoisted_5$h, toDisplayString(text.value), 1)
18962
+ createElementVNode("div", _hoisted_5$g, toDisplayString(text.value), 1)
18955
18963
  ]))
18956
18964
  ], 16));
18957
18965
  };
@@ -20371,7 +20379,7 @@ const _hoisted_4$o = {
20371
20379
  key: 1,
20372
20380
  class: "lupa-panel-title"
20373
20381
  };
20374
- const _hoisted_5$g = {
20382
+ const _hoisted_5$f = {
20375
20383
  key: 1,
20376
20384
  id: "lupa-search-box-panel"
20377
20385
  };
@@ -20595,7 +20603,7 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValue
20595
20603
  options: _ctx.options,
20596
20604
  onGoToResults: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("go-to-results"))
20597
20605
  }, null, 8, ["labels", "options"])) : createCommentVNode("", true)
20598
- ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_5$g, [
20606
+ ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_5$f, [
20599
20607
  createVNode(_sfc_main$1s, {
20600
20608
  options: _ctx.options.history,
20601
20609
  history: history.value,
@@ -21176,7 +21184,7 @@ const _hoisted_3$u = {
21176
21184
  class: "lupa-results-total-count"
21177
21185
  };
21178
21186
  const _hoisted_4$m = { class: "lupa-results-total-count-number" };
21179
- const _hoisted_5$f = ["innerHTML"];
21187
+ const _hoisted_5$e = ["innerHTML"];
21180
21188
  const _sfc_main$Z = /* @__PURE__ */ defineComponent({
21181
21189
  __name: "SearchResultsTitle",
21182
21190
  props: {
@@ -21237,7 +21245,7 @@ const _sfc_main$Z = /* @__PURE__ */ defineComponent({
21237
21245
  key: 2,
21238
21246
  class: "lupa-result-page-description-top",
21239
21247
  innerHTML: descriptionTop.value
21240
- }, null, 8, _hoisted_5$f)) : createCommentVNode("", true)
21248
+ }, null, 8, _hoisted_5$e)) : createCommentVNode("", true)
21241
21249
  ]);
21242
21250
  };
21243
21251
  }
@@ -21326,7 +21334,7 @@ const _sfc_main$X = /* @__PURE__ */ defineComponent({
21326
21334
  toggleTermFilter(
21327
21335
  // TODO: Fix any
21328
21336
  paramsStore.appendParams,
21329
- { type: "terms", value: filter2.value, key: filter2.key },
21337
+ { type: "terms", value: filter2.originalValue, key: filter2.key },
21330
21338
  optionStore.getQueryParamName,
21331
21339
  currentFilters.value
21332
21340
  );
@@ -21334,7 +21342,7 @@ const _sfc_main$X = /* @__PURE__ */ defineComponent({
21334
21342
  case "hierarchy":
21335
21343
  toggleHierarchyFilter(
21336
21344
  paramsStore.appendParams,
21337
- { type: "hierarchy", value: filter2.value, key: filter2.key },
21345
+ { type: "hierarchy", value: filter2.originalValue, key: filter2.key },
21338
21346
  optionStore.getQueryParamName,
21339
21347
  currentFilters.value,
21340
21348
  true
@@ -21440,7 +21448,7 @@ const _hoisted_1$P = {
21440
21448
  const _hoisted_2$B = { class: "lupa-category-back" };
21441
21449
  const _hoisted_3$s = ["href"];
21442
21450
  const _hoisted_4$k = ["href"];
21443
- const _hoisted_5$e = { class: "lupa-child-category-list" };
21451
+ const _hoisted_5$d = { class: "lupa-child-category-list" };
21444
21452
  const _sfc_main$V = /* @__PURE__ */ defineComponent({
21445
21453
  __name: "CategoryFilter",
21446
21454
  props: {
@@ -21548,7 +21556,7 @@ const _sfc_main$V = /* @__PURE__ */ defineComponent({
21548
21556
  onClick: handleNavigationParent
21549
21557
  }, toDisplayString(parentTitle.value), 11, _hoisted_4$k)
21550
21558
  ], 2),
21551
- createElementVNode("div", _hoisted_5$e, [
21559
+ createElementVNode("div", _hoisted_5$d, [
21552
21560
  (openBlock(true), createElementBlock(Fragment, null, renderList(categoryChildren.value, (child) => {
21553
21561
  return openBlock(), createBlock(_sfc_main$W, {
21554
21562
  key: getCategoryKey(child),
@@ -21568,15 +21576,14 @@ const _hoisted_1$O = {
21568
21576
  const _hoisted_2$A = ["placeholder"];
21569
21577
  const _hoisted_3$r = { class: "lupa-terms-list" };
21570
21578
  const _hoisted_4$j = ["onClick"];
21571
- const _hoisted_5$d = { class: "lupa-term-checkbox-wrapper" };
21572
- const _hoisted_6$8 = { class: "lupa-term-checkbox-label" };
21573
- const _hoisted_7$6 = { class: "lupa-term-label" };
21574
- const _hoisted_8$2 = {
21579
+ const _hoisted_5$c = { class: "lupa-term-checkbox-wrapper" };
21580
+ const _hoisted_6$8 = { class: "lupa-term-label" };
21581
+ const _hoisted_7$6 = {
21575
21582
  key: 0,
21576
21583
  class: "lupa-term-count"
21577
21584
  };
21578
- const _hoisted_9$2 = { key: 0 };
21579
- const _hoisted_10$1 = { key: 1 };
21585
+ const _hoisted_8$2 = { key: 0 };
21586
+ const _hoisted_9$2 = { key: 1 };
21580
21587
  const _sfc_main$U = /* @__PURE__ */ defineComponent({
21581
21588
  __name: "TermFacet",
21582
21589
  props: {
@@ -21608,7 +21615,12 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
21608
21615
  return searchResultStore.filterVisibleFilterValues(facet.value.key, (_b = (_a = facet.value) == null ? void 0 : _a.items) != null ? _b : []);
21609
21616
  });
21610
21617
  const displayValues = computed(() => {
21611
- return filteredValues.value.slice(0, itemLimit.value).map((v) => __spreadProps(__spreadValues({}, v), { title: getDisplayValue(v.title) }));
21618
+ return filteredValues.value.slice(0, itemLimit.value).filter(
21619
+ (v) => {
21620
+ var _a, _b, _c;
21621
+ return ((_a = props.options.excludeValues) == null ? void 0 : _a[facet.value.key]) ? !((_c = (_b = props.options.excludeValues) == null ? void 0 : _b[facet.value.key]) == null ? void 0 : _c[v.title]) : true;
21622
+ }
21623
+ ).map((v) => __spreadProps(__spreadValues({}, v), { title: getDisplayValue(v.title) }));
21612
21624
  });
21613
21625
  const filteredValues = computed(() => {
21614
21626
  var _a, _b;
@@ -21653,6 +21665,13 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
21653
21665
  var _a;
21654
21666
  return getTranslatedFacetValue(props.facet, item, (_a = searchResultOptions.value.filters) == null ? void 0 : _a.translations);
21655
21667
  };
21668
+ const getFacetValueClass = (item) => {
21669
+ try {
21670
+ return `lupa-facet-value-${slugifyClass(item.title)}`;
21671
+ } catch (e2) {
21672
+ return "";
21673
+ }
21674
+ };
21656
21675
  return (_ctx, _cache) => {
21657
21676
  return openBlock(), createElementBlock("div", _hoisted_1$O, [
21658
21677
  isFilterable.value ? withDirectives((openBlock(), createElementBlock("input", {
@@ -21672,15 +21691,17 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
21672
21691
  key: item.title,
21673
21692
  onClick: ($event) => handleFacetClick(item)
21674
21693
  }, [
21675
- createElementVNode("div", _hoisted_5$d, [
21694
+ createElementVNode("div", _hoisted_5$c, [
21676
21695
  createElementVNode("span", {
21677
21696
  class: normalizeClass(["lupa-term-checkbox", { checked: isChecked(item) }])
21678
21697
  }, null, 2)
21679
21698
  ]),
21680
- createElementVNode("div", _hoisted_6$8, [
21681
- createElementVNode("span", _hoisted_7$6, toDisplayString(getItemLabel(item)), 1),
21682
- _ctx.options.showDocumentCount ? (openBlock(), createElementBlock("span", _hoisted_8$2, "(" + toDisplayString(item.count) + ")", 1)) : createCommentVNode("", true)
21683
- ])
21699
+ createElementVNode("div", {
21700
+ class: normalizeClass(["lupa-term-checkbox-label", { [getFacetValueClass(item)]: true }])
21701
+ }, [
21702
+ createElementVNode("span", _hoisted_6$8, toDisplayString(getItemLabel(item)), 1),
21703
+ _ctx.options.showDocumentCount ? (openBlock(), createElementBlock("span", _hoisted_7$6, "(" + toDisplayString(item.count) + ")", 1)) : createCommentVNode("", true)
21704
+ ], 2)
21684
21705
  ], 10, _hoisted_4$j);
21685
21706
  }), 128))
21686
21707
  ]),
@@ -21690,7 +21711,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
21690
21711
  "data-cy": "lupa-facet-term",
21691
21712
  onClick: toggleShowAll
21692
21713
  }, [
21693
- showAll.value ? (openBlock(), createElementBlock("span", _hoisted_9$2, toDisplayString(_ctx.options.labels.showLess), 1)) : (openBlock(), createElementBlock("span", _hoisted_10$1, toDisplayString(_ctx.options.labels.showAll), 1))
21714
+ showAll.value ? (openBlock(), createElementBlock("span", _hoisted_8$2, toDisplayString(_ctx.options.labels.showLess), 1)) : (openBlock(), createElementBlock("span", _hoisted_9$2, toDisplayString(_ctx.options.labels.showAll), 1))
21694
21715
  ])) : createCommentVNode("", true)
21695
21716
  ]);
21696
21717
  };
@@ -22685,7 +22706,7 @@ const _hoisted_4$i = {
22685
22706
  key: 0,
22686
22707
  class: "lupa-stats-range-label"
22687
22708
  };
22688
- const _hoisted_5$c = { class: "lupa-stats-from" };
22709
+ const _hoisted_5$b = { class: "lupa-stats-from" };
22689
22710
  const _hoisted_6$7 = ["max", "min", "pattern", "aria-label"];
22690
22711
  const _hoisted_7$5 = { key: 0 };
22691
22712
  const _hoisted_8$1 = /* @__PURE__ */ createElementVNode("div", { class: "lupa-stats-separator" }, null, -1);
@@ -22885,7 +22906,7 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
22885
22906
  !isInputVisible.value ? (openBlock(), createElementBlock("div", _hoisted_2$z, toDisplayString(statsSummary.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$q, [
22886
22907
  createElementVNode("div", null, [
22887
22908
  rangeLabelFrom.value ? (openBlock(), createElementBlock("div", _hoisted_4$i, toDisplayString(rangeLabelFrom.value), 1)) : createCommentVNode("", true),
22888
- createElementVNode("div", _hoisted_5$c, [
22909
+ createElementVNode("div", _hoisted_5$b, [
22889
22910
  withDirectives(createElementVNode("input", {
22890
22911
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => fromValue.value = $event),
22891
22912
  type: "text",
@@ -22949,13 +22970,12 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
22949
22970
  }
22950
22971
  });
22951
22972
  const _hoisted_1$M = { class: "lupa-term-checkbox-wrapper" };
22952
- const _hoisted_2$y = { class: "lupa-term-checkbox-label" };
22953
- const _hoisted_3$p = { class: "lupa-term-label" };
22954
- const _hoisted_4$h = {
22973
+ const _hoisted_2$y = { class: "lupa-term-label" };
22974
+ const _hoisted_3$p = {
22955
22975
  key: 0,
22956
22976
  class: "lupa-term-count"
22957
22977
  };
22958
- const _hoisted_5$b = {
22978
+ const _hoisted_4$h = {
22959
22979
  key: 0,
22960
22980
  class: "lupa-facet-level"
22961
22981
  };
@@ -22995,6 +23015,13 @@ const _sfc_main$S = /* @__PURE__ */ defineComponent({
22995
23015
  value: item.key
22996
23016
  });
22997
23017
  };
23018
+ const getFacetValueClass = (item) => {
23019
+ try {
23020
+ return `lupa-facet-value-${slugifyClass(item.title)}`;
23021
+ } catch (e2) {
23022
+ return "";
23023
+ }
23024
+ };
22998
23025
  return (_ctx, _cache) => {
22999
23026
  const _component_HierarchyFacetLevel = resolveComponent("HierarchyFacetLevel", true);
23000
23027
  return openBlock(), createElementBlock("div", {
@@ -23010,12 +23037,14 @@ const _sfc_main$S = /* @__PURE__ */ defineComponent({
23010
23037
  class: normalizeClass(["lupa-term-checkbox", { checked: isChecked.value }])
23011
23038
  }, null, 2)
23012
23039
  ]),
23013
- createElementVNode("div", _hoisted_2$y, [
23014
- createElementVNode("span", _hoisted_3$p, toDisplayString(_ctx.item.title) + toDisplayString(" "), 1),
23015
- _ctx.options.showDocumentCount ? (openBlock(), createElementBlock("span", _hoisted_4$h, "(" + toDisplayString(_ctx.item.count) + ")", 1)) : createCommentVNode("", true)
23016
- ])
23040
+ createElementVNode("div", {
23041
+ class: normalizeClass(["lupa-term-checkbox-label", { [getFacetValueClass(_ctx.item)]: true }])
23042
+ }, [
23043
+ createElementVNode("span", _hoisted_2$y, toDisplayString(_ctx.item.title) + toDisplayString(" "), 1),
23044
+ _ctx.options.showDocumentCount ? (openBlock(), createElementBlock("span", _hoisted_3$p, "(" + toDisplayString(_ctx.item.count) + ")", 1)) : createCommentVNode("", true)
23045
+ ], 2)
23017
23046
  ]),
23018
- showChildren.value ? (openBlock(), createElementBlock("div", _hoisted_5$b, [
23047
+ showChildren.value ? (openBlock(), createElementBlock("div", _hoisted_4$h, [
23019
23048
  (openBlock(true), createElementBlock(Fragment, null, renderList(treeItem.value.children, (itemChild) => {
23020
23049
  return openBlock(), createBlock(_component_HierarchyFacetLevel, {
23021
23050
  key: itemChild.title,