import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { useEditContext } from "../../client/editContext";
import { SimpleIconButton } from "../../ui/SimpleIconButton";
import { ParheliaAgentIcon } from "../../ui/Icons";
import { MessageSquareMore } from "lucide-react";
import { useAgentStatus } from "../../ai/useAgentStatus";
import { AgentStatusBadge } from "../../ai/AgentStatusBadge";
import { LicenseFeatures, useFeature } from "../../../licensing";
import { useActiveAgentConversation } from "../../ai/useActiveAgentConversation";
import { toggleCommentsFeedback } from "../../reviews/openCommentsFeedback";
import { FullscreenControl } from "./FullscreenControl";
import { CountBadge } from "../../../components/ui/badge";
export function UtilityControls({ hideFullscreen = false, } = {}) {
    const editContext = useEditContext();
    const canUseAi = useFeature(LicenseFeatures.AI);
    const agentStatus = useAgentStatus(canUseAi);
    const hasActiveAgentConversation = useActiveAgentConversation();
    if (!editContext)
        return null;
    // Get page from active slot context if available, fallback to editContext.page
    const activeSlotContext = editContext.getActiveSlotContext?.();
    const page = activeSlotContext?.primaryPageViewContext?.page ?? editContext.page;
    const isMobile = editContext.isMobile;
    const isAgentsSidebarOpen = editContext.openSidebars.includes("agents-panel");
    const hasLayout = activeSlotContext?.item?.hasLayout ??
        editContext.item?.hasLayout ??
        page?.item?.hasLayout ??
        false;
    const commentsCount = editContext.comments?.filter((comment) => !comment.isResolved).length || 0;
    const handleAgentsClick = () => {
        if (isMobile) {
            editContext.toggleSidebar?.("agents-panel");
            return;
        }
        editContext.setShowAgentsPanel(!editContext.showAgentsPanel);
    };
    return (_jsxs(_Fragment, { children: [!isMobile && hasLayout && (_jsx(SimpleIconButton, { className: "relative", selected: !!editContext.showComments, icon: _jsx(MessageSquareMore, { className: "h-6 w-6 p-1", strokeWidth: 1 }), label: "Show comments", size: "large", "data-testid": "toggle-comments-button", onClick: () => toggleCommentsFeedback(editContext), children: commentsCount > 0 && (_jsx(CountBadge, { className: "absolute -top-1 -right-1 min-w-[16px]", children: commentsCount > 99 ? "99+" : commentsCount })) })), canUseAi && (_jsxs(_Fragment, { children: [_jsx(SimpleIconButton, { icon: _jsxs("div", { className: "relative", children: [_jsx(ParheliaAgentIcon, { className: "h-6 w-6 p-0.5" }), _jsx(AgentStatusBadge, { status: agentStatus })] }), label: "Agents", size: "large", "data-testid": "agents-panel-button", selected: isMobile ? isAgentsSidebarOpen : editContext.showAgentsPanel, onClick: handleAgentsClick }), hasActiveAgentConversation && (_jsx("span", { "data-testid": "active-agent-conversation", hidden: true }))] })), !hideFullscreen && _jsx(FullscreenControl, {})] }));
}
//# sourceMappingURL=UtilityControls.js.map