'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 _reduxRecord = require('./reduxRecord');

var _reduxRecord2 = _interopRequireDefault(_reduxRecord);

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

var QuizSessionEvent = function (_ReduxRecord) {
  (0, _inherits3.default)(QuizSessionEvent, _ReduxRecord);

  function QuizSessionEvent() {
    (0, _classCallCheck3.default)(this, QuizSessionEvent);
    return (0, _possibleConstructorReturn3.default)(this, (QuizSessionEvent.__proto__ || Object.getPrototypeOf(QuizSessionEvent)).apply(this, arguments));
  }

  (0, _createClass3.default)(QuizSessionEvent, [{
    key: 'isLoaded',
    value: function isLoaded() {
      return !!this.get('createdAt');
    }
  }, {
    key: 'createdDate',
    value: function createdDate() {
      return new Date(this.get('createdAt').split('|')[0]);
    }
  }, {
    key: 'getSessionItem',
    value: function getSessionItem() {
      var sessionItemPosition = Math.round(this.getIn(['eventData', 'position']));
      var sessionItemKey = this.quizSessionId + '_' + sessionItemPosition;
      return this.stateHelper().findSessionItem(sessionItemKey);
    }
  }, {
    key: 'getItem',
    value: function getItem() {
      return this.getSessionItem().getItem();
    }
  }]);
  return QuizSessionEvent;
}((0, _reduxRecord2.default)({
  createdAt: null,
  eventType: null,
  eventData: null,
  quizSessionId: null
}));

exports.default = QuizSessionEvent;