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