'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useQuery } from '@tanstack/react-query';
import { FilePen, FilePlus, GitBranch } from 'lucide-react';
import { getGitRepoInfo } from '../../../app/actions/get-git-log.js';
/**
 * Always-visible inline indicator next to the repo path: branch name + a
 * small "n added · n edited · ±lines" digest of working-tree drift. Lives
 * here so the user can see at a glance whether their app has uncommitted
 * work without needing to open the SmartDeployButton panel.
 *
 * The Commit / Commit & Push buttons that used to live in this cluster
 * have been removed — that's the SmartDeployButton's job now (Save 3
 * changes / Save & publish), and having two parallel paths to commit
 * was confusing for the non-technical target audience. The cluster is
 * pure read-only display of git state.
 */
export function GitStatusCluster({ applicationId: _applicationId, repositoryPath, }) {
    const { data } = useQuery({
        queryKey: ['git-repo-info', repositoryPath],
        queryFn: () => getGitRepoInfo(repositoryPath, 1),
        enabled: Boolean(repositoryPath),
        refetchInterval: 5000,
        refetchOnWindowFocus: true,
        staleTime: 2000,
    });
    const trimmedBranch = data?.currentBranch?.trim();
    const branch = trimmedBranch && trimmedBranch.length > 0 ? trimmedBranch : 'main';
    const added = data?.workingTree.untracked ?? 0;
    const edited = data?.workingTree.modified ?? 0;
    const insertions = data?.diffStats?.insertions ?? 0;
    const deletions = data?.diffStats?.deletions ?? 0;
    return (_jsxs("div", { className: "flex items-center gap-2 font-mono text-[11px]", children: [_jsxs("span", { className: "flex items-center gap-1", title: `Branch: ${branch}`, children: [_jsx(GitBranch, { className: "h-3 w-3" }), branch] }), added > 0 ? (_jsxs("span", { className: "flex items-center gap-0.5 text-emerald-500", title: `${added} added ${added === 1 ? 'file' : 'files'}`, children: [_jsx(FilePlus, { className: "h-3 w-3" }), added] })) : null, edited > 0 ? (_jsxs("span", { className: "flex items-center gap-0.5 text-amber-500", title: `${edited} edited ${edited === 1 ? 'file' : 'files'}`, children: [_jsx(FilePen, { className: "h-3 w-3" }), edited] })) : null, insertions > 0 || deletions > 0 ? (_jsxs("span", { className: "flex items-center gap-1", title: `${insertions} insertions, ${deletions} deletions vs HEAD`, children: [insertions > 0 ? _jsxs("span", { className: "text-emerald-500", children: ["+", insertions] }) : null, deletions > 0 ? _jsxs("span", { className: "text-rose-500", children: ["-", deletions] }) : null] })) : null] }));
}
