import { truncateToWidth } from "@earendil-works/pi-tui";
const ACTIVE_POINTER = "❯ ";
const INACTIVE_POINTER = "  ";
const NUMBER_SEPARATOR = ". ";
export const SUBMIT_LABEL = "Submit answers";
export const CANCEL_LABEL = "Cancel";
/**
 * Static 2-row picker rendered on the Submit Tab. Row 0 = "Submit answers", Row 1 = "Cancel".
 *
 * - Active pointer (❯) follows `props.rows[i].active` per tick.
 * - Both rows render in normal style at all times — D1 (revised) allows partial submission,
 *   so Submit is never dimmed or visually marked as unselectable. The warning header in
 *   `buildSubmitContainer` is the sole signal of incompleteness.
 * - `naturalHeight(width)` is state-INDEPENDENT and returns a constant 2, so the
 *   chrome-mirror layout in `buildSubmitContainer` can subtract a fixed 2 lines without
 *   re-rendering.
 */
export class SubmitPicker {
    constructor(theme) {
        this.theme = theme;
        this.props = { rows: [{ active: false }, { active: false }] };
    }
    setProps(props) {
        this.props = props;
    }
    handleInput(_data) { }
    invalidate() { }
    naturalHeight(_width) {
        return 2;
    }
    render(width) {
        const lines = [];
        for (let i = 0; i < 2; i++) {
            const text = i === 0 ? SUBMIT_LABEL : CANCEL_LABEL;
            const active = this.props.rows[i]?.active ?? false;
            const pointer = active ? ACTIVE_POINTER : INACTIVE_POINTER;
            const number = `${i + 1}${NUMBER_SEPARATOR}`;
            const label = active ? this.theme.fg("accent", this.theme.bold(text)) : this.theme.fg("text", text);
            lines.push(truncateToWidth(`${pointer}${number}${label}`, width, ""));
        }
        return lines;
    }
}
//# sourceMappingURL=submit-picker.js.map