"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

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

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf3 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));

var _Heading = _interopRequireDefault(require("@instructure/ui-elements/lib/components/Heading"));

var _Alert = _interopRequireDefault(require("@instructure/ui-alerts/lib/components/Alert"));

var _lib = _interopRequireDefault(require("@instructure/ui-themeable/lib"));

var _formatMessage = _interopRequireDefault(require("@instructure/quiz-common/lib/format-message"));

var _theme = _interopRequireDefault(require("./theme"));

var _dec, _class, _class2, _temp;

var styles = {
  componentId: 'eSNUQ',
  template: function template(theme) {
    return "\n\n.Header__styles__resultListHeading {\n  display: flex;\n  justify-content: flex-start;\n}\n\n.Header__styles__resultListInfo {\n  margin: ".concat(theme.resultListInfoMargin || 'inherit', ";\n  display: flex;\n  flex-wrap: wrap;\n  justify-content: flex-start;\n  align-items: center;\n}\n\n.Header__styles__resultListTitle {\n  width: 100%;\n  font-size: ").concat(theme.resultListTitleFontSize || 'inherit', ";\n  margin: ").concat(theme.resultListTitleMargin || 'inherit', " 0;\n}\n\n.Header__styles__resultListDescription {\n  width: 100%;\n}\n\n.Header__styles__regradeAlert {\n  padding-left: ").concat(theme.regradeAlertPadding || 'inherit', ";\n  padding-right: ").concat(theme.regradeAlertPadding || 'inherit', ";\n}\n");
  },
  'resultListHeading': 'Header__styles__resultListHeading',
  'resultListInfo': 'Header__styles__resultListInfo',
  'resultListTitle': 'Header__styles__resultListTitle',
  'resultListDescription': 'Header__styles__resultListDescription',
  'regradeAlert': 'Header__styles__regradeAlert'
};
var QuizSessionResultHeader = (_dec = (0, _lib.default)(_theme.default, styles), _dec(_class = (_temp = _class2 =
/*#__PURE__*/
function (_Component) {
  (0, _inherits2.default)(QuizSessionResultHeader, _Component);

  function QuizSessionResultHeader() {
    var _getPrototypeOf2;

    var _this;

    (0, _classCallCheck2.default)(this, QuizSessionResultHeader);

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

    _this = (0, _possibleConstructorReturn2.default)(this, (_getPrototypeOf2 = (0, _getPrototypeOf3.default)(QuizSessionResultHeader)).call.apply(_getPrototypeOf2, [this].concat(args)));

    _this.renderRegradeAlert = function () {
      if (_this.props.regradedSessionItemResults && _this.props.regradedSessionItemResults.size > 0) {
        var _s, _n;

        var questions = _this.props.regradedSessionItemResults.map(function (rsi) {
          return rsi.position;
        }).toJS().join(', ');

        return _react.default.createElement(_Alert.default, {
          variant: "warning"
        }, "Kua whakahoutia t\u0113nei aromatawai " + (_s = _this.props.regradedSessionItemResults.count(), _n = +_s, _n === 1 ? " te p\u0101tai " + questions + ".kua p\u0101ngiatia" : ("Ng\u0101 p\u0101tai " + questions + " kua p\u0101ngiatia.")));
      }
    };

    return _this;
  }

  (0, _createClass2.default)(QuizSessionResultHeader, [{
    key: "studentName",
    value: function studentName() {
      return this.props.quizSession.userDisplayName();
    }
  }, {
    key: "render",
    value: function render() {
      return _react.default.createElement("div", null, _react.default.createElement("div", {
        className: styles.resultListHeading
      }, _react.default.createElement("div", {
        className: styles.resultListInfo
      }, _react.default.createElement("div", {
        className: styles.resultListTitle
      }, _react.default.createElement(_Heading.default, {
        level: "h1"
      }, "Ng\u0101 hua")), _react.default.createElement("div", {
        className: styles.resultListDescription
      }, this.props.studentDescription || this.studentName()))), _react.default.createElement("div", {
        className: styles.regradeAlert
      }, this.renderRegradeAlert()));
    }
  }]);
  QuizSessionResultHeader.displayName = "QuizSessionResultHeader";
  return QuizSessionResultHeader;
}(_react.Component), _class2.propTypes = {
  quizSession: _reactImmutableProptypes.default.record.isRequired,
  regradedSessionItemResults: _reactImmutableProptypes.default.list,
  studentDescription: _propTypes.default.node
}, _class2.defaultProps = {
  regradedSessionItemResults: null,
  studentDescription: null
}, _temp)) || _class);
exports.default = QuizSessionResultHeader;