@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/ES10/index.cjs +880 -612
- package/ES10/index.d.ts +4 -3
- package/ES10/index.js +881 -613
- package/latest/index.cjs +849 -599
- package/latest/index.d.ts +4 -3
- package/latest/index.js +850 -600
- package/locales/ES10/index.cjs +25 -12
- package/locales/ES10/index.d.ts +1 -0
- package/locales/ES10/index.js +25 -12
- package/locales/latest/index.cjs +25 -12
- package/locales/latest/index.d.ts +1 -0
- package/locales/latest/index.js +25 -12
- package/locales/require.js +1152 -0
- package/package.json +3 -3
- package/server/ES10/index.cjs +749 -522
- package/server/ES10/index.d.ts +4 -3
- package/server/ES10/index.js +750 -523
- package/server/latest/index.cjs +734 -523
- package/server/latest/index.d.ts +4 -3
- package/server/latest/index.js +735 -524
package/server/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, "
|
|
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.
|
|
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_";
|
|
@@ -486,24 +486,30 @@ function $a0e53f99354809d9$export$6649caad96ef8870({
|
|
|
486
486
|
|
|
487
487
|
/** @jsxImportSource solid-js */
|
|
488
488
|
|
|
489
|
-
function $
|
|
490
|
-
const [
|
|
489
|
+
function $f13855d1b951b24a$export$ebdc3711f7e02ccd(what_to_watch) {
|
|
490
|
+
const [width, setWidth] = $5vyXB$solidjs.createSignal();
|
|
491
491
|
const resizeObserver = new ResizeObserver($5vyXB$depictaiutilishared.catchify(records => {
|
|
492
492
|
for (let j = 0; j < records.length; j++) {
|
|
493
493
|
const width = records[j].borderBoxSize?.[0]?.inlineSize ?? what_to_watch.getBoundingClientRect().width;
|
|
494
|
-
|
|
494
|
+
setWidth(width);
|
|
495
495
|
}
|
|
496
496
|
}));
|
|
497
497
|
// 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.
|
|
498
498
|
// It doesn't seem to work even when waiting for it to be in the DOM, also wait an animation frame
|
|
499
499
|
const disconnect = (0, $5vyXB$depictaiutilishared.observer).onexists(what_to_watch, ({
|
|
500
500
|
element: element
|
|
501
|
-
}) => requestAnimationFrame($5vyXB$depictaiutilishared.catchify(() =>
|
|
501
|
+
}) => requestAnimationFrame($5vyXB$depictaiutilishared.catchify(() => {
|
|
502
|
+
const current_size = what_to_watch.getBoundingClientRect().width;
|
|
503
|
+
if (current_size)
|
|
504
|
+
// 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.
|
|
505
|
+
setWidth(current_size);
|
|
506
|
+
resizeObserver.observe(element);
|
|
507
|
+
})));
|
|
502
508
|
$5vyXB$solidjs.onCleanup(() => {
|
|
503
509
|
resizeObserver.disconnect();
|
|
504
510
|
disconnect();
|
|
505
511
|
});
|
|
506
|
-
return
|
|
512
|
+
return width;
|
|
507
513
|
}
|
|
508
514
|
const $4e04be41243c3d80$var$transform_elements = sorted_cols_at_size => {
|
|
509
515
|
const cols_at_size = [];
|
|
@@ -786,7 +792,7 @@ class $7dd1edb2ee2b43ad$export$aa14a9f43128f61f extends $7dd1edb2ee2b43ad$export
|
|
|
786
792
|
});
|
|
787
793
|
}
|
|
788
794
|
}
|
|
789
|
-
const $edafe91daf3091d7$var$_tmpl$ = ["<div", ' class="', '"
|
|
795
|
+
const $edafe91daf3091d7$var$_tmpl$ = ["<div", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></div>"];
|
|
790
796
|
function $edafe91daf3091d7$export$b69d0d92862de18b(props) {
|
|
791
797
|
return $5vyXB$solidjs.ErrorBoundary({
|
|
792
798
|
fallback(err, retry) {
|
|
@@ -799,8 +805,7 @@ function $edafe91daf3091d7$export$b69d0d92862de18b(props) {
|
|
|
799
805
|
console.error(err.cause);
|
|
800
806
|
message = `${message}: ${err.message}`;
|
|
801
807
|
} else $5vyXB$depictaiutilishared.report([err, message_], severity_);
|
|
802
|
-
props.on_error_?.(retry);
|
|
803
|
-
return $5vyXB$solidjsweb.ssr($edafe91daf3091d7$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.ssrClassList(Object.fromEntries(props.class_list_?.map(c => [c, true]) || [])), $5vyXB$solidjsweb.escape(message));
|
|
808
|
+
return $5vyXB$solidjsweb.ssr($edafe91daf3091d7$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.ssrClassList(Object.fromEntries(props.class_list_?.map(c => [c, true]) || [])), $5vyXB$solidjsweb.escape(message), $5vyXB$solidjsweb.escape(props.on_error_?.(retry)));
|
|
804
809
|
},
|
|
805
810
|
get children() {
|
|
806
811
|
return props.children;
|
|
@@ -1261,12 +1266,12 @@ function $d659702496cb72ea$export$a71e92cfbb498adc(props) {
|
|
|
1261
1266
|
}
|
|
1262
1267
|
const $c77c68e559a1506c$var$_tmpl$ = '<path d="M11.669 10.531l9.156-9.156a.78.78 0 0 0 .237-.569c0-.221-.079-.412-.237-.569A.8.8 0 0 0 20.24 0a.77.77 0 0 0-.569.237l-9.14 9.14-9.14-9.14A.79.79 0 0 0 .807 0a.77.77 0 0 0-.569.237A.78.78 0 0 0 0 .807a.77.77 0 0 0 .237.569l9.156 9.156-9.156 9.14c-.159.157-.237.349-.237.569s.079.412.237.569c.085.085.174.148.268.19a1.095 1.095 0 0 0 .316.048.894.894 0 0 0 .285-.048.84.84 0 0 0 .285-.19l9.139-9.14 9.14 9.14a.894.894 0 0 0 .268.19 1.049 1.049 0 0 0 .301.048.941.941 0 0 0 .301-.048.84.84 0 0 0 .285-.19.78.78 0 0 0 .237-.569c0-.221-.079-.412-.237-.569z"></path>';
|
|
1263
1268
|
function $c77c68e559a1506c$export$3b621d86b1566b2(props = {}) {
|
|
1264
|
-
return $5vyXB$solidjsweb.ssrElement("svg", $5vyXB$solidjsweb.mergeProps(
|
|
1269
|
+
return $5vyXB$solidjsweb.ssrElement("svg", $5vyXB$solidjsweb.mergeProps({
|
|
1265
1270
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1266
1271
|
width: "21.064",
|
|
1267
1272
|
height: "21.047",
|
|
1268
1273
|
viewBox: "0 0 21.064 21.064"
|
|
1269
|
-
}), () => $5vyXB$solidjsweb.ssr($c77c68e559a1506c$var$_tmpl$), true);
|
|
1274
|
+
}, props), () => $5vyXB$solidjsweb.ssr($c77c68e559a1506c$var$_tmpl$), true);
|
|
1270
1275
|
}
|
|
1271
1276
|
|
|
1272
1277
|
/**
|
|
@@ -1480,7 +1485,7 @@ function $235a2771a44e28e9$export$fecbb157621501bd({
|
|
|
1480
1485
|
const $1c63082b2da848ad$var$_tmpl$ = ["<span", ' class="count">', "</span>"],
|
|
1481
1486
|
$1c63082b2da848ad$var$_tmpl$2 = ["<label", ' class="', '"', '><div class="left"><input type="checkbox"', "", "", '><span class="custom-indicator"></span><span class="text line-clamp">', "</span></div><!--$-->", "<!--/--></label>"];
|
|
1482
1487
|
const $1c63082b2da848ad$export$48513f6b9f8ce62d = props => {
|
|
1483
|
-
// 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
|
|
1488
|
+
/* 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
|
|
1484
1489
|
const count = $5vyXB$solidjs.createMemo(() => props.count_);
|
|
1485
1490
|
const label = $5vyXB$solidjs.createMemo(() => props.label_);
|
|
1486
1491
|
const checked = $5vyXB$solidjs.createMemo(() => props.checked_);
|
|
@@ -1512,6 +1517,59 @@ function $0fe1e7efdf4200d6$export$ca21a16d65b3dd8({
|
|
|
1512
1517
|
}) {
|
|
1513
1518
|
return $5vyXB$solidjsweb.ssr($0fe1e7efdf4200d6$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), `expand-filter ${get_show_extras() ? "expanded" : ""}`, $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $cc43b6428000c4bf$export$f21ab0717a89c77f), {})), get_show_extras() ? $5vyXB$solidjsweb.escape(i18n_.view_less_()) : $5vyXB$solidjsweb.escape(i18n_.view_more_()));
|
|
1514
1519
|
}
|
|
1520
|
+
const $d023ed916c84e75d$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"],
|
|
1521
|
+
$d023ed916c84e75d$var$_tmpl$2 = ["<span", ' class="', '"', ">", "</span>"];
|
|
1522
|
+
function $d023ed916c84e75d$export$ba17c5b7e6dda39f({
|
|
1523
|
+
whole_text_to_display_: whole_text_to_display_memo,
|
|
1524
|
+
searching_for_value_: searching_for_value_memo,
|
|
1525
|
+
class_: class_
|
|
1526
|
+
}) {
|
|
1527
|
+
const [get_has_highlighted, set_has_highlighted] = $5vyXB$solidjs.createSignal(false);
|
|
1528
|
+
const text_itself = $5vyXB$solidjs.createMemo(() => $5vyXB$solidjs.batch(() => {
|
|
1529
|
+
set_has_highlighted(false);
|
|
1530
|
+
const searching_for_value = searching_for_value_memo();
|
|
1531
|
+
const whole_text_to_display_ = whole_text_to_display_memo();
|
|
1532
|
+
let for_black = "";
|
|
1533
|
+
let pushed_grey = false;
|
|
1534
|
+
const search_q = searching_for_value;
|
|
1535
|
+
if (!search_q) return whole_text_to_display_;
|
|
1536
|
+
const output = [];
|
|
1537
|
+
const searching_for = search_q.toLowerCase();
|
|
1538
|
+
const push_black = () => {
|
|
1539
|
+
if (for_black) {
|
|
1540
|
+
set_has_highlighted(true);
|
|
1541
|
+
output.push($5vyXB$solidjsweb.ssr($d023ed916c84e75d$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape(for_black))); // "black"
|
|
1542
|
+
for_black = "";
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
for (let i = 0; i < whole_text_to_display_.length;) {
|
|
1546
|
+
let is_whole_word = true;
|
|
1547
|
+
let searching_for_but_with_texts_casing = "";
|
|
1548
|
+
const i_at_start = i;
|
|
1549
|
+
for (let j = 0; j < searching_for.length; i++, j++) {
|
|
1550
|
+
const letter_in_suggestion = whole_text_to_display_[i];
|
|
1551
|
+
if (letter_in_suggestion?.toLowerCase() !== searching_for[j]) {
|
|
1552
|
+
is_whole_word = false;
|
|
1553
|
+
i = i_at_start;
|
|
1554
|
+
break;
|
|
1555
|
+
}
|
|
1556
|
+
searching_for_but_with_texts_casing += letter_in_suggestion;
|
|
1557
|
+
}
|
|
1558
|
+
if (is_whole_word) {
|
|
1559
|
+
push_black();
|
|
1560
|
+
output.push(searching_for_but_with_texts_casing);
|
|
1561
|
+
pushed_grey = true;
|
|
1562
|
+
} else for_black += whole_text_to_display_[i++];
|
|
1563
|
+
}
|
|
1564
|
+
push_black();
|
|
1565
|
+
if (!pushed_grey) {
|
|
1566
|
+
set_has_highlighted(false);
|
|
1567
|
+
return whole_text_to_display_;
|
|
1568
|
+
}
|
|
1569
|
+
return output;
|
|
1570
|
+
}));
|
|
1571
|
+
return $5vyXB$solidjsweb.ssr($d023ed916c84e75d$var$_tmpl$2, $5vyXB$solidjsweb.ssrHydrationKey(), `${$5vyXB$solidjsweb.escape(class_, true) || ""} ${get_has_highlighted() ? "has-match" : ""}`, $5vyXB$solidjsweb.ssrAttribute("title", $5vyXB$solidjsweb.escape(whole_text_to_display_memo(), true), false), $5vyXB$solidjsweb.escape(text_itself()));
|
|
1572
|
+
}
|
|
1515
1573
|
const $d94869c80e337a3d$var$_tmpl$ = ["<form", ' class="checkboxes"><!--$-->', "<!--/--><!--$-->", "<!--/--></form>"];
|
|
1516
1574
|
const $d94869c80e337a3d$var$max_visible_without_collapsing = 15;
|
|
1517
1575
|
const $d94869c80e337a3d$var$show_non_collapsible_when_collapsed = 4;
|
|
@@ -1519,7 +1577,8 @@ function $d94869c80e337a3d$export$dd948f91abc3a1c4({
|
|
|
1519
1577
|
filter_: filter_,
|
|
1520
1578
|
selected_filters_: [get_selected_filters, set_selected_filters],
|
|
1521
1579
|
i18n_: i18n_,
|
|
1522
|
-
view_more_button_below_group_: [, set_view_more_button_below_group_]
|
|
1580
|
+
view_more_button_below_group_: [, set_view_more_button_below_group_],
|
|
1581
|
+
filter_query_: filter_query_
|
|
1523
1582
|
}) {
|
|
1524
1583
|
const existing_filter = $5vyXB$solidjs.createMemo(() => {
|
|
1525
1584
|
const {
|
|
@@ -1547,12 +1606,18 @@ function $d94869c80e337a3d$export$dd948f91abc3a1c4({
|
|
|
1547
1606
|
const value = $daa394359b026187$export$325f75597868c4f0(checkbox().value_);
|
|
1548
1607
|
return !!data?.some(item => $daa394359b026187$export$325f75597868c4f0(item) === value);
|
|
1549
1608
|
});
|
|
1609
|
+
const value = $5vyXB$solidjs.createMemo(() => checkbox().value_);
|
|
1550
1610
|
return $5vyXB$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
|
|
1551
1611
|
get value_() {
|
|
1552
|
-
return
|
|
1612
|
+
return value();
|
|
1553
1613
|
},
|
|
1554
1614
|
get label_() {
|
|
1555
|
-
return
|
|
1615
|
+
return $5vyXB$solidjsweb.createComponent((0, $d023ed916c84e75d$export$ba17c5b7e6dda39f), {
|
|
1616
|
+
get whole_text_to_display_() {
|
|
1617
|
+
return $5vyXB$solidjs.createMemo(() => checkbox().name_ || value());
|
|
1618
|
+
},
|
|
1619
|
+
searching_for_value_: () => filter_query_?.()
|
|
1620
|
+
});
|
|
1556
1621
|
},
|
|
1557
1622
|
get count_() {
|
|
1558
1623
|
return checkbox().count_;
|
|
@@ -1614,7 +1679,8 @@ const $c1dc1554c1b94233$var$_tmpl$ = ["<form", ' class="radios">', "</form>"],
|
|
|
1614
1679
|
$c1dc1554c1b94233$var$_tmpl$3 = ["<label", ' class="', '"', '><div class="left"><input type="radio"', "", '><span class="custom-indicator"></span><!--$-->', "<!--/--></div><!--$-->", "<!--/--></label>"];
|
|
1615
1680
|
function $c1dc1554c1b94233$export$430444115f70a734({
|
|
1616
1681
|
selected_filters_: selected_filters_,
|
|
1617
|
-
filter_: filter_
|
|
1682
|
+
filter_: filter_,
|
|
1683
|
+
filter_query_: filter_query_
|
|
1618
1684
|
}) {
|
|
1619
1685
|
const radio_name = $5vyXB$depictaiutilishared.make_random_classname();
|
|
1620
1686
|
const existing_filter = $5vyXB$solidjs.createMemo(() => {
|
|
@@ -1634,17 +1700,21 @@ function $c1dc1554c1b94233$export$430444115f70a734({
|
|
|
1634
1700
|
children: (value, index) => {
|
|
1635
1701
|
const random_selector = $5vyXB$depictaiutilishared.make_random_classname();
|
|
1636
1702
|
const count = $5vyXB$solidjs.createMemo(() => filter_().meta.counts?.[index]);
|
|
1703
|
+
const label = $5vyXB$solidjs.createMemo(() => {
|
|
1704
|
+
const name = filter_().meta?.names?.[index];
|
|
1705
|
+
if (name) return name;
|
|
1706
|
+
const v = value();
|
|
1707
|
+
return Array.isArray(v) ? v.join(" - ") : v + "";
|
|
1708
|
+
});
|
|
1637
1709
|
return $5vyXB$solidjsweb.ssr($c1dc1554c1b94233$var$_tmpl$3, $5vyXB$solidjsweb.ssrHydrationKey(), `input-row ${count() === 0 ? "count-0" : ""}`, $5vyXB$solidjsweb.ssrAttribute("for", $5vyXB$solidjsweb.escape(random_selector, true), false), $5vyXB$solidjsweb.ssrAttribute("id", $5vyXB$solidjsweb.escape(random_selector, true), false) + $5vyXB$solidjsweb.ssrAttribute("name", $5vyXB$solidjsweb.escape(radio_name, true), false), $5vyXB$solidjsweb.ssrAttribute("checked", $5vyXB$solidjs.createMemo(() => {
|
|
1638
1710
|
const v = value();
|
|
1639
1711
|
const data = existing_filter()?.data;
|
|
1640
1712
|
if ($daa394359b026187$export$325f75597868c4f0(data) === $daa394359b026187$export$325f75597868c4f0(v)) return true;
|
|
1641
1713
|
return Array.isArray(data) && data.every((item, index) => item === v[index]);
|
|
1642
|
-
})(), true), $5vyXB$solidjsweb.escape($5vyXB$
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
return Array.isArray(v) ? v.join(" - ") : v;
|
|
1647
|
-
})()), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
1714
|
+
})(), true), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $d023ed916c84e75d$export$ba17c5b7e6dda39f), {
|
|
1715
|
+
whole_text_to_display_: label,
|
|
1716
|
+
searching_for_value_: () => filter_query_?.()
|
|
1717
|
+
})), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
1648
1718
|
get when() {
|
|
1649
1719
|
return count() != undefined;
|
|
1650
1720
|
},
|
|
@@ -1661,7 +1731,8 @@ const $0b7222ba8a8bb72f$var$_tmpl$ = ["<div", ' class="', '"><div class="input-g
|
|
|
1661
1731
|
function $0b7222ba8a8bb72f$export$e0d834a0ad870cda({
|
|
1662
1732
|
filter_: filter_,
|
|
1663
1733
|
selected_filters_: selected_filters_,
|
|
1664
|
-
i18n_: i18n_
|
|
1734
|
+
i18n_: i18n_,
|
|
1735
|
+
filter_query_: filter_query_
|
|
1665
1736
|
}) {
|
|
1666
1737
|
// 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
|
|
1667
1738
|
// 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
|
|
@@ -1880,168 +1951,428 @@ function $7567511a7c3e4bd7$export$e5c2828934226505({
|
|
|
1880
1951
|
});
|
|
1881
1952
|
return outer_div;
|
|
1882
1953
|
}
|
|
1883
|
-
const $
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
function $3bdc00a1353c1150$export$a32086fa6616eafd({
|
|
1890
|
-
filter_: filter_,
|
|
1891
|
-
selected_filters_: selected_filters_,
|
|
1892
|
-
i18n_: i18n_,
|
|
1893
|
-
view_more_button_below_group_: view_more_button_below_group_,
|
|
1894
|
-
expanded_hierarchical_filters_: expanded_hierarchical_filters_
|
|
1954
|
+
const $5ea5a82e398f6f44$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"];
|
|
1955
|
+
const $5ea5a82e398f6f44$var$dont_cut_in_between_less_than_characters = 30;
|
|
1956
|
+
function $5ea5a82e398f6f44$export$e1a98a189fd2c0e7({
|
|
1957
|
+
content_result_: content_result_,
|
|
1958
|
+
key_: key_,
|
|
1959
|
+
cut_when_possible_: cut_when_possible_
|
|
1895
1960
|
}) {
|
|
1896
|
-
|
|
1897
|
-
const
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
}
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
}) => checking_field === field && checking_op === op);
|
|
1906
|
-
});
|
|
1907
|
-
const show_extras = $5vyXB$solidjs.createSignal(false);
|
|
1908
|
-
const trigger_sync_ = $3bdc00a1353c1150$var$batching_filter_state_syncer({
|
|
1909
|
-
filter_: filter_,
|
|
1910
|
-
existing_filter_: existing_filter,
|
|
1911
|
-
selected_filters_: selected_filters_,
|
|
1912
|
-
get category_structure_() {
|
|
1913
|
-
return structured_categories();
|
|
1914
|
-
}
|
|
1915
|
-
});
|
|
1916
|
-
const structured_categories = $5vyXB$solidjs.createMemo(() => {
|
|
1917
|
-
const execute_when_structure_finished = [];
|
|
1918
|
-
const {
|
|
1919
|
-
values: values,
|
|
1920
|
-
names: names,
|
|
1921
|
-
counts: counts
|
|
1922
|
-
} = filter_().meta;
|
|
1923
|
-
const data_structure = {};
|
|
1924
|
-
for (let i = 0; i < values.length; i++) {
|
|
1925
|
-
const value = values[i];
|
|
1926
|
-
let pointer = data_structure;
|
|
1927
|
-
let parent_ = {};
|
|
1928
|
-
let created_an_object = false;
|
|
1929
|
-
for (let j = 0; j < value.length; j++) {
|
|
1930
|
-
const this_categories_name = value[j];
|
|
1931
|
-
const obj = pointer[this_categories_name] ||= (() => {
|
|
1932
|
-
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;
|
|
1933
|
-
const created_obj = {
|
|
1934
|
-
name_: names[i],
|
|
1935
|
-
count_: counts?.[i],
|
|
1936
|
-
parent_: parent_,
|
|
1937
|
-
is_expanded_: $3bdc00a1353c1150$var$make_expanded_signal({
|
|
1938
|
-
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
1939
|
-
filter_value_: value_as_string
|
|
1940
|
-
}),
|
|
1941
|
-
value_: value_as_string,
|
|
1942
|
-
children_: {}
|
|
1943
|
-
};
|
|
1944
|
-
const {
|
|
1945
|
-
signal_: signal_,
|
|
1946
|
-
on_structure_complete_: on_structure_complete_
|
|
1947
|
-
} = $3bdc00a1353c1150$var$create_updating_signal({
|
|
1948
|
-
self_: created_obj,
|
|
1949
|
-
existing_filter_: $5vyXB$solidjs.untrack(existing_filter),
|
|
1950
|
-
trigger_sync_: trigger_sync_
|
|
1951
|
-
});
|
|
1952
|
-
execute_when_structure_finished.push(on_structure_complete_);
|
|
1953
|
-
created_obj.is_checked_ = signal_;
|
|
1954
|
-
parent_ = created_obj;
|
|
1955
|
-
created_an_object = true;
|
|
1956
|
-
return created_obj;
|
|
1957
|
-
})();
|
|
1958
|
-
pointer = obj.children_;
|
|
1959
|
-
parent_ = obj;
|
|
1960
|
-
}
|
|
1961
|
-
if (!created_an_object && "value_" in parent_) {
|
|
1962
|
-
// 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
|
|
1963
|
-
// [
|
|
1964
|
-
// ["Öl", "IPA"],
|
|
1965
|
-
// ["Öl", "Pale Ale"],
|
|
1966
|
-
// ["Öl", "Ale"],
|
|
1967
|
-
// ["Öl", "Mörk Lager"],
|
|
1968
|
-
// ["Öl", "Suröl"],
|
|
1969
|
-
// ["Öl", "Veteöl"],
|
|
1970
|
-
// ["Öl", "Stout och Porter"],
|
|
1971
|
-
// ["Öl"], // <- We are here, our `hierarchical_data_structure[string]`-object was created when we iterated over ["Öl", "IPA"]
|
|
1972
|
-
// ["Öl", "Ljus Lager"],
|
|
1973
|
-
// ];
|
|
1974
|
-
// In this case we want to just correct the name and value of the already created object, which will be in parent_
|
|
1975
|
-
parent_.value_ = value.map(v => v + "");
|
|
1976
|
-
parent_.name_ = names[i];
|
|
1977
|
-
parent_.count_ = counts[i];
|
|
1978
|
-
parent_.is_expanded_ = $3bdc00a1353c1150$var$make_expanded_signal({
|
|
1979
|
-
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
1980
|
-
filter_value_: parent_.value_
|
|
1981
|
-
});
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
while (execute_when_structure_finished.length) execute_when_structure_finished.pop()();
|
|
1985
|
-
$3bdc00a1353c1150$var$expand_until_choice(data_structure);
|
|
1986
|
-
$5vyXB$depictaiutilishared.dlog("CheckboxHierarchicalFilter: Recomputed structured_categories", data_structure);
|
|
1987
|
-
return data_structure;
|
|
1988
|
-
});
|
|
1989
|
-
const some_top_level_are_hidden = $5vyXB$solidjs.createMemo(() => Object.keys(structured_categories()).length > $3bdc00a1353c1150$var$max_visible_without_collapsing);
|
|
1990
|
-
const {
|
|
1991
|
-
expand: expand,
|
|
1992
|
-
collapse: collapse,
|
|
1993
|
-
ExpandingContainer: ExpandingContainer
|
|
1994
|
-
} = $4b455f60dadde8b8$export$5bad61ecde080b1f({
|
|
1995
|
-
duration: 200
|
|
1996
|
-
});
|
|
1997
|
-
const expanding_container_els = $5vyXB$solidjsweb.createComponent(ExpandingContainer, {
|
|
1961
|
+
const matched_tokens = $5vyXB$solidjs.createMemo(() => content_result_().highlights?.find(highlight => highlight.field == key_)?.matched_tokens);
|
|
1962
|
+
const full_value = $5vyXB$solidjs.createMemo(() => content_result_()[key_]?.replaceAll("\n", " "));
|
|
1963
|
+
return $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
1964
|
+
get when() {
|
|
1965
|
+
return matched_tokens()?.length;
|
|
1966
|
+
},
|
|
1967
|
+
get fallback() {
|
|
1968
|
+
return full_value();
|
|
1969
|
+
},
|
|
1998
1970
|
get children() {
|
|
1999
|
-
return
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
1971
|
+
return (() => {
|
|
1972
|
+
const segmented_cut_text = $5vyXB$solidjs.createMemo(() => {
|
|
1973
|
+
const segmented_text = $5ea5a82e398f6f44$export$1b00d74faf266c56(full_value(), matched_tokens());
|
|
1974
|
+
if (cut_when_possible_) $5ea5a82e398f6f44$var$cut_text(segmented_text);
|
|
1975
|
+
return segmented_text;
|
|
1976
|
+
});
|
|
1977
|
+
return $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Index), {
|
|
1978
|
+
get each() {
|
|
1979
|
+
return segmented_cut_text();
|
|
1980
|
+
},
|
|
1981
|
+
children: item => {
|
|
1982
|
+
return $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
1983
|
+
get when() {
|
|
1984
|
+
return item().highlighted_;
|
|
1985
|
+
},
|
|
1986
|
+
get fallback() {
|
|
1987
|
+
return item().text_;
|
|
1988
|
+
},
|
|
1989
|
+
get children() {
|
|
1990
|
+
return $5vyXB$solidjsweb.ssr($5ea5a82e398f6f44$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape(item().text_));
|
|
1991
|
+
}
|
|
1992
|
+
});
|
|
1993
|
+
}
|
|
1994
|
+
});
|
|
1995
|
+
})();
|
|
2007
1996
|
}
|
|
2008
1997
|
});
|
|
2009
|
-
$5vyXB$solidjs.createRenderEffect(() => {
|
|
2010
|
-
view_more_button_below_group_[1](some_top_level_are_hidden() ? $5vyXB$solidjsweb.createComponent((0, $0fe1e7efdf4200d6$export$ca21a16d65b3dd8), {
|
|
2011
|
-
show_extras_: show_extras,
|
|
2012
|
-
i18n_: i18n_
|
|
2013
|
-
}) : []);
|
|
2014
|
-
});
|
|
2015
|
-
$5vyXB$solidjs.createEffect($5vyXB$depictaiutilishared.catchify(async () => {
|
|
2016
|
-
if (!some_top_level_are_hidden()) {
|
|
2017
|
-
await collapse();
|
|
2018
|
-
return;
|
|
2019
|
-
}
|
|
2020
|
-
if (show_extras[0]()) await expand();else await collapse();
|
|
2021
|
-
}));
|
|
2022
|
-
return $5vyXB$solidjsweb.ssr($3bdc00a1353c1150$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), `checkboxes hierarchical ${Object.values(structured_categories()).some(category => Object.keys(category.children_).length) ? "any-expandable" : ""}`, $5vyXB$solidjsweb.escape($3bdc00a1353c1150$var$render_stuff($5vyXB$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_)), $5vyXB$solidjsweb.escape(expanding_container_els));
|
|
2023
1998
|
}
|
|
2024
|
-
function $
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
1999
|
+
function $5ea5a82e398f6f44$var$cut_text(segmented_text) {
|
|
2000
|
+
// cut away chunks of text that are not highlighted to give a google-like overview of the content
|
|
2001
|
+
const highlighted_segments = segmented_text?.filter(segment => segment.highlighted_);
|
|
2002
|
+
if (!segmented_text || !highlighted_segments?.length) return;
|
|
2003
|
+
// We have one or more highlighted segments
|
|
2004
|
+
if (highlighted_segments.length === 1) {
|
|
2005
|
+
// cut away from the left until the start of the highlighted sentence if just one sentence is highlighted
|
|
2006
|
+
$5ea5a82e398f6f44$var$cut_start(segmented_text.indexOf(highlighted_segments[0]), segmented_text);
|
|
2007
|
+
return;
|
|
2008
|
+
}
|
|
2009
|
+
// We have two or more highlighted segments, take the two biggest chunks and show them + a bit text around
|
|
2010
|
+
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
|
|
2011
|
+
);
|
|
2012
|
+
|
|
2013
|
+
const [longest_segment, next_longest_segment] = sorted_highlighted_segments;
|
|
2014
|
+
// We need to cut before the first segment - possibly through other segments - and maybe between segments
|
|
2015
|
+
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);
|
|
2016
|
+
$5ea5a82e398f6f44$var$cut_start(index_of_first_segment, segmented_text);
|
|
2017
|
+
// update indexes since we might have removed segments
|
|
2018
|
+
[index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
|
|
2019
|
+
let number_of_characters_between_segments = 0;
|
|
2020
|
+
for (let i = index_of_first_segment + 1; i < index_of_second_segment; i++) {
|
|
2021
|
+
const segment = segmented_text[i];
|
|
2022
|
+
number_of_characters_between_segments += segment.text_.length;
|
|
2023
|
+
}
|
|
2024
|
+
if (number_of_characters_between_segments < $5ea5a82e398f6f44$var$dont_cut_in_between_less_than_characters)
|
|
2025
|
+
// don't cut if there are less than 30 characters between the two segments
|
|
2026
|
+
return;
|
|
2027
|
+
// We have more than 50 characters between the two segments, cut between them
|
|
2028
|
+
const [split_start_segment, split_start_character] = $5ea5a82e398f6f44$var$find_split_point(index_of_first_segment, index_of_second_segment, segmented_text);
|
|
2029
|
+
const [split_end_segment, split_end_character] = $5ea5a82e398f6f44$var$find_split_point(index_of_second_segment, index_of_first_segment, segmented_text);
|
|
2030
|
+
if (split_start_segment === undefined || split_end_segment === undefined ||
|
|
2031
|
+
// identical split point, or split end before split start, can't do anything
|
|
2032
|
+
split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
|
|
2033
|
+
const dots_segment = {
|
|
2034
|
+
text_: " … ",
|
|
2035
|
+
highlighted_: false
|
|
2036
|
+
};
|
|
2037
|
+
const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
|
|
2038
|
+
if (i < split_start_segment || i > split_end_segment) return segment;
|
|
2039
|
+
const text = segment.text_;
|
|
2040
|
+
if (i == split_end_segment && i == split_start_segment) return [{
|
|
2041
|
+
...segment,
|
|
2042
|
+
text_: text.slice(0, split_start_character).trimEnd()
|
|
2043
|
+
}, dots_segment, {
|
|
2044
|
+
...segment,
|
|
2045
|
+
text_: text.slice(split_end_character + 1, text.length).trimStart()
|
|
2046
|
+
}];else if (i == split_start_segment) {
|
|
2047
|
+
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
|
|
2048
|
+
return segment;
|
|
2049
|
+
} else if (i == split_end_segment) return [dots_segment, {
|
|
2050
|
+
...segment,
|
|
2051
|
+
text_: text.slice(split_end_character + 1, text.length).trimStart()
|
|
2052
|
+
}];
|
|
2053
|
+
return []; // remove all segments inbetween
|
|
2054
|
+
});
|
|
2055
|
+
|
|
2056
|
+
segmented_text.splice(0, segmented_text.length, ...split_and_dotted_values); // Sorry…
|
|
2057
|
+
$5ea5a82e398f6f44$var$heal_holes(segmented_text);
|
|
2058
|
+
}
|
|
2059
|
+
function $5ea5a82e398f6f44$var$heal_holes(segmented_text) {
|
|
2060
|
+
// try to heal "holes" created in the segments so there are only alternating segments
|
|
2061
|
+
const segments_to_delete = new Set();
|
|
2062
|
+
for (let i = 0; i < segmented_text.length; i++) {
|
|
2063
|
+
const segment = segmented_text[i];
|
|
2064
|
+
let previous_segment;
|
|
2065
|
+
for (let j = i - 1; j >= 0; j--) {
|
|
2066
|
+
previous_segment = segmented_text[j];
|
|
2067
|
+
// Don't write to a segment that's marked for deletion or the contents we write to it will be deleted
|
|
2068
|
+
if (!segments_to_delete.has(previous_segment)) break;
|
|
2069
|
+
}
|
|
2070
|
+
if (previous_segment?.highlighted_ && segment.highlighted_ || previous_segment?.highlighted_ === false && segment.highlighted_ === false) {
|
|
2071
|
+
previous_segment.text_ += segment.text_; // IDK if this ever happens
|
|
2072
|
+
segments_to_delete.add(segment);
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
for (const segment of segments_to_delete) {
|
|
2076
|
+
const index = segmented_text.indexOf(segment);
|
|
2077
|
+
segmented_text.splice(index, 1);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
function $5ea5a82e398f6f44$var$find_split_point(index_of_start_segment, index_of_end_segment, segmented_text, be_very_aggressive = true) {
|
|
2081
|
+
const should_loop_backwards = index_of_start_segment > index_of_end_segment;
|
|
2082
|
+
const step = should_loop_backwards ? -1 : 1;
|
|
2083
|
+
const desperate_split_attempts = [":", ";", ","];
|
|
2084
|
+
while (desperate_split_attempts.length) {
|
|
2085
|
+
const split_point_between_words = [];
|
|
2086
|
+
// for the middle also try to split with a few more characters if the default ones don't work over a full run
|
|
2087
|
+
const desperate_split_attempt = desperate_split_attempts.pop();
|
|
2088
|
+
let is_first_character = true;
|
|
2089
|
+
for (let i = index_of_start_segment + step; should_loop_backwards ? i > index_of_end_segment : i < index_of_end_segment; i += step) {
|
|
2090
|
+
const segment = segmented_text[i];
|
|
2091
|
+
const text = segment.text_;
|
|
2092
|
+
for (let j = should_loop_backwards ? text.length - 1 : 0; should_loop_backwards ? j >= 0 : j < text.length; j += step) {
|
|
2093
|
+
const character = text[j];
|
|
2094
|
+
if (character == "." || character == "?" || character == "!" || character == desperate_split_attempt) return [i, j]; // segment index, character index
|
|
2095
|
+
if (is_first_character) is_first_character = false;else if (be_very_aggressive && character == " ") {
|
|
2096
|
+
split_point_between_words.push([i, j]);
|
|
2097
|
+
if (split_point_between_words.length > 3)
|
|
2098
|
+
// We can't find a split point, so we'll just split between words
|
|
2099
|
+
// 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
|
|
2100
|
+
return split_point_between_words[1];
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
return [];
|
|
2106
|
+
}
|
|
2107
|
+
function $5ea5a82e398f6f44$var$cut_start(cut_left_of_index, segmented_text) {
|
|
2108
|
+
// Cut the start of the text to bring the first matching token
|
|
2109
|
+
let is_first_character = false;
|
|
2110
|
+
let words_encountered = 0;
|
|
2111
|
+
outmost_loop: for (let i = cut_left_of_index - 1; i >= 0; i--) {
|
|
2112
|
+
const segment = segmented_text[i];
|
|
2113
|
+
// We assume that two adjacent highlighted segments don't exist and have been merged if they were to have existed
|
|
2114
|
+
const text = segment.text_;
|
|
2115
|
+
for (let j = text.length - 1; j >= 0; j--) {
|
|
2116
|
+
const character = text[j];
|
|
2117
|
+
const is_space = character == " ";
|
|
2118
|
+
if (!is_first_character && is_space) words_encountered++;
|
|
2119
|
+
if (character == "." || character == "?" || character == "!" || character == "," || words_encountered > 8 && is_space) {
|
|
2120
|
+
// We have to be really aggressive at the start of sentences so stuff can be seen on mobile, hence comma
|
|
2121
|
+
segment.text_ = text.slice(j + 1).trimStart();
|
|
2122
|
+
segmented_text.splice(0, i);
|
|
2123
|
+
if (character === "," || is_space)
|
|
2124
|
+
// if we cut at a comma or psace, we add a … at the beginning
|
|
2125
|
+
segmented_text.unshift({
|
|
2126
|
+
text_: "… ",
|
|
2127
|
+
highlighted_: false
|
|
2128
|
+
});
|
|
2129
|
+
break outmost_loop;
|
|
2130
|
+
}
|
|
2131
|
+
if (is_first_character) is_first_character = false;
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
$5ea5a82e398f6f44$var$heal_holes(segmented_text); // if we added a ... there could now be a sequence that's not alternating true/false
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
function $5ea5a82e398f6f44$export$1b00d74faf266c56(text, matched_strings, loose = false) {
|
|
2138
|
+
const output = [];
|
|
2139
|
+
if (!text) return; // shouldn't happen but whatever
|
|
2140
|
+
for (let i = 0; i < text.length; i++) {
|
|
2141
|
+
const found_strings = [];
|
|
2142
|
+
if (!i || text[i - 1] == " " || loose)
|
|
2143
|
+
// only match at the start of a word or string, it looks weird if i.e. "we" is highlighted in "activewear
|
|
2144
|
+
for (let j = 0; j < matched_strings.length; j++) {
|
|
2145
|
+
const matched_string = matched_strings[j];
|
|
2146
|
+
const part_in_text = text.slice(i, i + matched_string.length);
|
|
2147
|
+
if (matched_string.length < 2 && !loose) continue; // don't match on single characters, i.e. "I", it looks weird
|
|
2148
|
+
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
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
const last_index_in_output = output.length - 1;
|
|
2152
|
+
if (!found_strings.length) {
|
|
2153
|
+
const character = text[i];
|
|
2154
|
+
if (output[last_index_in_output]?.highlighted_ === false || output.length && /\s/.test(character))
|
|
2155
|
+
// 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
|
|
2156
|
+
output[last_index_in_output].text_ += character;else output.push({
|
|
2157
|
+
highlighted_: false,
|
|
2158
|
+
text_: character
|
|
2159
|
+
});
|
|
2160
|
+
} else {
|
|
2161
|
+
const longest_found_string = found_strings.reduce((a, b) => a.length > b.length ? a : b);
|
|
2162
|
+
if (output[last_index_in_output]?.highlighted_) output[last_index_in_output].text_ += longest_found_string;else output.push({
|
|
2163
|
+
highlighted_: true,
|
|
2164
|
+
text_: longest_found_string
|
|
2165
|
+
});
|
|
2166
|
+
i += longest_found_string.length - 1;
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
return output;
|
|
2170
|
+
}
|
|
2171
|
+
const $f6efb1605fcb9f39$var$_tmpl$ = ["<span", ' class="', '">', "</span>"],
|
|
2172
|
+
$f6efb1605fcb9f39$var$_tmpl$2 = ["<span", ' class="highlighted-part">', "</span>"];
|
|
2173
|
+
function $f6efb1605fcb9f39$export$8e79c28529dbfa90(props) {
|
|
2174
|
+
const segmented_text = $5vyXB$solidjs.createMemo(() => {
|
|
2175
|
+
const {
|
|
2176
|
+
to_highlight_: to_highlight_,
|
|
2177
|
+
text_: text_
|
|
2178
|
+
} = props;
|
|
2179
|
+
return $5ea5a82e398f6f44$export$1b00d74faf266c56(text_, to_highlight_ ? [to_highlight_] : [], true);
|
|
2180
|
+
});
|
|
2181
|
+
const has_highlights = $5vyXB$solidjs.createMemo(() => segmented_text().some(segment => segment.highlighted_));
|
|
2182
|
+
return $5vyXB$solidjsweb.ssr($f6efb1605fcb9f39$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey() + $5vyXB$solidjsweb.ssrAttribute("title", $5vyXB$solidjsweb.escape(props.text_, true), false), has_highlights() ? "has-match" : "", $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Index), {
|
|
2183
|
+
get each() {
|
|
2184
|
+
return segmented_text();
|
|
2185
|
+
},
|
|
2186
|
+
children: item => {
|
|
2187
|
+
return $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
2188
|
+
get when() {
|
|
2189
|
+
return item().highlighted_;
|
|
2190
|
+
},
|
|
2191
|
+
get fallback() {
|
|
2192
|
+
return item().text_;
|
|
2193
|
+
},
|
|
2194
|
+
get children() {
|
|
2195
|
+
return $5vyXB$solidjsweb.ssr($f6efb1605fcb9f39$var$_tmpl$2, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape(item().text_));
|
|
2196
|
+
}
|
|
2197
|
+
});
|
|
2198
|
+
}
|
|
2199
|
+
})));
|
|
2200
|
+
}
|
|
2201
|
+
const $3bdc00a1353c1150$var$_tmpl$ = ["<form", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></form>"],
|
|
2202
|
+
$3bdc00a1353c1150$var$_tmpl$2 = ["<div", ' class="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></div>"],
|
|
2203
|
+
$3bdc00a1353c1150$var$_tmpl$3 = ["<details", "></details>"],
|
|
2204
|
+
$3bdc00a1353c1150$var$_tmpl$4 = ["<summary", ' class="category-parent"><div class="summary"><span class="', '">', "</span><!--$-->", "<!--/--></div></summary>"];
|
|
2205
|
+
const $3bdc00a1353c1150$var$max_visible_without_collapsing = 15;
|
|
2206
|
+
const $3bdc00a1353c1150$var$show_non_collapsible_when_collapsed = 4;
|
|
2207
|
+
function $3bdc00a1353c1150$export$a32086fa6616eafd({
|
|
2208
|
+
filter_: filter_,
|
|
2209
|
+
selected_filters_: selected_filters_,
|
|
2210
|
+
i18n_: i18n_,
|
|
2211
|
+
view_more_button_below_group_: view_more_button_below_group_,
|
|
2212
|
+
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
2213
|
+
filter_query_: filter_query_
|
|
2214
|
+
}) {
|
|
2215
|
+
let form;
|
|
2216
|
+
const existing_filter = $5vyXB$solidjs.createMemo(() => {
|
|
2217
|
+
const {
|
|
2218
|
+
field: field,
|
|
2219
|
+
op: op
|
|
2220
|
+
} = filter_();
|
|
2221
|
+
return selected_filters_[0]().find(({
|
|
2222
|
+
field: checking_field,
|
|
2223
|
+
op: checking_op
|
|
2224
|
+
}) => checking_field === field && checking_op === op);
|
|
2225
|
+
});
|
|
2226
|
+
const show_extras = $5vyXB$solidjs.createSignal(false);
|
|
2227
|
+
const is_being_searched_ = $5vyXB$solidjs.createMemo(() => !!filter_query_?.()); // If the user is searching in the filter
|
|
2228
|
+
const trigger_sync_ = $3bdc00a1353c1150$var$batching_filter_state_syncer({
|
|
2229
|
+
filter_: filter_,
|
|
2230
|
+
existing_filter_: existing_filter,
|
|
2231
|
+
selected_filters_: selected_filters_,
|
|
2232
|
+
get category_structure_() {
|
|
2233
|
+
return structured_categories();
|
|
2234
|
+
}
|
|
2235
|
+
});
|
|
2236
|
+
const structured_categories = $5vyXB$solidjs.createMemo(() => {
|
|
2237
|
+
const execute_when_structure_finished = [];
|
|
2238
|
+
const {
|
|
2239
|
+
values: values,
|
|
2240
|
+
names: names,
|
|
2241
|
+
counts: counts
|
|
2242
|
+
} = filter_().meta;
|
|
2243
|
+
const data_structure = {};
|
|
2244
|
+
for (let i = 0; i < values.length; i++) {
|
|
2245
|
+
const value = values[i];
|
|
2246
|
+
let pointer = data_structure;
|
|
2247
|
+
let parent_ = {};
|
|
2248
|
+
let created_an_object = false;
|
|
2249
|
+
for (let j = 0; j < value.length; j++) {
|
|
2250
|
+
const this_categories_name = value[j];
|
|
2251
|
+
const obj = pointer[this_categories_name] ||= (() => {
|
|
2252
|
+
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;
|
|
2253
|
+
const created_obj = {
|
|
2254
|
+
name_: names[i],
|
|
2255
|
+
count_: counts?.[i],
|
|
2256
|
+
parent_: parent_,
|
|
2257
|
+
is_expanded_: $3bdc00a1353c1150$var$make_expanded_signal({
|
|
2258
|
+
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
2259
|
+
filter_value_: value_as_string,
|
|
2260
|
+
is_being_searched_: is_being_searched_
|
|
2261
|
+
}),
|
|
2262
|
+
value_: value_as_string,
|
|
2263
|
+
children_: {}
|
|
2264
|
+
};
|
|
2265
|
+
const {
|
|
2266
|
+
signal_: signal_,
|
|
2267
|
+
on_structure_complete_: on_structure_complete_
|
|
2268
|
+
} = $3bdc00a1353c1150$var$create_updating_signal({
|
|
2269
|
+
self_: created_obj,
|
|
2270
|
+
existing_filter_: $5vyXB$solidjs.untrack(existing_filter),
|
|
2271
|
+
trigger_sync_: trigger_sync_
|
|
2272
|
+
});
|
|
2273
|
+
execute_when_structure_finished.push(on_structure_complete_);
|
|
2274
|
+
created_obj.is_checked_ = signal_;
|
|
2275
|
+
parent_ = created_obj;
|
|
2276
|
+
created_an_object = true;
|
|
2277
|
+
return created_obj;
|
|
2278
|
+
})();
|
|
2279
|
+
pointer = obj.children_;
|
|
2280
|
+
parent_ = obj;
|
|
2281
|
+
}
|
|
2282
|
+
if (!created_an_object && "value_" in parent_) {
|
|
2283
|
+
// 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
|
|
2284
|
+
// [
|
|
2285
|
+
// ["Öl", "IPA"],
|
|
2286
|
+
// ["Öl", "Pale Ale"],
|
|
2287
|
+
// ["Öl", "Ale"],
|
|
2288
|
+
// ["Öl", "Mörk Lager"],
|
|
2289
|
+
// ["Öl", "Suröl"],
|
|
2290
|
+
// ["Öl", "Veteöl"],
|
|
2291
|
+
// ["Öl", "Stout och Porter"],
|
|
2292
|
+
// ["Öl"], // <- We are here, our `hierarchical_data_structure[string]`-object was created when we iterated over ["Öl", "IPA"]
|
|
2293
|
+
// ["Öl", "Ljus Lager"],
|
|
2294
|
+
// ];
|
|
2295
|
+
// In this case we want to just correct the name and value of the already created object, which will be in parent_
|
|
2296
|
+
parent_.value_ = value.map(v => v + "");
|
|
2297
|
+
parent_.name_ = names[i];
|
|
2298
|
+
parent_.count_ = counts[i];
|
|
2299
|
+
parent_.is_expanded_ = $3bdc00a1353c1150$var$make_expanded_signal({
|
|
2300
|
+
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
2301
|
+
filter_value_: parent_.value_,
|
|
2302
|
+
is_being_searched_: is_being_searched_
|
|
2303
|
+
});
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
while (execute_when_structure_finished.length) execute_when_structure_finished.pop()();
|
|
2307
|
+
$3bdc00a1353c1150$var$expand_until_choice(data_structure);
|
|
2308
|
+
$5vyXB$depictaiutilishared.dlog("CheckboxHierarchicalFilter: Recomputed structured_categories", data_structure);
|
|
2309
|
+
return data_structure;
|
|
2310
|
+
});
|
|
2311
|
+
const some_top_level_are_hidden = $5vyXB$solidjs.createMemo(() => Object.keys(structured_categories()).length > $3bdc00a1353c1150$var$max_visible_without_collapsing);
|
|
2312
|
+
const {
|
|
2313
|
+
expand: expand,
|
|
2314
|
+
collapse: collapse,
|
|
2315
|
+
ExpandingContainer: ExpandingContainer
|
|
2316
|
+
} = $4b455f60dadde8b8$export$5bad61ecde080b1f({
|
|
2317
|
+
duration: 200
|
|
2318
|
+
});
|
|
2319
|
+
const expanding_container_els = $5vyXB$solidjsweb.createComponent(ExpandingContainer, {
|
|
2320
|
+
get children() {
|
|
2321
|
+
return $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
2322
|
+
get when() {
|
|
2323
|
+
return some_top_level_are_hidden();
|
|
2324
|
+
},
|
|
2325
|
+
get children() {
|
|
2326
|
+
return $3bdc00a1353c1150$var$render_stuff($5vyXB$solidjs.createMemo(() => Object.fromEntries(Object.entries(structured_categories()).slice($3bdc00a1353c1150$var$show_non_collapsible_when_collapsed))), existing_filter, i18n_, filter_query_);
|
|
2327
|
+
}
|
|
2328
|
+
});
|
|
2329
|
+
}
|
|
2330
|
+
});
|
|
2331
|
+
$5vyXB$solidjs.createRenderEffect(() => {
|
|
2332
|
+
view_more_button_below_group_[1](some_top_level_are_hidden() ? $5vyXB$solidjsweb.createComponent((0, $0fe1e7efdf4200d6$export$ca21a16d65b3dd8), {
|
|
2333
|
+
show_extras_: show_extras,
|
|
2334
|
+
i18n_: i18n_
|
|
2335
|
+
}) : []);
|
|
2336
|
+
});
|
|
2337
|
+
$5vyXB$solidjs.createEffect($5vyXB$depictaiutilishared.catchify(async () => {
|
|
2338
|
+
if (!some_top_level_are_hidden()) {
|
|
2339
|
+
await collapse();
|
|
2340
|
+
return;
|
|
2341
|
+
}
|
|
2342
|
+
if (show_extras[0]()) await expand();else await collapse();
|
|
2343
|
+
}));
|
|
2344
|
+
return $5vyXB$solidjsweb.ssr($3bdc00a1353c1150$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), `checkboxes hierarchical ${Object.values(structured_categories()).some(category => Object.keys(category.children_).length) ? "any-expandable" : ""}`, $5vyXB$solidjsweb.escape($3bdc00a1353c1150$var$render_stuff($5vyXB$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_)), $5vyXB$solidjsweb.escape(expanding_container_els));
|
|
2345
|
+
}
|
|
2346
|
+
function $3bdc00a1353c1150$var$render_stuff(data, existing_filter, i18n_, filter_query_) {
|
|
2347
|
+
const keys = $5vyXB$solidjs.createMemo(() => Object.keys(data()));
|
|
2348
|
+
return $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.For), {
|
|
2349
|
+
get each() {
|
|
2350
|
+
return keys();
|
|
2351
|
+
},
|
|
2352
|
+
children: key => $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
2353
|
+
get when() {
|
|
2354
|
+
return $5vyXB$solidjs.createMemo(() => !!data()[key])();
|
|
2355
|
+
},
|
|
2356
|
+
get children() {
|
|
2357
|
+
return (() => {
|
|
2358
|
+
// 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
|
|
2359
|
+
const value = $5vyXB$solidjs.createMemo(() => data()[key]); // still sometimes get undefined here even though we have <Show>
|
|
2360
|
+
const has_expandable = $5vyXB$solidjs.createMemo(() => !!Object.keys(value()?.children_ || {}).length);
|
|
2361
|
+
const value_as_string = $5vyXB$solidjs.createMemo(() => JSON.stringify(value()?.value_));
|
|
2362
|
+
const label_text = $5vyXB$solidjs.createMemo(() => value()?.name_ || value_as_string());
|
|
2363
|
+
return $5vyXB$solidjsweb.ssr($3bdc00a1353c1150$var$_tmpl$2, $5vyXB$solidjsweb.ssrHydrationKey(), `checkbox-details ${has_expandable() ? "expandable" : ""}`, $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
|
|
2040
2364
|
get value_() {
|
|
2041
|
-
return
|
|
2365
|
+
return value_as_string();
|
|
2042
2366
|
},
|
|
2043
2367
|
get label_() {
|
|
2044
|
-
return
|
|
2368
|
+
return $5vyXB$solidjsweb.createComponent((0, $f6efb1605fcb9f39$export$8e79c28529dbfa90), {
|
|
2369
|
+
get text_() {
|
|
2370
|
+
return label_text();
|
|
2371
|
+
},
|
|
2372
|
+
get to_highlight_() {
|
|
2373
|
+
return filter_query_?.();
|
|
2374
|
+
}
|
|
2375
|
+
});
|
|
2045
2376
|
},
|
|
2046
2377
|
get count_() {
|
|
2047
2378
|
return has_expandable() ? undefined : value()?.count_;
|
|
@@ -2110,7 +2441,7 @@ function $3bdc00a1353c1150$var$render_stuff(data, existing_filter, i18n_) {
|
|
|
2110
2441
|
return is_open();
|
|
2111
2442
|
},
|
|
2112
2443
|
get children() {
|
|
2113
|
-
return $3bdc00a1353c1150$var$render_stuff($5vyXB$solidjs.createMemo(() => value()?.children_ || {}), existing_filter, i18n_);
|
|
2444
|
+
return $3bdc00a1353c1150$var$render_stuff($5vyXB$solidjs.createMemo(() => value()?.children_ || {}), existing_filter, i18n_, filter_query_);
|
|
2114
2445
|
}
|
|
2115
2446
|
});
|
|
2116
2447
|
})();
|
|
@@ -2218,7 +2549,8 @@ function $3bdc00a1353c1150$var$create_updating_signal({
|
|
|
2218
2549
|
}
|
|
2219
2550
|
function $3bdc00a1353c1150$var$make_expanded_signal({
|
|
2220
2551
|
expanded_hierarchical_filters_: [read_expanded_hierarchical_filters, write_expanded_hierarchical_filters],
|
|
2221
|
-
filter_value_: filter_value_
|
|
2552
|
+
filter_value_: filter_value_,
|
|
2553
|
+
is_being_searched_: is_being_searched_
|
|
2222
2554
|
}) {
|
|
2223
2555
|
const index_in_expanded_filters = $5vyXB$solidjs.createMemo(() => read_expanded_hierarchical_filters().findIndex(({
|
|
2224
2556
|
value_: value_
|
|
@@ -2257,7 +2589,9 @@ function $3bdc00a1353c1150$var$make_expanded_signal({
|
|
|
2257
2589
|
defer: true
|
|
2258
2590
|
}));
|
|
2259
2591
|
return {
|
|
2260
|
-
ui_should_show_expanded_: $5vyXB$solidjs.createMemo(
|
|
2592
|
+
ui_should_show_expanded_: $5vyXB$solidjs.createMemo(
|
|
2593
|
+
// When user is searching through filters, expand everything they haven't collapsed, so they can see the results
|
|
2594
|
+
() => user_choice_signal[0]() ?? (is_being_searched_() || get_low_precedence_expanded())),
|
|
2261
2595
|
set_low_precedence_expanded_: set_low_precedence_expanded,
|
|
2262
2596
|
set_user_expanded_: set_user_choice_expanded
|
|
2263
2597
|
};
|
|
@@ -2285,7 +2619,9 @@ const $0ef1681699140f1a$var$gap_px = 5;
|
|
|
2285
2619
|
const $0ef1681699140f1a$var$max_columns = 3;
|
|
2286
2620
|
const $0ef1681699140f1a$export$414f6a19d38e655c = ({
|
|
2287
2621
|
filter_: filter_,
|
|
2288
|
-
selected_filters_: [get_selected_filters, set_selected_filters]
|
|
2622
|
+
selected_filters_: [get_selected_filters, set_selected_filters],
|
|
2623
|
+
filter_query_: filter_query_,
|
|
2624
|
+
details_element_width_: details_element_width_
|
|
2289
2625
|
}) => {
|
|
2290
2626
|
const existing_filter = $5vyXB$solidjs.createMemo(() => {
|
|
2291
2627
|
const {
|
|
@@ -2313,18 +2649,18 @@ const $0ef1681699140f1a$export$414f6a19d38e655c = ({
|
|
|
2313
2649
|
const container_width_accessor = $5vyXB$solidjs.createMemo(() => {
|
|
2314
2650
|
const element = container();
|
|
2315
2651
|
if (!element) return;
|
|
2316
|
-
return $
|
|
2652
|
+
return $f13855d1b951b24a$export$ebdc3711f7e02ccd(element);
|
|
2317
2653
|
});
|
|
2318
2654
|
const [shadow_children, set_shadow_children] = $5vyXB$solidjs.createSignal(new Set(), {
|
|
2319
2655
|
equals: false
|
|
2320
2656
|
});
|
|
2321
2657
|
const shadow_grid = $5vyXB$solidjsweb.ssr($0ef1681699140f1a$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape([...shadow_children()])); // for getting the smallest possible sizes of all the items
|
|
2322
2658
|
$5vyXB$solidjs.createEffect(() => {
|
|
2323
|
-
const container_width = container_width_accessor()?.();
|
|
2324
|
-
if (container_width
|
|
2659
|
+
const container_width = container_width_accessor()?.() || details_element_width_();
|
|
2660
|
+
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
|
|
2325
2661
|
$0ef1681699140f1a$var$adjust_sizes(container_width, sizes_set(), set_cols_at_size);
|
|
2326
2662
|
});
|
|
2327
|
-
return [
|
|
2663
|
+
return [$5vyXB$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), {
|
|
2328
2664
|
get cols_at_size() {
|
|
2329
2665
|
return cols_at_size();
|
|
2330
2666
|
},
|
|
@@ -2346,27 +2682,33 @@ const $0ef1681699140f1a$export$414f6a19d38e655c = ({
|
|
|
2346
2682
|
const current_value = $daa394359b026187$export$325f75597868c4f0(value().value_);
|
|
2347
2683
|
return !!data?.some(item => $daa394359b026187$export$325f75597868c4f0(item) === current_value);
|
|
2348
2684
|
});
|
|
2349
|
-
const MakeButton = attributes =>
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2685
|
+
const MakeButton = attributes => {
|
|
2686
|
+
const label = $5vyXB$solidjs.createMemo(() => value().name_ || value().value_ + "");
|
|
2687
|
+
return $5vyXB$solidjsweb.ssrElement("button", $5vyXB$solidjsweb.mergeProps(attributes, {
|
|
2688
|
+
get disabled() {
|
|
2689
|
+
return value().count_ === 0 && !is_selected();
|
|
2690
|
+
},
|
|
2691
|
+
get classList() {
|
|
2692
|
+
return {
|
|
2693
|
+
minor: !is_selected(),
|
|
2694
|
+
major: is_selected(),
|
|
2695
|
+
"major-minor-transition": true
|
|
2696
|
+
};
|
|
2697
|
+
}
|
|
2698
|
+
}), () => ["<!--$-->", $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $d023ed916c84e75d$export$ba17c5b7e6dda39f), {
|
|
2699
|
+
whole_text_to_display_: label,
|
|
2700
|
+
searching_for_value_: () => filter_query_?.()
|
|
2701
|
+
})), "<!--/-->", "<!--$-->", $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
2702
|
+
get when() {
|
|
2703
|
+
return value().count_ != undefined;
|
|
2704
|
+
},
|
|
2705
|
+
get children() {
|
|
2706
|
+
return $5vyXB$solidjsweb.ssr($0ef1681699140f1a$var$_tmpl$2, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape(value().count_));
|
|
2707
|
+
}
|
|
2708
|
+
})), "<!--/-->"], true);
|
|
2709
|
+
};
|
|
2368
2710
|
const invisible_size_button = $5vyXB$solidjsweb.createComponent(MakeButton, {});
|
|
2369
|
-
const smallest_possible_size = $
|
|
2711
|
+
const smallest_possible_size = $f13855d1b951b24a$export$ebdc3711f7e02ccd(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
|
|
2370
2712
|
const sizes_value = $5vyXB$solidjs.untrack(sizes_set);
|
|
2371
2713
|
const shadow_children_value = $5vyXB$solidjs.untrack(shadow_children);
|
|
2372
2714
|
sizes_value.add(smallest_possible_size);
|
|
@@ -2386,7 +2728,7 @@ const $0ef1681699140f1a$export$414f6a19d38e655c = ({
|
|
|
2386
2728
|
}
|
|
2387
2729
|
});
|
|
2388
2730
|
}
|
|
2389
|
-
})];
|
|
2731
|
+
}), shadow_grid];
|
|
2390
2732
|
};
|
|
2391
2733
|
/**
|
|
2392
2734
|
* Calculate and apply cols_at_size overrides to fit as many items as possible in a row, evenly spaced
|
|
@@ -2452,7 +2794,8 @@ function $b51a2b8b9355e66c$export$82ed4b28ecb67608({
|
|
|
2452
2794
|
filter_: filter_,
|
|
2453
2795
|
selected_filters_: [get_selected_filters, set_selected_filters],
|
|
2454
2796
|
i18n_: i18n_,
|
|
2455
|
-
view_more_button_below_group_: [_get_view_more_button_below_group_, set_view_more_button_below_group_]
|
|
2797
|
+
view_more_button_below_group_: [_get_view_more_button_below_group_, set_view_more_button_below_group_],
|
|
2798
|
+
filter_query_: filter_query_
|
|
2456
2799
|
}) {
|
|
2457
2800
|
// same as in CheckboxFilter, maybe we should make this DRY at some point
|
|
2458
2801
|
const existing_filter = $5vyXB$solidjs.createMemo(() => {
|
|
@@ -2486,12 +2829,17 @@ function $b51a2b8b9355e66c$export$82ed4b28ecb67608({
|
|
|
2486
2829
|
const value = $daa394359b026187$export$325f75597868c4f0(checkbox().value_);
|
|
2487
2830
|
return !!data?.some(item => $daa394359b026187$export$325f75597868c4f0(item) === value);
|
|
2488
2831
|
});
|
|
2832
|
+
const value = $5vyXB$solidjs.createMemo(() => checkbox().value_);
|
|
2833
|
+
const label_text = $5vyXB$solidjs.createMemo(() => checkbox().name_ || value() + "");
|
|
2489
2834
|
const input_row = $5vyXB$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
|
|
2490
2835
|
get value_() {
|
|
2491
|
-
return
|
|
2836
|
+
return value();
|
|
2492
2837
|
},
|
|
2493
2838
|
get label_() {
|
|
2494
|
-
return
|
|
2839
|
+
return $5vyXB$solidjsweb.createComponent((0, $d023ed916c84e75d$export$ba17c5b7e6dda39f), {
|
|
2840
|
+
whole_text_to_display_: label_text,
|
|
2841
|
+
searching_for_value_: () => filter_query_?.()
|
|
2842
|
+
});
|
|
2495
2843
|
},
|
|
2496
2844
|
get count_() {
|
|
2497
2845
|
return checkbox().count_;
|
|
@@ -2742,10 +3090,143 @@ function $061ff5b4c3d36171$export$89c6019e4baa40b1(props) {
|
|
|
2742
3090
|
}
|
|
2743
3091
|
});
|
|
2744
3092
|
}
|
|
3093
|
+
const $87d7574e1d89d69b$var$_tmpl$ = '<path d="M19.811 20.174l-6.234-6.809a7.96 7.96 0 0 0 .923-1.179c.274-.424.502-.865.687-1.323a8.04 8.04 0 0 0 .42-1.436 7.88 7.88 0 0 0 .144-1.507c0-.526-.051-1.042-.154-1.548-.096-.506-.243-.995-.441-1.466s-.441-.919-.728-1.343a8.28 8.28 0 0 0-.984-1.21 7.86 7.86 0 0 0-1.2-.984A7.56 7.56 0 0 0 10.89.651C10.418.453 9.929.302 9.423.2S8.401.046 7.875.046 6.833.097 6.327.2 5.332.453 4.86.651a7.56 7.56 0 0 0-1.354.718c-.431.287-.831.615-1.2.984a8.28 8.28 0 0 0-.984 1.21 7.73 7.73 0 0 0-.728 1.343c-.198.472-.349.96-.451 1.466A8.31 8.31 0 0 0 0 7.921a8.31 8.31 0 0 0 .144 1.548c.103.506.253.995.451 1.466a8.08 8.08 0 0 0 .728 1.354 7.86 7.86 0 0 0 .984 1.2 7.54 7.54 0 0 0 1.2.995c.431.287.882.53 1.354.728.472.191.96.338 1.466.441a8.31 8.31 0 0 0 1.548.144c.451 0 .896-.038 1.333-.113a7.83 7.83 0 0 0 1.282-.328 7.55 7.55 0 0 0 1.2-.533 8.08 8.08 0 0 0 1.107-.749l6.245 6.809a.45.45 0 0 0 .174.123.55.55 0 0 0 .205.041.61.61 0 0 0 .195-.031c.061-.021.116-.055.164-.102.109-.096.164-.219.164-.369.007-.144-.038-.267-.133-.369zM1.046 7.921c0-.937.178-1.818.533-2.646.362-.834.851-1.559 1.466-2.174.622-.615 1.347-1.101 2.174-1.456.827-.362 1.712-.543 2.656-.543s1.829.181 2.656.543c.827.355 1.548.841 2.164 1.456.622.615 1.111 1.34 1.466 2.174a6.52 6.52 0 0 1 .543 2.646c0 .943-.181 1.829-.543 2.656a6.89 6.89 0 0 1-1.466 2.174c-.615.615-1.336 1.104-2.164 1.466-.827.356-1.712.533-2.656.533s-1.829-.178-2.656-.533c-.827-.362-1.552-.851-2.174-1.466-.615-.622-1.104-1.347-1.466-2.174-.355-.827-.533-1.712-.533-2.656z"></path>';
|
|
3094
|
+
function $87d7574e1d89d69b$export$82eafebb825fc23f(props = {}) {
|
|
3095
|
+
return $5vyXB$solidjsweb.ssrElement("svg", $5vyXB$solidjsweb.mergeProps({
|
|
3096
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3097
|
+
width: "20",
|
|
3098
|
+
height: "22",
|
|
3099
|
+
viewBox: "0 0 20 22"
|
|
3100
|
+
}, props), () => $5vyXB$solidjsweb.ssr($87d7574e1d89d69b$var$_tmpl$), true);
|
|
3101
|
+
}
|
|
3102
|
+
const $47d8681015b71901$var$_tmpl$ = ["<div", ' class="search-in-filters"><input type="text" class="query"', "><!--$-->", '<!--/--><button style="', '" class="clear">', "</button></div>"];
|
|
3103
|
+
const $47d8681015b71901$var$min_items_to_enable_filter_searching = 10; // For checkbox hierarchical we 2x this
|
|
3104
|
+
function $47d8681015b71901$export$4b2c5292ffe0c5dd(filter_array_, section, i18n_) {
|
|
3105
|
+
const [filter_query_, set_filter_query_] = $5vyXB$solidjs.createSignal();
|
|
3106
|
+
// Check if we have enough items to enable searching
|
|
3107
|
+
const enable_searchability = $5vyXB$solidjs.createMemo(() => {
|
|
3108
|
+
let count = 0;
|
|
3109
|
+
for (const filter of filter_array_()) {
|
|
3110
|
+
const type = filter.meta?.type;
|
|
3111
|
+
if (type === "range") continue;
|
|
3112
|
+
const length = filter.meta.values.length;
|
|
3113
|
+
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
|
|
3114
|
+
}
|
|
3115
|
+
|
|
3116
|
+
return count >= $47d8681015b71901$var$min_items_to_enable_filter_searching;
|
|
3117
|
+
});
|
|
3118
|
+
const SearchThisFilterGroup_ = () => {
|
|
3119
|
+
return $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
3120
|
+
get when() {
|
|
3121
|
+
return enable_searchability();
|
|
3122
|
+
},
|
|
3123
|
+
get children() {
|
|
3124
|
+
return $5vyXB$solidjsweb.ssr($47d8681015b71901$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.ssrAttribute("value", $5vyXB$solidjsweb.escape(filter_query_(), true) || "", false) + $5vyXB$solidjsweb.ssrAttribute("placeholder", $5vyXB$solidjsweb.escape(i18n_.search_a_filter_()(section), true), false), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $87d7574e1d89d69b$export$82eafebb825fc23f), {
|
|
3125
|
+
width: "16",
|
|
3126
|
+
height: "17.6",
|
|
3127
|
+
"class": "search-icon"
|
|
3128
|
+
})), "display:" + (filter_query_() ? "" : "none"), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $c77c68e559a1506c$export$3b621d86b1566b2), {
|
|
3129
|
+
width: "12",
|
|
3130
|
+
height: "12"
|
|
3131
|
+
})));
|
|
3132
|
+
}
|
|
3133
|
+
});
|
|
3134
|
+
};
|
|
3135
|
+
const searched_filter_array_ = $5vyXB$solidjs.createMemo(() => {
|
|
3136
|
+
const query = filter_query_();
|
|
3137
|
+
if (!enable_searchability() || !query) return filter_array_();
|
|
3138
|
+
const lowercase_query = query.toLowerCase();
|
|
3139
|
+
const check_string_match = to_check => {
|
|
3140
|
+
to_check = to_check.toLowerCase();
|
|
3141
|
+
return to_check.includes(lowercase_query) || lowercase_query.includes(to_check);
|
|
3142
|
+
};
|
|
3143
|
+
return filter_array_().map(filter => {
|
|
3144
|
+
const type = filter.meta?.type;
|
|
3145
|
+
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
|
|
3146
|
+
const meta = filter.meta;
|
|
3147
|
+
const {
|
|
3148
|
+
values: values,
|
|
3149
|
+
names: names,
|
|
3150
|
+
counts: counts
|
|
3151
|
+
} = meta;
|
|
3152
|
+
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
|
|
3153
|
+
const is_hierarchical_checkbox = type === "checkbox-hierarchical";
|
|
3154
|
+
// Which index of counts, values and names should be kept
|
|
3155
|
+
const filtered_indexes = values.map((item, index) => {
|
|
3156
|
+
const item_from_names = names?.[index];
|
|
3157
|
+
if (item_from_names && !is_hierarchical_checkbox)
|
|
3158
|
+
// 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
|
|
3159
|
+
item = item_from_names;
|
|
3160
|
+
if (typeof item === "number") return true;
|
|
3161
|
+
if (is_hierarchical_checkbox && names)
|
|
3162
|
+
// Special case for hierarchical checkboxes where we need to check if any of the names in the path match the query
|
|
3163
|
+
item = item.map((_, index) => names[$47d8681015b71901$var$find_str_arr_in_str_arr_arr("findIndex", values, item.slice(0, index + 1))]);
|
|
3164
|
+
if (Array.isArray(item)) return item.some(item => check_string_match(item + "")); // If any of the items in the array match, keep it
|
|
3165
|
+
return check_string_match(item);
|
|
3166
|
+
});
|
|
3167
|
+
const new_values = values.filter((_, i) => filtered_indexes[i]);
|
|
3168
|
+
if (!new_values.length) return false; // false = please delete this filter, see below
|
|
3169
|
+
const new_filter_object = {
|
|
3170
|
+
...filter,
|
|
3171
|
+
meta: {
|
|
3172
|
+
...meta,
|
|
3173
|
+
counts: counts?.filter((_, i) => filtered_indexes[i]),
|
|
3174
|
+
...(names ? {
|
|
3175
|
+
names: meta.names?.filter((_, i) => filtered_indexes[i])
|
|
3176
|
+
} : {}),
|
|
3177
|
+
values: new_values
|
|
3178
|
+
}
|
|
3179
|
+
};
|
|
3180
|
+
if (is_hierarchical_checkbox) {
|
|
3181
|
+
// For hierarchical checkbox we need to fill the holes created by filtering, for example if there is
|
|
3182
|
+
// ["Clothes"]
|
|
3183
|
+
// ["Clothes", "Blazers"]
|
|
3184
|
+
// And the user searched for "blazers" we need to add back ["Clothes"] so CheckboxHierarchicalFilter doesn't get confused
|
|
3185
|
+
// 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
|
|
3186
|
+
// So we do it here instead
|
|
3187
|
+
const new_meta = new_filter_object.meta;
|
|
3188
|
+
const new_values = new_meta.values;
|
|
3189
|
+
for (const value of new_values) {
|
|
3190
|
+
if (!Array.isArray(value)) continue; // Shouldn't happen
|
|
3191
|
+
if (value.length < 2) continue; // No parent
|
|
3192
|
+
const parent = value.slice(0, -1);
|
|
3193
|
+
// Check if parent exists
|
|
3194
|
+
if ($47d8681015b71901$var$find_str_arr_in_str_arr_arr("some", new_values, parent)) continue; // Parent exists
|
|
3195
|
+
// Otherwise, put it back
|
|
3196
|
+
const index_to_restore = $47d8681015b71901$var$find_str_arr_in_str_arr_arr("findIndex", values, parent);
|
|
3197
|
+
if (index_to_restore < 0) {
|
|
3198
|
+
$5vyXB$depictaiutilishared.dwarn("Can't restore", parent, "to", new_values);
|
|
3199
|
+
continue;
|
|
3200
|
+
}
|
|
3201
|
+
const current_index_of_us = new_values.findIndex(item => item === value);
|
|
3202
|
+
new_values.splice(current_index_of_us, 0, values[index_to_restore]);
|
|
3203
|
+
const count_to_restore = counts?.[index_to_restore];
|
|
3204
|
+
if (count_to_restore) new_meta.counts?.splice(current_index_of_us, 0, count_to_restore);
|
|
3205
|
+
const name_to_restore = names?.[index_to_restore];
|
|
3206
|
+
if (name_to_restore) new_meta.names?.splice(current_index_of_us, 0, name_to_restore);
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
return new_filter_object;
|
|
3210
|
+
}).filter(filter => filter); // Delete filters that don't have a value anymore
|
|
3211
|
+
});
|
|
3212
|
+
|
|
3213
|
+
return {
|
|
3214
|
+
SearchThisFilterGroup_: SearchThisFilterGroup_,
|
|
3215
|
+
searched_filter_array_: searched_filter_array_,
|
|
3216
|
+
filter_query_: filter_query_
|
|
3217
|
+
};
|
|
3218
|
+
}
|
|
3219
|
+
/**
|
|
3220
|
+
* Finds/whatevers what's effectively one hierarchical filter item in an array of hierarchical filter items
|
|
3221
|
+
* Functions similar to this happen loads in create_modified_filters, but they have additional checks so not touching them RN
|
|
3222
|
+
*/
|
|
3223
|
+
function $47d8681015b71901$var$find_str_arr_in_str_arr_arr(operation, haystack, needle) {
|
|
3224
|
+
return haystack[operation](value => value.length === needle.length && value.every((item, index) => item === needle[index]));
|
|
3225
|
+
}
|
|
2745
3226
|
const $aff9a96d30ed3563$var$_tmpl$ = ["<div", ' class="filter-collapsible">', "</div>"],
|
|
2746
3227
|
$aff9a96d30ed3563$var$_tmpl$2 = ["<button", ' class="clear-group"><!--$-->', "<!--/--><span>", "</span></button>"],
|
|
2747
3228
|
$aff9a96d30ed3563$var$_tmpl$3 = ["<div", ' class="view-more-clear"><!--$-->', "<!--/--><!--$-->", "<!--/--></div>"],
|
|
2748
|
-
$aff9a96d30ed3563$var$_tmpl$4 = ["<div", ' class="filter-collapsible-body"><div class="filter-part"
|
|
3229
|
+
$aff9a96d30ed3563$var$_tmpl$4 = ["<div", ' class="filter-collapsible-body"><div class="filter-part"><!--$-->', "<!--/--><!--$-->", "<!--/--></div><!--$-->", "<!--/--></div>"],
|
|
2749
3230
|
$aff9a96d30ed3563$var$_tmpl$5 = ["<details", ' class="filter-collapsible"', "></details>"],
|
|
2750
3231
|
$aff9a96d30ed3563$var$_tmpl$6 = ["<summary", ' class="filter-group-summary"><div class="summary"><span>', '</span><div class="selected-w-sign"><!--$-->', "<!--/--><!--$-->", "<!--/--></div></div></summary>"],
|
|
2751
3232
|
$aff9a96d30ed3563$var$_tmpl$7 = ["<div", ' class="ungrouped">', "</div>"],
|
|
@@ -2796,6 +3277,11 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
|
|
|
2796
3277
|
const filter_array_ = $5vyXB$solidjs.createMemo(() => {
|
|
2797
3278
|
return Object.values(togglable_filters_grouped_by_collapsible())[get_section_index()];
|
|
2798
3279
|
});
|
|
3280
|
+
const {
|
|
3281
|
+
SearchThisFilterGroup_: SearchThisFilterGroup_,
|
|
3282
|
+
searched_filter_array_: searched_filter_array_,
|
|
3283
|
+
filter_query_: filter_query_
|
|
3284
|
+
} = $47d8681015b71901$export$4b2c5292ffe0c5dd(filter_array_, section_, props.i18n_);
|
|
2799
3285
|
const is_open = $8c939a05b87fbbbc$export$ab34afce88557c0e({
|
|
2800
3286
|
get expanded_filters_() {
|
|
2801
3287
|
return props.expanded_filters_;
|
|
@@ -2808,6 +3294,8 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
|
|
|
2808
3294
|
// 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
|
|
2809
3295
|
filter_from_api]).filter(([selected_filter]) => selected_filter)));
|
|
2810
3296
|
const a_filter_is_selected = $5vyXB$solidjs.createMemo(() => selected_filters_in_group().size);
|
|
3297
|
+
const [get_details_width, set_get_details_width] = $5vyXB$solidjs.createSignal();
|
|
3298
|
+
const details_element_width_ = $5vyXB$solidjs.createMemo(() => get_details_width?.()?.());
|
|
2811
3299
|
return $5vyXB$solidjsweb.createComponent((0, $a69e505a12a77874$export$6c6d7a51fa9aa15d), {
|
|
2812
3300
|
is_open_: is_open,
|
|
2813
3301
|
get details_() {
|
|
@@ -2836,9 +3324,9 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
|
|
|
2836
3324
|
})));
|
|
2837
3325
|
},
|
|
2838
3326
|
get children() {
|
|
2839
|
-
return $5vyXB$solidjsweb.ssr($aff9a96d30ed3563$var$_tmpl$4, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Index), {
|
|
3327
|
+
return $5vyXB$solidjsweb.ssr($aff9a96d30ed3563$var$_tmpl$4, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent(SearchThisFilterGroup_, {})), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Index), {
|
|
2840
3328
|
get each() {
|
|
2841
|
-
return
|
|
3329
|
+
return searched_filter_array_();
|
|
2842
3330
|
},
|
|
2843
3331
|
children: filter => $5vyXB$solidjsweb.createComponent((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
|
|
2844
3332
|
severity_: "error",
|
|
@@ -2860,7 +3348,9 @@ function $aff9a96d30ed3563$var$ActualFilterBody(props) {
|
|
|
2860
3348
|
get i18n_() {
|
|
2861
3349
|
return props.i18n_;
|
|
2862
3350
|
},
|
|
2863
|
-
view_more_button_below_group_: view_more_button_below_group
|
|
3351
|
+
view_more_button_below_group_: view_more_button_below_group,
|
|
3352
|
+
filter_query_: filter_query_,
|
|
3353
|
+
details_element_width_: details_element_width_
|
|
2864
3354
|
});
|
|
2865
3355
|
}
|
|
2866
3356
|
})
|
|
@@ -6633,14 +7123,6 @@ const $3df11fc61432d1fd$var$_tmpl$ = ["<svg", ' xmlns="http://www.w3.org/2000/sv
|
|
|
6633
7123
|
function $3df11fc61432d1fd$export$1c641004b5485fed() {
|
|
6634
7124
|
return $5vyXB$solidjsweb.ssr($3df11fc61432d1fd$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey());
|
|
6635
7125
|
}
|
|
6636
|
-
const $87d7574e1d89d69b$var$_tmpl$ = '<path d="M19.811 20.174l-6.234-6.809a7.96 7.96 0 0 0 .923-1.179c.274-.424.502-.865.687-1.323a8.04 8.04 0 0 0 .42-1.436 7.88 7.88 0 0 0 .144-1.507c0-.526-.051-1.042-.154-1.548-.096-.506-.243-.995-.441-1.466s-.441-.919-.728-1.343a8.28 8.28 0 0 0-.984-1.21 7.86 7.86 0 0 0-1.2-.984A7.56 7.56 0 0 0 10.89.651C10.418.453 9.929.302 9.423.2S8.401.046 7.875.046 6.833.097 6.327.2 5.332.453 4.86.651a7.56 7.56 0 0 0-1.354.718c-.431.287-.831.615-1.2.984a8.28 8.28 0 0 0-.984 1.21 7.73 7.73 0 0 0-.728 1.343c-.198.472-.349.96-.451 1.466A8.31 8.31 0 0 0 0 7.921a8.31 8.31 0 0 0 .144 1.548c.103.506.253.995.451 1.466a8.08 8.08 0 0 0 .728 1.354 7.86 7.86 0 0 0 .984 1.2 7.54 7.54 0 0 0 1.2.995c.431.287.882.53 1.354.728.472.191.96.338 1.466.441a8.31 8.31 0 0 0 1.548.144c.451 0 .896-.038 1.333-.113a7.83 7.83 0 0 0 1.282-.328 7.55 7.55 0 0 0 1.2-.533 8.08 8.08 0 0 0 1.107-.749l6.245 6.809a.45.45 0 0 0 .174.123.55.55 0 0 0 .205.041.61.61 0 0 0 .195-.031c.061-.021.116-.055.164-.102.109-.096.164-.219.164-.369.007-.144-.038-.267-.133-.369zM1.046 7.921c0-.937.178-1.818.533-2.646.362-.834.851-1.559 1.466-2.174.622-.615 1.347-1.101 2.174-1.456.827-.362 1.712-.543 2.656-.543s1.829.181 2.656.543c.827.355 1.548.841 2.164 1.456.622.615 1.111 1.34 1.466 2.174a6.52 6.52 0 0 1 .543 2.646c0 .943-.181 1.829-.543 2.656a6.89 6.89 0 0 1-1.466 2.174c-.615.615-1.336 1.104-2.164 1.466-.827.356-1.712.533-2.656.533s-1.829-.178-2.656-.533c-.827-.362-1.552-.851-2.174-1.466-.615-.622-1.104-1.347-1.466-2.174-.355-.827-.533-1.712-.533-2.656z"></path>';
|
|
6637
|
-
function $87d7574e1d89d69b$export$82eafebb825fc23f(props = {}) {
|
|
6638
|
-
return $5vyXB$solidjsweb.ssrElement("svg", $5vyXB$solidjsweb.mergeProps(props, {
|
|
6639
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
6640
|
-
width: "20",
|
|
6641
|
-
height: "22"
|
|
6642
|
-
}), () => $5vyXB$solidjsweb.ssr($87d7574e1d89d69b$var$_tmpl$), true);
|
|
6643
|
-
}
|
|
6644
7126
|
const $66b8b9a9613c141d$var$_tmpl$ = ["<button", ' class="back" type="button"', ">", "</button>"],
|
|
6645
7127
|
$66b8b9a9613c141d$var$_tmpl$2 = ["<div", ' class="search-field"><!--$-->', '<!--/--><div class="field"><input class="', '" tabindex="0"', '><button type="button" class="clear"', ' style="', '">', '</button></div><button class="submit major" type="button"', ">", "</button></div>"];
|
|
6646
7128
|
function $66b8b9a9613c141d$export$b94867ecbd698f21({
|
|
@@ -7089,89 +7571,36 @@ function $9a268bf73b31a717$export$a146ac6fa8346a25({
|
|
|
7089
7571
|
const has_entries = $5vyXB$solidjs.createMemo(() => previous_searches_().length >= 1);
|
|
7090
7572
|
currently_showing_suggestions_[1](value => {
|
|
7091
7573
|
value[0] = $5vyXB$solidjs.createMemo(() => previous_searches_().map(result => ({
|
|
7092
|
-
type: (0, $3ec9e21d6b6debdd$export$3cf9497e790da491),
|
|
7093
|
-
title: result,
|
|
7094
|
-
suggestions_result_id: "history"
|
|
7095
|
-
})));
|
|
7096
|
-
return value;
|
|
7097
|
-
});
|
|
7098
|
-
$5vyXB$solidjs.onCleanup(() => currently_showing_suggestions_[1](value => {
|
|
7099
|
-
delete value[0];
|
|
7100
|
-
return value;
|
|
7101
|
-
}));
|
|
7102
|
-
return $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
7103
|
-
get when() {
|
|
7104
|
-
return has_entries();
|
|
7105
|
-
},
|
|
7106
|
-
get children() {
|
|
7107
|
-
return $5vyXB$solidjsweb.ssr($9a268bf73b31a717$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape(text_()), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Index), {
|
|
7108
|
-
get each() {
|
|
7109
|
-
return previous_searches_();
|
|
7110
|
-
},
|
|
7111
|
-
children: (item, index) => {
|
|
7112
|
-
const href = $496cde876b53ce1e$export$91c3b6774e8be0f5({
|
|
7113
|
-
param_: search_query_param_name_,
|
|
7114
|
-
value_: item,
|
|
7115
|
-
url_transformer_: url_transformer_
|
|
7116
|
-
});
|
|
7117
|
-
return $5vyXB$solidjsweb.ssr($9a268bf73b31a717$var$_tmpl$2, $5vyXB$solidjsweb.ssrHydrationKey(), `${`item` || ""} ${$5vyXB$solidjs.createMemo(() => read_selected_index_()?.[0] === 0 && read_selected_index_()?.[1] === index)() ? "selected" : ""}`, $5vyXB$solidjsweb.ssrAttribute("href", $5vyXB$solidjsweb.escape(href(), true), false), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $9e30168c4b1661d2$export$5d2caaa6b530761c), {})), $5vyXB$solidjsweb.ssrAttribute("title", $5vyXB$solidjsweb.escape(item(), true), false), $5vyXB$solidjsweb.escape(item()), $5vyXB$solidjsweb.ssrAttribute("title", $5vyXB$solidjsweb.escape(i18n_.previous_searches_delete_entry_from_history_(), true), false), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $c77c68e559a1506c$export$3b621d86b1566b2), {})));
|
|
7118
|
-
}
|
|
7119
|
-
})));
|
|
7120
|
-
}
|
|
7121
|
-
});
|
|
7122
|
-
}
|
|
7123
|
-
const $d023ed916c84e75d$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"],
|
|
7124
|
-
$d023ed916c84e75d$var$_tmpl$2 = ["<span", ' class="', '"', ">", "</span>"];
|
|
7125
|
-
function $d023ed916c84e75d$export$ba17c5b7e6dda39f({
|
|
7126
|
-
whole_text_to_display_: whole_text_to_display_memo,
|
|
7127
|
-
searching_for_value_: searching_for_value_memo,
|
|
7128
|
-
class_: class_
|
|
7129
|
-
}) {
|
|
7130
|
-
const [get_has_highlighted, set_has_highlighted] = $5vyXB$solidjs.createSignal(false);
|
|
7131
|
-
const text_itself = $5vyXB$solidjs.createMemo(() => $5vyXB$solidjs.batch(() => {
|
|
7132
|
-
set_has_highlighted(false);
|
|
7133
|
-
const searching_for_value = searching_for_value_memo();
|
|
7134
|
-
const whole_text_to_display_ = whole_text_to_display_memo();
|
|
7135
|
-
let for_black = "";
|
|
7136
|
-
let pushed_grey = false;
|
|
7137
|
-
const search_q = searching_for_value;
|
|
7138
|
-
if (!search_q) return whole_text_to_display_;
|
|
7139
|
-
const output = [];
|
|
7140
|
-
const searching_for = search_q.toLowerCase();
|
|
7141
|
-
const push_black = () => {
|
|
7142
|
-
if (for_black) {
|
|
7143
|
-
set_has_highlighted(true);
|
|
7144
|
-
output.push($5vyXB$solidjsweb.ssr($d023ed916c84e75d$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape(for_black))); // "black"
|
|
7145
|
-
for_black = "";
|
|
7146
|
-
}
|
|
7147
|
-
};
|
|
7148
|
-
for (let i = 0; i < whole_text_to_display_.length;) {
|
|
7149
|
-
let is_whole_word = true;
|
|
7150
|
-
let searching_for_but_with_texts_casing = "";
|
|
7151
|
-
const i_at_start = i;
|
|
7152
|
-
for (let j = 0; j < searching_for.length; i++, j++) {
|
|
7153
|
-
const letter_in_suggestion = whole_text_to_display_[i];
|
|
7154
|
-
if (letter_in_suggestion?.toLowerCase() !== searching_for[j]) {
|
|
7155
|
-
is_whole_word = false;
|
|
7156
|
-
i = i_at_start;
|
|
7157
|
-
break;
|
|
7574
|
+
type: (0, $3ec9e21d6b6debdd$export$3cf9497e790da491),
|
|
7575
|
+
title: result,
|
|
7576
|
+
suggestions_result_id: "history"
|
|
7577
|
+
})));
|
|
7578
|
+
return value;
|
|
7579
|
+
});
|
|
7580
|
+
$5vyXB$solidjs.onCleanup(() => currently_showing_suggestions_[1](value => {
|
|
7581
|
+
delete value[0];
|
|
7582
|
+
return value;
|
|
7583
|
+
}));
|
|
7584
|
+
return $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
7585
|
+
get when() {
|
|
7586
|
+
return has_entries();
|
|
7587
|
+
},
|
|
7588
|
+
get children() {
|
|
7589
|
+
return $5vyXB$solidjsweb.ssr($9a268bf73b31a717$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape(text_()), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Index), {
|
|
7590
|
+
get each() {
|
|
7591
|
+
return previous_searches_();
|
|
7592
|
+
},
|
|
7593
|
+
children: (item, index) => {
|
|
7594
|
+
const href = $496cde876b53ce1e$export$91c3b6774e8be0f5({
|
|
7595
|
+
param_: search_query_param_name_,
|
|
7596
|
+
value_: item,
|
|
7597
|
+
url_transformer_: url_transformer_
|
|
7598
|
+
});
|
|
7599
|
+
return $5vyXB$solidjsweb.ssr($9a268bf73b31a717$var$_tmpl$2, $5vyXB$solidjsweb.ssrHydrationKey(), `${`item` || ""} ${$5vyXB$solidjs.createMemo(() => read_selected_index_()?.[0] === 0 && read_selected_index_()?.[1] === index)() ? "selected" : ""}`, $5vyXB$solidjsweb.ssrAttribute("href", $5vyXB$solidjsweb.escape(href(), true), false), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $9e30168c4b1661d2$export$5d2caaa6b530761c), {})), $5vyXB$solidjsweb.ssrAttribute("title", $5vyXB$solidjsweb.escape(item(), true), false), $5vyXB$solidjsweb.escape(item()), $5vyXB$solidjsweb.ssrAttribute("title", $5vyXB$solidjsweb.escape(i18n_.previous_searches_delete_entry_from_history_(), true), false), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $c77c68e559a1506c$export$3b621d86b1566b2), {})));
|
|
7158
7600
|
}
|
|
7159
|
-
|
|
7160
|
-
}
|
|
7161
|
-
if (is_whole_word) {
|
|
7162
|
-
push_black();
|
|
7163
|
-
output.push(searching_for_but_with_texts_casing);
|
|
7164
|
-
pushed_grey = true;
|
|
7165
|
-
} else for_black += whole_text_to_display_[i++];
|
|
7166
|
-
}
|
|
7167
|
-
push_black();
|
|
7168
|
-
if (!pushed_grey) {
|
|
7169
|
-
set_has_highlighted(false);
|
|
7170
|
-
return whole_text_to_display_;
|
|
7601
|
+
})));
|
|
7171
7602
|
}
|
|
7172
|
-
|
|
7173
|
-
}));
|
|
7174
|
-
return $5vyXB$solidjsweb.ssr($d023ed916c84e75d$var$_tmpl$2, $5vyXB$solidjsweb.ssrHydrationKey(), `${$5vyXB$solidjsweb.escape(class_, true) || ""} ${get_has_highlighted() ? "has-history-match" : ""}`, $5vyXB$solidjsweb.ssrAttribute("title", $5vyXB$solidjsweb.escape(whole_text_to_display_memo(), true), false), $5vyXB$solidjsweb.escape(text_itself()));
|
|
7603
|
+
});
|
|
7175
7604
|
}
|
|
7176
7605
|
const $c0125412b4ea0c93$var$_tmpl$ = '<path d="M56 26.455a13.71 13.71 0 0 0-9.578 3.967A13.71 13.71 0 0 0 42.455 40v176a13.71 13.71 0 0 0 3.967 9.578A13.71 13.71 0 0 0 56 229.545h144A13.71 13.71 0 0 0 213.545 216V88a2.456 2.456 0 0 1 0-.002c.001-1.452-.597-2.895-1.623-3.922l-55.998-55.998a5.61 5.61 0 0 0-3.922-1.623 2.456 2.456 0 0 1-.002 0zm0 11.09h88A2.456 2.456 0 0 1 146.455 40v48c0 2.903 2.642 5.545 5.545 5.545h48A2.456 2.456 0 0 1 202.455 96v120a2.456 2.456 0 0 1-2.455 2.455H56A2.456 2.456 0 0 1 53.545 216V40A2.456 2.456 0 0 1 56 37.545zm103.061 11.498a2.456 2.456 0 0 1 2.676.531l28.689 28.689a2.456 2.456 0 0 1-1.736 4.191H160A2.456 2.456 0 0 1 157.545 80V51.311a2.456 2.456 0 0 1 1.516-2.268zM96 130.455c-2.903 0-5.545 2.642-5.545 5.545s2.642 5.545 5.545 5.545h64c2.903 0 5.545-2.642 5.545-5.545s-2.642-5.545-5.545-5.545zm0 32c-2.903 0-5.545 2.642-5.545 5.545s2.642 5.545 5.545 5.545h64c2.903 0 5.545-2.642 5.545-5.545s-2.642-5.545-5.545-5.545z"></path>';
|
|
7177
7606
|
function $c0125412b4ea0c93$export$605674723bcc715c(props = {}) {
|
|
@@ -7210,8 +7639,8 @@ function $6b65ba8af12c5a26$export$e872e2339fb04a7f({
|
|
|
7210
7639
|
type: type,
|
|
7211
7640
|
title: title
|
|
7212
7641
|
}) => type === (0, $3ec9e21d6b6debdd$export$3cf9497e790da491) && !filtered_previous_searches_().includes(title) // don't show the ones we already show from the history
|
|
7213
|
-
)
|
|
7214
|
-
|
|
7642
|
+
) // + limit to three query suggestions, API sends more sometimes
|
|
7643
|
+
.slice(0, 3));
|
|
7215
7644
|
const not_queries_memo = $5vyXB$solidjs.createMemo(() => {
|
|
7216
7645
|
// For the section that shows categories and content results
|
|
7217
7646
|
// We want to limit to 3 items, and we want to show the categories first
|
|
@@ -8006,224 +8435,6 @@ function $2005eec80e40088f$export$41b4894022a3580f({
|
|
|
8006
8435
|
})));
|
|
8007
8436
|
return style_props_;
|
|
8008
8437
|
}
|
|
8009
|
-
const $5ea5a82e398f6f44$var$_tmpl$ = ["<span", ' class="highlighted-part">', "</span>"];
|
|
8010
|
-
const $5ea5a82e398f6f44$var$dont_cut_in_between_less_than_characters = 30;
|
|
8011
|
-
function $5ea5a82e398f6f44$export$e1a98a189fd2c0e7({
|
|
8012
|
-
content_result_: content_result_,
|
|
8013
|
-
key_: key_,
|
|
8014
|
-
cut_when_possible_: cut_when_possible_
|
|
8015
|
-
}) {
|
|
8016
|
-
const matched_tokens = $5vyXB$solidjs.createMemo(() => content_result_().highlights?.find(highlight => highlight.field == key_)?.matched_tokens);
|
|
8017
|
-
const full_value = $5vyXB$solidjs.createMemo(() => content_result_()[key_]?.replaceAll("\n", " "));
|
|
8018
|
-
return $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
8019
|
-
get when() {
|
|
8020
|
-
return matched_tokens()?.length;
|
|
8021
|
-
},
|
|
8022
|
-
get fallback() {
|
|
8023
|
-
return full_value();
|
|
8024
|
-
},
|
|
8025
|
-
get children() {
|
|
8026
|
-
return (() => {
|
|
8027
|
-
const segmented_cut_text = $5vyXB$solidjs.createMemo(() => {
|
|
8028
|
-
const segmented_text = $5ea5a82e398f6f44$var$segment_text(full_value(), matched_tokens());
|
|
8029
|
-
if (cut_when_possible_) $5ea5a82e398f6f44$var$cut_text(segmented_text);
|
|
8030
|
-
return segmented_text;
|
|
8031
|
-
});
|
|
8032
|
-
return $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Index), {
|
|
8033
|
-
get each() {
|
|
8034
|
-
return segmented_cut_text();
|
|
8035
|
-
},
|
|
8036
|
-
children: item => {
|
|
8037
|
-
return $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
8038
|
-
get when() {
|
|
8039
|
-
return item().highlighted_;
|
|
8040
|
-
},
|
|
8041
|
-
get fallback() {
|
|
8042
|
-
return item().text_;
|
|
8043
|
-
},
|
|
8044
|
-
get children() {
|
|
8045
|
-
return $5vyXB$solidjsweb.ssr($5ea5a82e398f6f44$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape(item().text_));
|
|
8046
|
-
}
|
|
8047
|
-
});
|
|
8048
|
-
}
|
|
8049
|
-
});
|
|
8050
|
-
})();
|
|
8051
|
-
}
|
|
8052
|
-
});
|
|
8053
|
-
}
|
|
8054
|
-
function $5ea5a82e398f6f44$var$cut_text(segmented_text) {
|
|
8055
|
-
// cut away chunks of text that are not highlighted to give a google-like overview of the content
|
|
8056
|
-
const highlighted_segments = segmented_text?.filter(segment => segment.highlighted_);
|
|
8057
|
-
if (!segmented_text || !highlighted_segments?.length) return;
|
|
8058
|
-
// We have one or more highlighted segments
|
|
8059
|
-
if (highlighted_segments.length === 1) {
|
|
8060
|
-
// cut away from the left until the start of the highlighted sentence if just one sentence is highlighted
|
|
8061
|
-
$5ea5a82e398f6f44$var$cut_start(segmented_text.indexOf(highlighted_segments[0]), segmented_text);
|
|
8062
|
-
return;
|
|
8063
|
-
}
|
|
8064
|
-
// We have two or more highlighted segments, take the two biggest chunks and show them + a bit text around
|
|
8065
|
-
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
|
|
8066
|
-
);
|
|
8067
|
-
|
|
8068
|
-
const [longest_segment, next_longest_segment] = sorted_highlighted_segments;
|
|
8069
|
-
// We need to cut before the first segment - possibly through other segments - and maybe between segments
|
|
8070
|
-
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);
|
|
8071
|
-
$5ea5a82e398f6f44$var$cut_start(index_of_first_segment, segmented_text);
|
|
8072
|
-
// update indexes since we might have removed segments
|
|
8073
|
-
[index_of_first_segment, index_of_second_segment] = [segmented_text.indexOf(longest_segment), segmented_text.indexOf(next_longest_segment)].sort((a, b) => a - b);
|
|
8074
|
-
let number_of_characters_between_segments = 0;
|
|
8075
|
-
for (let i = index_of_first_segment + 1; i < index_of_second_segment; i++) {
|
|
8076
|
-
const segment = segmented_text[i];
|
|
8077
|
-
number_of_characters_between_segments += segment.text_.length;
|
|
8078
|
-
}
|
|
8079
|
-
if (number_of_characters_between_segments < $5ea5a82e398f6f44$var$dont_cut_in_between_less_than_characters)
|
|
8080
|
-
// don't cut if there are less than 30 characters between the two segments
|
|
8081
|
-
return;
|
|
8082
|
-
// We have more than 50 characters between the two segments, cut between them
|
|
8083
|
-
const [split_start_segment, split_start_character] = $5ea5a82e398f6f44$var$find_split_point(index_of_first_segment, index_of_second_segment, segmented_text);
|
|
8084
|
-
const [split_end_segment, split_end_character] = $5ea5a82e398f6f44$var$find_split_point(index_of_second_segment, index_of_first_segment, segmented_text);
|
|
8085
|
-
if (split_start_segment === undefined || split_end_segment === undefined ||
|
|
8086
|
-
// identical split point, or split end before split start, can't do anything
|
|
8087
|
-
split_start_segment == split_end_segment && split_start_character >= split_end_character || split_start_segment > split_end_segment) return;
|
|
8088
|
-
const dots_segment = {
|
|
8089
|
-
text_: " … ",
|
|
8090
|
-
highlighted_: false
|
|
8091
|
-
};
|
|
8092
|
-
const split_and_dotted_values = segmented_text.flatMap((segment, i) => {
|
|
8093
|
-
if (i < split_start_segment || i > split_end_segment) return segment;
|
|
8094
|
-
const text = segment.text_;
|
|
8095
|
-
if (i == split_end_segment && i == split_start_segment) return [{
|
|
8096
|
-
...segment,
|
|
8097
|
-
text_: text.slice(0, split_start_character).trimEnd()
|
|
8098
|
-
}, dots_segment, {
|
|
8099
|
-
...segment,
|
|
8100
|
-
text_: text.slice(split_end_character + 1, text.length).trimStart()
|
|
8101
|
-
}];else if (i == split_start_segment) {
|
|
8102
|
-
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
|
|
8103
|
-
return segment;
|
|
8104
|
-
} else if (i == split_end_segment) return [dots_segment, {
|
|
8105
|
-
...segment,
|
|
8106
|
-
text_: text.slice(split_end_character + 1, text.length).trimStart()
|
|
8107
|
-
}];
|
|
8108
|
-
return []; // remove all segments inbetween
|
|
8109
|
-
});
|
|
8110
|
-
|
|
8111
|
-
segmented_text.splice(0, segmented_text.length, ...split_and_dotted_values); // Sorry…
|
|
8112
|
-
$5ea5a82e398f6f44$var$heal_holes(segmented_text);
|
|
8113
|
-
}
|
|
8114
|
-
function $5ea5a82e398f6f44$var$heal_holes(segmented_text) {
|
|
8115
|
-
// try to heal "holes" created in the segments so there are only alternating segments
|
|
8116
|
-
const segments_to_delete = new Set();
|
|
8117
|
-
for (let i = 0; i < segmented_text.length; i++) {
|
|
8118
|
-
const segment = segmented_text[i];
|
|
8119
|
-
let previous_segment;
|
|
8120
|
-
for (let j = i - 1; j >= 0; j--) {
|
|
8121
|
-
previous_segment = segmented_text[j];
|
|
8122
|
-
// Don't write to a segment that's marked for deletion or the contents we write to it will be deleted
|
|
8123
|
-
if (!segments_to_delete.has(previous_segment)) break;
|
|
8124
|
-
}
|
|
8125
|
-
if (previous_segment?.highlighted_ && segment.highlighted_ || previous_segment?.highlighted_ === false && segment.highlighted_ === false) {
|
|
8126
|
-
previous_segment.text_ += segment.text_; // IDK if this ever happens
|
|
8127
|
-
segments_to_delete.add(segment);
|
|
8128
|
-
}
|
|
8129
|
-
}
|
|
8130
|
-
for (const segment of segments_to_delete) {
|
|
8131
|
-
const index = segmented_text.indexOf(segment);
|
|
8132
|
-
segmented_text.splice(index, 1);
|
|
8133
|
-
}
|
|
8134
|
-
}
|
|
8135
|
-
function $5ea5a82e398f6f44$var$find_split_point(index_of_start_segment, index_of_end_segment, segmented_text, be_very_aggressive = true) {
|
|
8136
|
-
const should_loop_backwards = index_of_start_segment > index_of_end_segment;
|
|
8137
|
-
const step = should_loop_backwards ? -1 : 1;
|
|
8138
|
-
const desperate_split_attempts = [":", ";", ","];
|
|
8139
|
-
while (desperate_split_attempts.length) {
|
|
8140
|
-
const split_point_between_words = [];
|
|
8141
|
-
// for the middle also try to split with a few more characters if the default ones don't work over a full run
|
|
8142
|
-
const desperate_split_attempt = desperate_split_attempts.pop();
|
|
8143
|
-
let is_first_character = true;
|
|
8144
|
-
for (let i = index_of_start_segment + step; should_loop_backwards ? i > index_of_end_segment : i < index_of_end_segment; i += step) {
|
|
8145
|
-
const segment = segmented_text[i];
|
|
8146
|
-
const text = segment.text_;
|
|
8147
|
-
for (let j = should_loop_backwards ? text.length - 1 : 0; should_loop_backwards ? j >= 0 : j < text.length; j += step) {
|
|
8148
|
-
const character = text[j];
|
|
8149
|
-
if (character == "." || character == "?" || character == "!" || character == desperate_split_attempt) return [i, j]; // segment index, character index
|
|
8150
|
-
if (is_first_character) is_first_character = false;else if (be_very_aggressive && character == " ") {
|
|
8151
|
-
split_point_between_words.push([i, j]);
|
|
8152
|
-
if (split_point_between_words.length > 3)
|
|
8153
|
-
// We can't find a split point, so we'll just split between words
|
|
8154
|
-
// 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
|
|
8155
|
-
return split_point_between_words[1];
|
|
8156
|
-
}
|
|
8157
|
-
}
|
|
8158
|
-
}
|
|
8159
|
-
}
|
|
8160
|
-
return [];
|
|
8161
|
-
}
|
|
8162
|
-
function $5ea5a82e398f6f44$var$cut_start(cut_left_of_index, segmented_text) {
|
|
8163
|
-
// Cut the start of the text to bring the first matching token
|
|
8164
|
-
let is_first_character = false;
|
|
8165
|
-
let words_encountered = 0;
|
|
8166
|
-
outmost_loop: for (let i = cut_left_of_index - 1; i >= 0; i--) {
|
|
8167
|
-
const segment = segmented_text[i];
|
|
8168
|
-
// We assume that two adjacent highlighted segments don't exist and have been merged if they were to have existed
|
|
8169
|
-
const text = segment.text_;
|
|
8170
|
-
for (let j = text.length - 1; j >= 0; j--) {
|
|
8171
|
-
const character = text[j];
|
|
8172
|
-
const is_space = character == " ";
|
|
8173
|
-
if (!is_first_character && is_space) words_encountered++;
|
|
8174
|
-
if (character == "." || character == "?" || character == "!" || character == "," || words_encountered > 8 && is_space) {
|
|
8175
|
-
// We have to be really aggressive at the start of sentences so stuff can be seen on mobile, hence comma
|
|
8176
|
-
segment.text_ = text.slice(j + 1).trimStart();
|
|
8177
|
-
segmented_text.splice(0, i);
|
|
8178
|
-
if (character === "," || is_space)
|
|
8179
|
-
// if we cut at a comma or psace, we add a … at the beginning
|
|
8180
|
-
segmented_text.unshift({
|
|
8181
|
-
text_: "… ",
|
|
8182
|
-
highlighted_: false
|
|
8183
|
-
});
|
|
8184
|
-
break outmost_loop;
|
|
8185
|
-
}
|
|
8186
|
-
if (is_first_character) is_first_character = false;
|
|
8187
|
-
}
|
|
8188
|
-
}
|
|
8189
|
-
$5ea5a82e398f6f44$var$heal_holes(segmented_text); // if we added a ... there could now be a sequence that's not alternating true/false
|
|
8190
|
-
}
|
|
8191
|
-
|
|
8192
|
-
function $5ea5a82e398f6f44$var$segment_text(text, matched_strings) {
|
|
8193
|
-
// segment text where the matched strings are highlighted sections
|
|
8194
|
-
const output = [];
|
|
8195
|
-
if (!text) return; // shouldn't happen but whatever
|
|
8196
|
-
for (let i = 0; i < text.length; i++) {
|
|
8197
|
-
const found_strings = [];
|
|
8198
|
-
if (!i || text[i - 1] == " ")
|
|
8199
|
-
// only match at the start of a word or string, it looks weird if i.e. "we" is highlighted in "activewear
|
|
8200
|
-
for (let j = 0; j < matched_strings.length; j++) {
|
|
8201
|
-
const matched_string = matched_strings[j];
|
|
8202
|
-
const part_in_text = text.slice(i, i + matched_string.length);
|
|
8203
|
-
if (matched_string.length < 2) continue; // don't match on single characters, i.e. "I", it looks weird
|
|
8204
|
-
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
|
|
8205
|
-
}
|
|
8206
|
-
|
|
8207
|
-
const last_index_in_output = output.length - 1;
|
|
8208
|
-
if (!found_strings.length) {
|
|
8209
|
-
const character = text[i];
|
|
8210
|
-
if (output[last_index_in_output]?.highlighted_ === false || output.length && /\s/.test(character))
|
|
8211
|
-
// 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
|
|
8212
|
-
output[last_index_in_output].text_ += character;else output.push({
|
|
8213
|
-
highlighted_: false,
|
|
8214
|
-
text_: character
|
|
8215
|
-
});
|
|
8216
|
-
} else {
|
|
8217
|
-
const longest_found_string = found_strings.reduce((a, b) => a.length > b.length ? a : b);
|
|
8218
|
-
if (output[last_index_in_output]?.highlighted_) output[last_index_in_output].text_ += longest_found_string;else output.push({
|
|
8219
|
-
highlighted_: true,
|
|
8220
|
-
text_: longest_found_string
|
|
8221
|
-
});
|
|
8222
|
-
i += longest_found_string.length - 1;
|
|
8223
|
-
}
|
|
8224
|
-
}
|
|
8225
|
-
return output;
|
|
8226
|
-
}
|
|
8227
8438
|
const $76227de40be817e5$var$_tmpl$ = ["<div", ' class="description line-clamp">', "</div>"],
|
|
8228
8439
|
$76227de40be817e5$var$_tmpl$2 = ["<div", ' class="content-card"><div class="image">', '</div><div class="info"><!--$-->', "<!--/--><!--$-->", "<!--/--></div></div>"];
|
|
8229
8440
|
function $76227de40be817e5$export$f631859cab12b342({
|