import{d as D,h,b as L,c as d,f as x}from"./VMenu-482e7fbc.js";import{l as A,m as S,B,r as R,aL as w,N as m,U as F,G as f,f as g,aR as I}from"./index-103db515.js";import{c as T,K as N}from"./VListItem-ab7a82e2.js";const O=A({fullscreen:Boolean,retainFocus:{type:Boolean,default:!0},scrollable:Boolean,...D({origin:"center center",scrollStrategy:"block",transition:{component:h},zIndex:2400})},"VDialog"),z=S()({name:"VDialog",props:O(),emits:{"update:modelValue":a=>!0,afterLeave:()=>!0},setup(a,p){let{emit:E,slots:u}=p;const r=B(a,"modelValue"),{scopeId:V}=L(),e=R();function v(t){var l,c;const n=t.relatedTarget,s=t.target;if(n!==s&&((l=e.value)!=null&&l.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&&m(()=>r.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(r,async t=>{var n;t||(await F(),(n=e.value.activatorEl)==null||n.focus({preventScroll:!0}))}),T(()=>{const t=d.filterProps(a),n=f({"aria-haspopup":"dialog","aria-expanded":String(r.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:r.value,"onUpdate:modelValue":l=>r.value=l,"aria-modal":"true",activatorProps:n,contentProps:s,role:"dialog",onAfterEnter:P,onAfterLeave:b},V),{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(N,{root:"VDialog"},{default:()=>{var i;return[(i=u.default)==null?void 0:i.call(u,...c)]}})}})}),x({},e)}});export{z as V};
