import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { notFound } from 'next/navigation';
import { resolve } from '../../lib/server-container.js';
import { getFeatureFlags } from '../../lib/feature-flags.js';
import { AgentList } from '../../components/agent-editor/agent-list.js';
import { CreateAgentDialog } from '../../components/agent-editor/create-agent-dialog.js';
import { WelcomeBanner } from '../../components/onboarding/welcome-banner.js';
export const dynamic = 'force-dynamic';
export default async function AgentsRoute() {
    const flags = getFeatureFlags();
    if (!flags.collaboration) {
        notFound();
    }
    const listPrompts = resolve('ListAgentPromptsUseCase');
    const overrideRepo = resolve('IAgentPromptOverrideRepository');
    const types = await listPrompts.listAgentTypesAsync();
    const overrides = await overrideRepo.listAll();
    const overrideCounts = new Map();
    for (const o of overrides) {
        overrideCounts.set(o.agentType, (overrideCounts.get(o.agentType) ?? 0) + 1);
    }
    const agents = types.map((t) => ({
        agentType: t.agentType,
        promptCount: t.promptCount,
        overrideCount: overrideCounts.get(t.agentType) ?? 0,
        isCustom: t.isCustom,
        ...(t.name !== undefined && { displayName: t.name }),
    }));
    return (_jsxs("div", { className: "mx-auto flex w-full max-w-3xl flex-col gap-6 p-6", children: [_jsx(WelcomeBanner, { id: "agents:v1", title: "Edit prompts, design graphs, or stand up a brand new agent.", description: "Each agent has Prompts, Graph, and Playground tabs. Custom agents share the same surfaces \u2014 pick New agent to create one.", ctaLabel: "Open the tutorial", ctaHref: "/onboarding#agents" }), _jsxs("header", { className: "flex items-end justify-between gap-4", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("h1", { className: "text-2xl font-semibold", children: "Agents" }), _jsx("p", { className: "text-muted-foreground text-sm", children: "Edit the prompts and inspect the LangGraph state machine for each registered agent." })] }), _jsx(CreateAgentDialog, {})] }), _jsx(AgentList, { agents: agents })] }));
}
