@depict-ai/ui 2.1.11 → 2.1.13

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.
@@ -1,12 +1,12 @@
1
1
  import { add_to_version_info as $i7OB2$add_to_version_info, base64_encode_unicode as $i7OB2$base64_encode_unicode, base64_decode_unicode as $i7OB2$base64_decode_unicode, dlog as $i7OB2$dlog, queueMacroTask as $i7OB2$queueMacroTask, catchify as $i7OB2$catchify, is_safari as $i7OB2$is_safari, observer as $i7OB2$observer, dwarn as $i7OB2$dwarn, Amazing_Slider as $i7OB2$Amazing_Slider, slider_snap_css as $i7OB2$slider_snap_css, slider_fading_factory as $i7OB2$slider_fading_factory, slider_fractional_factory as $i7OB2$slider_fractional_factory, camelCasifyObject as $i7OB2$camelCasifyObject, make_random_classname as $i7OB2$make_random_classname, n_col_styling_with_dist as $i7OB2$n_col_styling_with_dist, layout_get_visible_recs_without_partial_rows as $i7OB2$layout_get_visible_recs_without_partial_rows, layout_get_total_rec_amount_for_row as $i7OB2$layout_get_total_rec_amount_for_row, layout_media_query_header as $i7OB2$layout_media_query_header, report as $i7OB2$report, useExpandingContainer as $i7OB2$useExpandingContainer, standard_price_format as $i7OB2$standard_price_format, hex_to_rgb as $i7OB2$hex_to_rgb, relative_luminance_from_rgb as $i7OB2$relative_luminance_from_rgb, fetch_recs as $i7OB2$fetch_recs, snakeCasifyObject as $i7OB2$snakeCasifyObject, instant_exec_on_suspect_history_change as $i7OB2$instant_exec_on_suspect_history_change, base_url as $i7OB2$base_url, get_depict_id as $i7OB2$get_depict_id, get_user_id as $i7OB2$get_user_id, get_session_id as $i7OB2$get_session_id, sort_obj as $i7OB2$sort_obj, fetch_retry as $i7OB2$fetch_retry, add_version_query_params as $i7OB2$add_version_query_params, make_url_with_query_params as $i7OB2$make_url_with_query_params, edit_current_page_meta_tags as $i7OB2$edit_current_page_meta_tags, javascript_media_query as $i7OB2$javascript_media_query, use_href_accessor as $i7OB2$use_href_accessor, make_asyncIterable_exiter as $i7OB2$make_asyncIterable_exiter, href_change_ipns as $i7OB2$href_change_ipns, ContainedImage as $i7OB2$ContainedImage, deparallelize_no_drop as $i7OB2$deparallelize_no_drop, ListenableSet as $i7OB2$ListenableSet, insert_surfaces as $i7OB2$insert_surfaces } from "@depict-ai/utilishared/latest";
2
2
  import { createComponent as $i7OB2$createComponent, insert as $i7OB2$insert, ssr as $i7OB2$ssr, ssrHydrationKey as $i7OB2$ssrHydrationKey, ssrStyle as $i7OB2$ssrStyle, spread as $i7OB2$spread, escape as $i7OB2$escape, ssrAttribute as $i7OB2$ssrAttribute, mergeProps as $i7OB2$mergeProps1, isServer as $i7OB2$isServer, ssrElement as $i7OB2$ssrElement, ssrClassList as $i7OB2$ssrClassList, Dynamic as $i7OB2$Dynamic } from "solid-js/web";
3
- import { createSignal as $i7OB2$createSignal, getOwner as $i7OB2$getOwner, createEffect as $i7OB2$createEffect, runWithOwner as $i7OB2$runWithOwner, onCleanup as $i7OB2$onCleanup, createMemo as $i7OB2$createMemo, createContext as $i7OB2$createContext, useContext as $i7OB2$useContext, mergeProps as $i7OB2$mergeProps, Show as $i7OB2$Show, createResource as $i7OB2$createResource, Suspense as $i7OB2$Suspense, untrack as $i7OB2$untrack, createRenderEffect as $i7OB2$createRenderEffect, Index as $i7OB2$Index, createRoot as $i7OB2$createRoot, For as $i7OB2$For, createUniqueId as $i7OB2$createUniqueId, createComputed as $i7OB2$createComputed, ErrorBoundary as $i7OB2$ErrorBoundary, on as $i7OB2$on, batch as $i7OB2$batch, createReaction as $i7OB2$createReaction, mapArray as $i7OB2$mapArray } from "solid-js";
3
+ import { createSignal as $i7OB2$createSignal, getOwner as $i7OB2$getOwner, createEffect as $i7OB2$createEffect, runWithOwner as $i7OB2$runWithOwner, onCleanup as $i7OB2$onCleanup, createMemo as $i7OB2$createMemo, createContext as $i7OB2$createContext, useContext as $i7OB2$useContext, mergeProps as $i7OB2$mergeProps, Show as $i7OB2$Show, createResource as $i7OB2$createResource, Suspense as $i7OB2$Suspense, untrack as $i7OB2$untrack, createRenderEffect as $i7OB2$createRenderEffect, Index as $i7OB2$Index, createRoot as $i7OB2$createRoot, For as $i7OB2$For, createUniqueId as $i7OB2$createUniqueId, createComputed as $i7OB2$createComputed, ErrorBoundary as $i7OB2$ErrorBoundary, batch as $i7OB2$batch, on as $i7OB2$on, createReaction as $i7OB2$createReaction, mapArray as $i7OB2$mapArray } from "solid-js";
4
4
  import { createStore as $i7OB2$createStore, reconcile as $i7OB2$reconcile } from "solid-js/store";
5
5
 
6
6
  /*! Depict.ai search and product listing SDK */
7
7
  import { register_es_version } from "../../multi_import_deduplicator.mjs";
8
8
  register_es_version("ui", "latest");
9
- const $ec291e0010116877$export$83d89fbfd8236492 = "2.1.11";
9
+ const $ec291e0010116877$export$83d89fbfd8236492 = "2.1.13";
10
10
  const $4147651646da990a$var$fallback_operator = "in";
11
11
  const $4147651646da990a$var$fallback_token = "";
12
12
  const $4147651646da990a$var$legacy_filter_prefix = "filter_";
@@ -422,24 +422,30 @@ function $f32e14878e75af51$export$6649caad96ef8870({
422
422
 
423
423
  /** @jsxImportSource solid-js */
424
424
 
425
- function $0fdb37d8ddabef25$export$9f191182275e9ef(what_to_watch) {
426
- const [size, setSize] = $i7OB2$createSignal();
425
+ function $2449872a62a75a20$export$ebdc3711f7e02ccd(what_to_watch) {
426
+ const [width, setWidth] = $i7OB2$createSignal();
427
427
  const resizeObserver = new ResizeObserver($i7OB2$catchify(records => {
428
428
  for (let j = 0; j < records.length; j++) {
429
429
  const width = records[j].borderBoxSize?.[0]?.inlineSize ?? what_to_watch.getBoundingClientRect().width;
430
- setSize(width);
430
+ setWidth(width);
431
431
  }
432
432
  }));
433
433
  // If we start observing elements before they're in the DOM Chrome (Version 117.0.5938.92 (Official Build) (arm64)) sometimes gives us a resize event with a width of 0 and then doesn't dispatch one with the actual width once it's in the DOM. So we wait until the element is in the DOM before we start observing it.
434
434
  // It doesn't seem to work even when waiting for it to be in the DOM, also wait an animation frame
435
435
  const disconnect = (0, $i7OB2$observer).onexists(what_to_watch, ({
436
436
  element: element
437
- }) => requestAnimationFrame($i7OB2$catchify(() => resizeObserver.observe(element))));
437
+ }) => requestAnimationFrame($i7OB2$catchify(() => {
438
+ const current_size = what_to_watch.getBoundingClientRect().width;
439
+ if (current_size)
440
+ // If element has size, set signal to that. ResizeObserver only triggers when the content is visible in some cases, but it might already have a size. This reduces size filter expanding animation jank in chrome.
441
+ setWidth(current_size);
442
+ resizeObserver.observe(element);
443
+ })));
438
444
  $i7OB2$onCleanup(() => {
439
445
  resizeObserver.disconnect();
440
446
  disconnect();
441
447
  });
442
- return size;
448
+ return width;
443
449
  }
444
450
  const $b5cccc8ee7d24677$var$transform_elements = sorted_cols_at_size => {
445
451
  const cols_at_size = [];
@@ -722,7 +728,7 @@ class $4fd48cb976bf1789$export$aa14a9f43128f61f extends $4fd48cb976bf1789$export
722
728
  });
723
729
  }
724
730
  }
725
- const $b7436a6d1fd64e3b$var$_tmpl$ = ["<div", ' class="', '">', "</div>"];
731
+ const $b7436a6d1fd64e3b$var$_tmpl$ = ["<div", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></div>"];
726
732
  function $b7436a6d1fd64e3b$export$b69d0d92862de18b(props) {
727
733
  return $i7OB2$ErrorBoundary({
728
734
  fallback(err, retry) {
@@ -735,8 +741,7 @@ function $b7436a6d1fd64e3b$export$b69d0d92862de18b(props) {
735
741
  console.error(err.cause);
736
742
  message = `${message}: ${err.message}`;
737
743
  } else $i7OB2$report([err, message_], severity_);
738
- props.on_error_?.(retry);
739
- return $i7OB2$ssr($b7436a6d1fd64e3b$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$ssrClassList(Object.fromEntries(props.class_list_?.map(c => [c, true]) || [])), $i7OB2$escape(message));
744
+ return $i7OB2$ssr($b7436a6d1fd64e3b$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$ssrClassList(Object.fromEntries(props.class_list_?.map(c => [c, true]) || [])), $i7OB2$escape(message), $i7OB2$escape(props.on_error_?.(retry)));
740
745
  },
741
746
  get children() {
742
747
  return props.children;
@@ -1197,12 +1202,12 @@ function $8c0f86cb3e266eeb$export$a71e92cfbb498adc(props) {
1197
1202
  }
1198
1203
  const $19976a74d273070d$var$_tmpl$ = '<path d="M11.669 10.531l9.156-9.156a.78.78 0 0 0 .237-.569c0-.221-.079-.412-.237-.569A.8.8 0 0 0 20.24 0a.77.77 0 0 0-.569.237l-9.14 9.14-9.14-9.14A.79.79 0 0 0 .807 0a.77.77 0 0 0-.569.237A.78.78 0 0 0 0 .807a.77.77 0 0 0 .237.569l9.156 9.156-9.156 9.14c-.159.157-.237.349-.237.569s.079.412.237.569c.085.085.174.148.268.19a1.095 1.095 0 0 0 .316.048.894.894 0 0 0 .285-.048.84.84 0 0 0 .285-.19l9.139-9.14 9.14 9.14a.894.894 0 0 0 .268.19 1.049 1.049 0 0 0 .301.048.941.941 0 0 0 .301-.048.84.84 0 0 0 .285-.19.78.78 0 0 0 .237-.569c0-.221-.079-.412-.237-.569z"></path>';
1199
1204
  function $19976a74d273070d$export$3b621d86b1566b2(props = {}) {
1200
- return $i7OB2$ssrElement("svg", $i7OB2$mergeProps1(props, {
1205
+ return $i7OB2$ssrElement("svg", $i7OB2$mergeProps1({
1201
1206
  xmlns: "http://www.w3.org/2000/svg",
1202
1207
  width: "21.064",
1203
1208
  height: "21.047",
1204
1209
  viewBox: "0 0 21.064 21.064"
1205
- }), () => $i7OB2$ssr($19976a74d273070d$var$_tmpl$), true);
1210
+ }, props), () => $i7OB2$ssr($19976a74d273070d$var$_tmpl$), true);
1206
1211
  }
1207
1212
 
1208
1213
  /**
@@ -1416,7 +1421,7 @@ function $1adfe60f3a14a1d7$export$fecbb157621501bd({
1416
1421
  const $49b79728e7d9e2a1$var$_tmpl$ = ["<span", ' class="count">', "</span>"],
1417
1422
  $49b79728e7d9e2a1$var$_tmpl$2 = ["<label", ' class="', '"', '><div class="left"><input type="checkbox"', "", "", '><span class="custom-indicator"></span><span class="text line-clamp">', "</span></div><!--$-->", "<!--/--></label>"];
1418
1423
  const $49b79728e7d9e2a1$export$48513f6b9f8ce62d = props => {
1419
- // 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
1424
+ /* don't destructure props, it could have reactive getters */ // 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
1420
1425
  const count = $i7OB2$createMemo(() => props.count_);
1421
1426
  const label = $i7OB2$createMemo(() => props.label_);
1422
1427
  const checked = $i7OB2$createMemo(() => props.checked_);
@@ -1448,6 +1453,59 @@ function $67b173f9db427028$export$ca21a16d65b3dd8({
1448
1453
  }) {
1449
1454
  return $i7OB2$ssr($67b173f9db427028$var$_tmpl$, $i7OB2$ssrHydrationKey(), `expand-filter ${get_show_extras() ? "expanded" : ""}`, $i7OB2$escape($i7OB2$createComponent((0, $f8a56ba74eedd0c6$export$f21ab0717a89c77f), {})), get_show_extras() ? $i7OB2$escape(i18n_.view_less_()) : $i7OB2$escape(i18n_.view_more_()));
1450
1455
  }
1456
+ const $f3213c0640246d58$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"],
1457
+ $f3213c0640246d58$var$_tmpl$2 = ["<span", ' class="', '"', ">", "</span>"];
1458
+ function $f3213c0640246d58$export$ba17c5b7e6dda39f({
1459
+ whole_text_to_display_: whole_text_to_display_memo,
1460
+ searching_for_value_: searching_for_value_memo,
1461
+ class_: class_
1462
+ }) {
1463
+ const [get_has_highlighted, set_has_highlighted] = $i7OB2$createSignal(false);
1464
+ const text_itself = $i7OB2$createMemo(() => $i7OB2$batch(() => {
1465
+ set_has_highlighted(false);
1466
+ const searching_for_value = searching_for_value_memo();
1467
+ const whole_text_to_display_ = whole_text_to_display_memo();
1468
+ let for_black = "";
1469
+ let pushed_grey = false;
1470
+ const search_q = searching_for_value;
1471
+ if (!search_q) return whole_text_to_display_;
1472
+ const output = [];
1473
+ const searching_for = search_q.toLowerCase();
1474
+ const push_black = () => {
1475
+ if (for_black) {
1476
+ set_has_highlighted(true);
1477
+ output.push($i7OB2$ssr($f3213c0640246d58$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape(for_black))); // "black"
1478
+ for_black = "";
1479
+ }
1480
+ };
1481
+ for (let i = 0; i < whole_text_to_display_.length;) {
1482
+ let is_whole_word = true;
1483
+ let searching_for_but_with_texts_casing = "";
1484
+ const i_at_start = i;
1485
+ for (let j = 0; j < searching_for.length; i++, j++) {
1486
+ const letter_in_suggestion = whole_text_to_display_[i];
1487
+ if (letter_in_suggestion?.toLowerCase() !== searching_for[j]) {
1488
+ is_whole_word = false;
1489
+ i = i_at_start;
1490
+ break;
1491
+ }
1492
+ searching_for_but_with_texts_casing += letter_in_suggestion;
1493
+ }
1494
+ if (is_whole_word) {
1495
+ push_black();
1496
+ output.push(searching_for_but_with_texts_casing);
1497
+ pushed_grey = true;
1498
+ } else for_black += whole_text_to_display_[i++];
1499
+ }
1500
+ push_black();
1501
+ if (!pushed_grey) {
1502
+ set_has_highlighted(false);
1503
+ return whole_text_to_display_;
1504
+ }
1505
+ return output;
1506
+ }));
1507
+ return $i7OB2$ssr($f3213c0640246d58$var$_tmpl$2, $i7OB2$ssrHydrationKey(), `${$i7OB2$escape(class_, true) || ""} ${get_has_highlighted() ? "has-match" : ""}`, $i7OB2$ssrAttribute("title", $i7OB2$escape(whole_text_to_display_memo(), true), false), $i7OB2$escape(text_itself()));
1508
+ }
1451
1509
  const $a4601e6bea3ed1e6$var$_tmpl$ = ["<form", ' class="checkboxes"><!--$-->', "<!--/--><!--$-->", "<!--/--></form>"];
1452
1510
  const $a4601e6bea3ed1e6$var$max_visible_without_collapsing = 15;
1453
1511
  const $a4601e6bea3ed1e6$var$show_non_collapsible_when_collapsed = 4;
@@ -1455,7 +1513,8 @@ function $a4601e6bea3ed1e6$export$dd948f91abc3a1c4({
1455
1513
  filter_: filter_,
1456
1514
  selected_filters_: [get_selected_filters, set_selected_filters],
1457
1515
  i18n_: i18n_,
1458
- view_more_button_below_group_: [, set_view_more_button_below_group_]
1516
+ view_more_button_below_group_: [, set_view_more_button_below_group_],
1517
+ filter_query_: filter_query_
1459
1518
  }) {
1460
1519
  const existing_filter = $i7OB2$createMemo(() => {
1461
1520
  const {
@@ -1483,12 +1542,18 @@ function $a4601e6bea3ed1e6$export$dd948f91abc3a1c4({
1483
1542
  const value = $91aa8ee9f431800d$export$325f75597868c4f0(checkbox().value_);
1484
1543
  return !!data?.some(item => $91aa8ee9f431800d$export$325f75597868c4f0(item) === value);
1485
1544
  });
1545
+ const value = $i7OB2$createMemo(() => checkbox().value_);
1486
1546
  return $i7OB2$createComponent((0, $49b79728e7d9e2a1$export$48513f6b9f8ce62d), {
1487
1547
  get value_() {
1488
- return checkbox().value_;
1548
+ return value();
1489
1549
  },
1490
1550
  get label_() {
1491
- return checkbox().name_;
1551
+ return $i7OB2$createComponent((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
1552
+ get whole_text_to_display_() {
1553
+ return $i7OB2$createMemo(() => checkbox().name_ || value());
1554
+ },
1555
+ searching_for_value_: () => filter_query_?.()
1556
+ });
1492
1557
  },
1493
1558
  get count_() {
1494
1559
  return checkbox().count_;
@@ -1550,7 +1615,8 @@ const $eb8d9bf3b5700c26$var$_tmpl$ = ["<form", ' class="radios">', "</form>"],
1550
1615
  $eb8d9bf3b5700c26$var$_tmpl$3 = ["<label", ' class="', '"', '><div class="left"><input type="radio"', "", '><span class="custom-indicator"></span><!--$-->', "<!--/--></div><!--$-->", "<!--/--></label>"];
1551
1616
  function $eb8d9bf3b5700c26$export$430444115f70a734({
1552
1617
  selected_filters_: selected_filters_,
1553
- filter_: filter_
1618
+ filter_: filter_,
1619
+ filter_query_: filter_query_
1554
1620
  }) {
1555
1621
  const radio_name = $i7OB2$make_random_classname();
1556
1622
  const existing_filter = $i7OB2$createMemo(() => {
@@ -1570,17 +1636,21 @@ function $eb8d9bf3b5700c26$export$430444115f70a734({
1570
1636
  children: (value, index) => {
1571
1637
  const random_selector = $i7OB2$make_random_classname();
1572
1638
  const count = $i7OB2$createMemo(() => filter_().meta.counts?.[index]);
1639
+ const label = $i7OB2$createMemo(() => {
1640
+ const name = filter_().meta?.names?.[index];
1641
+ if (name) return name;
1642
+ const v = value();
1643
+ return Array.isArray(v) ? v.join(" - ") : v + "";
1644
+ });
1573
1645
  return $i7OB2$ssr($eb8d9bf3b5700c26$var$_tmpl$3, $i7OB2$ssrHydrationKey(), `input-row ${count() === 0 ? "count-0" : ""}`, $i7OB2$ssrAttribute("for", $i7OB2$escape(random_selector, true), false), $i7OB2$ssrAttribute("id", $i7OB2$escape(random_selector, true), false) + $i7OB2$ssrAttribute("name", $i7OB2$escape(radio_name, true), false), $i7OB2$ssrAttribute("checked", $i7OB2$createMemo(() => {
1574
1646
  const v = value();
1575
1647
  const data = existing_filter()?.data;
1576
1648
  if ($91aa8ee9f431800d$export$325f75597868c4f0(data) === $91aa8ee9f431800d$export$325f75597868c4f0(v)) return true;
1577
1649
  return Array.isArray(data) && data.every((item, index) => item === v[index]);
1578
- })(), true), $i7OB2$escape($i7OB2$createMemo(() => {
1579
- const name = filter_().meta?.names?.[index];
1580
- if (name) return name;
1581
- const v = value();
1582
- return Array.isArray(v) ? v.join(" - ") : v;
1583
- })()), $i7OB2$escape($i7OB2$createComponent((0, $i7OB2$Show), {
1650
+ })(), true), $i7OB2$escape($i7OB2$createComponent((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
1651
+ whole_text_to_display_: label,
1652
+ searching_for_value_: () => filter_query_?.()
1653
+ })), $i7OB2$escape($i7OB2$createComponent((0, $i7OB2$Show), {
1584
1654
  get when() {
1585
1655
  return count() != undefined;
1586
1656
  },
@@ -1597,7 +1667,8 @@ const $a6b08770e164eced$var$_tmpl$ = ["<div", ' class="', '"><div class="input-g
1597
1667
  function $a6b08770e164eced$export$e0d834a0ad870cda({
1598
1668
  filter_: filter_,
1599
1669
  selected_filters_: selected_filters_,
1600
- i18n_: i18n_
1670
+ i18n_: i18n_,
1671
+ filter_query_: filter_query_
1601
1672
  }) {
1602
1673
  // If you ever attempt to implement that one can drag one range "knob" over the other like on prisjakt, see https://gitlab.com/depict-ai/depict.ai/-/merge_requests/8458/diffs?commit_id=c52dbdd15ca073489bee138b15d27bb6bf2992df
1603
1674
  // The issue with it is that one wants to discard the changes to the lower value as soon as the lower value has become the upper value when dragging the initially lower knob over the initially upper knob
@@ -1816,168 +1887,428 @@ function $0b6bc2f8309efa8a$export$e5c2828934226505({
1816
1887
  });
1817
1888
  return outer_div;
1818
1889
  }
1819
- const $1c8cac76cb67e9af$var$_tmpl$ = ["<form", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></form>"],
1820
- $1c8cac76cb67e9af$var$_tmpl$2 = ["<div", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></div>"],
1821
- $1c8cac76cb67e9af$var$_tmpl$3 = ["<details", "></details>"],
1822
- $1c8cac76cb67e9af$var$_tmpl$4 = ["<summary", ' class="category-parent"><div class="summary"><span class="', '">', "</span><!--$-->", "<!--/--></div></summary>"];
1823
- const $1c8cac76cb67e9af$var$max_visible_without_collapsing = 15;
1824
- const $1c8cac76cb67e9af$var$show_non_collapsible_when_collapsed = 4;
1825
- function $1c8cac76cb67e9af$export$a32086fa6616eafd({
1826
- filter_: filter_,
1827
- selected_filters_: selected_filters_,
1828
- i18n_: i18n_,
1829
- view_more_button_below_group_: view_more_button_below_group_,
1830
- expanded_hierarchical_filters_: expanded_hierarchical_filters_
1890
+ const $522a690e0e2bd46d$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"];
1891
+ const $522a690e0e2bd46d$var$dont_cut_in_between_less_than_characters = 30;
1892
+ function $522a690e0e2bd46d$export$e1a98a189fd2c0e7({
1893
+ content_result_: content_result_,
1894
+ key_: key_,
1895
+ cut_when_possible_: cut_when_possible_
1831
1896
  }) {
1832
- let form;
1833
- const existing_filter = $i7OB2$createMemo(() => {
1834
- const {
1835
- field: field,
1836
- op: op
1837
- } = filter_();
1838
- return selected_filters_[0]().find(({
1839
- field: checking_field,
1840
- op: checking_op
1841
- }) => checking_field === field && checking_op === op);
1842
- });
1843
- const show_extras = $i7OB2$createSignal(false);
1844
- const trigger_sync_ = $1c8cac76cb67e9af$var$batching_filter_state_syncer({
1845
- filter_: filter_,
1846
- existing_filter_: existing_filter,
1847
- selected_filters_: selected_filters_,
1848
- get category_structure_() {
1849
- return structured_categories();
1850
- }
1851
- });
1852
- const structured_categories = $i7OB2$createMemo(() => {
1853
- const execute_when_structure_finished = [];
1854
- const {
1855
- values: values,
1856
- names: names,
1857
- counts: counts
1858
- } = filter_().meta;
1859
- const data_structure = {};
1860
- for (let i = 0; i < values.length; i++) {
1861
- const value = values[i];
1862
- let pointer = data_structure;
1863
- let parent_ = {};
1864
- let created_an_object = false;
1865
- for (let j = 0; j < value.length; j++) {
1866
- const this_categories_name = value[j];
1867
- const obj = pointer[this_categories_name] ||= (() => {
1868
- const value_as_string = value.map(v => typeof v === "number" ? v + "" : v); // don't think backend will ever send numbers but technically it's allowed;
1869
- const created_obj = {
1870
- name_: names[i],
1871
- count_: counts?.[i],
1872
- parent_: parent_,
1873
- is_expanded_: $1c8cac76cb67e9af$var$make_expanded_signal({
1874
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
1875
- filter_value_: value_as_string
1876
- }),
1877
- value_: value_as_string,
1878
- children_: {}
1879
- };
1880
- const {
1881
- signal_: signal_,
1882
- on_structure_complete_: on_structure_complete_
1883
- } = $1c8cac76cb67e9af$var$create_updating_signal({
1884
- self_: created_obj,
1885
- existing_filter_: $i7OB2$untrack(existing_filter),
1886
- trigger_sync_: trigger_sync_
1887
- });
1888
- execute_when_structure_finished.push(on_structure_complete_);
1889
- created_obj.is_checked_ = signal_;
1890
- parent_ = created_obj;
1891
- created_an_object = true;
1892
- return created_obj;
1893
- })();
1894
- pointer = obj.children_;
1895
- parent_ = obj;
1896
- }
1897
- if (!created_an_object && "value_" in parent_) {
1898
- // if an object was created for our "depth" in the hierarchy but not for our specific entry this means that the entry array was unsorted and looked something like
1899
- // [
1900
- // ["Öl", "IPA"],
1901
- // ["Öl", "Pale Ale"],
1902
- // ["Öl", "Ale"],
1903
- // ["Öl", "Mörk Lager"],
1904
- // ["Öl", "Suröl"],
1905
- // ["Öl", "Veteöl"],
1906
- // ["Öl", "Stout och Porter"],
1907
- // ["Öl"], // <- We are here, our `hierarchical_data_structure[string]`-object was created when we iterated over ["Öl", "IPA"]
1908
- // ["Öl", "Ljus Lager"],
1909
- // ];
1910
- // In this case we want to just correct the name and value of the already created object, which will be in parent_
1911
- parent_.value_ = value.map(v => v + "");
1912
- parent_.name_ = names[i];
1913
- parent_.count_ = counts[i];
1914
- parent_.is_expanded_ = $1c8cac76cb67e9af$var$make_expanded_signal({
1915
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
1916
- filter_value_: parent_.value_
1917
- });
1918
- }
1919
- }
1920
- while (execute_when_structure_finished.length) execute_when_structure_finished.pop()();
1921
- $1c8cac76cb67e9af$var$expand_until_choice(data_structure);
1922
- $i7OB2$dlog("CheckboxHierarchicalFilter: Recomputed structured_categories", data_structure);
1923
- return data_structure;
1924
- });
1925
- const some_top_level_are_hidden = $i7OB2$createMemo(() => Object.keys(structured_categories()).length > $1c8cac76cb67e9af$var$max_visible_without_collapsing);
1926
- const {
1927
- expand: expand,
1928
- collapse: collapse,
1929
- ExpandingContainer: ExpandingContainer
1930
- } = $24e27fab9c821b86$export$5bad61ecde080b1f({
1931
- duration: 200
1932
- });
1933
- const expanding_container_els = $i7OB2$createComponent(ExpandingContainer, {
1897
+ const matched_tokens = $i7OB2$createMemo(() => content_result_().highlights?.find(highlight => highlight.field == key_)?.matched_tokens);
1898
+ const full_value = $i7OB2$createMemo(() => content_result_()[key_]?.replaceAll("\n", " "));
1899
+ return $i7OB2$createComponent((0, $i7OB2$Show), {
1900
+ get when() {
1901
+ return matched_tokens()?.length;
1902
+ },
1903
+ get fallback() {
1904
+ return full_value();
1905
+ },
1934
1906
  get children() {
1935
- return $i7OB2$createComponent((0, $i7OB2$Show), {
1936
- get when() {
1937
- return some_top_level_are_hidden();
1938
- },
1939
- get children() {
1940
- return $1c8cac76cb67e9af$var$render_stuff($i7OB2$createMemo(() => Object.fromEntries(Object.entries(structured_categories()).slice($1c8cac76cb67e9af$var$show_non_collapsible_when_collapsed))), existing_filter, i18n_);
1941
- }
1942
- });
1907
+ return (() => {
1908
+ const segmented_cut_text = $i7OB2$createMemo(() => {
1909
+ const segmented_text = $522a690e0e2bd46d$export$1b00d74faf266c56(full_value(), matched_tokens());
1910
+ if (cut_when_possible_) $522a690e0e2bd46d$var$cut_text(segmented_text);
1911
+ return segmented_text;
1912
+ });
1913
+ return $i7OB2$createComponent((0, $i7OB2$Index), {
1914
+ get each() {
1915
+ return segmented_cut_text();
1916
+ },
1917
+ children: item => {
1918
+ return $i7OB2$createComponent((0, $i7OB2$Show), {
1919
+ get when() {
1920
+ return item().highlighted_;
1921
+ },
1922
+ get fallback() {
1923
+ return item().text_;
1924
+ },
1925
+ get children() {
1926
+ return $i7OB2$ssr($522a690e0e2bd46d$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape(item().text_));
1927
+ }
1928
+ });
1929
+ }
1930
+ });
1931
+ })();
1943
1932
  }
1944
1933
  });
1945
- $i7OB2$createRenderEffect(() => {
1946
- view_more_button_below_group_[1](some_top_level_are_hidden() ? $i7OB2$createComponent((0, $67b173f9db427028$export$ca21a16d65b3dd8), {
1947
- show_extras_: show_extras,
1948
- i18n_: i18n_
1949
- }) : []);
1950
- });
1951
- $i7OB2$createEffect($i7OB2$catchify(async () => {
1952
- if (!some_top_level_are_hidden()) {
1953
- await collapse();
1954
- return;
1955
- }
1956
- if (show_extras[0]()) await expand();else await collapse();
1957
- }));
1958
- return $i7OB2$ssr($1c8cac76cb67e9af$var$_tmpl$, $i7OB2$ssrHydrationKey(), `checkboxes hierarchical ${Object.values(structured_categories()).some(category => Object.keys(category.children_).length) ? "any-expandable" : ""}`, $i7OB2$escape($1c8cac76cb67e9af$var$render_stuff($i7OB2$createMemo(() => some_top_level_are_hidden() ? Object.fromEntries(Object.entries(structured_categories()).slice(0, $1c8cac76cb67e9af$var$show_non_collapsible_when_collapsed)) : structured_categories()), existing_filter, i18n_)), $i7OB2$escape(expanding_container_els));
1959
1934
  }
1960
- function $1c8cac76cb67e9af$var$render_stuff(data, existing_filter, i18n_) {
1961
- const keys = $i7OB2$createMemo(() => Object.keys(data()));
1962
- return $i7OB2$createComponent((0, $i7OB2$For), {
1963
- get each() {
1964
- return keys();
1965
- },
1966
- children: key => $i7OB2$createComponent((0, $i7OB2$Show), {
1967
- get when() {
1968
- return $i7OB2$createMemo(() => !!data()[key])();
1969
- },
1970
- get children() {
1971
- return (() => {
1972
- // for some reason the for thing doesn't dispose of us if the key no longer exists?? so I'm doing it with show instead
1973
- const value = $i7OB2$createMemo(() => data()[key]); // still sometimes get undefined here even though we have <Show>
1974
- const has_expandable = $i7OB2$createMemo(() => !!Object.keys(value()?.children_ || {}).length);
1975
- return $i7OB2$ssr($1c8cac76cb67e9af$var$_tmpl$2, $i7OB2$ssrHydrationKey(), `checkbox-details ${has_expandable() ? "expandable" : ""}`, $i7OB2$escape($i7OB2$createComponent((0, $49b79728e7d9e2a1$export$48513f6b9f8ce62d), {
1935
+ function $522a690e0e2bd46d$var$cut_text(segmented_text) {
1936
+ // cut away chunks of text that are not highlighted to give a google-like overview of the content
1937
+ const highlighted_segments = segmented_text?.filter(segment => segment.highlighted_);
1938
+ if (!segmented_text || !highlighted_segments?.length) return;
1939
+ // We have one or more highlighted segments
1940
+ if (highlighted_segments.length === 1) {
1941
+ // cut away from the left until the start of the highlighted sentence if just one sentence is highlighted
1942
+ $522a690e0e2bd46d$var$cut_start(segmented_text.indexOf(highlighted_segments[0]), segmented_text);
1943
+ return;
1944
+ }
1945
+ // We have two or more highlighted segments, take the two biggest chunks and show them + a bit text around
1946
+ 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
1947
+ );
1948
+
1949
+ const [longest_segment, next_longest_segment] = sorted_highlighted_segments;
1950
+ // We need to cut before the first segment - possibly through other segments - and maybe between segments
1951
+ 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);
1952
+ $522a690e0e2bd46d$var$cut_start(index_of_first_segment, segmented_text);
1953
+ // update indexes since we might have removed segments
1954
+ [index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
1955
+ let number_of_characters_between_segments = 0;
1956
+ for (let i = index_of_first_segment + 1; i < index_of_second_segment; i++) {
1957
+ const segment = segmented_text[i];
1958
+ number_of_characters_between_segments += segment.text_.length;
1959
+ }
1960
+ if (number_of_characters_between_segments < $522a690e0e2bd46d$var$dont_cut_in_between_less_than_characters)
1961
+ // don't cut if there are less than 30 characters between the two segments
1962
+ return;
1963
+ // We have more than 50 characters between the two segments, cut between them
1964
+ const [split_start_segment, split_start_character] = $522a690e0e2bd46d$var$find_split_point(index_of_first_segment, index_of_second_segment, segmented_text);
1965
+ const [split_end_segment, split_end_character] = $522a690e0e2bd46d$var$find_split_point(index_of_second_segment, index_of_first_segment, segmented_text);
1966
+ if (split_start_segment === undefined || split_end_segment === undefined ||
1967
+ // identical split point, or split end before split start, can't do anything
1968
+ split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
1969
+ const dots_segment = {
1970
+ text_: " … ",
1971
+ highlighted_: false
1972
+ };
1973
+ const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
1974
+ if (i < split_start_segment || i > split_end_segment) return segment;
1975
+ const text = segment.text_;
1976
+ if (i == split_end_segment && i == split_start_segment) return [{
1977
+ ...segment,
1978
+ text_: text.slice(0, split_start_character).trimEnd()
1979
+ }, dots_segment, {
1980
+ ...segment,
1981
+ text_: text.slice(split_end_character + 1, text.length).trimStart()
1982
+ }];else if (i == split_start_segment) {
1983
+ 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
1984
+ return segment;
1985
+ } else if (i == split_end_segment) return [dots_segment, {
1986
+ ...segment,
1987
+ text_: text.slice(split_end_character + 1, text.length).trimStart()
1988
+ }];
1989
+ return []; // remove all segments inbetween
1990
+ });
1991
+
1992
+ segmented_text.splice(0, segmented_text.length, ...split_and_dotted_values); // Sorry…
1993
+ $522a690e0e2bd46d$var$heal_holes(segmented_text);
1994
+ }
1995
+ function $522a690e0e2bd46d$var$heal_holes(segmented_text) {
1996
+ // try to heal "holes" created in the segments so there are only alternating segments
1997
+ const segments_to_delete = new Set();
1998
+ for (let i = 0; i < segmented_text.length; i++) {
1999
+ const segment = segmented_text[i];
2000
+ let previous_segment;
2001
+ for (let j = i - 1; j >= 0; j--) {
2002
+ previous_segment = segmented_text[j];
2003
+ // Don't write to a segment that's marked for deletion or the contents we write to it will be deleted
2004
+ if (!segments_to_delete.has(previous_segment)) break;
2005
+ }
2006
+ if (previous_segment?.highlighted_ && segment.highlighted_ || previous_segment?.highlighted_ === false && segment.highlighted_ === false) {
2007
+ previous_segment.text_ += segment.text_; // IDK if this ever happens
2008
+ segments_to_delete.add(segment);
2009
+ }
2010
+ }
2011
+ for (const segment of segments_to_delete) {
2012
+ const index = segmented_text.indexOf(segment);
2013
+ segmented_text.splice(index, 1);
2014
+ }
2015
+ }
2016
+ function $522a690e0e2bd46d$var$find_split_point(index_of_start_segment, index_of_end_segment, segmented_text, be_very_aggressive = true) {
2017
+ const should_loop_backwards = index_of_start_segment > index_of_end_segment;
2018
+ const step = should_loop_backwards ? -1 : 1;
2019
+ const desperate_split_attempts = [":", ";", ","];
2020
+ while (desperate_split_attempts.length) {
2021
+ const split_point_between_words = [];
2022
+ // for the middle also try to split with a few more characters if the default ones don't work over a full run
2023
+ const desperate_split_attempt = desperate_split_attempts.pop();
2024
+ let is_first_character = true;
2025
+ for (let i = index_of_start_segment + step; should_loop_backwards ? i > index_of_end_segment : i < index_of_end_segment; i += step) {
2026
+ const segment = segmented_text[i];
2027
+ const text = segment.text_;
2028
+ for (let j = should_loop_backwards ? text.length - 1 : 0; should_loop_backwards ? j >= 0 : j < text.length; j += step) {
2029
+ const character = text[j];
2030
+ if (character == "." || character == "?" || character == "!" || character == desperate_split_attempt) return [i, j]; // segment index, character index
2031
+ if (is_first_character) is_first_character = false;else if (be_very_aggressive && character == " ") {
2032
+ split_point_between_words.push([i, j]);
2033
+ if (split_point_between_words.length > 3)
2034
+ // We can't find a split point, so we'll just split between words
2035
+ // 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
2036
+ return split_point_between_words[1];
2037
+ }
2038
+ }
2039
+ }
2040
+ }
2041
+ return [];
2042
+ }
2043
+ function $522a690e0e2bd46d$var$cut_start(cut_left_of_index, segmented_text) {
2044
+ // Cut the start of the text to bring the first matching token
2045
+ let is_first_character = false;
2046
+ let words_encountered = 0;
2047
+ outmost_loop: for (let i = cut_left_of_index - 1; i >= 0; i--) {
2048
+ const segment = segmented_text[i];
2049
+ // We assume that two adjacent highlighted segments don't exist and have been merged if they were to have existed
2050
+ const text = segment.text_;
2051
+ for (let j = text.length - 1; j >= 0; j--) {
2052
+ const character = text[j];
2053
+ const is_space = character == " ";
2054
+ if (!is_first_character && is_space) words_encountered++;
2055
+ if (character == "." || character == "?" || character == "!" || character == "," || words_encountered > 8 && is_space) {
2056
+ // We have to be really aggressive at the start of sentences so stuff can be seen on mobile, hence comma
2057
+ segment.text_ = text.slice(j + 1).trimStart();
2058
+ segmented_text.splice(0, i);
2059
+ if (character === "," || is_space)
2060
+ // if we cut at a comma or psace, we add a … at the beginning
2061
+ segmented_text.unshift({
2062
+ text_: "… ",
2063
+ highlighted_: false
2064
+ });
2065
+ break outmost_loop;
2066
+ }
2067
+ if (is_first_character) is_first_character = false;
2068
+ }
2069
+ }
2070
+ $522a690e0e2bd46d$var$heal_holes(segmented_text); // if we added a ... there could now be a sequence that's not alternating true/false
2071
+ }
2072
+
2073
+ function $522a690e0e2bd46d$export$1b00d74faf266c56(text, matched_strings, loose = false) {
2074
+ const output = [];
2075
+ if (!text) return; // shouldn't happen but whatever
2076
+ for (let i = 0; i < text.length; i++) {
2077
+ const found_strings = [];
2078
+ if (!i || text[i - 1] == " " || loose)
2079
+ // only match at the start of a word or string, it looks weird if i.e. "we" is highlighted in "activewear
2080
+ for (let j = 0; j < matched_strings.length; j++) {
2081
+ const matched_string = matched_strings[j];
2082
+ const part_in_text = text.slice(i, i + matched_string.length);
2083
+ if (matched_string.length < 2 && !loose) continue; // don't match on single characters, i.e. "I", it looks weird
2084
+ 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
2085
+ }
2086
+
2087
+ const last_index_in_output = output.length - 1;
2088
+ if (!found_strings.length) {
2089
+ const character = text[i];
2090
+ if (output[last_index_in_output]?.highlighted_ === false || output.length && /\s/.test(character))
2091
+ // 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
2092
+ output[last_index_in_output].text_ += character;else output.push({
2093
+ highlighted_: false,
2094
+ text_: character
2095
+ });
2096
+ } else {
2097
+ const longest_found_string = found_strings.reduce((a, b) => a.length > b.length ? a : b);
2098
+ if (output[last_index_in_output]?.highlighted_) output[last_index_in_output].text_ += longest_found_string;else output.push({
2099
+ highlighted_: true,
2100
+ text_: longest_found_string
2101
+ });
2102
+ i += longest_found_string.length - 1;
2103
+ }
2104
+ }
2105
+ return output;
2106
+ }
2107
+ const $3ec2b9489931358d$var$_tmpl$ = ["<span", ' class="', '">', "</span>"],
2108
+ $3ec2b9489931358d$var$_tmpl$2 = ["<span", ' class="highlighted-part">', "</span>"];
2109
+ function $3ec2b9489931358d$export$8e79c28529dbfa90(props) {
2110
+ const segmented_text = $i7OB2$createMemo(() => {
2111
+ const {
2112
+ to_highlight_: to_highlight_,
2113
+ text_: text_
2114
+ } = props;
2115
+ return $522a690e0e2bd46d$export$1b00d74faf266c56(text_, to_highlight_ ? [to_highlight_] : [], true);
2116
+ });
2117
+ const has_highlights = $i7OB2$createMemo(() => segmented_text().some(segment => segment.highlighted_));
2118
+ return $i7OB2$ssr($3ec2b9489931358d$var$_tmpl$, $i7OB2$ssrHydrationKey() + $i7OB2$ssrAttribute("title", $i7OB2$escape(props.text_, true), false), has_highlights() ? "has-match" : "", $i7OB2$escape($i7OB2$createComponent((0, $i7OB2$Index), {
2119
+ get each() {
2120
+ return segmented_text();
2121
+ },
2122
+ children: item => {
2123
+ return $i7OB2$createComponent((0, $i7OB2$Show), {
2124
+ get when() {
2125
+ return item().highlighted_;
2126
+ },
2127
+ get fallback() {
2128
+ return item().text_;
2129
+ },
2130
+ get children() {
2131
+ return $i7OB2$ssr($3ec2b9489931358d$var$_tmpl$2, $i7OB2$ssrHydrationKey(), $i7OB2$escape(item().text_));
2132
+ }
2133
+ });
2134
+ }
2135
+ })));
2136
+ }
2137
+ const $1c8cac76cb67e9af$var$_tmpl$ = ["<form", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></form>"],
2138
+ $1c8cac76cb67e9af$var$_tmpl$2 = ["<div", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></div>"],
2139
+ $1c8cac76cb67e9af$var$_tmpl$3 = ["<details", "></details>"],
2140
+ $1c8cac76cb67e9af$var$_tmpl$4 = ["<summary", ' class="category-parent"><div class="summary"><span class="', '">', "</span><!--$-->", "<!--/--></div></summary>"];
2141
+ const $1c8cac76cb67e9af$var$max_visible_without_collapsing = 15;
2142
+ const $1c8cac76cb67e9af$var$show_non_collapsible_when_collapsed = 4;
2143
+ function $1c8cac76cb67e9af$export$a32086fa6616eafd({
2144
+ filter_: filter_,
2145
+ selected_filters_: selected_filters_,
2146
+ i18n_: i18n_,
2147
+ view_more_button_below_group_: view_more_button_below_group_,
2148
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2149
+ filter_query_: filter_query_
2150
+ }) {
2151
+ let form;
2152
+ const existing_filter = $i7OB2$createMemo(() => {
2153
+ const {
2154
+ field: field,
2155
+ op: op
2156
+ } = filter_();
2157
+ return selected_filters_[0]().find(({
2158
+ field: checking_field,
2159
+ op: checking_op
2160
+ }) => checking_field === field && checking_op === op);
2161
+ });
2162
+ const show_extras = $i7OB2$createSignal(false);
2163
+ const is_being_searched_ = $i7OB2$createMemo(() => !!filter_query_?.()); // If the user is searching in the filter
2164
+ const trigger_sync_ = $1c8cac76cb67e9af$var$batching_filter_state_syncer({
2165
+ filter_: filter_,
2166
+ existing_filter_: existing_filter,
2167
+ selected_filters_: selected_filters_,
2168
+ get category_structure_() {
2169
+ return structured_categories();
2170
+ }
2171
+ });
2172
+ const structured_categories = $i7OB2$createMemo(() => {
2173
+ const execute_when_structure_finished = [];
2174
+ const {
2175
+ values: values,
2176
+ names: names,
2177
+ counts: counts
2178
+ } = filter_().meta;
2179
+ const data_structure = {};
2180
+ for (let i = 0; i < values.length; i++) {
2181
+ const value = values[i];
2182
+ let pointer = data_structure;
2183
+ let parent_ = {};
2184
+ let created_an_object = false;
2185
+ for (let j = 0; j < value.length; j++) {
2186
+ const this_categories_name = value[j];
2187
+ const obj = pointer[this_categories_name] ||= (() => {
2188
+ const value_as_string = value.map(v => typeof v === "number" ? v + "" : v); // don't think backend will ever send numbers but technically it's allowed;
2189
+ const created_obj = {
2190
+ name_: names[i],
2191
+ count_: counts?.[i],
2192
+ parent_: parent_,
2193
+ is_expanded_: $1c8cac76cb67e9af$var$make_expanded_signal({
2194
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2195
+ filter_value_: value_as_string,
2196
+ is_being_searched_: is_being_searched_
2197
+ }),
2198
+ value_: value_as_string,
2199
+ children_: {}
2200
+ };
2201
+ const {
2202
+ signal_: signal_,
2203
+ on_structure_complete_: on_structure_complete_
2204
+ } = $1c8cac76cb67e9af$var$create_updating_signal({
2205
+ self_: created_obj,
2206
+ existing_filter_: $i7OB2$untrack(existing_filter),
2207
+ trigger_sync_: trigger_sync_
2208
+ });
2209
+ execute_when_structure_finished.push(on_structure_complete_);
2210
+ created_obj.is_checked_ = signal_;
2211
+ parent_ = created_obj;
2212
+ created_an_object = true;
2213
+ return created_obj;
2214
+ })();
2215
+ pointer = obj.children_;
2216
+ parent_ = obj;
2217
+ }
2218
+ if (!created_an_object && "value_" in parent_) {
2219
+ // if an object was created for our "depth" in the hierarchy but not for our specific entry this means that the entry array was unsorted and looked something like
2220
+ // [
2221
+ // ["Öl", "IPA"],
2222
+ // ["Öl", "Pale Ale"],
2223
+ // ["Öl", "Ale"],
2224
+ // ["Öl", "Mörk Lager"],
2225
+ // ["Öl", "Suröl"],
2226
+ // ["Öl", "Veteöl"],
2227
+ // ["Öl", "Stout och Porter"],
2228
+ // ["Öl"], // <- We are here, our `hierarchical_data_structure[string]`-object was created when we iterated over ["Öl", "IPA"]
2229
+ // ["Öl", "Ljus Lager"],
2230
+ // ];
2231
+ // In this case we want to just correct the name and value of the already created object, which will be in parent_
2232
+ parent_.value_ = value.map(v => v + "");
2233
+ parent_.name_ = names[i];
2234
+ parent_.count_ = counts[i];
2235
+ parent_.is_expanded_ = $1c8cac76cb67e9af$var$make_expanded_signal({
2236
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2237
+ filter_value_: parent_.value_,
2238
+ is_being_searched_: is_being_searched_
2239
+ });
2240
+ }
2241
+ }
2242
+ while (execute_when_structure_finished.length) execute_when_structure_finished.pop()();
2243
+ $1c8cac76cb67e9af$var$expand_until_choice(data_structure);
2244
+ $i7OB2$dlog("CheckboxHierarchicalFilter: Recomputed structured_categories", data_structure);
2245
+ return data_structure;
2246
+ });
2247
+ const some_top_level_are_hidden = $i7OB2$createMemo(() => Object.keys(structured_categories()).length > $1c8cac76cb67e9af$var$max_visible_without_collapsing);
2248
+ const {
2249
+ expand: expand,
2250
+ collapse: collapse,
2251
+ ExpandingContainer: ExpandingContainer
2252
+ } = $24e27fab9c821b86$export$5bad61ecde080b1f({
2253
+ duration: 200
2254
+ });
2255
+ const expanding_container_els = $i7OB2$createComponent(ExpandingContainer, {
2256
+ get children() {
2257
+ return $i7OB2$createComponent((0, $i7OB2$Show), {
2258
+ get when() {
2259
+ return some_top_level_are_hidden();
2260
+ },
2261
+ get children() {
2262
+ return $1c8cac76cb67e9af$var$render_stuff($i7OB2$createMemo(() => Object.fromEntries(Object.entries(structured_categories()).slice($1c8cac76cb67e9af$var$show_non_collapsible_when_collapsed))), existing_filter, i18n_, filter_query_);
2263
+ }
2264
+ });
2265
+ }
2266
+ });
2267
+ $i7OB2$createRenderEffect(() => {
2268
+ view_more_button_below_group_[1](some_top_level_are_hidden() ? $i7OB2$createComponent((0, $67b173f9db427028$export$ca21a16d65b3dd8), {
2269
+ show_extras_: show_extras,
2270
+ i18n_: i18n_
2271
+ }) : []);
2272
+ });
2273
+ $i7OB2$createEffect($i7OB2$catchify(async () => {
2274
+ if (!some_top_level_are_hidden()) {
2275
+ await collapse();
2276
+ return;
2277
+ }
2278
+ if (show_extras[0]()) await expand();else await collapse();
2279
+ }));
2280
+ return $i7OB2$ssr($1c8cac76cb67e9af$var$_tmpl$, $i7OB2$ssrHydrationKey(), `checkboxes hierarchical ${Object.values(structured_categories()).some(category => Object.keys(category.children_).length) ? "any-expandable" : ""}`, $i7OB2$escape($1c8cac76cb67e9af$var$render_stuff($i7OB2$createMemo(() => some_top_level_are_hidden() ? Object.fromEntries(Object.entries(structured_categories()).slice(0, $1c8cac76cb67e9af$var$show_non_collapsible_when_collapsed)) : structured_categories()), existing_filter, i18n_, filter_query_)), $i7OB2$escape(expanding_container_els));
2281
+ }
2282
+ function $1c8cac76cb67e9af$var$render_stuff(data, existing_filter, i18n_, filter_query_) {
2283
+ const keys = $i7OB2$createMemo(() => Object.keys(data()));
2284
+ return $i7OB2$createComponent((0, $i7OB2$For), {
2285
+ get each() {
2286
+ return keys();
2287
+ },
2288
+ children: key => $i7OB2$createComponent((0, $i7OB2$Show), {
2289
+ get when() {
2290
+ return $i7OB2$createMemo(() => !!data()[key])();
2291
+ },
2292
+ get children() {
2293
+ return (() => {
2294
+ // for some reason the for thing doesn't dispose of us if the key no longer exists?? so I'm doing it with show instead
2295
+ const value = $i7OB2$createMemo(() => data()[key]); // still sometimes get undefined here even though we have <Show>
2296
+ const has_expandable = $i7OB2$createMemo(() => !!Object.keys(value()?.children_ || {}).length);
2297
+ const value_as_string = $i7OB2$createMemo(() => JSON.stringify(value()?.value_));
2298
+ const label_text = $i7OB2$createMemo(() => value()?.name_ || value_as_string());
2299
+ return $i7OB2$ssr($1c8cac76cb67e9af$var$_tmpl$2, $i7OB2$ssrHydrationKey(), `checkbox-details ${has_expandable() ? "expandable" : ""}`, $i7OB2$escape($i7OB2$createComponent((0, $49b79728e7d9e2a1$export$48513f6b9f8ce62d), {
1976
2300
  get value_() {
1977
- return JSON.stringify(value()?.value_);
2301
+ return value_as_string();
1978
2302
  },
1979
2303
  get label_() {
1980
- return value()?.name_;
2304
+ return $i7OB2$createComponent((0, $3ec2b9489931358d$export$8e79c28529dbfa90), {
2305
+ get text_() {
2306
+ return label_text();
2307
+ },
2308
+ get to_highlight_() {
2309
+ return filter_query_?.();
2310
+ }
2311
+ });
1981
2312
  },
1982
2313
  get count_() {
1983
2314
  return has_expandable() ? undefined : value()?.count_;
@@ -2046,7 +2377,7 @@ function $1c8cac76cb67e9af$var$render_stuff(data, existing_filter, i18n_) {
2046
2377
  return is_open();
2047
2378
  },
2048
2379
  get children() {
2049
- return $1c8cac76cb67e9af$var$render_stuff($i7OB2$createMemo(() => value()?.children_ || {}), existing_filter, i18n_);
2380
+ return $1c8cac76cb67e9af$var$render_stuff($i7OB2$createMemo(() => value()?.children_ || {}), existing_filter, i18n_, filter_query_);
2050
2381
  }
2051
2382
  });
2052
2383
  })();
@@ -2154,7 +2485,8 @@ function $1c8cac76cb67e9af$var$create_updating_signal({
2154
2485
  }
2155
2486
  function $1c8cac76cb67e9af$var$make_expanded_signal({
2156
2487
  expanded_hierarchical_filters_: [read_expanded_hierarchical_filters, write_expanded_hierarchical_filters],
2157
- filter_value_: filter_value_
2488
+ filter_value_: filter_value_,
2489
+ is_being_searched_: is_being_searched_
2158
2490
  }) {
2159
2491
  const index_in_expanded_filters = $i7OB2$createMemo(() => read_expanded_hierarchical_filters().findIndex(({
2160
2492
  value_: value_
@@ -2193,7 +2525,9 @@ function $1c8cac76cb67e9af$var$make_expanded_signal({
2193
2525
  defer: true
2194
2526
  }));
2195
2527
  return {
2196
- ui_should_show_expanded_: $i7OB2$createMemo(() => user_choice_signal[0]() ?? get_low_precedence_expanded()),
2528
+ ui_should_show_expanded_: $i7OB2$createMemo(
2529
+ // When user is searching through filters, expand everything they haven't collapsed, so they can see the results
2530
+ () => user_choice_signal[0]() ?? (is_being_searched_() || get_low_precedence_expanded())),
2197
2531
  set_low_precedence_expanded_: set_low_precedence_expanded,
2198
2532
  set_user_expanded_: set_user_choice_expanded
2199
2533
  };
@@ -2221,7 +2555,9 @@ const $93716a9ad0dea854$var$gap_px = 5;
2221
2555
  const $93716a9ad0dea854$var$max_columns = 3;
2222
2556
  const $93716a9ad0dea854$export$414f6a19d38e655c = ({
2223
2557
  filter_: filter_,
2224
- selected_filters_: [get_selected_filters, set_selected_filters]
2558
+ selected_filters_: [get_selected_filters, set_selected_filters],
2559
+ filter_query_: filter_query_,
2560
+ details_element_width_: details_element_width_
2225
2561
  }) => {
2226
2562
  const existing_filter = $i7OB2$createMemo(() => {
2227
2563
  const {
@@ -2249,18 +2585,18 @@ const $93716a9ad0dea854$export$414f6a19d38e655c = ({
2249
2585
  const container_width_accessor = $i7OB2$createMemo(() => {
2250
2586
  const element = container();
2251
2587
  if (!element) return;
2252
- return $0fdb37d8ddabef25$export$9f191182275e9ef(element);
2588
+ return $2449872a62a75a20$export$ebdc3711f7e02ccd(element);
2253
2589
  });
2254
2590
  const [shadow_children, set_shadow_children] = $i7OB2$createSignal(new Set(), {
2255
2591
  equals: false
2256
2592
  });
2257
2593
  const shadow_grid = $i7OB2$ssr($93716a9ad0dea854$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape([...shadow_children()])); // for getting the smallest possible sizes of all the items
2258
2594
  $i7OB2$createEffect(() => {
2259
- const container_width = container_width_accessor()?.();
2260
- if (container_width == undefined) return;
2595
+ const container_width = container_width_accessor()?.() || details_element_width_();
2596
+ if (container_width === undefined) return; // On firefox, unexpanded <details> elements' contents dont't have a width, fall back to the width of the details element itself to not have janky expanding animations due to wrong number of columns at point of expanding
2261
2597
  $93716a9ad0dea854$var$adjust_sizes(container_width, sizes_set(), set_cols_at_size);
2262
2598
  });
2263
- return [shadow_grid, $i7OB2$createComponent((0, $c8d5ff4524619fcd$export$d21e32dfedac04be), {
2599
+ return [$i7OB2$createComponent((0, $c8d5ff4524619fcd$export$d21e32dfedac04be), {
2264
2600
  get cols_at_size() {
2265
2601
  return cols_at_size();
2266
2602
  },
@@ -2282,27 +2618,33 @@ const $93716a9ad0dea854$export$414f6a19d38e655c = ({
2282
2618
  const current_value = $91aa8ee9f431800d$export$325f75597868c4f0(value().value_);
2283
2619
  return !!data?.some(item => $91aa8ee9f431800d$export$325f75597868c4f0(item) === current_value);
2284
2620
  });
2285
- const MakeButton = attributes => $i7OB2$ssrElement("button", $i7OB2$mergeProps1(attributes, {
2286
- get disabled() {
2287
- return value().count_ === 0 && !is_selected();
2288
- },
2289
- get classList() {
2290
- return {
2291
- minor: !is_selected(),
2292
- major: is_selected(),
2293
- "major-minor-transition": true
2294
- };
2295
- }
2296
- }), () => ["<!--$-->", $i7OB2$escape(value().value_), "<!--/-->", "<!--$-->", $i7OB2$escape($i7OB2$createComponent((0, $i7OB2$Show), {
2297
- get when() {
2298
- return value().count_ != undefined;
2299
- },
2300
- get children() {
2301
- return $i7OB2$ssr($93716a9ad0dea854$var$_tmpl$2, $i7OB2$ssrHydrationKey(), $i7OB2$escape(value().count_));
2302
- }
2303
- })), "<!--/-->"], true);
2621
+ const MakeButton = attributes => {
2622
+ const label = $i7OB2$createMemo(() => value().name_ || value().value_ + "");
2623
+ return $i7OB2$ssrElement("button", $i7OB2$mergeProps1(attributes, {
2624
+ get disabled() {
2625
+ return value().count_ === 0 && !is_selected();
2626
+ },
2627
+ get classList() {
2628
+ return {
2629
+ minor: !is_selected(),
2630
+ major: is_selected(),
2631
+ "major-minor-transition": true
2632
+ };
2633
+ }
2634
+ }), () => ["<!--$-->", $i7OB2$escape($i7OB2$createComponent((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
2635
+ whole_text_to_display_: label,
2636
+ searching_for_value_: () => filter_query_?.()
2637
+ })), "<!--/-->", "<!--$-->", $i7OB2$escape($i7OB2$createComponent((0, $i7OB2$Show), {
2638
+ get when() {
2639
+ return value().count_ != undefined;
2640
+ },
2641
+ get children() {
2642
+ return $i7OB2$ssr($93716a9ad0dea854$var$_tmpl$2, $i7OB2$ssrHydrationKey(), $i7OB2$escape(value().count_));
2643
+ }
2644
+ })), "<!--/-->"], true);
2645
+ };
2304
2646
  const invisible_size_button = $i7OB2$createComponent(MakeButton, {});
2305
- const smallest_possible_size = $0fdb37d8ddabef25$export$9f191182275e9ef(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
2647
+ const smallest_possible_size = $2449872a62a75a20$export$ebdc3711f7e02ccd(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
2306
2648
  const sizes_value = $i7OB2$untrack(sizes_set);
2307
2649
  const shadow_children_value = $i7OB2$untrack(shadow_children);
2308
2650
  sizes_value.add(smallest_possible_size);
@@ -2322,7 +2664,7 @@ const $93716a9ad0dea854$export$414f6a19d38e655c = ({
2322
2664
  }
2323
2665
  });
2324
2666
  }
2325
- })];
2667
+ }), shadow_grid];
2326
2668
  };
2327
2669
  /**
2328
2670
  * Calculate and apply cols_at_size overrides to fit as many items as possible in a row, evenly spaced
@@ -2388,7 +2730,8 @@ function $e731d52d97444b7c$export$82ed4b28ecb67608({
2388
2730
  filter_: filter_,
2389
2731
  selected_filters_: [get_selected_filters, set_selected_filters],
2390
2732
  i18n_: i18n_,
2391
- view_more_button_below_group_: [_get_view_more_button_below_group_, set_view_more_button_below_group_]
2733
+ view_more_button_below_group_: [_get_view_more_button_below_group_, set_view_more_button_below_group_],
2734
+ filter_query_: filter_query_
2392
2735
  }) {
2393
2736
  // same as in CheckboxFilter, maybe we should make this DRY at some point
2394
2737
  const existing_filter = $i7OB2$createMemo(() => {
@@ -2422,12 +2765,17 @@ function $e731d52d97444b7c$export$82ed4b28ecb67608({
2422
2765
  const value = $91aa8ee9f431800d$export$325f75597868c4f0(checkbox().value_);
2423
2766
  return !!data?.some(item => $91aa8ee9f431800d$export$325f75597868c4f0(item) === value);
2424
2767
  });
2768
+ const value = $i7OB2$createMemo(() => checkbox().value_);
2769
+ const label_text = $i7OB2$createMemo(() => checkbox().name_ || value() + "");
2425
2770
  const input_row = $i7OB2$createComponent((0, $49b79728e7d9e2a1$export$48513f6b9f8ce62d), {
2426
2771
  get value_() {
2427
- return checkbox().value_;
2772
+ return value();
2428
2773
  },
2429
2774
  get label_() {
2430
- return checkbox().name_;
2775
+ return $i7OB2$createComponent((0, $f3213c0640246d58$export$ba17c5b7e6dda39f), {
2776
+ whole_text_to_display_: label_text,
2777
+ searching_for_value_: () => filter_query_?.()
2778
+ });
2431
2779
  },
2432
2780
  get count_() {
2433
2781
  return checkbox().count_;
@@ -2678,10 +3026,143 @@ function $d134eae24341b4a1$export$89c6019e4baa40b1(props) {
2678
3026
  }
2679
3027
  });
2680
3028
  }
3029
+ const $16f0ed5ea30d8d9c$var$_tmpl$ = '<path d="M19.811 20.174l-6.234-6.809a7.96 7.96 0 0 0 .923-1.179c.274-.424.502-.865.687-1.323a8.04 8.04 0 0 0 .42-1.436 7.88 7.88 0 0 0 .144-1.507c0-.526-.051-1.042-.154-1.548-.096-.506-.243-.995-.441-1.466s-.441-.919-.728-1.343a8.28 8.28 0 0 0-.984-1.21 7.86 7.86 0 0 0-1.2-.984A7.56 7.56 0 0 0 10.89.651C10.418.453 9.929.302 9.423.2S8.401.046 7.875.046 6.833.097 6.327.2 5.332.453 4.86.651a7.56 7.56 0 0 0-1.354.718c-.431.287-.831.615-1.2.984a8.28 8.28 0 0 0-.984 1.21 7.73 7.73 0 0 0-.728 1.343c-.198.472-.349.96-.451 1.466A8.31 8.31 0 0 0 0 7.921a8.31 8.31 0 0 0 .144 1.548c.103.506.253.995.451 1.466a8.08 8.08 0 0 0 .728 1.354 7.86 7.86 0 0 0 .984 1.2 7.54 7.54 0 0 0 1.2.995c.431.287.882.53 1.354.728.472.191.96.338 1.466.441a8.31 8.31 0 0 0 1.548.144c.451 0 .896-.038 1.333-.113a7.83 7.83 0 0 0 1.282-.328 7.55 7.55 0 0 0 1.2-.533 8.08 8.08 0 0 0 1.107-.749l6.245 6.809a.45.45 0 0 0 .174.123.55.55 0 0 0 .205.041.61.61 0 0 0 .195-.031c.061-.021.116-.055.164-.102.109-.096.164-.219.164-.369.007-.144-.038-.267-.133-.369zM1.046 7.921c0-.937.178-1.818.533-2.646.362-.834.851-1.559 1.466-2.174.622-.615 1.347-1.101 2.174-1.456.827-.362 1.712-.543 2.656-.543s1.829.181 2.656.543c.827.355 1.548.841 2.164 1.456.622.615 1.111 1.34 1.466 2.174a6.52 6.52 0 0 1 .543 2.646c0 .943-.181 1.829-.543 2.656a6.89 6.89 0 0 1-1.466 2.174c-.615.615-1.336 1.104-2.164 1.466-.827.356-1.712.533-2.656.533s-1.829-.178-2.656-.533c-.827-.362-1.552-.851-2.174-1.466-.615-.622-1.104-1.347-1.466-2.174-.355-.827-.533-1.712-.533-2.656z"></path>';
3030
+ function $16f0ed5ea30d8d9c$export$82eafebb825fc23f(props = {}) {
3031
+ return $i7OB2$ssrElement("svg", $i7OB2$mergeProps1({
3032
+ xmlns: "http://www.w3.org/2000/svg",
3033
+ width: "20",
3034
+ height: "22",
3035
+ viewBox: "0 0 20 22"
3036
+ }, props), () => $i7OB2$ssr($16f0ed5ea30d8d9c$var$_tmpl$), true);
3037
+ }
3038
+ const $e01b34f289b61435$var$_tmpl$ = ["<div", ' class="search-in-filters"><input type="text" class="query"', "><!--$-->", '<!--/--><button style="', '" class="clear">', "</button></div>"];
3039
+ const $e01b34f289b61435$var$min_items_to_enable_filter_searching = 10; // For checkbox hierarchical we 2x this
3040
+ function $e01b34f289b61435$export$4b2c5292ffe0c5dd(filter_array_, section, i18n_) {
3041
+ const [filter_query_, set_filter_query_] = $i7OB2$createSignal();
3042
+ // Check if we have enough items to enable searching
3043
+ const enable_searchability = $i7OB2$createMemo(() => {
3044
+ let count = 0;
3045
+ for (const filter of filter_array_()) {
3046
+ const type = filter.meta?.type;
3047
+ if (type === "range") continue;
3048
+ const length = filter.meta.values.length;
3049
+ count += type === "checkbox-color" ? length / 2 : type === "checkbox-grid" ? length / 3 : length; // For checkbox-color we have two columns, checkbox-grid three, so we can show search later
3050
+ }
3051
+
3052
+ return count >= $e01b34f289b61435$var$min_items_to_enable_filter_searching;
3053
+ });
3054
+ const SearchThisFilterGroup_ = () => {
3055
+ return $i7OB2$createComponent((0, $i7OB2$Show), {
3056
+ get when() {
3057
+ return enable_searchability();
3058
+ },
3059
+ get children() {
3060
+ return $i7OB2$ssr($e01b34f289b61435$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$ssrAttribute("value", $i7OB2$escape(filter_query_(), true) || "", false) + $i7OB2$ssrAttribute("placeholder", $i7OB2$escape(i18n_.search_a_filter_()(section), true), false), $i7OB2$escape($i7OB2$createComponent((0, $16f0ed5ea30d8d9c$export$82eafebb825fc23f), {
3061
+ width: "16",
3062
+ height: "17.6",
3063
+ "class": "search-icon"
3064
+ })), "display:" + (filter_query_() ? "" : "none"), $i7OB2$escape($i7OB2$createComponent((0, $19976a74d273070d$export$3b621d86b1566b2), {
3065
+ width: "12",
3066
+ height: "12"
3067
+ })));
3068
+ }
3069
+ });
3070
+ };
3071
+ const searched_filter_array_ = $i7OB2$createMemo(() => {
3072
+ const query = filter_query_();
3073
+ if (!enable_searchability() || !query) return filter_array_();
3074
+ const lowercase_query = query.toLowerCase();
3075
+ const check_string_match = to_check => {
3076
+ to_check = to_check.toLowerCase();
3077
+ return to_check.includes(lowercase_query) || lowercase_query.includes(to_check);
3078
+ };
3079
+ return filter_array_().map(filter => {
3080
+ const type = filter.meta?.type;
3081
+ if (type === "range") return filter; // can't search in range filters and for checkbox-hierarchical we do the searching in the filter component since we have access to a hierarchical structure there
3082
+ const meta = filter.meta;
3083
+ const {
3084
+ values: values,
3085
+ names: names,
3086
+ counts: counts
3087
+ } = meta;
3088
+ if (!Array.isArray(values)) return filter; // Might have to adjust this in the future, but I think these super simple filters won't need search
3089
+ const is_hierarchical_checkbox = type === "checkbox-hierarchical";
3090
+ // Which index of counts, values and names should be kept
3091
+ const filtered_indexes = values.map((item, index) => {
3092
+ const item_from_names = names?.[index];
3093
+ if (item_from_names && !is_hierarchical_checkbox)
3094
+ // We should use names if they exist, but sometimes backend doesn't provide any at all, and sometimes they are undefined, presumably from create_modified_filters
3095
+ item = item_from_names;
3096
+ if (typeof item === "number") return true;
3097
+ if (is_hierarchical_checkbox && names)
3098
+ // Special case for hierarchical checkboxes where we need to check if any of the names in the path match the query
3099
+ item = item.map((_, index) => names[$e01b34f289b61435$var$find_str_arr_in_str_arr_arr("findIndex", values, item.slice(0, index + 1))]);
3100
+ if (Array.isArray(item)) return item.some(item => check_string_match(item + "")); // If any of the items in the array match, keep it
3101
+ return check_string_match(item);
3102
+ });
3103
+ const new_values = values.filter((_, i) => filtered_indexes[i]);
3104
+ if (!new_values.length) return false; // false = please delete this filter, see below
3105
+ const new_filter_object = {
3106
+ ...filter,
3107
+ meta: {
3108
+ ...meta,
3109
+ counts: counts?.filter((_, i) => filtered_indexes[i]),
3110
+ ...(names ? {
3111
+ names: meta.names?.filter((_, i) => filtered_indexes[i])
3112
+ } : {}),
3113
+ values: new_values
3114
+ }
3115
+ };
3116
+ if (is_hierarchical_checkbox) {
3117
+ // For hierarchical checkbox we need to fill the holes created by filtering, for example if there is
3118
+ // ["Clothes"]
3119
+ // ["Clothes", "Blazers"]
3120
+ // And the user searched for "blazers" we need to add back ["Clothes"] so CheckboxHierarchicalFilter doesn't get confused
3121
+ // I explored doing the filtering there instead, but it's very hard to do it early enough before the expansion/collapsedness is calculated and check-logic is set up in relation to other items
3122
+ // So we do it here instead
3123
+ const new_meta = new_filter_object.meta;
3124
+ const new_values = new_meta.values;
3125
+ for (const value of new_values) {
3126
+ if (!Array.isArray(value)) continue; // Shouldn't happen
3127
+ if (value.length < 2) continue; // No parent
3128
+ const parent = value.slice(0, -1);
3129
+ // Check if parent exists
3130
+ if ($e01b34f289b61435$var$find_str_arr_in_str_arr_arr("some", new_values, parent)) continue; // Parent exists
3131
+ // Otherwise, put it back
3132
+ const index_to_restore = $e01b34f289b61435$var$find_str_arr_in_str_arr_arr("findIndex", values, parent);
3133
+ if (index_to_restore < 0) {
3134
+ $i7OB2$dwarn("Can't restore", parent, "to", new_values);
3135
+ continue;
3136
+ }
3137
+ const current_index_of_us = new_values.findIndex(item => item === value);
3138
+ new_values.splice(current_index_of_us, 0, values[index_to_restore]);
3139
+ const count_to_restore = counts?.[index_to_restore];
3140
+ if (count_to_restore) new_meta.counts?.splice(current_index_of_us, 0, count_to_restore);
3141
+ const name_to_restore = names?.[index_to_restore];
3142
+ if (name_to_restore) new_meta.names?.splice(current_index_of_us, 0, name_to_restore);
3143
+ }
3144
+ }
3145
+ return new_filter_object;
3146
+ }).filter(filter => filter); // Delete filters that don't have a value anymore
3147
+ });
3148
+
3149
+ return {
3150
+ SearchThisFilterGroup_: SearchThisFilterGroup_,
3151
+ searched_filter_array_: searched_filter_array_,
3152
+ filter_query_: filter_query_
3153
+ };
3154
+ }
3155
+ /**
3156
+ * Finds/whatevers what's effectively one hierarchical filter item in an array of hierarchical filter items
3157
+ * Functions similar to this happen loads in create_modified_filters, but they have additional checks so not touching them RN
3158
+ */
3159
+ function $e01b34f289b61435$var$find_str_arr_in_str_arr_arr(operation, haystack, needle) {
3160
+ return haystack[operation](value => value.length === needle.length && value.every((item, index) => item === needle[index]));
3161
+ }
2681
3162
  const $fab07f52c9861732$var$_tmpl$ = ["<div", ' class="filter-collapsible">', "</div>"],
2682
3163
  $fab07f52c9861732$var$_tmpl$2 = ["<button", ' class="clear-group"><!--$-->', "<!--/--><span>", "</span></button>"],
2683
3164
  $fab07f52c9861732$var$_tmpl$3 = ["<div", ' class="view-more-clear"><!--$-->', "<!--/--><!--$-->", "<!--/--></div>"],
2684
- $fab07f52c9861732$var$_tmpl$4 = ["<div", ' class="filter-collapsible-body"><div class="filter-part">', "</div><!--$-->", "<!--/--></div>"],
3165
+ $fab07f52c9861732$var$_tmpl$4 = ["<div", ' class="filter-collapsible-body"><div class="filter-part"><!--$-->', "<!--/--><!--$-->", "<!--/--></div><!--$-->", "<!--/--></div>"],
2685
3166
  $fab07f52c9861732$var$_tmpl$5 = ["<details", ' class="filter-collapsible"', "></details>"],
2686
3167
  $fab07f52c9861732$var$_tmpl$6 = ["<summary", ' class="filter-group-summary"><div class="summary"><span>', '</span><div class="selected-w-sign"><!--$-->', "<!--/--><!--$-->", "<!--/--></div></div></summary>"],
2687
3168
  $fab07f52c9861732$var$_tmpl$7 = ["<div", ' class="ungrouped">', "</div>"],
@@ -2732,6 +3213,11 @@ function $fab07f52c9861732$var$ActualFilterBody(props) {
2732
3213
  const filter_array_ = $i7OB2$createMemo(() => {
2733
3214
  return Object.values(togglable_filters_grouped_by_collapsible())[get_section_index()];
2734
3215
  });
3216
+ const {
3217
+ SearchThisFilterGroup_: SearchThisFilterGroup_,
3218
+ searched_filter_array_: searched_filter_array_,
3219
+ filter_query_: filter_query_
3220
+ } = $e01b34f289b61435$export$4b2c5292ffe0c5dd(filter_array_, section_, props.i18n_);
2735
3221
  const is_open = $84d6cd10bb7b1589$export$ab34afce88557c0e({
2736
3222
  get expanded_filters_() {
2737
3223
  return props.expanded_filters_;
@@ -2744,6 +3230,8 @@ function $fab07f52c9861732$var$ActualFilterBody(props) {
2744
3230
  // this is absolutely not accurate which is why we have the .filter below, it's just the easiest way to get the typing of the map correct
2745
3231
  filter_from_api]).filter(([selected_filter]) => selected_filter)));
2746
3232
  const a_filter_is_selected = $i7OB2$createMemo(() => selected_filters_in_group().size);
3233
+ const [get_details_width, set_get_details_width] = $i7OB2$createSignal();
3234
+ const details_element_width_ = $i7OB2$createMemo(() => get_details_width?.()?.());
2747
3235
  return $i7OB2$createComponent((0, $6bb0a0c563dff4bb$export$6c6d7a51fa9aa15d), {
2748
3236
  is_open_: is_open,
2749
3237
  get details_() {
@@ -2772,9 +3260,9 @@ function $fab07f52c9861732$var$ActualFilterBody(props) {
2772
3260
  })));
2773
3261
  },
2774
3262
  get children() {
2775
- return $i7OB2$ssr($fab07f52c9861732$var$_tmpl$4, $i7OB2$ssrHydrationKey(), $i7OB2$escape($i7OB2$createComponent((0, $i7OB2$Index), {
3263
+ return $i7OB2$ssr($fab07f52c9861732$var$_tmpl$4, $i7OB2$ssrHydrationKey(), $i7OB2$escape($i7OB2$createComponent(SearchThisFilterGroup_, {})), $i7OB2$escape($i7OB2$createComponent((0, $i7OB2$Index), {
2776
3264
  get each() {
2777
- return filter_array_();
3265
+ return searched_filter_array_();
2778
3266
  },
2779
3267
  children: filter => $i7OB2$createComponent((0, $b7436a6d1fd64e3b$export$b69d0d92862de18b), {
2780
3268
  severity_: "error",
@@ -2796,7 +3284,9 @@ function $fab07f52c9861732$var$ActualFilterBody(props) {
2796
3284
  get i18n_() {
2797
3285
  return props.i18n_;
2798
3286
  },
2799
- view_more_button_below_group_: view_more_button_below_group
3287
+ view_more_button_below_group_: view_more_button_below_group,
3288
+ filter_query_: filter_query_,
3289
+ details_element_width_: details_element_width_
2800
3290
  });
2801
3291
  }
2802
3292
  })
@@ -6569,14 +7059,6 @@ const $22e59517c2ec94d3$var$_tmpl$ = ["<svg", ' xmlns="http://www.w3.org/2000/sv
6569
7059
  function $22e59517c2ec94d3$export$1c641004b5485fed() {
6570
7060
  return $i7OB2$ssr($22e59517c2ec94d3$var$_tmpl$, $i7OB2$ssrHydrationKey());
6571
7061
  }
6572
- const $16f0ed5ea30d8d9c$var$_tmpl$ = '<path d="M19.811 20.174l-6.234-6.809a7.96 7.96 0 0 0 .923-1.179c.274-.424.502-.865.687-1.323a8.04 8.04 0 0 0 .42-1.436 7.88 7.88 0 0 0 .144-1.507c0-.526-.051-1.042-.154-1.548-.096-.506-.243-.995-.441-1.466s-.441-.919-.728-1.343a8.28 8.28 0 0 0-.984-1.21 7.86 7.86 0 0 0-1.2-.984A7.56 7.56 0 0 0 10.89.651C10.418.453 9.929.302 9.423.2S8.401.046 7.875.046 6.833.097 6.327.2 5.332.453 4.86.651a7.56 7.56 0 0 0-1.354.718c-.431.287-.831.615-1.2.984a8.28 8.28 0 0 0-.984 1.21 7.73 7.73 0 0 0-.728 1.343c-.198.472-.349.96-.451 1.466A8.31 8.31 0 0 0 0 7.921a8.31 8.31 0 0 0 .144 1.548c.103.506.253.995.451 1.466a8.08 8.08 0 0 0 .728 1.354 7.86 7.86 0 0 0 .984 1.2 7.54 7.54 0 0 0 1.2.995c.431.287.882.53 1.354.728.472.191.96.338 1.466.441a8.31 8.31 0 0 0 1.548.144c.451 0 .896-.038 1.333-.113a7.83 7.83 0 0 0 1.282-.328 7.55 7.55 0 0 0 1.2-.533 8.08 8.08 0 0 0 1.107-.749l6.245 6.809a.45.45 0 0 0 .174.123.55.55 0 0 0 .205.041.61.61 0 0 0 .195-.031c.061-.021.116-.055.164-.102.109-.096.164-.219.164-.369.007-.144-.038-.267-.133-.369zM1.046 7.921c0-.937.178-1.818.533-2.646.362-.834.851-1.559 1.466-2.174.622-.615 1.347-1.101 2.174-1.456.827-.362 1.712-.543 2.656-.543s1.829.181 2.656.543c.827.355 1.548.841 2.164 1.456.622.615 1.111 1.34 1.466 2.174a6.52 6.52 0 0 1 .543 2.646c0 .943-.181 1.829-.543 2.656a6.89 6.89 0 0 1-1.466 2.174c-.615.615-1.336 1.104-2.164 1.466-.827.356-1.712.533-2.656.533s-1.829-.178-2.656-.533c-.827-.362-1.552-.851-2.174-1.466-.615-.622-1.104-1.347-1.466-2.174-.355-.827-.533-1.712-.533-2.656z"></path>';
6573
- function $16f0ed5ea30d8d9c$export$82eafebb825fc23f(props = {}) {
6574
- return $i7OB2$ssrElement("svg", $i7OB2$mergeProps1(props, {
6575
- xmlns: "http://www.w3.org/2000/svg",
6576
- width: "20",
6577
- height: "22"
6578
- }), () => $i7OB2$ssr($16f0ed5ea30d8d9c$var$_tmpl$), true);
6579
- }
6580
7062
  const $5285d2814d0fac0c$var$_tmpl$ = ["<button", ' class="back" type="button"', ">", "</button>"],
6581
7063
  $5285d2814d0fac0c$var$_tmpl$2 = ["<div", ' class="search-field"><!--$-->', '<!--/--><div class="field"><input class="', '" tabindex="0"', '><button type="button" class="clear"', ' style="', '">', '</button></div><button class="submit major" type="button"', ">", "</button></div>"];
6582
7064
  function $5285d2814d0fac0c$export$b94867ecbd698f21({
@@ -7025,89 +7507,36 @@ function $7ad3a93cbe6fa208$export$a146ac6fa8346a25({
7025
7507
  const has_entries = $i7OB2$createMemo(() => previous_searches_().length >= 1);
7026
7508
  currently_showing_suggestions_[1](value => {
7027
7509
  value[0] = $i7OB2$createMemo(() => previous_searches_().map(result => ({
7028
- type: (0, $a0eb8b431ec1f87b$export$3cf9497e790da491),
7029
- title: result,
7030
- suggestions_result_id: "history"
7031
- })));
7032
- return value;
7033
- });
7034
- $i7OB2$onCleanup(() => currently_showing_suggestions_[1](value => {
7035
- delete value[0];
7036
- return value;
7037
- }));
7038
- return $i7OB2$createComponent((0, $i7OB2$Show), {
7039
- get when() {
7040
- return has_entries();
7041
- },
7042
- get children() {
7043
- return $i7OB2$ssr($7ad3a93cbe6fa208$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape(text_()), $i7OB2$escape($i7OB2$createComponent((0, $i7OB2$Index), {
7044
- get each() {
7045
- return previous_searches_();
7046
- },
7047
- children: (item, index) => {
7048
- const href = $a36cbc4f68bfd590$export$91c3b6774e8be0f5({
7049
- param_: search_query_param_name_,
7050
- value_: item,
7051
- url_transformer_: url_transformer_
7052
- });
7053
- return $i7OB2$ssr($7ad3a93cbe6fa208$var$_tmpl$2, $i7OB2$ssrHydrationKey(), `${`item` || ""} ${$i7OB2$createMemo(() => read_selected_index_()?.[0] === 0 && read_selected_index_()?.[1] === index)() ? "selected" : ""}`, $i7OB2$ssrAttribute("href", $i7OB2$escape(href(), true), false), $i7OB2$escape($i7OB2$createComponent((0, $694b7f90501fea4c$export$5d2caaa6b530761c), {})), $i7OB2$ssrAttribute("title", $i7OB2$escape(item(), true), false), $i7OB2$escape(item()), $i7OB2$ssrAttribute("title", $i7OB2$escape(i18n_.previous_searches_delete_entry_from_history_(), true), false), $i7OB2$escape($i7OB2$createComponent((0, $19976a74d273070d$export$3b621d86b1566b2), {})));
7054
- }
7055
- })));
7056
- }
7057
- });
7058
- }
7059
- const $f3213c0640246d58$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"],
7060
- $f3213c0640246d58$var$_tmpl$2 = ["<span", ' class="', '"', ">", "</span>"];
7061
- function $f3213c0640246d58$export$ba17c5b7e6dda39f({
7062
- whole_text_to_display_: whole_text_to_display_memo,
7063
- searching_for_value_: searching_for_value_memo,
7064
- class_: class_
7065
- }) {
7066
- const [get_has_highlighted, set_has_highlighted] = $i7OB2$createSignal(false);
7067
- const text_itself = $i7OB2$createMemo(() => $i7OB2$batch(() => {
7068
- set_has_highlighted(false);
7069
- const searching_for_value = searching_for_value_memo();
7070
- const whole_text_to_display_ = whole_text_to_display_memo();
7071
- let for_black = "";
7072
- let pushed_grey = false;
7073
- const search_q = searching_for_value;
7074
- if (!search_q) return whole_text_to_display_;
7075
- const output = [];
7076
- const searching_for = search_q.toLowerCase();
7077
- const push_black = () => {
7078
- if (for_black) {
7079
- set_has_highlighted(true);
7080
- output.push($i7OB2$ssr($f3213c0640246d58$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape(for_black))); // "black"
7081
- for_black = "";
7082
- }
7083
- };
7084
- for (let i = 0; i < whole_text_to_display_.length;) {
7085
- let is_whole_word = true;
7086
- let searching_for_but_with_texts_casing = "";
7087
- const i_at_start = i;
7088
- for (let j = 0; j < searching_for.length; i++, j++) {
7089
- const letter_in_suggestion = whole_text_to_display_[i];
7090
- if (letter_in_suggestion?.toLowerCase() !== searching_for[j]) {
7091
- is_whole_word = false;
7092
- i = i_at_start;
7093
- break;
7510
+ type: (0, $a0eb8b431ec1f87b$export$3cf9497e790da491),
7511
+ title: result,
7512
+ suggestions_result_id: "history"
7513
+ })));
7514
+ return value;
7515
+ });
7516
+ $i7OB2$onCleanup(() => currently_showing_suggestions_[1](value => {
7517
+ delete value[0];
7518
+ return value;
7519
+ }));
7520
+ return $i7OB2$createComponent((0, $i7OB2$Show), {
7521
+ get when() {
7522
+ return has_entries();
7523
+ },
7524
+ get children() {
7525
+ return $i7OB2$ssr($7ad3a93cbe6fa208$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape(text_()), $i7OB2$escape($i7OB2$createComponent((0, $i7OB2$Index), {
7526
+ get each() {
7527
+ return previous_searches_();
7528
+ },
7529
+ children: (item, index) => {
7530
+ const href = $a36cbc4f68bfd590$export$91c3b6774e8be0f5({
7531
+ param_: search_query_param_name_,
7532
+ value_: item,
7533
+ url_transformer_: url_transformer_
7534
+ });
7535
+ return $i7OB2$ssr($7ad3a93cbe6fa208$var$_tmpl$2, $i7OB2$ssrHydrationKey(), `${`item` || ""} ${$i7OB2$createMemo(() => read_selected_index_()?.[0] === 0 && read_selected_index_()?.[1] === index)() ? "selected" : ""}`, $i7OB2$ssrAttribute("href", $i7OB2$escape(href(), true), false), $i7OB2$escape($i7OB2$createComponent((0, $694b7f90501fea4c$export$5d2caaa6b530761c), {})), $i7OB2$ssrAttribute("title", $i7OB2$escape(item(), true), false), $i7OB2$escape(item()), $i7OB2$ssrAttribute("title", $i7OB2$escape(i18n_.previous_searches_delete_entry_from_history_(), true), false), $i7OB2$escape($i7OB2$createComponent((0, $19976a74d273070d$export$3b621d86b1566b2), {})));
7094
7536
  }
7095
- searching_for_but_with_texts_casing += letter_in_suggestion;
7096
- }
7097
- if (is_whole_word) {
7098
- push_black();
7099
- output.push(searching_for_but_with_texts_casing);
7100
- pushed_grey = true;
7101
- } else for_black += whole_text_to_display_[i++];
7102
- }
7103
- push_black();
7104
- if (!pushed_grey) {
7105
- set_has_highlighted(false);
7106
- return whole_text_to_display_;
7537
+ })));
7107
7538
  }
7108
- return output;
7109
- }));
7110
- return $i7OB2$ssr($f3213c0640246d58$var$_tmpl$2, $i7OB2$ssrHydrationKey(), `${$i7OB2$escape(class_, true) || ""} ${get_has_highlighted() ? "has-history-match" : ""}`, $i7OB2$ssrAttribute("title", $i7OB2$escape(whole_text_to_display_memo(), true), false), $i7OB2$escape(text_itself()));
7539
+ });
7111
7540
  }
7112
7541
  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>';
7113
7542
  function $190927650b4840eb$export$605674723bcc715c(props = {}) {
@@ -7146,8 +7575,8 @@ function $cea52f6b24092f05$export$e872e2339fb04a7f({
7146
7575
  type: type,
7147
7576
  title: title
7148
7577
  }) => type === (0, $a0eb8b431ec1f87b$export$3cf9497e790da491) && !filtered_previous_searches_().includes(title) // don't show the ones we already show from the history
7149
- ));
7150
-
7578
+ ) // + limit to three query suggestions, API sends more sometimes
7579
+ .slice(0, 3));
7151
7580
  const not_queries_memo = $i7OB2$createMemo(() => {
7152
7581
  // For the section that shows categories and content results
7153
7582
  // We want to limit to 3 items, and we want to show the categories first
@@ -7942,224 +8371,6 @@ function $1801dbce7adb3f19$export$41b4894022a3580f({
7942
8371
  })));
7943
8372
  return style_props_;
7944
8373
  }
7945
- const $522a690e0e2bd46d$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"];
7946
- const $522a690e0e2bd46d$var$dont_cut_in_between_less_than_characters = 30;
7947
- function $522a690e0e2bd46d$export$e1a98a189fd2c0e7({
7948
- content_result_: content_result_,
7949
- key_: key_,
7950
- cut_when_possible_: cut_when_possible_
7951
- }) {
7952
- const matched_tokens = $i7OB2$createMemo(() => content_result_().highlights?.find(highlight => highlight.field == key_)?.matched_tokens);
7953
- const full_value = $i7OB2$createMemo(() => content_result_()[key_]?.replaceAll("\n", " "));
7954
- return $i7OB2$createComponent((0, $i7OB2$Show), {
7955
- get when() {
7956
- return matched_tokens()?.length;
7957
- },
7958
- get fallback() {
7959
- return full_value();
7960
- },
7961
- get children() {
7962
- return (() => {
7963
- const segmented_cut_text = $i7OB2$createMemo(() => {
7964
- const segmented_text = $522a690e0e2bd46d$var$segment_text(full_value(), matched_tokens());
7965
- if (cut_when_possible_) $522a690e0e2bd46d$var$cut_text(segmented_text);
7966
- return segmented_text;
7967
- });
7968
- return $i7OB2$createComponent((0, $i7OB2$Index), {
7969
- get each() {
7970
- return segmented_cut_text();
7971
- },
7972
- children: item => {
7973
- return $i7OB2$createComponent((0, $i7OB2$Show), {
7974
- get when() {
7975
- return item().highlighted_;
7976
- },
7977
- get fallback() {
7978
- return item().text_;
7979
- },
7980
- get children() {
7981
- return $i7OB2$ssr($522a690e0e2bd46d$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape(item().text_));
7982
- }
7983
- });
7984
- }
7985
- });
7986
- })();
7987
- }
7988
- });
7989
- }
7990
- function $522a690e0e2bd46d$var$cut_text(segmented_text) {
7991
- // cut away chunks of text that are not highlighted to give a google-like overview of the content
7992
- const highlighted_segments = segmented_text?.filter(segment => segment.highlighted_);
7993
- if (!segmented_text || !highlighted_segments?.length) return;
7994
- // We have one or more highlighted segments
7995
- if (highlighted_segments.length === 1) {
7996
- // cut away from the left until the start of the highlighted sentence if just one sentence is highlighted
7997
- $522a690e0e2bd46d$var$cut_start(segmented_text.indexOf(highlighted_segments[0]), segmented_text);
7998
- return;
7999
- }
8000
- // We have two or more highlighted segments, take the two biggest chunks and show them + a bit text around
8001
- 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
8002
- );
8003
-
8004
- const [longest_segment, next_longest_segment] = sorted_highlighted_segments;
8005
- // We need to cut before the first segment - possibly through other segments - and maybe between segments
8006
- 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);
8007
- $522a690e0e2bd46d$var$cut_start(index_of_first_segment, segmented_text);
8008
- // update indexes since we might have removed segments
8009
- [index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
8010
- let number_of_characters_between_segments = 0;
8011
- for (let i = index_of_first_segment + 1; i < index_of_second_segment; i++) {
8012
- const segment = segmented_text[i];
8013
- number_of_characters_between_segments += segment.text_.length;
8014
- }
8015
- if (number_of_characters_between_segments < $522a690e0e2bd46d$var$dont_cut_in_between_less_than_characters)
8016
- // don't cut if there are less than 30 characters between the two segments
8017
- return;
8018
- // We have more than 50 characters between the two segments, cut between them
8019
- const [split_start_segment, split_start_character] = $522a690e0e2bd46d$var$find_split_point(index_of_first_segment, index_of_second_segment, segmented_text);
8020
- const [split_end_segment, split_end_character] = $522a690e0e2bd46d$var$find_split_point(index_of_second_segment, index_of_first_segment, segmented_text);
8021
- if (split_start_segment === undefined || split_end_segment === undefined ||
8022
- // identical split point, or split end before split start, can't do anything
8023
- split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
8024
- const dots_segment = {
8025
- text_: " … ",
8026
- highlighted_: false
8027
- };
8028
- const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
8029
- if (i < split_start_segment || i > split_end_segment) return segment;
8030
- const text = segment.text_;
8031
- if (i == split_end_segment && i == split_start_segment) return [{
8032
- ...segment,
8033
- text_: text.slice(0, split_start_character).trimEnd()
8034
- }, dots_segment, {
8035
- ...segment,
8036
- text_: text.slice(split_end_character + 1, text.length).trimStart()
8037
- }];else if (i == split_start_segment) {
8038
- 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
8039
- return segment;
8040
- } else if (i == split_end_segment) return [dots_segment, {
8041
- ...segment,
8042
- text_: text.slice(split_end_character + 1, text.length).trimStart()
8043
- }];
8044
- return []; // remove all segments inbetween
8045
- });
8046
-
8047
- segmented_text.splice(0, segmented_text.length, ...split_and_dotted_values); // Sorry…
8048
- $522a690e0e2bd46d$var$heal_holes(segmented_text);
8049
- }
8050
- function $522a690e0e2bd46d$var$heal_holes(segmented_text) {
8051
- // try to heal "holes" created in the segments so there are only alternating segments
8052
- const segments_to_delete = new Set();
8053
- for (let i = 0; i < segmented_text.length; i++) {
8054
- const segment = segmented_text[i];
8055
- let previous_segment;
8056
- for (let j = i - 1; j >= 0; j--) {
8057
- previous_segment = segmented_text[j];
8058
- // Don't write to a segment that's marked for deletion or the contents we write to it will be deleted
8059
- if (!segments_to_delete.has(previous_segment)) break;
8060
- }
8061
- if (previous_segment?.highlighted_ && segment.highlighted_ || previous_segment?.highlighted_ === false && segment.highlighted_ === false) {
8062
- previous_segment.text_ += segment.text_; // IDK if this ever happens
8063
- segments_to_delete.add(segment);
8064
- }
8065
- }
8066
- for (const segment of segments_to_delete) {
8067
- const index = segmented_text.indexOf(segment);
8068
- segmented_text.splice(index, 1);
8069
- }
8070
- }
8071
- function $522a690e0e2bd46d$var$find_split_point(index_of_start_segment, index_of_end_segment, segmented_text, be_very_aggressive = true) {
8072
- const should_loop_backwards = index_of_start_segment > index_of_end_segment;
8073
- const step = should_loop_backwards ? -1 : 1;
8074
- const desperate_split_attempts = [":", ";", ","];
8075
- while (desperate_split_attempts.length) {
8076
- const split_point_between_words = [];
8077
- // for the middle also try to split with a few more characters if the default ones don't work over a full run
8078
- const desperate_split_attempt = desperate_split_attempts.pop();
8079
- let is_first_character = true;
8080
- for (let i = index_of_start_segment + step; should_loop_backwards ? i > index_of_end_segment : i < index_of_end_segment; i += step) {
8081
- const segment = segmented_text[i];
8082
- const text = segment.text_;
8083
- for (let j = should_loop_backwards ? text.length - 1 : 0; should_loop_backwards ? j >= 0 : j < text.length; j += step) {
8084
- const character = text[j];
8085
- if (character == "." || character == "?" || character == "!" || character == desperate_split_attempt) return [i, j]; // segment index, character index
8086
- if (is_first_character) is_first_character = false;else if (be_very_aggressive && character == " ") {
8087
- split_point_between_words.push([i, j]);
8088
- if (split_point_between_words.length > 3)
8089
- // We can't find a split point, so we'll just split between words
8090
- // 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
8091
- return split_point_between_words[1];
8092
- }
8093
- }
8094
- }
8095
- }
8096
- return [];
8097
- }
8098
- function $522a690e0e2bd46d$var$cut_start(cut_left_of_index, segmented_text) {
8099
- // Cut the start of the text to bring the first matching token
8100
- let is_first_character = false;
8101
- let words_encountered = 0;
8102
- outmost_loop: for (let i = cut_left_of_index - 1; i >= 0; i--) {
8103
- const segment = segmented_text[i];
8104
- // We assume that two adjacent highlighted segments don't exist and have been merged if they were to have existed
8105
- const text = segment.text_;
8106
- for (let j = text.length - 1; j >= 0; j--) {
8107
- const character = text[j];
8108
- const is_space = character == " ";
8109
- if (!is_first_character && is_space) words_encountered++;
8110
- if (character == "." || character == "?" || character == "!" || character == "," || words_encountered > 8 && is_space) {
8111
- // We have to be really aggressive at the start of sentences so stuff can be seen on mobile, hence comma
8112
- segment.text_ = text.slice(j + 1).trimStart();
8113
- segmented_text.splice(0, i);
8114
- if (character === "," || is_space)
8115
- // if we cut at a comma or psace, we add a … at the beginning
8116
- segmented_text.unshift({
8117
- text_: "… ",
8118
- highlighted_: false
8119
- });
8120
- break outmost_loop;
8121
- }
8122
- if (is_first_character) is_first_character = false;
8123
- }
8124
- }
8125
- $522a690e0e2bd46d$var$heal_holes(segmented_text); // if we added a ... there could now be a sequence that's not alternating true/false
8126
- }
8127
-
8128
- function $522a690e0e2bd46d$var$segment_text(text, matched_strings) {
8129
- // segment text where the matched strings are highlighted sections
8130
- const output = [];
8131
- if (!text) return; // shouldn't happen but whatever
8132
- for (let i = 0; i < text.length; i++) {
8133
- const found_strings = [];
8134
- if (!i || text[i - 1] == " ")
8135
- // only match at the start of a word or string, it looks weird if i.e. "we" is highlighted in "activewear
8136
- for (let j = 0; j < matched_strings.length; j++) {
8137
- const matched_string = matched_strings[j];
8138
- const part_in_text = text.slice(i, i + matched_string.length);
8139
- if (matched_string.length < 2) continue; // don't match on single characters, i.e. "I", it looks weird
8140
- 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
8141
- }
8142
-
8143
- const last_index_in_output = output.length - 1;
8144
- if (!found_strings.length) {
8145
- const character = text[i];
8146
- if (output[last_index_in_output]?.highlighted_ === false || output.length && /\s/.test(character))
8147
- // 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
8148
- output[last_index_in_output].text_ += character;else output.push({
8149
- highlighted_: false,
8150
- text_: character
8151
- });
8152
- } else {
8153
- const longest_found_string = found_strings.reduce((a, b) => a.length > b.length ? a : b);
8154
- if (output[last_index_in_output]?.highlighted_) output[last_index_in_output].text_ += longest_found_string;else output.push({
8155
- highlighted_: true,
8156
- text_: longest_found_string
8157
- });
8158
- i += longest_found_string.length - 1;
8159
- }
8160
- }
8161
- return output;
8162
- }
8163
8374
  const $b2bf2cdcff8142d8$var$_tmpl$ = ["<div", ' class="description line-clamp">', "</div>"],
8164
8375
  $b2bf2cdcff8142d8$var$_tmpl$2 = ["<div", ' class="content-card"><div class="image">', '</div><div class="info"><!--$-->', "<!--/--><!--$-->", "<!--/--></div></div>"];
8165
8376
  function $b2bf2cdcff8142d8$export$f631859cab12b342({
@@ -9458,4 +9669,4 @@ const $4690a06c8489dcd0$export$c3834fa86c616831 = [[4], [3, 1024], [2, 901]];
9458
9669
  const $4690a06c8489dcd0$export$864d304a0bc46829 = "2%";
9459
9670
  const $4690a06c8489dcd0$export$7bf543b9d9be2c22 = (0, $e4615ecd1849548f$export$b91cec6bdc6b32a1);
9460
9671
  $i7OB2$add_to_version_info("ui", (0, $ec291e0010116877$export$83d89fbfd8236492));
9461
- export { $4147651646da990a$export$916e6850778505f6 as strip_encoded_filter_and_sort, $4147651646da990a$export$58aa3f171519b6d7 as encode_filters, $4147651646da990a$export$f934fa24c3a86811 as decode_filters, $660070e2a394b3c3$export$d7b7ab832c20e2f4 as shopifyContainedImageContextSymbol, $011607bdf658f807$export$e68cff63f76bd15b as ListingProvider, $011607bdf658f807$export$8d0c4fdbb05a2f2e as useListing, $660070e2a394b3c3$export$e4b984597b71e989 as ShopifyContainedImage, $f32e14878e75af51$export$6649caad96ef8870 as SlidableItems, $0fdb37d8ddabef25$export$9f191182275e9ef as make_accurate_size_accessor, $ee116da074deb002$export$9574e176201e5e8d as RecommendationSlider, $9ea5383493360761$export$9756467d34d91cdb as RecommendationGrid, $e8ffe11ed01df0fe$export$6e5611bc7e57e477 as ShopifyResponsiveImg, $e8ffe11ed01df0fe$export$e6fffe67d4cdd848 as makeSizeAccessor, $f18d425032111270$export$94026ee33dbabc26 as ImageContainer, $b7436a6d1fd64e3b$export$b69d0d92862de18b as SentryErrorBoundary, $6bb0a0c563dff4bb$export$6c6d7a51fa9aa15d as ExpandingDetails, $c16e74cfe125bb05$export$f091cbac892643a4 as accessor_of_object_to_object_with_accessor_values, $1adfe60f3a14a1d7$export$fecbb157621501bd as SelectedFilters, $fab07f52c9861732$export$3f1a388cc0d8fed7 as FilterBody, $5efb5894079b220e$export$b288c38ae3fddb56 as create_modified_filters, $c8d5ff4524619fcd$export$d21e32dfedac04be as SolidLayout, $194bd6b8e4c59830$export$79b1565500412d9b as general_modal_abstraction, $19976a74d273070d$export$3b621d86b1566b2 as CrossIcon, $fbbadcb080ad1d4a$export$8be2714ec7f169ee as GenericSliderArrowButton, $c58717f39bf51647$export$58e808b1db15d3bc as fetchDepictRecommendations, $961b5c64bef4662f$export$de035477d6fef996 as QuickLinks, $961b5c64bef4662f$export$5b7c3ce0ebe51f86 as BreadCrumbs, $e4615ecd1849548f$export$b91cec6bdc6b32a1 as CategoryTitle, $a6e23a834336fc19$export$824dde41348efed1 as embedded_num_products, $c9312089e8983364$export$643598a327b5833e as get_categories, $961b5c64bef4662f$export$f34314aa9505732e as DepictCategory, $961b5c64bef4662f$export$e2bf8ce7779e827e as CategoryPage, $806c97b931758897$export$ac6237957a15b3f0 as DepictSearch, $806c97b931758897$export$bde3eb976dfded9 as get_search_query_updating_blocked_signal, $806c97b931758897$export$f2dc7e4e4aa11abb as SearchPage, $806c97b931758897$export$316f6f283ae64765 as SearchField, $4fd48cb976bf1789$export$aa14a9f43128f61f as ProductCardError, $6891c018a834cfdd$export$d86a33413558014e as open_modal_with_alignment, $bb15dfb548a7666e$export$ee1733d9a8495996 as DefaultInstantCardPlaceholder, $b6d5529b253681aa$export$b3ad617e9036868 as align_field, $b5cccc8ee7d24677$export$6daf8749b65a1b77 as convert_sdk_cols_at_size_to_layout, $926b1b5ba2239356$export$1233ca167bf71f9a as styles_to_valid_css_string, $aea1edf92433e81e$export$fe334901e8bebd57 as disable_scrolling, $6e8944558258054f$export$d0596b5cae35ad4 as open_search_with_shift_slash, $7fa23e2a0079eca4$export$e015ed2f2950f2e3 as DepictAPI, $dc9262ef6f786812$export$d9f36cf74e24d595 as media_query_to_accessor, $6936724b9e0b98d5$export$689e204eadb33baf as setup_fast_leave, $bf52d9f9eebd1938$export$5196e4c01fa56fcb as show_toast, $8c0f86cb3e266eeb$export$a71e92cfbb498adc as SolidFormatPrice, $4ca91518c9a35379$export$828dcdd425fd3231 as connect_search_field_height_to_aligner_height, $d20eff0aadc28983$export$acb3eaade4b23afd as BasePlaceholder, $d134eae24341b4a1$export$89c6019e4baa40b1 as TextPlaceholder, $7f60f09116a3fe61$export$3f37af283f8fb843 as ImagePlaceholder, $753e9b2889a47c89$export$3ccaa27d81dd8556 as PageReplacer, $4690a06c8489dcd0$export$864d304a0bc46829 as defaultGridSpacing, $4690a06c8489dcd0$export$c3834fa86c616831 as defaultColsAtSize, $4690a06c8489dcd0$export$7bf543b9d9be2c22 as defaultCategoryTitlePlugin, $ec291e0010116877$export$83d89fbfd8236492 as version };
9672
+ export { $4147651646da990a$export$916e6850778505f6 as strip_encoded_filter_and_sort, $4147651646da990a$export$58aa3f171519b6d7 as encode_filters, $4147651646da990a$export$f934fa24c3a86811 as decode_filters, $660070e2a394b3c3$export$d7b7ab832c20e2f4 as shopifyContainedImageContextSymbol, $011607bdf658f807$export$e68cff63f76bd15b as ListingProvider, $011607bdf658f807$export$8d0c4fdbb05a2f2e as useListing, $660070e2a394b3c3$export$e4b984597b71e989 as ShopifyContainedImage, $f32e14878e75af51$export$6649caad96ef8870 as SlidableItems, $2449872a62a75a20$export$ebdc3711f7e02ccd as make_accurate_width_accessor, $ee116da074deb002$export$9574e176201e5e8d as RecommendationSlider, $9ea5383493360761$export$9756467d34d91cdb as RecommendationGrid, $e8ffe11ed01df0fe$export$6e5611bc7e57e477 as ShopifyResponsiveImg, $e8ffe11ed01df0fe$export$e6fffe67d4cdd848 as makeSizeAccessor, $f18d425032111270$export$94026ee33dbabc26 as ImageContainer, $b7436a6d1fd64e3b$export$b69d0d92862de18b as SentryErrorBoundary, $6bb0a0c563dff4bb$export$6c6d7a51fa9aa15d as ExpandingDetails, $c16e74cfe125bb05$export$f091cbac892643a4 as accessor_of_object_to_object_with_accessor_values, $1adfe60f3a14a1d7$export$fecbb157621501bd as SelectedFilters, $fab07f52c9861732$export$3f1a388cc0d8fed7 as FilterBody, $5efb5894079b220e$export$b288c38ae3fddb56 as create_modified_filters, $c8d5ff4524619fcd$export$d21e32dfedac04be as SolidLayout, $194bd6b8e4c59830$export$79b1565500412d9b as general_modal_abstraction, $19976a74d273070d$export$3b621d86b1566b2 as CrossIcon, $fbbadcb080ad1d4a$export$8be2714ec7f169ee as GenericSliderArrowButton, $c58717f39bf51647$export$58e808b1db15d3bc as fetchDepictRecommendations, $961b5c64bef4662f$export$de035477d6fef996 as QuickLinks, $961b5c64bef4662f$export$5b7c3ce0ebe51f86 as BreadCrumbs, $e4615ecd1849548f$export$b91cec6bdc6b32a1 as CategoryTitle, $a6e23a834336fc19$export$824dde41348efed1 as embedded_num_products, $c9312089e8983364$export$643598a327b5833e as get_categories, $961b5c64bef4662f$export$f34314aa9505732e as DepictCategory, $961b5c64bef4662f$export$e2bf8ce7779e827e as CategoryPage, $806c97b931758897$export$ac6237957a15b3f0 as DepictSearch, $806c97b931758897$export$bde3eb976dfded9 as get_search_query_updating_blocked_signal, $806c97b931758897$export$f2dc7e4e4aa11abb as SearchPage, $806c97b931758897$export$316f6f283ae64765 as SearchField, $4fd48cb976bf1789$export$aa14a9f43128f61f as ProductCardError, $6891c018a834cfdd$export$d86a33413558014e as open_modal_with_alignment, $bb15dfb548a7666e$export$ee1733d9a8495996 as DefaultInstantCardPlaceholder, $b6d5529b253681aa$export$b3ad617e9036868 as align_field, $b5cccc8ee7d24677$export$6daf8749b65a1b77 as convert_sdk_cols_at_size_to_layout, $926b1b5ba2239356$export$1233ca167bf71f9a as styles_to_valid_css_string, $aea1edf92433e81e$export$fe334901e8bebd57 as disable_scrolling, $6e8944558258054f$export$d0596b5cae35ad4 as open_search_with_shift_slash, $7fa23e2a0079eca4$export$e015ed2f2950f2e3 as DepictAPI, $dc9262ef6f786812$export$d9f36cf74e24d595 as media_query_to_accessor, $6936724b9e0b98d5$export$689e204eadb33baf as setup_fast_leave, $bf52d9f9eebd1938$export$5196e4c01fa56fcb as show_toast, $8c0f86cb3e266eeb$export$a71e92cfbb498adc as SolidFormatPrice, $4ca91518c9a35379$export$828dcdd425fd3231 as connect_search_field_height_to_aligner_height, $d20eff0aadc28983$export$acb3eaade4b23afd as BasePlaceholder, $d134eae24341b4a1$export$89c6019e4baa40b1 as TextPlaceholder, $7f60f09116a3fe61$export$3f37af283f8fb843 as ImagePlaceholder, $753e9b2889a47c89$export$3ccaa27d81dd8556 as PageReplacer, $4690a06c8489dcd0$export$864d304a0bc46829 as defaultGridSpacing, $4690a06c8489dcd0$export$c3834fa86c616831 as defaultColsAtSize, $4690a06c8489dcd0$export$7bf543b9d9be2c22 as defaultCategoryTitlePlugin, $ec291e0010116877$export$83d89fbfd8236492 as version };