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