'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.updateQuizSubmitFlag = exports.submitQuizSessionEvent = exports.sessionStartOrResumeEvent = exports.loadResumeData = exports.editResponse = exports.previewResponse = exports.updateTimerInfo = exports.updateQuizSessionStatusOnPageLoad = exports.updateIsTaking = exports.updateTimerMinimized = exports.backtrackingNextQuestion = exports.previousQuestion = exports.setCurrentSessionItemPosition = undefined;

var _uuid = require('uuid');

var _constants = require('../../constants');

var setCurrentSessionItemPosition = exports.setCurrentSessionItemPosition = function setCurrentSessionItemPosition(position) {
  return {
    type: _constants.SET_CURRENT_SESSION_ITEM_POSITION,
    payload: { position: position }
  };
};

var previousQuestion = exports.previousQuestion = function previousQuestion() {
  return {
    type: _constants.PREVIOUS_QUESTION,
    payload: {}
  };
};

var backtrackingNextQuestion = exports.backtrackingNextQuestion = function backtrackingNextQuestion() {
  return {
    type: _constants.BACKTRACKING_NEXT_QUESTION,
    payload: {}
  };
};

var updateTimerMinimized = exports.updateTimerMinimized = function updateTimerMinimized(bool) {
  return {
    type: _constants.UPDATE_TIMER_MINIMIZED,
    payload: {
      timerMinimized: bool
    }
  };
};

var updateIsTaking = exports.updateIsTaking = function updateIsTaking(bool) {
  return {
    type: _constants.UPDATE_IS_TAKING,
    payload: {
      isTaking: bool
    }
  };
};

var updateQuizSessionStatusOnPageLoad = exports.updateQuizSessionStatusOnPageLoad = function updateQuizSessionStatusOnPageLoad(status) {
  return {
    type: _constants.UPDATE_QUIZ_SESSION_STATUS_ON_PAGE_LOAD,
    payload: {
      quizSessionStatusOnPageLoad: status
    }
  };
};

var updateTimerInfo = exports.updateTimerInfo = function updateTimerInfo(timerData) {
  return {
    type: _constants.UPDATE_TIMER_INFO,
    payload: {
      timeLeftInSeconds: timerData.timeLeftInSeconds,
      timerRunning: timerData.timerRunning || false,
      timeRecording: timerData.timeRecording || false
    }
  };
};

var previewResponse = exports.previewResponse = function previewResponse(quizEntry, value) {
  return {
    type: _constants.PREVIEW_RESPONSE,
    payload: {
      position: quizEntry.position,
      itemId: quizEntry.getEntry().id,
      userResponse: { value: value }
    }
  };
};

var editResponse = exports.editResponse = function editResponse(sessionItem, value) {
  return {
    type: _constants.RESPONSE,
    payload: {
      position: sessionItem.position,
      itemId: sessionItem.getItem().id,
      userResponse: { value: value }
    }
  };
};

var loadResumeData = exports.loadResumeData = function loadResumeData(resumeData) {
  return {
    type: _constants.LOAD_RESUME_DATA,
    payload: resumeData
  };
};

var sessionStartOrResumeEvent = exports.sessionStartOrResumeEvent = function sessionStartOrResumeEvent(userAgent) {
  return {
    type: _constants.SESSION_STARTED_OR_RESUMED_EVENT,
    payload: {
      userAgent: userAgent,
      browserSessionId: (0, _uuid.v4)()
    }
  };
};

var submitQuizSessionEvent = exports.submitQuizSessionEvent = function submitQuizSessionEvent() {
  return {
    type: _constants.QUIZ_SUBMISSION_EVENT,
    payload: {}
  };
};

var updateQuizSubmitFlag = exports.updateQuizSubmitFlag = function updateQuizSubmitFlag(value) {
  return {
    type: _constants.UPDATE_QUIZ_SUBMIT_FLAG,
    payload: { value: value }
  };
};