'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('@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.qkHJImJ6PrWsM86kIuI9G {\n  border-bottom: ' + theme.rootBorderWidth + ' solid ' + theme.rootBorderColor + ';\n  overflow: hidden;\n}\n\n.MM-RB79qWeQMNI7jUqQnn {\n  padding: ' + theme.instructionsPaddingTopBottom + ' ' + theme.instructionsPaddingLeftRight + ';\n  border: ' + theme.instructionsBorderWidth + ' solid ' + theme.instructionsBorderColor + ';\n}\n\n._1A8-0W5Zfh4cU2FVAWK6Xx {\n  padding-bottom: ' + theme.instructionsHeaderPadding + ';\n  font-weight: ' + theme.instructionsHeaderFontWeight + ';\n}\n\n.yM8DjxZpHEqjwI3E9_yyl {\n  padding: ' + theme.infoPaddingTopBottom + ' ' + theme.infoPaddingLeftRight + ';\n  background-color: ' + theme.infoBackgroundColor + ';\n  height: 100%;\n  overflow: scroll;\n}\n\n._3a7y6i9mobxL-JG8hn1ou1 {\n  padding-top: ' + theme.headerPaddingTop + ';\n  padding-bottom: ' + theme.headerPaddingBottom + ';\n}\n\n._1GplnbUWOn5T4f7NmHMkgv {\n  font-size: ' + theme.titleFontSize + ';\n  font-weight: ' + theme.titleFontWeight + ';\n}\n\n._3bTUQ-AV7aIbWqueNPXouA {\n  padding: ' + theme.itemsPadding + ';\n  width: 50%;\n}\n\n.CK3y4ZALZI7ngNQOSoh8L {\n  flex: 1 1 auto;\n}\n\n.wz8aMUPkP01qbzX1HW0nm {\n  display: flex;\n  flex-direction: row;\n}\n\n._3ArnLy_8T5hN4HkL_EoZ9O {\n  width: 50%;\n}\n\n@media screen and (--phoneBreakPoint) {\n  .wz8aMUPkP01qbzX1HW0nm {\n    flex-direction: column;\n  }\n\n  ._3ArnLy_8T5hN4HkL_EoZ9O {\n    width: 100%;\n  }\n\n  ._3bTUQ-AV7aIbWqueNPXouA {\n    width: 100%;\n  }\n\n  .MM-RB79qWeQMNI7jUqQnn {\n    padding: ' + theme.phoneInstructionsPaddingTopBottom + ' ' + theme.phoneInstructionsPaddingLeftRight + ';\n  }\n\n  .yM8DjxZpHEqjwI3E9_yyl {\n    padding: ' + theme.phoneInfoPadding + ';\n  }\n\n  ._3NIf8EKEvT-MnetLjppSCV {\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': 'qkHJImJ6PrWsM86kIuI9G',
  'instructions': 'MM-RB79qWeQMNI7jUqQnn',
  'instructionsHeader': '_1A8-0W5Zfh4cU2FVAWK6Xx',
  'info': 'yM8DjxZpHEqjwI3E9_yyl',
  'header': '_3a7y6i9mobxL-JG8hn1ou1',
  'title': '_1GplnbUWOn5T4f7NmHMkgv',
  'items': '_3bTUQ-AV7aIbWqueNPXouA',
  'stimulusItem': 'CK3y4ZALZI7ngNQOSoh8L',
  'stimulusGroup': 'wz8aMUPkP01qbzX1HW0nm',
  'stimulusInfo': '_3ArnLy_8T5hN4HkL_EoZ9O',
  'connectingLines': '_3NIf8EKEvT-MnetLjppSCV'
};
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;