/** Parse a git diff string into structured per-file change lists. */
export function parseDiffFiles(diff) {
    const files = [];
    let current = null;
    let lineNo = 0;
    for (const line of diff.split('\n')) {
        if (line.startsWith('diff --git')) {
            const match = /b\/(.+)$/.exec(line);
            if (match?.[1]) {
                current = { path: match[1], lines: [] };
                files.push(current);
                lineNo = 0;
            }
            continue;
        }
        const hunkMatch = /^@@\s+-\d+(?:,\d+)?\s+\+(\d+)/.exec(line);
        if (hunkMatch?.[1]) {
            lineNo = Number(hunkMatch[1]);
            continue;
        }
        if (line.startsWith('+') && !line.startsWith('+++')) {
            current?.lines.push({ lineNo, content: line.slice(1) });
            lineNo++;
        }
        else if (!line.startsWith('-')) {
            lineNo++;
        }
    }
    return files;
}
//# sourceMappingURL=review-helpers.js.map