"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _reduxRecord = _interopRequireDefault(require("./reduxRecord"));

var QuizSessionEvent =
/*#__PURE__*/
function (_ReduxRecord) {
  (0, _inherits2.default)(QuizSessionEvent, _ReduxRecord);

  function QuizSessionEvent() {
    (0, _classCallCheck2.default)(this, QuizSessionEvent);
    return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(QuizSessionEvent).apply(this, arguments));
  }

  (0, _createClass2.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 = "".concat(this.quizSessionId, "_").concat(sessionItemPosition);
      return this.stateHelper().findSessionItem(sessionItemKey);
    }
  }, {
    key: "getItem",
    value: function getItem() {
      return this.getSessionItem().getItem();
    }
  }]);
  return QuizSessionEvent;
}((0, _reduxRecord.default)({
  createdAt: null,
  eventType: null,
  eventData: null,
  quizSessionId: null
}));

exports.default = QuizSessionEvent;