import{ac as M,bm as T,bU as A,bV as K,af as S,aW as U,bW as I,aZ as O,J as b,l as R,bu as $,bX as y,bh as F,G as L,K as g,ag as N,bb as p,q as V,bY as W,bZ as Z,ba as j,bk as w,b_ as q,b$ as P,b3 as G}from"./index-2e57ee69.js";const J=M({id:String,...T(A({closeDelay:250,closeOnContentClick:!0,locationStrategy:"connected",openDelay:300,scrim:!1,scrollStrategy:"reposition",transition:{component:K}}),["absolute"])},"VMenu"),z=S()({name:"VMenu",props:J(),emits:{"update:modelValue":l=>!0},setup(l,E){let{slots:i}=E;const u=U(l,"modelValue"),{scopeId:h}=I(),x=O(),f=b(()=>l.id||`v-menu-${x}`),n=R(),a=$(y,null),c=F(0);G(y,{register(){++c.value},unregister(){--c.value},closeParents(){setTimeout(()=>{c.value||(u.value=!1,a==null||a.closeParents())},40)}});async function v(e){var s,r,d;const t=e.relatedTarget,o=e.target;await j(),u.value&&t!==o&&((s=n.value)!=null&&s.contentEl)&&((r=n.value)!=null&&r.globalTop)&&![document,n.value.contentEl].includes(o)&&!n.value.contentEl.contains(o)&&((d=w(n.value.contentEl)[0])==null||d.focus())}L(u,e=>{e?(a==null||a.register(),document.addEventListener("focusin",v,{once:!0})):(a==null||a.unregister(),document.removeEventListener("focusin",v))});function C(){a==null||a.closeParents()}function D(e){var t,o,s;l.disabled||e.key==="Tab"&&(q(w((t=n.value)==null?void 0:t.contentEl,!1),e.shiftKey?"prev":"next",d=>d.tabIndex>=0)||(u.value=!1,(s=(o=n.value)==null?void 0:o.activatorEl)==null||s.focus()))}function m(e){var o;if(l.disabled)return;const t=(o=n.value)==null?void 0:o.contentEl;t&&u.value?e.key==="ArrowDown"?(e.preventDefault(),P(t,"next")):e.key==="ArrowUp"&&(e.preventDefault(),P(t,"prev")):["ArrowDown","ArrowUp"].includes(e.key)&&(u.value=!0,e.preventDefault(),setTimeout(()=>setTimeout(()=>m(e))))}const k=b(()=>g({"aria-haspopup":"menu","aria-expanded":String(u.value),"aria-owns":f.value,onKeydown:m},l.activatorProps));return N(()=>{const[e]=p.filterProps(l);return V(p,g({ref:n,class:["v-menu",l.class],style:l.style},e,{modelValue:u.value,"onUpdate:modelValue":t=>u.value=t,absolute:!0,activatorProps:k.value,"onClick:outside":C,onKeydown:D},h),{activator:i.activator,default:function(){for(var t=arguments.length,o=new Array(t),s=0;s<t;s++)o[s]=arguments[s];return V(W,{root:"VMenu"},{default:()=>{var r;return[(r=i.default)==null?void 0:r.call(i,...o)]}})}})}),Z({id:f,ΨopenChildren:c},n)}});export{z as V};
