import { isHandlerConventionFile } from '../graph/handler-conventions.js';
import { stableHash } from '../utils/hash.js';
// Files in handler-convention dirs (src/handlers, src/lambdas, …) that are
// neither IaC-referenced nor imported anywhere. Confidence 0.65 (runtime
// config-file wiring is invisible to ts-morph).
export function detectDeadHandlers(input) {
    const importedTargets = new Set();
    for (const imp of input.imports) {
        if (imp.target)
            importedTargets.add(imp.target);
    }
    const findings = [];
    for (const file of input.files) {
        if (!isHandlerConventionFile(file))
            continue;
        if (input.iacEntries.has(file))
            continue;
        if (importedTargets.has(file))
            continue;
        findings.push({
            detectorId: 'dead-handler',
            severity: 'low',
            confidence: 0.65,
            layer: 1,
            title: `Handler with no IaC wiring: ${file}`,
            description: `\`${file}\` lives in a handler-convention directory but no CDK / SST / Serverless-framework construct references its path, and no other file imports it.\nLocations:\n- ${file} (entire file)`,
            evidence: [
                {
                    file,
                    range: { startLine: 1, endLine: 1 },
                    snippet: `// (no IaC reference and no inbound import for ${file})`,
                },
            ],
            suggestion: 'If this handler is wired by a non-TypeScript config (`serverless.yml`, `sam.template.yaml`, runtime path string), mark this finding as a false positive. Otherwise it is dead infrastructure — wire it or remove the file.',
            fingerprint: `dead-handler:${stableHash(file)}`,
        });
    }
    return findings;
}
//# sourceMappingURL=dead-handler.js.map