'use strict';

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

var _redux = require('redux');

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

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

var _presenter2 = _interopRequireDefault(_presenter);

var _scrolling = require('../../../../actions/scrolling');

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

function getStimulus(parent) {
  return parent.entryType === 'BankEntry' ? parent.getEntry().getEntry() : parent.getEntry();
}

var mapDispatchToProps = exports.mapDispatchToProps = function mapDispatchToProps(dispatch, props) {
  return {
    childEntries: props.stimulusParent.getNestedEntries(),
    scrollToItem: props.scrollToItem || (0, _redux.bindActionCreators)(_scrolling.scrollToItem, dispatch)
  };
};

var mapStateToProps = exports.mapStateToProps = function mapStateToProps(state, props) {
  var stimulus = getStimulus(props.stimulusParent);
  var isShowingItems = state.getIn(['sidebar', stimulus.id], false);
  return {
    isShowingItems: isShowingItems,
    stimulus: stimulus
  };
};

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