"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 __values = (this && this.__values) || function(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
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 © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
var link_1 = __importDefault(require("next/link"));
function LinkedPath(_a) {
    var e_1, _b;
    var id = _a.id, path = _a.path, relativePath = _a.relativePath, isDir = _a.isDir;
    var href = "/share/public_paths/".concat(id);
    var first = ((0, jsx_runtime_1.jsx)(link_1.default, __assign({ href: href }, { children: (0, jsx_runtime_1.jsx)("a", { children: path }) }), href));
    var slash = function (key) { return (0, jsx_runtime_1.jsx)("span", { children: " / " }, "slash" + key); };
    var segments = [first, slash(href)];
    try {
        for (var _c = __values(relativePath.split("/")), _d = _c.next(); !_d.done; _d = _c.next()) {
            var segment = _d.value;
            if (!segment)
                continue;
            href += "/".concat(encodeURIComponent(segment));
            segments.push((0, jsx_runtime_1.jsx)(link_1.default, __assign({ href: href }, { children: (0, jsx_runtime_1.jsx)("a", { children: segment }) }), href));
            segments.push(slash(href));
        }
    }
    catch (e_1_1) { e_1 = { error: e_1_1 }; }
    finally {
        try {
            if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
        }
        finally { if (e_1) throw e_1.error; }
    }
    if (!isDir) {
        segments.pop();
    }
    return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: segments });
}
exports.default = LinkedPath;
//# sourceMappingURL=linked-path.js.map