(()=>{let t=":scope > .uicore-menu-panel > .wp-block-uicore-a-menu-wrapper > .wp-block-uicore-a-menu-link",d=".wp-block-uicore-a-menu-submenu",n="uicore-is-active",v="data-uicore-menu-focus-ready",E=e=>Array.from(e.querySelectorAll(t)),L=e=>e.classList.contains(n),f=({menu:e,activeItems:n})=>{let r=L(e);E(e).forEach(t=>{var e;r||0===n.size?t.style.opacity="":n.has(t)?t.style.opacity="1":(e=Array.from(n).some(e=>e.parentElement===t.parentElement),t.style.opacity=e?"0.4":"1")})},r=({menu:r,contextWindow:e=r?.ownerDocument?.defaultView})=>{if(!r||"true"===r.getAttribute(v)||!e)return null;var t=E(r);if(!t.length)return null;r.setAttribute(v,"true");let u=[],o=new Set;var n=Array.from(r.querySelectorAll(d));let a=()=>{o.clear(),f({menu:r,activeItems:o})},s=e=>{L(r)||(o.add(e),f({menu:r,activeItems:o}))},i=(e,t)=>{var n=e.querySelector(d);n&&t&&n.contains(t)||(o.delete(e),f({menu:r,activeItems:o}))},c=(t.forEach(t=>{let e=()=>s(t),n=()=>s(t),r=e=>i(t,e.relatedTarget),o=e=>i(t,e.relatedTarget);t.addEventListener("mouseenter",e),t.addEventListener("focusin",n),t.addEventListener("mouseleave",r),t.addEventListener("focusout",o),u.push(()=>{t.removeEventListener("mouseenter",e),t.removeEventListener("focusin",n),t.removeEventListener("mouseleave",r),t.removeEventListener("focusout",o)})}),n.forEach(t=>{let e=e=>{e.relatedTarget&&t.contains(e.relatedTarget)||a()};t.addEventListener("mouseleave",e),u.push(()=>{t.removeEventListener("mouseleave",e)})}),()=>a()),l=e=>{e.relatedTarget&&r.contains(e.relatedTarget)||a()},m=()=>{L(r)?a():f({menu:r,activeItems:o})};return r.addEventListener("mouseleave",c),r.addEventListener("focusout",l),e.addEventListener("resize",m),u.push(()=>{r.removeEventListener("mouseleave",c),r.removeEventListener("focusout",l),e.removeEventListener("resize",m)}),()=>{a(),u.forEach(e=>e()),r.removeAttribute(v)}},e=({contextDocument:e=document,contextWindow:t=window}={})=>{e.querySelectorAll(".wp-block-uicore-a-menu.uicore-bl-menu-focus").forEach(e=>{r({menu:e,contextWindow:t})})};window.MenuFocus={initMenuFocus:e,initMenuFocusMenu:r},document.addEventListener("DOMContentLoaded",()=>{document.body.classList.contains("block-editor-page")||e()})})();