const e=require("../vc-util/Dom/contains.js"),t=require("../_util/classNames.js"),n=require("../_util/omit.js"),r=require("../_util/props-util/initDefaultProps.js"),i=require("../_util/KeyCode.js"),a=require("../_util/pickAttrs.js"),o=require("./IDialogPropTypes.js"),s=require("./util.js"),c=require("./Content.js"),l=require("./Mask.js");let u=require("vue");var d=(0,u.defineComponent)({compatConfig:{MODE:3},name:`VcDialog`,inheritAttrs:!1,props:r.default({...o.default(),getOpenCount:Function,scrollLocker:Object},{mask:!0,visible:!1,keyboard:!0,closable:!0,maskClosable:!0,destroyOnClose:!1,prefixCls:`rc-dialog`,getOpenCount:()=>null,focusTriggerAfterClose:!0}),setup(r,{attrs:o,slots:d}){let f=(0,u.shallowRef)(),p=(0,u.shallowRef)(),m=(0,u.shallowRef)(),h=(0,u.shallowRef)(r.visible),g=(0,u.shallowRef)(`vcDialogTitle${s.getUUID()}`),_=t=>{if(t)e.default(p.value,document.activeElement)||(f.value=document.activeElement,m.value?.focus());else{let e=h.value;if(h.value=!1,r.mask&&f.value&&r.focusTriggerAfterClose){try{f.value.focus({preventScroll:!0})}catch{}f.value=null}e&&r.afterClose?.()}},v=e=>{r.onClose?.(e)},y=(0,u.shallowRef)(!1),b=(0,u.shallowRef)(),x=()=>{clearTimeout(b.value),y.value=!0},S=()=>{b.value=setTimeout(()=>{y.value=!1})},C=e=>{if(!r.maskClosable)return null;y.value?y.value=!1:p.value===e.target&&v(e)},w=e=>{if(r.keyboard&&e.keyCode===i.default.ESC){e.stopPropagation(),v(e);return}r.visible&&e.keyCode===i.default.TAB&&m.value.changeActive(!e.shiftKey)};return(0,u.watch)(()=>r.visible,()=>{r.visible&&(h.value=!0)},{flush:`post`}),(0,u.onBeforeUnmount)(()=>{clearTimeout(b.value),r.scrollLocker?.unLock()}),(0,u.watchEffect)(()=>{r.scrollLocker?.unLock(),h.value&&r.scrollLocker?.lock()}),()=>{let{prefixCls:e,mask:i,visible:f,maskTransitionName:y,maskAnimation:b,zIndex:T,wrapClassName:E,rootClassName:D,wrapStyle:O,closable:k,maskProps:A,maskStyle:j,transitionName:M,animation:N,wrapProps:P,title:F=d.title}=r,{style:I,class:L}=o;return(0,u.createVNode)(`div`,{class:[`${e}-root`,D],...a.default(r,{data:!0})},[(0,u.createVNode)(l.default,{prefixCls:e,visible:i&&f,motionName:s.getMotionName(e,y,b),style:{zIndex:T,...j},maskProps:A},null),(0,u.createVNode)(`div`,{tabIndex:-1,onKeydown:w,class:t.default(`${e}-wrap`,E),ref:p,onClick:C,role:`dialog`,"aria-labelledby":F?g.value:null,style:{zIndex:T,...O,display:h.value?null:`none`},...P},[(0,u.createVNode)(c.default,{...n.default(r,[`scrollLocker`]),style:I,class:L,onMousedown:x,onMouseup:S,ref:m,closable:k,ariaId:g.value,prefixCls:e,visible:f,onClose:v,onVisibleChanged:_,motionName:s.getMotionName(e,M,N)},d)])])}}});exports.default=d;