import { useEntity } from "@contember/binding";
import { memo, useMemo } from "react";
import { jsx } from "react/jsx-runtime";
import { Link } from "../../../routing/binding/Link.js";
const PageLinkById = memo(function(props) {
  const parentEntity = useEntity();
  const id = parentEntity.id;
  const target = useMemo(() => {
    if (typeof id !== "string") {
      return null;
    }
    if ("to" in props) {
      return {
        pageName: props.to,
        parameters: {
          [props.idParameterName ?? "id"]: id
        }
      };
    }
    return () => props.change(id, parentEntity);
  }, [id, parentEntity, props]);
  if (target !== null) {
    return /* @__PURE__ */ jsx(Link, {
      to: target,
      Component: props.Component,
      children: props.children
    });
  }
  return null;
});
export {
  PageLinkById
};
//# sourceMappingURL=PageLinkById.js.map
