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