import L from "../../@babel/runtime/helpers/esm/objectDestructuringEmpty.mjs";
import n from "../../@babel/runtime/helpers/esm/extends.mjs";
import U from "../../@babel/runtime/helpers/esm/slicedToArray.mjs";
import W from "../../@babel/runtime/helpers/esm/objectWithoutProperties.mjs";
import z from "../../classnames/index.mjs";
import B from "../../rc-motion/es/CSSMotion.mjs";
import "../../rc-motion/es/CSSMotionList.mjs";
import * as e from "react";
import F from "../../rc-util/es/hooks/useLayoutEffect.mjs";
import { TreeContext as G } from "./contextTypes.mjs";
import y from "./TreeNode.mjs";
import H from "./useUnmount.mjs";
import { getTreeNodeProps as I } from "./utils/treeUtil.mjs";
var J = ["className", "style", "motion", "motionNodes", "motionType", "onMotionStart", "onMotionEnd", "active", "treeNodeRequiredProps"], M = function(t, m) {
  var N = t.className, E = t.style, S = t.motion, o = t.motionNodes, d = t.motionType, R = t.onMotionStart, C = t.onMotionEnd, c = t.active, T = t.treeNodeRequiredProps, b = W(t, J), x = e.useState(!0), l = U(x, 2), p = l[0], h = l[1], P = e.useContext(G), V = P.prefixCls, a = o && d !== "hide";
  F(function() {
    o && a !== p && h(a);
  }, [o]);
  var k = function() {
    o && R();
  }, u = e.useRef(!1), f = function() {
    o && !u.current && (u.current = !0, C());
  };
  H(k, f);
  var q = function(s) {
    a === s && f();
  };
  return o ? /* @__PURE__ */ e.createElement(B, n({
    ref: m,
    visible: p
  }, S, {
    motionAppear: d === "show",
    onVisibleChanged: q
  }), function(r, s) {
    var $ = r.className, j = r.style;
    return /* @__PURE__ */ e.createElement("div", {
      ref: s,
      className: z("".concat(V, "-treenode-motion"), $),
      style: j
    }, o.map(function(i) {
      var v = n({}, (L(i.data), i.data)), w = i.title, g = i.key, A = i.isStart, O = i.isEnd;
      delete v.children;
      var D = I(g, T);
      return /* @__PURE__ */ e.createElement(y, n({}, v, D, {
        title: w,
        active: c,
        data: i.data,
        key: g,
        isStart: A,
        isEnd: O
      }));
    }));
  }) : /* @__PURE__ */ e.createElement(y, n({
    domRef: m,
    className: N,
    style: E
  }, b, {
    active: c
  }));
};
M.displayName = "MotionTreeNode";
var st = /* @__PURE__ */ e.forwardRef(M);
export {
  st as default
};
