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