import t from "react";
import $ from "../../../@ant-design/icons/es/icons/HolderOutlined.mjs";
import S from "../../../classnames/index.mjs";
import T from "../../../rc-tree/es/Tree.mjs";
import "../../../rc-tree/es/TreeNode.mjs";
import D from "../_util/motion.mjs";
import "../config-provider/index.mjs";
import L from "./style/index.mjs";
import M from "./utils/dropIndicator.mjs";
import R from "./utils/iconUtil.mjs";
import { ConfigContext as V } from "../config-provider/context.mjs";
const b = /* @__PURE__ */ t.forwardRef((a, g) => {
  const {
    getPrefixCls: l,
    direction: m,
    virtual: u,
    tree: r
  } = t.useContext(V), {
    prefixCls: h,
    className: C,
    showIcon: f = !1,
    showLine: d,
    switcherIcon: w,
    blockNode: p = !1,
    children: x,
    checkable: i = !1,
    selectable: n = !0,
    draggable: s,
    motion: c,
    style: N
  } = a, e = l("tree", h), O = l(), j = c ?? Object.assign(Object.assign({}, D(O)), {
    motionAppear: !1
  }), v = Object.assign(Object.assign({}, a), {
    checkable: i,
    selectable: n,
    showIcon: f,
    motion: j,
    blockNode: p,
    showLine: !!d,
    dropIndicatorRender: M
  }), [I, k, y] = L(e), E = t.useMemo(() => {
    if (!s)
      return !1;
    let o = {};
    switch (typeof s) {
      case "function":
        o.nodeDraggable = s;
        break;
      case "object":
        o = Object.assign({}, s);
        break;
    }
    return o.icon !== !1 && (o.icon = o.icon || /* @__PURE__ */ t.createElement($, null)), o;
  }, [s]), P = (o) => /* @__PURE__ */ t.createElement(R, {
    prefixCls: e,
    switcherIcon: w,
    treeNodeProps: o,
    showLine: d
  });
  return I(/* @__PURE__ */ t.createElement(T, Object.assign({
    itemHeight: 20,
    ref: g,
    virtual: u
  }, v, {
    // newProps may contain style so declare style below it
    style: Object.assign(Object.assign({}, r == null ? void 0 : r.style), N),
    prefixCls: e,
    className: S({
      [`${e}-icon-hide`]: !f,
      [`${e}-block-node`]: p,
      [`${e}-unselectable`]: !n,
      [`${e}-rtl`]: m === "rtl"
    }, r == null ? void 0 : r.className, C, k, y),
    direction: m,
    checkable: i && /* @__PURE__ */ t.createElement("span", {
      className: `${e}-checkbox-inner`
    }),
    selectable: n,
    switcherIcon: P,
    draggable: E
  }), x));
});
process.env.NODE_ENV !== "production" && (b.displayName = "Tree");
const U = b;
export {
  U as default
};
