"use strict";

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

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

var _reducer = require("../Overlay/reducer");

var _component = _interopRequireDefault(require("./component"));

var _reducer2 = require("./reducer");

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

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var mapStateToProps = function mapStateToProps(_ref) {
  var sharedTouchDevice = _ref.sharedTouchDevice,
      modal = _ref.modal;
  var isTouchDevice = sharedTouchDevice.isTouchDevice;
  var activeModalIds = modal.activeModalIds,
      activeOverlayModalIds = modal.activeOverlayModalIds;
  return {
    isTouchDevice: isTouchDevice,
    activeModalIds: activeModalIds,
    activeOverlayModalIds: activeOverlayModalIds
  };
};

var mergeProps = function mergeProps(state, _ref2, ownProps) {
  var dispatch = _ref2.dispatch;
  return _objectSpread({}, state, ownProps, {
    onOverlayToggle: function onOverlayToggle(_ref3) {
      var event = _ref3.event,
          selectedModalId = _ref3.id,
          hasOverlay = _ref3.hasOverlay,
          showOverlay = _ref3.showOverlay;
      event.stopPropagation();
      dispatch((0, _reducer2.modalToggle)({
        selectedModalId: selectedModalId,
        hasOverlay: hasOverlay
      }));
      hasOverlay && dispatch(showOverlay ? (0, _reducer.overlayShow)() : (0, _reducer.overlayHide)());
    }
  });
};

var _default = (0, _reactRedux.connect)(mapStateToProps, undefined, mergeProps)(_component.default);

exports.default = _default;