"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxDevRuntime = require("react/jsx-dev-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__ */ jsxDevRuntime.jsxDEV("a", { ...props }, void 0, false, {
    fileName: "/__w/interface/interface/packages/admin/src/routing/RoutingLink.tsx",
    lineNumber: 17,
    columnNumber: 2
  }, void 0)
);
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__ */ jsxDevRuntime.jsxDEV(InnerComponent, { active, href, target, ...componentProps, ...props, onClick: innerOnClick }, void 0, false, {
    fileName: "/__w/interface/interface/packages/admin/src/routing/RoutingLink.tsx",
    lineNumber: 41,
    columnNumber: 9
  }, void 0);
});
RoutingLink.displayName = "RoutingLink";
exports.RoutingLink = RoutingLink;
//# sourceMappingURL=RoutingLink.cjs.map
