"use strict";

exports.__esModule = true;
exports.default = void 0;
var _noop2 = _interopRequireDefault(require("lodash/fp/noop"));
var _has2 = _interopRequireDefault(require("lodash/fp/has"));
var _getOr2 = _interopRequireDefault(require("lodash/fp/getOr"));
var _url = require("url");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/* eslint-disable node/no-deprecated-api */

const isLeftClickEvent = e => e.button === 0;
const isModifiedEvent = e => !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
const navigation = options => {
  const _history = (0, _getOr2.default)({}, 'history', options);
  if (!(0, _has2.default)('push', _history)) {
    return () => _noop2.default;
  }
  return ({
    href
  } = {}) => e => {
    if (!href || e.defaultPrevented || isModifiedEvent(e) || !isLeftClickEvent(e)) {
      return;
    }
    if ((0, _url.parse)(href).host) return;
    e.preventDefault();
    _history.push(href);
  };
};
var _default = exports.default = navigation;
//# sourceMappingURL=navigation.js.map