@depict-ai/ui 2.1.12 → 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,6 +1,6 @@
1
1
  import { add_to_version_info as $b8hua$add_to_version_info, base64_encode_unicode as $b8hua$base64_encode_unicode, base64_decode_unicode as $b8hua$base64_decode_unicode, dlog as $b8hua$dlog, queueMacroTask as $b8hua$queueMacroTask, catchify as $b8hua$catchify, is_safari as $b8hua$is_safari, observer as $b8hua$observer, dwarn as $b8hua$dwarn, Amazing_Slider as $b8hua$Amazing_Slider, slider_snap_css as $b8hua$slider_snap_css, slider_fading_factory as $b8hua$slider_fading_factory, slider_fractional_factory as $b8hua$slider_fractional_factory, camelCasifyObject as $b8hua$camelCasifyObject, make_random_classname as $b8hua$make_random_classname, n_col_styling_with_dist as $b8hua$n_col_styling_with_dist, layout_get_visible_recs_without_partial_rows as $b8hua$layout_get_visible_recs_without_partial_rows, layout_get_total_rec_amount_for_row as $b8hua$layout_get_total_rec_amount_for_row, layout_media_query_header as $b8hua$layout_media_query_header, report as $b8hua$report, useExpandingContainer as $b8hua$useExpandingContainer, standard_price_format as $b8hua$standard_price_format, hex_to_rgb as $b8hua$hex_to_rgb, relative_luminance_from_rgb as $b8hua$relative_luminance_from_rgb, fetch_recs as $b8hua$fetch_recs, snakeCasifyObject as $b8hua$snakeCasifyObject, instant_exec_on_suspect_history_change as $b8hua$instant_exec_on_suspect_history_change, base_url as $b8hua$base_url, get_depict_id as $b8hua$get_depict_id, get_user_id as $b8hua$get_user_id, get_session_id as $b8hua$get_session_id, make_url_with_query_params as $b8hua$make_url_with_query_params, fetch_retry as $b8hua$fetch_retry, add_version_query_params as $b8hua$add_version_query_params, sort_obj as $b8hua$sort_obj, edit_current_page_meta_tags as $b8hua$edit_current_page_meta_tags, javascript_media_query as $b8hua$javascript_media_query, use_href_accessor as $b8hua$use_href_accessor, make_asyncIterable_exiter as $b8hua$make_asyncIterable_exiter, href_change_ipns as $b8hua$href_change_ipns, ContainedImage as $b8hua$ContainedImage, deparallelize_no_drop as $b8hua$deparallelize_no_drop, ListenableSet as $b8hua$ListenableSet, insert_surfaces as $b8hua$insert_surfaces } from "@depict-ai/utilishared/ES10";
2
2
  import { createComponent as $b8hua$createComponent, insert as $b8hua$insert, ssr as $b8hua$ssr, ssrHydrationKey as $b8hua$ssrHydrationKey, ssrStyle as $b8hua$ssrStyle, spread as $b8hua$spread, escape as $b8hua$escape, ssrAttribute as $b8hua$ssrAttribute, mergeProps as $b8hua$mergeProps1, isServer as $b8hua$isServer, ssrElement as $b8hua$ssrElement, ssrClassList as $b8hua$ssrClassList, Dynamic as $b8hua$Dynamic } from "solid-js/web";
3
- import { createSignal as $b8hua$createSignal, getOwner as $b8hua$getOwner, createEffect as $b8hua$createEffect, runWithOwner as $b8hua$runWithOwner, onCleanup as $b8hua$onCleanup, createMemo as $b8hua$createMemo, createContext as $b8hua$createContext, useContext as $b8hua$useContext, mergeProps as $b8hua$mergeProps, Show as $b8hua$Show, createResource as $b8hua$createResource, Suspense as $b8hua$Suspense, untrack as $b8hua$untrack, createRenderEffect as $b8hua$createRenderEffect, Index as $b8hua$Index, createRoot as $b8hua$createRoot, For as $b8hua$For, createUniqueId as $b8hua$createUniqueId, createComputed as $b8hua$createComputed, ErrorBoundary as $b8hua$ErrorBoundary, on as $b8hua$on, batch as $b8hua$batch, createReaction as $b8hua$createReaction, mapArray as $b8hua$mapArray } from "solid-js";
3
+ import { createSignal as $b8hua$createSignal, getOwner as $b8hua$getOwner, createEffect as $b8hua$createEffect, runWithOwner as $b8hua$runWithOwner, onCleanup as $b8hua$onCleanup, createMemo as $b8hua$createMemo, createContext as $b8hua$createContext, useContext as $b8hua$useContext, mergeProps as $b8hua$mergeProps, Show as $b8hua$Show, createResource as $b8hua$createResource, Suspense as $b8hua$Suspense, untrack as $b8hua$untrack, createRenderEffect as $b8hua$createRenderEffect, Index as $b8hua$Index, createRoot as $b8hua$createRoot, For as $b8hua$For, createUniqueId as $b8hua$createUniqueId, createComputed as $b8hua$createComputed, ErrorBoundary as $b8hua$ErrorBoundary, batch as $b8hua$batch, on as $b8hua$on, createReaction as $b8hua$createReaction, mapArray as $b8hua$mapArray } from "solid-js";
4
4
  import $b8hua$babelruntimehelpersclassPrivateFieldSet from "@babel/runtime/helpers/classPrivateFieldSet";
5
5
  import $b8hua$babelruntimehelpersclassPrivateFieldGet from "@babel/runtime/helpers/classPrivateFieldGet";
6
6
  import $b8hua$babelruntimehelpersdefineProperty from "@babel/runtime/helpers/defineProperty";
@@ -9,7 +9,7 @@ import { createStore as $b8hua$createStore, reconcile as $b8hua$reconcile } from
9
9
  /*! Depict.ai search and product listing SDK */
10
10
  import { register_es_version } from "../../multi_import_deduplicator.mjs";
11
11
  register_es_version("ui", "ES10");
12
- const $8db9a15135765c11$export$83d89fbfd8236492 = "2.1.12";
12
+ const $8db9a15135765c11$export$83d89fbfd8236492 = "2.1.13";
13
13
  const $2855bffe06ef7a03$var$fallback_operator = "in";
14
14
  const $2855bffe06ef7a03$var$fallback_token = "";
15
15
  const $2855bffe06ef7a03$var$legacy_filter_prefix = "filter_";
@@ -439,13 +439,13 @@ function $002f09d00aac50b2$export$6649caad96ef8870(_ref) {
439
439
 
440
440
  /** @jsxImportSource solid-js */
441
441
 
442
- function $0dc044cffe1e825b$export$9f191182275e9ef(what_to_watch) {
443
- const [size, setSize] = $b8hua$createSignal();
442
+ function $fc830a7ee59416ef$export$ebdc3711f7e02ccd(what_to_watch) {
443
+ const [width, setWidth] = $b8hua$createSignal();
444
444
  const resizeObserver = new ResizeObserver($b8hua$catchify(records => {
445
445
  for (let j = 0; j < records.length; j++) {
446
446
  var _records$j$borderBoxS, _records$j$borderBoxS2, _records$j$borderBoxS3;
447
447
  const width = (_records$j$borderBoxS = (_records$j$borderBoxS2 = records[j].borderBoxSize) === null || _records$j$borderBoxS2 === void 0 ? void 0 : (_records$j$borderBoxS3 = _records$j$borderBoxS2[0]) === null || _records$j$borderBoxS3 === void 0 ? void 0 : _records$j$borderBoxS3.inlineSize) !== null && _records$j$borderBoxS !== void 0 ? _records$j$borderBoxS : what_to_watch.getBoundingClientRect().width;
448
- setSize(width);
448
+ setWidth(width);
449
449
  }
450
450
  }));
451
451
  // 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.
@@ -454,13 +454,19 @@ function $0dc044cffe1e825b$export$9f191182275e9ef(what_to_watch) {
454
454
  let {
455
455
  element: element
456
456
  } = _ref;
457
- return requestAnimationFrame($b8hua$catchify(() => resizeObserver.observe(element)));
457
+ return requestAnimationFrame($b8hua$catchify(() => {
458
+ const current_size = what_to_watch.getBoundingClientRect().width;
459
+ if (current_size)
460
+ // 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.
461
+ setWidth(current_size);
462
+ resizeObserver.observe(element);
463
+ }));
458
464
  });
459
465
  $b8hua$onCleanup(() => {
460
466
  resizeObserver.disconnect();
461
467
  disconnect();
462
468
  });
463
- return size;
469
+ return width;
464
470
  }
465
471
  const $a9c7ba6087881ac2$var$transform_elements = sorted_cols_at_size => {
466
472
  const cols_at_size = [];
@@ -1257,12 +1263,12 @@ function $60ec7a29849d81db$export$a71e92cfbb498adc(props) {
1257
1263
  const $9783d437ad61594c$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>';
1258
1264
  function $9783d437ad61594c$export$3b621d86b1566b2() {
1259
1265
  let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1260
- return $b8hua$ssrElement("svg", $b8hua$mergeProps1(props, {
1266
+ return $b8hua$ssrElement("svg", $b8hua$mergeProps1({
1261
1267
  xmlns: "http://www.w3.org/2000/svg",
1262
1268
  width: "21.064",
1263
1269
  height: "21.047",
1264
1270
  viewBox: "0 0 21.064 21.064"
1265
- }), () => $b8hua$ssr($9783d437ad61594c$var$_tmpl$), true);
1271
+ }, props), () => $b8hua$ssr($9783d437ad61594c$var$_tmpl$), true);
1266
1272
  }
1267
1273
 
1268
1274
  /**
@@ -1490,7 +1496,7 @@ function $4711a82d08d2021b$export$fecbb157621501bd(_ref) {
1490
1496
  const $19e828709c7723a0$var$_tmpl$ = ["<span", ' class="count">', "</span>"],
1491
1497
  $19e828709c7723a0$var$_tmpl$2 = ["<label", ' class="', '"', '><div class="left"><input type="checkbox"', "", "", '><span class="custom-indicator"></span><span class="text line-clamp">', "</span></div><!--$-->", "<!--/--></label>"];
1492
1498
  const $19e828709c7723a0$export$48513f6b9f8ce62d = props => {
1493
- // 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
1499
+ /* 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
1494
1500
  const count = $b8hua$createMemo(() => props.count_);
1495
1501
  const label = $b8hua$createMemo(() => props.label_);
1496
1502
  const checked = $b8hua$createMemo(() => props.checked_);
@@ -1523,6 +1529,60 @@ function $3e850b2f2cca761f$export$ca21a16d65b3dd8(_ref) {
1523
1529
  } = _ref;
1524
1530
  return $b8hua$ssr($3e850b2f2cca761f$var$_tmpl$, $b8hua$ssrHydrationKey(), "expand-filter ".concat(get_show_extras() ? "expanded" : ""), $b8hua$escape($b8hua$createComponent((0, $ff3225aef892a467$export$f21ab0717a89c77f), {})), get_show_extras() ? $b8hua$escape(i18n_.view_less_()) : $b8hua$escape(i18n_.view_more_()));
1525
1531
  }
1532
+ const $02b6641aa50ce528$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"],
1533
+ $02b6641aa50ce528$var$_tmpl$2 = ["<span", ' class="', '"', ">", "</span>"];
1534
+ function $02b6641aa50ce528$export$ba17c5b7e6dda39f(_ref) {
1535
+ let {
1536
+ whole_text_to_display_: whole_text_to_display_memo,
1537
+ searching_for_value_: searching_for_value_memo,
1538
+ class_: class_
1539
+ } = _ref;
1540
+ const [get_has_highlighted, set_has_highlighted] = $b8hua$createSignal(false);
1541
+ const text_itself = $b8hua$createMemo(() => $b8hua$batch(() => {
1542
+ set_has_highlighted(false);
1543
+ const searching_for_value = searching_for_value_memo();
1544
+ const whole_text_to_display_ = whole_text_to_display_memo();
1545
+ let for_black = "";
1546
+ let pushed_grey = false;
1547
+ const search_q = searching_for_value;
1548
+ if (!search_q) return whole_text_to_display_;
1549
+ const output = [];
1550
+ const searching_for = search_q.toLowerCase();
1551
+ const push_black = () => {
1552
+ if (for_black) {
1553
+ set_has_highlighted(true);
1554
+ output.push($b8hua$ssr($02b6641aa50ce528$var$_tmpl$, $b8hua$ssrHydrationKey(), $b8hua$escape(for_black))); // "black"
1555
+ for_black = "";
1556
+ }
1557
+ };
1558
+ for (let i = 0; i < whole_text_to_display_.length;) {
1559
+ let is_whole_word = true;
1560
+ let searching_for_but_with_texts_casing = "";
1561
+ const i_at_start = i;
1562
+ for (let j = 0; j < searching_for.length; i++, j++) {
1563
+ const letter_in_suggestion = whole_text_to_display_[i];
1564
+ if ((letter_in_suggestion === null || letter_in_suggestion === void 0 ? void 0 : letter_in_suggestion.toLowerCase()) !== searching_for[j]) {
1565
+ is_whole_word = false;
1566
+ i = i_at_start;
1567
+ break;
1568
+ }
1569
+ searching_for_but_with_texts_casing += letter_in_suggestion;
1570
+ }
1571
+ if (is_whole_word) {
1572
+ push_black();
1573
+ output.push(searching_for_but_with_texts_casing);
1574
+ pushed_grey = true;
1575
+ } else for_black += whole_text_to_display_[i++];
1576
+ }
1577
+ push_black();
1578
+ if (!pushed_grey) {
1579
+ set_has_highlighted(false);
1580
+ return whole_text_to_display_;
1581
+ }
1582
+ return output;
1583
+ }));
1584
+ return $b8hua$ssr($02b6641aa50ce528$var$_tmpl$2, $b8hua$ssrHydrationKey(), "".concat($b8hua$escape(class_, true) || "", " ").concat(get_has_highlighted() ? "has-match" : ""), $b8hua$ssrAttribute("title", $b8hua$escape(whole_text_to_display_memo(), true), false), $b8hua$escape(text_itself()));
1585
+ }
1526
1586
  const $133484ef10e4e954$var$_tmpl$ = ["<form", ' class="checkboxes"><!--$-->', "<!--/--><!--$-->", "<!--/--></form>"];
1527
1587
  const $133484ef10e4e954$var$max_visible_without_collapsing = 15;
1528
1588
  const $133484ef10e4e954$var$show_non_collapsible_when_collapsed = 4;
@@ -1531,7 +1591,8 @@ function $133484ef10e4e954$export$dd948f91abc3a1c4(_ref) {
1531
1591
  filter_: filter_,
1532
1592
  selected_filters_: [get_selected_filters, set_selected_filters],
1533
1593
  i18n_: i18n_,
1534
- view_more_button_below_group_: [, set_view_more_button_below_group_]
1594
+ view_more_button_below_group_: [, set_view_more_button_below_group_],
1595
+ filter_query_: filter_query_
1535
1596
  } = _ref;
1536
1597
  const existing_filter = $b8hua$createMemo(() => {
1537
1598
  const {
@@ -1566,12 +1627,18 @@ function $133484ef10e4e954$export$dd948f91abc3a1c4(_ref) {
1566
1627
  const value = $af5d8e0b7d97a7f6$export$325f75597868c4f0(checkbox().value_);
1567
1628
  return !!(data !== null && data !== void 0 && data.some(item => $af5d8e0b7d97a7f6$export$325f75597868c4f0(item) === value));
1568
1629
  });
1630
+ const value = $b8hua$createMemo(() => checkbox().value_);
1569
1631
  return $b8hua$createComponent((0, $19e828709c7723a0$export$48513f6b9f8ce62d), {
1570
1632
  get value_() {
1571
- return checkbox().value_;
1633
+ return value();
1572
1634
  },
1573
1635
  get label_() {
1574
- return checkbox().name_;
1636
+ return $b8hua$createComponent((0, $02b6641aa50ce528$export$ba17c5b7e6dda39f), {
1637
+ get whole_text_to_display_() {
1638
+ return $b8hua$createMemo(() => checkbox().name_ || value());
1639
+ },
1640
+ searching_for_value_: () => filter_query_ === null || filter_query_ === void 0 ? void 0 : filter_query_()
1641
+ });
1575
1642
  },
1576
1643
  get count_() {
1577
1644
  return checkbox().count_;
@@ -1634,7 +1701,8 @@ const $b54fc842e721c9eb$var$_tmpl$ = ["<form", ' class="radios">', "</form>"],
1634
1701
  function $b54fc842e721c9eb$export$430444115f70a734(_ref) {
1635
1702
  let {
1636
1703
  selected_filters_: selected_filters_,
1637
- filter_: filter_
1704
+ filter_: filter_,
1705
+ filter_query_: filter_query_
1638
1706
  } = _ref;
1639
1707
  const radio_name = $b8hua$make_random_classname();
1640
1708
  const existing_filter = $b8hua$createMemo(() => {
@@ -1660,19 +1728,23 @@ function $b54fc842e721c9eb$export$430444115f70a734(_ref) {
1660
1728
  var _counts;
1661
1729
  return (_counts = filter_().meta.counts) === null || _counts === void 0 ? void 0 : _counts[index];
1662
1730
  });
1731
+ const label = $b8hua$createMemo(() => {
1732
+ var _filter_$meta, _filter_$meta$names;
1733
+ const name = (_filter_$meta = filter_().meta) === null || _filter_$meta === void 0 ? void 0 : (_filter_$meta$names = _filter_$meta.names) === null || _filter_$meta$names === void 0 ? void 0 : _filter_$meta$names[index];
1734
+ if (name) return name;
1735
+ const v = value();
1736
+ return Array.isArray(v) ? v.join(" - ") : v + "";
1737
+ });
1663
1738
  return $b8hua$ssr($b54fc842e721c9eb$var$_tmpl$3, $b8hua$ssrHydrationKey(), "input-row ".concat(count() === 0 ? "count-0" : ""), $b8hua$ssrAttribute("for", $b8hua$escape(random_selector, true), false), $b8hua$ssrAttribute("id", $b8hua$escape(random_selector, true), false) + $b8hua$ssrAttribute("name", $b8hua$escape(radio_name, true), false), $b8hua$ssrAttribute("checked", $b8hua$createMemo(() => {
1664
1739
  var _existing_filter;
1665
1740
  const v = value();
1666
1741
  const data = (_existing_filter = existing_filter()) === null || _existing_filter === void 0 ? void 0 : _existing_filter.data;
1667
1742
  if ($af5d8e0b7d97a7f6$export$325f75597868c4f0(data) === $af5d8e0b7d97a7f6$export$325f75597868c4f0(v)) return true;
1668
1743
  return Array.isArray(data) && data.every((item, index) => item === v[index]);
1669
- })(), true), $b8hua$escape($b8hua$createMemo(() => {
1670
- var _filter_$meta, _filter_$meta$names;
1671
- const name = (_filter_$meta = filter_().meta) === null || _filter_$meta === void 0 ? void 0 : (_filter_$meta$names = _filter_$meta.names) === null || _filter_$meta$names === void 0 ? void 0 : _filter_$meta$names[index];
1672
- if (name) return name;
1673
- const v = value();
1674
- return Array.isArray(v) ? v.join(" - ") : v;
1675
- })()), $b8hua$escape($b8hua$createComponent((0, $b8hua$Show), {
1744
+ })(), true), $b8hua$escape($b8hua$createComponent((0, $02b6641aa50ce528$export$ba17c5b7e6dda39f), {
1745
+ whole_text_to_display_: label,
1746
+ searching_for_value_: () => filter_query_ === null || filter_query_ === void 0 ? void 0 : filter_query_()
1747
+ })), $b8hua$escape($b8hua$createComponent((0, $b8hua$Show), {
1676
1748
  get when() {
1677
1749
  return count() != undefined;
1678
1750
  },
@@ -1690,7 +1762,8 @@ function $1e7465a8ffa97f6c$export$e0d834a0ad870cda(_ref) {
1690
1762
  let {
1691
1763
  filter_: filter_,
1692
1764
  selected_filters_: selected_filters_,
1693
- i18n_: i18n_
1765
+ i18n_: i18n_,
1766
+ filter_query_: filter_query_
1694
1767
  } = _ref;
1695
1768
  // 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
1696
1769
  // 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
@@ -1921,158 +1994,422 @@ function $457279ff15864cb9$export$e5c2828934226505(_ref) {
1921
1994
  });
1922
1995
  return outer_div;
1923
1996
  }
1924
- const $0ae614c5c7babb43$var$_tmpl$ = ["<form", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></form>"],
1925
- $0ae614c5c7babb43$var$_tmpl$2 = ["<div", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></div>"],
1926
- $0ae614c5c7babb43$var$_tmpl$3 = ["<details", "></details>"],
1927
- $0ae614c5c7babb43$var$_tmpl$4 = ["<summary", ' class="category-parent"><div class="summary"><span class="', '">', "</span><!--$-->", "<!--/--></div></summary>"];
1928
- const $0ae614c5c7babb43$var$max_visible_without_collapsing = 15;
1929
- const $0ae614c5c7babb43$var$show_non_collapsible_when_collapsed = 4;
1930
- function $0ae614c5c7babb43$export$a32086fa6616eafd(_ref) {
1997
+ const $f3a159279dc1a8fb$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"];
1998
+ const $f3a159279dc1a8fb$var$dont_cut_in_between_less_than_characters = 30;
1999
+ function $f3a159279dc1a8fb$export$e1a98a189fd2c0e7(_ref) {
1931
2000
  let {
1932
- filter_: filter_,
1933
- selected_filters_: selected_filters_,
1934
- i18n_: i18n_,
1935
- view_more_button_below_group_: view_more_button_below_group_,
1936
- expanded_hierarchical_filters_: expanded_hierarchical_filters_
2001
+ content_result_: content_result_,
2002
+ key_: key_,
2003
+ cut_when_possible_: cut_when_possible_
1937
2004
  } = _ref;
1938
- let form;
1939
- const existing_filter = $b8hua$createMemo(() => {
1940
- const {
1941
- field: field,
1942
- op: op
1943
- } = filter_();
1944
- return selected_filters_[0]().find(_ref2 => {
1945
- let {
1946
- field: checking_field,
1947
- op: checking_op
1948
- } = _ref2;
1949
- return checking_field === field && checking_op === op;
1950
- });
1951
- });
1952
- const show_extras = $b8hua$createSignal(false);
1953
- const trigger_sync_ = $0ae614c5c7babb43$var$batching_filter_state_syncer({
1954
- filter_: filter_,
1955
- existing_filter_: existing_filter,
1956
- selected_filters_: selected_filters_,
1957
- get category_structure_() {
1958
- return structured_categories();
1959
- }
1960
- });
1961
- const structured_categories = $b8hua$createMemo(() => {
1962
- const execute_when_structure_finished = [];
1963
- const {
1964
- values: values,
1965
- names: names,
1966
- counts: counts
1967
- } = filter_().meta;
1968
- const data_structure = {};
1969
- for (let i = 0; i < values.length; i++) {
1970
- const value = values[i];
1971
- let pointer = data_structure;
1972
- let parent_ = {};
1973
- let created_an_object = false;
1974
- for (let j = 0; j < value.length; j++) {
1975
- var _pointer;
1976
- const this_categories_name = value[j];
1977
- const obj = (_pointer = pointer)[this_categories_name] || (_pointer[this_categories_name] = (() => {
1978
- 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;
1979
- const created_obj = {
1980
- name_: names[i],
1981
- count_: counts === null || counts === void 0 ? void 0 : counts[i],
1982
- parent_: parent_,
1983
- is_expanded_: $0ae614c5c7babb43$var$make_expanded_signal({
1984
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
1985
- filter_value_: value_as_string
1986
- }),
1987
- value_: value_as_string,
1988
- children_: {}
1989
- };
1990
- const {
1991
- signal_: signal_,
1992
- on_structure_complete_: on_structure_complete_
1993
- } = $0ae614c5c7babb43$var$create_updating_signal({
1994
- self_: created_obj,
1995
- existing_filter_: $b8hua$untrack(existing_filter),
1996
- trigger_sync_: trigger_sync_
1997
- });
1998
- execute_when_structure_finished.push(on_structure_complete_);
1999
- created_obj.is_checked_ = signal_;
2000
- parent_ = created_obj;
2001
- created_an_object = true;
2002
- return created_obj;
2003
- })());
2004
- pointer = obj.children_;
2005
- parent_ = obj;
2006
- }
2007
- if (!created_an_object && "value_" in parent_) {
2008
- // 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
2009
- // [
2010
- // ["Öl", "IPA"],
2011
- // ["Öl", "Pale Ale"],
2012
- // ["Öl", "Ale"],
2013
- // ["Öl", "Mörk Lager"],
2014
- // ["Öl", "Suröl"],
2015
- // ["Öl", "Veteöl"],
2016
- // ["Öl", "Stout och Porter"],
2017
- // ["Öl"], // <- We are here, our `hierarchical_data_structure[string]`-object was created when we iterated over ["Öl", "IPA"]
2018
- // ["Öl", "Ljus Lager"],
2019
- // ];
2020
- // In this case we want to just correct the name and value of the already created object, which will be in parent_
2021
- parent_.value_ = value.map(v => v + "");
2022
- parent_.name_ = names[i];
2023
- parent_.count_ = counts[i];
2024
- parent_.is_expanded_ = $0ae614c5c7babb43$var$make_expanded_signal({
2025
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2026
- filter_value_: parent_.value_
2027
- });
2028
- }
2029
- }
2030
- while (execute_when_structure_finished.length) execute_when_structure_finished.pop()();
2031
- $0ae614c5c7babb43$var$expand_until_choice(data_structure);
2032
- $b8hua$dlog("CheckboxHierarchicalFilter: Recomputed structured_categories", data_structure);
2033
- return data_structure;
2005
+ const matched_tokens = $b8hua$createMemo(() => {
2006
+ var _content_result_$high, _content_result_$high2;
2007
+ return (_content_result_$high = content_result_().highlights) === null || _content_result_$high === void 0 ? void 0 : (_content_result_$high2 = _content_result_$high.find(highlight => highlight.field == key_)) === null || _content_result_$high2 === void 0 ? void 0 : _content_result_$high2.matched_tokens;
2034
2008
  });
2035
- const some_top_level_are_hidden = $b8hua$createMemo(() => Object.keys(structured_categories()).length > $0ae614c5c7babb43$var$max_visible_without_collapsing);
2036
- const {
2037
- expand: expand,
2038
- collapse: collapse,
2039
- ExpandingContainer: ExpandingContainer
2040
- } = $8e8b179489080711$export$5bad61ecde080b1f({
2041
- duration: 200
2009
+ const full_value = $b8hua$createMemo(() => {
2010
+ var _content_result_$key_;
2011
+ return (_content_result_$key_ = content_result_()[key_]) === null || _content_result_$key_ === void 0 ? void 0 : _content_result_$key_.replaceAll("\n", " ");
2042
2012
  });
2043
- const expanding_container_els = $b8hua$createComponent(ExpandingContainer, {
2013
+ return $b8hua$createComponent((0, $b8hua$Show), {
2014
+ get when() {
2015
+ var _matched_tokens;
2016
+ return (_matched_tokens = matched_tokens()) === null || _matched_tokens === void 0 ? void 0 : _matched_tokens.length;
2017
+ },
2018
+ get fallback() {
2019
+ return full_value();
2020
+ },
2044
2021
  get children() {
2045
- return $b8hua$createComponent((0, $b8hua$Show), {
2046
- get when() {
2047
- return some_top_level_are_hidden();
2048
- },
2049
- get children() {
2050
- return $0ae614c5c7babb43$var$render_stuff($b8hua$createMemo(() => Object.fromEntries(Object.entries(structured_categories()).slice($0ae614c5c7babb43$var$show_non_collapsible_when_collapsed))), existing_filter, i18n_);
2051
- }
2052
- });
2022
+ return (() => {
2023
+ const segmented_cut_text = $b8hua$createMemo(() => {
2024
+ const segmented_text = $f3a159279dc1a8fb$export$1b00d74faf266c56(full_value(), matched_tokens());
2025
+ if (cut_when_possible_) $f3a159279dc1a8fb$var$cut_text(segmented_text);
2026
+ return segmented_text;
2027
+ });
2028
+ return $b8hua$createComponent((0, $b8hua$Index), {
2029
+ get each() {
2030
+ return segmented_cut_text();
2031
+ },
2032
+ children: item => {
2033
+ return $b8hua$createComponent((0, $b8hua$Show), {
2034
+ get when() {
2035
+ return item().highlighted_;
2036
+ },
2037
+ get fallback() {
2038
+ return item().text_;
2039
+ },
2040
+ get children() {
2041
+ return $b8hua$ssr($f3a159279dc1a8fb$var$_tmpl$, $b8hua$ssrHydrationKey(), $b8hua$escape(item().text_));
2042
+ }
2043
+ });
2044
+ }
2045
+ });
2046
+ })();
2053
2047
  }
2054
2048
  });
2055
- $b8hua$createRenderEffect(() => {
2056
- view_more_button_below_group_[1](some_top_level_are_hidden() ? $b8hua$createComponent((0, $3e850b2f2cca761f$export$ca21a16d65b3dd8), {
2057
- show_extras_: show_extras,
2058
- i18n_: i18n_
2059
- }) : []);
2060
- });
2061
- $b8hua$createEffect($b8hua$catchify(async () => {
2062
- if (!some_top_level_are_hidden()) {
2063
- await collapse();
2064
- return;
2065
- }
2066
- if (show_extras[0]()) await expand();else await collapse();
2067
- }));
2068
- return $b8hua$ssr($0ae614c5c7babb43$var$_tmpl$, $b8hua$ssrHydrationKey(), "checkboxes hierarchical ".concat(Object.values(structured_categories()).some(category => Object.keys(category.children_).length) ? "any-expandable" : ""), $b8hua$escape($0ae614c5c7babb43$var$render_stuff($b8hua$createMemo(() => some_top_level_are_hidden() ? Object.fromEntries(Object.entries(structured_categories()).slice(0, $0ae614c5c7babb43$var$show_non_collapsible_when_collapsed)) : structured_categories()), existing_filter, i18n_)), $b8hua$escape(expanding_container_els));
2069
2049
  }
2070
- function $0ae614c5c7babb43$var$render_stuff(data, existing_filter, i18n_) {
2071
- const keys = $b8hua$createMemo(() => Object.keys(data()));
2072
- return $b8hua$createComponent((0, $b8hua$For), {
2073
- get each() {
2074
- return keys();
2075
- },
2050
+ function $f3a159279dc1a8fb$var$cut_text(segmented_text) {
2051
+ // cut away chunks of text that are not highlighted to give a google-like overview of the content
2052
+ const highlighted_segments = segmented_text === null || segmented_text === void 0 ? void 0 : segmented_text.filter(segment => segment.highlighted_);
2053
+ if (!segmented_text || !(highlighted_segments !== null && highlighted_segments !== void 0 && highlighted_segments.length)) return;
2054
+ // We have one or more highlighted segments
2055
+ if (highlighted_segments.length === 1) {
2056
+ // cut away from the left until the start of the highlighted sentence if just one sentence is highlighted
2057
+ $f3a159279dc1a8fb$var$cut_start(segmented_text.indexOf(highlighted_segments[0]), segmented_text);
2058
+ return;
2059
+ }
2060
+ // We have two or more highlighted segments, take the two biggest chunks and show them + a bit text around
2061
+ 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
2062
+ );
2063
+
2064
+ const [longest_segment, next_longest_segment] = sorted_highlighted_segments;
2065
+ // We need to cut before the first segment - possibly through other segments - and maybe between segments
2066
+ 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);
2067
+ $f3a159279dc1a8fb$var$cut_start(index_of_first_segment, segmented_text);
2068
+ // update indexes since we might have removed segments
2069
+ [index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
2070
+ let number_of_characters_between_segments = 0;
2071
+ for (let i = index_of_first_segment + 1; i < index_of_second_segment; i++) {
2072
+ const segment = segmented_text[i];
2073
+ number_of_characters_between_segments += segment.text_.length;
2074
+ }
2075
+ if (number_of_characters_between_segments < $f3a159279dc1a8fb$var$dont_cut_in_between_less_than_characters)
2076
+ // don't cut if there are less than 30 characters between the two segments
2077
+ return;
2078
+ // We have more than 50 characters between the two segments, cut between them
2079
+ const [split_start_segment, split_start_character] = $f3a159279dc1a8fb$var$find_split_point(index_of_first_segment, index_of_second_segment, segmented_text);
2080
+ const [split_end_segment, split_end_character] = $f3a159279dc1a8fb$var$find_split_point(index_of_second_segment, index_of_first_segment, segmented_text);
2081
+ if (split_start_segment === undefined || split_end_segment === undefined ||
2082
+ // identical split point, or split end before split start, can't do anything
2083
+ split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
2084
+ const dots_segment = {
2085
+ text_: " … ",
2086
+ highlighted_: false
2087
+ };
2088
+ const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
2089
+ if (i < split_start_segment || i > split_end_segment) return segment;
2090
+ const text = segment.text_;
2091
+ if (i == split_end_segment && i == split_start_segment) return [{
2092
+ ...segment,
2093
+ text_: text.slice(0, split_start_character).trimEnd()
2094
+ }, dots_segment, {
2095
+ ...segment,
2096
+ text_: text.slice(split_end_character + 1, text.length).trimStart()
2097
+ }];else if (i == split_start_segment) {
2098
+ 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
2099
+ return segment;
2100
+ } else if (i == split_end_segment) return [dots_segment, {
2101
+ ...segment,
2102
+ text_: text.slice(split_end_character + 1, text.length).trimStart()
2103
+ }];
2104
+ return []; // remove all segments inbetween
2105
+ });
2106
+
2107
+ segmented_text.splice(0, segmented_text.length, ...split_and_dotted_values); // Sorry…
2108
+ $f3a159279dc1a8fb$var$heal_holes(segmented_text);
2109
+ }
2110
+ function $f3a159279dc1a8fb$var$heal_holes(segmented_text) {
2111
+ // try to heal "holes" created in the segments so there are only alternating segments
2112
+ const segments_to_delete = new Set();
2113
+ for (let i = 0; i < segmented_text.length; i++) {
2114
+ var _previous_segment, _previous_segment2;
2115
+ const segment = segmented_text[i];
2116
+ let previous_segment;
2117
+ for (let j = i - 1; j >= 0; j--) {
2118
+ previous_segment = segmented_text[j];
2119
+ // Don't write to a segment that's marked for deletion or the contents we write to it will be deleted
2120
+ if (!segments_to_delete.has(previous_segment)) break;
2121
+ }
2122
+ if ((_previous_segment = previous_segment) !== null && _previous_segment !== void 0 && _previous_segment.highlighted_ && segment.highlighted_ || ((_previous_segment2 = previous_segment) === null || _previous_segment2 === void 0 ? void 0 : _previous_segment2.highlighted_) === false && segment.highlighted_ === false) {
2123
+ previous_segment.text_ += segment.text_; // IDK if this ever happens
2124
+ segments_to_delete.add(segment);
2125
+ }
2126
+ }
2127
+ for (const segment of segments_to_delete) {
2128
+ const index = segmented_text.indexOf(segment);
2129
+ segmented_text.splice(index, 1);
2130
+ }
2131
+ }
2132
+ function $f3a159279dc1a8fb$var$find_split_point(index_of_start_segment, index_of_end_segment, segmented_text) {
2133
+ let be_very_aggressive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
2134
+ const should_loop_backwards = index_of_start_segment > index_of_end_segment;
2135
+ const step = should_loop_backwards ? -1 : 1;
2136
+ const desperate_split_attempts = [":", ";", ","];
2137
+ while (desperate_split_attempts.length) {
2138
+ const split_point_between_words = [];
2139
+ // for the middle also try to split with a few more characters if the default ones don't work over a full run
2140
+ const desperate_split_attempt = desperate_split_attempts.pop();
2141
+ let is_first_character = true;
2142
+ for (let i = index_of_start_segment + step; should_loop_backwards ? i > index_of_end_segment : i < index_of_end_segment; i += step) {
2143
+ const segment = segmented_text[i];
2144
+ const text = segment.text_;
2145
+ for (let j = should_loop_backwards ? text.length - 1 : 0; should_loop_backwards ? j >= 0 : j < text.length; j += step) {
2146
+ const character = text[j];
2147
+ if (character == "." || character == "?" || character == "!" || character == desperate_split_attempt) return [i, j]; // segment index, character index
2148
+ if (is_first_character) is_first_character = false;else if (be_very_aggressive && character == " ") {
2149
+ split_point_between_words.push([i, j]);
2150
+ if (split_point_between_words.length > 3)
2151
+ // We can't find a split point, so we'll just split between words
2152
+ // 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
2153
+ return split_point_between_words[1];
2154
+ }
2155
+ }
2156
+ }
2157
+ }
2158
+ return [];
2159
+ }
2160
+ function $f3a159279dc1a8fb$var$cut_start(cut_left_of_index, segmented_text) {
2161
+ // Cut the start of the text to bring the first matching token
2162
+ let is_first_character = false;
2163
+ let words_encountered = 0;
2164
+ outmost_loop: for (let i = cut_left_of_index - 1; i >= 0; i--) {
2165
+ const segment = segmented_text[i];
2166
+ // We assume that two adjacent highlighted segments don't exist and have been merged if they were to have existed
2167
+ const text = segment.text_;
2168
+ for (let j = text.length - 1; j >= 0; j--) {
2169
+ const character = text[j];
2170
+ const is_space = character == " ";
2171
+ if (!is_first_character && is_space) words_encountered++;
2172
+ if (character == "." || character == "?" || character == "!" || character == "," || words_encountered > 8 && is_space) {
2173
+ // We have to be really aggressive at the start of sentences so stuff can be seen on mobile, hence comma
2174
+ segment.text_ = text.slice(j + 1).trimStart();
2175
+ segmented_text.splice(0, i);
2176
+ if (character === "," || is_space)
2177
+ // if we cut at a comma or psace, we add a … at the beginning
2178
+ segmented_text.unshift({
2179
+ text_: "… ",
2180
+ highlighted_: false
2181
+ });
2182
+ break outmost_loop;
2183
+ }
2184
+ if (is_first_character) is_first_character = false;
2185
+ }
2186
+ }
2187
+ $f3a159279dc1a8fb$var$heal_holes(segmented_text); // if we added a ... there could now be a sequence that's not alternating true/false
2188
+ }
2189
+
2190
+ function $f3a159279dc1a8fb$export$1b00d74faf266c56(text, matched_strings) {
2191
+ let loose = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
2192
+ const output = [];
2193
+ if (!text) return; // shouldn't happen but whatever
2194
+ for (let i = 0; i < text.length; i++) {
2195
+ const found_strings = [];
2196
+ if (!i || text[i - 1] == " " || loose)
2197
+ // only match at the start of a word or string, it looks weird if i.e. "we" is highlighted in "activewear
2198
+ for (let j = 0; j < matched_strings.length; j++) {
2199
+ const matched_string = matched_strings[j];
2200
+ const part_in_text = text.slice(i, i + matched_string.length);
2201
+ if (matched_string.length < 2 && !loose) continue; // don't match on single characters, i.e. "I", it looks weird
2202
+ 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
2203
+ }
2204
+
2205
+ const last_index_in_output = output.length - 1;
2206
+ if (!found_strings.length) {
2207
+ var _output$last_index_in;
2208
+ const character = text[i];
2209
+ if (((_output$last_index_in = output[last_index_in_output]) === null || _output$last_index_in === void 0 ? void 0 : _output$last_index_in.highlighted_) === false || output.length && /\s/.test(character))
2210
+ // 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
2211
+ output[last_index_in_output].text_ += character;else output.push({
2212
+ highlighted_: false,
2213
+ text_: character
2214
+ });
2215
+ } else {
2216
+ var _output$last_index_in2;
2217
+ const longest_found_string = found_strings.reduce((a, b) => a.length > b.length ? a : b);
2218
+ if ((_output$last_index_in2 = output[last_index_in_output]) !== null && _output$last_index_in2 !== void 0 && _output$last_index_in2.highlighted_) output[last_index_in_output].text_ += longest_found_string;else output.push({
2219
+ highlighted_: true,
2220
+ text_: longest_found_string
2221
+ });
2222
+ i += longest_found_string.length - 1;
2223
+ }
2224
+ }
2225
+ return output;
2226
+ }
2227
+ const $b0e2100b511ec9a4$var$_tmpl$ = ["<span", ' class="', '">', "</span>"],
2228
+ $b0e2100b511ec9a4$var$_tmpl$2 = ["<span", ' class="highlighted-part">', "</span>"];
2229
+ function $b0e2100b511ec9a4$export$8e79c28529dbfa90(props) {
2230
+ const segmented_text = $b8hua$createMemo(() => {
2231
+ const {
2232
+ to_highlight_: to_highlight_,
2233
+ text_: text_
2234
+ } = props;
2235
+ return $f3a159279dc1a8fb$export$1b00d74faf266c56(text_, to_highlight_ ? [to_highlight_] : [], true);
2236
+ });
2237
+ const has_highlights = $b8hua$createMemo(() => segmented_text().some(segment => segment.highlighted_));
2238
+ return $b8hua$ssr($b0e2100b511ec9a4$var$_tmpl$, $b8hua$ssrHydrationKey() + $b8hua$ssrAttribute("title", $b8hua$escape(props.text_, true), false), has_highlights() ? "has-match" : "", $b8hua$escape($b8hua$createComponent((0, $b8hua$Index), {
2239
+ get each() {
2240
+ return segmented_text();
2241
+ },
2242
+ children: item => {
2243
+ return $b8hua$createComponent((0, $b8hua$Show), {
2244
+ get when() {
2245
+ return item().highlighted_;
2246
+ },
2247
+ get fallback() {
2248
+ return item().text_;
2249
+ },
2250
+ get children() {
2251
+ return $b8hua$ssr($b0e2100b511ec9a4$var$_tmpl$2, $b8hua$ssrHydrationKey(), $b8hua$escape(item().text_));
2252
+ }
2253
+ });
2254
+ }
2255
+ })));
2256
+ }
2257
+ const $0ae614c5c7babb43$var$_tmpl$ = ["<form", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></form>"],
2258
+ $0ae614c5c7babb43$var$_tmpl$2 = ["<div", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></div>"],
2259
+ $0ae614c5c7babb43$var$_tmpl$3 = ["<details", "></details>"],
2260
+ $0ae614c5c7babb43$var$_tmpl$4 = ["<summary", ' class="category-parent"><div class="summary"><span class="', '">', "</span><!--$-->", "<!--/--></div></summary>"];
2261
+ const $0ae614c5c7babb43$var$max_visible_without_collapsing = 15;
2262
+ const $0ae614c5c7babb43$var$show_non_collapsible_when_collapsed = 4;
2263
+ function $0ae614c5c7babb43$export$a32086fa6616eafd(_ref) {
2264
+ let {
2265
+ filter_: filter_,
2266
+ selected_filters_: selected_filters_,
2267
+ i18n_: i18n_,
2268
+ view_more_button_below_group_: view_more_button_below_group_,
2269
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2270
+ filter_query_: filter_query_
2271
+ } = _ref;
2272
+ let form;
2273
+ const existing_filter = $b8hua$createMemo(() => {
2274
+ const {
2275
+ field: field,
2276
+ op: op
2277
+ } = filter_();
2278
+ return selected_filters_[0]().find(_ref2 => {
2279
+ let {
2280
+ field: checking_field,
2281
+ op: checking_op
2282
+ } = _ref2;
2283
+ return checking_field === field && checking_op === op;
2284
+ });
2285
+ });
2286
+ const show_extras = $b8hua$createSignal(false);
2287
+ const is_being_searched_ = $b8hua$createMemo(() => !!(filter_query_ !== null && filter_query_ !== void 0 && filter_query_())); // If the user is searching in the filter
2288
+ const trigger_sync_ = $0ae614c5c7babb43$var$batching_filter_state_syncer({
2289
+ filter_: filter_,
2290
+ existing_filter_: existing_filter,
2291
+ selected_filters_: selected_filters_,
2292
+ get category_structure_() {
2293
+ return structured_categories();
2294
+ }
2295
+ });
2296
+ const structured_categories = $b8hua$createMemo(() => {
2297
+ const execute_when_structure_finished = [];
2298
+ const {
2299
+ values: values,
2300
+ names: names,
2301
+ counts: counts
2302
+ } = filter_().meta;
2303
+ const data_structure = {};
2304
+ for (let i = 0; i < values.length; i++) {
2305
+ const value = values[i];
2306
+ let pointer = data_structure;
2307
+ let parent_ = {};
2308
+ let created_an_object = false;
2309
+ for (let j = 0; j < value.length; j++) {
2310
+ var _pointer;
2311
+ const this_categories_name = value[j];
2312
+ const obj = (_pointer = pointer)[this_categories_name] || (_pointer[this_categories_name] = (() => {
2313
+ 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;
2314
+ const created_obj = {
2315
+ name_: names[i],
2316
+ count_: counts === null || counts === void 0 ? void 0 : counts[i],
2317
+ parent_: parent_,
2318
+ is_expanded_: $0ae614c5c7babb43$var$make_expanded_signal({
2319
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2320
+ filter_value_: value_as_string,
2321
+ is_being_searched_: is_being_searched_
2322
+ }),
2323
+ value_: value_as_string,
2324
+ children_: {}
2325
+ };
2326
+ const {
2327
+ signal_: signal_,
2328
+ on_structure_complete_: on_structure_complete_
2329
+ } = $0ae614c5c7babb43$var$create_updating_signal({
2330
+ self_: created_obj,
2331
+ existing_filter_: $b8hua$untrack(existing_filter),
2332
+ trigger_sync_: trigger_sync_
2333
+ });
2334
+ execute_when_structure_finished.push(on_structure_complete_);
2335
+ created_obj.is_checked_ = signal_;
2336
+ parent_ = created_obj;
2337
+ created_an_object = true;
2338
+ return created_obj;
2339
+ })());
2340
+ pointer = obj.children_;
2341
+ parent_ = obj;
2342
+ }
2343
+ if (!created_an_object && "value_" in parent_) {
2344
+ // 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
2345
+ // [
2346
+ // ["Öl", "IPA"],
2347
+ // ["Öl", "Pale Ale"],
2348
+ // ["Öl", "Ale"],
2349
+ // ["Öl", "Mörk Lager"],
2350
+ // ["Öl", "Suröl"],
2351
+ // ["Öl", "Veteöl"],
2352
+ // ["Öl", "Stout och Porter"],
2353
+ // ["Öl"], // <- We are here, our `hierarchical_data_structure[string]`-object was created when we iterated over ["Öl", "IPA"]
2354
+ // ["Öl", "Ljus Lager"],
2355
+ // ];
2356
+ // In this case we want to just correct the name and value of the already created object, which will be in parent_
2357
+ parent_.value_ = value.map(v => v + "");
2358
+ parent_.name_ = names[i];
2359
+ parent_.count_ = counts[i];
2360
+ parent_.is_expanded_ = $0ae614c5c7babb43$var$make_expanded_signal({
2361
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2362
+ filter_value_: parent_.value_,
2363
+ is_being_searched_: is_being_searched_
2364
+ });
2365
+ }
2366
+ }
2367
+ while (execute_when_structure_finished.length) execute_when_structure_finished.pop()();
2368
+ $0ae614c5c7babb43$var$expand_until_choice(data_structure);
2369
+ $b8hua$dlog("CheckboxHierarchicalFilter: Recomputed structured_categories", data_structure);
2370
+ return data_structure;
2371
+ });
2372
+ const some_top_level_are_hidden = $b8hua$createMemo(() => Object.keys(structured_categories()).length > $0ae614c5c7babb43$var$max_visible_without_collapsing);
2373
+ const {
2374
+ expand: expand,
2375
+ collapse: collapse,
2376
+ ExpandingContainer: ExpandingContainer
2377
+ } = $8e8b179489080711$export$5bad61ecde080b1f({
2378
+ duration: 200
2379
+ });
2380
+ const expanding_container_els = $b8hua$createComponent(ExpandingContainer, {
2381
+ get children() {
2382
+ return $b8hua$createComponent((0, $b8hua$Show), {
2383
+ get when() {
2384
+ return some_top_level_are_hidden();
2385
+ },
2386
+ get children() {
2387
+ return $0ae614c5c7babb43$var$render_stuff($b8hua$createMemo(() => Object.fromEntries(Object.entries(structured_categories()).slice($0ae614c5c7babb43$var$show_non_collapsible_when_collapsed))), existing_filter, i18n_, filter_query_);
2388
+ }
2389
+ });
2390
+ }
2391
+ });
2392
+ $b8hua$createRenderEffect(() => {
2393
+ view_more_button_below_group_[1](some_top_level_are_hidden() ? $b8hua$createComponent((0, $3e850b2f2cca761f$export$ca21a16d65b3dd8), {
2394
+ show_extras_: show_extras,
2395
+ i18n_: i18n_
2396
+ }) : []);
2397
+ });
2398
+ $b8hua$createEffect($b8hua$catchify(async () => {
2399
+ if (!some_top_level_are_hidden()) {
2400
+ await collapse();
2401
+ return;
2402
+ }
2403
+ if (show_extras[0]()) await expand();else await collapse();
2404
+ }));
2405
+ return $b8hua$ssr($0ae614c5c7babb43$var$_tmpl$, $b8hua$ssrHydrationKey(), "checkboxes hierarchical ".concat(Object.values(structured_categories()).some(category => Object.keys(category.children_).length) ? "any-expandable" : ""), $b8hua$escape($0ae614c5c7babb43$var$render_stuff($b8hua$createMemo(() => some_top_level_are_hidden() ? Object.fromEntries(Object.entries(structured_categories()).slice(0, $0ae614c5c7babb43$var$show_non_collapsible_when_collapsed)) : structured_categories()), existing_filter, i18n_, filter_query_)), $b8hua$escape(expanding_container_els));
2406
+ }
2407
+ function $0ae614c5c7babb43$var$render_stuff(data, existing_filter, i18n_, filter_query_) {
2408
+ const keys = $b8hua$createMemo(() => Object.keys(data()));
2409
+ return $b8hua$createComponent((0, $b8hua$For), {
2410
+ get each() {
2411
+ return keys();
2412
+ },
2076
2413
  children: key => $b8hua$createComponent((0, $b8hua$Show), {
2077
2414
  get when() {
2078
2415
  return $b8hua$createMemo(() => !!data()[key])();
@@ -2085,14 +2422,27 @@ function $0ae614c5c7babb43$var$render_stuff(data, existing_filter, i18n_) {
2085
2422
  var _value;
2086
2423
  return !!Object.keys(((_value = value()) === null || _value === void 0 ? void 0 : _value.children_) || {}).length;
2087
2424
  });
2425
+ const value_as_string = $b8hua$createMemo(() => {
2426
+ var _value2;
2427
+ return JSON.stringify((_value2 = value()) === null || _value2 === void 0 ? void 0 : _value2.value_);
2428
+ });
2429
+ const label_text = $b8hua$createMemo(() => {
2430
+ var _value3;
2431
+ return ((_value3 = value()) === null || _value3 === void 0 ? void 0 : _value3.name_) || value_as_string();
2432
+ });
2088
2433
  return $b8hua$ssr($0ae614c5c7babb43$var$_tmpl$2, $b8hua$ssrHydrationKey(), "checkbox-details ".concat(has_expandable() ? "expandable" : ""), $b8hua$escape($b8hua$createComponent((0, $19e828709c7723a0$export$48513f6b9f8ce62d), {
2089
2434
  get value_() {
2090
- var _value2;
2091
- return JSON.stringify((_value2 = value()) === null || _value2 === void 0 ? void 0 : _value2.value_);
2435
+ return value_as_string();
2092
2436
  },
2093
2437
  get label_() {
2094
- var _value3;
2095
- return (_value3 = value()) === null || _value3 === void 0 ? void 0 : _value3.name_;
2438
+ return $b8hua$createComponent((0, $b0e2100b511ec9a4$export$8e79c28529dbfa90), {
2439
+ get text_() {
2440
+ return label_text();
2441
+ },
2442
+ get to_highlight_() {
2443
+ return filter_query_ === null || filter_query_ === void 0 ? void 0 : filter_query_();
2444
+ }
2445
+ });
2096
2446
  },
2097
2447
  get count_() {
2098
2448
  var _value4;
@@ -2176,7 +2526,7 @@ function $0ae614c5c7babb43$var$render_stuff(data, existing_filter, i18n_) {
2176
2526
  return $0ae614c5c7babb43$var$render_stuff($b8hua$createMemo(() => {
2177
2527
  var _value13;
2178
2528
  return ((_value13 = value()) === null || _value13 === void 0 ? void 0 : _value13.children_) || {};
2179
- }), existing_filter, i18n_);
2529
+ }), existing_filter, i18n_, filter_query_);
2180
2530
  }
2181
2531
  });
2182
2532
  })();
@@ -2291,7 +2641,8 @@ function $0ae614c5c7babb43$var$make_expanded_signal(_ref5) {
2291
2641
  var _untrack$untrack;
2292
2642
  let {
2293
2643
  expanded_hierarchical_filters_: [read_expanded_hierarchical_filters, write_expanded_hierarchical_filters],
2294
- filter_value_: filter_value_
2644
+ filter_value_: filter_value_,
2645
+ is_being_searched_: is_being_searched_
2295
2646
  } = _ref5;
2296
2647
  const index_in_expanded_filters = $b8hua$createMemo(() => read_expanded_hierarchical_filters().findIndex(_ref6 => {
2297
2648
  let {
@@ -2334,9 +2685,11 @@ function $0ae614c5c7babb43$var$make_expanded_signal(_ref5) {
2334
2685
  defer: true
2335
2686
  }));
2336
2687
  return {
2337
- ui_should_show_expanded_: $b8hua$createMemo(() => {
2688
+ ui_should_show_expanded_: $b8hua$createMemo(
2689
+ // When user is searching through filters, expand everything they haven't collapsed, so they can see the results
2690
+ () => {
2338
2691
  var _user_choice_signal$;
2339
- return (_user_choice_signal$ = user_choice_signal[0]()) !== null && _user_choice_signal$ !== void 0 ? _user_choice_signal$ : get_low_precedence_expanded();
2692
+ return (_user_choice_signal$ = user_choice_signal[0]()) !== null && _user_choice_signal$ !== void 0 ? _user_choice_signal$ : is_being_searched_() || get_low_precedence_expanded();
2340
2693
  }),
2341
2694
  set_low_precedence_expanded_: set_low_precedence_expanded,
2342
2695
  set_user_expanded_: set_user_choice_expanded
@@ -2366,7 +2719,9 @@ const $830ea8efda59884e$var$max_columns = 3;
2366
2719
  const $830ea8efda59884e$export$414f6a19d38e655c = _ref => {
2367
2720
  let {
2368
2721
  filter_: filter_,
2369
- selected_filters_: [get_selected_filters, set_selected_filters]
2722
+ selected_filters_: [get_selected_filters, set_selected_filters],
2723
+ filter_query_: filter_query_,
2724
+ details_element_width_: details_element_width_
2370
2725
  } = _ref;
2371
2726
  const existing_filter = $b8hua$createMemo(() => {
2372
2727
  const {
@@ -2400,7 +2755,7 @@ const $830ea8efda59884e$export$414f6a19d38e655c = _ref => {
2400
2755
  const container_width_accessor = $b8hua$createMemo(() => {
2401
2756
  const element = container();
2402
2757
  if (!element) return;
2403
- return $0dc044cffe1e825b$export$9f191182275e9ef(element);
2758
+ return $fc830a7ee59416ef$export$ebdc3711f7e02ccd(element);
2404
2759
  });
2405
2760
  const [shadow_children, set_shadow_children] = $b8hua$createSignal(new Set(), {
2406
2761
  equals: false
@@ -2408,11 +2763,11 @@ const $830ea8efda59884e$export$414f6a19d38e655c = _ref => {
2408
2763
  const shadow_grid = $b8hua$ssr($830ea8efda59884e$var$_tmpl$, $b8hua$ssrHydrationKey(), $b8hua$escape([...shadow_children()])); // for getting the smallest possible sizes of all the items
2409
2764
  $b8hua$createEffect(() => {
2410
2765
  var _container_width_acce;
2411
- const container_width = (_container_width_acce = container_width_accessor()) === null || _container_width_acce === void 0 ? void 0 : _container_width_acce();
2412
- if (container_width == undefined) return;
2766
+ const container_width = ((_container_width_acce = container_width_accessor()) === null || _container_width_acce === void 0 ? void 0 : _container_width_acce()) || details_element_width_();
2767
+ 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
2413
2768
  $830ea8efda59884e$var$adjust_sizes(container_width, sizes_set(), set_cols_at_size);
2414
2769
  });
2415
- return [shadow_grid, $b8hua$createComponent((0, $63f1f8dbcd07d3b0$export$d21e32dfedac04be), {
2770
+ return [$b8hua$createComponent((0, $63f1f8dbcd07d3b0$export$d21e32dfedac04be), {
2416
2771
  get cols_at_size() {
2417
2772
  return cols_at_size();
2418
2773
  },
@@ -2435,27 +2790,33 @@ const $830ea8efda59884e$export$414f6a19d38e655c = _ref => {
2435
2790
  const current_value = $af5d8e0b7d97a7f6$export$325f75597868c4f0(value().value_);
2436
2791
  return !!(data !== null && data !== void 0 && data.some(item => $af5d8e0b7d97a7f6$export$325f75597868c4f0(item) === current_value));
2437
2792
  });
2438
- const MakeButton = attributes => $b8hua$ssrElement("button", $b8hua$mergeProps1(attributes, {
2439
- get disabled() {
2440
- return value().count_ === 0 && !is_selected();
2441
- },
2442
- get classList() {
2443
- return {
2444
- minor: !is_selected(),
2445
- major: is_selected(),
2446
- "major-minor-transition": true
2447
- };
2448
- }
2449
- }), () => ["<!--$-->", $b8hua$escape(value().value_), "<!--/-->", "<!--$-->", $b8hua$escape($b8hua$createComponent((0, $b8hua$Show), {
2450
- get when() {
2451
- return value().count_ != undefined;
2452
- },
2453
- get children() {
2454
- return $b8hua$ssr($830ea8efda59884e$var$_tmpl$2, $b8hua$ssrHydrationKey(), $b8hua$escape(value().count_));
2455
- }
2456
- })), "<!--/-->"], true);
2793
+ const MakeButton = attributes => {
2794
+ const label = $b8hua$createMemo(() => value().name_ || value().value_ + "");
2795
+ return $b8hua$ssrElement("button", $b8hua$mergeProps1(attributes, {
2796
+ get disabled() {
2797
+ return value().count_ === 0 && !is_selected();
2798
+ },
2799
+ get classList() {
2800
+ return {
2801
+ minor: !is_selected(),
2802
+ major: is_selected(),
2803
+ "major-minor-transition": true
2804
+ };
2805
+ }
2806
+ }), () => ["<!--$-->", $b8hua$escape($b8hua$createComponent((0, $02b6641aa50ce528$export$ba17c5b7e6dda39f), {
2807
+ whole_text_to_display_: label,
2808
+ searching_for_value_: () => filter_query_ === null || filter_query_ === void 0 ? void 0 : filter_query_()
2809
+ })), "<!--/-->", "<!--$-->", $b8hua$escape($b8hua$createComponent((0, $b8hua$Show), {
2810
+ get when() {
2811
+ return value().count_ != undefined;
2812
+ },
2813
+ get children() {
2814
+ return $b8hua$ssr($830ea8efda59884e$var$_tmpl$2, $b8hua$ssrHydrationKey(), $b8hua$escape(value().count_));
2815
+ }
2816
+ })), "<!--/-->"], true);
2817
+ };
2457
2818
  const invisible_size_button = $b8hua$createComponent(MakeButton, {});
2458
- const smallest_possible_size = $0dc044cffe1e825b$export$9f191182275e9ef(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
2819
+ const smallest_possible_size = $fc830a7ee59416ef$export$ebdc3711f7e02ccd(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
2459
2820
  const sizes_value = $b8hua$untrack(sizes_set);
2460
2821
  const shadow_children_value = $b8hua$untrack(shadow_children);
2461
2822
  sizes_value.add(smallest_possible_size);
@@ -2475,7 +2836,7 @@ const $830ea8efda59884e$export$414f6a19d38e655c = _ref => {
2475
2836
  }
2476
2837
  });
2477
2838
  }
2478
- })];
2839
+ }), shadow_grid];
2479
2840
  };
2480
2841
  /**
2481
2842
  * Calculate and apply cols_at_size overrides to fit as many items as possible in a row, evenly spaced
@@ -2543,7 +2904,8 @@ function $2cb856c297c53e6c$export$82ed4b28ecb67608(_ref) {
2543
2904
  filter_: filter_,
2544
2905
  selected_filters_: [get_selected_filters, set_selected_filters],
2545
2906
  i18n_: i18n_,
2546
- view_more_button_below_group_: [_get_view_more_button_below_group_, set_view_more_button_below_group_]
2907
+ view_more_button_below_group_: [_get_view_more_button_below_group_, set_view_more_button_below_group_],
2908
+ filter_query_: filter_query_
2547
2909
  } = _ref;
2548
2910
  // same as in CheckboxFilter, maybe we should make this DRY at some point
2549
2911
  const existing_filter = $b8hua$createMemo(() => {
@@ -2588,12 +2950,17 @@ function $2cb856c297c53e6c$export$82ed4b28ecb67608(_ref) {
2588
2950
  const value = $af5d8e0b7d97a7f6$export$325f75597868c4f0(checkbox().value_);
2589
2951
  return !!(data !== null && data !== void 0 && data.some(item => $af5d8e0b7d97a7f6$export$325f75597868c4f0(item) === value));
2590
2952
  });
2953
+ const value = $b8hua$createMemo(() => checkbox().value_);
2954
+ const label_text = $b8hua$createMemo(() => checkbox().name_ || value() + "");
2591
2955
  const input_row = $b8hua$createComponent((0, $19e828709c7723a0$export$48513f6b9f8ce62d), {
2592
2956
  get value_() {
2593
- return checkbox().value_;
2957
+ return value();
2594
2958
  },
2595
2959
  get label_() {
2596
- return checkbox().name_;
2960
+ return $b8hua$createComponent((0, $02b6641aa50ce528$export$ba17c5b7e6dda39f), {
2961
+ whole_text_to_display_: label_text,
2962
+ searching_for_value_: () => filter_query_ === null || filter_query_ === void 0 ? void 0 : filter_query_()
2963
+ });
2597
2964
  },
2598
2965
  get count_() {
2599
2966
  return checkbox().count_;
@@ -2851,10 +3218,152 @@ function $ceafb6fb91c6f394$export$89c6019e4baa40b1(props) {
2851
3218
  }
2852
3219
  });
2853
3220
  }
3221
+ const $ef0f18a578b32578$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>';
3222
+ function $ef0f18a578b32578$export$82eafebb825fc23f() {
3223
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3224
+ return $b8hua$ssrElement("svg", $b8hua$mergeProps1({
3225
+ xmlns: "http://www.w3.org/2000/svg",
3226
+ width: "20",
3227
+ height: "22",
3228
+ viewBox: "0 0 20 22"
3229
+ }, props), () => $b8hua$ssr($ef0f18a578b32578$var$_tmpl$), true);
3230
+ }
3231
+ const $e354b2f9ce33cb75$var$_tmpl$ = ["<div", ' class="search-in-filters"><input type="text" class="query"', "><!--$-->", '<!--/--><button style="', '" class="clear">', "</button></div>"];
3232
+ const $e354b2f9ce33cb75$var$min_items_to_enable_filter_searching = 10; // For checkbox hierarchical we 2x this
3233
+ function $e354b2f9ce33cb75$export$4b2c5292ffe0c5dd(filter_array_, section, i18n_) {
3234
+ const [filter_query_, set_filter_query_] = $b8hua$createSignal();
3235
+ // Check if we have enough items to enable searching
3236
+ const enable_searchability = $b8hua$createMemo(() => {
3237
+ let count = 0;
3238
+ for (const filter of filter_array_()) {
3239
+ var _filter$meta;
3240
+ const type = (_filter$meta = filter.meta) === null || _filter$meta === void 0 ? void 0 : _filter$meta.type;
3241
+ if (type === "range") continue;
3242
+ const length = filter.meta.values.length;
3243
+ 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
3244
+ }
3245
+
3246
+ return count >= $e354b2f9ce33cb75$var$min_items_to_enable_filter_searching;
3247
+ });
3248
+ const SearchThisFilterGroup_ = () => {
3249
+ return $b8hua$createComponent((0, $b8hua$Show), {
3250
+ get when() {
3251
+ return enable_searchability();
3252
+ },
3253
+ get children() {
3254
+ return $b8hua$ssr($e354b2f9ce33cb75$var$_tmpl$, $b8hua$ssrHydrationKey(), $b8hua$ssrAttribute("value", $b8hua$escape(filter_query_(), true) || "", false) + $b8hua$ssrAttribute("placeholder", $b8hua$escape(i18n_.search_a_filter_()(section), true), false), $b8hua$escape($b8hua$createComponent((0, $ef0f18a578b32578$export$82eafebb825fc23f), {
3255
+ width: "16",
3256
+ height: "17.6",
3257
+ "class": "search-icon"
3258
+ })), "display:" + (filter_query_() ? "" : "none"), $b8hua$escape($b8hua$createComponent((0, $9783d437ad61594c$export$3b621d86b1566b2), {
3259
+ width: "12",
3260
+ height: "12"
3261
+ })));
3262
+ }
3263
+ });
3264
+ };
3265
+ const searched_filter_array_ = $b8hua$createMemo(() => {
3266
+ const query = filter_query_();
3267
+ if (!enable_searchability() || !query) return filter_array_();
3268
+ const lowercase_query = query.toLowerCase();
3269
+ const check_string_match = to_check => {
3270
+ to_check = to_check.toLowerCase();
3271
+ return to_check.includes(lowercase_query) || lowercase_query.includes(to_check);
3272
+ };
3273
+ return filter_array_().map(filter => {
3274
+ var _filter$meta2, _meta$names;
3275
+ const type = (_filter$meta2 = filter.meta) === null || _filter$meta2 === void 0 ? void 0 : _filter$meta2.type;
3276
+ 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
3277
+ const meta = filter.meta;
3278
+ const {
3279
+ values: values,
3280
+ names: names,
3281
+ counts: counts
3282
+ } = meta;
3283
+ 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
3284
+ const is_hierarchical_checkbox = type === "checkbox-hierarchical";
3285
+ // Which index of counts, values and names should be kept
3286
+ const filtered_indexes = values.map((item, index) => {
3287
+ const item_from_names = names === null || names === void 0 ? void 0 : names[index];
3288
+ if (item_from_names && !is_hierarchical_checkbox)
3289
+ // 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
3290
+ item = item_from_names;
3291
+ if (typeof item === "number") return true;
3292
+ if (is_hierarchical_checkbox && names)
3293
+ // Special case for hierarchical checkboxes where we need to check if any of the names in the path match the query
3294
+ item = item.map((_, index) => names[$e354b2f9ce33cb75$var$find_str_arr_in_str_arr_arr("findIndex", values, item.slice(0, index + 1))]);
3295
+ if (Array.isArray(item)) return item.some(item => check_string_match(item + "")); // If any of the items in the array match, keep it
3296
+ return check_string_match(item);
3297
+ });
3298
+ const new_values = values.filter((_, i) => filtered_indexes[i]);
3299
+ if (!new_values.length) return false; // false = please delete this filter, see below
3300
+ const new_filter_object = {
3301
+ ...filter,
3302
+ meta: {
3303
+ ...meta,
3304
+ counts: counts === null || counts === void 0 ? void 0 : counts.filter((_, i) => filtered_indexes[i]),
3305
+ ...(names ? {
3306
+ names: (_meta$names = meta.names) === null || _meta$names === void 0 ? void 0 : _meta$names.filter((_, i) => filtered_indexes[i])
3307
+ } : {}),
3308
+ values: new_values
3309
+ }
3310
+ };
3311
+ if (is_hierarchical_checkbox) {
3312
+ // For hierarchical checkbox we need to fill the holes created by filtering, for example if there is
3313
+ // ["Clothes"]
3314
+ // ["Clothes", "Blazers"]
3315
+ // And the user searched for "blazers" we need to add back ["Clothes"] so CheckboxHierarchicalFilter doesn't get confused
3316
+ // 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
3317
+ // So we do it here instead
3318
+ const new_meta = new_filter_object.meta;
3319
+ const new_values = new_meta.values;
3320
+ for (const value of new_values) {
3321
+ if (!Array.isArray(value)) continue; // Shouldn't happen
3322
+ if (value.length < 2) continue; // No parent
3323
+ const parent = value.slice(0, -1);
3324
+ // Check if parent exists
3325
+ if ($e354b2f9ce33cb75$var$find_str_arr_in_str_arr_arr("some", new_values, parent)) continue; // Parent exists
3326
+ // Otherwise, put it back
3327
+ const index_to_restore = $e354b2f9ce33cb75$var$find_str_arr_in_str_arr_arr("findIndex", values, parent);
3328
+ if (index_to_restore < 0) {
3329
+ $b8hua$dwarn("Can't restore", parent, "to", new_values);
3330
+ continue;
3331
+ }
3332
+ const current_index_of_us = new_values.findIndex(item => item === value);
3333
+ new_values.splice(current_index_of_us, 0, values[index_to_restore]);
3334
+ const count_to_restore = counts === null || counts === void 0 ? void 0 : counts[index_to_restore];
3335
+ if (count_to_restore) {
3336
+ var _new_meta$counts;
3337
+ (_new_meta$counts = new_meta.counts) === null || _new_meta$counts === void 0 || _new_meta$counts.splice(current_index_of_us, 0, count_to_restore);
3338
+ }
3339
+ const name_to_restore = names === null || names === void 0 ? void 0 : names[index_to_restore];
3340
+ if (name_to_restore) {
3341
+ var _new_meta$names;
3342
+ (_new_meta$names = new_meta.names) === null || _new_meta$names === void 0 || _new_meta$names.splice(current_index_of_us, 0, name_to_restore);
3343
+ }
3344
+ }
3345
+ }
3346
+ return new_filter_object;
3347
+ }).filter(filter => filter); // Delete filters that don't have a value anymore
3348
+ });
3349
+
3350
+ return {
3351
+ SearchThisFilterGroup_: SearchThisFilterGroup_,
3352
+ searched_filter_array_: searched_filter_array_,
3353
+ filter_query_: filter_query_
3354
+ };
3355
+ }
3356
+ /**
3357
+ * Finds/whatevers what's effectively one hierarchical filter item in an array of hierarchical filter items
3358
+ * Functions similar to this happen loads in create_modified_filters, but they have additional checks so not touching them RN
3359
+ */
3360
+ function $e354b2f9ce33cb75$var$find_str_arr_in_str_arr_arr(operation, haystack, needle) {
3361
+ return haystack[operation](value => value.length === needle.length && value.every((item, index) => item === needle[index]));
3362
+ }
2854
3363
  const $f6b0500577e1b210$var$_tmpl$ = ["<div", ' class="filter-collapsible">', "</div>"],
2855
3364
  $f6b0500577e1b210$var$_tmpl$2 = ["<button", ' class="clear-group"><!--$-->', "<!--/--><span>", "</span></button>"],
2856
3365
  $f6b0500577e1b210$var$_tmpl$3 = ["<div", ' class="view-more-clear"><!--$-->', "<!--/--><!--$-->", "<!--/--></div>"],
2857
- $f6b0500577e1b210$var$_tmpl$4 = ["<div", ' class="filter-collapsible-body"><div class="filter-part">', "</div><!--$-->", "<!--/--></div>"],
3366
+ $f6b0500577e1b210$var$_tmpl$4 = ["<div", ' class="filter-collapsible-body"><div class="filter-part"><!--$-->', "<!--/--><!--$-->", "<!--/--></div><!--$-->", "<!--/--></div>"],
2858
3367
  $f6b0500577e1b210$var$_tmpl$5 = ["<details", ' class="filter-collapsible"', "></details>"],
2859
3368
  $f6b0500577e1b210$var$_tmpl$6 = ["<summary", ' class="filter-group-summary"><div class="summary"><span>', '</span><div class="selected-w-sign"><!--$-->', "<!--/--><!--$-->", "<!--/--></div></div></summary>"],
2860
3369
  $f6b0500577e1b210$var$_tmpl$7 = ["<div", ' class="ungrouped">', "</div>"],
@@ -2911,6 +3420,11 @@ function $f6b0500577e1b210$var$ActualFilterBody(props) {
2911
3420
  const filter_array_ = $b8hua$createMemo(() => {
2912
3421
  return Object.values(togglable_filters_grouped_by_collapsible())[get_section_index()];
2913
3422
  });
3423
+ const {
3424
+ SearchThisFilterGroup_: SearchThisFilterGroup_,
3425
+ searched_filter_array_: searched_filter_array_,
3426
+ filter_query_: filter_query_
3427
+ } = $e354b2f9ce33cb75$export$4b2c5292ffe0c5dd(filter_array_, section_, props.i18n_);
2914
3428
  const is_open = $f1e63746f76ce012$export$ab34afce88557c0e({
2915
3429
  get expanded_filters_() {
2916
3430
  return props.expanded_filters_;
@@ -2926,6 +3440,11 @@ function $f6b0500577e1b210$var$ActualFilterBody(props) {
2926
3440
  return selected_filter;
2927
3441
  })));
2928
3442
  const a_filter_is_selected = $b8hua$createMemo(() => selected_filters_in_group().size);
3443
+ const [get_details_width, set_get_details_width] = $b8hua$createSignal();
3444
+ const details_element_width_ = $b8hua$createMemo(() => {
3445
+ var _get_details_width;
3446
+ return get_details_width === null || get_details_width === void 0 ? void 0 : (_get_details_width = get_details_width()) === null || _get_details_width === void 0 ? void 0 : _get_details_width();
3447
+ });
2929
3448
  return $b8hua$createComponent((0, $ad371564683947ab$export$6c6d7a51fa9aa15d), {
2930
3449
  is_open_: is_open,
2931
3450
  get details_() {
@@ -2954,9 +3473,9 @@ function $f6b0500577e1b210$var$ActualFilterBody(props) {
2954
3473
  })));
2955
3474
  },
2956
3475
  get children() {
2957
- return $b8hua$ssr($f6b0500577e1b210$var$_tmpl$4, $b8hua$ssrHydrationKey(), $b8hua$escape($b8hua$createComponent((0, $b8hua$Index), {
3476
+ return $b8hua$ssr($f6b0500577e1b210$var$_tmpl$4, $b8hua$ssrHydrationKey(), $b8hua$escape($b8hua$createComponent(SearchThisFilterGroup_, {})), $b8hua$escape($b8hua$createComponent((0, $b8hua$Index), {
2958
3477
  get each() {
2959
- return filter_array_();
3478
+ return searched_filter_array_();
2960
3479
  },
2961
3480
  children: filter => $b8hua$createComponent((0, $74777e8fe65b3dcb$export$b69d0d92862de18b), {
2962
3481
  severity_: "error",
@@ -2979,7 +3498,9 @@ function $f6b0500577e1b210$var$ActualFilterBody(props) {
2979
3498
  get i18n_() {
2980
3499
  return props.i18n_;
2981
3500
  },
2982
- view_more_button_below_group_: view_more_button_below_group
3501
+ view_more_button_below_group_: view_more_button_below_group,
3502
+ filter_query_: filter_query_,
3503
+ details_element_width_: details_element_width_
2983
3504
  });
2984
3505
  }
2985
3506
  })
@@ -7128,15 +7649,6 @@ const $ecc323d9c29305ee$var$_tmpl$ = ["<svg", ' xmlns="http://www.w3.org/2000/sv
7128
7649
  function $ecc323d9c29305ee$export$1c641004b5485fed() {
7129
7650
  return $b8hua$ssr($ecc323d9c29305ee$var$_tmpl$, $b8hua$ssrHydrationKey());
7130
7651
  }
7131
- const $ef0f18a578b32578$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>';
7132
- function $ef0f18a578b32578$export$82eafebb825fc23f() {
7133
- let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7134
- return $b8hua$ssrElement("svg", $b8hua$mergeProps1(props, {
7135
- xmlns: "http://www.w3.org/2000/svg",
7136
- width: "20",
7137
- height: "22"
7138
- }), () => $b8hua$ssr($ef0f18a578b32578$var$_tmpl$), true);
7139
- }
7140
7652
  const $584c06c09cf4609d$var$_tmpl$ = ["<button", ' class="back" type="button"', ">", "</button>"],
7141
7653
  $584c06c09cf4609d$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>"];
7142
7654
  function $584c06c09cf4609d$export$b94867ecbd698f21(_ref) {
@@ -7628,78 +8140,24 @@ function $494c9ad553139dbc$export$a146ac6fa8346a25(_ref) {
7628
8140
  return has_entries();
7629
8141
  },
7630
8142
  get children() {
7631
- return $b8hua$ssr($494c9ad553139dbc$var$_tmpl$, $b8hua$ssrHydrationKey(), $b8hua$escape(text_()), $b8hua$escape($b8hua$createComponent((0, $b8hua$Index), {
7632
- get each() {
7633
- return previous_searches_();
7634
- },
7635
- children: (item, index) => {
7636
- const href = $e8776b492383c292$export$91c3b6774e8be0f5({
7637
- param_: search_query_param_name_,
7638
- value_: item,
7639
- url_transformer_: url_transformer_
7640
- });
7641
- return $b8hua$ssr($494c9ad553139dbc$var$_tmpl$2, $b8hua$ssrHydrationKey(), "".concat("item", " ").concat($b8hua$createMemo(() => {
7642
- var _read_selected_index_, _read_selected_index_2;
7643
- return ((_read_selected_index_ = read_selected_index_()) === null || _read_selected_index_ === void 0 ? void 0 : _read_selected_index_[0]) === 0 && ((_read_selected_index_2 = read_selected_index_()) === null || _read_selected_index_2 === void 0 ? void 0 : _read_selected_index_2[1]) === index;
7644
- })() ? "selected" : ""), $b8hua$ssrAttribute("href", $b8hua$escape(href(), true), false), $b8hua$escape($b8hua$createComponent((0, $6d95ef50ee01d5a1$export$5d2caaa6b530761c), {})), $b8hua$ssrAttribute("title", $b8hua$escape(item(), true), false), $b8hua$escape(item()), $b8hua$ssrAttribute("title", $b8hua$escape(i18n_.previous_searches_delete_entry_from_history_(), true), false), $b8hua$escape($b8hua$createComponent((0, $9783d437ad61594c$export$3b621d86b1566b2), {})));
7645
- }
7646
- })));
7647
- }
7648
- });
7649
- }
7650
- const $02b6641aa50ce528$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"],
7651
- $02b6641aa50ce528$var$_tmpl$2 = ["<span", ' class="', '"', ">", "</span>"];
7652
- function $02b6641aa50ce528$export$ba17c5b7e6dda39f(_ref) {
7653
- let {
7654
- whole_text_to_display_: whole_text_to_display_memo,
7655
- searching_for_value_: searching_for_value_memo,
7656
- class_: class_
7657
- } = _ref;
7658
- const [get_has_highlighted, set_has_highlighted] = $b8hua$createSignal(false);
7659
- const text_itself = $b8hua$createMemo(() => $b8hua$batch(() => {
7660
- set_has_highlighted(false);
7661
- const searching_for_value = searching_for_value_memo();
7662
- const whole_text_to_display_ = whole_text_to_display_memo();
7663
- let for_black = "";
7664
- let pushed_grey = false;
7665
- const search_q = searching_for_value;
7666
- if (!search_q) return whole_text_to_display_;
7667
- const output = [];
7668
- const searching_for = search_q.toLowerCase();
7669
- const push_black = () => {
7670
- if (for_black) {
7671
- set_has_highlighted(true);
7672
- output.push($b8hua$ssr($02b6641aa50ce528$var$_tmpl$, $b8hua$ssrHydrationKey(), $b8hua$escape(for_black))); // "black"
7673
- for_black = "";
7674
- }
7675
- };
7676
- for (let i = 0; i < whole_text_to_display_.length;) {
7677
- let is_whole_word = true;
7678
- let searching_for_but_with_texts_casing = "";
7679
- const i_at_start = i;
7680
- for (let j = 0; j < searching_for.length; i++, j++) {
7681
- const letter_in_suggestion = whole_text_to_display_[i];
7682
- if ((letter_in_suggestion === null || letter_in_suggestion === void 0 ? void 0 : letter_in_suggestion.toLowerCase()) !== searching_for[j]) {
7683
- is_whole_word = false;
7684
- i = i_at_start;
7685
- break;
8143
+ return $b8hua$ssr($494c9ad553139dbc$var$_tmpl$, $b8hua$ssrHydrationKey(), $b8hua$escape(text_()), $b8hua$escape($b8hua$createComponent((0, $b8hua$Index), {
8144
+ get each() {
8145
+ return previous_searches_();
8146
+ },
8147
+ children: (item, index) => {
8148
+ const href = $e8776b492383c292$export$91c3b6774e8be0f5({
8149
+ param_: search_query_param_name_,
8150
+ value_: item,
8151
+ url_transformer_: url_transformer_
8152
+ });
8153
+ return $b8hua$ssr($494c9ad553139dbc$var$_tmpl$2, $b8hua$ssrHydrationKey(), "".concat("item", " ").concat($b8hua$createMemo(() => {
8154
+ var _read_selected_index_, _read_selected_index_2;
8155
+ return ((_read_selected_index_ = read_selected_index_()) === null || _read_selected_index_ === void 0 ? void 0 : _read_selected_index_[0]) === 0 && ((_read_selected_index_2 = read_selected_index_()) === null || _read_selected_index_2 === void 0 ? void 0 : _read_selected_index_2[1]) === index;
8156
+ })() ? "selected" : ""), $b8hua$ssrAttribute("href", $b8hua$escape(href(), true), false), $b8hua$escape($b8hua$createComponent((0, $6d95ef50ee01d5a1$export$5d2caaa6b530761c), {})), $b8hua$ssrAttribute("title", $b8hua$escape(item(), true), false), $b8hua$escape(item()), $b8hua$ssrAttribute("title", $b8hua$escape(i18n_.previous_searches_delete_entry_from_history_(), true), false), $b8hua$escape($b8hua$createComponent((0, $9783d437ad61594c$export$3b621d86b1566b2), {})));
7686
8157
  }
7687
- searching_for_but_with_texts_casing += letter_in_suggestion;
7688
- }
7689
- if (is_whole_word) {
7690
- push_black();
7691
- output.push(searching_for_but_with_texts_casing);
7692
- pushed_grey = true;
7693
- } else for_black += whole_text_to_display_[i++];
7694
- }
7695
- push_black();
7696
- if (!pushed_grey) {
7697
- set_has_highlighted(false);
7698
- return whole_text_to_display_;
8158
+ })));
7699
8159
  }
7700
- return output;
7701
- }));
7702
- return $b8hua$ssr($02b6641aa50ce528$var$_tmpl$2, $b8hua$ssrHydrationKey(), "".concat($b8hua$escape(class_, true) || "", " ").concat(get_has_highlighted() ? "has-history-match" : ""), $b8hua$ssrAttribute("title", $b8hua$escape(whole_text_to_display_memo(), true), false), $b8hua$escape(text_itself()));
8160
+ });
7703
8161
  }
7704
8162
  const $3c5e15c6ee4227a9$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>';
7705
8163
  function $3c5e15c6ee4227a9$export$605674723bcc715c() {
@@ -7743,8 +8201,8 @@ function $40dd3f46f55d62ba$export$e872e2339fb04a7f(_ref) {
7743
8201
  } = _ref2;
7744
8202
  return type === (0, $7cd4d275a9f8d600$export$3cf9497e790da491) && !filtered_previous_searches_().includes(title);
7745
8203
  } // don't show the ones we already show from the history
7746
- ));
7747
-
8204
+ ) // + limit to three query suggestions, API sends more sometimes
8205
+ .slice(0, 3));
7748
8206
  const not_queries_memo = $b8hua$createMemo(() => {
7749
8207
  // For the section that shows categories and content results
7750
8208
  // We want to limit to 3 items, and we want to show the categories first
@@ -8585,236 +9043,6 @@ function $8e8ce3f7a5eb11a6$export$41b4894022a3580f() {
8585
9043
  })));
8586
9044
  return style_props_;
8587
9045
  }
8588
- const $f3a159279dc1a8fb$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"];
8589
- const $f3a159279dc1a8fb$var$dont_cut_in_between_less_than_characters = 30;
8590
- function $f3a159279dc1a8fb$export$e1a98a189fd2c0e7(_ref) {
8591
- let {
8592
- content_result_: content_result_,
8593
- key_: key_,
8594
- cut_when_possible_: cut_when_possible_
8595
- } = _ref;
8596
- const matched_tokens = $b8hua$createMemo(() => {
8597
- var _content_result_$high, _content_result_$high2;
8598
- return (_content_result_$high = content_result_().highlights) === null || _content_result_$high === void 0 ? void 0 : (_content_result_$high2 = _content_result_$high.find(highlight => highlight.field == key_)) === null || _content_result_$high2 === void 0 ? void 0 : _content_result_$high2.matched_tokens;
8599
- });
8600
- const full_value = $b8hua$createMemo(() => {
8601
- var _content_result_$key_;
8602
- return (_content_result_$key_ = content_result_()[key_]) === null || _content_result_$key_ === void 0 ? void 0 : _content_result_$key_.replaceAll("\n", " ");
8603
- });
8604
- return $b8hua$createComponent((0, $b8hua$Show), {
8605
- get when() {
8606
- var _matched_tokens;
8607
- return (_matched_tokens = matched_tokens()) === null || _matched_tokens === void 0 ? void 0 : _matched_tokens.length;
8608
- },
8609
- get fallback() {
8610
- return full_value();
8611
- },
8612
- get children() {
8613
- return (() => {
8614
- const segmented_cut_text = $b8hua$createMemo(() => {
8615
- const segmented_text = $f3a159279dc1a8fb$var$segment_text(full_value(), matched_tokens());
8616
- if (cut_when_possible_) $f3a159279dc1a8fb$var$cut_text(segmented_text);
8617
- return segmented_text;
8618
- });
8619
- return $b8hua$createComponent((0, $b8hua$Index), {
8620
- get each() {
8621
- return segmented_cut_text();
8622
- },
8623
- children: item => {
8624
- return $b8hua$createComponent((0, $b8hua$Show), {
8625
- get when() {
8626
- return item().highlighted_;
8627
- },
8628
- get fallback() {
8629
- return item().text_;
8630
- },
8631
- get children() {
8632
- return $b8hua$ssr($f3a159279dc1a8fb$var$_tmpl$, $b8hua$ssrHydrationKey(), $b8hua$escape(item().text_));
8633
- }
8634
- });
8635
- }
8636
- });
8637
- })();
8638
- }
8639
- });
8640
- }
8641
- function $f3a159279dc1a8fb$var$cut_text(segmented_text) {
8642
- // cut away chunks of text that are not highlighted to give a google-like overview of the content
8643
- const highlighted_segments = segmented_text === null || segmented_text === void 0 ? void 0 : segmented_text.filter(segment => segment.highlighted_);
8644
- if (!segmented_text || !(highlighted_segments !== null && highlighted_segments !== void 0 && highlighted_segments.length)) return;
8645
- // We have one or more highlighted segments
8646
- if (highlighted_segments.length === 1) {
8647
- // cut away from the left until the start of the highlighted sentence if just one sentence is highlighted
8648
- $f3a159279dc1a8fb$var$cut_start(segmented_text.indexOf(highlighted_segments[0]), segmented_text);
8649
- return;
8650
- }
8651
- // We have two or more highlighted segments, take the two biggest chunks and show them + a bit text around
8652
- 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
8653
- );
8654
-
8655
- const [longest_segment, next_longest_segment] = sorted_highlighted_segments;
8656
- // We need to cut before the first segment - possibly through other segments - and maybe between segments
8657
- 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);
8658
- $f3a159279dc1a8fb$var$cut_start(index_of_first_segment, segmented_text);
8659
- // update indexes since we might have removed segments
8660
- [index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
8661
- let number_of_characters_between_segments = 0;
8662
- for (let i = index_of_first_segment + 1; i < index_of_second_segment; i++) {
8663
- const segment = segmented_text[i];
8664
- number_of_characters_between_segments += segment.text_.length;
8665
- }
8666
- if (number_of_characters_between_segments < $f3a159279dc1a8fb$var$dont_cut_in_between_less_than_characters)
8667
- // don't cut if there are less than 30 characters between the two segments
8668
- return;
8669
- // We have more than 50 characters between the two segments, cut between them
8670
- const [split_start_segment, split_start_character] = $f3a159279dc1a8fb$var$find_split_point(index_of_first_segment, index_of_second_segment, segmented_text);
8671
- const [split_end_segment, split_end_character] = $f3a159279dc1a8fb$var$find_split_point(index_of_second_segment, index_of_first_segment, segmented_text);
8672
- if (split_start_segment === undefined || split_end_segment === undefined ||
8673
- // identical split point, or split end before split start, can't do anything
8674
- split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
8675
- const dots_segment = {
8676
- text_: " … ",
8677
- highlighted_: false
8678
- };
8679
- const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
8680
- if (i < split_start_segment || i > split_end_segment) return segment;
8681
- const text = segment.text_;
8682
- if (i == split_end_segment && i == split_start_segment) return [{
8683
- ...segment,
8684
- text_: text.slice(0, split_start_character).trimEnd()
8685
- }, dots_segment, {
8686
- ...segment,
8687
- text_: text.slice(split_end_character + 1, text.length).trimStart()
8688
- }];else if (i == split_start_segment) {
8689
- 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
8690
- return segment;
8691
- } else if (i == split_end_segment) return [dots_segment, {
8692
- ...segment,
8693
- text_: text.slice(split_end_character + 1, text.length).trimStart()
8694
- }];
8695
- return []; // remove all segments inbetween
8696
- });
8697
-
8698
- segmented_text.splice(0, segmented_text.length, ...split_and_dotted_values); // Sorry…
8699
- $f3a159279dc1a8fb$var$heal_holes(segmented_text);
8700
- }
8701
- function $f3a159279dc1a8fb$var$heal_holes(segmented_text) {
8702
- // try to heal "holes" created in the segments so there are only alternating segments
8703
- const segments_to_delete = new Set();
8704
- for (let i = 0; i < segmented_text.length; i++) {
8705
- var _previous_segment, _previous_segment2;
8706
- const segment = segmented_text[i];
8707
- let previous_segment;
8708
- for (let j = i - 1; j >= 0; j--) {
8709
- previous_segment = segmented_text[j];
8710
- // Don't write to a segment that's marked for deletion or the contents we write to it will be deleted
8711
- if (!segments_to_delete.has(previous_segment)) break;
8712
- }
8713
- if ((_previous_segment = previous_segment) !== null && _previous_segment !== void 0 && _previous_segment.highlighted_ && segment.highlighted_ || ((_previous_segment2 = previous_segment) === null || _previous_segment2 === void 0 ? void 0 : _previous_segment2.highlighted_) === false && segment.highlighted_ === false) {
8714
- previous_segment.text_ += segment.text_; // IDK if this ever happens
8715
- segments_to_delete.add(segment);
8716
- }
8717
- }
8718
- for (const segment of segments_to_delete) {
8719
- const index = segmented_text.indexOf(segment);
8720
- segmented_text.splice(index, 1);
8721
- }
8722
- }
8723
- function $f3a159279dc1a8fb$var$find_split_point(index_of_start_segment, index_of_end_segment, segmented_text) {
8724
- let be_very_aggressive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
8725
- const should_loop_backwards = index_of_start_segment > index_of_end_segment;
8726
- const step = should_loop_backwards ? -1 : 1;
8727
- const desperate_split_attempts = [":", ";", ","];
8728
- while (desperate_split_attempts.length) {
8729
- const split_point_between_words = [];
8730
- // for the middle also try to split with a few more characters if the default ones don't work over a full run
8731
- const desperate_split_attempt = desperate_split_attempts.pop();
8732
- let is_first_character = true;
8733
- for (let i = index_of_start_segment + step; should_loop_backwards ? i > index_of_end_segment : i < index_of_end_segment; i += step) {
8734
- const segment = segmented_text[i];
8735
- const text = segment.text_;
8736
- for (let j = should_loop_backwards ? text.length - 1 : 0; should_loop_backwards ? j >= 0 : j < text.length; j += step) {
8737
- const character = text[j];
8738
- if (character == "." || character == "?" || character == "!" || character == desperate_split_attempt) return [i, j]; // segment index, character index
8739
- if (is_first_character) is_first_character = false;else if (be_very_aggressive && character == " ") {
8740
- split_point_between_words.push([i, j]);
8741
- if (split_point_between_words.length > 3)
8742
- // We can't find a split point, so we'll just split between words
8743
- // 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
8744
- return split_point_between_words[1];
8745
- }
8746
- }
8747
- }
8748
- }
8749
- return [];
8750
- }
8751
- function $f3a159279dc1a8fb$var$cut_start(cut_left_of_index, segmented_text) {
8752
- // Cut the start of the text to bring the first matching token
8753
- let is_first_character = false;
8754
- let words_encountered = 0;
8755
- outmost_loop: for (let i = cut_left_of_index - 1; i >= 0; i--) {
8756
- const segment = segmented_text[i];
8757
- // We assume that two adjacent highlighted segments don't exist and have been merged if they were to have existed
8758
- const text = segment.text_;
8759
- for (let j = text.length - 1; j >= 0; j--) {
8760
- const character = text[j];
8761
- const is_space = character == " ";
8762
- if (!is_first_character && is_space) words_encountered++;
8763
- if (character == "." || character == "?" || character == "!" || character == "," || words_encountered > 8 && is_space) {
8764
- // We have to be really aggressive at the start of sentences so stuff can be seen on mobile, hence comma
8765
- segment.text_ = text.slice(j + 1).trimStart();
8766
- segmented_text.splice(0, i);
8767
- if (character === "," || is_space)
8768
- // if we cut at a comma or psace, we add a … at the beginning
8769
- segmented_text.unshift({
8770
- text_: "… ",
8771
- highlighted_: false
8772
- });
8773
- break outmost_loop;
8774
- }
8775
- if (is_first_character) is_first_character = false;
8776
- }
8777
- }
8778
- $f3a159279dc1a8fb$var$heal_holes(segmented_text); // if we added a ... there could now be a sequence that's not alternating true/false
8779
- }
8780
-
8781
- function $f3a159279dc1a8fb$var$segment_text(text, matched_strings) {
8782
- // segment text where the matched strings are highlighted sections
8783
- const output = [];
8784
- if (!text) return; // shouldn't happen but whatever
8785
- for (let i = 0; i < text.length; i++) {
8786
- const found_strings = [];
8787
- if (!i || text[i - 1] == " ")
8788
- // only match at the start of a word or string, it looks weird if i.e. "we" is highlighted in "activewear
8789
- for (let j = 0; j < matched_strings.length; j++) {
8790
- const matched_string = matched_strings[j];
8791
- const part_in_text = text.slice(i, i + matched_string.length);
8792
- if (matched_string.length < 2) continue; // don't match on single characters, i.e. "I", it looks weird
8793
- 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
8794
- }
8795
-
8796
- const last_index_in_output = output.length - 1;
8797
- if (!found_strings.length) {
8798
- var _output$last_index_in;
8799
- const character = text[i];
8800
- if (((_output$last_index_in = output[last_index_in_output]) === null || _output$last_index_in === void 0 ? void 0 : _output$last_index_in.highlighted_) === false || output.length && /\s/.test(character))
8801
- // 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
8802
- output[last_index_in_output].text_ += character;else output.push({
8803
- highlighted_: false,
8804
- text_: character
8805
- });
8806
- } else {
8807
- var _output$last_index_in2;
8808
- const longest_found_string = found_strings.reduce((a, b) => a.length > b.length ? a : b);
8809
- if ((_output$last_index_in2 = output[last_index_in_output]) !== null && _output$last_index_in2 !== void 0 && _output$last_index_in2.highlighted_) output[last_index_in_output].text_ += longest_found_string;else output.push({
8810
- highlighted_: true,
8811
- text_: longest_found_string
8812
- });
8813
- i += longest_found_string.length - 1;
8814
- }
8815
- }
8816
- return output;
8817
- }
8818
9046
  const $22470de5f42cc35d$var$_tmpl$ = ["<div", ' class="description line-clamp">', "</div>"],
8819
9047
  $22470de5f42cc35d$var$_tmpl$2 = ["<div", ' class="content-card"><div class="image">', '</div><div class="info"><!--$-->', "<!--/--><!--$-->", "<!--/--></div></div>"];
8820
9048
  function $22470de5f42cc35d$export$f631859cab12b342(_ref) {
@@ -10339,4 +10567,4 @@ const $d399250dfa491636$export$c3834fa86c616831 = [[4], [3, 1024], [2, 901]];
10339
10567
  const $d399250dfa491636$export$864d304a0bc46829 = "2%";
10340
10568
  const $d399250dfa491636$export$7bf543b9d9be2c22 = (0, $fa332ea03168857c$export$b91cec6bdc6b32a1);
10341
10569
  $b8hua$add_to_version_info("ui", (0, $8db9a15135765c11$export$83d89fbfd8236492));
10342
- export { $2855bffe06ef7a03$export$916e6850778505f6 as strip_encoded_filter_and_sort, $2855bffe06ef7a03$export$58aa3f171519b6d7 as encode_filters, $2855bffe06ef7a03$export$f934fa24c3a86811 as decode_filters, $4df489344a0f97c7$export$d7b7ab832c20e2f4 as shopifyContainedImageContextSymbol, $5441862cd2f5e111$export$e68cff63f76bd15b as ListingProvider, $5441862cd2f5e111$export$8d0c4fdbb05a2f2e as useListing, $4df489344a0f97c7$export$e4b984597b71e989 as ShopifyContainedImage, $002f09d00aac50b2$export$6649caad96ef8870 as SlidableItems, $0dc044cffe1e825b$export$9f191182275e9ef as make_accurate_size_accessor, $d5d7e58c5c9d8db0$export$9574e176201e5e8d as RecommendationSlider, $b432b11321ad4c97$export$9756467d34d91cdb as RecommendationGrid, $56047603f9d212b6$export$6e5611bc7e57e477 as ShopifyResponsiveImg, $56047603f9d212b6$export$e6fffe67d4cdd848 as makeSizeAccessor, $801e8845d3fa3653$export$94026ee33dbabc26 as ImageContainer, $74777e8fe65b3dcb$export$b69d0d92862de18b as SentryErrorBoundary, $ad371564683947ab$export$6c6d7a51fa9aa15d as ExpandingDetails, $e18ab2868df26f40$export$f091cbac892643a4 as accessor_of_object_to_object_with_accessor_values, $4711a82d08d2021b$export$fecbb157621501bd as SelectedFilters, $f6b0500577e1b210$export$3f1a388cc0d8fed7 as FilterBody, $44aa24b1bb793549$export$b288c38ae3fddb56 as create_modified_filters, $63f1f8dbcd07d3b0$export$d21e32dfedac04be as SolidLayout, $d5f1e6a0f9117286$export$79b1565500412d9b as general_modal_abstraction, $9783d437ad61594c$export$3b621d86b1566b2 as CrossIcon, $ca6ab5f08bd28bca$export$8be2714ec7f169ee as GenericSliderArrowButton, $5c5732ef44f05b26$export$58e808b1db15d3bc as fetchDepictRecommendations, $f5f54892fd0c7d9f$export$de035477d6fef996 as QuickLinks, $f5f54892fd0c7d9f$export$5b7c3ce0ebe51f86 as BreadCrumbs, $fa332ea03168857c$export$b91cec6bdc6b32a1 as CategoryTitle, $702d7656a373973e$export$824dde41348efed1 as embedded_num_products, $96fd967c5b358ead$export$643598a327b5833e as get_categories, $f5f54892fd0c7d9f$export$f34314aa9505732e as DepictCategory, $f5f54892fd0c7d9f$export$e2bf8ce7779e827e as CategoryPage, $eb064bc3350276c1$export$ac6237957a15b3f0 as DepictSearch, $eb064bc3350276c1$export$bde3eb976dfded9 as get_search_query_updating_blocked_signal, $eb064bc3350276c1$export$f2dc7e4e4aa11abb as SearchPage, $eb064bc3350276c1$export$316f6f283ae64765 as SearchField, $f3b7124b76123e44$export$aa14a9f43128f61f as ProductCardError, $169c13c0531d91d2$export$d86a33413558014e as open_modal_with_alignment, $5eaa00b951637e96$export$ee1733d9a8495996 as DefaultInstantCardPlaceholder, $1308a7816c3d4f2d$export$b3ad617e9036868 as align_field, $a9c7ba6087881ac2$export$6daf8749b65a1b77 as convert_sdk_cols_at_size_to_layout, $cc64aabf2c7a1f1a$export$1233ca167bf71f9a as styles_to_valid_css_string, $e56d241d0f33d459$export$fe334901e8bebd57 as disable_scrolling, $573c007c697a1831$export$d0596b5cae35ad4 as open_search_with_shift_slash, $284849364a6ef73a$export$e015ed2f2950f2e3 as DepictAPI, $00a5b94f0c11efbb$export$d9f36cf74e24d595 as media_query_to_accessor, $e60a76195ac6d408$export$689e204eadb33baf as setup_fast_leave, $a61a2051e15c8d7a$export$5196e4c01fa56fcb as show_toast, $60ec7a29849d81db$export$a71e92cfbb498adc as SolidFormatPrice, $37e8c97bb6876197$export$828dcdd425fd3231 as connect_search_field_height_to_aligner_height, $bc2337c9a05ecd18$export$acb3eaade4b23afd as BasePlaceholder, $ceafb6fb91c6f394$export$89c6019e4baa40b1 as TextPlaceholder, $3ab4aa97880fb88d$export$3f37af283f8fb843 as ImagePlaceholder, $f9fd3017c20b774a$export$3ccaa27d81dd8556 as PageReplacer, $d399250dfa491636$export$864d304a0bc46829 as defaultGridSpacing, $d399250dfa491636$export$c3834fa86c616831 as defaultColsAtSize, $d399250dfa491636$export$7bf543b9d9be2c22 as defaultCategoryTitlePlugin, $8db9a15135765c11$export$83d89fbfd8236492 as version };
10570
+ export { $2855bffe06ef7a03$export$916e6850778505f6 as strip_encoded_filter_and_sort, $2855bffe06ef7a03$export$58aa3f171519b6d7 as encode_filters, $2855bffe06ef7a03$export$f934fa24c3a86811 as decode_filters, $4df489344a0f97c7$export$d7b7ab832c20e2f4 as shopifyContainedImageContextSymbol, $5441862cd2f5e111$export$e68cff63f76bd15b as ListingProvider, $5441862cd2f5e111$export$8d0c4fdbb05a2f2e as useListing, $4df489344a0f97c7$export$e4b984597b71e989 as ShopifyContainedImage, $002f09d00aac50b2$export$6649caad96ef8870 as SlidableItems, $fc830a7ee59416ef$export$ebdc3711f7e02ccd as make_accurate_width_accessor, $d5d7e58c5c9d8db0$export$9574e176201e5e8d as RecommendationSlider, $b432b11321ad4c97$export$9756467d34d91cdb as RecommendationGrid, $56047603f9d212b6$export$6e5611bc7e57e477 as ShopifyResponsiveImg, $56047603f9d212b6$export$e6fffe67d4cdd848 as makeSizeAccessor, $801e8845d3fa3653$export$94026ee33dbabc26 as ImageContainer, $74777e8fe65b3dcb$export$b69d0d92862de18b as SentryErrorBoundary, $ad371564683947ab$export$6c6d7a51fa9aa15d as ExpandingDetails, $e18ab2868df26f40$export$f091cbac892643a4 as accessor_of_object_to_object_with_accessor_values, $4711a82d08d2021b$export$fecbb157621501bd as SelectedFilters, $f6b0500577e1b210$export$3f1a388cc0d8fed7 as FilterBody, $44aa24b1bb793549$export$b288c38ae3fddb56 as create_modified_filters, $63f1f8dbcd07d3b0$export$d21e32dfedac04be as SolidLayout, $d5f1e6a0f9117286$export$79b1565500412d9b as general_modal_abstraction, $9783d437ad61594c$export$3b621d86b1566b2 as CrossIcon, $ca6ab5f08bd28bca$export$8be2714ec7f169ee as GenericSliderArrowButton, $5c5732ef44f05b26$export$58e808b1db15d3bc as fetchDepictRecommendations, $f5f54892fd0c7d9f$export$de035477d6fef996 as QuickLinks, $f5f54892fd0c7d9f$export$5b7c3ce0ebe51f86 as BreadCrumbs, $fa332ea03168857c$export$b91cec6bdc6b32a1 as CategoryTitle, $702d7656a373973e$export$824dde41348efed1 as embedded_num_products, $96fd967c5b358ead$export$643598a327b5833e as get_categories, $f5f54892fd0c7d9f$export$f34314aa9505732e as DepictCategory, $f5f54892fd0c7d9f$export$e2bf8ce7779e827e as CategoryPage, $eb064bc3350276c1$export$ac6237957a15b3f0 as DepictSearch, $eb064bc3350276c1$export$bde3eb976dfded9 as get_search_query_updating_blocked_signal, $eb064bc3350276c1$export$f2dc7e4e4aa11abb as SearchPage, $eb064bc3350276c1$export$316f6f283ae64765 as SearchField, $f3b7124b76123e44$export$aa14a9f43128f61f as ProductCardError, $169c13c0531d91d2$export$d86a33413558014e as open_modal_with_alignment, $5eaa00b951637e96$export$ee1733d9a8495996 as DefaultInstantCardPlaceholder, $1308a7816c3d4f2d$export$b3ad617e9036868 as align_field, $a9c7ba6087881ac2$export$6daf8749b65a1b77 as convert_sdk_cols_at_size_to_layout, $cc64aabf2c7a1f1a$export$1233ca167bf71f9a as styles_to_valid_css_string, $e56d241d0f33d459$export$fe334901e8bebd57 as disable_scrolling, $573c007c697a1831$export$d0596b5cae35ad4 as open_search_with_shift_slash, $284849364a6ef73a$export$e015ed2f2950f2e3 as DepictAPI, $00a5b94f0c11efbb$export$d9f36cf74e24d595 as media_query_to_accessor, $e60a76195ac6d408$export$689e204eadb33baf as setup_fast_leave, $a61a2051e15c8d7a$export$5196e4c01fa56fcb as show_toast, $60ec7a29849d81db$export$a71e92cfbb498adc as SolidFormatPrice, $37e8c97bb6876197$export$828dcdd425fd3231 as connect_search_field_height_to_aligner_height, $bc2337c9a05ecd18$export$acb3eaade4b23afd as BasePlaceholder, $ceafb6fb91c6f394$export$89c6019e4baa40b1 as TextPlaceholder, $3ab4aa97880fb88d$export$3f37af283f8fb843 as ImagePlaceholder, $f9fd3017c20b774a$export$3ccaa27d81dd8556 as PageReplacer, $d399250dfa491636$export$864d304a0bc46829 as defaultGridSpacing, $d399250dfa491636$export$c3834fa86c616831 as defaultColsAtSize, $d399250dfa491636$export$7bf543b9d9be2c22 as defaultCategoryTitlePlugin, $8db9a15135765c11$export$83d89fbfd8236492 as version };