"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _immutable = require("immutable");

var _constants = require("@instructure/quiz-common/lib/constants");

function addQuizSessionEvents(state, quizSessionEvents) {
  // in practice all events will share the same quizSessionId for now
  var quizSessionId = quizSessionEvents[0].quizSessionId; // add a new list or concat with a preexisting list

  return state.updateIn([quizSessionId], (0, _immutable.List)(), function (events) {
    return events.concat((0, _immutable.fromJS)(quizSessionEvents));
  });
}

var defaultState = (0, _immutable.fromJS)({});

var _default = function _default() {
  var state = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaultState;
  var action = arguments.length > 1 ? arguments[1] : void 0;

  switch (action.type) {
    case _constants.ADD_QUIZ_SESSION_EVENTS:
      return addQuizSessionEvents(state, action.payload);

    default:
      return state;
  }
};

exports.default = _default;