import { jsxDEV } from "react/jsx-dev-runtime";
import { useCallback } from "react";
import { SpinnerOverlay, ErrorList } from "@contember/ui";
import { useHandleIDPResponse } from "./useHandleIDPResponse.js";
const useResponseHandlerFeedback = ({ onLogin }) => {
  const responseState = useHandleIDPResponse({
    onLogin,
    onError: useCallback(() => {
      window.history.pushState({}, document.title, "/");
    }, [])
  });
  switch (responseState.type) {
    case "nothing":
      return null;
    case "failed":
      const error = {
        INVALID_IDP_RESPONSE: "Login failed",
        IDP_VALIDATION_FAILED: "Login failed",
        INVALID_LOCAL_STATE: "Login failed",
        PERSON_NOT_FOUND: "User not found"
      }[responseState.error];
      return /* @__PURE__ */ jsxDEV(ErrorList, { errors: [{ message: error }] }, void 0, false, {
        fileName: "/__w/interface/interface/packages/admin/src/tenant/components/idp/IDPResponseHandler.tsx",
        lineNumber: 29,
        columnNumber: 11
      }, void 0);
    default:
      return /* @__PURE__ */ jsxDEV(SpinnerOverlay, {}, void 0, false, {
        fileName: "/__w/interface/interface/packages/admin/src/tenant/components/idp/IDPResponseHandler.tsx",
        lineNumber: 32,
        columnNumber: 11
      }, void 0);
  }
};
const IDPResponseHandler = ({ onLogin }) => {
  return useResponseHandlerFeedback({ onLogin });
};
export {
  IDPResponseHandler,
  useResponseHandlerFeedback
};
//# sourceMappingURL=IDPResponseHandler.js.map
