"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var jsx_runtime_1 = require("react/jsx-runtime");
/*
 *  This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
// TODO: below we need to get the strategies!
// and also requiresToken for SignUp!
var icon_1 = require("@cocalc/frontend/components/icon");
var antd_1 = require("antd");
var sign_in_1 = __importDefault(require("components/auth/sign-in"));
var sign_up_1 = __importDefault(require("components/auth/sign-up"));
var router_1 = require("next/router");
var react_1 = require("react");
function InPlaceSignInOrUp(props) {
    var title = props.title, why = props.why, onSuccess = props.onSuccess;
    var router = (0, router_1.useRouter)();
    var _a = __read((0, react_1.useState)(""), 2), show = _a[0], setShow = _a[1];
    return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: { textAlign: "center" } }, { children: [(0, jsx_runtime_1.jsxs)(antd_1.Divider, { children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { name: "sign-in", style: { marginRight: "10px" } }), " ", title] }), (0, jsx_runtime_1.jsx)("a", __assign({ onClick: function () { return setShow("sign-in"); } }, { children: "Sign In" })), " or", " ", (0, jsx_runtime_1.jsx)("a", __assign({ onClick: function () { return setShow("sign-up"); } }, { children: "Sign Up" })), why == null ? "." : (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [" ", why, "."] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), show == "sign-in" && ((0, jsx_runtime_1.jsx)(sign_in_1.default, { minimal: true, onSuccess: onSuccess !== null && onSuccess !== void 0 ? onSuccess : (function () {
                    return router.push({
                        pathname: router.asPath.split("?")[0],
                        query: { edit: "true" },
                    });
                }) })), show == "sign-up" && ((0, jsx_runtime_1.jsx)(sign_up_1.default, { minimal: true, onSuccess: onSuccess !== null && onSuccess !== void 0 ? onSuccess : (function () {
                    return router.push({
                        pathname: router.asPath.split("?")[0],
                        query: { edit: "true" },
                    });
                }) }))] })));
}
exports.default = InPlaceSignInOrUp;
//# sourceMappingURL=in-place-sign-in-or-up.js.map