/**
 * NodeVersionDiagnostic
 *
 * Verifies that the Node.js runtime executing `shep doctor` is at or above
 * the project's minimum supported major version (Shep requires Node 22+).
 * Reads `process.version` directly — no subprocess needed.
 */
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);
};
import { injectable } from 'tsyringe';
import { DiagnosticStatus } from '../../../../domain/generated/output.js';
const MIN_NODE_MAJOR = 22;
let NodeVersionDiagnostic = class NodeVersionDiagnostic {
    versionString;
    name = 'node-version';
    constructor(versionString = process.version) {
        this.versionString = versionString;
    }
    async run() {
        const major = parseMajor(this.versionString);
        if (major === null) {
            return {
                name: this.name,
                status: DiagnosticStatus.Fail,
                detail: `Could not parse Node version "${this.versionString}"`,
                fixHint: `Ensure Node ${MIN_NODE_MAJOR}+ is installed and on PATH`,
            };
        }
        if (major < MIN_NODE_MAJOR) {
            return {
                name: this.name,
                status: DiagnosticStatus.Fail,
                detail: `Node ${this.versionString} is below the required v${MIN_NODE_MAJOR}+`,
                fixHint: `Install Node ${MIN_NODE_MAJOR} or newer (see .nvmrc); recommended via nvm or fnm`,
            };
        }
        return {
            name: this.name,
            status: DiagnosticStatus.Ok,
            detail: `Node ${this.versionString} (>= v${MIN_NODE_MAJOR})`,
        };
    }
};
NodeVersionDiagnostic = __decorate([
    injectable(),
    __metadata("design:paramtypes", [String])
], NodeVersionDiagnostic);
export { NodeVersionDiagnostic };
function parseMajor(versionString) {
    const m = /^v?(\d+)\./.exec(versionString.trim());
    if (!m)
        return null;
    const n = Number(m[1]);
    return Number.isFinite(n) ? n : null;
}
