import { useEntity } from "@contember/binding";
import { memo, useMemo } from "react";
import { jsxDEV } from "react/jsx-dev-runtime";
import { Link } from "../../../routing/binding/Link.js";
var _jsxFileName = "/__w/interface/interface/packages/admin/src/components/bindingFacade/buttons/PageLinkById.tsx";
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__ */ jsxDEV(Link, {
      to: target,
      Component: props.Component,
      children: props.children
    }, void 0, false, {
      fileName: _jsxFileName,
      lineNumber: 47,
      columnNumber: 4
    }, this);
  }
  return null;
});
export {
  PageLinkById
};
//# sourceMappingURL=PageLinkById.js.map
