import e from"../../_util/classNames.mjs";import{flattenChildren as t}from"../../_util/props-util/index.mjs";import n from"../../_util/supportsPassive.mjs";import{getTransitionProps as r}from"../../_util/transition.mjs";import{getMotion as i}from"../utils/motionUtil.mjs";import{innerProps as a}from"./interface.mjs";import o from"../../vc-align/Align.mjs";import s from"./useStretchStyle.mjs";import c from"./useVisibleStatus.mjs";import{Transition as l,computed as u,createVNode as d,defineComponent as f,shallowRef as p,toRef as m,vShow as h,watch as g,withDirectives as _,withModifiers as v}from"vue";var y=f({compatConfig:{MODE:3},name:`PopupInner`,inheritAttrs:!1,props:a,emits:[`mouseenter`,`mouseleave`,`mousedown`,`touchstart`,`align`],setup(a,{expose:f,attrs:y,slots:b}){let x=p(),S=p(),C=p(),[w,T]=s(m(a,`stretch`)),E=()=>{a.stretch&&T(a.getRootDomNode())},D=p(!1),O;g(()=>a.visible,e=>{clearTimeout(O),e?O=setTimeout(()=>{D.value=a.visible}):D.value=!1},{immediate:!0});let[k,A]=c(D,E),j=p(),M=()=>a.point?a.point:a.getRootDomNode,N=()=>{x.value?.forceAlign()},P=(e,t)=>{let n=a.getClassNameFromAlign(t),r=C.value;C.value!==n&&(C.value=n),k.value===`align`&&(r===n?A(()=>{j.value?.()}):Promise.resolve().then(()=>{N()}),a.onAlign?.(e,t))},F=u(()=>{let e=typeof a.animation==`object`?a.animation:i(a);return[`onAfterEnter`,`onAfterLeave`].forEach(t=>{let n=e[t];e[t]=e=>{A(),k.value=`stable`,n?.(e)}}),e}),I=()=>new Promise(e=>{j.value=e});g([F,k],()=>{!F.value&&k.value===`motion`&&A()},{immediate:!0}),f({forceAlign:N,getElement:()=>S.value.$el||S.value});let L=u(()=>!(a.align?.points&&(k.value===`align`||k.value===`stable`)));return()=>{let{zIndex:i,align:s,prefixCls:c,destroyPopupOnHide:u,onMouseenter:f,onMouseleave:p,onTouchstart:m=()=>{},onMousedown:g}=a,T=k.value,E=[{...w.value,zIndex:i,opacity:T===`motion`||T===`stable`||!D.value?null:0,pointerEvents:!D.value&&T!==`stable`?`none`:null},y.style],O=t(b.default?.({visible:a.visible}));O.length>1&&(O=d(`div`,{class:`${c}-content`},[O]));let A=e(c,y.class,C.value,!a.arrow&&`${c}-arrow-hidden`),j=D.value||!a.visible?r(F.value.name,F.value):{};return d(l,{ref:S,...j,onBeforeEnter:I},{default:()=>!u||a.visible?_(d(o,{target:M(),key:`popup`,ref:x,monitorWindowResize:!0,disabled:L.value,align:s,onAlign:P},{default:()=>d(`div`,{class:A,onMouseenter:f,onMouseleave:p,onMousedown:v(g,[`capture`]),[n?`onTouchstartPassive`:`onTouchstart`]:v(m,[`capture`]),style:E},[O])}),[[h,D.value]]):null})}}});export{y as default};