'use strict';

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

var _redux = require('redux');

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

var _stateHelper = require('../../../../util/stateHelper');

var _stateHelper2 = _interopRequireDefault(_stateHelper);

var _sidebar = require('../../../../actions/sidebar');

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

var _presenter2 = _interopRequireDefault(_presenter);

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

var mapStateToProps = exports.mapStateToProps = function mapStateToProps(state, props) {
  var helper = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _stateHelper2.default;

  var hideOnTake = helper.isOneQuestionAtATime() && !helper.backtrackingIsAllowed();
  var quizSessionNotLoaded = helper.activeQuizSession().id === '0';
  var hidden = !!props.onTake && (hideOnTake || quizSessionNotLoaded);

  return { hidden: hidden };
};

function mapDispatchToProps(dispatch, props) {
  return {
    sidebarMenuClick: props.sidebarMenuClick || (0, _redux.bindActionCreators)(_sidebar.toggleSidebar, dispatch)
  };
}

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