'use strict';

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

var _immutable = require('immutable');

var _reactRedux = require('../../../../common/react-redux');

var _SessionItem = require('../../../../common/records/SessionItem');

var _SessionItem2 = _interopRequireDefault(_SessionItem);

var _QuizSession = require('../../../../common/records/QuizSession');

var _QuizSession2 = _interopRequireDefault(_QuizSession);

var _QuizSessionResult = require('../../../../common/records/QuizSessionResult');

var _QuizSessionResult2 = _interopRequireDefault(_QuizSessionResult);

var _presenter = require('./presenter');

var _presenter2 = _interopRequireDefault(_presenter);

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

var mapStateToProps = exports.mapStateToProps = function mapStateToProps(state) {
  var quizSessionId = state.getIn(['quizSessions', 'activeQuizSessionId']);
  var quizSession = new _QuizSession2.default(state.getIn(['quizSessions', quizSessionId]));
  var qsrId = quizSession.authoritativeResult;
  var authoritativeResult = new _QuizSessionResult2.default(state.getIn(['quizSessionResults', qsrId]));

  var sessionItems = state.get('sessionItems', (0, _immutable.Map)()).map(function (si) {
    return new _SessionItem2.default(si);
  }).sortBy(function (si) {
    return si.position;
  }).toList();
  var sessionItemResults = state.get('sessionItemResults', (0, _immutable.Map)()).toList();

  return {
    quizSession: quizSession,
    quizSessionResult: authoritativeResult,
    sessionItems: sessionItems,
    sessionItemResults: sessionItemResults
  };
};

exports.default = (0, _reactRedux.connect)(mapStateToProps)(_presenter2.default);