"use strict";

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

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

var _notification = require("../../actions/notification");

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

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

var _RelationEditor = _interopRequireDefault(require("../../components/record/RelationEditor"));

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

const mapStateToProps = (state, ownProps) => {
  const {
    subject,
    object,
    predicate
  } = ownProps;
  return {
    objectData: (0, _reducers.getRecordData)(state, object.csid),
    objectError: (0, _reducers.getRecordError)(state, object.csid),
    findResult: (0, _reducers.getRelationFindResult)(state, subject, object, predicate),
    openModalName: (0, _reducers.getOpenModalName)(state)
  };
};

const mapDispatchToProps = {
  closeModal: _notification.closeModal,
  openModal: _notification.openModal,
  createRelation: _relation.createBidirectional,
  findRelation: _relation.find,
  unrelate: _relation.unrelateBidirectional,
  onUnmount: _relation.clearState
};

var _default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_RelationEditor.default);

exports.default = _default;