import { jsx } from "react/jsx-runtime";
import { useNavigate } from "react-router-dom";
export default function Link({
  to,
  children,
  onClick,
  replace = false,
  target = void 0,
  outLink = false,
  ...props
}) {
  const navigate = useNavigate();
  const handleClick = (e) => {
    const isInternal = to.startsWith("/") || to.startsWith("#") || to.startsWith("?");
    if (!outLink && isInternal) {
      e.preventDefault();
      navigate(to, { replace });
    } else if (!target) {
      e.preventDefault();
      window.location.href = to;
    }
    e.preventDefault();
    onClick?.(e);
  };
  return /* @__PURE__ */ jsx("a", { href: to, onClick: handleClick, target, rel: "noreferrer", ...props, children });
}
