
/**
 * 由 Fantastic-admin 提供技术支持
 * Powered by Fantastic-admin
 * https://fantastic-admin.github.io
 */

import{d as R,$ as C,W as B,n as d,p as T,g as f,c,b,i,z as m,w as H,am as _,Q as $,F as g,s as F,A as h,ai as S,bU as I,aa as A,a0 as L,av as w,E as N}from"./index-nGFMSQGw.js";import{_ as z,r as J}from"./item.vue_vue_type_script_setup_true_lang-DFSQ8avw.js";const V=R({name:"SubMenu",__name:"sub",props:{uniqueKey:{},menu:{},level:{default:0}},setup(x){const t=x,p=t.menu.path??JSON.stringify(t.menu),y=C(),u=C(),n=B(J),v=d(()=>n.openedMenus.includes(t.uniqueKey.at(-1))),k=d(()=>n.isMenuPopup?{enter(e){e.offsetHeight>window.innerHeight&&(e.style.height=`${window.innerHeight}px`)},afterEnter:()=>{},beforeLeave:e=>{e.style.overflow="hidden",e.style.maxHeight=`${e.offsetHeight}px`},leave:e=>{e.style.maxHeight="0"},afterLeave(e){e.style.overflow="",e.style.maxHeight=""}}:{enter(e){const s=e.offsetHeight;e.style.maxHeight="0",e.style.overflow="hidden",e.offsetHeight,e.style.maxHeight=`${s}px`},afterEnter(e){e.style.overflow="",e.style.maxHeight=""},beforeLeave(e){e.style.overflow="hidden",e.style.maxHeight=`${e.offsetHeight}px`},leave(e){e.style.maxHeight="0"},afterLeave(e){e.style.overflow="",e.style.maxHeight=""}}),q=d(()=>n.isMenuPopup?{enterActiveClass:"ease-in-out duration-300",enterFromClass:"opacity-0 translate-x-4",enterToClass:"opacity-100",leaveActiveClass:"ease-in-out duration-300",leaveFromClass:"opacity-100",leaveToClass:"opacity-0"}:{enterActiveClass:"ease-in-out duration-300",enterFromClass:"opacity-0",enterToClass:"opacity-100",leaveActiveClass:"ease-in-out duration-300",leaveFromClass:"opacity-100",leaveToClass:"opacity-0"}),l=d(()=>{let e=!0;return t.menu.children?t.menu.children.every(s=>{var o;return((o=s.meta)==null?void 0:o.menu)===!1})&&(e=!1):e=!1,e});function P(){n.isMenuPopup&&l.value||(l.value?n.handleSubMenuClick(p,t.uniqueKey):n.handleMenuItemClick(p))}let a;function E(){n.isMenuPopup&&(n.mouseInMenu=t.uniqueKey,a==null||a(),{stop:a}=w(()=>{if(l.value)n.openMenu(p,t.uniqueKey),N(()=>{const e=y.value.ref;let s=0,o=0;n.props.mode==="vertical"||t.level!==0?(s=e.getBoundingClientRect().top+e.scrollTop,o=e.getBoundingClientRect().left+e.getBoundingClientRect().width,s+u.value.getElement().offsetHeight>window.innerHeight&&(s=window.innerHeight-u.value.getElement().offsetHeight)):(s=e.getBoundingClientRect().top+e.getBoundingClientRect().height,o=e.getBoundingClientRect().left,s+u.value.getElement().offsetHeight>window.innerHeight&&(u.value.getElement().style.height=`${window.innerHeight-s}px`)),u.value.getElement().style.top=`${s}px`,u.value.getElement().style.left=`${o}px`});else{const e=t.menu.children?n.subMenus[p].indexPath.at(-1):n.items[p].indexPath.at(-1);n.openMenu(e,n.subMenus[e].indexPath)}},300))}function K(){n.isMenuPopup&&(n.mouseInMenu=[],a==null||a(),{stop:a}=w(()=>{n.mouseInMenu.length===0?n.closeMenu(t.uniqueKey):l.value&&!n.mouseInMenu.includes(t.uniqueKey.at(-1))&&n.closeMenu(t.uniqueKey.at(-1))},300))}return(e,s)=>{const o=T("SubMenu");return f(),c(g,null,[b(z,{ref_key:"itemRef",ref:y,"unique-key":e.uniqueKey,item:e.menu,level:e.level,"sub-menu":i(l),expand:i(v),onClick:P,onMouseenter:E,onMouseleave:K},null,8,["unique-key","item","level","sub-menu","expand"]),i(l)?(f(),m(L,{key:0,to:"body",disabled:!i(n).isMenuPopup},[b(A,S(i(q),I(i(k))),{default:H(()=>[i(v)?(f(),m(i(_),{key:0,ref_key:"subMenuRef",ref:u,options:{scrollbars:{visibility:"hidden"}},defer:"",class:$(["sub-menu",{"bg-[var(--g-sub-sidebar-bg)]":i(n).isMenuPopup,"ring-1 ring-stone-2 dark-ring-stone-8 shadow-xl fixed z-3000 w-[200px]":i(n).isMenuPopup,"mx-2":i(n).isMenuPopup&&(i(n).props.mode==="vertical"||e.level!==0)}])},{default:H(()=>[(f(!0),c(g,null,F(e.menu.children,r=>{var M;return f(),c(g,{key:r.path??JSON.stringify(r)},[((M=r.meta)==null?void 0:M.menu)!==!1?(f(),m(o,{key:0,"unique-key":[...e.uniqueKey,r.path??JSON.stringify(r)],menu:r,level:e.level+1},null,8,["unique-key","menu","level"])):h("",!0)],64)}),128))]),_:1},8,["class"])):h("",!0)]),_:1},16)],8,["disabled"])):h("",!0)],64)}}});export{V as _};
