import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useSyncExternalStore } from "react";
import { useEditContext } from "./client/editContext";
import { ActiveUsers } from "./menubar/ActiveUsers";
import { cn } from "../lib/utils";
import { NotificationCenter } from "./notifications/NotificationCenter";
import { WatchButton } from "./notifications/WatchButton";
import { getTaskBoardNavSnapshot, subscribeTaskBoardNav, } from "../task-board/taskBoardNavStore";
/**
 * GlobalMenuBar - Persistent top menu bar with workspace-specific titlebar and user menu
 * Visible on all workspaces except Home (when workspace.hideToolbar is true)
 * Spans only the content area width (not including the sidebar)
 */
export function GlobalMenuBar() {
    const editContext = useEditContext();
    const taskBoardNav = useSyncExternalStore(subscribeTaskBoardNav, getTaskBoardNavSnapshot, getTaskBoardNavSnapshot);
    if (!editContext)
        return null;
    const currentItemDescriptor = editContext.currentItemDescriptor;
    const isAgentsWorkspace = editContext.workspace?.id === "agents";
    const isTaskboardWorkspace = editContext.workspace?.id === "taskboard";
    const watchTarget = isAgentsWorkspace
        ? editContext.selectedAgentsWorkspaceAgentId
            ? {
                targetType: "agent-run",
                targetId: editContext.selectedAgentsWorkspaceAgentId,
            }
            : null
        : isTaskboardWorkspace
            ? taskBoardNav.selectedProjectId
                ? {
                    targetType: "project",
                    targetId: taskBoardNav.selectedProjectId,
                }
                : null
            : currentItemDescriptor?.id
                ? {
                    targetType: "item",
                    targetId: currentItemDescriptor.id,
                }
                : null;
    return (_jsxs("div", { className: cn("flex h-12 items-center justify-between gap-2 border-b border-gray-200 bg-white px-4 pl-1", "z-10"), "data-testid": "global-menu-bar", children: [_jsx("div", { className: "flex min-w-0 flex-1 items-center overflow-hidden", children: editContext.workspace?.titlebar }), _jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [watchTarget ? _jsx(WatchButton, { ...watchTarget }) : null, _jsx(NotificationCenter, {}), _jsx(ActiveUsers, {})] })] }));
}
//# sourceMappingURL=GlobalMenuBar.js.map