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

/***/ 755123:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Z": () => (/* binding */ Try)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(920997);
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(616689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(545725);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(antd__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var components_logo_square__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(961429);
/* harmony import */ var lib_use_customize__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(117682);
/* harmony import */ var _shared__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(402391);
/* harmony import */ var components_misc_A__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(940981);
/* harmony import */ var lib_api_post__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(194184);
/* harmony import */ var _cocalc_util_misc__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(477389);
/* harmony import */ var _cocalc_util_misc__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_cocalc_util_misc__WEBPACK_IMPORTED_MODULE_8__);
/* harmony import */ var components_share_loading__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(976087);
/* harmony import */ var react_google_recaptcha_v3__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(271704);
/* harmony import */ var react_google_recaptcha_v3__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(react_google_recaptcha_v3__WEBPACK_IMPORTED_MODULE_10__);
/*
Create an anonymous account.
*/ 










function Try(props) {
    const { reCaptchaKey  } = (0,lib_use_customize__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z)();
    return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(react_google_recaptcha_v3__WEBPACK_IMPORTED_MODULE_10__.GoogleReCaptchaProvider, {
        reCaptchaKey: reCaptchaKey,
        children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(Try0, {
            ...props
        })
    });
};
function Try0({ minimal , onSuccess  }) {
    const { siteName , anonymousSignup , reCaptchaKey  } = (0,lib_use_customize__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z)();
    const { 0: state , 1: setState  } = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)("wait");
    const { 0: error , 1: setError  } = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)("");
    const { executeRecaptcha  } = (0,react_google_recaptcha_v3__WEBPACK_IMPORTED_MODULE_10__.useGoogleReCaptcha)();
    if (!anonymousSignup) {
        return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("h1", {
            style: {
                textAlign: "center",
                margin: "45px auto"
            },
            children: [
                "Anonymous Trial of ",
                siteName,
                " Not Currently Available"
            ]
        });
    }
    async function createAnonymousAccount() {
        setState("creating");
        try {
            let reCaptchaToken;
            if (reCaptchaKey) {
                if (!executeRecaptcha) {
                    throw Error("Please wait a few seconds, then try again.");
                }
                reCaptchaToken = await executeRecaptcha("anonymous");
            }
            const result = await (0,lib_api_post__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z)("/auth/sign-up", {
                reCaptchaToken
            });
            if (result.issues && (0,_cocalc_util_misc__WEBPACK_IMPORTED_MODULE_8__.len)(result.issues) > 0) {
                throw Error(JSON.stringify(result.issues)); // TODO: should not happen, except for captcha error...
            }
            onSuccess?.();
        } catch (err) {
            setError(err.message);
            setState("wait");
        }
    }
    return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
        style: {
            margin: "30px",
            minHeight: "50vh"
        },
        children: [
            !minimal && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                style: {
                    textAlign: "center",
                    marginBottom: "15px"
                },
                children: [
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(components_logo_square__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z, {
                        style: {
                            width: "100px",
                            height: "100px",
                            marginBottom: "15px"
                        }
                    }),
                    /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("h1", {
                        children: [
                            "Use ",
                            siteName,
                            " Anonymously"
                        ]
                    })
                ]
            }),
            /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                style: _shared__WEBPACK_IMPORTED_MODULE_5__/* .LOGIN_STYLE */ .E,
                children: [
                    error && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_2__.Alert, {
                        type: "error",
                        message: error,
                        showIcon: true
                    }),
                    "Try ",
                    siteName,
                    " ",
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("b", {
                        children: "without"
                    }),
                    " ",
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(components_misc_A__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z, {
                        href: "/auth/sign-up",
                        external: !!minimal,
                        children: "creating an account"
                    }),
                    "!",
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_2__.Button, {
                        disabled: state != "wait",
                        shape: "round",
                        size: "large",
                        type: "primary",
                        style: {
                            width: "100%",
                            marginTop: "20px"
                        },
                        onClick: createAnonymousAccount,
                        children: state == "creating" ? /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(components_share_loading__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, {
                            children: "Configuring Anonymous Access..."
                        }) : /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
                            children: [
                                "Use ",
                                siteName,
                                " Anonymously"
                            ]
                        })
                    })
                ]
            }),
            !minimal && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                style: {
                    ..._shared__WEBPACK_IMPORTED_MODULE_5__/* .LOGIN_STYLE */ .E,
                    backgroundColor: "white",
                    margin: "30px auto",
                    padding: "15px"
                },
                children: [
                    "Already have an account? ",
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(components_misc_A__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z, {
                        href: "/auth/sign-in",
                        children: "Sign In"
                    }),
                    /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                        style: {
                            marginTop: "15px"
                        },
                        children: [
                            "Need an account? ",
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(components_misc_A__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z, {
                                href: "/auth/sign-up",
                                children: "Sign Up"
                            })
                        ]
                    })
                ]
            })
        ]
    });
}


/***/ })

};
;