"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _context = require("../config-provider/context");

var _verticalTree = _interopRequireDefault(require("./verticalTree"));

var _horizontalTree = _interopRequireDefault(require("./horizontalTree"));

var TreeRefRenderFunction = function TreeRefRenderFunction(props, ref) {
  var prefixCls = props.prefixCls,
      direction = props.direction,
      className = props.className;

  var _React$useContext = _react.default.useContext(_context.ConfigContext),
      getPrefixClassName = _React$useContext.getPrefixClassName;

  var treePrefix = getPrefixClassName('tree', prefixCls);
  var cls = (0, _classnames.default)(treePrefix, (0, _defineProperty2.default)({}, "".concat(treePrefix, "-").concat(direction), direction), className);
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, direction === 'horizontal' ? /*#__PURE__*/_react.default.createElement(_horizontalTree.default, Object.assign({}, props, {
    prefixCls: treePrefix,
    className: cls,
    ref: ref
  })) : /*#__PURE__*/_react.default.createElement(_verticalTree.default, Object.assign({}, props, {
    prefixCls: treePrefix,
    className: cls,
    ref: ref
  })));
};

var Tree = /*#__PURE__*/_react.default.forwardRef(TreeRefRenderFunction);

Tree.defaultProps = {
  direction: 'horizontal'
};
var _default = Tree;
exports.default = _default;