'use strict';

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

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

var _makeEditable = require('../../../../../../common/components/shared/functionality/makeEditable');

var _makeEditable2 = _interopRequireDefault(_makeEditable);

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

var _presenter2 = _interopRequireDefault(_presenter);

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

function mapStateToProps(state, props) {
  var entry = props.entry,
      quizEntry = props.quizEntry,
      workingQuizEntry = props.workingQuizEntry;

  var workingEntry = void 0;
  if (quizEntry.isItem || quizEntry.isBankEntry) {
    workingEntry = workingQuizEntry.getItem();
  } else {
    // This component is repurposed in RegradingOverride where we're editing a
    // quiz entry that doesn't have a specific item. For that case we expect
    // Bank quizEntry with Item entry.
    workingEntry = entry.getWorkingInstance();
  }

  return {
    workingEntry: workingEntry
  };
}

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