@getlupa/client 1.4.1 → 1.4.3

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.
@@ -7679,7 +7679,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7679
7679
  const _hoisted_1$1b = { id: "lupa-search-box-input-container" };
7680
7680
  const _hoisted_2$O = { class: "lupa-input-clear" };
7681
7681
  const _hoisted_3$A = { id: "lupa-search-box-input" };
7682
- const _hoisted_4$r = ["value"];
7682
+ const _hoisted_4$q = ["value"];
7683
7683
  const _hoisted_5$f = ["placeholder"];
7684
7684
  const _hoisted_6$8 = {
7685
7685
  key: 0,
@@ -7774,7 +7774,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7774
7774
  class: "lupa-hint",
7775
7775
  value: showHint.value ? suggestedValue.value.item.suggestion : "",
7776
7776
  disabled: ""
7777
- }, null, 8, _hoisted_4$r),
7777
+ }, null, 8, _hoisted_4$q),
7778
7778
  withDirectives(createBaseVNode("input", mergeProps({
7779
7779
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event)
7780
7780
  }, inputAttributes.value, {
@@ -7953,7 +7953,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7953
7953
  class: "lupa-suggestion-facet",
7954
7954
  "data-cy": "lupa-suggestion-facet"
7955
7955
  };
7956
- const _hoisted_4$q = {
7956
+ const _hoisted_4$p = {
7957
7957
  class: "lupa-suggestion-facet-label",
7958
7958
  "data-cy": "lupa-suggestion-facet-label"
7959
7959
  };
@@ -7999,7 +7999,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7999
7999
  innerHTML: _ctx.suggestion.displayHighlight
8000
8000
  }, null, 8, _hoisted_1$17)) : (openBlock(), createElementBlock("div", _hoisted_2$M, toDisplayString(_ctx.suggestion.display), 1)),
8001
8001
  _ctx.suggestion.facet ? (openBlock(), createElementBlock("div", _hoisted_3$z, [
8002
- createBaseVNode("span", _hoisted_4$q, toDisplayString(facetLabel.value), 1),
8002
+ createBaseVNode("span", _hoisted_4$p, toDisplayString(facetLabel.value), 1),
8003
8003
  createBaseVNode("span", _hoisted_5$e, toDisplayString(_ctx.suggestion.facet.title), 1)
8004
8004
  ])) : createCommentVNode("", true)
8005
8005
  ]);
@@ -8401,7 +8401,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8401
8401
  const _hoisted_1$10 = ["innerHTML"];
8402
8402
  const _hoisted_2$J = { key: 0 };
8403
8403
  const _hoisted_3$y = { key: 1 };
8404
- const _hoisted_4$p = { class: "lupa-search-box-custom-label" };
8404
+ const _hoisted_4$o = { class: "lupa-search-box-custom-label" };
8405
8405
  const _hoisted_5$d = { class: "lupa-search-box-custom-text" };
8406
8406
  const _sfc_main$15 = /* @__PURE__ */ defineComponent({
8407
8407
  __name: "SearchBoxProductCustom",
@@ -8434,7 +8434,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8434
8434
  class: [className.value, "lupa-search-box-product-custom"]
8435
8435
  }, toHandlers(_ctx.options.action ? { click: handleClick } : {}, true)), [
8436
8436
  !label.value ? (openBlock(), createElementBlock("div", _hoisted_2$J, toDisplayString(text.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$y, [
8437
- createBaseVNode("div", _hoisted_4$p, toDisplayString(label.value), 1),
8437
+ createBaseVNode("div", _hoisted_4$o, toDisplayString(label.value), 1),
8438
8438
  createBaseVNode("div", _hoisted_5$d, toDisplayString(text.value), 1)
8439
8439
  ]))
8440
8440
  ], 16));
@@ -8830,7 +8830,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8830
8830
  const _hoisted_1$Z = ["href"];
8831
8831
  const _hoisted_2$H = { class: "lupa-search-box-product-image-section" };
8832
8832
  const _hoisted_3$w = { class: "lupa-search-box-product-details-section" };
8833
- const _hoisted_4$o = {
8833
+ const _hoisted_4$n = {
8834
8834
  key: 0,
8835
8835
  class: "lupa-search-box-product-add-to-cart-section"
8836
8836
  };
@@ -8951,7 +8951,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8951
8951
  }, null, 8, ["item", "element", "labels", "link"]);
8952
8952
  }), 128))
8953
8953
  ]),
8954
- addToCartElement.value ? (openBlock(), createElementBlock("div", _hoisted_4$o, [
8954
+ addToCartElement.value ? (openBlock(), createElementBlock("div", _hoisted_4$n, [
8955
8955
  createVNode(_sfc_main$12, {
8956
8956
  class: "lupa-search-box-product-element",
8957
8957
  item: _ctx.item,
@@ -9086,12 +9086,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9086
9086
  key: 0,
9087
9087
  id: "lupa-search-box-panel"
9088
9088
  };
9089
- const _hoisted_2$G = {
9090
- class: "lupa-main-panel",
9091
- "data-cy": "lupa-main-panel"
9092
- };
9093
- const _hoisted_3$v = ["data-cy"];
9094
- const _hoisted_4$n = {
9089
+ const _hoisted_2$G = ["data-cy"];
9090
+ const _hoisted_3$v = {
9095
9091
  key: 1,
9096
9092
  id: "lupa-search-box-panel"
9097
9093
  };
@@ -9128,7 +9124,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9128
9124
  const panels = computed(() => props.options.panels);
9129
9125
  const sdkOptions = computed(() => props.options.options);
9130
9126
  const searchBoxStore = useSearchBoxStore();
9131
- const { suggestionResults, hasAnyResults } = storeToRefs(searchBoxStore);
9127
+ const { suggestionResults, hasAnyResults, panelItemCounts } = storeToRefs(searchBoxStore);
9132
9128
  const displayResults = computed(
9133
9129
  () => {
9134
9130
  var _a, _b;
@@ -9209,6 +9205,12 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9209
9205
  `${window.innerHeight - panel.getBoundingClientRect().y - 10}px`
9210
9206
  );
9211
9207
  };
9208
+ const numberOfVisiblePanels = computed(() => {
9209
+ return panelItemCounts.value.filter((v) => v.count > 0).length;
9210
+ });
9211
+ const expandOnSinglePanel = computed(() => {
9212
+ return numberOfVisiblePanels.value === 1 && props.options.expandOnSinglePanel;
9213
+ });
9212
9214
  return (_ctx, _cache) => {
9213
9215
  var _a;
9214
9216
  return openBlock(), createElementBlock("div", {
@@ -9216,7 +9218,11 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9216
9218
  ref: panelContainer
9217
9219
  }, [
9218
9220
  displayResults.value ? (openBlock(), createElementBlock("div", _hoisted_1$X, [
9219
- createBaseVNode("div", _hoisted_2$G, [
9221
+ createBaseVNode("div", {
9222
+ class: "lupa-main-panel",
9223
+ style: normalizeStyle(expandOnSinglePanel.value ? { display: "block" } : {}),
9224
+ "data-cy": "lupa-main-panel"
9225
+ }, [
9220
9226
  (openBlock(true), createElementBlock(Fragment, null, renderList(displayPanels.value, (panel, index) => {
9221
9227
  return openBlock(), createElementBlock("div", {
9222
9228
  key: index,
@@ -9245,9 +9251,9 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9245
9251
  key: "0"
9246
9252
  } : void 0
9247
9253
  ]), 1064, ["panel", "options", "debounce", "inputValue", "labels"])) : createCommentVNode("", true)
9248
- ], 10, _hoisted_3$v);
9254
+ ], 10, _hoisted_2$G);
9249
9255
  }), 128))
9250
- ]),
9256
+ ], 4),
9251
9257
  !unref(hasAnyResults) && _ctx.options.showNoResultsPanel ? (openBlock(), createBlock(_sfc_main$1f, {
9252
9258
  key: 0,
9253
9259
  labels: labels.value
@@ -9258,7 +9264,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9258
9264
  showTotalCount: (_a = _ctx.options.showTotalCount) != null ? _a : false,
9259
9265
  onGoToResults: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("go-to-results"))
9260
9266
  }, null, 8, ["labels", "showTotalCount"])) : createCommentVNode("", true)
9261
- ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_4$n, [
9267
+ ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_3$v, [
9262
9268
  createVNode(_sfc_main$1g, {
9263
9269
  options: _ctx.options.history,
9264
9270
  history: history.value,
@@ -9327,7 +9333,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9327
9333
  "debounce",
9328
9334
  "showTotalCount",
9329
9335
  "hideMoreResultsButtonOnNoResults",
9330
- "showNoResultsPanel"
9336
+ "showNoResultsPanel",
9337
+ "expandOnSinglePanel"
9331
9338
  ])
9332
9339
  );
9333
9340
  const searchTriggers = computed(() => {
@@ -13996,8 +14003,14 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
13996
14003
  const isTitleResultTopPosition = computed(() => {
13997
14004
  return props.options.searchTitlePosition === "search-results-top";
13998
14005
  });
14006
+ const handlePopState = () => {
14007
+ var _a;
14008
+ const searchParams = getSearchParams((_a = props.options.ssr) == null ? void 0 : _a.url);
14009
+ paramStore.add(parseParams(searchParams));
14010
+ };
13999
14011
  onMounted(() => {
14000
14012
  var _a, _b;
14013
+ window.addEventListener("popstate", handlePopState);
14001
14014
  window.addEventListener("resize", handleResize);
14002
14015
  if (props.initialData) {
14003
14016
  searchResultStore.add(__spreadValues2({}, props.initialData));
@@ -14008,6 +14021,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
14008
14021
  });
14009
14022
  onBeforeUnmount(() => {
14010
14023
  window.removeEventListener("resize", handleResize);
14024
+ window.removeEventListener("popstate", handlePopState);
14011
14025
  });
14012
14026
  const trackItemListView = (title, items = []) => {
14013
14027
  trackingStore.trackEvent({
@@ -20755,11 +20769,12 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20755
20769
  }
20756
20770
  return Env[environment] || Env["production"];
20757
20771
  };
20758
- const suggestSearchChatPhrases = (options, request) => __async(void 0, null, function* () {
20772
+ const suggestSearchChatPhrases = (options, request, chatSettings) => __async(void 0, null, function* () {
20759
20773
  var _a, _b, _c;
20760
20774
  const { environment, customBaseUrl } = options;
20775
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20761
20776
  try {
20762
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20777
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20763
20778
  body: JSON.stringify(request),
20764
20779
  headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20765
20780
  }));
@@ -20775,14 +20790,18 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20775
20790
  return { success: false, errors: [e] };
20776
20791
  }
20777
20792
  });
20778
- const suggestPhraseAlternatives = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
20793
+ const suggestPhraseAlternatives = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, { phrases }, chatSettings) {
20779
20794
  var _a, _b, _c;
20780
20795
  const { environment, customBaseUrl } = options;
20796
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20781
20797
  try {
20782
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20783
- body: JSON.stringify({ phrases }),
20784
- headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20785
- }));
20798
+ const res = yield fetch(
20799
+ `${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives${model}`,
20800
+ __spreadProps2(__spreadValues2({}, defaultConfig), {
20801
+ body: JSON.stringify({ phrases }),
20802
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20803
+ })
20804
+ );
20786
20805
  if (res.status < 400) {
20787
20806
  const data = yield res.json();
20788
20807
  return __spreadProps2(__spreadValues2({}, data), { success: true });
@@ -20795,11 +20814,12 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20795
20814
  return { success: false, errors: [e] };
20796
20815
  }
20797
20816
  });
20798
- const suggestSimplifiedPhrases = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
20817
+ const suggestSimplifiedPhrases = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, { phrases }, chatSettings) {
20799
20818
  var _a, _b, _c;
20800
20819
  const { environment, customBaseUrl } = options;
20820
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20801
20821
  try {
20802
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20822
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20803
20823
  body: JSON.stringify({ phrases }),
20804
20824
  headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20805
20825
  }));
@@ -20815,15 +20835,16 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20815
20835
  return { success: false, errors: [e] };
20816
20836
  }
20817
20837
  });
20818
- const suggestBestProductMatches = (_0, _1) => __async(void 0, [_0, _1], function* (options, {
20838
+ const suggestBestProductMatches = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, {
20819
20839
  initialQuery,
20820
20840
  productStrings,
20821
20841
  messageHistory
20822
- }) {
20842
+ }, chatSettings) {
20823
20843
  var _a, _b, _c;
20824
20844
  const { environment, customBaseUrl } = options;
20845
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20825
20846
  try {
20826
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20847
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20827
20848
  body: JSON.stringify({ initialQuery, messageHistory, productStrings }),
20828
20849
  headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20829
20850
  }));
@@ -20860,9 +20881,10 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20860
20881
  }
20861
20882
  return history;
20862
20883
  };
20863
- const getTextResponseChunkStream = (options, { initialQuery, messageHistory }, onChunkReceived) => {
20884
+ const getTextResponseChunkStream = (options, { initialQuery, messageHistory }, onChunkReceived, chatSettings) => {
20864
20885
  var _a;
20865
- fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20886
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20887
+ fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20866
20888
  body: JSON.stringify({ initialQuery, messageHistory }),
20867
20889
  headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20868
20890
  })).then((response) => {
@@ -21002,9 +21024,13 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21002
21024
  return result.items;
21003
21025
  });
21004
21026
  const getPhraseAlternatives = () => __async(this, null, function* () {
21005
- const { phrases } = yield ChatService.suggestPhraseAlternatives(props.options.sdkOptions, {
21006
- phrases: [props.phrase]
21007
- });
21027
+ const { phrases } = yield ChatService.suggestPhraseAlternatives(
21028
+ props.options.sdkOptions,
21029
+ {
21030
+ phrases: [props.phrase]
21031
+ },
21032
+ props.options.chatSettings
21033
+ );
21008
21034
  return phrases != null ? phrases : [];
21009
21035
  });
21010
21036
  return (_ctx, _cache) => {
@@ -21069,11 +21095,15 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21069
21095
  return (_b = (_a2 = result[titleKey.value]) == null ? void 0 : _a2.toString()) != null ? _b : "";
21070
21096
  }
21071
21097
  );
21072
- const { products } = yield ChatService.suggestBestProductMatches(props.options.sdkOptions, {
21073
- initialQuery: props.entry.userInput,
21074
- productStrings: productResultStrings,
21075
- messageHistory: (_a = props.history) != null ? _a : []
21076
- });
21098
+ const { products } = yield ChatService.suggestBestProductMatches(
21099
+ props.options.sdkOptions,
21100
+ {
21101
+ initialQuery: props.entry.userInput,
21102
+ productStrings: productResultStrings,
21103
+ messageHistory: (_a = props.history) != null ? _a : []
21104
+ },
21105
+ props.options.chatSettings
21106
+ );
21077
21107
  bestMatches.value = products;
21078
21108
  emit2("loaded", products);
21079
21109
  } finally {
@@ -21146,7 +21176,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21146
21176
  initialQuery: props.content,
21147
21177
  messageHistory: (_a = props.history) != null ? _a : []
21148
21178
  },
21149
- processChunk
21179
+ processChunk,
21180
+ props.options.chatSettings
21150
21181
  );
21151
21182
  });
21152
21183
  return (_ctx, _cache) => {
@@ -21243,7 +21274,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21243
21274
  };
21244
21275
  const { phrases, success } = yield ChatService.suggestSearchChatPhrases(
21245
21276
  props.options.sdkOptions,
21246
- request
21277
+ request,
21278
+ props.options.chatSettings
21247
21279
  );
21248
21280
  if (!success || !phrases.length) {
21249
21281
  error.value = "Something went wrong";
@@ -7679,7 +7679,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
7679
7679
  const _hoisted_1$1b = { id: "lupa-search-box-input-container" };
7680
7680
  const _hoisted_2$O = { class: "lupa-input-clear" };
7681
7681
  const _hoisted_3$A = { id: "lupa-search-box-input" };
7682
- const _hoisted_4$r = ["value"];
7682
+ const _hoisted_4$q = ["value"];
7683
7683
  const _hoisted_5$f = ["placeholder"];
7684
7684
  const _hoisted_6$8 = {
7685
7685
  key: 0,
@@ -7774,7 +7774,7 @@ const _sfc_main$1j = /* @__PURE__ */ defineComponent({
7774
7774
  class: "lupa-hint",
7775
7775
  value: showHint.value ? suggestedValue.value.item.suggestion : "",
7776
7776
  disabled: ""
7777
- }, null, 8, _hoisted_4$r),
7777
+ }, null, 8, _hoisted_4$q),
7778
7778
  withDirectives(createBaseVNode("input", mergeProps({
7779
7779
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event)
7780
7780
  }, inputAttributes.value, {
@@ -7953,7 +7953,7 @@ const _hoisted_3$z = {
7953
7953
  class: "lupa-suggestion-facet",
7954
7954
  "data-cy": "lupa-suggestion-facet"
7955
7955
  };
7956
- const _hoisted_4$q = {
7956
+ const _hoisted_4$p = {
7957
7957
  class: "lupa-suggestion-facet-label",
7958
7958
  "data-cy": "lupa-suggestion-facet-label"
7959
7959
  };
@@ -7999,7 +7999,7 @@ const _sfc_main$1e = /* @__PURE__ */ defineComponent({
7999
7999
  innerHTML: _ctx.suggestion.displayHighlight
8000
8000
  }, null, 8, _hoisted_1$17)) : (openBlock(), createElementBlock("div", _hoisted_2$M, toDisplayString(_ctx.suggestion.display), 1)),
8001
8001
  _ctx.suggestion.facet ? (openBlock(), createElementBlock("div", _hoisted_3$z, [
8002
- createBaseVNode("span", _hoisted_4$q, toDisplayString(facetLabel.value), 1),
8002
+ createBaseVNode("span", _hoisted_4$p, toDisplayString(facetLabel.value), 1),
8003
8003
  createBaseVNode("span", _hoisted_5$e, toDisplayString(_ctx.suggestion.facet.title), 1)
8004
8004
  ])) : createCommentVNode("", true)
8005
8005
  ]);
@@ -8401,7 +8401,7 @@ const _sfc_main$16 = /* @__PURE__ */ defineComponent({
8401
8401
  const _hoisted_1$10 = ["innerHTML"];
8402
8402
  const _hoisted_2$J = { key: 0 };
8403
8403
  const _hoisted_3$y = { key: 1 };
8404
- const _hoisted_4$p = { class: "lupa-search-box-custom-label" };
8404
+ const _hoisted_4$o = { class: "lupa-search-box-custom-label" };
8405
8405
  const _hoisted_5$d = { class: "lupa-search-box-custom-text" };
8406
8406
  const _sfc_main$15 = /* @__PURE__ */ defineComponent({
8407
8407
  __name: "SearchBoxProductCustom",
@@ -8434,7 +8434,7 @@ const _sfc_main$15 = /* @__PURE__ */ defineComponent({
8434
8434
  class: [className.value, "lupa-search-box-product-custom"]
8435
8435
  }, toHandlers(_ctx.options.action ? { click: handleClick } : {}, true)), [
8436
8436
  !label.value ? (openBlock(), createElementBlock("div", _hoisted_2$J, toDisplayString(text.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$y, [
8437
- createBaseVNode("div", _hoisted_4$p, toDisplayString(label.value), 1),
8437
+ createBaseVNode("div", _hoisted_4$o, toDisplayString(label.value), 1),
8438
8438
  createBaseVNode("div", _hoisted_5$d, toDisplayString(text.value), 1)
8439
8439
  ]))
8440
8440
  ], 16));
@@ -8830,7 +8830,7 @@ const useTrackingStore = defineStore("tracking", () => {
8830
8830
  const _hoisted_1$Z = ["href"];
8831
8831
  const _hoisted_2$H = { class: "lupa-search-box-product-image-section" };
8832
8832
  const _hoisted_3$w = { class: "lupa-search-box-product-details-section" };
8833
- const _hoisted_4$o = {
8833
+ const _hoisted_4$n = {
8834
8834
  key: 0,
8835
8835
  class: "lupa-search-box-product-add-to-cart-section"
8836
8836
  };
@@ -8951,7 +8951,7 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent({
8951
8951
  }, null, 8, ["item", "element", "labels", "link"]);
8952
8952
  }), 128))
8953
8953
  ]),
8954
- addToCartElement.value ? (openBlock(), createElementBlock("div", _hoisted_4$o, [
8954
+ addToCartElement.value ? (openBlock(), createElementBlock("div", _hoisted_4$n, [
8955
8955
  createVNode(_sfc_main$12, {
8956
8956
  class: "lupa-search-box-product-element",
8957
8957
  item: _ctx.item,
@@ -9086,12 +9086,8 @@ const _hoisted_1$X = {
9086
9086
  key: 0,
9087
9087
  id: "lupa-search-box-panel"
9088
9088
  };
9089
- const _hoisted_2$G = {
9090
- class: "lupa-main-panel",
9091
- "data-cy": "lupa-main-panel"
9092
- };
9093
- const _hoisted_3$v = ["data-cy"];
9094
- const _hoisted_4$n = {
9089
+ const _hoisted_2$G = ["data-cy"];
9090
+ const _hoisted_3$v = {
9095
9091
  key: 1,
9096
9092
  id: "lupa-search-box-panel"
9097
9093
  };
@@ -9128,7 +9124,7 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9128
9124
  const panels = computed(() => props.options.panels);
9129
9125
  const sdkOptions = computed(() => props.options.options);
9130
9126
  const searchBoxStore = useSearchBoxStore();
9131
- const { suggestionResults, hasAnyResults } = storeToRefs(searchBoxStore);
9127
+ const { suggestionResults, hasAnyResults, panelItemCounts } = storeToRefs(searchBoxStore);
9132
9128
  const displayResults = computed(
9133
9129
  () => {
9134
9130
  var _a, _b;
@@ -9209,6 +9205,12 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9209
9205
  `${window.innerHeight - panel.getBoundingClientRect().y - 10}px`
9210
9206
  );
9211
9207
  };
9208
+ const numberOfVisiblePanels = computed(() => {
9209
+ return panelItemCounts.value.filter((v) => v.count > 0).length;
9210
+ });
9211
+ const expandOnSinglePanel = computed(() => {
9212
+ return numberOfVisiblePanels.value === 1 && props.options.expandOnSinglePanel;
9213
+ });
9212
9214
  return (_ctx, _cache) => {
9213
9215
  var _a;
9214
9216
  return openBlock(), createElementBlock("div", {
@@ -9216,7 +9218,11 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9216
9218
  ref: panelContainer
9217
9219
  }, [
9218
9220
  displayResults.value ? (openBlock(), createElementBlock("div", _hoisted_1$X, [
9219
- createBaseVNode("div", _hoisted_2$G, [
9221
+ createBaseVNode("div", {
9222
+ class: "lupa-main-panel",
9223
+ style: normalizeStyle(expandOnSinglePanel.value ? { display: "block" } : {}),
9224
+ "data-cy": "lupa-main-panel"
9225
+ }, [
9220
9226
  (openBlock(true), createElementBlock(Fragment, null, renderList(displayPanels.value, (panel, index) => {
9221
9227
  return openBlock(), createElementBlock("div", {
9222
9228
  key: index,
@@ -9245,9 +9251,9 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9245
9251
  key: "0"
9246
9252
  } : void 0
9247
9253
  ]), 1064, ["panel", "options", "debounce", "inputValue", "labels"])) : createCommentVNode("", true)
9248
- ], 10, _hoisted_3$v);
9254
+ ], 10, _hoisted_2$G);
9249
9255
  }), 128))
9250
- ]),
9256
+ ], 4),
9251
9257
  !unref(hasAnyResults) && _ctx.options.showNoResultsPanel ? (openBlock(), createBlock(_sfc_main$1f, {
9252
9258
  key: 0,
9253
9259
  labels: labels.value
@@ -9258,7 +9264,7 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9258
9264
  showTotalCount: (_a = _ctx.options.showTotalCount) != null ? _a : false,
9259
9265
  onGoToResults: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("go-to-results"))
9260
9266
  }, null, 8, ["labels", "showTotalCount"])) : createCommentVNode("", true)
9261
- ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_4$n, [
9267
+ ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_3$v, [
9262
9268
  createVNode(_sfc_main$1g, {
9263
9269
  options: _ctx.options.history,
9264
9270
  history: history.value,
@@ -9327,7 +9333,8 @@ const _sfc_main$Z = /* @__PURE__ */ defineComponent({
9327
9333
  "debounce",
9328
9334
  "showTotalCount",
9329
9335
  "hideMoreResultsButtonOnNoResults",
9330
- "showNoResultsPanel"
9336
+ "showNoResultsPanel",
9337
+ "expandOnSinglePanel"
9331
9338
  ])
9332
9339
  );
9333
9340
  const searchTriggers = computed(() => {
@@ -13996,8 +14003,14 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
13996
14003
  const isTitleResultTopPosition = computed(() => {
13997
14004
  return props.options.searchTitlePosition === "search-results-top";
13998
14005
  });
14006
+ const handlePopState = () => {
14007
+ var _a;
14008
+ const searchParams = getSearchParams((_a = props.options.ssr) == null ? void 0 : _a.url);
14009
+ paramStore.add(parseParams(searchParams));
14010
+ };
13999
14011
  onMounted(() => {
14000
14012
  var _a, _b;
14013
+ window.addEventListener("popstate", handlePopState);
14001
14014
  window.addEventListener("resize", handleResize);
14002
14015
  if (props.initialData) {
14003
14016
  searchResultStore.add(__spreadValues2({}, props.initialData));
@@ -14008,6 +14021,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
14008
14021
  });
14009
14022
  onBeforeUnmount(() => {
14010
14023
  window.removeEventListener("resize", handleResize);
14024
+ window.removeEventListener("popstate", handlePopState);
14011
14025
  });
14012
14026
  const trackItemListView = (title, items = []) => {
14013
14027
  trackingStore.trackEvent({
@@ -20755,11 +20769,12 @@ const getApiUrl = (environment, customBaseUrl) => {
20755
20769
  }
20756
20770
  return Env[environment] || Env["production"];
20757
20771
  };
20758
- const suggestSearchChatPhrases = (options, request) => __async(void 0, null, function* () {
20772
+ const suggestSearchChatPhrases = (options, request, chatSettings) => __async(void 0, null, function* () {
20759
20773
  var _a, _b, _c;
20760
20774
  const { environment, customBaseUrl } = options;
20775
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20761
20776
  try {
20762
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20777
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20763
20778
  body: JSON.stringify(request),
20764
20779
  headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20765
20780
  }));
@@ -20775,14 +20790,18 @@ const suggestSearchChatPhrases = (options, request) => __async(void 0, null, fun
20775
20790
  return { success: false, errors: [e] };
20776
20791
  }
20777
20792
  });
20778
- const suggestPhraseAlternatives = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
20793
+ const suggestPhraseAlternatives = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, { phrases }, chatSettings) {
20779
20794
  var _a, _b, _c;
20780
20795
  const { environment, customBaseUrl } = options;
20796
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20781
20797
  try {
20782
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20783
- body: JSON.stringify({ phrases }),
20784
- headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20785
- }));
20798
+ const res = yield fetch(
20799
+ `${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives${model}`,
20800
+ __spreadProps2(__spreadValues2({}, defaultConfig), {
20801
+ body: JSON.stringify({ phrases }),
20802
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20803
+ })
20804
+ );
20786
20805
  if (res.status < 400) {
20787
20806
  const data = yield res.json();
20788
20807
  return __spreadProps2(__spreadValues2({}, data), { success: true });
@@ -20795,11 +20814,12 @@ const suggestPhraseAlternatives = (_0, _1) => __async(void 0, [_0, _1], function
20795
20814
  return { success: false, errors: [e] };
20796
20815
  }
20797
20816
  });
20798
- const suggestSimplifiedPhrases = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
20817
+ const suggestSimplifiedPhrases = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, { phrases }, chatSettings) {
20799
20818
  var _a, _b, _c;
20800
20819
  const { environment, customBaseUrl } = options;
20820
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20801
20821
  try {
20802
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20822
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20803
20823
  body: JSON.stringify({ phrases }),
20804
20824
  headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20805
20825
  }));
@@ -20815,15 +20835,16 @@ const suggestSimplifiedPhrases = (_0, _1) => __async(void 0, [_0, _1], function*
20815
20835
  return { success: false, errors: [e] };
20816
20836
  }
20817
20837
  });
20818
- const suggestBestProductMatches = (_0, _1) => __async(void 0, [_0, _1], function* (options, {
20838
+ const suggestBestProductMatches = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, {
20819
20839
  initialQuery,
20820
20840
  productStrings,
20821
20841
  messageHistory
20822
- }) {
20842
+ }, chatSettings) {
20823
20843
  var _a, _b, _c;
20824
20844
  const { environment, customBaseUrl } = options;
20845
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20825
20846
  try {
20826
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20847
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20827
20848
  body: JSON.stringify({ initialQuery, messageHistory, productStrings }),
20828
20849
  headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20829
20850
  }));
@@ -20860,9 +20881,10 @@ const prepareChatHistory = (chatLog) => {
20860
20881
  }
20861
20882
  return history;
20862
20883
  };
20863
- const getTextResponseChunkStream = (options, { initialQuery, messageHistory }, onChunkReceived) => {
20884
+ const getTextResponseChunkStream = (options, { initialQuery, messageHistory }, onChunkReceived, chatSettings) => {
20864
20885
  var _a;
20865
- fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20886
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20887
+ fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20866
20888
  body: JSON.stringify({ initialQuery, messageHistory }),
20867
20889
  headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20868
20890
  })).then((response) => {
@@ -21002,9 +21024,13 @@ const _sfc_main$4$1 = /* @__PURE__ */ defineComponent({
21002
21024
  return result.items;
21003
21025
  });
21004
21026
  const getPhraseAlternatives = () => __async(this, null, function* () {
21005
- const { phrases } = yield ChatService.suggestPhraseAlternatives(props.options.sdkOptions, {
21006
- phrases: [props.phrase]
21007
- });
21027
+ const { phrases } = yield ChatService.suggestPhraseAlternatives(
21028
+ props.options.sdkOptions,
21029
+ {
21030
+ phrases: [props.phrase]
21031
+ },
21032
+ props.options.chatSettings
21033
+ );
21008
21034
  return phrases != null ? phrases : [];
21009
21035
  });
21010
21036
  return (_ctx, _cache) => {
@@ -21069,11 +21095,15 @@ const _sfc_main$3$1 = /* @__PURE__ */ defineComponent({
21069
21095
  return (_b = (_a2 = result[titleKey.value]) == null ? void 0 : _a2.toString()) != null ? _b : "";
21070
21096
  }
21071
21097
  );
21072
- const { products } = yield ChatService.suggestBestProductMatches(props.options.sdkOptions, {
21073
- initialQuery: props.entry.userInput,
21074
- productStrings: productResultStrings,
21075
- messageHistory: (_a = props.history) != null ? _a : []
21076
- });
21098
+ const { products } = yield ChatService.suggestBestProductMatches(
21099
+ props.options.sdkOptions,
21100
+ {
21101
+ initialQuery: props.entry.userInput,
21102
+ productStrings: productResultStrings,
21103
+ messageHistory: (_a = props.history) != null ? _a : []
21104
+ },
21105
+ props.options.chatSettings
21106
+ );
21077
21107
  bestMatches.value = products;
21078
21108
  emit2("loaded", products);
21079
21109
  } finally {
@@ -21146,7 +21176,8 @@ const _sfc_main$2$1 = /* @__PURE__ */ defineComponent({
21146
21176
  initialQuery: props.content,
21147
21177
  messageHistory: (_a = props.history) != null ? _a : []
21148
21178
  },
21149
- processChunk
21179
+ processChunk,
21180
+ props.options.chatSettings
21150
21181
  );
21151
21182
  });
21152
21183
  return (_ctx, _cache) => {
@@ -21243,7 +21274,8 @@ const _sfc_main$1k = /* @__PURE__ */ defineComponent({
21243
21274
  };
21244
21275
  const { phrases, success } = yield ChatService.suggestSearchChatPhrases(
21245
21276
  props.options.sdkOptions,
21246
- request
21277
+ request,
21278
+ props.options.chatSettings
21247
21279
  );
21248
21280
  if (!success || !phrases.length) {
21249
21281
  error.value = "Something went wrong";
@@ -7677,7 +7677,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
7677
7677
  const _hoisted_1$1b = { id: "lupa-search-box-input-container" };
7678
7678
  const _hoisted_2$O = { class: "lupa-input-clear" };
7679
7679
  const _hoisted_3$A = { id: "lupa-search-box-input" };
7680
- const _hoisted_4$r = ["value"];
7680
+ const _hoisted_4$q = ["value"];
7681
7681
  const _hoisted_5$f = ["placeholder"];
7682
7682
  const _hoisted_6$8 = {
7683
7683
  key: 0,
@@ -7772,7 +7772,7 @@ const _sfc_main$1j = /* @__PURE__ */ defineComponent({
7772
7772
  class: "lupa-hint",
7773
7773
  value: showHint.value ? suggestedValue.value.item.suggestion : "",
7774
7774
  disabled: ""
7775
- }, null, 8, _hoisted_4$r),
7775
+ }, null, 8, _hoisted_4$q),
7776
7776
  withDirectives(createBaseVNode("input", mergeProps({
7777
7777
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event)
7778
7778
  }, inputAttributes.value, {
@@ -7951,7 +7951,7 @@ const _hoisted_3$z = {
7951
7951
  class: "lupa-suggestion-facet",
7952
7952
  "data-cy": "lupa-suggestion-facet"
7953
7953
  };
7954
- const _hoisted_4$q = {
7954
+ const _hoisted_4$p = {
7955
7955
  class: "lupa-suggestion-facet-label",
7956
7956
  "data-cy": "lupa-suggestion-facet-label"
7957
7957
  };
@@ -7997,7 +7997,7 @@ const _sfc_main$1e = /* @__PURE__ */ defineComponent({
7997
7997
  innerHTML: _ctx.suggestion.displayHighlight
7998
7998
  }, null, 8, _hoisted_1$17)) : (openBlock(), createElementBlock("div", _hoisted_2$M, toDisplayString(_ctx.suggestion.display), 1)),
7999
7999
  _ctx.suggestion.facet ? (openBlock(), createElementBlock("div", _hoisted_3$z, [
8000
- createBaseVNode("span", _hoisted_4$q, toDisplayString(facetLabel.value), 1),
8000
+ createBaseVNode("span", _hoisted_4$p, toDisplayString(facetLabel.value), 1),
8001
8001
  createBaseVNode("span", _hoisted_5$e, toDisplayString(_ctx.suggestion.facet.title), 1)
8002
8002
  ])) : createCommentVNode("", true)
8003
8003
  ]);
@@ -8399,7 +8399,7 @@ const _sfc_main$16 = /* @__PURE__ */ defineComponent({
8399
8399
  const _hoisted_1$10 = ["innerHTML"];
8400
8400
  const _hoisted_2$J = { key: 0 };
8401
8401
  const _hoisted_3$y = { key: 1 };
8402
- const _hoisted_4$p = { class: "lupa-search-box-custom-label" };
8402
+ const _hoisted_4$o = { class: "lupa-search-box-custom-label" };
8403
8403
  const _hoisted_5$d = { class: "lupa-search-box-custom-text" };
8404
8404
  const _sfc_main$15 = /* @__PURE__ */ defineComponent({
8405
8405
  __name: "SearchBoxProductCustom",
@@ -8432,7 +8432,7 @@ const _sfc_main$15 = /* @__PURE__ */ defineComponent({
8432
8432
  class: [className.value, "lupa-search-box-product-custom"]
8433
8433
  }, toHandlers(_ctx.options.action ? { click: handleClick } : {}, true)), [
8434
8434
  !label.value ? (openBlock(), createElementBlock("div", _hoisted_2$J, toDisplayString(text.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$y, [
8435
- createBaseVNode("div", _hoisted_4$p, toDisplayString(label.value), 1),
8435
+ createBaseVNode("div", _hoisted_4$o, toDisplayString(label.value), 1),
8436
8436
  createBaseVNode("div", _hoisted_5$d, toDisplayString(text.value), 1)
8437
8437
  ]))
8438
8438
  ], 16));
@@ -8828,7 +8828,7 @@ const useTrackingStore = defineStore("tracking", () => {
8828
8828
  const _hoisted_1$Z = ["href"];
8829
8829
  const _hoisted_2$H = { class: "lupa-search-box-product-image-section" };
8830
8830
  const _hoisted_3$w = { class: "lupa-search-box-product-details-section" };
8831
- const _hoisted_4$o = {
8831
+ const _hoisted_4$n = {
8832
8832
  key: 0,
8833
8833
  class: "lupa-search-box-product-add-to-cart-section"
8834
8834
  };
@@ -8949,7 +8949,7 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent({
8949
8949
  }, null, 8, ["item", "element", "labels", "link"]);
8950
8950
  }), 128))
8951
8951
  ]),
8952
- addToCartElement.value ? (openBlock(), createElementBlock("div", _hoisted_4$o, [
8952
+ addToCartElement.value ? (openBlock(), createElementBlock("div", _hoisted_4$n, [
8953
8953
  createVNode(_sfc_main$12, {
8954
8954
  class: "lupa-search-box-product-element",
8955
8955
  item: _ctx.item,
@@ -9084,12 +9084,8 @@ const _hoisted_1$X = {
9084
9084
  key: 0,
9085
9085
  id: "lupa-search-box-panel"
9086
9086
  };
9087
- const _hoisted_2$G = {
9088
- class: "lupa-main-panel",
9089
- "data-cy": "lupa-main-panel"
9090
- };
9091
- const _hoisted_3$v = ["data-cy"];
9092
- const _hoisted_4$n = {
9087
+ const _hoisted_2$G = ["data-cy"];
9088
+ const _hoisted_3$v = {
9093
9089
  key: 1,
9094
9090
  id: "lupa-search-box-panel"
9095
9091
  };
@@ -9126,7 +9122,7 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9126
9122
  const panels = computed(() => props.options.panels);
9127
9123
  const sdkOptions = computed(() => props.options.options);
9128
9124
  const searchBoxStore = useSearchBoxStore();
9129
- const { suggestionResults, hasAnyResults } = storeToRefs(searchBoxStore);
9125
+ const { suggestionResults, hasAnyResults, panelItemCounts } = storeToRefs(searchBoxStore);
9130
9126
  const displayResults = computed(
9131
9127
  () => {
9132
9128
  var _a, _b;
@@ -9207,6 +9203,12 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9207
9203
  `${window.innerHeight - panel.getBoundingClientRect().y - 10}px`
9208
9204
  );
9209
9205
  };
9206
+ const numberOfVisiblePanels = computed(() => {
9207
+ return panelItemCounts.value.filter((v) => v.count > 0).length;
9208
+ });
9209
+ const expandOnSinglePanel = computed(() => {
9210
+ return numberOfVisiblePanels.value === 1 && props.options.expandOnSinglePanel;
9211
+ });
9210
9212
  return (_ctx, _cache) => {
9211
9213
  var _a;
9212
9214
  return openBlock(), createElementBlock("div", {
@@ -9214,7 +9216,11 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9214
9216
  ref: panelContainer
9215
9217
  }, [
9216
9218
  displayResults.value ? (openBlock(), createElementBlock("div", _hoisted_1$X, [
9217
- createBaseVNode("div", _hoisted_2$G, [
9219
+ createBaseVNode("div", {
9220
+ class: "lupa-main-panel",
9221
+ style: normalizeStyle(expandOnSinglePanel.value ? { display: "block" } : {}),
9222
+ "data-cy": "lupa-main-panel"
9223
+ }, [
9218
9224
  (openBlock(true), createElementBlock(Fragment, null, renderList(displayPanels.value, (panel, index) => {
9219
9225
  return openBlock(), createElementBlock("div", {
9220
9226
  key: index,
@@ -9243,9 +9249,9 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9243
9249
  key: "0"
9244
9250
  } : void 0
9245
9251
  ]), 1064, ["panel", "options", "debounce", "inputValue", "labels"])) : createCommentVNode("", true)
9246
- ], 10, _hoisted_3$v);
9252
+ ], 10, _hoisted_2$G);
9247
9253
  }), 128))
9248
- ]),
9254
+ ], 4),
9249
9255
  !unref(hasAnyResults) && _ctx.options.showNoResultsPanel ? (openBlock(), createBlock(_sfc_main$1f, {
9250
9256
  key: 0,
9251
9257
  labels: labels.value
@@ -9256,7 +9262,7 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
9256
9262
  showTotalCount: (_a = _ctx.options.showTotalCount) != null ? _a : false,
9257
9263
  onGoToResults: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("go-to-results"))
9258
9264
  }, null, 8, ["labels", "showTotalCount"])) : createCommentVNode("", true)
9259
- ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_4$n, [
9265
+ ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_3$v, [
9260
9266
  createVNode(_sfc_main$1g, {
9261
9267
  options: _ctx.options.history,
9262
9268
  history: history.value,
@@ -9325,7 +9331,8 @@ const _sfc_main$Z = /* @__PURE__ */ defineComponent({
9325
9331
  "debounce",
9326
9332
  "showTotalCount",
9327
9333
  "hideMoreResultsButtonOnNoResults",
9328
- "showNoResultsPanel"
9334
+ "showNoResultsPanel",
9335
+ "expandOnSinglePanel"
9329
9336
  ])
9330
9337
  );
9331
9338
  const searchTriggers = computed(() => {
@@ -13994,8 +14001,14 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
13994
14001
  const isTitleResultTopPosition = computed(() => {
13995
14002
  return props.options.searchTitlePosition === "search-results-top";
13996
14003
  });
14004
+ const handlePopState = () => {
14005
+ var _a;
14006
+ const searchParams = getSearchParams((_a = props.options.ssr) == null ? void 0 : _a.url);
14007
+ paramStore.add(parseParams(searchParams));
14008
+ };
13997
14009
  onMounted(() => {
13998
14010
  var _a, _b;
14011
+ window.addEventListener("popstate", handlePopState);
13999
14012
  window.addEventListener("resize", handleResize);
14000
14013
  if (props.initialData) {
14001
14014
  searchResultStore.add(__spreadValues2({}, props.initialData));
@@ -14006,6 +14019,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
14006
14019
  });
14007
14020
  onBeforeUnmount(() => {
14008
14021
  window.removeEventListener("resize", handleResize);
14022
+ window.removeEventListener("popstate", handlePopState);
14009
14023
  });
14010
14024
  const trackItemListView = (title, items = []) => {
14011
14025
  trackingStore.trackEvent({
@@ -20753,11 +20767,12 @@ const getApiUrl = (environment, customBaseUrl) => {
20753
20767
  }
20754
20768
  return Env[environment] || Env["production"];
20755
20769
  };
20756
- const suggestSearchChatPhrases = (options, request) => __async(void 0, null, function* () {
20770
+ const suggestSearchChatPhrases = (options, request, chatSettings) => __async(void 0, null, function* () {
20757
20771
  var _a, _b, _c;
20758
20772
  const { environment, customBaseUrl } = options;
20773
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20759
20774
  try {
20760
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20775
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20761
20776
  body: JSON.stringify(request),
20762
20777
  headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20763
20778
  }));
@@ -20773,14 +20788,18 @@ const suggestSearchChatPhrases = (options, request) => __async(void 0, null, fun
20773
20788
  return { success: false, errors: [e] };
20774
20789
  }
20775
20790
  });
20776
- const suggestPhraseAlternatives = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
20791
+ const suggestPhraseAlternatives = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, { phrases }, chatSettings) {
20777
20792
  var _a, _b, _c;
20778
20793
  const { environment, customBaseUrl } = options;
20794
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20779
20795
  try {
20780
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20781
- body: JSON.stringify({ phrases }),
20782
- headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20783
- }));
20796
+ const res = yield fetch(
20797
+ `${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives${model}`,
20798
+ __spreadProps2(__spreadValues2({}, defaultConfig), {
20799
+ body: JSON.stringify({ phrases }),
20800
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20801
+ })
20802
+ );
20784
20803
  if (res.status < 400) {
20785
20804
  const data = yield res.json();
20786
20805
  return __spreadProps2(__spreadValues2({}, data), { success: true });
@@ -20793,11 +20812,12 @@ const suggestPhraseAlternatives = (_0, _1) => __async(void 0, [_0, _1], function
20793
20812
  return { success: false, errors: [e] };
20794
20813
  }
20795
20814
  });
20796
- const suggestSimplifiedPhrases = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
20815
+ const suggestSimplifiedPhrases = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, { phrases }, chatSettings) {
20797
20816
  var _a, _b, _c;
20798
20817
  const { environment, customBaseUrl } = options;
20818
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20799
20819
  try {
20800
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20820
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20801
20821
  body: JSON.stringify({ phrases }),
20802
20822
  headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20803
20823
  }));
@@ -20813,15 +20833,16 @@ const suggestSimplifiedPhrases = (_0, _1) => __async(void 0, [_0, _1], function*
20813
20833
  return { success: false, errors: [e] };
20814
20834
  }
20815
20835
  });
20816
- const suggestBestProductMatches = (_0, _1) => __async(void 0, [_0, _1], function* (options, {
20836
+ const suggestBestProductMatches = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, {
20817
20837
  initialQuery,
20818
20838
  productStrings,
20819
20839
  messageHistory
20820
- }) {
20840
+ }, chatSettings) {
20821
20841
  var _a, _b, _c;
20822
20842
  const { environment, customBaseUrl } = options;
20843
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20823
20844
  try {
20824
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20845
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20825
20846
  body: JSON.stringify({ initialQuery, messageHistory, productStrings }),
20826
20847
  headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20827
20848
  }));
@@ -20858,9 +20879,10 @@ const prepareChatHistory = (chatLog) => {
20858
20879
  }
20859
20880
  return history;
20860
20881
  };
20861
- const getTextResponseChunkStream = (options, { initialQuery, messageHistory }, onChunkReceived) => {
20882
+ const getTextResponseChunkStream = (options, { initialQuery, messageHistory }, onChunkReceived, chatSettings) => {
20862
20883
  var _a;
20863
- fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20884
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20885
+ fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20864
20886
  body: JSON.stringify({ initialQuery, messageHistory }),
20865
20887
  headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20866
20888
  })).then((response) => {
@@ -21000,9 +21022,13 @@ const _sfc_main$4$1 = /* @__PURE__ */ defineComponent({
21000
21022
  return result.items;
21001
21023
  });
21002
21024
  const getPhraseAlternatives = () => __async(this, null, function* () {
21003
- const { phrases } = yield ChatService.suggestPhraseAlternatives(props.options.sdkOptions, {
21004
- phrases: [props.phrase]
21005
- });
21025
+ const { phrases } = yield ChatService.suggestPhraseAlternatives(
21026
+ props.options.sdkOptions,
21027
+ {
21028
+ phrases: [props.phrase]
21029
+ },
21030
+ props.options.chatSettings
21031
+ );
21006
21032
  return phrases != null ? phrases : [];
21007
21033
  });
21008
21034
  return (_ctx, _cache) => {
@@ -21067,11 +21093,15 @@ const _sfc_main$3$1 = /* @__PURE__ */ defineComponent({
21067
21093
  return (_b = (_a2 = result[titleKey.value]) == null ? void 0 : _a2.toString()) != null ? _b : "";
21068
21094
  }
21069
21095
  );
21070
- const { products } = yield ChatService.suggestBestProductMatches(props.options.sdkOptions, {
21071
- initialQuery: props.entry.userInput,
21072
- productStrings: productResultStrings,
21073
- messageHistory: (_a = props.history) != null ? _a : []
21074
- });
21096
+ const { products } = yield ChatService.suggestBestProductMatches(
21097
+ props.options.sdkOptions,
21098
+ {
21099
+ initialQuery: props.entry.userInput,
21100
+ productStrings: productResultStrings,
21101
+ messageHistory: (_a = props.history) != null ? _a : []
21102
+ },
21103
+ props.options.chatSettings
21104
+ );
21075
21105
  bestMatches.value = products;
21076
21106
  emit2("loaded", products);
21077
21107
  } finally {
@@ -21144,7 +21174,8 @@ const _sfc_main$2$1 = /* @__PURE__ */ defineComponent({
21144
21174
  initialQuery: props.content,
21145
21175
  messageHistory: (_a = props.history) != null ? _a : []
21146
21176
  },
21147
- processChunk
21177
+ processChunk,
21178
+ props.options.chatSettings
21148
21179
  );
21149
21180
  });
21150
21181
  return (_ctx, _cache) => {
@@ -21241,7 +21272,8 @@ const _sfc_main$1k = /* @__PURE__ */ defineComponent({
21241
21272
  };
21242
21273
  const { phrases, success } = yield ChatService.suggestSearchChatPhrases(
21243
21274
  props.options.sdkOptions,
21244
- request
21275
+ request,
21276
+ props.options.chatSettings
21245
21277
  );
21246
21278
  if (!success || !phrases.length) {
21247
21279
  error.value = "Something went wrong";
@@ -7681,7 +7681,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7681
7681
  const _hoisted_1$1b = { id: "lupa-search-box-input-container" };
7682
7682
  const _hoisted_2$O = { class: "lupa-input-clear" };
7683
7683
  const _hoisted_3$A = { id: "lupa-search-box-input" };
7684
- const _hoisted_4$r = ["value"];
7684
+ const _hoisted_4$q = ["value"];
7685
7685
  const _hoisted_5$f = ["placeholder"];
7686
7686
  const _hoisted_6$8 = {
7687
7687
  key: 0,
@@ -7776,7 +7776,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7776
7776
  class: "lupa-hint",
7777
7777
  value: showHint.value ? suggestedValue.value.item.suggestion : "",
7778
7778
  disabled: ""
7779
- }, null, 8, _hoisted_4$r),
7779
+ }, null, 8, _hoisted_4$q),
7780
7780
  withDirectives(createBaseVNode("input", mergeProps({
7781
7781
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event)
7782
7782
  }, inputAttributes.value, {
@@ -7955,7 +7955,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7955
7955
  class: "lupa-suggestion-facet",
7956
7956
  "data-cy": "lupa-suggestion-facet"
7957
7957
  };
7958
- const _hoisted_4$q = {
7958
+ const _hoisted_4$p = {
7959
7959
  class: "lupa-suggestion-facet-label",
7960
7960
  "data-cy": "lupa-suggestion-facet-label"
7961
7961
  };
@@ -8001,7 +8001,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8001
8001
  innerHTML: _ctx.suggestion.displayHighlight
8002
8002
  }, null, 8, _hoisted_1$17)) : (openBlock(), createElementBlock("div", _hoisted_2$M, toDisplayString(_ctx.suggestion.display), 1)),
8003
8003
  _ctx.suggestion.facet ? (openBlock(), createElementBlock("div", _hoisted_3$z, [
8004
- createBaseVNode("span", _hoisted_4$q, toDisplayString(facetLabel.value), 1),
8004
+ createBaseVNode("span", _hoisted_4$p, toDisplayString(facetLabel.value), 1),
8005
8005
  createBaseVNode("span", _hoisted_5$e, toDisplayString(_ctx.suggestion.facet.title), 1)
8006
8006
  ])) : createCommentVNode("", true)
8007
8007
  ]);
@@ -8403,7 +8403,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8403
8403
  const _hoisted_1$10 = ["innerHTML"];
8404
8404
  const _hoisted_2$J = { key: 0 };
8405
8405
  const _hoisted_3$y = { key: 1 };
8406
- const _hoisted_4$p = { class: "lupa-search-box-custom-label" };
8406
+ const _hoisted_4$o = { class: "lupa-search-box-custom-label" };
8407
8407
  const _hoisted_5$d = { class: "lupa-search-box-custom-text" };
8408
8408
  const _sfc_main$15 = /* @__PURE__ */ defineComponent({
8409
8409
  __name: "SearchBoxProductCustom",
@@ -8436,7 +8436,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8436
8436
  class: [className.value, "lupa-search-box-product-custom"]
8437
8437
  }, toHandlers(_ctx.options.action ? { click: handleClick } : {}, true)), [
8438
8438
  !label.value ? (openBlock(), createElementBlock("div", _hoisted_2$J, toDisplayString(text.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$y, [
8439
- createBaseVNode("div", _hoisted_4$p, toDisplayString(label.value), 1),
8439
+ createBaseVNode("div", _hoisted_4$o, toDisplayString(label.value), 1),
8440
8440
  createBaseVNode("div", _hoisted_5$d, toDisplayString(text.value), 1)
8441
8441
  ]))
8442
8442
  ], 16));
@@ -8832,7 +8832,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8832
8832
  const _hoisted_1$Z = ["href"];
8833
8833
  const _hoisted_2$H = { class: "lupa-search-box-product-image-section" };
8834
8834
  const _hoisted_3$w = { class: "lupa-search-box-product-details-section" };
8835
- const _hoisted_4$o = {
8835
+ const _hoisted_4$n = {
8836
8836
  key: 0,
8837
8837
  class: "lupa-search-box-product-add-to-cart-section"
8838
8838
  };
@@ -8953,7 +8953,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8953
8953
  }, null, 8, ["item", "element", "labels", "link"]);
8954
8954
  }), 128))
8955
8955
  ]),
8956
- addToCartElement.value ? (openBlock(), createElementBlock("div", _hoisted_4$o, [
8956
+ addToCartElement.value ? (openBlock(), createElementBlock("div", _hoisted_4$n, [
8957
8957
  createVNode(_sfc_main$12, {
8958
8958
  class: "lupa-search-box-product-element",
8959
8959
  item: _ctx.item,
@@ -9088,12 +9088,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9088
9088
  key: 0,
9089
9089
  id: "lupa-search-box-panel"
9090
9090
  };
9091
- const _hoisted_2$G = {
9092
- class: "lupa-main-panel",
9093
- "data-cy": "lupa-main-panel"
9094
- };
9095
- const _hoisted_3$v = ["data-cy"];
9096
- const _hoisted_4$n = {
9091
+ const _hoisted_2$G = ["data-cy"];
9092
+ const _hoisted_3$v = {
9097
9093
  key: 1,
9098
9094
  id: "lupa-search-box-panel"
9099
9095
  };
@@ -9130,7 +9126,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9130
9126
  const panels = computed(() => props.options.panels);
9131
9127
  const sdkOptions = computed(() => props.options.options);
9132
9128
  const searchBoxStore = useSearchBoxStore();
9133
- const { suggestionResults, hasAnyResults } = storeToRefs(searchBoxStore);
9129
+ const { suggestionResults, hasAnyResults, panelItemCounts } = storeToRefs(searchBoxStore);
9134
9130
  const displayResults = computed(
9135
9131
  () => {
9136
9132
  var _a, _b;
@@ -9211,6 +9207,12 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9211
9207
  `${window.innerHeight - panel.getBoundingClientRect().y - 10}px`
9212
9208
  );
9213
9209
  };
9210
+ const numberOfVisiblePanels = computed(() => {
9211
+ return panelItemCounts.value.filter((v) => v.count > 0).length;
9212
+ });
9213
+ const expandOnSinglePanel = computed(() => {
9214
+ return numberOfVisiblePanels.value === 1 && props.options.expandOnSinglePanel;
9215
+ });
9214
9216
  return (_ctx, _cache) => {
9215
9217
  var _a;
9216
9218
  return openBlock(), createElementBlock("div", {
@@ -9218,7 +9220,11 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9218
9220
  ref: panelContainer
9219
9221
  }, [
9220
9222
  displayResults.value ? (openBlock(), createElementBlock("div", _hoisted_1$X, [
9221
- createBaseVNode("div", _hoisted_2$G, [
9223
+ createBaseVNode("div", {
9224
+ class: "lupa-main-panel",
9225
+ style: normalizeStyle(expandOnSinglePanel.value ? { display: "block" } : {}),
9226
+ "data-cy": "lupa-main-panel"
9227
+ }, [
9222
9228
  (openBlock(true), createElementBlock(Fragment, null, renderList(displayPanels.value, (panel, index) => {
9223
9229
  return openBlock(), createElementBlock("div", {
9224
9230
  key: index,
@@ -9247,9 +9253,9 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9247
9253
  key: "0"
9248
9254
  } : void 0
9249
9255
  ]), 1064, ["panel", "options", "debounce", "inputValue", "labels"])) : createCommentVNode("", true)
9250
- ], 10, _hoisted_3$v);
9256
+ ], 10, _hoisted_2$G);
9251
9257
  }), 128))
9252
- ]),
9258
+ ], 4),
9253
9259
  !unref(hasAnyResults) && _ctx.options.showNoResultsPanel ? (openBlock(), createBlock(_sfc_main$1f, {
9254
9260
  key: 0,
9255
9261
  labels: labels.value
@@ -9260,7 +9266,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9260
9266
  showTotalCount: (_a = _ctx.options.showTotalCount) != null ? _a : false,
9261
9267
  onGoToResults: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("go-to-results"))
9262
9268
  }, null, 8, ["labels", "showTotalCount"])) : createCommentVNode("", true)
9263
- ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_4$n, [
9269
+ ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_3$v, [
9264
9270
  createVNode(_sfc_main$1g, {
9265
9271
  options: _ctx.options.history,
9266
9272
  history: history.value,
@@ -9329,7 +9335,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9329
9335
  "debounce",
9330
9336
  "showTotalCount",
9331
9337
  "hideMoreResultsButtonOnNoResults",
9332
- "showNoResultsPanel"
9338
+ "showNoResultsPanel",
9339
+ "expandOnSinglePanel"
9333
9340
  ])
9334
9341
  );
9335
9342
  const searchTriggers = computed(() => {
@@ -13998,8 +14005,14 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
13998
14005
  const isTitleResultTopPosition = computed(() => {
13999
14006
  return props.options.searchTitlePosition === "search-results-top";
14000
14007
  });
14008
+ const handlePopState = () => {
14009
+ var _a;
14010
+ const searchParams = getSearchParams((_a = props.options.ssr) == null ? void 0 : _a.url);
14011
+ paramStore.add(parseParams(searchParams));
14012
+ };
14001
14013
  onMounted(() => {
14002
14014
  var _a, _b;
14015
+ window.addEventListener("popstate", handlePopState);
14003
14016
  window.addEventListener("resize", handleResize);
14004
14017
  if (props.initialData) {
14005
14018
  searchResultStore.add(__spreadValues2({}, props.initialData));
@@ -14010,6 +14023,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
14010
14023
  });
14011
14024
  onBeforeUnmount(() => {
14012
14025
  window.removeEventListener("resize", handleResize);
14026
+ window.removeEventListener("popstate", handlePopState);
14013
14027
  });
14014
14028
  const trackItemListView = (title, items = []) => {
14015
14029
  trackingStore.trackEvent({
@@ -20757,11 +20771,12 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20757
20771
  }
20758
20772
  return Env[environment] || Env["production"];
20759
20773
  };
20760
- const suggestSearchChatPhrases = (options, request) => __async(void 0, null, function* () {
20774
+ const suggestSearchChatPhrases = (options, request, chatSettings) => __async(void 0, null, function* () {
20761
20775
  var _a, _b, _c;
20762
20776
  const { environment, customBaseUrl } = options;
20777
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20763
20778
  try {
20764
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20779
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20765
20780
  body: JSON.stringify(request),
20766
20781
  headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20767
20782
  }));
@@ -20777,14 +20792,18 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20777
20792
  return { success: false, errors: [e] };
20778
20793
  }
20779
20794
  });
20780
- const suggestPhraseAlternatives = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
20795
+ const suggestPhraseAlternatives = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, { phrases }, chatSettings) {
20781
20796
  var _a, _b, _c;
20782
20797
  const { environment, customBaseUrl } = options;
20798
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20783
20799
  try {
20784
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20785
- body: JSON.stringify({ phrases }),
20786
- headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20787
- }));
20800
+ const res = yield fetch(
20801
+ `${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives${model}`,
20802
+ __spreadProps2(__spreadValues2({}, defaultConfig), {
20803
+ body: JSON.stringify({ phrases }),
20804
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20805
+ })
20806
+ );
20788
20807
  if (res.status < 400) {
20789
20808
  const data = yield res.json();
20790
20809
  return __spreadProps2(__spreadValues2({}, data), { success: true });
@@ -20797,11 +20816,12 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20797
20816
  return { success: false, errors: [e] };
20798
20817
  }
20799
20818
  });
20800
- const suggestSimplifiedPhrases = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
20819
+ const suggestSimplifiedPhrases = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, { phrases }, chatSettings) {
20801
20820
  var _a, _b, _c;
20802
20821
  const { environment, customBaseUrl } = options;
20822
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20803
20823
  try {
20804
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20824
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20805
20825
  body: JSON.stringify({ phrases }),
20806
20826
  headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20807
20827
  }));
@@ -20817,15 +20837,16 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20817
20837
  return { success: false, errors: [e] };
20818
20838
  }
20819
20839
  });
20820
- const suggestBestProductMatches = (_0, _1) => __async(void 0, [_0, _1], function* (options, {
20840
+ const suggestBestProductMatches = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, {
20821
20841
  initialQuery,
20822
20842
  productStrings,
20823
20843
  messageHistory
20824
- }) {
20844
+ }, chatSettings) {
20825
20845
  var _a, _b, _c;
20826
20846
  const { environment, customBaseUrl } = options;
20847
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20827
20848
  try {
20828
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20849
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20829
20850
  body: JSON.stringify({ initialQuery, messageHistory, productStrings }),
20830
20851
  headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20831
20852
  }));
@@ -20862,9 +20883,10 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20862
20883
  }
20863
20884
  return history;
20864
20885
  };
20865
- const getTextResponseChunkStream = (options, { initialQuery, messageHistory }, onChunkReceived) => {
20886
+ const getTextResponseChunkStream = (options, { initialQuery, messageHistory }, onChunkReceived, chatSettings) => {
20866
20887
  var _a;
20867
- fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20888
+ const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
20889
+ fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20868
20890
  body: JSON.stringify({ initialQuery, messageHistory }),
20869
20891
  headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20870
20892
  })).then((response) => {
@@ -21004,9 +21026,13 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21004
21026
  return result.items;
21005
21027
  });
21006
21028
  const getPhraseAlternatives = () => __async(this, null, function* () {
21007
- const { phrases } = yield ChatService.suggestPhraseAlternatives(props.options.sdkOptions, {
21008
- phrases: [props.phrase]
21009
- });
21029
+ const { phrases } = yield ChatService.suggestPhraseAlternatives(
21030
+ props.options.sdkOptions,
21031
+ {
21032
+ phrases: [props.phrase]
21033
+ },
21034
+ props.options.chatSettings
21035
+ );
21010
21036
  return phrases != null ? phrases : [];
21011
21037
  });
21012
21038
  return (_ctx, _cache) => {
@@ -21071,11 +21097,15 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21071
21097
  return (_b = (_a2 = result[titleKey.value]) == null ? void 0 : _a2.toString()) != null ? _b : "";
21072
21098
  }
21073
21099
  );
21074
- const { products } = yield ChatService.suggestBestProductMatches(props.options.sdkOptions, {
21075
- initialQuery: props.entry.userInput,
21076
- productStrings: productResultStrings,
21077
- messageHistory: (_a = props.history) != null ? _a : []
21078
- });
21100
+ const { products } = yield ChatService.suggestBestProductMatches(
21101
+ props.options.sdkOptions,
21102
+ {
21103
+ initialQuery: props.entry.userInput,
21104
+ productStrings: productResultStrings,
21105
+ messageHistory: (_a = props.history) != null ? _a : []
21106
+ },
21107
+ props.options.chatSettings
21108
+ );
21079
21109
  bestMatches.value = products;
21080
21110
  emit2("loaded", products);
21081
21111
  } finally {
@@ -21148,7 +21178,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21148
21178
  initialQuery: props.content,
21149
21179
  messageHistory: (_a = props.history) != null ? _a : []
21150
21180
  },
21151
- processChunk
21181
+ processChunk,
21182
+ props.options.chatSettings
21152
21183
  );
21153
21184
  });
21154
21185
  return (_ctx, _cache) => {
@@ -21245,7 +21276,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21245
21276
  };
21246
21277
  const { phrases, success } = yield ChatService.suggestSearchChatPhrases(
21247
21278
  props.options.sdkOptions,
21248
- request
21279
+ request,
21280
+ props.options.chatSettings
21249
21281
  );
21250
21282
  if (!success || !phrases.length) {
21251
21283
  error.value = "Something went wrong";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getlupa/client",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "main": "dist/lupaSearch.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/src/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@getlupa/client-sdk": "^1.3.4",
23
- "@getlupa/vue": "0.5.0",
23
+ "@getlupa/vue": "0.5.2",
24
24
  "@rushstack/eslint-patch": "^1.3.2",
25
25
  "@tsconfig/node18": "^2.0.1",
26
26
  "@types/jsdom": "^21.1.1",