"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _novaIcons = require("@coorpacademy/nova-icons");
var _provider = _interopRequireWildcard(require("../provider"));
var _style = _interopRequireDefault(require("./style.css"));
var _types = _interopRequireDefault(require("./types"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const Content = (props, legacyContext) => {
  const {
    icon,
    current,
    value
  } = props;
  const translate = (0, _provider.GetTranslateFromContext)(legacyContext);
  let child;
  let contentAriaLabel;
  switch (icon) {
    case 'no-answer':
      child = value;
      contentAriaLabel = translate('review_header_step_item.not_answered_question', {
        current: current ? 'current ' : '',
        headerStepValue: value
      });
      break;
    case 'right':
      child = /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademyCheck, {
        className: (0, _classnames.default)(_style.default.rightIcon, current && _style.default.currentRightIcon),
        role: "status",
        "aria-label": translate('review_header_step_item.correct_question', {
          current: current ? 'current ' : '',
          headerStepValue: value
        })
      });
      break;
    case 'wrong':
      child = /*#__PURE__*/_react.default.createElement(_novaIcons.NovaSolidStatusClose, {
        className: (0, _classnames.default)(_style.default.wrongIcon, current && _style.default.currentWrongIcon),
        role: "alert",
        "aria-label": translate('review_header_step_item.incorrect_question', {
          current: current ? 'current ' : '',
          headerStepValue: value
        })
      });
      break;
    case 'errors-number':
      child = value;
      contentAriaLabel = translate('bulk_import.errors_number', {
        bulkImportErrorsNumber: value
      });
      break;
    case 'valid':
      child = /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademyCheck, {
        className: (0, _classnames.default)(_style.default.validIcon),
        role: "status",
        "aria-label": translate('bulk_import.valid_scorm')
      });
      break;
    case 'invalid':
      child = /*#__PURE__*/_react.default.createElement(_novaIcons.NovaSolidStatusClose, {
        className: (0, _classnames.default)(_style.default.invalidIcon),
        role: "alert",
        "aria-label": translate('bulk_import.invalid_scorm')
      });
      break;
    default:
      return null;
  }
  return /*#__PURE__*/_react.default.createElement("span", _extends({}, icon === 'no-answer' || icon === 'errors-number' ? {
    'aria-label': contentAriaLabel,
    role: 'status'
  } : {}, {
    className: _style.default.value
  }), child);
};
const StatusItem = props => {
  const {
    icon,
    current,
    selected
  } = props;
  return /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _classnames.default)(_style.default.defaultStyle, icon === 'right' && _style.default.right, icon === 'wrong' && _style.default.wrong, current && _style.default.current, icon === 'valid' && _style.default.valid, icon === 'invalid' && _style.default.invalid, icon === 'errors-number' && _style.default.errorsNumber, selected && _style.default.selected),
    "data-name": "status-item"
  }, /*#__PURE__*/_react.default.createElement(Content, props));
};
Content.propTypes = process.env.NODE_ENV !== "production" ? _types.default : {};
Content.contextTypes = {
  skin: _provider.default.childContextTypes.skin,
  translate: _provider.default.childContextTypes.translate
};
StatusItem.propTypes = process.env.NODE_ENV !== "production" ? _types.default : {};
var _default = exports.default = StatusItem;
//# sourceMappingURL=index.js.map