@getlupa/client 1.15.7 → 1.15.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.
@@ -7285,7 +7285,7 @@ const DEFAULT_OPTIONS_RESULTS$1 = {
7285
7285
  details: "/{id}"
7286
7286
  },
7287
7287
  elements: [],
7288
- breadcrumbs: [{ label: "Main Page", link: "/" }, { label: "Search: {1}" }]
7288
+ breadcrumbs: []
7289
7289
  };
7290
7290
  const useScreenStore = defineStore("screen", () => {
7291
7291
  const measuredScreenWidth = ref(1e3);
@@ -8124,12 +8124,15 @@ const getFacetParam = (key, value, type = FACET_PARAMS_TYPE.TERMS) => {
8124
8124
  value
8125
8125
  };
8126
8126
  };
8127
- const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentFilters) => {
8127
+ const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentFilters, paramsToRemove = []) => {
8128
8128
  const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
8129
8129
  const newParams = toggleTermParam(currentFilter, facetAction.value);
8130
8130
  appendParams({
8131
8131
  params: [getFacetParam(facetAction.key, newParams)],
8132
- paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
8132
+ paramsToRemove: [
8133
+ ...paramsToRemove,
8134
+ ...[getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
8135
+ ]
8133
8136
  });
8134
8137
  };
8135
8138
  const replaceHierarchyParam = (params = [], param = "") => {
@@ -8815,7 +8818,7 @@ const _sfc_main$1s = /* @__PURE__ */ defineComponent({
8815
8818
  __name: "SearchBoxMoreResults",
8816
8819
  props: {
8817
8820
  labels: {},
8818
- showTotalCount: { type: Boolean }
8821
+ options: {}
8819
8822
  },
8820
8823
  emits: ["go-to-results"],
8821
8824
  setup(__props, { emit: emit2 }) {
@@ -8823,23 +8826,28 @@ const _sfc_main$1s = /* @__PURE__ */ defineComponent({
8823
8826
  const searchBoxStore = useSearchBoxStore();
8824
8827
  const { docResults, options } = storeToRefs(searchBoxStore);
8825
8828
  const totalCount = computed(() => {
8826
- var _a, _b, _c;
8827
- if (!props.showTotalCount) {
8829
+ var _a, _b, _c, _d;
8830
+ if (!((_a = props.options) == null ? void 0 : _a.showTotalCount)) {
8828
8831
  return "";
8829
8832
  }
8830
- const queryKey = (_b = (_a = options.value) == null ? void 0 : _a.panels.find((x2) => x2.type === "document")) == null ? void 0 : _b.queryKey;
8831
- const total = queryKey ? (_c = docResults.value[queryKey]) == null ? void 0 : _c.total : "";
8833
+ const queryKey = (_c = (_b = options.value) == null ? void 0 : _b.panels.find((x2) => x2.type === "document")) == null ? void 0 : _c.queryKey;
8834
+ const total = queryKey ? (_d = docResults.value[queryKey]) == null ? void 0 : _d.total : "";
8832
8835
  return total ? `(${total})` : "";
8833
8836
  });
8837
+ const showMoreResultsButton = computed(() => {
8838
+ var _a;
8839
+ return (_a = props.options.showMoreResultsButton) != null ? _a : true;
8840
+ });
8834
8841
  const handleClick = () => {
8835
8842
  emit2("go-to-results");
8836
8843
  };
8837
8844
  return (_ctx, _cache) => {
8838
- return openBlock(), createElementBlock("a", {
8845
+ return showMoreResultsButton.value ? (openBlock(), createElementBlock("a", {
8846
+ key: 0,
8839
8847
  class: "lupa-more-results",
8840
8848
  "data-cy": "lupa-more-results",
8841
8849
  onClick: handleClick
8842
- }, toDisplayString(_ctx.labels.moreResults) + " " + toDisplayString(totalCount.value), 1);
8850
+ }, toDisplayString(_ctx.labels.moreResults) + " " + toDisplayString(totalCount.value), 1)) : createCommentVNode("", true);
8843
8851
  };
8844
8852
  }
8845
8853
  });
@@ -20045,7 +20053,6 @@ const _sfc_main$$ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
20045
20053
  return resultCountFromRelatedPanel < 1;
20046
20054
  };
20047
20055
  return (_ctx, _cache) => {
20048
- var _a;
20049
20056
  return openBlock(), createElementBlock("div", {
20050
20057
  ref_key: "panelContainer",
20051
20058
  ref: panelContainer
@@ -20062,7 +20069,7 @@ const _sfc_main$$ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
20062
20069
  "data-cy": "lupa-main-panel"
20063
20070
  }, [
20064
20071
  (openBlock(true), createElementBlock(Fragment, null, renderList(displayPanels.value, (panel, index) => {
20065
- var _a2, _b, _c, _d;
20072
+ var _a, _b, _c, _d;
20066
20073
  return openBlock(), createElementBlock("div", {
20067
20074
  key: index,
20068
20075
  class: normalizeClass([
@@ -20072,7 +20079,7 @@ const _sfc_main$$ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
20072
20079
  style: normalizeStyle(panel.gridArea ? { gridArea: `${panel.gridArea}${index}` } : {}),
20073
20080
  "data-cy": "lupa-panel-" + panel.type + "-index"
20074
20081
  }, [
20075
- ((_a2 = panel.labels) == null ? void 0 : _a2.topResultsTitle) && showTopResultsPanelTitle(panel.queryKey) ? (openBlock(), createElementBlock("div", _hoisted_3$y, toDisplayString((_b = panel.labels) == null ? void 0 : _b.topResultsTitle), 1)) : createCommentVNode("", true),
20082
+ ((_a = panel.labels) == null ? void 0 : _a.topResultsTitle) && showTopResultsPanelTitle(panel.queryKey) ? (openBlock(), createElementBlock("div", _hoisted_3$y, toDisplayString((_b = panel.labels) == null ? void 0 : _b.topResultsTitle), 1)) : createCommentVNode("", true),
20076
20083
  ((_c = panel.labels) == null ? void 0 : _c.title) && showPanelTitle(panel) ? (openBlock(), createElementBlock("div", _hoisted_4$p, toDisplayString((_d = panel.labels) == null ? void 0 : _d.title), 1)) : createCommentVNode("", true),
20077
20084
  panel.queryKey && canShowPanel(panel) ? (openBlock(), createBlock(resolveDynamicComponent(getComponent(panel.type)), {
20078
20085
  key: 2,
@@ -20105,9 +20112,9 @@ const _sfc_main$$ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
20105
20112
  unref(hasAnyResults) || !_ctx.options.hideMoreResultsButtonOnNoResults ? (openBlock(), createBlock(_sfc_main$1s, {
20106
20113
  key: 2,
20107
20114
  labels: labels.value,
20108
- showTotalCount: (_a = _ctx.options.showTotalCount) != null ? _a : false,
20115
+ options: _ctx.options,
20109
20116
  onGoToResults: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("go-to-results"))
20110
- }, null, 8, ["labels", "showTotalCount"])) : createCommentVNode("", true)
20117
+ }, null, 8, ["labels", "options"])) : createCommentVNode("", true)
20111
20118
  ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_5$g, [
20112
20119
  createVNode(_sfc_main$1q, {
20113
20120
  options: _ctx.options.history,
@@ -20186,7 +20193,8 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent({
20186
20193
  "showTotalCount",
20187
20194
  "hideMoreResultsButtonOnNoResults",
20188
20195
  "showNoResultsPanel",
20189
- "expandOnSinglePanel"
20196
+ "expandOnSinglePanel",
20197
+ "showMoreResultsButton"
20190
20198
  ])
20191
20199
  );
20192
20200
  const searchTriggers = computed(() => {
@@ -20659,11 +20667,15 @@ const _sfc_main$X = /* @__PURE__ */ defineComponent({
20659
20667
  var _a, _b;
20660
20668
  return (_b = (_a = props.options.labels) == null ? void 0 : _a.searchResultsCount) != null ? _b : "";
20661
20669
  });
20670
+ const searchResultsTitleTemplate = computed(() => {
20671
+ var _a, _b, _c, _d, _e;
20672
+ return ((_c = (_b = (_a = props.options) == null ? void 0 : _a.labels) == null ? void 0 : _b.searchResults) == null ? void 0 : _c.includes("{")) ? addParamsToLabel((_e = (_d = props.options) == null ? void 0 : _d.labels) == null ? void 0 : _e.searchResults, queryText.value) : ``;
20673
+ });
20662
20674
  return (_ctx, _cache) => {
20663
20675
  return openBlock(), createElementBlock("div", null, [
20664
20676
  showSearchTitle.value ? (openBlock(), createElementBlock("h1", _hoisted_1$S, [
20665
- createTextVNode(toDisplayString(_ctx.options.labels.searchResults), 1),
20666
- queryText.value ? (openBlock(), createElementBlock("span", _hoisted_2$F, "'" + toDisplayString(queryText.value) + "'", 1)) : createCommentVNode("", true),
20677
+ createTextVNode(toDisplayString(searchResultsTitleTemplate.value || _ctx.options.labels.searchResults), 1),
20678
+ queryText.value && !searchResultsTitleTemplate.value ? (openBlock(), createElementBlock("span", _hoisted_2$F, "'" + toDisplayString(queryText.value) + "'", 1)) : createCommentVNode("", true),
20667
20679
  showProductCount.value ? (openBlock(), createElementBlock("span", _hoisted_3$w, [
20668
20680
  createTextVNode("(" + toDisplayString(searchResultsCountLabel.value), 1),
20669
20681
  createBaseVNode("span", _hoisted_4$n, toDisplayString(unref(totalItems)), 1),
@@ -24671,26 +24683,104 @@ var RelatedQuerySourceType = /* @__PURE__ */ ((RelatedQuerySourceType2) => {
24671
24683
  RelatedQuerySourceType2["FACETS"] = "facets";
24672
24684
  return RelatedQuerySourceType2;
24673
24685
  })(RelatedQuerySourceType || {});
24674
- const extractFacetsRelatedSource = (source, searchResults2) => {
24686
+ const combineIdenticalValues = (results) => {
24687
+ const result2 = [];
24688
+ const keys = /* @__PURE__ */ new Set();
24689
+ for (const item of results) {
24690
+ const trimmedValue = item.value.trim().toLowerCase();
24691
+ if (!keys.has(trimmedValue)) {
24692
+ keys.add(trimmedValue);
24693
+ result2.push({ key: item.key, value: item.value.trim() });
24694
+ }
24695
+ }
24696
+ return result2;
24697
+ };
24698
+ const processFacetsRelatedSourceSuggestionQuery = (searchText, querySource, options, activeFilters) => __async2(void 0, null, function* () {
24699
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
24700
+ if ((_a = Object.keys(activeFilters != null ? activeFilters : {})) == null ? void 0 : _a.length) {
24701
+ return [];
24702
+ }
24703
+ const lupaQuery = {
24704
+ searchText,
24705
+ limit: 1,
24706
+ trackTerm: false
24707
+ };
24708
+ try {
24709
+ const result2 = yield LupaSearchSdk.suggestions(querySource.queryKey, lupaQuery, options);
24710
+ if (!result2.success || ((_c = (_b = result2.items) == null ? void 0 : _b[0].suggestion) == null ? void 0 : _c.toLocaleLowerCase()) !== (searchText == null ? void 0 : searchText.toLocaleLowerCase())) {
24711
+ return [];
24712
+ }
24713
+ return (_i = (_h = (_f = (_e = (_d = result2.items) == null ? void 0 : _d[0].facets) == null ? void 0 : _e[querySource.facetKey]) == null ? void 0 : _f.map((item) => ({
24714
+ key: querySource.facetKey,
24715
+ value: item.title
24716
+ }))) == null ? void 0 : _h.slice(0, (_g = querySource.maxCount) != null ? _g : 5)) != null ? _i : [];
24717
+ } catch (error) {
24718
+ return [];
24719
+ }
24720
+ });
24721
+ const processFacetsRelatedSourceDocumentQuery = (searchText, querySource, options, activeFilters) => __async2(void 0, null, function* () {
24722
+ const lupaQuery = {
24723
+ searchText,
24724
+ limit: 1,
24725
+ filters: activeFilters,
24726
+ trackTerm: false
24727
+ };
24728
+ try {
24729
+ const result2 = yield LupaSearchSdk.query(querySource.queryKey, lupaQuery, options);
24730
+ if (!result2.success) {
24731
+ return [];
24732
+ }
24733
+ return extractFacetsRelatedSourceFromOriginalQuery(
24734
+ {
24735
+ type: RelatedQuerySourceType.FACETS,
24736
+ key: querySource.facetKey,
24737
+ count: querySource.maxCount
24738
+ },
24739
+ result2
24740
+ );
24741
+ } catch (error) {
24742
+ return [];
24743
+ }
24744
+ });
24745
+ const processFacetsRelatedSourceQuery = (searchText, query, options, activeFilters) => __async2(void 0, null, function* () {
24746
+ switch (query.type) {
24747
+ case "document":
24748
+ return processFacetsRelatedSourceDocumentQuery(searchText, query, options, activeFilters);
24749
+ case "suggestion":
24750
+ return processFacetsRelatedSourceSuggestionQuery(searchText, query, options, activeFilters);
24751
+ }
24752
+ });
24753
+ const extractFacetsRelatedSource = (source, searchResults2, options, activeFilters) => __async2(void 0, null, function* () {
24754
+ var _a, _b;
24755
+ if (!((_a = source.queries) == null ? void 0 : _a.length)) {
24756
+ return extractFacetsRelatedSourceFromOriginalQuery(source, searchResults2);
24757
+ }
24758
+ const promises = source.queries.map(
24759
+ (query) => processFacetsRelatedSourceQuery(searchResults2.searchText, query, options, activeFilters)
24760
+ );
24761
+ const result2 = (yield Promise.all(promises)).flat();
24762
+ return (_b = combineIdenticalValues(result2)) == null ? void 0 : _b.slice(0, source.count);
24763
+ });
24764
+ const extractFacetsRelatedSourceFromOriginalQuery = (source, searchResults2) => __async2(void 0, null, function* () {
24675
24765
  var _a, _b, _c, _d, _e;
24676
24766
  const facet = (_a = searchResults2.facets) == null ? void 0 : _a.find((facet2) => facet2.key === source.key);
24677
24767
  if (!facet) {
24678
24768
  return [];
24679
24769
  }
24680
24770
  if (facet.type === "terms") {
24681
- return (_c = (_b = facet.items) == null ? void 0 : _b.slice(0, source.count)) == null ? void 0 : _c.map((item) => item.title);
24771
+ return (_c = (_b = facet.items) == null ? void 0 : _b.slice(0, source.count)) == null ? void 0 : _c.map((item) => ({ key: source.key, value: item.title }));
24682
24772
  }
24683
24773
  if (facet.type === "hierarchy") {
24684
- return (_e = (_d = facet.items) == null ? void 0 : _d.slice(0, source.count)) == null ? void 0 : _e.map((item) => item.title);
24774
+ return (_e = (_d = facet.items) == null ? void 0 : _d.slice(0, source.count)) == null ? void 0 : _e.map((item) => ({ key: source.key, value: item.title }));
24685
24775
  }
24686
24776
  return [];
24687
- };
24688
- const extractRelatedSource = (source, searchResults2) => {
24777
+ });
24778
+ const extractRelatedSource = (source, searchResults2, options, activeFilters) => __async2(void 0, null, function* () {
24689
24779
  switch (source.type) {
24690
24780
  case RelatedQuerySourceType.FACETS:
24691
- return extractFacetsRelatedSource(source, searchResults2);
24781
+ return extractFacetsRelatedSource(source, searchResults2, options, activeFilters);
24692
24782
  }
24693
- };
24783
+ });
24694
24784
  const _hoisted_1$h = { class: "lupa-related-query-item" };
24695
24785
  const _hoisted_2$e = { class: "lupa-related-query-image" };
24696
24786
  const _hoisted_3$a = { class: "lupa-related-query-label" };
@@ -24703,12 +24793,16 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
24703
24793
  __name: "RelatedQueryPanel",
24704
24794
  props: {
24705
24795
  query: {},
24706
- options: {}
24796
+ sourceKey: {},
24797
+ options: {},
24798
+ existingItemsFromOtherQueries: {}
24707
24799
  },
24708
- setup(__props) {
24800
+ emits: ["loaded"],
24801
+ setup(__props, { emit: emit2 }) {
24709
24802
  const props = __props;
24710
24803
  const loading = ref(false);
24711
24804
  const relatedQueryResult = ref(null);
24805
+ const itemToDisplay = ref(null);
24712
24806
  const optionsStore = useOptionsStore();
24713
24807
  const searchResultStore = useSearchResultStore();
24714
24808
  const { searchResultOptions } = storeToRefs(optionsStore);
@@ -24729,10 +24823,6 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
24729
24823
  var _a, _b;
24730
24824
  return ((_b = (_a = relatedQueryResult.value) == null ? void 0 : _a.items) == null ? void 0 : _b.length) > 0;
24731
24825
  });
24732
- const firstResultItem = computed(() => {
24733
- var _a, _b;
24734
- return (_b = (_a = relatedQueryResult.value) == null ? void 0 : _a.items) == null ? void 0 : _b[0];
24735
- });
24736
24826
  const totalItemCount = computed(() => {
24737
24827
  var _a, _b;
24738
24828
  return (_b = (_a = relatedQueryResult.value) == null ? void 0 : _a.total) != null ? _b : 0;
@@ -24742,19 +24832,19 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
24742
24832
  return ((_a = props.options.source) == null ? void 0 : _a.mode) === "filter" ? (_b = searchResult.value) == null ? void 0 : _b.searchText : (_c = props.query) == null ? void 0 : _c.toLowerCase();
24743
24833
  });
24744
24834
  const relatedQueryFilters = computed(() => {
24745
- var _a, _b, _c;
24835
+ var _a;
24746
24836
  return ((_a = props.options.source) == null ? void 0 : _a.mode) === "filter" ? {
24747
- [(_c = (_b = props.options) == null ? void 0 : _b.source) == null ? void 0 : _c.key]: [props.query]
24837
+ [props.sourceKey]: [props.query]
24748
24838
  } : {};
24749
24839
  });
24750
24840
  const searchForRelatedQuery = () => __async2(this, null, function* () {
24751
- var _a, _b, _c;
24841
+ var _a, _b, _c, _d, _e, _f, _g, _h;
24752
24842
  if (!props.query) {
24753
24843
  return;
24754
24844
  }
24755
24845
  const lupaQuery = {
24756
24846
  searchText: searchText.value,
24757
- limit: 1,
24847
+ limit: 3,
24758
24848
  filters: relatedQueryFilters.value,
24759
24849
  trackTerm: false
24760
24850
  };
@@ -24768,8 +24858,13 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
24768
24858
  if (result2.success) {
24769
24859
  relatedQueryResult.value = result2;
24770
24860
  }
24861
+ const firstItem = (_c = (_b = relatedQueryResult.value) == null ? void 0 : _b.items) == null ? void 0 : _c[0];
24862
+ itemToDisplay.value = (_f = (_e = (_d = relatedQueryResult == null ? void 0 : relatedQueryResult.value) == null ? void 0 : _d.items) == null ? void 0 : _e.find(
24863
+ (i) => !props.existingItemsFromOtherQueries[`${i.id}`]
24864
+ )) != null ? _f : firstItem;
24865
+ emit2("loaded", itemToDisplay.value);
24771
24866
  } catch (error) {
24772
- (_c = (_b = searchResultOptions.value) == null ? void 0 : _b.options) == null ? void 0 : _c.onError(error);
24867
+ (_h = (_g = searchResultOptions.value) == null ? void 0 : _g.options) == null ? void 0 : _h.onError(error);
24773
24868
  } finally {
24774
24869
  loading.value = false;
24775
24870
  }
@@ -24787,11 +24882,11 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
24787
24882
  var _a;
24788
24883
  return openBlock(), createElementBlock("div", _hoisted_1$h, [
24789
24884
  createBaseVNode("div", _hoisted_2$e, [
24790
- firstResultItem.value && image.value ? (openBlock(), createBlock(_sfc_main$1l, {
24885
+ itemToDisplay.value && image.value ? (openBlock(), createBlock(_sfc_main$1l, {
24791
24886
  key: 0,
24792
24887
  "wrapper-class": "lupa-related-query-image-wrapper",
24793
24888
  "image-class": "lupa-related-query-image",
24794
- item: firstResultItem.value,
24889
+ item: itemToDisplay.value,
24795
24890
  options: image.value
24796
24891
  }, null, 8, ["item", "options"])) : createCommentVNode("", true)
24797
24892
  ]),
@@ -24823,47 +24918,63 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
24823
24918
  const paramsStore = useParamsStore();
24824
24919
  const optionsStore = useOptionsStore();
24825
24920
  const { searchResult } = storeToRefs(searchResultStore);
24921
+ const { searchResultOptions } = storeToRefs(optionsStore);
24922
+ const relatedQueries = ref([]);
24923
+ const allDisplayItems = ref({});
24924
+ const querySourceResultMap = ref({});
24826
24925
  const currentSearchText = computed(() => {
24827
24926
  var _a, _b;
24828
24927
  return (_b = (_a = searchResult.value) == null ? void 0 : _a.searchText) != null ? _b : "";
24829
24928
  });
24830
- const relatedQueries = computed(() => {
24831
- if (!props.options || !searchResult.value) {
24832
- return [];
24929
+ const currentFilters = computed(() => paramsStore.filters);
24930
+ const querySources = computed(() => {
24931
+ var _a, _b, _c, _d;
24932
+ return (_d = (_c = (_b = (_a = props.options) == null ? void 0 : _a.source) == null ? void 0 : _b.queries) == null ? void 0 : _c.map((q) => q.facetKey)) != null ? _d : [];
24933
+ });
24934
+ const currentFiltersWithoutQuerySources = computed(() => {
24935
+ const filters = {};
24936
+ if (currentFilters.value) {
24937
+ for (const key in currentFilters.value) {
24938
+ if (!querySources.value.includes(key)) {
24939
+ filters[key] = currentFilters.value[key];
24940
+ }
24941
+ }
24833
24942
  }
24834
- const queries = extractRelatedSource(props.options.source, searchResult.value);
24835
- return queries;
24943
+ return filters;
24836
24944
  });
24945
+ watch(searchResult, () => __async2(this, null, function* () {
24946
+ allDisplayItems.value = {};
24947
+ querySourceResultMap.value = {};
24948
+ if (!props.options || !searchResult.value) {
24949
+ relatedQueries.value = [];
24950
+ }
24951
+ const queries = yield extractRelatedSource(
24952
+ props.options.source,
24953
+ searchResult.value,
24954
+ searchResultOptions.value.options,
24955
+ currentFiltersWithoutQuerySources.value
24956
+ );
24957
+ relatedQueries.value = queries;
24958
+ }));
24837
24959
  const hasEnoughRelatedQueries = computed(() => {
24838
24960
  return relatedQueries.value.length > 1;
24839
24961
  });
24840
- const goToResults = ({ searchText }) => {
24841
- paramsStore.goToResults({ searchText });
24842
- };
24843
24962
  const handleRelatedQueryClick = (query) => {
24844
24963
  var _a;
24845
24964
  if (((_a = props.options.source) == null ? void 0 : _a.mode) === "filter") {
24846
24965
  handleFilter(query);
24847
24966
  } else {
24848
- goToResults({ searchText: query });
24967
+ paramsStore.goToResults({ searchText: query.value });
24849
24968
  }
24850
24969
  };
24851
24970
  const handleFilter = (query) => {
24852
- var _a, _b;
24853
- const facet = (_b = (_a = searchResult.value) == null ? void 0 : _a.facets) == null ? void 0 : _b.find(
24854
- (facet2) => {
24855
- var _a2, _b2;
24856
- return facet2.key === ((_b2 = (_a2 = props.options) == null ? void 0 : _a2.source) == null ? void 0 : _b2.key);
24857
- }
24858
- );
24859
- if (!facet || facet.type !== "terms") {
24860
- return [];
24861
- }
24971
+ var _a;
24862
24972
  toggleTermFilter(
24863
24973
  paramsStore.appendParams,
24864
- { type: "terms", key: facet.key, value: query },
24974
+ { type: "terms", key: query.key, value: query.value },
24865
24975
  optionsStore.getQueryParamName,
24866
- {}
24976
+ {},
24977
+ (_a = querySources.value) == null ? void 0 : _a.map((q) => `f.${q}`)
24867
24978
  );
24868
24979
  };
24869
24980
  const getSelectedFilterClass = (query) => {
@@ -24871,9 +24982,13 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
24871
24982
  if (((_a = props.options.source) == null ? void 0 : _a.mode) !== "filter") {
24872
24983
  return "";
24873
24984
  }
24874
- return Array.isArray((_c = (_b = searchResult.value) == null ? void 0 : _b.filters) == null ? void 0 : _c[props.options.source.key]) && ((_f = (_e = (_d = searchResult.value) == null ? void 0 : _d.filters) == null ? void 0 : _e[props.options.source.key]) == null ? void 0 : _f.includes(
24875
- query
24876
- )) ? "lupa-selected-related-query-filter" : "";
24985
+ return Array.isArray((_c = (_b = searchResult.value) == null ? void 0 : _b.filters) == null ? void 0 : _c[query.key]) && ((_f = (_e = (_d = searchResult.value) == null ? void 0 : _d.filters) == null ? void 0 : _e[query.key]) == null ? void 0 : _f.includes(query.value)) ? "lupa-selected-related-query-filter" : "";
24986
+ };
24987
+ const processLoadedItem = (query, item) => {
24988
+ if (item) {
24989
+ allDisplayItems.value[`${item.id}`] = item;
24990
+ }
24991
+ querySourceResultMap.value[query.value] = Boolean(item);
24877
24992
  };
24878
24993
  return (_ctx, _cache) => {
24879
24994
  var _a, _b, _c, _d;
@@ -24881,19 +24996,24 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
24881
24996
  ((_b = (_a = _ctx.options) == null ? void 0 : _a.labels) == null ? void 0 : _b.title) ? (openBlock(), createElementBlock("h3", _hoisted_2$d, toDisplayString((_d = (_c = _ctx.options) == null ? void 0 : _c.labels) == null ? void 0 : _d.title), 1)) : createCommentVNode("", true),
24882
24997
  createBaseVNode("ul", null, [
24883
24998
  (openBlock(true), createElementBlock(Fragment, null, renderList(relatedQueries.value, (query) => {
24884
- return openBlock(), createElementBlock("li", {
24885
- key: query + currentSearchText.value,
24999
+ return withDirectives((openBlock(), createElementBlock("li", {
25000
+ key: query.value + query.key + currentSearchText.value,
24886
25001
  class: normalizeClass(getSelectedFilterClass(query))
24887
25002
  }, [
24888
25003
  createBaseVNode("a", {
24889
25004
  onClick: ($event) => handleRelatedQueryClick(query)
24890
25005
  }, [
24891
25006
  createVNode(_sfc_main$j, {
25007
+ "source-key": query.key,
24892
25008
  options: _ctx.options,
24893
- query
24894
- }, null, 8, ["options", "query"])
25009
+ query: query.value,
25010
+ "existing-items-from-other-queries": allDisplayItems.value,
25011
+ onLoaded: (item) => processLoadedItem(query, item)
25012
+ }, null, 8, ["source-key", "options", "query", "existing-items-from-other-queries", "onLoaded"])
24895
25013
  ], 8, _hoisted_3$9)
24896
- ], 2);
25014
+ ], 2)), [
25015
+ [vShow, querySourceResultMap.value[query.value] !== false]
25016
+ ]);
24897
25017
  }), 128))
24898
25018
  ])
24899
25019
  ])) : createCommentVNode("", true);