import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import React from 'react';
import classNames from 'classnames';
import { ConfigContext } from '../config-provider/context';
import VerticalTree from './verticalTree';
import HorizontalTree from './horizontalTree';

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

  var _React$useContext = React.useContext(ConfigContext),
      getPrefixClassName = _React$useContext.getPrefixClassName;

  var treePrefix = getPrefixClassName('tree', prefixCls);
  var cls = classNames(treePrefix, _defineProperty({}, "".concat(treePrefix, "-").concat(direction), direction), className);
  return /*#__PURE__*/React.createElement(React.Fragment, null, direction === 'horizontal' ? /*#__PURE__*/React.createElement(HorizontalTree, Object.assign({}, props, {
    prefixCls: treePrefix,
    className: cls,
    ref: ref
  })) : /*#__PURE__*/React.createElement(VerticalTree, Object.assign({}, props, {
    prefixCls: treePrefix,
    className: cls,
    ref: ref
  })));
};

var Tree = /*#__PURE__*/React.forwardRef(TreeRefRenderFunction);
Tree.defaultProps = {
  direction: 'horizontal'
};
export default Tree;