import{d as D,h,b as x,c as m,f as A}from"./VMenu-4ca080f5.js";import{l as L,m as S,B,r as T,aM as w,N as g,U as F,G as f,f as p,aT as I}from"./index-5e5d70f8.js";import{c as R,K as N}from"./VListItem-a276ed14.js";const O=L({fullscreen:Boolean,retainFocus:{type:Boolean,default:!0},scrollable:Boolean,...D({origin:"center center",scrollStrategy:"block",transition:{component:h},zIndex:2400})},"VDialog"),k=S()({name:"VDialog",props:O(),emits:{"update:modelValue":a=>!0,afterEnter:()=>!0,afterLeave:()=>!0},setup(a,E){let{emit:v,slots:u}=E;const l=B(a,"modelValue"),{scopeId:V}=x(),e=T();function d(t){var r,c;const n=t.relatedTarget,s=t.target;if(n!==s&&((r=e.value)!=null&&r.contentEl)&&((c=e.value)!=null&&c.globalTop)&&![document,e.value.contentEl].includes(s)&&!e.value.contentEl.contains(s)){const o=I(e.value.contentEl);if(!o.length)return;const i=o[0],y=o[o.length-1];n===i?y.focus():i.focus()}}w&&g(()=>l.value&&a.retainFocus,t=>{t?document.addEventListener("focusin",d):document.removeEventListener("focusin",d)},{immediate:!0});function P(){var t;v("afterEnter"),(t=e.value)!=null&&t.contentEl&&!e.value.contentEl.contains(document.activeElement)&&e.value.contentEl.focus({preventScroll:!0})}function b(){v("afterLeave")}return g(l,async t=>{var n;t||(await F(),(n=e.value.activatorEl)==null||n.focus({preventScroll:!0}))}),R(()=>{const t=m.filterProps(a),n=f({"aria-haspopup":"dialog","aria-expanded":String(l.value)},a.activatorProps),s=f({tabindex:-1},a.contentProps);return p(m,f({ref:e,class:["v-dialog",{"v-dialog--fullscreen":a.fullscreen,"v-dialog--scrollable":a.scrollable},a.class],style:a.style},t,{modelValue:l.value,"onUpdate:modelValue":r=>l.value=r,"aria-modal":"true",activatorProps:n,contentProps:s,role:"dialog",onAfterEnter:P,onAfterLeave:b},V),{activator:u.activator,default:function(){for(var r=arguments.length,c=new Array(r),o=0;o<r;o++)c[o]=arguments[o];return p(N,{root:"VDialog"},{default:()=>{var i;return[(i=u.default)==null?void 0:i.call(u,...c)]}})}})}),A({},e)}});export{k as V};
