"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 link_1 = __importDefault(require("next/link"));
const external_link_1 = __importDefault(require("./external-link"));
const raw_url_1 = __importDefault(require("lib/share/raw-url"));
const download_url_1 = __importDefault(require("lib/share/download-url"));
const r_join_1 = require("@cocalc/frontend/components/r_join");
const site_name_1 = __importDefault(require("./site-name"));
const edit_1 = __importDefault(require("./edit"));
function PathActions({ id, path, url, relativePath, isDir, exclude, project_id, image, description, }) {
    const include = (action) => !exclude?.has(action);
    const v = [];
    if (include("edit")) {
        if (url && isDir) {
            // TODO!
            // have to implement git clone...
        }
        else {
            v.push((0, jsx_runtime_1.jsx)(edit_1.default, { id: id, path: path, url: url, relativePath: relativePath, image: image, project_id: project_id, description: description }, "edit"));
        }
    }
    if (!url && include("hosted")) {
        v.push((0, jsx_runtime_1.jsx)(link_1.default, { href: `/share/public_paths/${id}`, children: (0, jsx_runtime_1.jsxs)("a", { children: ["Hosted by ", (0, jsx_runtime_1.jsx)(site_name_1.default, {})] }) }, "hosted"));
    }
    if (!url && include("embed")) {
        v.push((0, jsx_runtime_1.jsx)(link_1.default, { href: `/share/public_paths/embed/${id}${relativePath ? "/" + relativePath : ""}`, children: (0, jsx_runtime_1.jsx)("a", { children: "Embed" }) }, "embed"));
    }
    if (!url && !isDir && include("download")) {
        v.push((0, jsx_runtime_1.jsx)("a", { href: (0, download_url_1.default)(id, path, relativePath), children: "Download" }, "download"));
    }
    if (!url && include("raw")) {
        v.push((0, jsx_runtime_1.jsx)(external_link_1.default, { href: (0, raw_url_1.default)({ id, path, relativePath }), children: "Raw" }, "raw"));
    }
    return (0, jsx_runtime_1.jsx)("div", { style: { marginTop: "5px" }, children: (0, r_join_1.r_join)(v, " | ") });
}
exports.default = PathActions;
//# sourceMappingURL=path-actions.js.map