@rebuy/rebuy-hydrogen 3.0.0-beta.10 → 3.0.0-beta.3

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 (44) hide show
  1. package/dist/components/AddToCartBtn/AddToCartBtn.d.ts.map +1 -1
  2. package/dist/components/AddToCartBtn/HydrogenAddToCartBtn.d.ts.map +1 -1
  3. package/dist/components/AddToCartBtn/HydrogenReactAddToCartBtn.d.ts.map +1 -1
  4. package/dist/components/ProductCard/ProductCard.d.ts.map +1 -1
  5. package/dist/components/ProductPrice/ProductPrice.d.ts +1 -1
  6. package/dist/components/ProductPrice/ProductPrice.d.ts.map +1 -1
  7. package/dist/components/VariantSelect/VariantSelect.d.ts +1 -1
  8. package/dist/components/VariantSelect/VariantSelect.d.ts.map +1 -1
  9. package/dist/hooks/titleLevel.d.ts.map +1 -1
  10. package/dist/index.css +88 -88
  11. package/dist/index.css.map +4 -4
  12. package/dist/index.js +421 -195
  13. package/dist/index.js.map +4 -4
  14. package/dist/index.mjs +430 -196
  15. package/dist/index.mjs.map +4 -4
  16. package/dist/providers/RebuyHydrogenContextProvider.d.ts +1 -1
  17. package/dist/providers/RebuyHydrogenContextProvider.d.ts.map +1 -1
  18. package/dist/providers/RebuyHydrogenReactContextProvider.d.ts.map +1 -1
  19. package/dist/providers/types.d.ts +1 -7
  20. package/dist/providers/types.d.ts.map +1 -1
  21. package/dist/types/rebuyCustom.d.ts +0 -1
  22. package/dist/types/rebuyCustom.d.ts.map +1 -1
  23. package/dist/types/shopify.d.ts.map +1 -1
  24. package/dist/types/widgets.d.ts +1 -1
  25. package/dist/types/widgets.d.ts.map +1 -1
  26. package/dist/utils/convertToRebuyProduct.d.ts.map +1 -1
  27. package/dist/utils/createContextParameters.d.ts.map +1 -1
  28. package/dist/utils/getEncodedAttributes.d.ts.map +1 -1
  29. package/dist/utils/getRebuyConfig.d.ts +1 -1
  30. package/dist/utils/getRebuyConfig.d.ts.map +1 -1
  31. package/dist/widgetContainer/RebuyWidgetContainer.d.ts +1 -1
  32. package/dist/widgetContainer/RebuyWidgetContainer.d.ts.map +1 -1
  33. package/dist/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.d.ts.map +1 -1
  34. package/dist/widgets/RebuyDynamicBundleProducts/BundleImages.d.ts.map +1 -1
  35. package/dist/widgets/RebuyDynamicBundleProducts/BundlePrice.d.ts.map +1 -1
  36. package/dist/widgets/RebuyDynamicBundleProducts/BundleSelection.d.ts +1 -1
  37. package/dist/widgets/RebuyDynamicBundleProducts/BundleSelection.d.ts.map +1 -1
  38. package/dist/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.d.ts.map +1 -1
  39. package/dist/widgets/RebuyDynamicBundleProducts/Select.d.ts.map +1 -1
  40. package/dist/widgets/RebuyProductAddOns/RebuyProductAddOnCard.d.ts.map +1 -1
  41. package/dist/widgets/RebuyProductAddOns/RebuyProductAddOns.d.ts.map +1 -1
  42. package/dist/widgets/RebuyProductAddOns/types.d.ts.map +1 -1
  43. package/dist/widgets/RebuyProductRecommendations/RebuyProductRecommendations.d.ts.map +1 -1
  44. package/package.json +20 -3
package/dist/index.js CHANGED
@@ -54,7 +54,12 @@ var Utilities = __toESM(require("@rebuy/rebuy/utilities"), 1);
54
54
 
55
55
  // src/utils/getEncodedAttributes.ts
56
56
  var getEncodedAttributes = (attributes) => encodeURIComponent(
57
- JSON.stringify(attributes.reduce((merged, { key, value }) => ({ ...merged, [key]: value }), {}))
57
+ JSON.stringify(
58
+ attributes.reduce(
59
+ (merged, { key, value }) => ({ ...merged, [key]: value }),
60
+ {}
61
+ )
62
+ )
58
63
  );
59
64
 
60
65
  // src/utils/createContextParameters.ts
@@ -95,11 +100,18 @@ var createContextParameters = ({
95
100
  }
96
101
  if (cartId) {
97
102
  cartContext.token = Utilities.getIdFromGraphUrl(cartId, "Cart");
98
- contextParameters.cart_token = Utilities.getIdFromGraphUrl(cartId, "Cart");
103
+ contextParameters.cart_token = Utilities.getIdFromGraphUrl(
104
+ cartId,
105
+ "Cart"
106
+ );
99
107
  }
100
108
  if (cartSubtotal) {
101
- cartContext.subtotal = Utilities.amountToCents(parseFloat(cartSubtotal));
102
- contextParameters.cart_subtotal = Utilities.amountToCents(parseFloat(cartSubtotal));
109
+ cartContext.subtotal = Utilities.amountToCents(
110
+ parseFloat(cartSubtotal)
111
+ );
112
+ contextParameters.cart_subtotal = Utilities.amountToCents(
113
+ parseFloat(cartSubtotal)
114
+ );
103
115
  }
104
116
  if (cartLinesLength) {
105
117
  const totalLines = cartLinesLength;
@@ -122,10 +134,16 @@ var createContextParameters = ({
122
134
  variant_id: ""
123
135
  };
124
136
  if (cartItem?.merchandise?.product?.id) {
125
- item.product_id = Utilities.getIdFromGraphUrl(cartItem.merchandise.product.id, "Product");
137
+ item.product_id = Utilities.getIdFromGraphUrl(
138
+ cartItem.merchandise.product.id,
139
+ "Product"
140
+ );
126
141
  }
127
142
  if (cartItem?.merchandise?.id) {
128
- item.variant_id = Utilities.getIdFromGraphUrl(cartItem.merchandise.id, "ProductVariant");
143
+ item.variant_id = Utilities.getIdFromGraphUrl(
144
+ cartItem.merchandise.id,
145
+ "ProductVariant"
146
+ );
129
147
  }
130
148
  if (cartItem?.attributes?.length) {
131
149
  const validAttributes = cartItem.attributes.filter(
@@ -151,18 +169,20 @@ var createContextParameters = ({
151
169
 
152
170
  // src/utils/getRebuyConfig.ts
153
171
  var import_rebuy = require("@rebuy/rebuy");
154
- var getRebuyConfig = async (storeDomain) => {
172
+ var getRebuyConfig = async (rebuyKey, storeDomain) => {
155
173
  try {
156
174
  const request = {
157
175
  parameters: { shop: storeDomain },
158
176
  url: `/api/v1/user/config`
159
177
  };
160
- const { data: rebuy, ...response } = await new import_rebuy.RebuyClient(void 0, void 0, storeDomain).getShieldedAsset(
161
- request.url,
162
- request.parameters
163
- );
178
+ const { data: rebuy, ...response } = await new import_rebuy.RebuyClient(
179
+ rebuyKey
180
+ ).getShieldedAsset(request.url, request.parameters);
164
181
  if (!rebuy?.shop) {
165
- throw new Error("Rebuy configuration is not properly set up - missing shop", { cause: response });
182
+ throw new Error(
183
+ "Rebuy configuration is not properly set up - missing shop",
184
+ { cause: response }
185
+ );
166
186
  }
167
187
  return rebuy;
168
188
  } catch (error) {
@@ -176,30 +196,30 @@ var getRebuyConfig = async (storeDomain) => {
176
196
  // src/providers/RebuyHydrogenContextProvider.tsx
177
197
  var import_jsx_runtime = require("react/jsx-runtime");
178
198
  var RebuyHydrogenContext = ({
179
- apiKey,
180
199
  cartAttributes,
181
200
  cartCost,
182
201
  cartId,
183
202
  cartLines,
184
203
  cartNote,
185
204
  cartQuantity,
186
- children,
187
- publicStoreDomain,
188
- shop
205
+ children
189
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;
190
210
  const [rebuyConfig, setRebuyConfig] = (0, import_react3.useState)(null);
191
211
  const location = (0, import_react2.useLocation)();
192
212
  const queryObject = Utilities2.queryStringToObject(location.search);
193
- const windowUrl = `${shop}${location.pathname}${location.search}`;
213
+ const windowUrl = `${primaryDomain}${location.pathname}${location.search}`;
194
214
  (0, import_react3.useEffect)(() => {
195
215
  const initConfig = async () => {
196
- const config = await getRebuyConfig(publicStoreDomain);
216
+ const config = await getRebuyConfig(rebuyKey, storeDomain);
197
217
  setRebuyConfig(config);
198
218
  };
199
219
  if (!rebuyConfig?.shop) {
200
220
  initConfig();
201
221
  }
202
- }, [rebuyConfig]);
222
+ }, [rebuyConfig, rebuyKey, storeDomain]);
203
223
  const contextParameters = (0, import_react3.useMemo)(
204
224
  () => createContextParameters({
205
225
  cacheKey: rebuyConfig?.shop?.cache_key,
@@ -214,7 +234,17 @@ var RebuyHydrogenContext = ({
214
234
  queryObject,
215
235
  windowUrl
216
236
  }),
217
- [rebuyConfig, windowUrl, queryObject, cartAttributes, cartCost, cartId, cartLines, cartQuantity, cartNote]
237
+ [
238
+ rebuyConfig,
239
+ windowUrl,
240
+ queryObject,
241
+ cartAttributes,
242
+ cartCost,
243
+ cartId,
244
+ cartLines,
245
+ cartQuantity,
246
+ cartNote
247
+ ]
218
248
  );
219
249
  const contextParametersJSON = JSON.stringify(contextParameters);
220
250
  const contextValue = (0, import_react3.useMemo)(
@@ -224,26 +254,20 @@ var RebuyHydrogenContext = ({
224
254
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RebuyContext.Provider, { value: contextValue, children });
225
255
  };
226
256
  var RebuyHydrogenContextProvider = ({
227
- apiKey,
228
257
  cart,
229
- children,
230
- publicStoreDomain,
231
- shop
258
+ children
232
259
  }) => {
233
260
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.Await, { resolve: cart, children: (resolvedCart) => {
234
261
  const cart2 = resolvedCart;
235
262
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
236
263
  RebuyHydrogenContext,
237
264
  {
238
- apiKey,
239
265
  cartAttributes: cart2?.attributes,
240
266
  cartCost: cart2?.cost?.subtotalAmount?.amount,
241
267
  cartId: cart2?.id,
242
268
  cartLines: cart2?.lines?.nodes,
243
269
  cartNote: cart2?.note,
244
270
  cartQuantity: cart2?.totalQuantity,
245
- publicStoreDomain,
246
- shop,
247
271
  children
248
272
  }
249
273
  );
@@ -719,25 +743,24 @@ var CART_FRAGMENT = `#graphql
719
743
 
720
744
  // src/providers/RebuyHydrogenReactContextProvider.tsx
721
745
  var import_jsx_runtime2 = require("react/jsx-runtime");
722
- var PUBLIC_PRIMARY_DOMAIN = process.env.PUBLIC_PRIMARY_DOMAIN;
723
- var PUBLIC_STORE_DOMAIN = process.env.PUBLIC_STORE_DOMAIN;
724
- var PUBLIC_STOREFRONT_ID = process.env.PUBLIC_STOREFRONT_ID;
725
- var PUBLIC_STOREFRONT_API_TOKEN = process.env.PUBLIC_STOREFRONT_API_TOKEN || "";
726
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;
727
750
  const [rebuyConfig, setRebuyConfig] = (0, import_react5.useState)(null);
728
751
  const location = (0, import_react4.useLocation)();
729
752
  const queryObject = Utilities3.queryStringToObject(location.search);
730
- const windowUrl = `${PUBLIC_PRIMARY_DOMAIN}${location.pathname}${location.search}`;
753
+ const windowUrl = `${primaryDomain}${location.pathname}${location.search}`;
731
754
  const cart = (0, import_hydrogen_react.useCart)();
732
755
  (0, import_react5.useEffect)(() => {
733
756
  const initConfig = async () => {
734
- const config = await getRebuyConfig(PUBLIC_STORE_DOMAIN);
757
+ const config = await getRebuyConfig(rebuyKey, storeDomain);
735
758
  setRebuyConfig(config);
736
759
  };
737
760
  if (!rebuyConfig?.shop) {
738
761
  initConfig();
739
762
  }
740
- }, [rebuyConfig, PUBLIC_STORE_DOMAIN]);
763
+ }, [rebuyConfig, rebuyKey, storeDomain]);
741
764
  const contextParameters = (0, import_react5.useMemo)(
742
765
  () => createContextParameters({
743
766
  cacheKey: rebuyConfig?.shop?.cache_key,
@@ -786,6 +809,9 @@ var RebuyHydrogenReactContextProvider = ({
786
809
  onNoteUpdateComplete,
787
810
  storefrontApiVersion = "2025-01"
788
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 || "";
789
815
  const adapted = {
790
816
  onAttributesUpdate: onAttributesUpdate ? () => onAttributesUpdate() : void 0,
791
817
  onAttributesUpdateComplete: onAttributesUpdateComplete ? () => onAttributesUpdateComplete() : void 0,
@@ -809,10 +835,10 @@ var RebuyHydrogenReactContextProvider = ({
809
835
  {
810
836
  countryIsoCode,
811
837
  languageIsoCode,
812
- storeDomain: PUBLIC_STORE_DOMAIN,
838
+ storeDomain: publicStoreDomain,
813
839
  storefrontApiVersion,
814
- storefrontId: PUBLIC_STOREFRONT_ID,
815
- storefrontToken: PUBLIC_STOREFRONT_API_TOKEN,
840
+ storefrontId,
841
+ storefrontToken,
816
842
  children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
817
843
  import_hydrogen_react.CartProvider,
818
844
  {
@@ -850,8 +876,21 @@ var import_rebuy2 = require("@rebuy/rebuy");
850
876
  var Utilities4 = __toESM(require("@rebuy/rebuy/utilities"), 1);
851
877
  var import_hydrogen = require("@shopify/hydrogen");
852
878
  var import_react6 = __toESM(require("react"), 1);
853
- var RebuyWidgetContainerBase = ({ children, ...props }) => {
854
- const { apiKey, collection, collectionId, dataSource, limit, options, product, productId, variant, variantId } = props;
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;
855
894
  const contextParameters = (0, import_react6.useContext)(RebuyContext);
856
895
  const [Rebuy, setRebuy] = (0, import_react6.useState)(null);
857
896
  const [initialized, setInitialized] = (0, import_react6.useState)(false);
@@ -860,9 +899,10 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
860
899
  const shopifyCollectionId = collection?.id ?? collectionId ?? null;
861
900
  const [products, setProducts] = (0, import_react6.useState)([]);
862
901
  const [metadata, setMetadata] = (0, import_react6.useState)();
902
+ const REBUY_API_KEY = process.env.PUBLIC_REBUY_API_KEY;
863
903
  (0, import_react6.useEffect)(() => {
864
904
  if (!Rebuy) {
865
- const client = new import_rebuy2.RebuyClient(apiKey);
905
+ const client = new import_rebuy2.RebuyClient(REBUY_API_KEY);
866
906
  client.setContextParameters(
867
907
  contextParameters
868
908
  // TODO: fix this type when @rebuy/rebuy is moved to typescript
@@ -873,7 +913,7 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
873
913
  setRebuy(client);
874
914
  setInitialized(true);
875
915
  }
876
- }, [apiKey, Rebuy, contextParameters, options]);
916
+ }, [REBUY_API_KEY, Rebuy, contextParameters, options]);
877
917
  (0, import_react6.useEffect)(() => {
878
918
  if (!Rebuy) return;
879
919
  Rebuy.setContextParameters(
@@ -888,27 +928,48 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
888
928
  // Keeping this object generic to allow for custom endpoints
889
929
  };
890
930
  if (shopifyProductId) {
891
- request2.params.shopify_product_ids = Utilities4.getIdFromGraphUrl(shopifyProductId, "Product");
931
+ request2.params.shopify_product_ids = Utilities4.getIdFromGraphUrl(
932
+ shopifyProductId,
933
+ "Product"
934
+ );
892
935
  }
893
936
  if (shopifyProductId) {
894
- request2.params.shopify_product_ids = Utilities4.getIdFromGraphUrl(shopifyProductId, "Product");
937
+ request2.params.shopify_product_ids = Utilities4.getIdFromGraphUrl(
938
+ shopifyProductId,
939
+ "Product"
940
+ );
895
941
  }
896
942
  if (shopifyVariantId) {
897
- request2.params.shopify_variant_ids = Utilities4.getIdFromGraphUrl(shopifyVariantId, "ProductVariant");
943
+ request2.params.shopify_variant_ids = Utilities4.getIdFromGraphUrl(
944
+ shopifyVariantId,
945
+ "ProductVariant"
946
+ );
898
947
  }
899
948
  if (shopifyCollectionId) {
900
- request2.params.shopify_collection_ids = Utilities4.getIdFromGraphUrl(shopifyCollectionId, "Collection");
949
+ request2.params.shopify_collection_ids = Utilities4.getIdFromGraphUrl(
950
+ shopifyCollectionId,
951
+ "Collection"
952
+ );
901
953
  }
902
954
  if (limit) {
903
955
  request2.params.limit = limit;
904
956
  }
905
957
  return request2;
906
- }, [dataSource, shopifyProductId, shopifyVariantId, shopifyCollectionId, limit]);
958
+ }, [
959
+ dataSource,
960
+ shopifyProductId,
961
+ shopifyVariantId,
962
+ shopifyCollectionId,
963
+ limit
964
+ ]);
907
965
  (0, import_react6.useEffect)(() => {
908
966
  let isMounted = true;
909
967
  if (!Rebuy || !initialized) return;
910
968
  const fetchData = async () => {
911
- const { data, metadata: metadata2 } = await Rebuy.getStorefrontData(request.endpoint, request.params);
969
+ const { data, metadata: metadata2 } = await Rebuy.getStorefrontData(
970
+ request.endpoint,
971
+ request.params
972
+ );
912
973
  if (isMounted) {
913
974
  setProducts(
914
975
  Array.isArray(data) ? data.map((product2) => ({
@@ -941,11 +1002,24 @@ var RebuyWidgetContainerBase = ({ children, ...props }) => {
941
1002
  };
942
1003
  var RebuyWidgetContainer = RebuyWidgetContainerBase;
943
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
+
944
1012
  // src/components/ProductCard/ProductCard.tsx
945
1013
  var import_react7 = require("@remix-run/react");
946
1014
  var import_hydrogen4 = require("@shopify/hydrogen");
947
1015
  var import_react8 = require("react");
948
1016
 
1017
+ // src/components/ProductCard/ProductCard.module.css
1018
+ var ProductCard_default = {
1019
+ container: "ProductCard_container",
1020
+ productInfo: "ProductCard_productInfo"
1021
+ };
1022
+
949
1023
  // src/components/AddToCartBtn/HydrogenAddToCartBtn.tsx
950
1024
  var import_hydrogen2 = require("@shopify/hydrogen");
951
1025
 
@@ -1006,13 +1080,22 @@ var HydrogenReactAddToCartBtn = ({
1006
1080
  linesAdd(linesToAdd);
1007
1081
  addToCartCallback?.();
1008
1082
  };
1009
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("button", { className: AddToCartBtn_default.button, disabled, onClick: handleAddToCart, type: "button", children: [
1010
- addToCartBtnText,
1011
- moneyData && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1012
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: " | " }),
1013
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_hydrogen_react2.Money, { data: moneyData, withoutTrailingZeros: true })
1014
- ] })
1015
- ] });
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
+ );
1016
1099
  };
1017
1100
 
1018
1101
  // src/components/AddToCartBtn/AddToCartBtn.tsx
@@ -1069,12 +1152,24 @@ var ProductPrice_default = {
1069
1152
 
1070
1153
  // src/components/ProductPrice/ProductPrice.tsx
1071
1154
  var import_jsx_runtime6 = require("react/jsx-runtime");
1072
- var RebuyProductPrice = ({ selectedVariant }) => {
1155
+ var RebuyProductPrice = ({
1156
+ selectedVariant
1157
+ }) => {
1073
1158
  if (!selectedVariant) return null;
1074
1159
  const { compareAtPriceV2: compareAtPrice, priceV2: price } = selectedVariant;
1075
1160
  const isDiscounted = (price2, compareAtPrice2) => Number(compareAtPrice2?.amount) > Number(price2?.amount);
1076
- const CompareAtPrice = ({ data: compareAtPrice2 }) => {
1077
- return compareAtPrice2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_hydrogen3.Money, { as: "span", className: ProductPrice_default.compareAtPrice, data: compareAtPrice2, withoutTrailingZeros: true });
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
+ );
1078
1173
  };
1079
1174
  return price && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: ProductPrice_default.priceContainer, children: [
1080
1175
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_hydrogen3.Money, { data: price, withoutTrailingZeros: true }),
@@ -1109,12 +1204,17 @@ var VariantSelect_default = {
1109
1204
 
1110
1205
  // src/components/VariantSelect/VariantSelect.tsx
1111
1206
  var import_jsx_runtime8 = require("react/jsx-runtime");
1112
- var VariantSelect = ({ handleSelectedVariant, product }) => {
1207
+ var VariantSelect = ({
1208
+ handleSelectedVariant,
1209
+ product
1210
+ }) => {
1113
1211
  const getOptionsLabel = (product2) => {
1114
1212
  const options = product2.variants.nodes[0].selectedOptions;
1115
1213
  const optionsFromKeys = options ? Object.keys(options[0]) : [];
1116
1214
  const optionsFromValues = options ? options.map((option) => option.name) : [];
1117
- const useValues = optionsFromKeys.every((key) => ["name", "value"].includes(key));
1215
+ const useValues = optionsFromKeys.every(
1216
+ (key) => ["name", "value"].includes(key)
1217
+ );
1118
1218
  return (useValues ? optionsFromValues : optionsFromKeys).join(" / ");
1119
1219
  };
1120
1220
  return product?.variants.nodes.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
@@ -1128,12 +1228,6 @@ var VariantSelect = ({ handleSelectedVariant, product }) => {
1128
1228
  ) });
1129
1229
  };
1130
1230
 
1131
- // src/components/ProductCard/ProductCard.module.css
1132
- var ProductCard_default = {
1133
- container: "ProductCard_container",
1134
- productInfo: "ProductCard_productInfo"
1135
- };
1136
-
1137
1231
  // src/components/ProductCard/ProductCard.tsx
1138
1232
  var import_jsx_runtime9 = require("react/jsx-runtime");
1139
1233
  var ProductCard = ({
@@ -1143,10 +1237,14 @@ var ProductCard = ({
1143
1237
  product,
1144
1238
  productCardTitleLevel
1145
1239
  }) => {
1146
- const [selectedVariant, setSelectedVariant] = (0, import_react8.useState)(product.variants.nodes[0]);
1240
+ const [selectedVariant, setSelectedVariant] = (0, import_react8.useState)(
1241
+ product.variants.nodes[0]
1242
+ );
1147
1243
  const { image } = selectedVariant;
1148
1244
  const handleSelectedVariant = (product2, variant_id) => {
1149
- const updatedVariant = product2.variants.nodes.find((variant) => variant.id === variant_id);
1245
+ const updatedVariant = product2.variants.nodes.find(
1246
+ (variant) => variant.id === variant_id
1247
+ );
1150
1248
  if (updatedVariant) {
1151
1249
  setSelectedVariant(updatedVariant);
1152
1250
  }
@@ -1162,9 +1260,21 @@ var ProductCard = ({
1162
1260
  }
1163
1261
  ) }),
1164
1262
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: ProductCard_default.productInfo, children: [
1165
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react7.Link, { to: `/products/${product.handle}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Title, { level: productCardTitleLevel, text: product.title }) }),
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
+ ) }),
1166
1270
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RebuyProductPrice, { selectedVariant }),
1167
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(VariantSelect, { handleSelectedVariant, product })
1271
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1272
+ VariantSelect,
1273
+ {
1274
+ handleSelectedVariant,
1275
+ product
1276
+ }
1277
+ )
1168
1278
  ] })
1169
1279
  ] }),
1170
1280
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
@@ -1217,13 +1327,6 @@ var getTitleLevel = (level, decreaseLevel = false) => {
1217
1327
  }
1218
1328
  };
1219
1329
 
1220
- // src/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.module.css
1221
- var RebuyCompleteTheLook_default = {
1222
- container: "RebuyCompleteTheLook_container",
1223
- productGrid: "RebuyCompleteTheLook_productGrid",
1224
- productItem: "RebuyCompleteTheLook_productItem"
1225
- };
1226
-
1227
1330
  // src/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.tsx
1228
1331
  var import_jsx_runtime10 = require("react/jsx-runtime");
1229
1332
  var RebuyCompleteTheLook = (props) => {
@@ -1240,7 +1343,14 @@ var RebuyCompleteTheLook = (props) => {
1240
1343
  return null;
1241
1344
  }
1242
1345
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: RebuyCompleteTheLook_default.container, children: [
1243
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
1346
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1347
+ Title,
1348
+ {
1349
+ level: getTitleLevel(customTitleLevel),
1350
+ style: customTitleStyle,
1351
+ text: customTitle
1352
+ }
1353
+ ),
1244
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)(
1245
1355
  ProductCard,
1246
1356
  {
@@ -1248,7 +1358,10 @@ var RebuyCompleteTheLook = (props) => {
1248
1358
  addToCartCallback,
1249
1359
  isHydrogenReact: props.isHydrogenReact,
1250
1360
  product,
1251
- productCardTitleLevel: getTitleLevel(customTitleLevel, true)
1361
+ productCardTitleLevel: getTitleLevel(
1362
+ customTitleLevel,
1363
+ true
1364
+ )
1252
1365
  }
1253
1366
  ) }, product.id)) })
1254
1367
  ] });
@@ -1257,6 +1370,84 @@ var RebuyCompleteTheLook = (props) => {
1257
1370
  // src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.tsx
1258
1371
  var import_react11 = require("react");
1259
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
+
1260
1451
  // src/utils/convertToRebuyProduct.tsx
1261
1452
  var convertToRebuyProduct = (isHydrogenReact, product) => {
1262
1453
  const mainProductVariants = isHydrogenReact ? product?.variants?.nodes?.map((variant) => {
@@ -1316,7 +1507,9 @@ var convertToRebuyProduct = (isHydrogenReact, product) => {
1316
1507
  },
1317
1508
  handle: product?.handle || "",
1318
1509
  id: product?.id || "",
1319
- images: [{ altText: "", height: 100, id: "", url: "", width: 100 }],
1510
+ images: [
1511
+ { altText: "", height: 100, id: "", url: "", width: 100 }
1512
+ ],
1320
1513
  media: [],
1321
1514
  metafields: [],
1322
1515
  options: [],
@@ -1325,9 +1518,12 @@ var convertToRebuyProduct = (isHydrogenReact, product) => {
1325
1518
  minVariantPrice: { amount: "0", currencyCode: "USD" }
1326
1519
  },
1327
1520
  selected: true,
1328
- selectedOptions: product?.selectedVariant?.selectedOptions?.reduce((acc, option) => {
1329
- return { ...acc, [option.name]: option.value };
1330
- }, {}) || {},
1521
+ selectedOptions: product?.selectedVariant?.selectedOptions?.reduce(
1522
+ (acc, option) => {
1523
+ return { ...acc, [option.name]: option.value };
1524
+ },
1525
+ {}
1526
+ ) || {},
1331
1527
  selectedSellingPlan: {},
1332
1528
  selectedSellingPlanAllocation: {},
1333
1529
  selectedVariant: {
@@ -1404,9 +1600,12 @@ var convertToRebuyProduct = (isHydrogenReact, product) => {
1404
1600
  minVariantPrice: { amount: "0", currencyCode: "USD" }
1405
1601
  },
1406
1602
  selected: true,
1407
- selectedOptions: product?.selectedOrFirstAvailableVariant?.selectedOptions?.reduce((acc, option) => {
1408
- return { ...acc, [option.name]: option.value };
1409
- }, {}) || {},
1603
+ selectedOptions: product?.selectedOrFirstAvailableVariant?.selectedOptions?.reduce(
1604
+ (acc, option) => {
1605
+ return { ...acc, [option.name]: option.value };
1606
+ },
1607
+ {}
1608
+ ) || {},
1410
1609
  selectedSellingPlan: {},
1411
1610
  selectedSellingPlanAllocation: {},
1412
1611
  selectedVariant: {
@@ -1482,35 +1681,15 @@ var convertToRebuyProduct = (isHydrogenReact, product) => {
1482
1681
 
1483
1682
  // src/widgets/RebuyDynamicBundleProducts/BundleImages.tsx
1484
1683
  var import_react9 = require("@remix-run/react");
1485
- var import_hydrogen5 = require("@shopify/hydrogen");
1684
+ var import_hydrogen6 = require("@shopify/hydrogen");
1486
1685
  var import_react10 = require("react");
1487
-
1488
- // src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.module.css
1489
- var RebuyDynamicBundleProducts_default = {
1490
- container: "RebuyDynamicBundleProducts_container",
1491
- addCartBtnContainer: "RebuyDynamicBundleProducts_addCartBtnContainer",
1492
- bundleContainer: "RebuyDynamicBundleProducts_bundleContainer",
1493
- select: "RebuyDynamicBundleProducts_select",
1494
- bundleItemRowContainer: "RebuyDynamicBundleProducts_bundleItemRowContainer",
1495
- unselected: "RebuyDynamicBundleProducts_unselected",
1496
- bundleItemRow: "RebuyDynamicBundleProducts_bundleItemRow",
1497
- bundleItemInput: "RebuyDynamicBundleProducts_bundleItemInput",
1498
- bundleItemLabel: "RebuyDynamicBundleProducts_bundleItemLabel",
1499
- bundleImages: "RebuyDynamicBundleProducts_bundleImages",
1500
- bundleImage: "RebuyDynamicBundleProducts_bundleImage",
1501
- "fade-in": "RebuyDynamicBundleProducts_fade-in",
1502
- bundleImageDelimiter: "RebuyDynamicBundleProducts_bundleImageDelimiter",
1503
- compareAtPrice: "RebuyDynamicBundleProducts_compareAtPrice"
1504
- };
1505
-
1506
- // src/widgets/RebuyDynamicBundleProducts/BundleImages.tsx
1507
- var import_jsx_runtime11 = require("react/jsx-runtime");
1686
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1508
1687
  var BundleImages = ({ products }) => {
1509
1688
  const selected = products.filter((product) => product.selected);
1510
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("ul", { className: RebuyDynamicBundleProducts_default.bundleImages, children: products.map((product, index) => {
1689
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("ul", { className: RebuyDynamicBundleProducts_default.bundleImages, children: products.map((product, index) => {
1511
1690
  const image = product.selectedVariant?.image;
1512
- const productImage = image ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1513
- import_hydrogen5.Image,
1691
+ const productImage = image ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1692
+ import_hydrogen6.Image,
1514
1693
  {
1515
1694
  alt: image.altText || `Picture of ${product.title}`,
1516
1695
  className: RebuyDynamicBundleProducts_default.bundleImage,
@@ -1524,53 +1703,66 @@ var BundleImages = ({ products }) => {
1524
1703
  product.title
1525
1704
  );
1526
1705
  const showDelimiter = selected[0]?.id !== product.id;
1527
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react10.Fragment, { children: product.selected && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1528
- showDelimiter && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("li", { className: RebuyDynamicBundleProducts_default.bundleImageDelimiter, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: "+" }) }),
1529
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("li", { className: "flex items-center", children: product.default ? (
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 ? (
1530
1709
  // Already on product page
1531
1710
  productImage
1532
1711
  ) : (
1533
1712
  // Link to product
1534
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react9.Link, { title: product.title, to: `/products/${product.handle}`, children: productImage })
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
+ )
1535
1721
  ) })
1536
1722
  ] }) }, product.id + "-BundleImages-" + index);
1537
1723
  }) });
1538
1724
  };
1539
1725
 
1540
1726
  // src/widgets/RebuyDynamicBundleProducts/Select.tsx
1541
- var import_jsx_runtime12 = require("react/jsx-runtime");
1727
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1542
1728
  var Select = ({ onSelectVariant, product }) => {
1543
1729
  const getOptionsLabel = (product2) => {
1544
1730
  const options = product2.variants.nodes[0].selectedOptions;
1545
1731
  const optionsFromKeys = options ? Object.keys(options[0]) : [];
1546
1732
  const optionsFromValues = options ? options.map((option) => option.name) : [];
1547
- const useValues = optionsFromKeys.every((key) => ["name", "value"].includes(key));
1733
+ const useValues = optionsFromKeys.every(
1734
+ (key) => ["name", "value"].includes(key)
1735
+ );
1548
1736
  return (useValues ? optionsFromValues : optionsFromKeys).join(" / ");
1549
1737
  };
1550
- return product && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1738
+ return product && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1551
1739
  "select",
1552
1740
  {
1553
1741
  "aria-label": "select variant",
1554
1742
  className: RebuyDynamicBundleProducts_default.select,
1555
1743
  onChange: (e) => onSelectVariant(product, e.target.value),
1556
1744
  value: product.selectedVariant.id,
1557
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("optgroup", { label: getOptionsLabel(product), children: product.variants.nodes.map(({ id, title }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: id, children: title }, id + "-BundleVariant")) })
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")) })
1558
1746
  }
1559
1747
  );
1560
1748
  };
1561
1749
 
1562
1750
  // src/widgets/RebuyDynamicBundleProducts/BundleSelection.tsx
1563
- var import_jsx_runtime13 = require("react/jsx-runtime");
1564
- var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
1565
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("ul", { children: products.map((product, index) => {
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) => {
1566
1758
  const { availableForSale } = product.selectedVariant;
1567
1759
  const isOutOfStock = !availableForSale;
1568
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1760
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1569
1761
  "li",
1570
1762
  {
1571
1763
  className: `${RebuyDynamicBundleProducts_default.bundleItemRowContainer} ${!product.selected && RebuyDynamicBundleProducts_default.unselected}`,
1572
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleItemRow, children: [
1573
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1764
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleItemRow, children: [
1765
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1574
1766
  "input",
1575
1767
  {
1576
1768
  checked: product.selected && availableForSale,
@@ -1582,14 +1774,32 @@ var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
1582
1774
  value: product.id
1583
1775
  }
1584
1776
  ),
1585
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleItemInput, children: [
1586
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: RebuyDynamicBundleProducts_default.bundleItemLabel, htmlFor: `${product.id}-toggle`, children: [
1587
- isOutOfStock && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: "SOLD OUT" }),
1588
- product.default && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: "This item:" }),
1589
- product.title,
1590
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(RebuyProductPrice, { selectedVariant: product.selectedVariant })
1591
- ] }),
1592
- product.variants.nodes.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Select, { onSelectVariant, product })
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
+ )
1593
1803
  ] })
1594
1804
  ] })
1595
1805
  },
@@ -1598,54 +1808,6 @@ var BundleSelection = ({ onSelectVariant, onToggleBundleItem, products }) => {
1598
1808
  }) });
1599
1809
  };
1600
1810
 
1601
- // src/widgets/RebuyDynamicBundleProducts/BundlePrice.tsx
1602
- var import_hydrogen6 = require("@shopify/hydrogen");
1603
- var import_jsx_runtime14 = require("react/jsx-runtime");
1604
- var BundlePrice = ({ products }) => {
1605
- const isDisabled = products.filter((product) => product.selected).length < 1;
1606
- const totalBundlePrice = () => {
1607
- let total = 0;
1608
- let currencyCode = "USD";
1609
- for (const product of products) {
1610
- if (product.selected && product.selectedVariant) {
1611
- const { priceV2: price2 } = product.selectedVariant;
1612
- total += Number(price2?.amount);
1613
- currencyCode = price2?.currencyCode || "USD";
1614
- }
1615
- }
1616
- return {
1617
- amount: String(total),
1618
- currencyCode
1619
- };
1620
- };
1621
- const totalBundleCompareAtPrice = () => {
1622
- let compareAtTotal = 0;
1623
- let currencyCode = "USD";
1624
- for (const product of products) {
1625
- if (product.selected && product.selectedVariant) {
1626
- const { compareAtPriceV2: compareAtPrice2, priceV2: price2 } = product.selectedVariant;
1627
- currencyCode = price2?.currencyCode || "USD";
1628
- compareAtTotal += Number((compareAtPrice2 || price2)?.amount);
1629
- }
1630
- }
1631
- return {
1632
- amount: String(compareAtTotal),
1633
- currencyCode
1634
- };
1635
- };
1636
- const isDiscounted = (price2, compareAtPrice2) => Number(compareAtPrice2?.amount) > Number(price2?.amount);
1637
- const price = totalBundlePrice();
1638
- const compareAtPrice = totalBundleCompareAtPrice();
1639
- const CompareAtPrice = ({ data: compareAtPrice2 }) => {
1640
- return compareAtPrice2 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_hydrogen6.Money, { as: "span", className: RebuyDynamicBundleProducts_default.compareAtPrice, data: compareAtPrice2, withoutTrailingZeros: true });
1641
- };
1642
- return products.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex items-center flex-col", children: !isDisabled && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("p", { className: "flex items-center gap-2 mb-2", children: [
1643
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: "Total Price:" }),
1644
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_hydrogen6.Money, { as: "span", data: price, withoutTrailingZeros: true }),
1645
- isDiscounted(price, compareAtPrice) && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CompareAtPrice, { data: compareAtPrice })
1646
- ] }) });
1647
- };
1648
-
1649
1811
  // src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.tsx
1650
1812
  var import_jsx_runtime15 = require("react/jsx-runtime");
1651
1813
  var RebuyDynamicBundleProducts = (props) => {
@@ -1661,7 +1823,10 @@ var RebuyDynamicBundleProducts = (props) => {
1661
1823
  } = props;
1662
1824
  const [bundleProducts, setBundleProducts] = (0, import_react11.useState)([]);
1663
1825
  (0, import_react11.useEffect)(() => {
1664
- const mainProduct = convertToRebuyProduct(isHydrogenReact || false, product);
1826
+ const mainProduct = convertToRebuyProduct(
1827
+ isHydrogenReact || false,
1828
+ product
1829
+ );
1665
1830
  const formattedProducts = products.map((product2) => {
1666
1831
  return {
1667
1832
  ...product2,
@@ -1680,7 +1845,9 @@ var RebuyDynamicBundleProducts = (props) => {
1680
1845
  );
1681
1846
  const onSelectVariant = (0, import_react11.useCallback)(
1682
1847
  (product2, variant_id) => {
1683
- const variant = product2.variants.nodes.find(({ id }) => id === variant_id);
1848
+ const variant = product2.variants.nodes.find(
1849
+ ({ id }) => id === variant_id
1850
+ );
1684
1851
  if (variant) {
1685
1852
  product2.selectedVariant = variant;
1686
1853
  product2.selected = variant.availableForSale || false;
@@ -1694,7 +1861,14 @@ var RebuyDynamicBundleProducts = (props) => {
1694
1861
  return null;
1695
1862
  }
1696
1863
  return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("section", { className: RebuyDynamicBundleProducts_default.container, children: [
1697
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
1864
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1865
+ Title,
1866
+ {
1867
+ level: getTitleLevel(customTitleLevel),
1868
+ style: customTitleStyle,
1869
+ text: customTitle
1870
+ }
1871
+ ),
1698
1872
  /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: RebuyDynamicBundleProducts_default.bundleContainer, children: [
1699
1873
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(BundleImages, { products: bundleProducts }),
1700
1874
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(BundlePrice, { products: bundleProducts }),
@@ -1781,8 +1955,20 @@ var RebuyProductAddOnCard = ({
1781
1955
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: RebuyProductAddOns_default.addOnCardTextContent, children: [
1782
1956
  !availableForSale && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: RebuyProductAddOns_default.addOnCardOutOfStock, children: outOfStockText }),
1783
1957
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Title, { level: titleLevel, text: product.title }),
1784
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(RebuyProductPrice, { selectedVariant: product.selectedVariant }),
1785
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react12.Link, { className: RebuyProductAddOns_default.addOnCardLearnMore, to: `/products/${product.handle}`, children: learnMoreText })
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
+ )
1786
1972
  ] })
1787
1973
  ] }) });
1788
1974
  };
@@ -1833,7 +2019,10 @@ var RebuyProductAddOns = (props) => {
1833
2019
  });
1834
2020
  setAddedItems(products);
1835
2021
  if (includeMainProduct) {
1836
- setAddedItems([convertToRebuyProduct(isHydrogenReact || false, product), ...products]);
2022
+ setAddedItems([
2023
+ convertToRebuyProduct(isHydrogenReact || false, product),
2024
+ ...products
2025
+ ]);
1837
2026
  } else {
1838
2027
  setAddedItems(products);
1839
2028
  }
@@ -1841,7 +2030,9 @@ var RebuyProductAddOns = (props) => {
1841
2030
  const handleChange = (0, import_react13.useCallback)(
1842
2031
  (event, product2) => {
1843
2032
  const newProducts = [...products];
1844
- const productIndex = newProducts.findIndex((p) => p.id === product2.id);
2033
+ const productIndex = newProducts.findIndex(
2034
+ (p) => p.id === product2.id
2035
+ );
1845
2036
  if (productIndex !== -1) {
1846
2037
  newProducts[productIndex] = {
1847
2038
  ...newProducts[productIndex],
@@ -1851,7 +2042,9 @@ var RebuyProductAddOns = (props) => {
1851
2042
  if (event.target.checked) {
1852
2043
  setAddedItems((prev) => [...prev, product2]);
1853
2044
  } else {
1854
- setAddedItems((prev) => prev.filter((item) => item.id !== product2.id));
2045
+ setAddedItems(
2046
+ (prev) => prev.filter((item) => item.id !== product2.id)
2047
+ );
1855
2048
  }
1856
2049
  }
1857
2050
  },
@@ -1884,7 +2077,14 @@ var RebuyProductAddOns = (props) => {
1884
2077
  return null;
1885
2078
  }
1886
2079
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: RebuyProductAddOns_default.container, children: [
1887
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
2080
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2081
+ Title,
2082
+ {
2083
+ level: getTitleLevel(customTitleLevel),
2084
+ style: customTitleStyle,
2085
+ text: customTitle
2086
+ }
2087
+ ),
1888
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)(
1889
2089
  RebuyProductAddOnCard,
1890
2090
  {
@@ -1898,11 +2098,23 @@ var RebuyProductAddOns = (props) => {
1898
2098
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: RebuyProductAddOns_default.productAddOnsFooter, children: [
1899
2099
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: RebuyProductAddOns_default.moneyContainer, children: [
1900
2100
  subtotalText,
1901
- subtotalWithOutProduct && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_hydrogen_react3.Money, { data: subtotalWithOutProduct, withoutTrailingZeros: true })
2101
+ subtotalWithOutProduct && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2102
+ import_hydrogen_react3.Money,
2103
+ {
2104
+ data: subtotalWithOutProduct,
2105
+ withoutTrailingZeros: true
2106
+ }
2107
+ )
1902
2108
  ] }),
1903
2109
  includeMainProduct && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: RebuyProductAddOns_default.moneyContainer, children: [
1904
2110
  withProductText,
1905
- subtotalWithProduct && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_hydrogen_react3.Money, { data: subtotalWithProduct, withoutTrailingZeros: true })
2111
+ subtotalWithProduct && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2112
+ import_hydrogen_react3.Money,
2113
+ {
2114
+ data: subtotalWithProduct,
2115
+ withoutTrailingZeros: true
2116
+ }
2117
+ )
1906
2118
  ] }),
1907
2119
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: RebuyProductAddOns_default.addCartBtnContainer, children: includeMainProduct ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1908
2120
  AddToCartBtn,
@@ -1912,7 +2124,9 @@ var RebuyProductAddOns = (props) => {
1912
2124
  disabled: addedItems.length === 0,
1913
2125
  isHydrogenReact,
1914
2126
  moneyData: subtotalWithProduct,
1915
- selectedVariants: addedItems.map((item) => item.selectedVariant)
2127
+ selectedVariants: addedItems.map(
2128
+ (item) => item.selectedVariant
2129
+ )
1916
2130
  }
1917
2131
  ) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1918
2132
  AddToCartBtn,
@@ -1922,7 +2136,9 @@ var RebuyProductAddOns = (props) => {
1922
2136
  disabled: addedItems.length === 0,
1923
2137
  isHydrogenReact,
1924
2138
  moneyData: subtotalWithOutProduct,
1925
- selectedVariants: addedItems.map((item) => item.selectedVariant)
2139
+ selectedVariants: addedItems.map(
2140
+ (item) => item.selectedVariant
2141
+ )
1926
2142
  }
1927
2143
  ) })
1928
2144
  ] })
@@ -1951,7 +2167,14 @@ var RebuyProductRecommendations = (props) => {
1951
2167
  return null;
1952
2168
  }
1953
2169
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("section", { className: RebuyProductRecommendations_default.container, children: [
1954
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Title, { level: getTitleLevel(customTitleLevel), style: customTitleStyle, text: customTitle }),
2170
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2171
+ Title,
2172
+ {
2173
+ level: getTitleLevel(customTitleLevel),
2174
+ style: customTitleStyle,
2175
+ text: customTitle
2176
+ }
2177
+ ),
1955
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)(
1956
2179
  ProductCard,
1957
2180
  {
@@ -1959,7 +2182,10 @@ var RebuyProductRecommendations = (props) => {
1959
2182
  addToCartCallback,
1960
2183
  isHydrogenReact: props.isHydrogenReact,
1961
2184
  product,
1962
- productCardTitleLevel: getTitleLevel(customTitleLevel, true)
2185
+ productCardTitleLevel: getTitleLevel(
2186
+ customTitleLevel,
2187
+ true
2188
+ )
1963
2189
  }
1964
2190
  ) }, product.id)) })
1965
2191
  ] });