"use strict";
exports.id = 112;
exports.ids = [112];
exports.modules = {

/***/ 7112:
/***/ ((module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2322);
/* harmony import */ var _components_loadBox_LoadingStatus__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2850);
/* harmony import */ var _components_toast_toast__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9035);
/* harmony import */ var _cromwell_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1815);
/* harmony import */ var _cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4536);
/* harmony import */ var _helpers_navigation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(2374);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(4661);
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_7__);
/* harmony import */ var _components_ForgotPassForm__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(4964);
/* harmony import */ var _components_ResetPassForm__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(3266);
/* harmony import */ var _components_SignInForm__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(6976);
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_components_loadBox_LoadingStatus__WEBPACK_IMPORTED_MODULE_1__, _components_toast_toast__WEBPACK_IMPORTED_MODULE_2__, _helpers_navigation__WEBPACK_IMPORTED_MODULE_5__, _components_ForgotPassForm__WEBPACK_IMPORTED_MODULE_8__, _components_ResetPassForm__WEBPACK_IMPORTED_MODULE_9__, _components_SignInForm__WEBPACK_IMPORTED_MODULE_10__]);
([_components_loadBox_LoadingStatus__WEBPACK_IMPORTED_MODULE_1__, _components_toast_toast__WEBPACK_IMPORTED_MODULE_2__, _helpers_navigation__WEBPACK_IMPORTED_MODULE_5__, _components_ForgotPassForm__WEBPACK_IMPORTED_MODULE_8__, _components_ResetPassForm__WEBPACK_IMPORTED_MODULE_9__, _components_SignInForm__WEBPACK_IMPORTED_MODULE_10__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);











const LoginPage = ()=>{
    const apiClient = (0,_cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_4__.getRestApiClient)();
    const [loading, setLoading] = (0,react__WEBPACK_IMPORTED_MODULE_6__.useState)(false);
    const navigate = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_7__.useNavigate)();
    const [formType, setFormType] = (0,react__WEBPACK_IMPORTED_MODULE_6__.useState)("sign-in");
    const [email, setEmail] = (0,react__WEBPACK_IMPORTED_MODULE_6__.useState)("");
    const checkAuth = async (showError)=>{
        const userInfo = await apiClient.getUserInfo({
            disableLog: true
        }).catch(()=>null);
        if (userInfo?.id) {
            if (!userInfo.roles?.length || !userInfo.email) {
                if (showError) _components_toast_toast__WEBPACK_IMPORTED_MODULE_2__/* .toast.error */ .A.error("Incorrect user account");
                return;
            }
            (0,_cromwell_core__WEBPACK_IMPORTED_MODULE_3__.setStoreItem)("userInfo", userInfo);
            loginSuccess(userInfo);
        } else {
            if (showError) _components_toast_toast__WEBPACK_IMPORTED_MODULE_2__/* .toast.error */ .A.error("Incorrect email or password");
        }
    };
    const loginSuccess = (userInfo)=>{
        if (!userInfo?.roles?.length) {
            _components_toast_toast__WEBPACK_IMPORTED_MODULE_2__/* .toast.error */ .A.error("Access forbidden");
            return;
        }
        // Find a page with allowed permissions for this user
        const sidebarLinks = (0,_helpers_navigation__WEBPACK_IMPORTED_MODULE_5__/* .getSideBarLinksFlat */ .o_)();
        const allowed = sidebarLinks.find((link)=>link.route && (0,_cromwell_core__WEBPACK_IMPORTED_MODULE_3__.matchPermissions)(userInfo, link.permissions));
        navigate(allowed?.route ?? "/");
    };
    (0,react__WEBPACK_IMPORTED_MODULE_6__.useEffect)(()=>{
        checkAuth();
    }, []);
    const handleGoToForgotPass = ()=>{
        setFormType("forgot-pass");
    };
    return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
        className: "bg-gradient-to-tr flex h-full from-indigo-900 to-pink-900 w-screen top-0 right-0 bottom-0 left-0 z-999 items-center fixed",
        children: [
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                className: "bg-white rounded-lg mx-auto max-w-sm shadow-md w-full overflow-hidden dark:bg-gray-800",
                children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                    className: "py-4 px-6",
                    children: [
                        /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", {
                            src: "/admin/static/logo_small_black.svg",
                            width: "80px",
                            className: "mx-auto mt-3"
                        }),
                        formType === "sign-in" && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_SignInForm__WEBPACK_IMPORTED_MODULE_10__/* .SignInForm */ .M, {
                            onClickForget: handleGoToForgotPass,
                            onSuccess: checkAuth,
                            loading: loading,
                            setLoading: setLoading
                        }),
                        formType === "forgot-pass" && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_ForgotPassForm__WEBPACK_IMPORTED_MODULE_8__/* .ForgotPassForm */ .n, {
                            onSuccess: (result)=>{
                                setEmail(result.email);
                                setFormType(result.step);
                            },
                            loading: loading,
                            setLoading: setLoading
                        }),
                        formType === "reset-pass" && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_ResetPassForm__WEBPACK_IMPORTED_MODULE_9__/* .ResetPassForm */ .J, {
                            email: email,
                            onSuccess: setFormType,
                            loading: loading,
                            setLoading: setLoading
                        })
                    ]
                })
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_loadBox_LoadingStatus__WEBPACK_IMPORTED_MODULE_1__/* .LoadingStatus */ .Q, {
                isActive: loading
            })
        ]
    });
};
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (LoginPage);

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });

/***/ }),

/***/ 4964:
/***/ ((module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "n": () => (/* binding */ ForgotPassForm)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2322);
/* harmony import */ var _components_toast_toast__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9035);
/* harmony import */ var _cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4536);
/* harmony import */ var _heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8802);
/* harmony import */ var _heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var react_hook_form__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5641);
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_components_toast_toast__WEBPACK_IMPORTED_MODULE_1__, react_hook_form__WEBPACK_IMPORTED_MODULE_5__]);
([_components_toast_toast__WEBPACK_IMPORTED_MODULE_1__, react_hook_form__WEBPACK_IMPORTED_MODULE_5__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);






const ForgotPassForm = ({ onSuccess , setLoading , loading  })=>{
    const apiClient = (0,_cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_2__.getRestApiClient)();
    const { register , handleSubmit , formState: { errors  }  } = (0,react_hook_form__WEBPACK_IMPORTED_MODULE_5__.useForm)();
    const handleForgotPass = async (data)=>{
        setLoading(true);
        try {
            const success = await apiClient?.forgotPassword({
                email: data.email
            }, {
                disableLog: true
            });
            if (success) {
                _components_toast_toast__WEBPACK_IMPORTED_MODULE_1__/* .toast.success */ .A.success("We sent you an e-mail");
                onSuccess({
                    step: "reset-pass",
                    email: data.email
                });
            } else {
                throw new Error("!success");
            }
        } catch (e) {
            console.error(e);
            let info = e?.message;
            try {
                info = JSON.parse(e.message);
            } catch (e) {}
            if (info?.statusCode === 429) {} else {
                _components_toast_toast__WEBPACK_IMPORTED_MODULE_1__/* .toast.error */ .A.error?.("Incorrect e-mail or user was not found");
            }
        }
        setLoading(false);
    };
    return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("form", {
        onSubmit: handleSubmit(handleForgotPass),
        children: [
            /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                className: "mt-4 w-full",
                children: [
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("label", {
                        htmlFor: "email",
                        className: "text-xs mb-1 tracking-wide text-gray-600 sm:text-sm",
                        children: "Email"
                    }),
                    /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                        className: "relative",
                        children: [
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                                className: "border border-transparent flex h-full top-0 left-0 w-10 absolute",
                                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                                    className: "rounded-tl-lg rounded-bl-lg flex h-full bg-gray-100 text-lg w-full text-gray-600 z-10 items-center justify-center",
                                    children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3__.EnvelopeIcon, {
                                        className: "h-5 w-5"
                                    })
                                })
                            }),
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", {
                                type: "email",
                                placeholder: "Email Address",
                                disabled: loading,
                                ...register("email", {
                                    required: true
                                }),
                                className: `text-sm sm:text-base relative w-full border ${errors.email ? "border-red-500" : "border-gray-200"} shadow-md focus:shadow-indigo-300 rounded-lg placeholder-gray-400 focus:border-indigo-400 focus:outline-none py-2 pr-2 pl-12`
                            })
                        ]
                    }),
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
                        className: "flex font-medium mt-1 text-xs tracking-wide ml-1 text-red-500 items-center",
                        children: errors.email && "Please provide an email address."
                    })
                ]
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                className: "flex mt-4 items-center justify-between",
                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
                    disabled: loading,
                    className: "rounded bg-gray-700 text-white py-2 px-4 transform transition-colors leading-5 duration-200 hover:bg-gray-600 focus:outline-none",
                    type: "submit",
                    children: "Reset Password"
                })
            })
        ]
    });
};

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });

/***/ }),

/***/ 3266:
/***/ ((module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "J": () => (/* binding */ ResetPassForm)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2322);
/* harmony import */ var _components_toast_toast__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9035);
/* harmony import */ var _cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4536);
/* harmony import */ var _heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8802);
/* harmony import */ var _heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var react_hook_form__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5641);
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_components_toast_toast__WEBPACK_IMPORTED_MODULE_1__, react_hook_form__WEBPACK_IMPORTED_MODULE_5__]);
([_components_toast_toast__WEBPACK_IMPORTED_MODULE_1__, react_hook_form__WEBPACK_IMPORTED_MODULE_5__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);






const ResetPassForm = ({ onSuccess , setLoading , loading , email  })=>{
    const apiClient = (0,_cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_2__.getRestApiClient)();
    const { register , handleSubmit , formState: { errors  }  } = (0,react_hook_form__WEBPACK_IMPORTED_MODULE_5__.useForm)({
        defaultValues: {
            email: email,
            password: "",
            code: ""
        }
    });
    const handleResetPass = async (data)=>{
        setLoading(true);
        try {
            const success = await apiClient?.resetPassword({
                email: data.email,
                code: data.code,
                newPassword: data.password
            });
            if (success) {
                _components_toast_toast__WEBPACK_IMPORTED_MODULE_1__/* .toast.success */ .A.success("Password has been changed.");
                onSuccess("sign-in");
            } else {
                throw new Error("!success");
            }
        } catch (e) {
            console.error(e);
            let info = e?.message;
            try {
                info = JSON.parse(e.message);
            } catch (e) {}
            if (info?.statusCode === 429) {} else if (info?.statusCode === 417) {
                _components_toast_toast__WEBPACK_IMPORTED_MODULE_1__/* .toast.error */ .A.error?.("Exceeded reset password attempts");
                // setCodeInput('')
                onSuccess("sign-in");
            } else {
                _components_toast_toast__WEBPACK_IMPORTED_MODULE_1__/* .toast.error */ .A.error?.("Incorrect e-mail or user was not found");
            }
        }
        setLoading(false);
    };
    return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("form", {
        onSubmit: handleSubmit(handleResetPass),
        children: [
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                className: "rounded-md bg-green-800 my-3 text-white w-full p-2",
                children: "We sent you an e-mail with reset code. Copy the code below and create a new password"
            }),
            /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                className: "mt-4 w-full",
                children: [
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("label", {
                        htmlFor: "email",
                        className: "text-xs mb-1 tracking-wide text-gray-600 sm:text-sm",
                        children: "Email"
                    }),
                    /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                        className: "relative",
                        children: [
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                                className: "border border-transparent flex h-full top-0 left-0 w-10 absolute",
                                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                                    className: "rounded-tl-lg rounded-bl-lg flex h-full bg-gray-100 text-lg w-full text-gray-600 z-10 items-center justify-center",
                                    children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3__.EnvelopeIcon, {
                                        className: "h-5 w-5"
                                    })
                                })
                            }),
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", {
                                type: "email",
                                placeholder: "Email Address",
                                disabled: true,
                                ...register("email", {
                                    required: true
                                }),
                                className: `text-sm sm:text-base relative w-full border ${errors.email ? "border-red-500" : "border-gray-200"} shadow-md focus:shadow-indigo-300 rounded-lg placeholder-gray-400 focus:border-indigo-400 focus:outline-none py-2 pr-2 pl-12`
                            })
                        ]
                    }),
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
                        className: "flex font-medium mt-1 text-xs tracking-wide ml-1 text-red-500 items-center",
                        children: errors.email && "Please provide an email address."
                    })
                ]
            }),
            /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                className: "mt-4 w-full",
                children: [
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("label", {
                        htmlFor: "password",
                        className: "text-xs mb-1 tracking-wide text-gray-600 sm:text-sm",
                        children: "Password"
                    }),
                    /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                        className: "relative",
                        children: [
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                                className: "border border-transparent flex h-full top-0 left-0 w-10 absolute",
                                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                                    className: "rounded-tl-lg rounded-bl-lg flex h-full bg-gray-100 text-lg w-full text-gray-600 z-10 items-center justify-center",
                                    children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3__.KeyIcon, {
                                        className: "h-5 w-5"
                                    })
                                })
                            }),
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", {
                                type: "password",
                                placeholder: "******",
                                disabled: loading,
                                ...register("password", {
                                    required: true
                                }),
                                className: `text-sm sm:text-base relative w-full border ${errors.password ? "border-red-500" : "border-gray-200"} shadow-md focus:shadow-indigo-300 rounded-lg placeholder-gray-400 focus:border-indigo-400 focus:outline-none py-2 pr-2 pl-12`
                            })
                        ]
                    }),
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
                        className: "flex font-medium mt-1 text-xs tracking-wide ml-1 text-red-500 items-center",
                        children: errors.password && errors.password.message
                    })
                ]
            }),
            /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                className: "mt-4 w-full",
                children: [
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("label", {
                        htmlFor: "code",
                        className: "text-xs mb-1 tracking-wide text-gray-600 sm:text-sm",
                        children: "Code"
                    }),
                    /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                        className: "relative",
                        children: [
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                                className: "border border-transparent flex h-full top-0 left-0 w-10 absolute",
                                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                                    className: "rounded-tl-lg rounded-bl-lg flex h-full bg-gray-100 text-lg w-full text-gray-600 z-10 items-center justify-center",
                                    children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3__.LockClosedIcon, {
                                        className: "h-5 w-5"
                                    })
                                })
                            }),
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", {
                                type: "text",
                                placeholder: "123456",
                                disabled: loading,
                                ...register("code", {
                                    required: true
                                }),
                                className: `text-sm sm:text-base relative w-full border ${errors.code ? "border-red-500" : "border-gray-200"} shadow-md focus:shadow-indigo-300 rounded-lg placeholder-gray-400 focus:border-indigo-400 focus:outline-none py-2 pr-2 pl-12`
                            })
                        ]
                    }),
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
                        className: "flex font-medium mt-1 text-xs tracking-wide ml-1 text-red-500 items-center",
                        children: errors.code && errors.code.message
                    })
                ]
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                className: "flex mt-4 items-center justify-between",
                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
                    disabled: loading,
                    className: "rounded bg-gray-700 text-white py-2 px-4 transform transition-colors leading-5 duration-200 hover:bg-gray-600 focus:outline-none",
                    type: "submit",
                    children: "Change Password"
                })
            })
        ]
    });
};

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });

/***/ }),

/***/ 6976:
/***/ ((module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "M": () => (/* binding */ SignInForm)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2322);
/* harmony import */ var _components_toast_toast__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9035);
/* harmony import */ var _cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4536);
/* harmony import */ var _heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8802);
/* harmony import */ var _heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var react_hook_form__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5641);
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_components_toast_toast__WEBPACK_IMPORTED_MODULE_1__, react_hook_form__WEBPACK_IMPORTED_MODULE_5__]);
([_components_toast_toast__WEBPACK_IMPORTED_MODULE_1__, react_hook_form__WEBPACK_IMPORTED_MODULE_5__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);






const SignInForm = ({ onClickForget , onSuccess , setLoading , loading  })=>{
    const apiClient = (0,_cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_2__.getRestApiClient)();
    const { register , handleSubmit , setError , formState: { errors  }  } = (0,react_hook_form__WEBPACK_IMPORTED_MODULE_5__.useForm)();
    const handleLoginClick = async (data)=>{
        setLoading(true);
        try {
            await apiClient.login({
                email: data.email,
                password: data.password
            }, {
                disableLog: true
            });
            onSuccess(true);
        } catch (e) {
            if (e.statusCode === 0) {
                _components_toast_toast__WEBPACK_IMPORTED_MODULE_1__/* .toast.error */ .A.error("Could not connect to the Server");
            } else {
                _components_toast_toast__WEBPACK_IMPORTED_MODULE_1__/* .toast.error */ .A.error("Incorrect email or password");
                setError("email", {
                    message: "Invalid email or password"
                });
                setError("password", {
                    message: "Invalid email or password"
                });
            }
            console.error(e);
        }
        setLoading(false);
    };
    return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("form", {
        onSubmit: handleSubmit(handleLoginClick),
        children: [
            /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                className: "mt-4 w-full",
                children: [
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("label", {
                        htmlFor: "email",
                        className: "text-xs mb-1 tracking-wide text-gray-600 sm:text-sm",
                        children: "Email"
                    }),
                    /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                        className: "relative",
                        children: [
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                                className: "border border-transparent flex h-full top-0 left-0 w-10 absolute",
                                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                                    className: "rounded-tl-lg rounded-bl-lg flex h-full bg-gray-100 text-lg w-full text-gray-600 z-10 items-center justify-center",
                                    children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3__.EnvelopeIcon, {
                                        className: "h-5 w-5"
                                    })
                                })
                            }),
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", {
                                type: "email",
                                placeholder: "Email Address",
                                disabled: loading,
                                ...register("email", {
                                    required: true
                                }),
                                className: `text-sm sm:text-base relative w-full border ${errors.email ? "border-red-500" : "border-gray-200"} shadow-md focus:shadow-indigo-300 rounded-lg placeholder-gray-400 focus:border-indigo-400 focus:outline-none py-2 pr-2 pl-12`
                            })
                        ]
                    }),
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
                        className: "flex font-medium mt-1 text-xs tracking-wide ml-1 text-red-500 items-center",
                        children: errors.email && "Please provide an email address."
                    })
                ]
            }),
            /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                className: "mt-4 w-full",
                children: [
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("label", {
                        htmlFor: "password",
                        className: "text-xs mb-1 tracking-wide text-gray-600 sm:text-sm",
                        children: "Password"
                    }),
                    /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                        className: "relative",
                        children: [
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                                className: "border border-transparent flex h-full top-0 left-0 w-10 absolute",
                                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                                    className: "rounded-tl-lg rounded-bl-lg flex h-full bg-gray-100 text-lg w-full text-gray-600 z-10 items-center justify-center",
                                    children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3__.KeyIcon, {
                                        className: "h-5 w-5"
                                    })
                                })
                            }),
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", {
                                type: "password",
                                placeholder: "******",
                                disabled: loading,
                                ...register("password", {
                                    required: true
                                }),
                                className: `text-sm sm:text-base relative w-full border ${errors.password ? "border-red-500" : "border-gray-200"} shadow-md focus:shadow-indigo-300 rounded-lg placeholder-gray-400 focus:border-indigo-400 focus:outline-none py-2 pr-2 pl-12`
                            })
                        ]
                    }),
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
                        className: "flex font-medium mt-1 text-xs tracking-wide ml-1 text-red-500 items-center",
                        children: errors.password && String(errors.password.message)
                    })
                ]
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                className: "flex mt-4 items-center justify-between",
                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", {
                    disabled: loading,
                    className: "rounded bg-gray-700 text-white py-2 px-4 transform transition-colors leading-5 duration-200 hover:bg-gray-600 focus:outline-none",
                    type: "submit",
                    children: "Login"
                })
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("p", {
                onClick: onClickForget,
                className: "my-2 hover:underline",
                children: "Forgot password?"
            })
        ]
    });
};

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });

/***/ })

};
;