"use strict";

exports.__esModule = true;
exports.default = exports.useNavigationHandler = void 0;

var _reactRouterDom = require("react-router-dom");

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var analyzeHref = function analyzeHref(href, location) {
  var url = new URL(href || "", window.location.origin);
  var local = url.origin === window.location.origin;
  var self = location.pathname === url.pathname && location.search === url.search && location.hash === url.hash;
  return {
    local: local,
    self: self,
    active: href && local && location.pathname.substr(0, url.pathname.length) === url.pathname
  };
};

var useNavigationHandler = function useNavigationHandler(href) {
  var location = (0, _reactRouterDom.useLocation)();
  var history = (0, _reactRouterDom.useHistory)();

  var _analyzeHref = analyzeHref(href, location),
      local = _analyzeHref.local,
      self = _analyzeHref.self,
      active = _analyzeHref.active;

  return [function (event) {
    if (local) {
      event.preventDefault();

      if (href && !self) {
        history.push(href);
      }
    }
  }, active];
};

exports.useNavigationHandler = useNavigationHandler;

__signature__(useNavigationHandler, "useLocation{location}\nuseHistory{history}", function () {
  return [_reactRouterDom.useLocation, _reactRouterDom.useHistory];
});

__signature__(useNavigationHandler, "useLocation{location}\nuseHistory{history}", function () {
  return [_reactRouterDom.useLocation, _reactRouterDom.useHistory];
});

var _default = useNavigationHandler;
var _default2 = _default;
var _default3 = _default2;
exports.default = _default3;
;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(analyzeHref, "analyzeHref", "/home/vsts/work/1/s/src/hooks/useNavigationHandler.js");
  reactHotLoader.register(useNavigationHandler, "useNavigationHandler", "/home/vsts/work/1/s/src/hooks/useNavigationHandler.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/hooks/useNavigationHandler.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();

;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(analyzeHref, "analyzeHref", "/home/vsts/work/1/s/src/hooks/useNavigationHandler.js");
  reactHotLoader.register(useNavigationHandler, "useNavigationHandler", "/home/vsts/work/1/s/src/hooks/useNavigationHandler.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/hooks/useNavigationHandler.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();