"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toDxScoreInput = toDxScoreInput;
exports.scoreDxFromScoreInput = scoreDxFromScoreInput;
exports.scoreDxDimension = scoreDxDimension;
/**
 * Developer Experience dimension — health-side adapter over the
 * declarative DX scoring spec.
 *
 * Builds `DxScoreInput` from the health-side `ScoreInput`
 * (HealthMetrics) and dispatches through `evaluateSpec`. The
 * resulting `DimensionScore` carries the score, rating, provenance,
 * and the dimension-specific metrics + details surfaced in the
 * health audit's markdown.
 */
const scoring_1 = require("../../scoring");
function toDxScoreInput(input) {
    const m = input.metrics;
    return {
        ciConfigCount: m.ciConfigCount,
        dockerConfigCount: m.dockerConfigCount,
        precommitConfigCount: m.precommitConfigCount,
        makefileExists: m.makefileExists,
        envExampleExists: m.envExampleExists,
        npmScriptsCount: m.npmScriptsCount,
        contributingExists: m.contributingExists,
        readmeLines: m.readmeLines,
        changelogExists: m.changelogExists,
    };
}
/**
 * Score-only adapter for the health remediation planner. Mirrors the
 * other dimensions' `score*FromScoreInput` shims.
 */
function scoreDxFromScoreInput(input) {
    return (0, scoring_1.evaluateSpec)(scoring_1.DX_SCORING_SPEC, toDxScoreInput(input));
}
function scoreDxDimension(input) {
    const m = input.metrics;
    const scoreInput = toDxScoreInput(input);
    const result = (0, scoring_1.evaluateSpec)(scoring_1.DX_SCORING_SPEC, scoreInput);
    const score = result.score;
    return {
        score,
        maxScore: 100,
        rating: (0, scoring_1.ratingFromScore)(score),
        rawScore: result.rawScore,
        rawPenalty: result.rawPenalty,
        methodology: result.methodology,
        deductions: result.deductions,
        capsApplied: result.capsApplied,
        topActions: result.topActions,
        metrics: {
            ciConfigCount: m.ciConfigCount,
            dockerConfigCount: m.dockerConfigCount,
            precommitConfigCount: m.precommitConfigCount,
            makefileExists: m.makefileExists,
            envExampleExists: m.envExampleExists,
            npmScriptsCount: m.npmScriptsCount,
            contributingExists: m.contributingExists,
            changelogExists: m.changelogExists,
        },
        details: `CI configs: ${m.ciConfigCount}` +
            `. Docker: ${m.dockerConfigCount > 0 ? 'yes' : 'no'}` +
            `. Pre-commit hooks: ${m.precommitConfigCount > 0 ? 'yes' : 'no'}` +
            `. Makefile: ${m.makefileExists ? 'yes' : 'no'}` +
            `. .env.example: ${m.envExampleExists ? 'yes' : 'no'}` +
            `. npm scripts: ${m.npmScriptsCount}` +
            '.',
    };
}
//# sourceMappingURL=shallow.js.map