'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const index = require('./index-da8257e2.js'); const privacyCookie = require('./privacyCookie-00b2977c.js'); const index$1 = require('./index-424e58a3.js'); const getPlaceholderUrl = require('./getPlaceholderUrl-fb4743cb.js'); const waitForHydrated = require('./waitForHydrated-d6cacbfb.js'); const api = require('./api-54551431.js'); const getTrackingData = (promotions, position) => { const last = position === -1; let slotPosition = last ? -1 : position + 1; // for last position we count from -1 down, for first we count from 1 up return promotions.map((promotion, i) => { var _a; return (Object.assign(Object.assign({}, promotion), { tracking: { id: (_a = promotion === null || promotion === void 0 ? void 0 : promotion.campaign) === null || _a === void 0 ? void 0 : _a.title, name: promotion === null || promotion === void 0 ? void 0 : promotion.headline, position: `slot${last ? slotPosition - i : slotPosition + i}`, } })); }); }; const setTrackingEventListeners = () => { Array.from(document.querySelectorAll(".js-ux-async-promotion-tracking")).forEach((element) => { try { const tracking = JSON.parse(element.getAttribute("data-tracking")); const url = element.getAttribute("href"); element.addEventListener("click", (e) => { e.preventDefault(); privacyCookie.isPrivacyCookieAccepted() .then(() => { window.ITdataLayer = window.ITdataLayer || []; window.ITdataLayer.push({ ecommerce: null }); window.ITdataLayer.push({ event: "promotionClick", ecommerce: { promoClick: { promotions: [tracking], }, }, eventCallback: function () { console.log("promotion click tracked"); document.location.href = url; }, }); }) .catch(() => { console.log("promotion tracking failed because cookie was not accepted"); document.location.href = url; }); }); } catch (e) { console.log("promotion tracking failed"); } }); }; const trackPromotionsShown = (promotionsTracking) => { window.ITdataLayer = window.ITdataLayer || []; window.ITdataLayer.push({ ecommerce: null }); window.ITdataLayer.push({ ecommerce: { promoView: { promotions: promotionsTracking, }, }, }); }; /** * Shuffles array in place. ES6 version * @param {Array} a items An array containing the items. */ function shuffle(a) { for (let i = a.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [a[i], a[j]] = [a[j], a[i]]; } return a; } function template(promotion) { const { image } = promotion.transformedProperties; return (`
${promotion.bodytext || ""}