@azzas/azzas-tracker-web 2.0.0-preview.0 → 2.0.0-preview.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.
@@ -319,6 +319,18 @@ var AzzasTracker = (() => {
319
319
  hasEcommerce: false,
320
320
  destinations: ["DataLayer"],
321
321
  requiredParams: ["brand", "line_items", "size", "item_ref"]
322
+ },
323
+ REFINE_RESULTS: {
324
+ name: "refine_results",
325
+ hasEcommerce: false,
326
+ destinations: ["DataLayer"],
327
+ requiredParams: ["brand", "region", "color", "price_range", "size", "category", "ordering"]
328
+ },
329
+ GRID_SIZE: {
330
+ name: "grid_size",
331
+ hasEcommerce: false,
332
+ destinations: ["DataLayer"],
333
+ requiredParams: ["brand", "slot_per_line"]
322
334
  }
323
335
  };
324
336
 
@@ -1000,6 +1012,12 @@ var AzzasTracker = (() => {
1000
1012
  return unique;
1001
1013
  };
1002
1014
  var capitalize = (str) => str ? str[0].toUpperCase() + str.slice(1).toLowerCase() : "";
1015
+ var resizeVtexImage2 = (url, width = 500, height = 500) => {
1016
+ return url == null ? void 0 : url.replace(
1017
+ /(\/arquivos\/ids\/\d+)-\d+-\d+\//,
1018
+ `$1-${width}-${height}/`
1019
+ );
1020
+ };
1003
1021
 
1004
1022
  // src/params/legacy/resolvers/paymentType/fromOrderForm.ts
1005
1023
  function paymentTypeFromOrderForm(context) {
@@ -1135,7 +1153,7 @@ var AzzasTracker = (() => {
1135
1153
  }
1136
1154
 
1137
1155
  // src/params/legacy/index.ts
1138
- var paramGetters = {
1156
+ var legacyGetters = {
1139
1157
  brand: getBrand,
1140
1158
  items: getItems,
1141
1159
  payment_type: getPaymentType,
@@ -1343,8 +1361,7 @@ var AzzasTracker = (() => {
1343
1361
  return context.meta.brand || null;
1344
1362
  },
1345
1363
  content_type: (context) => {
1346
- if (context == null ? void 0 : context.content_type) return context.content_type;
1347
- return `regiao`.concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
1364
+ return context.meta.content_type || null;
1348
1365
  },
1349
1366
  region: (context) => {
1350
1367
  return context.meta.region || null;
@@ -1356,14 +1373,18 @@ var AzzasTracker = (() => {
1356
1373
  if (context == null ? void 0 : context.currency) return context.currency;
1357
1374
  return "BRL";
1358
1375
  },
1376
+ slot_per_line: (context) => {
1377
+ var _a;
1378
+ return (_a = context.meta.slot_per_line) != null ? _a : null;
1379
+ },
1359
1380
  search_term: (context) => {
1360
- return context.searchTerm || null;
1381
+ return context.meta.search_term || null;
1361
1382
  },
1362
1383
  search_found: (context) => {
1363
- return !!context.searchFound;
1384
+ return context.meta.search_found || null;
1364
1385
  },
1365
1386
  search_quantity: (context) => {
1366
- return context.searchQuantity || 0;
1387
+ return context.meta.search_quantity || 0;
1367
1388
  },
1368
1389
  promotion_name: (context) => {
1369
1390
  return context.meta.promotion_name || null;
@@ -1374,9 +1395,6 @@ var AzzasTracker = (() => {
1374
1395
  creative_slot: (context) => {
1375
1396
  return context.meta.creative_slot || null;
1376
1397
  },
1377
- zipcode: (context) => {
1378
- return context.zipCode || null;
1379
- },
1380
1398
  size: (context) => {
1381
1399
  return context.size || null;
1382
1400
  },
@@ -1388,139 +1406,22 @@ var AzzasTracker = (() => {
1388
1406
  },
1389
1407
  type: (context) => {
1390
1408
  return context.type || null;
1391
- }
1392
- };
1393
-
1394
- // src/params/adapters/orderForm/index.ts
1395
- var orderFormAdapters = {
1396
- // orderform
1397
- payment_type: getPaymentType,
1398
- total_discount: (context) => {
1399
- var _a, _b;
1400
- if (context == null ? void 0 : context.totalDiscount) return context.totalDiscount;
1401
- const totalsList = ((_a = context.orderForm) == null ? void 0 : _a.totalizers) || ((_b = context.orderForm) == null ? void 0 : _b.totals) || [];
1402
- const items = context.orderForm.items;
1403
- const totalDiscount = items.reduce((acc, item) => {
1404
- const unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
1405
- return acc + unitDiscount * item.quantity;
1406
- }, 0);
1407
- const discounts = totalsList.find((t) => t.id === "Discounts");
1408
- return Math.abs(((discounts == null ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
1409
1409
  },
1410
- subtotal: (context) => {
1411
- var _a, _b;
1412
- const totalsList = ((_a = context.orderForm) == null ? void 0 : _a.totalizers) || ((_b = context.orderForm) == null ? void 0 : _b.totals) || [];
1413
- const subtotal = totalsList.filter((t) => t.id === "Items").reduce((acc, t) => acc + (t.value || 0), 0) / 100 || 0;
1414
- return subtotal;
1410
+ color: (context) => {
1411
+ return context.meta.color || null;
1415
1412
  },
1416
- coupon_message: (context) => {
1417
- var _a;
1418
- if (context.couponMessage) return context.couponMessage;
1419
- const messages = ((_a = context.orderForm) == null ? void 0 : _a.messages) || [];
1420
- if (messages.length === 0) return null;
1421
- const couponMessages = messages.filter(
1422
- (msg) => msg.text.toLowerCase().includes("cupom")
1423
- );
1424
- if (couponMessages.length === 0) return null;
1425
- return couponMessages.map((msg) => msg.text).join(" | ");
1413
+ price_range: (context) => {
1414
+ return context.meta.price_range || null;
1426
1415
  },
1427
- flag_pickup: (context) => {
1428
- var _a;
1429
- const orderForm = context.orderForm;
1430
- if (!orderForm) return null;
1431
- const logisticsInfo = ((_a = orderForm.shippingData) == null ? void 0 : _a.logisticsInfo) || [];
1432
- const hasPickup = logisticsInfo.some(
1433
- (info) => {
1434
- var _a2;
1435
- return (_a2 = info.slas) == null ? void 0 : _a2.some((sla) => sla.deliveryChannel === "pickup-in-point");
1436
- }
1437
- );
1438
- return hasPickup;
1416
+ category: (context) => {
1417
+ return context.meta.category || null;
1439
1418
  },
1440
- shippings: (context) => {
1441
- const orderForm = context.orderForm;
1442
- if (!orderForm) return null;
1443
- const groupShipping = {};
1444
- for (const info of orderForm.shippingData.logisticsInfo) {
1445
- const item = orderForm.items[info.itemIndex];
1446
- if (!item) continue;
1447
- for (const sla of info.slas) {
1448
- const key = sla.name;
1449
- if (!groupShipping[key]) {
1450
- groupShipping[key] = {
1451
- shipping_tier: sla.name,
1452
- delivery_time: parseInt(sla.shippingEstimate),
1453
- shipping: parseFloat((sla.price / 100).toFixed(1)),
1454
- line_items: []
1455
- };
1456
- }
1457
- groupShipping[key].line_items.push(item.id);
1458
- }
1459
- }
1460
- const shippings = Object.values(groupShipping).map((s) => ({
1461
- shipping: s.shipping,
1462
- shipping_tier: s.shipping_tier,
1463
- delivery_time: s.delivery_time,
1464
- line_items: s.line_items.join(",")
1465
- }));
1466
- return shippings || null;
1467
- },
1468
- shipping: (context) => {
1469
- var _a, _b, _c;
1470
- const logistics = (_c = (_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.shippingData) == null ? void 0 : _b.logisticsInfo) != null ? _c : [];
1471
- return logistics.reduce((total, item) => {
1472
- var _a2, _b2;
1473
- const selected = (_a2 = item.slas) == null ? void 0 : _a2.find((sla) => sla.id === item.selectedSla);
1474
- return total + ((_b2 = selected == null ? void 0 : selected.price) != null ? _b2 : 0);
1475
- }, 0);
1476
- },
1477
- shipping_tier: (context) => {
1478
- var _a, _b, _c;
1479
- const logistics = (_c = (_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.shippingData) == null ? void 0 : _b.logisticsInfo) != null ? _c : [];
1480
- const selectedSlas = logistics.map((item) => {
1481
- var _a2;
1482
- if (!item.selectedSla) return null;
1483
- return ((_a2 = item.slas) == null ? void 0 : _a2.find((sla) => sla.id === item.selectedSla)) || null;
1484
- }).filter(Boolean);
1485
- if (selectedSlas.length === 0) return null;
1486
- const uniqueTiers = Array.from(
1487
- new Map(
1488
- selectedSlas.map((sla) => {
1489
- var _a2;
1490
- const key = sla.deliveryChannel === "pickup-in-point" ? `pickup:${((_a2 = sla.pickupStoreInfo) == null ? void 0 : _a2.friendlyName) || sla.name || ""}` : `delivery:${sla.name || ""}`;
1491
- return [key, sla];
1492
- })
1493
- ).values()
1494
- );
1495
- const sortedTiers = uniqueTiers.sort((a, b) => {
1496
- var _a2, _b2;
1497
- const aOrder = a.deliveryChannel === "pickup-in-point" ? 0 : 1;
1498
- const bOrder = b.deliveryChannel === "pickup-in-point" ? 0 : 1;
1499
- if (aOrder !== bOrder) return aOrder - bOrder;
1500
- const aLabel = a.deliveryChannel === "pickup-in-point" ? ((_a2 = a.pickupStoreInfo) == null ? void 0 : _a2.friendlyName) || a.name || "" : a.name || "";
1501
- const bLabel = b.deliveryChannel === "pickup-in-point" ? ((_b2 = b.pickupStoreInfo) == null ? void 0 : _b2.friendlyName) || b.name || "" : b.name || "";
1502
- return aLabel.localeCompare(bLabel, "pt-BR");
1503
- });
1504
- const shippingTier = sortedTiers.map((sla) => {
1505
- var _a2;
1506
- return sla.deliveryChannel === "pickup-in-point" ? `retirada em loja${((_a2 = sla.pickupStoreInfo) == null ? void 0 : _a2.friendlyName) ? `: ${sla.pickupStoreInfo.friendlyName}` : ""}` : sla.deliveryChannel === "delivery" ? `receba em casa${sla.name ? `: ${sla.name}` : ""}` : null;
1507
- }).filter(Boolean).join(", ");
1508
- return shippingTier || null;
1509
- },
1510
- transaction_id: (context) => {
1511
- var _a, _b;
1512
- return ((_b = (_a = context.orderForm) == null ? void 0 : _a.orderGroup) == null ? void 0 : _b.toString()) || null;
1513
- },
1514
- coupon: (context) => {
1515
- var _a, _b;
1516
- return context.appliedCoupon || ((_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.marketingData) == null ? void 0 : _b.coupon) || null;
1517
- },
1518
- seller_cod_name: (context) => {
1519
- return context.appliedSellerCodName || (context == null ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
1419
+ ordering: (context) => {
1420
+ return context.meta.ordering || null;
1520
1421
  }
1521
1422
  };
1522
1423
 
1523
- // src/params/adapters/deco/utils/index.ts
1424
+ // src/params/adapters/deco/utils.ts
1524
1425
  var getItemCategory3 = (item) => {
1525
1426
  var _a;
1526
1427
  const value = item == null ? void 0 : item.category;
@@ -1538,12 +1439,6 @@ var AzzasTracker = (() => {
1538
1439
  const deepest = (_d = validHierarchy[validHierarchy.length - 1]) != null ? _d : "";
1539
1440
  return capitalize(deepest);
1540
1441
  };
1541
- var resizeVtexImage2 = (url, width = 500, height = 500) => {
1542
- return url == null ? void 0 : url.replace(
1543
- /(\/arquivos\/ids\/\d+)-\d+-\d+\//,
1544
- `$1-${width}-${height}/`
1545
- );
1546
- };
1547
1442
  function getItemShippingTier2() {
1548
1443
  return null;
1549
1444
  }
@@ -1554,13 +1449,11 @@ var AzzasTracker = (() => {
1554
1449
  var decoAdapter = {
1555
1450
  ...metaAdapters,
1556
1451
  // global adapters
1557
- ...orderFormAdapters,
1558
- // orderform adapters
1559
1452
  items: (context) => {
1560
1453
  if (context == null ? void 0 : context.items) return context.items;
1561
1454
  if (context == null ? void 0 : context.products) {
1562
1455
  return context.products.map((item) => {
1563
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D;
1456
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E;
1564
1457
  const COLOR_REGEX = /^[^_]+_/;
1565
1458
  const listPrice = (_c = (_b = (_a = item == null ? void 0 : item.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b[0].priceSpecification.find(
1566
1459
  (s) => s.priceType === LIST_PRICE_SCHEMA
@@ -1571,21 +1464,21 @@ var AzzasTracker = (() => {
1571
1464
  item_brand: (_g = (_f = (_e = item.brand) == null ? void 0 : _e.name) == null ? void 0 : _f.toLowerCase()) != null ? _g : null,
1572
1465
  item_name: (_h = item.alternateName) != null ? _h : null,
1573
1466
  price: (_j = (_i = item.offers) == null ? void 0 : _i.lowPrice) != null ? _j : null,
1574
- discount: Number(listPrice) - Number((_k = item == null ? void 0 : item.offers) == null ? void 0 : _k.lowPrice),
1467
+ discount: Math.round((Number(listPrice) - Number((_k = item == null ? void 0 : item.offers) == null ? void 0 : _k.lowPrice)) * 100) / 100,
1575
1468
  item_variant: ((_m = (_l = item == null ? void 0 : item.name) == null ? void 0 : _l.split(" - ")[0]) == null ? void 0 : _m.replace(COLOR_REGEX, "").replace(/_/g, " ")) || null,
1576
1469
  // cor
1577
1470
  item_variant2: (_o = (_n = item == null ? void 0 : item.name) == null ? void 0 : _n.split(" - ")[1]) != null ? _o : null,
1578
1471
  // tamanho
1579
1472
  item_shipping_tier: getItemShippingTier2(),
1580
- item_ref: (_r = (_q = (_p = item.additionalProperty) == null ? void 0 : _p.find(((i) => i.name === "RefId"))) == null ? void 0 : _q.value) != null ? _r : null,
1581
- item_category: (_s = getItemCategory3(item)) != null ? _s : null,
1582
- item_category2: (_t = getItemCategory22(item)) != null ? _t : null,
1583
- item_id: (_u = item == null ? void 0 : item.inProductGroupWithID) != null ? _u : null,
1584
- item_sku: (_v = item.sku) != null ? _v : null,
1585
- item_url: (_w = item.url) != null ? _w : null,
1586
- image_url: (_y = resizeVtexImage2((_x = item == null ? void 0 : item.image) == null ? void 0 : _x[0].url)) != null ? _y : null,
1587
- seller_id: (_C = (_B = (_A = (_z = item.offers) == null ? void 0 : _z.offers) == null ? void 0 : _A[0]) == null ? void 0 : _B.seller) != null ? _C : null,
1588
- item_list_name: (_D = item == null ? void 0 : item.item_list_name) != null ? _D : null
1473
+ item_ref: (_s = (_r = (_q = (_p = item.additionalProperty) == null ? void 0 : _p.find((i) => i.name === "RefId")) == null ? void 0 : _q.value) == null ? void 0 : _r.replace(/_\d+$/, "")) != null ? _s : null,
1474
+ item_category: (_t = getItemCategory3(item)) != null ? _t : null,
1475
+ item_category2: (_u = getItemCategory22(item)) != null ? _u : null,
1476
+ item_id: (_v = item == null ? void 0 : item.inProductGroupWithID) != null ? _v : null,
1477
+ item_sku: (_w = item.sku) != null ? _w : null,
1478
+ item_url: (_x = item.url) != null ? _x : null,
1479
+ image_url: (_z = resizeVtexImage2((_y = item == null ? void 0 : item.image) == null ? void 0 : _y[0].url)) != null ? _z : null,
1480
+ seller_id: (_D = (_C = (_B = (_A = item.offers) == null ? void 0 : _A.offers) == null ? void 0 : _B[0]) == null ? void 0 : _C.seller) != null ? _D : null,
1481
+ item_list_name: (_E = item == null ? void 0 : item.item_list_name) != null ? _E : null
1589
1482
  };
1590
1483
  });
1591
1484
  }
@@ -1639,8 +1532,202 @@ var AzzasTracker = (() => {
1639
1532
  }
1640
1533
  };
1641
1534
 
1642
- // src/params/adapters/headless/utils/index.ts
1535
+ // src/params/adapters/orderForm/utils.ts
1643
1536
  var getItemCategory5 = (item) => {
1537
+ var _a;
1538
+ const categories = item == null ? void 0 : item.productCategories;
1539
+ if (!categories) return "Cole\xE7\xE3o";
1540
+ const text = Object.values(categories).join(" ");
1541
+ const match = (_a = text.match(/outlet|bazar|sale/i)) == null ? void 0 : _a[0].toLowerCase();
1542
+ return match != null ? match : "Cole\xE7\xE3o";
1543
+ };
1544
+ var getItemCategory23 = (item) => {
1545
+ var _a, _b;
1546
+ const AVOID_CATEGORIES = /outlet|bazar|sale/i;
1547
+ const categories = Object.values((_a = item == null ? void 0 : item.productCategories) != null ? _a : {});
1548
+ const validHierarchy = categories.map((c) => c.trim()).filter((c) => c && !AVOID_CATEGORIES.test(c));
1549
+ const deepest = (_b = validHierarchy[validHierarchy.length - 1]) != null ? _b : "";
1550
+ return capitalize(deepest);
1551
+ };
1552
+ var getOrderFormItems = (orderForm) => {
1553
+ const idSelected = orderForm == null ? void 0 : orderForm.selected;
1554
+ return idSelected ? orderForm.items.filter((item) => item.id === idSelected) : orderForm.items;
1555
+ };
1556
+
1557
+ // src/params/adapters/orderForm/index.ts
1558
+ var orderFormAdapter = {
1559
+ ...metaAdapters,
1560
+ items: (context) => {
1561
+ if (context == null ? void 0 : context.items) return context.items;
1562
+ if ((context == null ? void 0 : context.orderForm) && (context == null ? void 0 : context.orderForm.items)) {
1563
+ return getOrderFormItems(context.orderForm).map((item, index) => {
1564
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
1565
+ return {
1566
+ quantity: (_a = item == null ? void 0 : item.quantity) != null ? _a : 1,
1567
+ index: (_d = (_c = (_b = context == null ? void 0 : context.orderForm) == null ? void 0 : _b.index) != null ? _c : index) != null ? _d : null,
1568
+ item_brand: (_f = (_e = item.additionalInfo) == null ? void 0 : _e.brandName) != null ? _f : null,
1569
+ item_name: (_g = item == null ? void 0 : item.name.replace(item == null ? void 0 : item.skuName, "").trim()) != null ? _g : null,
1570
+ price: (item == null ? void 0 : item.price) / 100,
1571
+ discount: ((item == null ? void 0 : item.listPrice) - (item == null ? void 0 : item.sellingPrice)) / 100,
1572
+ item_variant: (_k = (_j = (_i = (_h = item == null ? void 0 : item.skuName) == null ? void 0 : _h.split(" - ")[0]) == null ? void 0 : _i.split("_").pop()) == null ? void 0 : _j.trim()) != null ? _k : null,
1573
+ item_variant2: (_n = (_m = (_l = item == null ? void 0 : item.skuName) == null ? void 0 : _l.split(" - ")[1]) == null ? void 0 : _m.trim()) != null ? _n : null,
1574
+ item_shipping_tier: "",
1575
+ item_ref: (item == null ? void 0 : item.productRefId) || (item == null ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
1576
+ item_category: (_o = getItemCategory5(item)) != null ? _o : null,
1577
+ item_category2: (_p = getItemCategory23(item)) != null ? _p : null,
1578
+ item_id: (_q = item == null ? void 0 : item.productId) != null ? _q : null,
1579
+ item_sku: (_r = item == null ? void 0 : item.id) != null ? _r : null,
1580
+ item_url: (_s = item.detailUrl) != null ? _s : null,
1581
+ image_url: (_t = resizeVtexImage2(item.imageUrl)) != null ? _t : null,
1582
+ seller_id: (_u = item == null ? void 0 : item.seller) != null ? _u : null,
1583
+ item_list_name: (_w = (_v = context == null ? void 0 : context.orderForm) == null ? void 0 : _v.item_list_name) != null ? _w : null
1584
+ };
1585
+ });
1586
+ }
1587
+ return null;
1588
+ },
1589
+ // brand: (context: any) => {
1590
+ // if (context?.brand) return context.brand
1591
+ // if (context?.products) {
1592
+ // return context.products[0].brand?.name // tem que ajustar FARM por conta de FARM_ETC
1593
+ // }
1594
+ // return null
1595
+ // },
1596
+ line_items: (context) => {
1597
+ var _a;
1598
+ if (context == null ? void 0 : context.line_items) return context.line_items;
1599
+ if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
1600
+ return getOrderFormItems(context.orderForm).map((item) => item == null ? void 0 : item.productId).filter((id) => Boolean(id));
1601
+ },
1602
+ value: (context) => {
1603
+ var _a;
1604
+ if (context == null ? void 0 : context.value) return context.value;
1605
+ if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
1606
+ return getOrderFormItems(context.orderForm).map((item) => (item == null ? void 0 : item.price) / 100 * item.quantity).filter((price) => price !== void 0).reduce((sum, price) => sum + price, 0);
1607
+ },
1608
+ payment_type: getPaymentType,
1609
+ total_discount: (context) => {
1610
+ var _a, _b;
1611
+ if (context == null ? void 0 : context.totalDiscount) return context.totalDiscount;
1612
+ const totalsList = ((_a = context.orderForm) == null ? void 0 : _a.totalizers) || ((_b = context.orderForm) == null ? void 0 : _b.totals) || [];
1613
+ const items = context.orderForm.items;
1614
+ const totalDiscount = items.reduce((acc, item) => {
1615
+ const unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
1616
+ return acc + unitDiscount * item.quantity;
1617
+ }, 0);
1618
+ const discounts = totalsList.find((t) => t.id === "Discounts");
1619
+ return Math.abs(((discounts == null ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
1620
+ },
1621
+ subtotal: (context) => {
1622
+ var _a, _b;
1623
+ const totalsList = ((_a = context.orderForm) == null ? void 0 : _a.totalizers) || ((_b = context.orderForm) == null ? void 0 : _b.totals) || [];
1624
+ const subtotal = totalsList.filter((t) => t.id === "Items").reduce((acc, t) => acc + (t.value || 0), 0) / 100 || 0;
1625
+ return subtotal;
1626
+ },
1627
+ coupon_message: (context) => {
1628
+ var _a;
1629
+ if (context.couponMessage) return context.couponMessage;
1630
+ const messages = ((_a = context.orderForm) == null ? void 0 : _a.messages) || [];
1631
+ if (messages.length === 0) return null;
1632
+ const couponMessages = messages.filter(
1633
+ (msg) => msg.text.toLowerCase().includes("cupom")
1634
+ );
1635
+ if (couponMessages.length === 0) return null;
1636
+ return couponMessages.map((msg) => msg.text).join(" | ");
1637
+ },
1638
+ zipcode: (context) => {
1639
+ var _a;
1640
+ return (_a = context.zipcode) != null ? _a : null;
1641
+ },
1642
+ flag_pickup: (context) => {
1643
+ var _a;
1644
+ const orderForm = context.orderForm;
1645
+ if (!orderForm) return null;
1646
+ const logisticsInfo = ((_a = orderForm.shippingData) == null ? void 0 : _a.logisticsInfo) || [];
1647
+ const hasPickup = logisticsInfo.some(
1648
+ (info) => {
1649
+ var _a2;
1650
+ return (_a2 = info.slas) == null ? void 0 : _a2.some((sla) => sla.deliveryChannel === "pickup-in-point");
1651
+ }
1652
+ );
1653
+ return hasPickup;
1654
+ },
1655
+ shippings: (context) => {
1656
+ if (!context.orderForm) return null;
1657
+ const { items, shippingData } = context.orderForm;
1658
+ const acc = {};
1659
+ shippingData.logisticsInfo.forEach(({ itemIndex, slas }) => {
1660
+ const item = items[itemIndex];
1661
+ if (!item) return;
1662
+ slas.forEach((sla) => {
1663
+ if (!acc[sla.name]) acc[sla.name] = {
1664
+ shipping_tier: sla.name,
1665
+ delivery_time: parseInt(sla.shippingEstimate),
1666
+ shipping: parseFloat((sla.price / 100).toFixed(1)),
1667
+ line_items: []
1668
+ };
1669
+ acc[sla.name].line_items.push(item.id);
1670
+ });
1671
+ });
1672
+ return Object.values(acc).map((s) => ({ ...s, line_items: s.line_items.join(",") }));
1673
+ },
1674
+ shipping: (context) => {
1675
+ var _a, _b, _c;
1676
+ const logistics = (_c = (_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.shippingData) == null ? void 0 : _b.logisticsInfo) != null ? _c : [];
1677
+ return logistics.reduce((total, item) => {
1678
+ var _a2, _b2;
1679
+ const selected = (_a2 = item.slas) == null ? void 0 : _a2.find((sla) => sla.id === item.selectedSla);
1680
+ return total + ((_b2 = selected == null ? void 0 : selected.price) != null ? _b2 : 0);
1681
+ }, 0);
1682
+ },
1683
+ shipping_tier: (context) => {
1684
+ var _a, _b, _c;
1685
+ const logistics = (_c = (_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.shippingData) == null ? void 0 : _b.logisticsInfo) != null ? _c : [];
1686
+ const selectedSlas = logistics.map((item) => {
1687
+ var _a2;
1688
+ if (!item.selectedSla) return null;
1689
+ return ((_a2 = item.slas) == null ? void 0 : _a2.find((sla) => sla.id === item.selectedSla)) || null;
1690
+ }).filter(Boolean);
1691
+ if (selectedSlas.length === 0) return null;
1692
+ const uniqueTiers = Array.from(
1693
+ new Map(
1694
+ selectedSlas.map((sla) => {
1695
+ var _a2;
1696
+ const key = sla.deliveryChannel === "pickup-in-point" ? `pickup:${((_a2 = sla.pickupStoreInfo) == null ? void 0 : _a2.friendlyName) || sla.name || ""}` : `delivery:${sla.name || ""}`;
1697
+ return [key, sla];
1698
+ })
1699
+ ).values()
1700
+ );
1701
+ const sortedTiers = uniqueTiers.sort((a, b) => {
1702
+ var _a2, _b2;
1703
+ const aOrder = a.deliveryChannel === "pickup-in-point" ? 0 : 1;
1704
+ const bOrder = b.deliveryChannel === "pickup-in-point" ? 0 : 1;
1705
+ if (aOrder !== bOrder) return aOrder - bOrder;
1706
+ const aLabel = a.deliveryChannel === "pickup-in-point" ? ((_a2 = a.pickupStoreInfo) == null ? void 0 : _a2.friendlyName) || a.name || "" : a.name || "";
1707
+ const bLabel = b.deliveryChannel === "pickup-in-point" ? ((_b2 = b.pickupStoreInfo) == null ? void 0 : _b2.friendlyName) || b.name || "" : b.name || "";
1708
+ return aLabel.localeCompare(bLabel, "pt-BR");
1709
+ });
1710
+ const shippingTier = sortedTiers.map((sla) => {
1711
+ var _a2;
1712
+ return sla.deliveryChannel === "pickup-in-point" ? `retirada em loja${((_a2 = sla.pickupStoreInfo) == null ? void 0 : _a2.friendlyName) ? `: ${sla.pickupStoreInfo.friendlyName}` : ""}` : sla.deliveryChannel === "delivery" ? `receba em casa${sla.name ? `: ${sla.name}` : ""}` : null;
1713
+ }).filter(Boolean).join(", ");
1714
+ return shippingTier || null;
1715
+ },
1716
+ transaction_id: (context) => {
1717
+ var _a, _b;
1718
+ return ((_b = (_a = context.orderForm) == null ? void 0 : _a.orderGroup) == null ? void 0 : _b.toString()) || null;
1719
+ },
1720
+ coupon: (context) => {
1721
+ var _a, _b;
1722
+ return context.appliedCoupon || ((_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.marketingData) == null ? void 0 : _b.coupon) || null;
1723
+ },
1724
+ seller_cod_name: (context) => {
1725
+ return context.appliedSellerCodName || (context == null ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
1726
+ }
1727
+ };
1728
+
1729
+ // src/params/adapters/headless/utils.ts
1730
+ var getItemCategory6 = (item) => {
1644
1731
  const keywords = ["outlet", "bazar", "sale"];
1645
1732
  const regex = new RegExp(keywords.join("|"), "i");
1646
1733
  const value = item == null ? void 0 : item.categories;
@@ -1653,7 +1740,7 @@ var AzzasTracker = (() => {
1653
1740
  }
1654
1741
  return "Cole\xE7\xE3o";
1655
1742
  };
1656
- var getItemCategory23 = (item) => {
1743
+ var getItemCategory24 = (item) => {
1657
1744
  var _a, _b, _c;
1658
1745
  const avoidList = /outlet|bazar|sale/i;
1659
1746
  const lastCategory = (_b = (_a = item.categories) == null ? void 0 : _a[item.categories.length - 1]) != null ? _b : "";
@@ -1661,12 +1748,6 @@ var AzzasTracker = (() => {
1661
1748
  const deepestCategory = (_c = [...categoryHierarchy].reverse().find((c) => !avoidList.test(c))) != null ? _c : "";
1662
1749
  return deepestCategory && deepestCategory[0].toUpperCase() + deepestCategory.slice(1).toLowerCase();
1663
1750
  };
1664
- function resizeVtexImage3(url, width = 500, height = 500) {
1665
- return url == null ? void 0 : url.replace(
1666
- /(\/arquivos\/ids\/\d+)-\d+-\d+\//,
1667
- `$1-${width}-${height}/`
1668
- );
1669
- }
1670
1751
 
1671
1752
  // src/params/adapters/headless/zones/PDP.ts
1672
1753
  var HeadlessPdpZone = {
@@ -1683,18 +1764,19 @@ var AzzasTracker = (() => {
1683
1764
  item_brand: (_d = item.brand) != null ? _d : null,
1684
1765
  item_name: (_e = item.productName) != null ? _e : null,
1685
1766
  price: price != null ? price : null,
1767
+ item_shipping_tier: null,
1686
1768
  discount: Number(listPrice) - Number(price),
1687
1769
  item_variant: (_h = (_g = (_f = item.items[0]) == null ? void 0 : _f.name) == null ? void 0 : _g.split(" - ")[0]) != null ? _h : null,
1688
1770
  item_variant2: (_k = (_j = (_i = item.items[0]) == null ? void 0 : _i.name) == null ? void 0 : _j.split(" - ")[1]) != null ? _k : null,
1689
1771
  item_ref: (_l = item.productReference) != null ? _l : null,
1690
1772
  // sem ref no retorno do IS na multi-lib produtos PDC
1691
- item_category: getItemCategory5(item),
1692
- item_category2: (_m = getItemCategory23(item)) != null ? _m : null,
1773
+ item_category: getItemCategory6(item),
1774
+ item_category2: (_m = getItemCategory24(item)) != null ? _m : null,
1693
1775
  item_id: (_n = item == null ? void 0 : item.productId) != null ? _n : null,
1694
1776
  item_sku: (_p = (_o = item.items) == null ? void 0 : _o[0].itemId) != null ? _p : null,
1695
1777
  item_url: (_q = item.link) != null ? _q : null,
1696
1778
  // sem link/url no retorno do IS na multi-lib produtos PDC
1697
- image_url: (_t = resizeVtexImage3((_s = (_r = item == null ? void 0 : item.items) == null ? void 0 : _r[0].images) == null ? void 0 : _s[0].imageUrl)) != null ? _t : null,
1779
+ image_url: (_t = resizeVtexImage2((_s = (_r = item == null ? void 0 : item.items) == null ? void 0 : _r[0].images) == null ? void 0 : _s[0].imageUrl)) != null ? _t : null,
1698
1780
  seller_id: (_x = (_w = (_v = (_u = item.items) == null ? void 0 : _u[0]) == null ? void 0 : _v.sellers) == null ? void 0 : _w[0].sellerId) != null ? _x : null,
1699
1781
  item_list_name: (_y = item.item_list_name) != null ? _y : null
1700
1782
  };
@@ -1743,18 +1825,19 @@ var AzzasTracker = (() => {
1743
1825
  item_brand: (_b = item.brand.name) != null ? _b : null,
1744
1826
  item_name: (_c = item.name) != null ? _c : null,
1745
1827
  price: price != null ? price : null,
1828
+ item_shipping_tier: null,
1746
1829
  discount: Number(listPrice) - Number(price),
1747
1830
  item_variant: (_f = (_e = (_d = item.isVariantOf) == null ? void 0 : _d.hasVariant) == null ? void 0 : _e[0].name.split(" - ")[0]) != null ? _f : null,
1748
1831
  item_variant2: (_i = (_h = ((_g = item.additionalProperty) != null ? _g : []).find((p) => p.name === "Tamanho")) == null ? void 0 : _h.value) != null ? _i : null,
1749
1832
  item_ref: null,
1750
1833
  // sem ref no retorno do IS na multi-lib produtos PDC
1751
- item_category: getItemCategory5(item),
1752
- item_category2: (_j = getItemCategory23(item)) != null ? _j : null,
1834
+ item_category: getItemCategory6(item),
1835
+ item_category2: (_j = getItemCategory24(item)) != null ? _j : null,
1753
1836
  item_id: (_k = item.isVariantOf.productGroupID) != null ? _k : null,
1754
1837
  item_sku: (_l = item.sku) != null ? _l : null,
1755
1838
  item_url: null,
1756
1839
  // sem link/url no retorno do IS na multi-lib produtos PDC
1757
- image_url: (_n = resizeVtexImage3((_m = item == null ? void 0 : item.image) == null ? void 0 : _m[0].url)) != null ? _n : null,
1840
+ image_url: (_n = resizeVtexImage2((_m = item == null ? void 0 : item.image) == null ? void 0 : _m[0].url)) != null ? _n : null,
1758
1841
  seller_id: (_s = (_r = (_q = (_p = (_o = item.offers) == null ? void 0 : _o.offers) == null ? void 0 : _p.find((o) => o.availability)) == null ? void 0 : _q.seller) == null ? void 0 : _r.identifier) != null ? _s : null,
1759
1842
  item_list_name: (_t = item.item_list_name) != null ? _t : null
1760
1843
  };
@@ -1789,7 +1872,7 @@ var AzzasTracker = (() => {
1789
1872
  var headlessAdapter = {
1790
1873
  ...metaAdapters,
1791
1874
  // global adapters
1792
- ...orderFormAdapters,
1875
+ ...orderFormAdapter,
1793
1876
  // orderForm adapters, confirmar se no storefront tem evento que usa essses params
1794
1877
  brand: (context) => {
1795
1878
  if (context.zone === "PDP") {
@@ -1838,17 +1921,63 @@ var AzzasTracker = (() => {
1838
1921
  }
1839
1922
  };
1840
1923
 
1924
+ // src/params/adapters/pickup/utils.ts
1925
+ var getShippingTier = (sla) => {
1926
+ var _a, _b;
1927
+ const isPickup = sla.deliveryChannel === "pickup-in-point" /* PickupInPoint */;
1928
+ if (isPickup) {
1929
+ const storeName = (_b = (_a = sla.pickupStoreInfo) == null ? void 0 : _a.friendlyName) == null ? void 0 : _b.trim();
1930
+ return storeName ? `retirada em loja: ${storeName}` : "retirada em loja";
1931
+ }
1932
+ return sla.name ? `receba em casa: ${sla.name.toLowerCase()}` : "receba em casa";
1933
+ };
1934
+ var getDeliveryTime = (sla) => {
1935
+ const estimate = sla.shippingEstimate;
1936
+ if (!estimate) return 0;
1937
+ const days = parseInt(estimate, 10);
1938
+ return isNaN(days) ? 0 : days;
1939
+ };
1940
+
1941
+ // src/params/adapters/pickup/index.ts
1942
+ var pickupAdapter = {
1943
+ ...metaAdapters,
1944
+ flag_pickup: (context) => {
1945
+ var _a;
1946
+ return (_a = context == null ? void 0 : context.flag_pickup) != null ? _a : null;
1947
+ },
1948
+ shippings: (context) => {
1949
+ if (context.shippings) {
1950
+ return context.shippings.map((s) => {
1951
+ var _a, _b;
1952
+ return {
1953
+ line_items: (_a = s.line_items) != null ? _a : "",
1954
+ shipping: (_b = s.price) != null ? _b : 0,
1955
+ shipping_tier: getShippingTier(s),
1956
+ delivery_time: getDeliveryTime(s)
1957
+ };
1958
+ });
1959
+ }
1960
+ return null;
1961
+ },
1962
+ zipcode: (context) => {
1963
+ var _a;
1964
+ return (_a = context.zipcode) != null ? _a : null;
1965
+ }
1966
+ };
1967
+
1841
1968
  // src/formatter.ts
1842
1969
  var adapters = {
1843
1970
  DECO: decoAdapter,
1844
- HEADLESS: headlessAdapter
1971
+ HEADLESS: headlessAdapter,
1972
+ PICKUP: pickupAdapter,
1973
+ ORDERFORM: orderFormAdapter
1845
1974
  };
1846
1975
  async function getParameters(context, eventName) {
1847
1976
  var _a;
1848
1977
  const eventConfig = EVENTS[eventName];
1849
1978
  if (!eventConfig) return;
1850
1979
  const currentAdapter = context.adapter;
1851
- const getters = (_a = adapters[currentAdapter]) != null ? _a : paramGetters;
1980
+ const getters = (_a = adapters[currentAdapter]) != null ? _a : legacyGetters;
1852
1981
  const entries = await Promise.all(
1853
1982
  eventConfig.requiredParams.map(async (param) => {
1854
1983
  const getter = getters[param];