"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.SidebarMenuLink = SidebarMenuLink;
var _react = _interopRequireDefault(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _faCircleXmark = require("@fortawesome/free-solid-svg-icons/faCircleXmark");
var _fontAwesomeIcon = require("../font-awesome-icon");
var _useNonNativeButtonAttrs = require("../hooks/use-non-native-button-attrs");
var _useTranslation = require("../hooks/use-translation");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function SidebarMenuLink({
  children,
  className,
  link,
  itemKey,
  testId,
  isExternal = false,
  onClick = () => {},
  hasErrors = () => '',
  sectionErrorAriaLabel,
  isDisabled = false
}) {
  const {
    t
  } = (0, _useTranslation.useTranslation)();
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("a", {
    className: (0, _classnames.default)(className, {
      disabled: isDisabled
    }),
    href: link,
    onClick: e => onClick(e, itemKey),
    target: isExternal ? '_blank' : undefined,
    rel: "noopener noreferrer",
    "test-id": testId,
    tabIndex: (0, _useNonNativeButtonAttrs.getTabIndex)(isDisabled),
    children: [children, hasErrors() ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_fontAwesomeIcon.FontAwesomeIcon, {
      icon: _faCircleXmark.faCircleXmark,
      className: "sidebar-menu-link-error-icon",
      "aria-label": sectionErrorAriaLabel ?? t('Section has errors'),
      "aria-hidden": "false"
    }) : null]
  });
}