define(['jquery','underscore','Magento_Customer/js/model/authentication-popup','Magento_Customer/js/customer-data','nostojs','mage/translate','domReady!'],function($,_,authenticationPopup,customerData,nostojs,$t){'use strict';var htmlBody=$("body[data-container='body']");if($(".customer-welcome").length){htmlBody.addClass("customer-logged-in");}else{htmlBody.addClass("customer-logged-out");};$(document).on('click','.yotpo-login-link',function(e){e.preventDefault();authenticationPopup.showModal();});var cart=customerData.get('cart');var oldItems=undefined;var newtems=undefined;cart.subscribe(function(oldCart){if(!_.isUndefined(oldCart['items']&&oldItems==undefined)){let items=oldCart['items'];oldItems=items.map(a=>a.item_id);}else if(oldItems==undefined){let dsCart=localStorage.getItem('ds-cart');if(typeof dsCart!=='undefined'&&dsCart!=='{}'){let oldCart=JSON.parse(dsCart);if(!_.isEmpty(oldCart)){let items=oldCart.cart.items;oldItems=items.map(a=>a.item_id);}}}},this,"beforeChange");cart.subscribe(function(updatedCart){if(!_.isUndefined(updatedCart['items'])){let items=updatedCart['items'];newtems=items.map(a=>a.item_id);if(oldItems!=undefined&&newtems.sort().join(',')!==oldItems.sort().join(',')&&typeof nostojs==='function'){nostojs(function(api){api.createRecommendationRequest().setElements(['test-minicart']);});}}});$(".navigation .parent").on({mouseenter:function(){var $this=$(this),timer=$this.data("timer")||0;clearTimeout(timer);$this.addClass("hover-active");$this.data("timer",timer);},mouseleave:function(){var $this=$(this),timer=$this.data("timer")||0;clearTimeout(timer);timer=setTimeout(function(){$this.removeClass("hover-active");},300);$this.data("timer",timer);}});const scrollable=document.querySelector('.scrollable-links');if(!scrollable)return;const itemsContainer=scrollable.querySelector('[data-content-type="buttons"]');if(!itemsContainer)return;const scrollStep=150;const arrowPrev=document.createElement('button');arrowPrev.innerHTML='Prev';arrowPrev.className='scroll-arrow scroll-arrow--prev';const arrowNext=document.createElement('button');arrowNext.innerHTML='Next';arrowNext.className='scroll-arrow scroll-arrow--next';scrollable.appendChild(arrowPrev);scrollable.appendChild(arrowNext);function updateArrowState(){const maxScrollLeft=itemsContainer.scrollWidth-itemsContainer.clientWidth;if(itemsContainer.scrollLeft<=0){arrowPrev.classList.add('disabled');}else{arrowPrev.classList.remove('disabled');}
if(itemsContainer.scrollLeft>=maxScrollLeft-1){arrowNext.classList.add('disabled');}else{arrowNext.classList.remove('disabled');}}
arrowPrev.addEventListener('click',()=>{itemsContainer.scrollLeft-=scrollStep;setTimeout(updateArrowState,100);});arrowNext.addEventListener('click',()=>{itemsContainer.scrollLeft+=scrollStep;setTimeout(updateArrowState,100);});let isDown=false;let startX;let scrollLeft;let isDragging=false;itemsContainer.style.overflowX='auto';itemsContainer.style.scrollBehavior='smooth';itemsContainer.style.cursor='grab';itemsContainer.addEventListener('mousedown',(e)=>{isDown=true;isDragging=false;startX=e.pageX-itemsContainer.offsetLeft;scrollLeft=itemsContainer.scrollLeft;itemsContainer.style.cursor='grabbing';});itemsContainer.addEventListener('mouseleave',()=>{isDown=false;itemsContainer.style.cursor='grab';});itemsContainer.addEventListener('mouseup',()=>{isDown=false;itemsContainer.style.cursor='grab';setTimeout(()=>{isDragging=false;},0);});itemsContainer.addEventListener('mousemove',(e)=>{if(!isDown)return;e.preventDefault();const x=e.pageX-itemsContainer.offsetLeft;const walk=x-startX;if(Math.abs(walk)>5)isDragging=true;itemsContainer.scrollLeft=scrollLeft-walk;requestAnimationFrame(updateArrowState);});let isTouchDragging=false;itemsContainer.addEventListener('touchstart',(e)=>{isTouchDragging=false;startX=e.touches[0].pageX;scrollLeft=itemsContainer.scrollLeft;},{passive:true});itemsContainer.addEventListener('touchmove',(e)=>{const x=e.touches[0].pageX;const walk=x-startX;if(Math.abs(walk)>10)isTouchDragging=true;itemsContainer.scrollLeft=scrollLeft-walk;requestAnimationFrame(updateArrowState);},{passive:true});itemsContainer.addEventListener('click',(e)=>{if(isDragging||isTouchDragging){e.preventDefault();e.stopPropagation();}});updateArrowState();let resizeTimeout;window.addEventListener('resize',()=>{clearTimeout(resizeTimeout);resizeTimeout=setTimeout(updateArrowState,100);});});