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