import{m as D,k as h,f as x,e as d}from"./VMenu-f26d3a19.js";import{u as A,B as L,C as S}from"./forwardRefs-d0d7c5bd.js";import{p as B,n as I,as as w,r as F,b0 as R,I as m,av as T,E as f,f as g,b1 as C}from"./index-0ae84607.js";const O=B({fullscreen:Boolean,retainFocus:{type:Boolean,default:!0},scrollable:Boolean,...D({origin:"center center",scrollStrategy:"block",transition:{component:h},zIndex:2400})},"VDialog"),M=I()({name:"VDialog",props:O(),emits:{"update:modelValue":a=>!0,afterLeave:()=>!0},setup(a,p){let{emit:E,slots:u}=p;const l=w(a,"modelValue"),{scopeId:V}=x(),e=F();function v(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=C(e.value.contentEl);if(!o.length)return;const i=o[0],y=o[o.length-1];n===i?y.focus():i.focus()}}R&&m(()=>l.value&&a.retainFocus,t=>{t?document.addEventListener("focusin",v):document.removeEventListener("focusin",v)},{immediate:!0});function P(){var t;(t=e.value)!=null&&t.contentEl&&!e.value.contentEl.contains(document.activeElement)&&e.value.contentEl.focus({preventScroll:!0})}function b(){E("afterLeave")}return m(l,async t=>{var n;t||(await T(),(n=e.value.activatorEl)==null||n.focus({preventScroll:!0}))}),A(()=>{const t=d.filterProps(a),n=f({"aria-haspopup":"dialog","aria-expanded":String(l.value)},a.activatorProps),s=f({tabindex:-1},a.contentProps);return g(d,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 g(L,{root:"VDialog"},{default:()=>{var i;return[(i=u.default)==null?void 0:i.call(u,...c)]}})}})}),S({},e)}});export{M as V};
