@depict-ai/ui 2.0.21 → 2.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/latest/index.cjs CHANGED
@@ -10,6 +10,8 @@ function $parcel$export(e, n, v, s) {
10
10
  configurable: true
11
11
  });
12
12
  }
13
+ $parcel$export(module.exports, "encode_filters", () => $1ab22f2cd39b3061$export$58aa3f171519b6d7);
14
+ $parcel$export(module.exports, "decode_filters", () => $1ab22f2cd39b3061$export$f934fa24c3a86811);
13
15
  $parcel$export(module.exports, "shopifyContainedImageContextSymbol", () => $a33065cfed827fc0$export$d7b7ab832c20e2f4);
14
16
  $parcel$export(module.exports, "ListingProvider", () => $84798aaa863a4909$export$e68cff63f76bd15b);
15
17
  $parcel$export(module.exports, "useListing", () => $84798aaa863a4909$export$8d0c4fdbb05a2f2e);
@@ -66,7 +68,180 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $a3280f0aad997933$expo
66
68
  $parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $a3280f0aad997933$export$7bf543b9d9be2c22);
67
69
  $parcel$export(module.exports, "version", () => $b757f75811f3261f$export$83d89fbfd8236492);
68
70
  /*! Depict.ai search and product listing SDK */
69
- const $b757f75811f3261f$export$83d89fbfd8236492 = "2.0.21";
71
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "2.0.23";
72
+ const $1ab22f2cd39b3061$var$fallback_operator = "in";
73
+ const $1ab22f2cd39b3061$var$fallback_token = "";
74
+ const $1ab22f2cd39b3061$var$legacy_filter_prefix = "filter_";
75
+ const $1ab22f2cd39b3061$var$operator_map = {
76
+ "eq": "≡",
77
+ "neq": "≠",
78
+ "in": "∈",
79
+ "nin": "∉",
80
+ "leq": "≤",
81
+ "geq": "≥",
82
+ "inrange": "\uD83D\uDD22"
83
+ };
84
+ const $1ab22f2cd39b3061$var$ascending_token = "\uD83D\uDCC8";
85
+ const $1ab22f2cd39b3061$var$descending_token = "\uD83D\uDCC9";
86
+ const $1ab22f2cd39b3061$var$range_delimiter = "-";
87
+ const $1ab22f2cd39b3061$var$string_item_delimiter = "‚"; // This is not a comma but a comma-like character that browsers will render in the URL bar.
88
+ const $1ab22f2cd39b3061$var$array_item_delimiter = "‣"; // FIXME: decide on a character. Could theoretically be a double string delimiter.
89
+ const $1ab22f2cd39b3061$var$empty_item_replacement = "0️⃣";
90
+ const $1ab22f2cd39b3061$var$op_to_token = op => {
91
+ if (op === $1ab22f2cd39b3061$var$fallback_operator) return $1ab22f2cd39b3061$var$fallback_token;
92
+ return $1ab22f2cd39b3061$var$operator_map[op];
93
+ };
94
+ /**
95
+ * Checks if a given array of filter data can be neatly serialized into an URL query parameter, or if it should fall back to JSON+base64.
96
+ * The requirements are either an array of strings, containing no reserved characters, or an array of arrays of strings, containing no reserved characters.
97
+ * No deep or mixed nesting levels are supported.
98
+ */
99
+ function $1ab22f2cd39b3061$var$array_is_serializable(array, is_root = true) {
100
+ if (array.every(item => Array.isArray(item))) {
101
+ if (!is_root)
102
+ // Deeply nested arrays are not supported, but also don't exist as filters (yet)
103
+ return false;
104
+ return array.every(item => $1ab22f2cd39b3061$var$array_is_serializable(item, false));
105
+ }
106
+ if (array.some(item => typeof item !== "string"))
107
+ // Numbers are not supported, since 1 and "1" would encode to the same thing
108
+ return false;
109
+ // Encoding reserved characters is not supported
110
+ return !array.some(item => item.includes($1ab22f2cd39b3061$var$array_item_delimiter) || item.includes($1ab22f2cd39b3061$var$string_item_delimiter) || item === $1ab22f2cd39b3061$var$empty_item_replacement);
111
+ }
112
+ /**
113
+ * Human readable string[] or string[][] serialization for URLs.
114
+ * @param array
115
+ * @returns
116
+ */
117
+ function $1ab22f2cd39b3061$var$encode_array(array) {
118
+ const is_nested = array.every(item => Array.isArray(item));
119
+ if (is_nested) return array.map($1ab22f2cd39b3061$var$encode_array).join($1ab22f2cd39b3061$var$array_item_delimiter) + $1ab22f2cd39b3061$var$array_item_delimiter; // Nested arrays require a suffix to close nesting levels
120
+ return array.map(item => item === "" ? $1ab22f2cd39b3061$var$empty_item_replacement : item).join($1ab22f2cd39b3061$var$string_item_delimiter);
121
+ }
122
+ function $1ab22f2cd39b3061$var$decode_array(encoded_array) {
123
+ const is_nested = encoded_array.includes($1ab22f2cd39b3061$var$array_item_delimiter);
124
+ if (is_nested) return encoded_array.split($1ab22f2cd39b3061$var$array_item_delimiter).filter(s => s !== "") // Remove empty segments, caused by trailing delimiter
125
+ .map($1ab22f2cd39b3061$var$decode_array);
126
+ return encoded_array.split($1ab22f2cd39b3061$var$string_item_delimiter).filter(s => s !== "") // Remove empty segments, caused by trailing delimiter in the single item special case
127
+ .map(item => item === $1ab22f2cd39b3061$var$empty_item_replacement ? "" : item);
128
+ }
129
+ function $1ab22f2cd39b3061$var$encode_filter_data(op, data) {
130
+ if (data === "true")
131
+ // boolean encoding
132
+ return "1";
133
+ if (data === "false")
134
+ // boolean encoding
135
+ return "0";
136
+ const data_is_array = Array.isArray(data);
137
+ if (op === "inrange" && data_is_array && data.every(item => typeof item === "number"))
138
+ // numeric range filter encoding
139
+ return data.join($1ab22f2cd39b3061$var$range_delimiter);
140
+ if (data_is_array && $1ab22f2cd39b3061$var$array_is_serializable(data)) {
141
+ const encoded_data = $1ab22f2cd39b3061$var$encode_array(data);
142
+ if (!encoded_data.includes($1ab22f2cd39b3061$var$array_item_delimiter) && !encoded_data.includes($1ab22f2cd39b3061$var$string_item_delimiter))
143
+ // A string[] with only one item will encode without delimiters, which is indistinguishable from a plain string during decoding
144
+ // In that case we add a delimiter suffix at the end
145
+ return encoded_data + $1ab22f2cd39b3061$var$string_item_delimiter;
146
+ return encoded_data;
147
+ }
148
+ // Fallback encoding
149
+ return $gVhhF$depictaiutilishared.base64_encode_unicode(JSON.stringify(data));
150
+ }
151
+ function $1ab22f2cd39b3061$var$decode_filter_data(op, encoded_data) {
152
+ if (encoded_data === "1") return "true";
153
+ if (encoded_data === "0") return "false";
154
+ if (op === "inrange" && encoded_data.includes($1ab22f2cd39b3061$var$range_delimiter)) return encoded_data.split($1ab22f2cd39b3061$var$range_delimiter).map(x => parseFloat(x));
155
+ if (encoded_data.includes($1ab22f2cd39b3061$var$string_item_delimiter) || encoded_data.includes($1ab22f2cd39b3061$var$array_item_delimiter)) return $1ab22f2cd39b3061$var$decode_array(encoded_data);
156
+ try {
157
+ return JSON.parse($gVhhF$depictaiutilishared.base64_decode_unicode(encoded_data));
158
+ } catch (e) {
159
+ $gVhhF$depictaiutilishared.dlog("Failed to fallback parse filter data", op, encoded_data, e);
160
+ }
161
+ return null;
162
+ }
163
+ function $1ab22f2cd39b3061$export$58aa3f171519b6d7(filters, search_params, filter_query_param_prefix) {
164
+ for (const filter of filters) {
165
+ const {
166
+ field: field,
167
+ op: op,
168
+ data: data
169
+ } = filter;
170
+ const encoded_data = $1ab22f2cd39b3061$var$encode_filter_data(op, data);
171
+ search_params.set(filter_query_param_prefix + field + $1ab22f2cd39b3061$var$op_to_token(op), encoded_data);
172
+ }
173
+ }
174
+ function $1ab22f2cd39b3061$export$f934fa24c3a86811(search_params, filter_query_param_prefix) {
175
+ const found_filters = [];
176
+ for (const key of search_params.keys()) {
177
+ // Allow for backwards compatibility with the old filter query param prefix
178
+ let chosen_prefix = filter_query_param_prefix;
179
+ if (!key.startsWith(chosen_prefix)) {
180
+ chosen_prefix = $1ab22f2cd39b3061$var$legacy_filter_prefix;
181
+ if (!key.startsWith(chosen_prefix)) continue;
182
+ }
183
+ const encoded_data = search_params.get(key);
184
+ if (!encoded_data) continue;
185
+ const [op, token] = Object.entries($1ab22f2cd39b3061$var$operator_map).find(([, token]) => key.endsWith(token)) || [$1ab22f2cd39b3061$var$fallback_operator, $1ab22f2cd39b3061$var$fallback_token];
186
+ const data = $1ab22f2cd39b3061$var$decode_filter_data(op, encoded_data);
187
+ if (!data) continue;
188
+ const field = key.slice(chosen_prefix.length, token ? -token.length : undefined);
189
+ found_filters.push({
190
+ field: field,
191
+ op: op,
192
+ data: data
193
+ });
194
+ }
195
+ return found_filters;
196
+ }
197
+ function $1ab22f2cd39b3061$export$62acb285a7579555(sorting, search_params, sorting_query_param) {
198
+ if (!sorting) return;
199
+ const {
200
+ field: field,
201
+ order: order
202
+ } = sorting;
203
+ const ascending = order === "asc";
204
+ search_params.set(sorting_query_param, field + (ascending ? $1ab22f2cd39b3061$var$ascending_token : $1ab22f2cd39b3061$var$descending_token));
205
+ }
206
+ function $1ab22f2cd39b3061$export$766e9676e74997d3(search_params, sorting_query_param_) {
207
+ const encoded_sorting = search_params.get(sorting_query_param_);
208
+ if (!encoded_sorting) return;
209
+ if (encoded_sorting.endsWith($1ab22f2cd39b3061$var$ascending_token)) return {
210
+ field: encoded_sorting.slice(0, -$1ab22f2cd39b3061$var$ascending_token.length),
211
+ order: "asc"
212
+ };
213
+ if (encoded_sorting.endsWith($1ab22f2cd39b3061$var$descending_token)) return {
214
+ field: encoded_sorting.slice(0, -$1ab22f2cd39b3061$var$descending_token.length),
215
+ order: "desc"
216
+ };
217
+ $gVhhF$depictaiutilishared.dlog("Invalid sorting query param value", encoded_sorting);
218
+ return;
219
+ }
220
+ function $1ab22f2cd39b3061$export$916e6850778505f6(search_params, filter_query_param_prefix, sorting_query_param) {
221
+ // We'll be modifying the URLSearchParams object, so we need to make a copy of the keys first
222
+ const keys = [...search_params.keys()];
223
+ for (const key of keys) if (key.startsWith(filter_query_param_prefix) || key === sorting_query_param || key.startsWith($1ab22f2cd39b3061$var$legacy_filter_prefix)) search_params.delete(key);
224
+ }
225
+ const $1ab22f2cd39b3061$export$cf5feb2102aec7f2 = "went_sideways_clear_filters";
226
+ function $1ab22f2cd39b3061$export$43cd1e747fecd42e({
227
+ to_url_: to_url_,
228
+ set_clearing_flag_: set_clearing_flag_,
229
+ from_search_params_ = new URLSearchParams(location.search),
230
+ sorting_query_param_: sorting_query_param_,
231
+ filter_query_param_prefix_: filter_query_param_prefix_
232
+ }) {
233
+ if (!to_url_) return to_url_;
234
+ const was_url_object = to_url_ instanceof URL;
235
+ const url_object = was_url_object ? to_url_ : new URL(to_url_, location.origin);
236
+ const {
237
+ searchParams: searchParams
238
+ } = url_object;
239
+ if (set_clearing_flag_) searchParams.set($1ab22f2cd39b3061$export$cf5feb2102aec7f2, "true");
240
+ if (from_search_params_.has(sorting_query_param_)) searchParams.set(sorting_query_param_, from_search_params_.get(sorting_query_param_));
241
+ for (const key of from_search_params_.keys()) if (key.startsWith(filter_query_param_prefix_)) searchParams.set(key, from_search_params_.get(key));
242
+ if (was_url_object) return url_object;
243
+ return url_object.href;
244
+ }
70
245
  const $84798aaa863a4909$var$ListingContext = /*@__PURE__*/$gVhhF$solidjs.createContext();
71
246
  function $84798aaa863a4909$export$e68cff63f76bd15b(props) {
72
247
  const our_object = {};
@@ -1250,6 +1425,14 @@ function $c77c68e559a1506c$export$3b621d86b1566b2(props = {}) {
1250
1425
  return _el$;
1251
1426
  })();
1252
1427
  }
1428
+
1429
+ /**
1430
+ * Lower cases a string if possible. Mostly used to make the filter url values case-insensitive.
1431
+ */
1432
+ function $daa394359b026187$export$325f75597868c4f0(stuff) {
1433
+ if (typeof stuff !== "string") return stuff;
1434
+ return stuff.toLowerCase();
1435
+ }
1253
1436
  const $235a2771a44e28e9$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class="clear-all-filters minor"></button>`, 2),
1254
1437
  $235a2771a44e28e9$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="inner"><span class="title"><!#><!/>: </span><!#><!/></div>`, 8),
1255
1438
  $235a2771a44e28e9$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class="clear-filter major"><!#><!/><span><!#><!/><!#><!/><!#><!/> – <!#><!/><!#><!/><!#><!/></span></button>`, 18),
@@ -1335,7 +1518,7 @@ function $235a2771a44e28e9$export$fecbb157621501bd({
1335
1518
  let parent_ = {};
1336
1519
  let created_an_object = false;
1337
1520
  for (let j = 0; j < value.length; j++) {
1338
- const this_categories_name = value[j];
1521
+ const this_categories_name = $daa394359b026187$export$325f75597868c4f0(value[j]);
1339
1522
  const obj = pointer[this_categories_name] ||= (() => {
1340
1523
  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;
1341
1524
  const created_obj = {
@@ -1439,7 +1622,7 @@ function $235a2771a44e28e9$export$fecbb157621501bd({
1439
1622
  const index_of_us_in_meta = $gVhhF$solidjs.createMemo(() => {
1440
1623
  const sel_d = selected_data();
1441
1624
  return meta()?.values?.findIndex(value => {
1442
- return value === sel_d || Array.isArray(value) && Array.isArray(sel_d) && value.length === sel_d.length && value.every((item, index) => sel_d[index] === item);
1625
+ return $daa394359b026187$export$325f75597868c4f0(value) === $daa394359b026187$export$325f75597868c4f0(sel_d) || Array.isArray(value) && Array.isArray(sel_d) && value.length === sel_d.length && value.every((item, index) => $daa394359b026187$export$325f75597868c4f0(sel_d[index]) === $daa394359b026187$export$325f75597868c4f0(item));
1443
1626
  });
1444
1627
  });
1445
1628
  const name = $gVhhF$solidjs.createMemo(() => {
@@ -1453,7 +1636,7 @@ function $235a2771a44e28e9$export$fecbb157621501bd({
1453
1636
  let we_in_structure;
1454
1637
  let pointer = structure;
1455
1638
  for (const step of selected_data()) {
1456
- we_in_structure = pointer?.[step];
1639
+ we_in_structure = pointer?.[$daa394359b026187$export$325f75597868c4f0(step)];
1457
1640
  pointer = we_in_structure?.children_;
1458
1641
  }
1459
1642
  return we_in_structure;
@@ -1464,7 +1647,7 @@ function $235a2771a44e28e9$export$fecbb157621501bd({
1464
1647
  const siblings = parent?.children_;
1465
1648
  if (siblings) return [parent, ...Object.values(siblings)].every(({
1466
1649
  value_: value_
1467
- }) => iterable_selected_filter_data()?.some(v => Array.isArray(v) && v.length === value_.length && value_.every((val, index) => v[index] === val)));
1650
+ }) => iterable_selected_filter_data()?.some(v => Array.isArray(v) && v.length === value_.length && value_.every((val, index) => $daa394359b026187$export$325f75597868c4f0(v[index]) === $daa394359b026187$export$325f75597868c4f0(val))));
1468
1651
  return false;
1469
1652
  });
1470
1653
  return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
@@ -1486,7 +1669,7 @@ function $235a2771a44e28e9$export$fecbb157621501bd({
1486
1669
  cloned_selected_filters.splice(index_in_selected_filters, 1);
1487
1670
  const data = filter().data;
1488
1671
  const cloned_data = Array.isArray(data) ? [...data] : [data];
1489
- const index_of_item = cloned_data.findIndex(item => item === to_remove);
1672
+ const index_of_item = cloned_data.findIndex(item => $daa394359b026187$export$325f75597868c4f0(item) === $daa394359b026187$export$325f75597868c4f0(to_remove));
1490
1673
  if (index_of_item >= 0) cloned_data.splice(index_of_item, 1);
1491
1674
  const in_structure = us_in_structure();
1492
1675
  if (in_structure) {
@@ -1497,7 +1680,7 @@ function $235a2771a44e28e9$export$fecbb157621501bd({
1497
1680
  const {
1498
1681
  value_: value_
1499
1682
  } = kid;
1500
- const index_to_remove = cloned_data.findIndex(item => Array.isArray(item) && item.length === value_.length && value_.every((val, index) => item[index] === val));
1683
+ const index_to_remove = cloned_data.findIndex(item => Array.isArray(item) && item.length === value_.length && value_.every((val, index) => $daa394359b026187$export$325f75597868c4f0(item[index]) === $daa394359b026187$export$325f75597868c4f0(val)));
1501
1684
  if (index_to_remove >= 0) cloned_data.splice(index_to_remove, 1);
1502
1685
  recursive_kids.push(...Object.values(kid.children_));
1503
1686
  }
@@ -1676,6 +1859,11 @@ function $d94869c80e337a3d$export$dd948f91abc3a1c4({
1676
1859
  });
1677
1860
  const render_checkbox = checkbox => {
1678
1861
  // Checkbox always calls the getters in props, so we don't wrap these values into memos
1862
+ const is_checked = $gVhhF$solidjs.createMemo(() => {
1863
+ const data = existing_filter()?.data;
1864
+ const value = $daa394359b026187$export$325f75597868c4f0(checkbox().value_);
1865
+ return !!data?.some(item => $daa394359b026187$export$325f75597868c4f0(item) === value);
1866
+ });
1679
1867
  return $gVhhF$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
1680
1868
  get value_() {
1681
1869
  return checkbox().value_;
@@ -1687,7 +1875,7 @@ function $d94869c80e337a3d$export$dd948f91abc3a1c4({
1687
1875
  return checkbox().count_;
1688
1876
  },
1689
1877
  get checked_() {
1690
- return existing_filter()?.data?.includes(checkbox().value_);
1878
+ return is_checked();
1691
1879
  }
1692
1880
  });
1693
1881
  };
@@ -1839,7 +2027,7 @@ function $c1dc1554c1b94233$export$430444115f70a734({
1839
2027
  $gVhhF$solidjsweb.effect(() => _el$4.checked = $gVhhF$solidjs.createMemo(() => {
1840
2028
  const v = value();
1841
2029
  const data = existing_filter()?.data;
1842
- if (data === v) return true;
2030
+ if ($daa394359b026187$export$325f75597868c4f0(data) === $daa394359b026187$export$325f75597868c4f0(v)) return true;
1843
2031
  return Array.isArray(data) && data.every((item, index) => item === v[index]);
1844
2032
  })());
1845
2033
  return _el$2;
@@ -2561,7 +2749,7 @@ function $3bdc00a1353c1150$var$create_updating_signal({
2561
2749
  const on_structure_complete_ = () => {
2562
2750
  // wait for the children to have populated and us to have received the correct value_ and name_ values
2563
2751
  let updating_blocked = false;
2564
- const index_of_us_in_selected_filter = existing_filter_?.data?.findIndex?.(el => el.length === self_.value_.length && el.every((sub_el, index) => self_.value_[index] === sub_el));
2752
+ const index_of_us_in_selected_filter = existing_filter_?.data?.findIndex?.(el => el.length === self_.value_.length && el.every((sub_el, index) => $daa394359b026187$export$325f75597868c4f0(self_.value_[index]) === $daa394359b026187$export$325f75597868c4f0(sub_el)));
2565
2753
  signal_.push(...$gVhhF$solidjs.createSignal(index_of_us_in_selected_filter >= 0));
2566
2754
  const [read_checked, write_checked] = signal_;
2567
2755
  const child_objects = Object.values(self_.children_);
@@ -2732,7 +2920,11 @@ const $0ef1681699140f1a$export$414f6a19d38e655c = ({
2732
2920
  return buttons();
2733
2921
  },
2734
2922
  children: value => {
2735
- const is_selected = $gVhhF$solidjs.createMemo(() => existing_filter()?.data?.includes(value().value_));
2923
+ const is_selected = $gVhhF$solidjs.createMemo(() => {
2924
+ const data = existing_filter()?.data;
2925
+ const current_value = $daa394359b026187$export$325f75597868c4f0(value().value_);
2926
+ return !!data?.some(item => $daa394359b026187$export$325f75597868c4f0(item) === current_value);
2927
+ });
2736
2928
  const MakeButton = attributes => (() => {
2737
2929
  const _el$2 = $gVhhF$solidjsweb.getNextElement($0ef1681699140f1a$var$_tmpl$3),
2738
2930
  _el$5 = _el$2.firstChild,
@@ -2767,7 +2959,10 @@ const $0ef1681699140f1a$export$414f6a19d38e655c = ({
2767
2959
  ...base_object,
2768
2960
  data: new_data
2769
2961
  };
2770
- if (!is_selected()) new_filter_object.data.push(value().value_);else new_filter_object.data = new_filter_object.data.filter(v => v !== value().value_);
2962
+ if (!is_selected()) new_filter_object.data.push(value().value_);else {
2963
+ const current_value_lower = $daa394359b026187$export$325f75597868c4f0(value().value_);
2964
+ new_filter_object.data = new_filter_object.data.filter(v => $daa394359b026187$export$325f75597868c4f0(v) !== current_value_lower);
2965
+ }
2771
2966
  const selected_filters = [...get_selected_filters().filter(f => f !== set_filter), ...(new_filter_object.data.length ? [new_filter_object] : [])];
2772
2967
  set_selected_filters(selected_filters);
2773
2968
  });
@@ -2868,13 +3063,6 @@ function $0ef1681699140f1a$var$adjust_sizes(container_width, sizes, set_cols_at_
2868
3063
  overrides: column_to_row_result
2869
3064
  }]]);
2870
3065
  }
2871
- function $b54e6192d0caa293$export$d9f36cf74e24d595(media_query) {
2872
- const signal = $gVhhF$solidjs.createSignal(false);
2873
- $gVhhF$solidjs.onCleanup($gVhhF$depictaiutilishared.javascript_media_query(media_query, ({
2874
- matches: matches
2875
- }) => signal[1](matches)).remove);
2876
- return signal[0];
2877
- }
2878
3066
  const $b51a2b8b9355e66c$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<form class="checkbox-color"><!#><!/><!#><!/></form>`, 6);
2879
3067
  const $b51a2b8b9355e66c$var$max_visible_without_collapsing = 30;
2880
3068
  const $b51a2b8b9355e66c$var$show_non_collapsible_when_collapsed = 8;
@@ -2884,7 +3072,6 @@ function $b51a2b8b9355e66c$export$82ed4b28ecb67608({
2884
3072
  i18n_: i18n_,
2885
3073
  view_more_button_below_group_: [_get_view_more_button_below_group_, set_view_more_button_below_group_]
2886
3074
  }) {
2887
- const supports_hover = $b54e6192d0caa293$export$d9f36cf74e24d595("not all and (hover: none)");
2888
3075
  // same as in CheckboxFilter, maybe we should make this DRY at some point
2889
3076
  const existing_filter = $gVhhF$solidjs.createMemo(() => {
2890
3077
  const {
@@ -2912,6 +3099,11 @@ function $b51a2b8b9355e66c$export$82ed4b28ecb67608({
2912
3099
  const hex_color = $gVhhF$solidjs.createMemo(() => checkbox().value_.split(";")?.[1] || "");
2913
3100
  const rgb_color = $gVhhF$solidjs.createMemo(() => $gVhhF$depictaiutilishared.hex_to_rgb(hex_color()));
2914
3101
  const black_contrast_better = $gVhhF$solidjs.createMemo(() => rgb_color() ? $b51a2b8b9355e66c$var$does_black_contrast_better(rgb_color()) : false);
3102
+ const is_checked = $gVhhF$solidjs.createMemo(() => {
3103
+ const data = existing_filter()?.data;
3104
+ const value = $daa394359b026187$export$325f75597868c4f0(checkbox().value_);
3105
+ return !!data?.some(item => $daa394359b026187$export$325f75597868c4f0(item) === value);
3106
+ });
2915
3107
  const input_row = $gVhhF$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
2916
3108
  get value_() {
2917
3109
  return checkbox().value_;
@@ -2923,7 +3115,7 @@ function $b51a2b8b9355e66c$export$82ed4b28ecb67608({
2923
3115
  return checkbox().count_;
2924
3116
  },
2925
3117
  get checked_() {
2926
- return existing_filter()?.data?.includes(checkbox().value_);
3118
+ return is_checked();
2927
3119
  },
2928
3120
  custom_indicator_ref: span => {
2929
3121
  const {
@@ -3106,7 +3298,7 @@ function $b064919833b3e80b$export$53c59af873b303c9({
3106
3298
  break try_specific;
3107
3299
  }
3108
3300
  const needle = data_is_array ? data[0] : data;
3109
- const index_in_meta = meta.values.findIndex(value => needle === value || Array.isArray(needle) && Array.isArray(value) && needle.length === value.length && value.every((item, index) => needle[index] === item));
3301
+ const index_in_meta = meta.values.findIndex(value => $daa394359b026187$export$325f75597868c4f0(needle) === $daa394359b026187$export$325f75597868c4f0(value) || Array.isArray(needle) && Array.isArray(value) && needle.length === value.length && value.every((item, index) => $daa394359b026187$export$325f75597868c4f0(needle[index]) === $daa394359b026187$export$325f75597868c4f0(item)));
3110
3302
  return meta.names?.[index_in_meta] || meta.values?.[index_in_meta];
3111
3303
  }
3112
3304
  }
@@ -3664,7 +3856,8 @@ function $6e22b5314fb52f4c$export$e183a13865960371(params_to_default_value, rout
3664
3856
  const signals = {};
3665
3857
  const entries = Object.entries(params_to_default_value);
3666
3858
  const event_handler = $gVhhF$depictaiutilishared.catchify((what_happened, args) => {
3667
- if (what_happened == "popstate") $6e22b5314fb52f4c$var$history_state_change(signals, entries, args.state);
3859
+ // Intentionally always update our signals to the history state to allow external control of SDK state for doing things like https://linear.app/depictai/issue/X-1432/is-this-possible-with-the-depict-sdk
3860
+ $6e22b5314fb52f4c$var$history_state_change(signals, entries, what_happened === "popstate" ? args.state : history.state);
3668
3861
  });
3669
3862
  // createRenderEffect because we need the instant execution so the signals always contain values, even before solid's render phase
3670
3863
  $gVhhF$solidjs.createRenderEffect(() => {
@@ -4033,6 +4226,13 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
4033
4226
  }));
4034
4227
  }
4035
4228
  }
4229
+ function $b54e6192d0caa293$export$d9f36cf74e24d595(media_query) {
4230
+ const signal = $gVhhF$solidjs.createSignal(false);
4231
+ $gVhhF$solidjs.onCleanup($gVhhF$depictaiutilishared.javascript_media_query(media_query, ({
4232
+ matches: matches
4233
+ }) => signal[1](matches)).remove);
4234
+ return signal[0];
4235
+ }
4036
4236
  const $6b384adf40a5f4d7$var$get_available_range = (available_filters_, search_for_field) => {
4037
4237
  const maybe_meta = $gVhhF$solidjs.untrack(available_filters_)?.find(({
4038
4238
  op: op,
@@ -5623,179 +5823,6 @@ function $2fb324fbcc7b4a7b$var$ActualFloatingButtons({
5623
5823
  })();
5624
5824
  }
5625
5825
  $gVhhF$solidjsweb.delegateEvents(["click"]);
5626
- const $1ab22f2cd39b3061$var$fallback_operator = "in";
5627
- const $1ab22f2cd39b3061$var$fallback_token = "";
5628
- const $1ab22f2cd39b3061$var$legacy_filter_prefix = "filter_";
5629
- const $1ab22f2cd39b3061$var$operator_map = {
5630
- "eq": "≡",
5631
- "neq": "≠",
5632
- "in": "∈",
5633
- "nin": "∉",
5634
- "leq": "≤",
5635
- "geq": "≥",
5636
- "inrange": "\uD83D\uDD22"
5637
- };
5638
- const $1ab22f2cd39b3061$var$ascending_token = "\uD83D\uDCC8";
5639
- const $1ab22f2cd39b3061$var$descending_token = "\uD83D\uDCC9";
5640
- const $1ab22f2cd39b3061$var$range_delimiter = "-";
5641
- const $1ab22f2cd39b3061$var$string_item_delimiter = "‚"; // This is not a comma but a comma-like character that browsers will render in the URL bar.
5642
- const $1ab22f2cd39b3061$var$array_item_delimiter = "‣"; // FIXME: decide on a character. Could theoretically be a double string delimiter.
5643
- const $1ab22f2cd39b3061$var$empty_item_replacement = "0️⃣";
5644
- const $1ab22f2cd39b3061$var$op_to_token = op => {
5645
- if (op === $1ab22f2cd39b3061$var$fallback_operator) return $1ab22f2cd39b3061$var$fallback_token;
5646
- return $1ab22f2cd39b3061$var$operator_map[op];
5647
- };
5648
- /**
5649
- * Checks if a given array of filter data can be neatly serialized into an URL query parameter, or if it should fall back to JSON+base64.
5650
- * The requirements are either an array of strings, containing no reserved characters, or an array of arrays of strings, containing no reserved characters.
5651
- * No deep or mixed nesting levels are supported.
5652
- */
5653
- function $1ab22f2cd39b3061$var$array_is_serializable(array, is_root = true) {
5654
- if (array.every(item => Array.isArray(item))) {
5655
- if (!is_root)
5656
- // Deeply nested arrays are not supported, but also don't exist as filters (yet)
5657
- return false;
5658
- return array.every(item => $1ab22f2cd39b3061$var$array_is_serializable(item, false));
5659
- }
5660
- if (array.some(item => typeof item !== "string"))
5661
- // Numbers are not supported, since 1 and "1" would encode to the same thing
5662
- return false;
5663
- // Encoding reserved characters is not supported
5664
- return !array.some(item => item.includes($1ab22f2cd39b3061$var$array_item_delimiter) || item.includes($1ab22f2cd39b3061$var$string_item_delimiter) || item === $1ab22f2cd39b3061$var$empty_item_replacement);
5665
- }
5666
- /**
5667
- * Human readable string[] or string[][] serialization for URLs.
5668
- * @param array
5669
- * @returns
5670
- */
5671
- function $1ab22f2cd39b3061$var$encode_array(array) {
5672
- const is_nested = array.every(item => Array.isArray(item));
5673
- if (is_nested) return array.map($1ab22f2cd39b3061$var$encode_array).join($1ab22f2cd39b3061$var$array_item_delimiter) + $1ab22f2cd39b3061$var$array_item_delimiter; // Nested arrays require a suffix to close nesting levels
5674
- return array.map(item => item === "" ? $1ab22f2cd39b3061$var$empty_item_replacement : item).join($1ab22f2cd39b3061$var$string_item_delimiter);
5675
- }
5676
- function $1ab22f2cd39b3061$var$decode_array(encoded_array) {
5677
- const is_nested = encoded_array.includes($1ab22f2cd39b3061$var$array_item_delimiter);
5678
- if (is_nested) return encoded_array.split($1ab22f2cd39b3061$var$array_item_delimiter).filter(s => s !== "") // Remove empty segments, caused by trailing delimiter
5679
- .map($1ab22f2cd39b3061$var$decode_array);
5680
- return encoded_array.split($1ab22f2cd39b3061$var$string_item_delimiter).filter(s => s !== "") // Remove empty segments, caused by trailing delimiter in the single item special case
5681
- .map(item => item === $1ab22f2cd39b3061$var$empty_item_replacement ? "" : item);
5682
- }
5683
- function $1ab22f2cd39b3061$var$encode_filter_data(op, data) {
5684
- if (data === "true")
5685
- // boolean encoding
5686
- return "1";
5687
- if (data === "false")
5688
- // boolean encoding
5689
- return "0";
5690
- const data_is_array = Array.isArray(data);
5691
- if (op === "inrange" && data_is_array && data.every(item => typeof item === "number"))
5692
- // numeric range filter encoding
5693
- return data.join($1ab22f2cd39b3061$var$range_delimiter);
5694
- if (data_is_array && $1ab22f2cd39b3061$var$array_is_serializable(data)) {
5695
- const encoded_data = $1ab22f2cd39b3061$var$encode_array(data);
5696
- if (!encoded_data.includes($1ab22f2cd39b3061$var$array_item_delimiter) && !encoded_data.includes($1ab22f2cd39b3061$var$string_item_delimiter))
5697
- // A string[] with only one item will encode without delimiters, which is indistinguishable from a plain string during decoding
5698
- // In that case we add a delimiter suffix at the end
5699
- return encoded_data + $1ab22f2cd39b3061$var$string_item_delimiter;
5700
- return encoded_data;
5701
- }
5702
- // Fallback encoding
5703
- return $gVhhF$depictaiutilishared.base64_encode_unicode(JSON.stringify(data));
5704
- }
5705
- function $1ab22f2cd39b3061$var$decode_filter_data(op, encoded_data) {
5706
- if (encoded_data === "1") return "true";
5707
- if (encoded_data === "0") return "false";
5708
- if (op === "inrange" && encoded_data.includes($1ab22f2cd39b3061$var$range_delimiter)) return encoded_data.split($1ab22f2cd39b3061$var$range_delimiter).map(x => parseFloat(x));
5709
- if (encoded_data.includes($1ab22f2cd39b3061$var$string_item_delimiter) || encoded_data.includes($1ab22f2cd39b3061$var$array_item_delimiter)) return $1ab22f2cd39b3061$var$decode_array(encoded_data);
5710
- try {
5711
- return JSON.parse($gVhhF$depictaiutilishared.base64_decode_unicode(encoded_data));
5712
- } catch (e) {
5713
- $gVhhF$depictaiutilishared.dlog("Failed to fallback parse filter data", op, encoded_data, e);
5714
- }
5715
- return null;
5716
- }
5717
- function $1ab22f2cd39b3061$export$58aa3f171519b6d7(filters, search_params, filter_query_param_prefix) {
5718
- for (const filter of filters) {
5719
- const {
5720
- field: field,
5721
- op: op,
5722
- data: data
5723
- } = filter;
5724
- const encoded_data = $1ab22f2cd39b3061$var$encode_filter_data(op, data);
5725
- search_params.set(filter_query_param_prefix + field + $1ab22f2cd39b3061$var$op_to_token(op), encoded_data);
5726
- }
5727
- }
5728
- function $1ab22f2cd39b3061$export$f934fa24c3a86811(search_params, filter_query_param_prefix) {
5729
- const found_filters = [];
5730
- for (const key of search_params.keys()) {
5731
- // Allow for backwards compatibility with the old filter query param prefix
5732
- let chosen_prefix = filter_query_param_prefix;
5733
- if (!key.startsWith(chosen_prefix)) {
5734
- chosen_prefix = $1ab22f2cd39b3061$var$legacy_filter_prefix;
5735
- if (!key.startsWith(chosen_prefix)) continue;
5736
- }
5737
- const encoded_data = search_params.get(key);
5738
- if (!encoded_data) continue;
5739
- const [op, token] = Object.entries($1ab22f2cd39b3061$var$operator_map).find(([, token]) => key.endsWith(token)) || [$1ab22f2cd39b3061$var$fallback_operator, $1ab22f2cd39b3061$var$fallback_token];
5740
- const data = $1ab22f2cd39b3061$var$decode_filter_data(op, encoded_data);
5741
- if (!data) continue;
5742
- const field = key.slice(chosen_prefix.length, token ? -token.length : undefined);
5743
- found_filters.push({
5744
- field: field,
5745
- op: op,
5746
- data: data
5747
- });
5748
- }
5749
- return found_filters;
5750
- }
5751
- function $1ab22f2cd39b3061$export$62acb285a7579555(sorting, search_params, sorting_query_param) {
5752
- if (!sorting) return;
5753
- const {
5754
- field: field,
5755
- order: order
5756
- } = sorting;
5757
- const ascending = order === "asc";
5758
- search_params.set(sorting_query_param, field + (ascending ? $1ab22f2cd39b3061$var$ascending_token : $1ab22f2cd39b3061$var$descending_token));
5759
- }
5760
- function $1ab22f2cd39b3061$export$766e9676e74997d3(search_params, sorting_query_param_) {
5761
- const encoded_sorting = search_params.get(sorting_query_param_);
5762
- if (!encoded_sorting) return;
5763
- if (encoded_sorting.endsWith($1ab22f2cd39b3061$var$ascending_token)) return {
5764
- field: encoded_sorting.slice(0, -$1ab22f2cd39b3061$var$ascending_token.length),
5765
- order: "asc"
5766
- };
5767
- if (encoded_sorting.endsWith($1ab22f2cd39b3061$var$descending_token)) return {
5768
- field: encoded_sorting.slice(0, -$1ab22f2cd39b3061$var$descending_token.length),
5769
- order: "desc"
5770
- };
5771
- $gVhhF$depictaiutilishared.dlog("Invalid sorting query param value", encoded_sorting);
5772
- return;
5773
- }
5774
- function $1ab22f2cd39b3061$export$916e6850778505f6(search_params, filter_query_param_prefix, sorting_query_param) {
5775
- // We'll be modifying the URLSearchParams object, so we need to make a copy of the keys first
5776
- const keys = [...search_params.keys()];
5777
- for (const key of keys) if (key.startsWith(filter_query_param_prefix) || key === sorting_query_param || key.startsWith($1ab22f2cd39b3061$var$legacy_filter_prefix)) search_params.delete(key);
5778
- }
5779
- const $1ab22f2cd39b3061$export$cf5feb2102aec7f2 = "went_sideways_clear_filters";
5780
- function $1ab22f2cd39b3061$export$43cd1e747fecd42e({
5781
- to_url_: to_url_,
5782
- set_clearing_flag_: set_clearing_flag_,
5783
- from_search_params_ = new URLSearchParams(location.search),
5784
- sorting_query_param_: sorting_query_param_,
5785
- filter_query_param_prefix_: filter_query_param_prefix_
5786
- }) {
5787
- if (!to_url_) return to_url_;
5788
- const was_url_object = to_url_ instanceof URL;
5789
- const url_object = was_url_object ? to_url_ : new URL(to_url_, location.origin);
5790
- const {
5791
- searchParams: searchParams
5792
- } = url_object;
5793
- if (set_clearing_flag_) searchParams.set($1ab22f2cd39b3061$export$cf5feb2102aec7f2, "true");
5794
- if (from_search_params_.has(sorting_query_param_)) searchParams.set(sorting_query_param_, from_search_params_.get(sorting_query_param_));
5795
- for (const key of from_search_params_.keys()) if (key.startsWith(filter_query_param_prefix_)) searchParams.set(key, from_search_params_.get(key));
5796
- if (was_url_object) return url_object;
5797
- return url_object.href;
5798
- }
5799
5826
  const $e53b2e7e632ac4cb$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<nav class="crumbs"></nav>`, 2),
5800
5827
  $e53b2e7e632ac4cb$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<a class="crumb"></a>`, 2),
5801
5828
  $e53b2e7e632ac4cb$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class="separator"></span>`, 2);
@@ -10897,7 +10924,7 @@ class $0a6acf31d1eae57c$export$3ccaa27d81dd8556 extends EventTarget {
10897
10924
  }, "failed to open page");
10898
10925
  #empty_page_bugfix() {
10899
10926
  // Called when a "page" is "opened" using PageReplacer
10900
- const on_maybe_popstate = what_happened => {
10927
+ const on_maybe_popstate = $gVhhF$depictaiutilishared.catchify(what_happened => {
10901
10928
  if (what_happened !== "popstate") return;
10902
10929
  const cleaned_current_url = $0a6acf31d1eae57c$var$clean_url(location.href);
10903
10930
  if (!$0a6acf31d1eae57c$export$3ccaa27d81dd8556.#visited_urls.has(cleaned_current_url)) {
@@ -10926,7 +10953,7 @@ class $0a6acf31d1eae57c$export$3ccaa27d81dd8556 extends EventTarget {
10926
10953
  $0a6acf31d1eae57c$export$3ccaa27d81dd8556.#reverting_permitted = false; // Disallow any reverting since we can't - it would flash a white page until the reload has finished.
10927
10954
  this.#unload(); // Call unload to "kill" the solid-js stuff quicker so that it stops updating - the user is expecting the next thing that happens to be a navigation to the actual page the URL says they're on.
10928
10955
  }
10929
- };
10956
+ });
10930
10957
 
10931
10958
  (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).add(on_maybe_popstate);
10932
10959
  this.#revert_fns.push(() => (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).delete(on_maybe_popstate)); // Don't run the bugfixer if there isn't a PageReplacer page open since I assume the bug only happens when going back from a PageReplace'd page