"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 © 2021 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
const r_join_1 = require("@cocalc/frontend/components/r_join");
const A_1 = __importDefault(require("components/misc/A"));
const icon_1 = require("@cocalc/frontend/components/icon");
const customize_1 = require("lib/customize");
const software = {
    index: {},
    executables: { label: "Executables" },
    python: { label: "Python" },
    r: { label: "R Stats" },
    julia: { label: "Julia" },
    octave: { label: "Octave" },
};
const features = {
    index: {},
    "jupyter-notebook": { label: "Jupyter" },
    whiteboard: { label: "Whiteboard" },
    "latex-editor": { label: "LaTeX" },
    linux: { label: "Linux" },
    python: { label: "Python" },
    "r-statistical-software": { label: "R Stats" },
    sage: { label: "SageMath" },
    octave: { label: "Octave" },
    julia: { label: "Julia" },
    teaching: { label: "Teaching" },
    terminal: { label: "Terminal" },
    x11: { label: "X11" },
    compare: { label: "Compare" },
    api: { label: "API" },
};
const pricing = {
    index: {},
    products: { label: "Products" },
    subscriptions: { label: "Subscriptions" },
    courses: { label: "Courses" },
    dedicated: { label: "Dedicated" },
    onprem: { label: "OnPrem" },
};
const policies = {
    index: {},
    terms: { label: "Terms of Service", hide: (c) => !c.onCoCalcCom },
    copyright: { label: "Copyright", hide: (c) => !c.onCoCalcCom },
    privacy: { label: "Privacy", hide: (c) => !c.onCoCalcCom },
    thirdparties: { label: "Third Parties", hide: (c) => !c.onCoCalcCom },
    ferpa: { label: "FERPA", hide: (c) => !c.onCoCalcCom },
    accessibility: { label: "Accessibility", hide: (c) => !c.onCoCalcCom },
    imprint: { label: "Imprint", hide: (c) => !c.imprint },
    policies: { label: "Policies", hide: (c) => !c.policies },
};
const info = {
    index: {},
    doc: { label: "Documentation" },
    status: { label: "Status" },
    run: { label: "Run CoCalc" },
};
const sign_in = {
    "sign-in": { label: "Sign In", href: "/auth/sign-in" },
    "password-reset": { label: "Password Reset", href: "/auth/password-reset" },
};
const support = {
    index: {},
    community: { label: "Community" },
    new: { label: "New Ticket", hide: (customize) => !customize.zendesk },
    tickets: { label: "Tickets", hide: (customize) => !customize.zendesk },
};
const PAGES = {
    features,
    software,
    pricing,
    policies,
    share: {},
    info,
    "sign-up": {},
    "sign-in": sign_in,
    try: {},
    support,
    store: {},
};
function SubNav({ page, subPage }) {
    const customize = (0, customize_1.useCustomize)();
    const tabs = [];
    const p = PAGES[page];
    if (p == null)
        return null;
    for (const name in p) {
        if (p[name]?.disabled)
            continue;
        if (p[name]?.hide?.(customize))
            continue;
        let { label, href, icon } = p[name];
        if (name == "index") {
            if (!href)
                href = `/${page}`;
            if (!icon)
                icon = "home";
        }
        const selected = name == "index" ? !subPage : subPage == name;
        tabs.push((0, jsx_runtime_1.jsx)(SubPageTab, { page: page, selected: selected, name: name, label: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [icon && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { name: icon }), label ? " " : ""] })), label] }), href: href }, name));
    }
    return ((0, jsx_runtime_1.jsx)("div", { style: {
            backgroundColor: "white",
            textAlign: "center",
            color: "#666",
            padding: "15px 0",
        }, children: (0, r_join_1.r_join)(tabs, (0, jsx_runtime_1.jsx)("div", { style: { width: "16px", display: "inline-block" } })) }));
}
exports.default = SubNav;
function SubPageTab({ page, name, selected, label, href }) {
    return ((0, jsx_runtime_1.jsx)(A_1.default, { href: href ?? `/${page}/${name}`, style: selected
            ? {
                fontWeight: "bold",
                color: "blue",
                paddingBottom: "3px",
                borderBottom: "3px solid blue",
            }
            : { color: "#555" }, children: label }));
}
//# sourceMappingURL=sub-nav.js.map