import { existsSync } from "node:fs";
import { join } from "node:path";
import { Key } from "@nerf/pi-tui";
import { NerfDashboardOverlay } from "../dashboard-overlay.js";
import { ParallelMonitorOverlay } from "../parallel-monitor-overlay.js";
import { shortcutDesc } from "../../shared/mod.js";
export function registerShortcuts(pi) {
    pi.registerShortcut(Key.ctrlAlt("g"), {
        description: shortcutDesc("Open NERF dashboard", "/nerf status"),
        handler: async (ctx) => {
            if (!existsSync(join(process.cwd(), ".nerf"))) {
                ctx.ui.notify("No .nerf/ directory found. Run /nerf to start.", "info");
                return;
            }
            await ctx.ui.custom((tui, theme, _kb, done) => new NerfDashboardOverlay(tui, theme, () => done()), {
                overlay: true,
                overlayOptions: {
                    width: "90%",
                    minWidth: 80,
                    maxHeight: "92%",
                    anchor: "center",
                },
            });
        },
    });
    pi.registerShortcut(Key.ctrlAlt("p"), {
        description: shortcutDesc("Open parallel worker monitor", "/nerf parallel watch"),
        handler: async (ctx) => {
            const parallelDir = join(process.cwd(), ".nerf", "parallel");
            if (!existsSync(parallelDir)) {
                ctx.ui.notify("No parallel workers found. Run /nerf parallel start first.", "info");
                return;
            }
            await ctx.ui.custom((tui, theme, _kb, done) => new ParallelMonitorOverlay(tui, theme, () => done()), {
                overlay: true,
                overlayOptions: {
                    width: "90%",
                    minWidth: 80,
                    maxHeight: "92%",
                    anchor: "center",
                },
            });
        },
    });
}
