/**
 * GhCliAuthDiagnostic
 *
 * Verifies the GitHub CLI (`gh`) is installed and authenticated. Many Shep
 * surfaces (issue grooming, PR sync, IGitHubIssueWriter) reuse the token
 * resolved by `gh auth`, so a missing or unauthenticated `gh` blocks the
 * contributor automation pipeline.
 */
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
import { inject, injectable } from 'tsyringe';
import { DiagnosticStatus } from '../../../../domain/generated/output.js';
import { GitHubAuthError, } from '../../../ports/output/services/github-repository-service.interface.js';
let GhCliAuthDiagnostic = class GhCliAuthDiagnostic {
    githubService;
    name = 'gh-cli-auth';
    constructor(githubService) {
        this.githubService = githubService;
    }
    async run() {
        try {
            await this.githubService.checkAuth();
            return {
                name: this.name,
                status: DiagnosticStatus.Ok,
                detail: 'gh CLI is authenticated',
            };
        }
        catch (err) {
            const isAuthError = err instanceof GitHubAuthError;
            return {
                name: this.name,
                status: isAuthError ? DiagnosticStatus.Warn : DiagnosticStatus.Fail,
                detail: isAuthError
                    ? 'gh CLI is not authenticated'
                    : `gh auth check failed: ${err instanceof Error ? err.message : String(err)}`,
                fixHint: 'Run `gh auth login` to authenticate the GitHub CLI',
            };
        }
    }
};
GhCliAuthDiagnostic = __decorate([
    injectable(),
    __param(0, inject('IGitHubRepositoryService')),
    __metadata("design:paramtypes", [Object])
], GhCliAuthDiagnostic);
export { GhCliAuthDiagnostic };
