"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
module.exports = Link;
var _jsxRuntime = require("react/jsx-runtime");
var _reactRouterDom = require("react-router-dom");
function Link({
  to,
  children,
  onClick,
  replace = false,
  target = void 0,
  outLink = false,
  ...props
}) {
  const navigate = (0, _reactRouterDom.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__ */(0, _jsxRuntime.jsx)("a", {
    href: to,
    onClick: handleClick,
    target,
    rel: "noreferrer",
    ...props,
    children
  });
}