"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _novaIcons = require("@coorpacademy/nova-icons");
var _keys = _interopRequireDefault(require("lodash/fp/keys"));
var _snakeCase = _interopRequireDefault(require("lodash/fp/snakeCase"));
var _link = _interopRequireDefault(require("../../atom/link"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const LeftIcons = {
  BlueValidatedCircle: _novaIcons.NovaSolidStatusCheckCircle2,
  LocaleInError: _novaIcons.NovaSolidStatusClose
};
const getIconDataName = iconType => iconType === 'LocaleInError' ? 'validated-locale-icon' : 'locale-in-error-icon';
const buildTab = (tab, index) => {
  const {
    title,
    selected,
    onClick,
    leftIcon,
    iconAriaLabel
  } = tab;
  const LeftIcon = LeftIcons[leftIcon];
  return /*#__PURE__*/_react.default.createElement("li", {
    "data-name": `vertical_tab_${(0, _snakeCase.default)(title)}`,
    className: (0, _classnames.default)(_style.default.tab, selected && _style.default.selected),
    key: index,
    onClick: onClick
  }, /*#__PURE__*/_react.default.createElement("span", {
    className: _style.default.title
  }, title), LeftIcon ? /*#__PURE__*/_react.default.createElement(LeftIcon, {
    "data-name": getIconDataName(leftIcon),
    "aria-label": iconAriaLabel,
    className: leftIcon === 'LocaleInError' ? _style.default.leftIconError : _style.default.leftIcon
  }) : null);
};
const VerticalTabs = props => {
  const {
    tabs,
    className,
    'aria-label': ariaLabel
  } = props;
  const tabsList = tabs.map(buildTab);
  return /*#__PURE__*/_react.default.createElement("ul", {
    className: (0, _classnames.default)([_style.default.wrapper, className]),
    title: ariaLabel
  }, tabsList);
};
const LeftIconValues = process.env.NODE_ENV !== "production" ? [...(0, _keys.default)(LeftIcons), ''] : {};
VerticalTabs.propTypes = process.env.NODE_ENV !== "production" ? {
  tabs: _propTypes.default.arrayOf(_propTypes.default.shape({
    title: _link.default.propTypes.children,
    selected: _propTypes.default.bool,
    leftIcon: _propTypes.default.oneOf(LeftIconValues),
    onClick: _propTypes.default.func,
    iconAriaLabel: _propTypes.default.string
  })),
  className: _propTypes.default.string,
  'aria-label': _propTypes.default.string
} : {};
var _default = exports.default = VerticalTabs;
//# sourceMappingURL=index.js.map