const WRITE_KEY="35yFRuYNcrBF4M2r473RzQgKUdM",COLLECTOR_URL="https://events.eurovaistine.lt/v1/track";function getAnonymousId(){try{let e=localStorage.getItem("anonymousId");return e||(e="anon-"+Date.now()+"-"+Math.random().toString(16).slice(2),localStorage.setItem("anonymousId",e)),e}catch(e){return"anon-"+Date.now()+"-"+Math.random().toString(16).slice(2)}}function track(e,t){const o={anonymousId:getAnonymousId(),type:"track",channel:"web",event:e,properties:t||{},context:{userAgent:navigator.userAgent,locale:navigator.language,page:{path:location.pathname,url:location.href,title:document.title,referrer:document.referrer}},timestamp:(new Date).toISOString()};return fetch(COLLECTOR_URL,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Basic "+btoa(WRITE_KEY+":")},body:JSON.stringify(o)}).catch((e=>{console.warn("[Rudder] network error",e)}))}function getLastDataLayerEventByName(e){const t=window.dataLayer;if(!Array.isArray(t))return null;for(let o=t.length-1;o>=0;o--){const i=t[o];if(i&&i.event===e)return i}return null}function handleViewItem(e){if(!e)return;const t=e.ecommerce||{},o=t.items||[],i=o[0]||{};track("Product Viewed",{source:"Eshop_Frontend_JS",product_id:i.item_id,name:i.item_name,price:i.price,quantity:i.quantity,currency:t.currency,value:t.value,brand:i.item_brand??"",item_list_name:i.item_list_name??"",item_category:i.item_category??"",item_category2:i.item_category2??"",item_category3:i.item_category3??"",item_category4:i.item_category4??"",item_category5:i.item_category5??"",items:o})}function handleViewPromotion(e){if(!e)return;const t=e.ecommerce||{},o=t.items||[],i=o[0]||{};track("Promotion Viewed",{source:"Eshop_Frontend_JS",promotion_id:i.promotion_id||t.promotion_id,promotion_name:i.promotion_name||t.promotion_name,creative_name:i.creative_name,items:o})}function handleViewList(e){if(!e)return;const t=e.ecommerce||{},o=t.items||[];let i={};i=t.scopes?{source:"Eshop_Frontend_JS",item_list_name:t.item_list_name,category_identity:t.scopes.CategoryIdentity||"",category_label:t.scopes.CategoryLabel||"",items:o}:{source:"Eshop_Frontend_JS",item_list_name:t.item_list_name,search_term:t.search_term||"",items:o},track("view_list",i)}function handleAddToCart(e){if(!e)return;const t=e.ecommerce||{},o=t.items||[];track("add_to_cart",{source:"Eshop_Frontend_JS",value:t.value,items:o})}let viewItemTimer=null,viewPromotionTimer=null,sentViewItemForUrl=null,sentViewPromotionForUrl=null,sentaddToCarttForUrl=null,sentViewListForUrl=null,viewListTimer=null,addToCartTimer=null;function scheduleViewItemSend(){sentViewItemForUrl!==location.href&&(viewItemTimer&&clearTimeout(viewItemTimer),viewItemTimer=setTimeout((()=>{const e=getLastDataLayerEventByName("view_item");e&&sentViewItemForUrl!==location.href&&(sentViewItemForUrl=location.href,handleViewItem(e))}),150))}function scheduleViewPromotionSend(){sentViewPromotionForUrl!==location.href&&(viewPromotionTimer&&clearTimeout(viewPromotionTimer),viewPromotionTimer=setTimeout((()=>{const e=getLastDataLayerEventByName("view_promotion");e&&sentViewPromotionForUrl!==location.href&&(sentViewPromotionForUrl=location.href,handleViewPromotion(e))}),150))}function scheduleViewList(){sentViewListForUrl!==location.href&&(viewListTimer&&clearTimeout(viewListTimer),viewListTimer=setTimeout((()=>{const e=getLastDataLayerEventByName("luigisbox_view_item_list");e&&sentViewListForUrl!==location.href&&(sentViewListForUrl=location.href,handleViewList(e))}),150))}function scheduleAddToCart(){addToCartTimer&&clearTimeout(addToCartTimer),addToCartTimer=setTimeout((()=>{const e=getLastDataLayerEventByName("luigisbox_add_to_cart");e&&sentaddToCarttForUrl!==location.href&&(sentaddToCarttForUrl=location.href,handleAddToCart(e))}),150)}function processDataLayerEntry(e){e&&e.event&&("view_item"===e.event&&scheduleViewItemSend(),"view_promotion"===e.event&&scheduleViewPromotionSend(),"luigisbox_view_item_list"===e.event&&scheduleViewList(),"luigisbox_add_to_cart"===e.event&&scheduleAddToCart())}!function(){Array.isArray(window.dataLayer)||(window.dataLayer=[]),getLastDataLayerEventByName("view_item")&&scheduleViewItemSend(),getLastDataLayerEventByName("view_promotion")&&scheduleViewPromotionSend(),getLastDataLayerEventByName("luigisbox_view_item_list")&&scheduleViewList(),getLastDataLayerEventByName("luigisbox_add_to_cart")&&scheduleAddToCart();const e=window.dataLayer.push.bind(window.dataLayer);window.dataLayer.push=function(){for(let e=0;e