"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const ui = require("@contember/ui");
const react = require("react");
const useRoutingLink = require("./useRoutingLink.cjs");
const defaultComponent = ({ active, ...props }) => (
  // TODO do something with isActive?
  /* @__PURE__ */ jsxRuntime.jsx("a", { ...props })
);
const RoutingLink = react.memo(({ onClick, to, parametersResolver, parameters, Component, componentProps, target, ...props }) => {
  const { navigate, isActive: active, href } = useRoutingLink.useRoutingLink(to, parametersResolver, parameters);
  const innerOnClick = react.useCallback((e) => {
    if (e) {
      if (onClick) {
        onClick(e);
      }
      if (e.isDefaultPrevented() || ui.isSpecialLinkClick(e.nativeEvent) || target) {
        return;
      }
    }
    navigate(e);
  }, [navigate, onClick, target]);
  const InnerComponent = Component ?? defaultComponent;
  return /* @__PURE__ */ jsxRuntime.jsx(InnerComponent, { active, href, target, ...componentProps, ...props, onClick: innerOnClick });
});
RoutingLink.displayName = "RoutingLink";
exports.RoutingLink = RoutingLink;
//# sourceMappingURL=RoutingLink.cjs.map
