@getlupa/client 1.17.6 → 1.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.iife.js +1396 -1361
- package/dist/lupaSearch.js +1396 -1361
- package/dist/lupaSearch.mjs +1396 -1361
- package/dist/lupaSearch.umd.js +1396 -1361
- package/dist/src/modules/pluginManager/PluginConfigurationMerger.d.ts +2 -0
- package/package.json +2 -2
package/dist/lupaSearch.umd.js
CHANGED
|
@@ -7057,1319 +7057,36 @@ var __async = (__this, __arguments, generator) => {
|
|
|
7057
7057
|
return loadRedirectionRules(queryKey, (options === null || options === void 0 ? void 0 : options.environment) || "production", options === null || options === void 0 ? void 0 : options.customBaseUrl);
|
|
7058
7058
|
}
|
|
7059
7059
|
};
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
};
|
|
7076
|
-
const capitalize$1 = (str) => {
|
|
7077
|
-
if (!str) {
|
|
7078
|
-
return "";
|
|
7079
|
-
}
|
|
7080
|
-
return str[0].toLocaleUpperCase() + str.slice(1);
|
|
7081
|
-
};
|
|
7082
|
-
const addParamsToLabel = (label, ...params) => {
|
|
7083
|
-
if (!params || params.length < 1) {
|
|
7084
|
-
return label;
|
|
7085
|
-
}
|
|
7086
|
-
const paramKeys = Array.from(Array(params.length).keys());
|
|
7087
|
-
return paramKeys.reduce((a, c2) => a.replace(`{${c2 + 1}}`, params[c2]), label);
|
|
7088
|
-
};
|
|
7089
|
-
const getRandomString = (length) => {
|
|
7090
|
-
const chars = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
7091
|
-
let result2 = "";
|
|
7092
|
-
for (let i = length; i > 0; --i) {
|
|
7093
|
-
result2 += chars[Math.floor(Math.random() * chars.length)];
|
|
7094
|
-
}
|
|
7095
|
-
return result2;
|
|
7096
|
-
};
|
|
7097
|
-
const toFixedIfNecessary = (value, precision = 2) => {
|
|
7098
|
-
return (+parseFloat(value).toFixed(precision)).toString();
|
|
7099
|
-
};
|
|
7100
|
-
const getDisplayValue = (value) => {
|
|
7101
|
-
if (value === void 0) {
|
|
7102
|
-
return "";
|
|
7103
|
-
}
|
|
7104
|
-
if (typeof value === "string") {
|
|
7105
|
-
return value;
|
|
7106
|
-
}
|
|
7107
|
-
return toFixedIfNecessary(value.toString());
|
|
7108
|
-
};
|
|
7109
|
-
const getProductKey = (index, product, idKey) => {
|
|
7110
|
-
if (!idKey) {
|
|
7111
|
-
return index;
|
|
7112
|
-
}
|
|
7113
|
-
if (product[idKey]) {
|
|
7114
|
-
return product[idKey];
|
|
7115
|
-
}
|
|
7116
|
-
return index;
|
|
7117
|
-
};
|
|
7118
|
-
const normalizeFloat = (value) => {
|
|
7119
|
-
var _a;
|
|
7120
|
-
if (!value) {
|
|
7121
|
-
return 0;
|
|
7122
|
-
}
|
|
7123
|
-
return +((_a = value == null ? void 0 : value.replace(/[^0-9,.]/g, "")) == null ? void 0 : _a.replace(",", "."));
|
|
7124
|
-
};
|
|
7125
|
-
const escapeHtml$1 = (value) => {
|
|
7126
|
-
if (!value) {
|
|
7127
|
-
return "";
|
|
7128
|
-
}
|
|
7129
|
-
let output = "";
|
|
7130
|
-
let isSkip = false;
|
|
7131
|
-
value.split(/(<del>.*?<\/del>)/g).forEach((segment) => {
|
|
7132
|
-
if (segment.startsWith("<del>") && segment.endsWith("</del>")) {
|
|
7133
|
-
output += segment;
|
|
7134
|
-
isSkip = true;
|
|
7135
|
-
}
|
|
7136
|
-
if (!isSkip) {
|
|
7137
|
-
output += segment.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
7138
|
-
}
|
|
7139
|
-
if (isSkip) {
|
|
7140
|
-
isSkip = false;
|
|
7141
|
-
}
|
|
7142
|
-
});
|
|
7143
|
-
return output;
|
|
7144
|
-
};
|
|
7145
|
-
const inputsAreEqual = (input2, possibleValues) => {
|
|
7146
|
-
if (!input2) {
|
|
7147
|
-
return false;
|
|
7148
|
-
}
|
|
7149
|
-
const normalizedInput = getTransformedString(input2);
|
|
7150
|
-
return possibleValues.some((v) => getTransformedString(v) === normalizedInput);
|
|
7151
|
-
};
|
|
7152
|
-
const levenshteinDistance = (s = "", t = "") => {
|
|
7153
|
-
if (!(s == null ? void 0 : s.length)) {
|
|
7154
|
-
return t.length;
|
|
7155
|
-
}
|
|
7156
|
-
if (!(t == null ? void 0 : t.length)) {
|
|
7157
|
-
return s.length;
|
|
7158
|
-
}
|
|
7159
|
-
const arr = [];
|
|
7160
|
-
for (let i = 0; i <= t.length; i++) {
|
|
7161
|
-
arr[i] = [i];
|
|
7162
|
-
for (let j = 1; j <= s.length; j++) {
|
|
7163
|
-
arr[i][j] = i === 0 ? j : Math.min(
|
|
7164
|
-
arr[i - 1][j] + 1,
|
|
7165
|
-
arr[i][j - 1] + 1,
|
|
7166
|
-
arr[i - 1][j - 1] + (s[j - 1] === t[i - 1] ? 0 : 1)
|
|
7167
|
-
);
|
|
7168
|
-
}
|
|
7169
|
-
}
|
|
7170
|
-
return arr[t.length][s.length];
|
|
7171
|
-
};
|
|
7172
|
-
const findClosestStringValue = (input2, possibleValues, key) => {
|
|
7173
|
-
var _a;
|
|
7174
|
-
const directMatch = possibleValues.find((v) => v[key] === input2);
|
|
7175
|
-
if (directMatch) {
|
|
7176
|
-
return directMatch;
|
|
7177
|
-
}
|
|
7178
|
-
const distances = possibleValues.map((v) => levenshteinDistance(`${v[key]}`, input2));
|
|
7179
|
-
const minDistance = Math.min(...distances);
|
|
7180
|
-
const closestValue = (_a = possibleValues.filter((_, i) => distances[i] === minDistance)) == null ? void 0 : _a[0];
|
|
7181
|
-
return closestValue;
|
|
7182
|
-
};
|
|
7183
|
-
const DEFAULT_SEARCH_BOX_OPTIONS$1 = {
|
|
7184
|
-
inputSelector: "#searchBox",
|
|
7185
|
-
options: {
|
|
7186
|
-
environment: "production"
|
|
7187
|
-
},
|
|
7188
|
-
showTotalCount: false,
|
|
7189
|
-
minInputLength: 1,
|
|
7190
|
-
inputAttributes: {
|
|
7191
|
-
name: "q"
|
|
7192
|
-
},
|
|
7193
|
-
debounce: 0,
|
|
7194
|
-
labels: {
|
|
7195
|
-
placeholder: "Search for products...",
|
|
7196
|
-
noResults: "There are no results found.",
|
|
7197
|
-
moreResults: "Show more results",
|
|
7198
|
-
currency: "€",
|
|
7199
|
-
defaultFacetLabel: "Category:"
|
|
7200
|
-
},
|
|
7201
|
-
links: {
|
|
7202
|
-
searchResults: "/search"
|
|
7203
|
-
},
|
|
7204
|
-
panels: [
|
|
7205
|
-
{
|
|
7206
|
-
type: "suggestion",
|
|
7207
|
-
queryKey: "",
|
|
7208
|
-
highlight: true,
|
|
7209
|
-
limit: 5
|
|
7210
|
-
},
|
|
7211
|
-
{
|
|
7212
|
-
type: "document",
|
|
7213
|
-
queryKey: "",
|
|
7214
|
-
limit: 5,
|
|
7215
|
-
searchBySuggestion: false,
|
|
7216
|
-
links: {
|
|
7217
|
-
details: "{url}"
|
|
7218
|
-
},
|
|
7219
|
-
titleKey: "name",
|
|
7220
|
-
elements: []
|
|
7221
|
-
}
|
|
7222
|
-
],
|
|
7223
|
-
history: {
|
|
7224
|
-
labels: {
|
|
7225
|
-
clear: "Clear History"
|
|
7226
|
-
}
|
|
7227
|
-
}
|
|
7228
|
-
};
|
|
7229
|
-
const DEFAULT_OPTIONS_RESULTS$1 = {
|
|
7230
|
-
options: {
|
|
7231
|
-
environment: "production"
|
|
7232
|
-
},
|
|
7233
|
-
queryKey: "",
|
|
7234
|
-
containerSelector: "#searchResultsContainer",
|
|
7235
|
-
searchTitlePosition: "page-top",
|
|
7236
|
-
labels: {
|
|
7237
|
-
pageSize: "Page size:",
|
|
7238
|
-
sortBy: "Sort by:",
|
|
7239
|
-
itemCount: "Items {1} of {2}",
|
|
7240
|
-
filteredItemCount: "",
|
|
7241
|
-
currency: "€",
|
|
7242
|
-
showMore: "Show more",
|
|
7243
|
-
searchResults: "Search Query: ",
|
|
7244
|
-
emptyResults: "There are no results for the query:",
|
|
7245
|
-
mobileFilterButton: "Filter",
|
|
7246
|
-
htmlTitleTemplate: "Search Query: '{1}'",
|
|
7247
|
-
noResultsSuggestion: "No results found for this query: {1}",
|
|
7248
|
-
didYouMean: "Did you mean to search: {1}",
|
|
7249
|
-
similarQuery: "Search results for phrase {1}",
|
|
7250
|
-
similarQueries: "Similar queries:",
|
|
7251
|
-
similarResultsLabel: "Related to your query:"
|
|
7252
|
-
},
|
|
7253
|
-
grid: {
|
|
7254
|
-
columns: {
|
|
7255
|
-
xl: 4,
|
|
7256
|
-
l: 3,
|
|
7257
|
-
md: 2,
|
|
7258
|
-
sm: 2,
|
|
7259
|
-
xs: 1
|
|
7260
|
-
}
|
|
7261
|
-
},
|
|
7262
|
-
pagination: {
|
|
7263
|
-
sizeSelection: {
|
|
7264
|
-
position: {
|
|
7265
|
-
top: false,
|
|
7266
|
-
bottom: true
|
|
7267
|
-
},
|
|
7268
|
-
sizes: [10, 20, 25]
|
|
7269
|
-
},
|
|
7270
|
-
pageSelection: {
|
|
7271
|
-
position: {
|
|
7272
|
-
top: false,
|
|
7273
|
-
bottom: true
|
|
7274
|
-
},
|
|
7275
|
-
display: 5,
|
|
7276
|
-
displayMobile: 3
|
|
7277
|
-
}
|
|
7278
|
-
},
|
|
7279
|
-
sort: [],
|
|
7280
|
-
filters: {
|
|
7281
|
-
currentFilters: {
|
|
7282
|
-
visibility: {
|
|
7283
|
-
mobileSidebar: true,
|
|
7284
|
-
mobileToolbar: true
|
|
7285
|
-
},
|
|
7286
|
-
labels: {
|
|
7287
|
-
title: "Current filters:",
|
|
7288
|
-
clearAll: "Clear all"
|
|
7060
|
+
var commonjsGlobal$1 = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
7061
|
+
function getDefaultExportFromCjs(x2) {
|
|
7062
|
+
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
|
|
7063
|
+
}
|
|
7064
|
+
function getAugmentedNamespace(n) {
|
|
7065
|
+
if (n.__esModule)
|
|
7066
|
+
return n;
|
|
7067
|
+
var f2 = n.default;
|
|
7068
|
+
if (typeof f2 == "function") {
|
|
7069
|
+
var a = function a2() {
|
|
7070
|
+
if (this instanceof a2) {
|
|
7071
|
+
var args = [null];
|
|
7072
|
+
args.push.apply(args, arguments);
|
|
7073
|
+
var Ctor = Function.bind.apply(f2, args);
|
|
7074
|
+
return new Ctor();
|
|
7289
7075
|
}
|
|
7290
|
-
|
|
7291
|
-
facets: {
|
|
7292
|
-
labels: {
|
|
7293
|
-
title: "Filters:",
|
|
7294
|
-
showAll: "Show more",
|
|
7295
|
-
facetFilter: "Filter...",
|
|
7296
|
-
facetClear: "Clear"
|
|
7297
|
-
},
|
|
7298
|
-
filterable: {
|
|
7299
|
-
minValues: 5
|
|
7300
|
-
},
|
|
7301
|
-
hierarchy: {
|
|
7302
|
-
maxInitialLevel: 2,
|
|
7303
|
-
topLevelValueCountLimit: 5,
|
|
7304
|
-
filterable: true
|
|
7305
|
-
},
|
|
7306
|
-
facetValueCountLimit: 20,
|
|
7307
|
-
showDocumentCount: true,
|
|
7308
|
-
style: {
|
|
7309
|
-
type: "sidebar"
|
|
7310
|
-
}
|
|
7311
|
-
}
|
|
7312
|
-
},
|
|
7313
|
-
toolbar: {
|
|
7314
|
-
layoutSelector: true,
|
|
7315
|
-
itemSummary: true,
|
|
7316
|
-
clearFilters: false
|
|
7317
|
-
},
|
|
7318
|
-
isInStock: () => {
|
|
7319
|
-
return true;
|
|
7320
|
-
},
|
|
7321
|
-
badges: {
|
|
7322
|
-
anchor: "tr",
|
|
7323
|
-
elements: []
|
|
7324
|
-
},
|
|
7325
|
-
links: {
|
|
7326
|
-
details: "/{id}"
|
|
7327
|
-
},
|
|
7328
|
-
elements: [],
|
|
7329
|
-
breadcrumbs: []
|
|
7330
|
-
};
|
|
7331
|
-
const useScreenStore = defineStore("screen", () => {
|
|
7332
|
-
const measuredScreenWidth = ref(1e3);
|
|
7333
|
-
const optionsStore = useOptionsStore();
|
|
7334
|
-
const screenWidth = computed(() => {
|
|
7335
|
-
var _a, _b;
|
|
7336
|
-
const { searchResultOptions } = storeToRefs(optionsStore);
|
|
7337
|
-
return (_b = (_a = searchResultOptions.value.grid) == null ? void 0 : _a.forcedScreenWidth) != null ? _b : measuredScreenWidth.value;
|
|
7338
|
-
});
|
|
7339
|
-
const configuredGridSizes = computed(() => {
|
|
7340
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
7341
|
-
const { searchResultOptions } = storeToRefs(optionsStore);
|
|
7342
|
-
return {
|
|
7343
|
-
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,
|
|
7344
|
-
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,
|
|
7345
|
-
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,
|
|
7346
|
-
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
|
|
7076
|
+
return f2.apply(this, arguments);
|
|
7347
7077
|
};
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
}
|
|
7360
|
-
return "xl";
|
|
7361
|
-
}
|
|
7362
|
-
});
|
|
7363
|
-
const isMobileWidth = computed(() => {
|
|
7364
|
-
var _a;
|
|
7365
|
-
return (_a = ["xs", "sm"]) == null ? void 0 : _a.includes(currentScreenWidth.value);
|
|
7366
|
-
});
|
|
7367
|
-
const setScreenWidth = ({ width }) => {
|
|
7368
|
-
measuredScreenWidth.value = width;
|
|
7369
|
-
};
|
|
7370
|
-
return { screenWidth, currentScreenWidth, isMobileWidth, setScreenWidth };
|
|
7371
|
-
});
|
|
7372
|
-
const useOptionsStore = defineStore("options", () => {
|
|
7373
|
-
const searchBoxOptions = ref(
|
|
7374
|
-
DEFAULT_SEARCH_BOX_OPTIONS$1
|
|
7375
|
-
);
|
|
7376
|
-
const searchResultOptions = ref(
|
|
7377
|
-
DEFAULT_OPTIONS_RESULTS$1
|
|
7378
|
-
);
|
|
7379
|
-
const trackingOptions = ref({});
|
|
7380
|
-
const searchResultInitialFilters = ref({});
|
|
7381
|
-
const productRecommendationOptions = ref({});
|
|
7382
|
-
const screenStore = useScreenStore();
|
|
7383
|
-
const envOptions = computed(
|
|
7384
|
-
() => {
|
|
7385
|
-
var _a;
|
|
7386
|
-
return (_a = searchBoxOptions.value.options) != null ? _a : searchResultOptions.value.options;
|
|
7387
|
-
}
|
|
7388
|
-
);
|
|
7389
|
-
const classMap = computed(() => {
|
|
7390
|
-
var _a;
|
|
7391
|
-
return (_a = searchResultOptions.value.classMap) != null ? _a : {};
|
|
7392
|
-
});
|
|
7393
|
-
const initialFilters = computed(() => searchResultInitialFilters.value);
|
|
7394
|
-
const boxRoutingBehavior = computed(() => {
|
|
7395
|
-
var _a;
|
|
7396
|
-
return (_a = searchBoxOptions.value.routingBehavior) != null ? _a : "direct-link";
|
|
7397
|
-
});
|
|
7398
|
-
const searchResultsRoutingBehavior = computed(
|
|
7399
|
-
() => {
|
|
7400
|
-
var _a;
|
|
7401
|
-
return (_a = searchResultOptions.value.routingBehavior) != null ? _a : "direct-link";
|
|
7402
|
-
}
|
|
7403
|
-
);
|
|
7404
|
-
const defaultSearchResultPageSize = computed(
|
|
7405
|
-
() => {
|
|
7406
|
-
var _a, _b;
|
|
7407
|
-
return (_b = (_a = currentResolutionPageSizes.value) == null ? void 0 : _a[0]) != null ? _b : DEFAULT_PAGE_SIZE;
|
|
7408
|
-
}
|
|
7409
|
-
);
|
|
7410
|
-
const currentResolutionPageSizes = computed(() => {
|
|
7411
|
-
var _a, _b, _c, _d;
|
|
7412
|
-
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;
|
|
7413
|
-
if (Array.isArray(pageSizes)) {
|
|
7414
|
-
return pageSizes;
|
|
7415
|
-
}
|
|
7416
|
-
const screenSize = screenStore.currentScreenWidth;
|
|
7417
|
-
switch (screenSize) {
|
|
7418
|
-
case "xs":
|
|
7419
|
-
return pageSizes.xs;
|
|
7420
|
-
case "sm":
|
|
7421
|
-
return pageSizes.sm;
|
|
7422
|
-
case "md":
|
|
7423
|
-
return pageSizes.md;
|
|
7424
|
-
case "l":
|
|
7425
|
-
return pageSizes.l;
|
|
7426
|
-
case "xl":
|
|
7427
|
-
return pageSizes.xl;
|
|
7428
|
-
}
|
|
7429
|
-
});
|
|
7430
|
-
const setSearchBoxOptions = ({ options }) => {
|
|
7431
|
-
searchBoxOptions.value = options;
|
|
7432
|
-
};
|
|
7433
|
-
const setTrackingOptions = ({ options }) => {
|
|
7434
|
-
trackingOptions.value = options;
|
|
7435
|
-
};
|
|
7436
|
-
const setSearchResultOptions = ({ options }) => {
|
|
7437
|
-
searchResultOptions.value = options;
|
|
7438
|
-
};
|
|
7439
|
-
const setInitialFilters = ({ initialFilters: initialFilters2 }) => {
|
|
7440
|
-
searchResultInitialFilters.value = initialFilters2;
|
|
7441
|
-
};
|
|
7442
|
-
const setProductRecommendationOptions = ({
|
|
7443
|
-
options
|
|
7444
|
-
}) => {
|
|
7445
|
-
productRecommendationOptions.value = options;
|
|
7446
|
-
};
|
|
7447
|
-
const getQueryParamName = (param) => {
|
|
7448
|
-
var _a;
|
|
7449
|
-
const nameMap = searchBoxOptions.value.queryParameterNames;
|
|
7450
|
-
return (_a = nameMap == null ? void 0 : nameMap[param]) != null ? _a : param;
|
|
7451
|
-
};
|
|
7452
|
-
return {
|
|
7453
|
-
searchBoxOptions,
|
|
7454
|
-
searchResultOptions,
|
|
7455
|
-
trackingOptions,
|
|
7456
|
-
envOptions,
|
|
7457
|
-
classMap,
|
|
7458
|
-
initialFilters,
|
|
7459
|
-
boxRoutingBehavior,
|
|
7460
|
-
searchResultsRoutingBehavior,
|
|
7461
|
-
defaultSearchResultPageSize,
|
|
7462
|
-
currentResolutionPageSizes,
|
|
7463
|
-
productRecommendationOptions,
|
|
7464
|
-
setSearchBoxOptions,
|
|
7465
|
-
setTrackingOptions,
|
|
7466
|
-
setSearchResultOptions,
|
|
7467
|
-
setInitialFilters,
|
|
7468
|
-
setProductRecommendationOptions,
|
|
7469
|
-
getQueryParamName
|
|
7470
|
-
};
|
|
7471
|
-
});
|
|
7472
|
-
const initAnalyticsTracking = (analyticsOptions) => {
|
|
7473
|
-
try {
|
|
7474
|
-
if (analyticsOptions == null ? void 0 : analyticsOptions.enabled) {
|
|
7475
|
-
window.sessionStorage.setItem(TRACKING_ANALYTICS_KEY, JSON.stringify(analyticsOptions));
|
|
7476
|
-
} else {
|
|
7477
|
-
window.sessionStorage.removeItem(TRACKING_ANALYTICS_KEY);
|
|
7478
|
-
}
|
|
7479
|
-
} catch (e2) {
|
|
7480
|
-
}
|
|
7481
|
-
};
|
|
7482
|
-
const initBaseTracking = (enabled) => {
|
|
7483
|
-
try {
|
|
7484
|
-
if (enabled) {
|
|
7485
|
-
window.sessionStorage.setItem(TRACKING_STORAGE_KEY_BASE, "1");
|
|
7486
|
-
} else {
|
|
7487
|
-
window.sessionStorage.removeItem(TRACKING_STORAGE_KEY_BASE);
|
|
7488
|
-
clearSessionTracking();
|
|
7489
|
-
clearUserTracking();
|
|
7490
|
-
}
|
|
7491
|
-
} catch (e2) {
|
|
7492
|
-
}
|
|
7493
|
-
};
|
|
7494
|
-
const clearSessionTracking = () => {
|
|
7495
|
-
try {
|
|
7496
|
-
window.sessionStorage.removeItem(TRACKING_STORAGE_KEY);
|
|
7497
|
-
} catch (e2) {
|
|
7498
|
-
}
|
|
7499
|
-
};
|
|
7500
|
-
const initSessionTracking = () => {
|
|
7501
|
-
try {
|
|
7502
|
-
if (getSessionKey()) {
|
|
7503
|
-
return;
|
|
7504
|
-
}
|
|
7505
|
-
const key = getRandomString(TRACKING_KEY_LENGTH);
|
|
7506
|
-
window.sessionStorage.setItem(TRACKING_STORAGE_KEY, key);
|
|
7507
|
-
} catch (e2) {
|
|
7508
|
-
}
|
|
7509
|
-
};
|
|
7510
|
-
const initUserTracking = (userKey) => {
|
|
7511
|
-
try {
|
|
7512
|
-
if (getUserKey()) {
|
|
7513
|
-
return;
|
|
7514
|
-
}
|
|
7515
|
-
const key = userKey || getRandomString(TRACKING_KEY_LENGTH);
|
|
7516
|
-
window.localStorage.setItem(TRACKING_STORAGE_KEY, key);
|
|
7517
|
-
} catch (e2) {
|
|
7518
|
-
}
|
|
7519
|
-
};
|
|
7520
|
-
const clearUserTracking = () => {
|
|
7521
|
-
try {
|
|
7522
|
-
window.localStorage.removeItem(TRACKING_STORAGE_KEY);
|
|
7523
|
-
} catch (e2) {
|
|
7524
|
-
}
|
|
7525
|
-
};
|
|
7526
|
-
const isTrackingEnabled = () => {
|
|
7527
|
-
try {
|
|
7528
|
-
return Boolean(window.sessionStorage.getItem(TRACKING_STORAGE_KEY_BASE));
|
|
7529
|
-
} catch (e2) {
|
|
7530
|
-
return false;
|
|
7531
|
-
}
|
|
7532
|
-
};
|
|
7533
|
-
const isDelayedClickTracking = () => {
|
|
7534
|
-
try {
|
|
7535
|
-
return Boolean(window.localStorage.getItem(TRACKING_CLICK_DELAYED));
|
|
7536
|
-
} catch (e2) {
|
|
7537
|
-
return false;
|
|
7538
|
-
}
|
|
7539
|
-
};
|
|
7540
|
-
const getSessionKey = () => {
|
|
7541
|
-
var _a;
|
|
7542
|
-
try {
|
|
7543
|
-
return (_a = window.sessionStorage.getItem(TRACKING_STORAGE_KEY)) != null ? _a : void 0;
|
|
7544
|
-
} catch (e2) {
|
|
7545
|
-
return void 0;
|
|
7546
|
-
}
|
|
7547
|
-
};
|
|
7548
|
-
const getUserKey = () => {
|
|
7549
|
-
var _a;
|
|
7550
|
-
try {
|
|
7551
|
-
return (_a = window.localStorage.getItem(TRACKING_STORAGE_KEY)) != null ? _a : void 0;
|
|
7552
|
-
} catch (e2) {
|
|
7553
|
-
return void 0;
|
|
7554
|
-
}
|
|
7555
|
-
};
|
|
7556
|
-
const initTracking$1 = (options) => {
|
|
7557
|
-
initBaseTracking(Boolean(options.trackBase));
|
|
7558
|
-
if (options.trackSession) {
|
|
7559
|
-
initSessionTracking();
|
|
7560
|
-
} else {
|
|
7561
|
-
clearSessionTracking();
|
|
7562
|
-
}
|
|
7563
|
-
if (options.trackUser) {
|
|
7564
|
-
initUserTracking(options.userKey);
|
|
7565
|
-
} else {
|
|
7566
|
-
clearUserTracking();
|
|
7567
|
-
}
|
|
7568
|
-
if (options.analytics) {
|
|
7569
|
-
initAnalyticsTracking(options.analytics);
|
|
7570
|
-
}
|
|
7571
|
-
if (options.delayedClickTracking) {
|
|
7572
|
-
window.localStorage.setItem(TRACKING_CLICK_DELAYED, "1");
|
|
7573
|
-
checkAndDispatchDelayedEvents();
|
|
7574
|
-
} else {
|
|
7575
|
-
window.localStorage.removeItem(TRACKING_CLICK_DELAYED);
|
|
7576
|
-
}
|
|
7577
|
-
};
|
|
7578
|
-
const getLupaTrackingContext = () => {
|
|
7579
|
-
if (!isTrackingEnabled()) {
|
|
7580
|
-
return {};
|
|
7581
|
-
}
|
|
7582
|
-
return {
|
|
7583
|
-
userId: getUserKey(),
|
|
7584
|
-
sessionId: getSessionKey()
|
|
7585
|
-
};
|
|
7586
|
-
};
|
|
7587
|
-
const trackLupaEvent = (queryKey, data = {}, options) => {
|
|
7588
|
-
var _a, _b;
|
|
7589
|
-
if (!queryKey || !data.type) {
|
|
7590
|
-
return;
|
|
7591
|
-
}
|
|
7592
|
-
const eventData = {
|
|
7593
|
-
searchQuery: (_a = data.searchQuery) != null ? _a : "",
|
|
7594
|
-
itemId: (_b = data.itemId) != null ? _b : "",
|
|
7595
|
-
name: data.type,
|
|
7596
|
-
userId: getUserKey(),
|
|
7597
|
-
sessionId: getSessionKey(),
|
|
7598
|
-
filters: data.filters,
|
|
7599
|
-
metadata: data.metadata,
|
|
7600
|
-
sourceItemId: data.sourceItemId
|
|
7601
|
-
};
|
|
7602
|
-
LupaSearchSdk.track(queryKey, eventData, options);
|
|
7603
|
-
};
|
|
7604
|
-
const sendGa = (name, ...args) => {
|
|
7605
|
-
window.ga(() => {
|
|
7606
|
-
const trackers = window.ga.getAll();
|
|
7607
|
-
const firstTracker = trackers[0];
|
|
7608
|
-
if (!firstTracker) {
|
|
7609
|
-
console.error("GA tracker not found");
|
|
7610
|
-
}
|
|
7611
|
-
const trackerName = firstTracker.get("name");
|
|
7612
|
-
window.ga(`${trackerName}.${name}`, ...args);
|
|
7613
|
-
});
|
|
7614
|
-
};
|
|
7615
|
-
const trackAnalyticsEvent = (data) => {
|
|
7616
|
-
var _a, _b, _c;
|
|
7617
|
-
try {
|
|
7618
|
-
const options = JSON.parse(
|
|
7619
|
-
(_a = window.sessionStorage.getItem(TRACKING_ANALYTICS_KEY)) != null ? _a : "{}"
|
|
7620
|
-
);
|
|
7621
|
-
if (!data.analytics || !options.enabled || ((_c = options.ignoreEvents) == null ? void 0 : _c.includes((_b = data.analytics) == null ? void 0 : _b.type))) {
|
|
7622
|
-
return;
|
|
7623
|
-
}
|
|
7624
|
-
switch (options.type) {
|
|
7625
|
-
case "ua":
|
|
7626
|
-
sendUaAnalyticsEvent(data, options);
|
|
7627
|
-
break;
|
|
7628
|
-
case "ga4":
|
|
7629
|
-
sendGa4AnalyticsEvent(data, options);
|
|
7630
|
-
break;
|
|
7631
|
-
case "debug":
|
|
7632
|
-
processDebugEvent(data);
|
|
7633
|
-
break;
|
|
7634
|
-
default:
|
|
7635
|
-
sendUaAnalyticsEvent(data, options);
|
|
7636
|
-
}
|
|
7637
|
-
} catch (e2) {
|
|
7638
|
-
console.error("Unable to send an event to google analytics");
|
|
7639
|
-
}
|
|
7640
|
-
};
|
|
7641
|
-
const parseEcommerceData = (data, title) => {
|
|
7642
|
-
var _a, _b;
|
|
7643
|
-
return ((_a = data.analytics) == null ? void 0 : _a.items) ? {
|
|
7644
|
-
item_list_name: title,
|
|
7645
|
-
items: (_b = data.analytics) == null ? void 0 : _b.items
|
|
7646
|
-
} : void 0;
|
|
7647
|
-
};
|
|
7648
|
-
const sendUaAnalyticsEvent = (data, options) => {
|
|
7649
|
-
var _a, _b, _c, _d;
|
|
7650
|
-
const ga = window.ga;
|
|
7651
|
-
if (!ga) {
|
|
7652
|
-
console.error("Google Analytics object not found");
|
|
7653
|
-
return;
|
|
7654
|
-
}
|
|
7655
|
-
sendGa(
|
|
7656
|
-
"send",
|
|
7657
|
-
"event",
|
|
7658
|
-
options.parentEventName,
|
|
7659
|
-
(_b = (_a = data.analytics) == null ? void 0 : _a.type) != null ? _b : "",
|
|
7660
|
-
(_d = (_c = data.analytics) == null ? void 0 : _c.label) != null ? _d : ""
|
|
7661
|
-
);
|
|
7662
|
-
};
|
|
7663
|
-
const sendGa4AnalyticsEvent = (data, options) => {
|
|
7664
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
7665
|
-
if (!window || !window.dataLayer) {
|
|
7666
|
-
console.error("dataLayer object not found.");
|
|
7667
|
-
return;
|
|
7668
|
-
}
|
|
7669
|
-
const sendItemTitle = data.searchQuery !== ((_a = data.analytics) == null ? void 0 : _a.label);
|
|
7670
|
-
const title = sendItemTitle ? (_b = data.analytics) == null ? void 0 : _b.label : void 0;
|
|
7671
|
-
const params = __spreadValues2({
|
|
7672
|
-
search_text: data.searchQuery,
|
|
7673
|
-
item_title: title,
|
|
7674
|
-
item_id: data.itemId,
|
|
7675
|
-
ecommerce: parseEcommerceData(data, (_c = data.analytics) == null ? void 0 : _c.listLabel)
|
|
7676
|
-
}, (_e = (_d = data.analytics) == null ? void 0 : _d.additionalParams) != null ? _e : {});
|
|
7677
|
-
window.dataLayer.push(__spreadValues2({
|
|
7678
|
-
event: (_g = (_f = data.analytics) == null ? void 0 : _f.type) != null ? _g : options.parentEventName
|
|
7679
|
-
}, params));
|
|
7680
|
-
};
|
|
7681
|
-
const processDebugEvent = (data) => {
|
|
7682
|
-
var _a, _b, _c, _d;
|
|
7683
|
-
const sendItemTitle = data.searchQuery !== ((_a = data.analytics) == null ? void 0 : _a.label);
|
|
7684
|
-
const title = sendItemTitle ? (_b = data.analytics) == null ? void 0 : _b.label : void 0;
|
|
7685
|
-
const params = {
|
|
7686
|
-
event: (_c = data.analytics) == null ? void 0 : _c.type,
|
|
7687
|
-
search_text: data.searchQuery,
|
|
7688
|
-
item_title: title,
|
|
7689
|
-
item_id: data.itemId,
|
|
7690
|
-
ecommerce: parseEcommerceData(data, (_d = data.analytics) == null ? void 0 : _d.listLabel)
|
|
7691
|
-
};
|
|
7692
|
-
console.debug("Analytics debug event:", params);
|
|
7693
|
-
};
|
|
7694
|
-
const getDelayedEventsCache = () => {
|
|
7695
|
-
var _a;
|
|
7696
|
-
try {
|
|
7697
|
-
return JSON.parse((_a = window.localStorage.getItem(DELAYED_TRACKING_EVENTS_CACHE)) != null ? _a : "{}");
|
|
7698
|
-
} catch (e2) {
|
|
7699
|
-
return {};
|
|
7700
|
-
}
|
|
7701
|
-
};
|
|
7702
|
-
const storeDelayedEventCache = (cache) => {
|
|
7703
|
-
try {
|
|
7704
|
-
window.localStorage.setItem(DELAYED_TRACKING_EVENTS_CACHE, JSON.stringify(cache));
|
|
7705
|
-
} catch (e2) {
|
|
7706
|
-
}
|
|
7707
|
-
};
|
|
7708
|
-
const checkAndDispatchDelayedEvents = () => {
|
|
7709
|
-
var _a, _b;
|
|
7710
|
-
const optionsStore = useOptionsStore();
|
|
7711
|
-
const eventCache = getDelayedEventsCache();
|
|
7712
|
-
const urls = Object.keys(eventCache);
|
|
7713
|
-
for (const url of urls) {
|
|
7714
|
-
if ((_a = window.location.href) == null ? void 0 : _a.includes(url)) {
|
|
7715
|
-
const options = (_b = optionsStore.envOptions) != null ? _b : { environment: "production" };
|
|
7716
|
-
const { queryKey, data } = eventCache[url];
|
|
7717
|
-
track(queryKey, data, options);
|
|
7718
|
-
}
|
|
7719
|
-
}
|
|
7720
|
-
storeDelayedEventCache({});
|
|
7721
|
-
};
|
|
7722
|
-
const track = (queryKey, data = {}, options) => {
|
|
7723
|
-
var _a;
|
|
7724
|
-
if (!isTrackingEnabled()) {
|
|
7725
|
-
return;
|
|
7726
|
-
}
|
|
7727
|
-
const hasSearchQuery = data.searchQuery;
|
|
7728
|
-
if (!hasSearchQuery && !((_a = data.options) == null ? void 0 : _a.allowEmptySearchQuery)) {
|
|
7729
|
-
return;
|
|
7730
|
-
}
|
|
7731
|
-
trackAnalyticsEvent(data);
|
|
7732
|
-
trackLupaEvent(queryKey, data, options);
|
|
7733
|
-
};
|
|
7734
|
-
var DocumentElementType = /* @__PURE__ */ ((DocumentElementType2) => {
|
|
7735
|
-
DocumentElementType2["IMAGE"] = "image";
|
|
7736
|
-
DocumentElementType2["TITLE"] = "title";
|
|
7737
|
-
DocumentElementType2["CUSTOM"] = "custom";
|
|
7738
|
-
DocumentElementType2["DESCRIPTION"] = "description";
|
|
7739
|
-
DocumentElementType2["PRICE"] = "price";
|
|
7740
|
-
DocumentElementType2["REGULARPRICE"] = "regularPrice";
|
|
7741
|
-
DocumentElementType2["RATING"] = "rating";
|
|
7742
|
-
DocumentElementType2["SINGLE_STAR_RATING"] = "singleStarRating";
|
|
7743
|
-
DocumentElementType2["ADDTOCART"] = "addToCart";
|
|
7744
|
-
DocumentElementType2["CUSTOM_HTML"] = "customHtml";
|
|
7745
|
-
return DocumentElementType2;
|
|
7746
|
-
})(DocumentElementType || {});
|
|
7747
|
-
var SearchBoxPanelType = /* @__PURE__ */ ((SearchBoxPanelType2) => {
|
|
7748
|
-
SearchBoxPanelType2["SUGGESTION"] = "suggestion";
|
|
7749
|
-
SearchBoxPanelType2["DOCUMENT"] = "document";
|
|
7750
|
-
SearchBoxPanelType2["RELATED_SOURCE"] = "related-source";
|
|
7751
|
-
return SearchBoxPanelType2;
|
|
7752
|
-
})(SearchBoxPanelType || {});
|
|
7753
|
-
var BadgeType = /* @__PURE__ */ ((BadgeType2) => {
|
|
7754
|
-
BadgeType2["NEWITEM"] = "newItem";
|
|
7755
|
-
BadgeType2["TEXT"] = "text";
|
|
7756
|
-
BadgeType2["IMAGE"] = "image";
|
|
7757
|
-
BadgeType2["CUSTOM_HTML"] = "customHtml";
|
|
7758
|
-
BadgeType2["DISCOUNT"] = "discount";
|
|
7759
|
-
return BadgeType2;
|
|
7760
|
-
})(BadgeType || {});
|
|
7761
|
-
const retrieveHistory = () => {
|
|
7762
|
-
try {
|
|
7763
|
-
const historyString = window.localStorage.getItem(HISTORY_LOCAL_STORAGE_KEY);
|
|
7764
|
-
return historyString ? JSON.parse(historyString) : [];
|
|
7765
|
-
} catch (e2) {
|
|
7766
|
-
return [];
|
|
7767
|
-
}
|
|
7768
|
-
};
|
|
7769
|
-
const saveHistory = (items) => {
|
|
7770
|
-
try {
|
|
7771
|
-
window.localStorage.setItem(
|
|
7772
|
-
HISTORY_LOCAL_STORAGE_KEY,
|
|
7773
|
-
JSON.stringify(items.slice(0, HISTORY_MAX_ITEMS))
|
|
7774
|
-
);
|
|
7775
|
-
} catch (e2) {
|
|
7776
|
-
}
|
|
7777
|
-
};
|
|
7778
|
-
const useHistoryStore = defineStore("history", () => {
|
|
7779
|
-
const items = ref(retrieveHistory());
|
|
7780
|
-
const count = computed(() => items.value.length);
|
|
7781
|
-
const add2 = ({ item }) => {
|
|
7782
|
-
if (!item) {
|
|
7783
|
-
return items.value;
|
|
7784
|
-
}
|
|
7785
|
-
const newItems = items.value ? [item, ...items.value] : [item];
|
|
7786
|
-
const uniqueItems = Array.from(new Set(newItems));
|
|
7787
|
-
items.value = uniqueItems;
|
|
7788
|
-
saveHistory(uniqueItems);
|
|
7789
|
-
return uniqueItems;
|
|
7790
|
-
};
|
|
7791
|
-
const remove2 = ({ item }) => {
|
|
7792
|
-
var _a, _b;
|
|
7793
|
-
const tempItems = (_b = (_a = items.value) == null ? void 0 : _a.filter((i) => i !== item)) != null ? _b : [];
|
|
7794
|
-
saveHistory(tempItems);
|
|
7795
|
-
items.value = tempItems;
|
|
7796
|
-
return tempItems;
|
|
7797
|
-
};
|
|
7798
|
-
const clear2 = () => {
|
|
7799
|
-
saveHistory([]);
|
|
7800
|
-
items.value = [];
|
|
7801
|
-
};
|
|
7802
|
-
return { items, count, add: add2, remove: remove2, clear: clear2 };
|
|
7803
|
-
});
|
|
7804
|
-
const QUERY_PARAMS$1 = {
|
|
7805
|
-
QUERY: "q",
|
|
7806
|
-
PAGE: "p",
|
|
7807
|
-
LIMIT: "l",
|
|
7808
|
-
SORT: "s"
|
|
7809
|
-
};
|
|
7810
|
-
const QUERY_PARAMS_PARSED = {
|
|
7811
|
-
QUERY: "query",
|
|
7812
|
-
PAGE: "page",
|
|
7813
|
-
LIMIT: "limit",
|
|
7814
|
-
SORT: "sort"
|
|
7815
|
-
};
|
|
7816
|
-
const FACET_PARAMS_TYPE = {
|
|
7817
|
-
TERMS: "f.",
|
|
7818
|
-
RANGE: "fr.",
|
|
7819
|
-
HIERARCHY: "fh."
|
|
7820
|
-
};
|
|
7821
|
-
const FACET_FILTER_MAP = {
|
|
7822
|
-
terms: FACET_PARAMS_TYPE.TERMS,
|
|
7823
|
-
range: FACET_PARAMS_TYPE.RANGE,
|
|
7824
|
-
hierarchy: FACET_PARAMS_TYPE.HIERARCHY
|
|
7825
|
-
};
|
|
7826
|
-
const FACET_KEY_SEPARATOR = ".";
|
|
7827
|
-
const FACET_RANGE_SEPARATOR = ":";
|
|
7828
|
-
const HIERARCHY_SEPARATOR = ">";
|
|
7829
|
-
const FACET_TERM_RANGE_SEPARATOR = "-";
|
|
7830
|
-
const getAmount = (price, separator = ".") => {
|
|
7831
|
-
var _a, _b;
|
|
7832
|
-
if (typeof price === "number") {
|
|
7833
|
-
return `${(_a = price.toFixed(2)) == null ? void 0 : _a.replace(".", separator)}`;
|
|
7834
|
-
}
|
|
7835
|
-
const value = parseFloat(price);
|
|
7836
|
-
if (isNaN(value)) {
|
|
7837
|
-
return "";
|
|
7838
|
-
}
|
|
7839
|
-
return (_b = value.toFixed(2)) == null ? void 0 : _b.replace(".", separator);
|
|
7840
|
-
};
|
|
7841
|
-
const formatPrice = (price, currency = "€", separator = ",", currencyTemplate = "") => {
|
|
7842
|
-
if (price !== 0 && !price) {
|
|
7843
|
-
return "";
|
|
7844
|
-
}
|
|
7845
|
-
const amount = getAmount(price, separator);
|
|
7846
|
-
if (!amount) {
|
|
7847
|
-
return "";
|
|
7848
|
-
}
|
|
7849
|
-
if (currencyTemplate) {
|
|
7850
|
-
return addParamsToLabel(currencyTemplate, amount);
|
|
7851
|
-
}
|
|
7852
|
-
return `${amount} ${currency}`;
|
|
7853
|
-
};
|
|
7854
|
-
const formatPriceSummary = ([min, max], currency, separator = ",", currencyTemplate = "") => {
|
|
7855
|
-
if (min !== void 0 && max !== void 0) {
|
|
7856
|
-
return `${formatPrice(min, currency, separator, currencyTemplate)} - ${formatPrice(
|
|
7857
|
-
max,
|
|
7858
|
-
currency,
|
|
7859
|
-
separator,
|
|
7860
|
-
currencyTemplate
|
|
7861
|
-
)}`;
|
|
7862
|
-
}
|
|
7863
|
-
if (min !== void 0) {
|
|
7864
|
-
return `> ${formatPrice(min, currency, separator, currencyTemplate)}`;
|
|
7865
|
-
}
|
|
7866
|
-
return `< ${formatPrice(max, currency, separator, currencyTemplate)}`;
|
|
7867
|
-
};
|
|
7868
|
-
const getTranslatedFacetKey = (facet, translations) => {
|
|
7869
|
-
var _a, _b;
|
|
7870
|
-
return (_b = (_a = translations == null ? void 0 : translations.keyTranslations) == null ? void 0 : _a[facet.key]) != null ? _b : facet.label;
|
|
7871
|
-
};
|
|
7872
|
-
const getTranslatedFacetValue = (facet, value, translations) => {
|
|
7873
|
-
var _a, _b, _c;
|
|
7874
|
-
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;
|
|
7875
|
-
};
|
|
7876
|
-
const formatRange = (filter2) => {
|
|
7877
|
-
var _a, _b;
|
|
7878
|
-
const lt = (_a = filter2.lt) != null ? _a : filter2.lte;
|
|
7879
|
-
const gt = (_b = filter2.gt) != null ? _b : filter2.gte;
|
|
7880
|
-
if (gt !== void 0 && lt !== void 0) {
|
|
7881
|
-
return `${gt} - ${lt}`;
|
|
7882
|
-
}
|
|
7883
|
-
if (lt !== void 0) {
|
|
7884
|
-
return `<${filter2.lte !== void 0 ? "=" : ""} ${lt}`;
|
|
7885
|
-
}
|
|
7886
|
-
return `>${filter2.gte !== void 0 ? "=" : ""} ${gt}`;
|
|
7887
|
-
};
|
|
7888
|
-
const unfoldTermFilter = (key, filter2) => {
|
|
7889
|
-
const seed = [];
|
|
7890
|
-
return filter2.reduce((a, c2) => [...a, { key, value: c2, type: "terms" }], seed);
|
|
7891
|
-
};
|
|
7892
|
-
const unfoldHierarchyFilter = (key, filter2) => {
|
|
7893
|
-
const seed = [];
|
|
7894
|
-
return filter2.terms.reduce((a, c2) => [...a, { key, value: c2, type: "hierarchy" }], seed);
|
|
7895
|
-
};
|
|
7896
|
-
const unfoldRangeFilter = (key, filter2, price = {}) => {
|
|
7897
|
-
var _a;
|
|
7898
|
-
const gt = filter2.gte || filter2.gt;
|
|
7899
|
-
const lt = filter2.lte || filter2.lt;
|
|
7900
|
-
if (key.includes(CURRENCY_KEY_INDICATOR) || ((_a = price == null ? void 0 : price.keys) == null ? void 0 : _a.includes(key))) {
|
|
7901
|
-
return [
|
|
7902
|
-
{
|
|
7903
|
-
key,
|
|
7904
|
-
value: formatPriceSummary(
|
|
7905
|
-
[gt, lt],
|
|
7906
|
-
price.currency,
|
|
7907
|
-
price.separator,
|
|
7908
|
-
price.currencyTemplate
|
|
7909
|
-
),
|
|
7910
|
-
type: "range"
|
|
7911
|
-
}
|
|
7912
|
-
];
|
|
7913
|
-
}
|
|
7914
|
-
return [{ key, value: `${gt} - ${lt}`, type: "range" }];
|
|
7915
|
-
};
|
|
7916
|
-
const unfoldFilter = (key, filter2, price = {}) => {
|
|
7917
|
-
if (Array.isArray(filter2)) {
|
|
7918
|
-
return unfoldTermFilter(key, filter2);
|
|
7919
|
-
}
|
|
7920
|
-
if (filter2.gte) {
|
|
7921
|
-
return unfoldRangeFilter(key, filter2, price);
|
|
7922
|
-
}
|
|
7923
|
-
if (filter2.terms) {
|
|
7924
|
-
return unfoldHierarchyFilter(key, filter2);
|
|
7925
|
-
}
|
|
7926
|
-
return [];
|
|
7927
|
-
};
|
|
7928
|
-
const unfoldFilters = (filters, price = {}) => {
|
|
7929
|
-
if (!filters) {
|
|
7930
|
-
return [];
|
|
7931
|
-
}
|
|
7932
|
-
const seed = [];
|
|
7933
|
-
return Object.entries(filters).reduce((a, c2) => [...a, ...unfoldFilter(...c2, price)], seed);
|
|
7934
|
-
};
|
|
7935
|
-
const getLabeledFilters = (filters, facets2, translations) => {
|
|
7936
|
-
return filters.map((f2) => {
|
|
7937
|
-
var _a, _b, _c, _d;
|
|
7938
|
-
return __spreadProps2(__spreadValues2({}, f2), {
|
|
7939
|
-
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),
|
|
7940
|
-
value: getTranslatedFacetValue({ key: f2.key }, { title: f2.value }, translations)
|
|
7941
|
-
});
|
|
7942
|
-
});
|
|
7943
|
-
};
|
|
7944
|
-
const isFacetKey = (key) => key.startsWith(FACET_PARAMS_TYPE.RANGE) || key.startsWith(FACET_PARAMS_TYPE.TERMS) || key.startsWith(FACET_PARAMS_TYPE.HIERARCHY);
|
|
7945
|
-
const getMostSpecificHierarchyTerms = (terms) => {
|
|
7946
|
-
const specificTerms = [];
|
|
7947
|
-
for (const term of terms) {
|
|
7948
|
-
if (!terms.some((t) => t.startsWith(term) && t !== term)) {
|
|
7949
|
-
specificTerms.push(term);
|
|
7950
|
-
}
|
|
7951
|
-
}
|
|
7952
|
-
return Array.from(new Set(specificTerms));
|
|
7953
|
-
};
|
|
7954
|
-
const recursiveFilter = (items, query = "") => {
|
|
7955
|
-
if (!query) {
|
|
7956
|
-
return items;
|
|
7957
|
-
}
|
|
7958
|
-
return items.map((i) => recursiveFilterItem(i, query)).filter(Boolean);
|
|
7959
|
-
};
|
|
7960
|
-
const recursiveFilterItem = (item, query = "") => {
|
|
7961
|
-
const filterable = getNormalizedString(item.title).includes(getNormalizedString(query)) ? item : void 0;
|
|
7962
|
-
if (!item.children) {
|
|
7963
|
-
return filterable;
|
|
7964
|
-
}
|
|
7965
|
-
const children = recursiveFilter(item.children, query).filter(Boolean);
|
|
7966
|
-
const include = children.length > 0 || filterable;
|
|
7967
|
-
return include ? __spreadProps2(__spreadValues2({}, item), {
|
|
7968
|
-
children
|
|
7969
|
-
}) : void 0;
|
|
7970
|
-
};
|
|
7971
|
-
const rangeFilterToString = (rangeFilter, separator) => {
|
|
7972
|
-
separator = separator || FACET_TERM_RANGE_SEPARATOR;
|
|
7973
|
-
return rangeFilter && Object.keys(rangeFilter).length ? rangeFilter.gte + separator + (rangeFilter.lte || rangeFilter.lt) : "";
|
|
7974
|
-
};
|
|
7975
|
-
const pick = (obj, keys) => {
|
|
7976
|
-
const ret = /* @__PURE__ */ Object.create({});
|
|
7977
|
-
for (const k of keys) {
|
|
7978
|
-
ret[k] = obj[k];
|
|
7979
|
-
}
|
|
7980
|
-
return ret;
|
|
7981
|
-
};
|
|
7982
|
-
const getHint = (suggestion, inputValue) => {
|
|
7983
|
-
var _a;
|
|
7984
|
-
if (!inputValue) {
|
|
7985
|
-
return escapeHtml$1(suggestion);
|
|
7986
|
-
}
|
|
7987
|
-
return (_a = suggestion == null ? void 0 : suggestion.replace(
|
|
7988
|
-
inputValue == null ? void 0 : inputValue.toLocaleLowerCase(),
|
|
7989
|
-
`<strong>${escapeHtml$1(inputValue == null ? void 0 : inputValue.toLocaleLowerCase())}</strong>`
|
|
7990
|
-
)) != null ? _a : "";
|
|
7991
|
-
};
|
|
7992
|
-
const reverseKeyValue = (obj) => {
|
|
7993
|
-
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k.toLowerCase()]));
|
|
7994
|
-
};
|
|
7995
|
-
const getPageCount = (total, limit) => {
|
|
7996
|
-
return Math.ceil(total / limit) || 0;
|
|
7997
|
-
};
|
|
7998
|
-
const isObject$1 = (value) => {
|
|
7999
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
8000
|
-
};
|
|
8001
|
-
const parseParam = (key, params) => {
|
|
8002
|
-
const value = params.get(key);
|
|
8003
|
-
if (!value) {
|
|
8004
|
-
return void 0;
|
|
8005
|
-
}
|
|
8006
|
-
try {
|
|
8007
|
-
return decodeURIComponent(value);
|
|
8008
|
-
} catch (e2) {
|
|
8009
|
-
return void 0;
|
|
8010
|
-
}
|
|
8011
|
-
};
|
|
8012
|
-
const parseRegularKeys = (regularKeys, searchParams, getQueryParamName) => {
|
|
8013
|
-
const params = /* @__PURE__ */ Object.create({});
|
|
8014
|
-
const keys = reverseKeyValue({
|
|
8015
|
-
QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY,
|
|
8016
|
-
LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.LIMIT) : QUERY_PARAMS$1.LIMIT,
|
|
8017
|
-
PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE,
|
|
8018
|
-
SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.SORT) : QUERY_PARAMS$1.SORT
|
|
8019
|
-
});
|
|
8020
|
-
for (const key of regularKeys) {
|
|
8021
|
-
const rawKey = keys[key] || key;
|
|
8022
|
-
params[rawKey] = parseParam(key, searchParams);
|
|
8023
|
-
}
|
|
8024
|
-
return params;
|
|
8025
|
-
};
|
|
8026
|
-
const parseFacetKey = (key, searchParams) => {
|
|
8027
|
-
var _a, _b, _c, _d;
|
|
8028
|
-
if (key.startsWith(FACET_PARAMS_TYPE.TERMS)) {
|
|
8029
|
-
return (_b = (_a = searchParams.getAll(key)) == null ? void 0 : _a.map((v) => decodeURIComponent(v))) != null ? _b : [];
|
|
8030
|
-
}
|
|
8031
|
-
if (key.startsWith(FACET_PARAMS_TYPE.RANGE)) {
|
|
8032
|
-
const range = searchParams.get(key);
|
|
8033
|
-
if (!range) {
|
|
8034
|
-
return {};
|
|
8035
|
-
}
|
|
8036
|
-
const [min, max] = range.split(FACET_RANGE_SEPARATOR);
|
|
8037
|
-
return {
|
|
8038
|
-
gte: min,
|
|
8039
|
-
lte: max
|
|
8040
|
-
};
|
|
8041
|
-
}
|
|
8042
|
-
if (key.startsWith(FACET_PARAMS_TYPE.HIERARCHY)) {
|
|
8043
|
-
return {
|
|
8044
|
-
level: 0,
|
|
8045
|
-
terms: (_d = (_c = searchParams.getAll(key)) == null ? void 0 : _c.map((v) => decodeURIComponent(v))) != null ? _d : []
|
|
8046
|
-
};
|
|
8047
|
-
}
|
|
8048
|
-
return [];
|
|
8049
|
-
};
|
|
8050
|
-
const parseFacetKeys = (facetKeys, searchParams) => {
|
|
8051
|
-
const params = {};
|
|
8052
|
-
params.filters = {};
|
|
8053
|
-
for (const key of facetKeys) {
|
|
8054
|
-
const parsedKey = key.slice(key.indexOf(FACET_KEY_SEPARATOR) + 1);
|
|
8055
|
-
params.filters = __spreadProps2(__spreadValues2({}, params.filters), {
|
|
8056
|
-
[parsedKey]: parseFacetKey(key, searchParams)
|
|
8057
|
-
});
|
|
8058
|
-
}
|
|
8059
|
-
return params;
|
|
8060
|
-
};
|
|
8061
|
-
const parseParams = (getQueryParamName, searchParams) => {
|
|
8062
|
-
const params = /* @__PURE__ */ Object.create({});
|
|
8063
|
-
if (!searchParams)
|
|
8064
|
-
return params;
|
|
8065
|
-
const paramKeys = Array.from(searchParams.keys());
|
|
8066
|
-
const facetKeys = paramKeys.filter((k) => isFacetKey(k));
|
|
8067
|
-
const regularKeys = paramKeys.filter((k) => !isFacetKey(k));
|
|
8068
|
-
const r = __spreadValues2(__spreadValues2({
|
|
8069
|
-
[QUERY_PARAMS_PARSED.QUERY]: ""
|
|
8070
|
-
}, parseRegularKeys(regularKeys, searchParams, getQueryParamName)), parseFacetKeys(facetKeys, searchParams));
|
|
8071
|
-
return r;
|
|
8072
|
-
};
|
|
8073
|
-
const appendParam = (url, { name, value }, encode2 = true) => {
|
|
8074
|
-
if (Array.isArray(value)) {
|
|
8075
|
-
appendArrayParams(url, { name, value });
|
|
8076
|
-
} else {
|
|
8077
|
-
appendSingleParam(url, { name, value }, encode2);
|
|
8078
|
-
}
|
|
8079
|
-
};
|
|
8080
|
-
const appendSingleParam = (url, param, encode2 = true) => {
|
|
8081
|
-
const valueToAppend = encode2 ? encodeParam(param.value) : param.value;
|
|
8082
|
-
if (url.searchParams.has(param.name)) {
|
|
8083
|
-
url.searchParams.set(param.name, valueToAppend);
|
|
8084
|
-
} else {
|
|
8085
|
-
url.searchParams.append(param.name, valueToAppend);
|
|
8086
|
-
}
|
|
8087
|
-
};
|
|
8088
|
-
const appendArrayParams = (url, param) => {
|
|
8089
|
-
url.searchParams.delete(param.name);
|
|
8090
|
-
param.value.forEach((v) => url.searchParams.append(param.name, encodeParam(v)));
|
|
8091
|
-
};
|
|
8092
|
-
const getRemovableParams = (url, getQueryParamName, paramsToRemove) => {
|
|
8093
|
-
if (paramsToRemove === "all") {
|
|
8094
|
-
const params = {
|
|
8095
|
-
QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY,
|
|
8096
|
-
LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.LIMIT) : QUERY_PARAMS$1.LIMIT,
|
|
8097
|
-
PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE,
|
|
8098
|
-
SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.SORT) : QUERY_PARAMS$1.SORT
|
|
8099
|
-
};
|
|
8100
|
-
return [
|
|
8101
|
-
...Object.values(params),
|
|
8102
|
-
...Array.from(url.searchParams.keys()).filter((k) => isFacetKey(k))
|
|
8103
|
-
];
|
|
8104
|
-
}
|
|
8105
|
-
return paramsToRemove;
|
|
8106
|
-
};
|
|
8107
|
-
const removeParams = (url, params = []) => {
|
|
8108
|
-
for (const param of params) {
|
|
8109
|
-
if (url.searchParams.has(param)) {
|
|
8110
|
-
url.searchParams.delete(param);
|
|
8111
|
-
}
|
|
8112
|
-
}
|
|
8113
|
-
};
|
|
8114
|
-
const encodeParam = (param) => {
|
|
8115
|
-
const encoded = encodeURIComponent(param);
|
|
8116
|
-
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, " ");
|
|
8117
|
-
};
|
|
8118
|
-
const getQueryParam$1 = (name) => {
|
|
8119
|
-
try {
|
|
8120
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
8121
|
-
return urlParams.get(name);
|
|
8122
|
-
} catch (e2) {
|
|
8123
|
-
return null;
|
|
8124
|
-
}
|
|
8125
|
-
};
|
|
8126
|
-
const PATH_REPLACE_REGEXP = /{(.*?)}/gm;
|
|
8127
|
-
const generateLink = (linkPattern, document2) => {
|
|
8128
|
-
const matches = linkPattern.match(PATH_REPLACE_REGEXP);
|
|
8129
|
-
if (!matches) {
|
|
8130
|
-
return linkPattern;
|
|
8131
|
-
}
|
|
8132
|
-
let link = linkPattern;
|
|
8133
|
-
for (const match of matches) {
|
|
8134
|
-
const propertyKey = match.slice(1, match.length - 1);
|
|
8135
|
-
const property = document2[propertyKey] || "";
|
|
8136
|
-
link = link.replace(match, property);
|
|
8137
|
-
}
|
|
8138
|
-
return link;
|
|
8139
|
-
};
|
|
8140
|
-
const generateResultLink = (link, getQueryParamName, searchText, facet) => {
|
|
8141
|
-
if (!searchText) {
|
|
8142
|
-
return link;
|
|
8143
|
-
}
|
|
8144
|
-
const facetParam = facet ? `&${FACET_PARAMS_TYPE.TERMS}${encodeParam(facet.key)}=${encodeParam(facet.title)}` : "";
|
|
8145
|
-
const queryParam = `?${getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY}=${encodeParam(searchText)}`;
|
|
8146
|
-
return `${link}${queryParam}${facetParam}`;
|
|
8147
|
-
};
|
|
8148
|
-
const getRelativePath = (link) => {
|
|
8149
|
-
try {
|
|
8150
|
-
const url = new URL(link);
|
|
8151
|
-
const partialUrl = url.toString().substring(url.origin.length);
|
|
8152
|
-
return partialUrl.endsWith("/") ? partialUrl.slice(0, partialUrl.length - 1) : partialUrl;
|
|
8153
|
-
} catch (e2) {
|
|
8154
|
-
return (link == null ? void 0 : link.endsWith("/")) ? link.slice(0, link.length - 1) : link;
|
|
8155
|
-
}
|
|
8156
|
-
};
|
|
8157
|
-
const linksMatch = (link1, link2) => {
|
|
8158
|
-
if (!link1 || !link2) {
|
|
8159
|
-
return false;
|
|
8160
|
-
}
|
|
8161
|
-
return link1 === link2 || getRelativePath(link1) === getRelativePath(link2);
|
|
8162
|
-
};
|
|
8163
|
-
const emitRoutingEvent = (url) => {
|
|
8164
|
-
const event = new CustomEvent(LUPA_ROUTING_EVENT, { detail: url });
|
|
8165
|
-
window.dispatchEvent(event);
|
|
8166
|
-
};
|
|
8167
|
-
const handleRoutingEvent = (link, event, hasEventRouting = false) => {
|
|
8168
|
-
if (!hasEventRouting) {
|
|
8169
|
-
return;
|
|
8170
|
-
}
|
|
8171
|
-
event == null ? void 0 : event.preventDefault();
|
|
8172
|
-
emitRoutingEvent(link);
|
|
8173
|
-
};
|
|
8174
|
-
const redirectToResultsPage = (link, searchText, getQueryParamName, facet, routingBehavior = "direct-link") => {
|
|
8175
|
-
const url = generateResultLink(link, getQueryParamName, searchText, facet);
|
|
8176
|
-
if (routingBehavior === "event") {
|
|
8177
|
-
emitRoutingEvent(url);
|
|
8178
|
-
} else {
|
|
8179
|
-
window.location.assign(url);
|
|
8180
|
-
}
|
|
8181
|
-
};
|
|
8182
|
-
const getPageUrl = (pathnameOverride, ssr) => {
|
|
8183
|
-
if (typeof window !== "undefined") {
|
|
8184
|
-
const pathname = pathnameOverride || window.location.pathname;
|
|
8185
|
-
const origin = window.location.origin;
|
|
8186
|
-
const search2 = window.location.search;
|
|
8187
|
-
return new URL(origin + pathname + search2);
|
|
8188
|
-
}
|
|
8189
|
-
return new URL(ssr.url, ssr.baseUrl);
|
|
8190
|
-
};
|
|
8191
|
-
const getFacetKey = (key, type) => {
|
|
8192
|
-
return `${FACET_FILTER_MAP[type]}${key}`;
|
|
8193
|
-
};
|
|
8194
|
-
const getFacetParam = (key, value, type = FACET_PARAMS_TYPE.TERMS) => {
|
|
8195
|
-
return {
|
|
8196
|
-
name: `${type}${key}`,
|
|
8197
|
-
value
|
|
8198
|
-
};
|
|
8199
|
-
};
|
|
8200
|
-
const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentFilters, paramsToRemove = []) => {
|
|
8201
|
-
const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
|
|
8202
|
-
const newParams = toggleTermParam(currentFilter, facetAction.value);
|
|
8203
|
-
appendParams({
|
|
8204
|
-
params: [getFacetParam(facetAction.key, newParams)],
|
|
8205
|
-
paramsToRemove: [
|
|
8206
|
-
...paramsToRemove,
|
|
8207
|
-
...[getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
|
|
8208
|
-
]
|
|
8209
|
-
});
|
|
8210
|
-
};
|
|
8211
|
-
const replaceHierarchyParam = (params = [], param = "") => {
|
|
8212
|
-
if (params.some((p2) => p2.startsWith(param))) {
|
|
8213
|
-
return toggleLastPram(params, param);
|
|
8214
|
-
}
|
|
8215
|
-
return [param];
|
|
8216
|
-
};
|
|
8217
|
-
const toggleHierarchyFilter = (appendParams, facetAction, getQueryParamName, currentFilters, removeAllLevels = false) => {
|
|
8218
|
-
var _a, _b;
|
|
8219
|
-
const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
|
|
8220
|
-
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);
|
|
8221
|
-
appendParams({
|
|
8222
|
-
params: [getFacetParam(facetAction.key, newParams, FACET_PARAMS_TYPE.HIERARCHY)],
|
|
8223
|
-
paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
|
|
8224
|
-
});
|
|
8225
|
-
};
|
|
8226
|
-
const toggleRangeFilter = (appendParams, facetAction, getQueryParamName, currentFilters) => {
|
|
8227
|
-
const currentFilter = rangeFilterToString(
|
|
8228
|
-
currentFilters == null ? void 0 : currentFilters[facetAction.key],
|
|
8229
|
-
FACET_RANGE_SEPARATOR
|
|
8230
|
-
);
|
|
8231
|
-
let facetValue = facetAction.value.join(FACET_RANGE_SEPARATOR);
|
|
8232
|
-
facetValue = currentFilter === facetValue ? "" : facetValue;
|
|
8233
|
-
appendParams({
|
|
8234
|
-
params: [getFacetParam(facetAction.key, facetValue, FACET_PARAMS_TYPE.RANGE)],
|
|
8235
|
-
paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE],
|
|
8236
|
-
encode: false
|
|
8237
|
-
});
|
|
8238
|
-
};
|
|
8239
|
-
const toggleTermParam = (params = [], param = "") => {
|
|
8240
|
-
if (params == null ? void 0 : params.includes(param)) {
|
|
8241
|
-
return params.filter((p2) => p2 !== param);
|
|
8242
|
-
}
|
|
8243
|
-
return [param, ...params];
|
|
8244
|
-
};
|
|
8245
|
-
const toggleLastPram = (params = [], param = "") => {
|
|
8246
|
-
const paramLevel = param.split(">").length;
|
|
8247
|
-
return getMostSpecificHierarchyTerms(
|
|
8248
|
-
params.map(
|
|
8249
|
-
(p2) => p2.startsWith(param) ? p2.split(HIERARCHY_SEPARATOR).slice(0, paramLevel - 1).join(HIERARCHY_SEPARATOR).trim() : p2
|
|
8250
|
-
).filter(Boolean)
|
|
8251
|
-
);
|
|
8252
|
-
};
|
|
8253
|
-
const toggleHierarchyParam = (params = [], param = "", removeAllLevels = false) => {
|
|
8254
|
-
if (params == null ? void 0 : params.some((p2) => p2.startsWith(param))) {
|
|
8255
|
-
return removeAllLevels ? getMostSpecificHierarchyTerms(params.filter((p2) => !p2.startsWith(param))) : toggleLastPram(params, param);
|
|
8256
|
-
}
|
|
8257
|
-
return getMostSpecificHierarchyTerms([param, ...params]);
|
|
8258
|
-
};
|
|
8259
|
-
const CACHE_KEY = "lupasearch-client-redirections";
|
|
8260
|
-
const useRedirectionStore = defineStore("redirections", () => {
|
|
8261
|
-
const redirections = ref({ rules: [] });
|
|
8262
|
-
const redirectionOptions = ref({ enabled: false, queryKey: "" });
|
|
8263
|
-
const saveToLocalStorage2 = () => {
|
|
8264
|
-
try {
|
|
8265
|
-
localStorage.setItem(
|
|
8266
|
-
CACHE_KEY,
|
|
8267
|
-
JSON.stringify({
|
|
8268
|
-
redirections: redirections.value,
|
|
8269
|
-
savedAt: Date.now(),
|
|
8270
|
-
queryKey: redirectionOptions.value.queryKey
|
|
8271
|
-
})
|
|
8272
|
-
);
|
|
8273
|
-
} catch (e2) {
|
|
8274
|
-
}
|
|
8275
|
-
};
|
|
8276
|
-
const tryLoadFromLocalStorage2 = (config) => {
|
|
8277
|
-
var _a;
|
|
8278
|
-
if (!config.cacheSeconds)
|
|
8279
|
-
return false;
|
|
8280
|
-
try {
|
|
8281
|
-
const data = JSON.parse((_a = localStorage.getItem(CACHE_KEY)) != null ? _a : "");
|
|
8282
|
-
if (data.queryKey !== config.queryKey) {
|
|
8283
|
-
return false;
|
|
8284
|
-
}
|
|
8285
|
-
if ((data == null ? void 0 : data.redirections) && Date.now() - data.savedAt < 1e3 * config.cacheSeconds) {
|
|
8286
|
-
redirections.value = data.redirections;
|
|
8287
|
-
return true;
|
|
8288
|
-
}
|
|
8289
|
-
} catch (e2) {
|
|
8290
|
-
}
|
|
8291
|
-
return false;
|
|
8292
|
-
};
|
|
8293
|
-
const initiate = (config, options) => __async2(void 0, null, function* () {
|
|
8294
|
-
var _a, _b, _c, _d;
|
|
8295
|
-
if ((_a = redirectionOptions.value) == null ? void 0 : _a.enabled) {
|
|
8296
|
-
return;
|
|
8297
|
-
}
|
|
8298
|
-
redirectionOptions.value = config;
|
|
8299
|
-
if (!(config == null ? void 0 : config.enabled)) {
|
|
8300
|
-
return;
|
|
8301
|
-
}
|
|
8302
|
-
const loaded = tryLoadFromLocalStorage2(config);
|
|
8303
|
-
if (loaded || ((_c = (_b = redirections.value) == null ? void 0 : _b.rules) == null ? void 0 : _c.length) > 0) {
|
|
8304
|
-
return;
|
|
8305
|
-
}
|
|
8306
|
-
try {
|
|
8307
|
-
const result2 = yield LupaSearchSdk.loadRedirectionRules(config.queryKey, options);
|
|
8308
|
-
if (!((_d = result2 == null ? void 0 : result2.rules) == null ? void 0 : _d.length)) {
|
|
8309
|
-
redirections.value = { rules: [] };
|
|
8310
|
-
return;
|
|
8311
|
-
}
|
|
8312
|
-
redirections.value = result2;
|
|
8313
|
-
saveToLocalStorage2();
|
|
8314
|
-
} catch (e2) {
|
|
8315
|
-
}
|
|
8316
|
-
});
|
|
8317
|
-
const redirectOnKeywordIfConfigured = (input2, routingBehavior = "direct-link") => {
|
|
8318
|
-
var _a, _b, _c, _d;
|
|
8319
|
-
if (!((_b = (_a = redirections.value) == null ? void 0 : _a.rules) == null ? void 0 : _b.length)) {
|
|
8320
|
-
return false;
|
|
8321
|
-
}
|
|
8322
|
-
const redirectTo = redirections.value.rules.find((r) => inputsAreEqual(input2, r.sources));
|
|
8323
|
-
if (!redirectTo) {
|
|
8324
|
-
return false;
|
|
8325
|
-
}
|
|
8326
|
-
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;
|
|
8327
|
-
if (url === void 0 || url === null || url === "") {
|
|
8328
|
-
return false;
|
|
8329
|
-
}
|
|
8330
|
-
if (routingBehavior === "event") {
|
|
8331
|
-
emitRoutingEvent(url);
|
|
8332
|
-
} else {
|
|
8333
|
-
window.location.assign(url);
|
|
8334
|
-
}
|
|
8335
|
-
return true;
|
|
8336
|
-
};
|
|
8337
|
-
return {
|
|
8338
|
-
redirections,
|
|
8339
|
-
redirectOnKeywordIfConfigured,
|
|
8340
|
-
initiate
|
|
8341
|
-
};
|
|
8342
|
-
});
|
|
8343
|
-
var commonjsGlobal$1 = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
8344
|
-
function getDefaultExportFromCjs(x2) {
|
|
8345
|
-
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
|
|
8346
|
-
}
|
|
8347
|
-
function getAugmentedNamespace(n) {
|
|
8348
|
-
if (n.__esModule)
|
|
8349
|
-
return n;
|
|
8350
|
-
var f2 = n.default;
|
|
8351
|
-
if (typeof f2 == "function") {
|
|
8352
|
-
var a = function a2() {
|
|
8353
|
-
if (this instanceof a2) {
|
|
8354
|
-
var args = [null];
|
|
8355
|
-
args.push.apply(args, arguments);
|
|
8356
|
-
var Ctor = Function.bind.apply(f2, args);
|
|
8357
|
-
return new Ctor();
|
|
8358
|
-
}
|
|
8359
|
-
return f2.apply(this, arguments);
|
|
8360
|
-
};
|
|
8361
|
-
a.prototype = f2.prototype;
|
|
8362
|
-
} else
|
|
8363
|
-
a = {};
|
|
8364
|
-
Object.defineProperty(a, "__esModule", { value: true });
|
|
8365
|
-
Object.keys(n).forEach(function(k) {
|
|
8366
|
-
var d2 = Object.getOwnPropertyDescriptor(n, k);
|
|
8367
|
-
Object.defineProperty(a, k, d2.get ? d2 : {
|
|
8368
|
-
enumerable: true,
|
|
8369
|
-
get: function() {
|
|
8370
|
-
return n[k];
|
|
8371
|
-
}
|
|
8372
|
-
});
|
|
7078
|
+
a.prototype = f2.prototype;
|
|
7079
|
+
} else
|
|
7080
|
+
a = {};
|
|
7081
|
+
Object.defineProperty(a, "__esModule", { value: true });
|
|
7082
|
+
Object.keys(n).forEach(function(k) {
|
|
7083
|
+
var d2 = Object.getOwnPropertyDescriptor(n, k);
|
|
7084
|
+
Object.defineProperty(a, k, d2.get ? d2 : {
|
|
7085
|
+
enumerable: true,
|
|
7086
|
+
get: function() {
|
|
7087
|
+
return n[k];
|
|
7088
|
+
}
|
|
7089
|
+
});
|
|
8373
7090
|
});
|
|
8374
7091
|
return a;
|
|
8375
7092
|
}
|
|
@@ -13843,18 +12560,1308 @@ var __async = (__this, __arguments, generator) => {
|
|
|
13843
12560
|
if (symIterator) {
|
|
13844
12561
|
lodash2.prototype[symIterator] = wrapperToIterator;
|
|
13845
12562
|
}
|
|
13846
|
-
return lodash2;
|
|
13847
|
-
};
|
|
13848
|
-
var _ = runInContext();
|
|
13849
|
-
if (freeModule) {
|
|
13850
|
-
(freeModule.exports = _)._ = _;
|
|
13851
|
-
freeExports._ = _;
|
|
12563
|
+
return lodash2;
|
|
12564
|
+
};
|
|
12565
|
+
var _ = runInContext();
|
|
12566
|
+
if (freeModule) {
|
|
12567
|
+
(freeModule.exports = _)._ = _;
|
|
12568
|
+
freeExports._ = _;
|
|
12569
|
+
} else {
|
|
12570
|
+
root2._ = _;
|
|
12571
|
+
}
|
|
12572
|
+
}).call(commonjsGlobal$1);
|
|
12573
|
+
})(lodash$1, lodash$1.exports);
|
|
12574
|
+
var lodashExports$1 = lodash$1.exports;
|
|
12575
|
+
const getNormalizedString = (str) => {
|
|
12576
|
+
var _a, _b;
|
|
12577
|
+
if (!str) {
|
|
12578
|
+
return "";
|
|
12579
|
+
}
|
|
12580
|
+
const transformedStr = typeof str === "string" ? str : str.toString();
|
|
12581
|
+
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();
|
|
12582
|
+
};
|
|
12583
|
+
const getTransformedString = (str) => {
|
|
12584
|
+
var _a, _b;
|
|
12585
|
+
if (!str) {
|
|
12586
|
+
return "";
|
|
12587
|
+
}
|
|
12588
|
+
const transformedStr = typeof str === "string" ? str : str.toString();
|
|
12589
|
+
return transformedStr.normalize === void 0 ? (_a = transformedStr.toLocaleLowerCase()) == null ? void 0 : _a.trim() : (_b = transformedStr.toLocaleLowerCase().normalize("NFKD")) == null ? void 0 : _b.trim();
|
|
12590
|
+
};
|
|
12591
|
+
const capitalize$1 = (str) => {
|
|
12592
|
+
if (!str) {
|
|
12593
|
+
return "";
|
|
12594
|
+
}
|
|
12595
|
+
return str[0].toLocaleUpperCase() + str.slice(1);
|
|
12596
|
+
};
|
|
12597
|
+
const addParamsToLabel = (label, ...params) => {
|
|
12598
|
+
if (!params || params.length < 1) {
|
|
12599
|
+
return label;
|
|
12600
|
+
}
|
|
12601
|
+
const paramKeys = Array.from(Array(params.length).keys());
|
|
12602
|
+
return paramKeys.reduce((a, c2) => a.replace(`{${c2 + 1}}`, params[c2]), label);
|
|
12603
|
+
};
|
|
12604
|
+
const getRandomString = (length) => {
|
|
12605
|
+
const chars = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
12606
|
+
let result2 = "";
|
|
12607
|
+
for (let i = length; i > 0; --i) {
|
|
12608
|
+
result2 += chars[Math.floor(Math.random() * chars.length)];
|
|
12609
|
+
}
|
|
12610
|
+
return result2;
|
|
12611
|
+
};
|
|
12612
|
+
const toFixedIfNecessary = (value, precision = 2) => {
|
|
12613
|
+
return (+parseFloat(value).toFixed(precision)).toString();
|
|
12614
|
+
};
|
|
12615
|
+
const getDisplayValue = (value) => {
|
|
12616
|
+
if (value === void 0) {
|
|
12617
|
+
return "";
|
|
12618
|
+
}
|
|
12619
|
+
if (typeof value === "string") {
|
|
12620
|
+
return value;
|
|
12621
|
+
}
|
|
12622
|
+
return toFixedIfNecessary(value.toString());
|
|
12623
|
+
};
|
|
12624
|
+
const getProductKey = (index, product, idKey) => {
|
|
12625
|
+
if (!idKey) {
|
|
12626
|
+
return index;
|
|
12627
|
+
}
|
|
12628
|
+
if (product[idKey]) {
|
|
12629
|
+
return product[idKey];
|
|
12630
|
+
}
|
|
12631
|
+
return index;
|
|
12632
|
+
};
|
|
12633
|
+
const normalizeFloat = (value) => {
|
|
12634
|
+
var _a;
|
|
12635
|
+
if (!value) {
|
|
12636
|
+
return 0;
|
|
12637
|
+
}
|
|
12638
|
+
return +((_a = value == null ? void 0 : value.replace(/[^0-9,.]/g, "")) == null ? void 0 : _a.replace(",", "."));
|
|
12639
|
+
};
|
|
12640
|
+
const escapeHtml$1 = (value) => {
|
|
12641
|
+
if (!value) {
|
|
12642
|
+
return "";
|
|
12643
|
+
}
|
|
12644
|
+
let output = "";
|
|
12645
|
+
let isSkip = false;
|
|
12646
|
+
value.split(/(<del>.*?<\/del>)/g).forEach((segment) => {
|
|
12647
|
+
if (segment.startsWith("<del>") && segment.endsWith("</del>")) {
|
|
12648
|
+
output += segment;
|
|
12649
|
+
isSkip = true;
|
|
12650
|
+
}
|
|
12651
|
+
if (!isSkip) {
|
|
12652
|
+
output += segment.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
12653
|
+
}
|
|
12654
|
+
if (isSkip) {
|
|
12655
|
+
isSkip = false;
|
|
12656
|
+
}
|
|
12657
|
+
});
|
|
12658
|
+
return output;
|
|
12659
|
+
};
|
|
12660
|
+
const inputsAreEqual = (input2, possibleValues) => {
|
|
12661
|
+
if (!input2) {
|
|
12662
|
+
return false;
|
|
12663
|
+
}
|
|
12664
|
+
const normalizedInput = getTransformedString(input2);
|
|
12665
|
+
return possibleValues.some((v) => getTransformedString(v) === normalizedInput);
|
|
12666
|
+
};
|
|
12667
|
+
const levenshteinDistance = (s = "", t = "") => {
|
|
12668
|
+
if (!(s == null ? void 0 : s.length)) {
|
|
12669
|
+
return t.length;
|
|
12670
|
+
}
|
|
12671
|
+
if (!(t == null ? void 0 : t.length)) {
|
|
12672
|
+
return s.length;
|
|
12673
|
+
}
|
|
12674
|
+
const arr = [];
|
|
12675
|
+
for (let i = 0; i <= t.length; i++) {
|
|
12676
|
+
arr[i] = [i];
|
|
12677
|
+
for (let j = 1; j <= s.length; j++) {
|
|
12678
|
+
arr[i][j] = i === 0 ? j : Math.min(
|
|
12679
|
+
arr[i - 1][j] + 1,
|
|
12680
|
+
arr[i][j - 1] + 1,
|
|
12681
|
+
arr[i - 1][j - 1] + (s[j - 1] === t[i - 1] ? 0 : 1)
|
|
12682
|
+
);
|
|
12683
|
+
}
|
|
12684
|
+
}
|
|
12685
|
+
return arr[t.length][s.length];
|
|
12686
|
+
};
|
|
12687
|
+
const findClosestStringValue = (input2, possibleValues, key) => {
|
|
12688
|
+
var _a;
|
|
12689
|
+
const directMatch = possibleValues.find((v) => v[key] === input2);
|
|
12690
|
+
if (directMatch) {
|
|
12691
|
+
return directMatch;
|
|
12692
|
+
}
|
|
12693
|
+
const distances = possibleValues.map((v) => levenshteinDistance(`${v[key]}`, input2));
|
|
12694
|
+
const minDistance = Math.min(...distances);
|
|
12695
|
+
const closestValue = (_a = possibleValues.filter((_, i) => distances[i] === minDistance)) == null ? void 0 : _a[0];
|
|
12696
|
+
return closestValue;
|
|
12697
|
+
};
|
|
12698
|
+
const slugifyClass = (s) => {
|
|
12699
|
+
let slug = lodashExports$1.kebabCase(s);
|
|
12700
|
+
if (!slug || /^[0-9-]/.test(slug)) {
|
|
12701
|
+
slug = `c-${slug}`;
|
|
12702
|
+
}
|
|
12703
|
+
return slug;
|
|
12704
|
+
};
|
|
12705
|
+
const DEFAULT_SEARCH_BOX_OPTIONS$1 = {
|
|
12706
|
+
inputSelector: "#searchBox",
|
|
12707
|
+
options: {
|
|
12708
|
+
environment: "production"
|
|
12709
|
+
},
|
|
12710
|
+
showTotalCount: false,
|
|
12711
|
+
minInputLength: 1,
|
|
12712
|
+
inputAttributes: {
|
|
12713
|
+
name: "q"
|
|
12714
|
+
},
|
|
12715
|
+
debounce: 0,
|
|
12716
|
+
labels: {
|
|
12717
|
+
placeholder: "Search for products...",
|
|
12718
|
+
noResults: "There are no results found.",
|
|
12719
|
+
moreResults: "Show more results",
|
|
12720
|
+
currency: "€",
|
|
12721
|
+
defaultFacetLabel: "Category:"
|
|
12722
|
+
},
|
|
12723
|
+
links: {
|
|
12724
|
+
searchResults: "/search"
|
|
12725
|
+
},
|
|
12726
|
+
panels: [
|
|
12727
|
+
{
|
|
12728
|
+
type: "suggestion",
|
|
12729
|
+
queryKey: "",
|
|
12730
|
+
highlight: true,
|
|
12731
|
+
limit: 5
|
|
12732
|
+
},
|
|
12733
|
+
{
|
|
12734
|
+
type: "document",
|
|
12735
|
+
queryKey: "",
|
|
12736
|
+
limit: 5,
|
|
12737
|
+
searchBySuggestion: false,
|
|
12738
|
+
links: {
|
|
12739
|
+
details: "{url}"
|
|
12740
|
+
},
|
|
12741
|
+
titleKey: "name",
|
|
12742
|
+
elements: []
|
|
12743
|
+
}
|
|
12744
|
+
],
|
|
12745
|
+
history: {
|
|
12746
|
+
labels: {
|
|
12747
|
+
clear: "Clear History"
|
|
12748
|
+
}
|
|
12749
|
+
}
|
|
12750
|
+
};
|
|
12751
|
+
const DEFAULT_OPTIONS_RESULTS$1 = {
|
|
12752
|
+
options: {
|
|
12753
|
+
environment: "production"
|
|
12754
|
+
},
|
|
12755
|
+
queryKey: "",
|
|
12756
|
+
containerSelector: "#searchResultsContainer",
|
|
12757
|
+
searchTitlePosition: "page-top",
|
|
12758
|
+
labels: {
|
|
12759
|
+
pageSize: "Page size:",
|
|
12760
|
+
sortBy: "Sort by:",
|
|
12761
|
+
itemCount: "Items {1} of {2}",
|
|
12762
|
+
filteredItemCount: "",
|
|
12763
|
+
currency: "€",
|
|
12764
|
+
showMore: "Show more",
|
|
12765
|
+
searchResults: "Search Query: ",
|
|
12766
|
+
emptyResults: "There are no results for the query:",
|
|
12767
|
+
mobileFilterButton: "Filter",
|
|
12768
|
+
htmlTitleTemplate: "Search Query: '{1}'",
|
|
12769
|
+
noResultsSuggestion: "No results found for this query: {1}",
|
|
12770
|
+
didYouMean: "Did you mean to search: {1}",
|
|
12771
|
+
similarQuery: "Search results for phrase {1}",
|
|
12772
|
+
similarQueries: "Similar queries:",
|
|
12773
|
+
similarResultsLabel: "Related to your query:"
|
|
12774
|
+
},
|
|
12775
|
+
grid: {
|
|
12776
|
+
columns: {
|
|
12777
|
+
xl: 4,
|
|
12778
|
+
l: 3,
|
|
12779
|
+
md: 2,
|
|
12780
|
+
sm: 2,
|
|
12781
|
+
xs: 1
|
|
12782
|
+
}
|
|
12783
|
+
},
|
|
12784
|
+
pagination: {
|
|
12785
|
+
sizeSelection: {
|
|
12786
|
+
position: {
|
|
12787
|
+
top: false,
|
|
12788
|
+
bottom: true
|
|
12789
|
+
},
|
|
12790
|
+
sizes: [10, 20, 25]
|
|
12791
|
+
},
|
|
12792
|
+
pageSelection: {
|
|
12793
|
+
position: {
|
|
12794
|
+
top: false,
|
|
12795
|
+
bottom: true
|
|
12796
|
+
},
|
|
12797
|
+
display: 5,
|
|
12798
|
+
displayMobile: 3
|
|
12799
|
+
}
|
|
12800
|
+
},
|
|
12801
|
+
sort: [],
|
|
12802
|
+
filters: {
|
|
12803
|
+
currentFilters: {
|
|
12804
|
+
visibility: {
|
|
12805
|
+
mobileSidebar: true,
|
|
12806
|
+
mobileToolbar: true
|
|
12807
|
+
},
|
|
12808
|
+
labels: {
|
|
12809
|
+
title: "Current filters:",
|
|
12810
|
+
clearAll: "Clear all"
|
|
12811
|
+
}
|
|
12812
|
+
},
|
|
12813
|
+
facets: {
|
|
12814
|
+
labels: {
|
|
12815
|
+
title: "Filters:",
|
|
12816
|
+
showAll: "Show more",
|
|
12817
|
+
facetFilter: "Filter...",
|
|
12818
|
+
facetClear: "Clear"
|
|
12819
|
+
},
|
|
12820
|
+
filterable: {
|
|
12821
|
+
minValues: 5
|
|
12822
|
+
},
|
|
12823
|
+
hierarchy: {
|
|
12824
|
+
maxInitialLevel: 2,
|
|
12825
|
+
topLevelValueCountLimit: 5,
|
|
12826
|
+
filterable: true
|
|
12827
|
+
},
|
|
12828
|
+
facetValueCountLimit: 20,
|
|
12829
|
+
showDocumentCount: true,
|
|
12830
|
+
style: {
|
|
12831
|
+
type: "sidebar"
|
|
12832
|
+
}
|
|
12833
|
+
}
|
|
12834
|
+
},
|
|
12835
|
+
toolbar: {
|
|
12836
|
+
layoutSelector: true,
|
|
12837
|
+
itemSummary: true,
|
|
12838
|
+
clearFilters: false
|
|
12839
|
+
},
|
|
12840
|
+
isInStock: () => {
|
|
12841
|
+
return true;
|
|
12842
|
+
},
|
|
12843
|
+
badges: {
|
|
12844
|
+
anchor: "tr",
|
|
12845
|
+
elements: []
|
|
12846
|
+
},
|
|
12847
|
+
links: {
|
|
12848
|
+
details: "/{id}"
|
|
12849
|
+
},
|
|
12850
|
+
elements: [],
|
|
12851
|
+
breadcrumbs: []
|
|
12852
|
+
};
|
|
12853
|
+
const useScreenStore = defineStore("screen", () => {
|
|
12854
|
+
const measuredScreenWidth = ref(1e3);
|
|
12855
|
+
const optionsStore = useOptionsStore();
|
|
12856
|
+
const screenWidth = computed(() => {
|
|
12857
|
+
var _a, _b;
|
|
12858
|
+
const { searchResultOptions } = storeToRefs(optionsStore);
|
|
12859
|
+
return (_b = (_a = searchResultOptions.value.grid) == null ? void 0 : _a.forcedScreenWidth) != null ? _b : measuredScreenWidth.value;
|
|
12860
|
+
});
|
|
12861
|
+
const configuredGridSizes = computed(() => {
|
|
12862
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
12863
|
+
const { searchResultOptions } = storeToRefs(optionsStore);
|
|
12864
|
+
return {
|
|
12865
|
+
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,
|
|
12866
|
+
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,
|
|
12867
|
+
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,
|
|
12868
|
+
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
|
|
12869
|
+
};
|
|
12870
|
+
});
|
|
12871
|
+
const currentScreenWidth = computed(() => {
|
|
12872
|
+
const width = screenWidth.value;
|
|
12873
|
+
if (width <= configuredGridSizes.value.smMin) {
|
|
12874
|
+
return "xs";
|
|
12875
|
+
} else if (width > configuredGridSizes.value.smMin && width <= configuredGridSizes.value.mdMin) {
|
|
12876
|
+
return "sm";
|
|
12877
|
+
} else if (width > configuredGridSizes.value.mdMin && width <= configuredGridSizes.value.lMin) {
|
|
12878
|
+
return "md";
|
|
12879
|
+
} else if (width > configuredGridSizes.value.lMin && width <= configuredGridSizes.value.xlMin) {
|
|
12880
|
+
return "l";
|
|
12881
|
+
} else {
|
|
12882
|
+
return "xl";
|
|
12883
|
+
}
|
|
12884
|
+
});
|
|
12885
|
+
const isMobileWidth = computed(() => {
|
|
12886
|
+
var _a;
|
|
12887
|
+
return (_a = ["xs", "sm"]) == null ? void 0 : _a.includes(currentScreenWidth.value);
|
|
12888
|
+
});
|
|
12889
|
+
const setScreenWidth = ({ width }) => {
|
|
12890
|
+
measuredScreenWidth.value = width;
|
|
12891
|
+
};
|
|
12892
|
+
return { screenWidth, currentScreenWidth, isMobileWidth, setScreenWidth };
|
|
12893
|
+
});
|
|
12894
|
+
const useOptionsStore = defineStore("options", () => {
|
|
12895
|
+
const searchBoxOptions = ref(
|
|
12896
|
+
DEFAULT_SEARCH_BOX_OPTIONS$1
|
|
12897
|
+
);
|
|
12898
|
+
const searchResultOptions = ref(
|
|
12899
|
+
DEFAULT_OPTIONS_RESULTS$1
|
|
12900
|
+
);
|
|
12901
|
+
const trackingOptions = ref({});
|
|
12902
|
+
const searchResultInitialFilters = ref({});
|
|
12903
|
+
const productRecommendationOptions = ref({});
|
|
12904
|
+
const screenStore = useScreenStore();
|
|
12905
|
+
const envOptions = computed(
|
|
12906
|
+
() => {
|
|
12907
|
+
var _a;
|
|
12908
|
+
return (_a = searchBoxOptions.value.options) != null ? _a : searchResultOptions.value.options;
|
|
12909
|
+
}
|
|
12910
|
+
);
|
|
12911
|
+
const classMap = computed(() => {
|
|
12912
|
+
var _a;
|
|
12913
|
+
return (_a = searchResultOptions.value.classMap) != null ? _a : {};
|
|
12914
|
+
});
|
|
12915
|
+
const initialFilters = computed(() => searchResultInitialFilters.value);
|
|
12916
|
+
const boxRoutingBehavior = computed(() => {
|
|
12917
|
+
var _a;
|
|
12918
|
+
return (_a = searchBoxOptions.value.routingBehavior) != null ? _a : "direct-link";
|
|
12919
|
+
});
|
|
12920
|
+
const searchResultsRoutingBehavior = computed(
|
|
12921
|
+
() => {
|
|
12922
|
+
var _a;
|
|
12923
|
+
return (_a = searchResultOptions.value.routingBehavior) != null ? _a : "direct-link";
|
|
12924
|
+
}
|
|
12925
|
+
);
|
|
12926
|
+
const defaultSearchResultPageSize = computed(
|
|
12927
|
+
() => {
|
|
12928
|
+
var _a, _b;
|
|
12929
|
+
return (_b = (_a = currentResolutionPageSizes.value) == null ? void 0 : _a[0]) != null ? _b : DEFAULT_PAGE_SIZE;
|
|
12930
|
+
}
|
|
12931
|
+
);
|
|
12932
|
+
const currentResolutionPageSizes = computed(() => {
|
|
12933
|
+
var _a, _b, _c, _d;
|
|
12934
|
+
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;
|
|
12935
|
+
if (Array.isArray(pageSizes)) {
|
|
12936
|
+
return pageSizes;
|
|
12937
|
+
}
|
|
12938
|
+
const screenSize = screenStore.currentScreenWidth;
|
|
12939
|
+
switch (screenSize) {
|
|
12940
|
+
case "xs":
|
|
12941
|
+
return pageSizes.xs;
|
|
12942
|
+
case "sm":
|
|
12943
|
+
return pageSizes.sm;
|
|
12944
|
+
case "md":
|
|
12945
|
+
return pageSizes.md;
|
|
12946
|
+
case "l":
|
|
12947
|
+
return pageSizes.l;
|
|
12948
|
+
case "xl":
|
|
12949
|
+
return pageSizes.xl;
|
|
12950
|
+
}
|
|
12951
|
+
});
|
|
12952
|
+
const setSearchBoxOptions = ({ options }) => {
|
|
12953
|
+
searchBoxOptions.value = options;
|
|
12954
|
+
};
|
|
12955
|
+
const setTrackingOptions = ({ options }) => {
|
|
12956
|
+
trackingOptions.value = options;
|
|
12957
|
+
};
|
|
12958
|
+
const setSearchResultOptions = ({ options }) => {
|
|
12959
|
+
searchResultOptions.value = options;
|
|
12960
|
+
};
|
|
12961
|
+
const setInitialFilters = ({ initialFilters: initialFilters2 }) => {
|
|
12962
|
+
searchResultInitialFilters.value = initialFilters2;
|
|
12963
|
+
};
|
|
12964
|
+
const setProductRecommendationOptions = ({
|
|
12965
|
+
options
|
|
12966
|
+
}) => {
|
|
12967
|
+
productRecommendationOptions.value = options;
|
|
12968
|
+
};
|
|
12969
|
+
const getQueryParamName = (param) => {
|
|
12970
|
+
var _a;
|
|
12971
|
+
const nameMap = searchBoxOptions.value.queryParameterNames;
|
|
12972
|
+
return (_a = nameMap == null ? void 0 : nameMap[param]) != null ? _a : param;
|
|
12973
|
+
};
|
|
12974
|
+
return {
|
|
12975
|
+
searchBoxOptions,
|
|
12976
|
+
searchResultOptions,
|
|
12977
|
+
trackingOptions,
|
|
12978
|
+
envOptions,
|
|
12979
|
+
classMap,
|
|
12980
|
+
initialFilters,
|
|
12981
|
+
boxRoutingBehavior,
|
|
12982
|
+
searchResultsRoutingBehavior,
|
|
12983
|
+
defaultSearchResultPageSize,
|
|
12984
|
+
currentResolutionPageSizes,
|
|
12985
|
+
productRecommendationOptions,
|
|
12986
|
+
setSearchBoxOptions,
|
|
12987
|
+
setTrackingOptions,
|
|
12988
|
+
setSearchResultOptions,
|
|
12989
|
+
setInitialFilters,
|
|
12990
|
+
setProductRecommendationOptions,
|
|
12991
|
+
getQueryParamName
|
|
12992
|
+
};
|
|
12993
|
+
});
|
|
12994
|
+
const initAnalyticsTracking = (analyticsOptions) => {
|
|
12995
|
+
try {
|
|
12996
|
+
if (analyticsOptions == null ? void 0 : analyticsOptions.enabled) {
|
|
12997
|
+
window.sessionStorage.setItem(TRACKING_ANALYTICS_KEY, JSON.stringify(analyticsOptions));
|
|
12998
|
+
} else {
|
|
12999
|
+
window.sessionStorage.removeItem(TRACKING_ANALYTICS_KEY);
|
|
13000
|
+
}
|
|
13001
|
+
} catch (e2) {
|
|
13002
|
+
}
|
|
13003
|
+
};
|
|
13004
|
+
const initBaseTracking = (enabled) => {
|
|
13005
|
+
try {
|
|
13006
|
+
if (enabled) {
|
|
13007
|
+
window.sessionStorage.setItem(TRACKING_STORAGE_KEY_BASE, "1");
|
|
13008
|
+
} else {
|
|
13009
|
+
window.sessionStorage.removeItem(TRACKING_STORAGE_KEY_BASE);
|
|
13010
|
+
clearSessionTracking();
|
|
13011
|
+
clearUserTracking();
|
|
13012
|
+
}
|
|
13013
|
+
} catch (e2) {
|
|
13014
|
+
}
|
|
13015
|
+
};
|
|
13016
|
+
const clearSessionTracking = () => {
|
|
13017
|
+
try {
|
|
13018
|
+
window.sessionStorage.removeItem(TRACKING_STORAGE_KEY);
|
|
13019
|
+
} catch (e2) {
|
|
13020
|
+
}
|
|
13021
|
+
};
|
|
13022
|
+
const initSessionTracking = () => {
|
|
13023
|
+
try {
|
|
13024
|
+
if (getSessionKey()) {
|
|
13025
|
+
return;
|
|
13026
|
+
}
|
|
13027
|
+
const key = getRandomString(TRACKING_KEY_LENGTH);
|
|
13028
|
+
window.sessionStorage.setItem(TRACKING_STORAGE_KEY, key);
|
|
13029
|
+
} catch (e2) {
|
|
13030
|
+
}
|
|
13031
|
+
};
|
|
13032
|
+
const initUserTracking = (userKey) => {
|
|
13033
|
+
try {
|
|
13034
|
+
if (getUserKey()) {
|
|
13035
|
+
return;
|
|
13036
|
+
}
|
|
13037
|
+
const key = userKey || getRandomString(TRACKING_KEY_LENGTH);
|
|
13038
|
+
window.localStorage.setItem(TRACKING_STORAGE_KEY, key);
|
|
13039
|
+
} catch (e2) {
|
|
13040
|
+
}
|
|
13041
|
+
};
|
|
13042
|
+
const clearUserTracking = () => {
|
|
13043
|
+
try {
|
|
13044
|
+
window.localStorage.removeItem(TRACKING_STORAGE_KEY);
|
|
13045
|
+
} catch (e2) {
|
|
13046
|
+
}
|
|
13047
|
+
};
|
|
13048
|
+
const isTrackingEnabled = () => {
|
|
13049
|
+
try {
|
|
13050
|
+
return Boolean(window.sessionStorage.getItem(TRACKING_STORAGE_KEY_BASE));
|
|
13051
|
+
} catch (e2) {
|
|
13052
|
+
return false;
|
|
13053
|
+
}
|
|
13054
|
+
};
|
|
13055
|
+
const isDelayedClickTracking = () => {
|
|
13056
|
+
try {
|
|
13057
|
+
return Boolean(window.localStorage.getItem(TRACKING_CLICK_DELAYED));
|
|
13058
|
+
} catch (e2) {
|
|
13059
|
+
return false;
|
|
13060
|
+
}
|
|
13061
|
+
};
|
|
13062
|
+
const getSessionKey = () => {
|
|
13063
|
+
var _a;
|
|
13064
|
+
try {
|
|
13065
|
+
return (_a = window.sessionStorage.getItem(TRACKING_STORAGE_KEY)) != null ? _a : void 0;
|
|
13066
|
+
} catch (e2) {
|
|
13067
|
+
return void 0;
|
|
13068
|
+
}
|
|
13069
|
+
};
|
|
13070
|
+
const getUserKey = () => {
|
|
13071
|
+
var _a;
|
|
13072
|
+
try {
|
|
13073
|
+
return (_a = window.localStorage.getItem(TRACKING_STORAGE_KEY)) != null ? _a : void 0;
|
|
13074
|
+
} catch (e2) {
|
|
13075
|
+
return void 0;
|
|
13076
|
+
}
|
|
13077
|
+
};
|
|
13078
|
+
const initTracking$1 = (options) => {
|
|
13079
|
+
initBaseTracking(Boolean(options.trackBase));
|
|
13080
|
+
if (options.trackSession) {
|
|
13081
|
+
initSessionTracking();
|
|
13082
|
+
} else {
|
|
13083
|
+
clearSessionTracking();
|
|
13084
|
+
}
|
|
13085
|
+
if (options.trackUser) {
|
|
13086
|
+
initUserTracking(options.userKey);
|
|
13087
|
+
} else {
|
|
13088
|
+
clearUserTracking();
|
|
13089
|
+
}
|
|
13090
|
+
if (options.analytics) {
|
|
13091
|
+
initAnalyticsTracking(options.analytics);
|
|
13092
|
+
}
|
|
13093
|
+
if (options.delayedClickTracking) {
|
|
13094
|
+
window.localStorage.setItem(TRACKING_CLICK_DELAYED, "1");
|
|
13095
|
+
checkAndDispatchDelayedEvents();
|
|
13096
|
+
} else {
|
|
13097
|
+
window.localStorage.removeItem(TRACKING_CLICK_DELAYED);
|
|
13098
|
+
}
|
|
13099
|
+
};
|
|
13100
|
+
const getLupaTrackingContext = () => {
|
|
13101
|
+
if (!isTrackingEnabled()) {
|
|
13102
|
+
return {};
|
|
13103
|
+
}
|
|
13104
|
+
return {
|
|
13105
|
+
userId: getUserKey(),
|
|
13106
|
+
sessionId: getSessionKey()
|
|
13107
|
+
};
|
|
13108
|
+
};
|
|
13109
|
+
const trackLupaEvent = (queryKey, data = {}, options) => {
|
|
13110
|
+
var _a, _b;
|
|
13111
|
+
if (!queryKey || !data.type) {
|
|
13112
|
+
return;
|
|
13113
|
+
}
|
|
13114
|
+
const eventData = {
|
|
13115
|
+
searchQuery: (_a = data.searchQuery) != null ? _a : "",
|
|
13116
|
+
itemId: (_b = data.itemId) != null ? _b : "",
|
|
13117
|
+
name: data.type,
|
|
13118
|
+
userId: getUserKey(),
|
|
13119
|
+
sessionId: getSessionKey(),
|
|
13120
|
+
filters: data.filters,
|
|
13121
|
+
metadata: data.metadata,
|
|
13122
|
+
sourceItemId: data.sourceItemId
|
|
13123
|
+
};
|
|
13124
|
+
LupaSearchSdk.track(queryKey, eventData, options);
|
|
13125
|
+
};
|
|
13126
|
+
const sendGa = (name, ...args) => {
|
|
13127
|
+
window.ga(() => {
|
|
13128
|
+
const trackers = window.ga.getAll();
|
|
13129
|
+
const firstTracker = trackers[0];
|
|
13130
|
+
if (!firstTracker) {
|
|
13131
|
+
console.error("GA tracker not found");
|
|
13132
|
+
}
|
|
13133
|
+
const trackerName = firstTracker.get("name");
|
|
13134
|
+
window.ga(`${trackerName}.${name}`, ...args);
|
|
13135
|
+
});
|
|
13136
|
+
};
|
|
13137
|
+
const trackAnalyticsEvent = (data) => {
|
|
13138
|
+
var _a, _b, _c;
|
|
13139
|
+
try {
|
|
13140
|
+
const options = JSON.parse(
|
|
13141
|
+
(_a = window.sessionStorage.getItem(TRACKING_ANALYTICS_KEY)) != null ? _a : "{}"
|
|
13142
|
+
);
|
|
13143
|
+
if (!data.analytics || !options.enabled || ((_c = options.ignoreEvents) == null ? void 0 : _c.includes((_b = data.analytics) == null ? void 0 : _b.type))) {
|
|
13144
|
+
return;
|
|
13145
|
+
}
|
|
13146
|
+
switch (options.type) {
|
|
13147
|
+
case "ua":
|
|
13148
|
+
sendUaAnalyticsEvent(data, options);
|
|
13149
|
+
break;
|
|
13150
|
+
case "ga4":
|
|
13151
|
+
sendGa4AnalyticsEvent(data, options);
|
|
13152
|
+
break;
|
|
13153
|
+
case "debug":
|
|
13154
|
+
processDebugEvent(data);
|
|
13155
|
+
break;
|
|
13156
|
+
default:
|
|
13157
|
+
sendUaAnalyticsEvent(data, options);
|
|
13158
|
+
}
|
|
13159
|
+
} catch (e2) {
|
|
13160
|
+
console.error("Unable to send an event to google analytics");
|
|
13161
|
+
}
|
|
13162
|
+
};
|
|
13163
|
+
const parseEcommerceData = (data, title) => {
|
|
13164
|
+
var _a, _b;
|
|
13165
|
+
return ((_a = data.analytics) == null ? void 0 : _a.items) ? {
|
|
13166
|
+
item_list_name: title,
|
|
13167
|
+
items: (_b = data.analytics) == null ? void 0 : _b.items
|
|
13168
|
+
} : void 0;
|
|
13169
|
+
};
|
|
13170
|
+
const sendUaAnalyticsEvent = (data, options) => {
|
|
13171
|
+
var _a, _b, _c, _d;
|
|
13172
|
+
const ga = window.ga;
|
|
13173
|
+
if (!ga) {
|
|
13174
|
+
console.error("Google Analytics object not found");
|
|
13175
|
+
return;
|
|
13176
|
+
}
|
|
13177
|
+
sendGa(
|
|
13178
|
+
"send",
|
|
13179
|
+
"event",
|
|
13180
|
+
options.parentEventName,
|
|
13181
|
+
(_b = (_a = data.analytics) == null ? void 0 : _a.type) != null ? _b : "",
|
|
13182
|
+
(_d = (_c = data.analytics) == null ? void 0 : _c.label) != null ? _d : ""
|
|
13183
|
+
);
|
|
13184
|
+
};
|
|
13185
|
+
const sendGa4AnalyticsEvent = (data, options) => {
|
|
13186
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
13187
|
+
if (!window || !window.dataLayer) {
|
|
13188
|
+
console.error("dataLayer object not found.");
|
|
13189
|
+
return;
|
|
13190
|
+
}
|
|
13191
|
+
const sendItemTitle = data.searchQuery !== ((_a = data.analytics) == null ? void 0 : _a.label);
|
|
13192
|
+
const title = sendItemTitle ? (_b = data.analytics) == null ? void 0 : _b.label : void 0;
|
|
13193
|
+
const params = __spreadValues2({
|
|
13194
|
+
search_text: data.searchQuery,
|
|
13195
|
+
item_title: title,
|
|
13196
|
+
item_id: data.itemId,
|
|
13197
|
+
ecommerce: parseEcommerceData(data, (_c = data.analytics) == null ? void 0 : _c.listLabel)
|
|
13198
|
+
}, (_e = (_d = data.analytics) == null ? void 0 : _d.additionalParams) != null ? _e : {});
|
|
13199
|
+
window.dataLayer.push(__spreadValues2({
|
|
13200
|
+
event: (_g = (_f = data.analytics) == null ? void 0 : _f.type) != null ? _g : options.parentEventName
|
|
13201
|
+
}, params));
|
|
13202
|
+
};
|
|
13203
|
+
const processDebugEvent = (data) => {
|
|
13204
|
+
var _a, _b, _c, _d;
|
|
13205
|
+
const sendItemTitle = data.searchQuery !== ((_a = data.analytics) == null ? void 0 : _a.label);
|
|
13206
|
+
const title = sendItemTitle ? (_b = data.analytics) == null ? void 0 : _b.label : void 0;
|
|
13207
|
+
const params = {
|
|
13208
|
+
event: (_c = data.analytics) == null ? void 0 : _c.type,
|
|
13209
|
+
search_text: data.searchQuery,
|
|
13210
|
+
item_title: title,
|
|
13211
|
+
item_id: data.itemId,
|
|
13212
|
+
ecommerce: parseEcommerceData(data, (_d = data.analytics) == null ? void 0 : _d.listLabel)
|
|
13213
|
+
};
|
|
13214
|
+
console.debug("Analytics debug event:", params);
|
|
13215
|
+
};
|
|
13216
|
+
const getDelayedEventsCache = () => {
|
|
13217
|
+
var _a;
|
|
13218
|
+
try {
|
|
13219
|
+
return JSON.parse((_a = window.localStorage.getItem(DELAYED_TRACKING_EVENTS_CACHE)) != null ? _a : "{}");
|
|
13220
|
+
} catch (e2) {
|
|
13221
|
+
return {};
|
|
13222
|
+
}
|
|
13223
|
+
};
|
|
13224
|
+
const storeDelayedEventCache = (cache) => {
|
|
13225
|
+
try {
|
|
13226
|
+
window.localStorage.setItem(DELAYED_TRACKING_EVENTS_CACHE, JSON.stringify(cache));
|
|
13227
|
+
} catch (e2) {
|
|
13228
|
+
}
|
|
13229
|
+
};
|
|
13230
|
+
const checkAndDispatchDelayedEvents = () => {
|
|
13231
|
+
var _a, _b;
|
|
13232
|
+
const optionsStore = useOptionsStore();
|
|
13233
|
+
const eventCache = getDelayedEventsCache();
|
|
13234
|
+
const urls = Object.keys(eventCache);
|
|
13235
|
+
for (const url of urls) {
|
|
13236
|
+
if ((_a = window.location.href) == null ? void 0 : _a.includes(url)) {
|
|
13237
|
+
const options = (_b = optionsStore.envOptions) != null ? _b : { environment: "production" };
|
|
13238
|
+
const { queryKey, data } = eventCache[url];
|
|
13239
|
+
track(queryKey, data, options);
|
|
13240
|
+
}
|
|
13241
|
+
}
|
|
13242
|
+
storeDelayedEventCache({});
|
|
13243
|
+
};
|
|
13244
|
+
const track = (queryKey, data = {}, options) => {
|
|
13245
|
+
var _a;
|
|
13246
|
+
if (!isTrackingEnabled()) {
|
|
13247
|
+
return;
|
|
13248
|
+
}
|
|
13249
|
+
const hasSearchQuery = data.searchQuery;
|
|
13250
|
+
if (!hasSearchQuery && !((_a = data.options) == null ? void 0 : _a.allowEmptySearchQuery)) {
|
|
13251
|
+
return;
|
|
13252
|
+
}
|
|
13253
|
+
trackAnalyticsEvent(data);
|
|
13254
|
+
trackLupaEvent(queryKey, data, options);
|
|
13255
|
+
};
|
|
13256
|
+
var DocumentElementType = /* @__PURE__ */ ((DocumentElementType2) => {
|
|
13257
|
+
DocumentElementType2["IMAGE"] = "image";
|
|
13258
|
+
DocumentElementType2["TITLE"] = "title";
|
|
13259
|
+
DocumentElementType2["CUSTOM"] = "custom";
|
|
13260
|
+
DocumentElementType2["DESCRIPTION"] = "description";
|
|
13261
|
+
DocumentElementType2["PRICE"] = "price";
|
|
13262
|
+
DocumentElementType2["REGULARPRICE"] = "regularPrice";
|
|
13263
|
+
DocumentElementType2["RATING"] = "rating";
|
|
13264
|
+
DocumentElementType2["SINGLE_STAR_RATING"] = "singleStarRating";
|
|
13265
|
+
DocumentElementType2["ADDTOCART"] = "addToCart";
|
|
13266
|
+
DocumentElementType2["CUSTOM_HTML"] = "customHtml";
|
|
13267
|
+
return DocumentElementType2;
|
|
13268
|
+
})(DocumentElementType || {});
|
|
13269
|
+
var SearchBoxPanelType = /* @__PURE__ */ ((SearchBoxPanelType2) => {
|
|
13270
|
+
SearchBoxPanelType2["SUGGESTION"] = "suggestion";
|
|
13271
|
+
SearchBoxPanelType2["DOCUMENT"] = "document";
|
|
13272
|
+
SearchBoxPanelType2["RELATED_SOURCE"] = "related-source";
|
|
13273
|
+
return SearchBoxPanelType2;
|
|
13274
|
+
})(SearchBoxPanelType || {});
|
|
13275
|
+
var BadgeType = /* @__PURE__ */ ((BadgeType2) => {
|
|
13276
|
+
BadgeType2["NEWITEM"] = "newItem";
|
|
13277
|
+
BadgeType2["TEXT"] = "text";
|
|
13278
|
+
BadgeType2["IMAGE"] = "image";
|
|
13279
|
+
BadgeType2["CUSTOM_HTML"] = "customHtml";
|
|
13280
|
+
BadgeType2["DISCOUNT"] = "discount";
|
|
13281
|
+
return BadgeType2;
|
|
13282
|
+
})(BadgeType || {});
|
|
13283
|
+
const retrieveHistory = () => {
|
|
13284
|
+
try {
|
|
13285
|
+
const historyString = window.localStorage.getItem(HISTORY_LOCAL_STORAGE_KEY);
|
|
13286
|
+
return historyString ? JSON.parse(historyString) : [];
|
|
13287
|
+
} catch (e2) {
|
|
13288
|
+
return [];
|
|
13289
|
+
}
|
|
13290
|
+
};
|
|
13291
|
+
const saveHistory = (items) => {
|
|
13292
|
+
try {
|
|
13293
|
+
window.localStorage.setItem(
|
|
13294
|
+
HISTORY_LOCAL_STORAGE_KEY,
|
|
13295
|
+
JSON.stringify(items.slice(0, HISTORY_MAX_ITEMS))
|
|
13296
|
+
);
|
|
13297
|
+
} catch (e2) {
|
|
13298
|
+
}
|
|
13299
|
+
};
|
|
13300
|
+
const useHistoryStore = defineStore("history", () => {
|
|
13301
|
+
const items = ref(retrieveHistory());
|
|
13302
|
+
const count = computed(() => items.value.length);
|
|
13303
|
+
const add2 = ({ item }) => {
|
|
13304
|
+
if (!item) {
|
|
13305
|
+
return items.value;
|
|
13306
|
+
}
|
|
13307
|
+
const newItems = items.value ? [item, ...items.value] : [item];
|
|
13308
|
+
const uniqueItems = Array.from(new Set(newItems));
|
|
13309
|
+
items.value = uniqueItems;
|
|
13310
|
+
saveHistory(uniqueItems);
|
|
13311
|
+
return uniqueItems;
|
|
13312
|
+
};
|
|
13313
|
+
const remove2 = ({ item }) => {
|
|
13314
|
+
var _a, _b;
|
|
13315
|
+
const tempItems = (_b = (_a = items.value) == null ? void 0 : _a.filter((i) => i !== item)) != null ? _b : [];
|
|
13316
|
+
saveHistory(tempItems);
|
|
13317
|
+
items.value = tempItems;
|
|
13318
|
+
return tempItems;
|
|
13319
|
+
};
|
|
13320
|
+
const clear2 = () => {
|
|
13321
|
+
saveHistory([]);
|
|
13322
|
+
items.value = [];
|
|
13323
|
+
};
|
|
13324
|
+
return { items, count, add: add2, remove: remove2, clear: clear2 };
|
|
13325
|
+
});
|
|
13326
|
+
const QUERY_PARAMS$1 = {
|
|
13327
|
+
QUERY: "q",
|
|
13328
|
+
PAGE: "p",
|
|
13329
|
+
LIMIT: "l",
|
|
13330
|
+
SORT: "s"
|
|
13331
|
+
};
|
|
13332
|
+
const QUERY_PARAMS_PARSED = {
|
|
13333
|
+
QUERY: "query",
|
|
13334
|
+
PAGE: "page",
|
|
13335
|
+
LIMIT: "limit",
|
|
13336
|
+
SORT: "sort"
|
|
13337
|
+
};
|
|
13338
|
+
const FACET_PARAMS_TYPE = {
|
|
13339
|
+
TERMS: "f.",
|
|
13340
|
+
RANGE: "fr.",
|
|
13341
|
+
HIERARCHY: "fh."
|
|
13342
|
+
};
|
|
13343
|
+
const FACET_FILTER_MAP = {
|
|
13344
|
+
terms: FACET_PARAMS_TYPE.TERMS,
|
|
13345
|
+
range: FACET_PARAMS_TYPE.RANGE,
|
|
13346
|
+
hierarchy: FACET_PARAMS_TYPE.HIERARCHY
|
|
13347
|
+
};
|
|
13348
|
+
const FACET_KEY_SEPARATOR = ".";
|
|
13349
|
+
const FACET_RANGE_SEPARATOR = ":";
|
|
13350
|
+
const HIERARCHY_SEPARATOR = ">";
|
|
13351
|
+
const FACET_TERM_RANGE_SEPARATOR = "-";
|
|
13352
|
+
const getAmount = (price, separator = ".") => {
|
|
13353
|
+
var _a, _b;
|
|
13354
|
+
if (typeof price === "number") {
|
|
13355
|
+
return `${(_a = price.toFixed(2)) == null ? void 0 : _a.replace(".", separator)}`;
|
|
13356
|
+
}
|
|
13357
|
+
const value = parseFloat(price);
|
|
13358
|
+
if (isNaN(value)) {
|
|
13359
|
+
return "";
|
|
13360
|
+
}
|
|
13361
|
+
return (_b = value.toFixed(2)) == null ? void 0 : _b.replace(".", separator);
|
|
13362
|
+
};
|
|
13363
|
+
const formatPrice = (price, currency = "€", separator = ",", currencyTemplate = "") => {
|
|
13364
|
+
if (price !== 0 && !price) {
|
|
13365
|
+
return "";
|
|
13366
|
+
}
|
|
13367
|
+
const amount = getAmount(price, separator);
|
|
13368
|
+
if (!amount) {
|
|
13369
|
+
return "";
|
|
13370
|
+
}
|
|
13371
|
+
if (currencyTemplate) {
|
|
13372
|
+
return addParamsToLabel(currencyTemplate, amount);
|
|
13373
|
+
}
|
|
13374
|
+
return `${amount} ${currency}`;
|
|
13375
|
+
};
|
|
13376
|
+
const formatPriceSummary = ([min, max], currency, separator = ",", currencyTemplate = "") => {
|
|
13377
|
+
if (min !== void 0 && max !== void 0) {
|
|
13378
|
+
return `${formatPrice(min, currency, separator, currencyTemplate)} - ${formatPrice(
|
|
13379
|
+
max,
|
|
13380
|
+
currency,
|
|
13381
|
+
separator,
|
|
13382
|
+
currencyTemplate
|
|
13383
|
+
)}`;
|
|
13384
|
+
}
|
|
13385
|
+
if (min !== void 0) {
|
|
13386
|
+
return `> ${formatPrice(min, currency, separator, currencyTemplate)}`;
|
|
13387
|
+
}
|
|
13388
|
+
return `< ${formatPrice(max, currency, separator, currencyTemplate)}`;
|
|
13389
|
+
};
|
|
13390
|
+
const getTranslatedFacetKey = (facet, translations) => {
|
|
13391
|
+
var _a, _b;
|
|
13392
|
+
return (_b = (_a = translations == null ? void 0 : translations.keyTranslations) == null ? void 0 : _a[facet.key]) != null ? _b : facet.label;
|
|
13393
|
+
};
|
|
13394
|
+
const getTranslatedFacetValue = (facet, value, translations) => {
|
|
13395
|
+
var _a, _b, _c;
|
|
13396
|
+
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;
|
|
13397
|
+
};
|
|
13398
|
+
const formatRange = (filter2) => {
|
|
13399
|
+
var _a, _b;
|
|
13400
|
+
const lt = (_a = filter2.lt) != null ? _a : filter2.lte;
|
|
13401
|
+
const gt = (_b = filter2.gt) != null ? _b : filter2.gte;
|
|
13402
|
+
if (gt !== void 0 && lt !== void 0) {
|
|
13403
|
+
return `${gt} - ${lt}`;
|
|
13404
|
+
}
|
|
13405
|
+
if (lt !== void 0) {
|
|
13406
|
+
return `<${filter2.lte !== void 0 ? "=" : ""} ${lt}`;
|
|
13407
|
+
}
|
|
13408
|
+
return `>${filter2.gte !== void 0 ? "=" : ""} ${gt}`;
|
|
13409
|
+
};
|
|
13410
|
+
const unfoldTermFilter = (key, filter2) => {
|
|
13411
|
+
const seed = [];
|
|
13412
|
+
return filter2.reduce((a, c2) => [...a, { key, value: c2, type: "terms" }], seed);
|
|
13413
|
+
};
|
|
13414
|
+
const unfoldHierarchyFilter = (key, filter2) => {
|
|
13415
|
+
const seed = [];
|
|
13416
|
+
return filter2.terms.reduce((a, c2) => [...a, { key, value: c2, type: "hierarchy" }], seed);
|
|
13417
|
+
};
|
|
13418
|
+
const unfoldRangeFilter = (key, filter2, price = {}) => {
|
|
13419
|
+
var _a;
|
|
13420
|
+
const gt = filter2.gte || filter2.gt;
|
|
13421
|
+
const lt = filter2.lte || filter2.lt;
|
|
13422
|
+
if (key.includes(CURRENCY_KEY_INDICATOR) || ((_a = price == null ? void 0 : price.keys) == null ? void 0 : _a.includes(key))) {
|
|
13423
|
+
return [
|
|
13424
|
+
{
|
|
13425
|
+
key,
|
|
13426
|
+
value: formatPriceSummary(
|
|
13427
|
+
[gt, lt],
|
|
13428
|
+
price.currency,
|
|
13429
|
+
price.separator,
|
|
13430
|
+
price.currencyTemplate
|
|
13431
|
+
),
|
|
13432
|
+
type: "range"
|
|
13433
|
+
}
|
|
13434
|
+
];
|
|
13435
|
+
}
|
|
13436
|
+
return [{ key, value: `${gt} - ${lt}`, type: "range" }];
|
|
13437
|
+
};
|
|
13438
|
+
const unfoldFilter = (key, filter2, price = {}) => {
|
|
13439
|
+
if (Array.isArray(filter2)) {
|
|
13440
|
+
return unfoldTermFilter(key, filter2);
|
|
13441
|
+
}
|
|
13442
|
+
if (filter2.gte) {
|
|
13443
|
+
return unfoldRangeFilter(key, filter2, price);
|
|
13444
|
+
}
|
|
13445
|
+
if (filter2.terms) {
|
|
13446
|
+
return unfoldHierarchyFilter(key, filter2);
|
|
13447
|
+
}
|
|
13448
|
+
return [];
|
|
13449
|
+
};
|
|
13450
|
+
const unfoldFilters = (filters, price = {}) => {
|
|
13451
|
+
if (!filters) {
|
|
13452
|
+
return [];
|
|
13453
|
+
}
|
|
13454
|
+
const seed = [];
|
|
13455
|
+
return Object.entries(filters).reduce((a, c2) => [...a, ...unfoldFilter(...c2, price)], seed);
|
|
13456
|
+
};
|
|
13457
|
+
const getLabeledFilters = (filters, facets2, translations) => {
|
|
13458
|
+
return filters.map((f2) => {
|
|
13459
|
+
var _a, _b, _c, _d;
|
|
13460
|
+
return __spreadProps2(__spreadValues2({}, f2), {
|
|
13461
|
+
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),
|
|
13462
|
+
value: getTranslatedFacetValue({ key: f2.key }, { title: f2.value }, translations)
|
|
13463
|
+
});
|
|
13464
|
+
});
|
|
13465
|
+
};
|
|
13466
|
+
const isFacetKey = (key) => key.startsWith(FACET_PARAMS_TYPE.RANGE) || key.startsWith(FACET_PARAMS_TYPE.TERMS) || key.startsWith(FACET_PARAMS_TYPE.HIERARCHY);
|
|
13467
|
+
const getMostSpecificHierarchyTerms = (terms) => {
|
|
13468
|
+
const specificTerms = [];
|
|
13469
|
+
for (const term of terms) {
|
|
13470
|
+
if (!terms.some((t) => t.startsWith(term) && t !== term)) {
|
|
13471
|
+
specificTerms.push(term);
|
|
13472
|
+
}
|
|
13473
|
+
}
|
|
13474
|
+
return Array.from(new Set(specificTerms));
|
|
13475
|
+
};
|
|
13476
|
+
const recursiveFilter = (items, query = "") => {
|
|
13477
|
+
if (!query) {
|
|
13478
|
+
return items;
|
|
13479
|
+
}
|
|
13480
|
+
return items.map((i) => recursiveFilterItem(i, query)).filter(Boolean);
|
|
13481
|
+
};
|
|
13482
|
+
const recursiveFilterItem = (item, query = "") => {
|
|
13483
|
+
const filterable = getNormalizedString(item.title).includes(getNormalizedString(query)) ? item : void 0;
|
|
13484
|
+
if (!item.children) {
|
|
13485
|
+
return filterable;
|
|
13486
|
+
}
|
|
13487
|
+
const children = recursiveFilter(item.children, query).filter(Boolean);
|
|
13488
|
+
const include = children.length > 0 || filterable;
|
|
13489
|
+
return include ? __spreadProps2(__spreadValues2({}, item), {
|
|
13490
|
+
children
|
|
13491
|
+
}) : void 0;
|
|
13492
|
+
};
|
|
13493
|
+
const rangeFilterToString = (rangeFilter, separator) => {
|
|
13494
|
+
separator = separator || FACET_TERM_RANGE_SEPARATOR;
|
|
13495
|
+
return rangeFilter && Object.keys(rangeFilter).length ? rangeFilter.gte + separator + (rangeFilter.lte || rangeFilter.lt) : "";
|
|
13496
|
+
};
|
|
13497
|
+
const pick = (obj, keys) => {
|
|
13498
|
+
const ret = /* @__PURE__ */ Object.create({});
|
|
13499
|
+
for (const k of keys) {
|
|
13500
|
+
ret[k] = obj[k];
|
|
13501
|
+
}
|
|
13502
|
+
return ret;
|
|
13503
|
+
};
|
|
13504
|
+
const getHint = (suggestion, inputValue) => {
|
|
13505
|
+
var _a;
|
|
13506
|
+
if (!inputValue) {
|
|
13507
|
+
return escapeHtml$1(suggestion);
|
|
13508
|
+
}
|
|
13509
|
+
return (_a = suggestion == null ? void 0 : suggestion.replace(
|
|
13510
|
+
inputValue == null ? void 0 : inputValue.toLocaleLowerCase(),
|
|
13511
|
+
`<strong>${escapeHtml$1(inputValue == null ? void 0 : inputValue.toLocaleLowerCase())}</strong>`
|
|
13512
|
+
)) != null ? _a : "";
|
|
13513
|
+
};
|
|
13514
|
+
const reverseKeyValue = (obj) => {
|
|
13515
|
+
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k.toLowerCase()]));
|
|
13516
|
+
};
|
|
13517
|
+
const getPageCount = (total, limit) => {
|
|
13518
|
+
return Math.ceil(total / limit) || 0;
|
|
13519
|
+
};
|
|
13520
|
+
const isObject$1 = (value) => {
|
|
13521
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
13522
|
+
};
|
|
13523
|
+
const parseParam = (key, params) => {
|
|
13524
|
+
const value = params.get(key);
|
|
13525
|
+
if (!value) {
|
|
13526
|
+
return void 0;
|
|
13527
|
+
}
|
|
13528
|
+
try {
|
|
13529
|
+
return decodeURIComponent(value);
|
|
13530
|
+
} catch (e2) {
|
|
13531
|
+
return void 0;
|
|
13532
|
+
}
|
|
13533
|
+
};
|
|
13534
|
+
const parseRegularKeys = (regularKeys, searchParams, getQueryParamName) => {
|
|
13535
|
+
const params = /* @__PURE__ */ Object.create({});
|
|
13536
|
+
const keys = reverseKeyValue({
|
|
13537
|
+
QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY,
|
|
13538
|
+
LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.LIMIT) : QUERY_PARAMS$1.LIMIT,
|
|
13539
|
+
PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE,
|
|
13540
|
+
SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.SORT) : QUERY_PARAMS$1.SORT
|
|
13541
|
+
});
|
|
13542
|
+
for (const key of regularKeys) {
|
|
13543
|
+
const rawKey = keys[key] || key;
|
|
13544
|
+
params[rawKey] = parseParam(key, searchParams);
|
|
13545
|
+
}
|
|
13546
|
+
return params;
|
|
13547
|
+
};
|
|
13548
|
+
const parseFacetKey = (key, searchParams) => {
|
|
13549
|
+
var _a, _b, _c, _d;
|
|
13550
|
+
if (key.startsWith(FACET_PARAMS_TYPE.TERMS)) {
|
|
13551
|
+
return (_b = (_a = searchParams.getAll(key)) == null ? void 0 : _a.map((v) => decodeURIComponent(v))) != null ? _b : [];
|
|
13552
|
+
}
|
|
13553
|
+
if (key.startsWith(FACET_PARAMS_TYPE.RANGE)) {
|
|
13554
|
+
const range = searchParams.get(key);
|
|
13555
|
+
if (!range) {
|
|
13556
|
+
return {};
|
|
13557
|
+
}
|
|
13558
|
+
const [min, max] = range.split(FACET_RANGE_SEPARATOR);
|
|
13559
|
+
return {
|
|
13560
|
+
gte: min,
|
|
13561
|
+
lte: max
|
|
13562
|
+
};
|
|
13563
|
+
}
|
|
13564
|
+
if (key.startsWith(FACET_PARAMS_TYPE.HIERARCHY)) {
|
|
13565
|
+
return {
|
|
13566
|
+
level: 0,
|
|
13567
|
+
terms: (_d = (_c = searchParams.getAll(key)) == null ? void 0 : _c.map((v) => decodeURIComponent(v))) != null ? _d : []
|
|
13568
|
+
};
|
|
13569
|
+
}
|
|
13570
|
+
return [];
|
|
13571
|
+
};
|
|
13572
|
+
const parseFacetKeys = (facetKeys, searchParams) => {
|
|
13573
|
+
const params = {};
|
|
13574
|
+
params.filters = {};
|
|
13575
|
+
for (const key of facetKeys) {
|
|
13576
|
+
const parsedKey = key.slice(key.indexOf(FACET_KEY_SEPARATOR) + 1);
|
|
13577
|
+
params.filters = __spreadProps2(__spreadValues2({}, params.filters), {
|
|
13578
|
+
[parsedKey]: parseFacetKey(key, searchParams)
|
|
13579
|
+
});
|
|
13580
|
+
}
|
|
13581
|
+
return params;
|
|
13582
|
+
};
|
|
13583
|
+
const parseParams = (getQueryParamName, searchParams) => {
|
|
13584
|
+
const params = /* @__PURE__ */ Object.create({});
|
|
13585
|
+
if (!searchParams)
|
|
13586
|
+
return params;
|
|
13587
|
+
const paramKeys = Array.from(searchParams.keys());
|
|
13588
|
+
const facetKeys = paramKeys.filter((k) => isFacetKey(k));
|
|
13589
|
+
const regularKeys = paramKeys.filter((k) => !isFacetKey(k));
|
|
13590
|
+
const r = __spreadValues2(__spreadValues2({
|
|
13591
|
+
[QUERY_PARAMS_PARSED.QUERY]: ""
|
|
13592
|
+
}, parseRegularKeys(regularKeys, searchParams, getQueryParamName)), parseFacetKeys(facetKeys, searchParams));
|
|
13593
|
+
return r;
|
|
13594
|
+
};
|
|
13595
|
+
const appendParam = (url, { name, value }, encode2 = true) => {
|
|
13596
|
+
if (Array.isArray(value)) {
|
|
13597
|
+
appendArrayParams(url, { name, value });
|
|
13598
|
+
} else {
|
|
13599
|
+
appendSingleParam(url, { name, value }, encode2);
|
|
13600
|
+
}
|
|
13601
|
+
};
|
|
13602
|
+
const appendSingleParam = (url, param, encode2 = true) => {
|
|
13603
|
+
const valueToAppend = encode2 ? encodeParam(param.value) : param.value;
|
|
13604
|
+
if (url.searchParams.has(param.name)) {
|
|
13605
|
+
url.searchParams.set(param.name, valueToAppend);
|
|
13606
|
+
} else {
|
|
13607
|
+
url.searchParams.append(param.name, valueToAppend);
|
|
13608
|
+
}
|
|
13609
|
+
};
|
|
13610
|
+
const appendArrayParams = (url, param) => {
|
|
13611
|
+
url.searchParams.delete(param.name);
|
|
13612
|
+
param.value.forEach((v) => url.searchParams.append(param.name, encodeParam(v)));
|
|
13613
|
+
};
|
|
13614
|
+
const getRemovableParams = (url, getQueryParamName, paramsToRemove) => {
|
|
13615
|
+
if (paramsToRemove === "all") {
|
|
13616
|
+
const params = {
|
|
13617
|
+
QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY,
|
|
13618
|
+
LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.LIMIT) : QUERY_PARAMS$1.LIMIT,
|
|
13619
|
+
PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE,
|
|
13620
|
+
SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.SORT) : QUERY_PARAMS$1.SORT
|
|
13621
|
+
};
|
|
13622
|
+
return [
|
|
13623
|
+
...Object.values(params),
|
|
13624
|
+
...Array.from(url.searchParams.keys()).filter((k) => isFacetKey(k))
|
|
13625
|
+
];
|
|
13626
|
+
}
|
|
13627
|
+
return paramsToRemove;
|
|
13628
|
+
};
|
|
13629
|
+
const removeParams = (url, params = []) => {
|
|
13630
|
+
for (const param of params) {
|
|
13631
|
+
if (url.searchParams.has(param)) {
|
|
13632
|
+
url.searchParams.delete(param);
|
|
13633
|
+
}
|
|
13634
|
+
}
|
|
13635
|
+
};
|
|
13636
|
+
const encodeParam = (param) => {
|
|
13637
|
+
const encoded = encodeURIComponent(param);
|
|
13638
|
+
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, " ");
|
|
13639
|
+
};
|
|
13640
|
+
const getQueryParam$1 = (name) => {
|
|
13641
|
+
try {
|
|
13642
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
13643
|
+
return urlParams.get(name);
|
|
13644
|
+
} catch (e2) {
|
|
13645
|
+
return null;
|
|
13646
|
+
}
|
|
13647
|
+
};
|
|
13648
|
+
const PATH_REPLACE_REGEXP = /{(.*?)}/gm;
|
|
13649
|
+
const generateLink = (linkPattern, document2) => {
|
|
13650
|
+
const matches = linkPattern.match(PATH_REPLACE_REGEXP);
|
|
13651
|
+
if (!matches) {
|
|
13652
|
+
return linkPattern;
|
|
13653
|
+
}
|
|
13654
|
+
let link = linkPattern;
|
|
13655
|
+
for (const match of matches) {
|
|
13656
|
+
const propertyKey = match.slice(1, match.length - 1);
|
|
13657
|
+
const property = document2[propertyKey] || "";
|
|
13658
|
+
link = link.replace(match, property);
|
|
13659
|
+
}
|
|
13660
|
+
return link;
|
|
13661
|
+
};
|
|
13662
|
+
const generateResultLink = (link, getQueryParamName, searchText, facet) => {
|
|
13663
|
+
if (!searchText) {
|
|
13664
|
+
return link;
|
|
13665
|
+
}
|
|
13666
|
+
const facetParam = facet ? `&${FACET_PARAMS_TYPE.TERMS}${encodeParam(facet.key)}=${encodeParam(facet.title)}` : "";
|
|
13667
|
+
const queryParam = `?${getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY}=${encodeParam(searchText)}`;
|
|
13668
|
+
return `${link}${queryParam}${facetParam}`;
|
|
13669
|
+
};
|
|
13670
|
+
const getRelativePath = (link) => {
|
|
13671
|
+
try {
|
|
13672
|
+
const url = new URL(link);
|
|
13673
|
+
const partialUrl = url.toString().substring(url.origin.length);
|
|
13674
|
+
return partialUrl.endsWith("/") ? partialUrl.slice(0, partialUrl.length - 1) : partialUrl;
|
|
13675
|
+
} catch (e2) {
|
|
13676
|
+
return (link == null ? void 0 : link.endsWith("/")) ? link.slice(0, link.length - 1) : link;
|
|
13677
|
+
}
|
|
13678
|
+
};
|
|
13679
|
+
const linksMatch = (link1, link2) => {
|
|
13680
|
+
if (!link1 || !link2) {
|
|
13681
|
+
return false;
|
|
13682
|
+
}
|
|
13683
|
+
return link1 === link2 || getRelativePath(link1) === getRelativePath(link2);
|
|
13684
|
+
};
|
|
13685
|
+
const emitRoutingEvent = (url) => {
|
|
13686
|
+
const event = new CustomEvent(LUPA_ROUTING_EVENT, { detail: url });
|
|
13687
|
+
window.dispatchEvent(event);
|
|
13688
|
+
};
|
|
13689
|
+
const handleRoutingEvent = (link, event, hasEventRouting = false) => {
|
|
13690
|
+
if (!hasEventRouting) {
|
|
13691
|
+
return;
|
|
13692
|
+
}
|
|
13693
|
+
event == null ? void 0 : event.preventDefault();
|
|
13694
|
+
emitRoutingEvent(link);
|
|
13695
|
+
};
|
|
13696
|
+
const redirectToResultsPage = (link, searchText, getQueryParamName, facet, routingBehavior = "direct-link") => {
|
|
13697
|
+
const url = generateResultLink(link, getQueryParamName, searchText, facet);
|
|
13698
|
+
if (routingBehavior === "event") {
|
|
13699
|
+
emitRoutingEvent(url);
|
|
13700
|
+
} else {
|
|
13701
|
+
window.location.assign(url);
|
|
13702
|
+
}
|
|
13703
|
+
};
|
|
13704
|
+
const getPageUrl = (pathnameOverride, ssr) => {
|
|
13705
|
+
if (typeof window !== "undefined") {
|
|
13706
|
+
const pathname = pathnameOverride || window.location.pathname;
|
|
13707
|
+
const origin = window.location.origin;
|
|
13708
|
+
const search2 = window.location.search;
|
|
13709
|
+
return new URL(origin + pathname + search2);
|
|
13710
|
+
}
|
|
13711
|
+
return new URL(ssr.url, ssr.baseUrl);
|
|
13712
|
+
};
|
|
13713
|
+
const getFacetKey = (key, type) => {
|
|
13714
|
+
return `${FACET_FILTER_MAP[type]}${key}`;
|
|
13715
|
+
};
|
|
13716
|
+
const getFacetParam = (key, value, type = FACET_PARAMS_TYPE.TERMS) => {
|
|
13717
|
+
return {
|
|
13718
|
+
name: `${type}${key}`,
|
|
13719
|
+
value
|
|
13720
|
+
};
|
|
13721
|
+
};
|
|
13722
|
+
const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentFilters, paramsToRemove = []) => {
|
|
13723
|
+
const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
|
|
13724
|
+
const newParams = toggleTermParam(currentFilter, facetAction.value);
|
|
13725
|
+
appendParams({
|
|
13726
|
+
params: [getFacetParam(facetAction.key, newParams)],
|
|
13727
|
+
paramsToRemove: [
|
|
13728
|
+
...paramsToRemove,
|
|
13729
|
+
...[getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
|
|
13730
|
+
]
|
|
13731
|
+
});
|
|
13732
|
+
};
|
|
13733
|
+
const replaceHierarchyParam = (params = [], param = "") => {
|
|
13734
|
+
if (params.some((p2) => p2.startsWith(param))) {
|
|
13735
|
+
return toggleLastPram(params, param);
|
|
13736
|
+
}
|
|
13737
|
+
return [param];
|
|
13738
|
+
};
|
|
13739
|
+
const toggleHierarchyFilter = (appendParams, facetAction, getQueryParamName, currentFilters, removeAllLevels = false) => {
|
|
13740
|
+
var _a, _b;
|
|
13741
|
+
const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
|
|
13742
|
+
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);
|
|
13743
|
+
appendParams({
|
|
13744
|
+
params: [getFacetParam(facetAction.key, newParams, FACET_PARAMS_TYPE.HIERARCHY)],
|
|
13745
|
+
paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
|
|
13746
|
+
});
|
|
13747
|
+
};
|
|
13748
|
+
const toggleRangeFilter = (appendParams, facetAction, getQueryParamName, currentFilters) => {
|
|
13749
|
+
const currentFilter = rangeFilterToString(
|
|
13750
|
+
currentFilters == null ? void 0 : currentFilters[facetAction.key],
|
|
13751
|
+
FACET_RANGE_SEPARATOR
|
|
13752
|
+
);
|
|
13753
|
+
let facetValue = facetAction.value.join(FACET_RANGE_SEPARATOR);
|
|
13754
|
+
facetValue = currentFilter === facetValue ? "" : facetValue;
|
|
13755
|
+
appendParams({
|
|
13756
|
+
params: [getFacetParam(facetAction.key, facetValue, FACET_PARAMS_TYPE.RANGE)],
|
|
13757
|
+
paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE],
|
|
13758
|
+
encode: false
|
|
13759
|
+
});
|
|
13760
|
+
};
|
|
13761
|
+
const toggleTermParam = (params = [], param = "") => {
|
|
13762
|
+
if (params == null ? void 0 : params.includes(param)) {
|
|
13763
|
+
return params.filter((p2) => p2 !== param);
|
|
13764
|
+
}
|
|
13765
|
+
return [param, ...params];
|
|
13766
|
+
};
|
|
13767
|
+
const toggleLastPram = (params = [], param = "") => {
|
|
13768
|
+
const paramLevel = param.split(">").length;
|
|
13769
|
+
return getMostSpecificHierarchyTerms(
|
|
13770
|
+
params.map(
|
|
13771
|
+
(p2) => p2.startsWith(param) ? p2.split(HIERARCHY_SEPARATOR).slice(0, paramLevel - 1).join(HIERARCHY_SEPARATOR).trim() : p2
|
|
13772
|
+
).filter(Boolean)
|
|
13773
|
+
);
|
|
13774
|
+
};
|
|
13775
|
+
const toggleHierarchyParam = (params = [], param = "", removeAllLevels = false) => {
|
|
13776
|
+
if (params == null ? void 0 : params.some((p2) => p2.startsWith(param))) {
|
|
13777
|
+
return removeAllLevels ? getMostSpecificHierarchyTerms(params.filter((p2) => !p2.startsWith(param))) : toggleLastPram(params, param);
|
|
13778
|
+
}
|
|
13779
|
+
return getMostSpecificHierarchyTerms([param, ...params]);
|
|
13780
|
+
};
|
|
13781
|
+
const CACHE_KEY = "lupasearch-client-redirections";
|
|
13782
|
+
const useRedirectionStore = defineStore("redirections", () => {
|
|
13783
|
+
const redirections = ref({ rules: [] });
|
|
13784
|
+
const redirectionOptions = ref({ enabled: false, queryKey: "" });
|
|
13785
|
+
const saveToLocalStorage2 = () => {
|
|
13786
|
+
try {
|
|
13787
|
+
localStorage.setItem(
|
|
13788
|
+
CACHE_KEY,
|
|
13789
|
+
JSON.stringify({
|
|
13790
|
+
redirections: redirections.value,
|
|
13791
|
+
savedAt: Date.now(),
|
|
13792
|
+
queryKey: redirectionOptions.value.queryKey
|
|
13793
|
+
})
|
|
13794
|
+
);
|
|
13795
|
+
} catch (e2) {
|
|
13796
|
+
}
|
|
13797
|
+
};
|
|
13798
|
+
const tryLoadFromLocalStorage2 = (config) => {
|
|
13799
|
+
var _a;
|
|
13800
|
+
if (!config.cacheSeconds)
|
|
13801
|
+
return false;
|
|
13802
|
+
try {
|
|
13803
|
+
const data = JSON.parse((_a = localStorage.getItem(CACHE_KEY)) != null ? _a : "");
|
|
13804
|
+
if (data.queryKey !== config.queryKey) {
|
|
13805
|
+
return false;
|
|
13806
|
+
}
|
|
13807
|
+
if ((data == null ? void 0 : data.redirections) && Date.now() - data.savedAt < 1e3 * config.cacheSeconds) {
|
|
13808
|
+
redirections.value = data.redirections;
|
|
13809
|
+
return true;
|
|
13810
|
+
}
|
|
13811
|
+
} catch (e2) {
|
|
13812
|
+
}
|
|
13813
|
+
return false;
|
|
13814
|
+
};
|
|
13815
|
+
const initiate = (config, options) => __async2(void 0, null, function* () {
|
|
13816
|
+
var _a, _b, _c, _d;
|
|
13817
|
+
if ((_a = redirectionOptions.value) == null ? void 0 : _a.enabled) {
|
|
13818
|
+
return;
|
|
13819
|
+
}
|
|
13820
|
+
redirectionOptions.value = config;
|
|
13821
|
+
if (!(config == null ? void 0 : config.enabled)) {
|
|
13822
|
+
return;
|
|
13823
|
+
}
|
|
13824
|
+
const loaded = tryLoadFromLocalStorage2(config);
|
|
13825
|
+
if (loaded || ((_c = (_b = redirections.value) == null ? void 0 : _b.rules) == null ? void 0 : _c.length) > 0) {
|
|
13826
|
+
return;
|
|
13827
|
+
}
|
|
13828
|
+
try {
|
|
13829
|
+
const result2 = yield LupaSearchSdk.loadRedirectionRules(config.queryKey, options);
|
|
13830
|
+
if (!((_d = result2 == null ? void 0 : result2.rules) == null ? void 0 : _d.length)) {
|
|
13831
|
+
redirections.value = { rules: [] };
|
|
13832
|
+
return;
|
|
13833
|
+
}
|
|
13834
|
+
redirections.value = result2;
|
|
13835
|
+
saveToLocalStorage2();
|
|
13836
|
+
} catch (e2) {
|
|
13837
|
+
}
|
|
13838
|
+
});
|
|
13839
|
+
const redirectOnKeywordIfConfigured = (input2, routingBehavior = "direct-link") => {
|
|
13840
|
+
var _a, _b, _c, _d;
|
|
13841
|
+
if (!((_b = (_a = redirections.value) == null ? void 0 : _a.rules) == null ? void 0 : _b.length)) {
|
|
13842
|
+
return false;
|
|
13843
|
+
}
|
|
13844
|
+
const redirectTo = redirections.value.rules.find((r) => inputsAreEqual(input2, r.sources));
|
|
13845
|
+
if (!redirectTo) {
|
|
13846
|
+
return false;
|
|
13847
|
+
}
|
|
13848
|
+
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;
|
|
13849
|
+
if (url === void 0 || url === null || url === "") {
|
|
13850
|
+
return false;
|
|
13851
|
+
}
|
|
13852
|
+
if (routingBehavior === "event") {
|
|
13853
|
+
emitRoutingEvent(url);
|
|
13852
13854
|
} else {
|
|
13853
|
-
|
|
13855
|
+
window.location.assign(url);
|
|
13854
13856
|
}
|
|
13855
|
-
|
|
13856
|
-
|
|
13857
|
-
|
|
13857
|
+
return true;
|
|
13858
|
+
};
|
|
13859
|
+
return {
|
|
13860
|
+
redirections,
|
|
13861
|
+
redirectOnKeywordIfConfigured,
|
|
13862
|
+
initiate
|
|
13863
|
+
};
|
|
13864
|
+
});
|
|
13858
13865
|
const joinUrlParts = (...parts) => {
|
|
13859
13866
|
var _a, _b, _c;
|
|
13860
13867
|
if (parts.length === 1) {
|
|
@@ -14293,7 +14300,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
14293
14300
|
const _hoisted_2$T = { class: "lupa-input-clear" };
|
|
14294
14301
|
const _hoisted_3$C = { id: "lupa-search-box-input" };
|
|
14295
14302
|
const _hoisted_4$s = ["value"];
|
|
14296
|
-
const _hoisted_5$
|
|
14303
|
+
const _hoisted_5$i = ["aria-label", "placeholder"];
|
|
14297
14304
|
const _hoisted_6$9 = /* @__PURE__ */ createBaseVNode("span", { class: "lupa-search-submit-icon" }, null, -1);
|
|
14298
14305
|
const _hoisted_7$7 = [
|
|
14299
14306
|
_hoisted_6$9
|
|
@@ -14413,7 +14420,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
14413
14420
|
placeholder: labels.value.placeholder,
|
|
14414
14421
|
onInput: handleInput,
|
|
14415
14422
|
onFocus: handleFocus
|
|
14416
|
-
}), null, 16, _hoisted_5$
|
|
14423
|
+
}), null, 16, _hoisted_5$i), [
|
|
14417
14424
|
[vModelText, inputValue.value]
|
|
14418
14425
|
]),
|
|
14419
14426
|
_ctx.options.showSubmitButton ? (openBlock(), createElementBlock("button", {
|
|
@@ -14629,7 +14636,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
14629
14636
|
class: "lupa-suggestion-facet-label",
|
|
14630
14637
|
"data-cy": "lupa-suggestion-facet-label"
|
|
14631
14638
|
};
|
|
14632
|
-
const _hoisted_5$
|
|
14639
|
+
const _hoisted_5$h = {
|
|
14633
14640
|
class: "lupa-suggestion-facet-value",
|
|
14634
14641
|
"data-cy": "lupa-suggestion-facet-value"
|
|
14635
14642
|
};
|
|
@@ -14672,7 +14679,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
14672
14679
|
}, null, 8, _hoisted_1$1e)) : (openBlock(), createElementBlock("div", _hoisted_2$R, toDisplayString(_ctx.suggestion.display), 1)),
|
|
14673
14680
|
_ctx.suggestion.facet ? (openBlock(), createElementBlock("div", _hoisted_3$B, [
|
|
14674
14681
|
createBaseVNode("span", _hoisted_4$r, toDisplayString(facetLabel.value), 1),
|
|
14675
|
-
createBaseVNode("span", _hoisted_5$
|
|
14682
|
+
createBaseVNode("span", _hoisted_5$h, toDisplayString(_ctx.suggestion.facet.title), 1)
|
|
14676
14683
|
])) : createCommentVNode("", true)
|
|
14677
14684
|
]);
|
|
14678
14685
|
};
|
|
@@ -24166,7 +24173,7 @@ and ensure you are accounting for this risk.
|
|
|
24166
24173
|
const _hoisted_2$N = { key: 0 };
|
|
24167
24174
|
const _hoisted_3$A = { key: 1 };
|
|
24168
24175
|
const _hoisted_4$q = { class: "lupa-search-box-custom-label" };
|
|
24169
|
-
const _hoisted_5$
|
|
24176
|
+
const _hoisted_5$g = { class: "lupa-search-box-custom-text" };
|
|
24170
24177
|
const _sfc_main$1h = /* @__PURE__ */ defineComponent({
|
|
24171
24178
|
__name: "SearchBoxProductCustom",
|
|
24172
24179
|
props: {
|
|
@@ -24199,7 +24206,7 @@ and ensure you are accounting for this risk.
|
|
|
24199
24206
|
}, toHandlers(_ctx.options.action ? { click: handleClick } : {}, true)), [
|
|
24200
24207
|
!label.value ? (openBlock(), createElementBlock("div", _hoisted_2$N, toDisplayString(text.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$A, [
|
|
24201
24208
|
createBaseVNode("div", _hoisted_4$q, toDisplayString(label.value), 1),
|
|
24202
|
-
createBaseVNode("div", _hoisted_5$
|
|
24209
|
+
createBaseVNode("div", _hoisted_5$g, toDisplayString(text.value), 1)
|
|
24203
24210
|
]))
|
|
24204
24211
|
], 16));
|
|
24205
24212
|
};
|
|
@@ -25619,7 +25626,7 @@ and ensure you are accounting for this risk.
|
|
|
25619
25626
|
key: 1,
|
|
25620
25627
|
class: "lupa-panel-title"
|
|
25621
25628
|
};
|
|
25622
|
-
const _hoisted_5$
|
|
25629
|
+
const _hoisted_5$f = {
|
|
25623
25630
|
key: 1,
|
|
25624
25631
|
id: "lupa-search-box-panel"
|
|
25625
25632
|
};
|
|
@@ -25843,7 +25850,7 @@ and ensure you are accounting for this risk.
|
|
|
25843
25850
|
options: _ctx.options,
|
|
25844
25851
|
onGoToResults: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("go-to-results"))
|
|
25845
25852
|
}, null, 8, ["labels", "options"])) : createCommentVNode("", true)
|
|
25846
|
-
])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_5$
|
|
25853
|
+
])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_5$f, [
|
|
25847
25854
|
createVNode(_sfc_main$1s, {
|
|
25848
25855
|
options: _ctx.options.history,
|
|
25849
25856
|
history: history.value,
|
|
@@ -25929,6 +25936,10 @@ and ensure you are accounting for this risk.
|
|
|
25929
25936
|
var _a2;
|
|
25930
25937
|
return (_a2 = props.options.searchTriggers) != null ? _a2 : [];
|
|
25931
25938
|
});
|
|
25939
|
+
const searchBoxCloseTriggers = computed(() => {
|
|
25940
|
+
var _a2, _b;
|
|
25941
|
+
return (_b = (_a2 = props.options.searchBoxCloseTriggers) == null ? void 0 : _a2.map((selector) => document.querySelector(selector))) != null ? _b : [];
|
|
25942
|
+
});
|
|
25932
25943
|
const goToResultsDebounced = debounce$1(paramsStore.goToResults, (_a = props.options.debounce) != null ? _a : 300);
|
|
25933
25944
|
onMounted(() => {
|
|
25934
25945
|
var _a2, _b, _c;
|
|
@@ -25952,7 +25963,7 @@ and ensure you are accounting for this risk.
|
|
|
25952
25963
|
unbindSearchTriggers(searchTriggers.value, handleCurrentValueSearch);
|
|
25953
25964
|
});
|
|
25954
25965
|
const handleMouseClick = (e2) => {
|
|
25955
|
-
var _a2, _b, _c, _d;
|
|
25966
|
+
var _a2, _b, _c, _d, _e;
|
|
25956
25967
|
const el = document.getElementById("lupa-search-box");
|
|
25957
25968
|
const elementClass = (_b = (_a2 = e2.target) == null ? void 0 : _a2.className) != null ? _b : "";
|
|
25958
25969
|
const hasLupaClass = typeof elementClass.includes == "function" && elementClass.includes("lupa-search-box");
|
|
@@ -25960,6 +25971,9 @@ and ensure you are accounting for this risk.
|
|
|
25960
25971
|
if (openedAt.value && Date.now() - (openedAt == null ? void 0 : openedAt.value) < 500) {
|
|
25961
25972
|
return;
|
|
25962
25973
|
}
|
|
25974
|
+
if ((_c = searchBoxCloseTriggers.value) == null ? void 0 : _c.includes(e2.target)) {
|
|
25975
|
+
close();
|
|
25976
|
+
}
|
|
25963
25977
|
if (isOutsideElement && props.options.keepOpen) {
|
|
25964
25978
|
focused.value = false;
|
|
25965
25979
|
}
|
|
@@ -25968,11 +25982,11 @@ and ensure you are accounting for this risk.
|
|
|
25968
25982
|
}
|
|
25969
25983
|
opened.value = false;
|
|
25970
25984
|
suggestedValue.value = defaultSuggestedValue;
|
|
25971
|
-
if ((
|
|
25972
|
-
(
|
|
25985
|
+
if ((_d = props.options.callbacks) == null ? void 0 : _d.onClosed) {
|
|
25986
|
+
(_e = props.options.callbacks) == null ? void 0 : _e.onClosed();
|
|
25973
25987
|
}
|
|
25974
25988
|
};
|
|
25975
|
-
const close = () => {
|
|
25989
|
+
const close = (e2) => {
|
|
25976
25990
|
var _a2, _b;
|
|
25977
25991
|
opened.value = false;
|
|
25978
25992
|
focused.value = false;
|
|
@@ -26401,7 +26415,7 @@ and ensure you are accounting for this risk.
|
|
|
26401
26415
|
class: "lupa-results-total-count"
|
|
26402
26416
|
};
|
|
26403
26417
|
const _hoisted_4$m = { class: "lupa-results-total-count-number" };
|
|
26404
|
-
const _hoisted_5$
|
|
26418
|
+
const _hoisted_5$e = ["innerHTML"];
|
|
26405
26419
|
const _sfc_main$Z = /* @__PURE__ */ defineComponent({
|
|
26406
26420
|
__name: "SearchResultsTitle",
|
|
26407
26421
|
props: {
|
|
@@ -26462,7 +26476,7 @@ and ensure you are accounting for this risk.
|
|
|
26462
26476
|
key: 2,
|
|
26463
26477
|
class: "lupa-result-page-description-top",
|
|
26464
26478
|
innerHTML: descriptionTop.value
|
|
26465
|
-
}, null, 8, _hoisted_5$
|
|
26479
|
+
}, null, 8, _hoisted_5$e)) : createCommentVNode("", true)
|
|
26466
26480
|
]);
|
|
26467
26481
|
};
|
|
26468
26482
|
}
|
|
@@ -26665,7 +26679,7 @@ and ensure you are accounting for this risk.
|
|
|
26665
26679
|
const _hoisted_2$B = { class: "lupa-category-back" };
|
|
26666
26680
|
const _hoisted_3$s = ["href"];
|
|
26667
26681
|
const _hoisted_4$k = ["href"];
|
|
26668
|
-
const _hoisted_5$
|
|
26682
|
+
const _hoisted_5$d = { class: "lupa-child-category-list" };
|
|
26669
26683
|
const _sfc_main$V = /* @__PURE__ */ defineComponent({
|
|
26670
26684
|
__name: "CategoryFilter",
|
|
26671
26685
|
props: {
|
|
@@ -26773,7 +26787,7 @@ and ensure you are accounting for this risk.
|
|
|
26773
26787
|
onClick: handleNavigationParent
|
|
26774
26788
|
}, toDisplayString(parentTitle.value), 11, _hoisted_4$k)
|
|
26775
26789
|
], 2),
|
|
26776
|
-
createBaseVNode("div", _hoisted_5$
|
|
26790
|
+
createBaseVNode("div", _hoisted_5$d, [
|
|
26777
26791
|
(openBlock(true), createElementBlock(Fragment, null, renderList(categoryChildren.value, (child) => {
|
|
26778
26792
|
return openBlock(), createBlock(_sfc_main$W, {
|
|
26779
26793
|
key: getCategoryKey(child),
|
|
@@ -26793,15 +26807,14 @@ and ensure you are accounting for this risk.
|
|
|
26793
26807
|
const _hoisted_2$A = ["placeholder"];
|
|
26794
26808
|
const _hoisted_3$r = { class: "lupa-terms-list" };
|
|
26795
26809
|
const _hoisted_4$j = ["onClick"];
|
|
26796
|
-
const _hoisted_5$
|
|
26797
|
-
const _hoisted_6$8 = { class: "lupa-term-
|
|
26798
|
-
const _hoisted_7$6 = {
|
|
26799
|
-
const _hoisted_8$2 = {
|
|
26810
|
+
const _hoisted_5$c = { class: "lupa-term-checkbox-wrapper" };
|
|
26811
|
+
const _hoisted_6$8 = { class: "lupa-term-label" };
|
|
26812
|
+
const _hoisted_7$6 = {
|
|
26800
26813
|
key: 0,
|
|
26801
26814
|
class: "lupa-term-count"
|
|
26802
26815
|
};
|
|
26803
|
-
const
|
|
26804
|
-
const
|
|
26816
|
+
const _hoisted_8$2 = { key: 0 };
|
|
26817
|
+
const _hoisted_9$2 = { key: 1 };
|
|
26805
26818
|
const _sfc_main$U = /* @__PURE__ */ defineComponent({
|
|
26806
26819
|
__name: "TermFacet",
|
|
26807
26820
|
props: {
|
|
@@ -26833,7 +26846,12 @@ and ensure you are accounting for this risk.
|
|
|
26833
26846
|
return searchResultStore.filterVisibleFilterValues(facet.value.key, (_b = (_a = facet.value) == null ? void 0 : _a.items) != null ? _b : []);
|
|
26834
26847
|
});
|
|
26835
26848
|
const displayValues = computed(() => {
|
|
26836
|
-
return filteredValues.value.slice(0, itemLimit.value).
|
|
26849
|
+
return filteredValues.value.slice(0, itemLimit.value).filter(
|
|
26850
|
+
(v) => {
|
|
26851
|
+
var _a, _b, _c;
|
|
26852
|
+
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;
|
|
26853
|
+
}
|
|
26854
|
+
).map((v) => __spreadProps2(__spreadValues2({}, v), { title: getDisplayValue(v.title) }));
|
|
26837
26855
|
});
|
|
26838
26856
|
const filteredValues = computed(() => {
|
|
26839
26857
|
var _a, _b;
|
|
@@ -26878,6 +26896,13 @@ and ensure you are accounting for this risk.
|
|
|
26878
26896
|
var _a;
|
|
26879
26897
|
return getTranslatedFacetValue(props.facet, item, (_a = searchResultOptions.value.filters) == null ? void 0 : _a.translations);
|
|
26880
26898
|
};
|
|
26899
|
+
const getFacetValueClass = (item) => {
|
|
26900
|
+
try {
|
|
26901
|
+
return `lupa-facet-value-${slugifyClass(item.title)}`;
|
|
26902
|
+
} catch (e2) {
|
|
26903
|
+
return "";
|
|
26904
|
+
}
|
|
26905
|
+
};
|
|
26881
26906
|
return (_ctx, _cache) => {
|
|
26882
26907
|
return openBlock(), createElementBlock("div", _hoisted_1$O, [
|
|
26883
26908
|
isFilterable.value ? withDirectives((openBlock(), createElementBlock("input", {
|
|
@@ -26897,15 +26922,17 @@ and ensure you are accounting for this risk.
|
|
|
26897
26922
|
key: item.title,
|
|
26898
26923
|
onClick: ($event) => handleFacetClick(item)
|
|
26899
26924
|
}, [
|
|
26900
|
-
createBaseVNode("div", _hoisted_5$
|
|
26925
|
+
createBaseVNode("div", _hoisted_5$c, [
|
|
26901
26926
|
createBaseVNode("span", {
|
|
26902
26927
|
class: normalizeClass(["lupa-term-checkbox", { checked: isChecked(item) }])
|
|
26903
26928
|
}, null, 2)
|
|
26904
26929
|
]),
|
|
26905
|
-
createBaseVNode("div",
|
|
26906
|
-
|
|
26907
|
-
|
|
26908
|
-
|
|
26930
|
+
createBaseVNode("div", {
|
|
26931
|
+
class: normalizeClass(["lupa-term-checkbox-label", { [getFacetValueClass(item)]: true }])
|
|
26932
|
+
}, [
|
|
26933
|
+
createBaseVNode("span", _hoisted_6$8, toDisplayString(getItemLabel(item)), 1),
|
|
26934
|
+
_ctx.options.showDocumentCount ? (openBlock(), createElementBlock("span", _hoisted_7$6, "(" + toDisplayString(item.count) + ")", 1)) : createCommentVNode("", true)
|
|
26935
|
+
], 2)
|
|
26909
26936
|
], 10, _hoisted_4$j);
|
|
26910
26937
|
}), 128))
|
|
26911
26938
|
]),
|
|
@@ -26915,7 +26942,7 @@ and ensure you are accounting for this risk.
|
|
|
26915
26942
|
"data-cy": "lupa-facet-term",
|
|
26916
26943
|
onClick: toggleShowAll
|
|
26917
26944
|
}, [
|
|
26918
|
-
showAll.value ? (openBlock(), createElementBlock("span",
|
|
26945
|
+
showAll.value ? (openBlock(), createElementBlock("span", _hoisted_8$2, toDisplayString(_ctx.options.labels.showLess), 1)) : (openBlock(), createElementBlock("span", _hoisted_9$2, toDisplayString(_ctx.options.labels.showAll), 1))
|
|
26919
26946
|
])) : createCommentVNode("", true)
|
|
26920
26947
|
]);
|
|
26921
26948
|
};
|
|
@@ -27910,7 +27937,7 @@ and ensure you are accounting for this risk.
|
|
|
27910
27937
|
key: 0,
|
|
27911
27938
|
class: "lupa-stats-range-label"
|
|
27912
27939
|
};
|
|
27913
|
-
const _hoisted_5$
|
|
27940
|
+
const _hoisted_5$b = { class: "lupa-stats-from" };
|
|
27914
27941
|
const _hoisted_6$7 = ["max", "min", "pattern", "aria-label"];
|
|
27915
27942
|
const _hoisted_7$5 = { key: 0 };
|
|
27916
27943
|
const _hoisted_8$1 = /* @__PURE__ */ createBaseVNode("div", { class: "lupa-stats-separator" }, null, -1);
|
|
@@ -28110,7 +28137,7 @@ and ensure you are accounting for this risk.
|
|
|
28110
28137
|
!isInputVisible.value ? (openBlock(), createElementBlock("div", _hoisted_2$z, toDisplayString(statsSummary.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$q, [
|
|
28111
28138
|
createBaseVNode("div", null, [
|
|
28112
28139
|
rangeLabelFrom.value ? (openBlock(), createElementBlock("div", _hoisted_4$i, toDisplayString(rangeLabelFrom.value), 1)) : createCommentVNode("", true),
|
|
28113
|
-
createBaseVNode("div", _hoisted_5$
|
|
28140
|
+
createBaseVNode("div", _hoisted_5$b, [
|
|
28114
28141
|
withDirectives(createBaseVNode("input", {
|
|
28115
28142
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => fromValue.value = $event),
|
|
28116
28143
|
type: "text",
|
|
@@ -28174,13 +28201,12 @@ and ensure you are accounting for this risk.
|
|
|
28174
28201
|
}
|
|
28175
28202
|
});
|
|
28176
28203
|
const _hoisted_1$M = { class: "lupa-term-checkbox-wrapper" };
|
|
28177
|
-
const _hoisted_2$y = { class: "lupa-term-
|
|
28178
|
-
const _hoisted_3$p = {
|
|
28179
|
-
const _hoisted_4$h = {
|
|
28204
|
+
const _hoisted_2$y = { class: "lupa-term-label" };
|
|
28205
|
+
const _hoisted_3$p = {
|
|
28180
28206
|
key: 0,
|
|
28181
28207
|
class: "lupa-term-count"
|
|
28182
28208
|
};
|
|
28183
|
-
const
|
|
28209
|
+
const _hoisted_4$h = {
|
|
28184
28210
|
key: 0,
|
|
28185
28211
|
class: "lupa-facet-level"
|
|
28186
28212
|
};
|
|
@@ -28220,6 +28246,13 @@ and ensure you are accounting for this risk.
|
|
|
28220
28246
|
value: item.key
|
|
28221
28247
|
});
|
|
28222
28248
|
};
|
|
28249
|
+
const getFacetValueClass = (item) => {
|
|
28250
|
+
try {
|
|
28251
|
+
return `lupa-facet-value-${slugifyClass(item.title)}`;
|
|
28252
|
+
} catch (e2) {
|
|
28253
|
+
return "";
|
|
28254
|
+
}
|
|
28255
|
+
};
|
|
28223
28256
|
return (_ctx, _cache) => {
|
|
28224
28257
|
const _component_HierarchyFacetLevel = resolveComponent("HierarchyFacetLevel", true);
|
|
28225
28258
|
return openBlock(), createElementBlock("div", {
|
|
@@ -28235,12 +28268,14 @@ and ensure you are accounting for this risk.
|
|
|
28235
28268
|
class: normalizeClass(["lupa-term-checkbox", { checked: isChecked.value }])
|
|
28236
28269
|
}, null, 2)
|
|
28237
28270
|
]),
|
|
28238
|
-
createBaseVNode("div",
|
|
28239
|
-
|
|
28240
|
-
|
|
28241
|
-
|
|
28271
|
+
createBaseVNode("div", {
|
|
28272
|
+
class: normalizeClass(["lupa-term-checkbox-label", { [getFacetValueClass(_ctx.item)]: true }])
|
|
28273
|
+
}, [
|
|
28274
|
+
createBaseVNode("span", _hoisted_2$y, toDisplayString(_ctx.item.title) + toDisplayString(" "), 1),
|
|
28275
|
+
_ctx.options.showDocumentCount ? (openBlock(), createElementBlock("span", _hoisted_3$p, "(" + toDisplayString(_ctx.item.count) + ")", 1)) : createCommentVNode("", true)
|
|
28276
|
+
], 2)
|
|
28242
28277
|
]),
|
|
28243
|
-
showChildren.value ? (openBlock(), createElementBlock("div",
|
|
28278
|
+
showChildren.value ? (openBlock(), createElementBlock("div", _hoisted_4$h, [
|
|
28244
28279
|
(openBlock(true), createElementBlock(Fragment, null, renderList(treeItem.value.children, (itemChild) => {
|
|
28245
28280
|
return openBlock(), createBlock(_component_HierarchyFacetLevel, {
|
|
28246
28281
|
key: itemChild.title,
|