'use strict';

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

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

var _SearchToRelateModal = require('../../components/search/SearchToRelateModal');

var _SearchToRelateModal2 = _interopRequireDefault(_SearchToRelateModal);

var _prefs = require('../../actions/prefs');

var _relation = require('../../actions/relation');

var _searchToRelate = require('../../actions/searchToRelate');

var _search = require('../../actions/search');

var _reducers = require('../../reducers');

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

const mapStateToProps = state => {
  const recordType = (0, _reducers.getSearchToRelateRecordType)(state);

  return {
    keywordValue: (0, _reducers.getSearchToRelateKeyword)(state),
    recordTypeValue: recordType,
    vocabularyValue: (0, _reducers.getSearchToRelateVocabulary)(state, recordType),
    advancedSearchCondition: (0, _reducers.getSearchToRelateAdvanced)(state),
    perms: (0, _reducers.getUserPerms)(state),
    preferredPageSize: (0, _reducers.getSearchToRelatePageSize)(state),
    selectedItems: (0, _reducers.getSearchSelectedItems)(state, _SearchToRelateModal.searchName)
  };
};

const mapDispatchToProps = {
  clearSearchResults: _search.clearSearchResults,
  search: _search.search,
  onAdvancedSearchConditionCommit: _searchToRelate.setSearchToRelateAdvanced,
  onKeywordCommit: _searchToRelate.setSearchToRelateKeyword,
  onRecordTypeCommit: _searchToRelate.setSearchToRelateRecordType,
  onVocabularyCommit: _searchToRelate.setSearchToRelateVocabulary,
  onItemSelectChange: _search.setResultItemSelected,
  createRelations: _relation.batchCreateBidirectional,
  setAllItemsSelected: _search.setAllResultItemsSelected,
  setPreferredPageSize: _prefs.setSearchToRelatePageSize
};

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