import { jsx, jsxs } from "react/jsx-runtime";
import { Stack, VisuallyHidden } from "@contember/ui";
import { isNonEmptyTrimmedString, assert } from "@contember/utilities";
import { ArrowLeftIcon } from "lucide-react";
import { memo } from "react";
import { Link } from "./Link.js";
import { useMessageFormatter } from "../../i18n/useMessageFormatter.js";
const navigationBackLinkDictionary = {
  navigationBackLink: {
    back: "Back"
  }
};
const NavigateBackLink = memo(({
  icon,
  ariaLabel,
  children,
  visuallyHidden = true,
  ...props
}) => {
  const formatMessage = useMessageFormatter(navigationBackLinkDictionary);
  const finalAriaLabel = isNonEmptyTrimmedString(children) ? children : ariaLabel ?? formatMessage("navigationBackLink.back");
  assert("ariaLabel to be present when children is empty", finalAriaLabel, isNonEmptyTrimmedString);
  return /* @__PURE__ */ jsx(Link, { ...props, "aria-label": finalAriaLabel, children: /* @__PURE__ */ jsxs(Stack, { direction: "horizontal", align: "center", children: [
    icon ?? /* @__PURE__ */ jsx(ArrowLeftIcon, {}),
    /* @__PURE__ */ jsx(VisuallyHidden, { hidden: visuallyHidden, children: children ?? formatMessage("navigationBackLink.back") })
  ] }) });
});
NavigateBackLink.displayName = "NavigateBackLink";
export {
  NavigateBackLink,
  navigationBackLinkDictionary
};
//# sourceMappingURL=NavigateBackLink.js.map
