@depict-ai/ui 4.7.29 → 4.7.31

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
@@ -1,8 +1,8 @@
1
1
  var $gVhhF$depictaiutilishared = require("@depict-ai/utilishared/latest");
2
- var $gVhhF$depictaiutilisharedlatest = require("@depict-ai/utilishared/latest");
3
- var $gVhhF$solidjs = require("solid-js");
4
2
  var $gVhhF$solidjsweb = require("solid-js/web");
3
+ var $gVhhF$solidjs = require("solid-js");
5
4
  var $gVhhF$solidjsstore = require("solid-js/store");
5
+ var $gVhhF$depictaiutilisharedlatest = require("@depict-ai/utilishared/latest");
6
6
  require("../multi_import_deduplicator.cjs").register_es_version("ui", "latest");
7
7
  function $parcel$export(e, n, v, s) {
8
8
  Object.defineProperty(e, n, {
@@ -12,6 +12,7 @@ function $parcel$export(e, n, v, s) {
12
12
  configurable: true
13
13
  });
14
14
  }
15
+ $parcel$export(module.exports, "remap_blocks_to_index", () => $d92f338ba8f9da9b$export$92aa5d691d588f3f);
15
16
  $parcel$export(module.exports, "useMobileHover", () => $8bf678c45948a297$export$d4d96868197be50e);
16
17
  $parcel$export(module.exports, "useVisibilityState", () => $55cbacb79d3e0cea$export$54299a3c81f5425);
17
18
  $parcel$export(module.exports, "useSlidableInformation", () => $a0e53f99354809d9$export$eaa625fb39439e37);
@@ -104,7 +105,412 @@ $parcel$export(module.exports, "BreadCrumbs", () => $1f4925833f07df29$export$5b7
104
105
  $parcel$export(module.exports, "QuickLinks", () => $1f4925833f07df29$export$de035477d6fef996);
105
106
  $parcel$export(module.exports, "CategoryPage", () => $14f289047713d67a$export$e2bf8ce7779e827e);
106
107
  /*! Depict.ai search and product listing SDK */
107
- const $b757f75811f3261f$export$83d89fbfd8236492 = "4.7.29";
108
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "4.7.31";
109
+ function $b54e6192d0caa293$export$d9f36cf74e24d595(media_query) {
110
+ const signal = $gVhhF$solidjs.createSignal(false);
111
+ $gVhhF$solidjs.onCleanup($gVhhF$depictaiutilishared.javascript_media_query(media_query, ({
112
+ matches: matches
113
+ }) => signal[1](matches)).remove);
114
+ return signal[0];
115
+ }
116
+ function $17d06b3bcb035500$export$a79e666719b3647c(cols_at_size_) {
117
+ const size_active = $gVhhF$solidjs.createMemo(() => cols_at_size_().map(([n_cols, min_width, max_width]) => {
118
+ const media_query = $gVhhF$depictaiutilishared.layout_media_query_header(min_width, max_width).replaceAll("@media", "");
119
+ const matches = $b54e6192d0caa293$export$d9f36cf74e24d595(media_query);
120
+ return [matches, n_cols];
121
+ }));
122
+ const n_cols_currently_showing = $gVhhF$solidjs.createMemo(() => {
123
+ try {
124
+ const [, n_cols_currently_showing] = size_active().find(([media_query]) => media_query());
125
+ return n_cols_currently_showing;
126
+ } catch (e) {
127
+ $gVhhF$depictaiutilishared.dwarn("No active size found in columnsAtSize - can't render content blocks or looks");
128
+ return null;
129
+ }
130
+ });
131
+ return n_cols_currently_showing;
132
+ }
133
+
134
+ // Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
135
+ class $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 extends Error {}
136
+ class $7dd1edb2ee2b43ad$export$aa14a9f43128f61f extends $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 {
137
+ constructor(templateError) {
138
+ super("Uncaught error in product card template", {
139
+ cause: templateError
140
+ });
141
+ }
142
+ }
143
+ var $edafe91daf3091d7$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div><!$><!/><!$><!/>`);
144
+ const $edafe91daf3091d7$var$ExtraInfoContext = /*@__PURE__*/$gVhhF$solidjs.createContext();
145
+ function $edafe91daf3091d7$export$240ecf5363d76c0f(props) {
146
+ return $gVhhF$solidjsweb.createComponent($edafe91daf3091d7$var$ExtraInfoContext.Provider, {
147
+ get value() {
148
+ return props.getContext_;
149
+ },
150
+ get children() {
151
+ return props.children;
152
+ }
153
+ });
154
+ }
155
+ function $edafe91daf3091d7$export$b69d0d92862de18b(props) {
156
+ const getContextFunction = $gVhhF$solidjs.useContext($edafe91daf3091d7$var$ExtraInfoContext);
157
+ return $gVhhF$solidjs.ErrorBoundary({
158
+ fallback(err, retry) {
159
+ const {
160
+ message_: message_,
161
+ severity_: severity_
162
+ } = props;
163
+ let message = message_;
164
+ if (err instanceof (0, $7dd1edb2ee2b43ad$export$aa14a9f43128f61f)) {
165
+ console.error(err.cause);
166
+ message = `${message}: ${err.message}`;
167
+ } else $gVhhF$depictaiutilishared.report([err, message_], severity_, getContextFunction?.());
168
+ return (() => {
169
+ var _el$ = $gVhhF$solidjsweb.getNextElement($edafe91daf3091d7$var$_tmpl$),
170
+ _el$2 = _el$.firstChild,
171
+ [_el$3, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$2.nextSibling),
172
+ _el$4 = _el$3.nextSibling,
173
+ [_el$5, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling);
174
+ $gVhhF$solidjsweb.insert(_el$, message, _el$3, _co$);
175
+ $gVhhF$solidjsweb.insert(_el$, () => props.on_error_?.(retry), _el$5, _co$2);
176
+ $gVhhF$solidjsweb.effect(_$p => $gVhhF$solidjsweb.classList(_el$, Object.fromEntries(props.class_list_?.map(c => [c, true]) || []), _$p));
177
+ return _el$;
178
+ })();
179
+ },
180
+ get children() {
181
+ return props.children;
182
+ }
183
+ });
184
+ }
185
+ var $75777da1687ba3f6$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`),
186
+ $75777da1687ba3f6$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<style type=text/css>`);
187
+ const $75777da1687ba3f6$export$c500183c31c2b22e = "--spans-columns";
188
+ function $75777da1687ba3f6$export$ab6b147eec64fea5(props) {
189
+ const container_class = "x" + $gVhhF$solidjs.createUniqueId();
190
+ const container_element_ = (() => {
191
+ var _el$ = $gVhhF$solidjsweb.getNextElement($75777da1687ba3f6$var$_tmpl$);
192
+ $gVhhF$solidjsweb.spread(_el$, $gVhhF$solidjsweb.mergeProps(() => props.element_attributes, {
193
+ "classList": {
194
+ [container_class]: true
195
+ }
196
+ }), false, true);
197
+ $gVhhF$solidjsweb.insert(_el$, () => props.children);
198
+ $gVhhF$solidjsweb.runHydrationEvents();
199
+ return _el$;
200
+ })(); // Don't want this in the error boundary below, it should only be for the actual layouting
201
+ return $gVhhF$solidjsweb.createComponent((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
202
+ message_: "Failed calculating css grid layout",
203
+ severity_: "error",
204
+ get children() {
205
+ return $75777da1687ba3f6$export$e2f22da34aaf310a(props, container_element_, false, container_class);
206
+ }
207
+ });
208
+ }
209
+ function $75777da1687ba3f6$export$e2f22da34aaf310a(props, container_element, insert_after_container = false, container_class) {
210
+ if (!container_class) {
211
+ // only try to add if it wasn't provided, so that we have a code path without classList when doing SSR
212
+ container_class = $gVhhF$depictaiutilishared.make_random_classname();
213
+ container_element.classList.add(container_class);
214
+ }
215
+ const container_selector = `.depict .${container_class}`; // class so ppl can have id if needed
216
+ const col_styling = $gVhhF$solidjs.createMemo(() => $75777da1687ba3f6$var$generate_media_queried_declarations({
217
+ container_selector_: container_selector,
218
+ default_grid_spacing_text: props.grid_spacing,
219
+ cols_at_size_: props.cols_at_size,
220
+ override_vertical_spacing_: props.override_vertical_spacing,
221
+ top_row_shortened_by_: props.top_row_shortened_by_()
222
+ }));
223
+ const base_styling = $gVhhF$solidjs.createMemo(() => {
224
+ return `${container_selector}{display:grid;}`;
225
+ });
226
+ const get_styling = $gVhhF$solidjs.createMemo(() => base_styling() + col_styling());
227
+ const style_element = (() => {
228
+ var _el$2 = $gVhhF$solidjsweb.getNextElement($75777da1687ba3f6$var$_tmpl$2);
229
+ $gVhhF$solidjsweb.insert(_el$2, get_styling);
230
+ return _el$2;
231
+ })(); // need to create this after set_styling has been called or else there will be no styling in the SSR'd output
232
+ if (insert_after_container) container_element.after(style_element);
233
+ return [container_element, style_element];
234
+ }
235
+ function $75777da1687ba3f6$var$generate_media_queried_declarations({
236
+ container_selector_: container_selector_,
237
+ default_grid_spacing_text: default_grid_spacing_text,
238
+ cols_at_size_: cols_at_size_,
239
+ override_vertical_spacing_: override_vertical_spacing_,
240
+ top_row_shortened_by_: top_row_shortened_by_
241
+ }) {
242
+ return cols_at_size_.map(options => {
243
+ const [n_cols, min, max, grid_spacing_for_size] = options;
244
+ const main_spacing_to_use = grid_spacing_for_size || default_grid_spacing_text;
245
+ // See comment in else block below
246
+ const can_use_gap = override_vertical_spacing_ ? $75777da1687ba3f6$var$can_use_gap_for_unit(override_vertical_spacing_) : $75777da1687ba3f6$var$can_use_gap_for_unit(main_spacing_to_use);
247
+ let spacing_styling;
248
+ let additional_styling = ""; // outside the media query
249
+ if (can_use_gap) spacing_styling = `gap:${main_spacing_to_use};${override_vertical_spacing_ ? `row-gap:${override_vertical_spacing_};` : ``}`;else {
250
+ // When using percent units, which our default styling does (because convenient) and our interface relies on (hard to specify different gaps for different screen sizes)
251
+ // row gaps in grids are relative to the whole height of the grid, maybe see also https://stackoverflow.com/a/53563865. The issue with that is that as we load more products, the gap grows. Also, it breaks existing integrations.
252
+ // Logical thought: use margins for the vertical spacing. But margins in grids are apparently relative to the size of the individual items in grids.
253
+ // Given that, and that content blocks can be of different width, we have to do some complicated calculations to convert the provided gap, which is in gap of the total container width, to a margin of the individual items.
254
+ const vertical_spacing_to_use = override_vertical_spacing_ ?? main_spacing_to_use;
255
+ const width_multiplier = `var(${$75777da1687ba3f6$export$c500183c31c2b22e}, 1)`; // How many cards wide the current item is (needed because content blocks)
256
+ const one_item_width_exclusing_gaps = `calc(calc(100 / ${n_cols}) - calc(calc(${n_cols * 2 - 2} * calc(${$75777da1687ba3f6$var$strip_percent_unit(vertical_spacing_to_use)} / 2)) / ${n_cols}))`; // Width of one item in percent of the whole
257
+ // Equation from layout.tsx, also used in CheckboxGrid. Needs half spacing for some reason
258
+ const this_item_width_meat = `calc(${one_item_width_exclusing_gaps} * ${width_multiplier})`; // Width of just the card
259
+ const this_item_width_gaps = `calc(calc(${width_multiplier} - 1) * ${$75777da1687ba3f6$var$strip_percent_unit(vertical_spacing_to_use)})`; // Width of the gaps
260
+ const this_item_width = `calc(${this_item_width_meat} + ${this_item_width_gaps})`; // Width of this item including gaps
261
+ // this_item_width needs to be unitless, and since plain css can't do calc(40% / 5%) which would become unitless we need to strip all units in the calculations before
262
+ const convert_top_spacing_to_item_width_percentage = spacing => `calc(calc(100 / ${this_item_width}) * ${spacing})`; // Now finally we can convert the desired spacing to a percentage of this individual item's width (including gaps that would be there but aren't because content blocks span them)
263
+ spacing_styling = `column-gap:${main_spacing_to_use};`; // Still use gaps in the horizontal direction because that works flawlessly
264
+ // Re-use old layout code to get the correct :nth-child declarations for the top margins
265
+ additional_styling = $gVhhF$depictaiutilishared.n_col_styling_with_dist(container_selector_ + ">", convert_top_spacing_to_item_width_percentage(default_grid_spacing_text), [[n_cols, min, max, grid_spacing_for_size ? convert_top_spacing_to_item_width_percentage(grid_spacing_for_size) : null]], "grid", override_vertical_spacing_ ? convert_top_spacing_to_item_width_percentage(override_vertical_spacing_) : override_vertical_spacing_, top_row_shortened_by_);
266
+ }
267
+ const media_query_body = `${container_selector_}{${spacing_styling}grid-template-columns:repeat(${n_cols},minmax(0,1fr));}`;
268
+ return `${$gVhhF$depictaiutilishared.layout_media_query_header(min, max)}{${media_query_body}}${additional_styling}`;
269
+ }).join("");
270
+ }
271
+ function $75777da1687ba3f6$var$can_use_gap_for_unit(spacing) {
272
+ const trimmed_spacing = spacing.trim();
273
+ return !trimmed_spacing.includes("%");
274
+ }
275
+ function $75777da1687ba3f6$var$strip_percent_unit(css_value) {
276
+ return css_value.replaceAll("%", "");
277
+ }
278
+ var $9fe9883b1d8ecccc$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span>`);
279
+ function $9fe9883b1d8ecccc$export$acb3eaade4b23afd(props) {
280
+ // Work around https://github.com/solidjs/solid/issues/1980
281
+ return (() => {
282
+ var _el$ = $gVhhF$solidjsweb.getNextElement($9fe9883b1d8ecccc$var$_tmpl$);
283
+ $gVhhF$solidjsweb.effect(_p$ => {
284
+ var _v$ = `${props.class || ""} depict-placeholder`,
285
+ _v$2 = props.style;
286
+ _v$ !== _p$.e && $gVhhF$solidjsweb.className(_el$, _p$.e = _v$);
287
+ _p$.t = $gVhhF$solidjsweb.style(_el$, _v$2, _p$.t);
288
+ return _p$;
289
+ }, {
290
+ e: undefined,
291
+ t: undefined
292
+ });
293
+ return _el$;
294
+ })();
295
+ }
296
+ function $3bc4a89b971a3af5$export$3f37af283f8fb843(props) {
297
+ const style = $gVhhF$solidjs.createMemo(() => {
298
+ const {
299
+ style: style,
300
+ height: height,
301
+ width: width,
302
+ aspectRatio: aspectRatio
303
+ } = props;
304
+ const is_image = aspectRatio != undefined;
305
+ const size_data = is_image ? {
306
+ width: "100%",
307
+ "padding-bottom": `calc(calc(1 / ${aspectRatio}) * 100%)`
308
+ } : {
309
+ width: width,
310
+ height: height
311
+ };
312
+ return {
313
+ display: "block",
314
+ ...(style || {}),
315
+ ...size_data
316
+ };
317
+ });
318
+ return $gVhhF$solidjsweb.createComponent((0, $9fe9883b1d8ecccc$export$acb3eaade4b23afd), {
319
+ get style() {
320
+ return style();
321
+ },
322
+ get ["class"]() {
323
+ return props.class;
324
+ }
325
+ });
326
+ }
327
+ var $d92f338ba8f9da9b$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=content-block-wrapper>`);
328
+ function $d92f338ba8f9da9b$export$791ef57e62e21c3f({
329
+ content_blocks_: incoming_content_blocks,
330
+ cols_at_size_: cols_at_size_,
331
+ set_top_row_shortened_by_: set_top_row_shortened_by_
332
+ }) {
333
+ // these are by row
334
+ const [content_blocks, set_content_blocks] = $gVhhF$solidjsstore.createStore([]);
335
+ const n_cols_currently_showing_ = $17d06b3bcb035500$export$a79e666719b3647c(cols_at_size_);
336
+ $gVhhF$solidjs.createEffect(() => {
337
+ const incoming_value = incoming_content_blocks();
338
+ if (!incoming_value) {
339
+ set_content_blocks([]);
340
+ return;
341
+ }
342
+ set_content_blocks($gVhhF$solidjsstore.reconcile(incoming_value, {
343
+ key: "content"
344
+ })); // key: Make moving blocks faster, see https://github.com/solidjs/solid/issues/1925#issuecomment-1769671596
345
+ });
346
+
347
+ const get_wrapped_blocks_ = $d92f338ba8f9da9b$var$wrap_blocks_in_div(content_blocks, n_cols_currently_showing_);
348
+ $gVhhF$solidjs.createComputed(() => {
349
+ // Update our styling if a content block forces some items that should be in the top row into a lower one, so we can generate margin-top declarations for them
350
+ const top_row_block = get_wrapped_blocks_()[0];
351
+ const blocks_in_top_row_taken = top_row_block?.span_columns;
352
+ if (blocks_in_top_row_taken == undefined) {
353
+ // Fall back to zero if no content block in top row, since then no blocks in top row are taken
354
+ set_top_row_shortened_by_(0);
355
+ return;
356
+ }
357
+ set_top_row_shortened_by_(blocks_in_top_row_taken - 1); // minus one because the content block wrapper also is an element
358
+ });
359
+
360
+ return $gVhhF$solidjs.createMemo(() => $d92f338ba8f9da9b$export$92aa5d691d588f3f({
361
+ wrapped_blocks_: get_wrapped_blocks_(),
362
+ n_cols_currently_showing_: n_cols_currently_showing_()
363
+ }).content_blocks_by_index_);
364
+ }
365
+ function $d92f338ba8f9da9b$export$92aa5d691d588f3f({
366
+ wrapped_blocks_: wrapped_blocks_,
367
+ n_cols_currently_showing_: n_cols_currently_showing_
368
+ }) {
369
+ // This computation should be quite cheap since it just moves around things into an array
370
+ const content_blocks_by_index_ = [];
371
+ const constructed_block_arrays = new WeakSet();
372
+ // Need to keep track of products displaced by blocks above when mapping rows to indexes in the actual grid
373
+ const displaced_products_ = []; // undefined = is product, true = is content block if number instead of tuple number indicates content blocks in that row. Index in first array is row, index in second array is column
374
+ if (!n_cols_currently_showing_)
375
+ // Nope out of here if we don't know how many columns are showing
376
+ return {
377
+ content_blocks_by_index_: content_blocks_by_index_
378
+ };
379
+ for (let i = 0; i < wrapped_blocks_.length; i++) {
380
+ // i = row to show at
381
+ const block = wrapped_blocks_[i];
382
+ if (!block) continue; // Array can have holes/not defined places
383
+ const index_of_first_item_in_row = i * n_cols_currently_showing_;
384
+ const index_of_last_item_in_row = index_of_first_item_in_row + n_cols_currently_showing_;
385
+ const {
386
+ span_rows: span_rows,
387
+ position: position,
388
+ span_columns: span_columns
389
+ } = block; // span columns is already capped in the block wrapping step (wrap_blocks_in_div)
390
+ let target_index;
391
+ if (position === "left") target_index = index_of_first_item_in_row;else if (position === "right") target_index = index_of_last_item_in_row - span_columns;else if (position === "center") target_index = index_of_first_item_in_row + Math.floor((n_cols_currently_showing_ - span_columns) / 2);else throw new Error("Invalid position for content block - must be left, right or center: " + JSON.stringify(position));
392
+ // Calculate displacement of us by content blocks above us
393
+ let displacement_by_added_blocks = 0;
394
+ for (let j = 0; j < i; j++) {
395
+ const row = displaced_products_[j];
396
+ if (row === undefined) continue; // there were no blocks in this row
397
+ let displaced_items_in_row;
398
+ if (typeof row === "number") displaced_items_in_row = row;else {
399
+ displaced_items_in_row = row.filter(item => item).length;
400
+ displaced_products_[j] = displaced_items_in_row;
401
+ }
402
+ displacement_by_added_blocks += displaced_items_in_row;
403
+ }
404
+ const index_of_us_in_row = target_index - index_of_first_item_in_row;
405
+ for (let j = 0; j < index_of_us_in_row; j++) if (displaced_products_[i]?.[j])
406
+ // Add blocks in our *current* row to the displacement, but only the ones to our left
407
+ displacement_by_added_blocks++;
408
+ // Add block to output array at the correct index
409
+ const final_target_index = target_index - displacement_by_added_blocks;
410
+ const existing_block = content_blocks_by_index_[final_target_index];
411
+ const block_content = block.content;
412
+ // If two blocks want to exist at the same location (can happen, for example if one block wants to be at the end of a row and the other one at the start of the next row) add an array with both
413
+ if (existing_block) {
414
+ if (constructed_block_arrays.has(existing_block))
415
+ // Only push to arrays we have created to not create funky bugs when there's an array in JSX.Element
416
+ existing_block.push(block_content);else {
417
+ const array = [existing_block, block_content];
418
+ constructed_block_arrays.add(array);
419
+ content_blocks_by_index_[final_target_index] = array;
420
+ }
421
+ } else content_blocks_by_index_[final_target_index] = block_content;
422
+ // Update displacement
423
+ for (let j = 0; j < span_rows; j++) {
424
+ const row = displaced_products_[i + j] ||= [];
425
+ for (let k = index_of_us_in_row; k < index_of_us_in_row + span_columns; k++) row[k] = true;
426
+ }
427
+ }
428
+ return {
429
+ content_blocks_by_index_: content_blocks_by_index_,
430
+ displaced_products_: displaced_products_
431
+ };
432
+ }
433
+ /**
434
+ * Takes a store that contains an array from where index is number of row and value is the result of executing the content block rendering function.
435
+ * Then renders the content and wraps it into a div with the correct styling.
436
+ * Also caps span_columns to max available columns
437
+ */
438
+ function $d92f338ba8f9da9b$var$wrap_blocks_in_div(rendered_content_blocks, max_span_columns) {
439
+ const get_wrapped_blocks = $gVhhF$solidjs.mapArray(() => rendered_content_blocks, block => {
440
+ if (!block) return;
441
+ const final_span_columns = $gVhhF$solidjs.createMemo(() => Math.min(block.span_columns, max_span_columns() ?? Infinity));
442
+ // If the item spans an entire row, limit the height to 1 row since there's no concept of "rows" if there are no products beside the block
443
+ const final_span_rows = $gVhhF$solidjs.createMemo(() => final_span_columns() === max_span_columns() ? 1 : block.span_rows);
444
+ const [rendering_delayed, set_rendering_delayed_] = $gVhhF$solidjs.createSignal(true);
445
+ const content = $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
446
+ get when() {
447
+ return !rendering_delayed();
448
+ },
449
+ get children() {
450
+ var _el$ = $gVhhF$solidjsweb.getNextElement($d92f338ba8f9da9b$var$_tmpl$);
451
+ $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent($d92f338ba8f9da9b$var$RenderContent, {
452
+ get content() {
453
+ return block.content;
454
+ }
455
+ }));
456
+ $gVhhF$solidjsweb.effect(_p$ => {
457
+ var _v$ = {
458
+ [(0, $75777da1687ba3f6$export$c500183c31c2b22e)]: final_span_columns()
459
+ },
460
+ _v$2 = `span ${final_span_columns()}`,
461
+ _v$3 = `span ${final_span_rows()}`;
462
+ _p$.e = $gVhhF$solidjsweb.style(_el$, _v$, _p$.e);
463
+ _v$2 !== _p$.t && ((_p$.t = _v$2) != null ? _el$.style.setProperty("grid-column", _v$2) : _el$.style.removeProperty("grid-column"));
464
+ _v$3 !== _p$.a && ((_p$.a = _v$3) != null ? _el$.style.setProperty("grid-row", _v$3) : _el$.style.removeProperty("grid-row"));
465
+ return _p$;
466
+ }, {
467
+ e: undefined,
468
+ t: undefined,
469
+ a: undefined
470
+ });
471
+ return _el$;
472
+ }
473
+ });
474
+ return $gVhhF$solidjs.mergeProps(block, {
475
+ // Create content divs for the blocks with as much fine-grained diffing as possible?
476
+ content: () => {
477
+ // Sneaky on-demand rendering, so we don't render more blocks than we can show: we have the rendered value here and don't return a function that renders because if our block would be moved around we'd be guaranteed to re-render
478
+ // However, no need to count products to know if we should render: the <For> loops in Placeholders and render_displays will only call this function if there's actually a product here that wants to display this block
479
+ set_rendering_delayed_(false);
480
+ return content;
481
+ },
482
+ get span_columns() {
483
+ // Cap max width of block to the number of columns available, for everyone downstream
484
+ return final_span_columns();
485
+ },
486
+ get span_rows() {
487
+ return final_span_rows();
488
+ }
489
+ });
490
+ });
491
+ return get_wrapped_blocks;
492
+ }
493
+ /**
494
+ * Basically adds support for async content block functions and shows a rudimentary placeholder if rendering is delayed. Required due to react having a rendering delay.
495
+ */
496
+ function $d92f338ba8f9da9b$var$RenderContent(props) {
497
+ const [resource] = $gVhhF$solidjs.createResource(() => props.content,
498
+ // Could be reactive
499
+ fn => fn());
500
+ $gVhhF$solidjs.createEffect(() => {
501
+ if (resource.error) console.error("Error in content block rendering", resource.error);
502
+ });
503
+ // The suspense is for when there's an async content block (which we have to support due to react having a rendering delay) so that we can show some height while it's loading (should kinda never be visible)
504
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
505
+ get fallback() {
506
+ return $gVhhF$solidjsweb.createComponent((0, $3bc4a89b971a3af5$export$3f37af283f8fb843), {
507
+ width: "100%",
508
+ height: "max(100%, 400px)"
509
+ });
510
+ },
511
+ children: resource
512
+ });
513
+ }
108
514
  let $8bf678c45948a297$var$elementsHoveredSignal;
109
515
  let $8bf678c45948a297$var$consumersSignal;
110
516
  function $8bf678c45948a297$export$d4d96868197be50e() {
@@ -743,76 +1149,25 @@ function $0caf87eaa19079da$var$Placeholder({
743
1149
  dispose_original_copy();
744
1150
  $0caf87eaa19079da$var$renderingCachedPlaceholderElement[placeholderCacheKey_] = undefined;
745
1151
  };
746
- rendering?.then(unset_current_rendering, unset_current_rendering);
747
- } else
748
- // Otherwise, just make sure we've disposed our root
749
- dispose_original_copy();
750
- });
751
- return $gVhhF$solidjs.createMemo(() => {
752
- const unwrapped_array = get_unwrapped_element()();
753
- if (!unwrapped_array?.length || !unwrapped_array.every(item => item))
754
- // Haven't finished rendering yet in case of "async" rendering, so don't freeze the elements yet
755
- return;
756
- // placeholders have finished rendering, freeze the elements
757
- // here we might receive the result of a promise that has already been received, tore down and put into cached_placeholder_element, so don't overwrite that more valid result if it's already set
758
- $0caf87eaa19079da$var$cachedPlaceholderElements[placeholderCacheKey_] ||= get_cloned_placeholders(unwrapped_array); // Clone initial return value so that who gave us the elements can't mutate them, which has caused issues before with react
759
- $0caf87eaa19079da$var$renderingCachedPlaceholderElement[placeholderCacheKey_] = undefined;
760
- dispose_original_copy(); // So that this memo will never re-run and the placeholder rendering function can clean up
761
- return get_cloned_placeholders(); // clone, just in case. If we wouldn't, someone could modify the copy in the DOM, and it would affect the cached version
762
- });
763
- }
764
-
765
- // Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
766
- class $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 extends Error {}
767
- class $7dd1edb2ee2b43ad$export$aa14a9f43128f61f extends $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 {
768
- constructor(templateError) {
769
- super("Uncaught error in product card template", {
770
- cause: templateError
771
- });
772
- }
773
- }
774
- var $edafe91daf3091d7$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div><!$><!/><!$><!/>`);
775
- const $edafe91daf3091d7$var$ExtraInfoContext = /*@__PURE__*/$gVhhF$solidjs.createContext();
776
- function $edafe91daf3091d7$export$240ecf5363d76c0f(props) {
777
- return $gVhhF$solidjsweb.createComponent($edafe91daf3091d7$var$ExtraInfoContext.Provider, {
778
- get value() {
779
- return props.getContext_;
780
- },
781
- get children() {
782
- return props.children;
783
- }
1152
+ rendering?.then(unset_current_rendering, unset_current_rendering);
1153
+ } else
1154
+ // Otherwise, just make sure we've disposed our root
1155
+ dispose_original_copy();
784
1156
  });
785
- }
786
- function $edafe91daf3091d7$export$b69d0d92862de18b(props) {
787
- const getContextFunction = $gVhhF$solidjs.useContext($edafe91daf3091d7$var$ExtraInfoContext);
788
- return $gVhhF$solidjs.ErrorBoundary({
789
- fallback(err, retry) {
790
- const {
791
- message_: message_,
792
- severity_: severity_
793
- } = props;
794
- let message = message_;
795
- if (err instanceof (0, $7dd1edb2ee2b43ad$export$aa14a9f43128f61f)) {
796
- console.error(err.cause);
797
- message = `${message}: ${err.message}`;
798
- } else $gVhhF$depictaiutilishared.report([err, message_], severity_, getContextFunction?.());
799
- return (() => {
800
- var _el$ = $gVhhF$solidjsweb.getNextElement($edafe91daf3091d7$var$_tmpl$),
801
- _el$2 = _el$.firstChild,
802
- [_el$3, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$2.nextSibling),
803
- _el$4 = _el$3.nextSibling,
804
- [_el$5, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling);
805
- $gVhhF$solidjsweb.insert(_el$, message, _el$3, _co$);
806
- $gVhhF$solidjsweb.insert(_el$, () => props.on_error_?.(retry), _el$5, _co$2);
807
- $gVhhF$solidjsweb.effect(_$p => $gVhhF$solidjsweb.classList(_el$, Object.fromEntries(props.class_list_?.map(c => [c, true]) || []), _$p));
808
- return _el$;
809
- })();
810
- },
811
- get children() {
812
- return props.children;
813
- }
1157
+ return $gVhhF$solidjs.createMemo(() => {
1158
+ const unwrapped_array = get_unwrapped_element()();
1159
+ if (!unwrapped_array?.length || !unwrapped_array.every(item => item))
1160
+ // Haven't finished rendering yet in case of "async" rendering, so don't freeze the elements yet
1161
+ return;
1162
+ // placeholders have finished rendering, freeze the elements
1163
+ // here we might receive the result of a promise that has already been received, tore down and put into cached_placeholder_element, so don't overwrite that more valid result if it's already set
1164
+ $0caf87eaa19079da$var$cachedPlaceholderElements[placeholderCacheKey_] ||= get_cloned_placeholders(unwrapped_array); // Clone initial return value so that who gave us the elements can't mutate them, which has caused issues before with react
1165
+ $0caf87eaa19079da$var$renderingCachedPlaceholderElement[placeholderCacheKey_] = undefined;
1166
+ dispose_original_copy(); // So that this memo will never re-run and the placeholder rendering function can clean up
1167
+ return get_cloned_placeholders(); // clone, just in case. If we wouldn't, someone could modify the copy in the DOM, and it would affect the cached version
814
1168
  });
815
1169
  }
1170
+
816
1171
  var $f48d0fbb00835aaa$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`),
817
1172
  $f48d0fbb00835aaa$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<style type=text/css>`);
818
1173
  function $f48d0fbb00835aaa$export$d21e32dfedac04be(props) {
@@ -1072,62 +1427,6 @@ function $84798aaa863a4909$export$e68cff63f76bd15b(props) {
1072
1427
  function $84798aaa863a4909$export$8d0c4fdbb05a2f2e() {
1073
1428
  return $gVhhF$solidjs.useContext($84798aaa863a4909$var$ListingContext);
1074
1429
  }
1075
- var $9fe9883b1d8ecccc$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span>`);
1076
- function $9fe9883b1d8ecccc$export$acb3eaade4b23afd(props) {
1077
- // Work around https://github.com/solidjs/solid/issues/1980
1078
- return (() => {
1079
- var _el$ = $gVhhF$solidjsweb.getNextElement($9fe9883b1d8ecccc$var$_tmpl$);
1080
- $gVhhF$solidjsweb.effect(_p$ => {
1081
- var _v$ = `${props.class || ""} depict-placeholder`,
1082
- _v$2 = props.style;
1083
- _v$ !== _p$.e && $gVhhF$solidjsweb.className(_el$, _p$.e = _v$);
1084
- _p$.t = $gVhhF$solidjsweb.style(_el$, _v$2, _p$.t);
1085
- return _p$;
1086
- }, {
1087
- e: undefined,
1088
- t: undefined
1089
- });
1090
- return _el$;
1091
- })();
1092
- }
1093
- function $3bc4a89b971a3af5$export$3f37af283f8fb843(props) {
1094
- const style = $gVhhF$solidjs.createMemo(() => {
1095
- const {
1096
- style: style,
1097
- height: height,
1098
- width: width,
1099
- aspectRatio: aspectRatio
1100
- } = props;
1101
- const is_image = aspectRatio != undefined;
1102
- const size_data = is_image ? {
1103
- width: "100%",
1104
- "padding-bottom": `calc(calc(1 / ${aspectRatio}) * 100%)`
1105
- } : {
1106
- width: width,
1107
- height: height
1108
- };
1109
- return {
1110
- display: "block",
1111
- ...(style || {}),
1112
- ...size_data
1113
- };
1114
- });
1115
- return $gVhhF$solidjsweb.createComponent((0, $9fe9883b1d8ecccc$export$acb3eaade4b23afd), {
1116
- get style() {
1117
- return style();
1118
- },
1119
- get ["class"]() {
1120
- return props.class;
1121
- }
1122
- });
1123
- }
1124
- function $b54e6192d0caa293$export$d9f36cf74e24d595(media_query) {
1125
- const signal = $gVhhF$solidjs.createSignal(false);
1126
- $gVhhF$solidjs.onCleanup($gVhhF$depictaiutilishared.javascript_media_query(media_query, ({
1127
- matches: matches
1128
- }) => signal[1](matches)).remove);
1129
- return signal[0];
1130
- }
1131
1430
  function $061ff5b4c3d36171$export$89c6019e4baa40b1(props) {
1132
1431
  const style = $gVhhF$solidjs.createMemo(() => {
1133
1432
  const {
@@ -1958,7 +2257,7 @@ function $bda357ff87c46163$export$44809a8a3e867e30({
1958
2257
  [_el$3, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$2.nextSibling),
1959
2258
  _el$4 = _el$3.nextSibling,
1960
2259
  [_el$5, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling);
1961
- $gVhhF$solidjsweb.addEventListener(_el$, "click", $gVhhF$depictaiutilishared.catchify(() => setUserWantsExpanded(prev => display_() ? !prev : false)), true);
2260
+ $gVhhF$solidjsweb.addEventListener(_el$, "click", $gVhhF$depictaiutilishared.catchify(() => display_() && setUserWantsExpanded(prev => !prev)), true);
1962
2261
  $gVhhF$solidjsweb.use(el => {
1963
2262
  container = el;
1964
2263
  const ro = new ResizeObserver($gVhhF$depictaiutilishared.catchify(records => {
@@ -9930,7 +10229,8 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
9930
10229
  breadcrumbs: [],
9931
10230
  quick_links: [],
9932
10231
  image_urls: [],
9933
- failed: true
10232
+ failed: true,
10233
+ content_blocks: []
9934
10234
  }),
9935
10235
  method_: "GET"
9936
10236
  });
@@ -10944,171 +11244,78 @@ function $4117463e2939f5f4$export$63dd0350f8559dda({
10944
11244
  const last = get_last_result_in_viewport_();
10945
11245
  // Check if we are past the last result, in that case we want it to count as 100% for a better infinite scroll experience
10946
11246
  past_last_result_check: {
10947
- const elements_of_last_result = index_to_target_map_.get(index_to_target_map_.size - 1);
10948
- if (elements_of_last_result) {
10949
- if ($gVhhF$solidjs.untrack(is_loading_)) {
10950
- // We're loading, wait check again after we have inserted our new results
10951
- get_has_rendered_toggle();
10952
- break past_last_result_check;
10953
- }
10954
- for (const element of elements_of_last_result) {
10955
- if (document.documentElement.contains(element) && element.getBoundingClientRect().top <= 0)
10956
- // dlog(element, "which is of last product card is in or above viewport, probably loading more");
10957
- return 100;
10958
- }
10959
- }
10960
- }
10961
- if (isNaN(last)) return 0;
10962
- if (Math.abs(last) === Infinity)
10963
- // No product card in view and not after last card, assume first card
10964
- return 0;
10965
- return last / displays_by_key_().size * 100;
10966
- }, undefined, {
10967
- equals: false
10968
- });
10969
- }
10970
- function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
10971
- plp_results_: plp_results_,
10972
- product_card_template_: product_card_template_,
10973
- first_result_in_viewport_: [, setFirstResultInViewport],
10974
- last_result_in_viewport_: [lastResultInViewport, setLastResultsInViewport],
10975
- all_products_loaded_: all_products_loaded_,
10976
- min_products_to_fetch_: min_products_to_fetch_,
10977
- query_base_: query_base_,
10978
- depict_api_: depict_api_,
10979
- is_loading_: is_loading_,
10980
- content_blocks_: content_blocks_
10981
- }) {
10982
- // Although typing doesn't reflect it, plp_results is guaranteed to contain an array of at least one display at this point
10983
- const [get_extra_displays, set_extra_displays_] = $gVhhF$solidjs.createSignal([], {
10984
- equals: false
10985
- });
10986
- const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => [...(plp_results_()?.displays || []), ...get_extra_displays()]));
10987
- const {
10988
- indexToTargetMap_: indexToTargetMap_,
10989
- renderedDisplays_: renderedDisplays_,
10990
- currentlyIntersecting: currentlyIntersecting
10991
- } = $67155e1aeb7073f6$export$4a14175d33d81a96({
10992
- displays_by_key_: displays_by_key_,
10993
- product_card_template_: product_card_template_,
10994
- content_blocks_: content_blocks_,
10995
- alwaysObserveCards_: true
10996
- });
10997
- const percentage_in_view_ = $4117463e2939f5f4$export$63dd0350f8559dda({
10998
- get_last_result_in_viewport_: lastResultInViewport,
10999
- displays_by_key_: displays_by_key_,
11000
- index_to_target_map_: indexToTargetMap_,
11001
- is_loading_: is_loading_,
11002
- get_extra_displays: get_extra_displays
11003
- });
11004
- $3f08fe2992a2a8ca$export$5e4aed86c12acdd9({
11005
- percentage_in_view_: percentage_in_view_,
11006
- set_extra_displays_: set_extra_displays_,
11007
- all_products_loaded_: all_products_loaded_,
11008
- plp_results_: plp_results_,
11009
- min_products_to_fetch_: min_products_to_fetch_,
11010
- query_base_: query_base_,
11011
- depict_api_: depict_api_
11012
- });
11013
- $gVhhF$solidjs.createEffect(() => {
11014
- const intersecting = currentlyIntersecting();
11015
- setFirstResultInViewport(Math.min(...intersecting) + 1); // +1 because we want to start counting at 1
11016
- setLastResultsInViewport(Math.max(...intersecting) + 1);
11017
- });
11018
- return renderedDisplays_;
11019
- }
11020
- var $75777da1687ba3f6$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`),
11021
- $75777da1687ba3f6$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<style type=text/css>`);
11022
- const $75777da1687ba3f6$export$c500183c31c2b22e = "--spans-columns";
11023
- function $75777da1687ba3f6$export$ab6b147eec64fea5(props) {
11024
- const container_class = "x" + $gVhhF$solidjs.createUniqueId();
11025
- const container_element_ = (() => {
11026
- var _el$ = $gVhhF$solidjsweb.getNextElement($75777da1687ba3f6$var$_tmpl$);
11027
- $gVhhF$solidjsweb.spread(_el$, $gVhhF$solidjsweb.mergeProps(() => props.element_attributes, {
11028
- "classList": {
11029
- [container_class]: true
11030
- }
11031
- }), false, true);
11032
- $gVhhF$solidjsweb.insert(_el$, () => props.children);
11033
- $gVhhF$solidjsweb.runHydrationEvents();
11034
- return _el$;
11035
- })(); // Don't want this in the error boundary below, it should only be for the actual layouting
11036
- return $gVhhF$solidjsweb.createComponent((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
11037
- message_: "Failed calculating css grid layout",
11038
- severity_: "error",
11039
- get children() {
11040
- return $75777da1687ba3f6$export$e2f22da34aaf310a(props, container_element_, false, container_class);
11041
- }
11042
- });
11043
- }
11044
- function $75777da1687ba3f6$export$e2f22da34aaf310a(props, container_element, insert_after_container = false, container_class) {
11045
- if (!container_class) {
11046
- // only try to add if it wasn't provided, so that we have a code path without classList when doing SSR
11047
- container_class = $gVhhF$depictaiutilishared.make_random_classname();
11048
- container_element.classList.add(container_class);
11049
- }
11050
- const container_selector = `.depict .${container_class}`; // class so ppl can have id if needed
11051
- const col_styling = $gVhhF$solidjs.createMemo(() => $75777da1687ba3f6$var$generate_media_queried_declarations({
11052
- container_selector_: container_selector,
11053
- default_grid_spacing_text: props.grid_spacing,
11054
- cols_at_size_: props.cols_at_size,
11055
- override_vertical_spacing_: props.override_vertical_spacing,
11056
- top_row_shortened_by_: props.top_row_shortened_by_()
11057
- }));
11058
- const base_styling = $gVhhF$solidjs.createMemo(() => {
11059
- return `${container_selector}{display:grid;}`;
11060
- });
11061
- const get_styling = $gVhhF$solidjs.createMemo(() => base_styling() + col_styling());
11062
- const style_element = (() => {
11063
- var _el$2 = $gVhhF$solidjsweb.getNextElement($75777da1687ba3f6$var$_tmpl$2);
11064
- $gVhhF$solidjsweb.insert(_el$2, get_styling);
11065
- return _el$2;
11066
- })(); // need to create this after set_styling has been called or else there will be no styling in the SSR'd output
11067
- if (insert_after_container) container_element.after(style_element);
11068
- return [container_element, style_element];
11069
- }
11070
- function $75777da1687ba3f6$var$generate_media_queried_declarations({
11071
- container_selector_: container_selector_,
11072
- default_grid_spacing_text: default_grid_spacing_text,
11073
- cols_at_size_: cols_at_size_,
11074
- override_vertical_spacing_: override_vertical_spacing_,
11075
- top_row_shortened_by_: top_row_shortened_by_
11076
- }) {
11077
- return cols_at_size_.map(options => {
11078
- const [n_cols, min, max, grid_spacing_for_size] = options;
11079
- const main_spacing_to_use = grid_spacing_for_size || default_grid_spacing_text;
11080
- // See comment in else block below
11081
- const can_use_gap = override_vertical_spacing_ ? $75777da1687ba3f6$var$can_use_gap_for_unit(override_vertical_spacing_) : $75777da1687ba3f6$var$can_use_gap_for_unit(main_spacing_to_use);
11082
- let spacing_styling;
11083
- let additional_styling = ""; // outside the media query
11084
- if (can_use_gap) spacing_styling = `gap:${main_spacing_to_use};${override_vertical_spacing_ ? `row-gap:${override_vertical_spacing_};` : ``}`;else {
11085
- // When using percent units, which our default styling does (because convenient) and our interface relies on (hard to specify different gaps for different screen sizes)
11086
- // row gaps in grids are relative to the whole height of the grid, maybe see also https://stackoverflow.com/a/53563865. The issue with that is that as we load more products, the gap grows. Also, it breaks existing integrations.
11087
- // Logical thought: use margins for the vertical spacing. But margins in grids are apparently relative to the size of the individual items in grids.
11088
- // Given that, and that content blocks can be of different width, we have to do some complicated calculations to convert the provided gap, which is in gap of the total container width, to a margin of the individual items.
11089
- const vertical_spacing_to_use = override_vertical_spacing_ ?? main_spacing_to_use;
11090
- const width_multiplier = `var(${$75777da1687ba3f6$export$c500183c31c2b22e}, 1)`; // How many cards wide the current item is (needed because content blocks)
11091
- const one_item_width_exclusing_gaps = `calc(calc(100 / ${n_cols}) - calc(calc(${n_cols * 2 - 2} * calc(${$75777da1687ba3f6$var$strip_percent_unit(vertical_spacing_to_use)} / 2)) / ${n_cols}))`; // Width of one item in percent of the whole
11092
- // Equation from layout.tsx, also used in CheckboxGrid. Needs half spacing for some reason
11093
- const this_item_width_meat = `calc(${one_item_width_exclusing_gaps} * ${width_multiplier})`; // Width of just the card
11094
- const this_item_width_gaps = `calc(calc(${width_multiplier} - 1) * ${$75777da1687ba3f6$var$strip_percent_unit(vertical_spacing_to_use)})`; // Width of the gaps
11095
- const this_item_width = `calc(${this_item_width_meat} + ${this_item_width_gaps})`; // Width of this item including gaps
11096
- // this_item_width needs to be unitless, and since plain css can't do calc(40% / 5%) which would become unitless we need to strip all units in the calculations before
11097
- const convert_top_spacing_to_item_width_percentage = spacing => `calc(calc(100 / ${this_item_width}) * ${spacing})`; // Now finally we can convert the desired spacing to a percentage of this individual item's width (including gaps that would be there but aren't because content blocks span them)
11098
- spacing_styling = `column-gap:${main_spacing_to_use};`; // Still use gaps in the horizontal direction because that works flawlessly
11099
- // Re-use old layout code to get the correct :nth-child declarations for the top margins
11100
- additional_styling = $gVhhF$depictaiutilishared.n_col_styling_with_dist(container_selector_ + ">", convert_top_spacing_to_item_width_percentage(default_grid_spacing_text), [[n_cols, min, max, grid_spacing_for_size ? convert_top_spacing_to_item_width_percentage(grid_spacing_for_size) : null]], "grid", override_vertical_spacing_ ? convert_top_spacing_to_item_width_percentage(override_vertical_spacing_) : override_vertical_spacing_, top_row_shortened_by_);
11247
+ const elements_of_last_result = index_to_target_map_.get(index_to_target_map_.size - 1);
11248
+ if (elements_of_last_result) {
11249
+ if ($gVhhF$solidjs.untrack(is_loading_)) {
11250
+ // We're loading, wait check again after we have inserted our new results
11251
+ get_has_rendered_toggle();
11252
+ break past_last_result_check;
11253
+ }
11254
+ for (const element of elements_of_last_result) {
11255
+ if (document.documentElement.contains(element) && element.getBoundingClientRect().top <= 0)
11256
+ // dlog(element, "which is of last product card is in or above viewport, probably loading more");
11257
+ return 100;
11258
+ }
11259
+ }
11101
11260
  }
11102
- const media_query_body = `${container_selector_}{${spacing_styling}grid-template-columns:repeat(${n_cols},minmax(0,1fr));}`;
11103
- return `${$gVhhF$depictaiutilishared.layout_media_query_header(min, max)}{${media_query_body}}${additional_styling}`;
11104
- }).join("");
11105
- }
11106
- function $75777da1687ba3f6$var$can_use_gap_for_unit(spacing) {
11107
- const trimmed_spacing = spacing.trim();
11108
- return !trimmed_spacing.includes("%");
11261
+ if (isNaN(last)) return 0;
11262
+ if (Math.abs(last) === Infinity)
11263
+ // No product card in view and not after last card, assume first card
11264
+ return 0;
11265
+ return last / displays_by_key_().size * 100;
11266
+ }, undefined, {
11267
+ equals: false
11268
+ });
11109
11269
  }
11110
- function $75777da1687ba3f6$var$strip_percent_unit(css_value) {
11111
- return css_value.replaceAll("%", "");
11270
+ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
11271
+ plp_results_: plp_results_,
11272
+ product_card_template_: product_card_template_,
11273
+ first_result_in_viewport_: [, setFirstResultInViewport],
11274
+ last_result_in_viewport_: [lastResultInViewport, setLastResultsInViewport],
11275
+ all_products_loaded_: all_products_loaded_,
11276
+ min_products_to_fetch_: min_products_to_fetch_,
11277
+ query_base_: query_base_,
11278
+ depict_api_: depict_api_,
11279
+ is_loading_: is_loading_,
11280
+ content_blocks_: content_blocks_
11281
+ }) {
11282
+ // Although typing doesn't reflect it, plp_results is guaranteed to contain an array of at least one display at this point
11283
+ const [get_extra_displays, set_extra_displays_] = $gVhhF$solidjs.createSignal([], {
11284
+ equals: false
11285
+ });
11286
+ const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => [...(plp_results_()?.displays || []), ...get_extra_displays()]));
11287
+ const {
11288
+ indexToTargetMap_: indexToTargetMap_,
11289
+ renderedDisplays_: renderedDisplays_,
11290
+ currentlyIntersecting: currentlyIntersecting
11291
+ } = $67155e1aeb7073f6$export$4a14175d33d81a96({
11292
+ displays_by_key_: displays_by_key_,
11293
+ product_card_template_: product_card_template_,
11294
+ content_blocks_: content_blocks_,
11295
+ alwaysObserveCards_: true
11296
+ });
11297
+ const percentage_in_view_ = $4117463e2939f5f4$export$63dd0350f8559dda({
11298
+ get_last_result_in_viewport_: lastResultInViewport,
11299
+ displays_by_key_: displays_by_key_,
11300
+ index_to_target_map_: indexToTargetMap_,
11301
+ is_loading_: is_loading_,
11302
+ get_extra_displays: get_extra_displays
11303
+ });
11304
+ $3f08fe2992a2a8ca$export$5e4aed86c12acdd9({
11305
+ percentage_in_view_: percentage_in_view_,
11306
+ set_extra_displays_: set_extra_displays_,
11307
+ all_products_loaded_: all_products_loaded_,
11308
+ plp_results_: plp_results_,
11309
+ min_products_to_fetch_: min_products_to_fetch_,
11310
+ query_base_: query_base_,
11311
+ depict_api_: depict_api_
11312
+ });
11313
+ $gVhhF$solidjs.createEffect(() => {
11314
+ const intersecting = currentlyIntersecting();
11315
+ setFirstResultInViewport(Math.min(...intersecting) + 1); // +1 because we want to start counting at 1
11316
+ setLastResultsInViewport(Math.max(...intersecting) + 1);
11317
+ });
11318
+ return renderedDisplays_;
11112
11319
  }
11113
11320
  function $738c3a81fc46a340$export$cb5808ba002cdeed({
11114
11321
  layout_options_: layout_options_,
@@ -11132,213 +11339,6 @@ function $738c3a81fc46a340$export$cb5808ba002cdeed({
11132
11339
  }) : when_filters_closed_cols;
11133
11340
  });
11134
11341
  }
11135
- function $17d06b3bcb035500$export$a79e666719b3647c(cols_at_size_) {
11136
- const size_active = $gVhhF$solidjs.createMemo(() => cols_at_size_().map(([n_cols, min_width, max_width]) => {
11137
- const media_query = $gVhhF$depictaiutilishared.layout_media_query_header(min_width, max_width).replaceAll("@media", "");
11138
- const matches = $b54e6192d0caa293$export$d9f36cf74e24d595(media_query);
11139
- return [matches, n_cols];
11140
- }));
11141
- const n_cols_currently_showing = $gVhhF$solidjs.createMemo(() => {
11142
- try {
11143
- const [, n_cols_currently_showing] = size_active().find(([media_query]) => media_query());
11144
- return n_cols_currently_showing;
11145
- } catch (e) {
11146
- $gVhhF$depictaiutilishared.dwarn("No active size found in columnsAtSize - can't render content blocks or looks");
11147
- return null;
11148
- }
11149
- });
11150
- return n_cols_currently_showing;
11151
- }
11152
- var $d92f338ba8f9da9b$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=content-block-wrapper>`);
11153
- function $d92f338ba8f9da9b$export$791ef57e62e21c3f({
11154
- content_blocks_: incoming_content_blocks,
11155
- cols_at_size_: cols_at_size_,
11156
- set_top_row_shortened_by_: set_top_row_shortened_by_
11157
- }) {
11158
- // these are by row
11159
- const [content_blocks, set_content_blocks] = $gVhhF$solidjsstore.createStore([]);
11160
- const n_cols_currently_showing_ = $17d06b3bcb035500$export$a79e666719b3647c(cols_at_size_);
11161
- $gVhhF$solidjs.createEffect(() => {
11162
- const incoming_value = incoming_content_blocks();
11163
- if (!incoming_value) {
11164
- set_content_blocks([]);
11165
- return;
11166
- }
11167
- set_content_blocks($gVhhF$solidjsstore.reconcile(incoming_value, {
11168
- key: "content"
11169
- })); // key: Make moving blocks faster, see https://github.com/solidjs/solid/issues/1925#issuecomment-1769671596
11170
- });
11171
-
11172
- const get_wrapped_blocks_ = $d92f338ba8f9da9b$var$wrap_blocks_in_div(content_blocks, n_cols_currently_showing_);
11173
- $gVhhF$solidjs.createComputed(() => {
11174
- // Update our styling if a content block forces some items that should be in the top row into a lower one, so we can generate margin-top declarations for them
11175
- const top_row_block = get_wrapped_blocks_()[0];
11176
- const blocks_in_top_row_taken = top_row_block?.span_columns;
11177
- if (blocks_in_top_row_taken == undefined) {
11178
- // Fall back to zero if no content block in top row, since then no blocks in top row are taken
11179
- set_top_row_shortened_by_(0);
11180
- return;
11181
- }
11182
- set_top_row_shortened_by_(blocks_in_top_row_taken - 1); // minus one because the content block wrapper also is an element
11183
- });
11184
-
11185
- return $d92f338ba8f9da9b$var$remap_blocks_to_index({
11186
- get_wrapped_blocks_: get_wrapped_blocks_,
11187
- n_cols_currently_showing_: n_cols_currently_showing_
11188
- });
11189
- }
11190
- /**
11191
- * Calculate where to put each of the finished wrapped content blocks. Also limit blocks' max width.
11192
- * @returns an array where index is index of the blocks in the "displays array" and value is the content block (elements) to show at that index
11193
- */
11194
- function $d92f338ba8f9da9b$var$remap_blocks_to_index({
11195
- get_wrapped_blocks_: get_wrapped_blocks_,
11196
- n_cols_currently_showing_: n_cols_currently_showing_
11197
- }) {
11198
- return $gVhhF$solidjs.createMemo(() => {
11199
- // This computation should be quite cheap since it just moves around things into an array
11200
- const content_blocks_by_index = [];
11201
- const constructed_block_arrays = new WeakSet();
11202
- const wrapped_blocks = get_wrapped_blocks_();
11203
- const cols_showing = n_cols_currently_showing_();
11204
- // Need to keep track of products displaced by blocks above when mapping rows to indexes in the actual grid
11205
- const displaced_products = []; // undefined = is product, true = is content block if number instead of tuple number indicates content blocks in that row. Index in first array is row, index in second array is column
11206
- if (!cols_showing)
11207
- // Nope out of here if we don't know how many columns are showing
11208
- return content_blocks_by_index;
11209
- for (let i = 0; i < wrapped_blocks.length; i++) {
11210
- // i = row to show at
11211
- const block = wrapped_blocks[i];
11212
- if (!block) continue; // Array can have holes/not defined places
11213
- const index_of_first_item_in_row = i * cols_showing;
11214
- const index_of_last_item_in_row = index_of_first_item_in_row + cols_showing;
11215
- const {
11216
- span_rows: span_rows,
11217
- position: position,
11218
- span_columns: span_columns
11219
- } = block; // span columns is already capped in the block wrapping step (wrap_blocks_in_div)
11220
- let target_index;
11221
- if (position === "left") target_index = index_of_first_item_in_row;else if (position === "right") target_index = index_of_last_item_in_row - span_columns;else if (position === "center") target_index = index_of_first_item_in_row + Math.floor((cols_showing - span_columns) / 2);else throw new Error("Invalid position for content block - must be left, right or center: " + JSON.stringify(position));
11222
- // Calculate displacement of us by content blocks above us
11223
- let displacement_by_added_blocks = 0;
11224
- for (let j = 0; j < i; j++) {
11225
- const row = displaced_products[j];
11226
- if (row === undefined) continue; // there were no blocks in this row
11227
- let displaced_items_in_row;
11228
- if (typeof row === "number") displaced_items_in_row = row;else {
11229
- displaced_items_in_row = row.filter(item => item).length;
11230
- displaced_products[j] = displaced_items_in_row;
11231
- }
11232
- displacement_by_added_blocks += displaced_items_in_row;
11233
- }
11234
- const index_of_us_in_row = target_index - index_of_first_item_in_row;
11235
- for (let j = 0; j < index_of_us_in_row; j++) if (displaced_products[i]?.[j])
11236
- // Add blocks in our *current* row to the displacement, but only the ones to our left
11237
- displacement_by_added_blocks++;
11238
- // Add block to output array at the correct index
11239
- const final_target_index = target_index - displacement_by_added_blocks;
11240
- const existing_block = content_blocks_by_index[final_target_index];
11241
- const block_content = block.content;
11242
- // If two blocks want to exist at the same location (can happen, for example if one block wants to be at the end of a row and the other one at the start of the next row) add an array with both
11243
- if (existing_block) {
11244
- if (constructed_block_arrays.has(existing_block))
11245
- // Only push to arrays we have created to not create funky bugs when there's an array in JSX.Element
11246
- existing_block.push(block_content);else {
11247
- const array = [existing_block, block_content];
11248
- constructed_block_arrays.add(array);
11249
- content_blocks_by_index[final_target_index] = array;
11250
- }
11251
- } else content_blocks_by_index[final_target_index] = block_content;
11252
- // Update displacement
11253
- for (let j = 0; j < span_rows; j++) {
11254
- const row = displaced_products[i + j] ||= [];
11255
- for (let k = index_of_us_in_row; k < index_of_us_in_row + span_columns; k++) row[k] = true;
11256
- }
11257
- }
11258
- return content_blocks_by_index;
11259
- });
11260
- }
11261
- /**
11262
- * Takes a store that contains an array from where index is number of row and value is the result of executing the content block rendering function.
11263
- * Then renders the content and wraps it into a div with the correct styling.
11264
- * Also caps span_columns to max available columns
11265
- */
11266
- function $d92f338ba8f9da9b$var$wrap_blocks_in_div(rendered_content_blocks, max_span_columns) {
11267
- const get_wrapped_blocks = $gVhhF$solidjs.mapArray(() => rendered_content_blocks, block => {
11268
- if (!block) return;
11269
- const final_span_columns = $gVhhF$solidjs.createMemo(() => Math.min(block.span_columns, max_span_columns() ?? Infinity));
11270
- // If the item spans an entire row, limit the height to 1 row since there's no concept of "rows" if there are no products beside the block
11271
- const final_span_rows = $gVhhF$solidjs.createMemo(() => final_span_columns() === max_span_columns() ? 1 : block.span_rows);
11272
- const [rendering_delayed, set_rendering_delayed_] = $gVhhF$solidjs.createSignal(true);
11273
- const content = $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
11274
- get when() {
11275
- return !rendering_delayed();
11276
- },
11277
- get children() {
11278
- var _el$ = $gVhhF$solidjsweb.getNextElement($d92f338ba8f9da9b$var$_tmpl$);
11279
- $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent($d92f338ba8f9da9b$var$RenderContent, {
11280
- get content() {
11281
- return block.content;
11282
- }
11283
- }));
11284
- $gVhhF$solidjsweb.effect(_p$ => {
11285
- var _v$ = {
11286
- [(0, $75777da1687ba3f6$export$c500183c31c2b22e)]: final_span_columns()
11287
- },
11288
- _v$2 = `span ${final_span_columns()}`,
11289
- _v$3 = `span ${final_span_rows()}`;
11290
- _p$.e = $gVhhF$solidjsweb.style(_el$, _v$, _p$.e);
11291
- _v$2 !== _p$.t && ((_p$.t = _v$2) != null ? _el$.style.setProperty("grid-column", _v$2) : _el$.style.removeProperty("grid-column"));
11292
- _v$3 !== _p$.a && ((_p$.a = _v$3) != null ? _el$.style.setProperty("grid-row", _v$3) : _el$.style.removeProperty("grid-row"));
11293
- return _p$;
11294
- }, {
11295
- e: undefined,
11296
- t: undefined,
11297
- a: undefined
11298
- });
11299
- return _el$;
11300
- }
11301
- });
11302
- return $gVhhF$solidjs.mergeProps(block, {
11303
- // Create content divs for the blocks with as much fine-grained diffing as possible?
11304
- content: () => {
11305
- // Sneaky on-demand rendering, so we don't render more blocks than we can show: we have the rendered value here and don't return a function that renders because if our block would be moved around we'd be guaranteed to re-render
11306
- // However, no need to count products to know if we should render: the <For> loops in Placeholders and render_displays will only call this function if there's actually a product here that wants to display this block
11307
- set_rendering_delayed_(false);
11308
- return content;
11309
- },
11310
- get span_columns() {
11311
- // Cap max width of block to the number of columns available, for everyone downstream
11312
- return final_span_columns();
11313
- },
11314
- get span_rows() {
11315
- return final_span_rows();
11316
- }
11317
- });
11318
- });
11319
- return get_wrapped_blocks;
11320
- }
11321
- /**
11322
- * Basically adds support for async content block functions and shows a rudimentary placeholder if rendering is delayed. Required due to react having a rendering delay.
11323
- */
11324
- function $d92f338ba8f9da9b$var$RenderContent(props) {
11325
- const [resource] = $gVhhF$solidjs.createResource(() => props.content,
11326
- // Could be reactive
11327
- fn => fn());
11328
- $gVhhF$solidjs.createEffect(() => {
11329
- if (resource.error) console.error("Error in content block rendering", resource.error);
11330
- });
11331
- // The suspense is for when there's an async content block (which we have to support due to react having a rendering delay) so that we can show some height while it's loading (should kinda never be visible)
11332
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
11333
- get fallback() {
11334
- return $gVhhF$solidjsweb.createComponent((0, $3bc4a89b971a3af5$export$3f37af283f8fb843), {
11335
- width: "100%",
11336
- height: "max(100%, 400px)"
11337
- });
11338
- },
11339
- children: resource
11340
- });
11341
- }
11342
11342
  var $fe76fb463cc60b89$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=PLP-results><!$><!/><!$><!/>`);
11343
11343
  function $fe76fb463cc60b89$export$3925f87b1545cfc6({
11344
11344
  plp_results_: plp_results_,
@@ -14887,6 +14887,70 @@ function $bb9760b7a8acdc18$export$7af06a63c5a976c9(el, listing_id, i18n_) {
14887
14887
  $gVhhF$solidjs.onCleanup(disconnect);
14888
14888
  }
14889
14889
  $gVhhF$solidjsweb.delegateEvents(["click"]);
14890
+ var $32c662f618f5d80d$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<a><img>`),
14891
+ $32c662f618f5d80d$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<a><video loop>`);
14892
+ function $32c662f618f5d80d$export$780a853d15174484({
14893
+ contentBlock: contentBlock,
14894
+ router_: router_
14895
+ }) {
14896
+ if (contentBlock.content.type === "image") return () => (() => {
14897
+ var _el$ = $gVhhF$solidjsweb.getNextElement($32c662f618f5d80d$var$_tmpl$),
14898
+ _el$2 = _el$.firstChild;
14899
+ $gVhhF$solidjsweb.addEventListener(_el$, "click", $gVhhF$depictaiutilisharedlatest.catchify(ev => router_.navigate_.go_to_({
14900
+ new_url_: contentBlock.content.link,
14901
+ is_replace_: false,
14902
+ event_: ev
14903
+ })), true);
14904
+ _el$2.style.setProperty("width", "100%");
14905
+ _el$2.style.setProperty("height", "100%");
14906
+ _el$2.style.setProperty("object-fit", "cover");
14907
+ _el$2.style.setProperty("position", "absolute");
14908
+ _el$2.style.setProperty("inset", "0");
14909
+ $gVhhF$solidjsweb.effect(_p$ => {
14910
+ var _v$ = contentBlock.content.link,
14911
+ _v$2 = contentBlock.content.url;
14912
+ _v$ !== _p$.e && $gVhhF$solidjsweb.setAttribute(_el$, "href", _p$.e = _v$);
14913
+ _v$2 !== _p$.t && $gVhhF$solidjsweb.setAttribute(_el$2, "src", _p$.t = _v$2);
14914
+ return _p$;
14915
+ }, {
14916
+ e: undefined,
14917
+ t: undefined
14918
+ });
14919
+ $gVhhF$solidjsweb.runHydrationEvents();
14920
+ return _el$;
14921
+ })();
14922
+ if (contentBlock.content.type === "video") return () => (() => {
14923
+ var _el$3 = $gVhhF$solidjsweb.getNextElement($32c662f618f5d80d$var$_tmpl$2),
14924
+ _el$4 = _el$3.firstChild;
14925
+ $gVhhF$solidjsweb.addEventListener(_el$3, "click", $gVhhF$depictaiutilisharedlatest.catchify(ev => router_.navigate_.go_to_({
14926
+ new_url_: contentBlock.content.link,
14927
+ is_replace_: false,
14928
+ event_: ev
14929
+ })), true);
14930
+ $gVhhF$solidjsweb.setProperty(_el$4, "controls", false);
14931
+ $gVhhF$solidjsweb.setProperty(_el$4, "muted", true);
14932
+ $gVhhF$solidjsweb.setProperty(_el$4, "autoplay", true);
14933
+ $gVhhF$solidjsweb.setProperty(_el$4, "playsinline", true);
14934
+ _el$4.style.setProperty("width", "100%");
14935
+ _el$4.style.setProperty("height", "100%");
14936
+ _el$4.style.setProperty("object-fit", "cover");
14937
+ _el$4.style.setProperty("position", "absolute");
14938
+ _el$4.style.setProperty("inset", "0");
14939
+ $gVhhF$solidjsweb.effect(_p$ => {
14940
+ var _v$3 = contentBlock.content.link,
14941
+ _v$4 = contentBlock.content.url;
14942
+ _v$3 !== _p$.e && $gVhhF$solidjsweb.setAttribute(_el$3, "href", _p$.e = _v$3);
14943
+ _v$4 !== _p$.t && $gVhhF$solidjsweb.setAttribute(_el$4, "src", _p$.t = _v$4);
14944
+ return _p$;
14945
+ }, {
14946
+ e: undefined,
14947
+ t: undefined
14948
+ });
14949
+ $gVhhF$solidjsweb.runHydrationEvents();
14950
+ return _el$3;
14951
+ })();
14952
+ }
14953
+ $gVhhF$solidjsweb.delegateEvents(["click"]);
14890
14954
  var $840d88a04b2d22a7$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=product-count><!$><!/> <!$><!/>`),
14891
14955
  $840d88a04b2d22a7$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`),
14892
14956
  $840d88a04b2d22a7$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=filter-results-for-one-row><!$><!/><!$><!/>`),
@@ -14982,6 +15046,23 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
14982
15046
  }));
14983
15047
  // Make "Get Listing" request to get quicklinks, breadcrumbs, title, etc
14984
15048
  const [plp_meta] = $gVhhF$solidjs.createResource(meta_query_base, $gVhhF$depictaiutilisharedlatest.catchify(query => depict_api_.get_listing(query)));
15049
+ const contentBlocksByRow = $gVhhF$solidjs.createMemo(() => {
15050
+ if (content_blocks_by_row_()) return content_blocks_by_row_();
15051
+ const content = [];
15052
+ plp_meta()?.content_blocks?.forEach(row => {
15053
+ const contentBlock = {
15054
+ span_columns: row.span_columns,
15055
+ span_rows: row.span_rows,
15056
+ position: row.position,
15057
+ content: $32c662f618f5d80d$export$780a853d15174484({
15058
+ contentBlock: row,
15059
+ router_: router_
15060
+ })
15061
+ };
15062
+ content[row.row] = contentBlock;
15063
+ });
15064
+ return content;
15065
+ });
14985
15066
  const available_sortings_ = $gVhhF$solidjs.createMemo(() => plp_products_()?.sorts?.map(sort => ({
14986
15067
  ...sort,
14987
15068
  order: sort.order ?? "desc"
@@ -15242,7 +15323,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
15242
15323
  product_card_template_: product_card_template_,
15243
15324
  sort_or_filter_open_: sort_or_filter_open_,
15244
15325
  desktop_filter_elements_: desktop_filter_elements_,
15245
- content_blocks_by_row_: content_blocks_by_row_,
15326
+ content_blocks_by_row_: contentBlocksByRow,
15246
15327
  ConfiguredScrollStatus_: ConfiguredScrollStatus_,
15247
15328
  id_currently_querying_for_: id_to_query_for_,
15248
15329
  no_results_options_: {