{"version":3,"file":"product_list.min.js","sources":["product_list.js"],"sourcesContent":["(($, w) => {\n const gtmImpressionsChunkSize = 30;\n const assetId = 'gtm-eec-prod-list';\n\n let userInfo = null;\n if (w.umwAssets && w.umwAssets[assetId] && w.umwAssets[assetId].length) {\n userInfo = w.umwAssets[assetId][0];\n }\n\n w.PubSub.subscribe('externaltracking.product.listview', (_, productImpressions) => {\n if (productImpressions && productImpressions.items && productImpressions.items.length > 0) {\n processImpressions(productImpressions);\n }\n });\n\n function processImpressions(productListImpressions) {\n const listName = productListImpressions.listName || document.title;\n const allProducts = productListImpressions.items;\n const totalProductsCount = allProducts.length;\n var $allProductLinks = $(); \n var idx = 0, chunkIdx = 0;\n const utils = new GtmUtils();\n const currencyCode = utils.getCurrencyCode(productListImpressions);\n while (idx < totalProductsCount) {\n const positionShift = chunkIdx * gtmImpressionsChunkSize;\n\n const products = allProducts.slice(idx, idx += gtmImpressionsChunkSize);\n const gtmProducts = [];\n\n for (var i = 0, l = products.length; i < l; i++) {\n const prod = products[i];\n const positionInList = positionShift + i + 1;\n const gtmProd = utils.convertToGtmEecProduct(prod, { 'list': listName, 'position': positionInList });\n if (gtmProd) {\n gtmProducts.push(gtmProd);\n\n if (prod.$links) {\n prod.$links.data('gtm-product', gtmProd);\n prod.$links.data('listname', listName);\n prod.$links.data('currencycode', currencyCode);\n\n $allProductLinks = $allProductLinks.add(prod.$links);\n }\n }\n }\n\n const impressionViewEvent = {\n 'event': 'eec.impressionView',\n 'ecommerce': {\n 'currencyCode': currencyCode,\n 'impressions': gtmProducts\n }\n };\n \n if (userInfo) {\n impressionViewEvent.user = userInfo;\n }\n\n w.dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object.\n w.dataLayer.push(impressionViewEvent);\n\n ++chunkIdx;\n }\n\n if ($allProductLinks.length > 0) {\n $allProductLinks.on('click', function (evt) {\n try {\n var targetUrl = this.href;\n const $this = $(this);\n\n const productClickEvent = {\n 'event': 'eec.productClick',\n 'ecommerce': {\n 'currencyCode': $this.data('currencycode') || utils.getCurrencyCode(),\n 'click': {\n 'actionField': { 'list': $this.data('listname') },\n 'products': [$this.data('gtm-product')]\n }\n },\n 'eventCallback': function () {\n document.location = targetUrl;\n }\n };\n\n w.dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object.\n w.dataLayer.push(productClickEvent);\n\n evt.preventDefault();\n } catch (e) {\n console.error('[GTM]: Failed to push product click event to dataLayer. Reason: ' + e);\n }\n });\n }\n }\n})(jQuery, window);"],"names":["$","w","assetId","let","userInfo","umwAssets","length","PubSub","subscribe","_","productImpressions","items","processImpressions","listName","productListImpressions","document","title","allProducts","totalProductsCount","$allProductLinks","idx","chunkIdx","utils","GtmUtils","currencyCode","getCurrencyCode","positionShift","products","slice","gtmProducts","i","l","prod","positionInList","gtmProd","convertToGtmEecProduct","list","position","push","$links","data","add","impressionViewEvent","event","ecommerce","impressions","user","dataLayer","on","evt","targetUrl","this","href","$this","productClickEvent","click","actionField","eventCallback","location","preventDefault","e","console","error","jQuery","window"],"mappings":"CAAA,CAAEA,EAAGC,KAED,IAAMC,EAAU,oBAEhBC,IAAIC,EAAW,KACXH,EAAEI,WAAaJ,EAAEI,UAAUH,IAAYD,EAAEI,UAAUH,GAASI,SAC5DF,EAAWH,EAAEI,UAAUH,GAAS,IAGpCD,EAAEM,OAAOC,UAAU,oCAAqC,CAACC,EAAGC,KACxD,GAAIA,GAAsBA,EAAmBC,OAA2C,EAAlCD,EAAmBC,MAAML,OAC3EM,CAKJ,IAAMC,EAAWC,EAAuBD,UAAYE,SAASC,MACvDC,EAAcH,EAAuBH,MACrCO,EAAqBD,EAAYX,OACvC,IAAIa,EAAmBnB,EAAE,EACrBoB,EAAM,EAAGC,EAAW,EACxB,MAAMC,EAAQ,IAAIC,SACZC,EAAeF,EAAMG,gBAAgBX,CAAsB,EACjE,KAAOM,EAAMF,GAAoB,CAM7B,IALA,IAAMQ,EAvBkB,GAuBFL,EAEhBM,EAAWV,EAAYW,MAAMR,EAAKA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