@depict-ai/ui 1.4.4 → 1.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/latest/index.js CHANGED
@@ -5,7 +5,7 @@ import { createSignal as $9HbP8$createSignal, createMemo as $9HbP8$createMemo, u
5
5
  /*! Depict.ai search and product listing SDK */
6
6
  import { register_es_version } from "../multi_import_deduplicator.mjs";
7
7
  register_es_version("ui", "latest");
8
- const $ec291e0010116877$export$83d89fbfd8236492 = "1.4.4";
8
+ const $ec291e0010116877$export$83d89fbfd8236492 = "1.4.5";
9
9
  function $24e27fab9c821b86$export$5bad61ecde080b1f(...params) {
10
10
  const {
11
11
  collapse: collapse,
@@ -662,7 +662,7 @@ function $1adfe60f3a14a1d7$export$fecbb157621501bd({
662
662
  }
663
663
  (0, $9HbP8$delegateEvents)(["click"]);
664
664
  const $87c712b5b33f24f7$var$_tmpl$ = /*#__PURE__*/(0, $9HbP8$template)(`<span class="count"></span>`, 2),
665
- $87c712b5b33f24f7$var$_tmpl$2 = /*#__PURE__*/(0, $9HbP8$template)(`<label class="input-row"><div class="left"><input type="checkbox"><span class="custom-indicator"></span><span class="text"></span></div><!#><!/></label>`, 11);
665
+ $87c712b5b33f24f7$var$_tmpl$2 = /*#__PURE__*/(0, $9HbP8$template)(`<label class="input-row"><div class="left"><input type="checkbox"><span class="custom-indicator"></span><span class="text line-clamp"></span></div><!#><!/></label>`, 11);
666
666
  const $87c712b5b33f24f7$export$48513f6b9f8ce62d = props => {
667
667
  // It seems like there's no diffing without memos here (since we often just have computations in the getters above that update to the same result often because their dependencies change with unrelated changes often), so put memos here to avoid unneeded DOM changes
668
668
  const count = (0, $9HbP8$createMemo)(() => props.count_);
@@ -2615,9 +2615,14 @@ function $c8d5ff4524619fcd$var$ActualSolidLayout(props, container_element) {
2615
2615
  // Copy of Layout from utilishared but using solid-js signals instead of async iterable IPNS
2616
2616
  const show_all_rows = (0, $9HbP8$createMemo)(() => props.rows === "all");
2617
2617
  const rows_or_empty_object = (0, $9HbP8$createMemo)(() => show_all_rows() ? {} : props.rows);
2618
- const button_elements = (0, $a52235d12ccf9c88$export$2f0cbfbb4354bb52)((0, $9HbP8$createMemo)(() => rows_or_empty_object().button));
2619
- const have_a_button = (0, $9HbP8$createMemo)(() => {
2620
- const button = button_elements();
2618
+ const view_more_button_elements = (0, $a52235d12ccf9c88$export$2f0cbfbb4354bb52)((0, $9HbP8$createMemo)(() => rows_or_empty_object().button));
2619
+ const view_less_button_elements = (0, $a52235d12ccf9c88$export$2f0cbfbb4354bb52)((0, $9HbP8$createMemo)(() => rows_or_empty_object().view_less_button));
2620
+ const have_a_view_more_button = (0, $9HbP8$createMemo)(() => {
2621
+ const button = view_more_button_elements();
2622
+ return !(!button || Array.isArray(button) && !button.length);
2623
+ });
2624
+ const have_a_view_less_button = (0, $9HbP8$createMemo)(() => {
2625
+ const button = view_less_button_elements();
2621
2626
  return !(!button || Array.isArray(button) && !button.length);
2622
2627
  });
2623
2628
  const [get_styling, set_styling] = (0, $9HbP8$createSignal)();
@@ -2626,19 +2631,29 @@ function $c8d5ff4524619fcd$var$ActualSolidLayout(props, container_element) {
2626
2631
  const [get_children_count, set_children_count] = (0, $9HbP8$createSignal)(0);
2627
2632
  const update_children_count = () => set_children_count(container_element.children.length);
2628
2633
  const col_styling = (0, $9HbP8$createMemo)(() => (0, $9HbP8$n_col_styling_with_dist)(selector_beginning, props.grid_spacing, props.cols_at_size, props.layout, props.override_vertical_spacing));
2629
- const default_currently_visible_signal = (0, $9HbP8$createSignal)(0); // Keep this signal here so it doesn't change when rows_or_empty_object and I think it's to be expected that the "internal default signal" stays the same
2634
+ const default_currently_visible_signal = (0, $9HbP8$createSignal)((0, $9HbP8$untrack)(() => rows_or_empty_object().start_rows ?? 1)); // Keep this signal here, so it doesn't change when rows_or_empty_object and I think it's to be expected that the "internal default signal" stays the same
2630
2635
  const rows_visible_signal = (0, $9HbP8$createMemo)(() => rows_or_empty_object().currently_visible || default_currently_visible_signal);
2631
2636
  const get_rows_visible = (0, $9HbP8$createMemo)(() => rows_visible_signal()[0]());
2632
2637
  const set_rows_visible = (0, $9HbP8$createMemo)(() => rows_visible_signal()[1]);
2633
- const button_class = (0, $9HbP8$make_random_classname)();
2634
- const button_container = (0, $9HbP8$createMemo)(() => have_a_button() && (() => {
2638
+ const view_more_button_class = (0, $9HbP8$make_random_classname)();
2639
+ const view_less_button_class = (0, $9HbP8$make_random_classname)();
2640
+ const view_more_button_container = (0, $9HbP8$createMemo)(() => have_a_view_more_button() && (() => {
2635
2641
  const _el$2 = (0, $9HbP8$getNextElement)($c8d5ff4524619fcd$var$_tmpl$);
2636
2642
  (0, $9HbP8$addEventListener)(_el$2, "click", (0, $9HbP8$catchify)(() => set_rows_visible()(prev => prev + (rows_or_empty_object().rows_per_click ?? 1))), true);
2637
- (0, $9HbP8$className)(_el$2, "load-more-container " + button_class);
2643
+ (0, $9HbP8$className)(_el$2, `load-more-container ${view_more_button_class}`);
2638
2644
  (0, $9HbP8$insert)(_el$2, () => rows_or_empty_object().button);
2639
2645
  (0, $9HbP8$runHydrationEvents)();
2640
2646
  return _el$2;
2641
2647
  })());
2648
+ // We need to have duplicate buttons because which ones is shown depends on the number of rows visible and therefore on the viewport size and therefore on the css media queries
2649
+ const view_less_button_container = (0, $9HbP8$createMemo)(() => have_a_view_less_button() && (() => {
2650
+ const _el$3 = (0, $9HbP8$getNextElement)($c8d5ff4524619fcd$var$_tmpl$);
2651
+ (0, $9HbP8$addEventListener)(_el$3, "click", (0, $9HbP8$catchify)(() => set_rows_visible()(() => rows_or_empty_object().start_rows ?? 1)), true);
2652
+ (0, $9HbP8$className)(_el$3, `load-less-container ${view_less_button_class}`);
2653
+ (0, $9HbP8$insert)(_el$3, () => rows_or_empty_object().view_less_button);
2654
+ (0, $9HbP8$runHydrationEvents)();
2655
+ return _el$3;
2656
+ })());
2642
2657
  container_element.classList.add(container_class);
2643
2658
  (0, $9HbP8$createComputed)(() => {
2644
2659
  // Make sure we don't have more rows visible than max_rows (this could happen by max_rows being decreased)
@@ -2653,7 +2668,6 @@ function $c8d5ff4524619fcd$var$ActualSolidLayout(props, container_element) {
2653
2668
  set_styling(() => col_styling);
2654
2669
  return;
2655
2670
  }
2656
- (0, $9HbP8$untrack)(() => set_rows_visible()(rows_or_empty_object().start_rows ?? 1));
2657
2671
  update_children_count();
2658
2672
  const mutation_observer = new MutationObserver((0, $9HbP8$catchify)(update_children_count));
2659
2673
  mutation_observer.observe(container_element, {
@@ -2665,33 +2679,36 @@ function $c8d5ff4524619fcd$var$ActualSolidLayout(props, container_element) {
2665
2679
  () => (0, $9HbP8$createMemo)(() => {
2666
2680
  const {
2667
2681
  rows_per_click: rows_per_click,
2668
- max_rows = -1
2682
+ max_rows = -1,
2683
+ start_rows: start_rows
2669
2684
  } = rows_or_empty_object();
2670
2685
  const rows_visible = get_rows_visible();
2671
2686
  const children_count = get_children_count();
2672
2687
  return col_styling() + props.cols_at_size.map(options => {
2673
- const [, min, max] = options;
2674
- let should_hide_button;
2688
+ const [recs_per_row, min, max] = options;
2689
+ let should_hide_view_more_button;
2675
2690
  let visible_recs;
2676
2691
  if (props.disable_partial_rows) {
2677
2692
  visible_recs = (0, $9HbP8$layout_get_visible_recs_without_partial_rows)(rows_visible, children_count, options);
2678
2693
  const visible_recs_next_show_more = (0, $9HbP8$layout_get_visible_recs_without_partial_rows)(rows_visible + (rows_per_click || 0),
2679
2694
  // Should this really be zero when we default rows_per_click to 1?
2680
2695
  children_count, options);
2681
- should_hide_button = visible_recs === visible_recs_next_show_more;
2696
+ should_hide_view_more_button = visible_recs === visible_recs_next_show_more;
2682
2697
  } else {
2683
2698
  visible_recs = (0, $9HbP8$layout_get_total_rec_amount_for_row)(rows_visible, options);
2684
- should_hide_button = visible_recs >= children_count;
2699
+ should_hide_view_more_button = visible_recs >= children_count;
2685
2700
  }
2686
- const should_hide_button_final = button_class && (should_hide_button || max_rows !== -1 && rows_visible >= max_rows);
2687
- return `${(0, $9HbP8$layout_media_query_header)(min, max)}{${selector_beginning}:nth-child(n+${visible_recs + 1}){display:none}${props.layout == "slider" ? `${selector_beginning}:nth-child(n+${visible_recs}){margin-right:0}` : ""}${should_hide_button_final ? `.depict .${button_class}{display:none!important}` : ``}}`;
2701
+ const should_hide_button_final = should_hide_view_more_button || max_rows !== -1 && rows_visible >= max_rows;
2702
+ // I don't really understand the logic for when the view more button gets hidden so IDK if below is correct, but it works how it should for now
2703
+ const should_hide_view_less_button = !should_hide_view_more_button || start_rows == undefined || rows_visible <= start_rows || children_count <= recs_per_row * start_rows;
2704
+ return `${(0, $9HbP8$layout_media_query_header)(min, max)}{${selector_beginning}:nth-child(n+${visible_recs + 1}){display:none}${props.layout == "slider" ? `${selector_beginning}:nth-child(n+${visible_recs}){margin-right:0}` : ""}${should_hide_button_final ? `.depict .${view_more_button_class}{display:none!important}` : ``}${should_hide_view_less_button ? `.depict .${view_less_button_class}{display:none!important}` : ``}}`;
2688
2705
  }).join("");
2689
2706
  }));
2690
2707
  });
2691
- return [container_element, (0, $9HbP8$memo)(button_container), (() => {
2692
- const _el$3 = (0, $9HbP8$getNextElement)($c8d5ff4524619fcd$var$_tmpl$2);
2693
- (0, $9HbP8$insert)(_el$3, get_styling);
2694
- return _el$3;
2708
+ return [container_element, (0, $9HbP8$memo)(view_more_button_container), (0, $9HbP8$memo)(view_less_button_container), (() => {
2709
+ const _el$4 = (0, $9HbP8$getNextElement)($c8d5ff4524619fcd$var$_tmpl$2);
2710
+ (0, $9HbP8$insert)(_el$4, get_styling);
2711
+ return _el$4;
2695
2712
  })()];
2696
2713
  }
2697
2714
  (0, $9HbP8$delegateEvents)(["click"]);
@@ -2885,14 +2902,18 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
2885
2902
  }
2886
2903
  }
2887
2904
  async #run_url_creator_for_suggest(merchant, market, response) {
2888
- if (!this.page_url_creator) return response;
2905
+ const page_url_creator = this.page_url_creator;
2906
+ const category_transformer = this.display_transformers?.categories;
2907
+ if (!page_url_creator && !category_transformer) return response;
2889
2908
  // find category suggestions, run thing with them, and then replace them
2890
2909
  const category_suggestions = response.suggestions.filter(suggestion => suggestion.type === "category");
2891
- const page_urls = await this.page_url_creator({
2892
- type: "categories",
2910
+ const page_urls = await (page_url_creator || category_transformer)({
2893
2911
  market: market,
2894
2912
  merchant: merchant,
2895
- data: [...category_suggestions]
2913
+ data: [...category_suggestions],
2914
+ ...(page_url_creator ? {
2915
+ type: "categories"
2916
+ } : {})
2896
2917
  });
2897
2918
  this.#guard_url_creator_length(category_suggestions, page_urls);
2898
2919
  while (page_urls.length)
@@ -2900,17 +2921,29 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
2900
2921
  Object.defineProperties(category_suggestions.pop(), Object.getOwnPropertyDescriptors(page_urls.pop()));
2901
2922
  return response;
2902
2923
  }
2903
- async #run_url_creator_for_rest(merchant, market, input_data) {
2904
- if (!this.page_url_creator) return input_data;
2924
+ async #run_display_transformers_for_rest(merchant, market, input_data) {
2925
+ const {
2926
+ page_url_creator: page_url_creator,
2927
+ display_transformers: display_transformers
2928
+ } = this;
2929
+ if (!page_url_creator && !display_transformers) return input_data;
2930
+ const product_transformer = display_transformers?.products;
2931
+ const category_transformer = display_transformers?.categories;
2932
+ const content_result_transformer = display_transformers?.contentResults;
2905
2933
  const displays = input_data.displays;
2906
- const breadcrumb = input_data.breadcrumb;
2907
- const quick_links = input_data.quick_links;
2908
- if (displays) {
2909
- const page_urls = await this.page_url_creator({
2910
- type: "products",
2934
+ const {
2935
+ breadcrumb: breadcrumb,
2936
+ quick_links: quick_links,
2937
+ content_search_links: content_search_links
2938
+ } = input_data;
2939
+ if (displays && (page_url_creator || product_transformer)) {
2940
+ const page_urls = await (page_url_creator || product_transformer)({
2911
2941
  merchant: merchant,
2912
2942
  market: market,
2913
- displays: [...input_data.displays]
2943
+ displays: [...input_data.displays],
2944
+ ...(page_url_creator ? {
2945
+ type: "products"
2946
+ } : {})
2914
2947
  });
2915
2948
  this.#guard_url_creator_length(displays, page_urls);
2916
2949
  for (let i = 0; i < displays.length; i++) {
@@ -2928,19 +2961,30 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
2928
2961
  displays[i] = new_display_or_page_url;
2929
2962
  }
2930
2963
  }
2931
- for (const category_display_array of [breadcrumb, quick_links]) {
2964
+ if (page_url_creator || category_transformer) for (const category_display_array of [breadcrumb, quick_links]) {
2932
2965
  if (!category_display_array) continue;
2933
- const page_urls = await this.page_url_creator({
2934
- type: "categories",
2966
+ const page_urls = await (page_url_creator || category_transformer)({
2935
2967
  merchant: merchant,
2936
2968
  market: market,
2937
- data: [...category_display_array]
2969
+ data: [...category_display_array],
2970
+ ...(page_url_creator ? {
2971
+ type: "categories"
2972
+ } : {})
2938
2973
  });
2939
2974
  this.#guard_url_creator_length(category_display_array, page_urls);
2940
2975
  for (let i = 0; i < category_display_array.length; i++)
2941
2976
  // Copy over getters so we sneakily can make this reactive
2942
2977
  Object.defineProperties(category_display_array[i], Object.getOwnPropertyDescriptors(page_urls[i]));
2943
2978
  }
2979
+ if (content_search_links?.length && content_result_transformer) {
2980
+ const result = await content_result_transformer({
2981
+ merchant: merchant,
2982
+ market: market,
2983
+ data: [...content_search_links]
2984
+ });
2985
+ this.#guard_url_creator_length(content_search_links, result);
2986
+ input_data.content_search_links = result;
2987
+ }
2944
2988
  return input_data;
2945
2989
  }
2946
2990
  async #cached_post_request(endpoint, input_req, fallback_response) {
@@ -2967,7 +3011,7 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
2967
3011
  let result;
2968
3012
  try {
2969
3013
  const unmodified_result = await api_response.json();
2970
- result = await this.#run_url_creator_for_rest(input_req.tenant, input_req.market, unmodified_result);
3014
+ result = await this.#run_display_transformers_for_rest(input_req.tenant, input_req.market, unmodified_result);
2971
3015
  } catch (e) {
2972
3016
  (0, $9HbP8$dwarn)("URL creator or json decoding failed", e);
2973
3017
  break return_successfully;
@@ -2999,12 +3043,14 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
2999
3043
  get_metadata: get_metadata,
3000
3044
  get_user_id: get_user_id,
3001
3045
  get_session_id: get_session_id,
3002
- page_url_creator: page_url_creator
3046
+ page_url_creator: page_url_creator,
3047
+ display_transformers: display_transformers
3003
3048
  } = options ?? {};
3004
3049
  this.#get_metadata = get_metadata;
3005
3050
  this.#get_user_id = get_user_id;
3006
3051
  this.#get_session_id = get_session_id;
3007
3052
  this.page_url_creator = page_url_creator;
3053
+ this.display_transformers = display_transformers;
3008
3054
  }
3009
3055
  async suggest(input_req) {
3010
3056
  const with_ids = this.#add_ids_to_request(input_req);
@@ -3114,11 +3160,11 @@ function $fc5a12f3a857ca30$var$correct_range_filter_range_once({
3114
3160
  }
3115
3161
  }
3116
3162
  function $511cc0abd9a64ce8$export$92f2da32c6e7e7ee({
3117
- search_results_: search_results_,
3163
+ number_: number_,
3118
3164
  i18n_: i18n_
3119
3165
  }) {
3120
3166
  return (0, $9HbP8$createMemo)(() => {
3121
- const n_hits = search_results_()?.n_hits;
3167
+ const n_hits = number_();
3122
3168
  if (isNaN(n_hits)) return "";
3123
3169
  const price_formatting = i18n_.price_formatting_();
3124
3170
  return (0, $9HbP8$standard_price_format)(n_hits, 0,
@@ -5600,7 +5646,7 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({
5600
5646
  const [sort_or_filter_open_, set_sort_or_filter_open_] = (0, $9HbP8$createSignal)(false);
5601
5647
  const [desktop_filter_elements_, set_desktop_filter_elements] = (0, $9HbP8$createSignal)();
5602
5648
  const formatted_number_of_results_ = (0, $511cc0abd9a64ce8$export$92f2da32c6e7e7ee)({
5603
- search_results_: plp_results_,
5649
+ number_: (0, $9HbP8$createMemo)(() => plp_results_()?.n_hits),
5604
5650
  i18n_: i18n_
5605
5651
  });
5606
5652
  const [sort_and_filter_element_, set_sort_and_filter_element_] = (0, $9HbP8$createSignal)();
@@ -6181,7 +6227,6 @@ class $4fd2ba03703a7d92$export$7e1297a3a19f10d8 {
6181
6227
  }
6182
6228
  const $961b5c64bef4662f$var$_tmpl$ = /*#__PURE__*/(0, $9HbP8$template)(`<div class="depict plp category"></div>`, 2);
6183
6229
  // We just pass page_url_creator to DepictAPI when we instantiate it, so don't allow it to be specified if api is already specified
6184
- // on old displays, no page_url_creator can be specified
6185
6230
  /**
6186
6231
  * Type for the private properties that are shared between the different exported search SDK wrapper functions.
6187
6232
  * SDK users are not allowed to change/access these, they're an internal implementation detail.
@@ -6246,6 +6291,7 @@ class $961b5c64bef4662f$export$f34314aa9505732e {
6246
6291
  api: api,
6247
6292
  on_navigation: on_navigation,
6248
6293
  page_url_creator: page_url_creator,
6294
+ display_transformers: display_transformers,
6249
6295
  unique_instance_key_for_state = "",
6250
6296
  query_id_state_key: query_id_state_key,
6251
6297
  ...props_on_class
@@ -6290,8 +6336,10 @@ class $961b5c64bef4662f$export$f34314aa9505732e {
6290
6336
  quicklinks_signal_: (0, $9HbP8$createSignal)(),
6291
6337
  i18n_: i18n_,
6292
6338
  reset_history_state_: reset_history_state_,
6339
+ // @ts-ignore
6293
6340
  depict_api_: api ?? new (0, $7fa23e2a0079eca4$export$e015ed2f2950f2e3)({
6294
- page_url_creator: page_url_creator
6341
+ page_url_creator: page_url_creator,
6342
+ display_transformers: display_transformers
6295
6343
  }),
6296
6344
  router_: this.#router,
6297
6345
  selected_filters_: selected_filters_,
@@ -6918,11 +6966,11 @@ function $172e1b898d457050$export$7de92c4c2205ebf3({
6918
6966
  });
6919
6967
  }
6920
6968
  function $172e1b898d457050$var$make_state_saved_rows([get_showing_recommendation_rows, set_showing_recommendation_rows], i18n_) {
6921
- const currently_visible = (0, $9HbP8$createSignal)(0); // this number shouldn't matter for anything except typing
6969
+ const currently_visible = (0, $9HbP8$createSignal)((0, $9HbP8$untrack)(get_showing_recommendation_rows));
6922
6970
  const [get_currently_visible, set_currently_visible] = currently_visible;
6923
6971
  const rows = {
6924
6972
  currently_visible: currently_visible,
6925
- start_rows: (0, $9HbP8$untrack)(get_showing_recommendation_rows) ?? $172e1b898d457050$export$1c8c715550dc689d,
6973
+ start_rows: $172e1b898d457050$export$1c8c715550dc689d,
6926
6974
  rows_per_click: 3,
6927
6975
  button: (() => {
6928
6976
  const _el$7 = (0, $9HbP8$getNextElement)($172e1b898d457050$var$_tmpl$2);
@@ -7088,7 +7136,7 @@ const $c97b1f0e44afb9d2$export$27b710c08412a7ad = obj => {
7088
7136
  return Object.fromEntries(Object.keys(obj).map(key => [key, obj[key]()]));
7089
7137
  };
7090
7138
  const $e003be2a50d9e5bc$var$_tmpl$ = /*#__PURE__*/(0, $9HbP8$template)(`<span class="orig price"><!#><!/><!#><!/><!#><!/></span>`, 8),
7091
- $e003be2a50d9e5bc$var$_tmpl$2 = /*#__PURE__*/(0, $9HbP8$template)(`<a class="instant-card"><div class="img-part"></div><div class="right-part"><div class="title-brand-tagline"><span class="brand"></span><span class="title"></span><!#><!/></div><div class="price-container"><!#><!/><span class="price"><!#><!/><!#><!/><!#><!/></span></div></div></a>`, 26),
7139
+ $e003be2a50d9e5bc$var$_tmpl$2 = /*#__PURE__*/(0, $9HbP8$template)(`<a class="instant-card"><div class="img-part"></div><div class="right-part"><div class="title-brand-tagline"><span class="brand"></span><span class="title line-clamp"></span><!#><!/></div><div class="price-container"><!#><!/><span class="price"><!#><!/><!#><!/><!#><!/></span></div></div></a>`, 26),
7092
7140
  $e003be2a50d9e5bc$var$_tmpl$3 = /*#__PURE__*/(0, $9HbP8$template)(`<div class="tagline"></div>`, 2);
7093
7141
  const $e003be2a50d9e5bc$export$b05c0ae390cf3e06 = (display_or_variant_container, {
7094
7142
  i18n: i18n
@@ -7222,9 +7270,11 @@ function $eea41f703612261b$export$62f101a8aa597bf8({
7222
7270
  render_instant_card_placeholder_: render_instant_card_placeholder_,
7223
7271
  min_products_to_fetch_: min_products_to_fetch_,
7224
7272
  has_sort_or_filters_: has_sort_or_filters_,
7225
- set_num_results_accessor_: set_num_results_accessor_,
7273
+ set_total_num_results_accessor_: set_total_num_results_accessor_,
7226
7274
  i18n_: i18n_,
7227
- router_: router_
7275
+ router_: router_,
7276
+ set_modal_search_results_: set_modal_search_results_,
7277
+ content_search_enabled_: content_search_enabled_
7228
7278
  }) {
7229
7279
  const max_cards = 4;
7230
7280
  const [read_current_instant_query, write_current_instant_query] = (0, $9HbP8$createSignal)("");
@@ -7249,8 +7299,17 @@ function $eea41f703612261b$export$62f101a8aa597bf8({
7249
7299
  ...variable_data
7250
7300
  });
7251
7301
  }));
7252
- set_num_results_accessor_(() => (0, $511cc0abd9a64ce8$export$92f2da32c6e7e7ee)({
7253
- search_results_: search_results,
7302
+ // Maybe we should move this createResoure out of this component, on the other hand it bloats the parent component and if it fails it takes more than needed with it, so I think writing the content results from here is better
7303
+ // This is for the press-enter-to-instant-content-result feature which gets called from Autocomplete.tsx
7304
+ set_modal_search_results_(() => search_results);
7305
+ (0, $9HbP8$onCleanup)(() => set_modal_search_results_(undefined)); // for consistency, in case this component crashes
7306
+ set_total_num_results_accessor_(() => (0, $511cc0abd9a64ce8$export$92f2da32c6e7e7ee)({
7307
+ number_: (0, $9HbP8$createMemo)(() => {
7308
+ const hits = search_results()?.n_hits;
7309
+ const content_results = search_results()?.content_search_links?.length;
7310
+ if (!content_results || !content_search_enabled_()) return hits;
7311
+ return (hits ?? 0) + content_results;
7312
+ }),
7254
7313
  i18n_: i18n_
7255
7314
  }));
7256
7315
  const sliced_displays = (0, $9HbP8$createMemo)(() => search_results()?.displays?.slice(0, max_cards));
@@ -7348,7 +7407,7 @@ function $694b7f90501fea4c$export$5d2caaa6b530761c() {
7348
7407
  return (0, $9HbP8$getNextElement)($694b7f90501fea4c$var$_tmpl$);
7349
7408
  }
7350
7409
  const $7ad3a93cbe6fa208$var$_tmpl$ = /*#__PURE__*/(0, $9HbP8$template)(`<div class="previous-searches"><h2 class="text"></h2><div class="list"></div></div>`, 6),
7351
- $7ad3a93cbe6fa208$var$_tmpl$2 = /*#__PURE__*/(0, $9HbP8$template)(`<a class="item"><div class="left"><!#><!/><span></span></div><button class="delete"></button></a>`, 10);
7410
+ $7ad3a93cbe6fa208$var$_tmpl$2 = /*#__PURE__*/(0, $9HbP8$template)(`<a class="item"><div class="left"><!#><!/><span class="line-clamp"></span></div><button class="delete"></button></a>`, 10);
7352
7411
  function $7ad3a93cbe6fa208$export$a146ac6fa8346a25({
7353
7412
  text_: text_,
7354
7413
  previous_searches_: previous_searches_,
@@ -7430,15 +7489,18 @@ function $7ad3a93cbe6fa208$export$a146ac6fa8346a25({
7430
7489
  (0, $9HbP8$effect)(_p$ => {
7431
7490
  const _v$ = !!(0, $9HbP8$createMemo)(() => read_selected_index_()?.[0] === 0 && read_selected_index_()?.[1] === index)(),
7432
7491
  _v$2 = href(),
7433
- _v$3 = i18n_.previous_searches_delete_entry_from_history_();
7492
+ _v$3 = item(),
7493
+ _v$4 = i18n_.previous_searches_delete_entry_from_history_();
7434
7494
  _v$ !== _p$._v$ && _el$4.classList.toggle("selected", _p$._v$ = _v$);
7435
7495
  _v$2 !== _p$._v$2 && (0, $9HbP8$setAttribute)(_el$4, "href", _p$._v$2 = _v$2);
7436
- _v$3 !== _p$._v$3 && (0, $9HbP8$setAttribute)(_el$9, "title", _p$._v$3 = _v$3);
7496
+ _v$3 !== _p$._v$3 && (0, $9HbP8$setAttribute)(_el$6, "title", _p$._v$3 = _v$3);
7497
+ _v$4 !== _p$._v$4 && (0, $9HbP8$setAttribute)(_el$9, "title", _p$._v$4 = _v$4);
7437
7498
  return _p$;
7438
7499
  }, {
7439
7500
  _v$: undefined,
7440
7501
  _v$2: undefined,
7441
- _v$3: undefined
7502
+ _v$3: undefined,
7503
+ _v$4: undefined
7442
7504
  });
7443
7505
  return _el$4;
7444
7506
  })();
@@ -7507,18 +7569,37 @@ function $f3213c0640246d58$export$ba17c5b7e6dda39f({
7507
7569
  const _el$2 = (0, $9HbP8$getNextElement)($f3213c0640246d58$var$_tmpl$2);
7508
7570
  (0, $9HbP8$className)(_el$2, class_);
7509
7571
  (0, $9HbP8$insert)(_el$2, text_itself);
7510
- (0, $9HbP8$effect)(() => _el$2.classList.toggle("has-history-match", !!get_has_highlighted()));
7572
+ (0, $9HbP8$effect)(_p$ => {
7573
+ const _v$ = !!get_has_highlighted(),
7574
+ _v$2 = whole_text_to_display_memo() /* for when line-clamped, users can see full text on hover */;
7575
+ _v$ !== _p$._v$ && _el$2.classList.toggle("has-history-match", _p$._v$ = _v$);
7576
+ _v$2 !== _p$._v$2 && (0, $9HbP8$setAttribute)(_el$2, "title", _p$._v$2 = _v$2);
7577
+ return _p$;
7578
+ }, {
7579
+ _v$: undefined,
7580
+ _v$2: undefined
7581
+ });
7511
7582
  return _el$2;
7512
7583
  })();
7513
7584
  }
7585
+ const $190927650b4840eb$var$_tmpl$ = /*#__PURE__*/(0, $9HbP8$template)(`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 256 256"><path d="M56 26.455a13.71 13.71 0 0 0-9.578 3.967A13.71 13.71 0 0 0 42.455 40v176a13.71 13.71 0 0 0 3.967 9.578A13.71 13.71 0 0 0 56 229.545h144A13.71 13.71 0 0 0 213.545 216V88a2.456 2.456 0 0 1 0-.002c.001-1.452-.597-2.895-1.623-3.922l-55.998-55.998a5.61 5.61 0 0 0-3.922-1.623 2.456 2.456 0 0 1-.002 0zm0 11.09h88A2.456 2.456 0 0 1 146.455 40v48c0 2.903 2.642 5.545 5.545 5.545h48A2.456 2.456 0 0 1 202.455 96v120a2.456 2.456 0 0 1-2.455 2.455H56A2.456 2.456 0 0 1 53.545 216V40A2.456 2.456 0 0 1 56 37.545zm103.061 11.498a2.456 2.456 0 0 1 2.676.531l28.689 28.689a2.456 2.456 0 0 1-1.736 4.191H160A2.456 2.456 0 0 1 157.545 80V51.311a2.456 2.456 0 0 1 1.516-2.268zM96 130.455c-2.903 0-5.545 2.642-5.545 5.545s2.642 5.545 5.545 5.545h64c2.903 0 5.545-2.642 5.545-5.545s-2.642-5.545-5.545-5.545zm0 32c-2.903 0-5.545 2.642-5.545 5.545s2.642 5.545 5.545 5.545h64c2.903 0 5.545-2.642 5.545-5.545s-2.642-5.545-5.545-5.545z"></path></svg>`, 4);
7586
+ function $190927650b4840eb$export$605674723bcc715c(props = {}) {
7587
+ return (() => {
7588
+ const _el$ = (0, $9HbP8$getNextElement)($190927650b4840eb$var$_tmpl$);
7589
+ (0, $9HbP8$spread)(_el$, props, true, true);
7590
+ (0, $9HbP8$runHydrationEvents)();
7591
+ return _el$;
7592
+ })();
7593
+ }
7514
7594
  const $cea52f6b24092f05$var$_tmpl$ = /*#__PURE__*/(0, $9HbP8$template)(`<a class="suggestion"></a>`, 2),
7515
7595
  $cea52f6b24092f05$var$_tmpl$2 = /*#__PURE__*/(0, $9HbP8$template)(`<div class="search-icon"></div>`, 2),
7516
7596
  $cea52f6b24092f05$var$_tmpl$3 = /*#__PURE__*/(0, $9HbP8$template)(`<span class="type"></span>`, 2),
7517
7597
  $cea52f6b24092f05$var$_tmpl$4 = /*#__PURE__*/(0, $9HbP8$template)(`<div><!#><!/><span class="value"></span></div>`, 6),
7518
- $cea52f6b24092f05$var$_tmpl$5 = /*#__PURE__*/(0, $9HbP8$template)(`<h2 class="text"></h2>`, 2),
7519
- $cea52f6b24092f05$var$_tmpl$6 = /*#__PURE__*/(0, $9HbP8$template)(`<div class="suggestion-container query"><!#><!/><!#><!/></div>`, 6),
7520
- $cea52f6b24092f05$var$_tmpl$7 = /*#__PURE__*/(0, $9HbP8$template)(`<div class="suggestion-container page"></div>`, 2),
7521
- $cea52f6b24092f05$var$_tmpl$8 = /*#__PURE__*/(0, $9HbP8$template)(`<div class="suggestions"><!#><!/><!#><!/><!#><!/></div>`, 8);
7598
+ $cea52f6b24092f05$var$_tmpl$5 = /*#__PURE__*/(0, $9HbP8$template)(`<div class="with-icon"><!#><!/><!#><!/></div>`, 6),
7599
+ $cea52f6b24092f05$var$_tmpl$6 = /*#__PURE__*/(0, $9HbP8$template)(`<h2 class="text"></h2>`, 2),
7600
+ $cea52f6b24092f05$var$_tmpl$7 = /*#__PURE__*/(0, $9HbP8$template)(`<div class="suggestion-container query"><!#><!/><!#><!/></div>`, 6),
7601
+ $cea52f6b24092f05$var$_tmpl$8 = /*#__PURE__*/(0, $9HbP8$template)(`<div class="suggestion-container page"></div>`, 2),
7602
+ $cea52f6b24092f05$var$_tmpl$9 = /*#__PURE__*/(0, $9HbP8$template)(`<div class="suggestions"><!#><!/><!#><!/><!#><!/></div>`, 8);
7522
7603
  function $cea52f6b24092f05$export$e872e2339fb04a7f({
7523
7604
  suggestion_memo_: suggestion_memo_,
7524
7605
  search_query_url_param_name_: search_query_url_param_name_,
@@ -7531,7 +7612,8 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
7531
7612
  include_category_suggestions_: include_category_suggestions_,
7532
7613
  searching_for_value_: searching_for_value_,
7533
7614
  router_: router_,
7534
- submit_query_: submit_query_
7615
+ submit_query_: submit_query_,
7616
+ get_content_results_: get_content_results_
7535
7617
  }) {
7536
7618
  const queries_memo = (0, $9HbP8$createMemo)(() => suggestion_memo_().filter(({
7537
7619
  type: type,
@@ -7539,9 +7621,15 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
7539
7621
  }) => type === (0, $a0eb8b431ec1f87b$export$3cf9497e790da491) && !filtered_previous_searches_().includes(title) // don't show the ones we already show from the history
7540
7622
  ));
7541
7623
 
7542
- const not_queries_memo = (0, $9HbP8$createMemo)(() => suggestion_memo_().filter(({
7543
- type: type
7544
- }) => type !== (0, $a0eb8b431ec1f87b$export$3cf9497e790da491)));
7624
+ const not_queries_memo = (0, $9HbP8$createMemo)(() => {
7625
+ // For the section that shows categories and content results
7626
+ // We want to limit to 3 items, and we want to show the categories first
7627
+ const content_results = get_content_results_() || [];
7628
+ const from_suggest_request = include_category_suggestions_ ? suggestion_memo_().filter(({
7629
+ type: type
7630
+ }) => type !== (0, $a0eb8b431ec1f87b$export$3cf9497e790da491)) : [];
7631
+ return [...from_suggest_request.slice(0, content_results.length ? 2 : 3), ...content_results.slice(0, 1)];
7632
+ });
7545
7633
  const render_entry = (input_obj, autocomplete_data_index, index, is_history = false) => {
7546
7634
  const is_query = (0, $9HbP8$createMemo)(() => input_obj().type === (0, $a0eb8b431ec1f87b$export$3cf9497e790da491));
7547
7635
  const href_with_changed_params_accessor = (0, $9HbP8$createMemo)(() => is_query() ? (0, $a36cbc4f68bfd590$export$91c3b6774e8be0f5)({
@@ -7550,6 +7638,7 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
7550
7638
  url_transformer_: url_transformer_
7551
7639
  }) : undefined);
7552
7640
  const href = (0, $9HbP8$createMemo)(() => is_query() ? href_with_changed_params_accessor()() : input_obj().page_url);
7641
+ const is_selected = (0, $9HbP8$createMemo)(() => read_selected_index_()?.[0] === autocomplete_data_index && read_selected_index_()?.[1] === index);
7553
7642
  return (() => {
7554
7643
  const _el$ = (0, $9HbP8$getNextElement)($cea52f6b24092f05$var$_tmpl$);
7555
7644
  (0, $9HbP8$use)(element => element.addEventListener("click", (0, $9HbP8$catchify)(ev => {
@@ -7563,7 +7652,7 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
7563
7652
  return;
7564
7653
  }
7565
7654
  router_.navigate_.go_to_({
7566
- new_url_: input_obj().page_url,
7655
+ new_url_: href(),
7567
7656
  is_replace_: false,
7568
7657
  event_: ev
7569
7658
  });
@@ -7585,20 +7674,20 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
7585
7674
  return (0, $9HbP8$createComponent)((0, $694b7f90501fea4c$export$5d2caaa6b530761c), {});
7586
7675
  }
7587
7676
  }), (0, $9HbP8$createComponent)((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
7588
- class_: "value",
7677
+ class_: "value line-clamp",
7589
7678
  get whole_text_to_display_() {
7590
7679
  return (0, $9HbP8$createMemo)(() => input_obj().title);
7591
7680
  },
7592
7681
  searching_for_value_: searching_for_value_
7593
7682
  })] : [(0, $9HbP8$memo)((() => {
7594
- const _c$2 = (0, $9HbP8$memo)(() => typeof input_obj().parent_title === "string");
7683
+ const _c$2 = (0, $9HbP8$memo)(() => typeof input_obj() /* this is a harmless lie */.parent_title === "string");
7595
7684
  return () => _c$2() ? (() => {
7596
7685
  const _el$4 = (0, $9HbP8$getNextElement)($cea52f6b24092f05$var$_tmpl$4),
7597
7686
  _el$6 = _el$4.firstChild,
7598
7687
  [_el$7, _co$] = (0, $9HbP8$getNextMarker)(_el$6.nextSibling),
7599
7688
  _el$5 = _el$7.nextSibling;
7600
7689
  (0, $9HbP8$insert)(_el$4, (0, $9HbP8$createComponent)((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
7601
- class_: "category",
7690
+ class_: "category line-clamp",
7602
7691
  get whole_text_to_display_() {
7603
7692
  return (0, $9HbP8$createMemo)(() => input_obj().title);
7604
7693
  },
@@ -7606,16 +7695,38 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
7606
7695
  }), _el$7, _co$);
7607
7696
  (0, $9HbP8$insert)(_el$5, () => input_obj().parent_title);
7608
7697
  return _el$4;
7609
- })() : (0, $9HbP8$createComponent)((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
7610
- class_: "category",
7611
- get whole_text_to_display_() {
7612
- return (0, $9HbP8$createMemo)(() => input_obj().title);
7613
- },
7614
- searching_for_value_: searching_for_value_
7615
- });
7698
+ })() : (() => {
7699
+ const _c$3 = (0, $9HbP8$memo)(() => input_obj().type === "content");
7700
+ return () => _c$3() ? (() => {
7701
+ const _el$8 = (0, $9HbP8$getNextElement)($cea52f6b24092f05$var$_tmpl$5),
7702
+ _el$9 = _el$8.firstChild,
7703
+ [_el$10, _co$2] = (0, $9HbP8$getNextMarker)(_el$9.nextSibling),
7704
+ _el$11 = _el$10.nextSibling,
7705
+ [_el$12, _co$3] = (0, $9HbP8$getNextMarker)(_el$11.nextSibling);
7706
+ (0, $9HbP8$insert)(_el$8, (0, $9HbP8$createComponent)((0, $190927650b4840eb$export$605674723bcc715c), {
7707
+ width: "16",
7708
+ height: "16"
7709
+ }), _el$10, _co$2);
7710
+ (0, $9HbP8$insert)(_el$8, (0, $9HbP8$createComponent)((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
7711
+ class_: "content line-clamp",
7712
+ get whole_text_to_display_() {
7713
+ return (0, $9HbP8$createMemo)(() => input_obj().title);
7714
+ },
7715
+ searching_for_value_: searching_for_value_
7716
+ }), _el$12, _co$3);
7717
+ return _el$8;
7718
+ })() : (0, $9HbP8$createComponent)((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
7719
+ class_: "category line-clamp",
7720
+ get whole_text_to_display_() {
7721
+ return (0, $9HbP8$createMemo)(() => input_obj().title);
7722
+ },
7723
+ searching_for_value_: searching_for_value_
7724
+ });
7725
+ })();
7616
7726
  })()), (() => {
7617
7727
  const _el$3 = (0, $9HbP8$getNextElement)($cea52f6b24092f05$var$_tmpl$3);
7618
7728
  (0, $9HbP8$insert)(_el$3, (0, $9HbP8$createMemo)(() => {
7729
+ if (input_obj().type === "content") return i18n_.content_();
7619
7730
  if (input_obj().category_type === "BRAND") return i18n_.brand_();
7620
7731
  return i18n_.category_();
7621
7732
  }));
@@ -7624,7 +7735,7 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
7624
7735
  })());
7625
7736
  (0, $9HbP8$effect)(_p$ => {
7626
7737
  const _v$ = {
7627
- selected: (0, $9HbP8$createMemo)(() => read_selected_index_()?.[0] === autocomplete_data_index && read_selected_index_()?.[1] === index)(),
7738
+ selected: is_selected(),
7628
7739
  history: is_history,
7629
7740
  ["type-" + input_obj().type]: true
7630
7741
  },
@@ -7650,41 +7761,41 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
7650
7761
  }));
7651
7762
  };
7652
7763
  const should_show_previous_searches_in_query_part = (0, $9HbP8$createMemo)(() => !on_previous_searches_page_());
7653
- const should_show_at_all = (0, $9HbP8$createMemo)(() => suggestion_memo_()?.length || should_show_previous_searches_in_query_part() && filtered_previous_searches_().length);
7764
+ const should_show_at_all = (0, $9HbP8$createMemo)(() => suggestion_memo_()?.length || should_show_previous_searches_in_query_part() && filtered_previous_searches_().length || get_content_results_()?.length);
7654
7765
  const should_show_query_part = (0, $9HbP8$createMemo)(() => queries_memo().length || filtered_previous_searches_().length);
7655
7766
  return (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
7656
7767
  get when() {
7657
7768
  return should_show_at_all();
7658
7769
  },
7659
7770
  get children() {
7660
- const _el$8 = (0, $9HbP8$getNextElement)($cea52f6b24092f05$var$_tmpl$8),
7661
- _el$16 = _el$8.firstChild,
7662
- [_el$17, _co$4] = (0, $9HbP8$getNextMarker)(_el$16.nextSibling),
7663
- _el$18 = _el$17.nextSibling,
7664
- [_el$19, _co$5] = (0, $9HbP8$getNextMarker)(_el$18.nextSibling),
7665
- _el$20 = _el$19.nextSibling,
7666
- [_el$21, _co$6] = (0, $9HbP8$getNextMarker)(_el$20.nextSibling);
7667
- (0, $9HbP8$insert)(_el$8, (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
7771
+ const _el$13 = (0, $9HbP8$getNextElement)($cea52f6b24092f05$var$_tmpl$9),
7772
+ _el$21 = _el$13.firstChild,
7773
+ [_el$22, _co$6] = (0, $9HbP8$getNextMarker)(_el$21.nextSibling),
7774
+ _el$23 = _el$22.nextSibling,
7775
+ [_el$24, _co$7] = (0, $9HbP8$getNextMarker)(_el$23.nextSibling),
7776
+ _el$25 = _el$24.nextSibling,
7777
+ [_el$26, _co$8] = (0, $9HbP8$getNextMarker)(_el$25.nextSibling);
7778
+ (0, $9HbP8$insert)(_el$13, (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
7668
7779
  get when() {
7669
7780
  return on_previous_searches_page_();
7670
7781
  },
7671
7782
  get children() {
7672
- const _el$9 = (0, $9HbP8$getNextElement)($cea52f6b24092f05$var$_tmpl$5);
7673
- (0, $9HbP8$insert)(_el$9, () => i18n_.suggestions_());
7674
- return _el$9;
7783
+ const _el$14 = (0, $9HbP8$getNextElement)($cea52f6b24092f05$var$_tmpl$6);
7784
+ (0, $9HbP8$insert)(_el$14, () => i18n_.suggestions_());
7785
+ return _el$14;
7675
7786
  }
7676
- }), _el$17, _co$4);
7677
- (0, $9HbP8$insert)(_el$8, (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
7787
+ }), _el$22, _co$6);
7788
+ (0, $9HbP8$insert)(_el$13, (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
7678
7789
  get when() {
7679
7790
  return should_show_query_part();
7680
7791
  },
7681
7792
  get children() {
7682
- const _el$10 = (0, $9HbP8$getNextElement)($cea52f6b24092f05$var$_tmpl$6),
7683
- _el$11 = _el$10.firstChild,
7684
- [_el$12, _co$2] = (0, $9HbP8$getNextMarker)(_el$11.nextSibling),
7685
- _el$13 = _el$12.nextSibling,
7686
- [_el$14, _co$3] = (0, $9HbP8$getNextMarker)(_el$13.nextSibling);
7687
- (0, $9HbP8$insert)(_el$10, (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
7793
+ const _el$15 = (0, $9HbP8$getNextElement)($cea52f6b24092f05$var$_tmpl$7),
7794
+ _el$16 = _el$15.firstChild,
7795
+ [_el$17, _co$4] = (0, $9HbP8$getNextMarker)(_el$16.nextSibling),
7796
+ _el$18 = _el$17.nextSibling,
7797
+ [_el$19, _co$5] = (0, $9HbP8$getNextMarker)(_el$18.nextSibling);
7798
+ (0, $9HbP8$insert)(_el$15, (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
7688
7799
  get when() {
7689
7800
  return should_show_previous_searches_in_query_part();
7690
7801
  },
@@ -7707,8 +7818,8 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
7707
7818
  });
7708
7819
  })();
7709
7820
  }
7710
- }), _el$12, _co$2);
7711
- (0, $9HbP8$insert)(_el$10, () => {
7821
+ }), _el$17, _co$4);
7822
+ (0, $9HbP8$insert)(_el$15, () => {
7712
7823
  const index_in_autocomplete = 2;
7713
7824
  set_list_until_cleanup(queries_memo, index_in_autocomplete);
7714
7825
  return (0, $9HbP8$createComponent)((0, $9HbP8$Index), {
@@ -7717,18 +7828,18 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
7717
7828
  },
7718
7829
  children: (item, index) => render_entry(item, index_in_autocomplete, index)
7719
7830
  });
7720
- }, _el$14, _co$3);
7721
- return _el$10;
7831
+ }, _el$19, _co$5);
7832
+ return _el$15;
7722
7833
  }
7723
- }), _el$19, _co$5);
7724
- (0, $9HbP8$insert)(_el$8, (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
7834
+ }), _el$24, _co$7);
7835
+ (0, $9HbP8$insert)(_el$13, (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
7725
7836
  get when() {
7726
- return not_queries_memo().length && include_category_suggestions_;
7837
+ return not_queries_memo().length;
7727
7838
  },
7728
7839
  keyed: false,
7729
7840
  get children() {
7730
- const _el$15 = (0, $9HbP8$getNextElement)($cea52f6b24092f05$var$_tmpl$7);
7731
- (0, $9HbP8$insert)(_el$15, () => {
7841
+ const _el$20 = (0, $9HbP8$getNextElement)($cea52f6b24092f05$var$_tmpl$8);
7842
+ (0, $9HbP8$insert)(_el$20, () => {
7732
7843
  const index_in_autocomplete = 3;
7733
7844
  set_list_until_cleanup(not_queries_memo, index_in_autocomplete);
7734
7845
  return (0, $9HbP8$createComponent)((0, $9HbP8$Index), {
@@ -7738,15 +7849,30 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
7738
7849
  children: (item, index) => render_entry(item, index_in_autocomplete, index)
7739
7850
  });
7740
7851
  });
7741
- return _el$15;
7852
+ return _el$20;
7742
7853
  }
7743
- }), _el$21, _co$6);
7744
- (0, $9HbP8$effect)(() => _el$8.classList.toggle("compact", !!on_previous_searches_page_()));
7745
- return _el$8;
7854
+ }), _el$26, _co$8);
7855
+ (0, $9HbP8$effect)(() => _el$13.classList.toggle("compact", !!on_previous_searches_page_()));
7856
+ return _el$13;
7746
7857
  }
7747
7858
  });
7748
7859
  }
7749
- const $15f380f0ce2812cc$var$_tmpl$ = /*#__PURE__*/(0, $9HbP8$template)(`<a target="_blank"></a>`, 2);
7860
+ const $92a48aea6a9364d8$var$_tmpl$ = /*#__PURE__*/(0, $9HbP8$template)(`<a target="_blank"></a>`, 2);
7861
+ function $92a48aea6a9364d8$export$1efe1013da60d0e4(e, href) {
7862
+ if (e.metaKey || e.ctrlKey) {
7863
+ // Open link in a new tab with cmd/ctrl + enter.
7864
+ const link = (() => {
7865
+ const _el$ = (0, $9HbP8$getNextElement)($92a48aea6a9364d8$var$_tmpl$);
7866
+ (0, $9HbP8$setAttribute)(_el$, "href", href);
7867
+ return _el$;
7868
+ })();
7869
+ document.body.append(link);
7870
+ link.click();
7871
+ link.remove();
7872
+ return true;
7873
+ }
7874
+ return false;
7875
+ }
7750
7876
  function $15f380f0ce2812cc$export$217899a935ef803b({
7751
7877
  selected_index_: [read_selected_index, write_selected_index],
7752
7878
  currently_showing_suggestions_: [read_currently_showing_suggestions],
@@ -7820,6 +7946,7 @@ function $15f380f0ce2812cc$var$actual_navigation_working_on_fake_data({
7820
7946
  const sfv = get_search_field_value();
7821
7947
  if (!(0, $9HbP8$untrack)(() => read_updating_blocked())) previous_value = sfv;
7822
7948
  });
7949
+ const owner = (0, $9HbP8$getOwner)();
7823
7950
  const handler = (0, $9HbP8$catchify)(({
7824
7951
  keyCode: keyCode
7825
7952
  }) => (0, $9HbP8$untrack)(() => {
@@ -7850,29 +7977,29 @@ function $15f380f0ce2812cc$var$actual_navigation_working_on_fake_data({
7850
7977
  const {
7851
7978
  title: title
7852
7979
  } = selected_entry;
7853
- block_updating_for_one_change();
7980
+ (0, $9HbP8$runWithOwner)(owner, block_updating_for_one_change);
7854
7981
  set_search_field_value(title);
7855
- override_on_enter_for_this_entry(e => {
7982
+ (0, $9HbP8$runWithOwner)(owner, () => override_on_enter_for_this_entry(e => {
7856
7983
  // Open search query in new tab on cmd+enter
7857
7984
  // If it's not cmd+enter, pressing enter will just submit the value that was put into the field while selecting with the arrow keys ;)
7858
7985
  const url = new URL(location);
7859
7986
  url_transformer_?.(url);
7860
7987
  url.searchParams.set(search_query_param_name_, title);
7861
- return $15f380f0ce2812cc$var$open_link_on_cmd_pressed(e, url.href);
7862
- });
7863
- } else if (selected_entry?.type == "category") override_on_enter_for_this_entry(e => {
7988
+ return (0, $92a48aea6a9364d8$export$1efe1013da60d0e4)(e, url.href);
7989
+ }));
7990
+ } else if (selected_entry?.type == "category" || selected_entry?.type === "content") (0, $9HbP8$runWithOwner)(owner, () => override_on_enter_for_this_entry(e => {
7864
7991
  const {
7865
7992
  page_url: page_url
7866
7993
  } = selected_entry;
7867
- if (!$15f380f0ce2812cc$var$open_link_on_cmd_pressed(e, page_url))
7994
+ if (!(0, $92a48aea6a9364d8$export$1efe1013da60d0e4)(e, page_url))
7868
7995
  // Above fn will return true if it opened a new tab, and we won't make these checks anymore
7869
7996
  router_.navigate_.go_to_({
7870
7997
  new_url_: page_url,
7871
7998
  is_replace_: false
7872
7999
  });
7873
8000
  return true;
7874
- });else if (!selected_entry) {
7875
- block_updating_for_one_change();
8001
+ }));else if (!selected_entry) {
8002
+ (0, $9HbP8$runWithOwner)(owner, block_updating_for_one_change);
7876
8003
  set_search_field_value(previous_value);
7877
8004
  }
7878
8005
  }));
@@ -7883,20 +8010,37 @@ function $15f380f0ce2812cc$var$actual_navigation_working_on_fake_data({
7883
8010
  (0, $9HbP8$onCleanup)((0, $9HbP8$catchify)(() => el.removeEventListener("keyup", handler)));
7884
8011
  });
7885
8012
  }
7886
- function $15f380f0ce2812cc$var$open_link_on_cmd_pressed(e, href) {
7887
- if (e.metaKey || e.ctrlKey) {
7888
- // Open link in a new tab with cmd/ctrl + enter.
7889
- const link = (() => {
7890
- const _el$ = (0, $9HbP8$getNextElement)($15f380f0ce2812cc$var$_tmpl$);
7891
- (0, $9HbP8$setAttribute)(_el$, "href", href);
7892
- return _el$;
7893
- })();
7894
- document.body.append(link);
7895
- link.click();
7896
- link.remove();
7897
- return true;
7898
- }
7899
- return false;
8013
+ function $1ae0eaca6ada9753$export$af0124069c150252({
8014
+ set_override_on_enter_fn_: set_override_on_enter_fn_,
8015
+ get_modal_search_results_: get_modal_search_results_,
8016
+ read_suggestion_signal_: read_suggestion_signal_,
8017
+ router_: router_,
8018
+ content_results_: content_results_
8019
+ }) {
8020
+ const [get_autocomplete_wants_override_function, set_autocomplete_wants_override_function] = (0, $9HbP8$createSignal)(() => false);
8021
+ (0, $9HbP8$createComputed)(() => {
8022
+ const suggestions = read_suggestion_signal_();
8023
+ const search_results = get_modal_search_results_()?.();
8024
+ const content_results = content_results_();
8025
+ // If we only have one content result and nothing else, go there when pressing enter
8026
+ if (!suggestions.length && !search_results?.displays?.length && content_results?.length === 1) {
8027
+ const [{
8028
+ page_url: page_url
8029
+ }] = content_results;
8030
+ set_override_on_enter_fn_(e => {
8031
+ if (!(0, $92a48aea6a9364d8$export$1efe1013da60d0e4)(e, page_url))
8032
+ // Above fn will return true if it opened a new tab, and we won't make these checks anymore
8033
+ router_.navigate_.go_to_({
8034
+ new_url_: page_url,
8035
+ is_replace_: false
8036
+ });
8037
+ return true;
8038
+ });
8039
+ return;
8040
+ }
8041
+ set_override_on_enter_fn_(get_autocomplete_wants_override_function());
8042
+ });
8043
+ return new_fn => set_autocomplete_wants_override_function(() => new_fn);
7900
8044
  }
7901
8045
  const $a0eb8b431ec1f87b$export$3cf9497e790da491 = "query";
7902
8046
  function $a0eb8b431ec1f87b$export$2f2b9559550c7bbc({
@@ -7916,12 +8060,15 @@ function $a0eb8b431ec1f87b$export$2f2b9559550c7bbc({
7916
8060
  i18n_: i18n_,
7917
8061
  include_category_suggestions_: include_category_suggestions_,
7918
8062
  submit_query_: submit_query_,
7919
- router_: router_
8063
+ router_: router_,
8064
+ get_modal_search_results_: get_modal_search_results_,
8065
+ content_search_enabled_: content_search_enabled_
7920
8066
  }) {
7921
8067
  const [searching_for_value, set_searching_for_value] = (0, $9HbP8$createSignal)();
8068
+ const [show_stale_content_results, set_show_stale_content_results] = (0, $9HbP8$createSignal)(false);
7922
8069
  const [read_search_field_value] = search_field_value_;
7923
8070
  const updating_blocked = (0, $9HbP8$createSignal)(false);
7924
- const [read_suggestion_signal, write_suggestion_signal] = (0, $9HbP8$createSignal)([]);
8071
+ const [read_suggestion_signal_, write_suggestion_signal] = (0, $9HbP8$createSignal)([]);
7925
8072
  const filtered_previous_searches = (0, $9HbP8$createMemo)(() => [...unfiltered_previous_searches[0]()].reverse().filter(q => q !== get_search_query_()));
7926
8073
  const deparallelized_fn = (0, $9HbP8$deparallelize_no_drop)(async request_obj => {
7927
8074
  const api_response = await depict_api_.suggest(request_obj);
@@ -7940,15 +8087,38 @@ function $a0eb8b431ec1f87b$export$2f2b9559550c7bbc({
7940
8087
  });
7941
8088
 
7942
8089
  const show_previous_searches_component = (0, $9HbP8$createMemo)(() => !read_search_field_value() || (0, $9HbP8$untrack)(updating_blocked[0]) && !(0, $9HbP8$untrack)(searching_for_value));
8090
+ const get_content_results_ = (0, $9HbP8$createMemo)(prev => {
8091
+ if (!content_search_enabled_()) return [];
8092
+ if (show_stale_content_results())
8093
+ // don't update content results when query suggestions don't update because otherwise they disappear when trying to keyboard navigate to them
8094
+ return prev;
8095
+ return get_modal_search_results_()?.()?.content_search_links?.map(link => ({
8096
+ page_url: link.page_url,
8097
+ type: "content",
8098
+ title: link.title
8099
+ }));
8100
+ });
8101
+ // Ideally we'd propagate up the suggestion signal too and call this from SearchModal.tsx? Because it's not super related with autocomplete, but it's not a huge feature, and it's easier here so keeping it.
8102
+ // It's the functionality to open the content results page when you press enter, in the modal, when there's only one content result
8103
+ const manipulated_set_override_on_enter_fn_ = (0, $1ae0eaca6ada9753$export$af0124069c150252)({
8104
+ set_override_on_enter_fn_: set_override_on_enter_fn_,
8105
+ get_modal_search_results_: get_modal_search_results_,
8106
+ read_suggestion_signal_: read_suggestion_signal_,
8107
+ router_: router_,
8108
+ content_results_: get_content_results_
8109
+ });
7943
8110
  (0, $9HbP8$createComputed)(() => {
7944
8111
  const field_value = read_search_field_value();
7945
- if (!(0, $9HbP8$untrack)(updating_blocked[0])) {
8112
+ if ((0, $9HbP8$untrack)(updating_blocked[0]))
8113
+ // not using updating_blocked instead of below signal since I presume they'd start updating too early then
8114
+ set_show_stale_content_results(true);else {
7946
8115
  set_searching_for_value(field_value);
7947
8116
  deparallelized_fn({
7948
8117
  query: field_value,
7949
8118
  tenant: tenant_(),
7950
8119
  market: market_()
7951
8120
  });
8121
+ set_show_stale_content_results(false);
7952
8122
  }
7953
8123
  });
7954
8124
  (0, $9HbP8$createComputed)((0, $9HbP8$on)(search_field_value_[0], () => !updating_blocked[0]() && selected_index_[1](undefined), {
@@ -7960,7 +8130,7 @@ function $a0eb8b431ec1f87b$export$2f2b9559550c7bbc({
7960
8130
  search_field_value_: search_field_value_,
7961
8131
  updating_blocked_: updating_blocked,
7962
8132
  currently_showing_suggestions_: currently_showing_suggestions_,
7963
- set_override_on_enter_fn_: set_override_on_enter_fn_,
8133
+ set_override_on_enter_fn_: manipulated_set_override_on_enter_fn_,
7964
8134
  search_query_param_name_: search_query_url_param_name_,
7965
8135
  url_transformer_: url_transformer_,
7966
8136
  router_: router_
@@ -7999,11 +8169,12 @@ function $a0eb8b431ec1f87b$export$2f2b9559550c7bbc({
7999
8169
  },
8000
8170
  on_previous_searches_page_: show_previous_searches_component,
8001
8171
  i18n_: i18n_,
8172
+ get_content_results_: get_content_results_,
8002
8173
  url_transformer_: url_transformer_,
8003
8174
  searching_for_value_: searching_for_value,
8004
8175
  search_query_url_param_name_: search_query_url_param_name_,
8005
8176
  selected_index_: selected_index_,
8006
- suggestion_memo_: read_suggestion_signal,
8177
+ suggestion_memo_: read_suggestion_signal_,
8007
8178
  currently_showing_suggestions_: currently_showing_suggestions_,
8008
8179
  include_category_suggestions_: include_category_suggestions_,
8009
8180
  router_: router_,
@@ -8107,7 +8278,8 @@ function $fabfda1230351b1a$export$1c593cbd6f1e10bc({
8107
8278
  bottom_distance_under_modal_: bottom_distance_under_modal_,
8108
8279
  selected_text_range_: selected_text_range_,
8109
8280
  dont_sync_search_field_value_except_on_submit_ = false,
8110
- router_: router_
8281
+ router_: router_,
8282
+ content_search_enabled_: content_search_enabled_
8111
8283
  }) {
8112
8284
  let on_enter_in_search_field_function;
8113
8285
  // As per feedback from stronger we sometimes want a modal with the search field value disconnected from the one in the rest of the UI, see https://depictaiworkspace.slack.com/archives/C02J16R9XEH/p1679065878487709.
@@ -8124,44 +8296,37 @@ function $fabfda1230351b1a$export$1c593cbd6f1e10bc({
8124
8296
  };
8125
8297
  const [input_field, set_input_field] = (0, $9HbP8$createSignal)();
8126
8298
  const [get_search_field_value_] = search_field_value_;
8127
- const [elements_outside_scrollable, set_elements_outside_scrollable] = (0, $9HbP8$createSignal)();
8128
- const [elements_inside_scrollable, set_elements_inside_scrollable] = (0, $9HbP8$createSignal)();
8299
+ const [get_modal_search_results, set_modal_search_results_] = (0, $9HbP8$createSignal)();
8129
8300
  const close_on_escape_handler = (0, $9HbP8$catchify)(({
8130
8301
  key: key
8131
8302
  }) => {
8132
8303
  if (key === "Escape") close_modal_();
8133
8304
  });
8134
- const [get_num_results_accessor, set_num_results_accessor_] = (0, $9HbP8$createSignal)();
8305
+ const [get_total_num_results_accessor, set_total_num_results_accessor_] = (0, $9HbP8$createSignal)();
8135
8306
  const selected_index = (0, $9HbP8$createSignal)();
8136
8307
  const currently_showing_suggestions_ = (0, $9HbP8$createSignal)([], {
8137
8308
  equals: false
8138
8309
  });
8310
+ const less_than_700_high = (0, $dc9262ef6f786812$export$d9f36cf74e24d595)("(max-height:700px)");
8311
+ const DiscoverMoreSection = () => (() => {
8312
+ const _el$ = (0, $9HbP8$getNextElement)($fabfda1230351b1a$var$_tmpl$),
8313
+ _el$2 = _el$.firstChild;
8314
+ (0, $9HbP8$addEventListener)(_el$2, "click", (0, $9HbP8$catchify)(() => submit_query_()), true);
8315
+ (0, $9HbP8$insert)(_el$2, (() => {
8316
+ const _c$ = (0, $9HbP8$memo)(() => !!get_search_field_value_());
8317
+ return () => _c$() ? i18n_.modal_view_all_results_()((() => {
8318
+ const _el$3 = (0, $9HbP8$getNextElement)($fabfda1230351b1a$var$_tmpl$2);
8319
+ (0, $9HbP8$insert)(_el$3, () => get_total_num_results_accessor?.());
8320
+ return _el$3;
8321
+ })()) : i18n_.modal_discover_more_();
8322
+ })());
8323
+ (0, $9HbP8$runHydrationEvents)();
8324
+ return _el$;
8325
+ })();
8139
8326
  if (disable_scrolling_) (0, $aea1edf92433e81e$export$fe334901e8bebd57)();
8140
8327
  $fabfda1230351b1a$var$close_modal_when_navigating_away(close_modal_, search_query_url_param_name_);
8141
8328
  window.addEventListener("keydown", close_on_escape_handler);
8142
8329
  (0, $9HbP8$onCleanup)((0, $9HbP8$catchify)(() => window.removeEventListener("keydown", close_on_escape_handler)));
8143
- const owner = (0, $9HbP8$getOwner)();
8144
- (0, $9HbP8$onCleanup)((0, $9HbP8$javascript_media_query)("(max-height:700px)", ({
8145
- matches: matches
8146
- }) => (0, $9HbP8$runWithOwner)(owner, () => {
8147
- // the if below is reactive so we need an owner
8148
- (matches ? set_elements_outside_scrollable : set_elements_inside_scrollable)("");
8149
- (matches ? set_elements_inside_scrollable : set_elements_outside_scrollable)((() => {
8150
- const _el$ = (0, $9HbP8$getNextElement)($fabfda1230351b1a$var$_tmpl$),
8151
- _el$2 = _el$.firstChild;
8152
- (0, $9HbP8$addEventListener)(_el$2, "click", (0, $9HbP8$catchify)(() => submit_query_()), true);
8153
- (0, $9HbP8$insert)(_el$2, (() => {
8154
- const _c$ = (0, $9HbP8$memo)(() => !!get_search_field_value_());
8155
- return () => _c$() ? i18n_.modal_view_all_results_()((() => {
8156
- const _el$3 = (0, $9HbP8$getNextElement)($fabfda1230351b1a$var$_tmpl$2);
8157
- (0, $9HbP8$insert)(_el$3, () => get_num_results_accessor?.());
8158
- return _el$3;
8159
- })()) : i18n_.modal_discover_more_();
8160
- })());
8161
- (0, $9HbP8$runHydrationEvents)();
8162
- return _el$;
8163
- })());
8164
- })).remove);
8165
8330
  if (closing_animation_) register_closing_animation_(closing_animation_);
8166
8331
  (0, $c64d28ca12452b21$export$3340fdd8259bd4fd)({
8167
8332
  get_search_field_value_: get_search_field_value_,
@@ -8243,7 +8408,9 @@ function $fabfda1230351b1a$export$1c593cbd6f1e10bc({
8243
8408
  i18n_: i18n_,
8244
8409
  include_category_suggestions_: enable_category_suggestions_ ?? true,
8245
8410
  router_: router_,
8246
- submit_query_: submit_query_
8411
+ submit_query_: submit_query_,
8412
+ get_modal_search_results_: get_modal_search_results,
8413
+ content_search_enabled_: content_search_enabled_
8247
8414
  });
8248
8415
  }
8249
8416
  }), _el$8, _co$);
@@ -8257,14 +8424,30 @@ function $fabfda1230351b1a$export$1c593cbd6f1e10bc({
8257
8424
  tenant_: tenant_,
8258
8425
  i18n_: i18n_,
8259
8426
  market_: market_,
8260
- set_num_results_accessor_: set_num_results_accessor_,
8427
+ set_total_num_results_accessor_: set_total_num_results_accessor_,
8261
8428
  router_: router_,
8429
+ set_modal_search_results_: set_modal_search_results_,
8430
+ content_search_enabled_: content_search_enabled_,
8262
8431
  ...instant_results_options_
8263
8432
  });
8264
8433
  }
8265
8434
  }), _el$10, _co$2);
8266
- (0, $9HbP8$insert)(_el$6, elements_inside_scrollable, _el$12, _co$3);
8267
- (0, $9HbP8$insert)(_el$5, elements_outside_scrollable, _el$16, _co$5);
8435
+ (0, $9HbP8$insert)(_el$6, (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
8436
+ get when() {
8437
+ return less_than_700_high();
8438
+ },
8439
+ get children() {
8440
+ return (0, $9HbP8$createComponent)(DiscoverMoreSection, {});
8441
+ }
8442
+ }), _el$12, _co$3);
8443
+ (0, $9HbP8$insert)(_el$5, (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
8444
+ get when() {
8445
+ return !less_than_700_high();
8446
+ },
8447
+ get children() {
8448
+ return (0, $9HbP8$createComponent)(DiscoverMoreSection, {});
8449
+ }
8450
+ }), _el$16, _co$5);
8268
8451
  (0, $9HbP8$insert)(_el$4, (0, $9HbP8$createComponent)((0, $19f1f3e588d63502$export$f021bdedd3ec901a), {
8269
8452
  styles: body_style
8270
8453
  }), _el$18, _co$6);
@@ -8369,11 +8552,13 @@ const $f8c929beb82c512b$var$_tmpl$ = /*#__PURE__*/(0, $9HbP8$template)(`<b></b>`
8369
8552
  function $f8c929beb82c512b$export$9dd50d35b9d94fdf({
8370
8553
  get_search_query_: get_search_query_,
8371
8554
  i18n_: i18n_,
8372
- formatted_number_of_results_: formatted_number_of_results_
8555
+ formatted_number_of_results_: formatted_number_of_results_,
8556
+ number_of_results_: number_of_results_,
8557
+ type: type
8373
8558
  }) {
8374
8559
  const contents = (0, $9HbP8$createMemo)((0, $9HbP8$catchify)(() => {
8375
8560
  const q = get_search_query_();
8376
- return i18n_.get_showing_results_for_()((() => {
8561
+ return i18n_[type === $f8c929beb82c512b$export$2452208c79fe93ea.content ? "get_showing_pages_for_" : "get_showing_results_for_"]()((() => {
8377
8562
  const _el$ = (0, $9HbP8$getNextElement)($f8c929beb82c512b$var$_tmpl$);
8378
8563
  (0, $9HbP8$insert)(_el$, q);
8379
8564
  return _el$;
@@ -8381,7 +8566,7 @@ function $f8c929beb82c512b$export$9dd50d35b9d94fdf({
8381
8566
  const _el$2 = (0, $9HbP8$getNextElement)($f8c929beb82c512b$var$_tmpl$);
8382
8567
  (0, $9HbP8$insert)(_el$2, formatted_number_of_results_);
8383
8568
  return _el$2;
8384
- })());
8569
+ })(), !!q, number_of_results_());
8385
8570
  }));
8386
8571
  return (() => {
8387
8572
  const _el$3 = (0, $9HbP8$getNextElement)($f8c929beb82c512b$var$_tmpl$2);
@@ -8389,6 +8574,11 @@ function $f8c929beb82c512b$export$9dd50d35b9d94fdf({
8389
8574
  return _el$3;
8390
8575
  })();
8391
8576
  }
8577
+ let $f8c929beb82c512b$export$2452208c79fe93ea;
8578
+ (function (ShowingResultsForType) {
8579
+ ShowingResultsForType[ShowingResultsForType["products"] = 0] = "products";
8580
+ ShowingResultsForType[ShowingResultsForType["content"] = 1] = "content";
8581
+ })($f8c929beb82c512b$export$2452208c79fe93ea || ($f8c929beb82c512b$export$2452208c79fe93ea = {}));
8392
8582
  function $1801dbce7adb3f19$export$41b4894022a3580f({
8393
8583
  style_props_ = (0, $9HbP8$createSignal)({})
8394
8584
  } = {}) {
@@ -8407,8 +8597,486 @@ function $1801dbce7adb3f19$export$41b4894022a3580f({
8407
8597
  })));
8408
8598
  return style_props_;
8409
8599
  }
8600
+ const $522a690e0e2bd46d$var$_tmpl$ = /*#__PURE__*/(0, $9HbP8$template)(`<span class="highlighted-part"></span>`, 2);
8601
+ const $522a690e0e2bd46d$var$dont_cut_in_between_less_than_characters = 30;
8602
+ function $522a690e0e2bd46d$export$e1a98a189fd2c0e7({
8603
+ content_result_: content_result_,
8604
+ key_: key_,
8605
+ cut_when_possible_: cut_when_possible_
8606
+ }) {
8607
+ const matched_tokens = (0, $9HbP8$createMemo)(() => content_result_().highlights?.find(highlight => highlight.field == key_)?.matched_tokens);
8608
+ const full_value = (0, $9HbP8$createMemo)(() => content_result_()[key_]?.replaceAll("\n", " "));
8609
+ return (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
8610
+ get when() {
8611
+ return matched_tokens()?.length;
8612
+ },
8613
+ get fallback() {
8614
+ return full_value();
8615
+ },
8616
+ get children() {
8617
+ return (() => {
8618
+ const segmented_cut_text = (0, $9HbP8$createMemo)(() => {
8619
+ const segmented_text = $522a690e0e2bd46d$var$segment_text(full_value(), matched_tokens());
8620
+ if (cut_when_possible_) $522a690e0e2bd46d$var$cut_text(segmented_text);
8621
+ return segmented_text;
8622
+ });
8623
+ return (0, $9HbP8$createComponent)((0, $9HbP8$Index), {
8624
+ get each() {
8625
+ return segmented_cut_text();
8626
+ },
8627
+ children: item => {
8628
+ return (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
8629
+ get when() {
8630
+ return item().highlighted_;
8631
+ },
8632
+ get fallback() {
8633
+ return item().text_;
8634
+ },
8635
+ get children() {
8636
+ const _el$ = (0, $9HbP8$getNextElement)($522a690e0e2bd46d$var$_tmpl$);
8637
+ (0, $9HbP8$insert)(_el$, () => item().text_);
8638
+ return _el$;
8639
+ }
8640
+ });
8641
+ }
8642
+ });
8643
+ })();
8644
+ }
8645
+ });
8646
+ }
8647
+ function $522a690e0e2bd46d$var$cut_text(segmented_text) {
8648
+ // cut away chunks of text that are not highlighted to give a google-like overview of the content
8649
+ const highlighted_segments = segmented_text?.filter(segment => segment.highlighted_);
8650
+ if (!segmented_text || !highlighted_segments?.length) return;
8651
+ // We have one or more highlighted segments
8652
+ if (highlighted_segments.length === 1) {
8653
+ // cut away from the left until the start of the highlighted sentence if just one sentence is highlighted
8654
+ $522a690e0e2bd46d$var$cut_start(segmented_text.indexOf(highlighted_segments[0]), segmented_text);
8655
+ return;
8656
+ }
8657
+ // We have two or more highlighted segments, take the two biggest chunks and show them + a bit text around
8658
+ const sorted_highlighted_segments = [...highlighted_segments].sort((a, b) => b.text_.trim().length - a.text_.trim().length // trim to avoid unfair comparisons due to whitespace
8659
+ );
8660
+
8661
+ const [longest_segment, next_longest_segment] = sorted_highlighted_segments;
8662
+ // We need to cut before the first segment - possibly through other segments - and maybe between segments
8663
+ let [index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
8664
+ $522a690e0e2bd46d$var$cut_start(index_of_first_segment, segmented_text);
8665
+ // update indexes since we might have removed segments
8666
+ [index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
8667
+ let number_of_characters_between_segments = 0;
8668
+ for (let i = index_of_first_segment + 1; i < index_of_second_segment; i++) {
8669
+ const segment = segmented_text[i];
8670
+ number_of_characters_between_segments += segment.text_.length;
8671
+ }
8672
+ if (number_of_characters_between_segments < $522a690e0e2bd46d$var$dont_cut_in_between_less_than_characters)
8673
+ // don't cut if there are less than 30 characters between the two segments
8674
+ return;
8675
+ // We have more than 50 characters between the two segments, cut between them
8676
+ const [split_start_segment, split_start_character] = $522a690e0e2bd46d$var$find_split_point(index_of_first_segment, index_of_second_segment, segmented_text);
8677
+ const [split_end_segment, split_end_character] = $522a690e0e2bd46d$var$find_split_point(index_of_second_segment, index_of_first_segment, segmented_text);
8678
+ if (split_start_segment === undefined || split_end_segment === undefined ||
8679
+ // identical split point, or split end before split start, can't do anything
8680
+ split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
8681
+ const dots_segment = {
8682
+ text_: " … ",
8683
+ highlighted_: false
8684
+ };
8685
+ const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
8686
+ if (i < split_start_segment || i > split_end_segment) return segment;
8687
+ const text = segment.text_;
8688
+ if (i == split_end_segment && i == split_start_segment) return [{
8689
+ ...segment,
8690
+ text_: text.slice(0, split_start_character).trimEnd()
8691
+ }, dots_segment, {
8692
+ ...segment,
8693
+ text_: text.slice(split_end_character + 1, text.length).trimStart()
8694
+ }];else if (i == split_start_segment) {
8695
+ segment.text_ = text.slice(0, split_start_character).trimEnd(); // this would be split_start_character + 1, but we want to remove the last "dot" because . ... looks weird
8696
+ return segment;
8697
+ } else if (i == split_end_segment) return [dots_segment, {
8698
+ ...segment,
8699
+ text_: text.slice(split_end_character + 1, text.length).trimStart()
8700
+ }];
8701
+ return []; // remove all segments inbetween
8702
+ });
8703
+
8704
+ segmented_text.splice(0, segmented_text.length, ...split_and_dotted_values); // Sorry…
8705
+ $522a690e0e2bd46d$var$heal_holes(segmented_text);
8706
+ }
8707
+ function $522a690e0e2bd46d$var$heal_holes(segmented_text) {
8708
+ // try to heal "holes" created in the segments so there are only alternating segments
8709
+ const segments_to_delete = new Set();
8710
+ for (let i = 0; i < segmented_text.length; i++) {
8711
+ const segment = segmented_text[i];
8712
+ let previous_segment;
8713
+ for (let j = i - 1; j >= 0; j--) {
8714
+ previous_segment = segmented_text[j];
8715
+ // Don't write to a segment that's marked for deletion or the contents we write to it will be deleted
8716
+ if (!segments_to_delete.has(previous_segment)) break;
8717
+ }
8718
+ if (previous_segment?.highlighted_ && segment.highlighted_ || previous_segment?.highlighted_ === false && segment.highlighted_ === false) {
8719
+ previous_segment.text_ += segment.text_; // IDK if this ever happens
8720
+ segments_to_delete.add(segment);
8721
+ }
8722
+ }
8723
+ for (const segment of segments_to_delete) {
8724
+ const index = segmented_text.indexOf(segment);
8725
+ segmented_text.splice(index, 1);
8726
+ }
8727
+ }
8728
+ function $522a690e0e2bd46d$var$find_split_point(index_of_start_segment, index_of_end_segment, segmented_text, be_very_aggressive = true) {
8729
+ const should_loop_backwards = index_of_start_segment > index_of_end_segment;
8730
+ const step = should_loop_backwards ? -1 : 1;
8731
+ const desperate_split_attempts = [":", ";", ","];
8732
+ while (desperate_split_attempts.length) {
8733
+ const split_point_between_words = [];
8734
+ // for the middle also try to split with a few more characters if the default ones don't work over a full run
8735
+ const desperate_split_attempt = desperate_split_attempts.pop();
8736
+ let is_first_character = true;
8737
+ for (let i = index_of_start_segment + step; should_loop_backwards ? i > index_of_end_segment : i < index_of_end_segment; i += step) {
8738
+ const segment = segmented_text[i];
8739
+ const text = segment.text_;
8740
+ for (let j = should_loop_backwards ? text.length - 1 : 0; should_loop_backwards ? j >= 0 : j < text.length; j += step) {
8741
+ const character = text[j];
8742
+ if (character == "." || character == "?" || character == "!" || character == desperate_split_attempt) return [i, j]; // segment index, character index
8743
+ if (is_first_character) is_first_character = false;else if (be_very_aggressive && character == " ") {
8744
+ split_point_between_words.push([i, j]);
8745
+ if (split_point_between_words.length > 3)
8746
+ // We can't find a split point, so we'll just split between words
8747
+ // This is because for UI reasons we only want to show 2 lines of text, so we need to be very aggressive with getting the second match soon
8748
+ return split_point_between_words[1];
8749
+ }
8750
+ }
8751
+ }
8752
+ }
8753
+ return [];
8754
+ }
8755
+ function $522a690e0e2bd46d$var$cut_start(cut_left_of_index, segmented_text) {
8756
+ // Cut the start of the text to bring the first matching token
8757
+ let is_first_character = false;
8758
+ let words_encountered = 0;
8759
+ outmost_loop: for (let i = cut_left_of_index - 1; i >= 0; i--) {
8760
+ const segment = segmented_text[i];
8761
+ // We assume that two adjacent highlighted segments don't exist and have been merged if they were to have existed
8762
+ const text = segment.text_;
8763
+ for (let j = text.length - 1; j >= 0; j--) {
8764
+ const character = text[j];
8765
+ const is_space = character == " ";
8766
+ if (!is_first_character && is_space) words_encountered++;
8767
+ if (character == "." || character == "?" || character == "!" || character == "," || words_encountered > 8 && is_space) {
8768
+ // We have to be really aggressive at the start of sentences so stuff can be seen on mobile, hence comma
8769
+ segment.text_ = text.slice(j + 1).trimStart();
8770
+ segmented_text.splice(0, i);
8771
+ if (character === "," || is_space)
8772
+ // if we cut at a comma or psace, we add a … at the beginning
8773
+ segmented_text.unshift({
8774
+ text_: "… ",
8775
+ highlighted_: false
8776
+ });
8777
+ break outmost_loop;
8778
+ }
8779
+ if (is_first_character) is_first_character = false;
8780
+ }
8781
+ }
8782
+ $522a690e0e2bd46d$var$heal_holes(segmented_text); // if we added a ... there could now be a sequence that's not alternating true/false
8783
+ }
8784
+
8785
+ function $522a690e0e2bd46d$var$segment_text(text, matched_strings) {
8786
+ // segment text where the matched strings are highlighted sections
8787
+ const output = [];
8788
+ if (!text) return; // shouldn't happen but whatever
8789
+ for (let i = 0; i < text.length; i++) {
8790
+ const found_strings = [];
8791
+ if (!i || text[i - 1] == " ")
8792
+ // only match at the start of a word or string, it looks weird if i.e. "we" is highlighted in "activewear
8793
+ for (let j = 0; j < matched_strings.length; j++) {
8794
+ const matched_string = matched_strings[j];
8795
+ const part_in_text = text.slice(i, i + matched_string.length);
8796
+ if (matched_string.length < 2) continue; // don't match on single characters, i.e. "I", it looks weird
8797
+ if (part_in_text.toLowerCase() === matched_string.toLowerCase()) found_strings.push(part_in_text); // use the casing from the text, not from typesense, can look weird otherwise
8798
+ }
8799
+
8800
+ const last_index_in_output = output.length - 1;
8801
+ if (!found_strings.length) {
8802
+ const character = text[i];
8803
+ if (output[last_index_in_output]?.highlighted_ === false || output.length && /\s/.test(character))
8804
+ // always push whitespace characters to the last segment, this is because typesense doesn't see them as part of the matched tokens but we want to be able to detect "phat" matched segments
8805
+ output[last_index_in_output].text_ += character;else output.push({
8806
+ highlighted_: false,
8807
+ text_: character
8808
+ });
8809
+ } else {
8810
+ const longest_found_string = found_strings.reduce((a, b) => a.length > b.length ? a : b);
8811
+ if (output[last_index_in_output]?.highlighted_) output[last_index_in_output].text_ += longest_found_string;else output.push({
8812
+ highlighted_: true,
8813
+ text_: longest_found_string
8814
+ });
8815
+ i += longest_found_string.length - 1;
8816
+ }
8817
+ }
8818
+ return output;
8819
+ }
8820
+ const $b2bf2cdcff8142d8$var$_tmpl$ = /*#__PURE__*/(0, $9HbP8$template)(`<a></a>`, 2),
8821
+ $b2bf2cdcff8142d8$var$_tmpl$2 = /*#__PURE__*/(0, $9HbP8$template)(`<div></div>`, 2),
8822
+ $b2bf2cdcff8142d8$var$_tmpl$3 = /*#__PURE__*/(0, $9HbP8$template)(`<div class="description line-clamp"></div>`, 2),
8823
+ $b2bf2cdcff8142d8$var$_tmpl$4 = /*#__PURE__*/(0, $9HbP8$template)(`<div class="content-card"><div class="image"></div><div class="info"><!#><!/><!#><!/></div></div>`, 10);
8824
+ function $b2bf2cdcff8142d8$export$f631859cab12b342({
8825
+ router_: router_,
8826
+ content_result_: content_result_
8827
+ }) {
8828
+ const make_link_attributes = () => {
8829
+ const result = content_result_?.();
8830
+ if (!result) return;
8831
+ return {
8832
+ href: result.page_url,
8833
+ onClick: (0, $9HbP8$catchify)(ev => router_.navigate_.go_to_({
8834
+ new_url_: result.page_url,
8835
+ is_replace_: false,
8836
+ event_: ev
8837
+ }))
8838
+ };
8839
+ };
8840
+ const LinkIfPossible = ({
8841
+ children: children,
8842
+ ...attributes
8843
+ }) => {
8844
+ if (content_result_) return (() => {
8845
+ const _el$ = (0, $9HbP8$getNextElement)($b2bf2cdcff8142d8$var$_tmpl$);
8846
+ (0, $9HbP8$spread)(_el$, attributes, false, true);
8847
+ (0, $9HbP8$insert)(_el$, children);
8848
+ (0, $9HbP8$runHydrationEvents)();
8849
+ return _el$;
8850
+ })();
8851
+ return (() => {
8852
+ const _el$2 = (0, $9HbP8$getNextElement)($b2bf2cdcff8142d8$var$_tmpl$2);
8853
+ (0, $9HbP8$spread)(_el$2, attributes, false, true);
8854
+ (0, $9HbP8$insert)(_el$2, children);
8855
+ (0, $9HbP8$runHydrationEvents)();
8856
+ return _el$2;
8857
+ })();
8858
+ };
8859
+ return (() => {
8860
+ const _el$3 = (0, $9HbP8$getNextElement)($b2bf2cdcff8142d8$var$_tmpl$4),
8861
+ _el$4 = _el$3.firstChild,
8862
+ _el$5 = _el$4.nextSibling,
8863
+ _el$7 = _el$5.firstChild,
8864
+ [_el$8, _co$] = (0, $9HbP8$getNextMarker)(_el$7.nextSibling),
8865
+ _el$9 = _el$8.nextSibling,
8866
+ [_el$10, _co$2] = (0, $9HbP8$getNextMarker)(_el$9.nextSibling);
8867
+ (0, $9HbP8$insert)(_el$4, (0, $9HbP8$createComponent)(LinkIfPossible, (0, $9HbP8$mergeProps)(make_link_attributes, {
8868
+ tabIndex: "-1",
8869
+ get children() {
8870
+ return (0, $9HbP8$createComponent)((0, $190927650b4840eb$export$605674723bcc715c), {
8871
+ width: "28",
8872
+ height: "28"
8873
+ });
8874
+ }
8875
+ })));
8876
+ (0, $9HbP8$insert)(_el$5, (0, $9HbP8$createComponent)(LinkIfPossible, (0, $9HbP8$mergeProps)({
8877
+ "class": "content-title line-clamp"
8878
+ }, make_link_attributes, {
8879
+ get title() {
8880
+ return content_result_?.().title;
8881
+ },
8882
+ get children() {
8883
+ return content_result_ ? (0, $9HbP8$createComponent)((0, $522a690e0e2bd46d$export$e1a98a189fd2c0e7), {
8884
+ content_result_: content_result_,
8885
+ key_: "title",
8886
+ cut_when_possible_: false
8887
+ }) : (0, $9HbP8$createComponent)((0, $d134eae24341b4a1$export$89c6019e4baa40b1), {
8888
+ height: "1em",
8889
+ width: "20ch"
8890
+ });
8891
+ }
8892
+ })), _el$8, _co$);
8893
+ (0, $9HbP8$insert)(_el$5, (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
8894
+ get when() {
8895
+ return content_result_?.().description || !content_result_;
8896
+ },
8897
+ get children() {
8898
+ const _el$6 = (0, $9HbP8$getNextElement)($b2bf2cdcff8142d8$var$_tmpl$3);
8899
+ (0, $9HbP8$insert)(_el$6, (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
8900
+ when: content_result_,
8901
+ get fallback() {
8902
+ return Array.from({
8903
+ length: 4
8904
+ }).map(() => (0, $9HbP8$createComponent)((0, $d134eae24341b4a1$export$89c6019e4baa40b1), {
8905
+ height: "1em",
8906
+ width: "min(50ch, 100%)"
8907
+ }));
8908
+ },
8909
+ get children() {
8910
+ return (0, $9HbP8$createComponent)((0, $522a690e0e2bd46d$export$e1a98a189fd2c0e7), {
8911
+ content_result_: content_result_,
8912
+ key_: "description",
8913
+ cut_when_possible_: true
8914
+ });
8915
+ }
8916
+ }));
8917
+ return _el$6;
8918
+ }
8919
+ }), _el$10, _co$2);
8920
+ return _el$3;
8921
+ })();
8922
+ }
8923
+ function $b26bdbd081f63e3f$export$9ff751cd77687edc({
8924
+ search_results_: search_results_,
8925
+ router_: router_
8926
+ }) {
8927
+ const content_results = (0, $9HbP8$createMemo)(() => search_results_()?.content_search_links);
8928
+ const content_results_by_page_url = (0, $9HbP8$createMemo)(() => {
8929
+ const map = new Map();
8930
+ const results = content_results();
8931
+ if (!results) return map;
8932
+ for (let i = 0; i < results.length; i++) {
8933
+ const content_result = results[i];
8934
+ map.set(content_result.page_url, content_result);
8935
+ }
8936
+ return map;
8937
+ });
8938
+ return (0, $9HbP8$createComponent)((0, $9HbP8$For), {
8939
+ get each() {
8940
+ return [...content_results_by_page_url().keys()];
8941
+ },
8942
+ children: page_url => {
8943
+ const content_result = (0, $9HbP8$createMemo)(() => content_results_by_page_url().get(page_url));
8944
+ return (0, $9HbP8$createComponent)((0, $b2bf2cdcff8142d8$export$f631859cab12b342), {
8945
+ content_result_: content_result,
8946
+ router_: router_
8947
+ });
8948
+ }
8949
+ });
8950
+ }
8951
+ function $9d5b3ed1fc91c672$export$4405d077f0a20494({
8952
+ content_results_rows_: [get_history_state_content_results_rows],
8953
+ cols_at_size_: cols_at_size_
8954
+ }) {
8955
+ const largest_column = (0, $9HbP8$createMemo)(() => {
8956
+ const largest_in_cols_at_size = Math.max(...cols_at_size_().map(([cols]) => cols));
8957
+ if (isNaN(largest_in_cols_at_size) || Math.abs(largest_in_cols_at_size) === Infinity) return 4; // fallback to something big so we always have the right amount of placeholders
8958
+ return largest_in_cols_at_size;
8959
+ });
8960
+ const num_placeholders = (0, $9HbP8$createMemo)(() => (get_history_state_content_results_rows() ?? (0, $49de9d31aeea1b5e$export$70ceae36059a1036)) * largest_column());
8961
+ return (0, $9HbP8$createComponent)((0, $9HbP8$Index), {
8962
+ get each() {
8963
+ return Array.from({
8964
+ length: num_placeholders()
8965
+ });
8966
+ },
8967
+ children: () => (0, $9HbP8$createComponent)((0, $b2bf2cdcff8142d8$export$f631859cab12b342), {})
8968
+ });
8969
+ }
8970
+ const $49de9d31aeea1b5e$var$_tmpl$ = /*#__PURE__*/(0, $9HbP8$template)(`<div class="content-results"><!#><!/><!#><!/></div>`, 6),
8971
+ $49de9d31aeea1b5e$var$_tmpl$2 = /*#__PURE__*/(0, $9HbP8$template)(`<button class="view-more"></button>`, 2),
8972
+ $49de9d31aeea1b5e$var$_tmpl$3 = /*#__PURE__*/(0, $9HbP8$template)(`<button class="view-less"></button>`, 2);
8973
+ const $49de9d31aeea1b5e$export$70ceae36059a1036 = 1;
8974
+ function $49de9d31aeea1b5e$export$6d0c9c22f6652669({
8975
+ search_results_: search_results_,
8976
+ get_search_query_: get_search_query_,
8977
+ i18n_: i18n_,
8978
+ layout_options_: layout_options_,
8979
+ router_: router_,
8980
+ query_base_: query_base_,
8981
+ content_results_rows_: content_results_rows_
8982
+ }) {
8983
+ const content_results = (0, $9HbP8$createMemo)(() => search_results_()?.content_search_links);
8984
+ const num_results = (0, $9HbP8$createMemo)(() => content_results()?.length);
8985
+ const is_loading_ = (0, $9HbP8$createMemo)(() => search_results_.loading || query_base_.loading); // See comment in PLPResults/index.tsx on why we need this
8986
+ const formatted_number_of_results_ = (0, $511cc0abd9a64ce8$export$92f2da32c6e7e7ee)({
8987
+ number_: num_results,
8988
+ i18n_: i18n_
8989
+ });
8990
+ const [is_showing_placeholders, set_is_showing_placeholders] = (0, $9HbP8$createSignal)(false);
8991
+ const rows_object = $49de9d31aeea1b5e$var$make_state_saved_rows(content_results_rows_, i18n_);
8992
+ return (() => {
8993
+ const _el$ = (0, $9HbP8$getNextElement)($49de9d31aeea1b5e$var$_tmpl$),
8994
+ _el$2 = _el$.firstChild,
8995
+ [_el$3, _co$] = (0, $9HbP8$getNextMarker)(_el$2.nextSibling),
8996
+ _el$4 = _el$3.nextSibling,
8997
+ [_el$5, _co$2] = (0, $9HbP8$getNextMarker)(_el$4.nextSibling);
8998
+ (0, $9HbP8$insert)(_el$, (0, $9HbP8$createComponent)((0, $f8c929beb82c512b$export$9dd50d35b9d94fdf), {
8999
+ get_search_query_: get_search_query_,
9000
+ i18n_: i18n_,
9001
+ formatted_number_of_results_: formatted_number_of_results_,
9002
+ get type() {
9003
+ return (0, $f8c929beb82c512b$export$2452208c79fe93ea).content;
9004
+ },
9005
+ number_of_results_: num_results
9006
+ }), _el$3, _co$);
9007
+ (0, $9HbP8$insert)(_el$, (0, $9HbP8$createComponent)((0, $c8d5ff4524619fcd$export$d21e32dfedac04be), (0, $9HbP8$mergeProps)({
9008
+ layout: "grid",
9009
+ element_attributes: {
9010
+ class: "cards"
9011
+ }
9012
+ }, layout_options_, {
9013
+ rows: rows_object,
9014
+ get children() {
9015
+ return (0, $9HbP8$createComponent)((0, $9HbP8$Suspense), {
9016
+ get fallback() {
9017
+ return (() => {
9018
+ set_is_showing_placeholders(true);
9019
+ (0, $9HbP8$onCleanup)(() => set_is_showing_placeholders(false));
9020
+ return (0, $9HbP8$createComponent)((0, $9d5b3ed1fc91c672$export$4405d077f0a20494), {
9021
+ content_results_rows_: content_results_rows_,
9022
+ get cols_at_size_() {
9023
+ return (0, $9HbP8$createMemo)(() => layout_options_().cols_at_size);
9024
+ }
9025
+ });
9026
+ })();
9027
+ },
9028
+ get children() {
9029
+ return (0, $9HbP8$createComponent)((0, $b26bdbd081f63e3f$export$9ff751cd77687edc), {
9030
+ router_: router_,
9031
+ search_results_: search_results_
9032
+ });
9033
+ }
9034
+ });
9035
+ }
9036
+ })), _el$5, _co$2);
9037
+ (0, $9HbP8$effect)(_p$ => {
9038
+ const _v$ = !!is_showing_placeholders(),
9039
+ _v$2 = is_loading_() || content_results()?.length > 0 ? "" : "none";
9040
+ _v$ !== _p$._v$ && _el$.classList.toggle("loading", _p$._v$ = _v$);
9041
+ _v$2 !== _p$._v$2 && _el$.style.setProperty("display", _p$._v$2 = _v$2);
9042
+ return _p$;
9043
+ }, {
9044
+ _v$: undefined,
9045
+ _v$2: undefined
9046
+ });
9047
+ return _el$;
9048
+ })();
9049
+ }
9050
+ function $49de9d31aeea1b5e$var$make_state_saved_rows(
9051
+ // similar to the one in SearchRecommendations.tsx but not enough to warrant a shared function IMO
9052
+ [get_showing_content_results_rows, set_showing_content_results_rows], i18n_) {
9053
+ const currently_visible = (0, $9HbP8$createSignal)((0, $9HbP8$untrack)(get_showing_content_results_rows));
9054
+ const [get_currently_visible, set_currently_visible] = currently_visible;
9055
+ const rows = {
9056
+ currently_visible: currently_visible,
9057
+ start_rows: $49de9d31aeea1b5e$export$70ceae36059a1036,
9058
+ button: (() => {
9059
+ const _el$6 = (0, $9HbP8$getNextElement)($49de9d31aeea1b5e$var$_tmpl$2);
9060
+ (0, $9HbP8$insert)(_el$6, () => i18n_.view_more_());
9061
+ return _el$6;
9062
+ })(),
9063
+ view_less_button: (() => {
9064
+ const _el$7 = (0, $9HbP8$getNextElement)($49de9d31aeea1b5e$var$_tmpl$3);
9065
+ (0, $9HbP8$insert)(_el$7, () => i18n_.view_less_());
9066
+ return _el$7;
9067
+ })(),
9068
+ rows_per_click: 3
9069
+ };
9070
+ (0, $9HbP8$createComputed)((0, $9HbP8$on)(get_currently_visible, new_visible => set_showing_content_results_rows(new_visible), {
9071
+ defer: true
9072
+ }));
9073
+ (0, $9HbP8$createComputed)((0, $9HbP8$on)(get_showing_content_results_rows, (new_rows = $49de9d31aeea1b5e$export$70ceae36059a1036) => set_currently_visible(new_rows), {
9074
+ defer: true
9075
+ }));
9076
+ return rows;
9077
+ }
8410
9078
  const $7097477c78a89208$var$_tmpl$ = /*#__PURE__*/(0, $9HbP8$template)(`<div class="filter-results-for-one-row"><!#><!/><!#><!/></div>`, 6),
8411
- $7097477c78a89208$var$_tmpl$2 = /*#__PURE__*/(0, $9HbP8$template)(`<div class="depict plp search"><div class="listing-page"><!#><!/><!#><!/><!#><!/><!#><!/><!#><!/><!#><!/></div><!#><!/><!#><!/></div>`, 20);
9079
+ $7097477c78a89208$var$_tmpl$2 = /*#__PURE__*/(0, $9HbP8$template)(`<div class="depict plp search"><div class="listing-page"><!#><!/><!#><!/><!#><!/><!#><!/><!#><!/><!#><!/><!#><!/></div><!#><!/><!#><!/></div>`, 22);
8412
9080
  function $7097477c78a89208$export$a54ec244c8863715({
8413
9081
  depict_api_: depict_api_,
8414
9082
  search_field_value_: search_field_value_,
@@ -8437,7 +9105,11 @@ function $7097477c78a89208$export$a54ec244c8863715({
8437
9105
  recommendations_layout_options_: recommendations_layout_options_,
8438
9106
  scroll_restoration_data_: scroll_restoration_data_,
8439
9107
  product_card_template_: product_card_template_,
8440
- modal_body_style_ref_: modal_body_style_ref_
9108
+ modal_body_style_ref_: modal_body_style_ref_,
9109
+ router_: router_,
9110
+ content_results_rows_: content_results_rows_,
9111
+ content_layout_options_: content_layout_options_,
9112
+ content_search_enabled_: content_search_enabled_
8441
9113
  }) {
8442
9114
  const [get_sorting] = current_sorting_;
8443
9115
  const all_products_loaded_ = (0, $9HbP8$createSignal)(false);
@@ -8495,16 +9167,23 @@ function $7097477c78a89208$export$a54ec244c8863715({
8495
9167
  const SafeSearchField = (0, $9HbP8$catchify)((0, $5285d2814d0fac0c$export$b94867ecbd698f21));
8496
9168
  const [sort_or_filter_open_, set_sort_or_filter_open_] = (0, $9HbP8$createSignal)(false);
8497
9169
  const [desktop_filter_elements_, set_desktop_filter_elements] = (0, $9HbP8$createSignal)();
9170
+ const n_hits = (0, $9HbP8$createMemo)(() => search_results_()?.n_hits);
8498
9171
  const formatted_number_of_results_ = (0, $511cc0abd9a64ce8$export$92f2da32c6e7e7ee)({
8499
- search_results_: search_results_,
9172
+ number_: n_hits,
8500
9173
  i18n_: i18n_
8501
9174
  });
8502
9175
  const [sort_and_filter_element_, set_sort_and_filter_element_] = (0, $9HbP8$createSignal)();
8503
- const results_for = (0, $9HbP8$createComponent)((0, $f8c929beb82c512b$export$9dd50d35b9d94fdf), {
9176
+ const no_results_text_ = (0, $9HbP8$createMemo)(() => (search_results_()?.content_search_links?.length ? i18n_.no_products_ : i18n_.no_results_text_)());
9177
+ const results_for = (0, $9HbP8$createComponent)((0, $f8c929beb82c512b$export$9dd50d35b9d94fdf), (0, $9HbP8$mergeProps)({
9178
+ get type() {
9179
+ return (0, $f8c929beb82c512b$export$2452208c79fe93ea).products;
9180
+ },
9181
+ number_of_results_: n_hits
9182
+ }, {
8504
9183
  get_search_query_: get_search_query_,
8505
9184
  i18n_: i18n_,
8506
9185
  formatted_number_of_results_: formatted_number_of_results_
8507
- });
9186
+ }));
8508
9187
  const filters_opener = (0, $cdea4cf8c5c071ef$export$d7841e452f2e59a8)({
8509
9188
  set_sort_or_filter_open_: set_sort_or_filter_open_,
8510
9189
  set_extra_els_in_results_container_: set_desktop_filter_elements,
@@ -8622,10 +9301,12 @@ function $7097477c78a89208$export$a54ec244c8863715({
8622
9301
  [_el$17, _co$7] = (0, $9HbP8$getNextMarker)(_el$16.nextSibling),
8623
9302
  _el$18 = _el$17.nextSibling,
8624
9303
  [_el$19, _co$8] = (0, $9HbP8$getNextMarker)(_el$18.nextSibling),
8625
- _el$20 = _el$7.nextSibling,
9304
+ _el$20 = _el$19.nextSibling,
8626
9305
  [_el$21, _co$9] = (0, $9HbP8$getNextMarker)(_el$20.nextSibling),
8627
- _el$22 = _el$21.nextSibling,
8628
- [_el$23, _co$10] = (0, $9HbP8$getNextMarker)(_el$22.nextSibling);
9306
+ _el$22 = _el$7.nextSibling,
9307
+ [_el$23, _co$10] = (0, $9HbP8$getNextMarker)(_el$22.nextSibling),
9308
+ _el$24 = _el$23.nextSibling,
9309
+ [_el$25, _co$11] = (0, $9HbP8$getNextMarker)(_el$24.nextSibling);
8629
9310
  (0, $9HbP8$insert)(_el$7, get_search_field_elements, _el$9, _co$3);
8630
9311
  (0, $9HbP8$insert)(_el$7, make_category_suggestion_card_ ? (0, $9HbP8$createComponent)((0, $b7436a6d1fd64e3b$export$b69d0d92862de18b), {
8631
9312
  severity_: "error",
@@ -8637,7 +9318,29 @@ function $7097477c78a89208$export$a54ec244c8863715({
8637
9318
  });
8638
9319
  }
8639
9320
  }) : null, _el$11, _co$4);
8640
- (0, $9HbP8$insert)(_el$7, () => results_filters[0](), _el$13, _co$5);
9321
+ (0, $9HbP8$insert)(_el$7, (0, $9HbP8$createComponent)((0, $b7436a6d1fd64e3b$export$b69d0d92862de18b), {
9322
+ severity_: "error",
9323
+ message_: "ContentResults failed",
9324
+ get children() {
9325
+ return (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
9326
+ get when() {
9327
+ return content_search_enabled_();
9328
+ },
9329
+ get children() {
9330
+ return (0, $9HbP8$createComponent)((0, $49de9d31aeea1b5e$export$6d0c9c22f6652669), {
9331
+ content_results_rows_: content_results_rows_,
9332
+ search_results_: search_results_,
9333
+ i18n_: i18n_,
9334
+ get_search_query_: get_search_query_,
9335
+ layout_options_: content_layout_options_,
9336
+ router_: router_,
9337
+ query_base_: search_query_base_
9338
+ });
9339
+ }
9340
+ });
9341
+ }
9342
+ }), _el$13, _co$5);
9343
+ (0, $9HbP8$insert)(_el$7, () => results_filters[0](), _el$15, _co$6);
8641
9344
  (0, $9HbP8$insert)(_el$7, (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
8642
9345
  get when() {
8643
9346
  return selected_filters_[0]()?.length;
@@ -8660,7 +9363,7 @@ function $7097477c78a89208$export$a54ec244c8863715({
8660
9363
  }
8661
9364
  });
8662
9365
  }
8663
- }), _el$15, _co$6);
9366
+ }), _el$17, _co$7);
8664
9367
  (0, $9HbP8$insert)(_el$7, (0, $9HbP8$createComponent)((0, $b7436a6d1fd64e3b$export$b69d0d92862de18b), {
8665
9368
  severity_: "error",
8666
9369
  message_: "Search results failed",
@@ -8683,11 +9386,14 @@ function $7097477c78a89208$export$a54ec244c8863715({
8683
9386
  selected_filters_: selected_filters_,
8684
9387
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
8685
9388
  local_filter_cache_: local_filter_cache_,
8686
- i18n_: i18n_
9389
+ i18n_: {
9390
+ ...i18n_,
9391
+ no_results_text_: no_results_text_
9392
+ }
8687
9393
  }
8688
9394
  });
8689
9395
  }
8690
- }), _el$17, _co$7);
9396
+ }), _el$19, _co$8);
8691
9397
  (0, $9HbP8$insert)(_el$7, (0, $9HbP8$createComponent)((0, $9HbP8$Show), {
8692
9398
  get when() {
8693
9399
  return get_all_products_loaded() && !disable_search_recommendations_;
@@ -8712,7 +9418,7 @@ function $7097477c78a89208$export$a54ec244c8863715({
8712
9418
  }
8713
9419
  });
8714
9420
  }
8715
- }), _el$19, _co$8);
9421
+ }), _el$21, _co$9);
8716
9422
  (0, $9HbP8$insert)(_el$6, (0, $9HbP8$createComponent)((0, $b7436a6d1fd64e3b$export$b69d0d92862de18b), {
8717
9423
  message_: "Scroll status failed",
8718
9424
  severity_: "error",
@@ -8725,7 +9431,7 @@ function $7097477c78a89208$export$a54ec244c8863715({
8725
9431
  number_of_results_: (0, $9HbP8$createMemo)(() => search_results_()?.n_hits)
8726
9432
  });
8727
9433
  }
8728
- }), _el$21, _co$9);
9434
+ }), _el$23, _co$10);
8729
9435
  (0, $9HbP8$insert)(_el$6, (0, $9HbP8$createComponent)((0, $b7436a6d1fd64e3b$export$b69d0d92862de18b), {
8730
9436
  message_: "Floating buttons failed",
8731
9437
  severity_: "error",
@@ -8738,7 +9444,7 @@ function $7097477c78a89208$export$a54ec244c8863715({
8738
9444
  i18n_: i18n_
8739
9445
  });
8740
9446
  }
8741
- }), _el$23, _co$10);
9447
+ }), _el$25, _co$11);
8742
9448
  (0, $9HbP8$effect)(() => (0, $9HbP8$setAttribute)(_el$6, "id", (0, $f86ba724282f6690$export$44dad306455dddf).SEARCH_PAGE));
8743
9449
  return _el$6;
8744
9450
  })()];
@@ -8763,6 +9469,27 @@ function $4ca91518c9a35379$export$828dcdd425fd3231(aligner) {
8763
9469
  cleanup: cleanup
8764
9470
  };
8765
9471
  }
9472
+
9473
+ /**
9474
+ * Content results ContentCard look stupid on mobile if there are two columns of them, so we limit the number of columns to 1 if the screen is too small
9475
+ */
9476
+ function $1848f7cca286fbab$export$ff7109b9b2b206ba(sdk_cols_at_size, min_width_for_more_than_one_column = 500) {
9477
+ if (!sdk_cols_at_size.length) return sdk_cols_at_size;
9478
+ const sorted_sizes = sdk_cols_at_size.map(([cols, max_width]) => [cols, max_width ?? Infinity]).sort(([, a], [, b]) => a - b);
9479
+ const [[, smallest_max_width]] = sorted_sizes;
9480
+ if (smallest_max_width > min_width_for_more_than_one_column)
9481
+ // If everything above min_width_for_more_than_one_column, we can just add a 1 column at the beginning
9482
+ return [[1, min_width_for_more_than_one_column], ...sdk_cols_at_size];
9483
+ const to_delete = [];
9484
+ for (let i = 0; i < sorted_sizes.length; i++) {
9485
+ const [, max_width] = sorted_sizes[i];
9486
+ if (max_width > min_width_for_more_than_one_column) continue;
9487
+ to_delete.push(i);
9488
+ }
9489
+ while (to_delete.length) sorted_sizes.splice(to_delete.pop(), 1);
9490
+ sorted_sizes.unshift([1, min_width_for_more_than_one_column]);
9491
+ return sorted_sizes.map(([cols, max_width]) => max_width == Infinity ? [cols] : [cols, max_width]);
9492
+ }
8766
9493
  const $806c97b931758897$var$_tmpl$ = /*#__PURE__*/(0, $9HbP8$template)(`<div class="depict plp search"></div>`, 2);
8767
9494
  // We just pass page_url_creator to DepictAPI when we instantiate it, so don't allow it to be specified if api is already specified
8768
9495
  /**
@@ -8772,6 +9499,7 @@ const $806c97b931758897$var$_tmpl$ = /*#__PURE__*/(0, $9HbP8$template)(`<div cla
8772
9499
  * Type for the private properties that are shared between the different exported search SDK wrapper functions. SDK users are not allowed to change/access these, they're an internal implementation detail.
8773
9500
  */
8774
9501
  const $806c97b931758897$var$privately_shared_properties = /*@__PURE__*/new WeakMap();
9502
+ const $806c97b931758897$var$content_search_default = false;
8775
9503
  const $806c97b931758897$var$min_products_to_fetch_ = 20;
8776
9504
  const $806c97b931758897$export$bde3eb976dfded9 = depict_search => $806c97b931758897$var$privately_shared_properties.get(depict_search)?.search_query_updating_blocked_;
8777
9505
  class $806c97b931758897$export$ac6237957a15b3f0 {
@@ -8779,6 +9507,7 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
8779
9507
  #merchant_signal = (0, $9HbP8$createSignal)();
8780
9508
  #market_signal = (0, $9HbP8$createSignal)();
8781
9509
  #modal_open_signal = (0, $9HbP8$createSignal)(false);
9510
+ #content_search_signal = (0, $9HbP8$createSignal)();
8782
9511
  static #keys_constructed_with = new Set();
8783
9512
  #router = new (0, $4fd2ba03703a7d92$export$7e1297a3a19f10d8)("hard_navigation");
8784
9513
  constructor({
@@ -8788,9 +9517,10 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
8788
9517
  on_navigation: on_navigation,
8789
9518
  enable_category_suggestions = true,
8790
9519
  page_url_creator: page_url_creator,
9520
+ display_transformers: display_transformers,
9521
+ api: api,
8791
9522
  // Stuff needed for non-standard customer deployments that we shouldn't actually expose
8792
9523
  disable_scrolling_during_modal = true,
8793
- api: api,
8794
9524
  bottom_distance_under_modal: bottom_distance_under_modal,
8795
9525
  render_instant_card: render_instant_card,
8796
9526
  ...props_on_class
@@ -8824,6 +9554,7 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
8824
9554
  local_filter_cache: [],
8825
9555
  expanded_hierarchical_filters: [],
8826
9556
  showing_recommendation_rows: (0, $172e1b898d457050$export$1c8c715550dc689d),
9557
+ content_results_rows: (0, $49de9d31aeea1b5e$export$70ceae36059a1036),
8827
9558
  scroll_restoration_data: []
8828
9559
  }),
8829
9560
  router_: this.#router,
@@ -8834,12 +9565,18 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
8834
9565
  const get_search_query_ = (0, $9HbP8$createMemo)(previous_value => {
8835
9566
  if (get_search_query_updating_blocked()) return previous_value;else return raw_search_query_accessor();
8836
9567
  });
9568
+ // @ts-ignore
8837
9569
  const depict_api_ = api ?? new (0, $7fa23e2a0079eca4$export$e015ed2f2950f2e3)({
8838
- page_url_creator: page_url_creator
9570
+ page_url_creator: page_url_creator,
9571
+ display_transformers: display_transformers
8839
9572
  });
8840
9573
  const previous_searches = (0, $21f51c14cb3f586f$export$84bba84a7b837187)(get_search_query_);
8841
9574
  const [, set_search_showing_recommendation_rows] = state_.showing_recommendation_rows;
8842
- const after_submit_ = () => set_search_showing_recommendation_rows((0, $172e1b898d457050$export$1c8c715550dc689d)); // do this every time after we have submitted a new query - otherwise there might already be a saved number of rows in the state
9575
+ const [, set_search_content_results_rows] = state_.content_results_rows;
9576
+ const after_submit_ = () => {
9577
+ set_search_showing_recommendation_rows((0, $172e1b898d457050$export$1c8c715550dc689d));
9578
+ set_search_content_results_rows((0, $49de9d31aeea1b5e$export$70ceae36059a1036));
9579
+ }; // do this every time after we have submitted a new query - otherwise there might already be a saved number of rows in the state
8843
9580
  const on_submit_with_unchanged_value_ = () => this.modal_open = false;
8844
9581
  const [get_search_field_value_, set_search_field_value_] = state_.field_value;
8845
9582
  const configured_submit_query_ = new_query => (0, $bfd908d13d90934c$export$e16630ecb9644a1c)({
@@ -8897,6 +9634,7 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
8897
9634
  submit_query_: configured_submit_query_,
8898
9635
  url_transformer_: url_transformer,
8899
9636
  router_: this.#router,
9637
+ content_search_enabled_: () => this.#content_search_signal[0]() ?? $806c97b931758897$var$content_search_default,
8900
9638
  instant_results_options_: {
8901
9639
  min_products_to_fetch_: $806c97b931758897$var$min_products_to_fetch_,
8902
9640
  render_instant_card_: render_instant_card,
@@ -8961,6 +9699,12 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
8961
9699
  (0, $9HbP8$onCleanup)(() => $806c97b931758897$export$ac6237957a15b3f0.#keys_constructed_with.delete(unique_instance_key_for_state));
8962
9700
  });
8963
9701
  }
9702
+ get enable_content_search() {
9703
+ return this.#content_search_signal[0]();
9704
+ }
9705
+ set enable_content_search(new_state) {
9706
+ this.#content_search_signal[1](new_state);
9707
+ }
8964
9708
  get on_navigation() {
8965
9709
  // The only non-reactive public property on the class (I don't see it making sense to have it reactive)
8966
9710
  return this.#router.on_navigation_;
@@ -9042,6 +9786,7 @@ function $806c97b931758897$export$f2dc7e4e4aa11abb(props) {
9042
9786
  depict_api_: shared_properties.depict_api_,
9043
9787
  min_products_to_fetch_: $806c97b931758897$var$min_products_to_fetch_,
9044
9788
  local_filter_cache_: state_.local_filter_cache,
9789
+ content_search_enabled_: () => depict_search.enable_content_search ?? $806c97b931758897$var$content_search_default,
9045
9790
  search_field_value_: state_.field_value,
9046
9791
  get_search_query_: shared_properties.get_search_query_,
9047
9792
  clear_filters_on_next_submit_: shared_properties.clear_filters_on_next_submit_,
@@ -9068,6 +9813,8 @@ function $806c97b931758897$export$f2dc7e4e4aa11abb(props) {
9068
9813
  search_filters_open_: state_.filters_open,
9069
9814
  search_sorting_open_: state_.sorting_open,
9070
9815
  expanded_filters_: state_.expanded_filters,
9816
+ content_results_rows_: state_.content_results_rows,
9817
+ router_: shared_properties.router_,
9071
9818
  make_category_suggestion_card_: shared_properties.enable_category_suggestions_ ? category_suggestion_ => {
9072
9819
  return (0, $897bd4a76f611b38$export$d757d54550ebfb3d)({
9073
9820
  category_suggestion_: category_suggestion_,
@@ -9083,6 +9830,10 @@ function $806c97b931758897$export$f2dc7e4e4aa11abb(props) {
9083
9830
  cols_at_size: (0, $b5cccc8ee7d24677$export$6daf8749b65a1b77)(props.cols_at_size),
9084
9831
  ...grid_spacing_override()
9085
9832
  })),
9833
+ content_layout_options_: (0, $9HbP8$createMemo)(() => ({
9834
+ cols_at_size: (0, $b5cccc8ee7d24677$export$6daf8749b65a1b77)((0, $1848f7cca286fbab$export$ff7109b9b2b206ba)(props.cols_at_size)),
9835
+ ...grid_spacing_override()
9836
+ })),
9086
9837
  recommendations_layout_options_: (0, $9HbP8$createMemo)(() => {
9087
9838
  const {
9088
9839
  extra_depict_options: extra_depict_options