@getlupa/client 1.17.7 → 1.17.9

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