import{a9 as D,bW as h,bX as x,ac as A,ak as L,au as S,r as w,bY as B,H as d,ae as F,af as I,bZ as m,O as f,z as g,bj as O,aM as R,b_ as T}from"./D6By_0qX.js";const k=D({fullscreen:Boolean,retainFocus:{type:Boolean,default:!0},scrollable:Boolean,...h({origin:"center center",scrollStrategy:"block",transition:{component:x},zIndex:2400})},"VDialog"),C=A()({name:"VDialog",props:k(),emits:{"update:modelValue":a=>!0,afterLeave:()=>!0},setup(a,p){let{emit:E,slots:i}=p;const r=L(a,"modelValue"),{scopeId:b}=S(),e=w();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=T(e.value.contentEl);if(!o.length)return;const u=o[0],y=o[o.length-1];n===u?y.focus():u.focus()}}B&&d(()=>r.value&&a.retainFocus,t=>{t?document.addEventListener("focusin",v):document.removeEventListener("focusin",v)},{immediate:!0});function V(){var t;(t=e.value)!=null&&t.contentEl&&!e.value.contentEl.contains(document.activeElement)&&e.value.contentEl.focus({preventScroll:!0})}function P(){E("afterLeave")}return d(r,async t=>{var n;t||(await R(),(n=e.value.activatorEl)==null||n.focus({preventScroll:!0}))}),F(()=>{const t=m.filterProps(a),n=f({"aria-haspopup":"dialog","aria-expanded":String(r.value)},a.activatorProps),s=f({tabindex:-1},a.contentProps);return g(m,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:V,onAfterLeave:P},b),{activator:i.activator,default:function(){for(var l=arguments.length,c=new Array(l),o=0;o<l;o++)c[o]=arguments[o];return g(O,{root:"VDialog"},{default:()=>{var u;return[(u=i.default)==null?void 0:u.call(i,...c)]}})}})}),I({},e)}});export{C as V};
