@azzas/azzas-tracker-web 2.0.0-preview.0 → 2.0.0-preview.10

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.
@@ -1308,14 +1308,49 @@ var AzzasTracker = function() {
1308
1308
  });
1309
1309
  })();
1310
1310
  };
1311
- var getItemShippingTier2 = function getItemShippingTier2() {
1312
- return null;
1311
+ var getBrandCode2 = function getBrandCode2(brand) {
1312
+ if (!brand) return null;
1313
+ var standardized = brand.toLowerCase().trim();
1314
+ return BRAND_CODES2[standardized] || null;
1313
1315
  };
1314
- var resizeVtexImage3 = function resizeVtexImage3(url) {
1315
- var width = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 500, height = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 500;
1316
- return url === null || url === void 0 ? void 0 : url.replace(/(\/arquivos\/ids\/\d+)-\d+-\d+\//, "$1-".concat(width, "-").concat(height, "/"));
1316
+ var normalizeBrand2 = function normalizeBrand2(input) {
1317
+ var brandStrings = [];
1318
+ if (Array.isArray(input) && input.every(function(item) {
1319
+ return typeof item === "string";
1320
+ })) {
1321
+ brandStrings = input;
1322
+ } else if (Array.isArray(input)) {
1323
+ brandStrings = input.map(function(item) {
1324
+ var _item_additionalInfo;
1325
+ return ((_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) || item.brand;
1326
+ });
1327
+ } else if ((typeof input === "undefined" ? "undefined" : _type_of(input)) === "object" && input !== null && "brand" in input) {
1328
+ var _input_additionalInfo;
1329
+ brandStrings = [
1330
+ ((_input_additionalInfo = input.additionalInfo) === null || _input_additionalInfo === void 0 ? void 0 : _input_additionalInfo.brandName) || input.brand
1331
+ ];
1332
+ } else if (typeof input === "string") {
1333
+ return getBrandCode2(input);
1334
+ } else {
1335
+ return null;
1336
+ }
1337
+ var brandCodes = brandStrings.map(getBrandCode2).filter(function(code) {
1338
+ return code !== null;
1339
+ });
1340
+ var uniqueSortedCodes = _to_consumable_array(new Set(brandCodes)).sort();
1341
+ return uniqueSortedCodes.length > 0 ? uniqueSortedCodes.join("_") : null;
1317
1342
  };
1318
- var getParameters = function getParameters(context, eventName) {
1343
+ var getItemShippingTier2 = function getItemShippingTier2(orderForm, item) {
1344
+ var _orderForm_shippingData_logisticsInfo, _orderForm_shippingData, _info_slas, _selectedSla_pickupStoreInfo;
1345
+ var info = orderForm === null || orderForm === void 0 ? void 0 : (_orderForm_shippingData = orderForm.shippingData) === null || _orderForm_shippingData === void 0 ? void 0 : (_orderForm_shippingData_logisticsInfo = _orderForm_shippingData.logisticsInfo) === null || _orderForm_shippingData_logisticsInfo === void 0 ? void 0 : _orderForm_shippingData_logisticsInfo.find(function(li) {
1346
+ return li.itemId === item.id;
1347
+ });
1348
+ var selectedSla = info === null || info === void 0 ? void 0 : (_info_slas = info.slas) === null || _info_slas === void 0 ? void 0 : _info_slas.find(function(sla) {
1349
+ return sla.id === info.selectedSla;
1350
+ });
1351
+ return (selectedSla === null || selectedSla === void 0 ? void 0 : (_selectedSla_pickupStoreInfo = selectedSla.pickupStoreInfo) === null || _selectedSla_pickupStoreInfo === void 0 ? void 0 : _selectedSla_pickupStoreInfo.friendlyName) ? "retirada em loja: ".concat(selectedSla.pickupStoreInfo.friendlyName) : (selectedSla === null || selectedSla === void 0 ? void 0 : selectedSla.name) ? "Receba em casa: ".concat(selectedSla.name) : null;
1352
+ };
1353
+ var getParameters = function getParameters(context, eventName, config2) {
1319
1354
  return _async_to_generator(function() {
1320
1355
  var _adapters_currentAdapter, eventConfig, currentAdapter, getters, entries;
1321
1356
  return _ts_generator(this, function(_state) {
@@ -1326,7 +1361,7 @@ var AzzasTracker = function() {
1326
1361
  2
1327
1362
  ];
1328
1363
  currentAdapter = context.adapter;
1329
- getters = (_adapters_currentAdapter = adapters[currentAdapter]) !== null && _adapters_currentAdapter !== void 0 ? _adapters_currentAdapter : paramGetters;
1364
+ getters = (_adapters_currentAdapter = adapters[currentAdapter]) !== null && _adapters_currentAdapter !== void 0 ? _adapters_currentAdapter : legacyGetters;
1330
1365
  return [
1331
1366
  4,
1332
1367
  Promise.all(eventConfig.requiredParams.map(function(param) {
@@ -1351,7 +1386,7 @@ var AzzasTracker = function() {
1351
1386
  ];
1352
1387
  return [
1353
1388
  4,
1354
- getter(context, eventName)
1389
+ getter(context, config2)
1355
1390
  ];
1356
1391
  case 1:
1357
1392
  return [
@@ -1375,8 +1410,10 @@ var AzzasTracker = function() {
1375
1410
  });
1376
1411
  })();
1377
1412
  };
1378
- var trackWebEvent = // src/index.ts
1379
- function trackWebEvent(event, context) {
1413
+ var initTracker = function initTracker(c) {
1414
+ config = c;
1415
+ };
1416
+ var trackWebEvent = function trackWebEvent(event, context) {
1380
1417
  return _async_to_generator(function() {
1381
1418
  var parameters, err;
1382
1419
  return _ts_generator(this, function(_state) {
@@ -1390,7 +1427,7 @@ var AzzasTracker = function() {
1390
1427
  ]);
1391
1428
  return [
1392
1429
  4,
1393
- getParameters(context, event)
1430
+ getParameters(context, event, config)
1394
1431
  ];
1395
1432
  case 1:
1396
1433
  parameters = _state.sent();
@@ -1480,6 +1517,9 @@ var AzzasTracker = function() {
1480
1517
  default: function() {
1481
1518
  return src_default;
1482
1519
  },
1520
+ initTracker: function() {
1521
+ return initTracker;
1522
+ },
1483
1523
  trackWebEvent: function() {
1484
1524
  return trackWebEvent;
1485
1525
  }
@@ -1893,10 +1933,36 @@ var AzzasTracker = function() {
1893
1933
  ],
1894
1934
  requiredParams: [
1895
1935
  "brand",
1896
- "line_items",
1897
1936
  "size",
1898
1937
  "item_ref"
1899
1938
  ]
1939
+ },
1940
+ REFINE_RESULTS: {
1941
+ name: "refine_results",
1942
+ hasEcommerce: false,
1943
+ destinations: [
1944
+ "DataLayer"
1945
+ ],
1946
+ requiredParams: [
1947
+ "brand",
1948
+ "region",
1949
+ "color",
1950
+ "price_range",
1951
+ "size",
1952
+ "category",
1953
+ "ordering"
1954
+ ]
1955
+ },
1956
+ GRID_SIZE: {
1957
+ name: "grid_size",
1958
+ hasEcommerce: false,
1959
+ destinations: [
1960
+ "DataLayer"
1961
+ ],
1962
+ requiredParams: [
1963
+ "brand",
1964
+ "slot_per_line"
1965
+ ]
1900
1966
  }
1901
1967
  };
1902
1968
  var BRAND_CODES = {
@@ -2079,13 +2145,17 @@ var AzzasTracker = function() {
2079
2145
  var capitalize = function(str) {
2080
2146
  return str ? str[0].toUpperCase() + str.slice(1).toLowerCase() : "";
2081
2147
  };
2148
+ var resizeVtexImage2 = function(url) {
2149
+ var width = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 500, height = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 500;
2150
+ return url === null || url === void 0 ? void 0 : url.replace(/(\/arquivos\/ids\/\d+)-\d+-\d+\//, "$1-".concat(width, "-").concat(height, "/"));
2151
+ };
2082
2152
  // src/params/userInfo.ts
2083
2153
  var PROD_DOMAINS = {
2084
2154
  "animale": {
2085
2155
  "store": "https://www.animale.com.br",
2086
2156
  "checkout": "https://secure.animale.com.br"
2087
2157
  },
2088
- "farm": {
2158
+ "lojafarm": {
2089
2159
  "store": "https://lojafarm.myvtex.com"
2090
2160
  },
2091
2161
  "mariafilo": {
@@ -2103,12 +2173,12 @@ var AzzasTracker = function() {
2103
2173
  "bynv": {
2104
2174
  "store": "https://bynv.myvtex.com"
2105
2175
  },
2106
- "fabula": {
2176
+ "lojafabula": {
2107
2177
  "store": "https://lojafabula.myvtex.com"
2108
2178
  }
2109
2179
  };
2110
2180
  // src/params/legacy/index.ts
2111
- var paramGetters = {
2181
+ var legacyGetters = {
2112
2182
  brand: getBrand,
2113
2183
  items: getItems,
2114
2184
  payment_type: getPaymentType,
@@ -2368,12 +2438,8 @@ var AzzasTracker = function() {
2368
2438
  // src/params/adapters/meta/index.ts
2369
2439
  var metaAdapters = {
2370
2440
  user_info: getUserInfo,
2371
- brand: function(context) {
2372
- return context.meta.brand || null;
2373
- },
2374
2441
  content_type: function(context) {
2375
- if (context === null || context === void 0 ? void 0 : context.content_type) return context.content_type;
2376
- return "regiao".concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
2442
+ return context.meta.content_type || null;
2377
2443
  },
2378
2444
  region: function(context) {
2379
2445
  return context.meta.region || null;
@@ -2381,18 +2447,22 @@ var AzzasTracker = function() {
2381
2447
  pre_filled: function(context) {
2382
2448
  return !!context.preFilled;
2383
2449
  },
2384
- currency: function(context) {
2385
- if (context === null || context === void 0 ? void 0 : context.currency) return context.currency;
2450
+ currency: function(_, config2) {
2451
+ if (config2 === null || config2 === void 0 ? void 0 : config2.currency) return config2.currency;
2386
2452
  return "BRL";
2387
2453
  },
2454
+ slot_per_line: function(context) {
2455
+ var _context_meta_slot_per_line;
2456
+ return (_context_meta_slot_per_line = context.meta.slot_per_line) !== null && _context_meta_slot_per_line !== void 0 ? _context_meta_slot_per_line : null;
2457
+ },
2388
2458
  search_term: function(context) {
2389
- return context.searchTerm || null;
2459
+ return context.meta.search_term || null;
2390
2460
  },
2391
2461
  search_found: function(context) {
2392
- return !!context.searchFound;
2462
+ return context.meta.search_found || null;
2393
2463
  },
2394
2464
  search_quantity: function(context) {
2395
- return context.searchQuantity || 0;
2465
+ return context.meta.search_quantity || 0;
2396
2466
  },
2397
2467
  promotion_name: function(context) {
2398
2468
  return context.meta.promotion_name || null;
@@ -2403,201 +2473,38 @@ var AzzasTracker = function() {
2403
2473
  creative_slot: function(context) {
2404
2474
  return context.meta.creative_slot || null;
2405
2475
  },
2406
- zipcode: function(context) {
2407
- return context.zipCode || null;
2408
- },
2409
- size: function(context) {
2410
- return context.size || null;
2411
- },
2412
2476
  item_ref: function(context) {
2413
- return context.itemRef || null;
2477
+ return context.meta.item_ref || null;
2414
2478
  },
2415
2479
  method: function(context) {
2416
- return context.method || null;
2480
+ return context.meta.method || null;
2417
2481
  },
2418
2482
  type: function(context) {
2419
- return context.type || null;
2420
- }
2421
- };
2422
- // src/params/adapters/orderForm/index.ts
2423
- var orderFormAdapters = {
2424
- // orderform
2425
- payment_type: getPaymentType,
2426
- total_discount: function(context) {
2427
- var _context_orderForm, _context_orderForm1;
2428
- if (context === null || context === void 0 ? void 0 : context.totalDiscount) return context.totalDiscount;
2429
- var totalsList = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.totalizers) || ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totals) || [];
2430
- var items = context.orderForm.items;
2431
- var totalDiscount = items.reduce(function(acc, item) {
2432
- var unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
2433
- return acc + unitDiscount * item.quantity;
2434
- }, 0);
2435
- var discounts = totalsList.find(function(t) {
2436
- return t.id === "Discounts";
2437
- });
2438
- return Math.abs(((discounts === null || discounts === void 0 ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
2439
- },
2440
- subtotal: function(context) {
2441
- var _context_orderForm, _context_orderForm1;
2442
- var totalsList = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.totalizers) || ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totals) || [];
2443
- var subtotal = totalsList.filter(function(t) {
2444
- return t.id === "Items";
2445
- }).reduce(function(acc, t) {
2446
- return acc + (t.value || 0);
2447
- }, 0) / 100 || 0;
2448
- return subtotal;
2449
- },
2450
- coupon_message: function(context) {
2451
- var _context_orderForm;
2452
- if (context.couponMessage) return context.couponMessage;
2453
- var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
2454
- if (messages.length === 0) return null;
2455
- var couponMessages = messages.filter(function(msg) {
2456
- return msg.text.toLowerCase().includes("cupom");
2457
- });
2458
- if (couponMessages.length === 0) return null;
2459
- return couponMessages.map(function(msg) {
2460
- return msg.text;
2461
- }).join(" | ");
2483
+ return context.meta.type || null;
2462
2484
  },
2463
- flag_pickup: function(context) {
2464
- var _orderForm_shippingData;
2465
- var orderForm = context.orderForm;
2466
- if (!orderForm) return null;
2467
- var logisticsInfo = ((_orderForm_shippingData = orderForm.shippingData) === null || _orderForm_shippingData === void 0 ? void 0 : _orderForm_shippingData.logisticsInfo) || [];
2468
- var hasPickup = logisticsInfo.some(function(info) {
2469
- var _info_slas;
2470
- return (_info_slas = info.slas) === null || _info_slas === void 0 ? void 0 : _info_slas.some(function(sla) {
2471
- return sla.deliveryChannel === "pickup-in-point";
2472
- });
2473
- });
2474
- return hasPickup;
2485
+ color: function(context) {
2486
+ return context.meta.color || null;
2475
2487
  },
2476
- shippings: function(context) {
2477
- var orderForm = context.orderForm;
2478
- if (!orderForm) return null;
2479
- var groupShipping = {};
2480
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2481
- try {
2482
- for(var _iterator = orderForm.shippingData.logisticsInfo[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2483
- var info = _step.value;
2484
- var item = orderForm.items[info.itemIndex];
2485
- if (!item) continue;
2486
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2487
- try {
2488
- for(var _iterator1 = info.slas[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2489
- var sla = _step1.value;
2490
- var key = sla.name;
2491
- if (!groupShipping[key]) {
2492
- groupShipping[key] = {
2493
- shipping_tier: sla.name,
2494
- delivery_time: parseInt(sla.shippingEstimate),
2495
- shipping: parseFloat((sla.price / 100).toFixed(1)),
2496
- line_items: []
2497
- };
2498
- }
2499
- groupShipping[key].line_items.push(item.id);
2500
- }
2501
- } catch (err) {
2502
- _didIteratorError1 = true;
2503
- _iteratorError1 = err;
2504
- } finally{
2505
- try {
2506
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2507
- _iterator1.return();
2508
- }
2509
- } finally{
2510
- if (_didIteratorError1) {
2511
- throw _iteratorError1;
2512
- }
2513
- }
2514
- }
2515
- }
2516
- } catch (err) {
2517
- _didIteratorError = true;
2518
- _iteratorError = err;
2519
- } finally{
2520
- try {
2521
- if (!_iteratorNormalCompletion && _iterator.return != null) {
2522
- _iterator.return();
2523
- }
2524
- } finally{
2525
- if (_didIteratorError) {
2526
- throw _iteratorError;
2527
- }
2528
- }
2529
- }
2530
- var shippings = Object.values(groupShipping).map(function(s) {
2531
- return {
2532
- shipping: s.shipping,
2533
- shipping_tier: s.shipping_tier,
2534
- delivery_time: s.delivery_time,
2535
- line_items: s.line_items.join(",")
2536
- };
2537
- });
2538
- return shippings || null;
2539
- },
2540
- shipping: function(context) {
2541
- var _ref;
2542
- var _context_orderForm_shippingData, _context_orderForm;
2543
- var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
2544
- return logistics.reduce(function(total, item) {
2545
- var _ref;
2546
- var _item_slas;
2547
- var selected = (_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
2548
- return sla.id === item.selectedSla;
2549
- });
2550
- return total + ((_ref = selected === null || selected === void 0 ? void 0 : selected.price) !== null && _ref !== void 0 ? _ref : 0);
2551
- }, 0);
2552
- },
2553
- shipping_tier: function(context) {
2554
- var _ref;
2555
- var _context_orderForm_shippingData, _context_orderForm;
2556
- var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
2557
- var selectedSlas = logistics.map(function(item) {
2558
- var _item_slas;
2559
- if (!item.selectedSla) return null;
2560
- return ((_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
2561
- return sla.id === item.selectedSla;
2562
- })) || null;
2563
- }).filter(Boolean);
2564
- if (selectedSlas.length === 0) return null;
2565
- var uniqueTiers = Array.from(new Map(selectedSlas.map(function(sla) {
2566
- var _sla_pickupStoreInfo;
2567
- var key = sla.deliveryChannel === "pickup-in-point" ? "pickup:".concat(((_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : _sla_pickupStoreInfo.friendlyName) || sla.name || "") : "delivery:".concat(sla.name || "");
2568
- return [
2569
- key,
2570
- sla
2571
- ];
2572
- })).values());
2573
- var sortedTiers = uniqueTiers.sort(function(a, b) {
2574
- var _a_pickupStoreInfo, _b_pickupStoreInfo;
2575
- var aOrder = a.deliveryChannel === "pickup-in-point" ? 0 : 1;
2576
- var bOrder = b.deliveryChannel === "pickup-in-point" ? 0 : 1;
2577
- if (aOrder !== bOrder) return aOrder - bOrder;
2578
- var aLabel = a.deliveryChannel === "pickup-in-point" ? ((_a_pickupStoreInfo = a.pickupStoreInfo) === null || _a_pickupStoreInfo === void 0 ? void 0 : _a_pickupStoreInfo.friendlyName) || a.name || "" : a.name || "";
2579
- var bLabel = b.deliveryChannel === "pickup-in-point" ? ((_b_pickupStoreInfo = b.pickupStoreInfo) === null || _b_pickupStoreInfo === void 0 ? void 0 : _b_pickupStoreInfo.friendlyName) || b.name || "" : b.name || "";
2580
- return aLabel.localeCompare(bLabel, "pt-BR");
2581
- });
2582
- var shippingTier = sortedTiers.map(function(sla) {
2583
- var _sla_pickupStoreInfo;
2584
- return sla.deliveryChannel === "pickup-in-point" ? "retirada em loja".concat(((_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : _sla_pickupStoreInfo.friendlyName) ? ": ".concat(sla.pickupStoreInfo.friendlyName) : "") : sla.deliveryChannel === "delivery" ? "receba em casa".concat(sla.name ? ": ".concat(sla.name) : "") : null;
2585
- }).filter(Boolean).join(", ");
2586
- return shippingTier || null;
2488
+ price_range: function(context) {
2489
+ return context.meta.price_range || null;
2587
2490
  },
2588
- transaction_id: function(context) {
2589
- var _context_orderForm_orderGroup, _context_orderForm;
2590
- return ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_orderGroup = _context_orderForm.orderGroup) === null || _context_orderForm_orderGroup === void 0 ? void 0 : _context_orderForm_orderGroup.toString()) || null;
2491
+ category: function(context) {
2492
+ return context.meta.category || null;
2591
2493
  },
2592
- coupon: function(context) {
2593
- var _context_orderForm_marketingData, _context_orderForm;
2594
- return context.appliedCoupon || (context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_marketingData = _context_orderForm.marketingData) === null || _context_orderForm_marketingData === void 0 ? void 0 : _context_orderForm_marketingData.coupon) || null;
2494
+ ordering: function(context) {
2495
+ return context.meta.ordering || null;
2595
2496
  },
2596
- seller_cod_name: function(context) {
2597
- return context.appliedSellerCodName || (context === null || context === void 0 ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
2497
+ size: function(context) {
2498
+ return context.meta.size || null;
2598
2499
  }
2599
2500
  };
2600
- // src/params/adapters/deco/utils/index.ts
2501
+ // src/core/farm.ts
2502
+ var BRAND_CODES2 = {
2503
+ farm: "farmrio",
2504
+ "farm etc": "farmetc",
2505
+ "farm rio": "farmrio"
2506
+ };
2507
+ // src/params/adapters/deco/utils.ts
2601
2508
  var getItemCategory3 = function(item) {
2602
2509
  var _text_match;
2603
2510
  var value = item === null || item === void 0 ? void 0 : item.category;
@@ -2618,21 +2525,17 @@ var AzzasTracker = function() {
2618
2525
  var deepest = (_validHierarchy_ = validHierarchy[validHierarchy.length - 1]) !== null && _validHierarchy_ !== void 0 ? _validHierarchy_ : "";
2619
2526
  return capitalize(deepest);
2620
2527
  };
2621
- var resizeVtexImage2 = function(url) {
2622
- var width = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 500, height = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 500;
2623
- return url === null || url === void 0 ? void 0 : url.replace(/(\/arquivos\/ids\/\d+)-\d+-\d+\//, "$1-".concat(width, "-").concat(height, "/"));
2624
- };
2625
2528
  // src/params/adapters/deco/index.ts
2626
2529
  var IN_STOCK_SCHEMA = "https://schema.org/InStock";
2627
2530
  var LIST_PRICE_SCHEMA = "https://schema.org/ListPrice";
2628
- var decoAdapter = _object_spread_props(_object_spread({}, metaAdapters, orderFormAdapters), {
2629
- // orderform adapters
2531
+ var decoAdapter = _object_spread_props(_object_spread({}, metaAdapters), {
2532
+ // global adapters
2630
2533
  items: function(context) {
2631
2534
  if (context === null || context === void 0 ? void 0 : context.items) return context.items;
2632
2535
  if (context === null || context === void 0 ? void 0 : context.products) {
2633
2536
  return context.products.map(function(item) {
2634
2537
  var _ref, _ref1, _item_alternateName, _ref2, _ref3, _ref4, _getItemCategory3, _getItemCategory22, _ref5, _item_sku, _item_url, _resizeVtexImage2, _ref6, _ref7;
2635
- var _item_offers_offers__priceSpecification_find, _item_offers_offers, _item_offers, _item_brand_name, _item_brand, _item_offers1, _item_offers2, _item_name_split_, _item_name, _item_name1, _item_additionalProperty_find, _item_additionalProperty, _item_image, _item_offers_offers_, _item_offers_offers1, _item_offers3;
2538
+ var _item_offers_offers__priceSpecification_find, _item_offers_offers, _item_offers, _item_brand_name, _item_brand, _item_offers1, _item_offers2, _item_name_split_, _item_name, _item_name1, _item_additionalProperty_find_value, _item_additionalProperty_find, _item_additionalProperty, _item_image, _item_offers_offers_, _item_offers_offers1, _item_offers3;
2636
2539
  var COLOR_REGEX = /^[^_]+_/;
2637
2540
  var listPrice = item === null || item === void 0 ? void 0 : (_item_offers = item.offers) === null || _item_offers === void 0 ? void 0 : (_item_offers_offers = _item_offers.offers) === null || _item_offers_offers === void 0 ? void 0 : (_item_offers_offers__priceSpecification_find = _item_offers_offers[0].priceSpecification.find(function(s) {
2638
2541
  return s.priceType === LIST_PRICE_SCHEMA;
@@ -2643,15 +2546,15 @@ var AzzasTracker = function() {
2643
2546
  item_brand: (_ref1 = (_item_brand = item.brand) === null || _item_brand === void 0 ? void 0 : (_item_brand_name = _item_brand.name) === null || _item_brand_name === void 0 ? void 0 : _item_brand_name.toLowerCase()) !== null && _ref1 !== void 0 ? _ref1 : null,
2644
2547
  item_name: (_item_alternateName = item.alternateName) !== null && _item_alternateName !== void 0 ? _item_alternateName : null,
2645
2548
  price: (_ref2 = (_item_offers1 = item.offers) === null || _item_offers1 === void 0 ? void 0 : _item_offers1.lowPrice) !== null && _ref2 !== void 0 ? _ref2 : null,
2646
- discount: Number(listPrice) - Number(item === null || item === void 0 ? void 0 : (_item_offers2 = item.offers) === null || _item_offers2 === void 0 ? void 0 : _item_offers2.lowPrice),
2549
+ discount: Math.round((Number(listPrice) - Number(item === null || item === void 0 ? void 0 : (_item_offers2 = item.offers) === null || _item_offers2 === void 0 ? void 0 : _item_offers2.lowPrice)) * 100) / 100,
2647
2550
  item_variant: (item === null || item === void 0 ? void 0 : (_item_name = item.name) === null || _item_name === void 0 ? void 0 : (_item_name_split_ = _item_name.split(" - ")[0]) === null || _item_name_split_ === void 0 ? void 0 : _item_name_split_.replace(COLOR_REGEX, "").replace(/_/g, " ")) || null,
2648
2551
  // cor
2649
2552
  item_variant2: (_ref3 = item === null || item === void 0 ? void 0 : (_item_name1 = item.name) === null || _item_name1 === void 0 ? void 0 : _item_name1.split(" - ")[1]) !== null && _ref3 !== void 0 ? _ref3 : null,
2650
2553
  // tamanho
2651
- item_shipping_tier: getItemShippingTier2(),
2554
+ item_shipping_tier: "",
2652
2555
  item_ref: (_ref4 = (_item_additionalProperty = item.additionalProperty) === null || _item_additionalProperty === void 0 ? void 0 : (_item_additionalProperty_find = _item_additionalProperty.find(function(i) {
2653
2556
  return i.name === "RefId";
2654
- })) === null || _item_additionalProperty_find === void 0 ? void 0 : _item_additionalProperty_find.value) !== null && _ref4 !== void 0 ? _ref4 : null,
2557
+ })) === null || _item_additionalProperty_find === void 0 ? void 0 : (_item_additionalProperty_find_value = _item_additionalProperty_find.value) === null || _item_additionalProperty_find_value === void 0 ? void 0 : _item_additionalProperty_find_value.replace(/_\d+$/, "")) !== null && _ref4 !== void 0 ? _ref4 : null,
2655
2558
  item_category: (_getItemCategory3 = getItemCategory3(item)) !== null && _getItemCategory3 !== void 0 ? _getItemCategory3 : null,
2656
2559
  item_category2: (_getItemCategory22 = getItemCategory22(item)) !== null && _getItemCategory22 !== void 0 ? _getItemCategory22 : null,
2657
2560
  item_id: (_ref5 = item === null || item === void 0 ? void 0 : item.inProductGroupWithID) !== null && _ref5 !== void 0 ? _ref5 : null,
@@ -2665,13 +2568,17 @@ var AzzasTracker = function() {
2665
2568
  }
2666
2569
  return null;
2667
2570
  },
2668
- // brand: (context: DecoBrandContext) => {
2669
- // if (context?.brand) return context.brand
2670
- // if (context?.products) {
2671
- // return context.products[0].brand?.name // tem que ajustar FARM por conta de FARM_ETC
2672
- // }
2673
- // return null
2674
- // },
2571
+ brand: function(context, config2) {
2572
+ if (config2 === null || config2 === void 0 ? void 0 : config2.brand) return config2.brand;
2573
+ if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
2574
+ if (context === null || context === void 0 ? void 0 : context.products) {
2575
+ return normalizeBrand2(context.products.map(function(p) {
2576
+ var _p_brand;
2577
+ return p === null || p === void 0 ? void 0 : (_p_brand = p.brand) === null || _p_brand === void 0 ? void 0 : _p_brand.name;
2578
+ }));
2579
+ }
2580
+ return null;
2581
+ },
2675
2582
  line_items: function(context) {
2676
2583
  if (context === null || context === void 0 ? void 0 : context.line_items) return context.line_items;
2677
2584
  if (context === null || context === void 0 ? void 0 : context.products) {
@@ -2721,7 +2628,7 @@ var AzzasTracker = function() {
2721
2628
  return null;
2722
2629
  }
2723
2630
  });
2724
- // src/params/adapters/headless/utils/index.ts
2631
+ // src/params/adapters/headless/utils.ts
2725
2632
  var getItemCategory5 = function(item) {
2726
2633
  var keywords = [
2727
2634
  "outlet",
@@ -2756,7 +2663,7 @@ var AzzasTracker = function() {
2756
2663
  if (context === null || context === void 0 ? void 0 : context.items) return context.items;
2757
2664
  if (context === null || context === void 0 ? void 0 : context.products) {
2758
2665
  return context.products.map(function(item) {
2759
- var _ref, _item_brand, _item_productName, _ref1, _ref2, _item_productReference, _getItemCategory23, _ref3, _ref4, _item_link, _resizeVtexImage3, _ref5, _item_item_list_name;
2666
+ var _ref, _item_brand, _item_productName, _ref1, _ref2, _item_productReference, _getItemCategory23, _ref3, _ref4, _item_link, _resizeVtexImage2, _ref5, _item_item_list_name;
2760
2667
  var _item_items__sellers, _item_items__sellers1, _item_items__name, _item_items_, _item_items__name1, _item_items_1, _item_items, _item_items__images, _item_items1, _item_items__sellers2, _item_items_2, _item_items2;
2761
2668
  var listPrice = item === null || item === void 0 ? void 0 : (_item_items__sellers = item.items[0].sellers) === null || _item_items__sellers === void 0 ? void 0 : _item_items__sellers[0].commertialOffer.ListPrice;
2762
2669
  var price = item === null || item === void 0 ? void 0 : (_item_items__sellers1 = item.items[0].sellers) === null || _item_items__sellers1 === void 0 ? void 0 : _item_items__sellers1[0].commertialOffer.Price;
@@ -2766,6 +2673,7 @@ var AzzasTracker = function() {
2766
2673
  item_brand: (_item_brand = item.brand) !== null && _item_brand !== void 0 ? _item_brand : null,
2767
2674
  item_name: (_item_productName = item.productName) !== null && _item_productName !== void 0 ? _item_productName : null,
2768
2675
  price: price !== null && price !== void 0 ? price : null,
2676
+ item_shipping_tier: null,
2769
2677
  discount: Number(listPrice) - Number(price),
2770
2678
  item_variant: (_ref1 = (_item_items_ = item.items[0]) === null || _item_items_ === void 0 ? void 0 : (_item_items__name = _item_items_.name) === null || _item_items__name === void 0 ? void 0 : _item_items__name.split(" - ")[0]) !== null && _ref1 !== void 0 ? _ref1 : null,
2771
2679
  item_variant2: (_ref2 = (_item_items_1 = item.items[0]) === null || _item_items_1 === void 0 ? void 0 : (_item_items__name1 = _item_items_1.name) === null || _item_items__name1 === void 0 ? void 0 : _item_items__name1.split(" - ")[1]) !== null && _ref2 !== void 0 ? _ref2 : null,
@@ -2777,7 +2685,7 @@ var AzzasTracker = function() {
2777
2685
  item_sku: (_ref4 = (_item_items = item.items) === null || _item_items === void 0 ? void 0 : _item_items[0].itemId) !== null && _ref4 !== void 0 ? _ref4 : null,
2778
2686
  item_url: (_item_link = item.link) !== null && _item_link !== void 0 ? _item_link : null,
2779
2687
  // sem link/url no retorno do IS na multi-lib produtos PDC
2780
- image_url: (_resizeVtexImage3 = resizeVtexImage3(item === null || item === void 0 ? void 0 : (_item_items1 = item.items) === null || _item_items1 === void 0 ? void 0 : (_item_items__images = _item_items1[0].images) === null || _item_items__images === void 0 ? void 0 : _item_items__images[0].imageUrl)) !== null && _resizeVtexImage3 !== void 0 ? _resizeVtexImage3 : null,
2688
+ image_url: (_resizeVtexImage2 = resizeVtexImage2(item === null || item === void 0 ? void 0 : (_item_items1 = item.items) === null || _item_items1 === void 0 ? void 0 : (_item_items__images = _item_items1[0].images) === null || _item_items__images === void 0 ? void 0 : _item_items__images[0].imageUrl)) !== null && _resizeVtexImage2 !== void 0 ? _resizeVtexImage2 : null,
2781
2689
  seller_id: (_ref5 = (_item_items2 = item.items) === null || _item_items2 === void 0 ? void 0 : (_item_items_2 = _item_items2[0]) === null || _item_items_2 === void 0 ? void 0 : (_item_items__sellers2 = _item_items_2.sellers) === null || _item_items__sellers2 === void 0 ? void 0 : _item_items__sellers2[0].sellerId) !== null && _ref5 !== void 0 ? _ref5 : null,
2782
2690
  item_list_name: (_item_item_list_name = item.item_list_name) !== null && _item_item_list_name !== void 0 ? _item_item_list_name : null
2783
2691
  };
@@ -2810,7 +2718,8 @@ var AzzasTracker = function() {
2810
2718
  }
2811
2719
  return null;
2812
2720
  },
2813
- brand: function(context) {
2721
+ brand: function(context, config2) {
2722
+ if (config2 === null || config2 === void 0 ? void 0 : config2.brand) return config2.brand;
2814
2723
  if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
2815
2724
  if (context === null || context === void 0 ? void 0 : context.products) {
2816
2725
  return context.products.map(function(p) {
@@ -2826,7 +2735,7 @@ var AzzasTracker = function() {
2826
2735
  if (context === null || context === void 0 ? void 0 : context.items) return context.items;
2827
2736
  if (context === null || context === void 0 ? void 0 : context.products) {
2828
2737
  return context.products.map(function(item) {
2829
- var _ref, _item_brand_name, _item_name, _ref1, _ref2, _item_additionalProperty, _getItemCategory23, _item_isVariantOf_productGroupID, _item_sku, _resizeVtexImage3, _ref3, _item_item_list_name;
2738
+ var _ref, _item_brand_name, _item_name, _ref1, _ref2, _item_additionalProperty, _getItemCategory23, _item_isVariantOf_productGroupID, _item_sku, _resizeVtexImage2, _ref3, _item_item_list_name;
2830
2739
  var _item_isVariantOf_hasVariant, _item_isVariantOf, _find, _item_image, _item_offers_offers_find_seller, _item_offers_offers_find, _item_offers_offers, _item_offers;
2831
2740
  var listPrice = item.offers.highPrice;
2832
2741
  var price = item.offers.lowPrice;
@@ -2836,6 +2745,7 @@ var AzzasTracker = function() {
2836
2745
  item_brand: (_item_brand_name = item.brand.name) !== null && _item_brand_name !== void 0 ? _item_brand_name : null,
2837
2746
  item_name: (_item_name = item.name) !== null && _item_name !== void 0 ? _item_name : null,
2838
2747
  price: price !== null && price !== void 0 ? price : null,
2748
+ item_shipping_tier: null,
2839
2749
  discount: Number(listPrice) - Number(price),
2840
2750
  item_variant: (_ref1 = (_item_isVariantOf = item.isVariantOf) === null || _item_isVariantOf === void 0 ? void 0 : (_item_isVariantOf_hasVariant = _item_isVariantOf.hasVariant) === null || _item_isVariantOf_hasVariant === void 0 ? void 0 : _item_isVariantOf_hasVariant[0].name.split(" - ")[0]) !== null && _ref1 !== void 0 ? _ref1 : null,
2841
2751
  item_variant2: (_ref2 = (_find = ((_item_additionalProperty = item.additionalProperty) !== null && _item_additionalProperty !== void 0 ? _item_additionalProperty : []).find(function(p) {
@@ -2849,7 +2759,7 @@ var AzzasTracker = function() {
2849
2759
  item_sku: (_item_sku = item.sku) !== null && _item_sku !== void 0 ? _item_sku : null,
2850
2760
  item_url: null,
2851
2761
  // sem link/url no retorno do IS na multi-lib produtos PDC
2852
- image_url: (_resizeVtexImage3 = resizeVtexImage3(item === null || item === void 0 ? void 0 : (_item_image = item.image) === null || _item_image === void 0 ? void 0 : _item_image[0].url)) !== null && _resizeVtexImage3 !== void 0 ? _resizeVtexImage3 : null,
2762
+ image_url: (_resizeVtexImage2 = resizeVtexImage2(item === null || item === void 0 ? void 0 : (_item_image = item.image) === null || _item_image === void 0 ? void 0 : _item_image[0].url)) !== null && _resizeVtexImage2 !== void 0 ? _resizeVtexImage2 : null,
2853
2763
  seller_id: (_ref3 = (_item_offers = item.offers) === null || _item_offers === void 0 ? void 0 : (_item_offers_offers = _item_offers.offers) === null || _item_offers_offers === void 0 ? void 0 : (_item_offers_offers_find = _item_offers_offers.find(function(o) {
2854
2764
  return o.availability;
2855
2765
  })) === null || _item_offers_offers_find === void 0 ? void 0 : (_item_offers_offers_find_seller = _item_offers_offers_find.seller) === null || _item_offers_offers_find_seller === void 0 ? void 0 : _item_offers_offers_find_seller.identifier) !== null && _ref3 !== void 0 ? _ref3 : null,
@@ -2883,7 +2793,8 @@ var AzzasTracker = function() {
2883
2793
  }
2884
2794
  return null;
2885
2795
  },
2886
- brand: function(context) {
2796
+ brand: function(context, config2) {
2797
+ if (config2 === null || config2 === void 0 ? void 0 : config2.brand) return config2.brand;
2887
2798
  if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
2888
2799
  if (context === null || context === void 0 ? void 0 : context.products) {
2889
2800
  return context.products.map(function(p) {
@@ -2894,14 +2805,14 @@ var AzzasTracker = function() {
2894
2805
  }
2895
2806
  };
2896
2807
  // src/params/adapters/headless/index.ts
2897
- var headlessAdapter = _object_spread_props(_object_spread({}, metaAdapters, orderFormAdapters), {
2898
- // orderForm adapters, confirmar se no storefront tem evento que usa essses params
2899
- brand: function(context) {
2808
+ var headlessAdapter = _object_spread_props(_object_spread({}, metaAdapters), {
2809
+ // global adapters
2810
+ brand: function(context, config2) {
2900
2811
  if (context.zone === "PDP") {
2901
- return HeadlessPdpZone.brand(context);
2812
+ return HeadlessPdpZone.brand(context, config2);
2902
2813
  }
2903
2814
  if (context.zone === "PDC") {
2904
- return HeadlessPdcZone.brand(context);
2815
+ return HeadlessPdcZone.brand(context, config2);
2905
2816
  }
2906
2817
  return null;
2907
2818
  },
@@ -2946,10 +2857,293 @@ var AzzasTracker = function() {
2946
2857
  return null;
2947
2858
  }
2948
2859
  });
2860
+ // src/params/adapters/pickup/utils.ts
2861
+ var getShippingTier = function(sla) {
2862
+ var isPickup = sla.deliveryChannel === "pickup-in-point" /* PickupInPoint */ ;
2863
+ if (isPickup) {
2864
+ var _sla_pickupStoreInfo_friendlyName, _sla_pickupStoreInfo;
2865
+ var storeName = (_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : (_sla_pickupStoreInfo_friendlyName = _sla_pickupStoreInfo.friendlyName) === null || _sla_pickupStoreInfo_friendlyName === void 0 ? void 0 : _sla_pickupStoreInfo_friendlyName.trim();
2866
+ return storeName ? "retirada em loja: ".concat(storeName) : "retirada em loja";
2867
+ }
2868
+ return sla.name ? "receba em casa: ".concat(sla.name.toLowerCase()) : "receba em casa";
2869
+ };
2870
+ var getDeliveryTime = function(sla) {
2871
+ var estimate = sla.shippingEstimate;
2872
+ if (!estimate) return 0;
2873
+ var days = parseInt(estimate, 10);
2874
+ return isNaN(days) ? 0 : days;
2875
+ };
2876
+ // src/params/adapters/pickup/index.ts
2877
+ var pickupAdapter = _object_spread_props(_object_spread({}, metaAdapters), {
2878
+ flag_pickup: function(context) {
2879
+ var _ref;
2880
+ return (_ref = context === null || context === void 0 ? void 0 : context.flag_pickup) !== null && _ref !== void 0 ? _ref : null;
2881
+ },
2882
+ shippings: function(context) {
2883
+ if (context.shippings) {
2884
+ return context.shippings.map(function(s) {
2885
+ var _s_line_items;
2886
+ return {
2887
+ line_items: (_s_line_items = s.line_items) !== null && _s_line_items !== void 0 ? _s_line_items : "",
2888
+ shipping: s.price / 100,
2889
+ shipping_tier: getShippingTier(s),
2890
+ delivery_time: getDeliveryTime(s)
2891
+ };
2892
+ });
2893
+ }
2894
+ return null;
2895
+ },
2896
+ brand: function(context, config2) {
2897
+ if (config2 === null || config2 === void 0 ? void 0 : config2.brand) return config2.brand;
2898
+ if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
2899
+ return null;
2900
+ },
2901
+ zipcode: function(context) {
2902
+ var _context_meta_zipcode;
2903
+ return (_context_meta_zipcode = context.meta.zipcode) !== null && _context_meta_zipcode !== void 0 ? _context_meta_zipcode : null;
2904
+ }
2905
+ });
2906
+ // src/params/adapters/orderForm/utils.ts
2907
+ var getItemCategory6 = function(item) {
2908
+ var _text_match;
2909
+ var categories = item === null || item === void 0 ? void 0 : item.productCategories;
2910
+ if (!categories) return "Cole\xE7\xE3o";
2911
+ var text = Object.values(categories).join(" ");
2912
+ var match = (_text_match = text.match(/outlet|bazar|sale/i)) === null || _text_match === void 0 ? void 0 : _text_match[0].toLowerCase();
2913
+ return match !== null && match !== void 0 ? match : "Cole\xE7\xE3o";
2914
+ };
2915
+ var getItemCategory24 = function(item) {
2916
+ var _ref, _validHierarchy_;
2917
+ var AVOID_CATEGORIES = /outlet|bazar|sale/i;
2918
+ var categories = Object.values((_ref = item === null || item === void 0 ? void 0 : item.productCategories) !== null && _ref !== void 0 ? _ref : {});
2919
+ var validHierarchy = categories.map(function(c) {
2920
+ return c.trim();
2921
+ }).filter(function(c) {
2922
+ return c && !AVOID_CATEGORIES.test(c);
2923
+ });
2924
+ var deepest = (_validHierarchy_ = validHierarchy[validHierarchy.length - 1]) !== null && _validHierarchy_ !== void 0 ? _validHierarchy_ : "";
2925
+ return capitalize(deepest);
2926
+ };
2927
+ var getOrderFormItems = function(orderForm) {
2928
+ var idSelected = orderForm === null || orderForm === void 0 ? void 0 : orderForm.selected;
2929
+ return idSelected ? orderForm.items.filter(function(item) {
2930
+ return item.id === idSelected;
2931
+ }) : orderForm.items;
2932
+ };
2933
+ // src/params/adapters/orderForm/index.ts
2934
+ var orderFormAdapter = _object_spread_props(_object_spread({}, metaAdapters), {
2935
+ items: function(context) {
2936
+ if (context === null || context === void 0 ? void 0 : context.items) return context.items;
2937
+ if ((context === null || context === void 0 ? void 0 : context.orderForm) && (context === null || context === void 0 ? void 0 : context.orderForm.items)) {
2938
+ return getOrderFormItems(context.orderForm).map(function(item, index) {
2939
+ var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _getItemCategory6, _getItemCategory24, _ref7, _ref8, _item_detailUrl, _resizeVtexImage2, _ref9, _ref10;
2940
+ var _context_orderForm, _item_additionalInfo, _item_skuName_split__split_pop, _item_skuName_split_, _item_skuName, _item_skuName_split_1, _item_skuName1, _context_orderForm1;
2941
+ return {
2942
+ quantity: (_ref = item === null || item === void 0 ? void 0 : item.quantity) !== null && _ref !== void 0 ? _ref : 1,
2943
+ index: (_ref1 = (_ref2 = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.index) !== null && _ref2 !== void 0 ? _ref2 : index) !== null && _ref1 !== void 0 ? _ref1 : null,
2944
+ item_brand: (_ref3 = (_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) !== null && _ref3 !== void 0 ? _ref3 : null,
2945
+ item_name: (_ref4 = item === null || item === void 0 ? void 0 : item.name.replace(item === null || item === void 0 ? void 0 : item.skuName, "").trim()) !== null && _ref4 !== void 0 ? _ref4 : null,
2946
+ price: (item === null || item === void 0 ? void 0 : item.price) / 100,
2947
+ discount: ((item === null || item === void 0 ? void 0 : item.listPrice) - (item === null || item === void 0 ? void 0 : item.sellingPrice)) / 100,
2948
+ item_variant: (_ref5 = item === null || item === void 0 ? void 0 : (_item_skuName = item.skuName) === null || _item_skuName === void 0 ? void 0 : (_item_skuName_split_ = _item_skuName.split(" - ")[0]) === null || _item_skuName_split_ === void 0 ? void 0 : (_item_skuName_split__split_pop = _item_skuName_split_.split("_").pop()) === null || _item_skuName_split__split_pop === void 0 ? void 0 : _item_skuName_split__split_pop.trim()) !== null && _ref5 !== void 0 ? _ref5 : null,
2949
+ item_variant2: (_ref6 = item === null || item === void 0 ? void 0 : (_item_skuName1 = item.skuName) === null || _item_skuName1 === void 0 ? void 0 : (_item_skuName_split_1 = _item_skuName1.split(" - ")[1]) === null || _item_skuName_split_1 === void 0 ? void 0 : _item_skuName_split_1.trim()) !== null && _ref6 !== void 0 ? _ref6 : null,
2950
+ item_shipping_tier: getItemShippingTier2(context.orderForm, item),
2951
+ item_ref: (item === null || item === void 0 ? void 0 : item.productRefId) || (item === null || item === void 0 ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
2952
+ item_category: (_getItemCategory6 = getItemCategory6(item)) !== null && _getItemCategory6 !== void 0 ? _getItemCategory6 : null,
2953
+ item_category2: (_getItemCategory24 = getItemCategory24(item)) !== null && _getItemCategory24 !== void 0 ? _getItemCategory24 : null,
2954
+ item_id: (_ref7 = item === null || item === void 0 ? void 0 : item.productId) !== null && _ref7 !== void 0 ? _ref7 : null,
2955
+ item_sku: (_ref8 = item === null || item === void 0 ? void 0 : item.id) !== null && _ref8 !== void 0 ? _ref8 : null,
2956
+ item_url: (_item_detailUrl = item.detailUrl) !== null && _item_detailUrl !== void 0 ? _item_detailUrl : null,
2957
+ image_url: (_resizeVtexImage2 = resizeVtexImage2(item.imageUrl)) !== null && _resizeVtexImage2 !== void 0 ? _resizeVtexImage2 : null,
2958
+ seller_id: (_ref9 = item === null || item === void 0 ? void 0 : item.seller) !== null && _ref9 !== void 0 ? _ref9 : null,
2959
+ item_list_name: (_ref10 = context === null || context === void 0 ? void 0 : (_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.item_list_name) !== null && _ref10 !== void 0 ? _ref10 : null
2960
+ };
2961
+ });
2962
+ }
2963
+ return null;
2964
+ },
2965
+ brand: function(context, config2) {
2966
+ var _context_orderForm;
2967
+ if (config2 === null || config2 === void 0 ? void 0 : config2.brand) return config2.brand;
2968
+ if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
2969
+ if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
2970
+ var brands = getOrderFormItems(context.orderForm).map(function(item) {
2971
+ return item.additionalInfo.brandName;
2972
+ });
2973
+ return normalizeBrand2(brands);
2974
+ },
2975
+ line_items: function(context) {
2976
+ var _context_orderForm;
2977
+ if (context === null || context === void 0 ? void 0 : context.line_items) return context.line_items;
2978
+ if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
2979
+ return getOrderFormItems(context.orderForm).map(function(item) {
2980
+ return item === null || item === void 0 ? void 0 : item.productId;
2981
+ }).filter(function(id) {
2982
+ return Boolean(id);
2983
+ });
2984
+ },
2985
+ value: function(context) {
2986
+ var _context_orderForm;
2987
+ if (context === null || context === void 0 ? void 0 : context.value) return context.value;
2988
+ if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
2989
+ return getOrderFormItems(context.orderForm).map(function(item) {
2990
+ return (item === null || item === void 0 ? void 0 : item.price) / 100 * item.quantity;
2991
+ }).filter(function(price) {
2992
+ return price !== void 0;
2993
+ }).reduce(function(sum, price) {
2994
+ return sum + price;
2995
+ }, 0);
2996
+ },
2997
+ payment_type: getPaymentType,
2998
+ total_discount: function(context) {
2999
+ var _context_orderForm, _context_orderForm1;
3000
+ if (context === null || context === void 0 ? void 0 : context.total_discount) return context.total_discount;
3001
+ if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
3002
+ var totalsList = ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totalizers) || [];
3003
+ var totalDiscount = getOrderFormItems(context.orderForm).reduce(function(acc, item) {
3004
+ var unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
3005
+ return acc + unitDiscount * item.quantity;
3006
+ }, 0);
3007
+ var discounts = totalsList.find(function(t) {
3008
+ return t.id === "Discounts";
3009
+ });
3010
+ return Math.abs(((discounts === null || discounts === void 0 ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
3011
+ },
3012
+ subtotal: function(context) {
3013
+ var _context_orderForm, _context_orderForm1;
3014
+ var totalsList = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.totalizers) || ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totals) || [];
3015
+ var subtotal = totalsList.filter(function(t) {
3016
+ return t.id === "Items";
3017
+ }).reduce(function(acc, t) {
3018
+ return acc + (t.value || 0);
3019
+ }, 0) / 100 || 0;
3020
+ return subtotal;
3021
+ },
3022
+ coupon_message: function(context) {
3023
+ var _context_orderForm;
3024
+ if (context.couponMessage) return context.couponMessage;
3025
+ var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
3026
+ if (messages.length === 0) return null;
3027
+ var couponMessages = messages.filter(function(msg) {
3028
+ return msg.text.toLowerCase().includes("cupom");
3029
+ });
3030
+ if (couponMessages.length === 0) return null;
3031
+ return couponMessages.map(function(msg) {
3032
+ return msg.text;
3033
+ }).join(" | ");
3034
+ },
3035
+ zipcode: function(context) {
3036
+ var _context_meta_zipcode;
3037
+ return (_context_meta_zipcode = context.meta.zipcode) !== null && _context_meta_zipcode !== void 0 ? _context_meta_zipcode : null;
3038
+ },
3039
+ flag_pickup: function(context) {
3040
+ var _orderForm_shippingData;
3041
+ var orderForm = context.orderForm;
3042
+ if (!orderForm) return null;
3043
+ var logisticsInfo = ((_orderForm_shippingData = orderForm.shippingData) === null || _orderForm_shippingData === void 0 ? void 0 : _orderForm_shippingData.logisticsInfo) || [];
3044
+ var hasPickup = logisticsInfo.some(function(info) {
3045
+ var _info_slas;
3046
+ return (_info_slas = info.slas) === null || _info_slas === void 0 ? void 0 : _info_slas.some(function(sla) {
3047
+ return sla.deliveryChannel === "pickup-in-point";
3048
+ });
3049
+ });
3050
+ return hasPickup;
3051
+ },
3052
+ shippings: function(context) {
3053
+ if (!context.orderForm) return null;
3054
+ var _context_orderForm = context.orderForm, items = _context_orderForm.items, shippingData = _context_orderForm.shippingData;
3055
+ var acc = {};
3056
+ shippingData.logisticsInfo.forEach(function(param) {
3057
+ var itemIndex = param.itemIndex, slas = param.slas;
3058
+ var item = items[itemIndex];
3059
+ if (!item) return;
3060
+ slas.forEach(function(sla) {
3061
+ if (!acc[sla.name]) acc[sla.name] = {
3062
+ shipping_tier: sla.name,
3063
+ delivery_time: parseInt(sla.shippingEstimate),
3064
+ shipping: parseFloat((sla.price / 100).toFixed(1)),
3065
+ line_items: []
3066
+ };
3067
+ acc[sla.name].line_items.push(item.id);
3068
+ });
3069
+ });
3070
+ return Object.values(acc).map(function(s) {
3071
+ return _object_spread_props(_object_spread({}, s), {
3072
+ line_items: s.line_items.join(",")
3073
+ });
3074
+ });
3075
+ },
3076
+ shipping: function(context) {
3077
+ var _ref;
3078
+ var _context_orderForm_shippingData, _context_orderForm;
3079
+ var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
3080
+ return logistics.reduce(function(total, item) {
3081
+ var _ref;
3082
+ var _item_slas;
3083
+ var selected = (_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
3084
+ return sla.id === item.selectedSla;
3085
+ });
3086
+ return total + ((_ref = selected === null || selected === void 0 ? void 0 : selected.price) !== null && _ref !== void 0 ? _ref : 0);
3087
+ }, 0);
3088
+ },
3089
+ shipping_tier: function(context) {
3090
+ var _ref;
3091
+ var _context_orderForm_shippingData, _context_orderForm;
3092
+ var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
3093
+ var selectedSlas = logistics.map(function(item) {
3094
+ var _item_slas;
3095
+ if (!item.selectedSla) return null;
3096
+ return ((_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
3097
+ return sla.id === item.selectedSla;
3098
+ })) || null;
3099
+ }).filter(Boolean);
3100
+ if (selectedSlas.length === 0) return null;
3101
+ var uniqueTiers = Array.from(new Map(selectedSlas.map(function(sla) {
3102
+ var _sla_pickupStoreInfo;
3103
+ var key = sla.deliveryChannel === "pickup-in-point" ? "pickup:".concat(((_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : _sla_pickupStoreInfo.friendlyName) || sla.name || "") : "delivery:".concat(sla.name || "");
3104
+ return [
3105
+ key,
3106
+ sla
3107
+ ];
3108
+ })).values());
3109
+ var sortedTiers = uniqueTiers.sort(function(a, b) {
3110
+ var _a_pickupStoreInfo, _b_pickupStoreInfo;
3111
+ var aOrder = a.deliveryChannel === "pickup-in-point" ? 0 : 1;
3112
+ var bOrder = b.deliveryChannel === "pickup-in-point" ? 0 : 1;
3113
+ if (aOrder !== bOrder) return aOrder - bOrder;
3114
+ var aLabel = a.deliveryChannel === "pickup-in-point" ? ((_a_pickupStoreInfo = a.pickupStoreInfo) === null || _a_pickupStoreInfo === void 0 ? void 0 : _a_pickupStoreInfo.friendlyName) || a.name || "" : a.name || "";
3115
+ var bLabel = b.deliveryChannel === "pickup-in-point" ? ((_b_pickupStoreInfo = b.pickupStoreInfo) === null || _b_pickupStoreInfo === void 0 ? void 0 : _b_pickupStoreInfo.friendlyName) || b.name || "" : b.name || "";
3116
+ return aLabel.localeCompare(bLabel, "pt-BR");
3117
+ });
3118
+ var shippingTier = sortedTiers.map(function(sla) {
3119
+ var _sla_pickupStoreInfo;
3120
+ return sla.deliveryChannel === "pickup-in-point" ? "retirada em loja".concat(((_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : _sla_pickupStoreInfo.friendlyName) ? ": ".concat(sla.pickupStoreInfo.friendlyName) : "") : sla.deliveryChannel === "delivery" ? "receba em casa".concat(sla.name ? ": ".concat(sla.name) : "") : null;
3121
+ }).filter(Boolean).join(", ");
3122
+ return shippingTier || null;
3123
+ },
3124
+ transaction_id: function(context) {
3125
+ var _context_orderForm_orderGroup, _context_orderForm;
3126
+ return ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_orderGroup = _context_orderForm.orderGroup) === null || _context_orderForm_orderGroup === void 0 ? void 0 : _context_orderForm_orderGroup.toString()) || null;
3127
+ },
3128
+ coupon: function(context) {
3129
+ var _context_orderForm_marketingData, _context_orderForm;
3130
+ return context.appliedCoupon || (context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_marketingData = _context_orderForm.marketingData) === null || _context_orderForm_marketingData === void 0 ? void 0 : _context_orderForm_marketingData.coupon) || null;
3131
+ },
3132
+ seller_cod_name: function(context) {
3133
+ return context.appliedSellerCodName || (context === null || context === void 0 ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
3134
+ }
3135
+ });
2949
3136
  // src/formatter.ts
2950
3137
  var adapters = {
2951
3138
  DECO: decoAdapter,
2952
- HEADLESS: headlessAdapter
3139
+ HEADLESS: headlessAdapter,
3140
+ PICKUP: pickupAdapter,
3141
+ ORDERFORM: orderFormAdapter
3142
+ };
3143
+ // src/index.ts
3144
+ var config = {
3145
+ brand: "",
3146
+ currency: "BRL"
2953
3147
  };
2954
3148
  var src_default = {
2955
3149
  trackWebEvent: trackWebEvent,