@depict-ai/ui 2.1.12 → 2.1.14

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.
@@ -25,7 +25,7 @@ $parcel$export(module.exports, "ListingProvider", () => $d067f3a30f047b41$export
25
25
  $parcel$export(module.exports, "useListing", () => $d067f3a30f047b41$export$8d0c4fdbb05a2f2e);
26
26
  $parcel$export(module.exports, "ShopifyContainedImage", () => $28535bb7671c63d1$export$e4b984597b71e989);
27
27
  $parcel$export(module.exports, "SlidableItems", () => $ad8ec7729fffeb9c$export$6649caad96ef8870);
28
- $parcel$export(module.exports, "make_accurate_size_accessor", () => $13671aa5e984acd9$export$9f191182275e9ef);
28
+ $parcel$export(module.exports, "make_accurate_width_accessor", () => $c387d7f1d9fb66c0$export$ebdc3711f7e02ccd);
29
29
  $parcel$export(module.exports, "RecommendationSlider", () => $2badc30d7c6610e1$export$9574e176201e5e8d);
30
30
  $parcel$export(module.exports, "RecommendationGrid", () => $41227f10ad680afd$export$9756467d34d91cdb);
31
31
  $parcel$export(module.exports, "ShopifyResponsiveImg", () => $858fdcf73148519f$export$6e5611bc7e57e477);
@@ -76,7 +76,7 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $33eed84f447aa0c0$expo
76
76
  $parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $33eed84f447aa0c0$export$7bf543b9d9be2c22);
77
77
  $parcel$export(module.exports, "version", () => $aa1938dec50d6c12$export$83d89fbfd8236492);
78
78
  /*! Depict.ai search and product listing SDK */
79
- const $aa1938dec50d6c12$export$83d89fbfd8236492 = "2.1.12";
79
+ const $aa1938dec50d6c12$export$83d89fbfd8236492 = "2.1.14";
80
80
  const $a68b73fd7ba0853f$var$fallback_operator = "in";
81
81
  const $a68b73fd7ba0853f$var$fallback_token = "";
82
82
  const $a68b73fd7ba0853f$var$legacy_filter_prefix = "filter_";
@@ -506,13 +506,13 @@ function $ad8ec7729fffeb9c$export$6649caad96ef8870(_ref) {
506
506
 
507
507
  /** @jsxImportSource solid-js */
508
508
 
509
- function $13671aa5e984acd9$export$9f191182275e9ef(what_to_watch) {
510
- const [size, setSize] = $3hooq$solidjs.createSignal();
509
+ function $c387d7f1d9fb66c0$export$ebdc3711f7e02ccd(what_to_watch) {
510
+ const [width, setWidth] = $3hooq$solidjs.createSignal();
511
511
  const resizeObserver = new ResizeObserver($3hooq$depictaiutilishared.catchify(records => {
512
512
  for (let j = 0; j < records.length; j++) {
513
513
  var _records$j$borderBoxS, _records$j$borderBoxS2, _records$j$borderBoxS3;
514
514
  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;
515
- setSize(width);
515
+ setWidth(width);
516
516
  }
517
517
  }));
518
518
  // 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.
@@ -521,13 +521,19 @@ function $13671aa5e984acd9$export$9f191182275e9ef(what_to_watch) {
521
521
  let {
522
522
  element: element
523
523
  } = _ref;
524
- return requestAnimationFrame($3hooq$depictaiutilishared.catchify(() => resizeObserver.observe(element)));
524
+ return requestAnimationFrame($3hooq$depictaiutilishared.catchify(() => {
525
+ const current_size = what_to_watch.getBoundingClientRect().width;
526
+ if (current_size)
527
+ // 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.
528
+ setWidth(current_size);
529
+ resizeObserver.observe(element);
530
+ }));
525
531
  });
526
532
  $3hooq$solidjs.onCleanup(() => {
527
533
  resizeObserver.disconnect();
528
534
  disconnect();
529
535
  });
530
- return size;
536
+ return width;
531
537
  }
532
538
  const $5401a6698b0c0658$var$transform_elements = sorted_cols_at_size => {
533
539
  const cols_at_size = [];
@@ -1324,12 +1330,12 @@ function $f38f2e64ebe2da86$export$a71e92cfbb498adc(props) {
1324
1330
  const $083b2336093176cf$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>';
1325
1331
  function $083b2336093176cf$export$3b621d86b1566b2() {
1326
1332
  let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1327
- return $3hooq$solidjsweb.ssrElement("svg", $3hooq$solidjsweb.mergeProps(props, {
1333
+ return $3hooq$solidjsweb.ssrElement("svg", $3hooq$solidjsweb.mergeProps({
1328
1334
  xmlns: "http://www.w3.org/2000/svg",
1329
1335
  width: "21.064",
1330
1336
  height: "21.047",
1331
1337
  viewBox: "0 0 21.064 21.064"
1332
- }), () => $3hooq$solidjsweb.ssr($083b2336093176cf$var$_tmpl$), true);
1338
+ }, props), () => $3hooq$solidjsweb.ssr($083b2336093176cf$var$_tmpl$), true);
1333
1339
  }
1334
1340
 
1335
1341
  /**
@@ -1557,7 +1563,7 @@ function $c5842bdb10e57229$export$fecbb157621501bd(_ref) {
1557
1563
  const $902a0ca2b52f3898$var$_tmpl$ = ["<span", ' class="count">', "</span>"],
1558
1564
  $902a0ca2b52f3898$var$_tmpl$2 = ["<label", ' class="', '"', '><div class="left"><input type="checkbox"', "", "", '><span class="custom-indicator"></span><span class="text line-clamp">', "</span></div><!--$-->", "<!--/--></label>"];
1559
1565
  const $902a0ca2b52f3898$export$48513f6b9f8ce62d = props => {
1560
- // 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
1566
+ /* 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
1561
1567
  const count = $3hooq$solidjs.createMemo(() => props.count_);
1562
1568
  const label = $3hooq$solidjs.createMemo(() => props.label_);
1563
1569
  const checked = $3hooq$solidjs.createMemo(() => props.checked_);
@@ -1590,6 +1596,60 @@ function $b0477e4d832f090e$export$ca21a16d65b3dd8(_ref) {
1590
1596
  } = _ref;
1591
1597
  return $3hooq$solidjsweb.ssr($b0477e4d832f090e$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), "expand-filter ".concat(get_show_extras() ? "expanded" : ""), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $a904ccf883f60231$export$f21ab0717a89c77f), {})), get_show_extras() ? $3hooq$solidjsweb.escape(i18n_.view_less_()) : $3hooq$solidjsweb.escape(i18n_.view_more_()));
1592
1598
  }
1599
+ const $23c3f390dee33ff8$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"],
1600
+ $23c3f390dee33ff8$var$_tmpl$2 = ["<span", ' class="', '"', ">", "</span>"];
1601
+ function $23c3f390dee33ff8$export$ba17c5b7e6dda39f(_ref) {
1602
+ let {
1603
+ whole_text_to_display_: whole_text_to_display_memo,
1604
+ searching_for_value_: searching_for_value_memo,
1605
+ class_: class_
1606
+ } = _ref;
1607
+ const [get_has_highlighted, set_has_highlighted] = $3hooq$solidjs.createSignal(false);
1608
+ const text_itself = $3hooq$solidjs.createMemo(() => $3hooq$solidjs.batch(() => {
1609
+ set_has_highlighted(false);
1610
+ const searching_for_value = searching_for_value_memo();
1611
+ const whole_text_to_display_ = whole_text_to_display_memo();
1612
+ let for_black = "";
1613
+ let pushed_grey = false;
1614
+ const search_q = searching_for_value;
1615
+ if (!search_q) return whole_text_to_display_;
1616
+ const output = [];
1617
+ const searching_for = search_q.toLowerCase();
1618
+ const push_black = () => {
1619
+ if (for_black) {
1620
+ set_has_highlighted(true);
1621
+ output.push($3hooq$solidjsweb.ssr($23c3f390dee33ff8$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape(for_black))); // "black"
1622
+ for_black = "";
1623
+ }
1624
+ };
1625
+ for (let i = 0; i < whole_text_to_display_.length;) {
1626
+ let is_whole_word = true;
1627
+ let searching_for_but_with_texts_casing = "";
1628
+ const i_at_start = i;
1629
+ for (let j = 0; j < searching_for.length; i++, j++) {
1630
+ const letter_in_suggestion = whole_text_to_display_[i];
1631
+ if ((letter_in_suggestion === null || letter_in_suggestion === void 0 ? void 0 : letter_in_suggestion.toLowerCase()) !== searching_for[j]) {
1632
+ is_whole_word = false;
1633
+ i = i_at_start;
1634
+ break;
1635
+ }
1636
+ searching_for_but_with_texts_casing += letter_in_suggestion;
1637
+ }
1638
+ if (is_whole_word) {
1639
+ push_black();
1640
+ output.push(searching_for_but_with_texts_casing);
1641
+ pushed_grey = true;
1642
+ } else for_black += whole_text_to_display_[i++];
1643
+ }
1644
+ push_black();
1645
+ if (!pushed_grey) {
1646
+ set_has_highlighted(false);
1647
+ return whole_text_to_display_;
1648
+ }
1649
+ return output;
1650
+ }));
1651
+ return $3hooq$solidjsweb.ssr($23c3f390dee33ff8$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), "".concat($3hooq$solidjsweb.escape(class_, true) || "", " ").concat(get_has_highlighted() ? "has-match" : ""), $3hooq$solidjsweb.ssrAttribute("title", $3hooq$solidjsweb.escape(whole_text_to_display_memo(), true), false), $3hooq$solidjsweb.escape(text_itself()));
1652
+ }
1593
1653
  const $9b54b9c5381716eb$var$_tmpl$ = ["<form", ' class="checkboxes"><!--$-->', "<!--/--><!--$-->", "<!--/--></form>"];
1594
1654
  const $9b54b9c5381716eb$var$max_visible_without_collapsing = 15;
1595
1655
  const $9b54b9c5381716eb$var$show_non_collapsible_when_collapsed = 4;
@@ -1598,7 +1658,8 @@ function $9b54b9c5381716eb$export$dd948f91abc3a1c4(_ref) {
1598
1658
  filter_: filter_,
1599
1659
  selected_filters_: [get_selected_filters, set_selected_filters],
1600
1660
  i18n_: i18n_,
1601
- view_more_button_below_group_: [, set_view_more_button_below_group_]
1661
+ view_more_button_below_group_: [, set_view_more_button_below_group_],
1662
+ filter_query_: filter_query_
1602
1663
  } = _ref;
1603
1664
  const existing_filter = $3hooq$solidjs.createMemo(() => {
1604
1665
  const {
@@ -1633,12 +1694,18 @@ function $9b54b9c5381716eb$export$dd948f91abc3a1c4(_ref) {
1633
1694
  const value = $e2d74bb03cc5252e$export$325f75597868c4f0(checkbox().value_);
1634
1695
  return !!(data !== null && data !== void 0 && data.some(item => $e2d74bb03cc5252e$export$325f75597868c4f0(item) === value));
1635
1696
  });
1697
+ const value = $3hooq$solidjs.createMemo(() => checkbox().value_);
1636
1698
  return $3hooq$solidjsweb.createComponent((0, $902a0ca2b52f3898$export$48513f6b9f8ce62d), {
1637
1699
  get value_() {
1638
- return checkbox().value_;
1700
+ return value();
1639
1701
  },
1640
1702
  get label_() {
1641
- return checkbox().name_;
1703
+ return $3hooq$solidjsweb.createComponent((0, $23c3f390dee33ff8$export$ba17c5b7e6dda39f), {
1704
+ get whole_text_to_display_() {
1705
+ return $3hooq$solidjs.createMemo(() => checkbox().name_ || value());
1706
+ },
1707
+ searching_for_value_: () => filter_query_ === null || filter_query_ === void 0 ? void 0 : filter_query_()
1708
+ });
1642
1709
  },
1643
1710
  get count_() {
1644
1711
  return checkbox().count_;
@@ -1701,7 +1768,8 @@ const $d9239dad9a9d899b$var$_tmpl$ = ["<form", ' class="radios">', "</form>"],
1701
1768
  function $d9239dad9a9d899b$export$430444115f70a734(_ref) {
1702
1769
  let {
1703
1770
  selected_filters_: selected_filters_,
1704
- filter_: filter_
1771
+ filter_: filter_,
1772
+ filter_query_: filter_query_
1705
1773
  } = _ref;
1706
1774
  const radio_name = $3hooq$depictaiutilishared.make_random_classname();
1707
1775
  const existing_filter = $3hooq$solidjs.createMemo(() => {
@@ -1727,19 +1795,23 @@ function $d9239dad9a9d899b$export$430444115f70a734(_ref) {
1727
1795
  var _counts;
1728
1796
  return (_counts = filter_().meta.counts) === null || _counts === void 0 ? void 0 : _counts[index];
1729
1797
  });
1798
+ const label = $3hooq$solidjs.createMemo(() => {
1799
+ var _filter_$meta, _filter_$meta$names;
1800
+ 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];
1801
+ if (name) return name;
1802
+ const v = value();
1803
+ return Array.isArray(v) ? v.join(" - ") : v + "";
1804
+ });
1730
1805
  return $3hooq$solidjsweb.ssr($d9239dad9a9d899b$var$_tmpl$3, $3hooq$solidjsweb.ssrHydrationKey(), "input-row ".concat(count() === 0 ? "count-0" : ""), $3hooq$solidjsweb.ssrAttribute("for", $3hooq$solidjsweb.escape(random_selector, true), false), $3hooq$solidjsweb.ssrAttribute("id", $3hooq$solidjsweb.escape(random_selector, true), false) + $3hooq$solidjsweb.ssrAttribute("name", $3hooq$solidjsweb.escape(radio_name, true), false), $3hooq$solidjsweb.ssrAttribute("checked", $3hooq$solidjs.createMemo(() => {
1731
1806
  var _existing_filter;
1732
1807
  const v = value();
1733
1808
  const data = (_existing_filter = existing_filter()) === null || _existing_filter === void 0 ? void 0 : _existing_filter.data;
1734
1809
  if ($e2d74bb03cc5252e$export$325f75597868c4f0(data) === $e2d74bb03cc5252e$export$325f75597868c4f0(v)) return true;
1735
1810
  return Array.isArray(data) && data.every((item, index) => item === v[index]);
1736
- })(), true), $3hooq$solidjsweb.escape($3hooq$solidjs.createMemo(() => {
1737
- var _filter_$meta, _filter_$meta$names;
1738
- 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];
1739
- if (name) return name;
1740
- const v = value();
1741
- return Array.isArray(v) ? v.join(" - ") : v;
1742
- })()), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
1811
+ })(), true), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $23c3f390dee33ff8$export$ba17c5b7e6dda39f), {
1812
+ whole_text_to_display_: label,
1813
+ searching_for_value_: () => filter_query_ === null || filter_query_ === void 0 ? void 0 : filter_query_()
1814
+ })), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
1743
1815
  get when() {
1744
1816
  return count() != undefined;
1745
1817
  },
@@ -1757,7 +1829,8 @@ function $0257c760a99bfacb$export$e0d834a0ad870cda(_ref) {
1757
1829
  let {
1758
1830
  filter_: filter_,
1759
1831
  selected_filters_: selected_filters_,
1760
- i18n_: i18n_
1832
+ i18n_: i18n_,
1833
+ filter_query_: filter_query_
1761
1834
  } = _ref;
1762
1835
  // 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
1763
1836
  // 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
@@ -1988,159 +2061,423 @@ function $ac040bdfeed58ee4$export$e5c2828934226505(_ref) {
1988
2061
  });
1989
2062
  return outer_div;
1990
2063
  }
1991
- const $9c1d49181fb3002a$var$_tmpl$ = ["<form", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></form>"],
1992
- $9c1d49181fb3002a$var$_tmpl$2 = ["<div", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></div>"],
1993
- $9c1d49181fb3002a$var$_tmpl$3 = ["<details", "></details>"],
1994
- $9c1d49181fb3002a$var$_tmpl$4 = ["<summary", ' class="category-parent"><div class="summary"><span class="', '">', "</span><!--$-->", "<!--/--></div></summary>"];
1995
- const $9c1d49181fb3002a$var$max_visible_without_collapsing = 15;
1996
- const $9c1d49181fb3002a$var$show_non_collapsible_when_collapsed = 4;
1997
- function $9c1d49181fb3002a$export$a32086fa6616eafd(_ref) {
2064
+ const $99472afa7112c427$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"];
2065
+ const $99472afa7112c427$var$dont_cut_in_between_less_than_characters = 30;
2066
+ function $99472afa7112c427$export$e1a98a189fd2c0e7(_ref) {
1998
2067
  let {
1999
- filter_: filter_,
2000
- selected_filters_: selected_filters_,
2001
- i18n_: i18n_,
2002
- view_more_button_below_group_: view_more_button_below_group_,
2003
- expanded_hierarchical_filters_: expanded_hierarchical_filters_
2068
+ content_result_: content_result_,
2069
+ key_: key_,
2070
+ cut_when_possible_: cut_when_possible_
2004
2071
  } = _ref;
2005
- let form;
2006
- const existing_filter = $3hooq$solidjs.createMemo(() => {
2007
- const {
2008
- field: field,
2009
- op: op
2010
- } = filter_();
2011
- return selected_filters_[0]().find(_ref2 => {
2012
- let {
2013
- field: checking_field,
2014
- op: checking_op
2015
- } = _ref2;
2016
- return checking_field === field && checking_op === op;
2017
- });
2018
- });
2019
- const show_extras = $3hooq$solidjs.createSignal(false);
2020
- const trigger_sync_ = $9c1d49181fb3002a$var$batching_filter_state_syncer({
2021
- filter_: filter_,
2022
- existing_filter_: existing_filter,
2023
- selected_filters_: selected_filters_,
2024
- get category_structure_() {
2025
- return structured_categories();
2026
- }
2027
- });
2028
- const structured_categories = $3hooq$solidjs.createMemo(() => {
2029
- const execute_when_structure_finished = [];
2030
- const {
2031
- values: values,
2032
- names: names,
2033
- counts: counts
2034
- } = filter_().meta;
2035
- const data_structure = {};
2036
- for (let i = 0; i < values.length; i++) {
2037
- const value = values[i];
2038
- let pointer = data_structure;
2039
- let parent_ = {};
2040
- let created_an_object = false;
2041
- for (let j = 0; j < value.length; j++) {
2042
- var _pointer;
2043
- const this_categories_name = value[j];
2044
- const obj = (_pointer = pointer)[this_categories_name] || (_pointer[this_categories_name] = (() => {
2045
- 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;
2046
- const created_obj = {
2047
- name_: names[i],
2048
- count_: counts === null || counts === void 0 ? void 0 : counts[i],
2049
- parent_: parent_,
2050
- is_expanded_: $9c1d49181fb3002a$var$make_expanded_signal({
2051
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2052
- filter_value_: value_as_string
2053
- }),
2054
- value_: value_as_string,
2055
- children_: {}
2056
- };
2057
- const {
2058
- signal_: signal_,
2059
- on_structure_complete_: on_structure_complete_
2060
- } = $9c1d49181fb3002a$var$create_updating_signal({
2061
- self_: created_obj,
2062
- existing_filter_: $3hooq$solidjs.untrack(existing_filter),
2063
- trigger_sync_: trigger_sync_
2064
- });
2065
- execute_when_structure_finished.push(on_structure_complete_);
2066
- created_obj.is_checked_ = signal_;
2067
- parent_ = created_obj;
2068
- created_an_object = true;
2069
- return created_obj;
2070
- })());
2071
- pointer = obj.children_;
2072
- parent_ = obj;
2073
- }
2074
- if (!created_an_object && "value_" in parent_) {
2075
- // 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
2076
- // [
2077
- // ["Öl", "IPA"],
2078
- // ["Öl", "Pale Ale"],
2079
- // ["Öl", "Ale"],
2080
- // ["Öl", "Mörk Lager"],
2081
- // ["Öl", "Suröl"],
2082
- // ["Öl", "Veteöl"],
2083
- // ["Öl", "Stout och Porter"],
2084
- // ["Öl"], // <- We are here, our `hierarchical_data_structure[string]`-object was created when we iterated over ["Öl", "IPA"]
2085
- // ["Öl", "Ljus Lager"],
2086
- // ];
2087
- // In this case we want to just correct the name and value of the already created object, which will be in parent_
2088
- parent_.value_ = value.map(v => v + "");
2089
- parent_.name_ = names[i];
2090
- parent_.count_ = counts[i];
2091
- parent_.is_expanded_ = $9c1d49181fb3002a$var$make_expanded_signal({
2092
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2093
- filter_value_: parent_.value_
2094
- });
2095
- }
2096
- }
2097
- while (execute_when_structure_finished.length) execute_when_structure_finished.pop()();
2098
- $9c1d49181fb3002a$var$expand_until_choice(data_structure);
2099
- $3hooq$depictaiutilishared.dlog("CheckboxHierarchicalFilter: Recomputed structured_categories", data_structure);
2100
- return data_structure;
2072
+ const matched_tokens = $3hooq$solidjs.createMemo(() => {
2073
+ var _content_result_$high, _content_result_$high2;
2074
+ 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;
2101
2075
  });
2102
- const some_top_level_are_hidden = $3hooq$solidjs.createMemo(() => Object.keys(structured_categories()).length > $9c1d49181fb3002a$var$max_visible_without_collapsing);
2103
- const {
2104
- expand: expand,
2105
- collapse: collapse,
2106
- ExpandingContainer: ExpandingContainer
2107
- } = $d6d51b09cb2116a6$export$5bad61ecde080b1f({
2108
- duration: 200
2076
+ const full_value = $3hooq$solidjs.createMemo(() => {
2077
+ var _content_result_$key_;
2078
+ return (_content_result_$key_ = content_result_()[key_]) === null || _content_result_$key_ === void 0 ? void 0 : _content_result_$key_.replaceAll("\n", " ");
2109
2079
  });
2110
- const expanding_container_els = $3hooq$solidjsweb.createComponent(ExpandingContainer, {
2080
+ return $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
2081
+ get when() {
2082
+ var _matched_tokens;
2083
+ return (_matched_tokens = matched_tokens()) === null || _matched_tokens === void 0 ? void 0 : _matched_tokens.length;
2084
+ },
2085
+ get fallback() {
2086
+ return full_value();
2087
+ },
2111
2088
  get children() {
2112
- return $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
2113
- get when() {
2114
- return some_top_level_are_hidden();
2115
- },
2116
- get children() {
2117
- return $9c1d49181fb3002a$var$render_stuff($3hooq$solidjs.createMemo(() => Object.fromEntries(Object.entries(structured_categories()).slice($9c1d49181fb3002a$var$show_non_collapsible_when_collapsed))), existing_filter, i18n_);
2118
- }
2119
- });
2089
+ return (() => {
2090
+ const segmented_cut_text = $3hooq$solidjs.createMemo(() => {
2091
+ const segmented_text = $99472afa7112c427$export$1b00d74faf266c56(full_value(), matched_tokens());
2092
+ if (cut_when_possible_) $99472afa7112c427$var$cut_text(segmented_text);
2093
+ return segmented_text;
2094
+ });
2095
+ return $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Index), {
2096
+ get each() {
2097
+ return segmented_cut_text();
2098
+ },
2099
+ children: item => {
2100
+ return $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
2101
+ get when() {
2102
+ return item().highlighted_;
2103
+ },
2104
+ get fallback() {
2105
+ return item().text_;
2106
+ },
2107
+ get children() {
2108
+ return $3hooq$solidjsweb.ssr($99472afa7112c427$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape(item().text_));
2109
+ }
2110
+ });
2111
+ }
2112
+ });
2113
+ })();
2120
2114
  }
2121
2115
  });
2122
- $3hooq$solidjs.createRenderEffect(() => {
2123
- view_more_button_below_group_[1](some_top_level_are_hidden() ? $3hooq$solidjsweb.createComponent((0, $b0477e4d832f090e$export$ca21a16d65b3dd8), {
2124
- show_extras_: show_extras,
2125
- i18n_: i18n_
2126
- }) : []);
2127
- });
2128
- $3hooq$solidjs.createEffect($3hooq$depictaiutilishared.catchify(async () => {
2129
- if (!some_top_level_are_hidden()) {
2130
- await collapse();
2131
- return;
2132
- }
2133
- if (show_extras[0]()) await expand();else await collapse();
2134
- }));
2135
- return $3hooq$solidjsweb.ssr($9c1d49181fb3002a$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), "checkboxes hierarchical ".concat(Object.values(structured_categories()).some(category => Object.keys(category.children_).length) ? "any-expandable" : ""), $3hooq$solidjsweb.escape($9c1d49181fb3002a$var$render_stuff($3hooq$solidjs.createMemo(() => some_top_level_are_hidden() ? Object.fromEntries(Object.entries(structured_categories()).slice(0, $9c1d49181fb3002a$var$show_non_collapsible_when_collapsed)) : structured_categories()), existing_filter, i18n_)), $3hooq$solidjsweb.escape(expanding_container_els));
2136
2116
  }
2137
- function $9c1d49181fb3002a$var$render_stuff(data, existing_filter, i18n_) {
2138
- const keys = $3hooq$solidjs.createMemo(() => Object.keys(data()));
2139
- return $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.For), {
2140
- get each() {
2141
- return keys();
2142
- },
2143
- children: key => $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
2117
+ function $99472afa7112c427$var$cut_text(segmented_text) {
2118
+ // cut away chunks of text that are not highlighted to give a google-like overview of the content
2119
+ const highlighted_segments = segmented_text === null || segmented_text === void 0 ? void 0 : segmented_text.filter(segment => segment.highlighted_);
2120
+ if (!segmented_text || !(highlighted_segments !== null && highlighted_segments !== void 0 && highlighted_segments.length)) return;
2121
+ // We have one or more highlighted segments
2122
+ if (highlighted_segments.length === 1) {
2123
+ // cut away from the left until the start of the highlighted sentence if just one sentence is highlighted
2124
+ $99472afa7112c427$var$cut_start(segmented_text.indexOf(highlighted_segments[0]), segmented_text);
2125
+ return;
2126
+ }
2127
+ // We have two or more highlighted segments, take the two biggest chunks and show them + a bit text around
2128
+ 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
2129
+ );
2130
+
2131
+ const [longest_segment, next_longest_segment] = sorted_highlighted_segments;
2132
+ // We need to cut before the first segment - possibly through other segments - and maybe between segments
2133
+ 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);
2134
+ $99472afa7112c427$var$cut_start(index_of_first_segment, segmented_text);
2135
+ // update indexes since we might have removed segments
2136
+ [index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
2137
+ let number_of_characters_between_segments = 0;
2138
+ for (let i = index_of_first_segment + 1; i < index_of_second_segment; i++) {
2139
+ const segment = segmented_text[i];
2140
+ number_of_characters_between_segments += segment.text_.length;
2141
+ }
2142
+ if (number_of_characters_between_segments < $99472afa7112c427$var$dont_cut_in_between_less_than_characters)
2143
+ // don't cut if there are less than 30 characters between the two segments
2144
+ return;
2145
+ // We have more than 50 characters between the two segments, cut between them
2146
+ const [split_start_segment, split_start_character] = $99472afa7112c427$var$find_split_point(index_of_first_segment, index_of_second_segment, segmented_text);
2147
+ const [split_end_segment, split_end_character] = $99472afa7112c427$var$find_split_point(index_of_second_segment, index_of_first_segment, segmented_text);
2148
+ if (split_start_segment === undefined || split_end_segment === undefined ||
2149
+ // identical split point, or split end before split start, can't do anything
2150
+ split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
2151
+ const dots_segment = {
2152
+ text_: " … ",
2153
+ highlighted_: false
2154
+ };
2155
+ const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
2156
+ if (i < split_start_segment || i > split_end_segment) return segment;
2157
+ const text = segment.text_;
2158
+ if (i == split_end_segment && i == split_start_segment) return [{
2159
+ ...segment,
2160
+ text_: text.slice(0, split_start_character).trimEnd()
2161
+ }, dots_segment, {
2162
+ ...segment,
2163
+ text_: text.slice(split_end_character + 1, text.length).trimStart()
2164
+ }];else if (i == split_start_segment) {
2165
+ 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
2166
+ return segment;
2167
+ } else if (i == split_end_segment) return [dots_segment, {
2168
+ ...segment,
2169
+ text_: text.slice(split_end_character + 1, text.length).trimStart()
2170
+ }];
2171
+ return []; // remove all segments inbetween
2172
+ });
2173
+
2174
+ segmented_text.splice(0, segmented_text.length, ...split_and_dotted_values); // Sorry…
2175
+ $99472afa7112c427$var$heal_holes(segmented_text);
2176
+ }
2177
+ function $99472afa7112c427$var$heal_holes(segmented_text) {
2178
+ // try to heal "holes" created in the segments so there are only alternating segments
2179
+ const segments_to_delete = new Set();
2180
+ for (let i = 0; i < segmented_text.length; i++) {
2181
+ var _previous_segment, _previous_segment2;
2182
+ const segment = segmented_text[i];
2183
+ let previous_segment;
2184
+ for (let j = i - 1; j >= 0; j--) {
2185
+ previous_segment = segmented_text[j];
2186
+ // Don't write to a segment that's marked for deletion or the contents we write to it will be deleted
2187
+ if (!segments_to_delete.has(previous_segment)) break;
2188
+ }
2189
+ 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) {
2190
+ previous_segment.text_ += segment.text_; // IDK if this ever happens
2191
+ segments_to_delete.add(segment);
2192
+ }
2193
+ }
2194
+ for (const segment of segments_to_delete) {
2195
+ const index = segmented_text.indexOf(segment);
2196
+ segmented_text.splice(index, 1);
2197
+ }
2198
+ }
2199
+ function $99472afa7112c427$var$find_split_point(index_of_start_segment, index_of_end_segment, segmented_text) {
2200
+ let be_very_aggressive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
2201
+ const should_loop_backwards = index_of_start_segment > index_of_end_segment;
2202
+ const step = should_loop_backwards ? -1 : 1;
2203
+ const desperate_split_attempts = [":", ";", ","];
2204
+ while (desperate_split_attempts.length) {
2205
+ const split_point_between_words = [];
2206
+ // for the middle also try to split with a few more characters if the default ones don't work over a full run
2207
+ const desperate_split_attempt = desperate_split_attempts.pop();
2208
+ let is_first_character = true;
2209
+ for (let i = index_of_start_segment + step; should_loop_backwards ? i > index_of_end_segment : i < index_of_end_segment; i += step) {
2210
+ const segment = segmented_text[i];
2211
+ const text = segment.text_;
2212
+ for (let j = should_loop_backwards ? text.length - 1 : 0; should_loop_backwards ? j >= 0 : j < text.length; j += step) {
2213
+ const character = text[j];
2214
+ if (character == "." || character == "?" || character == "!" || character == desperate_split_attempt) return [i, j]; // segment index, character index
2215
+ if (is_first_character) is_first_character = false;else if (be_very_aggressive && character == " ") {
2216
+ split_point_between_words.push([i, j]);
2217
+ if (split_point_between_words.length > 3)
2218
+ // We can't find a split point, so we'll just split between words
2219
+ // 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
2220
+ return split_point_between_words[1];
2221
+ }
2222
+ }
2223
+ }
2224
+ }
2225
+ return [];
2226
+ }
2227
+ function $99472afa7112c427$var$cut_start(cut_left_of_index, segmented_text) {
2228
+ // Cut the start of the text to bring the first matching token
2229
+ let is_first_character = false;
2230
+ let words_encountered = 0;
2231
+ outmost_loop: for (let i = cut_left_of_index - 1; i >= 0; i--) {
2232
+ const segment = segmented_text[i];
2233
+ // We assume that two adjacent highlighted segments don't exist and have been merged if they were to have existed
2234
+ const text = segment.text_;
2235
+ for (let j = text.length - 1; j >= 0; j--) {
2236
+ const character = text[j];
2237
+ const is_space = character == " ";
2238
+ if (!is_first_character && is_space) words_encountered++;
2239
+ if (character == "." || character == "?" || character == "!" || character == "," || words_encountered > 8 && is_space) {
2240
+ // We have to be really aggressive at the start of sentences so stuff can be seen on mobile, hence comma
2241
+ segment.text_ = text.slice(j + 1).trimStart();
2242
+ segmented_text.splice(0, i);
2243
+ if (character === "," || is_space)
2244
+ // if we cut at a comma or psace, we add a … at the beginning
2245
+ segmented_text.unshift({
2246
+ text_: "… ",
2247
+ highlighted_: false
2248
+ });
2249
+ break outmost_loop;
2250
+ }
2251
+ if (is_first_character) is_first_character = false;
2252
+ }
2253
+ }
2254
+ $99472afa7112c427$var$heal_holes(segmented_text); // if we added a ... there could now be a sequence that's not alternating true/false
2255
+ }
2256
+
2257
+ function $99472afa7112c427$export$1b00d74faf266c56(text, matched_strings) {
2258
+ let loose = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
2259
+ const output = [];
2260
+ if (!text) return; // shouldn't happen but whatever
2261
+ for (let i = 0; i < text.length; i++) {
2262
+ const found_strings = [];
2263
+ if (!i || text[i - 1] == " " || loose)
2264
+ // only match at the start of a word or string, it looks weird if i.e. "we" is highlighted in "activewear
2265
+ for (let j = 0; j < matched_strings.length; j++) {
2266
+ const matched_string = matched_strings[j];
2267
+ const part_in_text = text.slice(i, i + matched_string.length);
2268
+ if (matched_string.length < 2 && !loose) continue; // don't match on single characters, i.e. "I", it looks weird
2269
+ 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
2270
+ }
2271
+
2272
+ const last_index_in_output = output.length - 1;
2273
+ if (!found_strings.length) {
2274
+ var _output$last_index_in;
2275
+ const character = text[i];
2276
+ 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))
2277
+ // 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
2278
+ output[last_index_in_output].text_ += character;else output.push({
2279
+ highlighted_: false,
2280
+ text_: character
2281
+ });
2282
+ } else {
2283
+ var _output$last_index_in2;
2284
+ const longest_found_string = found_strings.reduce((a, b) => a.length > b.length ? a : b);
2285
+ 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({
2286
+ highlighted_: true,
2287
+ text_: longest_found_string
2288
+ });
2289
+ i += longest_found_string.length - 1;
2290
+ }
2291
+ }
2292
+ return output;
2293
+ }
2294
+ const $dc5db6bf7093867a$var$_tmpl$ = ["<span", ' class="', '">', "</span>"],
2295
+ $dc5db6bf7093867a$var$_tmpl$2 = ["<span", ' class="highlighted-part">', "</span>"];
2296
+ function $dc5db6bf7093867a$export$8e79c28529dbfa90(props) {
2297
+ const segmented_text = $3hooq$solidjs.createMemo(() => {
2298
+ const {
2299
+ to_highlight_: to_highlight_,
2300
+ text_: text_
2301
+ } = props;
2302
+ return $99472afa7112c427$export$1b00d74faf266c56(text_, to_highlight_ ? [to_highlight_] : [], true);
2303
+ });
2304
+ const has_highlights = $3hooq$solidjs.createMemo(() => segmented_text().some(segment => segment.highlighted_));
2305
+ return $3hooq$solidjsweb.ssr($dc5db6bf7093867a$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey() + $3hooq$solidjsweb.ssrAttribute("title", $3hooq$solidjsweb.escape(props.text_, true), false), has_highlights() ? "has-match" : "", $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Index), {
2306
+ get each() {
2307
+ return segmented_text();
2308
+ },
2309
+ children: item => {
2310
+ return $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
2311
+ get when() {
2312
+ return item().highlighted_;
2313
+ },
2314
+ get fallback() {
2315
+ return item().text_;
2316
+ },
2317
+ get children() {
2318
+ return $3hooq$solidjsweb.ssr($dc5db6bf7093867a$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape(item().text_));
2319
+ }
2320
+ });
2321
+ }
2322
+ })));
2323
+ }
2324
+ const $9c1d49181fb3002a$var$_tmpl$ = ["<form", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></form>"],
2325
+ $9c1d49181fb3002a$var$_tmpl$2 = ["<div", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></div>"],
2326
+ $9c1d49181fb3002a$var$_tmpl$3 = ["<details", "></details>"],
2327
+ $9c1d49181fb3002a$var$_tmpl$4 = ["<summary", ' class="category-parent"><div class="summary"><span class="', '">', "</span><!--$-->", "<!--/--></div></summary>"];
2328
+ const $9c1d49181fb3002a$var$max_visible_without_collapsing = 15;
2329
+ const $9c1d49181fb3002a$var$show_non_collapsible_when_collapsed = 4;
2330
+ function $9c1d49181fb3002a$export$a32086fa6616eafd(_ref) {
2331
+ let {
2332
+ filter_: filter_,
2333
+ selected_filters_: selected_filters_,
2334
+ i18n_: i18n_,
2335
+ view_more_button_below_group_: view_more_button_below_group_,
2336
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2337
+ filter_query_: filter_query_
2338
+ } = _ref;
2339
+ let form;
2340
+ const existing_filter = $3hooq$solidjs.createMemo(() => {
2341
+ const {
2342
+ field: field,
2343
+ op: op
2344
+ } = filter_();
2345
+ return selected_filters_[0]().find(_ref2 => {
2346
+ let {
2347
+ field: checking_field,
2348
+ op: checking_op
2349
+ } = _ref2;
2350
+ return checking_field === field && checking_op === op;
2351
+ });
2352
+ });
2353
+ const show_extras = $3hooq$solidjs.createSignal(false);
2354
+ const is_being_searched_ = $3hooq$solidjs.createMemo(() => !!(filter_query_ !== null && filter_query_ !== void 0 && filter_query_())); // If the user is searching in the filter
2355
+ const trigger_sync_ = $9c1d49181fb3002a$var$batching_filter_state_syncer({
2356
+ filter_: filter_,
2357
+ existing_filter_: existing_filter,
2358
+ selected_filters_: selected_filters_,
2359
+ get category_structure_() {
2360
+ return structured_categories();
2361
+ }
2362
+ });
2363
+ const structured_categories = $3hooq$solidjs.createMemo(() => {
2364
+ const execute_when_structure_finished = [];
2365
+ const {
2366
+ values: values,
2367
+ names: names,
2368
+ counts: counts
2369
+ } = filter_().meta;
2370
+ const data_structure = {};
2371
+ for (let i = 0; i < values.length; i++) {
2372
+ const value = values[i];
2373
+ let pointer = data_structure;
2374
+ let parent_ = {};
2375
+ let created_an_object = false;
2376
+ for (let j = 0; j < value.length; j++) {
2377
+ var _pointer;
2378
+ const this_categories_name = value[j];
2379
+ const obj = (_pointer = pointer)[this_categories_name] || (_pointer[this_categories_name] = (() => {
2380
+ 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;
2381
+ const created_obj = {
2382
+ name_: names[i],
2383
+ count_: counts === null || counts === void 0 ? void 0 : counts[i],
2384
+ parent_: parent_,
2385
+ is_expanded_: $9c1d49181fb3002a$var$make_expanded_signal({
2386
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2387
+ filter_value_: value_as_string,
2388
+ is_being_searched_: is_being_searched_
2389
+ }),
2390
+ value_: value_as_string,
2391
+ children_: {}
2392
+ };
2393
+ const {
2394
+ signal_: signal_,
2395
+ on_structure_complete_: on_structure_complete_
2396
+ } = $9c1d49181fb3002a$var$create_updating_signal({
2397
+ self_: created_obj,
2398
+ existing_filter_: $3hooq$solidjs.untrack(existing_filter),
2399
+ trigger_sync_: trigger_sync_
2400
+ });
2401
+ execute_when_structure_finished.push(on_structure_complete_);
2402
+ created_obj.is_checked_ = signal_;
2403
+ parent_ = created_obj;
2404
+ created_an_object = true;
2405
+ return created_obj;
2406
+ })());
2407
+ pointer = obj.children_;
2408
+ parent_ = obj;
2409
+ }
2410
+ if (!created_an_object && "value_" in parent_) {
2411
+ // 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
2412
+ // [
2413
+ // ["Öl", "IPA"],
2414
+ // ["Öl", "Pale Ale"],
2415
+ // ["Öl", "Ale"],
2416
+ // ["Öl", "Mörk Lager"],
2417
+ // ["Öl", "Suröl"],
2418
+ // ["Öl", "Veteöl"],
2419
+ // ["Öl", "Stout och Porter"],
2420
+ // ["Öl"], // <- We are here, our `hierarchical_data_structure[string]`-object was created when we iterated over ["Öl", "IPA"]
2421
+ // ["Öl", "Ljus Lager"],
2422
+ // ];
2423
+ // In this case we want to just correct the name and value of the already created object, which will be in parent_
2424
+ parent_.value_ = value.map(v => v + "");
2425
+ parent_.name_ = names[i];
2426
+ parent_.count_ = counts === null || counts === void 0 ? void 0 : counts[i];
2427
+ parent_.is_expanded_ = $9c1d49181fb3002a$var$make_expanded_signal({
2428
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2429
+ filter_value_: parent_.value_,
2430
+ is_being_searched_: is_being_searched_
2431
+ });
2432
+ }
2433
+ }
2434
+ while (execute_when_structure_finished.length) execute_when_structure_finished.pop()();
2435
+ $9c1d49181fb3002a$var$expand_until_choice(data_structure);
2436
+ $3hooq$depictaiutilishared.dlog("CheckboxHierarchicalFilter: Recomputed structured_categories", data_structure);
2437
+ return data_structure;
2438
+ });
2439
+ const some_top_level_are_hidden = $3hooq$solidjs.createMemo(() => Object.keys(structured_categories()).length > $9c1d49181fb3002a$var$max_visible_without_collapsing);
2440
+ const {
2441
+ expand: expand,
2442
+ collapse: collapse,
2443
+ ExpandingContainer: ExpandingContainer
2444
+ } = $d6d51b09cb2116a6$export$5bad61ecde080b1f({
2445
+ duration: 200
2446
+ });
2447
+ const expanding_container_els = $3hooq$solidjsweb.createComponent(ExpandingContainer, {
2448
+ get children() {
2449
+ return $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
2450
+ get when() {
2451
+ return some_top_level_are_hidden();
2452
+ },
2453
+ get children() {
2454
+ return $9c1d49181fb3002a$var$render_stuff($3hooq$solidjs.createMemo(() => Object.fromEntries(Object.entries(structured_categories()).slice($9c1d49181fb3002a$var$show_non_collapsible_when_collapsed))), existing_filter, i18n_, filter_query_);
2455
+ }
2456
+ });
2457
+ }
2458
+ });
2459
+ $3hooq$solidjs.createRenderEffect(() => {
2460
+ view_more_button_below_group_[1](some_top_level_are_hidden() ? $3hooq$solidjsweb.createComponent((0, $b0477e4d832f090e$export$ca21a16d65b3dd8), {
2461
+ show_extras_: show_extras,
2462
+ i18n_: i18n_
2463
+ }) : []);
2464
+ });
2465
+ $3hooq$solidjs.createEffect($3hooq$depictaiutilishared.catchify(async () => {
2466
+ if (!some_top_level_are_hidden()) {
2467
+ await collapse();
2468
+ return;
2469
+ }
2470
+ if (show_extras[0]()) await expand();else await collapse();
2471
+ }));
2472
+ return $3hooq$solidjsweb.ssr($9c1d49181fb3002a$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), "checkboxes hierarchical ".concat(Object.values(structured_categories()).some(category => Object.keys(category.children_).length) ? "any-expandable" : ""), $3hooq$solidjsweb.escape($9c1d49181fb3002a$var$render_stuff($3hooq$solidjs.createMemo(() => some_top_level_are_hidden() ? Object.fromEntries(Object.entries(structured_categories()).slice(0, $9c1d49181fb3002a$var$show_non_collapsible_when_collapsed)) : structured_categories()), existing_filter, i18n_, filter_query_)), $3hooq$solidjsweb.escape(expanding_container_els));
2473
+ }
2474
+ function $9c1d49181fb3002a$var$render_stuff(data, existing_filter, i18n_, filter_query_) {
2475
+ const keys = $3hooq$solidjs.createMemo(() => Object.keys(data()));
2476
+ return $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.For), {
2477
+ get each() {
2478
+ return keys();
2479
+ },
2480
+ children: key => $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
2144
2481
  get when() {
2145
2482
  return $3hooq$solidjs.createMemo(() => !!data()[key])();
2146
2483
  },
@@ -2152,14 +2489,27 @@ function $9c1d49181fb3002a$var$render_stuff(data, existing_filter, i18n_) {
2152
2489
  var _value;
2153
2490
  return !!Object.keys(((_value = value()) === null || _value === void 0 ? void 0 : _value.children_) || {}).length;
2154
2491
  });
2492
+ const value_as_string = $3hooq$solidjs.createMemo(() => {
2493
+ var _value2;
2494
+ return JSON.stringify((_value2 = value()) === null || _value2 === void 0 ? void 0 : _value2.value_);
2495
+ });
2496
+ const label_text = $3hooq$solidjs.createMemo(() => {
2497
+ var _value3;
2498
+ return ((_value3 = value()) === null || _value3 === void 0 ? void 0 : _value3.name_) || value_as_string();
2499
+ });
2155
2500
  return $3hooq$solidjsweb.ssr($9c1d49181fb3002a$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), "checkbox-details ".concat(has_expandable() ? "expandable" : ""), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $902a0ca2b52f3898$export$48513f6b9f8ce62d), {
2156
2501
  get value_() {
2157
- var _value2;
2158
- return JSON.stringify((_value2 = value()) === null || _value2 === void 0 ? void 0 : _value2.value_);
2502
+ return value_as_string();
2159
2503
  },
2160
2504
  get label_() {
2161
- var _value3;
2162
- return (_value3 = value()) === null || _value3 === void 0 ? void 0 : _value3.name_;
2505
+ return $3hooq$solidjsweb.createComponent((0, $dc5db6bf7093867a$export$8e79c28529dbfa90), {
2506
+ get text_() {
2507
+ return label_text();
2508
+ },
2509
+ get to_highlight_() {
2510
+ return filter_query_ === null || filter_query_ === void 0 ? void 0 : filter_query_();
2511
+ }
2512
+ });
2163
2513
  },
2164
2514
  get count_() {
2165
2515
  var _value4;
@@ -2243,7 +2593,7 @@ function $9c1d49181fb3002a$var$render_stuff(data, existing_filter, i18n_) {
2243
2593
  return $9c1d49181fb3002a$var$render_stuff($3hooq$solidjs.createMemo(() => {
2244
2594
  var _value13;
2245
2595
  return ((_value13 = value()) === null || _value13 === void 0 ? void 0 : _value13.children_) || {};
2246
- }), existing_filter, i18n_);
2596
+ }), existing_filter, i18n_, filter_query_);
2247
2597
  }
2248
2598
  });
2249
2599
  })();
@@ -2358,7 +2708,8 @@ function $9c1d49181fb3002a$var$make_expanded_signal(_ref5) {
2358
2708
  var _untrack$untrack;
2359
2709
  let {
2360
2710
  expanded_hierarchical_filters_: [read_expanded_hierarchical_filters, write_expanded_hierarchical_filters],
2361
- filter_value_: filter_value_
2711
+ filter_value_: filter_value_,
2712
+ is_being_searched_: is_being_searched_
2362
2713
  } = _ref5;
2363
2714
  const index_in_expanded_filters = $3hooq$solidjs.createMemo(() => read_expanded_hierarchical_filters().findIndex(_ref6 => {
2364
2715
  let {
@@ -2401,9 +2752,11 @@ function $9c1d49181fb3002a$var$make_expanded_signal(_ref5) {
2401
2752
  defer: true
2402
2753
  }));
2403
2754
  return {
2404
- ui_should_show_expanded_: $3hooq$solidjs.createMemo(() => {
2755
+ ui_should_show_expanded_: $3hooq$solidjs.createMemo(
2756
+ // When user is searching through filters, expand everything they haven't collapsed, so they can see the results
2757
+ () => {
2405
2758
  var _user_choice_signal$;
2406
- return (_user_choice_signal$ = user_choice_signal[0]()) !== null && _user_choice_signal$ !== void 0 ? _user_choice_signal$ : get_low_precedence_expanded();
2759
+ return (_user_choice_signal$ = user_choice_signal[0]()) !== null && _user_choice_signal$ !== void 0 ? _user_choice_signal$ : is_being_searched_() || get_low_precedence_expanded();
2407
2760
  }),
2408
2761
  set_low_precedence_expanded_: set_low_precedence_expanded,
2409
2762
  set_user_expanded_: set_user_choice_expanded
@@ -2433,7 +2786,9 @@ const $cd0e5524f9476f9b$var$max_columns = 3;
2433
2786
  const $cd0e5524f9476f9b$export$414f6a19d38e655c = _ref => {
2434
2787
  let {
2435
2788
  filter_: filter_,
2436
- selected_filters_: [get_selected_filters, set_selected_filters]
2789
+ selected_filters_: [get_selected_filters, set_selected_filters],
2790
+ filter_query_: filter_query_,
2791
+ details_element_width_: details_element_width_
2437
2792
  } = _ref;
2438
2793
  const existing_filter = $3hooq$solidjs.createMemo(() => {
2439
2794
  const {
@@ -2467,7 +2822,7 @@ const $cd0e5524f9476f9b$export$414f6a19d38e655c = _ref => {
2467
2822
  const container_width_accessor = $3hooq$solidjs.createMemo(() => {
2468
2823
  const element = container();
2469
2824
  if (!element) return;
2470
- return $13671aa5e984acd9$export$9f191182275e9ef(element);
2825
+ return $c387d7f1d9fb66c0$export$ebdc3711f7e02ccd(element);
2471
2826
  });
2472
2827
  const [shadow_children, set_shadow_children] = $3hooq$solidjs.createSignal(new Set(), {
2473
2828
  equals: false
@@ -2475,11 +2830,11 @@ const $cd0e5524f9476f9b$export$414f6a19d38e655c = _ref => {
2475
2830
  const shadow_grid = $3hooq$solidjsweb.ssr($cd0e5524f9476f9b$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape([...shadow_children()])); // for getting the smallest possible sizes of all the items
2476
2831
  $3hooq$solidjs.createEffect(() => {
2477
2832
  var _container_width_acce;
2478
- const container_width = (_container_width_acce = container_width_accessor()) === null || _container_width_acce === void 0 ? void 0 : _container_width_acce();
2479
- if (container_width == undefined) return;
2833
+ const container_width = ((_container_width_acce = container_width_accessor()) === null || _container_width_acce === void 0 ? void 0 : _container_width_acce()) || details_element_width_();
2834
+ 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
2480
2835
  $cd0e5524f9476f9b$var$adjust_sizes(container_width, sizes_set(), set_cols_at_size);
2481
2836
  });
2482
- return [shadow_grid, $3hooq$solidjsweb.createComponent((0, $6c2c739b113a8ddf$export$d21e32dfedac04be), {
2837
+ return [$3hooq$solidjsweb.createComponent((0, $6c2c739b113a8ddf$export$d21e32dfedac04be), {
2483
2838
  get cols_at_size() {
2484
2839
  return cols_at_size();
2485
2840
  },
@@ -2502,27 +2857,33 @@ const $cd0e5524f9476f9b$export$414f6a19d38e655c = _ref => {
2502
2857
  const current_value = $e2d74bb03cc5252e$export$325f75597868c4f0(value().value_);
2503
2858
  return !!(data !== null && data !== void 0 && data.some(item => $e2d74bb03cc5252e$export$325f75597868c4f0(item) === current_value));
2504
2859
  });
2505
- const MakeButton = attributes => $3hooq$solidjsweb.ssrElement("button", $3hooq$solidjsweb.mergeProps(attributes, {
2506
- get disabled() {
2507
- return value().count_ === 0 && !is_selected();
2508
- },
2509
- get classList() {
2510
- return {
2511
- minor: !is_selected(),
2512
- major: is_selected(),
2513
- "major-minor-transition": true
2514
- };
2515
- }
2516
- }), () => ["<!--$-->", $3hooq$solidjsweb.escape(value().value_), "<!--/-->", "<!--$-->", $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
2517
- get when() {
2518
- return value().count_ != undefined;
2519
- },
2520
- get children() {
2521
- return $3hooq$solidjsweb.ssr($cd0e5524f9476f9b$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape(value().count_));
2522
- }
2523
- })), "<!--/-->"], true);
2860
+ const MakeButton = attributes => {
2861
+ const label = $3hooq$solidjs.createMemo(() => value().name_ || value().value_ + "");
2862
+ return $3hooq$solidjsweb.ssrElement("button", $3hooq$solidjsweb.mergeProps(attributes, {
2863
+ get disabled() {
2864
+ return value().count_ === 0 && !is_selected();
2865
+ },
2866
+ get classList() {
2867
+ return {
2868
+ minor: !is_selected(),
2869
+ major: is_selected(),
2870
+ "major-minor-transition": true
2871
+ };
2872
+ }
2873
+ }), () => ["<!--$-->", $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $23c3f390dee33ff8$export$ba17c5b7e6dda39f), {
2874
+ whole_text_to_display_: label,
2875
+ searching_for_value_: () => filter_query_ === null || filter_query_ === void 0 ? void 0 : filter_query_()
2876
+ })), "<!--/-->", "<!--$-->", $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
2877
+ get when() {
2878
+ return value().count_ != undefined;
2879
+ },
2880
+ get children() {
2881
+ return $3hooq$solidjsweb.ssr($cd0e5524f9476f9b$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape(value().count_));
2882
+ }
2883
+ })), "<!--/-->"], true);
2884
+ };
2524
2885
  const invisible_size_button = $3hooq$solidjsweb.createComponent(MakeButton, {});
2525
- const smallest_possible_size = $13671aa5e984acd9$export$9f191182275e9ef(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
2886
+ const smallest_possible_size = $c387d7f1d9fb66c0$export$ebdc3711f7e02ccd(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
2526
2887
  const sizes_value = $3hooq$solidjs.untrack(sizes_set);
2527
2888
  const shadow_children_value = $3hooq$solidjs.untrack(shadow_children);
2528
2889
  sizes_value.add(smallest_possible_size);
@@ -2542,7 +2903,7 @@ const $cd0e5524f9476f9b$export$414f6a19d38e655c = _ref => {
2542
2903
  }
2543
2904
  });
2544
2905
  }
2545
- })];
2906
+ }), shadow_grid];
2546
2907
  };
2547
2908
  /**
2548
2909
  * Calculate and apply cols_at_size overrides to fit as many items as possible in a row, evenly spaced
@@ -2610,7 +2971,8 @@ function $476a3dc36afc1938$export$82ed4b28ecb67608(_ref) {
2610
2971
  filter_: filter_,
2611
2972
  selected_filters_: [get_selected_filters, set_selected_filters],
2612
2973
  i18n_: i18n_,
2613
- view_more_button_below_group_: [_get_view_more_button_below_group_, set_view_more_button_below_group_]
2974
+ view_more_button_below_group_: [_get_view_more_button_below_group_, set_view_more_button_below_group_],
2975
+ filter_query_: filter_query_
2614
2976
  } = _ref;
2615
2977
  // same as in CheckboxFilter, maybe we should make this DRY at some point
2616
2978
  const existing_filter = $3hooq$solidjs.createMemo(() => {
@@ -2655,12 +3017,17 @@ function $476a3dc36afc1938$export$82ed4b28ecb67608(_ref) {
2655
3017
  const value = $e2d74bb03cc5252e$export$325f75597868c4f0(checkbox().value_);
2656
3018
  return !!(data !== null && data !== void 0 && data.some(item => $e2d74bb03cc5252e$export$325f75597868c4f0(item) === value));
2657
3019
  });
3020
+ const value = $3hooq$solidjs.createMemo(() => checkbox().value_);
3021
+ const label_text = $3hooq$solidjs.createMemo(() => checkbox().name_ || value() + "");
2658
3022
  const input_row = $3hooq$solidjsweb.createComponent((0, $902a0ca2b52f3898$export$48513f6b9f8ce62d), {
2659
3023
  get value_() {
2660
- return checkbox().value_;
3024
+ return value();
2661
3025
  },
2662
3026
  get label_() {
2663
- return checkbox().name_;
3027
+ return $3hooq$solidjsweb.createComponent((0, $23c3f390dee33ff8$export$ba17c5b7e6dda39f), {
3028
+ whole_text_to_display_: label_text,
3029
+ searching_for_value_: () => filter_query_ === null || filter_query_ === void 0 ? void 0 : filter_query_()
3030
+ });
2664
3031
  },
2665
3032
  get count_() {
2666
3033
  return checkbox().count_;
@@ -2918,10 +3285,154 @@ function $a7f7d416e6f61504$export$89c6019e4baa40b1(props) {
2918
3285
  }
2919
3286
  });
2920
3287
  }
3288
+ const $5b88b077e48a4451$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>';
3289
+ function $5b88b077e48a4451$export$82eafebb825fc23f() {
3290
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3291
+ return $3hooq$solidjsweb.ssrElement("svg", $3hooq$solidjsweb.mergeProps({
3292
+ xmlns: "http://www.w3.org/2000/svg",
3293
+ width: "20",
3294
+ height: "22",
3295
+ viewBox: "0 0 20 22"
3296
+ }, props), () => $3hooq$solidjsweb.ssr($5b88b077e48a4451$var$_tmpl$), true);
3297
+ }
3298
+ const $8e7ac26c00243687$var$_tmpl$ = ["<div", ' class="search-in-filters"><input type="text" class="query"', "><!--$-->", '<!--/--><button style="', '" class="clear-filter-search">', "</button></div>"];
3299
+ const $8e7ac26c00243687$var$min_items_to_enable_filter_searching = 10; // For checkbox hierarchical we 2x this
3300
+ function $8e7ac26c00243687$export$4b2c5292ffe0c5dd(filter_array_, section, i18n_) {
3301
+ const [filter_query_, set_filter_query_] = $3hooq$solidjs.createSignal();
3302
+ // Check if we have enough items to enable searching
3303
+ const enable_searchability = $3hooq$solidjs.createMemo(() => {
3304
+ let count = 0;
3305
+ for (const filter of filter_array_()) {
3306
+ var _filter$meta;
3307
+ const type = (_filter$meta = filter.meta) === null || _filter$meta === void 0 ? void 0 : _filter$meta.type;
3308
+ if (type === "range") continue;
3309
+ const length = filter.meta.values.length;
3310
+ count += type === "checkbox-color" || type === "checkbox-grid" ? length / 3 : length; // For checkbox-color we have two columns, checkbox-grid three, so we can show search later
3311
+ }
3312
+
3313
+ return count >= $8e7ac26c00243687$var$min_items_to_enable_filter_searching;
3314
+ });
3315
+ const SearchThisFilterGroup_ = () => {
3316
+ return $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
3317
+ get when() {
3318
+ return enable_searchability();
3319
+ },
3320
+ get children() {
3321
+ return $3hooq$solidjsweb.ssr($8e7ac26c00243687$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.ssrAttribute("value", $3hooq$solidjsweb.escape(filter_query_(), true) || "", false) + $3hooq$solidjsweb.ssrAttribute("placeholder", $3hooq$solidjsweb.escape(i18n_.search_a_filter_()(section), true), false), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $5b88b077e48a4451$export$82eafebb825fc23f), {
3322
+ width: "16",
3323
+ height: "17.6",
3324
+ "class": "search-icon"
3325
+ })), "display:" + (filter_query_() ? "" : "none"), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $083b2336093176cf$export$3b621d86b1566b2), {
3326
+ width: "12",
3327
+ height: "12"
3328
+ })));
3329
+ }
3330
+ });
3331
+ };
3332
+ const searched_filter_array_ = $3hooq$solidjs.createMemo(() => {
3333
+ const query = filter_query_();
3334
+ if (!enable_searchability() || !query) return filter_array_();
3335
+ const lowercase_query = query.toLowerCase();
3336
+ const check_string_match = to_check => {
3337
+ to_check = to_check.toLowerCase();
3338
+ return to_check.includes(lowercase_query) || lowercase_query.includes(to_check);
3339
+ };
3340
+ return filter_array_().map(filter => {
3341
+ var _filter$meta2, _meta$names;
3342
+ const type = (_filter$meta2 = filter.meta) === null || _filter$meta2 === void 0 ? void 0 : _filter$meta2.type;
3343
+ 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
3344
+ const meta = filter.meta;
3345
+ const {
3346
+ values: values,
3347
+ names: names,
3348
+ counts: counts
3349
+ } = meta;
3350
+ 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
3351
+ const is_hierarchical_checkbox = type === "checkbox-hierarchical";
3352
+ // Which index of counts, values and names should be kept
3353
+ const filtered_indexes = values.map((item, index) => {
3354
+ const item_from_names = names === null || names === void 0 ? void 0 : names[index];
3355
+ if (item_from_names && !is_hierarchical_checkbox)
3356
+ // 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
3357
+ item = item_from_names;
3358
+ if (typeof item === "number") return true;
3359
+ if (is_hierarchical_checkbox && names)
3360
+ // Special case for hierarchical checkboxes where we need to check if any of the names in the path match the query
3361
+ item = item.map((_, index) => names[$8e7ac26c00243687$var$find_str_arr_in_str_arr_arr("findIndex", values, item.slice(0, index + 1))]);
3362
+ if (Array.isArray(item)) return item.some(item => check_string_match(item + "")); // If any of the items in the array match, keep it
3363
+ return check_string_match(item);
3364
+ });
3365
+ const new_values = values.filter((_, i) => filtered_indexes[i]);
3366
+ if (!new_values.length) return false; // false = please delete this filter, see below
3367
+ const new_filter_object = {
3368
+ ...filter,
3369
+ meta: {
3370
+ ...meta,
3371
+ ...(counts ? {
3372
+ counts: counts === null || counts === void 0 ? void 0 : counts.filter((_, i) => filtered_indexes[i])
3373
+ } : {}),
3374
+ ...(names ? {
3375
+ names: (_meta$names = meta.names) === null || _meta$names === void 0 ? void 0 : _meta$names.filter((_, i) => filtered_indexes[i])
3376
+ } : {}),
3377
+ values: new_values
3378
+ }
3379
+ };
3380
+ if (is_hierarchical_checkbox) {
3381
+ // For hierarchical checkbox we need to fill the holes created by filtering, for example if there is
3382
+ // ["Clothes"]
3383
+ // ["Clothes", "Blazers"]
3384
+ // And the user searched for "blazers" we need to add back ["Clothes"] so CheckboxHierarchicalFilter doesn't get confused
3385
+ // 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
3386
+ // So we do it here instead
3387
+ const new_meta = new_filter_object.meta;
3388
+ const new_values = new_meta.values;
3389
+ for (const value of new_values) {
3390
+ if (!Array.isArray(value)) continue; // Shouldn't happen
3391
+ if (value.length < 2) continue; // No parent
3392
+ const parent = value.slice(0, -1);
3393
+ // Check if parent exists
3394
+ if ($8e7ac26c00243687$var$find_str_arr_in_str_arr_arr("some", new_values, parent)) continue; // Parent exists
3395
+ // Otherwise, put it back
3396
+ const index_to_restore = $8e7ac26c00243687$var$find_str_arr_in_str_arr_arr("findIndex", values, parent);
3397
+ if (index_to_restore < 0) {
3398
+ $3hooq$depictaiutilishared.dwarn("Can't restore", parent, "to", new_values);
3399
+ continue;
3400
+ }
3401
+ const current_index_of_us = new_values.findIndex(item => item === value);
3402
+ new_values.splice(current_index_of_us, 0, values[index_to_restore]);
3403
+ const count_to_restore = counts === null || counts === void 0 ? void 0 : counts[index_to_restore];
3404
+ if (count_to_restore) {
3405
+ var _new_meta$counts;
3406
+ (_new_meta$counts = new_meta.counts) === null || _new_meta$counts === void 0 || _new_meta$counts.splice(current_index_of_us, 0, count_to_restore);
3407
+ }
3408
+ const name_to_restore = names === null || names === void 0 ? void 0 : names[index_to_restore];
3409
+ if (name_to_restore) {
3410
+ var _new_meta$names;
3411
+ (_new_meta$names = new_meta.names) === null || _new_meta$names === void 0 || _new_meta$names.splice(current_index_of_us, 0, name_to_restore);
3412
+ }
3413
+ }
3414
+ }
3415
+ return new_filter_object;
3416
+ }).filter(filter => filter); // Delete filters that don't have a value anymore
3417
+ });
3418
+
3419
+ return {
3420
+ SearchThisFilterGroup_: SearchThisFilterGroup_,
3421
+ searched_filter_array_: searched_filter_array_,
3422
+ filter_query_: filter_query_
3423
+ };
3424
+ }
3425
+ /**
3426
+ * Finds/whatevers what's effectively one hierarchical filter item in an array of hierarchical filter items
3427
+ * Functions similar to this happen loads in create_modified_filters, but they have additional checks so not touching them RN
3428
+ */
3429
+ function $8e7ac26c00243687$var$find_str_arr_in_str_arr_arr(operation, haystack, needle) {
3430
+ return haystack[operation](value => value.length === needle.length && value.every((item, index) => item === needle[index]));
3431
+ }
2921
3432
  const $164d474fea221d77$var$_tmpl$ = ["<div", ' class="filter-collapsible">', "</div>"],
2922
3433
  $164d474fea221d77$var$_tmpl$2 = ["<button", ' class="clear-group"><!--$-->', "<!--/--><span>", "</span></button>"],
2923
3434
  $164d474fea221d77$var$_tmpl$3 = ["<div", ' class="view-more-clear"><!--$-->', "<!--/--><!--$-->", "<!--/--></div>"],
2924
- $164d474fea221d77$var$_tmpl$4 = ["<div", ' class="filter-collapsible-body"><div class="filter-part">', "</div><!--$-->", "<!--/--></div>"],
3435
+ $164d474fea221d77$var$_tmpl$4 = ["<div", ' class="filter-collapsible-body"><div class="filter-part"><!--$-->', "<!--/--><!--$-->", "<!--/--></div><!--$-->", "<!--/--></div>"],
2925
3436
  $164d474fea221d77$var$_tmpl$5 = ["<details", ' class="filter-collapsible"', "></details>"],
2926
3437
  $164d474fea221d77$var$_tmpl$6 = ["<summary", ' class="filter-group-summary"><div class="summary"><span>', '</span><div class="selected-w-sign"><!--$-->', "<!--/--><!--$-->", "<!--/--></div></div></summary>"],
2927
3438
  $164d474fea221d77$var$_tmpl$7 = ["<div", ' class="ungrouped">', "</div>"],
@@ -2978,6 +3489,11 @@ function $164d474fea221d77$var$ActualFilterBody(props) {
2978
3489
  const filter_array_ = $3hooq$solidjs.createMemo(() => {
2979
3490
  return Object.values(togglable_filters_grouped_by_collapsible())[get_section_index()];
2980
3491
  });
3492
+ const {
3493
+ SearchThisFilterGroup_: SearchThisFilterGroup_,
3494
+ searched_filter_array_: searched_filter_array_,
3495
+ filter_query_: filter_query_
3496
+ } = $8e7ac26c00243687$export$4b2c5292ffe0c5dd(filter_array_, section_, props.i18n_);
2981
3497
  const is_open = $4c1dcf1a9c604a68$export$ab34afce88557c0e({
2982
3498
  get expanded_filters_() {
2983
3499
  return props.expanded_filters_;
@@ -2993,6 +3509,11 @@ function $164d474fea221d77$var$ActualFilterBody(props) {
2993
3509
  return selected_filter;
2994
3510
  })));
2995
3511
  const a_filter_is_selected = $3hooq$solidjs.createMemo(() => selected_filters_in_group().size);
3512
+ const [get_details_width, set_get_details_width] = $3hooq$solidjs.createSignal();
3513
+ const details_element_width_ = $3hooq$solidjs.createMemo(() => {
3514
+ var _get_details_width;
3515
+ 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();
3516
+ });
2996
3517
  return $3hooq$solidjsweb.createComponent((0, $4cfe8400ed3f92c4$export$6c6d7a51fa9aa15d), {
2997
3518
  is_open_: is_open,
2998
3519
  get details_() {
@@ -3021,9 +3542,9 @@ function $164d474fea221d77$var$ActualFilterBody(props) {
3021
3542
  })));
3022
3543
  },
3023
3544
  get children() {
3024
- return $3hooq$solidjsweb.ssr($164d474fea221d77$var$_tmpl$4, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Index), {
3545
+ return $3hooq$solidjsweb.ssr($164d474fea221d77$var$_tmpl$4, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent(SearchThisFilterGroup_, {})), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Index), {
3025
3546
  get each() {
3026
- return filter_array_();
3547
+ return searched_filter_array_();
3027
3548
  },
3028
3549
  children: filter => $3hooq$solidjsweb.createComponent((0, $1b3cf201cdd38687$export$b69d0d92862de18b), {
3029
3550
  severity_: "error",
@@ -3046,7 +3567,9 @@ function $164d474fea221d77$var$ActualFilterBody(props) {
3046
3567
  get i18n_() {
3047
3568
  return props.i18n_;
3048
3569
  },
3049
- view_more_button_below_group_: view_more_button_below_group
3570
+ view_more_button_below_group_: view_more_button_below_group,
3571
+ filter_query_: filter_query_,
3572
+ details_element_width_: details_element_width_
3050
3573
  });
3051
3574
  }
3052
3575
  })
@@ -7195,15 +7718,6 @@ const $dd98275d380b2cfd$var$_tmpl$ = ["<svg", ' xmlns="http://www.w3.org/2000/sv
7195
7718
  function $dd98275d380b2cfd$export$1c641004b5485fed() {
7196
7719
  return $3hooq$solidjsweb.ssr($dd98275d380b2cfd$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey());
7197
7720
  }
7198
- const $5b88b077e48a4451$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>';
7199
- function $5b88b077e48a4451$export$82eafebb825fc23f() {
7200
- let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7201
- return $3hooq$solidjsweb.ssrElement("svg", $3hooq$solidjsweb.mergeProps(props, {
7202
- xmlns: "http://www.w3.org/2000/svg",
7203
- width: "20",
7204
- height: "22"
7205
- }), () => $3hooq$solidjsweb.ssr($5b88b077e48a4451$var$_tmpl$), true);
7206
- }
7207
7721
  const $29e5dbeb69da7a36$var$_tmpl$ = ["<button", ' class="back" type="button"', ">", "</button>"],
7208
7722
  $29e5dbeb69da7a36$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>"];
7209
7723
  function $29e5dbeb69da7a36$export$b94867ecbd698f21(_ref) {
@@ -7695,78 +8209,24 @@ function $4edbc04f5c5a1843$export$a146ac6fa8346a25(_ref) {
7695
8209
  return has_entries();
7696
8210
  },
7697
8211
  get children() {
7698
- return $3hooq$solidjsweb.ssr($4edbc04f5c5a1843$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape(text_()), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Index), {
7699
- get each() {
7700
- return previous_searches_();
7701
- },
7702
- children: (item, index) => {
7703
- const href = $77fe1b91e837c071$export$91c3b6774e8be0f5({
7704
- param_: search_query_param_name_,
7705
- value_: item,
7706
- url_transformer_: url_transformer_
7707
- });
7708
- return $3hooq$solidjsweb.ssr($4edbc04f5c5a1843$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), "".concat("item", " ").concat($3hooq$solidjs.createMemo(() => {
7709
- var _read_selected_index_, _read_selected_index_2;
7710
- 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;
7711
- })() ? "selected" : ""), $3hooq$solidjsweb.ssrAttribute("href", $3hooq$solidjsweb.escape(href(), true), false), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $8767e7eba5066d2b$export$5d2caaa6b530761c), {})), $3hooq$solidjsweb.ssrAttribute("title", $3hooq$solidjsweb.escape(item(), true), false), $3hooq$solidjsweb.escape(item()), $3hooq$solidjsweb.ssrAttribute("title", $3hooq$solidjsweb.escape(i18n_.previous_searches_delete_entry_from_history_(), true), false), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $083b2336093176cf$export$3b621d86b1566b2), {})));
7712
- }
7713
- })));
7714
- }
7715
- });
7716
- }
7717
- const $23c3f390dee33ff8$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"],
7718
- $23c3f390dee33ff8$var$_tmpl$2 = ["<span", ' class="', '"', ">", "</span>"];
7719
- function $23c3f390dee33ff8$export$ba17c5b7e6dda39f(_ref) {
7720
- let {
7721
- whole_text_to_display_: whole_text_to_display_memo,
7722
- searching_for_value_: searching_for_value_memo,
7723
- class_: class_
7724
- } = _ref;
7725
- const [get_has_highlighted, set_has_highlighted] = $3hooq$solidjs.createSignal(false);
7726
- const text_itself = $3hooq$solidjs.createMemo(() => $3hooq$solidjs.batch(() => {
7727
- set_has_highlighted(false);
7728
- const searching_for_value = searching_for_value_memo();
7729
- const whole_text_to_display_ = whole_text_to_display_memo();
7730
- let for_black = "";
7731
- let pushed_grey = false;
7732
- const search_q = searching_for_value;
7733
- if (!search_q) return whole_text_to_display_;
7734
- const output = [];
7735
- const searching_for = search_q.toLowerCase();
7736
- const push_black = () => {
7737
- if (for_black) {
7738
- set_has_highlighted(true);
7739
- output.push($3hooq$solidjsweb.ssr($23c3f390dee33ff8$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape(for_black))); // "black"
7740
- for_black = "";
7741
- }
7742
- };
7743
- for (let i = 0; i < whole_text_to_display_.length;) {
7744
- let is_whole_word = true;
7745
- let searching_for_but_with_texts_casing = "";
7746
- const i_at_start = i;
7747
- for (let j = 0; j < searching_for.length; i++, j++) {
7748
- const letter_in_suggestion = whole_text_to_display_[i];
7749
- if ((letter_in_suggestion === null || letter_in_suggestion === void 0 ? void 0 : letter_in_suggestion.toLowerCase()) !== searching_for[j]) {
7750
- is_whole_word = false;
7751
- i = i_at_start;
7752
- break;
8212
+ return $3hooq$solidjsweb.ssr($4edbc04f5c5a1843$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape(text_()), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Index), {
8213
+ get each() {
8214
+ return previous_searches_();
8215
+ },
8216
+ children: (item, index) => {
8217
+ const href = $77fe1b91e837c071$export$91c3b6774e8be0f5({
8218
+ param_: search_query_param_name_,
8219
+ value_: item,
8220
+ url_transformer_: url_transformer_
8221
+ });
8222
+ return $3hooq$solidjsweb.ssr($4edbc04f5c5a1843$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), "".concat("item", " ").concat($3hooq$solidjs.createMemo(() => {
8223
+ var _read_selected_index_, _read_selected_index_2;
8224
+ 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;
8225
+ })() ? "selected" : ""), $3hooq$solidjsweb.ssrAttribute("href", $3hooq$solidjsweb.escape(href(), true), false), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $8767e7eba5066d2b$export$5d2caaa6b530761c), {})), $3hooq$solidjsweb.ssrAttribute("title", $3hooq$solidjsweb.escape(item(), true), false), $3hooq$solidjsweb.escape(item()), $3hooq$solidjsweb.ssrAttribute("title", $3hooq$solidjsweb.escape(i18n_.previous_searches_delete_entry_from_history_(), true), false), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $083b2336093176cf$export$3b621d86b1566b2), {})));
7753
8226
  }
7754
- searching_for_but_with_texts_casing += letter_in_suggestion;
7755
- }
7756
- if (is_whole_word) {
7757
- push_black();
7758
- output.push(searching_for_but_with_texts_casing);
7759
- pushed_grey = true;
7760
- } else for_black += whole_text_to_display_[i++];
7761
- }
7762
- push_black();
7763
- if (!pushed_grey) {
7764
- set_has_highlighted(false);
7765
- return whole_text_to_display_;
8227
+ })));
7766
8228
  }
7767
- return output;
7768
- }));
7769
- return $3hooq$solidjsweb.ssr($23c3f390dee33ff8$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), "".concat($3hooq$solidjsweb.escape(class_, true) || "", " ").concat(get_has_highlighted() ? "has-history-match" : ""), $3hooq$solidjsweb.ssrAttribute("title", $3hooq$solidjsweb.escape(whole_text_to_display_memo(), true), false), $3hooq$solidjsweb.escape(text_itself()));
8229
+ });
7770
8230
  }
7771
8231
  const $3cf7b4db1e203c93$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>';
7772
8232
  function $3cf7b4db1e203c93$export$605674723bcc715c() {
@@ -7810,8 +8270,8 @@ function $0677d509ad208e22$export$e872e2339fb04a7f(_ref) {
7810
8270
  } = _ref2;
7811
8271
  return type === (0, $ce079d50d380ee11$export$3cf9497e790da491) && !filtered_previous_searches_().includes(title);
7812
8272
  } // don't show the ones we already show from the history
7813
- ));
7814
-
8273
+ ) // + limit to three query suggestions, API sends more sometimes
8274
+ .slice(0, 3));
7815
8275
  const not_queries_memo = $3hooq$solidjs.createMemo(() => {
7816
8276
  // For the section that shows categories and content results
7817
8277
  // We want to limit to 3 items, and we want to show the categories first
@@ -8652,236 +9112,6 @@ function $996102a9349df6d7$export$41b4894022a3580f() {
8652
9112
  })));
8653
9113
  return style_props_;
8654
9114
  }
8655
- const $99472afa7112c427$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"];
8656
- const $99472afa7112c427$var$dont_cut_in_between_less_than_characters = 30;
8657
- function $99472afa7112c427$export$e1a98a189fd2c0e7(_ref) {
8658
- let {
8659
- content_result_: content_result_,
8660
- key_: key_,
8661
- cut_when_possible_: cut_when_possible_
8662
- } = _ref;
8663
- const matched_tokens = $3hooq$solidjs.createMemo(() => {
8664
- var _content_result_$high, _content_result_$high2;
8665
- 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;
8666
- });
8667
- const full_value = $3hooq$solidjs.createMemo(() => {
8668
- var _content_result_$key_;
8669
- return (_content_result_$key_ = content_result_()[key_]) === null || _content_result_$key_ === void 0 ? void 0 : _content_result_$key_.replaceAll("\n", " ");
8670
- });
8671
- return $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
8672
- get when() {
8673
- var _matched_tokens;
8674
- return (_matched_tokens = matched_tokens()) === null || _matched_tokens === void 0 ? void 0 : _matched_tokens.length;
8675
- },
8676
- get fallback() {
8677
- return full_value();
8678
- },
8679
- get children() {
8680
- return (() => {
8681
- const segmented_cut_text = $3hooq$solidjs.createMemo(() => {
8682
- const segmented_text = $99472afa7112c427$var$segment_text(full_value(), matched_tokens());
8683
- if (cut_when_possible_) $99472afa7112c427$var$cut_text(segmented_text);
8684
- return segmented_text;
8685
- });
8686
- return $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Index), {
8687
- get each() {
8688
- return segmented_cut_text();
8689
- },
8690
- children: item => {
8691
- return $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
8692
- get when() {
8693
- return item().highlighted_;
8694
- },
8695
- get fallback() {
8696
- return item().text_;
8697
- },
8698
- get children() {
8699
- return $3hooq$solidjsweb.ssr($99472afa7112c427$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape(item().text_));
8700
- }
8701
- });
8702
- }
8703
- });
8704
- })();
8705
- }
8706
- });
8707
- }
8708
- function $99472afa7112c427$var$cut_text(segmented_text) {
8709
- // cut away chunks of text that are not highlighted to give a google-like overview of the content
8710
- const highlighted_segments = segmented_text === null || segmented_text === void 0 ? void 0 : segmented_text.filter(segment => segment.highlighted_);
8711
- if (!segmented_text || !(highlighted_segments !== null && highlighted_segments !== void 0 && highlighted_segments.length)) return;
8712
- // We have one or more highlighted segments
8713
- if (highlighted_segments.length === 1) {
8714
- // cut away from the left until the start of the highlighted sentence if just one sentence is highlighted
8715
- $99472afa7112c427$var$cut_start(segmented_text.indexOf(highlighted_segments[0]), segmented_text);
8716
- return;
8717
- }
8718
- // We have two or more highlighted segments, take the two biggest chunks and show them + a bit text around
8719
- 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
8720
- );
8721
-
8722
- const [longest_segment, next_longest_segment] = sorted_highlighted_segments;
8723
- // We need to cut before the first segment - possibly through other segments - and maybe between segments
8724
- 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);
8725
- $99472afa7112c427$var$cut_start(index_of_first_segment, segmented_text);
8726
- // update indexes since we might have removed segments
8727
- [index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
8728
- let number_of_characters_between_segments = 0;
8729
- for (let i = index_of_first_segment + 1; i < index_of_second_segment; i++) {
8730
- const segment = segmented_text[i];
8731
- number_of_characters_between_segments += segment.text_.length;
8732
- }
8733
- if (number_of_characters_between_segments < $99472afa7112c427$var$dont_cut_in_between_less_than_characters)
8734
- // don't cut if there are less than 30 characters between the two segments
8735
- return;
8736
- // We have more than 50 characters between the two segments, cut between them
8737
- const [split_start_segment, split_start_character] = $99472afa7112c427$var$find_split_point(index_of_first_segment, index_of_second_segment, segmented_text);
8738
- const [split_end_segment, split_end_character] = $99472afa7112c427$var$find_split_point(index_of_second_segment, index_of_first_segment, segmented_text);
8739
- if (split_start_segment === undefined || split_end_segment === undefined ||
8740
- // identical split point, or split end before split start, can't do anything
8741
- split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
8742
- const dots_segment = {
8743
- text_: " … ",
8744
- highlighted_: false
8745
- };
8746
- const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
8747
- if (i < split_start_segment || i > split_end_segment) return segment;
8748
- const text = segment.text_;
8749
- if (i == split_end_segment && i == split_start_segment) return [{
8750
- ...segment,
8751
- text_: text.slice(0, split_start_character).trimEnd()
8752
- }, dots_segment, {
8753
- ...segment,
8754
- text_: text.slice(split_end_character + 1, text.length).trimStart()
8755
- }];else if (i == split_start_segment) {
8756
- 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
8757
- return segment;
8758
- } else if (i == split_end_segment) return [dots_segment, {
8759
- ...segment,
8760
- text_: text.slice(split_end_character + 1, text.length).trimStart()
8761
- }];
8762
- return []; // remove all segments inbetween
8763
- });
8764
-
8765
- segmented_text.splice(0, segmented_text.length, ...split_and_dotted_values); // Sorry…
8766
- $99472afa7112c427$var$heal_holes(segmented_text);
8767
- }
8768
- function $99472afa7112c427$var$heal_holes(segmented_text) {
8769
- // try to heal "holes" created in the segments so there are only alternating segments
8770
- const segments_to_delete = new Set();
8771
- for (let i = 0; i < segmented_text.length; i++) {
8772
- var _previous_segment, _previous_segment2;
8773
- const segment = segmented_text[i];
8774
- let previous_segment;
8775
- for (let j = i - 1; j >= 0; j--) {
8776
- previous_segment = segmented_text[j];
8777
- // Don't write to a segment that's marked for deletion or the contents we write to it will be deleted
8778
- if (!segments_to_delete.has(previous_segment)) break;
8779
- }
8780
- 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) {
8781
- previous_segment.text_ += segment.text_; // IDK if this ever happens
8782
- segments_to_delete.add(segment);
8783
- }
8784
- }
8785
- for (const segment of segments_to_delete) {
8786
- const index = segmented_text.indexOf(segment);
8787
- segmented_text.splice(index, 1);
8788
- }
8789
- }
8790
- function $99472afa7112c427$var$find_split_point(index_of_start_segment, index_of_end_segment, segmented_text) {
8791
- let be_very_aggressive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
8792
- const should_loop_backwards = index_of_start_segment > index_of_end_segment;
8793
- const step = should_loop_backwards ? -1 : 1;
8794
- const desperate_split_attempts = [":", ";", ","];
8795
- while (desperate_split_attempts.length) {
8796
- const split_point_between_words = [];
8797
- // for the middle also try to split with a few more characters if the default ones don't work over a full run
8798
- const desperate_split_attempt = desperate_split_attempts.pop();
8799
- let is_first_character = true;
8800
- for (let i = index_of_start_segment + step; should_loop_backwards ? i > index_of_end_segment : i < index_of_end_segment; i += step) {
8801
- const segment = segmented_text[i];
8802
- const text = segment.text_;
8803
- for (let j = should_loop_backwards ? text.length - 1 : 0; should_loop_backwards ? j >= 0 : j < text.length; j += step) {
8804
- const character = text[j];
8805
- if (character == "." || character == "?" || character == "!" || character == desperate_split_attempt) return [i, j]; // segment index, character index
8806
- if (is_first_character) is_first_character = false;else if (be_very_aggressive && character == " ") {
8807
- split_point_between_words.push([i, j]);
8808
- if (split_point_between_words.length > 3)
8809
- // We can't find a split point, so we'll just split between words
8810
- // 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
8811
- return split_point_between_words[1];
8812
- }
8813
- }
8814
- }
8815
- }
8816
- return [];
8817
- }
8818
- function $99472afa7112c427$var$cut_start(cut_left_of_index, segmented_text) {
8819
- // Cut the start of the text to bring the first matching token
8820
- let is_first_character = false;
8821
- let words_encountered = 0;
8822
- outmost_loop: for (let i = cut_left_of_index - 1; i >= 0; i--) {
8823
- const segment = segmented_text[i];
8824
- // We assume that two adjacent highlighted segments don't exist and have been merged if they were to have existed
8825
- const text = segment.text_;
8826
- for (let j = text.length - 1; j >= 0; j--) {
8827
- const character = text[j];
8828
- const is_space = character == " ";
8829
- if (!is_first_character && is_space) words_encountered++;
8830
- if (character == "." || character == "?" || character == "!" || character == "," || words_encountered > 8 && is_space) {
8831
- // We have to be really aggressive at the start of sentences so stuff can be seen on mobile, hence comma
8832
- segment.text_ = text.slice(j + 1).trimStart();
8833
- segmented_text.splice(0, i);
8834
- if (character === "," || is_space)
8835
- // if we cut at a comma or psace, we add a … at the beginning
8836
- segmented_text.unshift({
8837
- text_: "… ",
8838
- highlighted_: false
8839
- });
8840
- break outmost_loop;
8841
- }
8842
- if (is_first_character) is_first_character = false;
8843
- }
8844
- }
8845
- $99472afa7112c427$var$heal_holes(segmented_text); // if we added a ... there could now be a sequence that's not alternating true/false
8846
- }
8847
-
8848
- function $99472afa7112c427$var$segment_text(text, matched_strings) {
8849
- // segment text where the matched strings are highlighted sections
8850
- const output = [];
8851
- if (!text) return; // shouldn't happen but whatever
8852
- for (let i = 0; i < text.length; i++) {
8853
- const found_strings = [];
8854
- if (!i || text[i - 1] == " ")
8855
- // only match at the start of a word or string, it looks weird if i.e. "we" is highlighted in "activewear
8856
- for (let j = 0; j < matched_strings.length; j++) {
8857
- const matched_string = matched_strings[j];
8858
- const part_in_text = text.slice(i, i + matched_string.length);
8859
- if (matched_string.length < 2) continue; // don't match on single characters, i.e. "I", it looks weird
8860
- 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
8861
- }
8862
-
8863
- const last_index_in_output = output.length - 1;
8864
- if (!found_strings.length) {
8865
- var _output$last_index_in;
8866
- const character = text[i];
8867
- 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))
8868
- // 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
8869
- output[last_index_in_output].text_ += character;else output.push({
8870
- highlighted_: false,
8871
- text_: character
8872
- });
8873
- } else {
8874
- var _output$last_index_in2;
8875
- const longest_found_string = found_strings.reduce((a, b) => a.length > b.length ? a : b);
8876
- 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({
8877
- highlighted_: true,
8878
- text_: longest_found_string
8879
- });
8880
- i += longest_found_string.length - 1;
8881
- }
8882
- }
8883
- return output;
8884
- }
8885
9115
  const $f1fc9ea3e7632eba$var$_tmpl$ = ["<div", ' class="description line-clamp">', "</div>"],
8886
9116
  $f1fc9ea3e7632eba$var$_tmpl$2 = ["<div", ' class="content-card"><div class="image">', '</div><div class="info"><!--$-->', "<!--/--><!--$-->", "<!--/--></div></div>"];
8887
9117
  function $f1fc9ea3e7632eba$export$f631859cab12b342(_ref) {
@@ -8935,7 +9165,7 @@ function $f1fc9ea3e7632eba$export$f631859cab12b342(_ref) {
8935
9165
  }
8936
9166
  }))), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
8937
9167
  get when() {
8938
- return (content_result_ === null || content_result_ === void 0 ? void 0 : content_result_().description) || !content_result_;
9168
+ return content_result_ === null || content_result_ === void 0 ? void 0 : content_result_().description;
8939
9169
  },
8940
9170
  get children() {
8941
9171
  return $3hooq$solidjsweb.ssr($f1fc9ea3e7632eba$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {