@depict-ai/ui 1.4.4 → 1.4.6

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.
@@ -5,7 +5,7 @@ import { createSignal as $i7OB2$createSignal, createMemo as $i7OB2$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.6";
9
9
  function $24e27fab9c821b86$export$5bad61ecde080b1f(...params) {
10
10
  const {
11
11
  collapse: collapse,
@@ -365,7 +365,7 @@ function $1adfe60f3a14a1d7$export$fecbb157621501bd({
365
365
  return outmost_element;
366
366
  }
367
367
  const $87c712b5b33f24f7$var$_tmpl$ = ["<span", ' class="count">', "</span>"],
368
- $87c712b5b33f24f7$var$_tmpl$2 = ["<label", ' class="', '"', '><div class="left"><input type="checkbox"', "", '><span class="custom-indicator"></span><span class="text">', "</span></div><!--#-->", "<!--/--></label>"];
368
+ $87c712b5b33f24f7$var$_tmpl$2 = ["<label", ' class="', '"', '><div class="left"><input type="checkbox"', "", '><span class="custom-indicator"></span><span class="text line-clamp">', "</span></div><!--#-->", "<!--/--></label>"];
369
369
  const $87c712b5b33f24f7$export$48513f6b9f8ce62d = props => {
370
370
  // 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
371
371
  const count = (0, $i7OB2$createMemo)(() => props.count_);
@@ -1856,9 +1856,14 @@ function $c8d5ff4524619fcd$var$ActualSolidLayout(props, container_element) {
1856
1856
  // Copy of Layout from utilishared but using solid-js signals instead of async iterable IPNS
1857
1857
  const show_all_rows = (0, $i7OB2$createMemo)(() => props.rows === "all");
1858
1858
  const rows_or_empty_object = (0, $i7OB2$createMemo)(() => show_all_rows() ? {} : props.rows);
1859
- const button_elements = (0, $a52235d12ccf9c88$export$2f0cbfbb4354bb52)((0, $i7OB2$createMemo)(() => rows_or_empty_object().button));
1860
- const have_a_button = (0, $i7OB2$createMemo)(() => {
1861
- const button = button_elements();
1859
+ const view_more_button_elements = (0, $a52235d12ccf9c88$export$2f0cbfbb4354bb52)((0, $i7OB2$createMemo)(() => rows_or_empty_object().button));
1860
+ const view_less_button_elements = (0, $a52235d12ccf9c88$export$2f0cbfbb4354bb52)((0, $i7OB2$createMemo)(() => rows_or_empty_object().view_less_button));
1861
+ const have_a_view_more_button = (0, $i7OB2$createMemo)(() => {
1862
+ const button = view_more_button_elements();
1863
+ return !(!button || Array.isArray(button) && !button.length);
1864
+ });
1865
+ const have_a_view_less_button = (0, $i7OB2$createMemo)(() => {
1866
+ const button = view_less_button_elements();
1862
1867
  return !(!button || Array.isArray(button) && !button.length);
1863
1868
  });
1864
1869
  const [get_styling, set_styling] = (0, $i7OB2$createSignal)();
@@ -1867,12 +1872,15 @@ function $c8d5ff4524619fcd$var$ActualSolidLayout(props, container_element) {
1867
1872
  const [get_children_count, set_children_count] = (0, $i7OB2$createSignal)(0);
1868
1873
  const update_children_count = () => set_children_count(container_element.children.length);
1869
1874
  const col_styling = (0, $i7OB2$createMemo)(() => (0, $i7OB2$n_col_styling_with_dist)(selector_beginning, props.grid_spacing, props.cols_at_size, props.layout, props.override_vertical_spacing));
1870
- const default_currently_visible_signal = (0, $i7OB2$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
1875
+ const default_currently_visible_signal = (0, $i7OB2$createSignal)((0, $i7OB2$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
1871
1876
  const rows_visible_signal = (0, $i7OB2$createMemo)(() => rows_or_empty_object().currently_visible || default_currently_visible_signal);
1872
1877
  const get_rows_visible = (0, $i7OB2$createMemo)(() => rows_visible_signal()[0]());
1873
1878
  const set_rows_visible = (0, $i7OB2$createMemo)(() => rows_visible_signal()[1]);
1874
- const button_class = (0, $i7OB2$make_random_classname)();
1875
- const button_container = (0, $i7OB2$createMemo)(() => have_a_button() && (0, $i7OB2$ssr)($c8d5ff4524619fcd$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)(), "load-more-container " + (0, $i7OB2$escape)(button_class, true), (0, $i7OB2$escape)(rows_or_empty_object().button)));
1879
+ const view_more_button_class = (0, $i7OB2$make_random_classname)();
1880
+ const view_less_button_class = (0, $i7OB2$make_random_classname)();
1881
+ const view_more_button_container = (0, $i7OB2$createMemo)(() => have_a_view_more_button() && (0, $i7OB2$ssr)($c8d5ff4524619fcd$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)(), `load-more-container ${(0, $i7OB2$escape)(view_more_button_class, true)}`, (0, $i7OB2$escape)(rows_or_empty_object().button)));
1882
+ // 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
1883
+ const view_less_button_container = (0, $i7OB2$createMemo)(() => have_a_view_less_button() && (0, $i7OB2$ssr)($c8d5ff4524619fcd$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)(), `load-less-container ${(0, $i7OB2$escape)(view_less_button_class, true)}`, (0, $i7OB2$escape)(rows_or_empty_object().view_less_button)));
1876
1884
  container_element.classList.add(container_class);
1877
1885
  (0, $i7OB2$createComputed)(() => {
1878
1886
  // Make sure we don't have more rows visible than max_rows (this could happen by max_rows being decreased)
@@ -1887,7 +1895,6 @@ function $c8d5ff4524619fcd$var$ActualSolidLayout(props, container_element) {
1887
1895
  set_styling(() => col_styling);
1888
1896
  return;
1889
1897
  }
1890
- (0, $i7OB2$untrack)(() => set_rows_visible()(rows_or_empty_object().start_rows ?? 1));
1891
1898
  update_children_count();
1892
1899
  const mutation_observer = new MutationObserver((0, $i7OB2$catchify)(update_children_count));
1893
1900
  mutation_observer.observe(container_element, {
@@ -1899,30 +1906,33 @@ function $c8d5ff4524619fcd$var$ActualSolidLayout(props, container_element) {
1899
1906
  () => (0, $i7OB2$createMemo)(() => {
1900
1907
  const {
1901
1908
  rows_per_click: rows_per_click,
1902
- max_rows = -1
1909
+ max_rows = -1,
1910
+ start_rows: start_rows
1903
1911
  } = rows_or_empty_object();
1904
1912
  const rows_visible = get_rows_visible();
1905
1913
  const children_count = get_children_count();
1906
1914
  return col_styling() + props.cols_at_size.map(options => {
1907
- const [, min, max] = options;
1908
- let should_hide_button;
1915
+ const [recs_per_row, min, max] = options;
1916
+ let should_hide_view_more_button;
1909
1917
  let visible_recs;
1910
1918
  if (props.disable_partial_rows) {
1911
1919
  visible_recs = (0, $i7OB2$layout_get_visible_recs_without_partial_rows)(rows_visible, children_count, options);
1912
1920
  const visible_recs_next_show_more = (0, $i7OB2$layout_get_visible_recs_without_partial_rows)(rows_visible + (rows_per_click || 0),
1913
1921
  // Should this really be zero when we default rows_per_click to 1?
1914
1922
  children_count, options);
1915
- should_hide_button = visible_recs === visible_recs_next_show_more;
1923
+ should_hide_view_more_button = visible_recs === visible_recs_next_show_more;
1916
1924
  } else {
1917
1925
  visible_recs = (0, $i7OB2$layout_get_total_rec_amount_for_row)(rows_visible, options);
1918
- should_hide_button = visible_recs >= children_count;
1926
+ should_hide_view_more_button = visible_recs >= children_count;
1919
1927
  }
1920
- const should_hide_button_final = button_class && (should_hide_button || max_rows !== -1 && rows_visible >= max_rows);
1921
- return `${(0, $i7OB2$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}` : ``}}`;
1928
+ const should_hide_button_final = should_hide_view_more_button || max_rows !== -1 && rows_visible >= max_rows;
1929
+ // 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
1930
+ 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;
1931
+ return `${(0, $i7OB2$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}` : ``}}`;
1922
1932
  }).join("");
1923
1933
  }));
1924
1934
  });
1925
- return [container_element, button_container(), (0, $i7OB2$ssr)($c8d5ff4524619fcd$var$_tmpl$2, (0, $i7OB2$ssrHydrationKey)(), get_styling)];
1935
+ return [container_element, view_more_button_container(), view_less_button_container(), (0, $i7OB2$ssr)($c8d5ff4524619fcd$var$_tmpl$2, (0, $i7OB2$ssrHydrationKey)(), get_styling)];
1926
1936
  }
1927
1937
  async function $194bd6b8e4c59830$export$79b1565500412d9b(search_modal, modal_fn_opts) {
1928
1938
  const body = await (0, $i7OB2$observer).wait_for_element("body");
@@ -2022,6 +2032,43 @@ function $ca6f574bd8772184$var$history_state_change(signals, entries, state) {
2022
2032
  }
2023
2033
  });
2024
2034
  }
2035
+ const $90980bd87c9960f9$export$3064e1e8c6513da3 = new Set();
2036
+ let $90980bd87c9960f9$var$has_ran = false;
2037
+ function $90980bd87c9960f9$export$5162a71f252e6122() {
2038
+ if ($90980bd87c9960f9$var$has_ran || typeof history !== "object") return;
2039
+ $90980bd87c9960f9$var$has_ran = true;
2040
+ for (const function_name of ["replaceState", "pushState"]) {
2041
+ if (Object.getOwnPropertyNames(history).includes(function_name)) $90980bd87c9960f9$var$proxy_push_state(function_name, history);
2042
+ $90980bd87c9960f9$var$proxy_push_state(function_name, History.prototype);
2043
+ }
2044
+ }
2045
+ function $90980bd87c9960f9$var$proxy_push_state(function_name, thing) {
2046
+ thing[function_name] = new Proxy(thing[function_name], {
2047
+ apply(target, this_arg, arg_list) {
2048
+ try {
2049
+ if (typeof arg_list[0] == "object") {
2050
+ const cloned_object = {
2051
+ ...arg_list[0]
2052
+ };
2053
+ const old_state = history.state;
2054
+ for (const key in old_state) {
2055
+ if (!$90980bd87c9960f9$var$starts_with_any_prefix(key)) continue;
2056
+ if (!(key in cloned_object)) cloned_object[key] = old_state[key];
2057
+ }
2058
+ arg_list[0] = cloned_object;
2059
+ }
2060
+ } catch (e) {
2061
+ (0, $i7OB2$report)([e, "Failed to preserve items in history.state"], "error");
2062
+ }
2063
+ return Reflect.apply(target, this_arg, arg_list);
2064
+ }
2065
+ });
2066
+ }
2067
+ function $90980bd87c9960f9$var$starts_with_any_prefix(key) {
2068
+ for (const prefix of $90980bd87c9960f9$export$3064e1e8c6513da3) {
2069
+ if (key.startsWith(prefix)) return true;
2070
+ }
2071
+ }
2025
2072
  function $a8fa7302d6f93c0b$export$9862539c89138352({
2026
2073
  get_default_values_: get_default_values_,
2027
2074
  router_: router_,
@@ -2041,6 +2088,8 @@ function $a8fa7302d6f93c0b$export$9862539c89138352({
2041
2088
  };
2042
2089
  let unprefixed_state;
2043
2090
  unprefixed_state = Object.fromEntries(Object.entries(prefixed_state).map(([key, value]) => [key.slice(prefix_.length), value]));
2091
+ (0, $90980bd87c9960f9$export$3064e1e8c6513da3).add(prefix_);
2092
+ // There's intentionally no onCleanup here since we want to preserve the state even if all components (in i.e. react-ui) that use the provider running this are unmounted and the provider is destroyed, since it might be re-created and need the old state (for example for doing scroll restoration)
2044
2093
  return [reset_state, unprefixed_state];
2045
2094
  }
2046
2095
 
@@ -2114,14 +2163,18 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
2114
2163
  }
2115
2164
  }
2116
2165
  async #run_url_creator_for_suggest(merchant, market, response) {
2117
- if (!this.page_url_creator) return response;
2166
+ const page_url_creator = this.page_url_creator;
2167
+ const category_transformer = this.display_transformers?.categories;
2168
+ if (!page_url_creator && !category_transformer) return response;
2118
2169
  // find category suggestions, run thing with them, and then replace them
2119
2170
  const category_suggestions = response.suggestions.filter(suggestion => suggestion.type === "category");
2120
- const page_urls = await this.page_url_creator({
2121
- type: "categories",
2171
+ const page_urls = await (page_url_creator || category_transformer)({
2122
2172
  market: market,
2123
2173
  merchant: merchant,
2124
- data: [...category_suggestions]
2174
+ data: [...category_suggestions],
2175
+ ...(page_url_creator ? {
2176
+ type: "categories"
2177
+ } : {})
2125
2178
  });
2126
2179
  this.#guard_url_creator_length(category_suggestions, page_urls);
2127
2180
  while (page_urls.length)
@@ -2129,17 +2182,29 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
2129
2182
  Object.defineProperties(category_suggestions.pop(), Object.getOwnPropertyDescriptors(page_urls.pop()));
2130
2183
  return response;
2131
2184
  }
2132
- async #run_url_creator_for_rest(merchant, market, input_data) {
2133
- if (!this.page_url_creator) return input_data;
2185
+ async #run_display_transformers_for_rest(merchant, market, input_data) {
2186
+ const {
2187
+ page_url_creator: page_url_creator,
2188
+ display_transformers: display_transformers
2189
+ } = this;
2190
+ if (!page_url_creator && !display_transformers) return input_data;
2191
+ const product_transformer = display_transformers?.products;
2192
+ const category_transformer = display_transformers?.categories;
2193
+ const content_result_transformer = display_transformers?.contentResults;
2134
2194
  const displays = input_data.displays;
2135
- const breadcrumb = input_data.breadcrumb;
2136
- const quick_links = input_data.quick_links;
2137
- if (displays) {
2138
- const page_urls = await this.page_url_creator({
2139
- type: "products",
2195
+ const {
2196
+ breadcrumb: breadcrumb,
2197
+ quick_links: quick_links,
2198
+ content_search_links: content_search_links
2199
+ } = input_data;
2200
+ if (displays && (page_url_creator || product_transformer)) {
2201
+ const page_urls = await (page_url_creator || product_transformer)({
2140
2202
  merchant: merchant,
2141
2203
  market: market,
2142
- displays: [...input_data.displays]
2204
+ displays: [...input_data.displays],
2205
+ ...(page_url_creator ? {
2206
+ type: "products"
2207
+ } : {})
2143
2208
  });
2144
2209
  this.#guard_url_creator_length(displays, page_urls);
2145
2210
  for (let i = 0; i < displays.length; i++) {
@@ -2157,19 +2222,30 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
2157
2222
  displays[i] = new_display_or_page_url;
2158
2223
  }
2159
2224
  }
2160
- for (const category_display_array of [breadcrumb, quick_links]) {
2225
+ if (page_url_creator || category_transformer) for (const category_display_array of [breadcrumb, quick_links]) {
2161
2226
  if (!category_display_array) continue;
2162
- const page_urls = await this.page_url_creator({
2163
- type: "categories",
2227
+ const page_urls = await (page_url_creator || category_transformer)({
2164
2228
  merchant: merchant,
2165
2229
  market: market,
2166
- data: [...category_display_array]
2230
+ data: [...category_display_array],
2231
+ ...(page_url_creator ? {
2232
+ type: "categories"
2233
+ } : {})
2167
2234
  });
2168
2235
  this.#guard_url_creator_length(category_display_array, page_urls);
2169
2236
  for (let i = 0; i < category_display_array.length; i++)
2170
2237
  // Copy over getters so we sneakily can make this reactive
2171
2238
  Object.defineProperties(category_display_array[i], Object.getOwnPropertyDescriptors(page_urls[i]));
2172
2239
  }
2240
+ if (content_search_links?.length && content_result_transformer) {
2241
+ const result = await content_result_transformer({
2242
+ merchant: merchant,
2243
+ market: market,
2244
+ data: [...content_search_links]
2245
+ });
2246
+ this.#guard_url_creator_length(content_search_links, result);
2247
+ input_data.content_search_links = result;
2248
+ }
2173
2249
  return input_data;
2174
2250
  }
2175
2251
  async #cached_post_request(endpoint, input_req, fallback_response) {
@@ -2196,7 +2272,7 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
2196
2272
  let result;
2197
2273
  try {
2198
2274
  const unmodified_result = await api_response.json();
2199
- result = await this.#run_url_creator_for_rest(input_req.tenant, input_req.market, unmodified_result);
2275
+ result = await this.#run_display_transformers_for_rest(input_req.tenant, input_req.market, unmodified_result);
2200
2276
  } catch (e) {
2201
2277
  (0, $i7OB2$dwarn)("URL creator or json decoding failed", e);
2202
2278
  break return_successfully;
@@ -2228,12 +2304,14 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
2228
2304
  get_metadata: get_metadata,
2229
2305
  get_user_id: get_user_id,
2230
2306
  get_session_id: get_session_id,
2231
- page_url_creator: page_url_creator
2307
+ page_url_creator: page_url_creator,
2308
+ display_transformers: display_transformers
2232
2309
  } = options ?? {};
2233
2310
  this.#get_metadata = get_metadata;
2234
2311
  this.#get_user_id = get_user_id;
2235
2312
  this.#get_session_id = get_session_id;
2236
2313
  this.page_url_creator = page_url_creator;
2314
+ this.display_transformers = display_transformers;
2237
2315
  }
2238
2316
  async suggest(input_req) {
2239
2317
  const with_ids = this.#add_ids_to_request(input_req);
@@ -2343,11 +2421,11 @@ function $fc5a12f3a857ca30$var$correct_range_filter_range_once({
2343
2421
  }
2344
2422
  }
2345
2423
  function $511cc0abd9a64ce8$export$92f2da32c6e7e7ee({
2346
- search_results_: search_results_,
2424
+ number_: number_,
2347
2425
  i18n_: i18n_
2348
2426
  }) {
2349
2427
  return (0, $i7OB2$createMemo)(() => {
2350
- const n_hits = search_results_()?.n_hits;
2428
+ const n_hits = number_();
2351
2429
  if (isNaN(n_hits)) return "";
2352
2430
  const price_formatting = i18n_.price_formatting_();
2353
2431
  return (0, $i7OB2$standard_price_format)(n_hits, 0,
@@ -4436,7 +4514,7 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({
4436
4514
  const [sort_or_filter_open_, set_sort_or_filter_open_] = (0, $i7OB2$createSignal)(false);
4437
4515
  const [desktop_filter_elements_, set_desktop_filter_elements] = (0, $i7OB2$createSignal)();
4438
4516
  const formatted_number_of_results_ = (0, $511cc0abd9a64ce8$export$92f2da32c6e7e7ee)({
4439
- search_results_: plp_results_,
4517
+ number_: (0, $i7OB2$createMemo)(() => plp_results_()?.n_hits),
4440
4518
  i18n_: i18n_
4441
4519
  });
4442
4520
  const [sort_and_filter_element_, set_sort_and_filter_element_] = (0, $i7OB2$createSignal)();
@@ -4652,37 +4730,6 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({
4652
4730
  }
4653
4731
  })))];
4654
4732
  }
4655
- let $90980bd87c9960f9$var$has_ran = false;
4656
- function $90980bd87c9960f9$export$5162a71f252e6122() {
4657
- if ($90980bd87c9960f9$var$has_ran || typeof history !== "object") return;
4658
- $90980bd87c9960f9$var$has_ran = true;
4659
- for (const function_name of ["replaceState", "pushState"]) {
4660
- if (Object.getOwnPropertyNames(history).includes(function_name)) $90980bd87c9960f9$var$proxy_push_state(function_name, history);
4661
- $90980bd87c9960f9$var$proxy_push_state(function_name, History.prototype);
4662
- }
4663
- }
4664
- function $90980bd87c9960f9$var$proxy_push_state(function_name, thing) {
4665
- thing[function_name] = new Proxy(thing[function_name], {
4666
- apply(target, this_arg, arg_list) {
4667
- try {
4668
- if (typeof arg_list[0] == "object") {
4669
- const cloned_object = {
4670
- ...arg_list[0]
4671
- };
4672
- const old_state = history.state;
4673
- for (const key in old_state) {
4674
- if (!key.startsWith("category_") && !key.startsWith("search_")) continue;
4675
- if (!(key in cloned_object)) cloned_object[key] = old_state[key];
4676
- }
4677
- arg_list[0] = cloned_object;
4678
- }
4679
- } catch (e) {
4680
- (0, $i7OB2$report)([e, "Failed to preserve items in history.state"], "error");
4681
- }
4682
- return Reflect.apply(target, this_arg, arg_list);
4683
- }
4684
- });
4685
- }
4686
4733
  const $b5cccc8ee7d24677$var$transform_elements = sorted_cols_at_size => {
4687
4734
  const cols_at_size = [];
4688
4735
  for (let i = 0; i < sorted_cols_at_size.length; i++) {
@@ -4968,7 +5015,6 @@ class $4fd2ba03703a7d92$export$7e1297a3a19f10d8 {
4968
5015
  }
4969
5016
  const $961b5c64bef4662f$var$_tmpl$ = ["<div", ' class="depict plp category">', "</div>"];
4970
5017
  // 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
4971
- // on old displays, no page_url_creator can be specified
4972
5018
  /**
4973
5019
  * Type for the private properties that are shared between the different exported search SDK wrapper functions.
4974
5020
  * SDK users are not allowed to change/access these, they're an internal implementation detail.
@@ -5028,6 +5074,7 @@ class $961b5c64bef4662f$export$f34314aa9505732e {
5028
5074
  api: api,
5029
5075
  on_navigation: on_navigation,
5030
5076
  page_url_creator: page_url_creator,
5077
+ display_transformers: display_transformers,
5031
5078
  unique_instance_key_for_state = "",
5032
5079
  query_id_state_key: query_id_state_key,
5033
5080
  ...props_on_class
@@ -5072,8 +5119,10 @@ class $961b5c64bef4662f$export$f34314aa9505732e {
5072
5119
  quicklinks_signal_: (0, $i7OB2$createSignal)(),
5073
5120
  i18n_: i18n_,
5074
5121
  reset_history_state_: reset_history_state_,
5122
+ // @ts-ignore
5075
5123
  depict_api_: api ?? new (0, $7fa23e2a0079eca4$export$e015ed2f2950f2e3)({
5076
- page_url_creator: page_url_creator
5124
+ page_url_creator: page_url_creator,
5125
+ display_transformers: display_transformers
5077
5126
  }),
5078
5127
  router_: this.#router,
5079
5128
  selected_filters_: selected_filters_,
@@ -5532,11 +5581,11 @@ function $172e1b898d457050$export$7de92c4c2205ebf3({
5532
5581
  });
5533
5582
  }
5534
5583
  function $172e1b898d457050$var$make_state_saved_rows([get_showing_recommendation_rows, set_showing_recommendation_rows], i18n_) {
5535
- const currently_visible = (0, $i7OB2$createSignal)(0); // this number shouldn't matter for anything except typing
5584
+ const currently_visible = (0, $i7OB2$createSignal)((0, $i7OB2$untrack)(get_showing_recommendation_rows));
5536
5585
  const [get_currently_visible, set_currently_visible] = currently_visible;
5537
5586
  const rows = {
5538
5587
  currently_visible: currently_visible,
5539
- start_rows: (0, $i7OB2$untrack)(get_showing_recommendation_rows) ?? $172e1b898d457050$export$1c8c715550dc689d,
5588
+ start_rows: $172e1b898d457050$export$1c8c715550dc689d,
5540
5589
  rows_per_click: 3,
5541
5590
  button: (0, $i7OB2$ssr)($172e1b898d457050$var$_tmpl$2, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)(i18n_.view_more_()))
5542
5591
  };
@@ -5698,7 +5747,7 @@ const $c97b1f0e44afb9d2$export$27b710c08412a7ad = obj => {
5698
5747
  return Object.fromEntries(Object.keys(obj).map(key => [key, obj[key]()]));
5699
5748
  };
5700
5749
  const $e003be2a50d9e5bc$var$_tmpl$ = ["<span", ' class="orig price"><!--#-->', "<!--/--><!--#-->", "<!--/--><!--#-->", "<!--/--></span>"],
5701
- $e003be2a50d9e5bc$var$_tmpl$2 = ["<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="', '"><!--#-->', "<!--/--><!--#-->", "<!--/--><!--#-->", "<!--/--></span></div></div></a>"],
5750
+ $e003be2a50d9e5bc$var$_tmpl$2 = ["<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="', '"><!--#-->', "<!--/--><!--#-->", "<!--/--><!--#-->", "<!--/--></span></div></div></a>"],
5702
5751
  $e003be2a50d9e5bc$var$_tmpl$3 = ["<div", ' class="tagline">', "</div>"];
5703
5752
  const $e003be2a50d9e5bc$export$b05c0ae390cf3e06 = (display_or_variant_container, {
5704
5753
  i18n: i18n
@@ -5767,9 +5816,11 @@ function $eea41f703612261b$export$62f101a8aa597bf8({
5767
5816
  render_instant_card_placeholder_: render_instant_card_placeholder_,
5768
5817
  min_products_to_fetch_: min_products_to_fetch_,
5769
5818
  has_sort_or_filters_: has_sort_or_filters_,
5770
- set_num_results_accessor_: set_num_results_accessor_,
5819
+ set_total_num_results_accessor_: set_total_num_results_accessor_,
5771
5820
  i18n_: i18n_,
5772
- router_: router_
5821
+ router_: router_,
5822
+ set_modal_search_results_: set_modal_search_results_,
5823
+ content_search_enabled_: content_search_enabled_
5773
5824
  }) {
5774
5825
  const max_cards = 4;
5775
5826
  const [read_current_instant_query, write_current_instant_query] = (0, $i7OB2$createSignal)("");
@@ -5794,8 +5845,17 @@ function $eea41f703612261b$export$62f101a8aa597bf8({
5794
5845
  ...variable_data
5795
5846
  });
5796
5847
  }));
5797
- set_num_results_accessor_(() => (0, $511cc0abd9a64ce8$export$92f2da32c6e7e7ee)({
5798
- search_results_: search_results,
5848
+ // 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
5849
+ // This is for the press-enter-to-instant-content-result feature which gets called from Autocomplete.tsx
5850
+ set_modal_search_results_(() => search_results);
5851
+ (0, $i7OB2$onCleanup)(() => set_modal_search_results_(undefined)); // for consistency, in case this component crashes
5852
+ set_total_num_results_accessor_(() => (0, $511cc0abd9a64ce8$export$92f2da32c6e7e7ee)({
5853
+ number_: (0, $i7OB2$createMemo)(() => {
5854
+ const hits = search_results()?.n_hits;
5855
+ const content_results = search_results()?.content_search_links?.length;
5856
+ if (!content_results || !content_search_enabled_()) return hits;
5857
+ return (hits ?? 0) + content_results;
5858
+ }),
5799
5859
  i18n_: i18n_
5800
5860
  }));
5801
5861
  const sliced_displays = (0, $i7OB2$createMemo)(() => search_results()?.displays?.slice(0, max_cards));
@@ -5860,7 +5920,7 @@ function $694b7f90501fea4c$export$5d2caaa6b530761c() {
5860
5920
  return (0, $i7OB2$ssr)($694b7f90501fea4c$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)());
5861
5921
  }
5862
5922
  const $7ad3a93cbe6fa208$var$_tmpl$ = ["<div", ' class="previous-searches"><h2 class="text">', '</h2><div class="list">', "</div></div>"],
5863
- $7ad3a93cbe6fa208$var$_tmpl$2 = ["<a", ' class="', '"', '><div class="left"><!--#-->', "<!--/--><span>", '</span></div><button class="delete"', ">", "</button></a>"];
5923
+ $7ad3a93cbe6fa208$var$_tmpl$2 = ["<a", ' class="', '"', '><div class="left"><!--#-->', '<!--/--><span class="line-clamp"', ">", '</span></div><button class="delete"', ">", "</button></a>"];
5864
5924
  function $7ad3a93cbe6fa208$export$a146ac6fa8346a25({
5865
5925
  text_: text_,
5866
5926
  previous_searches_: previous_searches_,
@@ -5900,14 +5960,14 @@ function $7ad3a93cbe6fa208$export$a146ac6fa8346a25({
5900
5960
  value_: item,
5901
5961
  url_transformer_: url_transformer_
5902
5962
  });
5903
- return (0, $i7OB2$ssr)($7ad3a93cbe6fa208$var$_tmpl$2, (0, $i7OB2$ssrHydrationKey)(), `${`item` || ""} ${(0, $i7OB2$createMemo)(() => read_selected_index_()?.[0] === 0 && read_selected_index_()?.[1] === index)() ? "selected" : ""}`, (0, $i7OB2$ssrAttribute)("href", (0, $i7OB2$escape)(href(), true), false), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $694b7f90501fea4c$export$5d2caaa6b530761c), {})), (0, $i7OB2$escape)(item()), (0, $i7OB2$ssrAttribute)("title", (0, $i7OB2$escape)(i18n_.previous_searches_delete_entry_from_history_(), true), false), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $19976a74d273070d$export$3b621d86b1566b2), {})));
5963
+ return (0, $i7OB2$ssr)($7ad3a93cbe6fa208$var$_tmpl$2, (0, $i7OB2$ssrHydrationKey)(), `${`item` || ""} ${(0, $i7OB2$createMemo)(() => read_selected_index_()?.[0] === 0 && read_selected_index_()?.[1] === index)() ? "selected" : ""}`, (0, $i7OB2$ssrAttribute)("href", (0, $i7OB2$escape)(href(), true), false), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $694b7f90501fea4c$export$5d2caaa6b530761c), {})), (0, $i7OB2$ssrAttribute)("title", (0, $i7OB2$escape)(item(), true), false), (0, $i7OB2$escape)(item()), (0, $i7OB2$ssrAttribute)("title", (0, $i7OB2$escape)(i18n_.previous_searches_delete_entry_from_history_(), true), false), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $19976a74d273070d$export$3b621d86b1566b2), {})));
5904
5964
  }
5905
5965
  })));
5906
5966
  }
5907
5967
  });
5908
5968
  }
5909
5969
  const $f3213c0640246d58$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"],
5910
- $f3213c0640246d58$var$_tmpl$2 = ["<span", ' class="', '">', "</span>"];
5970
+ $f3213c0640246d58$var$_tmpl$2 = ["<span", ' class="', '"', ">", "</span>"];
5911
5971
  function $f3213c0640246d58$export$ba17c5b7e6dda39f({
5912
5972
  whole_text_to_display_: whole_text_to_display_memo,
5913
5973
  searching_for_value_: searching_for_value_memo,
@@ -5957,16 +6017,27 @@ function $f3213c0640246d58$export$ba17c5b7e6dda39f({
5957
6017
  }
5958
6018
  return output;
5959
6019
  }));
5960
- return (0, $i7OB2$ssr)($f3213c0640246d58$var$_tmpl$2, (0, $i7OB2$ssrHydrationKey)(), `${(0, $i7OB2$escape)(class_, true) || ""} ${get_has_highlighted() ? "has-history-match" : ""}`, (0, $i7OB2$escape)(text_itself()));
6020
+ return (0, $i7OB2$ssr)($f3213c0640246d58$var$_tmpl$2, (0, $i7OB2$ssrHydrationKey)(), `${(0, $i7OB2$escape)(class_, true) || ""} ${get_has_highlighted() ? "has-history-match" : ""}`, (0, $i7OB2$ssrAttribute)("title", (0, $i7OB2$escape)(whole_text_to_display_memo(), true), false), (0, $i7OB2$escape)(text_itself()));
6021
+ }
6022
+ const $190927650b4840eb$var$_tmpl$ = '<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>';
6023
+ function $190927650b4840eb$export$605674723bcc715c(props = {}) {
6024
+ return (0, $i7OB2$ssrElement)("svg", () => ({
6025
+ "xmlns": "http://www.w3.org/2000/svg",
6026
+ "width": "32",
6027
+ "height": "32",
6028
+ "viewBox": "0 0 256 256",
6029
+ ...props
6030
+ }), () => (0, $i7OB2$ssr)($190927650b4840eb$var$_tmpl$), true);
5961
6031
  }
5962
6032
  const $cea52f6b24092f05$var$_tmpl$ = ["<a", ' class="', '"', ">", "</a>"],
5963
6033
  $cea52f6b24092f05$var$_tmpl$2 = ["<div", ' class="search-icon">', "</div>"],
5964
6034
  $cea52f6b24092f05$var$_tmpl$3 = ["<span", ' class="type">', "</span>"],
5965
6035
  $cea52f6b24092f05$var$_tmpl$4 = ["<div", "><!--#-->", '<!--/--><span class="value">', "</span></div>"],
5966
- $cea52f6b24092f05$var$_tmpl$5 = ["<h2", ' class="text">', "</h2>"],
5967
- $cea52f6b24092f05$var$_tmpl$6 = ["<div", ' class="suggestion-container query"><!--#-->', "<!--/--><!--#-->", "<!--/--></div>"],
5968
- $cea52f6b24092f05$var$_tmpl$7 = ["<div", ' class="suggestion-container page">', "</div>"],
5969
- $cea52f6b24092f05$var$_tmpl$8 = ["<div", ' class="', '"><!--#-->', "<!--/--><!--#-->", "<!--/--><!--#-->", "<!--/--></div>"];
6036
+ $cea52f6b24092f05$var$_tmpl$5 = ["<div", ' class="with-icon"><!--#-->', "<!--/--><!--#-->", "<!--/--></div>"],
6037
+ $cea52f6b24092f05$var$_tmpl$6 = ["<h2", ' class="text">', "</h2>"],
6038
+ $cea52f6b24092f05$var$_tmpl$7 = ["<div", ' class="suggestion-container query"><!--#-->', "<!--/--><!--#-->", "<!--/--></div>"],
6039
+ $cea52f6b24092f05$var$_tmpl$8 = ["<div", ' class="suggestion-container page">', "</div>"],
6040
+ $cea52f6b24092f05$var$_tmpl$9 = ["<div", ' class="', '"><!--#-->', "<!--/--><!--#-->", "<!--/--><!--#-->", "<!--/--></div>"];
5970
6041
  function $cea52f6b24092f05$export$e872e2339fb04a7f({
5971
6042
  suggestion_memo_: suggestion_memo_,
5972
6043
  search_query_url_param_name_: search_query_url_param_name_,
@@ -5979,7 +6050,8 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
5979
6050
  include_category_suggestions_: include_category_suggestions_,
5980
6051
  searching_for_value_: searching_for_value_,
5981
6052
  router_: router_,
5982
- submit_query_: submit_query_
6053
+ submit_query_: submit_query_,
6054
+ get_content_results_: get_content_results_
5983
6055
  }) {
5984
6056
  const queries_memo = (0, $i7OB2$createMemo)(() => suggestion_memo_().filter(({
5985
6057
  type: type,
@@ -5987,9 +6059,15 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
5987
6059
  }) => type === (0, $a0eb8b431ec1f87b$export$3cf9497e790da491) && !filtered_previous_searches_().includes(title) // don't show the ones we already show from the history
5988
6060
  ));
5989
6061
 
5990
- const not_queries_memo = (0, $i7OB2$createMemo)(() => suggestion_memo_().filter(({
5991
- type: type
5992
- }) => type !== (0, $a0eb8b431ec1f87b$export$3cf9497e790da491)));
6062
+ const not_queries_memo = (0, $i7OB2$createMemo)(() => {
6063
+ // For the section that shows categories and content results
6064
+ // We want to limit to 3 items, and we want to show the categories first
6065
+ const content_results = get_content_results_() || [];
6066
+ const from_suggest_request = include_category_suggestions_ ? suggestion_memo_().filter(({
6067
+ type: type
6068
+ }) => type !== (0, $a0eb8b431ec1f87b$export$3cf9497e790da491)) : [];
6069
+ return [...from_suggest_request.slice(0, content_results.length ? 2 : 3), ...content_results.slice(0, 1)];
6070
+ });
5993
6071
  const render_entry = (input_obj, autocomplete_data_index, index, is_history = false) => {
5994
6072
  const is_query = (0, $i7OB2$createMemo)(() => input_obj().type === (0, $a0eb8b431ec1f87b$export$3cf9497e790da491));
5995
6073
  const href_with_changed_params_accessor = (0, $i7OB2$createMemo)(() => is_query() ? (0, $a36cbc4f68bfd590$export$91c3b6774e8be0f5)({
@@ -5998,7 +6076,8 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
5998
6076
  url_transformer_: url_transformer_
5999
6077
  }) : undefined);
6000
6078
  const href = (0, $i7OB2$createMemo)(() => is_query() ? href_with_changed_params_accessor()() : input_obj().page_url);
6001
- return (0, $i7OB2$ssr)($cea52f6b24092f05$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)(), `suggestion ${(0, $i7OB2$createMemo)(() => read_selected_index_()?.[0] === autocomplete_data_index && read_selected_index_()?.[1] === index)() ? "selected" : ""} ${is_history ? "history" : ""} ${(0, $i7OB2$escape)((0, $i7OB2$escape)("type-" + input_obj().type, true), true)}`, (0, $i7OB2$ssrAttribute)("href", (0, $i7OB2$escape)(href(), true), false), is_query() ? (0, $i7OB2$escape)([(0, $i7OB2$createComponent)((0, $i7OB2$Show), {
6079
+ const is_selected = (0, $i7OB2$createMemo)(() => read_selected_index_()?.[0] === autocomplete_data_index && read_selected_index_()?.[1] === index);
6080
+ return (0, $i7OB2$ssr)($cea52f6b24092f05$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)(), `suggestion ${is_selected() ? "selected" : ""} ${is_history ? "history" : ""} ${(0, $i7OB2$escape)((0, $i7OB2$escape)("type-" + input_obj().type, true), true)}`, (0, $i7OB2$ssrAttribute)("href", (0, $i7OB2$escape)(href(), true), false), is_query() ? (0, $i7OB2$escape)([(0, $i7OB2$createComponent)((0, $i7OB2$Show), {
6002
6081
  when: is_history,
6003
6082
  get fallback() {
6004
6083
  return (0, $i7OB2$ssr)($cea52f6b24092f05$var$_tmpl$2, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $16f0ed5ea30d8d9c$export$82eafebb825fc23f), {})));
@@ -6007,24 +6086,34 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
6007
6086
  return (0, $i7OB2$createComponent)((0, $694b7f90501fea4c$export$5d2caaa6b530761c), {});
6008
6087
  }
6009
6088
  }), (0, $i7OB2$createComponent)((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
6010
- class_: "value",
6089
+ class_: "value line-clamp",
6090
+ get whole_text_to_display_() {
6091
+ return (0, $i7OB2$createMemo)(() => input_obj().title);
6092
+ },
6093
+ searching_for_value_: searching_for_value_
6094
+ })]) : (0, $i7OB2$escape)([typeof input_obj() /* this is a harmless lie */.parent_title === "string" ? (0, $i7OB2$ssr)($cea52f6b24092f05$var$_tmpl$4, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
6095
+ class_: "category line-clamp",
6011
6096
  get whole_text_to_display_() {
6012
6097
  return (0, $i7OB2$createMemo)(() => input_obj().title);
6013
6098
  },
6014
6099
  searching_for_value_: searching_for_value_
6015
- })]) : (0, $i7OB2$escape)([typeof input_obj().parent_title === "string" ? (0, $i7OB2$ssr)($cea52f6b24092f05$var$_tmpl$4, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
6016
- class_: "category",
6100
+ })), (0, $i7OB2$escape)(input_obj().parent_title)) : input_obj().type === "content" ? (0, $i7OB2$ssr)($cea52f6b24092f05$var$_tmpl$5, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $190927650b4840eb$export$605674723bcc715c), {
6101
+ width: "16",
6102
+ height: "16"
6103
+ })), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
6104
+ class_: "content line-clamp",
6017
6105
  get whole_text_to_display_() {
6018
6106
  return (0, $i7OB2$createMemo)(() => input_obj().title);
6019
6107
  },
6020
6108
  searching_for_value_: searching_for_value_
6021
- })), (0, $i7OB2$escape)(input_obj().parent_title)) : (0, $i7OB2$createComponent)((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
6022
- class_: "category",
6109
+ }))) : (0, $i7OB2$createComponent)((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
6110
+ class_: "category line-clamp",
6023
6111
  get whole_text_to_display_() {
6024
6112
  return (0, $i7OB2$createMemo)(() => input_obj().title);
6025
6113
  },
6026
6114
  searching_for_value_: searching_for_value_
6027
6115
  }), (0, $i7OB2$ssr)($cea52f6b24092f05$var$_tmpl$3, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)((0, $i7OB2$createMemo)(() => {
6116
+ if (input_obj().type === "content") return i18n_.content_();
6028
6117
  if (input_obj().category_type === "BRAND") return i18n_.brand_();
6029
6118
  return i18n_.category_();
6030
6119
  })()))]));
@@ -6040,26 +6129,26 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
6040
6129
  }));
6041
6130
  };
6042
6131
  const should_show_previous_searches_in_query_part = (0, $i7OB2$createMemo)(() => !on_previous_searches_page_());
6043
- const should_show_at_all = (0, $i7OB2$createMemo)(() => suggestion_memo_()?.length || should_show_previous_searches_in_query_part() && filtered_previous_searches_().length);
6132
+ const should_show_at_all = (0, $i7OB2$createMemo)(() => suggestion_memo_()?.length || should_show_previous_searches_in_query_part() && filtered_previous_searches_().length || get_content_results_()?.length);
6044
6133
  const should_show_query_part = (0, $i7OB2$createMemo)(() => queries_memo().length || filtered_previous_searches_().length);
6045
6134
  return (0, $i7OB2$createComponent)((0, $i7OB2$Show), {
6046
6135
  get when() {
6047
6136
  return should_show_at_all();
6048
6137
  },
6049
6138
  get children() {
6050
- return (0, $i7OB2$ssr)($cea52f6b24092f05$var$_tmpl$8, (0, $i7OB2$ssrHydrationKey)(), `suggestions ${on_previous_searches_page_() ? "compact" : ""}`, (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $i7OB2$Show), {
6139
+ return (0, $i7OB2$ssr)($cea52f6b24092f05$var$_tmpl$9, (0, $i7OB2$ssrHydrationKey)(), `suggestions ${on_previous_searches_page_() ? "compact" : ""}`, (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $i7OB2$Show), {
6051
6140
  get when() {
6052
6141
  return on_previous_searches_page_();
6053
6142
  },
6054
6143
  get children() {
6055
- return (0, $i7OB2$ssr)($cea52f6b24092f05$var$_tmpl$5, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)(i18n_.suggestions_()));
6144
+ return (0, $i7OB2$ssr)($cea52f6b24092f05$var$_tmpl$6, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)(i18n_.suggestions_()));
6056
6145
  }
6057
6146
  })), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $i7OB2$Show), {
6058
6147
  get when() {
6059
6148
  return should_show_query_part();
6060
6149
  },
6061
6150
  get children() {
6062
- return (0, $i7OB2$ssr)($cea52f6b24092f05$var$_tmpl$6, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $i7OB2$Show), {
6151
+ return (0, $i7OB2$ssr)($cea52f6b24092f05$var$_tmpl$7, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $i7OB2$Show), {
6063
6152
  get when() {
6064
6153
  return should_show_previous_searches_in_query_part();
6065
6154
  },
@@ -6095,11 +6184,11 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
6095
6184
  }
6096
6185
  })), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $i7OB2$Show), {
6097
6186
  get when() {
6098
- return not_queries_memo().length && include_category_suggestions_;
6187
+ return not_queries_memo().length;
6099
6188
  },
6100
6189
  keyed: false,
6101
6190
  get children() {
6102
- return (0, $i7OB2$ssr)($cea52f6b24092f05$var$_tmpl$7, (0, $i7OB2$ssrHydrationKey)(), (() => {
6191
+ return (0, $i7OB2$ssr)($cea52f6b24092f05$var$_tmpl$8, (0, $i7OB2$ssrHydrationKey)(), (() => {
6103
6192
  const index_in_autocomplete = 3;
6104
6193
  set_list_until_cleanup(not_queries_memo, index_in_autocomplete);
6105
6194
  return (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $i7OB2$Index), {
@@ -6114,7 +6203,18 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
6114
6203
  }
6115
6204
  });
6116
6205
  }
6117
- const $15f380f0ce2812cc$var$_tmpl$ = ["<a", ' target="_blank"></a>'];
6206
+ const $92a48aea6a9364d8$var$_tmpl$ = ["<a", ' target="_blank"></a>'];
6207
+ function $92a48aea6a9364d8$export$1efe1013da60d0e4(e, href) {
6208
+ if (e.metaKey || e.ctrlKey) {
6209
+ // Open link in a new tab with cmd/ctrl + enter.
6210
+ const link = (0, $i7OB2$ssr)($92a48aea6a9364d8$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)() + (0, $i7OB2$ssrAttribute)("href", (0, $i7OB2$escape)(href, true), false));
6211
+ document.body.append(link);
6212
+ link.click();
6213
+ link.remove();
6214
+ return true;
6215
+ }
6216
+ return false;
6217
+ }
6118
6218
  function $15f380f0ce2812cc$export$217899a935ef803b({
6119
6219
  selected_index_: [read_selected_index, write_selected_index],
6120
6220
  currently_showing_suggestions_: [read_currently_showing_suggestions],
@@ -6188,6 +6288,7 @@ function $15f380f0ce2812cc$var$actual_navigation_working_on_fake_data({
6188
6288
  const sfv = get_search_field_value();
6189
6289
  if (!(0, $i7OB2$untrack)(() => read_updating_blocked())) previous_value = sfv;
6190
6290
  });
6291
+ const owner = (0, $i7OB2$getOwner)();
6191
6292
  const handler = (0, $i7OB2$catchify)(({
6192
6293
  keyCode: keyCode
6193
6294
  }) => (0, $i7OB2$untrack)(() => {
@@ -6218,29 +6319,29 @@ function $15f380f0ce2812cc$var$actual_navigation_working_on_fake_data({
6218
6319
  const {
6219
6320
  title: title
6220
6321
  } = selected_entry;
6221
- block_updating_for_one_change();
6322
+ (0, $i7OB2$runWithOwner)(owner, block_updating_for_one_change);
6222
6323
  set_search_field_value(title);
6223
- override_on_enter_for_this_entry(e => {
6324
+ (0, $i7OB2$runWithOwner)(owner, () => override_on_enter_for_this_entry(e => {
6224
6325
  // Open search query in new tab on cmd+enter
6225
6326
  // 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 ;)
6226
6327
  const url = new URL(location);
6227
6328
  url_transformer_?.(url);
6228
6329
  url.searchParams.set(search_query_param_name_, title);
6229
- return $15f380f0ce2812cc$var$open_link_on_cmd_pressed(e, url.href);
6230
- });
6231
- } else if (selected_entry?.type == "category") override_on_enter_for_this_entry(e => {
6330
+ return (0, $92a48aea6a9364d8$export$1efe1013da60d0e4)(e, url.href);
6331
+ }));
6332
+ } else if (selected_entry?.type == "category" || selected_entry?.type === "content") (0, $i7OB2$runWithOwner)(owner, () => override_on_enter_for_this_entry(e => {
6232
6333
  const {
6233
6334
  page_url: page_url
6234
6335
  } = selected_entry;
6235
- if (!$15f380f0ce2812cc$var$open_link_on_cmd_pressed(e, page_url))
6336
+ if (!(0, $92a48aea6a9364d8$export$1efe1013da60d0e4)(e, page_url))
6236
6337
  // Above fn will return true if it opened a new tab, and we won't make these checks anymore
6237
6338
  router_.navigate_.go_to_({
6238
6339
  new_url_: page_url,
6239
6340
  is_replace_: false
6240
6341
  });
6241
6342
  return true;
6242
- });else if (!selected_entry) {
6243
- block_updating_for_one_change();
6343
+ }));else if (!selected_entry) {
6344
+ (0, $i7OB2$runWithOwner)(owner, block_updating_for_one_change);
6244
6345
  set_search_field_value(previous_value);
6245
6346
  }
6246
6347
  }));
@@ -6251,16 +6352,37 @@ function $15f380f0ce2812cc$var$actual_navigation_working_on_fake_data({
6251
6352
  (0, $i7OB2$onCleanup)((0, $i7OB2$catchify)(() => el.removeEventListener("keyup", handler)));
6252
6353
  });
6253
6354
  }
6254
- function $15f380f0ce2812cc$var$open_link_on_cmd_pressed(e, href) {
6255
- if (e.metaKey || e.ctrlKey) {
6256
- // Open link in a new tab with cmd/ctrl + enter.
6257
- const link = (0, $i7OB2$ssr)($15f380f0ce2812cc$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)() + (0, $i7OB2$ssrAttribute)("href", (0, $i7OB2$escape)(href, true), false));
6258
- document.body.append(link);
6259
- link.click();
6260
- link.remove();
6261
- return true;
6262
- }
6263
- return false;
6355
+ function $1ae0eaca6ada9753$export$af0124069c150252({
6356
+ set_override_on_enter_fn_: set_override_on_enter_fn_,
6357
+ get_modal_search_results_: get_modal_search_results_,
6358
+ read_suggestion_signal_: read_suggestion_signal_,
6359
+ router_: router_,
6360
+ content_results_: content_results_
6361
+ }) {
6362
+ const [get_autocomplete_wants_override_function, set_autocomplete_wants_override_function] = (0, $i7OB2$createSignal)(() => false);
6363
+ (0, $i7OB2$createComputed)(() => {
6364
+ const suggestions = read_suggestion_signal_();
6365
+ const search_results = get_modal_search_results_()?.();
6366
+ const content_results = content_results_();
6367
+ // If we only have one content result and nothing else, go there when pressing enter
6368
+ if (!suggestions.length && !search_results?.displays?.length && content_results?.length === 1) {
6369
+ const [{
6370
+ page_url: page_url
6371
+ }] = content_results;
6372
+ set_override_on_enter_fn_(e => {
6373
+ if (!(0, $92a48aea6a9364d8$export$1efe1013da60d0e4)(e, page_url))
6374
+ // Above fn will return true if it opened a new tab, and we won't make these checks anymore
6375
+ router_.navigate_.go_to_({
6376
+ new_url_: page_url,
6377
+ is_replace_: false
6378
+ });
6379
+ return true;
6380
+ });
6381
+ return;
6382
+ }
6383
+ set_override_on_enter_fn_(get_autocomplete_wants_override_function());
6384
+ });
6385
+ return new_fn => set_autocomplete_wants_override_function(() => new_fn);
6264
6386
  }
6265
6387
  const $a0eb8b431ec1f87b$export$3cf9497e790da491 = "query";
6266
6388
  function $a0eb8b431ec1f87b$export$2f2b9559550c7bbc({
@@ -6280,12 +6402,15 @@ function $a0eb8b431ec1f87b$export$2f2b9559550c7bbc({
6280
6402
  i18n_: i18n_,
6281
6403
  include_category_suggestions_: include_category_suggestions_,
6282
6404
  submit_query_: submit_query_,
6283
- router_: router_
6405
+ router_: router_,
6406
+ get_modal_search_results_: get_modal_search_results_,
6407
+ content_search_enabled_: content_search_enabled_
6284
6408
  }) {
6285
6409
  const [searching_for_value, set_searching_for_value] = (0, $i7OB2$createSignal)();
6410
+ const [show_stale_content_results, set_show_stale_content_results] = (0, $i7OB2$createSignal)(false);
6286
6411
  const [read_search_field_value] = search_field_value_;
6287
6412
  const updating_blocked = (0, $i7OB2$createSignal)(false);
6288
- const [read_suggestion_signal, write_suggestion_signal] = (0, $i7OB2$createSignal)([]);
6413
+ const [read_suggestion_signal_, write_suggestion_signal] = (0, $i7OB2$createSignal)([]);
6289
6414
  const filtered_previous_searches = (0, $i7OB2$createMemo)(() => [...unfiltered_previous_searches[0]()].reverse().filter(q => q !== get_search_query_()));
6290
6415
  const deparallelized_fn = (0, $i7OB2$deparallelize_no_drop)(async request_obj => {
6291
6416
  const api_response = await depict_api_.suggest(request_obj);
@@ -6304,15 +6429,38 @@ function $a0eb8b431ec1f87b$export$2f2b9559550c7bbc({
6304
6429
  });
6305
6430
 
6306
6431
  const show_previous_searches_component = (0, $i7OB2$createMemo)(() => !read_search_field_value() || (0, $i7OB2$untrack)(updating_blocked[0]) && !(0, $i7OB2$untrack)(searching_for_value));
6432
+ const get_content_results_ = (0, $i7OB2$createMemo)(prev => {
6433
+ if (!content_search_enabled_()) return [];
6434
+ if (show_stale_content_results())
6435
+ // don't update content results when query suggestions don't update because otherwise they disappear when trying to keyboard navigate to them
6436
+ return prev;
6437
+ return get_modal_search_results_()?.()?.content_search_links?.map(link => ({
6438
+ page_url: link.page_url,
6439
+ type: "content",
6440
+ title: link.title
6441
+ }));
6442
+ });
6443
+ // 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.
6444
+ // It's the functionality to open the content results page when you press enter, in the modal, when there's only one content result
6445
+ const manipulated_set_override_on_enter_fn_ = (0, $1ae0eaca6ada9753$export$af0124069c150252)({
6446
+ set_override_on_enter_fn_: set_override_on_enter_fn_,
6447
+ get_modal_search_results_: get_modal_search_results_,
6448
+ read_suggestion_signal_: read_suggestion_signal_,
6449
+ router_: router_,
6450
+ content_results_: get_content_results_
6451
+ });
6307
6452
  (0, $i7OB2$createComputed)(() => {
6308
6453
  const field_value = read_search_field_value();
6309
- if (!(0, $i7OB2$untrack)(updating_blocked[0])) {
6454
+ if ((0, $i7OB2$untrack)(updating_blocked[0]))
6455
+ // not using updating_blocked instead of below signal since I presume they'd start updating too early then
6456
+ set_show_stale_content_results(true);else {
6310
6457
  set_searching_for_value(field_value);
6311
6458
  deparallelized_fn({
6312
6459
  query: field_value,
6313
6460
  tenant: tenant_(),
6314
6461
  market: market_()
6315
6462
  });
6463
+ set_show_stale_content_results(false);
6316
6464
  }
6317
6465
  });
6318
6466
  (0, $i7OB2$createComputed)((0, $i7OB2$on)(search_field_value_[0], () => !updating_blocked[0]() && selected_index_[1](undefined), {
@@ -6324,7 +6472,7 @@ function $a0eb8b431ec1f87b$export$2f2b9559550c7bbc({
6324
6472
  search_field_value_: search_field_value_,
6325
6473
  updating_blocked_: updating_blocked,
6326
6474
  currently_showing_suggestions_: currently_showing_suggestions_,
6327
- set_override_on_enter_fn_: set_override_on_enter_fn_,
6475
+ set_override_on_enter_fn_: manipulated_set_override_on_enter_fn_,
6328
6476
  search_query_param_name_: search_query_url_param_name_,
6329
6477
  url_transformer_: url_transformer_,
6330
6478
  router_: router_
@@ -6363,11 +6511,12 @@ function $a0eb8b431ec1f87b$export$2f2b9559550c7bbc({
6363
6511
  },
6364
6512
  on_previous_searches_page_: show_previous_searches_component,
6365
6513
  i18n_: i18n_,
6514
+ get_content_results_: get_content_results_,
6366
6515
  url_transformer_: url_transformer_,
6367
6516
  searching_for_value_: searching_for_value,
6368
6517
  search_query_url_param_name_: search_query_url_param_name_,
6369
6518
  selected_index_: selected_index_,
6370
- suggestion_memo_: read_suggestion_signal,
6519
+ suggestion_memo_: read_suggestion_signal_,
6371
6520
  currently_showing_suggestions_: currently_showing_suggestions_,
6372
6521
  include_category_suggestions_: include_category_suggestions_,
6373
6522
  router_: router_,
@@ -6467,7 +6616,8 @@ function $fabfda1230351b1a$export$1c593cbd6f1e10bc({
6467
6616
  bottom_distance_under_modal_: bottom_distance_under_modal_,
6468
6617
  selected_text_range_: selected_text_range_,
6469
6618
  dont_sync_search_field_value_except_on_submit_ = false,
6470
- router_: router_
6619
+ router_: router_,
6620
+ content_search_enabled_: content_search_enabled_
6471
6621
  }) {
6472
6622
  let on_enter_in_search_field_function;
6473
6623
  // 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.
@@ -6484,30 +6634,23 @@ function $fabfda1230351b1a$export$1c593cbd6f1e10bc({
6484
6634
  };
6485
6635
  const [input_field, set_input_field] = (0, $i7OB2$createSignal)();
6486
6636
  const [get_search_field_value_] = search_field_value_;
6487
- const [elements_outside_scrollable, set_elements_outside_scrollable] = (0, $i7OB2$createSignal)();
6488
- const [elements_inside_scrollable, set_elements_inside_scrollable] = (0, $i7OB2$createSignal)();
6637
+ const [get_modal_search_results, set_modal_search_results_] = (0, $i7OB2$createSignal)();
6489
6638
  const close_on_escape_handler = (0, $i7OB2$catchify)(({
6490
6639
  key: key
6491
6640
  }) => {
6492
6641
  if (key === "Escape") close_modal_();
6493
6642
  });
6494
- const [get_num_results_accessor, set_num_results_accessor_] = (0, $i7OB2$createSignal)();
6643
+ const [get_total_num_results_accessor, set_total_num_results_accessor_] = (0, $i7OB2$createSignal)();
6495
6644
  const selected_index = (0, $i7OB2$createSignal)();
6496
6645
  const currently_showing_suggestions_ = (0, $i7OB2$createSignal)([], {
6497
6646
  equals: false
6498
6647
  });
6648
+ const less_than_700_high = (0, $dc9262ef6f786812$export$d9f36cf74e24d595)("(max-height:700px)");
6649
+ const DiscoverMoreSection = () => (0, $i7OB2$ssr)($fabfda1230351b1a$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)(), get_search_field_value_() ? (0, $i7OB2$escape)(i18n_.modal_view_all_results_()((0, $i7OB2$ssr)($fabfda1230351b1a$var$_tmpl$2, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)(get_total_num_results_accessor?.())))) : (0, $i7OB2$escape)(i18n_.modal_discover_more_()));
6499
6650
  if (disable_scrolling_) (0, $aea1edf92433e81e$export$fe334901e8bebd57)();
6500
6651
  $fabfda1230351b1a$var$close_modal_when_navigating_away(close_modal_, search_query_url_param_name_);
6501
6652
  window.addEventListener("keydown", close_on_escape_handler);
6502
6653
  (0, $i7OB2$onCleanup)((0, $i7OB2$catchify)(() => window.removeEventListener("keydown", close_on_escape_handler)));
6503
- const owner = (0, $i7OB2$getOwner)();
6504
- (0, $i7OB2$onCleanup)((0, $i7OB2$javascript_media_query)("(max-height:700px)", ({
6505
- matches: matches
6506
- }) => (0, $i7OB2$runWithOwner)(owner, () => {
6507
- // the if below is reactive so we need an owner
6508
- (matches ? set_elements_outside_scrollable : set_elements_inside_scrollable)("");
6509
- (matches ? set_elements_inside_scrollable : set_elements_outside_scrollable)((0, $i7OB2$ssr)($fabfda1230351b1a$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)(), get_search_field_value_() ? (0, $i7OB2$escape)(i18n_.modal_view_all_results_()((0, $i7OB2$ssr)($fabfda1230351b1a$var$_tmpl$2, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)(get_num_results_accessor?.())))) : (0, $i7OB2$escape)(i18n_.modal_discover_more_())));
6510
- })).remove);
6511
6654
  if (closing_animation_) register_closing_animation_(closing_animation_);
6512
6655
  (0, $c64d28ca12452b21$export$3340fdd8259bd4fd)({
6513
6656
  get_search_field_value_: get_search_field_value_,
@@ -6566,7 +6709,9 @@ function $fabfda1230351b1a$export$1c593cbd6f1e10bc({
6566
6709
  i18n_: i18n_,
6567
6710
  include_category_suggestions_: enable_category_suggestions_ ?? true,
6568
6711
  router_: router_,
6569
- submit_query_: submit_query_
6712
+ submit_query_: submit_query_,
6713
+ get_modal_search_results_: get_modal_search_results,
6714
+ content_search_enabled_: content_search_enabled_
6570
6715
  });
6571
6716
  }
6572
6717
  })), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $b7436a6d1fd64e3b$export$b69d0d92862de18b), {
@@ -6579,12 +6724,28 @@ function $fabfda1230351b1a$export$1c593cbd6f1e10bc({
6579
6724
  tenant_: tenant_,
6580
6725
  i18n_: i18n_,
6581
6726
  market_: market_,
6582
- set_num_results_accessor_: set_num_results_accessor_,
6727
+ set_total_num_results_accessor_: set_total_num_results_accessor_,
6583
6728
  router_: router_,
6729
+ set_modal_search_results_: set_modal_search_results_,
6730
+ content_search_enabled_: content_search_enabled_,
6584
6731
  ...instant_results_options_
6585
6732
  });
6586
6733
  }
6587
- })), (0, $i7OB2$escape)(elements_inside_scrollable()), (0, $i7OB2$escape)(elements_outside_scrollable()), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $19f1f3e588d63502$export$f021bdedd3ec901a), {
6734
+ })), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $i7OB2$Show), {
6735
+ get when() {
6736
+ return less_than_700_high();
6737
+ },
6738
+ get children() {
6739
+ return (0, $i7OB2$createComponent)(DiscoverMoreSection, {});
6740
+ }
6741
+ })), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $i7OB2$Show), {
6742
+ get when() {
6743
+ return !less_than_700_high();
6744
+ },
6745
+ get children() {
6746
+ return (0, $i7OB2$createComponent)(DiscoverMoreSection, {});
6747
+ }
6748
+ })), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $19f1f3e588d63502$export$f021bdedd3ec901a), {
6588
6749
  styles: body_style
6589
6750
  })));
6590
6751
  return [(0, $i7OB2$ssr)($fabfda1230351b1a$var$_tmpl$4, (0, $i7OB2$ssrHydrationKey)() + (0, $i7OB2$ssrAttribute)("id", (0, $i7OB2$escape)((0, $f86ba724282f6690$export$44dad306455dddf).SEARCH_MODAL, true), false), `depict plp search ${(0, $i7OB2$escape)((0, $i7OB2$ssrClassList)(class_list_?.()), true) || ""}`, (0, $i7OB2$escape)(modal_element))];
@@ -6656,14 +6817,21 @@ const $f8c929beb82c512b$var$_tmpl$ = ["<b", ">", "</b>"],
6656
6817
  function $f8c929beb82c512b$export$9dd50d35b9d94fdf({
6657
6818
  get_search_query_: get_search_query_,
6658
6819
  i18n_: i18n_,
6659
- formatted_number_of_results_: formatted_number_of_results_
6820
+ formatted_number_of_results_: formatted_number_of_results_,
6821
+ number_of_results_: number_of_results_,
6822
+ type: type
6660
6823
  }) {
6661
6824
  const contents = (0, $i7OB2$createMemo)((0, $i7OB2$catchify)(() => {
6662
6825
  const q = get_search_query_();
6663
- return i18n_.get_showing_results_for_()((0, $i7OB2$ssr)($f8c929beb82c512b$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)(q)), (0, $i7OB2$ssr)($f8c929beb82c512b$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)(formatted_number_of_results_())));
6826
+ return i18n_[type === $f8c929beb82c512b$export$2452208c79fe93ea.content ? "get_showing_pages_for_" : "get_showing_results_for_"]()((0, $i7OB2$ssr)($f8c929beb82c512b$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)(q)), (0, $i7OB2$ssr)($f8c929beb82c512b$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)(formatted_number_of_results_())), !!q, number_of_results_());
6664
6827
  }));
6665
6828
  return (0, $i7OB2$ssr)($f8c929beb82c512b$var$_tmpl$2, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)(contents()));
6666
6829
  }
6830
+ let $f8c929beb82c512b$export$2452208c79fe93ea;
6831
+ (function (ShowingResultsForType) {
6832
+ ShowingResultsForType[ShowingResultsForType["products"] = 0] = "products";
6833
+ ShowingResultsForType[ShowingResultsForType["content"] = 1] = "content";
6834
+ })($f8c929beb82c512b$export$2452208c79fe93ea || ($f8c929beb82c512b$export$2452208c79fe93ea = {}));
6667
6835
  function $1801dbce7adb3f19$export$41b4894022a3580f({
6668
6836
  style_props_ = (0, $i7OB2$createSignal)({})
6669
6837
  } = {}) {
@@ -6682,8 +6850,429 @@ function $1801dbce7adb3f19$export$41b4894022a3580f({
6682
6850
  })));
6683
6851
  return style_props_;
6684
6852
  }
6853
+ const $522a690e0e2bd46d$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"];
6854
+ const $522a690e0e2bd46d$var$dont_cut_in_between_less_than_characters = 30;
6855
+ function $522a690e0e2bd46d$export$e1a98a189fd2c0e7({
6856
+ content_result_: content_result_,
6857
+ key_: key_,
6858
+ cut_when_possible_: cut_when_possible_
6859
+ }) {
6860
+ const matched_tokens = (0, $i7OB2$createMemo)(() => content_result_().highlights?.find(highlight => highlight.field == key_)?.matched_tokens);
6861
+ const full_value = (0, $i7OB2$createMemo)(() => content_result_()[key_]?.replaceAll("\n", " "));
6862
+ return (0, $i7OB2$createComponent)((0, $i7OB2$Show), {
6863
+ get when() {
6864
+ return matched_tokens()?.length;
6865
+ },
6866
+ get fallback() {
6867
+ return full_value();
6868
+ },
6869
+ get children() {
6870
+ return (() => {
6871
+ const segmented_cut_text = (0, $i7OB2$createMemo)(() => {
6872
+ const segmented_text = $522a690e0e2bd46d$var$segment_text(full_value(), matched_tokens());
6873
+ if (cut_when_possible_) $522a690e0e2bd46d$var$cut_text(segmented_text);
6874
+ return segmented_text;
6875
+ });
6876
+ return (0, $i7OB2$createComponent)((0, $i7OB2$Index), {
6877
+ get each() {
6878
+ return segmented_cut_text();
6879
+ },
6880
+ children: item => {
6881
+ return (0, $i7OB2$createComponent)((0, $i7OB2$Show), {
6882
+ get when() {
6883
+ return item().highlighted_;
6884
+ },
6885
+ get fallback() {
6886
+ return item().text_;
6887
+ },
6888
+ get children() {
6889
+ return (0, $i7OB2$ssr)($522a690e0e2bd46d$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)(item().text_));
6890
+ }
6891
+ });
6892
+ }
6893
+ });
6894
+ })();
6895
+ }
6896
+ });
6897
+ }
6898
+ function $522a690e0e2bd46d$var$cut_text(segmented_text) {
6899
+ // cut away chunks of text that are not highlighted to give a google-like overview of the content
6900
+ const highlighted_segments = segmented_text?.filter(segment => segment.highlighted_);
6901
+ if (!segmented_text || !highlighted_segments?.length) return;
6902
+ // We have one or more highlighted segments
6903
+ if (highlighted_segments.length === 1) {
6904
+ // cut away from the left until the start of the highlighted sentence if just one sentence is highlighted
6905
+ $522a690e0e2bd46d$var$cut_start(segmented_text.indexOf(highlighted_segments[0]), segmented_text);
6906
+ return;
6907
+ }
6908
+ // We have two or more highlighted segments, take the two biggest chunks and show them + a bit text around
6909
+ 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
6910
+ );
6911
+
6912
+ const [longest_segment, next_longest_segment] = sorted_highlighted_segments;
6913
+ // We need to cut before the first segment - possibly through other segments - and maybe between segments
6914
+ 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);
6915
+ $522a690e0e2bd46d$var$cut_start(index_of_first_segment, segmented_text);
6916
+ // update indexes since we might have removed segments
6917
+ [index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
6918
+ let number_of_characters_between_segments = 0;
6919
+ for (let i = index_of_first_segment + 1; i < index_of_second_segment; i++) {
6920
+ const segment = segmented_text[i];
6921
+ number_of_characters_between_segments += segment.text_.length;
6922
+ }
6923
+ if (number_of_characters_between_segments < $522a690e0e2bd46d$var$dont_cut_in_between_less_than_characters)
6924
+ // don't cut if there are less than 30 characters between the two segments
6925
+ return;
6926
+ // We have more than 50 characters between the two segments, cut between them
6927
+ const [split_start_segment, split_start_character] = $522a690e0e2bd46d$var$find_split_point(index_of_first_segment, index_of_second_segment, segmented_text);
6928
+ const [split_end_segment, split_end_character] = $522a690e0e2bd46d$var$find_split_point(index_of_second_segment, index_of_first_segment, segmented_text);
6929
+ if (split_start_segment === undefined || split_end_segment === undefined ||
6930
+ // identical split point, or split end before split start, can't do anything
6931
+ split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
6932
+ const dots_segment = {
6933
+ text_: " … ",
6934
+ highlighted_: false
6935
+ };
6936
+ const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
6937
+ if (i < split_start_segment || i > split_end_segment) return segment;
6938
+ const text = segment.text_;
6939
+ if (i == split_end_segment && i == split_start_segment) return [{
6940
+ ...segment,
6941
+ text_: text.slice(0, split_start_character).trimEnd()
6942
+ }, dots_segment, {
6943
+ ...segment,
6944
+ text_: text.slice(split_end_character + 1, text.length).trimStart()
6945
+ }];else if (i == split_start_segment) {
6946
+ 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
6947
+ return segment;
6948
+ } else if (i == split_end_segment) return [dots_segment, {
6949
+ ...segment,
6950
+ text_: text.slice(split_end_character + 1, text.length).trimStart()
6951
+ }];
6952
+ return []; // remove all segments inbetween
6953
+ });
6954
+
6955
+ segmented_text.splice(0, segmented_text.length, ...split_and_dotted_values); // Sorry…
6956
+ $522a690e0e2bd46d$var$heal_holes(segmented_text);
6957
+ }
6958
+ function $522a690e0e2bd46d$var$heal_holes(segmented_text) {
6959
+ // try to heal "holes" created in the segments so there are only alternating segments
6960
+ const segments_to_delete = new Set();
6961
+ for (let i = 0; i < segmented_text.length; i++) {
6962
+ const segment = segmented_text[i];
6963
+ let previous_segment;
6964
+ for (let j = i - 1; j >= 0; j--) {
6965
+ previous_segment = segmented_text[j];
6966
+ // Don't write to a segment that's marked for deletion or the contents we write to it will be deleted
6967
+ if (!segments_to_delete.has(previous_segment)) break;
6968
+ }
6969
+ if (previous_segment?.highlighted_ && segment.highlighted_ || previous_segment?.highlighted_ === false && segment.highlighted_ === false) {
6970
+ previous_segment.text_ += segment.text_; // IDK if this ever happens
6971
+ segments_to_delete.add(segment);
6972
+ }
6973
+ }
6974
+ for (const segment of segments_to_delete) {
6975
+ const index = segmented_text.indexOf(segment);
6976
+ segmented_text.splice(index, 1);
6977
+ }
6978
+ }
6979
+ function $522a690e0e2bd46d$var$find_split_point(index_of_start_segment, index_of_end_segment, segmented_text, be_very_aggressive = true) {
6980
+ const should_loop_backwards = index_of_start_segment > index_of_end_segment;
6981
+ const step = should_loop_backwards ? -1 : 1;
6982
+ const desperate_split_attempts = [":", ";", ","];
6983
+ while (desperate_split_attempts.length) {
6984
+ const split_point_between_words = [];
6985
+ // for the middle also try to split with a few more characters if the default ones don't work over a full run
6986
+ const desperate_split_attempt = desperate_split_attempts.pop();
6987
+ let is_first_character = true;
6988
+ for (let i = index_of_start_segment + step; should_loop_backwards ? i > index_of_end_segment : i < index_of_end_segment; i += step) {
6989
+ const segment = segmented_text[i];
6990
+ const text = segment.text_;
6991
+ for (let j = should_loop_backwards ? text.length - 1 : 0; should_loop_backwards ? j >= 0 : j < text.length; j += step) {
6992
+ const character = text[j];
6993
+ if (character == "." || character == "?" || character == "!" || character == desperate_split_attempt) return [i, j]; // segment index, character index
6994
+ if (is_first_character) is_first_character = false;else if (be_very_aggressive && character == " ") {
6995
+ split_point_between_words.push([i, j]);
6996
+ if (split_point_between_words.length > 3)
6997
+ // We can't find a split point, so we'll just split between words
6998
+ // 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
6999
+ return split_point_between_words[1];
7000
+ }
7001
+ }
7002
+ }
7003
+ }
7004
+ return [];
7005
+ }
7006
+ function $522a690e0e2bd46d$var$cut_start(cut_left_of_index, segmented_text) {
7007
+ // Cut the start of the text to bring the first matching token
7008
+ let is_first_character = false;
7009
+ let words_encountered = 0;
7010
+ outmost_loop: for (let i = cut_left_of_index - 1; i >= 0; i--) {
7011
+ const segment = segmented_text[i];
7012
+ // We assume that two adjacent highlighted segments don't exist and have been merged if they were to have existed
7013
+ const text = segment.text_;
7014
+ for (let j = text.length - 1; j >= 0; j--) {
7015
+ const character = text[j];
7016
+ const is_space = character == " ";
7017
+ if (!is_first_character && is_space) words_encountered++;
7018
+ if (character == "." || character == "?" || character == "!" || character == "," || words_encountered > 8 && is_space) {
7019
+ // We have to be really aggressive at the start of sentences so stuff can be seen on mobile, hence comma
7020
+ segment.text_ = text.slice(j + 1).trimStart();
7021
+ segmented_text.splice(0, i);
7022
+ if (character === "," || is_space)
7023
+ // if we cut at a comma or psace, we add a … at the beginning
7024
+ segmented_text.unshift({
7025
+ text_: "… ",
7026
+ highlighted_: false
7027
+ });
7028
+ break outmost_loop;
7029
+ }
7030
+ if (is_first_character) is_first_character = false;
7031
+ }
7032
+ }
7033
+ $522a690e0e2bd46d$var$heal_holes(segmented_text); // if we added a ... there could now be a sequence that's not alternating true/false
7034
+ }
7035
+
7036
+ function $522a690e0e2bd46d$var$segment_text(text, matched_strings) {
7037
+ // segment text where the matched strings are highlighted sections
7038
+ const output = [];
7039
+ if (!text) return; // shouldn't happen but whatever
7040
+ for (let i = 0; i < text.length; i++) {
7041
+ const found_strings = [];
7042
+ if (!i || text[i - 1] == " ")
7043
+ // only match at the start of a word or string, it looks weird if i.e. "we" is highlighted in "activewear
7044
+ for (let j = 0; j < matched_strings.length; j++) {
7045
+ const matched_string = matched_strings[j];
7046
+ const part_in_text = text.slice(i, i + matched_string.length);
7047
+ if (matched_string.length < 2) continue; // don't match on single characters, i.e. "I", it looks weird
7048
+ 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
7049
+ }
7050
+
7051
+ const last_index_in_output = output.length - 1;
7052
+ if (!found_strings.length) {
7053
+ const character = text[i];
7054
+ if (output[last_index_in_output]?.highlighted_ === false || output.length && /\s/.test(character))
7055
+ // 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
7056
+ output[last_index_in_output].text_ += character;else output.push({
7057
+ highlighted_: false,
7058
+ text_: character
7059
+ });
7060
+ } else {
7061
+ const longest_found_string = found_strings.reduce((a, b) => a.length > b.length ? a : b);
7062
+ if (output[last_index_in_output]?.highlighted_) output[last_index_in_output].text_ += longest_found_string;else output.push({
7063
+ highlighted_: true,
7064
+ text_: longest_found_string
7065
+ });
7066
+ i += longest_found_string.length - 1;
7067
+ }
7068
+ }
7069
+ return output;
7070
+ }
7071
+ const $b2bf2cdcff8142d8$var$_tmpl$ = ["<div", ' class="description line-clamp">', "</div>"],
7072
+ $b2bf2cdcff8142d8$var$_tmpl$2 = ["<div", ' class="content-card"><div class="image">', '</div><div class="info"><!--#-->', "<!--/--><!--#-->", "<!--/--></div></div>"];
7073
+ function $b2bf2cdcff8142d8$export$f631859cab12b342({
7074
+ router_: router_,
7075
+ content_result_: content_result_
7076
+ }) {
7077
+ const make_link_attributes = () => {
7078
+ const result = content_result_?.();
7079
+ if (!result) return;
7080
+ return {
7081
+ href: result.page_url,
7082
+ onClick: (0, $i7OB2$catchify)(ev => router_.navigate_.go_to_({
7083
+ new_url_: result.page_url,
7084
+ is_replace_: false,
7085
+ event_: ev
7086
+ }))
7087
+ };
7088
+ };
7089
+ const LinkIfPossible = ({
7090
+ children: children,
7091
+ ...attributes
7092
+ }) => {
7093
+ if (content_result_) return (0, $i7OB2$ssrElement)("a", attributes, () => (0, $i7OB2$escape)(children), true);
7094
+ return (0, $i7OB2$ssrElement)("div", attributes, () => (0, $i7OB2$escape)(children), true);
7095
+ };
7096
+ return (0, $i7OB2$ssr)($b2bf2cdcff8142d8$var$_tmpl$2, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)((0, $i7OB2$createComponent)(LinkIfPossible, (0, $i7OB2$mergeProps)(make_link_attributes, {
7097
+ tabIndex: "-1",
7098
+ get children() {
7099
+ return (0, $i7OB2$createComponent)((0, $190927650b4840eb$export$605674723bcc715c), {
7100
+ width: "28",
7101
+ height: "28"
7102
+ });
7103
+ }
7104
+ }))), (0, $i7OB2$escape)((0, $i7OB2$createComponent)(LinkIfPossible, (0, $i7OB2$mergeProps)({
7105
+ "class": "content-title line-clamp"
7106
+ }, make_link_attributes, {
7107
+ get title() {
7108
+ return content_result_?.().title;
7109
+ },
7110
+ get children() {
7111
+ return content_result_ ? (0, $i7OB2$createComponent)((0, $522a690e0e2bd46d$export$e1a98a189fd2c0e7), {
7112
+ content_result_: content_result_,
7113
+ key_: "title",
7114
+ cut_when_possible_: false
7115
+ }) : (0, $i7OB2$createComponent)((0, $d134eae24341b4a1$export$89c6019e4baa40b1), {
7116
+ height: "1em",
7117
+ width: "20ch"
7118
+ });
7119
+ }
7120
+ }))), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $i7OB2$Show), {
7121
+ get when() {
7122
+ return content_result_?.().description || !content_result_;
7123
+ },
7124
+ get children() {
7125
+ return (0, $i7OB2$ssr)($b2bf2cdcff8142d8$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $i7OB2$Show), {
7126
+ when: content_result_,
7127
+ get fallback() {
7128
+ return Array.from({
7129
+ length: 4
7130
+ }).map(() => (0, $i7OB2$createComponent)((0, $d134eae24341b4a1$export$89c6019e4baa40b1), {
7131
+ height: "1em",
7132
+ width: "min(50ch, 100%)"
7133
+ }));
7134
+ },
7135
+ get children() {
7136
+ return (0, $i7OB2$createComponent)((0, $522a690e0e2bd46d$export$e1a98a189fd2c0e7), {
7137
+ content_result_: content_result_,
7138
+ key_: "description",
7139
+ cut_when_possible_: true
7140
+ });
7141
+ }
7142
+ })));
7143
+ }
7144
+ })));
7145
+ }
7146
+ function $b26bdbd081f63e3f$export$9ff751cd77687edc({
7147
+ search_results_: search_results_,
7148
+ router_: router_
7149
+ }) {
7150
+ const content_results = (0, $i7OB2$createMemo)(() => search_results_()?.content_search_links);
7151
+ const content_results_by_page_url = (0, $i7OB2$createMemo)(() => {
7152
+ const map = new Map();
7153
+ const results = content_results();
7154
+ if (!results) return map;
7155
+ for (let i = 0; i < results.length; i++) {
7156
+ const content_result = results[i];
7157
+ map.set(content_result.page_url, content_result);
7158
+ }
7159
+ return map;
7160
+ });
7161
+ return (0, $i7OB2$createComponent)((0, $i7OB2$For), {
7162
+ get each() {
7163
+ return [...content_results_by_page_url().keys()];
7164
+ },
7165
+ children: page_url => {
7166
+ const content_result = (0, $i7OB2$createMemo)(() => content_results_by_page_url().get(page_url));
7167
+ return (0, $i7OB2$createComponent)((0, $b2bf2cdcff8142d8$export$f631859cab12b342), {
7168
+ content_result_: content_result,
7169
+ router_: router_
7170
+ });
7171
+ }
7172
+ });
7173
+ }
7174
+ function $9d5b3ed1fc91c672$export$4405d077f0a20494({
7175
+ content_results_rows_: [get_history_state_content_results_rows],
7176
+ cols_at_size_: cols_at_size_
7177
+ }) {
7178
+ const largest_column = (0, $i7OB2$createMemo)(() => {
7179
+ const largest_in_cols_at_size = Math.max(...cols_at_size_().map(([cols]) => cols));
7180
+ 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
7181
+ return largest_in_cols_at_size;
7182
+ });
7183
+ const num_placeholders = (0, $i7OB2$createMemo)(() => (get_history_state_content_results_rows() ?? (0, $49de9d31aeea1b5e$export$70ceae36059a1036)) * largest_column());
7184
+ return (0, $i7OB2$createComponent)((0, $i7OB2$Index), {
7185
+ get each() {
7186
+ return Array.from({
7187
+ length: num_placeholders()
7188
+ });
7189
+ },
7190
+ children: () => (0, $i7OB2$createComponent)((0, $b2bf2cdcff8142d8$export$f631859cab12b342), {})
7191
+ });
7192
+ }
7193
+ const $49de9d31aeea1b5e$var$_tmpl$ = ["<div", ' class="', '" style="', '"><!--#-->', "<!--/--><!--#-->", "<!--/--></div>"],
7194
+ $49de9d31aeea1b5e$var$_tmpl$2 = ["<button", ' class="view-more">', "</button>"],
7195
+ $49de9d31aeea1b5e$var$_tmpl$3 = ["<button", ' class="view-less">', "</button>"];
7196
+ const $49de9d31aeea1b5e$export$70ceae36059a1036 = 1;
7197
+ function $49de9d31aeea1b5e$export$6d0c9c22f6652669({
7198
+ search_results_: search_results_,
7199
+ get_search_query_: get_search_query_,
7200
+ i18n_: i18n_,
7201
+ layout_options_: layout_options_,
7202
+ router_: router_,
7203
+ query_base_: query_base_,
7204
+ content_results_rows_: content_results_rows_
7205
+ }) {
7206
+ const content_results = (0, $i7OB2$createMemo)(() => search_results_()?.content_search_links);
7207
+ const num_results = (0, $i7OB2$createMemo)(() => content_results()?.length);
7208
+ const is_loading_ = (0, $i7OB2$createMemo)(() => search_results_.loading || query_base_.loading); // See comment in PLPResults/index.tsx on why we need this
7209
+ const formatted_number_of_results_ = (0, $511cc0abd9a64ce8$export$92f2da32c6e7e7ee)({
7210
+ number_: num_results,
7211
+ i18n_: i18n_
7212
+ });
7213
+ const [is_showing_placeholders, set_is_showing_placeholders] = (0, $i7OB2$createSignal)(false);
7214
+ const rows_object = $49de9d31aeea1b5e$var$make_state_saved_rows(content_results_rows_, i18n_);
7215
+ return (0, $i7OB2$ssr)($49de9d31aeea1b5e$var$_tmpl$, (0, $i7OB2$ssrHydrationKey)(), `content-results ${is_showing_placeholders() ? "loading" : ""}`, "display:" + (is_loading_() || content_results()?.length > 0 ? "" : "none"), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $f8c929beb82c512b$export$9dd50d35b9d94fdf), {
7216
+ get_search_query_: get_search_query_,
7217
+ i18n_: i18n_,
7218
+ formatted_number_of_results_: formatted_number_of_results_,
7219
+ get type() {
7220
+ return (0, $f8c929beb82c512b$export$2452208c79fe93ea).content;
7221
+ },
7222
+ number_of_results_: num_results
7223
+ })), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $c8d5ff4524619fcd$export$d21e32dfedac04be), (0, $i7OB2$mergeProps)({
7224
+ layout: "grid",
7225
+ element_attributes: {
7226
+ class: "cards"
7227
+ }
7228
+ }, layout_options_, {
7229
+ rows: rows_object,
7230
+ get children() {
7231
+ return (0, $i7OB2$createComponent)((0, $i7OB2$Suspense), {
7232
+ get fallback() {
7233
+ return (() => {
7234
+ set_is_showing_placeholders(true);
7235
+ (0, $i7OB2$onCleanup)(() => set_is_showing_placeholders(false));
7236
+ return (0, $i7OB2$createComponent)((0, $9d5b3ed1fc91c672$export$4405d077f0a20494), {
7237
+ content_results_rows_: content_results_rows_,
7238
+ get cols_at_size_() {
7239
+ return (0, $i7OB2$createMemo)(() => layout_options_().cols_at_size);
7240
+ }
7241
+ });
7242
+ })();
7243
+ },
7244
+ get children() {
7245
+ return (0, $i7OB2$createComponent)((0, $b26bdbd081f63e3f$export$9ff751cd77687edc), {
7246
+ router_: router_,
7247
+ search_results_: search_results_
7248
+ });
7249
+ }
7250
+ });
7251
+ }
7252
+ }))));
7253
+ }
7254
+ function $49de9d31aeea1b5e$var$make_state_saved_rows(
7255
+ // similar to the one in SearchRecommendations.tsx but not enough to warrant a shared function IMO
7256
+ [get_showing_content_results_rows, set_showing_content_results_rows], i18n_) {
7257
+ const currently_visible = (0, $i7OB2$createSignal)((0, $i7OB2$untrack)(get_showing_content_results_rows));
7258
+ const [get_currently_visible, set_currently_visible] = currently_visible;
7259
+ const rows = {
7260
+ currently_visible: currently_visible,
7261
+ start_rows: $49de9d31aeea1b5e$export$70ceae36059a1036,
7262
+ button: (0, $i7OB2$ssr)($49de9d31aeea1b5e$var$_tmpl$2, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)(i18n_.view_more_())),
7263
+ view_less_button: (0, $i7OB2$ssr)($49de9d31aeea1b5e$var$_tmpl$3, (0, $i7OB2$ssrHydrationKey)(), (0, $i7OB2$escape)(i18n_.view_less_())),
7264
+ rows_per_click: 3
7265
+ };
7266
+ (0, $i7OB2$createComputed)((0, $i7OB2$on)(get_currently_visible, new_visible => set_showing_content_results_rows(new_visible), {
7267
+ defer: true
7268
+ }));
7269
+ (0, $i7OB2$createComputed)((0, $i7OB2$on)(get_showing_content_results_rows, (new_rows = $49de9d31aeea1b5e$export$70ceae36059a1036) => set_currently_visible(new_rows), {
7270
+ defer: true
7271
+ }));
7272
+ return rows;
7273
+ }
6685
7274
  const $7097477c78a89208$var$_tmpl$ = ["<div", ' class="filter-results-for-one-row"><!--#-->', "<!--/--><!--#-->", "<!--/--></div>"],
6686
- $7097477c78a89208$var$_tmpl$2 = ["<div", ' class="depict plp search"><div class="listing-page"><!--#-->', "<!--/--><!--#-->", "<!--/--><!--#-->", "<!--/--><!--#-->", "<!--/--><!--#-->", "<!--/--><!--#-->", "<!--/--></div><!--#-->", "<!--/--><!--#-->", "<!--/--></div>"];
7275
+ $7097477c78a89208$var$_tmpl$2 = ["<div", ' class="depict plp search"><div class="listing-page"><!--#-->', "<!--/--><!--#-->", "<!--/--><!--#-->", "<!--/--><!--#-->", "<!--/--><!--#-->", "<!--/--><!--#-->", "<!--/--><!--#-->", "<!--/--></div><!--#-->", "<!--/--><!--#-->", "<!--/--></div>"];
6687
7276
  function $7097477c78a89208$export$a54ec244c8863715({
6688
7277
  depict_api_: depict_api_,
6689
7278
  search_field_value_: search_field_value_,
@@ -6712,7 +7301,11 @@ function $7097477c78a89208$export$a54ec244c8863715({
6712
7301
  recommendations_layout_options_: recommendations_layout_options_,
6713
7302
  scroll_restoration_data_: scroll_restoration_data_,
6714
7303
  product_card_template_: product_card_template_,
6715
- modal_body_style_ref_: modal_body_style_ref_
7304
+ modal_body_style_ref_: modal_body_style_ref_,
7305
+ router_: router_,
7306
+ content_results_rows_: content_results_rows_,
7307
+ content_layout_options_: content_layout_options_,
7308
+ content_search_enabled_: content_search_enabled_
6716
7309
  }) {
6717
7310
  const [get_sorting] = current_sorting_;
6718
7311
  const all_products_loaded_ = (0, $i7OB2$createSignal)(false);
@@ -6770,16 +7363,23 @@ function $7097477c78a89208$export$a54ec244c8863715({
6770
7363
  const SafeSearchField = (0, $i7OB2$catchify)((0, $5285d2814d0fac0c$export$b94867ecbd698f21));
6771
7364
  const [sort_or_filter_open_, set_sort_or_filter_open_] = (0, $i7OB2$createSignal)(false);
6772
7365
  const [desktop_filter_elements_, set_desktop_filter_elements] = (0, $i7OB2$createSignal)();
7366
+ const n_hits = (0, $i7OB2$createMemo)(() => search_results_()?.n_hits);
6773
7367
  const formatted_number_of_results_ = (0, $511cc0abd9a64ce8$export$92f2da32c6e7e7ee)({
6774
- search_results_: search_results_,
7368
+ number_: n_hits,
6775
7369
  i18n_: i18n_
6776
7370
  });
6777
7371
  const [sort_and_filter_element_, set_sort_and_filter_element_] = (0, $i7OB2$createSignal)();
6778
- const results_for = (0, $i7OB2$createComponent)((0, $f8c929beb82c512b$export$9dd50d35b9d94fdf), {
7372
+ const no_results_text_ = (0, $i7OB2$createMemo)(() => (search_results_()?.content_search_links?.length ? i18n_.no_products_ : i18n_.no_results_text_)());
7373
+ const results_for = (0, $i7OB2$createComponent)((0, $f8c929beb82c512b$export$9dd50d35b9d94fdf), (0, $i7OB2$mergeProps)({
7374
+ get type() {
7375
+ return (0, $f8c929beb82c512b$export$2452208c79fe93ea).products;
7376
+ },
7377
+ number_of_results_: n_hits
7378
+ }, {
6779
7379
  get_search_query_: get_search_query_,
6780
7380
  i18n_: i18n_,
6781
7381
  formatted_number_of_results_: formatted_number_of_results_
6782
- });
7382
+ }));
6783
7383
  const filters_opener = (0, $cdea4cf8c5c071ef$export$d7841e452f2e59a8)({
6784
7384
  set_sort_or_filter_open_: set_sort_or_filter_open_,
6785
7385
  set_extra_els_in_results_container_: set_desktop_filter_elements,
@@ -6882,7 +7482,28 @@ function $7097477c78a89208$export$a54ec244c8863715({
6882
7482
  children: make_category_suggestion_card_
6883
7483
  });
6884
7484
  }
6885
- })) : (0, $i7OB2$escape)(null), (0, $i7OB2$escape)(results_filters[0]()), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $i7OB2$Show), {
7485
+ })) : (0, $i7OB2$escape)(null), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $b7436a6d1fd64e3b$export$b69d0d92862de18b), {
7486
+ severity_: "error",
7487
+ message_: "ContentResults failed",
7488
+ get children() {
7489
+ return (0, $i7OB2$createComponent)((0, $i7OB2$Show), {
7490
+ get when() {
7491
+ return content_search_enabled_();
7492
+ },
7493
+ get children() {
7494
+ return (0, $i7OB2$createComponent)((0, $49de9d31aeea1b5e$export$6d0c9c22f6652669), {
7495
+ content_results_rows_: content_results_rows_,
7496
+ search_results_: search_results_,
7497
+ i18n_: i18n_,
7498
+ get_search_query_: get_search_query_,
7499
+ layout_options_: content_layout_options_,
7500
+ router_: router_,
7501
+ query_base_: search_query_base_
7502
+ });
7503
+ }
7504
+ });
7505
+ }
7506
+ })), (0, $i7OB2$escape)(results_filters[0]()), (0, $i7OB2$escape)((0, $i7OB2$createComponent)((0, $i7OB2$Show), {
6886
7507
  get when() {
6887
7508
  return selected_filters_[0]()?.length;
6888
7509
  },
@@ -6926,7 +7547,10 @@ function $7097477c78a89208$export$a54ec244c8863715({
6926
7547
  selected_filters_: selected_filters_,
6927
7548
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
6928
7549
  local_filter_cache_: local_filter_cache_,
6929
- i18n_: i18n_
7550
+ i18n_: {
7551
+ ...i18n_,
7552
+ no_results_text_: no_results_text_
7553
+ }
6930
7554
  }
6931
7555
  });
6932
7556
  }
@@ -7000,6 +7624,27 @@ function $4ca91518c9a35379$export$828dcdd425fd3231(aligner) {
7000
7624
  cleanup: cleanup
7001
7625
  };
7002
7626
  }
7627
+
7628
+ /**
7629
+ * 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
7630
+ */
7631
+ function $1848f7cca286fbab$export$ff7109b9b2b206ba(sdk_cols_at_size, min_width_for_more_than_one_column = 500) {
7632
+ if (!sdk_cols_at_size.length) return sdk_cols_at_size;
7633
+ const sorted_sizes = sdk_cols_at_size.map(([cols, max_width]) => [cols, max_width ?? Infinity]).sort(([, a], [, b]) => a - b);
7634
+ const [[, smallest_max_width]] = sorted_sizes;
7635
+ if (smallest_max_width > min_width_for_more_than_one_column)
7636
+ // If everything above min_width_for_more_than_one_column, we can just add a 1 column at the beginning
7637
+ return [[1, min_width_for_more_than_one_column], ...sdk_cols_at_size];
7638
+ const to_delete = [];
7639
+ for (let i = 0; i < sorted_sizes.length; i++) {
7640
+ const [, max_width] = sorted_sizes[i];
7641
+ if (max_width > min_width_for_more_than_one_column) continue;
7642
+ to_delete.push(i);
7643
+ }
7644
+ while (to_delete.length) sorted_sizes.splice(to_delete.pop(), 1);
7645
+ sorted_sizes.unshift([1, min_width_for_more_than_one_column]);
7646
+ return sorted_sizes.map(([cols, max_width]) => max_width == Infinity ? [cols] : [cols, max_width]);
7647
+ }
7003
7648
  const $806c97b931758897$var$_tmpl$ = ["<div", ' class="depict plp search">', "</div>"];
7004
7649
  // 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
7005
7650
  /**
@@ -7009,6 +7654,7 @@ const $806c97b931758897$var$_tmpl$ = ["<div", ' class="depict plp search">', "</
7009
7654
  * 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.
7010
7655
  */
7011
7656
  const $806c97b931758897$var$privately_shared_properties = /*@__PURE__*/new WeakMap();
7657
+ const $806c97b931758897$var$content_search_default = false;
7012
7658
  const $806c97b931758897$var$min_products_to_fetch_ = 20;
7013
7659
  const $806c97b931758897$export$bde3eb976dfded9 = depict_search => $806c97b931758897$var$privately_shared_properties.get(depict_search)?.search_query_updating_blocked_;
7014
7660
  class $806c97b931758897$export$ac6237957a15b3f0 {
@@ -7016,6 +7662,7 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
7016
7662
  #merchant_signal = (0, $i7OB2$createSignal)();
7017
7663
  #market_signal = (0, $i7OB2$createSignal)();
7018
7664
  #modal_open_signal = (0, $i7OB2$createSignal)(false);
7665
+ #content_search_signal = (0, $i7OB2$createSignal)();
7019
7666
  static #keys_constructed_with = new Set();
7020
7667
  #router = new (0, $4fd2ba03703a7d92$export$7e1297a3a19f10d8)("hard_navigation");
7021
7668
  constructor({
@@ -7025,9 +7672,10 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
7025
7672
  on_navigation: on_navigation,
7026
7673
  enable_category_suggestions = true,
7027
7674
  page_url_creator: page_url_creator,
7675
+ display_transformers: display_transformers,
7676
+ api: api,
7028
7677
  // Stuff needed for non-standard customer deployments that we shouldn't actually expose
7029
7678
  disable_scrolling_during_modal = true,
7030
- api: api,
7031
7679
  bottom_distance_under_modal: bottom_distance_under_modal,
7032
7680
  render_instant_card: render_instant_card,
7033
7681
  ...props_on_class
@@ -7061,6 +7709,7 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
7061
7709
  local_filter_cache: [],
7062
7710
  expanded_hierarchical_filters: [],
7063
7711
  showing_recommendation_rows: (0, $172e1b898d457050$export$1c8c715550dc689d),
7712
+ content_results_rows: (0, $49de9d31aeea1b5e$export$70ceae36059a1036),
7064
7713
  scroll_restoration_data: []
7065
7714
  }),
7066
7715
  router_: this.#router,
@@ -7071,12 +7720,18 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
7071
7720
  const get_search_query_ = (0, $i7OB2$createMemo)(previous_value => {
7072
7721
  if (get_search_query_updating_blocked()) return previous_value;else return raw_search_query_accessor();
7073
7722
  });
7723
+ // @ts-ignore
7074
7724
  const depict_api_ = api ?? new (0, $7fa23e2a0079eca4$export$e015ed2f2950f2e3)({
7075
- page_url_creator: page_url_creator
7725
+ page_url_creator: page_url_creator,
7726
+ display_transformers: display_transformers
7076
7727
  });
7077
7728
  const previous_searches = (0, $21f51c14cb3f586f$export$84bba84a7b837187)(get_search_query_);
7078
7729
  const [, set_search_showing_recommendation_rows] = state_.showing_recommendation_rows;
7079
- 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
7730
+ const [, set_search_content_results_rows] = state_.content_results_rows;
7731
+ const after_submit_ = () => {
7732
+ set_search_showing_recommendation_rows((0, $172e1b898d457050$export$1c8c715550dc689d));
7733
+ set_search_content_results_rows((0, $49de9d31aeea1b5e$export$70ceae36059a1036));
7734
+ }; // do this every time after we have submitted a new query - otherwise there might already be a saved number of rows in the state
7080
7735
  const on_submit_with_unchanged_value_ = () => this.modal_open = false;
7081
7736
  const [get_search_field_value_, set_search_field_value_] = state_.field_value;
7082
7737
  const configured_submit_query_ = new_query => (0, $bfd908d13d90934c$export$e16630ecb9644a1c)({
@@ -7134,6 +7789,7 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
7134
7789
  submit_query_: configured_submit_query_,
7135
7790
  url_transformer_: url_transformer,
7136
7791
  router_: this.#router,
7792
+ content_search_enabled_: () => this.#content_search_signal[0]() ?? $806c97b931758897$var$content_search_default,
7137
7793
  instant_results_options_: {
7138
7794
  min_products_to_fetch_: $806c97b931758897$var$min_products_to_fetch_,
7139
7795
  render_instant_card_: render_instant_card,
@@ -7198,6 +7854,12 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
7198
7854
  (0, $i7OB2$onCleanup)(() => $806c97b931758897$export$ac6237957a15b3f0.#keys_constructed_with.delete(unique_instance_key_for_state));
7199
7855
  });
7200
7856
  }
7857
+ get enable_content_search() {
7858
+ return this.#content_search_signal[0]();
7859
+ }
7860
+ set enable_content_search(new_state) {
7861
+ this.#content_search_signal[1](new_state);
7862
+ }
7201
7863
  get on_navigation() {
7202
7864
  // The only non-reactive public property on the class (I don't see it making sense to have it reactive)
7203
7865
  return this.#router.on_navigation_;
@@ -7279,6 +7941,7 @@ function $806c97b931758897$export$f2dc7e4e4aa11abb(props) {
7279
7941
  depict_api_: shared_properties.depict_api_,
7280
7942
  min_products_to_fetch_: $806c97b931758897$var$min_products_to_fetch_,
7281
7943
  local_filter_cache_: state_.local_filter_cache,
7944
+ content_search_enabled_: () => depict_search.enable_content_search ?? $806c97b931758897$var$content_search_default,
7282
7945
  search_field_value_: state_.field_value,
7283
7946
  get_search_query_: shared_properties.get_search_query_,
7284
7947
  clear_filters_on_next_submit_: shared_properties.clear_filters_on_next_submit_,
@@ -7305,6 +7968,8 @@ function $806c97b931758897$export$f2dc7e4e4aa11abb(props) {
7305
7968
  search_filters_open_: state_.filters_open,
7306
7969
  search_sorting_open_: state_.sorting_open,
7307
7970
  expanded_filters_: state_.expanded_filters,
7971
+ content_results_rows_: state_.content_results_rows,
7972
+ router_: shared_properties.router_,
7308
7973
  make_category_suggestion_card_: shared_properties.enable_category_suggestions_ ? category_suggestion_ => {
7309
7974
  return (0, $897bd4a76f611b38$export$d757d54550ebfb3d)({
7310
7975
  category_suggestion_: category_suggestion_,
@@ -7320,6 +7985,10 @@ function $806c97b931758897$export$f2dc7e4e4aa11abb(props) {
7320
7985
  cols_at_size: (0, $b5cccc8ee7d24677$export$6daf8749b65a1b77)(props.cols_at_size),
7321
7986
  ...grid_spacing_override()
7322
7987
  })),
7988
+ content_layout_options_: (0, $i7OB2$createMemo)(() => ({
7989
+ cols_at_size: (0, $b5cccc8ee7d24677$export$6daf8749b65a1b77)((0, $1848f7cca286fbab$export$ff7109b9b2b206ba)(props.cols_at_size)),
7990
+ ...grid_spacing_override()
7991
+ })),
7323
7992
  recommendations_layout_options_: (0, $i7OB2$createMemo)(() => {
7324
7993
  const {
7325
7994
  extra_depict_options: extra_depict_options