'use strict';

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

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _dec, _class, _class2, _temp;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactImmutableProptypes = require('react-immutable-proptypes');

var _reactImmutableProptypes2 = _interopRequireDefault(_reactImmutableProptypes);

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

var _lib2 = _interopRequireDefault(_lib);

var _RichContentRenderer = require('@instructure/quiz-rce/lib/components/RichContentRenderer');

var _RichContentRenderer2 = _interopRequireDefault(_RichContentRenderer);

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

var _formatMessage2 = _interopRequireDefault(_formatMessage);

var _theme = require('./theme');

var _theme2 = _interopRequireDefault(_theme);

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

var styles = {
  template: function template(theme) {
    return '/*  imported from styles.css  */\n\n._1gFu1030HRGlbIZ4CZq-E_ {\n  border-bottom: ' + theme.rootBorderWidth + ' solid ' + theme.rootBorderColor + ';\n  overflow: hidden;\n}\n\n._4IIMbBuL-xFVgQz1_ICBc {\n  padding: ' + theme.instructionsPaddingTopBottom + ' ' + theme.instructionsPaddingLeftRight + ';\n  border: ' + theme.instructionsBorderWidth + ' solid ' + theme.instructionsBorderColor + ';\n}\n\n._3ZUEy4PrELL1IZh3LHcdO7 {\n  padding-bottom: ' + theme.instructionsHeaderPadding + ';\n  font-weight: ' + theme.instructionsHeaderFontWeight + ';\n}\n\n._2UqUxA8vgOiAE6F7sDgrLM {\n  padding: ' + theme.infoPaddingTopBottom + ' ' + theme.infoPaddingLeftRight + ';\n  background-color: ' + theme.infoBackgroundColor + ';\n  height: 100%;\n  overflow: scroll;\n}\n\n._27rADq9FaxRcRCmx4K3rWF {\n  padding-top: ' + theme.headerPaddingTop + ';\n  padding-bottom: ' + theme.headerPaddingBottom + ';\n}\n\n._2ZJJeL0upPGBI1iZ1wiOQM {\n  font-size: ' + theme.titleFontSize + ';\n  font-weight: ' + theme.titleFontWeight + ';\n}\n\n._3U0Gs0g-7izSOGiNOKBxcM {\n  padding: ' + theme.itemsPadding + ';\n  width: 50%;\n}\n\n._1jXdUFOgk-lIVKt3sdjcUd {\n  flex: 1 1 auto;\n}\n\n._1rXqUc8l4HgIGCm7r5ZtYO {\n  display: flex;\n  flex-direction: row;\n}\n\n._2OCpnoRQeOWGrpTNtLMS-e {\n  width: 50%;\n}\n\n@media screen and (--phoneBreakPoint) {\n  ._1rXqUc8l4HgIGCm7r5ZtYO {\n    flex-direction: column;\n  }\n\n  ._2OCpnoRQeOWGrpTNtLMS-e {\n    width: 100%;\n  }\n\n  ._3U0Gs0g-7izSOGiNOKBxcM {\n    width: 100%;\n  }\n\n  ._4IIMbBuL-xFVgQz1_ICBc {\n    padding: ' + theme.phoneInstructionsPaddingTopBottom + ' ' + theme.phoneInstructionsPaddingLeftRight + ';\n  }\n\n  ._2UqUxA8vgOiAE6F7sDgrLM {\n    padding: ' + theme.phoneInfoPadding + ';\n  }\n\n  ._143XfDNEUq0sLaINuJAdWe {\n    flex: 0 0 1rem;\n\n    border-left: ' + theme.phoneConnectingLinesBorderWidth + ' dotted;\n    border-bottom: ' + theme.phoneConnectingLinesBorderWidth + ' dotted;\n    border-color: ' + theme.phoneConnectingLinesBorderColor + ';\n\n    margin-top: ' + theme.phoneConnectingLinesMargin + ';\n    margin-right: ' + theme.phoneConnectingLinesMargin + ';\n    height: 2rem;\n    width: 1.5rem;\n  }\n}\n';
  },
  'root': '_1gFu1030HRGlbIZ4CZq-E_',
  'instructions': '_4IIMbBuL-xFVgQz1_ICBc',
  'instructionsHeader': '_3ZUEy4PrELL1IZh3LHcdO7',
  'info': '_2UqUxA8vgOiAE6F7sDgrLM',
  'header': '_27rADq9FaxRcRCmx4K3rWF',
  'title': '_2ZJJeL0upPGBI1iZ1wiOQM',
  'items': '_3U0Gs0g-7izSOGiNOKBxcM',
  'stimulusItem': '_1jXdUFOgk-lIVKt3sdjcUd',
  'stimulusGroup': '_1rXqUc8l4HgIGCm7r5ZtYO',
  'stimulusInfo': '_2OCpnoRQeOWGrpTNtLMS-e',
  'connectingLines': '_143XfDNEUq0sLaINuJAdWe'
};
var ResultStimulus = (_dec = (0, _lib2.default)(_theme2.default, styles), _dec(_class = (_temp = _class2 = function (_Component) {
  (0, _inherits3.default)(ResultStimulus, _Component);

  function ResultStimulus() {
    (0, _classCallCheck3.default)(this, ResultStimulus);
    return (0, _possibleConstructorReturn3.default)(this, (ResultStimulus.__proto__ || Object.getPrototypeOf(ResultStimulus)).apply(this, arguments));
  }

  (0, _createClass3.default)(ResultStimulus, [{
    key: 'renderStimulusInstructions',
    value: function renderStimulusInstructions() {
      var instructions = this.props.stimulus.instructions;
      if (instructions) {
        return _react2.default.createElement(
          'div',
          { className: styles.instructions },
          _react2.default.createElement(
            'div',
            { className: styles.instructionsHeader },
            (0, _formatMessage2.default)('Instructions')
          ),
          _react2.default.createElement(
            'div',
            null,
            instructions
          )
        );
      }
    }
  }, {
    key: 'renderStimulusInfo',
    value: function renderStimulusInfo() {
      var title = this.props.stimulus.title;
      var body = this.props.stimulus.body;
      return _react2.default.createElement(
        'div',
        { className: styles.info },
        _react2.default.createElement(
          'div',
          { className: styles.header },
          _react2.default.createElement(
            'div',
            { className: styles.title },
            title
          )
        ),
        _react2.default.createElement(_RichContentRenderer2.default, { content: body })
      );
    }
  }, {
    key: 'renderStimulusItems',
    value: function renderStimulusItems() {
      var _this2 = this;

      return this.props.sessionItem.getNestedEntries().toArray().map(function (sessionItem, i) {
        return _react2.default.createElement(
          'div',
          { key: sessionItem.position },
          _react2.default.createElement('div', { className: styles.connectingLines }),
          _react2.default.createElement(
            'div',
            { className: styles.stimulusItem },
            _this2.props.renderItem(sessionItem, i !== 0)
          )
        );
      });
    }
  }, {
    key: 'render',
    value: function render() {
      return _react2.default.createElement(
        'div',
        null,
        _react2.default.createElement(
          'div',
          { className: styles.root },
          this.renderStimulusInstructions(),
          _react2.default.createElement(
            'div',
            { className: styles.stimulusGroup },
            _react2.default.createElement(
              'div',
              { className: styles.stimulusInfo },
              this.renderStimulusInfo()
            ),
            _react2.default.createElement(
              'div',
              { className: styles.items },
              this.renderStimulusItems()
            )
          )
        )
      );
    }
  }]);
  ResultStimulus.displayName = 'ResultStimulus'
  ;
  return ResultStimulus;
}(_react.Component), _class2.propTypes = {
  stimulus: _reactImmutableProptypes2.default.record.isRequired,
  sessionItem: _reactImmutableProptypes2.default.record.isRequired,
  renderItem: _propTypes2.default.func.isRequired
}, _temp)) || _class);
exports.default = ResultStimulus;