@azzas/azzas-tracker-web 2.0.0-preview.0 → 2.0.0-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.
@@ -1326,7 +1326,7 @@ var AzzasTracker = function() {
1326
1326
  2
1327
1327
  ];
1328
1328
  currentAdapter = context.adapter;
1329
- getters = (_adapters_currentAdapter = adapters[currentAdapter]) !== null && _adapters_currentAdapter !== void 0 ? _adapters_currentAdapter : paramGetters;
1329
+ getters = (_adapters_currentAdapter = adapters[currentAdapter]) !== null && _adapters_currentAdapter !== void 0 ? _adapters_currentAdapter : legacyGetters;
1330
1330
  return [
1331
1331
  4,
1332
1332
  Promise.all(eventConfig.requiredParams.map(function(param) {
@@ -1897,6 +1897,33 @@ var AzzasTracker = function() {
1897
1897
  "size",
1898
1898
  "item_ref"
1899
1899
  ]
1900
+ },
1901
+ REFINE_RESULTS: {
1902
+ name: "refine_results",
1903
+ hasEcommerce: false,
1904
+ destinations: [
1905
+ "DataLayer"
1906
+ ],
1907
+ requiredParams: [
1908
+ "brand",
1909
+ "region",
1910
+ "color",
1911
+ "price_range",
1912
+ "size",
1913
+ "category",
1914
+ "ordering"
1915
+ ]
1916
+ },
1917
+ GRID_SIZE: {
1918
+ name: "grid_size",
1919
+ hasEcommerce: false,
1920
+ destinations: [
1921
+ "DataLayer"
1922
+ ],
1923
+ requiredParams: [
1924
+ "brand",
1925
+ "slot_per_line"
1926
+ ]
1900
1927
  }
1901
1928
  };
1902
1929
  var BRAND_CODES = {
@@ -2108,7 +2135,7 @@ var AzzasTracker = function() {
2108
2135
  }
2109
2136
  };
2110
2137
  // src/params/legacy/index.ts
2111
- var paramGetters = {
2138
+ var legacyGetters = {
2112
2139
  brand: getBrand,
2113
2140
  items: getItems,
2114
2141
  payment_type: getPaymentType,
@@ -2372,8 +2399,7 @@ var AzzasTracker = function() {
2372
2399
  return context.meta.brand || null;
2373
2400
  },
2374
2401
  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;
2402
+ return context.meta.content_type || null;
2377
2403
  },
2378
2404
  region: function(context) {
2379
2405
  return context.meta.region || null;
@@ -2385,14 +2411,18 @@ var AzzasTracker = function() {
2385
2411
  if (context === null || context === void 0 ? void 0 : context.currency) return context.currency;
2386
2412
  return "BRL";
2387
2413
  },
2414
+ slot_per_line: function(context) {
2415
+ var _context_meta_slot_per_line;
2416
+ 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;
2417
+ },
2388
2418
  search_term: function(context) {
2389
- return context.searchTerm || null;
2419
+ return context.meta.search_term || null;
2390
2420
  },
2391
2421
  search_found: function(context) {
2392
- return !!context.searchFound;
2422
+ return context.meta.search_found || null;
2393
2423
  },
2394
2424
  search_quantity: function(context) {
2395
- return context.searchQuantity || 0;
2425
+ return context.meta.search_quantity || 0;
2396
2426
  },
2397
2427
  promotion_name: function(context) {
2398
2428
  return context.meta.promotion_name || null;
@@ -2403,9 +2433,6 @@ var AzzasTracker = function() {
2403
2433
  creative_slot: function(context) {
2404
2434
  return context.meta.creative_slot || null;
2405
2435
  },
2406
- zipcode: function(context) {
2407
- return context.zipCode || null;
2408
- },
2409
2436
  size: function(context) {
2410
2437
  return context.size || null;
2411
2438
  },
@@ -2417,8 +2444,144 @@ var AzzasTracker = function() {
2417
2444
  },
2418
2445
  type: function(context) {
2419
2446
  return context.type || null;
2447
+ },
2448
+ color: function(context) {
2449
+ return context.meta.color || null;
2450
+ },
2451
+ price_range: function(context) {
2452
+ return context.meta.price_range || null;
2453
+ },
2454
+ category: function(context) {
2455
+ return context.meta.category || null;
2456
+ },
2457
+ ordering: function(context) {
2458
+ return context.meta.ordering || null;
2420
2459
  }
2421
2460
  };
2461
+ // src/params/adapters/deco/utils.ts
2462
+ var getItemCategory3 = function(item) {
2463
+ var _text_match;
2464
+ var value = item === null || item === void 0 ? void 0 : item.category;
2465
+ if (!value) return "Cole\xE7\xE3o";
2466
+ var text = Array.isArray(value) ? value.join(" ") : String(value);
2467
+ var match = (_text_match = text.match(/outlet|bazar|sale/i)) === null || _text_match === void 0 ? void 0 : _text_match[0].toLowerCase();
2468
+ return match !== null && match !== void 0 ? match : "Cole\xE7\xE3o";
2469
+ };
2470
+ var getItemCategory22 = function(item) {
2471
+ var _ref, _categories_, _validHierarchy_;
2472
+ var _item_category;
2473
+ var AVOID_CATEGORIES = /^(outlet|bazar|sale)$/i;
2474
+ var categories = (_ref = (_item_category = item.category) === null || _item_category === void 0 ? void 0 : _item_category.split(">")) !== null && _ref !== void 0 ? _ref : [];
2475
+ var last = (_categories_ = categories[categories.length - 1]) !== null && _categories_ !== void 0 ? _categories_ : "";
2476
+ var validHierarchy = last.split("/").filter(function(c) {
2477
+ return c && !AVOID_CATEGORIES.test(c);
2478
+ });
2479
+ var deepest = (_validHierarchy_ = validHierarchy[validHierarchy.length - 1]) !== null && _validHierarchy_ !== void 0 ? _validHierarchy_ : "";
2480
+ return capitalize(deepest);
2481
+ };
2482
+ var resizeVtexImage2 = function(url) {
2483
+ var width = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 500, height = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 500;
2484
+ return url === null || url === void 0 ? void 0 : url.replace(/(\/arquivos\/ids\/\d+)-\d+-\d+\//, "$1-".concat(width, "-").concat(height, "/"));
2485
+ };
2486
+ // src/params/adapters/deco/index.ts
2487
+ var IN_STOCK_SCHEMA = "https://schema.org/InStock";
2488
+ var LIST_PRICE_SCHEMA = "https://schema.org/ListPrice";
2489
+ var decoAdapter = _object_spread_props(_object_spread({}, metaAdapters), {
2490
+ // global adapters
2491
+ items: function(context) {
2492
+ if (context === null || context === void 0 ? void 0 : context.items) return context.items;
2493
+ if (context === null || context === void 0 ? void 0 : context.products) {
2494
+ return context.products.map(function(item) {
2495
+ var _ref, _ref1, _item_alternateName, _ref2, _ref3, _ref4, _getItemCategory3, _getItemCategory22, _ref5, _item_sku, _item_url, _resizeVtexImage2, _ref6, _ref7;
2496
+ 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;
2497
+ var COLOR_REGEX = /^[^_]+_/;
2498
+ 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) {
2499
+ return s.priceType === LIST_PRICE_SCHEMA;
2500
+ })) === null || _item_offers_offers__priceSpecification_find === void 0 ? void 0 : _item_offers_offers__priceSpecification_find.price;
2501
+ return {
2502
+ quantity: 1,
2503
+ index: (_ref = item === null || item === void 0 ? void 0 : item.index) !== null && _ref !== void 0 ? _ref : 0,
2504
+ 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,
2505
+ item_name: (_item_alternateName = item.alternateName) !== null && _item_alternateName !== void 0 ? _item_alternateName : null,
2506
+ price: (_ref2 = (_item_offers1 = item.offers) === null || _item_offers1 === void 0 ? void 0 : _item_offers1.lowPrice) !== null && _ref2 !== void 0 ? _ref2 : null,
2507
+ 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),
2508
+ 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,
2509
+ // cor
2510
+ 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,
2511
+ // tamanho
2512
+ item_shipping_tier: getItemShippingTier2(),
2513
+ item_ref: (_ref4 = (_item_additionalProperty = item.additionalProperty) === null || _item_additionalProperty === void 0 ? void 0 : (_item_additionalProperty_find = _item_additionalProperty.find(function(i) {
2514
+ return i.name === "RefId";
2515
+ })) === null || _item_additionalProperty_find === void 0 ? void 0 : _item_additionalProperty_find.value) !== null && _ref4 !== void 0 ? _ref4 : null,
2516
+ item_category: (_getItemCategory3 = getItemCategory3(item)) !== null && _getItemCategory3 !== void 0 ? _getItemCategory3 : null,
2517
+ item_category2: (_getItemCategory22 = getItemCategory22(item)) !== null && _getItemCategory22 !== void 0 ? _getItemCategory22 : null,
2518
+ item_id: (_ref5 = item === null || item === void 0 ? void 0 : item.inProductGroupWithID) !== null && _ref5 !== void 0 ? _ref5 : null,
2519
+ item_sku: (_item_sku = item.sku) !== null && _item_sku !== void 0 ? _item_sku : null,
2520
+ item_url: (_item_url = item.url) !== null && _item_url !== void 0 ? _item_url : null,
2521
+ 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,
2522
+ seller_id: (_ref6 = (_item_offers3 = item.offers) === null || _item_offers3 === void 0 ? void 0 : (_item_offers_offers1 = _item_offers3.offers) === null || _item_offers_offers1 === void 0 ? void 0 : (_item_offers_offers_ = _item_offers_offers1[0]) === null || _item_offers_offers_ === void 0 ? void 0 : _item_offers_offers_.seller) !== null && _ref6 !== void 0 ? _ref6 : null,
2523
+ item_list_name: (_ref7 = item === null || item === void 0 ? void 0 : item.item_list_name) !== null && _ref7 !== void 0 ? _ref7 : null
2524
+ };
2525
+ });
2526
+ }
2527
+ return null;
2528
+ },
2529
+ // brand: (context: DecoBrandContext) => {
2530
+ // if (context?.brand) return context.brand
2531
+ // if (context?.products) {
2532
+ // return context.products[0].brand?.name // tem que ajustar FARM por conta de FARM_ETC
2533
+ // }
2534
+ // return null
2535
+ // },
2536
+ line_items: function(context) {
2537
+ if (context === null || context === void 0 ? void 0 : context.line_items) return context.line_items;
2538
+ if (context === null || context === void 0 ? void 0 : context.products) {
2539
+ return context.products.map(function(item) {
2540
+ return item === null || item === void 0 ? void 0 : item.inProductGroupWithID;
2541
+ }).filter(function(id) {
2542
+ return Boolean(id);
2543
+ });
2544
+ }
2545
+ return null;
2546
+ },
2547
+ value: function(context) {
2548
+ if (context === null || context === void 0 ? void 0 : context.value) return context.value;
2549
+ if (context === null || context === void 0 ? void 0 : context.products) {
2550
+ return context.products.map(function(item) {
2551
+ var _item_offers;
2552
+ return (_item_offers = item.offers) === null || _item_offers === void 0 ? void 0 : _item_offers.lowPrice;
2553
+ }).filter(function(price) {
2554
+ return price !== void 0;
2555
+ }).reduce(function(sum, price) {
2556
+ return sum + price;
2557
+ }, 0);
2558
+ }
2559
+ return null;
2560
+ },
2561
+ available_grid: function(context) {
2562
+ if (context === null || context === void 0 ? void 0 : context.available_grid) return context.available_grid;
2563
+ if (context === null || context === void 0 ? void 0 : context.products) {
2564
+ var sizes = context.products.flatMap(function(product) {
2565
+ var _ref;
2566
+ var _product_isVariantOf_hasVariant, _product_isVariantOf;
2567
+ return (_ref = (_product_isVariantOf = product.isVariantOf) === null || _product_isVariantOf === void 0 ? void 0 : (_product_isVariantOf_hasVariant = _product_isVariantOf.hasVariant) === null || _product_isVariantOf_hasVariant === void 0 ? void 0 : _product_isVariantOf_hasVariant.filter(function(variant) {
2568
+ var _variant_offers_offers, _variant_offers;
2569
+ return (_variant_offers = variant.offers) === null || _variant_offers === void 0 ? void 0 : (_variant_offers_offers = _variant_offers.offers) === null || _variant_offers_offers === void 0 ? void 0 : _variant_offers_offers.some(function(o) {
2570
+ return o.availability === IN_STOCK_SCHEMA;
2571
+ });
2572
+ }).map(function(variant) {
2573
+ var _variant_name;
2574
+ return (_variant_name = variant.name) === null || _variant_name === void 0 ? void 0 : _variant_name.split(" - ")[1];
2575
+ }).filter(function(name) {
2576
+ return Boolean(name);
2577
+ })) !== null && _ref !== void 0 ? _ref : [];
2578
+ });
2579
+ var result = sortSizes(sizes).join(",").trim();
2580
+ return result || null;
2581
+ }
2582
+ return null;
2583
+ }
2584
+ });
2422
2585
  // src/params/adapters/orderForm/index.ts
2423
2586
  var orderFormAdapters = {
2424
2587
  // orderform
@@ -2597,131 +2760,7 @@ var AzzasTracker = function() {
2597
2760
  return context.appliedSellerCodName || (context === null || context === void 0 ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
2598
2761
  }
2599
2762
  };
2600
- // src/params/adapters/deco/utils/index.ts
2601
- var getItemCategory3 = function(item) {
2602
- var _text_match;
2603
- var value = item === null || item === void 0 ? void 0 : item.category;
2604
- if (!value) return "Cole\xE7\xE3o";
2605
- var text = Array.isArray(value) ? value.join(" ") : String(value);
2606
- var match = (_text_match = text.match(/outlet|bazar|sale/i)) === null || _text_match === void 0 ? void 0 : _text_match[0].toLowerCase();
2607
- return match !== null && match !== void 0 ? match : "Cole\xE7\xE3o";
2608
- };
2609
- var getItemCategory22 = function(item) {
2610
- var _ref, _categories_, _validHierarchy_;
2611
- var _item_category;
2612
- var AVOID_CATEGORIES = /^(outlet|bazar|sale)$/i;
2613
- var categories = (_ref = (_item_category = item.category) === null || _item_category === void 0 ? void 0 : _item_category.split(">")) !== null && _ref !== void 0 ? _ref : [];
2614
- var last = (_categories_ = categories[categories.length - 1]) !== null && _categories_ !== void 0 ? _categories_ : "";
2615
- var validHierarchy = last.split("/").filter(function(c) {
2616
- return c && !AVOID_CATEGORIES.test(c);
2617
- });
2618
- var deepest = (_validHierarchy_ = validHierarchy[validHierarchy.length - 1]) !== null && _validHierarchy_ !== void 0 ? _validHierarchy_ : "";
2619
- return capitalize(deepest);
2620
- };
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
- // src/params/adapters/deco/index.ts
2626
- var IN_STOCK_SCHEMA = "https://schema.org/InStock";
2627
- var LIST_PRICE_SCHEMA = "https://schema.org/ListPrice";
2628
- var decoAdapter = _object_spread_props(_object_spread({}, metaAdapters, orderFormAdapters), {
2629
- // orderform adapters
2630
- items: function(context) {
2631
- if (context === null || context === void 0 ? void 0 : context.items) return context.items;
2632
- if (context === null || context === void 0 ? void 0 : context.products) {
2633
- return context.products.map(function(item) {
2634
- 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;
2636
- var COLOR_REGEX = /^[^_]+_/;
2637
- 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
- return s.priceType === LIST_PRICE_SCHEMA;
2639
- })) === null || _item_offers_offers__priceSpecification_find === void 0 ? void 0 : _item_offers_offers__priceSpecification_find.price;
2640
- return {
2641
- quantity: 1,
2642
- index: (_ref = item === null || item === void 0 ? void 0 : item.index) !== null && _ref !== void 0 ? _ref : 0,
2643
- 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
- item_name: (_item_alternateName = item.alternateName) !== null && _item_alternateName !== void 0 ? _item_alternateName : null,
2645
- 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),
2647
- 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
- // cor
2649
- 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
- // tamanho
2651
- item_shipping_tier: getItemShippingTier2(),
2652
- item_ref: (_ref4 = (_item_additionalProperty = item.additionalProperty) === null || _item_additionalProperty === void 0 ? void 0 : (_item_additionalProperty_find = _item_additionalProperty.find(function(i) {
2653
- return i.name === "RefId";
2654
- })) === null || _item_additionalProperty_find === void 0 ? void 0 : _item_additionalProperty_find.value) !== null && _ref4 !== void 0 ? _ref4 : null,
2655
- item_category: (_getItemCategory3 = getItemCategory3(item)) !== null && _getItemCategory3 !== void 0 ? _getItemCategory3 : null,
2656
- item_category2: (_getItemCategory22 = getItemCategory22(item)) !== null && _getItemCategory22 !== void 0 ? _getItemCategory22 : null,
2657
- item_id: (_ref5 = item === null || item === void 0 ? void 0 : item.inProductGroupWithID) !== null && _ref5 !== void 0 ? _ref5 : null,
2658
- item_sku: (_item_sku = item.sku) !== null && _item_sku !== void 0 ? _item_sku : null,
2659
- item_url: (_item_url = item.url) !== null && _item_url !== void 0 ? _item_url : null,
2660
- 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,
2661
- seller_id: (_ref6 = (_item_offers3 = item.offers) === null || _item_offers3 === void 0 ? void 0 : (_item_offers_offers1 = _item_offers3.offers) === null || _item_offers_offers1 === void 0 ? void 0 : (_item_offers_offers_ = _item_offers_offers1[0]) === null || _item_offers_offers_ === void 0 ? void 0 : _item_offers_offers_.seller) !== null && _ref6 !== void 0 ? _ref6 : null,
2662
- item_list_name: (_ref7 = item === null || item === void 0 ? void 0 : item.item_list_name) !== null && _ref7 !== void 0 ? _ref7 : null
2663
- };
2664
- });
2665
- }
2666
- return null;
2667
- },
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
- // },
2675
- line_items: function(context) {
2676
- if (context === null || context === void 0 ? void 0 : context.line_items) return context.line_items;
2677
- if (context === null || context === void 0 ? void 0 : context.products) {
2678
- return context.products.map(function(item) {
2679
- return item === null || item === void 0 ? void 0 : item.inProductGroupWithID;
2680
- }).filter(function(id) {
2681
- return Boolean(id);
2682
- });
2683
- }
2684
- return null;
2685
- },
2686
- value: function(context) {
2687
- if (context === null || context === void 0 ? void 0 : context.value) return context.value;
2688
- if (context === null || context === void 0 ? void 0 : context.products) {
2689
- return context.products.map(function(item) {
2690
- var _item_offers;
2691
- return (_item_offers = item.offers) === null || _item_offers === void 0 ? void 0 : _item_offers.lowPrice;
2692
- }).filter(function(price) {
2693
- return price !== void 0;
2694
- }).reduce(function(sum, price) {
2695
- return sum + price;
2696
- }, 0);
2697
- }
2698
- return null;
2699
- },
2700
- available_grid: function(context) {
2701
- if (context === null || context === void 0 ? void 0 : context.available_grid) return context.available_grid;
2702
- if (context === null || context === void 0 ? void 0 : context.products) {
2703
- var sizes = context.products.flatMap(function(product) {
2704
- var _ref;
2705
- var _product_isVariantOf_hasVariant, _product_isVariantOf;
2706
- return (_ref = (_product_isVariantOf = product.isVariantOf) === null || _product_isVariantOf === void 0 ? void 0 : (_product_isVariantOf_hasVariant = _product_isVariantOf.hasVariant) === null || _product_isVariantOf_hasVariant === void 0 ? void 0 : _product_isVariantOf_hasVariant.filter(function(variant) {
2707
- var _variant_offers_offers, _variant_offers;
2708
- return (_variant_offers = variant.offers) === null || _variant_offers === void 0 ? void 0 : (_variant_offers_offers = _variant_offers.offers) === null || _variant_offers_offers === void 0 ? void 0 : _variant_offers_offers.some(function(o) {
2709
- return o.availability === IN_STOCK_SCHEMA;
2710
- });
2711
- }).map(function(variant) {
2712
- var _variant_name;
2713
- return (_variant_name = variant.name) === null || _variant_name === void 0 ? void 0 : _variant_name.split(" - ")[1];
2714
- }).filter(function(name) {
2715
- return Boolean(name);
2716
- })) !== null && _ref !== void 0 ? _ref : [];
2717
- });
2718
- var result = sortSizes(sizes).join(",").trim();
2719
- return result || null;
2720
- }
2721
- return null;
2722
- }
2723
- });
2724
- // src/params/adapters/headless/utils/index.ts
2763
+ // src/params/adapters/headless/utils.ts
2725
2764
  var getItemCategory5 = function(item) {
2726
2765
  var keywords = [
2727
2766
  "outlet",
@@ -2946,10 +2985,52 @@ var AzzasTracker = function() {
2946
2985
  return null;
2947
2986
  }
2948
2987
  });
2988
+ // src/params/adapters/pickup/utils.ts
2989
+ var getShippingTier = function(sla) {
2990
+ var isPickup = sla.deliveryChannel === "pickup-in-point" /* PickupInPoint */ ;
2991
+ if (isPickup) {
2992
+ var _sla_pickupStoreInfo_friendlyName, _sla_pickupStoreInfo;
2993
+ 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();
2994
+ return storeName ? "retirada em loja: ".concat(storeName) : "retirada em loja";
2995
+ }
2996
+ return sla.name ? "receba em casa: ".concat(sla.name.toLowerCase()) : "receba em casa";
2997
+ };
2998
+ var getDeliveryTime = function(sla) {
2999
+ var estimate = sla.shippingEstimate;
3000
+ if (!estimate) return 0;
3001
+ var days = parseInt(estimate, 10);
3002
+ return isNaN(days) ? 0 : days;
3003
+ };
3004
+ // src/params/adapters/pickup/index.ts
3005
+ var pickupAdapter = _object_spread_props(_object_spread({}, metaAdapters), {
3006
+ flag_pickup: function(context) {
3007
+ var _ref;
3008
+ return (_ref = context === null || context === void 0 ? void 0 : context.flag_pickup) !== null && _ref !== void 0 ? _ref : null;
3009
+ },
3010
+ shippings: function(context) {
3011
+ if (context.shippings) {
3012
+ return context.shippings.map(function(s) {
3013
+ var _s_line_items, _s_price;
3014
+ return {
3015
+ line_items: (_s_line_items = s.line_items) !== null && _s_line_items !== void 0 ? _s_line_items : "",
3016
+ shipping: (_s_price = s.price) !== null && _s_price !== void 0 ? _s_price : 0,
3017
+ shipping_tier: getShippingTier(s),
3018
+ delivery_time: getDeliveryTime(s)
3019
+ };
3020
+ });
3021
+ }
3022
+ return null;
3023
+ },
3024
+ zipcode: function(context) {
3025
+ var _context_zipcode;
3026
+ return (_context_zipcode = context.zipcode) !== null && _context_zipcode !== void 0 ? _context_zipcode : null;
3027
+ }
3028
+ });
2949
3029
  // src/formatter.ts
2950
3030
  var adapters = {
2951
3031
  DECO: decoAdapter,
2952
- HEADLESS: headlessAdapter
3032
+ HEADLESS: headlessAdapter,
3033
+ PICKUP: pickupAdapter
2953
3034
  };
2954
3035
  var src_default = {
2955
3036
  trackWebEvent: trackWebEvent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azzas/azzas-tracker-web",
3
- "version": "2.0.0-preview.0",
3
+ "version": "2.0.0-preview.1",
4
4
  "type": "module",
5
5
  "main": "./dist/mod.cjs",
6
6
  "module": "./dist/mod.js",