'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('quiz-interactions/lib/components/common/components/rce/RichContentRenderer');

var _RichContentRenderer2 = _interopRequireDefault(_RichContentRenderer);

var _formatMessage = require('../../../../../common/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._23PClAl7_8sYn3LpCx9qXH {\n  border-bottom: ' + theme.rootBorderWidth + ' solid ' + theme.rootBorderColor + ';\n  overflow: hidden;\n}\n\n._3EYWDO61_qOUsEmtf5r4Hz {\n  padding: ' + theme.instructionsPaddingTopBottom + ' ' + theme.instructionsPaddingLeftRight + ';\n  border: ' + theme.instructionsBorderWidth + ' solid ' + theme.instructionsBorderColor + ';\n}\n\n._2bVzmkGC3B7ZRKtNLynHc- {\n  padding-bottom: ' + theme.instructionsHeaderPadding + ';\n  font-weight: ' + theme.instructionsHeaderFontWeight + ';\n}\n\n._3NHmzQKku3TtFQId7umtH4 {\n  padding: ' + theme.infoPaddingTopBottom + ' ' + theme.infoPaddingLeftRight + ';\n  background-color: ' + theme.infoBackgroundColor + ';\n  height: 100%;\n  overflow: scroll;\n}\n\n._2TriwqwLRpdVBf1y3oz2jD {\n  padding-top: ' + theme.headerPaddingTop + ';\n  padding-bottom: ' + theme.headerPaddingBottom + ';\n}\n\n._1GoDXe8NlSL39mVz2yt9D1 {\n  font-size: ' + theme.titleFontSize + ';\n  font-weight: ' + theme.titleFontWeight + ';\n}\n\n._3rmOPEdIqlPy-T87q9CO_y {\n  padding: ' + theme.itemsPadding + ';\n  width: 50%;\n}\n\n._15SPOQS8y4UTmsU71jjtdo {\n  flex: 1 1 auto;\n}\n\n._2X01sQsxZ9Fjpa09c9Sbj- {\n  display: flex;\n  flex-direction: row;\n}\n\n._2pp9UWGHu249ThNGEZeOhC {\n  width: 50%;\n}\n\n@media screen and (--phoneBreakPoint) {\n  ._2X01sQsxZ9Fjpa09c9Sbj- {\n    flex-direction: column;\n  }\n\n  ._2pp9UWGHu249ThNGEZeOhC {\n    width: 100%;\n  }\n\n  ._3rmOPEdIqlPy-T87q9CO_y {\n    width: 100%;\n  }\n\n  ._3EYWDO61_qOUsEmtf5r4Hz {\n    padding: ' + theme.phoneInstructionsPaddingTopBottom + ' ' + theme.phoneInstructionsPaddingLeftRight + ';\n  }\n\n  ._3NHmzQKku3TtFQId7umtH4 {\n    padding: ' + theme.phoneInfoPadding + ';\n  }\n\n  ._1k1JzCpXeTvrznAfCQrs8i {\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': '_23PClAl7_8sYn3LpCx9qXH',
  'instructions': '_3EYWDO61_qOUsEmtf5r4Hz',
  'instructionsHeader': '_2bVzmkGC3B7ZRKtNLynHc-',
  'info': '_3NHmzQKku3TtFQId7umtH4',
  'header': '_2TriwqwLRpdVBf1y3oz2jD',
  'title': '_1GoDXe8NlSL39mVz2yt9D1',
  'items': '_3rmOPEdIqlPy-T87q9CO_y',
  'stimulusItem': '_15SPOQS8y4UTmsU71jjtdo',
  'stimulusGroup': '_2X01sQsxZ9Fjpa09c9Sbj-',
  'stimulusInfo': '_2pp9UWGHu249ThNGEZeOhC',
  'connectingLines': '_1k1JzCpXeTvrznAfCQrs8i'
};
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;