define(['jquery','matchMedia','mage/mage','domReady!'],function($,mediaCheck){'use strict';let $body=$('body'),$html=$('html');if(!$body.hasClass('checkout-index-index')&&window?.ias_config?.headerSticky){$('.header-sticky-container').mage('stickyElement',{stickyContainerSelector:'header.page-header',bodyClass:'header-sticky',mobileOffsetTopSelector:'.header-sticky-container .header.content',mobileStickOnEnd:false,stickOnScrollUp:window.ias_config.headerStickyScrollUp});} $html.toggleClass('hover-allow',matchMedia('(pointer:fine)').matches);let $deferredContent=$('[data-content-type][data-defer-time]:not([data-defer-time=""]):not([data-defer-time="0"]), .defer-images-load.autoinit-widget');if($deferredContent.length){$deferredContent.mage('loadImages',{});} let deferImagesFooter=$('footer.page-footer .defer-images-load:not(.autoinit-widget)');if(deferImagesFooter.length){$('footer.page-footer').mage('loadImages',{"delay":3000});} $('.collapsible.autoinit-widget').mage('collapsible',{openedState:'active',scrollToTopIfVisible:false});$('.toggle-element').not('.collapsible').mage('collapsible',{content:'.toggle-content',trigger:'.toggle-trigger',openedState:'active',scrollToTopIfVisible:false});let headerManager={triggerItself:false,init:function(){this.bindMyAccount();this.bindSearch();this.bindMinicart();$body.on('ias.closeMyAccount',this.closeMyAccount.bind(this)).on('ias.closeMinicart',this.closeMinicart.bind(this)).on('ias.closeMegamenu',this.closeMegamenu.bind(this));},bindMyAccount:function(){$('#header-my-account').on('dropdowndialogopen',function(){if(!this.triggerItself){if(this.checkIsDesktop()){this.closeMegamenu();}else{if(!$('[data-role="my-account-trigger"]:visible').closest('.header-account-link').length){this.closeMegamenu();}}}}.bind(this));},bindSearch:function(){$('.modal-search [data-role=search-trigger], #search_mini_form').on('click',function(){if(!this.triggerItself){this.triggerItself=true;this.closeMegamenu();if(!this.checkIsDesktop()){this.closeMyAccount();this.closeMinicart() this.closeMegamenu();} this.triggerItself=false;}}.bind(this));},bindMinicart:function(){$('[data-block="minicart"]').on('dropdowndialogopen',function(){if(!this.triggerItself){this.closeMegamenu();}}.bind(this));},closeMyAccount:function(){if($('body').hasClass('my-account-active')){$('#header-my-account .toggle-active.active [data-role=trigger]').first().click();}},closeMinicart:function(){if($('body').hasClass('minicart-active')){$('[data-block="minicart"] .action.showcart').first().click();}},closeMegamenu:function(){if($('html').hasClass('nav-open')){$('[data-action="toggle-nav"]').first().click();} if($('body').hasClass('navigation-open')){$('.navigation .navigation-menu .active-menu').removeClass('active-menu');$('.navigation .navigation-menu .active-content').removeClass('active-content');}},checkIsDesktop:function(){return matchMedia("screen and (min-width:768px)").matches;}};let scrollbarChecker={scrollbarStaticClass:'scrollbar-static',scrollbarAbsoluteClass:'scrollbar-absolute',init:function(){let scrollbarAbsolute=this.checkScrollbarAbsolute();$html.removeClass(this.scrollbarStaticClass+' '+this.scrollbarAbsoluteClass).addClass((scrollbarAbsolute)?this.scrollbarAbsoluteClass:this.scrollbarStaticClass);},checkScrollbarAbsolute:function(){let $scrollBar=$('');$body.append($scrollBar);let result=$scrollBar.width()===$scrollBar.find('#scrollbar-checker-content').width();$scrollBar.remove();return result;}} scrollbarChecker.init();headerManager.init();});