import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from "ink";
import { StructuredDiff, diffLineColor, isUnifiedDiff } from "./StructuredDiff.js";
export function structuredDiffListModel(diff, maxLines = 220) {
    const lines = diff.split(/\r?\n/);
    return {
        isDiff: isUnifiedDiff(diff),
        visibleLines: lines.slice(0, maxLines),
        hidden: Math.max(0, lines.length - maxLines),
    };
}
export function StructuredDiffList(props) {
    if (props.rich ?? true) {
        return _jsx(StructuredDiff, { diff: props.diff, maxLines: props.maxLines });
    }
    const model = structuredDiffListModel(props.diff, props.maxLines);
    return (_jsxs(Box, { flexDirection: "column", children: [model.visibleLines.map((line, index) => (_jsx(Text, { color: diffLineColor(line), children: line || " " }, `${index}:${line}`))), model.hidden ? _jsxs(Text, { color: "gray", children: ["+", model.hidden, " hidden lines"] }) : null] }));
}
