"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxDevRuntime = require("react/jsx-dev-runtime");
const react = require("react");
const ui = require("@contember/ui");
const useHandleIDPResponse = require("./useHandleIDPResponse.cjs");
const useResponseHandlerFeedback = ({ onLogin }) => {
  const responseState = useHandleIDPResponse.useHandleIDPResponse({
    onLogin,
    onError: react.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__ */ jsxDevRuntime.jsxDEV(ui.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__ */ jsxDevRuntime.jsxDEV(ui.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 });
};
exports.IDPResponseHandler = IDPResponseHandler;
exports.useResponseHandlerFeedback = useResponseHandlerFeedback;
//# sourceMappingURL=IDPResponseHandler.cjs.map
