import { jsx, Fragment } from "react/jsx-runtime";
import { SpinnerOverlay, Message } from "@contember/ui";
import { useEffect } from "react";
function FeedbackRenderer({ accessorTreeState, children }) {
  useEffect(() => {
    if (accessorTreeState.name === "error" && accessorTreeState.error.type === "unauthorized") {
      window.location.href = "/";
    }
  }, [accessorTreeState]);
  if (accessorTreeState.name === "initializing") {
    return /* @__PURE__ */ jsx(SpinnerOverlay, {});
  }
  if (accessorTreeState.name === "error") {
    if (accessorTreeState.error.type === "unauthorized") {
      return null;
    }
    return /* @__PURE__ */ jsx(Message, { intent: "danger", children: accessorTreeState.error.type });
  }
  return /* @__PURE__ */ jsx(Fragment, { children });
}
export {
  FeedbackRenderer
};
//# sourceMappingURL=FeedbackRenderer.js.map
