import e from"../../_util/classNames.mjs";import t from"../../_util/omit.mjs";import n from"../../_util/KeyCode.mjs";import{drawerChildProps as r}from"./IDrawerPropTypes.mjs";import{dataToArray as i,windowIsUndefined as a}from"./utils.mjs";import{Transition as o,createVNode as s,defineComponent as c,nextTick as l,onMounted as u,onUnmounted as d,shallowRef as f,vShow as p,watch as m,withDirectives as h}from"vue";var g={},_=c({compatConfig:{MODE:3},inheritAttrs:!1,props:r(),emits:[`close`,`handleClick`,`change`],setup(r,{emit:c,slots:_}){let v=f(),y=f(),b=f(),x=f(),S=f(),C=[],w=`drawer_id_${Number((Date.now()+Math.random()).toString().replace(`.`,Math.round(Math.random()*9).toString())).toString(16)}`;u(()=>{l(()=>{let{open:e,getContainer:t,showMask:n,autofocus:i}=r,a=t?.();k(r),e&&(a&&a.parentNode===document.body&&(g[w]=e),l(()=>{i&&T()}),n&&r.scrollLocker?.lock())})}),m(()=>r.level,()=>{k(r)},{flush:`post`}),m(()=>r.open,()=>{let{open:e,getContainer:t,scrollLocker:n,showMask:i,autofocus:a}=r,o=t?.();o&&o.parentNode===document.body&&(g[w]=!!e),e?(a&&T(),i&&n?.lock()):n?.unLock()},{flush:`post`}),d(()=>{let{open:e}=r;delete g[w],e&&(document.body.style.touchAction=``),r.scrollLocker?.unLock()}),m(()=>r.placement,e=>{e&&(S.value=null)});let T=()=>{y.value?.focus?.()},E=e=>{c(`close`,e)},D=e=>{e.keyCode===n.ESC&&(e.stopPropagation(),E(e))},O=()=>{let{open:e,afterVisibleChange:t}=r;t&&t(!!e)},k=({level:e,getContainer:t})=>{if(a)return;let n=t?.(),r=n?n.parentNode:null;C=[],e===`all`?(r?Array.prototype.slice.call(r.children):[]).forEach(e=>{e.nodeName!==`SCRIPT`&&e.nodeName!==`STYLE`&&e.nodeName!==`LINK`&&e!==n&&C.push(e)}):e&&i(e).forEach(e=>{document.querySelectorAll(e).forEach(e=>{C.push(e)})})},A=e=>{c(`handleClick`,e)},j=f(!1);return m(y,()=>{l(()=>{j.value=!0})}),()=>{let{width:n,height:i,open:a,prefixCls:c,placement:l,level:u,levelMove:d,ease:f,duration:m,getContainer:g,onChange:C,afterVisibleChange:w,showMask:T,maskClosable:k,maskStyle:M,keyboard:N,getOpenCount:P,scrollLocker:F,contentWrapperStyle:I,style:L,class:R,rootClassName:z,rootStyle:B,maskMotion:V,motion:H,inline:U,...W}=r,G=a&&j.value,K=e(c,{[`${c}-${l}`]:!0,[`${c}-open`]:G,[`${c}-inline`]:U,"no-mask":!T,[z]:!0}),q=typeof H==`function`?H(l):H;return s(`div`,{...t(W,[`autofocus`]),tabindex:-1,class:K,style:B,ref:y,onKeydown:G&&N?D:void 0},[s(o,V,{default:()=>[T&&h(s(`div`,{class:`${c}-mask`,onClick:k?E:void 0,style:M,ref:b},null),[[p,G]])]}),s(o,{...q,onAfterEnter:O,onAfterLeave:O},{default:()=>[h(s(`div`,{class:`${c}-content-wrapper`,style:[I],ref:v},[s(`div`,{class:[`${c}-content`,R],style:L,ref:S},[_.default?.()]),_.handler?s(`div`,{onClick:A,ref:x},[_.handler?.()]):null]),[[p,G]])]})])}}});export{_ as default};