@azzas/azzas-tracker-web 2.0.1 → 2.0.2-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mod.js CHANGED
@@ -958,8 +958,8 @@ var documentToHash = async (document2) => {
958
958
  return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
959
959
  };
960
960
  var SIZE_ORDER = {
961
- alfabetico: ["PP", "P", "M", "G", "GG", "XG", "XGG", "EG", "EGG", "3G", "4G", "5G"],
962
- infantil: ["RN", "0-3M", "3-6M", "6-9M", "9-12M", "12-18M", "18-24M", "P", "M", "G", "GG"]
961
+ alfabetico: ["PP", "P", "M", "G", "GG", "GGG", "XG", "XGG", "EG", "EGG", "3G", "4G", "5G"],
962
+ infantil: ["RN", "0-3M", "3-6M", "6-9M", "9-12M", "12-18M", "18-24M", "P", "M", "G", "GG", "GGG"]
963
963
  };
964
964
  var detectSizeType = (sizes) => {
965
965
  if (sizes.every((s) => /^\d+([.,]\d+)?$/.test(s))) return "numerico";
@@ -1627,19 +1627,19 @@ var reservaAdapter = {
1627
1627
  return null;
1628
1628
  },
1629
1629
  available_grid: (context) => {
1630
+ var _a;
1630
1631
  if (context == null ? void 0 : context.available_grid) return context.available_grid;
1631
- if (context == null ? void 0 : context.products) {
1632
- const sizes = context.products.filter((product) => {
1633
- var _a, _b;
1634
- return (_b = (_a = product.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b.some((o) => o.availability === "https://schema.org/InStock");
1635
- }).map((product) => {
1636
- var _a;
1637
- return (_a = product.name) == null ? void 0 : _a.split(" - ")[1];
1638
- }).filter((name) => Boolean(name));
1639
- const result = sortSizes(sizes).join(",").trim();
1640
- return result || null;
1641
- }
1642
- return null;
1632
+ if (!((_a = context == null ? void 0 : context.products) == null ? void 0 : _a.length)) return null;
1633
+ const sizes = context.products.flatMap((p) => {
1634
+ var _a2, _b, _c, _d;
1635
+ const { productGroupID, skuVariants } = (_a2 = p == null ? void 0 : p.isVariantOf) != null ? _a2 : {};
1636
+ const currentColor = (_b = p == null ? void 0 : p.similarItems) == null ? void 0 : _b.find((i) => (i == null ? void 0 : i.productId) === productGroupID);
1637
+ const variantIDs = (_c = skuVariants == null ? void 0 : skuVariants.allVariantProducts) == null ? void 0 : _c.map((v) => v == null ? void 0 : v.productID);
1638
+ return ((_d = currentColor == null ? void 0 : currentColor.sizes) != null ? _d : []).flatMap(
1639
+ (entry) => (entry == null ? void 0 : entry.isAvailable) && (entry == null ? void 0 : entry.size) && (!(variantIDs == null ? void 0 : variantIDs.length) || variantIDs.includes(entry.skuId)) ? [entry.size] : []
1640
+ );
1641
+ });
1642
+ return sortSizes(sizes).join(",").trim() || null;
1643
1643
  }
1644
1644
  };
1645
1645