"use strict";

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

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

var _styledComponents = require("./styled-components.js");

var _checkIndeterminate = _interopRequireDefault(require("../icon/check-indeterminate.js"));

var _plus = _interopRequireDefault(require("../icon/plus.js"));

var _overrides = require("../helpers/overrides.js");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var TreeLabel = function TreeLabel(_ref) {
  var hasChildren = _ref.hasChildren,
      isExpanded = _ref.isExpanded,
      label = _ref.label,
      _ref$overrides = _ref.overrides,
      overrides = _ref$overrides === void 0 ? {} : _ref$overrides,
      node = _ref.node,
      props = _objectWithoutProperties(_ref, ["hasChildren", "isExpanded", "label", "overrides", "node"]);

  var IconContainerOverride = overrides.IconContainer,
      ExapandIconOverride = overrides.ExpandIcon,
      CollapseIconOverride = overrides.CollapseIcon,
      TreeItemContentOverride = overrides.TreeItemContent;

  var IconContainer = (0, _overrides.getOverride)(IconContainerOverride) || _styledComponents.StyledIconContainer;

  var ExpandIcon = (0, _overrides.getOverride)(ExapandIconOverride) || _plus.default;

  var CollapseIcon = (0, _overrides.getOverride)(CollapseIconOverride) || _checkIndeterminate.default;

  var TreeItemContent = (0, _overrides.getOverride)(TreeItemContentOverride) || _styledComponents.StyledItemContent;

  return _react.default.createElement(TreeItemContent, props, hasChildren && _react.default.createElement(IconContainer, (0, _overrides.getOverrideProps)(IconContainerOverride), !isExpanded ? _react.default.createElement(ExpandIcon, (0, _overrides.getOverrideProps)(ExapandIconOverride)) : _react.default.createElement(CollapseIcon, (0, _overrides.getOverrideProps)(CollapseIconOverride))), typeof label === 'function' ? label(node) : label);
};

var _default = TreeLabel;
exports.default = _default;