@rebuy/rebuy-hydrogen 3.0.0-beta.1 → 3.0.0-beta.2

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.
Files changed (109) hide show
  1. package/README.md +0 -2
  2. package/dist/components/AddToCartBtn/AddToCartBtn.d.ts +3 -0
  3. package/dist/components/AddToCartBtn/AddToCartBtn.d.ts.map +1 -0
  4. package/dist/components/AddToCartBtn/HydrogenAddToCartBtn.d.ts +3 -0
  5. package/dist/components/AddToCartBtn/HydrogenAddToCartBtn.d.ts.map +1 -0
  6. package/dist/components/AddToCartBtn/HydrogenReactAddToCartBtn.d.ts +3 -0
  7. package/dist/components/AddToCartBtn/HydrogenReactAddToCartBtn.d.ts.map +1 -0
  8. package/dist/components/AddToCartBtn/index.d.ts +2 -0
  9. package/dist/components/AddToCartBtn/index.d.ts.map +1 -0
  10. package/dist/components/AddToCartBtn/types.d.ts +26 -0
  11. package/dist/components/AddToCartBtn/types.d.ts.map +1 -0
  12. package/dist/components/ProductCard/ProductCard.d.ts +3 -0
  13. package/dist/components/ProductCard/ProductCard.d.ts.map +1 -0
  14. package/dist/components/ProductCard/index.d.ts +2 -0
  15. package/dist/components/ProductCard/index.d.ts.map +1 -0
  16. package/dist/components/ProductCard/types.d.ts +10 -0
  17. package/dist/components/ProductCard/types.d.ts.map +1 -0
  18. package/dist/components/ProductPrice/ProductPrice.d.ts +5 -0
  19. package/dist/components/ProductPrice/ProductPrice.d.ts.map +1 -0
  20. package/dist/components/ProductPrice/index.d.ts +2 -0
  21. package/dist/components/ProductPrice/index.d.ts.map +1 -0
  22. package/dist/components/Title/Title.d.ts +3 -0
  23. package/dist/components/Title/Title.d.ts.map +1 -0
  24. package/dist/components/Title/index.d.ts +2 -0
  25. package/dist/components/Title/index.d.ts.map +1 -0
  26. package/dist/components/Title/types.d.ts +7 -0
  27. package/dist/components/Title/types.d.ts.map +1 -0
  28. package/dist/components/VariantSelect/VariantSelect.d.ts +3 -0
  29. package/dist/components/VariantSelect/VariantSelect.d.ts.map +1 -0
  30. package/dist/components/VariantSelect/index.d.ts +2 -0
  31. package/dist/components/VariantSelect/index.d.ts.map +1 -0
  32. package/dist/components/VariantSelect/types.d.ts +6 -0
  33. package/dist/components/VariantSelect/types.d.ts.map +1 -0
  34. package/dist/context/RebuyContext.d.ts +6 -0
  35. package/dist/context/RebuyContext.d.ts.map +1 -0
  36. package/dist/hooks/titleLevel.d.ts +3 -0
  37. package/dist/hooks/titleLevel.d.ts.map +1 -0
  38. package/dist/index.css +296 -0
  39. package/dist/index.css.map +7 -0
  40. package/dist/index.d.ts +8 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +2193 -0
  43. package/dist/index.js.map +7 -0
  44. package/dist/index.mjs +2169 -0
  45. package/dist/index.mjs.map +7 -0
  46. package/dist/providers/RebuyHydrogenContextProvider.d.ts +3 -0
  47. package/dist/providers/RebuyHydrogenContextProvider.d.ts.map +1 -0
  48. package/dist/providers/RebuyHydrogenReactContextProvider.d.ts +3 -0
  49. package/dist/providers/RebuyHydrogenReactContextProvider.d.ts.map +1 -0
  50. package/dist/providers/types.d.ts +48 -0
  51. package/dist/providers/types.d.ts.map +1 -0
  52. package/dist/queries/cart.queries.d.ts +5 -0
  53. package/dist/queries/cart.queries.d.ts.map +1 -0
  54. package/dist/types/common.d.ts +9 -0
  55. package/dist/types/common.d.ts.map +1 -0
  56. package/dist/types/rebuyCustom.d.ts +239 -0
  57. package/dist/types/rebuyCustom.d.ts.map +1 -0
  58. package/dist/types/rebuySmartCart.d.ts +184 -0
  59. package/dist/types/rebuySmartCart.d.ts.map +1 -0
  60. package/dist/types/shopify.d.ts +85 -0
  61. package/dist/types/shopify.d.ts.map +1 -0
  62. package/dist/types/widgets.d.ts +22 -0
  63. package/dist/types/widgets.d.ts.map +1 -0
  64. package/dist/utils/convertToRebuyProduct.d.ts +156 -0
  65. package/dist/utils/convertToRebuyProduct.d.ts.map +1 -0
  66. package/dist/utils/createContextParameters.d.ts +3 -0
  67. package/dist/utils/createContextParameters.d.ts.map +1 -0
  68. package/dist/utils/getEncodedAttributes.d.ts +3 -0
  69. package/dist/utils/getEncodedAttributes.d.ts.map +1 -0
  70. package/dist/utils/getRebuyConfig.d.ts +3 -0
  71. package/dist/utils/getRebuyConfig.d.ts.map +1 -0
  72. package/dist/widgetContainer/RebuyWidgetContainer.d.ts +8 -0
  73. package/dist/widgetContainer/RebuyWidgetContainer.d.ts.map +1 -0
  74. package/dist/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.d.ts +3 -0
  75. package/dist/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.d.ts.map +1 -0
  76. package/dist/widgets/RebuyCompleteTheLook/index.d.ts +2 -0
  77. package/dist/widgets/RebuyCompleteTheLook/index.d.ts.map +1 -0
  78. package/dist/widgets/RebuyCompleteTheLook/types.d.ts +5 -0
  79. package/dist/widgets/RebuyCompleteTheLook/types.d.ts.map +1 -0
  80. package/dist/widgets/RebuyDynamicBundleProducts/BundleImages.d.ts +5 -0
  81. package/dist/widgets/RebuyDynamicBundleProducts/BundleImages.d.ts.map +1 -0
  82. package/dist/widgets/RebuyDynamicBundleProducts/BundlePrice.d.ts +5 -0
  83. package/dist/widgets/RebuyDynamicBundleProducts/BundlePrice.d.ts.map +1 -0
  84. package/dist/widgets/RebuyDynamicBundleProducts/BundleSelection.d.ts +3 -0
  85. package/dist/widgets/RebuyDynamicBundleProducts/BundleSelection.d.ts.map +1 -0
  86. package/dist/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.d.ts +3 -0
  87. package/dist/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.d.ts.map +1 -0
  88. package/dist/widgets/RebuyDynamicBundleProducts/Select.d.ts +3 -0
  89. package/dist/widgets/RebuyDynamicBundleProducts/Select.d.ts.map +1 -0
  90. package/dist/widgets/RebuyDynamicBundleProducts/index.d.ts +2 -0
  91. package/dist/widgets/RebuyDynamicBundleProducts/index.d.ts.map +1 -0
  92. package/dist/widgets/RebuyDynamicBundleProducts/types.d.ts +19 -0
  93. package/dist/widgets/RebuyDynamicBundleProducts/types.d.ts.map +1 -0
  94. package/dist/widgets/RebuyProductAddOns/RebuyProductAddOnCard.d.ts +3 -0
  95. package/dist/widgets/RebuyProductAddOns/RebuyProductAddOnCard.d.ts.map +1 -0
  96. package/dist/widgets/RebuyProductAddOns/RebuyProductAddOns.d.ts +3 -0
  97. package/dist/widgets/RebuyProductAddOns/RebuyProductAddOns.d.ts.map +1 -0
  98. package/dist/widgets/RebuyProductAddOns/index.d.ts +2 -0
  99. package/dist/widgets/RebuyProductAddOns/index.d.ts.map +1 -0
  100. package/dist/widgets/RebuyProductAddOns/types.d.ts +19 -0
  101. package/dist/widgets/RebuyProductAddOns/types.d.ts.map +1 -0
  102. package/dist/widgets/RebuyProductRecommendations/RebuyProductRecommendations.d.ts +3 -0
  103. package/dist/widgets/RebuyProductRecommendations/RebuyProductRecommendations.d.ts.map +1 -0
  104. package/dist/widgets/RebuyProductRecommendations/index.d.ts +2 -0
  105. package/dist/widgets/RebuyProductRecommendations/index.d.ts.map +1 -0
  106. package/dist/widgets/RebuyProductRecommendations/types.d.ts +5 -0
  107. package/dist/widgets/RebuyProductRecommendations/types.d.ts.map +1 -0
  108. package/package.json +1 -1
  109. package/src/components/Title/Title.tsx +1 -2
package/dist/index.js ADDED
@@ -0,0 +1,2193 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ RebuyCompleteTheLook: () => RebuyCompleteTheLook,
34
+ RebuyDynamicBundleProducts: () => RebuyDynamicBundleProducts,
35
+ RebuyHydrogenContextProvider: () => RebuyHydrogenContextProvider,
36
+ RebuyHydrogenReactContextProvider: () => RebuyHydrogenReactContextProvider,
37
+ RebuyProductAddOns: () => RebuyProductAddOns,
38
+ RebuyProductRecommendations: () => RebuyProductRecommendations,
39
+ RebuyWidgetContainer: () => RebuyWidgetContainer
40
+ });
41
+ module.exports = __toCommonJS(index_exports);
42
+
43
+ // src/providers/RebuyHydrogenContextProvider.tsx
44
+ var Utilities2 = __toESM(require("@rebuy/rebuy/utilities"), 1);
45
+ var import_react2 = require("@remix-run/react");
46
+ var import_react3 = require("react");
47
+
48
+ // src/context/RebuyContext.tsx
49
+ var import_react = require("react");
50
+ var RebuyContext = (0, import_react.createContext)(null);
51
+
52
+ // src/utils/createContextParameters.ts
53
+ var Utilities = __toESM(require("@rebuy/rebuy/utilities"), 1);
54
+
55
+ // src/utils/getEncodedAttributes.ts
56
+ var getEncodedAttributes = (attributes) => encodeURIComponent(
57
+ JSON.stringify(
58
+ attributes.reduce(
59
+ (merged, { key, value }) => ({ ...merged, [key]: value }),
60
+ {}
61
+ )
62
+ )
63
+ );
64
+
65
+ // src/utils/createContextParameters.ts
66
+ var createContextParameters = ({
67
+ cacheKey,
68
+ cartAttributes,
69
+ cartId,
70
+ cartLines,
71
+ cartLinesLength,
72
+ cartNote,
73
+ cartSubtotal,
74
+ cartTotalQuantity,
75
+ isHydrogenReact,
76
+ queryObject,
77
+ windowUrl
78
+ }) => {
79
+ const contextParameters = {
80
+ cache_key: cacheKey,
81
+ cart_count: 0,
82
+ cart_item_count: 0,
83
+ cart_line_count: 0,
84
+ cart_subtotal: 0,
85
+ isHydrogenReact,
86
+ time: "",
87
+ url: windowUrl
88
+ };
89
+ const cartContext = {
90
+ attributes: "",
91
+ item_count: 0,
92
+ items: [],
93
+ line_count: 0,
94
+ note: "",
95
+ subtotal: 0,
96
+ token: ""
97
+ };
98
+ if (Object.prototype.hasOwnProperty.call(queryObject, "time")) {
99
+ contextParameters.time = queryObject.time;
100
+ }
101
+ if (cartId) {
102
+ cartContext.token = Utilities.getIdFromGraphUrl(cartId, "Cart");
103
+ contextParameters.cart_token = Utilities.getIdFromGraphUrl(
104
+ cartId,
105
+ "Cart"
106
+ );
107
+ }
108
+ if (cartSubtotal) {
109
+ cartContext.subtotal = Utilities.amountToCents(
110
+ parseFloat(cartSubtotal)
111
+ );
112
+ contextParameters.cart_subtotal = Utilities.amountToCents(
113
+ parseFloat(cartSubtotal)
114
+ );
115
+ }
116
+ if (cartLinesLength) {
117
+ const totalLines = cartLinesLength;
118
+ cartContext.line_count = totalLines;
119
+ contextParameters.cart_count = totalLines;
120
+ contextParameters.cart_line_count = totalLines;
121
+ }
122
+ if (cartTotalQuantity) {
123
+ cartContext.item_count = cartTotalQuantity;
124
+ contextParameters.cart_item_count = cartTotalQuantity;
125
+ }
126
+ if (cartLines) {
127
+ cartContext.items = [];
128
+ for (const cartItem of cartLines) {
129
+ const item = {
130
+ attributes: [],
131
+ product_id: "",
132
+ properties: "",
133
+ quantity: cartItem?.quantity,
134
+ variant_id: ""
135
+ };
136
+ if (cartItem?.merchandise?.product?.id) {
137
+ item.product_id = Utilities.getIdFromGraphUrl(
138
+ cartItem.merchandise.product.id,
139
+ "Product"
140
+ );
141
+ }
142
+ if (cartItem?.merchandise?.id) {
143
+ item.variant_id = Utilities.getIdFromGraphUrl(
144
+ cartItem.merchandise.id,
145
+ "ProductVariant"
146
+ );
147
+ }
148
+ if (cartItem?.attributes?.length) {
149
+ const validAttributes = cartItem.attributes.filter(
150
+ (attr) => attr !== void 0 && typeof attr.key === "string" && typeof attr.value === "string"
151
+ );
152
+ item.properties = getEncodedAttributes(validAttributes);
153
+ }
154
+ cartContext.items.push(item);
155
+ }
156
+ }
157
+ if (cartAttributes) {
158
+ const validAttributes = cartAttributes.filter(
159
+ (attr) => attr !== void 0 && typeof attr.key === "string" && typeof attr.value === "string"
160
+ );
161
+ cartContext.attributes = getEncodedAttributes(validAttributes);
162
+ }
163
+ if (cartNote) {
164
+ cartContext.note = cartNote;
165
+ }
166
+ contextParameters.cart = cartContext;
167
+ return contextParameters;
168
+ };
169
+
170
+ // src/utils/getRebuyConfig.ts
171
+ var import_rebuy = require("@rebuy/rebuy");
172
+ var getRebuyConfig = async (rebuyKey, storeDomain) => {
173
+ try {
174
+ const request = {
175
+ parameters: { shop: storeDomain },
176
+ url: `/api/v1/user/config`
177
+ };
178
+ const { data: rebuy, ...response } = await new import_rebuy.RebuyClient(
179
+ rebuyKey
180
+ ).getShieldedAsset(request.url, request.parameters);
181
+ if (!rebuy?.shop) {
182
+ throw new Error(
183
+ "Rebuy configuration is not properly set up - missing shop",
184
+ { cause: response }
185
+ );
186
+ }
187
+ return rebuy;
188
+ } catch (error) {
189
+ const err = error;
190
+ console.warn("Error fetching Rebuy shop config");
191
+ console.error(err, err.cause);
192
+ throw err;
193
+ }
194
+ };
195
+
196
+ // src/providers/RebuyHydrogenContextProvider.tsx
197
+ var import_jsx_runtime = require("react/jsx-runtime");
198
+ var RebuyHydrogenContext = ({
199
+ cartAttributes,
200
+ cartCost,
201
+ cartId,
202
+ cartLines,
203
+ cartNote,
204
+ cartQuantity,
205
+ children
206
+ }) => {
207
+ const primaryDomain = process.env.PRIMARY_DOMAIN;
208
+ const rebuyKey = process.env.PUBLIC_REBUY_API_KEY;
209
+ const storeDomain = process.env.PUBLIC_STORE_DOMAIN;
210
+ const [rebuyConfig, setRebuyConfig] = (0, import_react3.useState)(null);
211
+ const location = (0, import_react2.useLocation)();
212
+ const queryObject = Utilities2.queryStringToObject(location.search);
213
+ const windowUrl = `${primaryDomain}${location.pathname}${location.search}`;
214
+ (0, import_react3.useEffect)(() => {
215
+ const initConfig = async () => {
216
+ const config = await getRebuyConfig(rebuyKey, storeDomain);
217
+ setRebuyConfig(config);
218
+ };
219
+ if (!rebuyConfig?.shop) {
220
+ initConfig();
221
+ }
222
+ }, [rebuyConfig, rebuyKey, storeDomain]);
223
+ const contextParameters = (0, import_react3.useMemo)(
224
+ () => createContextParameters({
225
+ cacheKey: rebuyConfig?.shop?.cache_key,
226
+ cartAttributes,
227
+ cartId,
228
+ cartLines,
229
+ cartLinesLength: cartLines?.length,
230
+ cartNote,
231
+ cartSubtotal: cartCost,
232
+ cartTotalQuantity: cartQuantity,
233
+ isHydrogenReact: false,
234
+ queryObject,
235
+ windowUrl
236
+ }),
237
+ [
238
+ rebuyConfig,
239
+ windowUrl,
240
+ queryObject,
241
+ cartAttributes,
242
+ cartCost,
243
+ cartId,
244
+ cartLines,
245
+ cartQuantity,
246
+ cartNote
247
+ ]
248
+ );
249
+ const contextParametersJSON = JSON.stringify(contextParameters);
250
+ const contextValue = (0, import_react3.useMemo)(
251
+ () => ({ contextParameters: JSON.parse(contextParametersJSON) }),
252
+ [contextParametersJSON]
253
+ );
254
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RebuyContext.Provider, { value: contextValue, children });
255
+ };
256
+ var RebuyHydrogenContextProvider = ({
257
+ cart,
258
+ children
259
+ }) => {
260
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.Await, { resolve: cart, children: (resolvedCart) => {
261
+ const cart2 = resolvedCart;
262
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
263
+ RebuyHydrogenContext,
264
+ {
265
+ cartAttributes: cart2?.attributes,
266
+ cartCost: cart2?.cost?.subtotalAmount?.amount,
267
+ cartId: cart2?.id,
268
+ cartLines: cart2?.lines?.nodes,
269
+ cartNote: cart2?.note,
270
+ cartQuantity: cart2?.totalQuantity,
271
+ children
272
+ }
273
+ );
274
+ } });
275
+ };
276
+
277
+ // src/providers/RebuyHydrogenReactContextProvider.tsx
278
+ var Utilities3 = __toESM(require("@rebuy/rebuy/utilities"), 1);
279
+ var import_react4 = require("@remix-run/react");
280
+ var import_hydrogen_react = require("@shopify/hydrogen-react");
281
+ var import_react5 = require("react");
282
+
283
+ // src/queries/cart.queries.ts
284
+ var OPTION_FRAGMENT = `#graphql
285
+ fragment OptionFragment on ProductOption {
286
+ id
287
+ name
288
+ optionValues {
289
+ id
290
+ name
291
+ swatch {
292
+ color
293
+ image {
294
+ mediaContentType
295
+ previewImage {
296
+ height
297
+ id
298
+ url
299
+ width
300
+ altText
301
+ }
302
+ id
303
+ alt
304
+ }
305
+ }
306
+ }
307
+ }
308
+ `;
309
+ var CART_LINE_FRAGMENT = `#graphql
310
+ fragment CartLineFragment on CartLine {
311
+ id
312
+ quantity
313
+ cost {
314
+ amountPerQuantity {
315
+ amount
316
+ currencyCode
317
+ }
318
+ compareAtAmountPerQuantity {
319
+ amount
320
+ currencyCode
321
+ }
322
+ totalAmount {
323
+ amount
324
+ currencyCode
325
+ }
326
+ subtotalAmount {
327
+ amount
328
+ currencyCode
329
+ }
330
+ }
331
+ attributes {
332
+ key
333
+ value
334
+ }
335
+ discountAllocations {
336
+ discountedAmount {
337
+ amount
338
+ currencyCode
339
+ }
340
+ ... on CartAutomaticDiscountAllocation {
341
+ __typename
342
+ discountedAmount {
343
+ amount
344
+ currencyCode
345
+ }
346
+ title
347
+ }
348
+ ... on CartCodeDiscountAllocation {
349
+ __typename
350
+ code
351
+ discountedAmount {
352
+ amount
353
+ currencyCode
354
+ }
355
+ }
356
+ ... on CartCustomDiscountAllocation {
357
+ __typename
358
+ discountedAmount {
359
+ amount
360
+ currencyCode
361
+ }
362
+ title
363
+ }
364
+ }
365
+ merchandise {
366
+ ... on ProductVariant {
367
+ availableForSale
368
+ id
369
+ sku
370
+ title
371
+ compareAtPrice {
372
+ amount
373
+ currencyCode
374
+ }
375
+ image {
376
+ altText
377
+ height
378
+ id
379
+ url
380
+ width
381
+ }
382
+ price {
383
+ amount
384
+ currencyCode
385
+ }
386
+ product {
387
+ handle
388
+ id
389
+ productType
390
+ tags
391
+ title
392
+ vendor
393
+ collections(first: 10) {
394
+ nodes {
395
+ handle
396
+ }
397
+ }
398
+ options {
399
+ ...OptionFragment
400
+ }
401
+ images(first: 20) {
402
+ nodes {
403
+ altText
404
+ height
405
+ id
406
+ url
407
+ width
408
+ }
409
+ }
410
+ }
411
+ selectedOptions {
412
+ name
413
+ value
414
+ }
415
+ }
416
+ }
417
+ }
418
+ `;
419
+ var CART_LINE_COMPONENT_FRAGMENT = `#graphql
420
+ fragment CartLineComponentFragment on ComponentizableCartLine {
421
+ id
422
+ quantity
423
+ cost {
424
+ amountPerQuantity {
425
+ amount
426
+ currencyCode
427
+ }
428
+ compareAtAmountPerQuantity {
429
+ amount
430
+ currencyCode
431
+ }
432
+ totalAmount {
433
+ amount
434
+ currencyCode
435
+ }
436
+ subtotalAmount {
437
+ amount
438
+ currencyCode
439
+ }
440
+ }
441
+ attributes {
442
+ key
443
+ value
444
+ }
445
+ discountAllocations {
446
+ discountedAmount {
447
+ amount
448
+ currencyCode
449
+ }
450
+ ... on CartAutomaticDiscountAllocation {
451
+ __typename
452
+ discountedAmount {
453
+ amount
454
+ currencyCode
455
+ }
456
+ title
457
+ }
458
+ ... on CartCodeDiscountAllocation {
459
+ __typename
460
+ code
461
+ discountedAmount {
462
+ amount
463
+ currencyCode
464
+ }
465
+ }
466
+ ... on CartCustomDiscountAllocation {
467
+ __typename
468
+ discountedAmount {
469
+ amount
470
+ currencyCode
471
+ }
472
+ title
473
+ }
474
+ }
475
+ merchandise {
476
+ ... on ProductVariant {
477
+ availableForSale
478
+ id
479
+ sku
480
+ title
481
+ compareAtPrice {
482
+ amount
483
+ currencyCode
484
+ }
485
+ image {
486
+ altText
487
+ height
488
+ id
489
+ url
490
+ width
491
+ }
492
+ price {
493
+ amount
494
+ currencyCode
495
+ }
496
+ product {
497
+ handle
498
+ id
499
+ productType
500
+ tags
501
+ title
502
+ vendor
503
+ collections(first: 10) {
504
+ nodes {
505
+ handle
506
+ }
507
+ }
508
+ options {
509
+ id
510
+ name
511
+ optionValues {
512
+ id
513
+ name
514
+ swatch {
515
+ color
516
+ image {
517
+ mediaContentType
518
+ previewImage {
519
+ height
520
+ id
521
+ url
522
+ width
523
+ altText
524
+ }
525
+ id
526
+ alt
527
+ }
528
+ }
529
+ }
530
+ }
531
+ images(first: 20) {
532
+ nodes {
533
+ altText
534
+ height
535
+ id
536
+ url
537
+ width
538
+ }
539
+ }
540
+ }
541
+ selectedOptions {
542
+ name
543
+ value
544
+ }
545
+ }
546
+ }
547
+ lineComponents {
548
+ id
549
+ quantity
550
+ cost {
551
+ amountPerQuantity {
552
+ amount
553
+ currencyCode
554
+ }
555
+ compareAtAmountPerQuantity {
556
+ amount
557
+ currencyCode
558
+ }
559
+ totalAmount {
560
+ amount
561
+ currencyCode
562
+ }
563
+ subtotalAmount {
564
+ amount
565
+ currencyCode
566
+ }
567
+ }
568
+ attributes {
569
+ key
570
+ value
571
+ }
572
+ discountAllocations {
573
+ discountedAmount {
574
+ amount
575
+ currencyCode
576
+ }
577
+ ... on CartAutomaticDiscountAllocation {
578
+ __typename
579
+ discountedAmount {
580
+ amount
581
+ currencyCode
582
+ }
583
+ title
584
+ }
585
+ ... on CartCodeDiscountAllocation {
586
+ __typename
587
+ code
588
+ discountedAmount {
589
+ amount
590
+ currencyCode
591
+ }
592
+ }
593
+ ... on CartCustomDiscountAllocation {
594
+ __typename
595
+ discountedAmount {
596
+ amount
597
+ currencyCode
598
+ }
599
+ title
600
+ }
601
+ }
602
+ merchandise {
603
+ ... on ProductVariant {
604
+ availableForSale
605
+ id
606
+ sku
607
+ title
608
+ compareAtPrice {
609
+ amount
610
+ currencyCode
611
+ }
612
+ image {
613
+ altText
614
+ height
615
+ id
616
+ url
617
+ width
618
+ }
619
+ price {
620
+ amount
621
+ currencyCode
622
+ }
623
+ product {
624
+ handle
625
+ id
626
+ productType
627
+ tags
628
+ title
629
+ vendor
630
+ collections(first: 10) {
631
+ nodes {
632
+ handle
633
+ }
634
+ }
635
+ options {
636
+ ...OptionFragment
637
+ }
638
+ images(first: 20) {
639
+ nodes {
640
+ altText
641
+ height
642
+ id
643
+ url
644
+ width
645
+ }
646
+ }
647
+ }
648
+ selectedOptions {
649
+ name
650
+ value
651
+ }
652
+ }
653
+ }
654
+ }
655
+ }
656
+ `;
657
+ var CART_FRAGMENT = `#graphql
658
+ fragment CartFragment on Cart {
659
+ id
660
+ checkoutUrl
661
+ createdAt
662
+ totalQuantity
663
+ note
664
+ updatedAt
665
+ __typename
666
+ buyerIdentity {
667
+ countryCode
668
+ customer {
669
+ id
670
+ email
671
+ firstName
672
+ lastName
673
+ displayName
674
+ }
675
+ email
676
+ phone
677
+ }
678
+ attributes {
679
+ key
680
+ value
681
+ }
682
+ cost {
683
+ subtotalAmount {
684
+ amount
685
+ currencyCode
686
+ }
687
+ totalAmount {
688
+ amount
689
+ currencyCode
690
+ }
691
+ }
692
+ discountAllocations {
693
+ discountedAmount {
694
+ amount
695
+ currencyCode
696
+ }
697
+ ... on CartAutomaticDiscountAllocation {
698
+ __typename
699
+ discountedAmount {
700
+ amount
701
+ currencyCode
702
+ }
703
+ title
704
+ }
705
+ ... on CartCodeDiscountAllocation {
706
+ __typename
707
+ code
708
+ discountedAmount {
709
+ amount
710
+ currencyCode
711
+ }
712
+ }
713
+ ... on CartCustomDiscountAllocation {
714
+ __typename
715
+ discountedAmount {
716
+ amount
717
+ currencyCode
718
+ }
719
+ title
720
+ }
721
+ }
722
+ discountCodes {
723
+ applicable
724
+ code
725
+ }
726
+ lines(first: $numCartLines) {
727
+ edges {
728
+ node {
729
+ ...CartLineComponentFragment
730
+ }
731
+ }
732
+ edges {
733
+ node {
734
+ ...CartLineFragment
735
+ }
736
+ }
737
+ }
738
+ }
739
+ ${CART_LINE_FRAGMENT}
740
+ ${CART_LINE_COMPONENT_FRAGMENT}
741
+ ${OPTION_FRAGMENT}
742
+ `;
743
+
744
+ // src/providers/RebuyHydrogenReactContextProvider.tsx
745
+ var import_jsx_runtime2 = require("react/jsx-runtime");
746
+ var RebuyHydrogenReactContext = ({ children }) => {
747
+ const primaryDomain = process.env.PRIMARY_DOMAIN;
748
+ const rebuyKey = process.env.PUBLIC_REBUY_API_KEY;
749
+ const storeDomain = process.env.PUBLIC_STORE_DOMAIN;
750
+ const [rebuyConfig, setRebuyConfig] = (0, import_react5.useState)(null);
751
+ const location = (0, import_react4.useLocation)();
752
+ const queryObject = Utilities3.queryStringToObject(location.search);
753
+ const windowUrl = `${primaryDomain}${location.pathname}${location.search}`;
754
+ const cart = (0, import_hydrogen_react.useCart)();
755
+ (0, import_react5.useEffect)(() => {
756
+ const initConfig = async () => {
757
+ const config = await getRebuyConfig(rebuyKey, storeDomain);
758
+ setRebuyConfig(config);
759
+ };
760
+ if (!rebuyConfig?.shop) {
761
+ initConfig();
762
+ }
763
+ }, [rebuyConfig, rebuyKey, storeDomain]);
764
+ const contextParameters = (0, import_react5.useMemo)(
765
+ () => createContextParameters({
766
+ cacheKey: rebuyConfig?.shop?.cache_key,
767
+ cartAttributes: cart?.attributes,
768
+ cartId: cart?.id,
769
+ cartLines: cart?.lines,
770
+ cartLinesLength: cart?.lines?.length,
771
+ cartSubtotal: cart?.cost?.subtotalAmount?.amount,
772
+ cartTotalQuantity: cart?.totalQuantity,
773
+ isHydrogenReact: true,
774
+ queryObject,
775
+ windowUrl
776
+ }),
777
+ [rebuyConfig, windowUrl, queryObject, cart]
778
+ );
779
+ const contextParametersJSON = JSON.stringify(contextParameters);
780
+ const contextValue = (0, import_react5.useMemo)(
781
+ () => ({ contextParameters: JSON.parse(contextParametersJSON) }),
782
+ [contextParametersJSON]
783
+ );
784
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RebuyContext.Provider, { value: contextValue, children });
785
+ };
786
+ var RebuyHydrogenReactContextProvider = ({
787
+ cartFragment = CART_FRAGMENT,
788
+ children,
789
+ countryIsoCode = "US",
790
+ customerAccessToken = "",
791
+ data,
792
+ languageIsoCode = "EN",
793
+ numCartLines,
794
+ onAttributesUpdate,
795
+ onAttributesUpdateComplete,
796
+ onBuyerIdentityUpdate,
797
+ onBuyerIdentityUpdateComplete,
798
+ onCreate,
799
+ onCreateComplete,
800
+ onDiscountCodesUpdate,
801
+ onDiscountCodesUpdateComplete,
802
+ onLineAdd,
803
+ onLineAddComplete,
804
+ onLineRemove,
805
+ onLineRemoveComplete,
806
+ onLineUpdate,
807
+ onLineUpdateComplete,
808
+ onNoteUpdate,
809
+ onNoteUpdateComplete,
810
+ storefrontApiVersion = "2025-01"
811
+ }) => {
812
+ const publicStoreDomain = process.env.PUBLIC_STORE_DOMAIN;
813
+ const storefrontId = process.env.PUBLIC_STOREFRONT_ID;
814
+ const storefrontToken = process.env.PUBLIC_STOREFRONT_API_TOKEN || "";
815
+ const adapted = {
816
+ onAttributesUpdate: onAttributesUpdate ? () => onAttributesUpdate() : void 0,
817
+ onAttributesUpdateComplete: onAttributesUpdateComplete ? () => onAttributesUpdateComplete() : void 0,
818
+ onBuyerIdentityUpdate: onBuyerIdentityUpdate ? () => onBuyerIdentityUpdate() : void 0,
819
+ onBuyerIdentityUpdateComplete: onBuyerIdentityUpdateComplete ? () => onBuyerIdentityUpdateComplete() : void 0,
820
+ onCreate: onCreate ? () => onCreate() : void 0,
821
+ onCreateComplete: onCreateComplete ? () => onCreateComplete() : void 0,
822
+ onDiscountCodesUpdate: onDiscountCodesUpdate ? () => onDiscountCodesUpdate() : void 0,
823
+ onDiscountCodesUpdateComplete: onDiscountCodesUpdateComplete ? () => onDiscountCodesUpdateComplete() : void 0,
824
+ onLineAdd: onLineAdd ? () => onLineAdd() : void 0,
825
+ onLineAddComplete: onLineAddComplete ? () => onLineAddComplete() : void 0,
826
+ onLineRemove: onLineRemove ? () => onLineRemove() : void 0,
827
+ onLineRemoveComplete: onLineRemoveComplete ? () => onLineRemoveComplete() : void 0,
828
+ onLineUpdate: onLineUpdate ? () => onLineUpdate() : void 0,
829
+ onLineUpdateComplete: onLineUpdateComplete ? () => onLineUpdateComplete() : void 0,
830
+ onNoteUpdate: onNoteUpdate ? () => onNoteUpdate() : void 0,
831
+ onNoteUpdateComplete: onNoteUpdateComplete ? () => onNoteUpdateComplete() : void 0
832
+ };
833
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
834
+ import_hydrogen_react.ShopifyProvider,
835
+ {
836
+ countryIsoCode,
837
+ languageIsoCode,
838
+ storeDomain: publicStoreDomain,
839
+ storefrontApiVersion,
840
+ storefrontId,
841
+ storefrontToken,
842
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
843
+ import_hydrogen_react.CartProvider,
844
+ {
845
+ cartFragment,
846
+ countryCode: countryIsoCode,
847
+ customerAccessToken,
848
+ data,
849
+ languageCode: languageIsoCode,
850
+ numCartLines,
851
+ onAttributesUpdate: adapted.onAttributesUpdate,
852
+ onAttributesUpdateComplete: adapted.onAttributesUpdateComplete,
853
+ onBuyerIdentityUpdate: adapted.onBuyerIdentityUpdate,
854
+ onBuyerIdentityUpdateComplete: adapted.onBuyerIdentityUpdateComplete,
855
+ onCreate: adapted.onCreate,
856
+ onCreateComplete: adapted.onCreateComplete,
857
+ onDiscountCodesUpdate: adapted.onDiscountCodesUpdate,
858
+ onDiscountCodesUpdateComplete: adapted.onDiscountCodesUpdateComplete,
859
+ onLineAdd: adapted.onLineAdd,
860
+ onLineAddComplete: adapted.onLineAddComplete,
861
+ onLineRemove: adapted.onLineRemove,
862
+ onLineRemoveComplete: adapted.onLineRemoveComplete,
863
+ onLineUpdate: adapted.onLineUpdate,
864
+ onLineUpdateComplete: adapted.onLineUpdateComplete,
865
+ onNoteUpdate: adapted.onNoteUpdate,
866
+ onNoteUpdateComplete: adapted.onNoteUpdateComplete,
867
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RebuyHydrogenReactContext, { children })
868
+ }
869
+ )
870
+ }
871
+ );
872
+ };
873
+
874
+ // src/widgetContainer/RebuyWidgetContainer.tsx
875
+ var import_rebuy2 = require("@rebuy/rebuy");
876
+ var Utilities4 = __toESM(require("@rebuy/rebuy/utilities"), 1);
877
+ var import_hydrogen = require("@shopify/hydrogen");
878
+ var import_react6 = __toESM(require("react"), 1);
879
+ var RebuyWidgetContainerBase = ({
880
+ children,
881
+ ...props
882
+ }) => {
883
+ const {
884
+ collection,
885
+ collectionId,
886
+ dataSource,
887
+ limit,
888
+ options,
889
+ product,
890
+ productId,
891
+ variant,
892
+ variantId
893
+ } = props;
894
+ const contextParameters = (0, import_react6.useContext)(RebuyContext);
895
+ const [Rebuy, setRebuy] = (0, import_react6.useState)(null);
896
+ const [initialized, setInitialized] = (0, import_react6.useState)(false);
897
+ const shopifyProductId = product?.id ?? productId ?? null;
898
+ const shopifyVariantId = variant?.id ?? variantId ?? null;
899
+ const shopifyCollectionId = collection?.id ?? collectionId ?? null;
900
+ const [products, setProducts] = (0, import_react6.useState)([]);
901
+ const [metadata, setMetadata] = (0, import_react6.useState)();
902
+ const REBUY_API_KEY = process.env.PUBLIC_REBUY_API_KEY;
903
+ (0, import_react6.useEffect)(() => {
904
+ if (!Rebuy) {
905
+ const client = new import_rebuy2.RebuyClient(REBUY_API_KEY);
906
+ client.setContextParameters(
907
+ contextParameters
908
+ // TODO: fix this type when @rebuy/rebuy is moved to typescript
909
+ );
910
+ if (options) {
911
+ client.setDefaultParameters(options);
912
+ }
913
+ setRebuy(client);
914
+ setInitialized(true);
915
+ }
916
+ }, [REBUY_API_KEY, Rebuy, contextParameters, options]);
917
+ (0, import_react6.useEffect)(() => {
918
+ if (!Rebuy) return;
919
+ Rebuy.setContextParameters(
920
+ contextParameters
921
+ // TODO: fix this type when @rebuy/rebuy is moved to typescript
922
+ );
923
+ }, [Rebuy, contextParameters]);
924
+ const request = (0, import_react6.useMemo)(() => {
925
+ const request2 = {
926
+ endpoint: dataSource || "/api/v1/products/recommended",
927
+ params: {}
928
+ // Keeping this object generic to allow for custom endpoints
929
+ };
930
+ if (shopifyProductId) {
931
+ request2.params.shopify_product_ids = Utilities4.getIdFromGraphUrl(
932
+ shopifyProductId,
933
+ "Product"
934
+ );
935
+ }
936
+ if (shopifyProductId) {
937
+ request2.params.shopify_product_ids = Utilities4.getIdFromGraphUrl(
938
+ shopifyProductId,
939
+ "Product"
940
+ );
941
+ }
942
+ if (shopifyVariantId) {
943
+ request2.params.shopify_variant_ids = Utilities4.getIdFromGraphUrl(
944
+ shopifyVariantId,
945
+ "ProductVariant"
946
+ );
947
+ }
948
+ if (shopifyCollectionId) {
949
+ request2.params.shopify_collection_ids = Utilities4.getIdFromGraphUrl(
950
+ shopifyCollectionId,
951
+ "Collection"
952
+ );
953
+ }
954
+ if (limit) {
955
+ request2.params.limit = limit;
956
+ }
957
+ return request2;
958
+ }, [
959
+ dataSource,
960
+ shopifyProductId,
961
+ shopifyVariantId,
962
+ shopifyCollectionId,
963
+ limit
964
+ ]);
965
+ (0, import_react6.useEffect)(() => {
966
+ let isMounted = true;
967
+ if (!Rebuy || !initialized) return;
968
+ const fetchData = async () => {
969
+ const { data, metadata: metadata2 } = await Rebuy.getStorefrontData(
970
+ request.endpoint,
971
+ request.params
972
+ );
973
+ if (isMounted) {
974
+ setProducts(
975
+ Array.isArray(data) ? data.map((product2) => ({
976
+ ...product2,
977
+ variants: {
978
+ nodes: product2.variants ? (0, import_hydrogen.flattenConnection)(product2.variants) : []
979
+ }
980
+ })) : []
981
+ );
982
+ setMetadata(metadata2);
983
+ }
984
+ };
985
+ fetchData();
986
+ return () => {
987
+ isMounted = false;
988
+ };
989
+ }, [Rebuy, initialized, request]);
990
+ const childrenWithProps = (props2) => import_react6.default.Children.map(
991
+ children,
992
+ (child) => import_react6.default.isValidElement(child) ? import_react6.default.cloneElement(child, props2) : child
993
+ );
994
+ const childProps = {
995
+ ...props,
996
+ isHydrogenReact: contextParameters?.contextParameters?.isHydrogenReact,
997
+ key: product?.id,
998
+ metadata,
999
+ products
1000
+ };
1001
+ return childrenWithProps(childProps);
1002
+ };
1003
+ var RebuyWidgetContainer = RebuyWidgetContainerBase;
1004
+
1005
+ // src/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.module.css
1006
+ var RebuyCompleteTheLook_default = {
1007
+ container: "RebuyCompleteTheLook_container",
1008
+ productGrid: "RebuyCompleteTheLook_productGrid",
1009
+ productItem: "RebuyCompleteTheLook_productItem"
1010
+ };
1011
+
1012
+ // src/components/ProductCard/ProductCard.tsx
1013
+ var import_react7 = require("@remix-run/react");
1014
+ var import_hydrogen4 = require("@shopify/hydrogen");
1015
+ var import_react8 = require("react");
1016
+
1017
+ // src/components/ProductCard/ProductCard.module.css
1018
+ var ProductCard_default = {
1019
+ container: "ProductCard_container",
1020
+ productInfo: "ProductCard_productInfo"
1021
+ };
1022
+
1023
+ // src/components/AddToCartBtn/HydrogenAddToCartBtn.tsx
1024
+ var import_hydrogen2 = require("@shopify/hydrogen");
1025
+
1026
+ // src/components/AddToCartBtn/AddToCartBtn.module.css
1027
+ var AddToCartBtn_default = {
1028
+ button: "AddToCartBtn_button"
1029
+ };
1030
+
1031
+ // src/components/AddToCartBtn/HydrogenAddToCartBtn.tsx
1032
+ var import_jsx_runtime3 = require("react/jsx-runtime");
1033
+ var HydrogenAddToCartBtn = ({
1034
+ addToCartBtnText,
1035
+ addToCartCallback,
1036
+ disabled,
1037
+ linesToAdd,
1038
+ moneyData
1039
+ }) => {
1040
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1041
+ import_hydrogen2.CartForm,
1042
+ {
1043
+ action: import_hydrogen2.CartForm.ACTIONS.LinesAdd,
1044
+ inputs: {
1045
+ lines: linesToAdd
1046
+ },
1047
+ route: "/cart",
1048
+ children: (fetcher) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1049
+ "button",
1050
+ {
1051
+ className: AddToCartBtn_default.button,
1052
+ disabled: disabled || fetcher.state !== "idle",
1053
+ onClick: addToCartCallback,
1054
+ type: "submit",
1055
+ children: [
1056
+ addToCartBtnText,
1057
+ moneyData && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1058
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: " | " }),
1059
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_hydrogen2.Money, { data: moneyData, withoutTrailingZeros: true })
1060
+ ] })
1061
+ ]
1062
+ }
1063
+ ) })
1064
+ }
1065
+ );
1066
+ };
1067
+
1068
+ // src/components/AddToCartBtn/HydrogenReactAddToCartBtn.tsx
1069
+ var import_hydrogen_react2 = require("@shopify/hydrogen-react");
1070
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1071
+ var HydrogenReactAddToCartBtn = ({
1072
+ addToCartBtnText,
1073
+ addToCartCallback,
1074
+ disabled,
1075
+ linesToAdd,
1076
+ moneyData
1077
+ }) => {
1078
+ const { linesAdd } = (0, import_hydrogen_react2.useCart)();
1079
+ const handleAddToCart = () => {
1080
+ linesAdd(linesToAdd);
1081
+ addToCartCallback?.();
1082
+ };
1083
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1084
+ "button",
1085
+ {
1086
+ className: AddToCartBtn_default.button,
1087
+ disabled,
1088
+ onClick: handleAddToCart,
1089
+ type: "button",
1090
+ children: [
1091
+ addToCartBtnText,
1092
+ moneyData && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1093
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: " | " }),
1094
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_hydrogen_react2.Money, { data: moneyData, withoutTrailingZeros: true })
1095
+ ] })
1096
+ ]
1097
+ }
1098
+ );
1099
+ };
1100
+
1101
+ // src/components/AddToCartBtn/AddToCartBtn.tsx
1102
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1103
+ var AddToCartBtn = ({
1104
+ addToCartBtnText,
1105
+ addToCartCallback,
1106
+ disabled,
1107
+ isHydrogenReact,
1108
+ moneyData,
1109
+ selectedVariants
1110
+ }) => {
1111
+ const linesToAdd = selectedVariants.map((variant) => ({
1112
+ attributes: [
1113
+ { key: "_source", value: "Rebuy" },
1114
+ { key: "_attribution", value: "Rebuy Product Recommendations" }
1115
+ ],
1116
+ merchandiseId: variant.id,
1117
+ quantity: 1,
1118
+ selectedVariant: variant
1119
+ }));
1120
+ if (isHydrogenReact) {
1121
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1122
+ HydrogenReactAddToCartBtn,
1123
+ {
1124
+ addToCartBtnText,
1125
+ addToCartCallback,
1126
+ disabled,
1127
+ linesToAdd,
1128
+ moneyData
1129
+ }
1130
+ );
1131
+ }
1132
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1133
+ HydrogenAddToCartBtn,
1134
+ {
1135
+ addToCartBtnText,
1136
+ addToCartCallback,
1137
+ disabled,
1138
+ linesToAdd,
1139
+ moneyData
1140
+ }
1141
+ );
1142
+ };
1143
+
1144
+ // src/components/ProductPrice/ProductPrice.tsx
1145
+ var import_hydrogen3 = require("@shopify/hydrogen");
1146
+
1147
+ // src/components/ProductPrice/ProductPrice.module.css
1148
+ var ProductPrice_default = {
1149
+ priceContainer: "ProductPrice_priceContainer",
1150
+ compareAtPrice: "ProductPrice_compareAtPrice"
1151
+ };
1152
+
1153
+ // src/components/ProductPrice/ProductPrice.tsx
1154
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1155
+ var RebuyProductPrice = ({
1156
+ selectedVariant
1157
+ }) => {
1158
+ if (!selectedVariant) return null;
1159
+ const { compareAtPriceV2: compareAtPrice, priceV2: price } = selectedVariant;
1160
+ const isDiscounted = (price2, compareAtPrice2) => Number(compareAtPrice2?.amount) > Number(price2?.amount);
1161
+ const CompareAtPrice = ({
1162
+ data: compareAtPrice2
1163
+ }) => {
1164
+ return compareAtPrice2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1165
+ import_hydrogen3.Money,
1166
+ {
1167
+ as: "span",
1168
+ className: ProductPrice_default.compareAtPrice,
1169
+ data: compareAtPrice2,
1170
+ withoutTrailingZeros: true
1171
+ }
1172
+ );
1173
+ };
1174
+ return price && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: ProductPrice_default.priceContainer, children: [
1175
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_hydrogen3.Money, { data: price, withoutTrailingZeros: true }),
1176
+ compareAtPrice && isDiscounted(price, compareAtPrice) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CompareAtPrice, { data: compareAtPrice })
1177
+ ] });
1178
+ };
1179
+
1180
+ // src/components/Title/Title.tsx
1181
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1182
+ var Title = ({ level, style, text }) => {
1183
+ switch (level) {
1184
+ case "h1":
1185
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h1", { style, children: text });
1186
+ default:
1187
+ case "h2":
1188
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h2", { style, children: text });
1189
+ case "h3":
1190
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h3", { style, children: text });
1191
+ case "h4":
1192
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h4", { style, children: text });
1193
+ case "h5":
1194
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h5", { style, children: text });
1195
+ case "h6":
1196
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h6", { style, children: text });
1197
+ }
1198
+ };
1199
+
1200
+ // src/components/VariantSelect/VariantSelect.module.css
1201
+ var VariantSelect_default = {
1202
+ select: "VariantSelect_select"
1203
+ };
1204
+
1205
+ // src/components/VariantSelect/VariantSelect.tsx
1206
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1207
+ var VariantSelect = ({
1208
+ handleSelectedVariant,
1209
+ product
1210
+ }) => {
1211
+ const getOptionsLabel = (product2) => {
1212
+ const options = product2.variants.nodes[0].selectedOptions;
1213
+ const optionsFromKeys = options ? Object.keys(options[0]) : [];
1214
+ const optionsFromValues = options ? options.map((option) => option.name) : [];
1215
+ const useValues = optionsFromKeys.every(
1216
+ (key) => ["name", "value"].includes(key)
1217
+ );
1218
+ return (useValues ? optionsFromValues : optionsFromKeys).join(" / ");
1219
+ };
1220
+ return product?.variants.nodes.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1221
+ "select",
1222
+ {
1223
+ "aria-label": "select variant",
1224
+ className: VariantSelect_default.select,
1225
+ onChange: (e) => handleSelectedVariant(product, e.target.value),
1226
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("optgroup", { label: getOptionsLabel(product), children: product.variants.nodes.map(({ id, title }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: id, children: title }, id + "-variant")) })
1227
+ }
1228
+ ) });
1229
+ };
1230
+
1231
+ // src/components/ProductCard/ProductCard.tsx
1232
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1233
+ var ProductCard = ({
1234
+ addToCartBtnText,
1235
+ addToCartCallback,
1236
+ isHydrogenReact,
1237
+ product,
1238
+ productCardTitleLevel
1239
+ }) => {
1240
+ const [selectedVariant, setSelectedVariant] = (0, import_react8.useState)(
1241
+ product.variants.nodes[0]
1242
+ );
1243
+ const { image } = selectedVariant;
1244
+ const handleSelectedVariant = (product2, variant_id) => {
1245
+ const updatedVariant = product2.variants.nodes.find(
1246
+ (variant) => variant.id === variant_id
1247
+ );
1248
+ if (updatedVariant) {
1249
+ setSelectedVariant(updatedVariant);
1250
+ }
1251
+ };
1252
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: ProductCard_default.container, children: [
1253
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
1254
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react7.Link, { to: `/products/${product.handle}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1255
+ import_hydrogen4.Image,
1256
+ {
1257
+ alt: image?.altText ?? `Picture of ${product.title}`,
1258
+ data: image,
1259
+ sizes: "(max-width: 320px) 280px, (max-width: 768px) 720px, 1440px"
1260
+ }
1261
+ ) }),
1262
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: ProductCard_default.productInfo, children: [
1263
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react7.Link, { to: `/products/${product.handle}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1264
+ Title,
1265
+ {
1266
+ level: productCardTitleLevel,
1267
+ text: product.title
1268
+ }
1269
+ ) }),
1270
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RebuyProductPrice, { selectedVariant }),
1271
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1272
+ VariantSelect,
1273
+ {
1274
+ handleSelectedVariant,
1275
+ product
1276
+ }
1277
+ )
1278
+ ] })
1279
+ ] }),
1280
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1281
+ AddToCartBtn,
1282
+ {
1283
+ addToCartBtnText,
1284
+ addToCartCallback,
1285
+ isHydrogenReact,
1286
+ selectedVariants: [selectedVariant]
1287
+ }
1288
+ )
1289
+ ] });
1290
+ };
1291
+
1292
+ // src/hooks/titleLevel.tsx
1293
+ var getTitleLevel = (level, decreaseLevel = false) => {
1294
+ switch (level) {
1295
+ case "h1":
1296
+ if (decreaseLevel) {
1297
+ return "h2" /* H2 */;
1298
+ }
1299
+ return "h1" /* H1 */;
1300
+ case "h2":
1301
+ if (decreaseLevel) {
1302
+ return "h3" /* H3 */;
1303
+ }
1304
+ return "h2" /* H2 */;
1305
+ case "h3":
1306
+ if (decreaseLevel) {
1307
+ return "h4" /* H4 */;
1308
+ }
1309
+ return "h3" /* H3 */;
1310
+ case "h4":
1311
+ if (decreaseLevel) {
1312
+ return "h5" /* H5 */;
1313
+ }
1314
+ return "h4" /* H4 */;
1315
+ case "h5":
1316
+ if (decreaseLevel) {
1317
+ return "h6" /* H6 */;
1318
+ }
1319
+ return "h5" /* H5 */;
1320
+ case "h6":
1321
+ if (decreaseLevel) {
1322
+ return "h6" /* H6 */;
1323
+ }
1324
+ return "h6" /* H6 */;
1325
+ default:
1326
+ return "h2" /* H2 */;
1327
+ }
1328
+ };
1329
+
1330
+ // src/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.tsx
1331
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1332
+ var RebuyCompleteTheLook = (props) => {
1333
+ const {
1334
+ addToCartBtnText = "Add to cart",
1335
+ addToCartCallback,
1336
+ customTitle = `These pair with ${props.product?.title}`,
1337
+ customTitleLevel = "h2",
1338
+ customTitleStyle,
1339
+ products = []
1340
+ } = props;
1341
+ if (products.length === 0) {
1342
+ console.log("RebuyCompleteTheLook: No products found");
1343
+ return null;
1344
+ }
1345
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: RebuyCompleteTheLook_default.container, children: [
1346
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1347
+ Title,
1348
+ {
1349
+ level: getTitleLevel(customTitleLevel),
1350
+ style: customTitleStyle,
1351
+ text: customTitle
1352
+ }
1353
+ ),
1354
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { className: RebuyCompleteTheLook_default.productGrid, children: products.map((product) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("li", { className: RebuyCompleteTheLook_default.productItem, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1355
+ ProductCard,
1356
+ {
1357
+ addToCartBtnText,
1358
+ addToCartCallback,
1359
+ isHydrogenReact: props.isHydrogenReact,
1360
+ product,
1361
+ productCardTitleLevel: getTitleLevel(
1362
+ customTitleLevel,
1363
+ true
1364
+ )
1365
+ }
1366
+ ) }, product.id)) })
1367
+ ] });
1368
+ };
1369
+
1370
+ // src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.tsx
1371
+ var import_react11 = require("react");
1372
+
1373
+ // src/widgets/RebuyDynamicBundleProducts/BundlePrice.tsx
1374
+ var import_hydrogen5 = require("@shopify/hydrogen");
1375
+
1376
+ // src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.module.css
1377
+ var RebuyDynamicBundleProducts_default = {
1378
+ container: "RebuyDynamicBundleProducts_container",
1379
+ addCartBtnContainer: "RebuyDynamicBundleProducts_addCartBtnContainer",
1380
+ bundleContainer: "RebuyDynamicBundleProducts_bundleContainer",
1381
+ select: "RebuyDynamicBundleProducts_select",
1382
+ bundleItemRowContainer: "RebuyDynamicBundleProducts_bundleItemRowContainer",
1383
+ unselected: "RebuyDynamicBundleProducts_unselected",
1384
+ bundleItemRow: "RebuyDynamicBundleProducts_bundleItemRow",
1385
+ bundleItemInput: "RebuyDynamicBundleProducts_bundleItemInput",
1386
+ bundleItemLabel: "RebuyDynamicBundleProducts_bundleItemLabel",
1387
+ bundleImages: "RebuyDynamicBundleProducts_bundleImages",
1388
+ bundleImage: "RebuyDynamicBundleProducts_bundleImage",
1389
+ fadeIn: "RebuyDynamicBundleProducts_fadeIn",
1390
+ bundleImageDelimiter: "RebuyDynamicBundleProducts_bundleImageDelimiter",
1391
+ compareAtPrice: "RebuyDynamicBundleProducts_compareAtPrice"
1392
+ };
1393
+
1394
+ // src/widgets/RebuyDynamicBundleProducts/BundlePrice.tsx
1395
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1396
+ var BundlePrice = ({ products }) => {
1397
+ const isDisabled = products.filter((product) => product.selected).length < 1;
1398
+ const totalBundlePrice = () => {
1399
+ let total = 0;
1400
+ let currencyCode = "USD";
1401
+ for (const product of products) {
1402
+ if (product.selected && product.selectedVariant) {
1403
+ const { priceV2: price2 } = product.selectedVariant;
1404
+ total += Number(price2?.amount);
1405
+ currencyCode = price2?.currencyCode || "USD";
1406
+ }
1407
+ }
1408
+ return {
1409
+ amount: String(total),
1410
+ currencyCode
1411
+ };
1412
+ };
1413
+ const totalBundleCompareAtPrice = () => {
1414
+ let compareAtTotal = 0;
1415
+ let currencyCode = "USD";
1416
+ for (const product of products) {
1417
+ if (product.selected && product.selectedVariant) {
1418
+ const { compareAtPriceV2: compareAtPrice2, priceV2: price2 } = product.selectedVariant;
1419
+ currencyCode = price2?.currencyCode || "USD";
1420
+ compareAtTotal += Number((compareAtPrice2 || price2)?.amount);
1421
+ }
1422
+ }
1423
+ return {
1424
+ amount: String(compareAtTotal),
1425
+ currencyCode
1426
+ };
1427
+ };
1428
+ const isDiscounted = (price2, compareAtPrice2) => Number(compareAtPrice2?.amount) > Number(price2?.amount);
1429
+ const price = totalBundlePrice();
1430
+ const compareAtPrice = totalBundleCompareAtPrice();
1431
+ const CompareAtPrice = ({
1432
+ data: compareAtPrice2
1433
+ }) => {
1434
+ return compareAtPrice2 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1435
+ import_hydrogen5.Money,
1436
+ {
1437
+ as: "span",
1438
+ className: RebuyDynamicBundleProducts_default.compareAtPrice,
1439
+ data: compareAtPrice2,
1440
+ withoutTrailingZeros: true
1441
+ }
1442
+ );
1443
+ };
1444
+ return products.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex items-center flex-col", children: !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { className: "flex items-center gap-2 mb-2", children: [
1445
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: "Total Price:" }),
1446
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_hydrogen5.Money, { as: "span", data: price, withoutTrailingZeros: true }),
1447
+ isDiscounted(price, compareAtPrice) && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CompareAtPrice, { data: compareAtPrice })
1448
+ ] }) });
1449
+ };
1450
+
1451
+ // src/utils/convertToRebuyProduct.tsx
1452
+ var convertToRebuyProduct = (isHydrogenReact, product) => {
1453
+ const mainProductVariants = isHydrogenReact ? product?.variants?.nodes?.map((variant) => {
1454
+ return {
1455
+ ...variant
1456
+ };
1457
+ }) || [] : product?.adjacentVariants.map((variant) => {
1458
+ return {
1459
+ availableForSale: variant.availableForSale,
1460
+ compareAtPriceV2: {
1461
+ amount: variant.compareAtPrice?.amount || "",
1462
+ currencyCode: variant.compareAtPrice?.currencyCode || "USD"
1463
+ },
1464
+ id: variant.id,
1465
+ image: {
1466
+ altText: variant.image?.altText || "",
1467
+ height: variant.image?.height || 100,
1468
+ id: variant.image?.id || "",
1469
+ url: variant.image?.url || "",
1470
+ width: variant.image?.width || 100
1471
+ },
1472
+ priceV2: {
1473
+ amount: variant.price.amount || "",
1474
+ currencyCode: variant.price.currencyCode || "USD"
1475
+ },
1476
+ product: {
1477
+ handle: product.handle,
1478
+ id: product.id,
1479
+ title: product.title,
1480
+ vendor: product.vendor
1481
+ },
1482
+ selectedOptions: variant.selectedOptions,
1483
+ sku: variant.sku || "",
1484
+ title: variant.title || ""
1485
+ };
1486
+ }) || [];
1487
+ return isHydrogenReact ? {
1488
+ collections: {
1489
+ nodes: product?.collections.nodes.map((collection) => {
1490
+ return {
1491
+ handle: collection.handle
1492
+ };
1493
+ }) || []
1494
+ },
1495
+ compareAtPriceRange: {
1496
+ maxVariantCompareAtPrice: null,
1497
+ minVariantCompareAtPrice: null
1498
+ },
1499
+ description: product?.description || "",
1500
+ descriptionHtml: product?.descriptionHtml || "",
1501
+ featuredImage: {
1502
+ altText: product?.featuredImage?.altText || "",
1503
+ height: product?.featuredImage?.height || 100,
1504
+ id: product?.featuredImage?.id || "",
1505
+ url: product?.featuredImage?.url || "",
1506
+ width: product?.featuredImage?.width || 100
1507
+ },
1508
+ handle: product?.handle || "",
1509
+ id: product?.id || "",
1510
+ images: [
1511
+ { altText: "", height: 100, id: "", url: "", width: 100 }
1512
+ ],
1513
+ media: [],
1514
+ metafields: [],
1515
+ options: [],
1516
+ priceRange: product?.priceRange || {
1517
+ maxVariantPrice: { amount: "0", currencyCode: "USD" },
1518
+ minVariantPrice: { amount: "0", currencyCode: "USD" }
1519
+ },
1520
+ selected: true,
1521
+ selectedOptions: product?.selectedVariant?.selectedOptions?.reduce(
1522
+ (acc, option) => {
1523
+ return { ...acc, [option.name]: option.value };
1524
+ },
1525
+ {}
1526
+ ) || {},
1527
+ selectedSellingPlan: {},
1528
+ selectedSellingPlanAllocation: {},
1529
+ selectedVariant: {
1530
+ availableForSale: product?.selectedVariant?.availableForSale || false,
1531
+ compareAtPriceV2: {
1532
+ amount: product?.selectedVariant?.compareAtPrice?.amount || "",
1533
+ currencyCode: product?.selectedVariant?.compareAtPrice?.currencyCode || "USD"
1534
+ },
1535
+ id: product?.selectedVariant?.id || "",
1536
+ image: {
1537
+ altText: product?.selectedVariant?.image?.altText || "",
1538
+ height: product?.selectedVariant?.image?.height || 100,
1539
+ id: product?.selectedVariant?.image?.id || "",
1540
+ url: product?.selectedVariant?.image?.url || "",
1541
+ width: product?.selectedVariant?.image?.width || 100
1542
+ },
1543
+ priceV2: {
1544
+ amount: product?.selectedVariant?.price.amount || "",
1545
+ currencyCode: product?.selectedVariant?.price.currencyCode || "USD"
1546
+ },
1547
+ product: {
1548
+ handle: product?.handle || "",
1549
+ id: product?.id || "",
1550
+ title: product?.title || "",
1551
+ vendor: product?.vendor || ""
1552
+ },
1553
+ selectedOptions: product?.selectedVariant?.selectedOptions || [],
1554
+ sku: product?.selectedVariant?.sku || "",
1555
+ title: product?.selectedVariant?.title || ""
1556
+ },
1557
+ sellingPlanGroups: [],
1558
+ seo: {
1559
+ description: product?.seo?.description || "",
1560
+ title: product?.seo?.title || ""
1561
+ },
1562
+ title: product?.title || "",
1563
+ variants: {
1564
+ nodes: mainProductVariants
1565
+ },
1566
+ vendor: product?.vendor || ""
1567
+ } : {
1568
+ collections: {
1569
+ nodes: []
1570
+ },
1571
+ compareAtPriceRange: {
1572
+ maxVariantCompareAtPrice: null,
1573
+ minVariantCompareAtPrice: null
1574
+ },
1575
+ description: product?.description || "",
1576
+ descriptionHtml: product?.descriptionHtml || "",
1577
+ featuredImage: {
1578
+ altText: product?.selectedOrFirstAvailableVariant?.image?.altText || "",
1579
+ height: product?.selectedOrFirstAvailableVariant?.image?.height || 100,
1580
+ id: product?.selectedOrFirstAvailableVariant?.image?.id || "",
1581
+ url: product?.selectedOrFirstAvailableVariant?.image?.url || "",
1582
+ width: product?.selectedOrFirstAvailableVariant?.image?.width || 100
1583
+ },
1584
+ handle: product?.handle || "",
1585
+ id: product?.id || "",
1586
+ images: [
1587
+ {
1588
+ altText: product?.selectedOrFirstAvailableVariant?.image?.altText || "",
1589
+ height: product?.selectedOrFirstAvailableVariant?.image?.height || 100,
1590
+ id: product?.selectedOrFirstAvailableVariant?.image?.id || "",
1591
+ url: product?.selectedOrFirstAvailableVariant?.image?.url || "",
1592
+ width: product?.selectedOrFirstAvailableVariant?.image?.width || 100
1593
+ }
1594
+ ],
1595
+ media: [],
1596
+ metafields: [],
1597
+ options: [],
1598
+ priceRange: product?.priceRange || {
1599
+ maxVariantPrice: { amount: "0", currencyCode: "USD" },
1600
+ minVariantPrice: { amount: "0", currencyCode: "USD" }
1601
+ },
1602
+ selected: true,
1603
+ selectedOptions: product?.selectedOrFirstAvailableVariant?.selectedOptions?.reduce(
1604
+ (acc, option) => {
1605
+ return { ...acc, [option.name]: option.value };
1606
+ },
1607
+ {}
1608
+ ) || {},
1609
+ selectedSellingPlan: {},
1610
+ selectedSellingPlanAllocation: {},
1611
+ selectedVariant: {
1612
+ availableForSale: product?.selectedOrFirstAvailableVariant?.availableForSale || false,
1613
+ compareAtPriceV2: {
1614
+ amount: product?.selectedOrFirstAvailableVariant?.compareAtPrice?.amount || "",
1615
+ currencyCode: product?.selectedOrFirstAvailableVariant?.compareAtPrice?.currencyCode || "USD"
1616
+ },
1617
+ id: product?.selectedOrFirstAvailableVariant?.id || "",
1618
+ image: {
1619
+ altText: product?.selectedOrFirstAvailableVariant?.image?.altText || "",
1620
+ height: product?.selectedOrFirstAvailableVariant?.image?.height || 100,
1621
+ id: product?.selectedOrFirstAvailableVariant?.image?.id || "",
1622
+ url: product?.selectedOrFirstAvailableVariant?.image?.url || "",
1623
+ width: product?.selectedOrFirstAvailableVariant?.image?.width || 100
1624
+ },
1625
+ priceV2: {
1626
+ amount: product?.selectedOrFirstAvailableVariant?.price.amount || "",
1627
+ currencyCode: product?.selectedOrFirstAvailableVariant?.price.currencyCode || "USD"
1628
+ },
1629
+ product: {
1630
+ handle: product?.handle || "",
1631
+ id: product?.id || "",
1632
+ title: product?.title || "",
1633
+ vendor: product?.vendor || ""
1634
+ },
1635
+ selectedOptions: product?.selectedOrFirstAvailableVariant?.selectedOptions || [],
1636
+ sku: product?.selectedOrFirstAvailableVariant?.sku || "",
1637
+ title: product?.selectedOrFirstAvailableVariant?.title || ""
1638
+ },
1639
+ sellingPlanGroups: [],
1640
+ seo: {
1641
+ description: null,
1642
+ title: null
1643
+ },
1644
+ title: product?.title || "",
1645
+ variants: {
1646
+ nodes: [
1647
+ {
1648
+ availableForSale: product?.selectedOrFirstAvailableVariant?.availableForSale || false,
1649
+ compareAtPriceV2: {
1650
+ amount: product?.selectedOrFirstAvailableVariant?.compareAtPrice?.amount || "",
1651
+ currencyCode: product?.selectedOrFirstAvailableVariant?.compareAtPrice?.currencyCode || "USD"
1652
+ },
1653
+ id: product?.selectedOrFirstAvailableVariant?.id || "",
1654
+ image: {
1655
+ altText: product?.selectedOrFirstAvailableVariant?.image?.altText || "",
1656
+ height: product?.selectedOrFirstAvailableVariant?.image?.height || 100,
1657
+ id: product?.selectedOrFirstAvailableVariant?.image?.id || "",
1658
+ url: product?.selectedOrFirstAvailableVariant?.image?.url || "",
1659
+ width: product?.selectedOrFirstAvailableVariant?.image?.width || 100
1660
+ },
1661
+ priceV2: {
1662
+ amount: product?.selectedOrFirstAvailableVariant?.price.amount || "",
1663
+ currencyCode: product?.selectedOrFirstAvailableVariant?.price.currencyCode || "USD"
1664
+ },
1665
+ product: {
1666
+ handle: product?.handle || "",
1667
+ id: product?.id || "",
1668
+ title: product?.title || "",
1669
+ vendor: product?.vendor || ""
1670
+ },
1671
+ selectedOptions: product?.selectedOrFirstAvailableVariant?.selectedOptions || [],
1672
+ sku: product?.selectedOrFirstAvailableVariant?.sku || "",
1673
+ title: product?.selectedOrFirstAvailableVariant?.title || ""
1674
+ },
1675
+ ...mainProductVariants
1676
+ ]
1677
+ },
1678
+ vendor: product?.vendor || ""
1679
+ };
1680
+ };
1681
+
1682
+ // src/widgets/RebuyDynamicBundleProducts/BundleImages.tsx
1683
+ var import_react9 = require("@remix-run/react");
1684
+ var import_hydrogen6 = require("@shopify/hydrogen");
1685
+ var import_react10 = require("react");
1686
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1687
+ var BundleImages = ({ products }) => {
1688
+ const selected = products.filter((product) => product.selected);
1689
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("ul", { className: RebuyDynamicBundleProducts_default.bundleImages, children: products.map((product, index) => {
1690
+ const image = product.selectedVariant?.image;
1691
+ const productImage = image ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1692
+ import_hydrogen6.Image,
1693
+ {
1694
+ alt: image.altText || `Picture of ${product.title}`,
1695
+ className: RebuyDynamicBundleProducts_default.bundleImage,
1696
+ data: image,
1697
+ height: 80,
1698
+ title: product.title,
1699
+ width: 80
1700
+ }
1701
+ ) : (
1702
+ // No image defined
1703
+ product.title
1704
+ );
1705
+ const showDelimiter = selected[0]?.id !== product.id;
1706
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react10.Fragment, { children: product.selected && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
1707
+ showDelimiter && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("li", { className: RebuyDynamicBundleProducts_default.bundleImageDelimiter, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: "+" }) }),
1708
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("li", { className: "flex items-center", children: product.default ? (
1709
+ // Already on product page
1710
+ productImage
1711
+ ) : (
1712
+ // Link to product
1713
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1714
+ import_react9.Link,
1715
+ {
1716
+ title: product.title,
1717
+ to: `/products/${product.handle}`,
1718
+ children: productImage
1719
+ }
1720
+ )
1721
+ ) })
1722
+ ] }) }, product.id + "-BundleImages-" + index);
1723
+ }) });
1724
+ };
1725
+
1726
+ // src/widgets/RebuyDynamicBundleProducts/Select.tsx
1727
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1728
+ var Select = ({ onSelectVariant, product }) => {
1729
+ const getOptionsLabel = (product2) => {
1730
+ const options = product2.variants.nodes[0].selectedOptions;
1731
+ const optionsFromKeys = options ? Object.keys(options[0]) : [];
1732
+ const optionsFromValues = options ? options.map((option) => option.name) : [];
1733
+ const useValues = optionsFromKeys.every(
1734
+ (key) => ["name", "value"].includes(key)
1735
+ );
1736
+ return (useValues ? optionsFromValues : optionsFromKeys).join(" / ");
1737
+ };
1738
+ return product && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1739
+ "select",
1740
+ {
1741
+ "aria-label": "select variant",
1742
+ className: RebuyDynamicBundleProducts_default.select,
1743
+ onChange: (e) => onSelectVariant(product, e.target.value),
1744
+ value: product.selectedVariant.id,
1745
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("optgroup", { label: getOptionsLabel(product), children: product.variants.nodes.map(({ id, title }) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: id, children: title }, id + "-BundleVariant")) })
1746
+ }
1747
+ );
1748
+ };
1749
+
1750
+ // src/widgets/RebuyDynamicBundleProducts/BundleSelection.tsx
1751
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1752
+ var BundleSelection = ({
1753
+ onSelectVariant,
1754
+ onToggleBundleItem,
1755
+ products
1756
+ }) => {
1757
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("ul", { children: products.map((product, index) => {
1758
+ const { availableForSale } = product.selectedVariant;
1759
+ const isOutOfStock = !availableForSale;
1760
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1761
+ "li",
1762
+ {
1763
+ className: `${RebuyDynamicBundleProducts_default.bundleItemRowContainer} ${!product.selected && RebuyDynamicBundleProducts_default.unselected}`,
1764
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleItemRow, children: [
1765
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1766
+ "input",
1767
+ {
1768
+ checked: product.selected && availableForSale,
1769
+ className: "mt-1 rounded-sm accent-black cursor-pointer",
1770
+ disabled: isOutOfStock,
1771
+ id: `${product.id}-toggle`,
1772
+ onChange: () => onToggleBundleItem(product),
1773
+ type: "checkbox",
1774
+ value: product.id
1775
+ }
1776
+ ),
1777
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleItemInput, children: [
1778
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1779
+ "label",
1780
+ {
1781
+ className: RebuyDynamicBundleProducts_default.bundleItemLabel,
1782
+ htmlFor: `${product.id}-toggle`,
1783
+ children: [
1784
+ isOutOfStock && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("b", { children: "SOLD OUT" }),
1785
+ product.default && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("b", { children: "This item:" }),
1786
+ product.title,
1787
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1788
+ RebuyProductPrice,
1789
+ {
1790
+ selectedVariant: product.selectedVariant
1791
+ }
1792
+ )
1793
+ ]
1794
+ }
1795
+ ),
1796
+ product.variants.nodes.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1797
+ Select,
1798
+ {
1799
+ onSelectVariant,
1800
+ product
1801
+ }
1802
+ )
1803
+ ] })
1804
+ ] })
1805
+ },
1806
+ product.id + "-BundleSelection" + index
1807
+ );
1808
+ }) });
1809
+ };
1810
+
1811
+ // src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.tsx
1812
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1813
+ var RebuyDynamicBundleProducts = (props) => {
1814
+ const {
1815
+ addToCartBtnText = "Add to cart",
1816
+ addToCartCallback,
1817
+ customTitle = `These pair with ${props.product?.title}`,
1818
+ customTitleLevel = "h2",
1819
+ customTitleStyle,
1820
+ isHydrogenReact,
1821
+ product,
1822
+ products = []
1823
+ } = props;
1824
+ const [bundleProducts, setBundleProducts] = (0, import_react11.useState)([]);
1825
+ (0, import_react11.useEffect)(() => {
1826
+ const mainProduct = convertToRebuyProduct(
1827
+ isHydrogenReact || false,
1828
+ product
1829
+ );
1830
+ const formattedProducts = products.map((product2) => {
1831
+ return {
1832
+ ...product2,
1833
+ selected: true,
1834
+ selectedVariant: product2.variants.nodes[0]
1835
+ };
1836
+ });
1837
+ setBundleProducts([mainProduct, ...formattedProducts]);
1838
+ }, [product, products, isHydrogenReact]);
1839
+ const onToggleBundleItem = (0, import_react11.useCallback)(
1840
+ (product2) => {
1841
+ product2.selected = !product2.selected;
1842
+ setBundleProducts([...bundleProducts]);
1843
+ },
1844
+ [bundleProducts]
1845
+ );
1846
+ const onSelectVariant = (0, import_react11.useCallback)(
1847
+ (product2, variant_id) => {
1848
+ const variant = product2.variants.nodes.find(
1849
+ ({ id }) => id === variant_id
1850
+ );
1851
+ if (variant) {
1852
+ product2.selectedVariant = variant;
1853
+ product2.selected = variant.availableForSale || false;
1854
+ setBundleProducts([...bundleProducts]);
1855
+ }
1856
+ },
1857
+ [bundleProducts]
1858
+ );
1859
+ if (products.length === 0) {
1860
+ console.log("RebuyDynamicBundleProducts: No products found");
1861
+ return null;
1862
+ }
1863
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("section", { className: RebuyDynamicBundleProducts_default.container, children: [
1864
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1865
+ Title,
1866
+ {
1867
+ level: getTitleLevel(customTitleLevel),
1868
+ style: customTitleStyle,
1869
+ text: customTitle
1870
+ }
1871
+ ),
1872
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleContainer, children: [
1873
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(BundleImages, { products: bundleProducts }),
1874
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(BundlePrice, { products: bundleProducts }),
1875
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: RebuyDynamicBundleProducts_default.addCartBtnContainer, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1876
+ AddToCartBtn,
1877
+ {
1878
+ addToCartBtnText,
1879
+ addToCartCallback,
1880
+ disabled: bundleProducts.filter((product2) => product2.selected).length === 0,
1881
+ isHydrogenReact,
1882
+ selectedVariants: bundleProducts.filter((product2) => product2.selected).map((product2) => {
1883
+ return product2.selectedVariant;
1884
+ })
1885
+ }
1886
+ ) }),
1887
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1888
+ BundleSelection,
1889
+ {
1890
+ onSelectVariant,
1891
+ onToggleBundleItem,
1892
+ products: bundleProducts
1893
+ }
1894
+ )
1895
+ ] })
1896
+ ] });
1897
+ };
1898
+
1899
+ // src/widgets/RebuyProductAddOns/RebuyProductAddOns.tsx
1900
+ var import_hydrogen_react3 = require("@shopify/hydrogen-react");
1901
+ var import_react13 = require("react");
1902
+
1903
+ // src/widgets/RebuyProductAddOns/RebuyProductAddOnCard.tsx
1904
+ var import_react12 = require("@remix-run/react");
1905
+ var import_hydrogen7 = require("@shopify/hydrogen");
1906
+
1907
+ // src/widgets/RebuyProductAddOns/RebuyProductAddOns.module.css
1908
+ var RebuyProductAddOns_default = {
1909
+ container: "RebuyProductAddOns_container",
1910
+ productAddOnsList: "RebuyProductAddOns_productAddOnsList",
1911
+ addOnCard: "RebuyProductAddOns_addOnCard",
1912
+ addOnCardContent: "RebuyProductAddOns_addOnCardContent",
1913
+ addOnCardInput: "RebuyProductAddOns_addOnCardInput",
1914
+ addOnCardContentImage: "RebuyProductAddOns_addOnCardContentImage",
1915
+ addOnCardOutOfStock: "RebuyProductAddOns_addOnCardOutOfStock",
1916
+ addOnCardTextContent: "RebuyProductAddOns_addOnCardTextContent",
1917
+ addOnCardLearnMore: "RebuyProductAddOns_addOnCardLearnMore",
1918
+ addCartBtnContainer: "RebuyProductAddOns_addCartBtnContainer",
1919
+ moneyContainer: "RebuyProductAddOns_moneyContainer"
1920
+ };
1921
+
1922
+ // src/widgets/RebuyProductAddOns/RebuyProductAddOnCard.tsx
1923
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1924
+ var RebuyProductAddOnCard = ({
1925
+ handleChange,
1926
+ learnMoreText,
1927
+ outOfStockText,
1928
+ product,
1929
+ titleLevel
1930
+ }) => {
1931
+ const { availableForSale, image } = product.selectedVariant || {};
1932
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { className: RebuyProductAddOns_default.addOnCard, htmlFor: product.id, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: RebuyProductAddOns_default.addOnCardContent, children: [
1933
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1934
+ "input",
1935
+ {
1936
+ checked: Boolean(product.selected),
1937
+ className: RebuyProductAddOns_default.addOnCardInput,
1938
+ disabled: !product.variants.nodes[0].availableForSale,
1939
+ id: product.id,
1940
+ name: product.title,
1941
+ onChange: (event) => handleChange(event, product),
1942
+ type: "checkbox",
1943
+ value: ""
1944
+ }
1945
+ ),
1946
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: RebuyProductAddOns_default.addOnCardContentImage, children: image && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1947
+ import_hydrogen7.Image,
1948
+ {
1949
+ alt: image.altText || `Picture of ${product.title}`,
1950
+ data: image,
1951
+ height: 150,
1952
+ width: 300
1953
+ }
1954
+ ) }),
1955
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: RebuyProductAddOns_default.addOnCardTextContent, children: [
1956
+ !availableForSale && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: RebuyProductAddOns_default.addOnCardOutOfStock, children: outOfStockText }),
1957
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Title, { level: titleLevel, text: product.title }),
1958
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1959
+ RebuyProductPrice,
1960
+ {
1961
+ selectedVariant: product.selectedVariant
1962
+ }
1963
+ ),
1964
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1965
+ import_react12.Link,
1966
+ {
1967
+ className: RebuyProductAddOns_default.addOnCardLearnMore,
1968
+ to: `/products/${product.handle}`,
1969
+ children: learnMoreText
1970
+ }
1971
+ )
1972
+ ] })
1973
+ ] }) });
1974
+ };
1975
+
1976
+ // src/widgets/RebuyProductAddOns/RebuyProductAddOns.tsx
1977
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1978
+ var RebuyProductAddOns = (props) => {
1979
+ const {
1980
+ addToCartCallback,
1981
+ customTitle = `These pair with ${props.product?.title}`,
1982
+ customTitleLevel = "h2",
1983
+ customTitleStyle,
1984
+ includeMainProduct = false,
1985
+ isHydrogenReact,
1986
+ learnMoreText = "Learn more",
1987
+ outOfStockText = "Out of stock",
1988
+ product,
1989
+ products = [],
1990
+ addToCartBtnText = "Add to cart",
1991
+ subtotalText = "Add-ons Subtotal: ",
1992
+ withProductText = `With ${product?.title}: `
1993
+ } = props;
1994
+ const [addedItems, setAddedItems] = (0, import_react13.useState)(products);
1995
+ const [subtotalWithProduct, setSubtotalWithProduct] = (0, import_react13.useState)();
1996
+ const [subtotalWithOutProduct, setSubtotalWithOutProduct] = (0, import_react13.useState)();
1997
+ (0, import_react13.useEffect)(() => {
1998
+ let initialTotal = 0;
1999
+ let currencyCode = "USD";
2000
+ products.map((product2) => {
2001
+ product2.selectedVariant = product2.variants.nodes[0];
2002
+ product2.selected = true;
2003
+ if (product2.selectedVariant?.priceV2) {
2004
+ initialTotal += Number(product2.selectedVariant.priceV2.amount);
2005
+ currencyCode = product2.selectedVariant.priceV2.currencyCode || "USD";
2006
+ }
2007
+ });
2008
+ setSubtotalWithProduct({
2009
+ amount: String(initialTotal),
2010
+ currencyCode
2011
+ });
2012
+ setSubtotalWithOutProduct({
2013
+ amount: String(
2014
+ initialTotal - Number(
2015
+ isHydrogenReact ? product?.selectedVariant?.price.amount : product?.selectedOrFirstAvailableVariant?.price.amount
2016
+ )
2017
+ ),
2018
+ currencyCode
2019
+ });
2020
+ setAddedItems(products);
2021
+ if (includeMainProduct) {
2022
+ setAddedItems([
2023
+ convertToRebuyProduct(isHydrogenReact || false, product),
2024
+ ...products
2025
+ ]);
2026
+ } else {
2027
+ setAddedItems(products);
2028
+ }
2029
+ }, [products, product, isHydrogenReact, includeMainProduct]);
2030
+ const handleChange = (0, import_react13.useCallback)(
2031
+ (event, product2) => {
2032
+ const newProducts = [...products];
2033
+ const productIndex = newProducts.findIndex(
2034
+ (p) => p.id === product2.id
2035
+ );
2036
+ if (productIndex !== -1) {
2037
+ newProducts[productIndex] = {
2038
+ ...newProducts[productIndex],
2039
+ selected: event.target.checked
2040
+ };
2041
+ product2.selected = event.target.checked;
2042
+ if (event.target.checked) {
2043
+ setAddedItems((prev) => [...prev, product2]);
2044
+ } else {
2045
+ setAddedItems(
2046
+ (prev) => prev.filter((item) => item.id !== product2.id)
2047
+ );
2048
+ }
2049
+ }
2050
+ },
2051
+ [products]
2052
+ );
2053
+ (0, import_react13.useEffect)(() => {
2054
+ let total = 0;
2055
+ let currencyCode = "USD";
2056
+ addedItems.forEach((item) => {
2057
+ if (item.selected && item.selectedVariant?.priceV2) {
2058
+ total += Number(item.selectedVariant.priceV2.amount);
2059
+ currencyCode = item.selectedVariant.priceV2.currencyCode || "USD";
2060
+ }
2061
+ });
2062
+ setSubtotalWithProduct({
2063
+ amount: String(total),
2064
+ currencyCode
2065
+ });
2066
+ setSubtotalWithOutProduct({
2067
+ amount: String(
2068
+ total - Number(
2069
+ isHydrogenReact ? product?.selectedVariant?.price.amount : product?.selectedOrFirstAvailableVariant?.price.amount
2070
+ )
2071
+ ),
2072
+ currencyCode
2073
+ });
2074
+ }, [addedItems, product, isHydrogenReact]);
2075
+ if (products.length === 0) {
2076
+ console.log("RebuyProductAddOns: No products found");
2077
+ return null;
2078
+ }
2079
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: RebuyProductAddOns_default.container, children: [
2080
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2081
+ Title,
2082
+ {
2083
+ level: getTitleLevel(customTitleLevel),
2084
+ style: customTitleStyle,
2085
+ text: customTitle
2086
+ }
2087
+ ),
2088
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("ul", { className: RebuyProductAddOns_default.productAddOnsList, children: products.map((product2) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2089
+ RebuyProductAddOnCard,
2090
+ {
2091
+ handleChange,
2092
+ learnMoreText,
2093
+ outOfStockText,
2094
+ product: product2,
2095
+ titleLevel: getTitleLevel(customTitleLevel, true)
2096
+ }
2097
+ ) }, product2.id)) }),
2098
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: RebuyProductAddOns_default.productAddOnsFooter, children: [
2099
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: RebuyProductAddOns_default.moneyContainer, children: [
2100
+ subtotalText,
2101
+ subtotalWithOutProduct && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2102
+ import_hydrogen_react3.Money,
2103
+ {
2104
+ data: subtotalWithOutProduct,
2105
+ withoutTrailingZeros: true
2106
+ }
2107
+ )
2108
+ ] }),
2109
+ includeMainProduct && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: RebuyProductAddOns_default.moneyContainer, children: [
2110
+ withProductText,
2111
+ subtotalWithProduct && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2112
+ import_hydrogen_react3.Money,
2113
+ {
2114
+ data: subtotalWithProduct,
2115
+ withoutTrailingZeros: true
2116
+ }
2117
+ )
2118
+ ] }),
2119
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: RebuyProductAddOns_default.addCartBtnContainer, children: includeMainProduct ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2120
+ AddToCartBtn,
2121
+ {
2122
+ addToCartBtnText,
2123
+ addToCartCallback,
2124
+ disabled: addedItems.length === 0,
2125
+ isHydrogenReact,
2126
+ moneyData: subtotalWithProduct,
2127
+ selectedVariants: addedItems.map(
2128
+ (item) => item.selectedVariant
2129
+ )
2130
+ }
2131
+ ) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2132
+ AddToCartBtn,
2133
+ {
2134
+ addToCartBtnText,
2135
+ addToCartCallback,
2136
+ disabled: addedItems.length === 0,
2137
+ isHydrogenReact,
2138
+ moneyData: subtotalWithOutProduct,
2139
+ selectedVariants: addedItems.map(
2140
+ (item) => item.selectedVariant
2141
+ )
2142
+ }
2143
+ ) })
2144
+ ] })
2145
+ ] });
2146
+ };
2147
+
2148
+ // src/widgets/RebuyProductRecommendations/RebuyProductRecommendations.module.css
2149
+ var RebuyProductRecommendations_default = {
2150
+ container: "RebuyProductRecommendations_container",
2151
+ productGrid: "RebuyProductRecommendations_productGrid"
2152
+ };
2153
+
2154
+ // src/widgets/RebuyProductRecommendations/RebuyProductRecommendations.tsx
2155
+ var import_jsx_runtime18 = require("react/jsx-runtime");
2156
+ var RebuyProductRecommendations = (props) => {
2157
+ const {
2158
+ addToCartBtnText = "Add to cart",
2159
+ addToCartCallback,
2160
+ customTitle = `These pair with ${props.product?.title}`,
2161
+ customTitleLevel = "h2",
2162
+ customTitleStyle,
2163
+ products = []
2164
+ } = props;
2165
+ if (products.length === 0) {
2166
+ console.log("RebuyProductRecommendations: No products found");
2167
+ return null;
2168
+ }
2169
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("section", { className: RebuyProductRecommendations_default.container, children: [
2170
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2171
+ Title,
2172
+ {
2173
+ level: getTitleLevel(customTitleLevel),
2174
+ style: customTitleStyle,
2175
+ text: customTitle
2176
+ }
2177
+ ),
2178
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("ul", { className: RebuyProductRecommendations_default.productGrid, children: products.map((product) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("li", { className: RebuyProductRecommendations_default.productItem, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2179
+ ProductCard,
2180
+ {
2181
+ addToCartBtnText,
2182
+ addToCartCallback,
2183
+ isHydrogenReact: props.isHydrogenReact,
2184
+ product,
2185
+ productCardTitleLevel: getTitleLevel(
2186
+ customTitleLevel,
2187
+ true
2188
+ )
2189
+ }
2190
+ ) }, product.id)) })
2191
+ ] });
2192
+ };
2193
+ //# sourceMappingURL=index.js.map