'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, _temp2;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _reactImmutableProptypes2 = _interopRequireDefault(_reactImmutableProptypes);

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

var _Heading2 = _interopRequireDefault(_Heading);

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

var _lib2 = _interopRequireDefault(_lib);

var _formatMessage = require('../../../../format-message');

var _formatMessage2 = _interopRequireDefault(_formatMessage);

var _CustomPropTypes = require('../../../../util/CustomPropTypes');

var _CustomPropTypes2 = _interopRequireDefault(_CustomPropTypes);

var _SessionItemResult = require('../SessionItemResult');

var _SessionItemResult2 = _interopRequireDefault(_SessionItemResult);

var _ResultStimulus = require('../ResultStimulus');

var _ResultStimulus2 = _interopRequireDefault(_ResultStimulus);

var _generateDisplayPositions = require('../../../../util/generateDisplayPositions');

var _generateDisplayPositions2 = _interopRequireDefault(_generateDisplayPositions);

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.SessionItemResultsList__styles__sessionItemResultsListHeaderWrapper {\n  text-align: left;\n  margin: ' + theme.sessionItemResultsListHeaderWrapperMarginTopBottom + ' ' + theme.sessionItemResultsListHeaderWrapperMarginLeftRight + ';\n}\n\n[dir="ltr"] .SessionItemResultsList__styles__sessionItemResultsListHeaderWrapper {\n  text-align: left;\n}\n\n[dir="rtl"] .SessionItemResultsList__styles__sessionItemResultsListHeaderWrapper {\n  text-align: left;\n}\n\n.SessionItemResultsList__styles__sessionItemResultsListHeader {\n  font-size: ' + theme.sessionItemResultsListHeaderFontSize + ';\n}\n\n.SessionItemResultsList__styles__sessionItemResultsList {\n  margin-top: ' + theme.sessionItemResultsListMargin + ';\n  border-bottom: solid ' + theme.sessionItemResultsListBorderWidth + ' ' + theme.sessionItemResultsListBorderColor + ';\n}\n';
  },
  'sessionItemResultsListHeaderWrapper': 'SessionItemResultsList__styles__sessionItemResultsListHeaderWrapper',
  'sessionItemResultsListHeader': 'SessionItemResultsList__styles__sessionItemResultsListHeader',
  'sessionItemResultsList': 'SessionItemResultsList__styles__sessionItemResultsList'
};
var SessionItemResultsList = (_dec = (0, _lib2.default)(_theme2.default, styles), _dec(_class = (_temp2 = _class2 = function (_Component) {
  (0, _inherits3.default)(SessionItemResultsList, _Component);

  function SessionItemResultsList() {
    var _ref;

    var _temp, _this, _ret;

    (0, _classCallCheck3.default)(this, SessionItemResultsList);

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

    return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = SessionItemResultsList.__proto__ || Object.getPrototypeOf(SessionItemResultsList)).call.apply(_ref, [this].concat(args))), _this), _this.renderSessionItem = function (sessionItem, shouldRenderTopBorder) {
      return _react2.default.createElement(_SessionItemResult2.default, {
        appContainer: _this.props.appContainer,
        key: sessionItem.id,
        sessionItem: sessionItem,
        sessionItemResult: sessionItem.sessionItemResult,
        shouldRenderTopBorder: shouldRenderTopBorder
      });
    }, _this.renderItems = function () {
      return (0, _generateDisplayPositions2.default)(_this.props.sessionItems).map(function (si) {
        return _this.renderItem(si.record);
      });
    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  }

  (0, _createClass3.default)(SessionItemResultsList, [{
    key: 'renderItem',
    value: function renderItem(sessionItem) {
      if (sessionItem.isStimulus) {
        return _react2.default.createElement(_ResultStimulus2.default, {
          key: sessionItem.id,
          renderItem: this.renderSessionItem,
          stimulus: sessionItem.stimulusRecord,
          sessionItem: sessionItem
        });
      }
      return this.renderSessionItem(sessionItem, true);
    }
  }, {
    key: 'render',
    value: function render() {
      return _react2.default.createElement(
        'div',
        null,
        _react2.default.createElement(
          'div',
          { className: styles.sessionItemResultsListHeaderWrapper },
          _react2.default.createElement(
            'div',
            { className: styles.sessionItemResultsListHeader },
            _react2.default.createElement(
              _Heading2.default,
              { level: 'h2' },
              'Repons Ou yo:'
            )
          )
        ),
        _react2.default.createElement(
          'div',
          { className: styles.sessionItemResultsList },
          this.renderItems()
        )
      );
    }
  }]);
  SessionItemResultsList.displayName = 'SessionItemResultsList'
  ;
  return SessionItemResultsList;
}(_react.Component), _class2.propTypes = {
  appContainer: _CustomPropTypes2.default.selectors.isRequired,
  sessionItems: _reactImmutableProptypes2.default.list.isRequired
}, _temp2)) || _class);
exports.default = SessionItemResultsList;