{"version":3,"file":"MegaMenu.min.js","sources":["MegaMenu.js"],"sourcesContent":["(function (w) {\r\n const assetId = '~/theme/v1/Views/Menu/MegaMenu.min.js';\r\n\r\n if (!w.umwAssets || !w.umwAssets[assetId]) {\r\n console.error('No context found for ' + assetId);\r\n return;\r\n }\r\n\r\n w.umwAssets[assetId].forEach(ctx => {\r\n const prefixClass = \"uc203-full-width\";\r\n const classes = {\r\n control: \"js-\" + prefixClass,\r\n lvl1Item: \"js-\" + prefixClass + \"-lvl1-item\",\r\n popup: prefixClass + \"-popup\",\r\n lvl1ItemHovered: prefixClass + \"-lvl1-item-hovered\",\r\n };\r\n\r\n const desktopHeaderContainer = document.querySelector('.site-header-desktop');\r\n const control = document.querySelector(\".\" + classes.control);\r\n if (!control) return; // Exit if control is not found\r\n\r\n let hoverTimerId;\r\n\r\n // Using event delegation for mouseenter and mouseleave\r\n control.addEventListener(\"mouseenter\", handleMouseOver, true);\r\n control.addEventListener(\"mouseleave\", handleMouseOut, true);\r\n\r\n function handleMouseOver(e) {\r\n if (!e.target.matches(\".\" + classes.lvl1Item)) return;\r\n\r\n const beforeMegaMenuLvl1Mouseenter = new CustomEvent(\"megamenu:lvl1:beforemouseenter\");\r\n control.dispatchEvent(beforeMegaMenuLvl1Mouseenter);\r\n if (beforeMegaMenuLvl1Mouseenter.defaultPrevented) return;\r\n\r\n clearTimeout(hoverTimerId);\r\n hoverTimerId = setTimeout(() => applyHoverState(e.target), 250);\r\n }\r\n\r\n function handleMouseOut(e) {\r\n if (!e.target.matches(\".\" + classes.lvl1Item)) return;\r\n\r\n const beforeMegaMenuLvl1Mouseleave = new CustomEvent(\"megamenu:lvl1:beforemouseleave\");\r\n control.dispatchEvent(beforeMegaMenuLvl1Mouseleave);\r\n if (beforeMegaMenuLvl1Mouseleave.defaultPrevented) return;\r\n\r\n clearTimeout(hoverTimerId);\r\n hoverTimerId = setTimeout(removeHoverState, 250);\r\n }\r\n\r\n function applyHoverState(target) {\r\n control.querySelectorAll(\".\" + classes.lvl1Item).forEach(item => item.classList.remove(classes.lvl1ItemHovered));\r\n target.classList.add(classes.lvl1ItemHovered);\r\n adjustPopupIfNecessary(target);\r\n }\r\n\r\n function removeHoverState() {\r\n control.querySelectorAll(\".\" + classes.lvl1Item).forEach(item => item.classList.remove(classes.lvl1ItemHovered));\r\n document.body.classList.remove('uc203-hovered');\r\n }\r\n\r\n function adjustPopupIfNecessary(target) {\r\n if (!target.classList.contains('has-submenu')) {\r\n document.body.classList.remove('uc203-hovered');\r\n return;\r\n }\r\n\r\n const hoveredLevel1PopupContainer = target.querySelector('.' + classes.popup);\r\n const heightHeaderAndMegaMenu = desktopHeaderContainer.clientHeight + hoveredLevel1PopupContainer.clientHeight;\r\n if (heightHeaderAndMegaMenu > window.innerHeight) {\r\n hoveredLevel1PopupContainer.classList.add('scrollable');\r\n hoveredLevel1PopupContainer.style.height = `calc(${window.innerHeight * .9 - desktopHeaderContainer.clientHeight}px)`;\r\n }\r\n document.body.classList.add('uc203-hovered');\r\n }\r\n });\r\n})(window);"],"names":["w","assetId","umwAssets","forEach","ctx","prefixClass","classes","control","lvl1Item","popup","lvl1ItemHovered","desktopHeaderContainer","document","querySelector","let","hoverTimerId","removeHoverState","querySelectorAll","item","classList","remove","body","addEventListener","e","beforeMegaMenuLvl1Mouseenter","target","matches","CustomEvent","dispatchEvent","defaultPrevented","clearTimeout","setTimeout","add","adjustPopupIfNecessary","contains","hoveredLevel1PopupContainer","clientHeight","window","innerHeight","style","height","beforeMegaMenuLvl1Mouseleave","console","error"],"mappings":"CAAWA,IACP,IAAMC,EAAU,wCAEXD,EAAEE,WAAcF,EAAEE,UAAUD,GAKjCD,EAAEE,UAAUD,GAASE,QAAQC,IACzB,IAAMC,EAAc,mBACpB,IAAMC,EAAU,CACZC,QAAS,MAAQF,EACjBG,SAAU,MAAQH,EAAc,aAChCI,MAAOJ,EAAc,SACrBK,gBAAiBL,EAAc,oBACnC,EAEMM,EAAyBC,SAASC,cAAc,sBAAsB,EAC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