import ye from "../../@babel/runtime/helpers/esm/extends.mjs";
import W from "../../@babel/runtime/helpers/esm/defineProperty.mjs";
import ge from "../../@babel/runtime/helpers/esm/typeof.mjs";
import T from "../../@babel/runtime/helpers/esm/objectSpread2.mjs";
import X from "../../@babel/runtime/helpers/esm/toConsumableArray.mjs";
import he from "../../@babel/runtime/helpers/esm/classCallCheck.mjs";
import Ke from "../../@babel/runtime/helpers/esm/createClass.mjs";
import V from "../../@babel/runtime/helpers/esm/assertThisInitialized.mjs";
import Ne from "../../@babel/runtime/helpers/esm/inherits.mjs";
import me from "../../@babel/runtime/helpers/esm/createSuper.mjs";
import ke from "../../classnames/index.mjs";
import A from "../../rc-util/es/KeyCode.mjs";
import De from "../../rc-util/es/pickAttrs.mjs";
import { warningOnce as j } from "../../rc-util/es/warning.mjs";
import * as M from "react";
import { TreeContext as Ee } from "./contextTypes.mjs";
import xe from "./DropIndicator.mjs";
import Ce, { MotionEntity as Se, MOTION_KEY as J } from "./NodeList.mjs";
import Te from "./TreeNode.mjs";
import { arrDel as b, getDragChildrenKeys as Pe, calcDropPosition as Q, arrAdd as O, posToArr as be, conductExpandParent as Z, calcSelectedKeys as ee, parseCheckedKeys as q } from "./util.mjs";
import { conductCheck as B } from "./utils/conductUtil.mjs";
import I from "./utils/keyUtil.mjs";
import { fillFieldNames as te, convertNodePropsToEventData as P, getTreeNodeProps as H, flattenTreeData as z, convertTreeToData as Oe, convertDataToEntities as we, warningWithoutKey as Le } from "./utils/treeUtil.mjs";
var Ae = 10, oe = /* @__PURE__ */ function(Y) {
  Ne($, Y);
  var G = me($);
  function $() {
    var e;
    he(this, $);
    for (var l = arguments.length, h = new Array(l), N = 0; N < l; N++)
      h[N] = arguments[N];
    return e = G.call.apply(G, [this].concat(h)), e.destroyed = !1, e.delayedDragEnterLogic = void 0, e.loadingRetryTimes = {}, e.state = {
      keyEntities: {},
      indent: null,
      selectedKeys: [],
      checkedKeys: [],
      halfCheckedKeys: [],
      loadedKeys: [],
      loadingKeys: [],
      expandedKeys: [],
      draggingNodeKey: null,
      dragChildrenKeys: [],
      // dropTargetKey is the key of abstract-drop-node
      // the abstract-drop-node is the real drop node when drag and drop
      // not the DOM drag over node
      dropTargetKey: null,
      dropPosition: null,
      dropContainerKey: null,
      dropLevelOffset: null,
      dropTargetPos: null,
      dropAllowed: !0,
      // the abstract-drag-over-node
      // if mouse is on the bottom of top dom node or no the top of the bottom dom node
      // abstract-drag-over-node is the top node
      dragOverNodeKey: null,
      treeData: [],
      flattenNodes: [],
      focused: !1,
      activeKey: null,
      listChanging: !1,
      prevProps: null,
      fieldNames: te()
    }, e.dragStartMousePosition = null, e.dragNode = void 0, e.currentMouseOverDroppableNodeKey = null, e.listRef = /* @__PURE__ */ M.createRef(), e.onNodeDragStart = function(t, n) {
      var o = e.state, r = o.expandedKeys, d = o.keyEntities, s = e.props.onDragStart, i = n.props.eventKey;
      e.dragNode = n, e.dragStartMousePosition = {
        x: t.clientX,
        y: t.clientY
      };
      var c = b(r, i);
      e.setState({
        draggingNodeKey: i,
        dragChildrenKeys: Pe(i, d),
        indent: e.listRef.current.getIndentWidth()
      }), e.setExpandedKeys(c), window.addEventListener("dragend", e.onWindowDragEnd), s == null || s({
        event: t,
        node: P(n.props)
      });
    }, e.onNodeDragEnter = function(t, n) {
      var o = e.state, r = o.expandedKeys, d = o.keyEntities, s = o.dragChildrenKeys, i = o.flattenNodes, c = o.indent, p = e.props, u = p.onDragEnter, a = p.onExpand, v = p.allowDrop, y = p.direction, f = n.props, g = f.pos, K = f.eventKey, m = V(e), k = m.dragNode;
      if (e.currentMouseOverDroppableNodeKey !== K && (e.currentMouseOverDroppableNodeKey = K), !k) {
        e.resetDragState();
        return;
      }
      var D = Q(t, k, n, c, e.dragStartMousePosition, v, i, d, r, y), C = D.dropPosition, E = D.dropLevelOffset, x = D.dropTargetKey, S = D.dropContainerKey, L = D.dropTargetPos, R = D.dropAllowed, _ = D.dragOverNodeKey;
      if (
        // don't allow drop inside its children
        s.indexOf(x) !== -1 || // don't allow drop when drop is not allowed caculated by calcDropPosition
        !R
      ) {
        e.resetDragState();
        return;
      }
      if (e.delayedDragEnterLogic || (e.delayedDragEnterLogic = {}), Object.keys(e.delayedDragEnterLogic).forEach(function(w) {
        clearTimeout(e.delayedDragEnterLogic[w]);
      }), k.props.eventKey !== n.props.eventKey && (t.persist(), e.delayedDragEnterLogic[g] = window.setTimeout(function() {
        if (e.state.draggingNodeKey !== null) {
          var w = X(r), U = I(d, n.props.eventKey);
          U && (U.children || []).length && (w = O(r, n.props.eventKey)), "expandedKeys" in e.props || e.setExpandedKeys(w), a == null || a(w, {
            node: P(n.props),
            expanded: !0,
            nativeEvent: t.nativeEvent
          });
        }
      }, 800)), k.props.eventKey === x && E === 0) {
        e.resetDragState();
        return;
      }
      e.setState({
        dragOverNodeKey: _,
        dropPosition: C,
        dropLevelOffset: E,
        dropTargetKey: x,
        dropContainerKey: S,
        dropTargetPos: L,
        dropAllowed: R
      }), u == null || u({
        event: t,
        node: P(n.props),
        expandedKeys: r
      });
    }, e.onNodeDragOver = function(t, n) {
      var o = e.state, r = o.dragChildrenKeys, d = o.flattenNodes, s = o.keyEntities, i = o.expandedKeys, c = o.indent, p = e.props, u = p.onDragOver, a = p.allowDrop, v = p.direction, y = V(e), f = y.dragNode;
      if (f) {
        var g = Q(t, f, n, c, e.dragStartMousePosition, a, d, s, i, v), K = g.dropPosition, m = g.dropLevelOffset, k = g.dropTargetKey, D = g.dropContainerKey, C = g.dropAllowed, E = g.dropTargetPos, x = g.dragOverNodeKey;
        r.indexOf(k) !== -1 || !C || (f.props.eventKey === k && m === 0 ? e.state.dropPosition === null && e.state.dropLevelOffset === null && e.state.dropTargetKey === null && e.state.dropContainerKey === null && e.state.dropTargetPos === null && e.state.dropAllowed === !1 && e.state.dragOverNodeKey === null || e.resetDragState() : K === e.state.dropPosition && m === e.state.dropLevelOffset && k === e.state.dropTargetKey && D === e.state.dropContainerKey && E === e.state.dropTargetPos && C === e.state.dropAllowed && x === e.state.dragOverNodeKey || e.setState({
          dropPosition: K,
          dropLevelOffset: m,
          dropTargetKey: k,
          dropContainerKey: D,
          dropTargetPos: E,
          dropAllowed: C,
          dragOverNodeKey: x
        }), u == null || u({
          event: t,
          node: P(n.props)
        }));
      }
    }, e.onNodeDragLeave = function(t, n) {
      e.currentMouseOverDroppableNodeKey === n.props.eventKey && !t.currentTarget.contains(t.relatedTarget) && (e.resetDragState(), e.currentMouseOverDroppableNodeKey = null);
      var o = e.props.onDragLeave;
      o == null || o({
        event: t,
        node: P(n.props)
      });
    }, e.onWindowDragEnd = function(t) {
      e.onNodeDragEnd(t, null, !0), window.removeEventListener("dragend", e.onWindowDragEnd);
    }, e.onNodeDragEnd = function(t, n) {
      var o = e.props.onDragEnd;
      e.setState({
        dragOverNodeKey: null
      }), e.cleanDragState(), o == null || o({
        event: t,
        node: P(n.props)
      }), e.dragNode = null, window.removeEventListener("dragend", e.onWindowDragEnd);
    }, e.onNodeDrop = function(t, n) {
      var o, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1, d = e.state, s = d.dragChildrenKeys, i = d.dropPosition, c = d.dropTargetKey, p = d.dropTargetPos, u = d.dropAllowed;
      if (u) {
        var a = e.props.onDrop;
        if (e.setState({
          dragOverNodeKey: null
        }), e.cleanDragState(), c !== null) {
          var v = T(T({}, H(c, e.getTreeNodeRequiredProps())), {}, {
            active: ((o = e.getActiveItem()) === null || o === void 0 ? void 0 : o.key) === c,
            data: I(e.state.keyEntities, c).node
          }), y = s.indexOf(c) !== -1;
          j(!y, "Can not drop to dragNode's children node. This is a bug of rc-tree. Please report an issue.");
          var f = be(p), g = {
            event: t,
            node: P(v),
            dragNode: e.dragNode ? P(e.dragNode.props) : null,
            dragNodesKeys: [e.dragNode.props.eventKey].concat(s),
            dropToGap: i !== 0,
            dropPosition: i + Number(f[f.length - 1])
          };
          r || a == null || a(g), e.dragNode = null;
        }
      }
    }, e.cleanDragState = function() {
      var t = e.state.draggingNodeKey;
      t !== null && e.setState({
        draggingNodeKey: null,
        dropPosition: null,
        dropContainerKey: null,
        dropTargetKey: null,
        dropLevelOffset: null,
        dropAllowed: !0,
        dragOverNodeKey: null
      }), e.dragStartMousePosition = null, e.currentMouseOverDroppableNodeKey = null;
    }, e.triggerExpandActionExpand = function(t, n) {
      var o = e.state, r = o.expandedKeys, d = o.flattenNodes, s = n.expanded, i = n.key, c = n.isLeaf;
      if (!(c || t.shiftKey || t.metaKey || t.ctrlKey)) {
        var p = d.filter(function(a) {
          return a.key === i;
        })[0], u = P(T(T({}, H(i, e.getTreeNodeRequiredProps())), {}, {
          data: p.data
        }));
        e.setExpandedKeys(s ? b(r, i) : O(r, i)), e.onNodeExpand(t, u);
      }
    }, e.onNodeClick = function(t, n) {
      var o = e.props, r = o.onClick, d = o.expandAction;
      d === "click" && e.triggerExpandActionExpand(t, n), r == null || r(t, n);
    }, e.onNodeDoubleClick = function(t, n) {
      var o = e.props, r = o.onDoubleClick, d = o.expandAction;
      d === "doubleClick" && e.triggerExpandActionExpand(t, n), r == null || r(t, n);
    }, e.onNodeSelect = function(t, n) {
      var o = e.state.selectedKeys, r = e.state, d = r.keyEntities, s = r.fieldNames, i = e.props, c = i.onSelect, p = i.multiple, u = n.selected, a = n[s.key], v = !u;
      v ? p ? o = O(o, a) : o = [a] : o = b(o, a);
      var y = o.map(function(f) {
        var g = I(d, f);
        return g ? g.node : null;
      }).filter(function(f) {
        return f;
      });
      e.setUncontrolledState({
        selectedKeys: o
      }), c == null || c(o, {
        event: "select",
        selected: v,
        node: n,
        selectedNodes: y,
        nativeEvent: t.nativeEvent
      });
    }, e.onNodeCheck = function(t, n, o) {
      var r = e.state, d = r.keyEntities, s = r.checkedKeys, i = r.halfCheckedKeys, c = e.props, p = c.checkStrictly, u = c.onCheck, a = n.key, v, y = {
        event: "check",
        node: n,
        checked: o,
        nativeEvent: t.nativeEvent
      };
      if (p) {
        var f = o ? O(s, a) : b(s, a), g = b(i, a);
        v = {
          checked: f,
          halfChecked: g
        }, y.checkedNodes = f.map(function(E) {
          return I(d, E);
        }).filter(function(E) {
          return E;
        }).map(function(E) {
          return E.node;
        }), e.setUncontrolledState({
          checkedKeys: f
        });
      } else {
        var K = B([].concat(X(s), [a]), !0, d), m = K.checkedKeys, k = K.halfCheckedKeys;
        if (!o) {
          var D = new Set(m);
          D.delete(a);
          var C = B(Array.from(D), {
            checked: !1,
            halfCheckedKeys: k
          }, d);
          m = C.checkedKeys, k = C.halfCheckedKeys;
        }
        v = m, y.checkedNodes = [], y.checkedNodesPositions = [], y.halfCheckedKeys = k, m.forEach(function(E) {
          var x = I(d, E);
          if (x) {
            var S = x.node, L = x.pos;
            y.checkedNodes.push(S), y.checkedNodesPositions.push({
              node: S,
              pos: L
            });
          }
        }), e.setUncontrolledState({
          checkedKeys: m
        }, !1, {
          halfCheckedKeys: k
        });
      }
      u == null || u(v, y);
    }, e.onNodeLoad = function(t) {
      var n = t.key, o = new Promise(function(r, d) {
        e.setState(function(s) {
          var i = s.loadedKeys, c = i === void 0 ? [] : i, p = s.loadingKeys, u = p === void 0 ? [] : p, a = e.props, v = a.loadData, y = a.onLoad;
          if (!v || c.indexOf(n) !== -1 || u.indexOf(n) !== -1)
            return null;
          var f = v(t);
          return f.then(function() {
            var g = e.state.loadedKeys, K = O(g, n);
            y == null || y(K, {
              event: "load",
              node: t
            }), e.setUncontrolledState({
              loadedKeys: K
            }), e.setState(function(m) {
              return {
                loadingKeys: b(m.loadingKeys, n)
              };
            }), r();
          }).catch(function(g) {
            if (e.setState(function(m) {
              return {
                loadingKeys: b(m.loadingKeys, n)
              };
            }), e.loadingRetryTimes[n] = (e.loadingRetryTimes[n] || 0) + 1, e.loadingRetryTimes[n] >= Ae) {
              var K = e.state.loadedKeys;
              j(!1, "Retry for `loadData` many times but still failed. No more retry."), e.setUncontrolledState({
                loadedKeys: O(K, n)
              }), r();
            }
            d(g);
          }), {
            loadingKeys: O(u, n)
          };
        });
      });
      return o.catch(function() {
      }), o;
    }, e.onNodeMouseEnter = function(t, n) {
      var o = e.props.onMouseEnter;
      o == null || o({
        event: t,
        node: n
      });
    }, e.onNodeMouseLeave = function(t, n) {
      var o = e.props.onMouseLeave;
      o == null || o({
        event: t,
        node: n
      });
    }, e.onNodeContextMenu = function(t, n) {
      var o = e.props.onRightClick;
      o && (t.preventDefault(), o({
        event: t,
        node: n
      }));
    }, e.onFocus = function() {
      var t = e.props.onFocus;
      e.setState({
        focused: !0
      });
      for (var n = arguments.length, o = new Array(n), r = 0; r < n; r++)
        o[r] = arguments[r];
      t == null || t.apply(void 0, o);
    }, e.onBlur = function() {
      var t = e.props.onBlur;
      e.setState({
        focused: !1
      }), e.onActiveChange(null);
      for (var n = arguments.length, o = new Array(n), r = 0; r < n; r++)
        o[r] = arguments[r];
      t == null || t.apply(void 0, o);
    }, e.getTreeNodeRequiredProps = function() {
      var t = e.state, n = t.expandedKeys, o = t.selectedKeys, r = t.loadedKeys, d = t.loadingKeys, s = t.checkedKeys, i = t.halfCheckedKeys, c = t.dragOverNodeKey, p = t.dropPosition, u = t.keyEntities;
      return {
        expandedKeys: n || [],
        selectedKeys: o || [],
        loadedKeys: r || [],
        loadingKeys: d || [],
        checkedKeys: s || [],
        halfCheckedKeys: i || [],
        dragOverNodeKey: c,
        dropPosition: p,
        keyEntities: u
      };
    }, e.setExpandedKeys = function(t) {
      var n = e.state, o = n.treeData, r = n.fieldNames, d = z(o, t, r);
      e.setUncontrolledState({
        expandedKeys: t,
        flattenNodes: d
      }, !0);
    }, e.onNodeExpand = function(t, n) {
      var o = e.state.expandedKeys, r = e.state, d = r.listChanging, s = r.fieldNames, i = e.props, c = i.onExpand, p = i.loadData, u = n.expanded, a = n[s.key];
      if (!d) {
        var v = o.indexOf(a), y = !u;
        if (j(u && v !== -1 || !u && v === -1, "Expand state not sync with index check"), y ? o = O(o, a) : o = b(o, a), e.setExpandedKeys(o), c == null || c(o, {
          node: n,
          expanded: y,
          nativeEvent: t.nativeEvent
        }), y && p) {
          var f = e.onNodeLoad(n);
          f && f.then(function() {
            var g = z(e.state.treeData, o, s);
            e.setUncontrolledState({
              flattenNodes: g
            });
          }).catch(function() {
            var g = e.state.expandedKeys, K = b(g, a);
            e.setExpandedKeys(K);
          });
        }
      }
    }, e.onListChangeStart = function() {
      e.setUncontrolledState({
        listChanging: !0
      });
    }, e.onListChangeEnd = function() {
      setTimeout(function() {
        e.setUncontrolledState({
          listChanging: !1
        });
      });
    }, e.onActiveChange = function(t) {
      var n = e.state.activeKey, o = e.props, r = o.onActiveChange, d = o.itemScrollOffset, s = d === void 0 ? 0 : d;
      n !== t && (e.setState({
        activeKey: t
      }), t !== null && e.scrollTo({
        key: t,
        offset: s
      }), r == null || r(t));
    }, e.getActiveItem = function() {
      var t = e.state, n = t.activeKey, o = t.flattenNodes;
      return n === null ? null : o.find(function(r) {
        var d = r.key;
        return d === n;
      }) || null;
    }, e.offsetActiveKey = function(t) {
      var n = e.state, o = n.flattenNodes, r = n.activeKey, d = o.findIndex(function(c) {
        var p = c.key;
        return p === r;
      });
      d === -1 && t < 0 && (d = o.length), d = (d + t + o.length) % o.length;
      var s = o[d];
      if (s) {
        var i = s.key;
        e.onActiveChange(i);
      } else
        e.onActiveChange(null);
    }, e.onKeyDown = function(t) {
      var n = e.state, o = n.activeKey, r = n.expandedKeys, d = n.checkedKeys, s = n.fieldNames, i = e.props, c = i.onKeyDown, p = i.checkable, u = i.selectable;
      switch (t.which) {
        case A.UP: {
          e.offsetActiveKey(-1), t.preventDefault();
          break;
        }
        case A.DOWN: {
          e.offsetActiveKey(1), t.preventDefault();
          break;
        }
      }
      var a = e.getActiveItem();
      if (a && a.data) {
        var v = e.getTreeNodeRequiredProps(), y = a.data.isLeaf === !1 || !!(a.data[s.children] || []).length, f = P(T(T({}, H(o, v)), {}, {
          data: a.data,
          active: !0
        }));
        switch (t.which) {
          case A.LEFT: {
            y && r.includes(o) ? e.onNodeExpand({}, f) : a.parent && e.onActiveChange(a.parent.key), t.preventDefault();
            break;
          }
          case A.RIGHT: {
            y && !r.includes(o) ? e.onNodeExpand({}, f) : a.children && a.children.length && e.onActiveChange(a.children[0].key), t.preventDefault();
            break;
          }
          case A.ENTER:
          case A.SPACE: {
            p && !f.disabled && f.checkable !== !1 && !f.disableCheckbox ? e.onNodeCheck({}, f, !d.includes(o)) : !p && u && !f.disabled && f.selectable !== !1 && e.onNodeSelect({}, f);
            break;
          }
        }
      }
      c == null || c(t);
    }, e.setUncontrolledState = function(t) {
      var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, o = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
      if (!e.destroyed) {
        var r = !1, d = !0, s = {};
        Object.keys(t).forEach(function(i) {
          if (i in e.props) {
            d = !1;
            return;
          }
          r = !0, s[i] = t[i];
        }), r && (!n || d) && e.setState(T(T({}, s), o));
      }
    }, e.scrollTo = function(t) {
      e.listRef.current.scrollTo(t);
    }, e;
  }
  return Ke($, [{
    key: "componentDidMount",
    value: function() {
      this.destroyed = !1, this.onUpdated();
    }
  }, {
    key: "componentDidUpdate",
    value: function() {
      this.onUpdated();
    }
  }, {
    key: "onUpdated",
    value: function() {
      var l = this.props, h = l.activeKey, N = l.itemScrollOffset, t = N === void 0 ? 0 : N;
      h !== void 0 && h !== this.state.activeKey && (this.setState({
        activeKey: h
      }), h !== null && this.scrollTo({
        key: h,
        offset: t
      }));
    }
  }, {
    key: "componentWillUnmount",
    value: function() {
      window.removeEventListener("dragend", this.onWindowDragEnd), this.destroyed = !0;
    }
  }, {
    key: "resetDragState",
    value: function() {
      this.setState({
        dragOverNodeKey: null,
        dropPosition: null,
        dropLevelOffset: null,
        dropTargetKey: null,
        dropContainerKey: null,
        dropTargetPos: null,
        dropAllowed: !1
      });
    }
  }, {
    key: "render",
    value: function() {
      var l, h = this.state, N = h.focused, t = h.flattenNodes, n = h.keyEntities, o = h.draggingNodeKey, r = h.activeKey, d = h.dropLevelOffset, s = h.dropContainerKey, i = h.dropTargetKey, c = h.dropPosition, p = h.dragOverNodeKey, u = h.indent, a = this.props, v = a.prefixCls, y = a.className, f = a.style, g = a.showLine, K = a.focusable, m = a.tabIndex, k = m === void 0 ? 0 : m, D = a.selectable, C = a.showIcon, E = a.icon, x = a.switcherIcon, S = a.draggable, L = a.checkable, R = a.checkStrictly, _ = a.disabled, w = a.motion, U = a.loadData, ne = a.filterTreeNode, ae = a.height, re = a.itemHeight, de = a.virtual, ie = a.titleRender, se = a.dropIndicatorRender, le = a.onContextMenu, ce = a.onScroll, fe = a.direction, pe = a.rootClassName, ue = a.rootStyle, ve = De(this.props, {
        aria: !0,
        data: !0
      }), F;
      return S && (ge(S) === "object" ? F = S : typeof S == "function" ? F = {
        nodeDraggable: S
      } : F = {}), /* @__PURE__ */ M.createElement(Ee.Provider, {
        value: {
          prefixCls: v,
          selectable: D,
          showIcon: C,
          icon: E,
          switcherIcon: x,
          draggable: F,
          draggingNodeKey: o,
          checkable: L,
          checkStrictly: R,
          disabled: _,
          keyEntities: n,
          dropLevelOffset: d,
          dropContainerKey: s,
          dropTargetKey: i,
          dropPosition: c,
          dragOverNodeKey: p,
          indent: u,
          direction: fe,
          dropIndicatorRender: se,
          loadData: U,
          filterTreeNode: ne,
          titleRender: ie,
          onNodeClick: this.onNodeClick,
          onNodeDoubleClick: this.onNodeDoubleClick,
          onNodeExpand: this.onNodeExpand,
          onNodeSelect: this.onNodeSelect,
          onNodeCheck: this.onNodeCheck,
          onNodeLoad: this.onNodeLoad,
          onNodeMouseEnter: this.onNodeMouseEnter,
          onNodeMouseLeave: this.onNodeMouseLeave,
          onNodeContextMenu: this.onNodeContextMenu,
          onNodeDragStart: this.onNodeDragStart,
          onNodeDragEnter: this.onNodeDragEnter,
          onNodeDragOver: this.onNodeDragOver,
          onNodeDragLeave: this.onNodeDragLeave,
          onNodeDragEnd: this.onNodeDragEnd,
          onNodeDrop: this.onNodeDrop
        }
      }, /* @__PURE__ */ M.createElement("div", {
        role: "tree",
        className: ke(v, y, pe, (l = {}, W(l, "".concat(v, "-show-line"), g), W(l, "".concat(v, "-focused"), N), W(l, "".concat(v, "-active-focused"), r !== null), l)),
        style: ue
      }, /* @__PURE__ */ M.createElement(Ce, ye({
        ref: this.listRef,
        prefixCls: v,
        style: f,
        data: t,
        disabled: _,
        selectable: D,
        checkable: !!L,
        motion: w,
        dragging: o !== null,
        height: ae,
        itemHeight: re,
        virtual: de,
        focusable: K,
        focused: N,
        tabIndex: k,
        activeItem: this.getActiveItem(),
        onFocus: this.onFocus,
        onBlur: this.onBlur,
        onKeyDown: this.onKeyDown,
        onActiveChange: this.onActiveChange,
        onListChangeStart: this.onListChangeStart,
        onListChangeEnd: this.onListChangeEnd,
        onContextMenu: le,
        onScroll: ce
      }, this.getTreeNodeRequiredProps(), ve))));
    }
  }], [{
    key: "getDerivedStateFromProps",
    value: function(l, h) {
      var N = h.prevProps, t = {
        prevProps: l
      };
      function n(K) {
        return !N && K in l || N && N[K] !== l[K];
      }
      var o, r = h.fieldNames;
      if (n("fieldNames") && (r = te(l.fieldNames), t.fieldNames = r), n("treeData") ? o = l.treeData : n("children") && (j(!1, "`children` of Tree is deprecated. Please use `treeData` instead."), o = Oe(l.children)), o) {
        t.treeData = o;
        var d = we(o, {
          fieldNames: r
        });
        t.keyEntities = T(W({}, J, Se), d.keyEntities), process.env.NODE_ENV !== "production" && Le(o, r);
      }
      var s = t.keyEntities || h.keyEntities;
      if (n("expandedKeys") || N && n("autoExpandParent"))
        t.expandedKeys = l.autoExpandParent || !N && l.defaultExpandParent ? Z(l.expandedKeys, s) : l.expandedKeys;
      else if (!N && l.defaultExpandAll) {
        var i = T({}, s);
        delete i[J], t.expandedKeys = Object.keys(i).map(function(K) {
          return i[K].key;
        });
      } else
        !N && l.defaultExpandedKeys && (t.expandedKeys = l.autoExpandParent || l.defaultExpandParent ? Z(l.defaultExpandedKeys, s) : l.defaultExpandedKeys);
      if (t.expandedKeys || delete t.expandedKeys, o || t.expandedKeys) {
        var c = z(o || h.treeData, t.expandedKeys || h.expandedKeys, r);
        t.flattenNodes = c;
      }
      if (l.selectable && (n("selectedKeys") ? t.selectedKeys = ee(l.selectedKeys, l) : !N && l.defaultSelectedKeys && (t.selectedKeys = ee(l.defaultSelectedKeys, l))), l.checkable) {
        var p;
        if (n("checkedKeys") ? p = q(l.checkedKeys) || {} : !N && l.defaultCheckedKeys ? p = q(l.defaultCheckedKeys) || {} : o && (p = q(l.checkedKeys) || {
          checkedKeys: h.checkedKeys,
          halfCheckedKeys: h.halfCheckedKeys
        }), p) {
          var u = p, a = u.checkedKeys, v = a === void 0 ? [] : a, y = u.halfCheckedKeys, f = y === void 0 ? [] : y;
          if (!l.checkStrictly) {
            var g = B(v, !0, s);
            v = g.checkedKeys, f = g.halfCheckedKeys;
          }
          t.checkedKeys = v, t.halfCheckedKeys = f;
        }
      }
      return n("loadedKeys") && (t.loadedKeys = l.loadedKeys), t;
    }
  }]), $;
}(M.Component);
oe.defaultProps = {
  prefixCls: "rc-tree",
  showLine: !1,
  showIcon: !0,
  selectable: !0,
  multiple: !1,
  checkable: !1,
  disabled: !1,
  checkStrictly: !1,
  draggable: !1,
  defaultExpandParent: !0,
  autoExpandParent: !1,
  defaultExpandAll: !1,
  defaultExpandedKeys: [],
  defaultCheckedKeys: [],
  defaultSelectedKeys: [],
  dropIndicatorRender: xe,
  allowDrop: function() {
    return !0;
  },
  expandAction: !1
};
oe.TreeNode = Te;
export {
  oe as default
};
