2026-11-06 22:20:06 +00:00
|
|
|
const Nav = (() => {
|
|
|
|
|
"use strict";
|
2026-11-07 23:43:26 +00:00
|
|
|
const TABS = [["stream", "Stream"], ["agents", "Agents"], ["artifacts", "Artifacts"], ["tasks", "Tasks"]];
|
2026-11-10 21:10:20 +00:00
|
|
|
const SUBS = {stream: [["inbox", "Inbox"], ["rules", "Firewall"]]};
|
2026-11-06 22:20:06 +00:00
|
|
|
const VIEWS = [["orbit", "Orbit"], ["chord", "Chord"], ["swimlane", "Swimlane"], ["tree", "Tree"], ["3d", "3D"]];
|
2026-11-09 22:22:46 +00:00
|
|
|
const TASK_VIEWS = [["list", "List"], ["board", "Board"], ["rasci", "RASCI"], ["gantt", "Gantt"], ["burn", "Burndown and burnup"], ["3d", "3D"]];
|
2026-11-08 17:26:51 +00:00
|
|
|
const OWN = {agents: [["hierarchy", "Hierarchy"]]};
|
2026-11-07 15:03:14 +00:00
|
|
|
const ICONS = {
|
2026-11-10 21:10:20 +00:00
|
|
|
stream: "bi-activity", inbox: "bi-inbox", rules: "bi-card-checklist", agents: "bi-people", artifacts: "bi-git", tasks: "bi-list-check",
|
2026-11-07 17:46:39 +00:00
|
|
|
orbit: "bi-globe2", chord: "bi-bezier2", swimlane: "bi-bar-chart-steps", tree: "bi-diagram-3", "3d": "bi-badge-3d", hierarchy: "bi-diagram-2",
|
2026-11-09 06:53:55 +00:00
|
|
|
list: "bi-list-task", board: "bi-kanban", rasci: "bi-grid-3x3", gantt: "bi-calendar-range", burn: "bi-graph-down-arrow",
|
2026-11-07 15:03:14 +00:00
|
|
|
};
|
2026-11-06 22:20:06 +00:00
|
|
|
const OLD = {graph: ["agents", "orbit"], tree: ["artifacts", "tree"]};
|
2026-11-07 23:43:26 +00:00
|
|
|
const viewsOf = (screen) => (screen === "tasks" ? TASK_VIEWS : [...VIEWS, ...(OWN[screen] || [])]);
|
2026-11-07 17:46:39 +00:00
|
|
|
const known = (screen, view) => viewsOf(screen).some(([id]) => id === view);
|
2026-11-06 22:20:06 +00:00
|
|
|
|
|
|
|
|
function tabOf(screen) {
|
|
|
|
|
return Object.keys(SUBS).find((tab) => SUBS[tab].some(([id]) => id === screen)) || screen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hashOf(screen, view) {
|
|
|
|
|
return tabOf(screen) === screen ? (view ? `#${screen}/${view}` : `#${screen}`) : `#${tabOf(screen)}/${screen}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function route(hash) {
|
|
|
|
|
const [head, sub] = decodeURIComponent(String(hash).replace(/^#/, "")).split("/");
|
2026-11-10 21:10:20 +00:00
|
|
|
if (head === "stream" && sub === "radio") {
|
|
|
|
|
return {screen: "stream", view: null, redirect: "#stream", spot: true};
|
|
|
|
|
}
|
2026-11-06 22:20:06 +00:00
|
|
|
if (Object.hasOwn(OLD, head)) {
|
|
|
|
|
const [screen, fallback] = OLD[head];
|
2026-11-07 17:46:39 +00:00
|
|
|
const view = known(screen, sub) ? sub : fallback;
|
2026-11-06 22:20:06 +00:00
|
|
|
return {screen, view, redirect: hashOf(screen, view)};
|
|
|
|
|
}
|
|
|
|
|
if (Object.hasOwn(SUBS, head) && SUBS[head].some(([id]) => id === sub)) {
|
|
|
|
|
return {screen: sub, view: null, redirect: null};
|
|
|
|
|
}
|
|
|
|
|
if (TABS.some(([id]) => id === head) && head !== "stream") {
|
2026-11-07 17:46:39 +00:00
|
|
|
return {screen: head, view: known(head, sub) ? sub : null, redirect: null};
|
2026-11-06 22:20:06 +00:00
|
|
|
}
|
|
|
|
|
return {screen: "stream", view: null, redirect: null};
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-07 23:43:26 +00:00
|
|
|
return {TABS, SUBS, VIEWS, TASK_VIEWS, ICONS, viewsOf, route, hashOf, tabOf};
|
2026-11-06 22:20:06 +00:00
|
|
|
})();
|
|
|
|
|
if (typeof module === "object" && module.exports) {
|
|
|
|
|
module.exports = Nav;
|
|
|
|
|
}
|