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