/**
 * RunDoctorUseCase
 *
 * Orchestrates the `shep doctor` strategy pipeline. Resolves a list of
 * `IDiagnostic` strategies and an `IDiagnosticRunner`, executes them via
 * the runner (parallel + per-diagnostic timeout, see infrastructure
 * adapter), and returns the aggregated `DoctorReport`.
 *
 * Pure orchestration: NO presentation concerns (no formatting, no exit
 * codes). The CLI layer maps `overallStatus` to an exit code; web layers
 * render the report into a table or summary block.
 */
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, injectAll } from 'tsyringe';
import { DiagnosticStatus } from '../../../domain/generated/output.js';
let RunDoctorUseCase = class RunDoctorUseCase {
    runner;
    diagnostics;
    constructor(runner, diagnostics) {
        this.runner = runner;
        this.diagnostics = diagnostics;
    }
    async execute() {
        const report = await this.runner.runAll(this.diagnostics);
        return { ...report, summary: countByStatus(report) };
    }
};
RunDoctorUseCase = __decorate([
    injectable(),
    __param(0, inject('IDiagnosticRunner')),
    __param(1, injectAll('IDiagnostic')),
    __metadata("design:paramtypes", [Object, Array])
], RunDoctorUseCase);
export { RunDoctorUseCase };
function countByStatus(report) {
    const summary = { ok: 0, warn: 0, fail: 0 };
    for (const r of report.results) {
        if (r.status === DiagnosticStatus.Ok)
            summary.ok += 1;
        else if (r.status === DiagnosticStatus.Warn)
            summary.warn += 1;
        else if (r.status === DiagnosticStatus.Fail)
            summary.fail += 1;
    }
    return summary;
}
