import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import React from 'react';
import PropTypes from 'prop-types';
import { isFunction } from '../util/isType';
/**
 * @ignore
 * */

var TD =
/*#__PURE__*/
function (_React$Component) {
  _inherits(TD, _React$Component);

  function TD() {
    var _getPrototypeOf2;

    var _this;

    _classCallCheck(this, TD);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(TD)).call.apply(_getPrototypeOf2, [this].concat(args)));

    _defineProperty(_assertThisInitialized(_this), "levelRender", function (level) {
      if (!level) return '';
      var result = [];

      for (var i = 0; i < level; i++) {
        result.push(React.createElement("div", {
          style: {
            "width": "50px",
            "height": "2px",
            "float": "left"
          }
        }));
      }

      return result;
    });

    return _this;
  }

  _createClass(TD, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          content = _this$props.content,
          render = _this$props.render,
          level = _this$props.level,
          other = _objectWithoutProperties(_this$props, ["content", "render", "level"]);

      return React.createElement("td", other, this.levelRender(level), isFunction(render) ? render(content) : content);
    }
  }]);

  return TD;
}(React.Component);

_defineProperty(TD, "defaultProps", {});

_defineProperty(TD, "propTypes", {
  content: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array, PropTypes.bool, PropTypes.object]),
  render: PropTypes.func
});

export default TD;