import{U}from"./raf-C-x62Pcl.js";import{b as V,i as te,k as le,R as x,N as ae,bI as se,y as f,u as ie,D as L,G as ue,O as k,j as l,bA as re,am as ce,a3 as fe,aK as de,a6 as ve,bd as z,P as ye}from"./index-BKKvzUDD.js";import{a as ge}from"./index-DfyOU94W.js";import{f as M}from"./index-BjEW7-SA.js";const be=V({center:Boolean,alignCenter:{type:Boolean,default:void 0},closeIcon:{type:te},draggable:{type:Boolean,default:void 0},overflow:{type:Boolean,default:void 0},fullscreen:Boolean,headerClass:String,bodyClass:String,footerClass:String,showClose:{type:Boolean,default:!0},title:{type:String,default:""},ariaLevel:{type:String,default:"2"}}),Ee={close:()=>!0},Se=V({...be,appendToBody:Boolean,appendTo:{type:x([String,Object]),default:"body"},beforeClose:{type:x(Function)},destroyOnClose:Boolean,closeOnClickModal:{type:Boolean,default:!0},closeOnPressEscape:{type:Boolean,default:!0},lockScroll:{type:Boolean,default:!0},modal:{type:Boolean,default:!0},modalPenetrable:Boolean,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"},transition:{type:x([String,Object]),default:void 0}}),De={open:()=>!0,opened:()=>!0,close:()=>!0,closed:()=>!0,[U]:e=>le(e),openAutoFocus:()=>!0,closeAutoFocus:()=>!0},Oe=Symbol("dialogInjectionKey"),p="dialog-fade",me="ElDialog",xe=(e,a)=>{const i=ae().emit,{nextZIndex:d}=se();let P="";const $=M(),G=M(),s=f(!1),C=f(!1),v=f(!1),y=f(e.zIndex??d()),g=f(!1);let u,r;const h=ie(),K=l(()=>{var o;return((o=h.value)==null?void 0:o.namespace)??"el"}),b=l(()=>{var o;return(o=h.value)==null?void 0:o.dialog}),Z=l(()=>{const o={},n=`--${K.value}-dialog`;if(!e.fullscreen){e.top&&(o[`${n}-margin-top`]=e.top);const c=ce(e.width);c&&(o[`${n}-width`]=c)}return o}),q=l(()=>{var o;return(e.draggable??((o=b.value)==null?void 0:o.draggable)??!1)&&!e.fullscreen}),F=l(()=>{var o;return e.alignCenter??((o=b.value)==null?void 0:o.alignCenter)??!1}),W=l(()=>{var o;return e.overflow??((o=b.value)==null?void 0:o.overflow)??!1}),w=l(()=>e.modalPenetrable&&!e.modal&&!e.fullscreen),J=l(()=>F.value?{display:"flex"}:{}),Q=l(()=>{var c;const o=e.transition??((c=b.value)==null?void 0:c.transition)??"dialog-fade",n={name:o,onAfterEnter:A,onBeforeLeave:I,onAfterLeave:B};if(fe(o)){const t={...o},O=(m,ne)=>_=>{ve(m)?m.forEach(j=>{z(j)&&j(_)}):z(m)&&m(_),ne()};return t.onAfterEnter=O(t.onAfterEnter,A),t.onBeforeLeave=O(t.onBeforeLeave,I),t.onAfterLeave=O(t.onAfterLeave,B),t.name||(t.name=p,de(me,`transition.name is missing when using object syntax, fallback to '${p}'`)),t}return n});function A(){i("opened")}function B(){i("closed"),i(U,!1),e.destroyOnClose&&(v.value=!1),g.value=!1}function I(){g.value=!0,i("close")}function N(){r==null||r(),u==null||u(),e.openDelay&&e.openDelay>0?{stop:u}=k(()=>T(),e.openDelay):T()}function E(){u==null||u(),r==null||r(),e.closeDelay&&e.closeDelay>0?{stop:r}=k(()=>D(),e.closeDelay):D()}function S(){function o(n){n||(C.value=!0,s.value=!1)}e.beforeClose?e.beforeClose(o):E()}function X(){e.closeOnClickModal&&S()}function T(){re&&(s.value=!0)}function D(){s.value=!1}function Y(){i("openAutoFocus")}function H(){i("closeAutoFocus")}function R(o){var n;((n=o.detail)==null?void 0:n.focusReason)==="pointer"&&o.preventDefault()}e.lockScroll&&ge(s);function ee(){e.closeOnPressEscape&&S()}function oe(){!s.value||!w.value||e.zIndex!==void 0||(y.value=d())}return L(()=>e.zIndex,()=>{y.value=e.zIndex??d()}),L(()=>e.modelValue,o=>{o?(C.value=!1,g.value=!1,N(),v.value=!0,y.value=e.zIndex??d(),ye(()=>{i("open"),a.value&&(a.value.parentElement.scrollTop=0,a.value.parentElement.scrollLeft=0,a.value.scrollTop=0)})):s.value&&E()}),L(()=>e.fullscreen,o=>{a.value&&(o?(P=a.value.style.transform,a.value.style.transform=""):a.value.style.transform=P)}),ue(()=>{e.modelValue&&(s.value=!0,v.value=!0,N())}),{afterEnter:A,afterLeave:B,beforeLeave:I,handleClose:S,onModalClick:X,close:E,doClose:D,onOpenAutoFocus:Y,onCloseAutoFocus:H,onCloseRequested:ee,onFocusoutPrevented:R,bringToFront:oe,titleId:$,bodyId:G,closed:C,style:Z,overlayDialogStyle:J,rendered:v,visible:s,zIndex:y,transitionConfig:Q,_draggable:q,_alignCenter:F,_overflow:W,closing:g,penetrable:w}};export{be as a,Oe as b,De as c,Ee as d,Se as e,xe as u};
