@depict-ai/portal-components 2.7.5 → 2.7.6

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/dist/module.js CHANGED
@@ -1,14 +1,13 @@
1
- import {add_to_version_info as $2MCgq$add_to_version_info} from "@depict-ai/utilishared/latest";
2
- import {createSignal as $2MCgq$createSignal, createMemo as $2MCgq$createMemo, untrack as $2MCgq$untrack} from "solid-js";
3
- import {accessor_of_object_to_object_with_accessor_values as $2MCgq$accessor_of_object_to_object_with_accessor_values, create_modified_filters as $2MCgq$create_modified_filters, SelectedFilters as $2MCgq$SelectedFilters, FilterBody as $2MCgq$FilterBody, ExpandingDetails as $2MCgq$ExpandingDetails, ListingProvider as $2MCgq$ListingProvider, PseudoRouter as $2MCgq$PseudoRouter, LookCard as $2MCgq$LookCard} from "@depict-ai/ui/latest";
4
- import {render as $2MCgq$render, insert as $2MCgq$insert} from "solid-js/web";
1
+ import {add_to_version_info as $2MCgq$add_to_version_info, standard_price_format as $2MCgq$standard_price_format, catchify as $2MCgq$catchify, dlog as $2MCgq$dlog, dwarn as $2MCgq$dwarn} from "@depict-ai/utilishared/latest";
2
+ import {render as $2MCgq$render, template as $2MCgq$template, createComponent as $2MCgq$createComponent, addEventListener as $2MCgq$addEventListener, use as $2MCgq$use, insert as $2MCgq$insert, effect as $2MCgq$effect, className as $2MCgq$className, setAttribute as $2MCgq$setAttribute, style as $2MCgq$style, memo as $2MCgq$memo, classList as $2MCgq$classList, spread as $2MCgq$spread, mergeProps as $2MCgq$mergeProps, delegateEvents as $2MCgq$delegateEvents} from "solid-js/web";
5
3
  import {useRef as $2MCgq$useRef, useState as $2MCgq$useState, useEffect as $2MCgq$useEffect, createElement as $2MCgq$createElement, Fragment as $2MCgq$Fragment} from "react";
6
4
  import {createStore as $2MCgq$createStore, reconcile as $2MCgq$reconcile} from "solid-js/store";
5
+ import {media_query_to_accessor as $2MCgq$media_query_to_accessor, TextPlaceholder as $2MCgq$TextPlaceholder, useSlidableInformation as $2MCgq$useSlidableInformation, SlidableItems as $2MCgq$SlidableItems, ImagePlaceholder as $2MCgq$ImagePlaceholder, ImageContainer as $2MCgq$ImageContainer, ShopifyContainedImage as $2MCgq$ShopifyContainedImage, useVisibilityState as $2MCgq$useVisibilityState, useProductCardIndex as $2MCgq$useProductCardIndex, useProductCardIsVisible as $2MCgq$useProductCardIsVisible, accessor_of_object_to_object_with_accessor_values as $2MCgq$accessor_of_object_to_object_with_accessor_values, create_modified_filters as $2MCgq$create_modified_filters, SelectedFilters as $2MCgq$SelectedFilters, FilterBody as $2MCgq$FilterBody, ExpandingDetails as $2MCgq$ExpandingDetails, ListingProvider as $2MCgq$ListingProvider, PseudoRouter as $2MCgq$PseudoRouter, LookCard as $2MCgq$LookCard} from "@depict-ai/ui/latest";
6
+ import {createContext as $2MCgq$createContext, createMemo as $2MCgq$createMemo, createSignal as $2MCgq$createSignal, untrack as $2MCgq$untrack, createResource as $2MCgq$createResource, Suspense as $2MCgq$Suspense, createEffect as $2MCgq$createEffect, Show as $2MCgq$Show, children as $2MCgq$children, onCleanup as $2MCgq$onCleanup, For as $2MCgq$For, createRenderEffect as $2MCgq$createRenderEffect, on as $2MCgq$on, useContext as $2MCgq$useContext} from "solid-js";
7
7
  import {createPortal as $2MCgq$createPortal} from "react-dom";
8
8
 
9
9
  /*! Depict.ai portal components */ // This is where the actual source of your React stuff should live
10
- const $91c11b750e80ede3$export$83d89fbfd8236492 = "2.7.5";
11
-
10
+ const $91c11b750e80ede3$export$83d89fbfd8236492 = "2.7.6";
12
11
 
13
12
 
14
13
 
@@ -36,6 +35,955 @@ function $0fe03f2fcd2418f8$export$f6e64e17bd69eeef({ solid_component: solid_comp
36
35
 
37
36
 
38
37
 
38
+
39
+
40
+
41
+ var $29535f590238371c$var$_tmpl$ = /*#__PURE__*/ (0, $2MCgq$template)(`<a>`), $29535f590238371c$var$_tmpl$2 = /*#__PURE__*/ (0, $2MCgq$template)(`<div class="d-title line-clamp">`), $29535f590238371c$var$_tmpl$3 = /*#__PURE__*/ (0, $2MCgq$template)(`<div class=d-product-card>`), $29535f590238371c$var$_tmpl$4 = /*#__PURE__*/ (0, $2MCgq$template)(`<svg xmlns=http://www.w3.org/2000/svg width=12 height=12 class=more><path d="M10.8 6c0 .153-.061.299-.169.407s-.255.169-.407.169H6.576v3.648c0 .153-.061.299-.169.407S6.153 10.8 6 10.8s-.299-.061-.407-.169-.169-.255-.169-.407V6.576H1.776c-.153 0-.299-.061-.407-.169S1.2 6.153 1.2 6s.061-.299.169-.407.255-.169.407-.169h3.648V1.776c0-.153.061-.299.169-.407S5.847 1.2 6 1.2s.299.061.407.169.169.255.169.407v3.648h3.648c.153 0 .299.061.407.169s.169.255.169.407z">`), $29535f590238371c$var$_tmpl$5 = /*#__PURE__*/ (0, $2MCgq$template)(`<div class=d-swatches>`), $29535f590238371c$var$_tmpl$6 = /*#__PURE__*/ (0, $2MCgq$template)(`<a class=d-swatch>`), $29535f590238371c$var$_tmpl$7 = /*#__PURE__*/ (0, $2MCgq$template)(`<span class=more>+ <!> more`), $29535f590238371c$var$_tmpl$8 = /*#__PURE__*/ (0, $2MCgq$template)(`<div class=sizes>`), $29535f590238371c$var$_tmpl$9 = /*#__PURE__*/ (0, $2MCgq$template)(`<span>`), $29535f590238371c$var$_tmpl$10 = /*#__PURE__*/ (0, $2MCgq$template)(`<s>`), $29535f590238371c$var$_tmpl$11 = /*#__PURE__*/ (0, $2MCgq$template)(`<div>`), $29535f590238371c$var$_tmpl$12 = /*#__PURE__*/ (0, $2MCgq$template)(`<div class="media-item video">`), $29535f590238371c$var$_tmpl$13 = /*#__PURE__*/ (0, $2MCgq$template)(`<div class="media-item image">`), $29535f590238371c$var$_tmpl$14 = /*#__PURE__*/ (0, $2MCgq$template)(`<source type=application/x-mpegURL>`), $29535f590238371c$var$_tmpl$15 = /*#__PURE__*/ (0, $2MCgq$template)(`<video class=s-responsive-image crossorigin=anonymous>`), $29535f590238371c$var$_tmpl$16 = /*#__PURE__*/ (0, $2MCgq$template)(`<source>`), $29535f590238371c$var$_tmpl$17 = /*#__PURE__*/ (0, $2MCgq$template)(`<span class=price>`), $29535f590238371c$var$_tmpl$18 = /*#__PURE__*/ (0, $2MCgq$template)(`<span class=original-price>`);
42
+ // You can import from the solid-js library here and leverage its reactivity to create an interactive UI.
43
+ // Also, Depict packages can be imported (you must import /latest from those).
44
+ const $29535f590238371c$var$sizeOrder = [
45
+ "XXS",
46
+ "XS",
47
+ "XS/S",
48
+ "S",
49
+ "S/M",
50
+ "M",
51
+ "M/L",
52
+ "L",
53
+ "L/XL",
54
+ "XL",
55
+ "XL/XXL",
56
+ "XXL",
57
+ "One Size",
58
+ "Onesize"
59
+ ];
60
+ const $29535f590238371c$var$imageAspectRatio = 1;
61
+ const $29535f590238371c$var$ContainsColorSwatchesContext = /*@__PURE__*/ (0, $2MCgq$createContext)();
62
+ let $29535f590238371c$var$colorCanvasContext;
63
+ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOptions_ = ()=>({
64
+ image_radius: "md",
65
+ alignment: "left",
66
+ sizes: true,
67
+ smart_labels: {
68
+ font_size_rem: 0.5,
69
+ enabled: true,
70
+ bold: false,
71
+ italic: false,
72
+ color: "red",
73
+ bg_color: "yellow"
74
+ },
75
+ title: {
76
+ font_size_rem: 1.6,
77
+ enabled: true,
78
+ bold: false,
79
+ italic: false,
80
+ color: "black"
81
+ },
82
+ price: {
83
+ font_size_rem: 1.5,
84
+ enabled: true,
85
+ bold: false,
86
+ italic: false,
87
+ color: "black"
88
+ },
89
+ original_price: {
90
+ font_size_rem: 0.9,
91
+ enabled: true,
92
+ bold: false,
93
+ italic: false,
94
+ color: "black"
95
+ },
96
+ use_hover_image: true,
97
+ image_carousel: true,
98
+ color_options: true
99
+ })) {
100
+ const variantDisplays = (0, $2MCgq$createMemo)(()=>display()?.variant_displays);
101
+ const defaultVariantIndex = (0, $2MCgq$createMemo)(()=>display()?.variant_index);
102
+ const [showVariantIndex, setShowVariantIndex] = (0, $2MCgq$createSignal)((0, $2MCgq$untrack)(defaultVariantIndex));
103
+ const [cardIsHovered, setCardIsHovered] = (0, $2MCgq$createSignal)(false);
104
+ const variantToShow = (0, $2MCgq$createMemo)(()=>variantDisplays()?.[showVariantIndex()]);
105
+ const noHoverSupport_ = (0, $2MCgq$media_query_to_accessor)("(hover: none)");
106
+ const sizesInStock_ = (0, $2MCgq$createMemo)(()=>new Map(variantDisplays()?.map((d)=>[
107
+ d.size_name,
108
+ d.in_stock
109
+ ]).filter(([name])=>name)));
110
+ const titleOptions = (0, $2MCgq$createMemo)(()=>configuredOptions_().title);
111
+ const colorMap = (0, $2MCgq$createMemo)(()=>new Map(variantDisplays()?.map((variant, index)=>[
112
+ variant.color_name,
113
+ {
114
+ hexColor_: variant.color_name,
115
+ pageUrl_: variant.page_url,
116
+ variantIndex_: index
117
+ }
118
+ ]).filter(([colorName])=>colorName) // in case color_name is null
119
+ ));
120
+ const [salePrice] = (0, $2MCgq$createResource)(variantToShow, (v)=>v?.sale_price);
121
+ const [originalPrice] = (0, $2MCgq$createResource)(variantToShow, (v)=>v?.original_price);
122
+ const onSale = (0, $2MCgq$createMemo)(()=>(0, $2MCgq$createComponent)((0, $2MCgq$Suspense), {
123
+ get children () {
124
+ return originalPrice() !== salePrice();
125
+ }
126
+ }));
127
+ const swatchContainerHeight = (0, $2MCgq$createMemo)(()=>{
128
+ // To avoid the product cards switching around as one hovers and price switches to the swatches, we have to make the swatches container have the same height as the price one
129
+ let considerSize = [];
130
+ const { original_price: original_price, price: price } = configuredOptions_();
131
+ const isOnSale = onSale?.()?.(); // Hack for getting if we're on sale without triggering <Suspense> above us
132
+ if (price.enabled) considerSize.push(price.font_size_rem);
133
+ if (original_price.enabled && isOnSale) considerSize.push(original_price.font_size_rem);
134
+ if (!considerSize.length) return;
135
+ return Math.max(...considerSize);
136
+ });
137
+ const LinkWrapped = (props)=>(()=>{
138
+ var _el$ = $29535f590238371c$var$_tmpl$();
139
+ (0, $2MCgq$addEventListener)(_el$, "click", (0, $2MCgq$catchify)((e)=>{
140
+ const { target: target } = e;
141
+ const navbuttonSelector = ".d-navbutton";
142
+ if (target.matches(navbuttonSelector) || target.closest(navbuttonSelector)) // Don't navigate if optional slider button that can be shown using css was clicked
143
+ e.preventDefault();
144
+ }), true);
145
+ (0, $2MCgq$use)((el)=>props?.ref?.(el), _el$);
146
+ (0, $2MCgq$insert)(_el$, ()=>props.children);
147
+ (0, $2MCgq$effect)((_p$)=>{
148
+ var _v$ = props.class, _v$2 = variantToShow()?.page_url || "#";
149
+ _v$ !== _p$.e && (0, $2MCgq$className)(_el$, _p$.e = _v$);
150
+ _v$2 !== _p$.t && (0, $2MCgq$setAttribute)(_el$, "href", _p$.t = _v$2);
151
+ return _p$;
152
+ }, {
153
+ e: undefined,
154
+ t: undefined
155
+ });
156
+ return _el$;
157
+ })();
158
+ const Title = (props)=>(()=>{
159
+ var _el$2 = $29535f590238371c$var$_tmpl$2();
160
+ var _ref$ = props.ref_;
161
+ typeof _ref$ === "function" ? (0, $2MCgq$use)(_ref$, _el$2) : props.ref_ = _el$2;
162
+ (0, $2MCgq$insert)(_el$2, ()=>variantToShow()?.title ?? [
163
+ (0, $2MCgq$createComponent)((0, $2MCgq$TextPlaceholder), {
164
+ height: "1em",
165
+ width: "20ch"
166
+ }),
167
+ (0, $2MCgq$createComponent)((0, $2MCgq$TextPlaceholder), {
168
+ height: "1em",
169
+ width: "20ch"
170
+ })
171
+ ]);
172
+ (0, $2MCgq$effect)((_p$)=>{
173
+ var _v$3 = variantToShow()?.title, _v$4 = $29535f590238371c$var$styleForTextOptions(titleOptions());
174
+ _v$3 !== _p$.e && (0, $2MCgq$setAttribute)(_el$2, "title", _p$.e = _v$3);
175
+ _p$.t = (0, $2MCgq$style)(_el$2, _v$4, _p$.t);
176
+ return _p$;
177
+ }, {
178
+ e: undefined,
179
+ t: undefined
180
+ });
181
+ return _el$2;
182
+ })();
183
+ (0, $2MCgq$createEffect)(()=>noHoverSupport_() && setCardIsHovered(false));
184
+ return (0, $2MCgq$createComponent)($29535f590238371c$var$ContainsColorSwatchesProvider, {
185
+ get children () {
186
+ var _el$3 = $29535f590238371c$var$_tmpl$3();
187
+ (0, $2MCgq$addEventListener)(_el$3, "mouseleave", (0, $2MCgq$catchify)(()=>!noHoverSupport_() && setCardIsHovered(false)));
188
+ (0, $2MCgq$addEventListener)(_el$3, "mouseenter", (0, $2MCgq$catchify)(()=>!noHoverSupport_() && setCardIsHovered(true)));
189
+ (0, $2MCgq$insert)(_el$3, (0, $2MCgq$createComponent)(LinkWrapped, {
190
+ "class": "upper",
191
+ get children () {
192
+ return (0, $2MCgq$createComponent)($29535f590238371c$var$ImagesAndVideos, {
193
+ image_urls_: ()=>variantToShow()?.image_urls,
194
+ video_: ()=>variantToShow()?.videos?.[0],
195
+ configuredOptions_: configuredOptions_,
196
+ cardIsHovered_: ()=>showVariantIndex() === display()?.variant_index && cardIsHovered()
197
+ });
198
+ }
199
+ }), null);
200
+ (0, $2MCgq$insert)(_el$3, (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
201
+ get when () {
202
+ return titleOptions().enabled || configuredOptions_().price.enabled || configuredOptions_().sizes || configuredOptions_().color_options;
203
+ },
204
+ get children () {
205
+ return (()=>{
206
+ // We want the whole product card to be a link, except for the color swatches
207
+ const [containsColorSwatches] = $29535f590238371c$var$useContainsColorSwatches();
208
+ const LinkWrappedIfHaveSwatches = (props)=>{
209
+ const resolved = (0, $2MCgq$children)(()=>props.children);
210
+ return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
211
+ get when () {
212
+ return containsColorSwatches();
213
+ },
214
+ get fallback () {
215
+ return resolved();
216
+ },
217
+ get children () {
218
+ return (0, $2MCgq$createComponent)(LinkWrapped, {
219
+ get children () {
220
+ return resolved();
221
+ }
222
+ });
223
+ }
224
+ });
225
+ };
226
+ return (0, $2MCgq$createComponent)($29535f590238371c$var$InComponentOrDiv, {
227
+ get component_ () {
228
+ return !containsColorSwatches() && LinkWrapped;
229
+ },
230
+ class_: "text-container",
231
+ get children () {
232
+ return [
233
+ (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
234
+ get when () {
235
+ return titleOptions().enabled;
236
+ },
237
+ get fallback () {
238
+ return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
239
+ get when () {
240
+ return configuredOptions_().sizes;
241
+ },
242
+ get children () {
243
+ return (0, $2MCgq$createComponent)(LinkWrappedIfHaveSwatches, {
244
+ get children () {
245
+ return (0, $2MCgq$createComponent)($29535f590238371c$var$Sizes, {
246
+ sizesInStock_: sizesInStock_,
247
+ fontSizeRem_: ()=>titleOptions().font_size_rem
248
+ });
249
+ }
250
+ });
251
+ }
252
+ });
253
+ },
254
+ get children () {
255
+ return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
256
+ get when () {
257
+ return (0, $2MCgq$memo)(()=>!!configuredOptions_().sizes)() && sizesInStock_().size > 1;
258
+ },
259
+ get fallback () {
260
+ return (0, $2MCgq$createComponent)(LinkWrappedIfHaveSwatches, {
261
+ get children () {
262
+ return (0, $2MCgq$createComponent)(Title, {});
263
+ }
264
+ });
265
+ },
266
+ get children () {
267
+ return (0, $2MCgq$createComponent)($29535f590238371c$var$AnimatedRowSwitch, {
268
+ DefaultComponent_: Title,
269
+ HoveredComponent_: ({ ref_: ref_ })=>(0, $2MCgq$createComponent)($29535f590238371c$var$Sizes, {
270
+ sizesInStock_: sizesInStock_,
271
+ fontSizeRem_: ()=>titleOptions().font_size_rem,
272
+ ref_: ref_
273
+ }),
274
+ cardIsHovered_: cardIsHovered,
275
+ containerComponent_: ()=>containsColorSwatches() && LinkWrapped
276
+ });
277
+ }
278
+ });
279
+ }
280
+ }),
281
+ (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
282
+ get when () {
283
+ return configuredOptions_().price.enabled;
284
+ },
285
+ get fallback () {
286
+ return (0, $2MCgq$memo)(()=>!!configuredOptions_().color_options)() && (0, $2MCgq$createComponent)($29535f590238371c$var$ColorSwatches, {
287
+ colorMap_: colorMap,
288
+ showVariantIndex_: showVariantIndex,
289
+ setShowVariantIndex_: setShowVariantIndex,
290
+ colorsAtIndex_: ()=>variantDisplays()?.map((variant)=>variant.color_name),
291
+ wantedContainerHeightRem_: swatchContainerHeight,
292
+ defaultVariantIndex_: defaultVariantIndex
293
+ });
294
+ },
295
+ get children () {
296
+ return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
297
+ get when () {
298
+ return (0, $2MCgq$memo)(()=>!!configuredOptions_().color_options)() && colorMap().size > 1;
299
+ },
300
+ get fallback () {
301
+ return (0, $2MCgq$createComponent)($29535f590238371c$var$Prices, {
302
+ variantToShow_: variantToShow,
303
+ get formatPrice_ () {
304
+ return info?.formatPrice;
305
+ },
306
+ configuredOptions_: configuredOptions_,
307
+ salePrice_: salePrice,
308
+ originalPrice_: originalPrice,
309
+ wrapperComponent_: ()=>containsColorSwatches() && LinkWrapped
310
+ });
311
+ },
312
+ get children () {
313
+ return (0, $2MCgq$createComponent)($29535f590238371c$var$AnimatedRowSwitch, {
314
+ containerComponent_: ()=>!containsColorSwatches() && LinkWrapped,
315
+ DefaultComponent_: ({ ref_: ref_ })=>(0, $2MCgq$createComponent)($29535f590238371c$var$Prices, {
316
+ variantToShow_: variantToShow,
317
+ get formatPrice_ () {
318
+ return info?.formatPrice;
319
+ },
320
+ salePrice_: salePrice,
321
+ originalPrice_: originalPrice,
322
+ configuredOptions_: configuredOptions_,
323
+ wrapperComponent_: ()=>containsColorSwatches() && LinkWrapped,
324
+ ref_: ref_
325
+ }),
326
+ HoveredComponent_: ({ ref_: ref_ })=>(0, $2MCgq$createComponent)($29535f590238371c$var$ColorSwatches, {
327
+ colorMap_: colorMap,
328
+ showVariantIndex_: showVariantIndex,
329
+ setShowVariantIndex_: setShowVariantIndex,
330
+ colorsAtIndex_: ()=>variantDisplays()?.map((variant)=>variant.color_name),
331
+ ref_: ref_,
332
+ wantedContainerHeightRem_: swatchContainerHeight,
333
+ defaultVariantIndex_: defaultVariantIndex
334
+ }),
335
+ cardIsHovered_: cardIsHovered
336
+ });
337
+ }
338
+ });
339
+ }
340
+ })
341
+ ];
342
+ }
343
+ });
344
+ })();
345
+ }
346
+ }), null);
347
+ (0, $2MCgq$effect)(()=>configuredOptions_().alignment != null ? _el$3.style.setProperty("--alignment", configuredOptions_().alignment) : _el$3.style.removeProperty("--alignment"));
348
+ return _el$3;
349
+ }
350
+ });
351
+ }
352
+ /**
353
+ * Transitions between DefaultComponent_ and HoveredComponent_ when cardIsHovered_ changes in both height and opacity.
354
+ */ function $29535f590238371c$var$AnimatedRowSwitch({ DefaultComponent_: DefaultComponent_, HoveredComponent_: HoveredComponent_, cardIsHovered_: cardIsHovered_, containerComponent_: containerComponent_ }) {
355
+ let defaultElement;
356
+ let hoveredElement;
357
+ let containerElement;
358
+ let defaultElementAnimation;
359
+ let hoveredElementAnimation;
360
+ let containerAnimation;
361
+ const fadeInKeyframes = [
362
+ {
363
+ opacity: 0,
364
+ pointerEvents: "none",
365
+ cursor: "default"
366
+ },
367
+ {
368
+ opacity: 1,
369
+ pointerEvents: "auto",
370
+ cursor: "unset"
371
+ }
372
+ ];
373
+ const fadeOutKeyframes = [
374
+ ...fadeInKeyframes
375
+ ].reverse();
376
+ (0, $2MCgq$createEffect)((firstRun)=>{
377
+ const isHovered = cardIsHovered_();
378
+ if (!hoveredElement || !defaultElement) return; // Got no sizes probably, can't switch to anything
379
+ const hoveredStyle = hoveredElement.style;
380
+ const defaultStyle = defaultElement.style;
381
+ const containerStyle = containerElement.style;
382
+ const duration = 200;
383
+ const easing = "ease-in-out";
384
+ hoveredStyle.position = "absolute";
385
+ if (firstRun) {
386
+ Object.assign(hoveredStyle, fadeInKeyframes[0]);
387
+ return;
388
+ }
389
+ defaultStyle.position = "absolute";
390
+ // These animations we can let live forever, since opacity always goes between 0 and 1
391
+ hoveredElementAnimation ||= hoveredElement.animate(fadeInKeyframes, {
392
+ duration: duration,
393
+ fill: "both",
394
+ easing: easing
395
+ });
396
+ defaultElementAnimation ||= defaultElement.animate(fadeOutKeyframes, {
397
+ duration: duration,
398
+ fill: "both",
399
+ easing: easing
400
+ });
401
+ if (!containerAnimation) {
402
+ const containerKeyframes = [
403
+ {
404
+ height: defaultElement.getBoundingClientRect().height + "px"
405
+ },
406
+ {
407
+ height: hoveredElement.getBoundingClientRect().height + "px"
408
+ }
409
+ ];
410
+ containerAnimation = containerElement.animate(containerKeyframes, {
411
+ duration: duration,
412
+ easing: easing
413
+ });
414
+ containerAnimation.finished.then(()=>{
415
+ containerAnimation?.cancel();
416
+ containerAnimation = undefined;
417
+ // Animation can survive direction change so need to get current hovered state when it finishes
418
+ const hoveredNow = (0, $2MCgq$untrack)(cardIsHovered_);
419
+ containerStyle.height = "";
420
+ if (hoveredNow) hoveredStyle.position = "";
421
+ else defaultStyle.position = "";
422
+ });
423
+ if (!isHovered) // When starting the animation in reverse we need to set the current time to the end of the animation
424
+ containerAnimation.currentTime = containerAnimation.effect.getComputedTiming().endTime;
425
+ // Remove this animation once it has finished and re-create it later since the size of the elements containing texts might change, i.e. when the window is resized of zoom level adjusted
426
+ }
427
+ const animationDirection = isHovered ? 1 : -1;
428
+ defaultElementAnimation.updatePlaybackRate(animationDirection);
429
+ defaultElementAnimation.play();
430
+ hoveredElementAnimation.updatePlaybackRate(animationDirection);
431
+ hoveredElementAnimation.play();
432
+ containerAnimation.updatePlaybackRate(animationDirection);
433
+ }, true);
434
+ return (0, $2MCgq$createComponent)($29535f590238371c$var$InComponentOrDiv, {
435
+ get component_ () {
436
+ return containerComponent_();
437
+ },
438
+ class_: "animated-row-switch",
439
+ ref_: (el)=>containerElement = el,
440
+ get children () {
441
+ return [
442
+ (0, $2MCgq$createComponent)(DefaultComponent_, {
443
+ ref_: (el)=>defaultElement = el
444
+ }),
445
+ (0, $2MCgq$createComponent)(HoveredComponent_, {
446
+ ref_: (el)=>hoveredElement = el
447
+ })
448
+ ];
449
+ }
450
+ });
451
+ }
452
+ function $29535f590238371c$var$ColorSwatches({ colorMap_: colorMap_, setShowVariantIndex_: setShowVariantIndex_, showVariantIndex_: showVariantIndex_, colorsAtIndex_: colorsAtIndex_, wantedContainerHeightRem_: wantedContainerHeightRem_, defaultVariantIndex_: defaultVariantIndex_, ref_: ref_ }) {
453
+ let unHoverDebouncedTimeout;
454
+ const entriesToShow = ()=>[
455
+ ...colorMap_().entries()
456
+ ].slice(0, 12);
457
+ const [, setContainsColorSwatches] = $29535f590238371c$var$useContainsColorSwatches();
458
+ return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
459
+ get when () {
460
+ return entriesToShow().length > 1;
461
+ },
462
+ get children () {
463
+ return (()=>{
464
+ setContainsColorSwatches(true);
465
+ (0, $2MCgq$onCleanup)(()=>setContainsColorSwatches(false));
466
+ return (()=>{
467
+ var _el$4 = $29535f590238371c$var$_tmpl$5();
468
+ var _ref$2 = ref_;
469
+ typeof _ref$2 === "function" ? (0, $2MCgq$use)(_ref$2, _el$4) : ref_ = _el$4;
470
+ (0, $2MCgq$insert)(_el$4, (0, $2MCgq$createComponent)((0, $2MCgq$For), {
471
+ get each () {
472
+ return entriesToShow();
473
+ },
474
+ children: ([colorName, { pageUrl_: pageUrl_, hexColor_: hexColor_, variantIndex_: variantIndex_ }])=>{
475
+ const thisColorIsDefaultColor = (0, $2MCgq$createMemo)(()=>colorsAtIndex_()?.[defaultVariantIndex_()] === colorName);
476
+ // Since we don't have actual colors right now and rely on color names working as css colors
477
+ // We need a default fallback for it being usable
478
+ const [invalidColor, setInvalidColor] = (0, $2MCgq$createSignal)(false);
479
+ return (()=>{
480
+ var _el$6 = $29535f590238371c$var$_tmpl$6();
481
+ (0, $2MCgq$use)((element)=>requestAnimationFrame(// After one frame we're usually in the DOM, if we're not boxShadow is ""
482
+ // If it's none, the color was invalid - so just show this swatch as a white swatch which is the prettiest
483
+ (0, $2MCgq$catchify)(()=>getComputedStyle(element).boxShadow === "none" && setInvalidColor(true))), _el$6);
484
+ (0, $2MCgq$addEventListener)(_el$6, "pointerleave", (0, $2MCgq$catchify)((e)=>{
485
+ clearTimeout(unHoverDebouncedTimeout);
486
+ unHoverDebouncedTimeout = setTimeout((0, $2MCgq$catchify)(()=>setShowVariantIndex_(defaultVariantIndex_())), 500);
487
+ }));
488
+ (0, $2MCgq$addEventListener)(_el$6, "pointerenter", (0, $2MCgq$catchify)((e)=>{
489
+ clearTimeout(unHoverDebouncedTimeout);
490
+ setShowVariantIndex_(thisColorIsDefaultColor() ? defaultVariantIndex_() : variantIndex_);
491
+ }));
492
+ (0, $2MCgq$setAttribute)(_el$6, "href", pageUrl_);
493
+ (0, $2MCgq$setAttribute)(_el$6, "title", colorName);
494
+ (0, $2MCgq$effect)((_p$)=>{
495
+ var _v$5 = `--background:${invalidColor() ? "white" : hexColor_}`, _v$6 = !!(colorsAtIndex_?.[showVariantIndex_()] === colorName), _v$7 = !!thisColorIsDefaultColor(), _v$8 = !!($29535f590238371c$var$isLightColor(hexColor_) || invalidColor());
496
+ _p$.e = (0, $2MCgq$style)(_el$6, _v$5, _p$.e);
497
+ _v$6 !== _p$.t && _el$6.classList.toggle("selected", _p$.t = _v$6);
498
+ _v$7 !== _p$.a && _el$6.classList.toggle("first", _p$.a = _v$7);
499
+ _v$8 !== _p$.o && _el$6.classList.toggle("light-colored", _p$.o = _v$8);
500
+ return _p$;
501
+ }, {
502
+ e: undefined,
503
+ t: undefined,
504
+ a: undefined,
505
+ o: undefined
506
+ });
507
+ return _el$6;
508
+ })();
509
+ }
510
+ }), null);
511
+ (0, $2MCgq$insert)(_el$4, (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
512
+ get when () {
513
+ return entriesToShow().length !== colorMap_().size;
514
+ },
515
+ get children () {
516
+ return $29535f590238371c$var$_tmpl$4();
517
+ }
518
+ }), null);
519
+ (0, $2MCgq$effect)((_$p)=>(0, $2MCgq$style)(_el$4, isNaN(wantedContainerHeightRem_()) ? "" : `--swatch-container-height:${wantedContainerHeightRem_()}rem`, _$p));
520
+ return _el$4;
521
+ })();
522
+ })();
523
+ }
524
+ });
525
+ }
526
+ function $29535f590238371c$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_, fontSizeRem_: fontSizeRem_ }) {
527
+ const keys = ()=>[
528
+ ...sizesInStock_().keys()
529
+ ];
530
+ const keysToShow = ()=>keys().slice(0, 7);
531
+ const hidden = ()=>keys().length - keysToShow().length;
532
+ return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
533
+ get when () {
534
+ return keysToShow().length > 1;
535
+ },
536
+ get children () {
537
+ var _el$7 = $29535f590238371c$var$_tmpl$8();
538
+ var _ref$3 = ref_;
539
+ typeof _ref$3 === "function" ? (0, $2MCgq$use)(_ref$3, _el$7) : ref_ = _el$7;
540
+ (0, $2MCgq$insert)(_el$7, (0, $2MCgq$createComponent)((0, $2MCgq$For), {
541
+ get each () {
542
+ return $29535f590238371c$var$sortSizes(keysToShow());
543
+ },
544
+ children: (size)=>(0, $2MCgq$createComponent)((0, $2MCgq$Show), {
545
+ get when () {
546
+ return sizesInStock_().get(size);
547
+ },
548
+ get fallback () {
549
+ return (()=>{
550
+ var _el$13 = $29535f590238371c$var$_tmpl$10();
551
+ (0, $2MCgq$insert)(_el$13, size);
552
+ return _el$13;
553
+ })();
554
+ },
555
+ get children () {
556
+ var _el$12 = $29535f590238371c$var$_tmpl$9();
557
+ (0, $2MCgq$insert)(_el$12, size);
558
+ return _el$12;
559
+ }
560
+ })
561
+ }), null);
562
+ (0, $2MCgq$insert)(_el$7, (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
563
+ get when () {
564
+ return hidden() > 0;
565
+ },
566
+ get children () {
567
+ var _el$8 = $29535f590238371c$var$_tmpl$7(), _el$9 = _el$8.firstChild, _el$11 = _el$9.nextSibling, _el$10 = _el$11.nextSibling;
568
+ (0, $2MCgq$insert)(_el$8, hidden, _el$11);
569
+ return _el$8;
570
+ }
571
+ }), null);
572
+ (0, $2MCgq$effect)((_$p)=>(0, $2MCgq$style)(_el$7, `--font-size-rem:${fontSizeRem_()}rem`, _$p));
573
+ return _el$7;
574
+ }
575
+ });
576
+ }
577
+ function $29535f590238371c$var$styleForTextOptions(options) {
578
+ return {
579
+ "--font-size-rem": options.font_size_rem + "rem",
580
+ ...options.bold && {
581
+ "--font-weight": "bold"
582
+ },
583
+ ...options.italic && {
584
+ "--font-style": "italic"
585
+ },
586
+ ...options.color && {
587
+ "--color": options.color
588
+ },
589
+ ...options.bg_color && {
590
+ "--background": options.bg_color
591
+ }
592
+ };
593
+ }
594
+ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video_: video_, configuredOptions_: configuredOptions_, cardIsHovered_: cardIsHovered_ }) {
595
+ const isAlreadyInSlider = !!(0, $2MCgq$useSlidableInformation)();
596
+ const containerClasses = ()=>[
597
+ "image-video",
598
+ "border-radius-" + configuredOptions_().image_radius
599
+ ];
600
+ // Don't make cards swipable inside of sliders (PLP slider or recs slider)
601
+ const slidable = (0, $2MCgq$createMemo)(()=>!isAlreadyInSlider && configuredOptions_().image_carousel);
602
+ const hoverImageDisabled = (0, $2MCgq$createMemo)(()=>!configuredOptions_().use_hover_image);
603
+ const video_urls = ()=>video_()?.video_urls;
604
+ const Container = (props)=>{
605
+ if (slidable()) return (0, $2MCgq$createComponent)((0, $2MCgq$SlidableItems), {
606
+ arrow_height_: 25,
607
+ arrow_width_: 12.5,
608
+ disable_fading_: true,
609
+ slider_ref_: (slider)=>{
610
+ const { container: container, insert_here: insert_here } = slider;
611
+ slider.stepstoslide = 1; // In case anyone enables the hidden buttons using css
612
+ (0, $2MCgq$createRenderEffect)((previous)=>(0, $2MCgq$classList)(container, {
613
+ products: true,
614
+ ...Object.fromEntries(containerClasses().map((cls)=>[
615
+ cls,
616
+ true
617
+ ]))
618
+ }, previous));
619
+ // Scroll to beginning when changing what variant we're showing
620
+ (0, $2MCgq$createEffect)((0, $2MCgq$on)(image_urls_, ()=>insert_here.scrollTo({
621
+ left: 0,
622
+ behavior: "auto"
623
+ }), {
624
+ defer: true
625
+ }));
626
+ },
627
+ get children () {
628
+ return props.children;
629
+ }
630
+ });
631
+ return (()=>{
632
+ var _el$14 = $29535f590238371c$var$_tmpl$11();
633
+ (0, $2MCgq$insert)(_el$14, ()=>props.children);
634
+ (0, $2MCgq$effect)(()=>(0, $2MCgq$className)(_el$14, containerClasses().join(" ")));
635
+ return _el$14;
636
+ })();
637
+ };
638
+ return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
639
+ get when () {
640
+ return image_urls_();
641
+ },
642
+ get fallback () {
643
+ return (0, $2MCgq$createComponent)((0, $2MCgq$ImagePlaceholder), {
644
+ aspectRatio: $29535f590238371c$var$imageAspectRatio
645
+ });
646
+ },
647
+ get children () {
648
+ return (0, $2MCgq$createComponent)(Container, {
649
+ get children () {
650
+ return [
651
+ (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
652
+ get when () {
653
+ return video_urls()?.length;
654
+ },
655
+ get children () {
656
+ var _el$15 = $29535f590238371c$var$_tmpl$12();
657
+ (0, $2MCgq$insert)(_el$15, (0, $2MCgq$createComponent)((0, $2MCgq$ImageContainer), {
658
+ aspectRatio: $29535f590238371c$var$imageAspectRatio,
659
+ get children () {
660
+ return (0, $2MCgq$createComponent)($29535f590238371c$var$Video, {
661
+ get video_sources_ () {
662
+ return video_urls();
663
+ },
664
+ get poster_ () {
665
+ return video_()?.preview_image_url || image_urls_()?.[0];
666
+ }
667
+ });
668
+ }
669
+ }));
670
+ return _el$15;
671
+ }
672
+ }),
673
+ (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
674
+ get when () {
675
+ return !video_urls()?.length || slidable();
676
+ },
677
+ get children () {
678
+ return (0, $2MCgq$createComponent)((0, $2MCgq$For), {
679
+ get each () {
680
+ return (0, $2MCgq$memo)(()=>!!slidable())() ? image_urls_() : image_urls_()?.slice(0, 1);
681
+ },
682
+ children: (image_url, index)=>(0, $2MCgq$createComponent)((0, $2MCgq$Show), {
683
+ get when () {
684
+ return hoverImageDisabled() || index() !== 1;
685
+ },
686
+ get children () {
687
+ var _el$16 = $29535f590238371c$var$_tmpl$13();
688
+ (0, $2MCgq$insert)(_el$16, (0, $2MCgq$createComponent)((0, $2MCgq$ShopifyContainedImage), {
689
+ src: image_url,
690
+ aspectRatio: $29535f590238371c$var$imageAspectRatio,
691
+ imgProps: {
692
+ alt: "Product image"
693
+ }
694
+ }), null);
695
+ (0, $2MCgq$insert)(_el$16, (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
696
+ get when () {
697
+ return (0, $2MCgq$memo)(()=>!!(!index() && image_urls_()?.[1]))() && !hoverImageDisabled();
698
+ },
699
+ get children () {
700
+ return (0, $2MCgq$createComponent)((0, $2MCgq$ShopifyContainedImage), {
701
+ get src () {
702
+ return image_urls_()[1];
703
+ },
704
+ aspectRatio: $29535f590238371c$var$imageAspectRatio,
705
+ imgProps: {
706
+ alt: "Product image"
707
+ },
708
+ get ["class"] () {
709
+ return `hover${cardIsHovered_() ? " visible" : ""}`;
710
+ }
711
+ });
712
+ }
713
+ }), null);
714
+ return _el$16;
715
+ }
716
+ })
717
+ });
718
+ }
719
+ })
720
+ ];
721
+ }
722
+ });
723
+ }
724
+ });
725
+ }
726
+ function $29535f590238371c$var$Video(props) {
727
+ // Making some assumptions for shopify here rn, change those if wanting to support other browsers too
728
+ const tabIsVisible = (0, $2MCgq$useVisibilityState)();
729
+ const hlsSource = (0, $2MCgq$createMemo)(()=>props.video_sources_.find((src)=>src.endsWith(".m3u8"))); // Prefer HLS when given by backend and browser supported
730
+ // This is because HLS automatically lets the browser choose both a fitting resolution and quality, depending on video dimensions and network conditions
731
+ const nonHLSSources = (0, $2MCgq$createMemo)(()=>{
732
+ const sources = props.video_sources_?.filter((src)=>!src.endsWith(".m3u8"));
733
+ try {
734
+ $29535f590238371c$var$sortVideoUrlsByQuality(sources);
735
+ } catch (e) {
736
+ (0, $2MCgq$dlog)("Sorting by quality failed", e);
737
+ }
738
+ return sources;
739
+ });
740
+ const productCardIndexAccessor = (0, $2MCgq$useProductCardIndex)();
741
+ const isVisible = (0, $2MCgq$useProductCardIsVisible)();
742
+ const slidableInformation = (0, $2MCgq$useSlidableInformation)();
743
+ const hiddenInImageCarousel = (0, $2MCgq$createMemo)(()=>{
744
+ // Pause video when swiping to the next image
745
+ slidableInformation?.intersectionEntries_(); // Re-check when intersecting entries change
746
+ const intersectingsObject = slidableInformation?.slider_.intersecting_items_object;
747
+ // If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
748
+ if (!intersectingsObject || !Object.keys(intersectingsObject).length) return false;
749
+ // Video is always the first card in the slider
750
+ const ratio = intersectingsObject?.[0]?.intersectionRatio;
751
+ return !ratio;
752
+ });
753
+ return (()=>{
754
+ var _el$17 = $29535f590238371c$var$_tmpl$15();
755
+ (0, $2MCgq$use)((element)=>{
756
+ element.disablePictureInPicture = true;
757
+ (0, $2MCgq$createEffect)(()=>{
758
+ if (isVisible() && tabIsVisible() && !hiddenInImageCarousel()) element.play().catch((e)=>(0, $2MCgq$dwarn)("Error playing video", e));
759
+ else element.pause();
760
+ });
761
+ }, _el$17);
762
+ _el$17.controls = false;
763
+ _el$17.playsInline = true;
764
+ _el$17.loop = true;
765
+ _el$17.muted = true;
766
+ (0, $2MCgq$spread)(_el$17, (0, $2MCgq$mergeProps)({
767
+ get poster () {
768
+ return props.poster_;
769
+ }
770
+ }, ()=>productCardIndexAccessor?.() < 8 && {
771
+ preload: "auto"
772
+ }), false, true);
773
+ (0, $2MCgq$insert)(_el$17, (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
774
+ get when () {
775
+ return hlsSource();
776
+ },
777
+ get children () {
778
+ var _el$18 = $29535f590238371c$var$_tmpl$14();
779
+ (0, $2MCgq$effect)(()=>(0, $2MCgq$setAttribute)(_el$18, "src", hlsSource()));
780
+ return _el$18;
781
+ }
782
+ }), null);
783
+ (0, $2MCgq$insert)(_el$17, (0, $2MCgq$createComponent)((0, $2MCgq$For), {
784
+ get each () {
785
+ return nonHLSSources();
786
+ },
787
+ children: (source)=>(()=>{
788
+ var _el$19 = $29535f590238371c$var$_tmpl$16();
789
+ (0, $2MCgq$setAttribute)(_el$19, "src", source);
790
+ return _el$19;
791
+ })()
792
+ }), null);
793
+ return _el$17;
794
+ })();
795
+ }
796
+ // ChatGPT written
797
+ function $29535f590238371c$var$sortVideoUrlsByQuality(urls) {
798
+ // Function to extract resolution from a URL, assuming format consistency
799
+ function getResolution(url) {
800
+ const match = url.match(/(\d+)p/);
801
+ return match ? parseInt(match[1], 10) : 0;
802
+ }
803
+ // Sort the URLs based on the resolution extracted
804
+ return urls.sort((a, b)=>{
805
+ const resolutionA = getResolution(a);
806
+ const resolutionB = getResolution(b);
807
+ // For descending order, compare B to A
808
+ return resolutionB - resolutionA;
809
+ });
810
+ }
811
+ function $29535f590238371c$var$Prices({ formatPrice_: formatPrice_, configuredOptions_: configuredOptions_, salePrice_: salePrice_, originalPrice_: originalPrice_, ref_: ref_, variantToShow_: variantToShow_, wrapperComponent_: wrapperComponent_ }) {
812
+ // Depict is fetching the prices from Shopify's storefront API on the frontend. This is because getting all prices in all currencies from Shopify be too computationally intensive (~1 million prices for some customers that can change at any time depending on exchange rate).
813
+ // This is why the prices are wrapped in a Promise (we want to render product cards without having to wait for the price request).
814
+ const priceOptions = ()=>configuredOptions_().price;
815
+ const originalPriceOptions = ()=>configuredOptions_().original_price;
816
+ return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
817
+ get when () {
818
+ return priceOptions().enabled;
819
+ },
820
+ get children () {
821
+ return (0, $2MCgq$createComponent)($29535f590238371c$var$InComponentOrDiv, {
822
+ get component_ () {
823
+ return wrapperComponent_();
824
+ },
825
+ class_: "price-container",
826
+ ref_: ref_,
827
+ get children () {
828
+ return [
829
+ (()=>{
830
+ var _el$20 = $29535f590238371c$var$_tmpl$17();
831
+ (0, $2MCgq$insert)(_el$20, (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
832
+ get when () {
833
+ return variantToShow_();
834
+ },
835
+ get fallback () {
836
+ return (0, $2MCgq$createComponent)((0, $2MCgq$TextPlaceholder), {
837
+ height: "1em",
838
+ width: "5ch"
839
+ });
840
+ },
841
+ get children () {
842
+ return (0, $2MCgq$createComponent)((0, $2MCgq$Suspense), {
843
+ get fallback () {
844
+ return (0, $2MCgq$createComponent)((0, $2MCgq$TextPlaceholder), {
845
+ height: "1em",
846
+ width: "5ch"
847
+ });
848
+ },
849
+ get children () {
850
+ return formatPrice_?.(salePrice_());
851
+ }
852
+ });
853
+ }
854
+ }));
855
+ (0, $2MCgq$effect)((_$p)=>(0, $2MCgq$style)(_el$20, $29535f590238371c$var$styleForTextOptions(priceOptions()), _$p));
856
+ return _el$20;
857
+ })(),
858
+ (0, $2MCgq$createComponent)((0, $2MCgq$Suspense), {
859
+ get children () {
860
+ return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
861
+ get when () {
862
+ return (0, $2MCgq$memo)(()=>originalPrice_() !== salePrice_())() && originalPriceOptions().enabled;
863
+ },
864
+ get children () {
865
+ return [
866
+ " ",
867
+ (()=>{
868
+ var _el$21 = $29535f590238371c$var$_tmpl$18();
869
+ (0, $2MCgq$insert)(_el$21, ()=>formatPrice_?.(originalPrice_()));
870
+ (0, $2MCgq$effect)((_$p)=>(0, $2MCgq$style)(_el$21, $29535f590238371c$var$styleForTextOptions(originalPriceOptions()), _$p));
871
+ return _el$21;
872
+ })()
873
+ ];
874
+ }
875
+ });
876
+ }
877
+ })
878
+ ];
879
+ }
880
+ });
881
+ }
882
+ });
883
+ }
884
+ function $29535f590238371c$var$isLightColor(anyCssColor) {
885
+ // Source: https://stackoverflow.com/a/47355187
886
+ $29535f590238371c$var$colorCanvasContext ||= document.createElement("canvas").getContext("2d");
887
+ $29535f590238371c$var$colorCanvasContext.fillStyle = anyCssColor;
888
+ const asHex = $29535f590238371c$var$colorCanvasContext.fillStyle;
889
+ // Source: https://stackoverflow.com/a/12043228
890
+ const stripped = asHex.substring(1); // strip #
891
+ const rgb = parseInt(stripped, 16); // convert rrggbb to decimal
892
+ const r = rgb >> 16 & 0xff; // extract red
893
+ const g = rgb >> 8 & 0xff; // extract green
894
+ const b = rgb >> 0 & 0xff; // extract blue
895
+ const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; // per ITU-R BT.709, apparently between 0 and 255
896
+ return luma > 200;
897
+ }
898
+ // Mostly written by chatGPT
899
+ function $29535f590238371c$var$sortSizes(sizesToSort) {
900
+ const sizeEntries = sizesToSort.map((size)=>{
901
+ const numericMatch = size.match(/^(\d+)(?:\/\d+)?$/);
902
+ if (numericMatch) // It's a numeric size or a range like "44/46", we sort by the first number.
903
+ return {
904
+ size: size,
905
+ numericValue: parseInt(numericMatch[1], 10)
906
+ };
907
+ return {
908
+ size: size
909
+ };
910
+ });
911
+ sizeEntries.sort((a, b)=>{
912
+ const indexA = $29535f590238371c$var$sizeOrder.indexOf(a.size);
913
+ const indexB = $29535f590238371c$var$sizeOrder.indexOf(b.size);
914
+ // Both sizes are in the predefined list
915
+ if (indexA !== -1 && indexB !== -1) return indexA - indexB;
916
+ // Handle numeric and mixed sorting
917
+ if (a.numericValue != null && b.numericValue != null) return a.numericValue - b.numericValue;
918
+ if (a.numericValue != null && indexB === -1) return -1; // numeric values come before unknown text
919
+ if (b.numericValue != null && indexA === -1) return 1; // numeric values come before unknown text
920
+ // Fallback if both are unrecognized, sort alphabetically
921
+ return a.size.localeCompare(b.size);
922
+ });
923
+ return sizeEntries.map((entry)=>entry.size);
924
+ }
925
+ function $29535f590238371c$var$ContainsColorSwatchesProvider(props) {
926
+ const containsSignal = (0, $2MCgq$createSignal)(false);
927
+ return (0, $2MCgq$createComponent)($29535f590238371c$var$ContainsColorSwatchesContext.Provider, {
928
+ value: containsSignal,
929
+ get children () {
930
+ return props.children;
931
+ }
932
+ });
933
+ }
934
+ function $29535f590238371c$var$useContainsColorSwatches() {
935
+ return (0, $2MCgq$useContext)($29535f590238371c$var$ContainsColorSwatchesContext);
936
+ }
937
+ // Work around https://github.com/solidjs/solid/issues/2136 and random shit I thought was an issue before I found https://github.com/solidjs/solid/issues/2137
938
+ function $29535f590238371c$var$InComponentOrDiv(props) {
939
+ const resolved = (0, $2MCgq$children)(()=>props.children);
940
+ return (0, $2MCgq$createMemo)(()=>{
941
+ const Component = props.component_;
942
+ if (Component) return (0, $2MCgq$createComponent)(Component, {
943
+ get ["class"] () {
944
+ return props.class_;
945
+ },
946
+ ref (r$) {
947
+ var _ref$4 = props.ref_;
948
+ typeof _ref$4 === "function" ? _ref$4(r$) : props.ref_ = r$;
949
+ },
950
+ get children () {
951
+ return resolved();
952
+ }
953
+ });
954
+ return (()=>{
955
+ var _el$22 = $29535f590238371c$var$_tmpl$11();
956
+ (0, $2MCgq$use)((el)=>props.ref_?.(el), _el$22);
957
+ (0, $2MCgq$insert)(_el$22, resolved);
958
+ (0, $2MCgq$effect)(()=>(0, $2MCgq$className)(_el$22, props.class_));
959
+ return _el$22;
960
+ })();
961
+ });
962
+ }
963
+ (0, $2MCgq$delegateEvents)([
964
+ "click"
965
+ ]);
966
+
967
+
968
+
969
+ function $474e9d712b745d60$export$d1a48be4967fe67c(react_props) {
970
+ return (0, $0fe03f2fcd2418f8$export$f6e64e17bd69eeef)({
971
+ solid_component: (props_store)=>{
972
+ return (0, $29535f590238371c$export$f11681c54c860912)(()=>props_store.display, {
973
+ set_on_index_change: ()=>{},
974
+ depictCardsDataset: {},
975
+ formatPrice: (price)=>price && (0, $2MCgq$standard_price_format)(price)
976
+ }, ()=>props_store.options);
977
+ },
978
+ props: react_props,
979
+ className: "depict"
980
+ });
981
+ }
982
+
983
+
984
+
985
+
986
+
39
987
  function $d899f63cec76a884$export$32717ad33b14d079(get_value, get_set_function) {
40
988
  const return_value = [
41
989
  get_value,
@@ -220,4 +1168,4 @@ function $8a700ff0722c56b3$export$48787da2a5568bc(react_props) {
220
1168
  (0, $2MCgq$add_to_version_info)("react-ui", (0, $91c11b750e80ede3$export$83d89fbfd8236492));
221
1169
 
222
1170
 
223
- export {$0cb1638b3c084153$export$aea1707d7b01c3a2 as ReactSelectedFilters, $890b58a81f64b470$export$d929db7fb6179159 as ReactFilterBody, $c79c5cb5e9424dd7$export$4ea53cd12ff17334 as ExpandingSection, $8a700ff0722c56b3$export$48787da2a5568bc as ReactLookCard, $91c11b750e80ede3$export$83d89fbfd8236492 as version};
1171
+ export {$474e9d712b745d60$export$d1a48be4967fe67c as ReactDefaultProductCard, $0cb1638b3c084153$export$aea1707d7b01c3a2 as ReactSelectedFilters, $890b58a81f64b470$export$d929db7fb6179159 as ReactFilterBody, $c79c5cb5e9424dd7$export$4ea53cd12ff17334 as ExpandingSection, $8a700ff0722c56b3$export$48787da2a5568bc as ReactLookCard, $91c11b750e80ede3$export$83d89fbfd8236492 as version};