'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.ResultStimulus__styles__root {\n  border-bottom: ' + theme.rootBorderWidth + ' solid ' + theme.rootBorderColor + ';\n  overflow: hidden;\n}\n\n.ResultStimulus__styles__instructions {\n  padding: ' + theme.instructionsPaddingTopBottom + ' ' + theme.instructionsPaddingLeftRight + ';\n  border: ' + theme.instructionsBorderWidth + ' solid ' + theme.instructionsBorderColor + ';\n}\n\n.ResultStimulus__styles__instructionsHeader {\n  padding-bottom: ' + theme.instructionsHeaderPadding + ';\n  font-weight: ' + theme.instructionsHeaderFontWeight + ';\n}\n\n.ResultStimulus__styles__info {\n  padding: ' + theme.infoPaddingTopBottom + ' ' + theme.infoPaddingLeftRight + ';\n  background-color: ' + theme.infoBackgroundColor + ';\n  height: 100%;\n  overflow: scroll;\n}\n\n.ResultStimulus__styles__header {\n  padding-top: ' + theme.headerPaddingTop + ';\n  padding-bottom: ' + theme.headerPaddingBottom + ';\n}\n\n.ResultStimulus__styles__title {\n  font-size: ' + theme.titleFontSize + ';\n  font-weight: ' + theme.titleFontWeight + ';\n}\n\n.ResultStimulus__styles__items {\n  padding: ' + theme.itemsPadding + ';\n  width: 50%;\n}\n\n.ResultStimulus__styles__stimulusItem {\n  flex: 1 1 auto;\n}\n\n.ResultStimulus__styles__stimulusGroup {\n  display: flex;\n  flex-direction: row;\n}\n\n.ResultStimulus__styles__stimulusInfo {\n  width: 50%;\n}\n\n@media screen and (--phoneBreakPoint) {\n  .ResultStimulus__styles__stimulusGroup {\n    flex-direction: column;\n  }\n\n  .ResultStimulus__styles__stimulusInfo {\n    width: 100%;\n  }\n\n  .ResultStimulus__styles__items {\n    width: 100%;\n  }\n\n  .ResultStimulus__styles__instructions {\n    padding: ' + theme.phoneInstructionsPaddingTopBottom + ' ' + theme.phoneInstructionsPaddingLeftRight + ';\n  }\n\n  .ResultStimulus__styles__info {\n    padding: ' + theme.phoneInfoPadding + ';\n  }\n\n  .ResultStimulus__styles__connectingLines {\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': 'ResultStimulus__styles__root',
  'instructions': 'ResultStimulus__styles__instructions',
  'instructionsHeader': 'ResultStimulus__styles__instructionsHeader',
  'info': 'ResultStimulus__styles__info',
  'header': 'ResultStimulus__styles__header',
  'title': 'ResultStimulus__styles__title',
  'items': 'ResultStimulus__styles__items',
  'stimulusItem': 'ResultStimulus__styles__stimulusItem',
  'stimulusGroup': 'ResultStimulus__styles__stimulusGroup',
  'stimulusInfo': 'ResultStimulus__styles__stimulusInfo',
  'connectingLines': 'ResultStimulus__styles__connectingLines'
};
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 },
            'Anweisungen'
          ),
          _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;