"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 path_1 = require("path");
const antd_1 = require("antd");
const icon_1 = require("@cocalc/frontend/components/icon");
const use_customize_1 = __importDefault(require("lib/use-customize"));
const open_directly_1 = __importDefault(require("./open-directly"));
const open_anonymously_1 = __importDefault(require("./open-anonymously"));
const choose_project_1 = __importDefault(require("./choose-project"));
const in_place_sign_in_or_up_1 = __importDefault(require("components/auth/in-place-sign-in-or-up"));
const misc_1 = require("@cocalc/util/misc");
function EditOptions({ id, path, url, relativePath, project_id, image, onClose, description, }) {
    const { account } = (0, use_customize_1.default)();
    return ((0, jsx_runtime_1.jsxs)(antd_1.Card, { style: { margin: "30px 0" }, title: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: { position: "absolute", right: "30px", cursor: "pointer" }, onClick: onClose, children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { name: "times-circle" }) }), (0, jsx_runtime_1.jsx)(icon_1.Icon, { style: { marginRight: "10px" }, name: "pencil" }), " Edit", " ", (0, jsx_runtime_1.jsx)("b", { children: (0, misc_1.trunc_middle)((0, path_1.join)(path, relativePath), 60) })] }), children: [account?.account_id != null && ((0, jsx_runtime_1.jsx)(SignedInOptions, { id: id, path: path, url: url, relativePath: relativePath, project_id: project_id, image: image, description: description })), account?.account_id == null && (0, jsx_runtime_1.jsx)(NotSignedInOptions, {}), (0, jsx_runtime_1.jsx)("br", {})] }));
}
exports.default = EditOptions;
function SignedInOptions({ id, path, url, relativePath, project_id, image, description, }) {
    const { isCollaborator } = (0, use_customize_1.default)();
    return !url && isCollaborator ? ((0, jsx_runtime_1.jsx)(open_directly_1.default, { id: id, project_id: project_id, path: path, relativePath: relativePath })) : ((0, jsx_runtime_1.jsx)(choose_project_1.default, { id: id, src_project_id: project_id, path: path, url: url, relativePath: relativePath, image: image, description: description ? description : path ? path : relativePath }));
}
function NotSignedInOptions() {
    const { anonymousSignup } = (0, use_customize_1.default)();
    return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(in_place_sign_in_or_up_1.default, { title: "Choose Project", why: "to edit in one of your projects" }), anonymousSignup && (0, jsx_runtime_1.jsx)(open_anonymously_1.default, {})] }));
}
//# sourceMappingURL=edit-options.js.map