import { watch } from "node:fs";
import type pino from "pino";
import { getCheckoutShortstat, getCheckoutStatus, getPullRequestStatus, resolveGhPath } from "../utils/checkout-git.js";
export type WorkspaceGitRuntimeSnapshot = {
    cwd: string;
    git: {
        isGit: boolean;
        repoRoot: string | null;
        mainRepoRoot: string | null;
        currentBranch: string | null;
        remoteUrl: string | null;
        isSeaworkOwnedWorktree: boolean;
        isDirty: boolean | null;
        aheadBehind: {
            ahead: number;
            behind: number;
        } | null;
        aheadOfOrigin: number | null;
        behindOfOrigin: number | null;
        diffStat: {
            additions: number;
            deletions: number;
        } | null;
    };
    github: {
        featuresEnabled: boolean;
        pullRequest: {
            url: string;
            title: string;
            state: string;
            baseRefName: string;
            headRefName: string;
            isMerged: boolean;
        } | null;
        error: {
            message: string;
        } | null;
        refreshedAt: string | null;
    };
};
export interface WorkspaceGitService {
    subscribe(params: {
        cwd: string;
    }, listener: WorkspaceGitListener): Promise<{
        initial: WorkspaceGitRuntimeSnapshot;
        unsubscribe: () => void;
    }>;
    peekSnapshot(cwd: string): WorkspaceGitRuntimeSnapshot | null;
    getSnapshot(cwd: string): Promise<WorkspaceGitRuntimeSnapshot>;
    refresh(cwd: string, options?: {
        priority?: "normal" | "high";
    }): Promise<void>;
    dispose(): void;
}
export type WorkspaceGitListener = (snapshot: WorkspaceGitRuntimeSnapshot) => void;
interface WorkspaceGitServiceDependencies {
    watch: typeof watch;
    getCheckoutStatus: typeof getCheckoutStatus;
    getCheckoutShortstat: typeof getCheckoutShortstat;
    getPullRequestStatus: typeof getPullRequestStatus;
    resolveGhPath: typeof resolveGhPath;
    resolveAbsoluteGitDir: (cwd: string) => Promise<string | null>;
    hasOriginRemote: (cwd: string) => Promise<boolean>;
    runGitFetch: (cwd: string) => Promise<void>;
    now: () => Date;
}
interface WorkspaceGitServiceOptions {
    logger: pino.Logger;
    seaworkHome: string;
    deps?: Partial<WorkspaceGitServiceDependencies>;
}
export declare class WorkspaceGitServiceImpl implements WorkspaceGitService {
    private readonly logger;
    private readonly seaworkHome;
    private readonly deps;
    private readonly workspaceTargets;
    private readonly repoTargets;
    private readonly workspaceTargetSetups;
    constructor(options: WorkspaceGitServiceOptions);
    subscribe(params: {
        cwd: string;
    }, listener: WorkspaceGitListener): Promise<{
        initial: WorkspaceGitRuntimeSnapshot;
        unsubscribe: () => void;
    }>;
    getSnapshot(cwd: string): Promise<WorkspaceGitRuntimeSnapshot>;
    peekSnapshot(cwd: string): WorkspaceGitRuntimeSnapshot | null;
    refresh(cwd: string, _options?: {
        priority?: "normal" | "high";
    }): Promise<void>;
    dispose(): void;
    private ensureWorkspaceTarget;
    private createWorkspaceTarget;
    private resolveWorkspaceGitRefsRoot;
    private startWorkspaceWatchers;
    private ensureRepoTarget;
    private scheduleWorkspaceRefresh;
    private refreshWorkspaceTarget;
    private refreshSnapshot;
    private rememberSnapshot;
    private runRepoFetch;
    private removeWorkspaceListener;
    private removeWorkspaceTarget;
    private closeWorkspaceTarget;
    private closeRepoTarget;
}
export {};
//# sourceMappingURL=workspace-git-service.d.ts.map