import{defineComponent as S,shallowRef as v,computed as w,watch as x,nextTick as C,onMounted as P,onBeforeUnmount as k,createVNode as n,Transition as K,withDirectives as b,vShow as g}from"vue";import j from"../_util/collapseMotion.mjs";import p from"./TreeNode.mjs";import{useInjectTreeContext as B}from"./contextTypes.mjs";import{treeNodeProps as D}from"./props.mjs";const I=S({compatConfig:{MODE:3},name:"MotionTreeNode",inheritAttrs:!1,props:{...D,active:Boolean,motion:Object,motionNodes:{type:Array},onMotionStart:Function,onMotionEnd:Function,motionType:String},setup(e,{attrs:l,slots:m}){const i=v(!0),y=B(),c=v(!1),a=w(()=>e.motion?e.motion:j()),r=(s,o)=>{o==="appear"?a.value?.onAfterEnter?.(s):o==="leave"&&a.value?.onAfterLeave?.(s),c.value||e.onMotionEnd(),c.value=!0};return x(()=>e.motionNodes,()=>{e.motionNodes&&e.motionType==="hide"&&i.value&&C(()=>{i.value=!1})},{immediate:!0,flush:"post"}),P(()=>{e.motionNodes&&e.onMotionStart()}),k(()=>{e.motionNodes&&r()}),()=>{const{motion:s,motionNodes:o,motionType:h,active:d,eventKey:M,...N}=e;return o?n(K,{...a.value,appear:h==="show",onAfterAppear:t=>r(t,"appear"),onAfterLeave:t=>r(t,"leave")},{default:()=>[b(n("div",{class:`${y.value.prefixCls}-treenode-motion`},[o.map(t=>{const{data:{...u},title:T,key:f,isStart:A,isEnd:E}=t;return delete u.children,n(p,{...u,title:T,active:d,data:t.data,key:f,eventKey:f,isStart:A,isEnd:E},m)})]),[[g,i.value]])]}):n(p,{class:l.class,style:l.style,...N,active:d,eventKey:M},m)}}});export{I as default};
