import { ContainerSpinner, Message } from "@contember/ui";
import { useEffect } from "react";
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
var _jsxFileName = "/__w/interface/interface/packages/admin/src/components/bindingFacade/renderers/FeedbackRenderer.tsx";
function FeedbackRenderer({
  accessorTreeState,
  children
}) {
  useEffect(() => {
    if (accessorTreeState.name === "error" && accessorTreeState.error.type === "unauthorized") {
      window.location.href = "/";
    }
  }, [accessorTreeState]);
  if (accessorTreeState.name === "initializing") {
    return /* @__PURE__ */ jsxDEV(ContainerSpinner, {}, void 0, false, {
      fileName: _jsxFileName,
      lineNumber: 19,
      columnNumber: 10
    }, this);
  }
  if (accessorTreeState.name === "error") {
    switch (accessorTreeState.error.type) {
      case "unauthorized":
        return null;
      case "networkError": {
        throw new Error(accessorTreeState.error.metadata.responseText);
      }
      case "gqlError": {
        throw new Error(JSON.stringify(accessorTreeState.error.errors, null, "  "));
      }
      case "unknownError":
      default:
        return /* @__PURE__ */ jsxDEV(Message, {
          intent: "danger",
          children: "Unknown error"
        }, void 0, false, {
          fileName: _jsxFileName,
          lineNumber: 43,
          columnNumber: 12
        }, this);
    }
  }
  return /* @__PURE__ */ jsxDEV(Fragment, {
    children
  }, void 0, false);
}
export {
  FeedbackRenderer
};
//# sourceMappingURL=FeedbackRenderer.js.map
