import { truncateToWidth } from "@earendil-works/pi-tui";
export class TabBar {
    constructor(theme) {
        this.theme = theme;
        this.props = { tabs: [], submit: { active: false, allAnswered: false } };
    }
    setProps(props) {
        this.props = props;
    }
    handleInput(_data) { }
    invalidate() { }
    render(width) {
        const pieces = [" ← "];
        for (const tab of this.props.tabs) {
            const box = tab.answered ? "■" : "□";
            const rawSeg = ` ${box} ${tab.label} `;
            const styled = tab.active
                ? this.theme.bg("selectedBg", this.theme.fg("text", rawSeg))
                : this.theme.fg(tab.answered ? "success" : "muted", rawSeg);
            pieces.push(styled);
            pieces.push(" ");
        }
        const submitText = " ✓ Submit ";
        const submitStyled = this.props.submit.active
            ? this.theme.bg("selectedBg", this.theme.fg("text", submitText))
            : this.theme.fg(this.props.submit.allAnswered ? "success" : "dim", submitText);
        pieces.push(submitStyled);
        pieces.push(" →");
        const tabLine = truncateToWidth(pieces.join(""), width, "");
        return [tabLine, ""];
    }
}
//# sourceMappingURL=tab-bar.js.map