@depict-ai/ui 4.7.14 → 4.7.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ES10/index.cjs CHANGED
@@ -18,6 +18,7 @@ function $parcel$export(e, n, v, s) {
18
18
  function $parcel$interopDefault(a) {
19
19
  return a && a.__esModule ? a.default : a;
20
20
  }
21
+ $parcel$export(module.exports, "useProductCardIsVisible", () => $a52942afacbced93$export$80bb7300ce6a8be3);
21
22
  $parcel$export(module.exports, "useExpandingContainerReactive", () => $d6d51b09cb2116a6$export$5bad61ecde080b1f);
22
23
  $parcel$export(module.exports, "LooksSliderOrGrid", () => $e57cd46536ad992e$export$2c9f9bf2092486aa);
23
24
  $parcel$export(module.exports, "LookCard", () => $47e3c3102c78121b$export$44809a8a3e867e30);
@@ -104,78 +105,18 @@ $parcel$export(module.exports, "BreadCrumbs", () => $335c02c1241a9ca8$export$5b7
104
105
  $parcel$export(module.exports, "QuickLinks", () => $335c02c1241a9ca8$export$de035477d6fef996);
105
106
  $parcel$export(module.exports, "CategoryPage", () => $c10e33c4681f8c9b$export$e2bf8ce7779e827e);
106
107
  /*! Depict.ai search and product listing SDK */
107
- const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.7.14";
108
- function $d6d51b09cb2116a6$export$5bad61ecde080b1f() {
109
- const {
110
- collapse: collapse,
111
- expand: expand,
112
- ExpandingContainer: ExpandingContainer
113
- } = $52FdA$depictaiutilishared.useExpandingContainer(...arguments);
114
- return {
115
- collapse: collapse,
116
- expand: expand,
117
- ExpandingContainer: _ref => {
118
- let {
119
- children: children
120
- } = _ref;
121
- // get reactive signals/solid's jsx elements into `ExpandingContainer`
122
- const fake_div = document.createElement("div");
123
- const outer_expanding = $52FdA$solidjsweb.createComponent(ExpandingContainer, {
124
- children: [fake_div]
125
- });
126
- const parent = fake_div.parentElement;
127
- fake_div.remove();
128
- $52FdA$solidjsweb.insert(parent, children);
129
- return outer_expanding;
130
- }
131
- };
132
- }
133
- const $5401a6698b0c0658$var$transform_elements = sorted_cols_at_size => {
134
- const cols_at_size = [];
135
- for (let i = 0; i < sorted_cols_at_size.length; i++) {
136
- var _sorted_cols_at_size;
137
- const [nb_cols, width] = sorted_cols_at_size[i];
138
- const next_width = (_sorted_cols_at_size = sorted_cols_at_size[i + 1]) === null || _sorted_cols_at_size === void 0 ? void 0 : _sorted_cols_at_size[1];
139
- const max_width = i === 0 ? "" : "".concat(width, "px");
140
- const min_width = next_width !== undefined ? "".concat(next_width + 1, "px") : "";
141
- const col_at_size = [nb_cols, min_width, max_width];
142
- cols_at_size.push(col_at_size);
143
- }
144
- return cols_at_size;
145
- };
146
- const $5401a6698b0c0658$export$6daf8749b65a1b77 = cols_at_size => {
147
- var _cols_at_size$every;
148
- // Check that every element is an array
149
- const are_arrays = cols_at_size === null || cols_at_size === void 0 ? void 0 : (_cols_at_size$every = cols_at_size.every) === null || _cols_at_size$every === void 0 ? void 0 : _cols_at_size$every.call(cols_at_size, element => Array.isArray(element));
150
- if (!are_arrays) throw new Error("Every element in cols_at_size must be an array");
151
- // Check width duplicates
152
- const widths = cols_at_size.map(_ref => {
153
- let [_, width] = _ref;
154
- return width;
155
- });
156
- const widths_set = new Set(widths);
157
- if (widths_set.size < widths.length) throw new Error("There are duplicate widths in cols_at_size");
158
- if (cols_at_size.length === 1) {
159
- const [nb_cols, width] = cols_at_size[0];
160
- const max_width = width !== undefined ? "".concat(width, "px") : "";
161
- return [[nb_cols, "", max_width]];
108
+ const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.7.16";
109
+
110
+ /**
111
+ * Gets product_id (the thing we key the rendering on) from a display
112
+ */
113
+ function $b85edfec41cd3989$export$548d053aba053d79(display) {
114
+ if ("variant_index" in display) {
115
+ const actual_display = display.variant_displays[display.variant_index];
116
+ return actual_display.product_id;
162
117
  }
163
- // Sort widths in ascending order
164
- const sorted_cols_at_size = [...cols_at_size].sort((a, b) => {
165
- const [_b, width_A] = a;
166
- const [_a, width_b] = b;
167
- if (width_A === undefined) return -1;
168
- if (width_b === undefined) return 1;
169
- return width_b - width_A;
170
- });
171
- return $5401a6698b0c0658$var$transform_elements(sorted_cols_at_size);
172
- };
173
- function $8edd3cf30d1fd8b4$export$a2cc176055f8f08() {
174
- let what = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "grid";
175
- const text = "Please try setting `columnsAtSize`/`gridSpacing` on the `SearchPage`/`CategoryPage` components to change the " + what + " before setting it with CSS. If you do with CSS, set `columnsAtSize` to an empty array to ensure no declarations created by the SDK leak through.";
176
- return (0, $52FdA$solidjsweb.isServer) ? {
177
- t: "<!-- ".concat(text, " -->")
178
- } : document.createComment(text);
118
+ if ("listing_id" in display) return display.listing_id;
119
+ return display.product_id;
179
120
  }
180
121
  function $e82d0d417fa613e8$export$2f0cbfbb4354bb52(elements) {
181
122
  // FYI this probably doesn't work on hugely deep nestings or large amount of elements
@@ -189,121 +130,6 @@ function $e82d0d417fa613e8$var$unwrapping_helper(elements) {
189
130
  } else if (typeof elements == "function") result.push(...$e82d0d417fa613e8$var$unwrapping_helper(elements()));else if (elements != undefined && typeof elements != "boolean") result.push(elements);
190
131
  return result;
191
132
  }
192
- let $e3915574cfd3466c$var$cached_placeholder_element;
193
- let $e3915574cfd3466c$var$rendering_cached_placeholder_element;
194
- function $e3915574cfd3466c$export$f33414a4df0afd3f(_ref) {
195
- let {
196
- product_card_template_: product_card_template_,
197
- num_placeholders_: num_placeholders_,
198
- content_blocks_: content_blocks_
199
- } = _ref;
200
- const [num_to_actually_show, set_num_to_actually_show] = $52FdA$solidjs.createSignal($52FdA$solidjs.untrack(num_placeholders_));
201
- if (0, $52FdA$solidjsweb.isServer)
202
- // want to render simple placeholders on server, effects don't run there
203
- // FIXME when adding proper SSR: also SSR content blocks
204
- return $52FdA$solidjs.createMemo(() => Array.from({
205
- length: num_placeholders_()
206
- }).map(() => {
207
- const template_result = product_card_template_(null, undefined);
208
- // @ts-ignore
209
- if (typeof (template_result === null || template_result === void 0 ? void 0 : template_result.then) !== "function") return template_result;
210
- }));
211
- $52FdA$solidjs.createRenderEffect(() => {
212
- const existing_num = num_to_actually_show();
213
- const to_add = num_placeholders_() - existing_num;
214
- if (to_add <= 0) return;
215
- // Below comment is from when we used recommendation renderer and manual DOM manipulation for this, but I'm still scared to remove placeholders and mess up scroll restoration, so I'm keeping the way it worked. Otherwise, <Index> could be used which would be far more elegant.
216
- // We don't need to remove placeholders, only need to add. The reason for that is that chrome restores the scroll position once all tasks queued as reaction of the "popstate" events have been completed in the task queue. That means that we need to get the placeholders in fast, or we might lose scroll position if the previous site was shorter.
217
- // The query id and the amount might update in separate tasks because one comes from href_change_ipns and the other one from another "popstate" listener. Therefore, we need to be able to dynamically add more placeholders. I'm not entirely sure about this anymore though, since we have the scroll position on a per-id basis it might work anyway but THIS WORKS, and I've been working on this bug for 3 hours so let's just keep it this way.
218
- // Above comments were from when we added elements in this createRenderEffect. Now I changed it to just increment the number and render them from an <Index> instead, so I can add content blocks better
219
- // Functionality should be the same
220
- set_num_to_actually_show(existing_num + to_add);
221
- });
222
- return $52FdA$solidjsweb.createComponent((0, $52FdA$solidjs.Index), {
223
- get each() {
224
- return Array.from({
225
- length: num_to_actually_show()
226
- });
227
- },
228
- children: (_item, index) => {
229
- const possible_content_block = $52FdA$solidjs.createMemo(() => {
230
- var _content_blocks_, _content_blocks_2;
231
- return content_blocks_ === null || content_blocks_ === void 0 ? void 0 : (_content_blocks_ = content_blocks_()) === null || _content_blocks_ === void 0 ? void 0 : (_content_blocks_2 = _content_blocks_()) === null || _content_blocks_2 === void 0 ? void 0 : _content_blocks_2[index];
232
- });
233
- // Show content block before product card, so it's *at* that index
234
- return [possible_content_block, $e3915574cfd3466c$var$Placeholder({
235
- product_card_template_: product_card_template_
236
- })]; // https://github.com/solidjs/solid/releases/tag/v1.7.0
237
- }
238
- });
239
- }
240
- /**
241
- * Get one placeholder element. It will be cloned for each placeholder for ultimate performance even when solid-js isn't rendering the placeholders.
242
- */
243
- function $e3915574cfd3466c$var$Placeholder(_ref2) {
244
- let {
245
- product_card_template_: product_card_template_
246
- } = _ref2;
247
- const get_cloned_placeholders = function () {
248
- let element_to_clone = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : $e3915574cfd3466c$var$cached_placeholder_element;
249
- return Array.isArray(element_to_clone) ? element_to_clone.map(el => el instanceof Node ? el.cloneNode(true) : el) : element_to_clone;
250
- };
251
- if ($e3915574cfd3466c$var$cached_placeholder_element) return get_cloned_placeholders();
252
- let dispose_original_copy;
253
- const get_unwrapped_element = $52FdA$solidjs.createRoot(dispose => {
254
- dispose_original_copy = dispose;
255
- // if product_card_template_ is async and rejects the resource will take care of throwing upwards here in the solid-js error handling system
256
- const [resource] = $52FdA$solidjs.createResource(() => {
257
- if ($e3915574cfd3466c$var$rendering_cached_placeholder_element) return $e3915574cfd3466c$var$rendering_cached_placeholder_element;
258
- const return_value = product_card_template_(null, undefined);
259
- if (typeof return_value === "object" && typeof (return_value === null || return_value === void 0 ? void 0 : return_value.then) === "function")
260
- // Is Promise or promise-like object
261
- $e3915574cfd3466c$var$rendering_cached_placeholder_element = return_value;
262
- return return_value;
263
- });
264
- return $52FdA$solidjs.createMemo(() => {
265
- if (resource.loading) return () => [];
266
- return $e82d0d417fa613e8$export$2f0cbfbb4354bb52(resource);
267
- });
268
- });
269
- $52FdA$solidjs.onCleanup(() => {
270
- if ($e3915574cfd3466c$var$rendering_cached_placeholder_element) {
271
- var _rendering_cached_pla;
272
- // If we're still rendering in our separate root, let the rendering finish or other <Placeholder> components waiting for it might get an incomplete result
273
- const unset_current_rendering = () => {
274
- dispose_original_copy();
275
- $e3915574cfd3466c$var$rendering_cached_placeholder_element = undefined;
276
- };
277
- (_rendering_cached_pla = $e3915574cfd3466c$var$rendering_cached_placeholder_element) === null || _rendering_cached_pla === void 0 || _rendering_cached_pla.then(unset_current_rendering, unset_current_rendering);
278
- } else
279
- // Otherwise, just make sure we've disposed our root
280
- dispose_original_copy();
281
- });
282
- return $52FdA$solidjs.createMemo(() => {
283
- const unwrapped_array = get_unwrapped_element()();
284
- if (!(unwrapped_array !== null && unwrapped_array !== void 0 && unwrapped_array.length) || !unwrapped_array.every(item => item))
285
- // Haven't finished rendering yet in case of "async" rendering, so don't freeze the elements yet
286
- return;
287
- // placeholders have finished rendering, freeze the elements
288
- // 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
289
- $e3915574cfd3466c$var$cached_placeholder_element || ($e3915574cfd3466c$var$cached_placeholder_element = 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
290
- $e3915574cfd3466c$var$rendering_cached_placeholder_element = undefined;
291
- dispose_original_copy(); // So that this memo will never re-run and the placeholder rendering function can clean up
292
- 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
293
- });
294
- }
295
-
296
- /**
297
- * Gets product_id (the thing we key the rendering on) from a display
298
- */
299
- function $b85edfec41cd3989$export$548d053aba053d79(display) {
300
- if ("variant_index" in display) {
301
- const actual_display = display.variant_displays[display.variant_index];
302
- return actual_display.product_id;
303
- }
304
- if ("listing_id" in display) return display.listing_id;
305
- return display.product_id;
306
- }
307
133
  const $b54645378dfc7280$var$ProductCardIndexContext = /*@__PURE__*/$52FdA$solidjs.createContext();
308
134
  function $b54645378dfc7280$export$11354f017ddc9790(props) {
309
135
  return $52FdA$solidjsweb.createComponent($b54645378dfc7280$var$ProductCardIndexContext.Provider, {
@@ -521,6 +347,266 @@ function $76012c4468a53d1f$var$deep_equal(obj1, obj2) {
521
347
  }
522
348
  return true;
523
349
  }
350
+ const $a52942afacbced93$var$CurrentlyIntersectingContext = /*@__PURE__*/$52FdA$solidjs.createContext();
351
+ function $a52942afacbced93$export$4a14175d33d81a96(_ref) {
352
+ let {
353
+ displays_by_key_: displays_by_key_,
354
+ product_card_template_: product_card_template_,
355
+ content_blocks_: content_blocks_,
356
+ alwaysObserveCards_: alwaysObserveCards_
357
+ } = _ref;
358
+ // The following sets up an intersection observer to determine which results are in the viewport, used for the ScrollStatus indicator, knowing when to load more and any other consumer of the useProductCardIsVisible hook.
359
+ const targetToIndexMap_ = new Map();
360
+ const indexToTargetMap_ = new Map();
361
+ const [listenersForIntersecting, setListenersForIntersecting] = $52FdA$solidjs.createSignal(0);
362
+ const [currentlyIntersecting, setCurrentlyIntersecting] = $52FdA$solidjs.createSignal(new Set(), {
363
+ equals: false
364
+ });
365
+ const shouldObserve = $52FdA$solidjs.createMemo(() => alwaysObserveCards_ || listenersForIntersecting() > 0);
366
+ const intersection_observer = new IntersectionObserver($52FdA$depictaiutilishared.catchify(records => {
367
+ const intersectingValue = currentlyIntersecting();
368
+ for (let i = 0; i < records.length; i++) {
369
+ const record = records[i];
370
+ const {
371
+ target: target,
372
+ intersectionRatio: intersectionRatio
373
+ } = record;
374
+ const index_of_target = targetToIndexMap_.get(target);
375
+ if (index_of_target == undefined) return; // It seems like it can happen that we get IntersectionObserverEntries after the onCleanup function for a recommendation card has run, in Firefox. Probably a bug in Firefox? If I understood the bug correctly, this is a workaround.
376
+ const is_in_set = intersectingValue.has(index_of_target);
377
+ if (intersectionRatio > 0) {
378
+ if (!is_in_set) intersectingValue.add(index_of_target);
379
+ } else if (is_in_set) intersectingValue.delete(index_of_target);
380
+ }
381
+ setCurrentlyIntersecting(intersectingValue);
382
+ }, "renderDisplays IO failed"));
383
+ const renderedDisplays_ = $52FdA$solidjsweb.createComponent($a52942afacbced93$var$CurrentlyIntersectingContext.Provider, {
384
+ value: {
385
+ currentlyIntersecting_: currentlyIntersecting,
386
+ setIsListening_: setListenersForIntersecting
387
+ },
388
+ get children() {
389
+ return $76012c4468a53d1f$export$43f0fb951fcb0c54({
390
+ displays_by_key_: displays_by_key_,
391
+ product_card_template_: product_card_template_,
392
+ content_blocks_: content_blocks_,
393
+ do_per_elements_: (elements, index_accessor) =>
394
+ // Adds/removes elements from the "results in viewport" intersection observer above
395
+ $52FdA$solidjs.createEffect(() => {
396
+ if (!shouldObserve()) return;
397
+ const display_index = index_accessor();
398
+ // Nested createEffect because we only want to re-run this when the index changes (or we should/shouldn't observe)
399
+ // We need to save in a map which index the elements of this template are so that we can know that in the IntersectionObserver callback
400
+ for (let i = 0; i < elements.length; i++) {
401
+ const element = elements[i];
402
+ targetToIndexMap_.set(element, display_index);
403
+ intersection_observer.observe(element);
404
+ $52FdA$solidjs.onCleanup(() => {
405
+ intersection_observer.unobserve(element);
406
+ targetToIndexMap_.delete(element);
407
+ const intersecting = $52FdA$solidjs.untrack(currentlyIntersecting);
408
+ const wasDeleted = intersecting.delete(display_index);
409
+ if (wasDeleted) setCurrentlyIntersecting(intersecting);
410
+ });
411
+ }
412
+ indexToTargetMap_.set(display_index, elements);
413
+ $52FdA$solidjs.onCleanup(() => indexToTargetMap_.delete(display_index));
414
+ })
415
+ });
416
+ }
417
+ });
418
+ return {
419
+ renderedDisplays_: renderedDisplays_,
420
+ indexToTargetMap_: indexToTargetMap_,
421
+ currentlyIntersecting: currentlyIntersecting
422
+ };
423
+ }
424
+ function $a52942afacbced93$export$80bb7300ce6a8be3() {
425
+ const {
426
+ setIsListening_: setIsListening_,
427
+ currentlyIntersecting_: currentlyIntersecting_
428
+ } = $52FdA$solidjs.useContext($a52942afacbced93$var$CurrentlyIntersectingContext) || {};
429
+ const getOurIndex = $b54645378dfc7280$export$e3faf4d95300054f();
430
+ const isVisible = $52FdA$solidjs.createMemo(() => currentlyIntersecting_ === null || currentlyIntersecting_ === void 0 ? void 0 : currentlyIntersecting_().has(getOurIndex === null || getOurIndex === void 0 ? void 0 : getOurIndex()));
431
+ setIsListening_ === null || setIsListening_ === void 0 || setIsListening_(prev => prev + 1);
432
+ $52FdA$solidjs.onCleanup(() => setIsListening_ === null || setIsListening_ === void 0 ? void 0 : setIsListening_(prev => prev + 1));
433
+ return isVisible;
434
+ }
435
+ function $d6d51b09cb2116a6$export$5bad61ecde080b1f() {
436
+ const {
437
+ collapse: collapse,
438
+ expand: expand,
439
+ ExpandingContainer: ExpandingContainer
440
+ } = $52FdA$depictaiutilishared.useExpandingContainer(...arguments);
441
+ return {
442
+ collapse: collapse,
443
+ expand: expand,
444
+ ExpandingContainer: _ref => {
445
+ let {
446
+ children: children
447
+ } = _ref;
448
+ // get reactive signals/solid's jsx elements into `ExpandingContainer`
449
+ const fake_div = document.createElement("div");
450
+ const outer_expanding = $52FdA$solidjsweb.createComponent(ExpandingContainer, {
451
+ children: [fake_div]
452
+ });
453
+ const parent = fake_div.parentElement;
454
+ fake_div.remove();
455
+ $52FdA$solidjsweb.insert(parent, children);
456
+ return outer_expanding;
457
+ }
458
+ };
459
+ }
460
+ const $5401a6698b0c0658$var$transform_elements = sorted_cols_at_size => {
461
+ const cols_at_size = [];
462
+ for (let i = 0; i < sorted_cols_at_size.length; i++) {
463
+ var _sorted_cols_at_size;
464
+ const [nb_cols, width] = sorted_cols_at_size[i];
465
+ const next_width = (_sorted_cols_at_size = sorted_cols_at_size[i + 1]) === null || _sorted_cols_at_size === void 0 ? void 0 : _sorted_cols_at_size[1];
466
+ const max_width = i === 0 ? "" : "".concat(width, "px");
467
+ const min_width = next_width !== undefined ? "".concat(next_width + 1, "px") : "";
468
+ const col_at_size = [nb_cols, min_width, max_width];
469
+ cols_at_size.push(col_at_size);
470
+ }
471
+ return cols_at_size;
472
+ };
473
+ const $5401a6698b0c0658$export$6daf8749b65a1b77 = cols_at_size => {
474
+ var _cols_at_size$every;
475
+ // Check that every element is an array
476
+ const are_arrays = cols_at_size === null || cols_at_size === void 0 ? void 0 : (_cols_at_size$every = cols_at_size.every) === null || _cols_at_size$every === void 0 ? void 0 : _cols_at_size$every.call(cols_at_size, element => Array.isArray(element));
477
+ if (!are_arrays) throw new Error("Every element in cols_at_size must be an array");
478
+ // Check width duplicates
479
+ const widths = cols_at_size.map(_ref => {
480
+ let [_, width] = _ref;
481
+ return width;
482
+ });
483
+ const widths_set = new Set(widths);
484
+ if (widths_set.size < widths.length) throw new Error("There are duplicate widths in cols_at_size");
485
+ if (cols_at_size.length === 1) {
486
+ const [nb_cols, width] = cols_at_size[0];
487
+ const max_width = width !== undefined ? "".concat(width, "px") : "";
488
+ return [[nb_cols, "", max_width]];
489
+ }
490
+ // Sort widths in ascending order
491
+ const sorted_cols_at_size = [...cols_at_size].sort((a, b) => {
492
+ const [_b, width_A] = a;
493
+ const [_a, width_b] = b;
494
+ if (width_A === undefined) return -1;
495
+ if (width_b === undefined) return 1;
496
+ return width_b - width_A;
497
+ });
498
+ return $5401a6698b0c0658$var$transform_elements(sorted_cols_at_size);
499
+ };
500
+ function $8edd3cf30d1fd8b4$export$a2cc176055f8f08() {
501
+ let what = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "grid";
502
+ const text = "Please try setting `columnsAtSize`/`gridSpacing` on the `SearchPage`/`CategoryPage` components to change the " + what + " before setting it with CSS. If you do with CSS, set `columnsAtSize` to an empty array to ensure no declarations created by the SDK leak through.";
503
+ return (0, $52FdA$solidjsweb.isServer) ? {
504
+ t: "<!-- ".concat(text, " -->")
505
+ } : document.createComment(text);
506
+ }
507
+ let $e3915574cfd3466c$var$cached_placeholder_element;
508
+ let $e3915574cfd3466c$var$rendering_cached_placeholder_element;
509
+ function $e3915574cfd3466c$export$f33414a4df0afd3f(_ref) {
510
+ let {
511
+ product_card_template_: product_card_template_,
512
+ num_placeholders_: num_placeholders_,
513
+ content_blocks_: content_blocks_
514
+ } = _ref;
515
+ const [num_to_actually_show, set_num_to_actually_show] = $52FdA$solidjs.createSignal($52FdA$solidjs.untrack(num_placeholders_));
516
+ if (0, $52FdA$solidjsweb.isServer)
517
+ // want to render simple placeholders on server, effects don't run there
518
+ // FIXME when adding proper SSR: also SSR content blocks
519
+ return $52FdA$solidjs.createMemo(() => Array.from({
520
+ length: num_placeholders_()
521
+ }).map(() => {
522
+ const template_result = product_card_template_(null, undefined);
523
+ // @ts-ignore
524
+ if (typeof (template_result === null || template_result === void 0 ? void 0 : template_result.then) !== "function") return template_result;
525
+ }));
526
+ $52FdA$solidjs.createRenderEffect(() => {
527
+ const existing_num = num_to_actually_show();
528
+ const to_add = num_placeholders_() - existing_num;
529
+ if (to_add <= 0) return;
530
+ // Below comment is from when we used recommendation renderer and manual DOM manipulation for this, but I'm still scared to remove placeholders and mess up scroll restoration, so I'm keeping the way it worked. Otherwise, <Index> could be used which would be far more elegant.
531
+ // We don't need to remove placeholders, only need to add. The reason for that is that chrome restores the scroll position once all tasks queued as reaction of the "popstate" events have been completed in the task queue. That means that we need to get the placeholders in fast, or we might lose scroll position if the previous site was shorter.
532
+ // The query id and the amount might update in separate tasks because one comes from href_change_ipns and the other one from another "popstate" listener. Therefore, we need to be able to dynamically add more placeholders. I'm not entirely sure about this anymore though, since we have the scroll position on a per-id basis it might work anyway but THIS WORKS, and I've been working on this bug for 3 hours so let's just keep it this way.
533
+ // Above comments were from when we added elements in this createRenderEffect. Now I changed it to just increment the number and render them from an <Index> instead, so I can add content blocks better
534
+ // Functionality should be the same
535
+ set_num_to_actually_show(existing_num + to_add);
536
+ });
537
+ return $52FdA$solidjsweb.createComponent((0, $52FdA$solidjs.Index), {
538
+ get each() {
539
+ return Array.from({
540
+ length: num_to_actually_show()
541
+ });
542
+ },
543
+ children: (_item, index) => {
544
+ const possible_content_block = $52FdA$solidjs.createMemo(() => {
545
+ var _content_blocks_, _content_blocks_2;
546
+ return content_blocks_ === null || content_blocks_ === void 0 ? void 0 : (_content_blocks_ = content_blocks_()) === null || _content_blocks_ === void 0 ? void 0 : (_content_blocks_2 = _content_blocks_()) === null || _content_blocks_2 === void 0 ? void 0 : _content_blocks_2[index];
547
+ });
548
+ // Show content block before product card, so it's *at* that index
549
+ return [possible_content_block, $e3915574cfd3466c$var$Placeholder({
550
+ product_card_template_: product_card_template_
551
+ })]; // https://github.com/solidjs/solid/releases/tag/v1.7.0
552
+ }
553
+ });
554
+ }
555
+ /**
556
+ * Get one placeholder element. It will be cloned for each placeholder for ultimate performance even when solid-js isn't rendering the placeholders.
557
+ */
558
+ function $e3915574cfd3466c$var$Placeholder(_ref2) {
559
+ let {
560
+ product_card_template_: product_card_template_
561
+ } = _ref2;
562
+ const get_cloned_placeholders = function () {
563
+ let element_to_clone = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : $e3915574cfd3466c$var$cached_placeholder_element;
564
+ return Array.isArray(element_to_clone) ? element_to_clone.map(el => el instanceof Node ? el.cloneNode(true) : el) : element_to_clone;
565
+ };
566
+ if ($e3915574cfd3466c$var$cached_placeholder_element) return get_cloned_placeholders();
567
+ let dispose_original_copy;
568
+ const get_unwrapped_element = $52FdA$solidjs.createRoot(dispose => {
569
+ dispose_original_copy = dispose;
570
+ // if product_card_template_ is async and rejects the resource will take care of throwing upwards here in the solid-js error handling system
571
+ const [resource] = $52FdA$solidjs.createResource(() => {
572
+ if ($e3915574cfd3466c$var$rendering_cached_placeholder_element) return $e3915574cfd3466c$var$rendering_cached_placeholder_element;
573
+ const return_value = product_card_template_(null, undefined);
574
+ if (typeof return_value === "object" && typeof (return_value === null || return_value === void 0 ? void 0 : return_value.then) === "function")
575
+ // Is Promise or promise-like object
576
+ $e3915574cfd3466c$var$rendering_cached_placeholder_element = return_value;
577
+ return return_value;
578
+ });
579
+ return $52FdA$solidjs.createMemo(() => {
580
+ if (resource.loading) return () => [];
581
+ return $e82d0d417fa613e8$export$2f0cbfbb4354bb52(resource);
582
+ });
583
+ });
584
+ $52FdA$solidjs.onCleanup(() => {
585
+ if ($e3915574cfd3466c$var$rendering_cached_placeholder_element) {
586
+ var _rendering_cached_pla;
587
+ // If we're still rendering in our separate root, let the rendering finish or other <Placeholder> components waiting for it might get an incomplete result
588
+ const unset_current_rendering = () => {
589
+ dispose_original_copy();
590
+ $e3915574cfd3466c$var$rendering_cached_placeholder_element = undefined;
591
+ };
592
+ (_rendering_cached_pla = $e3915574cfd3466c$var$rendering_cached_placeholder_element) === null || _rendering_cached_pla === void 0 || _rendering_cached_pla.then(unset_current_rendering, unset_current_rendering);
593
+ } else
594
+ // Otherwise, just make sure we've disposed our root
595
+ dispose_original_copy();
596
+ });
597
+ return $52FdA$solidjs.createMemo(() => {
598
+ const unwrapped_array = get_unwrapped_element()();
599
+ if (!(unwrapped_array !== null && unwrapped_array !== void 0 && unwrapped_array.length) || !unwrapped_array.every(item => item))
600
+ // Haven't finished rendering yet in case of "async" rendering, so don't freeze the elements yet
601
+ return;
602
+ // placeholders have finished rendering, freeze the elements
603
+ // 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
604
+ $e3915574cfd3466c$var$cached_placeholder_element || ($e3915574cfd3466c$var$cached_placeholder_element = 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
605
+ $e3915574cfd3466c$var$rendering_cached_placeholder_element = undefined;
606
+ dispose_original_copy(); // So that this memo will never re-run and the placeholder rendering function can clean up
607
+ 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
608
+ });
609
+ }
524
610
 
525
611
  // Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
526
612
  class $95e4006e1dcb5b72$export$e1d52e4f0c7557a1 extends Error {}
@@ -881,10 +967,13 @@ function $236a257ee52e5414$export$d41d19e89346fa2(_ref) {
881
967
  return (() => {
882
968
  // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
883
969
  const displays_by_key_ = $76012c4468a53d1f$export$7f8bd308237ab5a5($52FdA$solidjs.createMemo(() => recommendations_resource_() || []));
884
- return $76012c4468a53d1f$export$43f0fb951fcb0c54({
970
+ const {
971
+ renderedDisplays_: renderedDisplays_
972
+ } = $a52942afacbced93$export$4a14175d33d81a96({
885
973
  displays_by_key_: displays_by_key_,
886
974
  product_card_template_: product_card_template_
887
975
  });
976
+ return renderedDisplays_;
888
977
  })();
889
978
  }
890
979
  });
@@ -2112,10 +2201,13 @@ function $2c920813c92d6987$export$7da560f849543dff(_ref) {
2112
2201
  return (() => {
2113
2202
  // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
2114
2203
  const displays_by_key_ = $76012c4468a53d1f$export$7f8bd308237ab5a5($52FdA$solidjs.createMemo(() => recommendations_resource_() || []));
2115
- return $76012c4468a53d1f$export$43f0fb951fcb0c54({
2204
+ const {
2205
+ renderedDisplays_: renderedDisplays_
2206
+ } = $a52942afacbced93$export$4a14175d33d81a96({
2116
2207
  displays_by_key_: displays_by_key_,
2117
2208
  product_card_template_: product_card_template_
2118
2209
  });
2210
+ return renderedDisplays_;
2119
2211
  })();
2120
2212
  }
2121
2213
  });
@@ -10770,10 +10862,13 @@ function $c77adcdf5346b187$export$7de92c4c2205ebf3(_ref) {
10770
10862
  if (!should_show() && prev) return prev; // When we're invisible, don't update what we're rendering to be possibly undefined to preserve the same products if possible
10771
10863
  return recommendations_resource() || [];
10772
10864
  }));
10773
- return $76012c4468a53d1f$export$43f0fb951fcb0c54({
10865
+ const {
10866
+ renderedDisplays_: renderedDisplays_
10867
+ } = $a52942afacbced93$export$4a14175d33d81a96({
10774
10868
  displays_by_key_: displays_by_key_,
10775
10869
  product_card_template_: product_card_template_
10776
10870
  });
10871
+ return renderedDisplays_;
10777
10872
  })();
10778
10873
  }
10779
10874
  });
@@ -11440,8 +11535,8 @@ function $0d3ee7000f047e67$export$a1fd619a4743ca08(_ref) {
11440
11535
  let {
11441
11536
  plp_results_: plp_results_,
11442
11537
  product_card_template_: product_card_template_,
11443
- first_result_in_viewport_: [, set_first_result_in_viewport],
11444
- last_result_in_viewport_: [get_last_result_in_viewport_, set_last_result_in_viewport],
11538
+ first_result_in_viewport_: [, setFirstResultInViewport],
11539
+ last_result_in_viewport_: [lastResultInViewport, setLastResultsInViewport],
11445
11540
  all_products_loaded_: all_products_loaded_,
11446
11541
  min_products_to_fetch_: min_products_to_fetch_,
11447
11542
  query_base_: query_base_,
@@ -11449,27 +11544,6 @@ function $0d3ee7000f047e67$export$a1fd619a4743ca08(_ref) {
11449
11544
  is_loading_: is_loading_,
11450
11545
  content_blocks_: content_blocks_
11451
11546
  } = _ref;
11452
- // The following sets up an intersection observer to determine which results are in the viewport, used for the ScrollStatus indicator and knowing when to load more
11453
- const target_to_index_map = new Map();
11454
- const index_to_target_map_ = new Map();
11455
- const currently_intersecting = new Set();
11456
- const intersection_observer = new IntersectionObserver($52FdA$depictaiutilishared.catchify(records => {
11457
- for (let i = 0; i < records.length; i++) {
11458
- const record = records[i];
11459
- const {
11460
- target: target,
11461
- intersectionRatio: intersectionRatio
11462
- } = record;
11463
- const index_of_target = target_to_index_map.get(target);
11464
- if (index_of_target == undefined) return; // It seems like it can happen that we get IntersectionObserverEntries after the onCleanup function for a recommendation card has run, in Firefox. Probably a bug in Firefox? If I understood the bug correctly, this is a workaround.
11465
- const is_in_set = currently_intersecting.has(index_of_target);
11466
- if (intersectionRatio > 0) {
11467
- if (!is_in_set) currently_intersecting.add(index_of_target);
11468
- } else if (is_in_set) currently_intersecting.delete(index_of_target);
11469
- }
11470
- set_first_result_in_viewport(Math.min(...currently_intersecting) + 1); // +1 because we want to start counting at 1
11471
- set_last_result_in_viewport(Math.max(...currently_intersecting) + 1);
11472
- }, "PLPResults IO failed"));
11473
11547
  // Although typing doesn't reflect it, plp_results is guaranteed to contain an array of at least one display at this point
11474
11548
  const [get_extra_displays, set_extra_displays_] = $52FdA$solidjs.createSignal([], {
11475
11549
  equals: false
@@ -11478,10 +11552,20 @@ function $0d3ee7000f047e67$export$a1fd619a4743ca08(_ref) {
11478
11552
  var _plp_results_;
11479
11553
  return [...(((_plp_results_ = plp_results_()) === null || _plp_results_ === void 0 ? void 0 : _plp_results_.displays) || []), ...get_extra_displays()];
11480
11554
  }));
11555
+ const {
11556
+ indexToTargetMap_: indexToTargetMap_,
11557
+ renderedDisplays_: renderedDisplays_,
11558
+ currentlyIntersecting: currentlyIntersecting
11559
+ } = $a52942afacbced93$export$4a14175d33d81a96({
11560
+ displays_by_key_: displays_by_key_,
11561
+ product_card_template_: product_card_template_,
11562
+ content_blocks_: content_blocks_,
11563
+ alwaysObserveCards_: true
11564
+ });
11481
11565
  const percentage_in_view_ = $45c16e404a883f74$export$63dd0350f8559dda({
11482
- get_last_result_in_viewport_: get_last_result_in_viewport_,
11566
+ get_last_result_in_viewport_: lastResultInViewport,
11483
11567
  displays_by_key_: displays_by_key_,
11484
- index_to_target_map_: index_to_target_map_,
11568
+ index_to_target_map_: indexToTargetMap_,
11485
11569
  is_loading_: is_loading_,
11486
11570
  get_extra_displays: get_extra_displays
11487
11571
  });
@@ -11494,30 +11578,12 @@ function $0d3ee7000f047e67$export$a1fd619a4743ca08(_ref) {
11494
11578
  query_base_: query_base_,
11495
11579
  depict_api_: depict_api_
11496
11580
  });
11497
- return $76012c4468a53d1f$export$43f0fb951fcb0c54({
11498
- displays_by_key_: displays_by_key_,
11499
- product_card_template_: product_card_template_,
11500
- content_blocks_: content_blocks_,
11501
- do_per_elements_: (elements, index_accessor) =>
11502
- // Adds/removes elements from the "results in viewport" intersection observer above
11503
- $52FdA$solidjs.createEffect(() => {
11504
- const display_index = index_accessor();
11505
- // Nested createEffect because we only want to re-run this when the index changes
11506
- // We need to save in a map which index the elements of this template are so that we can know that in the IntersectionObserver callback
11507
- for (let i = 0; i < elements.length; i++) {
11508
- const element = elements[i];
11509
- target_to_index_map.set(element, display_index);
11510
- intersection_observer.observe(element);
11511
- $52FdA$solidjs.onCleanup(() => {
11512
- intersection_observer.unobserve(element);
11513
- target_to_index_map.delete(element);
11514
- currently_intersecting.delete(display_index);
11515
- });
11516
- }
11517
- index_to_target_map_.set(display_index, elements);
11518
- $52FdA$solidjs.onCleanup(() => index_to_target_map_.delete(display_index));
11519
- })
11581
+ $52FdA$solidjs.createEffect(() => {
11582
+ const intersecting = currentlyIntersecting();
11583
+ setFirstResultInViewport(Math.min(...intersecting) + 1); // +1 because we want to start counting at 1
11584
+ setLastResultsInViewport(Math.max(...intersecting) + 1);
11520
11585
  });
11586
+ return renderedDisplays_;
11521
11587
  }
11522
11588
  var $830518481649feb1$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<div>`),
11523
11589
  $830518481649feb1$var$_tmpl$2 = /*#__PURE__*/$52FdA$solidjsweb.template(`<style type=text/css>`);
@@ -11948,11 +12014,13 @@ function $484eec37514a982e$export$3925f87b1545cfc6(_ref) {
11948
12014
  cols_at_size_: modified_cols_at_size,
11949
12015
  set_top_row_shortened_by_: set_top_row_shortened_by_
11950
12016
  }));
11951
- const rendered_placeholders = $52FdA$solidjs.createMemo(() => get_should_have_placeholders_rendered() ? $e3915574cfd3466c$export$f33414a4df0afd3f({
11952
- content_blocks_: content_blocks_,
11953
- product_card_template_: product_card_template_,
11954
- num_placeholders_: num_placeholders_
11955
- }) : undefined);
12017
+ const rendered_placeholders = $52FdA$solidjs.createMemo(() => {
12018
+ if (get_should_have_placeholders_rendered()) return $e3915574cfd3466c$export$f33414a4df0afd3f({
12019
+ content_blocks_: content_blocks_,
12020
+ product_card_template_: product_card_template_,
12021
+ num_placeholders_: num_placeholders_
12022
+ });
12023
+ });
11956
12024
  const layout = $52FdA$solidjs.createMemo(() => {
11957
12025
  const incoming_layout = layout_options_().layout;
11958
12026
  if (incoming_layout === "slider-without-filters") return "slider";