"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
const react_1 = require("react");
const router_1 = require("next/router");
const util_1 = require("lib/share/util");
const loading_1 = __importDefault(require("components/share/loading"));
const customize_1 = require("lib/share/customize");
const public_paths_1 = __importDefault(require("components/share/public-paths"));
const layout_1 = require("components/share/layout");
const avatar_1 = __importDefault(require("components/account/avatar"));
function Account({ first_name, last_name, publicPaths, customize, account_id, redirect, }) {
    const router = (0, router_1.useRouter)();
    (0, react_1.useEffect)(() => {
        if (redirect) {
            router.replace(redirect);
        }
    }, [redirect]);
    if (first_name == null || last_name == null || publicPaths == null) {
        return (0, jsx_runtime_1.jsx)(loading_1.default, { style: { fontSize: "30px" } });
    }
    const name = (0, util_1.trunc)(`${first_name} ${last_name}`, 150);
    const client_id = customize.account?.account_id;
    return ((0, jsx_runtime_1.jsx)(customize_1.Customize, { value: customize, children: (0, jsx_runtime_1.jsxs)(layout_1.Layout, { title: name, children: [(0, jsx_runtime_1.jsxs)("h1", { children: [(0, jsx_runtime_1.jsx)(avatar_1.default, { account_id: account_id }), " ", name] }), client_id == account_id ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: "You are an active collaborator on projects that contain the published documents listed below. We include any unlisted or disabled published documents so that you can browse or edit them from here. This full list is only visible to you (other people only see public documents)." })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [name, " is an active collaborator on projects that contain the following public documents:"] })), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(public_paths_1.default, { publicPaths: publicPaths })] }) }));
}
exports.default = Account;
//# sourceMappingURL=account.js.map