import{a0 as I,a1 as V,ax as _,aK as $,r as c,b8 as G,b9 as Z,G as B,y as S,a5 as q,e as K,a8 as j,ba as D,aO as H}from"./index-25eb6331.js";import{s as J,U as P,m as x,I as Q}from"./index-3bef6acb.js";import{t as W,c as X}from"./button-c2afb424.js";import{b as Y}from"./index-db57f3ab.js";const R=I({center:Boolean,alignCenter:Boolean,closeIcon:{type:J},draggable:Boolean,overflow:Boolean,fullscreen:Boolean,headerClass:String,bodyClass:String,footerClass:String,showClose:{type:Boolean,default:!0},title:{type:String,default:""},ariaLevel:{type:String,default:"2"}}),ae={close:()=>!0},se=I({...R,appendToBody:Boolean,appendTo:{type:W.to.type,default:"body"},beforeClose:{type:V(Function)},destroyOnClose:Boolean,closeOnClickModal:{type:Boolean,default:!0},closeOnPressEscape:{type:Boolean,default:!0},lockScroll:{type:Boolean,default:!0},modal:{type:Boolean,default:!0},openDelay:{type:Number,default:0},closeDelay:{type:Number,default:0},top:{type:String},modelValue:Boolean,modalClass:String,headerClass:String,bodyClass:String,footerClass:String,width:{type:[String,Number]},zIndex:{type:Number},trapFocus:Boolean,headerAriaLevel:{type:String,default:"2"}}),ue={open:()=>!0,opened:()=>!0,close:()=>!0,closed:()=>!0,[P]:e=>_(e),openAutoFocus:()=>!0,closeAutoFocus:()=>!0},ie=(e,l)=>{var m;const n=j().emit,{nextZIndex:C}=$();let p="";const T=x(),h=x(),t=c(!1),r=c(!1),i=c(!1),d=c((m=e.zIndex)!=null?m:C());let s,u;const E=G("namespace",Z),F=B(()=>{const o={},a="--".concat(E.value,"-dialog");return e.fullscreen||(e.top&&(o["".concat(a,"-margin-top")]=e.top),e.width&&(o["".concat(a,"-width")]=Q(e.width))),o}),O=B(()=>e.alignCenter?{display:"flex"}:{});function A(){n("opened")}function k(){n("closed"),n(P,!1),e.destroyOnClose&&(i.value=!1)}function w(){n("close")}function b(){u==null||u(),s==null||s(),e.openDelay&&e.openDelay>0?{stop:s}=D(()=>g(),e.openDelay):g()}function f(){s==null||s(),u==null||u(),e.closeDelay&&e.closeDelay>0?{stop:u}=D(()=>v(),e.closeDelay):v()}function y(){function o(a){a||(r.value=!0,t.value=!1)}e.beforeClose?e.beforeClose(o):f()}function L(){e.closeOnClickModal&&y()}function g(){H&&(t.value=!0)}function v(){t.value=!1}function N(){n("openAutoFocus")}function M(){n("closeAutoFocus")}function z(o){var a;((a=o.detail)==null?void 0:a.focusReason)==="pointer"&&o.preventDefault()}e.lockScroll&&Y(t);function U(){e.closeOnPressEscape&&y()}return S(()=>e.modelValue,o=>{o?(r.value=!1,b(),i.value=!0,d.value=X(e.zIndex)?C():d.value++,q(()=>{n("open"),l.value&&(l.value.parentElement.scrollTop=0,l.value.parentElement.scrollLeft=0,l.value.scrollTop=0)})):t.value&&f()}),S(()=>e.fullscreen,o=>{l.value&&(o?(p=l.value.style.transform,l.value.style.transform=""):l.value.style.transform=p)}),K(()=>{e.modelValue&&(t.value=!0,i.value=!0,b())}),{afterEnter:A,afterLeave:k,beforeLeave:w,handleClose:y,onModalClick:L,close:f,doClose:v,onOpenAutoFocus:N,onCloseAutoFocus:M,onCloseRequested:U,onFocusoutPrevented:z,titleId:T,bodyId:h,closed:r,style:F,overlayDialogStyle:O,rendered:i,visible:t,zIndex:d}};export{ae as a,se as b,ue as c,R as d,ie as u};
