@depict-ai/ui 2.1.11 → 2.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/latest/index.cjs CHANGED
@@ -19,7 +19,7 @@ $parcel$export(module.exports, "ListingProvider", () => $84798aaa863a4909$export
19
19
  $parcel$export(module.exports, "useListing", () => $84798aaa863a4909$export$8d0c4fdbb05a2f2e);
20
20
  $parcel$export(module.exports, "ShopifyContainedImage", () => $a33065cfed827fc0$export$e4b984597b71e989);
21
21
  $parcel$export(module.exports, "SlidableItems", () => $a0e53f99354809d9$export$6649caad96ef8870);
22
- $parcel$export(module.exports, "make_accurate_size_accessor", () => $e5f442fb78c98741$export$9f191182275e9ef);
22
+ $parcel$export(module.exports, "make_accurate_width_accessor", () => $f13855d1b951b24a$export$ebdc3711f7e02ccd);
23
23
  $parcel$export(module.exports, "RecommendationSlider", () => $72f96c4782db0b1b$export$9574e176201e5e8d);
24
24
  $parcel$export(module.exports, "RecommendationGrid", () => $1f8dbf7e28b3eff2$export$9756467d34d91cdb);
25
25
  $parcel$export(module.exports, "ShopifyResponsiveImg", () => $19950faaac026e09$export$6e5611bc7e57e477);
@@ -70,7 +70,7 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $a3280f0aad997933$expo
70
70
  $parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $a3280f0aad997933$export$7bf543b9d9be2c22);
71
71
  $parcel$export(module.exports, "version", () => $b757f75811f3261f$export$83d89fbfd8236492);
72
72
  /*! Depict.ai search and product listing SDK */
73
- const $b757f75811f3261f$export$83d89fbfd8236492 = "2.1.11";
73
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "2.1.13";
74
74
  const $1ab22f2cd39b3061$var$fallback_operator = "in";
75
75
  const $1ab22f2cd39b3061$var$fallback_token = "";
76
76
  const $1ab22f2cd39b3061$var$legacy_filter_prefix = "filter_";
@@ -511,24 +511,30 @@ function $a0e53f99354809d9$export$6649caad96ef8870({
511
511
 
512
512
  /** @jsxImportSource solid-js */
513
513
 
514
- function $e5f442fb78c98741$export$9f191182275e9ef(what_to_watch) {
515
- const [size, setSize] = $gVhhF$solidjs.createSignal();
514
+ function $f13855d1b951b24a$export$ebdc3711f7e02ccd(what_to_watch) {
515
+ const [width, setWidth] = $gVhhF$solidjs.createSignal();
516
516
  const resizeObserver = new ResizeObserver($gVhhF$depictaiutilishared.catchify(records => {
517
517
  for (let j = 0; j < records.length; j++) {
518
518
  const width = records[j].borderBoxSize?.[0]?.inlineSize ?? what_to_watch.getBoundingClientRect().width;
519
- setSize(width);
519
+ setWidth(width);
520
520
  }
521
521
  }));
522
522
  // 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.
523
523
  // It doesn't seem to work even when waiting for it to be in the DOM, also wait an animation frame
524
524
  const disconnect = (0, $gVhhF$depictaiutilishared.observer).onexists(what_to_watch, ({
525
525
  element: element
526
- }) => requestAnimationFrame($gVhhF$depictaiutilishared.catchify(() => resizeObserver.observe(element))));
526
+ }) => requestAnimationFrame($gVhhF$depictaiutilishared.catchify(() => {
527
+ const current_size = what_to_watch.getBoundingClientRect().width;
528
+ if (current_size)
529
+ // 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.
530
+ setWidth(current_size);
531
+ resizeObserver.observe(element);
532
+ })));
527
533
  $gVhhF$solidjs.onCleanup(() => {
528
534
  resizeObserver.disconnect();
529
535
  disconnect();
530
536
  });
531
- return size;
537
+ return width;
532
538
  }
533
539
  const $4e04be41243c3d80$var$transform_elements = sorted_cols_at_size => {
534
540
  const cols_at_size = [];
@@ -811,7 +817,7 @@ class $7dd1edb2ee2b43ad$export$aa14a9f43128f61f extends $7dd1edb2ee2b43ad$export
811
817
  });
812
818
  }
813
819
  }
814
- const $edafe91daf3091d7$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`);
820
+ const $edafe91daf3091d7$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div><!$><!/><!$><!/>`);
815
821
  function $edafe91daf3091d7$export$b69d0d92862de18b(props) {
816
822
  return $gVhhF$solidjs.ErrorBoundary({
817
823
  fallback(err, retry) {
@@ -824,10 +830,14 @@ function $edafe91daf3091d7$export$b69d0d92862de18b(props) {
824
830
  console.error(err.cause);
825
831
  message = `${message}: ${err.message}`;
826
832
  } else $gVhhF$depictaiutilishared.report([err, message_], severity_);
827
- props.on_error_?.(retry);
828
833
  return (() => {
829
- const _el$ = $gVhhF$solidjsweb.getNextElement($edafe91daf3091d7$var$_tmpl$);
830
- $gVhhF$solidjsweb.insert(_el$, message);
834
+ const _el$ = $gVhhF$solidjsweb.getNextElement($edafe91daf3091d7$var$_tmpl$),
835
+ _el$2 = _el$.firstChild,
836
+ [_el$3, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$2.nextSibling),
837
+ _el$4 = _el$3.nextSibling,
838
+ [_el$5, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling);
839
+ $gVhhF$solidjsweb.insert(_el$, message, _el$3, _co$);
840
+ $gVhhF$solidjsweb.insert(_el$, () => props.on_error_?.(retry), _el$5, _co$2);
831
841
  $gVhhF$solidjsweb.effect(_$p => $gVhhF$solidjsweb.classList(_el$, Object.fromEntries(props.class_list_?.map(c => [c, true]) || []), _$p));
832
842
  return _el$;
833
843
  })();
@@ -1510,16 +1520,11 @@ function $47e2cc552c02110c$export$8895d39404bd2bb1(props) {
1510
1520
  if (delay_toast_) return show_configured_toast;else show_configured_toast();
1511
1521
  }
1512
1522
  $gVhhF$solidjsweb.delegateEvents(["click"]);
1513
- const $c77c68e559a1506c$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<svg><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">`);
1523
+ const $c77c68e559a1506c$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<svg xmlns=http://www.w3.org/2000/svg width=21.064 height=21.047 viewBox="0 0 21.064 21.064"><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">`);
1514
1524
  function $c77c68e559a1506c$export$3b621d86b1566b2(props = {}) {
1515
1525
  return (() => {
1516
1526
  const _el$ = $gVhhF$solidjsweb.getNextElement($c77c68e559a1506c$var$_tmpl$);
1517
- $gVhhF$solidjsweb.spread(_el$, $gVhhF$solidjsweb.mergeProps(props, {
1518
- "xmlns": "http://www.w3.org/2000/svg",
1519
- "width": "21.064",
1520
- "height": "21.047",
1521
- "viewBox": "0 0 21.064 21.064"
1522
- }), true, true);
1527
+ $gVhhF$solidjsweb.spread(_el$, props, true, true);
1523
1528
  $gVhhF$solidjsweb.runHydrationEvents();
1524
1529
  return _el$;
1525
1530
  })();
@@ -1833,7 +1838,7 @@ $gVhhF$solidjsweb.delegateEvents(["click"]);
1833
1838
  const $1c63082b2da848ad$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class=count>`),
1834
1839
  $1c63082b2da848ad$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<label class=input-row><div class=left><input type=checkbox><span class=custom-indicator></span><span class="text line-clamp"></span></div><!$><!/>`);
1835
1840
  const $1c63082b2da848ad$export$48513f6b9f8ce62d = props => {
1836
- // 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
1841
+ /* 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
1837
1842
  const count = $gVhhF$solidjs.createMemo(() => props.count_);
1838
1843
  const label = $gVhhF$solidjs.createMemo(() => props.label_);
1839
1844
  const checked = $gVhhF$solidjs.createMemo(() => props.checked_);
@@ -1926,6 +1931,78 @@ function $0fe1e7efdf4200d6$export$ca21a16d65b3dd8({
1926
1931
  })();
1927
1932
  }
1928
1933
  $gVhhF$solidjsweb.delegateEvents(["click"]);
1934
+ const $d023ed916c84e75d$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class=highlighted-part>`),
1935
+ $d023ed916c84e75d$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span>`);
1936
+ function $d023ed916c84e75d$export$ba17c5b7e6dda39f({
1937
+ whole_text_to_display_: whole_text_to_display_memo,
1938
+ searching_for_value_: searching_for_value_memo,
1939
+ class_: class_
1940
+ }) {
1941
+ const [get_has_highlighted, set_has_highlighted] = $gVhhF$solidjs.createSignal(false);
1942
+ const text_itself = $gVhhF$solidjs.createMemo(() => $gVhhF$solidjs.batch(() => {
1943
+ set_has_highlighted(false);
1944
+ const searching_for_value = searching_for_value_memo();
1945
+ const whole_text_to_display_ = whole_text_to_display_memo();
1946
+ let for_black = "";
1947
+ let pushed_grey = false;
1948
+ const search_q = searching_for_value;
1949
+ if (!search_q) return whole_text_to_display_;
1950
+ const output = [];
1951
+ const searching_for = search_q.toLowerCase();
1952
+ const push_black = () => {
1953
+ if (for_black) {
1954
+ set_has_highlighted(true);
1955
+ output.push((() => {
1956
+ const _el$ = $gVhhF$solidjsweb.getNextElement($d023ed916c84e75d$var$_tmpl$);
1957
+ $gVhhF$solidjsweb.insert(_el$, for_black);
1958
+ return _el$;
1959
+ })()); // "black"
1960
+ for_black = "";
1961
+ }
1962
+ };
1963
+ for (let i = 0; i < whole_text_to_display_.length;) {
1964
+ let is_whole_word = true;
1965
+ let searching_for_but_with_texts_casing = "";
1966
+ const i_at_start = i;
1967
+ for (let j = 0; j < searching_for.length; i++, j++) {
1968
+ const letter_in_suggestion = whole_text_to_display_[i];
1969
+ if (letter_in_suggestion?.toLowerCase() !== searching_for[j]) {
1970
+ is_whole_word = false;
1971
+ i = i_at_start;
1972
+ break;
1973
+ }
1974
+ searching_for_but_with_texts_casing += letter_in_suggestion;
1975
+ }
1976
+ if (is_whole_word) {
1977
+ push_black();
1978
+ output.push(searching_for_but_with_texts_casing);
1979
+ pushed_grey = true;
1980
+ } else for_black += whole_text_to_display_[i++];
1981
+ }
1982
+ push_black();
1983
+ if (!pushed_grey) {
1984
+ set_has_highlighted(false);
1985
+ return whole_text_to_display_;
1986
+ }
1987
+ return output;
1988
+ }));
1989
+ return (() => {
1990
+ const _el$2 = $gVhhF$solidjsweb.getNextElement($d023ed916c84e75d$var$_tmpl$2);
1991
+ $gVhhF$solidjsweb.className(_el$2, class_);
1992
+ $gVhhF$solidjsweb.insert(_el$2, text_itself);
1993
+ $gVhhF$solidjsweb.effect(_p$ => {
1994
+ const _v$ = !!get_has_highlighted(),
1995
+ _v$2 = whole_text_to_display_memo() /* for when line-clamped, users can see full text on hover */;
1996
+ _v$ !== _p$._v$ && _el$2.classList.toggle("has-match", _p$._v$ = _v$);
1997
+ _v$2 !== _p$._v$2 && $gVhhF$solidjsweb.setAttribute(_el$2, "title", _p$._v$2 = _v$2);
1998
+ return _p$;
1999
+ }, {
2000
+ _v$: undefined,
2001
+ _v$2: undefined
2002
+ });
2003
+ return _el$2;
2004
+ })();
2005
+ }
1929
2006
  const $d94869c80e337a3d$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<form class=checkboxes><!$><!/><!$><!/>`);
1930
2007
  const $d94869c80e337a3d$var$max_visible_without_collapsing = 15;
1931
2008
  const $d94869c80e337a3d$var$show_non_collapsible_when_collapsed = 4;
@@ -1933,7 +2010,8 @@ function $d94869c80e337a3d$export$dd948f91abc3a1c4({
1933
2010
  filter_: filter_,
1934
2011
  selected_filters_: [get_selected_filters, set_selected_filters],
1935
2012
  i18n_: i18n_,
1936
- view_more_button_below_group_: [, set_view_more_button_below_group_]
2013
+ view_more_button_below_group_: [, set_view_more_button_below_group_],
2014
+ filter_query_: filter_query_
1937
2015
  }) {
1938
2016
  const existing_filter = $gVhhF$solidjs.createMemo(() => {
1939
2017
  const {
@@ -1961,12 +2039,18 @@ function $d94869c80e337a3d$export$dd948f91abc3a1c4({
1961
2039
  const value = $daa394359b026187$export$325f75597868c4f0(checkbox().value_);
1962
2040
  return !!data?.some(item => $daa394359b026187$export$325f75597868c4f0(item) === value);
1963
2041
  });
2042
+ const value = $gVhhF$solidjs.createMemo(() => checkbox().value_);
1964
2043
  return $gVhhF$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
1965
2044
  get value_() {
1966
- return checkbox().value_;
2045
+ return value();
1967
2046
  },
1968
2047
  get label_() {
1969
- return checkbox().name_;
2048
+ return $gVhhF$solidjsweb.createComponent((0, $d023ed916c84e75d$export$ba17c5b7e6dda39f), {
2049
+ get whole_text_to_display_() {
2050
+ return $gVhhF$solidjs.createMemo(() => checkbox().name_ || value());
2051
+ },
2052
+ searching_for_value_: () => filter_query_?.()
2053
+ });
1970
2054
  },
1971
2055
  get count_() {
1972
2056
  return checkbox().count_;
@@ -2058,7 +2142,8 @@ const $c1dc1554c1b94233$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<f
2058
2142
  $c1dc1554c1b94233$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<label class=input-row><div class=left><input type=radio><span class=custom-indicator></span><!$><!/></div><!$><!/>`);
2059
2143
  function $c1dc1554c1b94233$export$430444115f70a734({
2060
2144
  selected_filters_: selected_filters_,
2061
- filter_: filter_
2145
+ filter_: filter_,
2146
+ filter_query_: filter_query_
2062
2147
  }) {
2063
2148
  const radio_name = $gVhhF$depictaiutilishared.make_random_classname();
2064
2149
  const existing_filter = $gVhhF$solidjs.createMemo(() => {
@@ -2080,6 +2165,12 @@ function $c1dc1554c1b94233$export$430444115f70a734({
2080
2165
  children: (value, index) => {
2081
2166
  const random_selector = $gVhhF$depictaiutilishared.make_random_classname();
2082
2167
  const count = $gVhhF$solidjs.createMemo(() => filter_().meta.counts?.[index]);
2168
+ const label = $gVhhF$solidjs.createMemo(() => {
2169
+ const name = filter_().meta?.names?.[index];
2170
+ if (name) return name;
2171
+ const v = value();
2172
+ return Array.isArray(v) ? v.join(" - ") : v + "";
2173
+ });
2083
2174
  return (() => {
2084
2175
  const _el$2 = $gVhhF$solidjsweb.getNextElement($c1dc1554c1b94233$var$_tmpl$3),
2085
2176
  _el$3 = _el$2.firstChild,
@@ -2104,11 +2195,9 @@ function $c1dc1554c1b94233$export$430444115f70a734({
2104
2195
  }));
2105
2196
  $gVhhF$solidjsweb.setAttribute(_el$4, "id", random_selector);
2106
2197
  $gVhhF$solidjsweb.setAttribute(_el$4, "name", radio_name);
2107
- $gVhhF$solidjsweb.insert(_el$3, $gVhhF$solidjs.createMemo(() => {
2108
- const name = filter_().meta?.names?.[index];
2109
- if (name) return name;
2110
- const v = value();
2111
- return Array.isArray(v) ? v.join(" - ") : v;
2198
+ $gVhhF$solidjsweb.insert(_el$3, $gVhhF$solidjsweb.createComponent((0, $d023ed916c84e75d$export$ba17c5b7e6dda39f), {
2199
+ whole_text_to_display_: label,
2200
+ searching_for_value_: () => filter_query_?.()
2112
2201
  }), _el$7, _co$);
2113
2202
  $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
2114
2203
  get when() {
@@ -2140,7 +2229,8 @@ const $0b7222ba8a8bb72f$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<d
2140
2229
  function $0b7222ba8a8bb72f$export$e0d834a0ad870cda({
2141
2230
  filter_: filter_,
2142
2231
  selected_filters_: selected_filters_,
2143
- i18n_: i18n_
2232
+ i18n_: i18n_,
2233
+ filter_query_: filter_query_
2144
2234
  }) {
2145
2235
  // 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
2146
2236
  // 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
@@ -2519,140 +2609,409 @@ function $7567511a7c3e4bd7$export$e5c2828934226505({
2519
2609
  });
2520
2610
  return outer_div;
2521
2611
  }
2522
- const $3bdc00a1353c1150$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<form class="checkboxes hierarchical"><!$><!/><!$><!/>`),
2523
- $3bdc00a1353c1150$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=checkbox-details><!$><!/><!$><!/>`),
2524
- $3bdc00a1353c1150$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<details>`),
2525
- $3bdc00a1353c1150$var$_tmpl$4 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<summary class=category-parent><div class=summary><span class=count></span><!$><!/>`);
2526
- const $3bdc00a1353c1150$var$max_visible_without_collapsing = 15;
2527
- const $3bdc00a1353c1150$var$show_non_collapsible_when_collapsed = 4;
2528
- function $3bdc00a1353c1150$export$a32086fa6616eafd({
2529
- filter_: filter_,
2530
- selected_filters_: selected_filters_,
2531
- i18n_: i18n_,
2532
- view_more_button_below_group_: view_more_button_below_group_,
2533
- expanded_hierarchical_filters_: expanded_hierarchical_filters_
2612
+ const $5ea5a82e398f6f44$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class=highlighted-part>`);
2613
+ const $5ea5a82e398f6f44$var$dont_cut_in_between_less_than_characters = 30;
2614
+ function $5ea5a82e398f6f44$export$e1a98a189fd2c0e7({
2615
+ content_result_: content_result_,
2616
+ key_: key_,
2617
+ cut_when_possible_: cut_when_possible_
2534
2618
  }) {
2535
- let form;
2536
- const existing_filter = $gVhhF$solidjs.createMemo(() => {
2537
- const {
2538
- field: field,
2539
- op: op
2540
- } = filter_();
2541
- return selected_filters_[0]().find(({
2542
- field: checking_field,
2543
- op: checking_op
2544
- }) => checking_field === field && checking_op === op);
2545
- });
2546
- const show_extras = $gVhhF$solidjs.createSignal(false);
2547
- const trigger_sync_ = $3bdc00a1353c1150$var$batching_filter_state_syncer({
2548
- filter_: filter_,
2549
- existing_filter_: existing_filter,
2550
- selected_filters_: selected_filters_,
2551
- get category_structure_() {
2552
- return structured_categories();
2553
- }
2554
- });
2555
- const structured_categories = $gVhhF$solidjs.createMemo(() => {
2556
- const execute_when_structure_finished = [];
2557
- const {
2558
- values: values,
2559
- names: names,
2560
- counts: counts
2561
- } = filter_().meta;
2562
- const data_structure = {};
2563
- for (let i = 0; i < values.length; i++) {
2564
- const value = values[i];
2565
- let pointer = data_structure;
2566
- let parent_ = {};
2567
- let created_an_object = false;
2568
- for (let j = 0; j < value.length; j++) {
2569
- const this_categories_name = value[j];
2570
- const obj = pointer[this_categories_name] ||= (() => {
2571
- 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;
2572
- const created_obj = {
2573
- name_: names[i],
2574
- count_: counts?.[i],
2575
- parent_: parent_,
2576
- is_expanded_: $3bdc00a1353c1150$var$make_expanded_signal({
2577
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2578
- filter_value_: value_as_string
2579
- }),
2580
- value_: value_as_string,
2581
- children_: {}
2582
- };
2583
- const {
2584
- signal_: signal_,
2585
- on_structure_complete_: on_structure_complete_
2586
- } = $3bdc00a1353c1150$var$create_updating_signal({
2587
- self_: created_obj,
2588
- existing_filter_: $gVhhF$solidjs.untrack(existing_filter),
2589
- trigger_sync_: trigger_sync_
2590
- });
2591
- execute_when_structure_finished.push(on_structure_complete_);
2592
- created_obj.is_checked_ = signal_;
2593
- parent_ = created_obj;
2594
- created_an_object = true;
2595
- return created_obj;
2596
- })();
2597
- pointer = obj.children_;
2598
- parent_ = obj;
2599
- }
2600
- if (!created_an_object && "value_" in parent_) {
2601
- // 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
2602
- // [
2603
- // ["Öl", "IPA"],
2604
- // ["Öl", "Pale Ale"],
2605
- // ["Öl", "Ale"],
2606
- // ["Öl", "Mörk Lager"],
2607
- // ["Öl", "Suröl"],
2608
- // ["Öl", "Veteöl"],
2609
- // ["Öl", "Stout och Porter"],
2610
- // ["Öl"], // <- We are here, our `hierarchical_data_structure[string]`-object was created when we iterated over ["Öl", "IPA"]
2611
- // ["Öl", "Ljus Lager"],
2612
- // ];
2613
- // In this case we want to just correct the name and value of the already created object, which will be in parent_
2614
- parent_.value_ = value.map(v => v + "");
2615
- parent_.name_ = names[i];
2616
- parent_.count_ = counts[i];
2617
- parent_.is_expanded_ = $3bdc00a1353c1150$var$make_expanded_signal({
2618
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2619
- filter_value_: parent_.value_
2620
- });
2621
- }
2622
- }
2623
- while (execute_when_structure_finished.length) execute_when_structure_finished.pop()();
2624
- $3bdc00a1353c1150$var$expand_until_choice(data_structure);
2625
- $gVhhF$depictaiutilishared.dlog("CheckboxHierarchicalFilter: Recomputed structured_categories", data_structure);
2626
- return data_structure;
2627
- });
2628
- const some_top_level_are_hidden = $gVhhF$solidjs.createMemo(() => Object.keys(structured_categories()).length > $3bdc00a1353c1150$var$max_visible_without_collapsing);
2629
- const {
2630
- expand: expand,
2631
- collapse: collapse,
2632
- ExpandingContainer: ExpandingContainer
2633
- } = $4b455f60dadde8b8$export$5bad61ecde080b1f({
2634
- duration: 200
2635
- });
2636
- const expanding_container_els = $gVhhF$solidjsweb.createComponent(ExpandingContainer, {
2619
+ const matched_tokens = $gVhhF$solidjs.createMemo(() => content_result_().highlights?.find(highlight => highlight.field == key_)?.matched_tokens);
2620
+ const full_value = $gVhhF$solidjs.createMemo(() => content_result_()[key_]?.replaceAll("\n", " "));
2621
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
2622
+ get when() {
2623
+ return matched_tokens()?.length;
2624
+ },
2625
+ get fallback() {
2626
+ return full_value();
2627
+ },
2637
2628
  get children() {
2638
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
2639
- get when() {
2640
- return some_top_level_are_hidden();
2641
- },
2642
- get children() {
2643
- return $3bdc00a1353c1150$var$render_stuff($gVhhF$solidjs.createMemo(() => Object.fromEntries(Object.entries(structured_categories()).slice($3bdc00a1353c1150$var$show_non_collapsible_when_collapsed))), existing_filter, i18n_);
2644
- }
2645
- });
2629
+ return (() => {
2630
+ const segmented_cut_text = $gVhhF$solidjs.createMemo(() => {
2631
+ const segmented_text = $5ea5a82e398f6f44$export$1b00d74faf266c56(full_value(), matched_tokens());
2632
+ if (cut_when_possible_) $5ea5a82e398f6f44$var$cut_text(segmented_text);
2633
+ return segmented_text;
2634
+ });
2635
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
2636
+ get each() {
2637
+ return segmented_cut_text();
2638
+ },
2639
+ children: item => {
2640
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
2641
+ get when() {
2642
+ return item().highlighted_;
2643
+ },
2644
+ get fallback() {
2645
+ return item().text_;
2646
+ },
2647
+ get children() {
2648
+ const _el$ = $gVhhF$solidjsweb.getNextElement($5ea5a82e398f6f44$var$_tmpl$);
2649
+ $gVhhF$solidjsweb.insert(_el$, () => item().text_);
2650
+ return _el$;
2651
+ }
2652
+ });
2653
+ }
2654
+ });
2655
+ })();
2646
2656
  }
2647
2657
  });
2648
- $gVhhF$solidjs.createRenderEffect(() => {
2649
- view_more_button_below_group_[1](some_top_level_are_hidden() ? $gVhhF$solidjsweb.createComponent((0, $0fe1e7efdf4200d6$export$ca21a16d65b3dd8), {
2650
- show_extras_: show_extras,
2651
- i18n_: i18n_
2652
- }) : []);
2653
- });
2654
- $gVhhF$solidjs.createEffect($gVhhF$depictaiutilishared.catchify(async () => {
2655
- if (!some_top_level_are_hidden()) {
2658
+ }
2659
+ function $5ea5a82e398f6f44$var$cut_text(segmented_text) {
2660
+ // cut away chunks of text that are not highlighted to give a google-like overview of the content
2661
+ const highlighted_segments = segmented_text?.filter(segment => segment.highlighted_);
2662
+ if (!segmented_text || !highlighted_segments?.length) return;
2663
+ // We have one or more highlighted segments
2664
+ if (highlighted_segments.length === 1) {
2665
+ // cut away from the left until the start of the highlighted sentence if just one sentence is highlighted
2666
+ $5ea5a82e398f6f44$var$cut_start(segmented_text.indexOf(highlighted_segments[0]), segmented_text);
2667
+ return;
2668
+ }
2669
+ // We have two or more highlighted segments, take the two biggest chunks and show them + a bit text around
2670
+ 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
2671
+ );
2672
+
2673
+ const [longest_segment, next_longest_segment] = sorted_highlighted_segments;
2674
+ // We need to cut before the first segment - possibly through other segments - and maybe between segments
2675
+ 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);
2676
+ $5ea5a82e398f6f44$var$cut_start(index_of_first_segment, segmented_text);
2677
+ // update indexes since we might have removed segments
2678
+ [index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
2679
+ let number_of_characters_between_segments = 0;
2680
+ for (let i = index_of_first_segment + 1; i < index_of_second_segment; i++) {
2681
+ const segment = segmented_text[i];
2682
+ number_of_characters_between_segments += segment.text_.length;
2683
+ }
2684
+ if (number_of_characters_between_segments < $5ea5a82e398f6f44$var$dont_cut_in_between_less_than_characters)
2685
+ // don't cut if there are less than 30 characters between the two segments
2686
+ return;
2687
+ // We have more than 50 characters between the two segments, cut between them
2688
+ const [split_start_segment, split_start_character] = $5ea5a82e398f6f44$var$find_split_point(index_of_first_segment, index_of_second_segment, segmented_text);
2689
+ const [split_end_segment, split_end_character] = $5ea5a82e398f6f44$var$find_split_point(index_of_second_segment, index_of_first_segment, segmented_text);
2690
+ if (split_start_segment === undefined || split_end_segment === undefined ||
2691
+ // identical split point, or split end before split start, can't do anything
2692
+ split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
2693
+ const dots_segment = {
2694
+ text_: " … ",
2695
+ highlighted_: false
2696
+ };
2697
+ const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
2698
+ if (i < split_start_segment || i > split_end_segment) return segment;
2699
+ const text = segment.text_;
2700
+ if (i == split_end_segment && i == split_start_segment) return [{
2701
+ ...segment,
2702
+ text_: text.slice(0, split_start_character).trimEnd()
2703
+ }, dots_segment, {
2704
+ ...segment,
2705
+ text_: text.slice(split_end_character + 1, text.length).trimStart()
2706
+ }];else if (i == split_start_segment) {
2707
+ 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
2708
+ return segment;
2709
+ } else if (i == split_end_segment) return [dots_segment, {
2710
+ ...segment,
2711
+ text_: text.slice(split_end_character + 1, text.length).trimStart()
2712
+ }];
2713
+ return []; // remove all segments inbetween
2714
+ });
2715
+
2716
+ segmented_text.splice(0, segmented_text.length, ...split_and_dotted_values); // Sorry…
2717
+ $5ea5a82e398f6f44$var$heal_holes(segmented_text);
2718
+ }
2719
+ function $5ea5a82e398f6f44$var$heal_holes(segmented_text) {
2720
+ // try to heal "holes" created in the segments so there are only alternating segments
2721
+ const segments_to_delete = new Set();
2722
+ for (let i = 0; i < segmented_text.length; i++) {
2723
+ const segment = segmented_text[i];
2724
+ let previous_segment;
2725
+ for (let j = i - 1; j >= 0; j--) {
2726
+ previous_segment = segmented_text[j];
2727
+ // Don't write to a segment that's marked for deletion or the contents we write to it will be deleted
2728
+ if (!segments_to_delete.has(previous_segment)) break;
2729
+ }
2730
+ if (previous_segment?.highlighted_ && segment.highlighted_ || previous_segment?.highlighted_ === false && segment.highlighted_ === false) {
2731
+ previous_segment.text_ += segment.text_; // IDK if this ever happens
2732
+ segments_to_delete.add(segment);
2733
+ }
2734
+ }
2735
+ for (const segment of segments_to_delete) {
2736
+ const index = segmented_text.indexOf(segment);
2737
+ segmented_text.splice(index, 1);
2738
+ }
2739
+ }
2740
+ function $5ea5a82e398f6f44$var$find_split_point(index_of_start_segment, index_of_end_segment, segmented_text, be_very_aggressive = true) {
2741
+ const should_loop_backwards = index_of_start_segment > index_of_end_segment;
2742
+ const step = should_loop_backwards ? -1 : 1;
2743
+ const desperate_split_attempts = [":", ";", ","];
2744
+ while (desperate_split_attempts.length) {
2745
+ const split_point_between_words = [];
2746
+ // for the middle also try to split with a few more characters if the default ones don't work over a full run
2747
+ const desperate_split_attempt = desperate_split_attempts.pop();
2748
+ let is_first_character = true;
2749
+ for (let i = index_of_start_segment + step; should_loop_backwards ? i > index_of_end_segment : i < index_of_end_segment; i += step) {
2750
+ const segment = segmented_text[i];
2751
+ const text = segment.text_;
2752
+ for (let j = should_loop_backwards ? text.length - 1 : 0; should_loop_backwards ? j >= 0 : j < text.length; j += step) {
2753
+ const character = text[j];
2754
+ if (character == "." || character == "?" || character == "!" || character == desperate_split_attempt) return [i, j]; // segment index, character index
2755
+ if (is_first_character) is_first_character = false;else if (be_very_aggressive && character == " ") {
2756
+ split_point_between_words.push([i, j]);
2757
+ if (split_point_between_words.length > 3)
2758
+ // We can't find a split point, so we'll just split between words
2759
+ // 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
2760
+ return split_point_between_words[1];
2761
+ }
2762
+ }
2763
+ }
2764
+ }
2765
+ return [];
2766
+ }
2767
+ function $5ea5a82e398f6f44$var$cut_start(cut_left_of_index, segmented_text) {
2768
+ // Cut the start of the text to bring the first matching token
2769
+ let is_first_character = false;
2770
+ let words_encountered = 0;
2771
+ outmost_loop: for (let i = cut_left_of_index - 1; i >= 0; i--) {
2772
+ const segment = segmented_text[i];
2773
+ // We assume that two adjacent highlighted segments don't exist and have been merged if they were to have existed
2774
+ const text = segment.text_;
2775
+ for (let j = text.length - 1; j >= 0; j--) {
2776
+ const character = text[j];
2777
+ const is_space = character == " ";
2778
+ if (!is_first_character && is_space) words_encountered++;
2779
+ if (character == "." || character == "?" || character == "!" || character == "," || words_encountered > 8 && is_space) {
2780
+ // We have to be really aggressive at the start of sentences so stuff can be seen on mobile, hence comma
2781
+ segment.text_ = text.slice(j + 1).trimStart();
2782
+ segmented_text.splice(0, i);
2783
+ if (character === "," || is_space)
2784
+ // if we cut at a comma or psace, we add a … at the beginning
2785
+ segmented_text.unshift({
2786
+ text_: "… ",
2787
+ highlighted_: false
2788
+ });
2789
+ break outmost_loop;
2790
+ }
2791
+ if (is_first_character) is_first_character = false;
2792
+ }
2793
+ }
2794
+ $5ea5a82e398f6f44$var$heal_holes(segmented_text); // if we added a ... there could now be a sequence that's not alternating true/false
2795
+ }
2796
+
2797
+ function $5ea5a82e398f6f44$export$1b00d74faf266c56(text, matched_strings, loose = false) {
2798
+ const output = [];
2799
+ if (!text) return; // shouldn't happen but whatever
2800
+ for (let i = 0; i < text.length; i++) {
2801
+ const found_strings = [];
2802
+ if (!i || text[i - 1] == " " || loose)
2803
+ // only match at the start of a word or string, it looks weird if i.e. "we" is highlighted in "activewear
2804
+ for (let j = 0; j < matched_strings.length; j++) {
2805
+ const matched_string = matched_strings[j];
2806
+ const part_in_text = text.slice(i, i + matched_string.length);
2807
+ if (matched_string.length < 2 && !loose) continue; // don't match on single characters, i.e. "I", it looks weird
2808
+ 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
2809
+ }
2810
+
2811
+ const last_index_in_output = output.length - 1;
2812
+ if (!found_strings.length) {
2813
+ const character = text[i];
2814
+ if (output[last_index_in_output]?.highlighted_ === false || output.length && /\s/.test(character))
2815
+ // 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
2816
+ output[last_index_in_output].text_ += character;else output.push({
2817
+ highlighted_: false,
2818
+ text_: character
2819
+ });
2820
+ } else {
2821
+ const longest_found_string = found_strings.reduce((a, b) => a.length > b.length ? a : b);
2822
+ if (output[last_index_in_output]?.highlighted_) output[last_index_in_output].text_ += longest_found_string;else output.push({
2823
+ highlighted_: true,
2824
+ text_: longest_found_string
2825
+ });
2826
+ i += longest_found_string.length - 1;
2827
+ }
2828
+ }
2829
+ return output;
2830
+ }
2831
+ const $f6efb1605fcb9f39$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span>`),
2832
+ $f6efb1605fcb9f39$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class=highlighted-part>`);
2833
+ function $f6efb1605fcb9f39$export$8e79c28529dbfa90(props) {
2834
+ const segmented_text = $gVhhF$solidjs.createMemo(() => {
2835
+ const {
2836
+ to_highlight_: to_highlight_,
2837
+ text_: text_
2838
+ } = props;
2839
+ return $5ea5a82e398f6f44$export$1b00d74faf266c56(text_, to_highlight_ ? [to_highlight_] : [], true);
2840
+ });
2841
+ const has_highlights = $gVhhF$solidjs.createMemo(() => segmented_text().some(segment => segment.highlighted_));
2842
+ return (() => {
2843
+ const _el$ = $gVhhF$solidjsweb.getNextElement($f6efb1605fcb9f39$var$_tmpl$);
2844
+ $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
2845
+ get each() {
2846
+ return segmented_text();
2847
+ },
2848
+ children: item => {
2849
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
2850
+ get when() {
2851
+ return item().highlighted_;
2852
+ },
2853
+ get fallback() {
2854
+ return item().text_;
2855
+ },
2856
+ get children() {
2857
+ const _el$2 = $gVhhF$solidjsweb.getNextElement($f6efb1605fcb9f39$var$_tmpl$2);
2858
+ $gVhhF$solidjsweb.insert(_el$2, () => item().text_);
2859
+ return _el$2;
2860
+ }
2861
+ });
2862
+ }
2863
+ }));
2864
+ $gVhhF$solidjsweb.effect(_p$ => {
2865
+ const _v$ = props.text_,
2866
+ _v$2 = !!has_highlights();
2867
+ _v$ !== _p$._v$ && $gVhhF$solidjsweb.setAttribute(_el$, "title", _p$._v$ = _v$);
2868
+ _v$2 !== _p$._v$2 && _el$.classList.toggle("has-match", _p$._v$2 = _v$2);
2869
+ return _p$;
2870
+ }, {
2871
+ _v$: undefined,
2872
+ _v$2: undefined
2873
+ });
2874
+ return _el$;
2875
+ })();
2876
+ }
2877
+ const $3bdc00a1353c1150$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<form class="checkboxes hierarchical"><!$><!/><!$><!/>`),
2878
+ $3bdc00a1353c1150$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=checkbox-details><!$><!/><!$><!/>`),
2879
+ $3bdc00a1353c1150$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<details>`),
2880
+ $3bdc00a1353c1150$var$_tmpl$4 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<summary class=category-parent><div class=summary><span class=count></span><!$><!/>`);
2881
+ const $3bdc00a1353c1150$var$max_visible_without_collapsing = 15;
2882
+ const $3bdc00a1353c1150$var$show_non_collapsible_when_collapsed = 4;
2883
+ function $3bdc00a1353c1150$export$a32086fa6616eafd({
2884
+ filter_: filter_,
2885
+ selected_filters_: selected_filters_,
2886
+ i18n_: i18n_,
2887
+ view_more_button_below_group_: view_more_button_below_group_,
2888
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2889
+ filter_query_: filter_query_
2890
+ }) {
2891
+ let form;
2892
+ const existing_filter = $gVhhF$solidjs.createMemo(() => {
2893
+ const {
2894
+ field: field,
2895
+ op: op
2896
+ } = filter_();
2897
+ return selected_filters_[0]().find(({
2898
+ field: checking_field,
2899
+ op: checking_op
2900
+ }) => checking_field === field && checking_op === op);
2901
+ });
2902
+ const show_extras = $gVhhF$solidjs.createSignal(false);
2903
+ const is_being_searched_ = $gVhhF$solidjs.createMemo(() => !!filter_query_?.()); // If the user is searching in the filter
2904
+ const trigger_sync_ = $3bdc00a1353c1150$var$batching_filter_state_syncer({
2905
+ filter_: filter_,
2906
+ existing_filter_: existing_filter,
2907
+ selected_filters_: selected_filters_,
2908
+ get category_structure_() {
2909
+ return structured_categories();
2910
+ }
2911
+ });
2912
+ const structured_categories = $gVhhF$solidjs.createMemo(() => {
2913
+ const execute_when_structure_finished = [];
2914
+ const {
2915
+ values: values,
2916
+ names: names,
2917
+ counts: counts
2918
+ } = filter_().meta;
2919
+ const data_structure = {};
2920
+ for (let i = 0; i < values.length; i++) {
2921
+ const value = values[i];
2922
+ let pointer = data_structure;
2923
+ let parent_ = {};
2924
+ let created_an_object = false;
2925
+ for (let j = 0; j < value.length; j++) {
2926
+ const this_categories_name = value[j];
2927
+ const obj = pointer[this_categories_name] ||= (() => {
2928
+ 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;
2929
+ const created_obj = {
2930
+ name_: names[i],
2931
+ count_: counts?.[i],
2932
+ parent_: parent_,
2933
+ is_expanded_: $3bdc00a1353c1150$var$make_expanded_signal({
2934
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2935
+ filter_value_: value_as_string,
2936
+ is_being_searched_: is_being_searched_
2937
+ }),
2938
+ value_: value_as_string,
2939
+ children_: {}
2940
+ };
2941
+ const {
2942
+ signal_: signal_,
2943
+ on_structure_complete_: on_structure_complete_
2944
+ } = $3bdc00a1353c1150$var$create_updating_signal({
2945
+ self_: created_obj,
2946
+ existing_filter_: $gVhhF$solidjs.untrack(existing_filter),
2947
+ trigger_sync_: trigger_sync_
2948
+ });
2949
+ execute_when_structure_finished.push(on_structure_complete_);
2950
+ created_obj.is_checked_ = signal_;
2951
+ parent_ = created_obj;
2952
+ created_an_object = true;
2953
+ return created_obj;
2954
+ })();
2955
+ pointer = obj.children_;
2956
+ parent_ = obj;
2957
+ }
2958
+ if (!created_an_object && "value_" in parent_) {
2959
+ // 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
2960
+ // [
2961
+ // ["Öl", "IPA"],
2962
+ // ["Öl", "Pale Ale"],
2963
+ // ["Öl", "Ale"],
2964
+ // ["Öl", "Mörk Lager"],
2965
+ // ["Öl", "Suröl"],
2966
+ // ["Öl", "Veteöl"],
2967
+ // ["Öl", "Stout och Porter"],
2968
+ // ["Öl"], // <- We are here, our `hierarchical_data_structure[string]`-object was created when we iterated over ["Öl", "IPA"]
2969
+ // ["Öl", "Ljus Lager"],
2970
+ // ];
2971
+ // In this case we want to just correct the name and value of the already created object, which will be in parent_
2972
+ parent_.value_ = value.map(v => v + "");
2973
+ parent_.name_ = names[i];
2974
+ parent_.count_ = counts[i];
2975
+ parent_.is_expanded_ = $3bdc00a1353c1150$var$make_expanded_signal({
2976
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2977
+ filter_value_: parent_.value_,
2978
+ is_being_searched_: is_being_searched_
2979
+ });
2980
+ }
2981
+ }
2982
+ while (execute_when_structure_finished.length) execute_when_structure_finished.pop()();
2983
+ $3bdc00a1353c1150$var$expand_until_choice(data_structure);
2984
+ $gVhhF$depictaiutilishared.dlog("CheckboxHierarchicalFilter: Recomputed structured_categories", data_structure);
2985
+ return data_structure;
2986
+ });
2987
+ const some_top_level_are_hidden = $gVhhF$solidjs.createMemo(() => Object.keys(structured_categories()).length > $3bdc00a1353c1150$var$max_visible_without_collapsing);
2988
+ const {
2989
+ expand: expand,
2990
+ collapse: collapse,
2991
+ ExpandingContainer: ExpandingContainer
2992
+ } = $4b455f60dadde8b8$export$5bad61ecde080b1f({
2993
+ duration: 200
2994
+ });
2995
+ const expanding_container_els = $gVhhF$solidjsweb.createComponent(ExpandingContainer, {
2996
+ get children() {
2997
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
2998
+ get when() {
2999
+ return some_top_level_are_hidden();
3000
+ },
3001
+ get children() {
3002
+ return $3bdc00a1353c1150$var$render_stuff($gVhhF$solidjs.createMemo(() => Object.fromEntries(Object.entries(structured_categories()).slice($3bdc00a1353c1150$var$show_non_collapsible_when_collapsed))), existing_filter, i18n_, filter_query_);
3003
+ }
3004
+ });
3005
+ }
3006
+ });
3007
+ $gVhhF$solidjs.createRenderEffect(() => {
3008
+ view_more_button_below_group_[1](some_top_level_are_hidden() ? $gVhhF$solidjsweb.createComponent((0, $0fe1e7efdf4200d6$export$ca21a16d65b3dd8), {
3009
+ show_extras_: show_extras,
3010
+ i18n_: i18n_
3011
+ }) : []);
3012
+ });
3013
+ $gVhhF$solidjs.createEffect($gVhhF$depictaiutilishared.catchify(async () => {
3014
+ if (!some_top_level_are_hidden()) {
2656
3015
  await collapse();
2657
3016
  return;
2658
3017
  }
@@ -2666,13 +3025,13 @@ function $3bdc00a1353c1150$export$a32086fa6616eafd({
2666
3025
  [_el$5, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling);
2667
3026
  const _ref$ = form;
2668
3027
  typeof _ref$ === "function" ? $gVhhF$solidjsweb.use(_ref$, _el$) : form = _el$;
2669
- $gVhhF$solidjsweb.insert(_el$, () => $3bdc00a1353c1150$var$render_stuff($gVhhF$solidjs.createMemo(() => some_top_level_are_hidden() ? Object.fromEntries(Object.entries(structured_categories()).slice(0, $3bdc00a1353c1150$var$show_non_collapsible_when_collapsed)) : structured_categories()), existing_filter, i18n_), _el$3, _co$);
3028
+ $gVhhF$solidjsweb.insert(_el$, () => $3bdc00a1353c1150$var$render_stuff($gVhhF$solidjs.createMemo(() => some_top_level_are_hidden() ? Object.fromEntries(Object.entries(structured_categories()).slice(0, $3bdc00a1353c1150$var$show_non_collapsible_when_collapsed)) : structured_categories()), existing_filter, i18n_, filter_query_), _el$3, _co$);
2670
3029
  $gVhhF$solidjsweb.insert(_el$, expanding_container_els, _el$5, _co$2);
2671
3030
  $gVhhF$solidjsweb.effect(() => _el$.classList.toggle("any-expandable", !!Object.values(structured_categories()).some(category => Object.keys(category.children_).length)));
2672
3031
  return _el$;
2673
3032
  })();
2674
3033
  }
2675
- function $3bdc00a1353c1150$var$render_stuff(data, existing_filter, i18n_) {
3034
+ function $3bdc00a1353c1150$var$render_stuff(data, existing_filter, i18n_, filter_query_) {
2676
3035
  const keys = $gVhhF$solidjs.createMemo(() => Object.keys(data()));
2677
3036
  return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.For), {
2678
3037
  get each() {
@@ -2687,6 +3046,8 @@ function $3bdc00a1353c1150$var$render_stuff(data, existing_filter, i18n_) {
2687
3046
  // for some reason the for thing doesn't dispose of us if the key no longer exists?? so I'm doing it with show instead
2688
3047
  const value = $gVhhF$solidjs.createMemo(() => data()[key]); // still sometimes get undefined here even though we have <Show>
2689
3048
  const has_expandable = $gVhhF$solidjs.createMemo(() => !!Object.keys(value()?.children_ || {}).length);
3049
+ const value_as_string = $gVhhF$solidjs.createMemo(() => JSON.stringify(value()?.value_));
3050
+ const label_text = $gVhhF$solidjs.createMemo(() => value()?.name_ || value_as_string());
2690
3051
  return (() => {
2691
3052
  const _el$6 = $gVhhF$solidjsweb.getNextElement($3bdc00a1353c1150$var$_tmpl$2),
2692
3053
  _el$7 = _el$6.firstChild,
@@ -2695,10 +3056,17 @@ function $3bdc00a1353c1150$var$render_stuff(data, existing_filter, i18n_) {
2695
3056
  [_el$10, _co$4] = $gVhhF$solidjsweb.getNextMarker(_el$9.nextSibling);
2696
3057
  $gVhhF$solidjsweb.insert(_el$6, $gVhhF$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
2697
3058
  get value_() {
2698
- return JSON.stringify(value()?.value_);
3059
+ return value_as_string();
2699
3060
  },
2700
3061
  get label_() {
2701
- return value()?.name_;
3062
+ return $gVhhF$solidjsweb.createComponent((0, $f6efb1605fcb9f39$export$8e79c28529dbfa90), {
3063
+ get text_() {
3064
+ return label_text();
3065
+ },
3066
+ get to_highlight_() {
3067
+ return filter_query_?.();
3068
+ }
3069
+ });
2702
3070
  },
2703
3071
  get count_() {
2704
3072
  return $gVhhF$solidjsweb.memo(() => !!has_expandable())() ? undefined : value()?.count_;
@@ -2778,7 +3146,7 @@ function $3bdc00a1353c1150$var$render_stuff(data, existing_filter, i18n_) {
2778
3146
  return is_open();
2779
3147
  },
2780
3148
  get children() {
2781
- return $3bdc00a1353c1150$var$render_stuff($gVhhF$solidjs.createMemo(() => value()?.children_ || {}), existing_filter, i18n_);
3149
+ return $3bdc00a1353c1150$var$render_stuff($gVhhF$solidjs.createMemo(() => value()?.children_ || {}), existing_filter, i18n_, filter_query_);
2782
3150
  }
2783
3151
  });
2784
3152
  })();
@@ -2889,7 +3257,8 @@ function $3bdc00a1353c1150$var$create_updating_signal({
2889
3257
  }
2890
3258
  function $3bdc00a1353c1150$var$make_expanded_signal({
2891
3259
  expanded_hierarchical_filters_: [read_expanded_hierarchical_filters, write_expanded_hierarchical_filters],
2892
- filter_value_: filter_value_
3260
+ filter_value_: filter_value_,
3261
+ is_being_searched_: is_being_searched_
2893
3262
  }) {
2894
3263
  const index_in_expanded_filters = $gVhhF$solidjs.createMemo(() => read_expanded_hierarchical_filters().findIndex(({
2895
3264
  value_: value_
@@ -2928,7 +3297,9 @@ function $3bdc00a1353c1150$var$make_expanded_signal({
2928
3297
  defer: true
2929
3298
  }));
2930
3299
  return {
2931
- ui_should_show_expanded_: $gVhhF$solidjs.createMemo(() => user_choice_signal[0]() ?? get_low_precedence_expanded()),
3300
+ ui_should_show_expanded_: $gVhhF$solidjs.createMemo(
3301
+ // When user is searching through filters, expand everything they haven't collapsed, so they can see the results
3302
+ () => user_choice_signal[0]() ?? (is_being_searched_() || get_low_precedence_expanded())),
2932
3303
  set_low_precedence_expanded_: set_low_precedence_expanded,
2933
3304
  set_user_expanded_: set_user_choice_expanded
2934
3305
  };
@@ -2957,7 +3328,9 @@ const $0ef1681699140f1a$var$gap_px = 5;
2957
3328
  const $0ef1681699140f1a$var$max_columns = 3;
2958
3329
  const $0ef1681699140f1a$export$414f6a19d38e655c = ({
2959
3330
  filter_: filter_,
2960
- selected_filters_: [get_selected_filters, set_selected_filters]
3331
+ selected_filters_: [get_selected_filters, set_selected_filters],
3332
+ filter_query_: filter_query_,
3333
+ details_element_width_: details_element_width_
2961
3334
  }) => {
2962
3335
  const existing_filter = $gVhhF$solidjs.createMemo(() => {
2963
3336
  const {
@@ -2985,7 +3358,7 @@ const $0ef1681699140f1a$export$414f6a19d38e655c = ({
2985
3358
  const container_width_accessor = $gVhhF$solidjs.createMemo(() => {
2986
3359
  const element = container();
2987
3360
  if (!element) return;
2988
- return $e5f442fb78c98741$export$9f191182275e9ef(element);
3361
+ return $f13855d1b951b24a$export$ebdc3711f7e02ccd(element);
2989
3362
  });
2990
3363
  const [shadow_children, set_shadow_children] = $gVhhF$solidjs.createSignal(new Set(), {
2991
3364
  equals: false
@@ -2996,11 +3369,11 @@ const $0ef1681699140f1a$export$414f6a19d38e655c = ({
2996
3369
  return _el$;
2997
3370
  })(); // for getting the smallest possible sizes of all the items
2998
3371
  $gVhhF$solidjs.createEffect(() => {
2999
- const container_width = container_width_accessor()?.();
3000
- if (container_width == undefined) return;
3372
+ const container_width = container_width_accessor()?.() || details_element_width_();
3373
+ 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
3001
3374
  $0ef1681699140f1a$var$adjust_sizes(container_width, sizes_set(), set_cols_at_size);
3002
3375
  });
3003
- return [shadow_grid, $gVhhF$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), {
3376
+ return [$gVhhF$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), {
3004
3377
  get cols_at_size() {
3005
3378
  return cols_at_size();
3006
3379
  },
@@ -3022,66 +3395,72 @@ const $0ef1681699140f1a$export$414f6a19d38e655c = ({
3022
3395
  const current_value = $daa394359b026187$export$325f75597868c4f0(value().value_);
3023
3396
  return !!data?.some(item => $daa394359b026187$export$325f75597868c4f0(item) === current_value);
3024
3397
  });
3025
- const MakeButton = attributes => (() => {
3026
- const _el$2 = $gVhhF$solidjsweb.getNextElement($0ef1681699140f1a$var$_tmpl$3),
3027
- _el$5 = _el$2.firstChild,
3028
- [_el$6, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling),
3029
- _el$7 = _el$6.nextSibling,
3030
- [_el$8, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$7.nextSibling);
3031
- $gVhhF$solidjsweb.spread(_el$2, $gVhhF$solidjsweb.mergeProps(attributes, {
3032
- get disabled() {
3033
- return $gVhhF$solidjsweb.memo(() => value().count_ === 0)() && !is_selected();
3034
- },
3035
- get classList() {
3036
- return {
3037
- minor: !is_selected(),
3038
- major: is_selected(),
3039
- "major-minor-transition": true
3040
- };
3041
- },
3042
- get onClick() {
3043
- return $gVhhF$depictaiutilishared.catchify(() => {
3044
- const set_filter = existing_filter();
3045
- const {
3046
- field: field,
3047
- op: op
3048
- } = filter_();
3049
- const base_object = set_filter ? set_filter : {
3050
- op: op,
3051
- field: field
3052
- };
3053
- const old_data = base_object.data;
3054
- const new_data = [...(Array.isArray(old_data) ? [...old_data] : old_data ? [old_data] : [])];
3055
- const new_filter_object = {
3056
- ...base_object,
3057
- data: new_data
3398
+ const MakeButton = attributes => {
3399
+ const label = $gVhhF$solidjs.createMemo(() => value().name_ || value().value_ + "");
3400
+ return (() => {
3401
+ const _el$2 = $gVhhF$solidjsweb.getNextElement($0ef1681699140f1a$var$_tmpl$3),
3402
+ _el$5 = _el$2.firstChild,
3403
+ [_el$6, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling),
3404
+ _el$7 = _el$6.nextSibling,
3405
+ [_el$8, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$7.nextSibling);
3406
+ $gVhhF$solidjsweb.spread(_el$2, $gVhhF$solidjsweb.mergeProps(attributes, {
3407
+ get disabled() {
3408
+ return $gVhhF$solidjsweb.memo(() => value().count_ === 0)() && !is_selected();
3409
+ },
3410
+ get classList() {
3411
+ return {
3412
+ minor: !is_selected(),
3413
+ major: is_selected(),
3414
+ "major-minor-transition": true
3058
3415
  };
3059
- if (!is_selected()) new_filter_object.data.push(value().value_);else {
3060
- const current_value_lower = $daa394359b026187$export$325f75597868c4f0(value().value_);
3061
- new_filter_object.data = new_filter_object.data.filter(v => $daa394359b026187$export$325f75597868c4f0(v) !== current_value_lower);
3062
- }
3063
- const selected_filters = [...get_selected_filters().filter(f => f !== set_filter), ...(new_filter_object.data.length ? [new_filter_object] : [])];
3064
- set_selected_filters(selected_filters);
3065
- });
3066
- }
3067
- }), false, true);
3068
- $gVhhF$solidjsweb.insert(_el$2, () => value().value_, _el$6, _co$);
3069
- $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
3070
- get when() {
3071
- return value().count_ != undefined;
3072
- },
3073
- get children() {
3074
- const _el$3 = $gVhhF$solidjsweb.getNextElement($0ef1681699140f1a$var$_tmpl$2),
3075
- _el$4 = _el$3.firstChild;
3076
- $gVhhF$solidjsweb.insert(_el$4, () => value().count_);
3077
- return _el$3;
3078
- }
3079
- }), _el$8, _co$2);
3080
- $gVhhF$solidjsweb.runHydrationEvents();
3081
- return _el$2;
3082
- })();
3416
+ },
3417
+ get onClick() {
3418
+ return $gVhhF$depictaiutilishared.catchify(() => {
3419
+ const set_filter = existing_filter();
3420
+ const {
3421
+ field: field,
3422
+ op: op
3423
+ } = filter_();
3424
+ const base_object = set_filter ? set_filter : {
3425
+ op: op,
3426
+ field: field
3427
+ };
3428
+ const old_data = base_object.data;
3429
+ const new_data = [...(Array.isArray(old_data) ? [...old_data] : old_data ? [old_data] : [])];
3430
+ const new_filter_object = {
3431
+ ...base_object,
3432
+ data: new_data
3433
+ };
3434
+ if (!is_selected()) new_filter_object.data.push(value().value_);else {
3435
+ const current_value_lower = $daa394359b026187$export$325f75597868c4f0(value().value_);
3436
+ new_filter_object.data = new_filter_object.data.filter(v => $daa394359b026187$export$325f75597868c4f0(v) !== current_value_lower);
3437
+ }
3438
+ const selected_filters = [...get_selected_filters().filter(f => f !== set_filter), ...(new_filter_object.data.length ? [new_filter_object] : [])];
3439
+ set_selected_filters(selected_filters);
3440
+ });
3441
+ }
3442
+ }), false, true);
3443
+ $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $d023ed916c84e75d$export$ba17c5b7e6dda39f), {
3444
+ whole_text_to_display_: label,
3445
+ searching_for_value_: () => filter_query_?.()
3446
+ }), _el$6, _co$);
3447
+ $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
3448
+ get when() {
3449
+ return value().count_ != undefined;
3450
+ },
3451
+ get children() {
3452
+ const _el$3 = $gVhhF$solidjsweb.getNextElement($0ef1681699140f1a$var$_tmpl$2),
3453
+ _el$4 = _el$3.firstChild;
3454
+ $gVhhF$solidjsweb.insert(_el$4, () => value().count_);
3455
+ return _el$3;
3456
+ }
3457
+ }), _el$8, _co$2);
3458
+ $gVhhF$solidjsweb.runHydrationEvents();
3459
+ return _el$2;
3460
+ })();
3461
+ };
3083
3462
  const invisible_size_button = $gVhhF$solidjsweb.createComponent(MakeButton, {});
3084
- const smallest_possible_size = $e5f442fb78c98741$export$9f191182275e9ef(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
3463
+ const smallest_possible_size = $f13855d1b951b24a$export$ebdc3711f7e02ccd(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
3085
3464
  const sizes_value = $gVhhF$solidjs.untrack(sizes_set);
3086
3465
  const shadow_children_value = $gVhhF$solidjs.untrack(shadow_children);
3087
3466
  sizes_value.add(smallest_possible_size);
@@ -3101,7 +3480,7 @@ const $0ef1681699140f1a$export$414f6a19d38e655c = ({
3101
3480
  }
3102
3481
  });
3103
3482
  }
3104
- })];
3483
+ }), shadow_grid];
3105
3484
  };
3106
3485
  /**
3107
3486
  * Calculate and apply cols_at_size overrides to fit as many items as possible in a row, evenly spaced
@@ -3167,7 +3546,8 @@ function $b51a2b8b9355e66c$export$82ed4b28ecb67608({
3167
3546
  filter_: filter_,
3168
3547
  selected_filters_: [get_selected_filters, set_selected_filters],
3169
3548
  i18n_: i18n_,
3170
- view_more_button_below_group_: [_get_view_more_button_below_group_, set_view_more_button_below_group_]
3549
+ view_more_button_below_group_: [_get_view_more_button_below_group_, set_view_more_button_below_group_],
3550
+ filter_query_: filter_query_
3171
3551
  }) {
3172
3552
  // same as in CheckboxFilter, maybe we should make this DRY at some point
3173
3553
  const existing_filter = $gVhhF$solidjs.createMemo(() => {
@@ -3201,12 +3581,17 @@ function $b51a2b8b9355e66c$export$82ed4b28ecb67608({
3201
3581
  const value = $daa394359b026187$export$325f75597868c4f0(checkbox().value_);
3202
3582
  return !!data?.some(item => $daa394359b026187$export$325f75597868c4f0(item) === value);
3203
3583
  });
3584
+ const value = $gVhhF$solidjs.createMemo(() => checkbox().value_);
3585
+ const label_text = $gVhhF$solidjs.createMemo(() => checkbox().name_ || value() + "");
3204
3586
  const input_row = $gVhhF$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
3205
3587
  get value_() {
3206
- return checkbox().value_;
3588
+ return value();
3207
3589
  },
3208
3590
  get label_() {
3209
- return checkbox().name_;
3591
+ return $gVhhF$solidjsweb.createComponent((0, $d023ed916c84e75d$export$ba17c5b7e6dda39f), {
3592
+ whole_text_to_display_: label_text,
3593
+ searching_for_value_: () => filter_query_?.()
3594
+ });
3210
3595
  },
3211
3596
  get count_() {
3212
3597
  return checkbox().count_;
@@ -3509,10 +3894,165 @@ function $061ff5b4c3d36171$export$89c6019e4baa40b1(props) {
3509
3894
  }
3510
3895
  });
3511
3896
  }
3897
+ const $87d7574e1d89d69b$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<svg xmlns=http://www.w3.org/2000/svg width=20 height=22 viewBox="0 0 20 22"><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">`);
3898
+ function $87d7574e1d89d69b$export$82eafebb825fc23f(props = {}) {
3899
+ return (() => {
3900
+ const _el$ = $gVhhF$solidjsweb.getNextElement($87d7574e1d89d69b$var$_tmpl$);
3901
+ $gVhhF$solidjsweb.spread(_el$, props, true, true);
3902
+ $gVhhF$solidjsweb.runHydrationEvents();
3903
+ return _el$;
3904
+ })();
3905
+ }
3906
+ const $47d8681015b71901$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=search-in-filters><input type=text class=query><!$><!/><button class=clear>`);
3907
+ const $47d8681015b71901$var$min_items_to_enable_filter_searching = 10; // For checkbox hierarchical we 2x this
3908
+ function $47d8681015b71901$export$4b2c5292ffe0c5dd(filter_array_, section, i18n_) {
3909
+ const [filter_query_, set_filter_query_] = $gVhhF$solidjs.createSignal();
3910
+ // Check if we have enough items to enable searching
3911
+ const enable_searchability = $gVhhF$solidjs.createMemo(() => {
3912
+ let count = 0;
3913
+ for (const filter of filter_array_()) {
3914
+ const type = filter.meta?.type;
3915
+ if (type === "range") continue;
3916
+ const length = filter.meta.values.length;
3917
+ count += type === "checkbox-color" ? length / 2 : type === "checkbox-grid" ? length / 3 : length; // For checkbox-color we have two columns, checkbox-grid three, so we can show search later
3918
+ }
3919
+
3920
+ return count >= $47d8681015b71901$var$min_items_to_enable_filter_searching;
3921
+ });
3922
+ const SearchThisFilterGroup_ = () => {
3923
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
3924
+ get when() {
3925
+ return enable_searchability();
3926
+ },
3927
+ get children() {
3928
+ const _el$ = $gVhhF$solidjsweb.getNextElement($47d8681015b71901$var$_tmpl$),
3929
+ _el$2 = _el$.firstChild,
3930
+ _el$4 = _el$2.nextSibling,
3931
+ [_el$5, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling),
3932
+ _el$3 = _el$5.nextSibling;
3933
+ _el$2.$$input = ev => set_filter_query_(ev.currentTarget.value);
3934
+ $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $87d7574e1d89d69b$export$82eafebb825fc23f), {
3935
+ width: "16",
3936
+ height: "17.6",
3937
+ "class": "search-icon"
3938
+ }), _el$5, _co$);
3939
+ _el$3.$$click = () => set_filter_query_();
3940
+ $gVhhF$solidjsweb.insert(_el$3, $gVhhF$solidjsweb.createComponent((0, $c77c68e559a1506c$export$3b621d86b1566b2), {
3941
+ width: "12",
3942
+ height: "12"
3943
+ }));
3944
+ $gVhhF$solidjsweb.effect(_p$ => {
3945
+ const _v$ = i18n_.search_a_filter_()(section),
3946
+ _v$2 = filter_query_() ? "" : "none";
3947
+ _v$ !== _p$._v$ && $gVhhF$solidjsweb.setAttribute(_el$2, "placeholder", _p$._v$ = _v$);
3948
+ _v$2 !== _p$._v$2 && ((_p$._v$2 = _v$2) != null ? _el$3.style.setProperty("display", _v$2) : _el$3.style.removeProperty("display"));
3949
+ return _p$;
3950
+ }, {
3951
+ _v$: undefined,
3952
+ _v$2: undefined
3953
+ });
3954
+ $gVhhF$solidjsweb.effect(() => $gVhhF$solidjsweb.setProperty(_el$2, "value", filter_query_() || ""));
3955
+ $gVhhF$solidjsweb.runHydrationEvents();
3956
+ return _el$;
3957
+ }
3958
+ });
3959
+ };
3960
+ const searched_filter_array_ = $gVhhF$solidjs.createMemo(() => {
3961
+ const query = filter_query_();
3962
+ if (!enable_searchability() || !query) return filter_array_();
3963
+ const lowercase_query = query.toLowerCase();
3964
+ const check_string_match = to_check => {
3965
+ to_check = to_check.toLowerCase();
3966
+ return to_check.includes(lowercase_query) || lowercase_query.includes(to_check);
3967
+ };
3968
+ return filter_array_().map(filter => {
3969
+ const type = filter.meta?.type;
3970
+ 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
3971
+ const meta = filter.meta;
3972
+ const {
3973
+ values: values,
3974
+ names: names,
3975
+ counts: counts
3976
+ } = meta;
3977
+ 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
3978
+ const is_hierarchical_checkbox = type === "checkbox-hierarchical";
3979
+ // Which index of counts, values and names should be kept
3980
+ const filtered_indexes = values.map((item, index) => {
3981
+ const item_from_names = names?.[index];
3982
+ if (item_from_names && !is_hierarchical_checkbox)
3983
+ // 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
3984
+ item = item_from_names;
3985
+ if (typeof item === "number") return true;
3986
+ if (is_hierarchical_checkbox && names)
3987
+ // Special case for hierarchical checkboxes where we need to check if any of the names in the path match the query
3988
+ item = item.map((_, index) => names[$47d8681015b71901$var$find_str_arr_in_str_arr_arr("findIndex", values, item.slice(0, index + 1))]);
3989
+ if (Array.isArray(item)) return item.some(item => check_string_match(item + "")); // If any of the items in the array match, keep it
3990
+ return check_string_match(item);
3991
+ });
3992
+ const new_values = values.filter((_, i) => filtered_indexes[i]);
3993
+ if (!new_values.length) return false; // false = please delete this filter, see below
3994
+ const new_filter_object = {
3995
+ ...filter,
3996
+ meta: {
3997
+ ...meta,
3998
+ counts: counts?.filter((_, i) => filtered_indexes[i]),
3999
+ ...(names ? {
4000
+ names: meta.names?.filter((_, i) => filtered_indexes[i])
4001
+ } : {}),
4002
+ values: new_values
4003
+ }
4004
+ };
4005
+ if (is_hierarchical_checkbox) {
4006
+ // For hierarchical checkbox we need to fill the holes created by filtering, for example if there is
4007
+ // ["Clothes"]
4008
+ // ["Clothes", "Blazers"]
4009
+ // And the user searched for "blazers" we need to add back ["Clothes"] so CheckboxHierarchicalFilter doesn't get confused
4010
+ // 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
4011
+ // So we do it here instead
4012
+ const new_meta = new_filter_object.meta;
4013
+ const new_values = new_meta.values;
4014
+ for (const value of new_values) {
4015
+ if (!Array.isArray(value)) continue; // Shouldn't happen
4016
+ if (value.length < 2) continue; // No parent
4017
+ const parent = value.slice(0, -1);
4018
+ // Check if parent exists
4019
+ if ($47d8681015b71901$var$find_str_arr_in_str_arr_arr("some", new_values, parent)) continue; // Parent exists
4020
+ // Otherwise, put it back
4021
+ const index_to_restore = $47d8681015b71901$var$find_str_arr_in_str_arr_arr("findIndex", values, parent);
4022
+ if (index_to_restore < 0) {
4023
+ $gVhhF$depictaiutilishared.dwarn("Can't restore", parent, "to", new_values);
4024
+ continue;
4025
+ }
4026
+ const current_index_of_us = new_values.findIndex(item => item === value);
4027
+ new_values.splice(current_index_of_us, 0, values[index_to_restore]);
4028
+ const count_to_restore = counts?.[index_to_restore];
4029
+ if (count_to_restore) new_meta.counts?.splice(current_index_of_us, 0, count_to_restore);
4030
+ const name_to_restore = names?.[index_to_restore];
4031
+ if (name_to_restore) new_meta.names?.splice(current_index_of_us, 0, name_to_restore);
4032
+ }
4033
+ }
4034
+ return new_filter_object;
4035
+ }).filter(filter => filter); // Delete filters that don't have a value anymore
4036
+ });
4037
+
4038
+ return {
4039
+ SearchThisFilterGroup_: SearchThisFilterGroup_,
4040
+ searched_filter_array_: searched_filter_array_,
4041
+ filter_query_: filter_query_
4042
+ };
4043
+ }
4044
+ /**
4045
+ * Finds/whatevers what's effectively one hierarchical filter item in an array of hierarchical filter items
4046
+ * Functions similar to this happen loads in create_modified_filters, but they have additional checks so not touching them RN
4047
+ */
4048
+ function $47d8681015b71901$var$find_str_arr_in_str_arr_arr(operation, haystack, needle) {
4049
+ return haystack[operation](value => value.length === needle.length && value.every((item, index) => item === needle[index]));
4050
+ }
4051
+ $gVhhF$solidjsweb.delegateEvents(["input", "click"]);
3512
4052
  const $aff9a96d30ed3563$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=filter-collapsible>`),
3513
4053
  $aff9a96d30ed3563$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class=clear-group><!$><!/><span>`),
3514
4054
  $aff9a96d30ed3563$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=view-more-clear><!$><!/><!$><!/>`),
3515
- $aff9a96d30ed3563$var$_tmpl$4 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=filter-collapsible-body><div class=filter-part></div><!$><!/>`),
4055
+ $aff9a96d30ed3563$var$_tmpl$4 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=filter-collapsible-body><div class=filter-part><!$><!/><!$><!/></div><!$><!/>`),
3516
4056
  $aff9a96d30ed3563$var$_tmpl$5 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<details class=filter-collapsible>`),
3517
4057
  $aff9a96d30ed3563$var$_tmpl$6 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<summary class=filter-group-summary><div class=summary><span></span><div class=selected-w-sign><!$><!/><!$><!/>`),
3518
4058
  $aff9a96d30ed3563$var$_tmpl$7 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=ungrouped>`),
@@ -3567,6 +4107,11 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3567
4107
  const filter_array_ = $gVhhF$solidjs.createMemo(() => {
3568
4108
  return Object.values(togglable_filters_grouped_by_collapsible())[get_section_index()];
3569
4109
  });
4110
+ const {
4111
+ SearchThisFilterGroup_: SearchThisFilterGroup_,
4112
+ searched_filter_array_: searched_filter_array_,
4113
+ filter_query_: filter_query_
4114
+ } = $47d8681015b71901$export$4b2c5292ffe0c5dd(filter_array_, section_, props.i18n_);
3570
4115
  const is_open = $8c939a05b87fbbbc$export$ab34afce88557c0e({
3571
4116
  get expanded_filters_() {
3572
4117
  return props.expanded_filters_;
@@ -3579,27 +4124,30 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3579
4124
  // this is absolutely not accurate which is why we have the .filter below, it's just the easiest way to get the typing of the map correct
3580
4125
  filter_from_api]).filter(([selected_filter]) => selected_filter)));
3581
4126
  const a_filter_is_selected = $gVhhF$solidjs.createMemo(() => selected_filters_in_group().size);
4127
+ const [get_details_width, set_get_details_width] = $gVhhF$solidjs.createSignal();
4128
+ const details_element_width_ = $gVhhF$solidjs.createMemo(() => get_details_width?.()?.());
3582
4129
  return $gVhhF$solidjsweb.createComponent((0, $a69e505a12a77874$export$6c6d7a51fa9aa15d), {
3583
4130
  is_open_: is_open,
3584
4131
  get details_() {
3585
4132
  return (() => {
3586
- const _el$15 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$5);
3587
- $gVhhF$solidjsweb.setAttribute(_el$15, "data-group-title", section_);
3588
- return _el$15;
4133
+ const _el$19 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$5);
4134
+ $gVhhF$solidjsweb.use(element => set_get_details_width(() => $f13855d1b951b24a$export$ebdc3711f7e02ccd(element)), _el$19);
4135
+ $gVhhF$solidjsweb.setAttribute(_el$19, "data-group-title", section_);
4136
+ return _el$19;
3589
4137
  })();
3590
4138
  },
3591
4139
  get summary_() {
3592
4140
  return (() => {
3593
- const _el$16 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$6),
3594
- _el$17 = _el$16.firstChild,
3595
- _el$18 = _el$17.firstChild,
3596
- _el$19 = _el$18.nextSibling,
3597
- _el$20 = _el$19.firstChild,
3598
- [_el$21, _co$5] = $gVhhF$solidjsweb.getNextMarker(_el$20.nextSibling),
3599
- _el$22 = _el$21.nextSibling,
3600
- [_el$23, _co$6] = $gVhhF$solidjsweb.getNextMarker(_el$22.nextSibling);
3601
- $gVhhF$solidjsweb.insert(_el$18, section_);
3602
- $gVhhF$solidjsweb.insert(_el$19, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
4141
+ const _el$20 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$6),
4142
+ _el$21 = _el$20.firstChild,
4143
+ _el$22 = _el$21.firstChild,
4144
+ _el$23 = _el$22.nextSibling,
4145
+ _el$24 = _el$23.firstChild,
4146
+ [_el$25, _co$7] = $gVhhF$solidjsweb.getNextMarker(_el$24.nextSibling),
4147
+ _el$26 = _el$25.nextSibling,
4148
+ [_el$27, _co$8] = $gVhhF$solidjsweb.getNextMarker(_el$26.nextSibling);
4149
+ $gVhhF$solidjsweb.insert(_el$22, section_);
4150
+ $gVhhF$solidjsweb.insert(_el$23, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
3603
4151
  get when() {
3604
4152
  return a_filter_is_selected();
3605
4153
  },
@@ -3611,26 +4159,31 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3611
4159
  }
3612
4160
  });
3613
4161
  }
3614
- }), _el$21, _co$5);
3615
- $gVhhF$solidjsweb.insert(_el$19, $gVhhF$solidjsweb.createComponent((0, $7567511a7c3e4bd7$export$e5c2828934226505), {
4162
+ }), _el$25, _co$7);
4163
+ $gVhhF$solidjsweb.insert(_el$23, $gVhhF$solidjsweb.createComponent((0, $7567511a7c3e4bd7$export$e5c2828934226505), {
3616
4164
  get expanded_() {
3617
4165
  return is_open[0];
3618
4166
  },
3619
4167
  get i18n_() {
3620
4168
  return props.i18n_;
3621
4169
  }
3622
- }), _el$23, _co$6);
3623
- return _el$16;
4170
+ }), _el$27, _co$8);
4171
+ return _el$20;
3624
4172
  })();
3625
4173
  },
3626
4174
  get children() {
3627
4175
  const _el$2 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$4),
3628
4176
  _el$3 = _el$2.firstChild,
3629
- _el$13 = _el$3.nextSibling,
3630
- [_el$14, _co$4] = $gVhhF$solidjsweb.getNextMarker(_el$13.nextSibling);
4177
+ _el$4 = _el$3.firstChild,
4178
+ [_el$5, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling),
4179
+ _el$6 = _el$5.nextSibling,
4180
+ [_el$7, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$6.nextSibling),
4181
+ _el$17 = _el$3.nextSibling,
4182
+ [_el$18, _co$6] = $gVhhF$solidjsweb.getNextMarker(_el$17.nextSibling);
4183
+ $gVhhF$solidjsweb.insert(_el$3, $gVhhF$solidjsweb.createComponent(SearchThisFilterGroup_, {}), _el$5, _co$);
3631
4184
  $gVhhF$solidjsweb.insert(_el$3, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
3632
4185
  get each() {
3633
- return filter_array_();
4186
+ return searched_filter_array_();
3634
4187
  },
3635
4188
  children: filter => $gVhhF$solidjsweb.createComponent((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
3636
4189
  severity_: "error",
@@ -3652,11 +4205,13 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3652
4205
  get i18n_() {
3653
4206
  return props.i18n_;
3654
4207
  },
3655
- view_more_button_below_group_: view_more_button_below_group
4208
+ view_more_button_below_group_: view_more_button_below_group,
4209
+ filter_query_: filter_query_,
4210
+ details_element_width_: details_element_width_
3656
4211
  });
3657
4212
  }
3658
4213
  })
3659
- }));
4214
+ }), _el$7, _co$2);
3660
4215
  $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
3661
4216
  get when() {
3662
4217
  return $gVhhF$solidjs.createMemo(() => {
@@ -3665,22 +4220,22 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3665
4220
  })();
3666
4221
  },
3667
4222
  get children() {
3668
- const _el$4 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$3),
3669
- _el$9 = _el$4.firstChild,
3670
- [_el$10, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$9.nextSibling),
3671
- _el$11 = _el$10.nextSibling,
3672
- [_el$12, _co$3] = $gVhhF$solidjsweb.getNextMarker(_el$11.nextSibling);
3673
- $gVhhF$solidjsweb.insert(_el$4, () => view_more_button_below_group[0](), _el$10, _co$2);
3674
- $gVhhF$solidjsweb.insert(_el$4, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
4223
+ const _el$8 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$3),
4224
+ _el$13 = _el$8.firstChild,
4225
+ [_el$14, _co$4] = $gVhhF$solidjsweb.getNextMarker(_el$13.nextSibling),
4226
+ _el$15 = _el$14.nextSibling,
4227
+ [_el$16, _co$5] = $gVhhF$solidjsweb.getNextMarker(_el$15.nextSibling);
4228
+ $gVhhF$solidjsweb.insert(_el$8, () => view_more_button_below_group[0](), _el$14, _co$4);
4229
+ $gVhhF$solidjsweb.insert(_el$8, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
3675
4230
  get when() {
3676
4231
  return a_filter_is_selected();
3677
4232
  },
3678
4233
  get children() {
3679
- const _el$5 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$2),
3680
- _el$7 = _el$5.firstChild,
3681
- [_el$8, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$7.nextSibling),
3682
- _el$6 = _el$8.nextSibling;
3683
- $gVhhF$solidjsweb.addEventListener(_el$5, "click", $gVhhF$depictaiutilishared.catchify(() => {
4234
+ const _el$9 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$2),
4235
+ _el$11 = _el$9.firstChild,
4236
+ [_el$12, _co$3] = $gVhhF$solidjsweb.getNextMarker(_el$11.nextSibling),
4237
+ _el$10 = _el$12.nextSibling;
4238
+ $gVhhF$solidjsweb.addEventListener(_el$9, "click", $gVhhF$depictaiutilishared.catchify(() => {
3684
4239
  const new_filter_obj = [...props.selected_filters_[0]()];
3685
4240
  for (const filter of filter_array_()) {
3686
4241
  const index = new_filter_obj.findIndex(({
@@ -3691,15 +4246,15 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3691
4246
  }
3692
4247
  props.selected_filters_[1](new_filter_obj);
3693
4248
  }), true);
3694
- $gVhhF$solidjsweb.insert(_el$5, $gVhhF$solidjsweb.createComponent((0, $c77c68e559a1506c$export$3b621d86b1566b2), {}), _el$8, _co$);
3695
- $gVhhF$solidjsweb.insert(_el$6, () => props.i18n_.clear_individual_filter_());
4249
+ $gVhhF$solidjsweb.insert(_el$9, $gVhhF$solidjsweb.createComponent((0, $c77c68e559a1506c$export$3b621d86b1566b2), {}), _el$12, _co$3);
4250
+ $gVhhF$solidjsweb.insert(_el$10, () => props.i18n_.clear_individual_filter_());
3696
4251
  $gVhhF$solidjsweb.runHydrationEvents();
3697
- return _el$5;
4252
+ return _el$9;
3698
4253
  }
3699
- }), _el$12, _co$3);
3700
- return _el$4;
4254
+ }), _el$16, _co$5);
4255
+ return _el$8;
3701
4256
  }
3702
- }), _el$14, _co$4);
4257
+ }), _el$18, _co$6);
3703
4258
  return _el$2;
3704
4259
  }
3705
4260
  });
@@ -3712,8 +4267,8 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3712
4267
  return untogglable_filters()?.length;
3713
4268
  },
3714
4269
  get children() {
3715
- const _el$24 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$7);
3716
- $gVhhF$solidjsweb.insert(_el$24, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
4270
+ const _el$28 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$7);
4271
+ $gVhhF$solidjsweb.insert(_el$28, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
3717
4272
  get each() {
3718
4273
  return untogglable_filters();
3719
4274
  },
@@ -3738,15 +4293,15 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3738
4293
  }), $gVhhF$solidjsweb.memo(get_view_more_button_below_group)];
3739
4294
  }
3740
4295
  }));
3741
- return _el$24;
4296
+ return _el$28;
3742
4297
  }
3743
4298
  }), $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
3744
4299
  get when() {
3745
4300
  return $gVhhF$solidjsweb.memo(() => !!!props.are_in_modal_ /* modal has its own clear button */)() && props.selected_filters_[0]()?.length;
3746
4301
  },
3747
4302
  get children() {
3748
- const _el$25 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$8);
3749
- $gVhhF$solidjsweb.addEventListener(_el$25, "click", $gVhhF$depictaiutilishared.catchify(() => $47e2cc552c02110c$export$8895d39404bd2bb1({
4303
+ const _el$29 = $gVhhF$solidjsweb.getNextElement($aff9a96d30ed3563$var$_tmpl$8);
4304
+ $gVhhF$solidjsweb.addEventListener(_el$29, "click", $gVhhF$depictaiutilishared.catchify(() => $47e2cc552c02110c$export$8895d39404bd2bb1({
3750
4305
  user_triggered_: true,
3751
4306
  selected_filters_: props.selected_filters_,
3752
4307
  i18n_: props.i18n_,
@@ -3754,9 +4309,9 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
3754
4309
  expanded_hierarchical_filters_: props.expanded_hierarchical_filters_,
3755
4310
  local_filter_cache_: props.local_filter_cache_
3756
4311
  })), true);
3757
- $gVhhF$solidjsweb.insert(_el$25, () => props.i18n_.clear_all_filters_from_big_button_());
4312
+ $gVhhF$solidjsweb.insert(_el$29, () => props.i18n_.clear_all_filters_from_big_button_());
3758
4313
  $gVhhF$solidjsweb.runHydrationEvents();
3759
- return _el$25;
4314
+ return _el$29;
3760
4315
  }
3761
4316
  })];
3762
4317
  }
@@ -7997,19 +8552,6 @@ const $3df11fc61432d1fd$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<s
7997
8552
  function $3df11fc61432d1fd$export$1c641004b5485fed() {
7998
8553
  return $gVhhF$solidjsweb.getNextElement($3df11fc61432d1fd$var$_tmpl$);
7999
8554
  }
8000
- const $87d7574e1d89d69b$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<svg><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">`);
8001
- function $87d7574e1d89d69b$export$82eafebb825fc23f(props = {}) {
8002
- return (() => {
8003
- const _el$ = $gVhhF$solidjsweb.getNextElement($87d7574e1d89d69b$var$_tmpl$);
8004
- $gVhhF$solidjsweb.spread(_el$, $gVhhF$solidjsweb.mergeProps(props, {
8005
- "xmlns": "http://www.w3.org/2000/svg",
8006
- "width": "20",
8007
- "height": "22"
8008
- }), true, true);
8009
- $gVhhF$solidjsweb.runHydrationEvents();
8010
- return _el$;
8011
- })();
8012
- }
8013
8555
  const $66b8b9a9613c141d$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class=back type=button>`),
8014
8556
  $66b8b9a9613c141d$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=search-field><!$><!/><div class=field><input class=query tabindex=0><button type=button class=clear></button></div><button class="submit major"type=button>`);
8015
8557
  function $66b8b9a9613c141d$export$b94867ecbd698f21({
@@ -8747,91 +9289,19 @@ function $9a268bf73b31a717$export$a146ac6fa8346a25({
8747
9289
  _v$3 !== _p$._v$3 && $gVhhF$solidjsweb.setAttribute(_el$6, "title", _p$._v$3 = _v$3);
8748
9290
  _v$4 !== _p$._v$4 && $gVhhF$solidjsweb.setAttribute(_el$9, "title", _p$._v$4 = _v$4);
8749
9291
  return _p$;
8750
- }, {
8751
- _v$: undefined,
8752
- _v$2: undefined,
8753
- _v$3: undefined,
8754
- _v$4: undefined
8755
- });
8756
- return _el$4;
8757
- })();
8758
- }
8759
- }));
8760
- return _el$;
8761
- }
8762
- });
8763
- }
8764
- const $d023ed916c84e75d$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class=highlighted-part>`),
8765
- $d023ed916c84e75d$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span>`);
8766
- function $d023ed916c84e75d$export$ba17c5b7e6dda39f({
8767
- whole_text_to_display_: whole_text_to_display_memo,
8768
- searching_for_value_: searching_for_value_memo,
8769
- class_: class_
8770
- }) {
8771
- const [get_has_highlighted, set_has_highlighted] = $gVhhF$solidjs.createSignal(false);
8772
- const text_itself = $gVhhF$solidjs.createMemo(() => $gVhhF$solidjs.batch(() => {
8773
- set_has_highlighted(false);
8774
- const searching_for_value = searching_for_value_memo();
8775
- const whole_text_to_display_ = whole_text_to_display_memo();
8776
- let for_black = "";
8777
- let pushed_grey = false;
8778
- const search_q = searching_for_value;
8779
- if (!search_q) return whole_text_to_display_;
8780
- const output = [];
8781
- const searching_for = search_q.toLowerCase();
8782
- const push_black = () => {
8783
- if (for_black) {
8784
- set_has_highlighted(true);
8785
- output.push((() => {
8786
- const _el$ = $gVhhF$solidjsweb.getNextElement($d023ed916c84e75d$var$_tmpl$);
8787
- $gVhhF$solidjsweb.insert(_el$, for_black);
8788
- return _el$;
8789
- })()); // "black"
8790
- for_black = "";
8791
- }
8792
- };
8793
- for (let i = 0; i < whole_text_to_display_.length;) {
8794
- let is_whole_word = true;
8795
- let searching_for_but_with_texts_casing = "";
8796
- const i_at_start = i;
8797
- for (let j = 0; j < searching_for.length; i++, j++) {
8798
- const letter_in_suggestion = whole_text_to_display_[i];
8799
- if (letter_in_suggestion?.toLowerCase() !== searching_for[j]) {
8800
- is_whole_word = false;
8801
- i = i_at_start;
8802
- break;
9292
+ }, {
9293
+ _v$: undefined,
9294
+ _v$2: undefined,
9295
+ _v$3: undefined,
9296
+ _v$4: undefined
9297
+ });
9298
+ return _el$4;
9299
+ })();
8803
9300
  }
8804
- searching_for_but_with_texts_casing += letter_in_suggestion;
8805
- }
8806
- if (is_whole_word) {
8807
- push_black();
8808
- output.push(searching_for_but_with_texts_casing);
8809
- pushed_grey = true;
8810
- } else for_black += whole_text_to_display_[i++];
8811
- }
8812
- push_black();
8813
- if (!pushed_grey) {
8814
- set_has_highlighted(false);
8815
- return whole_text_to_display_;
9301
+ }));
9302
+ return _el$;
8816
9303
  }
8817
- return output;
8818
- }));
8819
- return (() => {
8820
- const _el$2 = $gVhhF$solidjsweb.getNextElement($d023ed916c84e75d$var$_tmpl$2);
8821
- $gVhhF$solidjsweb.className(_el$2, class_);
8822
- $gVhhF$solidjsweb.insert(_el$2, text_itself);
8823
- $gVhhF$solidjsweb.effect(_p$ => {
8824
- const _v$ = !!get_has_highlighted(),
8825
- _v$2 = whole_text_to_display_memo() /* for when line-clamped, users can see full text on hover */;
8826
- _v$ !== _p$._v$ && _el$2.classList.toggle("has-history-match", _p$._v$ = _v$);
8827
- _v$2 !== _p$._v$2 && $gVhhF$solidjsweb.setAttribute(_el$2, "title", _p$._v$2 = _v$2);
8828
- return _p$;
8829
- }, {
8830
- _v$: undefined,
8831
- _v$2: undefined
8832
- });
8833
- return _el$2;
8834
- })();
9304
+ });
8835
9305
  }
8836
9306
  const $c0125412b4ea0c93$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<svg xmlns=http://www.w3.org/2000/svg width=32 height=32 viewBox="0 0 256 256"><path d="M56 26.455a13.71 13.71 0 0 0-9.578 3.967A13.71 13.71 0 0 0 42.455 40v176a13.71 13.71 0 0 0 3.967 9.578A13.71 13.71 0 0 0 56 229.545h144A13.71 13.71 0 0 0 213.545 216V88a2.456 2.456 0 0 1 0-.002c.001-1.452-.597-2.895-1.623-3.922l-55.998-55.998a5.61 5.61 0 0 0-3.922-1.623 2.456 2.456 0 0 1-.002 0zm0 11.09h88A2.456 2.456 0 0 1 146.455 40v48c0 2.903 2.642 5.545 5.545 5.545h48A2.456 2.456 0 0 1 202.455 96v120a2.456 2.456 0 0 1-2.455 2.455H56A2.456 2.456 0 0 1 53.545 216V40A2.456 2.456 0 0 1 56 37.545zm103.061 11.498a2.456 2.456 0 0 1 2.676.531l28.689 28.689a2.456 2.456 0 0 1-1.736 4.191H160A2.456 2.456 0 0 1 157.545 80V51.311a2.456 2.456 0 0 1 1.516-2.268zM96 130.455c-2.903 0-5.545 2.642-5.545 5.545s2.642 5.545 5.545 5.545h64c2.903 0 5.545-2.642 5.545-5.545s-2.642-5.545-5.545-5.545zm0 32c-2.903 0-5.545 2.642-5.545 5.545s2.642 5.545 5.545 5.545h64c2.903 0 5.545-2.642 5.545-5.545s-2.642-5.545-5.545-5.545z">`);
8837
9307
  function $c0125412b4ea0c93$export$605674723bcc715c(props = {}) {
@@ -8870,8 +9340,8 @@ function $6b65ba8af12c5a26$export$e872e2339fb04a7f({
8870
9340
  type: type,
8871
9341
  title: title
8872
9342
  }) => type === (0, $3ec9e21d6b6debdd$export$3cf9497e790da491) && !filtered_previous_searches_().includes(title) // don't show the ones we already show from the history
8873
- ));
8874
-
9343
+ ) // + limit to three query suggestions, API sends more sometimes
9344
+ .slice(0, 3));
8875
9345
  const not_queries_memo = $gVhhF$solidjs.createMemo(() => {
8876
9346
  // For the section that shows categories and content results
8877
9347
  // We want to limit to 3 items, and we want to show the categories first
@@ -9851,226 +10321,6 @@ function $2005eec80e40088f$export$41b4894022a3580f({
9851
10321
  })));
9852
10322
  return style_props_;
9853
10323
  }
9854
- const $5ea5a82e398f6f44$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class=highlighted-part>`);
9855
- const $5ea5a82e398f6f44$var$dont_cut_in_between_less_than_characters = 30;
9856
- function $5ea5a82e398f6f44$export$e1a98a189fd2c0e7({
9857
- content_result_: content_result_,
9858
- key_: key_,
9859
- cut_when_possible_: cut_when_possible_
9860
- }) {
9861
- const matched_tokens = $gVhhF$solidjs.createMemo(() => content_result_().highlights?.find(highlight => highlight.field == key_)?.matched_tokens);
9862
- const full_value = $gVhhF$solidjs.createMemo(() => content_result_()[key_]?.replaceAll("\n", " "));
9863
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
9864
- get when() {
9865
- return matched_tokens()?.length;
9866
- },
9867
- get fallback() {
9868
- return full_value();
9869
- },
9870
- get children() {
9871
- return (() => {
9872
- const segmented_cut_text = $gVhhF$solidjs.createMemo(() => {
9873
- const segmented_text = $5ea5a82e398f6f44$var$segment_text(full_value(), matched_tokens());
9874
- if (cut_when_possible_) $5ea5a82e398f6f44$var$cut_text(segmented_text);
9875
- return segmented_text;
9876
- });
9877
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
9878
- get each() {
9879
- return segmented_cut_text();
9880
- },
9881
- children: item => {
9882
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
9883
- get when() {
9884
- return item().highlighted_;
9885
- },
9886
- get fallback() {
9887
- return item().text_;
9888
- },
9889
- get children() {
9890
- const _el$ = $gVhhF$solidjsweb.getNextElement($5ea5a82e398f6f44$var$_tmpl$);
9891
- $gVhhF$solidjsweb.insert(_el$, () => item().text_);
9892
- return _el$;
9893
- }
9894
- });
9895
- }
9896
- });
9897
- })();
9898
- }
9899
- });
9900
- }
9901
- function $5ea5a82e398f6f44$var$cut_text(segmented_text) {
9902
- // cut away chunks of text that are not highlighted to give a google-like overview of the content
9903
- const highlighted_segments = segmented_text?.filter(segment => segment.highlighted_);
9904
- if (!segmented_text || !highlighted_segments?.length) return;
9905
- // We have one or more highlighted segments
9906
- if (highlighted_segments.length === 1) {
9907
- // cut away from the left until the start of the highlighted sentence if just one sentence is highlighted
9908
- $5ea5a82e398f6f44$var$cut_start(segmented_text.indexOf(highlighted_segments[0]), segmented_text);
9909
- return;
9910
- }
9911
- // We have two or more highlighted segments, take the two biggest chunks and show them + a bit text around
9912
- 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
9913
- );
9914
-
9915
- const [longest_segment, next_longest_segment] = sorted_highlighted_segments;
9916
- // We need to cut before the first segment - possibly through other segments - and maybe between segments
9917
- 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);
9918
- $5ea5a82e398f6f44$var$cut_start(index_of_first_segment, segmented_text);
9919
- // update indexes since we might have removed segments
9920
- [index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
9921
- let number_of_characters_between_segments = 0;
9922
- for (let i = index_of_first_segment + 1; i < index_of_second_segment; i++) {
9923
- const segment = segmented_text[i];
9924
- number_of_characters_between_segments += segment.text_.length;
9925
- }
9926
- if (number_of_characters_between_segments < $5ea5a82e398f6f44$var$dont_cut_in_between_less_than_characters)
9927
- // don't cut if there are less than 30 characters between the two segments
9928
- return;
9929
- // We have more than 50 characters between the two segments, cut between them
9930
- const [split_start_segment, split_start_character] = $5ea5a82e398f6f44$var$find_split_point(index_of_first_segment, index_of_second_segment, segmented_text);
9931
- const [split_end_segment, split_end_character] = $5ea5a82e398f6f44$var$find_split_point(index_of_second_segment, index_of_first_segment, segmented_text);
9932
- if (split_start_segment === undefined || split_end_segment === undefined ||
9933
- // identical split point, or split end before split start, can't do anything
9934
- split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
9935
- const dots_segment = {
9936
- text_: " … ",
9937
- highlighted_: false
9938
- };
9939
- const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
9940
- if (i < split_start_segment || i > split_end_segment) return segment;
9941
- const text = segment.text_;
9942
- if (i == split_end_segment && i == split_start_segment) return [{
9943
- ...segment,
9944
- text_: text.slice(0, split_start_character).trimEnd()
9945
- }, dots_segment, {
9946
- ...segment,
9947
- text_: text.slice(split_end_character + 1, text.length).trimStart()
9948
- }];else if (i == split_start_segment) {
9949
- 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
9950
- return segment;
9951
- } else if (i == split_end_segment) return [dots_segment, {
9952
- ...segment,
9953
- text_: text.slice(split_end_character + 1, text.length).trimStart()
9954
- }];
9955
- return []; // remove all segments inbetween
9956
- });
9957
-
9958
- segmented_text.splice(0, segmented_text.length, ...split_and_dotted_values); // Sorry…
9959
- $5ea5a82e398f6f44$var$heal_holes(segmented_text);
9960
- }
9961
- function $5ea5a82e398f6f44$var$heal_holes(segmented_text) {
9962
- // try to heal "holes" created in the segments so there are only alternating segments
9963
- const segments_to_delete = new Set();
9964
- for (let i = 0; i < segmented_text.length; i++) {
9965
- const segment = segmented_text[i];
9966
- let previous_segment;
9967
- for (let j = i - 1; j >= 0; j--) {
9968
- previous_segment = segmented_text[j];
9969
- // Don't write to a segment that's marked for deletion or the contents we write to it will be deleted
9970
- if (!segments_to_delete.has(previous_segment)) break;
9971
- }
9972
- if (previous_segment?.highlighted_ && segment.highlighted_ || previous_segment?.highlighted_ === false && segment.highlighted_ === false) {
9973
- previous_segment.text_ += segment.text_; // IDK if this ever happens
9974
- segments_to_delete.add(segment);
9975
- }
9976
- }
9977
- for (const segment of segments_to_delete) {
9978
- const index = segmented_text.indexOf(segment);
9979
- segmented_text.splice(index, 1);
9980
- }
9981
- }
9982
- function $5ea5a82e398f6f44$var$find_split_point(index_of_start_segment, index_of_end_segment, segmented_text, be_very_aggressive = true) {
9983
- const should_loop_backwards = index_of_start_segment > index_of_end_segment;
9984
- const step = should_loop_backwards ? -1 : 1;
9985
- const desperate_split_attempts = [":", ";", ","];
9986
- while (desperate_split_attempts.length) {
9987
- const split_point_between_words = [];
9988
- // for the middle also try to split with a few more characters if the default ones don't work over a full run
9989
- const desperate_split_attempt = desperate_split_attempts.pop();
9990
- let is_first_character = true;
9991
- for (let i = index_of_start_segment + step; should_loop_backwards ? i > index_of_end_segment : i < index_of_end_segment; i += step) {
9992
- const segment = segmented_text[i];
9993
- const text = segment.text_;
9994
- for (let j = should_loop_backwards ? text.length - 1 : 0; should_loop_backwards ? j >= 0 : j < text.length; j += step) {
9995
- const character = text[j];
9996
- if (character == "." || character == "?" || character == "!" || character == desperate_split_attempt) return [i, j]; // segment index, character index
9997
- if (is_first_character) is_first_character = false;else if (be_very_aggressive && character == " ") {
9998
- split_point_between_words.push([i, j]);
9999
- if (split_point_between_words.length > 3)
10000
- // We can't find a split point, so we'll just split between words
10001
- // 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
10002
- return split_point_between_words[1];
10003
- }
10004
- }
10005
- }
10006
- }
10007
- return [];
10008
- }
10009
- function $5ea5a82e398f6f44$var$cut_start(cut_left_of_index, segmented_text) {
10010
- // Cut the start of the text to bring the first matching token
10011
- let is_first_character = false;
10012
- let words_encountered = 0;
10013
- outmost_loop: for (let i = cut_left_of_index - 1; i >= 0; i--) {
10014
- const segment = segmented_text[i];
10015
- // We assume that two adjacent highlighted segments don't exist and have been merged if they were to have existed
10016
- const text = segment.text_;
10017
- for (let j = text.length - 1; j >= 0; j--) {
10018
- const character = text[j];
10019
- const is_space = character == " ";
10020
- if (!is_first_character && is_space) words_encountered++;
10021
- if (character == "." || character == "?" || character == "!" || character == "," || words_encountered > 8 && is_space) {
10022
- // We have to be really aggressive at the start of sentences so stuff can be seen on mobile, hence comma
10023
- segment.text_ = text.slice(j + 1).trimStart();
10024
- segmented_text.splice(0, i);
10025
- if (character === "," || is_space)
10026
- // if we cut at a comma or psace, we add a … at the beginning
10027
- segmented_text.unshift({
10028
- text_: "… ",
10029
- highlighted_: false
10030
- });
10031
- break outmost_loop;
10032
- }
10033
- if (is_first_character) is_first_character = false;
10034
- }
10035
- }
10036
- $5ea5a82e398f6f44$var$heal_holes(segmented_text); // if we added a ... there could now be a sequence that's not alternating true/false
10037
- }
10038
-
10039
- function $5ea5a82e398f6f44$var$segment_text(text, matched_strings) {
10040
- // segment text where the matched strings are highlighted sections
10041
- const output = [];
10042
- if (!text) return; // shouldn't happen but whatever
10043
- for (let i = 0; i < text.length; i++) {
10044
- const found_strings = [];
10045
- if (!i || text[i - 1] == " ")
10046
- // only match at the start of a word or string, it looks weird if i.e. "we" is highlighted in "activewear
10047
- for (let j = 0; j < matched_strings.length; j++) {
10048
- const matched_string = matched_strings[j];
10049
- const part_in_text = text.slice(i, i + matched_string.length);
10050
- if (matched_string.length < 2) continue; // don't match on single characters, i.e. "I", it looks weird
10051
- 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
10052
- }
10053
-
10054
- const last_index_in_output = output.length - 1;
10055
- if (!found_strings.length) {
10056
- const character = text[i];
10057
- if (output[last_index_in_output]?.highlighted_ === false || output.length && /\s/.test(character))
10058
- // 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
10059
- output[last_index_in_output].text_ += character;else output.push({
10060
- highlighted_: false,
10061
- text_: character
10062
- });
10063
- } else {
10064
- const longest_found_string = found_strings.reduce((a, b) => a.length > b.length ? a : b);
10065
- if (output[last_index_in_output]?.highlighted_) output[last_index_in_output].text_ += longest_found_string;else output.push({
10066
- highlighted_: true,
10067
- text_: longest_found_string
10068
- });
10069
- i += longest_found_string.length - 1;
10070
- }
10071
- }
10072
- return output;
10073
- }
10074
10324
  const $76227de40be817e5$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<a>`),
10075
10325
  $76227de40be817e5$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`),
10076
10326
  $76227de40be817e5$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="description line-clamp">`),