var _excluded = ["scope"];
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import { useEventListener } from './EventListener';
function bindHotkeys(_ref) {
  var _ref$dependencies = _ref.dependencies,
    dependencies = _ref$dependencies === void 0 ? [] : _ref$dependencies,
    _ref$event = _ref.event,
    event = _ref$event === void 0 ? 'keydown' : _ref$event,
    _ref$handler = _ref.handler,
    _handler = _ref$handler === void 0 ? function () {} : _ref$handler,
    key = _ref.key,
    preventDefault = _ref.preventDefault,
    stopPropagation = _ref.stopPropagation;
  return function (scope) {
    var keys = Array.isArray(key) ? key : [key];
    useEventListener({
      dependencies: dependencies,
      event: event,
      handler: function handler(e) {
        if (keys.includes(e.key)) {
          _handler(e);
          preventDefault && e.preventDefault();
          stopPropagation && e.stopPropagation();
        }
      },
      scope: scope
    });
  };
}

/**
 * @deprecatedSince 9.7.0
 * @deprecated Pass functions directly to JSX elements. For window events, add a new listener and remove it in an effect
 */
export function useHotkey(_ref2) {
  var _ref2$scope = _ref2.scope,
    scope = _ref2$scope === void 0 ? window : _ref2$scope,
    config = _objectWithoutProperties(_ref2, _excluded);
  var scopes = Array.isArray(scope) ? scope : [scope];
  scopes.forEach(bindHotkeys(config));
}
//# sourceMappingURL=Hotkey.js.map