/**
 * Walk `text` line by line. Lines that match `matchPrefix` start a new entry;
 * lines that don't match glue onto the preceding entry's body with `\n`.
 *
 * Returns an empty `parsedLines` array when no line matches the prefix —
 * the caller decides whether to route the input to a non-conversation path
 * (document chunker) or loud-fail.
 */
export function scanTimestampedLines(input) {
    const { text, matchPrefix, formatIso } = input;
    const lines = text.split("\n");
    const raw = [];
    for (let i = 0; i < lines.length; i++) {
        const line = lines[i];
        if (line.length === 0 && i === lines.length - 1)
            continue;
        const m = matchPrefix(line);
        if (m) {
            const { remainder, ...parts } = m;
            raw.push({ parts, remainder });
        }
        else {
            const last = raw[raw.length - 1];
            if (last)
                last.remainder += "\n" + line;
        }
    }
    const parsedLines = raw.map((r, idx) => ({
        dateSent: formatIso(r.parts),
        body: r.remainder.replace(/\s+$/, ""),
        sequenceIndex: idx,
    }));
    return { parsedLines, matchedCount: parsedLines.length };
}
//# sourceMappingURL=timestamp-scanner.js.map