@getlupa/client 1.17.1 → 1.17.5

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.
@@ -7861,6 +7861,14 @@ const formatPriceSummary = ([min, max], currency, separator = ",", currencyTempl
7861
7861
  }
7862
7862
  return `< ${formatPrice(max, currency, separator, currencyTemplate)}`;
7863
7863
  };
7864
+ const getTranslatedFacetKey = (facet, translations) => {
7865
+ var _a, _b;
7866
+ return (_b = (_a = translations == null ? void 0 : translations.keyTranslations) == null ? void 0 : _a[facet.key]) != null ? _b : facet.label;
7867
+ };
7868
+ const getTranslatedFacetValue = (facet, value, translations) => {
7869
+ var _a, _b, _c;
7870
+ 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;
7871
+ };
7864
7872
  const formatRange = (filter2) => {
7865
7873
  var _a, _b;
7866
7874
  const lt = (_a = filter2.lt) != null ? _a : filter2.lte;
@@ -7920,11 +7928,12 @@ const unfoldFilters = (filters, price = {}) => {
7920
7928
  const seed = [];
7921
7929
  return Object.entries(filters).reduce((a, c2) => [...a, ...unfoldFilter(...c2, price)], seed);
7922
7930
  };
7923
- const getLabeledFilters = (filters, facets2) => {
7931
+ const getLabeledFilters = (filters, facets2, translations) => {
7924
7932
  return filters.map((f2) => {
7925
- var _a, _b;
7933
+ var _a, _b, _c, _d;
7926
7934
  return __spreadProps2(__spreadValues2({}, f2), {
7927
- label: (_b = (_a = facets2 == null ? void 0 : facets2.find((ft) => ft.key === f2.key)) == null ? void 0 : _a.label) != null ? _b : capitalize$1(f2.key)
7935
+ 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),
7936
+ value: getTranslatedFacetValue({ key: f2.key }, { title: f2.value }, translations)
7928
7937
  });
7929
7938
  });
7930
7939
  };
@@ -14277,7 +14286,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
14277
14286
  };
14278
14287
  });
14279
14288
  const _hoisted_1$1i = { id: "lupa-search-box-input-container" };
14280
- const _hoisted_2$U = { class: "lupa-input-clear" };
14289
+ const _hoisted_2$T = { class: "lupa-input-clear" };
14281
14290
  const _hoisted_3$C = { id: "lupa-search-box-input" };
14282
14291
  const _hoisted_4$s = ["value"];
14283
14292
  const _hoisted_5$j = ["aria-label", "placeholder"];
@@ -14374,7 +14383,7 @@ const _sfc_main$1v = /* @__PURE__ */ defineComponent({
14374
14383
  __expose({ focus });
14375
14384
  return (_ctx, _cache) => {
14376
14385
  return openBlock(), createElementBlock("div", _hoisted_1$1i, [
14377
- createBaseVNode("div", _hoisted_2$U, [
14386
+ createBaseVNode("div", _hoisted_2$T, [
14378
14387
  createBaseVNode("div", {
14379
14388
  class: normalizeClass(["lupa-input-clear-content", { "lupa-input-clear-filled": inputValue.value }]),
14380
14389
  onClick: clear2
@@ -14457,7 +14466,7 @@ const _sfc_main$1u = /* @__PURE__ */ defineComponent({
14457
14466
  }
14458
14467
  });
14459
14468
  const _hoisted_1$1h = { class: "lupa-search-box-history-item" };
14460
- const _hoisted_2$T = { class: "lupa-search-box-history-item-content" };
14469
+ const _hoisted_2$S = { class: "lupa-search-box-history-item-content" };
14461
14470
  const _sfc_main$1t = /* @__PURE__ */ defineComponent({
14462
14471
  __name: "SearchBoxHistoryItem",
14463
14472
  props: {
@@ -14475,7 +14484,7 @@ const _sfc_main$1t = /* @__PURE__ */ defineComponent({
14475
14484
  };
14476
14485
  return (_ctx, _cache) => {
14477
14486
  return openBlock(), createElementBlock("div", _hoisted_1$1h, [
14478
- createBaseVNode("div", _hoisted_2$T, [
14487
+ createBaseVNode("div", _hoisted_2$S, [
14479
14488
  createBaseVNode("div", {
14480
14489
  class: normalizeClass(["lupa-search-box-history-item-text", { "lupa-search-box-history-item-highlighted": _ctx.highlighted }]),
14481
14490
  onClick: click2
@@ -14602,7 +14611,7 @@ const generateGridTemplate = (elements) => {
14602
14611
  return gridTemplate.join(" ");
14603
14612
  };
14604
14613
  const _hoisted_1$1e = ["innerHTML"];
14605
- const _hoisted_2$S = {
14614
+ const _hoisted_2$R = {
14606
14615
  key: 1,
14607
14616
  "data-cy": "lupa-suggestion-value",
14608
14617
  class: "lupa-suggestion-value"
@@ -14656,7 +14665,7 @@ const _sfc_main$1q = /* @__PURE__ */ defineComponent({
14656
14665
  class: "lupa-suggestion-value",
14657
14666
  "data-cy": "lupa-suggestion-value",
14658
14667
  innerHTML: _ctx.suggestion.displayHighlight
14659
- }, null, 8, _hoisted_1$1e)) : (openBlock(), createElementBlock("div", _hoisted_2$S, toDisplayString(_ctx.suggestion.display), 1)),
14668
+ }, null, 8, _hoisted_1$1e)) : (openBlock(), createElementBlock("div", _hoisted_2$R, toDisplayString(_ctx.suggestion.display), 1)),
14660
14669
  _ctx.suggestion.facet ? (openBlock(), createElementBlock("div", _hoisted_3$B, [
14661
14670
  createBaseVNode("span", _hoisted_4$r, toDisplayString(facetLabel.value), 1),
14662
14671
  createBaseVNode("span", _hoisted_5$i, toDisplayString(_ctx.suggestion.facet.title), 1)
@@ -23795,6 +23804,11 @@ const processDisplayCondition = (displayCondition, doc2 = {}) => {
23795
23804
  case "exists": {
23796
23805
  return fields == null ? void 0 : fields.every((field) => getFieldValue(doc2, field) !== void 0);
23797
23806
  }
23807
+ case "notExists": {
23808
+ return fields == null ? void 0 : fields.every(
23809
+ (field) => getFieldValue(doc2, field) === void 0 || getFieldValue(doc2, field) === null
23810
+ );
23811
+ }
23798
23812
  case "equals": {
23799
23813
  if (fields.length < 2)
23800
23814
  return false;
@@ -23851,7 +23865,7 @@ const replaceImageWithPlaceholder = (e2, placeholder) => {
23851
23865
  }
23852
23866
  };
23853
23867
  const _hoisted_1$1c = ["src"];
23854
- const _hoisted_2$R = ["src"];
23868
+ const _hoisted_2$Q = ["src"];
23855
23869
  const _sfc_main$1n = /* @__PURE__ */ defineComponent({
23856
23870
  __name: "ProductImage",
23857
23871
  props: {
@@ -24002,7 +24016,7 @@ const _sfc_main$1n = /* @__PURE__ */ defineComponent({
24002
24016
  class: ["lupa-images-main-image", { [_ctx.imageClass]: true }],
24003
24017
  style: styleOverride.value,
24004
24018
  src: finalMainImageUrl.value
24005
- }, { alt: imageAlt.value ? imageAlt.value : void 0 }, { onError: replaceWithPlaceholder }), null, 16, _hoisted_2$R))
24019
+ }, { alt: imageAlt.value ? imageAlt.value : void 0 }, { onError: replaceWithPlaceholder }), null, 16, _hoisted_2$Q))
24006
24020
  ], 38);
24007
24021
  };
24008
24022
  }
@@ -24025,7 +24039,7 @@ const _sfc_main$1m = /* @__PURE__ */ defineComponent({
24025
24039
  }
24026
24040
  });
24027
24041
  const _hoisted_1$1b = ["innerHTML"];
24028
- const _hoisted_2$Q = {
24042
+ const _hoisted_2$P = {
24029
24043
  key: 1,
24030
24044
  class: "lupa-search-box-product-title"
24031
24045
  };
@@ -24052,14 +24066,14 @@ const _sfc_main$1l = /* @__PURE__ */ defineComponent({
24052
24066
  key: 0,
24053
24067
  class: "lupa-search-box-product-title",
24054
24068
  innerHTML: sanitizedTitle.value
24055
- }, null, 8, _hoisted_1$1b)) : (openBlock(), createElementBlock("div", _hoisted_2$Q, [
24069
+ }, null, 8, _hoisted_1$1b)) : (openBlock(), createElementBlock("div", _hoisted_2$P, [
24056
24070
  createBaseVNode("strong", null, toDisplayString(title.value), 1)
24057
24071
  ]));
24058
24072
  };
24059
24073
  }
24060
24074
  });
24061
24075
  const _hoisted_1$1a = ["innerHTML"];
24062
- const _hoisted_2$P = {
24076
+ const _hoisted_2$O = {
24063
24077
  key: 1,
24064
24078
  class: "lupa-search-box-product-description"
24065
24079
  };
@@ -24086,7 +24100,7 @@ const _sfc_main$1k = /* @__PURE__ */ defineComponent({
24086
24100
  key: 0,
24087
24101
  class: "lupa-search-box-product-description",
24088
24102
  innerHTML: sanitizedDescription.value
24089
- }, null, 8, _hoisted_1$1a)) : (openBlock(), createElementBlock("div", _hoisted_2$P, toDisplayString(description.value), 1));
24103
+ }, null, 8, _hoisted_1$1a)) : (openBlock(), createElementBlock("div", _hoisted_2$O, toDisplayString(description.value), 1));
24090
24104
  };
24091
24105
  }
24092
24106
  });
@@ -24145,7 +24159,7 @@ const _sfc_main$1i = /* @__PURE__ */ defineComponent({
24145
24159
  }
24146
24160
  });
24147
24161
  const _hoisted_1$18 = ["innerHTML"];
24148
- const _hoisted_2$O = { key: 0 };
24162
+ const _hoisted_2$N = { key: 0 };
24149
24163
  const _hoisted_3$A = { key: 1 };
24150
24164
  const _hoisted_4$q = { class: "lupa-search-box-custom-label" };
24151
24165
  const _hoisted_5$h = { class: "lupa-search-box-custom-text" };
@@ -24179,7 +24193,7 @@ const _sfc_main$1h = /* @__PURE__ */ defineComponent({
24179
24193
  key: 1,
24180
24194
  class: [className.value, "lupa-search-box-product-custom"]
24181
24195
  }, toHandlers(_ctx.options.action ? { click: handleClick } : {}, true)), [
24182
- !label.value ? (openBlock(), createElementBlock("div", _hoisted_2$O, toDisplayString(text.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$A, [
24196
+ !label.value ? (openBlock(), createElementBlock("div", _hoisted_2$N, toDisplayString(text.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$A, [
24183
24197
  createBaseVNode("div", _hoisted_4$q, toDisplayString(label.value), 1),
24184
24198
  createBaseVNode("div", _hoisted_5$h, toDisplayString(text.value), 1)
24185
24199
  ]))
@@ -24302,6 +24316,10 @@ const useSearchResultStore = defineStore("searchResult", () => {
24302
24316
  var _a, _b, _c;
24303
24317
  return (_c = (_b = (_a = searchResultOptions.value) == null ? void 0 : _a.labels) == null ? void 0 : _b.currencyTemplate) != null ? _c : "";
24304
24318
  });
24319
+ const filterTranslations = computed(() => {
24320
+ var _a, _b, _c;
24321
+ return (_c = (_b = (_a = searchResultOptions.value) == null ? void 0 : _a.filters) == null ? void 0 : _b.translations) != null ? _c : {};
24322
+ });
24305
24323
  const labeledFilters = computed(
24306
24324
  () => getLabeledFilters(
24307
24325
  unfoldFilters(filters.value, {
@@ -24310,7 +24328,8 @@ const useSearchResultStore = defineStore("searchResult", () => {
24310
24328
  separator: priceSeparator.value,
24311
24329
  currencyTemplate: currencyTemplate.value
24312
24330
  }),
24313
- facets2.value
24331
+ facets2.value,
24332
+ filterTranslations.value
24314
24333
  )
24315
24334
  );
24316
24335
  const displayFilters = computed(() => {
@@ -24493,7 +24512,7 @@ const useSearchResultStore = defineStore("searchResult", () => {
24493
24512
  };
24494
24513
  });
24495
24514
  const _hoisted_1$16 = { class: "lupa-search-box-add-to-cart-wrapper" };
24496
- const _hoisted_2$N = { class: "lupa-search-box-product-addtocart" };
24515
+ const _hoisted_2$M = { class: "lupa-search-box-product-addtocart" };
24497
24516
  const _hoisted_3$z = ["onClick", "disabled"];
24498
24517
  const _sfc_main$1f = /* @__PURE__ */ defineComponent({
24499
24518
  __name: "SearchBoxProductAddToCart",
@@ -24530,7 +24549,7 @@ const _sfc_main$1f = /* @__PURE__ */ defineComponent({
24530
24549
  });
24531
24550
  return (_ctx, _cache) => {
24532
24551
  return openBlock(), createElementBlock("div", _hoisted_1$16, [
24533
- createBaseVNode("div", _hoisted_2$N, [
24552
+ createBaseVNode("div", _hoisted_2$M, [
24534
24553
  createBaseVNode("button", mergeProps({
24535
24554
  onClick: withModifiers(handleClick, ["stop", "prevent"]),
24536
24555
  class: loading.value ? "lupa-add-to-cart-loading" : "lupa-add-to-cart",
@@ -24644,7 +24663,7 @@ const _sfc_main$1e = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValu
24644
24663
  }
24645
24664
  }));
24646
24665
  const _hoisted_1$14 = { class: "lupa-badge-title" };
24647
- const _hoisted_2$M = ["src"];
24666
+ const _hoisted_2$L = ["src"];
24648
24667
  const _hoisted_3$y = { key: 1 };
24649
24668
  const _hoisted_4$p = {
24650
24669
  key: 0,
@@ -24687,7 +24706,7 @@ const _sfc_main$1d = /* @__PURE__ */ defineComponent({
24687
24706
  image.value ? (openBlock(), createElementBlock("img", {
24688
24707
  key: 0,
24689
24708
  src: image.value
24690
- }, null, 8, _hoisted_2$M)) : createCommentVNode("", true),
24709
+ }, null, 8, _hoisted_2$L)) : createCommentVNode("", true),
24691
24710
  hasTitleText.value && showTitle.value ? (openBlock(), createElementBlock("span", _hoisted_3$y, toDisplayString(_ctx.badge.titleText), 1)) : createCommentVNode("", true)
24692
24711
  ]),
24693
24712
  hasAdditionalText.value ? (openBlock(), createElementBlock("span", _hoisted_4$p, toDisplayString(_ctx.badge.additionalText), 1)) : createCommentVNode("", true)
@@ -24787,7 +24806,7 @@ const _sfc_main$1a = /* @__PURE__ */ defineComponent({
24787
24806
  }
24788
24807
  });
24789
24808
  const _hoisted_1$10 = { class: "lupa-image-badges" };
24790
- const _hoisted_2$L = ["src"];
24809
+ const _hoisted_2$K = ["src"];
24791
24810
  const _sfc_main$19 = /* @__PURE__ */ defineComponent({
24792
24811
  __name: "ImageBadge",
24793
24812
  props: {
@@ -24816,7 +24835,7 @@ const _sfc_main$19 = /* @__PURE__ */ defineComponent({
24816
24835
  }, [
24817
24836
  createBaseVNode("img", {
24818
24837
  src: getImageUrl(item)
24819
- }, null, 8, _hoisted_2$L)
24838
+ }, null, 8, _hoisted_2$K)
24820
24839
  ]);
24821
24840
  }), 128))
24822
24841
  ]);
@@ -24975,7 +24994,7 @@ const _sfc_main$17 = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValu
24975
24994
  }
24976
24995
  }));
24977
24996
  const _hoisted_1$_ = ["href"];
24978
- const _hoisted_2$K = { class: "lupa-search-box-product-details-section" };
24997
+ const _hoisted_2$J = { class: "lupa-search-box-product-details-section" };
24979
24998
  const _hoisted_3$x = {
24980
24999
  key: 0,
24981
25000
  class: "lupa-search-box-product-add-to-cart-section"
@@ -25076,7 +25095,7 @@ const _sfc_main$16 = /* @__PURE__ */ defineComponent({
25076
25095
  }, null, 8, ["item", "element", "labels", "link"]);
25077
25096
  }), 128))
25078
25097
  ], 4),
25079
- createBaseVNode("div", _hoisted_2$K, [
25098
+ createBaseVNode("div", _hoisted_2$J, [
25080
25099
  (openBlock(true), createElementBlock(Fragment, null, renderList(detailElements.value, (element) => {
25081
25100
  var _a;
25082
25101
  return openBlock(), createBlock(_sfc_main$1e, {
@@ -25249,6 +25268,9 @@ const _sfc_main$15 = /* @__PURE__ */ defineComponent({
25249
25268
  }
25250
25269
  emit2("product-click");
25251
25270
  handleRoutingEvent(link, event, boxRoutingBehavior.value === "event");
25271
+ if (props.panelOptions.programmaticNavigation) {
25272
+ window.location.assign(link);
25273
+ }
25252
25274
  };
25253
25275
  return (_ctx, _cache) => {
25254
25276
  return openBlock(), createElementBlock("div", _hoisted_1$Z, [
@@ -25279,7 +25301,7 @@ const _sfc_main$15 = /* @__PURE__ */ defineComponent({
25279
25301
  }
25280
25302
  });
25281
25303
  const _hoisted_1$Y = { class: "lupa-search-box-documents-go-to-results-wrapper" };
25282
- const _hoisted_2$J = { key: 0 };
25304
+ const _hoisted_2$I = { key: 0 };
25283
25305
  const _sfc_main$14 = /* @__PURE__ */ defineComponent({
25284
25306
  __name: "SearchBoxProductsGoToResultsButton",
25285
25307
  props: {
@@ -25316,7 +25338,7 @@ const _sfc_main$14 = /* @__PURE__ */ defineComponent({
25316
25338
  onClick: goToResults
25317
25339
  }, [
25318
25340
  createTextVNode(toDisplayString(goToResultsLabel.value) + " ", 1),
25319
- totalCount.value ? (openBlock(), createElementBlock("span", _hoisted_2$J, " " + toDisplayString(totalCount.value), 1)) : createCommentVNode("", true)
25341
+ totalCount.value ? (openBlock(), createElementBlock("span", _hoisted_2$I, " " + toDisplayString(totalCount.value), 1)) : createCommentVNode("", true)
25320
25342
  ])
25321
25343
  ]);
25322
25344
  };
@@ -25584,7 +25606,7 @@ const _hoisted_1$X = {
25584
25606
  key: 0,
25585
25607
  id: "lupa-search-box-panel"
25586
25608
  };
25587
- const _hoisted_2$I = ["data-cy"];
25609
+ const _hoisted_2$H = ["data-cy"];
25588
25610
  const _hoisted_3$w = {
25589
25611
  key: 0,
25590
25612
  class: "lupa-panel-title lupa-panel-title-top-results"
@@ -25804,7 +25826,7 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValu
25804
25826
  key: "0"
25805
25827
  } : void 0
25806
25828
  ]), 1064, ["panel", "search-box-options", "options", "debounce", "inputValue", "labels"])) : createCommentVNode("", true)
25807
- ], 14, _hoisted_2$I);
25829
+ ], 14, _hoisted_2$H);
25808
25830
  }), 128))
25809
25831
  ], 4),
25810
25832
  !unref(hasAnyResults) && _ctx.options.showNoResultsPanel ? (openBlock(), createBlock(_sfc_main$1r, {
@@ -25843,8 +25865,7 @@ const unbindSearchTriggers = (triggers = [], event) => {
25843
25865
  const elements = getElements(triggers);
25844
25866
  elements.forEach((e2) => e2 == null ? void 0 : e2.removeEventListener(BIND_EVENT, event));
25845
25867
  };
25846
- const _hoisted_1$W = { id: "lupa-search-box" };
25847
- const _hoisted_2$H = { class: "lupa-search-box-wrapper" };
25868
+ const _hoisted_1$W = { class: "lupa-search-box-wrapper" };
25848
25869
  const _sfc_main$10 = /* @__PURE__ */ defineComponent({
25849
25870
  __name: "SearchBox",
25850
25871
  props: {
@@ -25869,6 +25890,7 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
25869
25890
  const suggestedValue = ref(defaultSuggestedValue);
25870
25891
  const opened = ref(props.isSearchContainer);
25871
25892
  const focused = ref(false);
25893
+ const openedAt = ref(null);
25872
25894
  const searchBoxInput = ref(null);
25873
25895
  const { highlightedDocument } = storeToRefs(searchBoxStore);
25874
25896
  const searchValue = computed(() => {
@@ -25905,7 +25927,7 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
25905
25927
  });
25906
25928
  const goToResultsDebounced = debounce$1(paramsStore.goToResults, (_a = props.options.debounce) != null ? _a : 300);
25907
25929
  onMounted(() => {
25908
- var _a2;
25930
+ var _a2, _b, _c;
25909
25931
  window.addEventListener("keydown", handleKeyDown);
25910
25932
  window.addEventListener("click", handleMouseClick);
25911
25933
  paramsStore.setSearchResultsLink(props.options.links.searchResults);
@@ -25916,6 +25938,9 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
25916
25938
  if (props.isSearchContainer && searchBoxInput.value) {
25917
25939
  (_a2 = searchBoxInput.value) == null ? void 0 : _a2.focus();
25918
25940
  }
25941
+ if ((_b = props.options.callbacks) == null ? void 0 : _b.onMounted) {
25942
+ (_c = props.options.callbacks) == null ? void 0 : _c.onMounted();
25943
+ }
25919
25944
  });
25920
25945
  onBeforeUnmount(() => {
25921
25946
  window.removeEventListener("keydown", handleKeyDown);
@@ -25923,11 +25948,14 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
25923
25948
  unbindSearchTriggers(searchTriggers.value, handleCurrentValueSearch);
25924
25949
  });
25925
25950
  const handleMouseClick = (e2) => {
25926
- var _a2, _b;
25951
+ var _a2, _b, _c, _d;
25927
25952
  const el = document.getElementById("lupa-search-box");
25928
25953
  const elementClass = (_b = (_a2 = e2.target) == null ? void 0 : _a2.className) != null ? _b : "";
25929
25954
  const hasLupaClass = typeof elementClass.includes == "function" && elementClass.includes("lupa-search-box");
25930
25955
  const isOutsideElement = el && !el.contains(e2.target) && !hasLupaClass;
25956
+ if (openedAt.value && Date.now() - (openedAt == null ? void 0 : openedAt.value) < 500) {
25957
+ return;
25958
+ }
25931
25959
  if (isOutsideElement && props.options.keepOpen) {
25932
25960
  focused.value = false;
25933
25961
  }
@@ -25936,11 +25964,18 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
25936
25964
  }
25937
25965
  opened.value = false;
25938
25966
  suggestedValue.value = defaultSuggestedValue;
25967
+ if ((_c = props.options.callbacks) == null ? void 0 : _c.onClosed) {
25968
+ (_d = props.options.callbacks) == null ? void 0 : _d.onClosed();
25969
+ }
25939
25970
  };
25940
25971
  const close = () => {
25972
+ var _a2, _b;
25941
25973
  opened.value = false;
25942
25974
  focused.value = false;
25943
25975
  suggestedValue.value = defaultSuggestedValue;
25976
+ if ((_a2 = props.options.callbacks) == null ? void 0 : _a2.onClosed) {
25977
+ (_b = props.options.callbacks) == null ? void 0 : _b.onClosed();
25978
+ }
25944
25979
  };
25945
25980
  const handleKeyDown = (e2) => {
25946
25981
  var _a2, _b;
@@ -25959,15 +25994,22 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
25959
25994
  handleSearch();
25960
25995
  resetValues();
25961
25996
  break;
25997
+ case "Escape":
25998
+ opened.value = false;
25999
+ focused.value = false;
26000
+ break;
25962
26001
  }
25963
26002
  };
25964
26003
  const handleInput = (value) => {
25965
- var _a2;
26004
+ var _a2, _b;
25966
26005
  opened.value = true;
25967
26006
  focused.value = true;
25968
26007
  inputValue.value = (_a2 = value == null ? void 0 : value.replace(/\s+$/, "")) != null ? _a2 : "";
25969
26008
  suggestedValue.value = defaultSuggestedValue;
25970
26009
  searchBoxStore.resetHighlightIndex();
26010
+ if ((_b = props.options.callbacks) == null ? void 0 : _b.onSearchBoxInput) {
26011
+ props.options.callbacks.onSearchBoxInput(value);
26012
+ }
25971
26013
  trackSearchQuery(value);
25972
26014
  if (props.isSearchContainer) {
25973
26015
  goToResultsDebounced({
@@ -26100,6 +26142,13 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
26100
26142
  });
26101
26143
  };
26102
26144
  watch(() => props.options.debounce, handleCurrentValueSearch);
26145
+ watch(opened, () => {
26146
+ if (opened.value) {
26147
+ openedAt.value = Date.now();
26148
+ } else {
26149
+ openedAt.value = null;
26150
+ }
26151
+ });
26103
26152
  const resetValues = () => {
26104
26153
  inputValue.value = "";
26105
26154
  suggestedValue.value = defaultSuggestedValue;
@@ -26111,10 +26160,27 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
26111
26160
  const slotProps = (props2) => {
26112
26161
  return __spreadValues2({}, props2);
26113
26162
  };
26163
+ const onFocus = () => {
26164
+ var _a2, _b;
26165
+ opened.value = true;
26166
+ if ((_a2 = props.options.callbacks) == null ? void 0 : _a2.onFocused) {
26167
+ (_b = props.options.callbacks) == null ? void 0 : _b.onFocused();
26168
+ }
26169
+ };
26170
+ const onBlur = () => {
26171
+ var _a2, _b;
26172
+ focused.value = false;
26173
+ if ((_a2 = props.options.callbacks) == null ? void 0 : _a2.onBlurred) {
26174
+ (_b = props.options.callbacks) == null ? void 0 : _b.onBlurred();
26175
+ }
26176
+ };
26114
26177
  return (_ctx, _cache) => {
26115
26178
  var _a2;
26116
- return openBlock(), createElementBlock("div", _hoisted_1$W, [
26117
- createBaseVNode("div", _hoisted_2$H, [
26179
+ return openBlock(), createElementBlock("div", {
26180
+ id: "lupa-search-box",
26181
+ class: normalizeClass({ "lupa-search-box-opened": opened.value })
26182
+ }, [
26183
+ createBaseVNode("div", _hoisted_1$W, [
26118
26184
  createVNode(_sfc_main$1v, {
26119
26185
  options: inputOptions.value,
26120
26186
  suggestedValue: suggestedValue.value,
@@ -26123,10 +26189,10 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
26123
26189
  ref_key: "searchBoxInput",
26124
26190
  ref: searchBoxInput,
26125
26191
  onInput: handleInput,
26126
- onBlur: _cache[0] || (_cache[0] = ($event) => focused.value = false),
26127
- onFocus: _cache[1] || (_cache[1] = ($event) => opened.value = true),
26192
+ onBlur,
26193
+ onFocus,
26128
26194
  onSearch: handleSearch,
26129
- onClose: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("close"))
26195
+ onClose: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("close"))
26130
26196
  }, null, 8, ["options", "suggestedValue", "can-close", "emit-input-on-focus"]),
26131
26197
  opened.value || _ctx.isSearchContainer ? (openBlock(), createBlock(_sfc_main$11, {
26132
26198
  key: 0,
@@ -26149,7 +26215,7 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
26149
26215
  } : void 0
26150
26216
  ]), 1032, ["options", "inputValue", "isSearchContainer", "focused"])) : createCommentVNode("", true)
26151
26217
  ])
26152
- ]);
26218
+ ], 2);
26153
26219
  };
26154
26220
  }
26155
26221
  });
@@ -26743,6 +26809,8 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
26743
26809
  setup(__props, { emit: emit2 }) {
26744
26810
  const props = __props;
26745
26811
  const searchResultStore = useSearchResultStore();
26812
+ const optionsStore = useOptionsStore();
26813
+ const { searchResultOptions } = storeToRefs(optionsStore);
26746
26814
  const facet = computed(() => {
26747
26815
  var _a;
26748
26816
  return (_a = props.facet) != null ? _a : { type: "terms", items: [], key: "" };
@@ -26802,6 +26870,10 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
26802
26870
  selectedItems = isRange.value && selectedItems ? [rangeFilterToString(selectedItems)] : selectedItems;
26803
26871
  return selectedItems == null ? void 0 : selectedItems.includes((_b = item.title) == null ? void 0 : _b.toString());
26804
26872
  };
26873
+ const getItemLabel = (item) => {
26874
+ var _a;
26875
+ return getTranslatedFacetValue(props.facet, item, (_a = searchResultOptions.value.filters) == null ? void 0 : _a.translations);
26876
+ };
26805
26877
  return (_ctx, _cache) => {
26806
26878
  return openBlock(), createElementBlock("div", _hoisted_1$O, [
26807
26879
  isFilterable.value ? withDirectives((openBlock(), createElementBlock("input", {
@@ -26827,7 +26899,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
26827
26899
  }, null, 2)
26828
26900
  ]),
26829
26901
  createBaseVNode("div", _hoisted_6$8, [
26830
- createBaseVNode("span", _hoisted_7$6, toDisplayString(item.title), 1),
26902
+ createBaseVNode("span", _hoisted_7$6, toDisplayString(getItemLabel(item)), 1),
26831
26903
  _ctx.options.showDocumentCount ? (openBlock(), createElementBlock("span", _hoisted_8$2, "(" + toDisplayString(item.count) + ")", 1)) : createCommentVNode("", true)
26832
26904
  ])
26833
26905
  ], 10, _hoisted_4$j);
@@ -28311,7 +28383,9 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
28311
28383
  return (_a2 = props.currentFilters) != null ? _a2 : {};
28312
28384
  });
28313
28385
  const searchResultStore = useSearchResultStore();
28386
+ const optionsStore = useOptionsStore();
28314
28387
  const { currentFilterKeys } = storeToRefs(searchResultStore);
28388
+ const { searchResultOptions } = storeToRefs(optionsStore);
28315
28389
  const isOpen = ref((_b = (_a = props.options.expand) == null ? void 0 : _a.includes(props.facet.key)) != null ? _b : false);
28316
28390
  const facetPanel = ref(null);
28317
28391
  const facetType = computed(() => {
@@ -28350,6 +28424,10 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
28350
28424
  const facetKeyClass = computed(() => {
28351
28425
  return `lupa-facet-${facet.value.key}`;
28352
28426
  });
28427
+ const facetLabel = computed(() => {
28428
+ var _a2;
28429
+ return getTranslatedFacetKey(props.facet, (_a2 = searchResultOptions.value.filters) == null ? void 0 : _a2.translations);
28430
+ });
28353
28431
  onMounted(() => {
28354
28432
  var _a2;
28355
28433
  if (((_a2 = props.options.style) == null ? void 0 : _a2.type) === "top-dropdown") {
@@ -28405,7 +28483,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
28405
28483
  "data-cy": "lupa-search-result-facet-label",
28406
28484
  onClick: toggleFacet
28407
28485
  }, [
28408
- createBaseVNode("div", _hoisted_1$K, toDisplayString(facet.value.label), 1),
28486
+ createBaseVNode("div", _hoisted_1$K, toDisplayString(facetLabel.value), 1),
28409
28487
  createBaseVNode("div", {
28410
28488
  class: normalizeClass(["lupa-facet-label-caret", isOpen.value && "open"])
28411
28489
  }, null, 2)
@@ -39595,6 +39673,33 @@ const attatchShadowDom = ({
39595
39673
  shadow.appendChild(style);
39596
39674
  }
39597
39675
  };
39676
+ const createDomPing = () => {
39677
+ let intervalId = null;
39678
+ let remaining = 0;
39679
+ return (intervalMs = 100, count = 50) => {
39680
+ if (intervalId !== null) {
39681
+ clearInterval(intervalId);
39682
+ }
39683
+ remaining = count;
39684
+ const flush = () => {
39685
+ if (remaining-- <= 0) {
39686
+ if (intervalId !== null) {
39687
+ clearInterval(intervalId);
39688
+ intervalId = null;
39689
+ }
39690
+ return;
39691
+ }
39692
+ const el = document.createElement("div");
39693
+ el.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;pointer-events:none;";
39694
+ el.setAttribute("data-nudge", Date.now().toString());
39695
+ document.body.appendChild(el);
39696
+ document.body.removeChild(el);
39697
+ };
39698
+ flush();
39699
+ intervalId = window.setInterval(flush, intervalMs);
39700
+ };
39701
+ };
39702
+ const startDomPing = createDomPing();
39598
39703
  const getMountElement = (element, mountingBehavior = "replace", mountToParent) => {
39599
39704
  const parent = element == null ? void 0 : element.parentElement;
39600
39705
  if (mountingBehavior === "replace") {
@@ -39650,6 +39755,58 @@ const app = {
39650
39755
  recommendations: {},
39651
39756
  chat: {}
39652
39757
  };
39758
+ const addSearchBoxDomPingIfConfigured = (options, mountOptions) => {
39759
+ var _a;
39760
+ if (!((_a = mountOptions == null ? void 0 : mountOptions.domPing) == null ? void 0 : _a.count)) {
39761
+ return options;
39762
+ }
39763
+ const newOptions = __spreadProps(__spreadValues({}, options), {
39764
+ callbacks: {
39765
+ onMounted: () => {
39766
+ var _a2, _b;
39767
+ (_b = (_a2 = options.callbacks) == null ? void 0 : _a2.onMounted) == null ? void 0 : _b.call(_a2);
39768
+ startDomPing(mountOptions.domPing.intervalMs, mountOptions.domPing.count);
39769
+ },
39770
+ onBlurred: () => {
39771
+ var _a2, _b;
39772
+ (_b = (_a2 = options.callbacks) == null ? void 0 : _a2.onBlurred) == null ? void 0 : _b.call(_a2);
39773
+ startDomPing(mountOptions.domPing.intervalMs, mountOptions.domPing.count);
39774
+ },
39775
+ onFocused: () => {
39776
+ var _a2, _b;
39777
+ (_b = (_a2 = options.callbacks) == null ? void 0 : _a2.onFocused) == null ? void 0 : _b.call(_a2);
39778
+ startDomPing(mountOptions.domPing.intervalMs, mountOptions.domPing.count);
39779
+ },
39780
+ onSearchBoxInput: (...args) => {
39781
+ var _a2, _b;
39782
+ (_b = (_a2 = options.callbacks) == null ? void 0 : _a2.onSearchBoxInput) == null ? void 0 : _b.call(_a2, ...args);
39783
+ startDomPing(mountOptions.domPing.intervalMs, mountOptions.domPing.count);
39784
+ }
39785
+ }
39786
+ });
39787
+ return newOptions;
39788
+ };
39789
+ const addSearchResultsDomPingIfConfigured = (options, mountOptions) => {
39790
+ var _a;
39791
+ if (!((_a = mountOptions == null ? void 0 : mountOptions.domPing) == null ? void 0 : _a.count)) {
39792
+ return options;
39793
+ }
39794
+ const newOptions = __spreadProps(__spreadValues({}, options), {
39795
+ callbacks: {
39796
+ onMounted: () => {
39797
+ var _a2, _b;
39798
+ (_b = (_a2 = options.callbacks) == null ? void 0 : _a2.onMounted) == null ? void 0 : _b.call(_a2);
39799
+ startDomPing(mountOptions.domPing.intervalMs, mountOptions.domPing.count);
39800
+ },
39801
+ onUrlQueryChange: (...args) => {
39802
+ var _a2, _b;
39803
+ (_b = (_a2 = options.callbacks) == null ? void 0 : _a2.onUrlQueryChange) == null ? void 0 : _b.call(_a2, ...args);
39804
+ startDomPing(mountOptions.domPing.intervalMs, mountOptions.domPing.count);
39805
+ }
39806
+ }
39807
+ });
39808
+ return newOptions;
39809
+ };
39653
39810
  const applySearchBox = (options, mountOptions) => {
39654
39811
  const existingInstance = app.box[options.inputSelector];
39655
39812
  if (existingInstance) {
@@ -39679,9 +39836,10 @@ const searchBox = (options, mountOptions) => {
39679
39836
  if (!canMount(mountOptions == null ? void 0 : mountOptions.allowedMountUrls)) {
39680
39837
  return;
39681
39838
  }
39839
+ const transformedOptions = addSearchBoxDomPingIfConfigured(options, mountOptions);
39682
39840
  const inputs = (_a = options.inputSelector) == null ? void 0 : _a.split(",");
39683
39841
  for (const input2 of inputs) {
39684
- applySearchBox(__spreadProps(__spreadValues({}, options), { inputSelector: input2.trim() }), mountOptions);
39842
+ applySearchBox(__spreadProps(__spreadValues({}, transformedOptions), { inputSelector: input2.trim() }), mountOptions);
39685
39843
  }
39686
39844
  };
39687
39845
  const searchResults = (options, mountOptions) => {
@@ -39699,12 +39857,13 @@ const searchResults = (options, mountOptions) => {
39699
39857
  }
39700
39858
  return;
39701
39859
  }
39860
+ const transformedOptions = addSearchResultsDomPingIfConfigured(options, mountOptions);
39702
39861
  const instance = createVue(
39703
39862
  options.containerSelector,
39704
39863
  mountOptions == null ? void 0 : mountOptions.mountingBehavior,
39705
39864
  _sfc_main$3,
39706
39865
  {
39707
- searchResultsOptions: options
39866
+ searchResultsOptions: transformedOptions
39708
39867
  }
39709
39868
  );
39710
39869
  if (!instance) {
@@ -40144,6 +40303,7 @@ const mountSearchBox = (configuration, options, optionOverrides, fetch2 = true,
40144
40303
  }
40145
40304
  const resolvedConfiguration = JSON.parse(configuration.searchBox);
40146
40305
  const allowedMountUrls = resolvedConfiguration.allowedMountUrls;
40306
+ const domPing = resolvedConfiguration.domPing;
40147
40307
  const visible = yield waitForElementToBeVisible(
40148
40308
  resolvedConfiguration.inputSelector,
40149
40309
  0,
@@ -40159,7 +40319,7 @@ const mountSearchBox = (configuration, options, optionOverrides, fetch2 = true,
40159
40319
  resolvedConfiguration,
40160
40320
  (_a = optionOverrides == null ? void 0 : optionOverrides.searchBox) != null ? _a : {}
40161
40321
  );
40162
- searchBox(__spreadProps(__spreadValues({}, mergedOptions), { options }), { fetch: fetch2, allowedMountUrls });
40322
+ searchBox(__spreadProps(__spreadValues({}, mergedOptions), { options }), { fetch: fetch2, allowedMountUrls, domPing });
40163
40323
  });
40164
40324
  const mountSearchResults = (configuration, options, optionOverrides, fetch2 = true, remount = false) => __async(void 0, null, function* () {
40165
40325
  var _a;
@@ -40168,6 +40328,7 @@ const mountSearchResults = (configuration, options, optionOverrides, fetch2 = tr
40168
40328
  }
40169
40329
  const resolvedConfiguration = JSON.parse(configuration.searchResults);
40170
40330
  const allowedMountUrls = resolvedConfiguration.allowedMountUrls;
40331
+ const domPing = resolvedConfiguration.domPing;
40171
40332
  const visible = yield waitForElementToBeVisible(
40172
40333
  resolvedConfiguration.containerSelector,
40173
40334
  0,
@@ -40183,7 +40344,7 @@ const mountSearchResults = (configuration, options, optionOverrides, fetch2 = tr
40183
40344
  resolvedConfiguration,
40184
40345
  (_a = optionOverrides == null ? void 0 : optionOverrides.searchResults) != null ? _a : {}
40185
40346
  );
40186
- searchResults(__spreadProps(__spreadValues({}, mergedOptions), { options }), { fetch: fetch2, allowedMountUrls });
40347
+ searchResults(__spreadProps(__spreadValues({}, mergedOptions), { options }), { fetch: fetch2, allowedMountUrls, domPing });
40187
40348
  });
40188
40349
  const mountProductList = (configuration, options, optionOverrides, fetch2 = true, remount = false) => __async(void 0, null, function* () {
40189
40350
  var _a;