import { useState, useEffect } from "react";
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
const DefaultRoleRenderer = ({
  role
}) => /* @__PURE__ */ jsxDEV(Fragment, {
  children: [role, " "]
}, void 0, true);
const useRoleRenderer = (roleRendererFactory, query) => {
  const [roleRenderer, setRoleRenderer] = useState();
  useEffect(() => {
    if (!roleRendererFactory) {
      setRoleRenderer(() => DefaultRoleRenderer);
      return;
    }
    if (query.state !== "success") {
      return;
    }
    (async () => {
      const renderer = await roleRendererFactory(query.data.project.roles);
      setRoleRenderer(() => renderer);
    })();
  }, [roleRendererFactory, query]);
  return roleRenderer;
};
export {
  useRoleRenderer
};
//# sourceMappingURL=RoleRenderer.js.map
