"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.TopBarNav = TopBarNav;
function _react() {
  const data = _interopRequireDefault(require("react"));
  _react = function () {
    return data;
  };
  return data;
}
function _classnames() {
  const data = _interopRequireDefault(require("classnames"));
  _classnames = function () {
    return data;
  };
  return data;
}
function _reactRouterDom() {
  const data = require("react-router-dom");
  _reactRouterDom = function () {
    return data;
  };
  return data;
}
function _baseReactNavigation() {
  const data = require("@teambit/base-react.navigation.link");
  _baseReactNavigation = function () {
    return data;
  };
  return data;
}
function _topBarNavModule() {
  const data = _interopRequireDefault(require("./top-bar-nav.module.scss"));
  _topBarNavModule = function () {
    return data;
  };
  return data;
}
const _excluded = ["href", "className", "activeClassName", "children", "displayName", "ignoreQueryParams"];
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
// @todo - this will be fixed as part of the @teambit/base-react.navigation.link upgrade to latest
const Link = _baseReactNavigation().Link;
function TopBarNav(_ref) {
  let {
      href,
      className,
      activeClassName,
      children,
      displayName,
      ignoreQueryParams
    } = _ref,
    rest = _objectWithoutProperties(_ref, _excluded);
  const {
    search
  } = (0, _reactRouterDom().useLocation)(); // sticky query params

  // @hack - this is so that the displayName will not pass to the link and cause a warning in the console.
  // it is used for component page nav link widgets (code, aspects etc),
  // but not for regular menu links (overview, compositions, etc).
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  const preventPassingDisplayNameToLink = displayName;
  const target = href && !ignoreQueryParams && `${href}${search}` || href;
  return /*#__PURE__*/_react().default.createElement(Link, _extends({}, rest, {
    className: (0, _classnames().default)(className, _topBarNavModule().default.topBarLink),
    activeClassName: (0, _classnames().default)(activeClassName, _topBarNavModule().default.active),
    href: target
  }), /*#__PURE__*/_react().default.createElement("div", null, children));
}

//# sourceMappingURL=top-bar-nav.js.map