import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
export class SessionDividerComponent {
    theme;
    model;
    constructor(theme, model) {
        this.theme = theme;
        this.model = model;
    }
    update(model) {
        this.model = model;
    }
    invalidate() { }
    render(width) {
        const leftDashes = "──";
        const leftWidth = Math.min(visibleWidth(leftDashes), Math.max(0, width));
        const left = leftWidth === visibleWidth(leftDashes)
            ? leftDashes
            : Array.from(leftDashes).slice(0, leftWidth).join("");
        const maxLabelWidth = Math.max(0, width - leftWidth - 1);
        const labelRaw = ` ${this.model.label} `;
        const label = maxLabelWidth > 0 ? truncateToWidth(labelRaw, maxLabelWidth, "…") : "";
        const remainingWidth = Math.max(0, width - leftWidth - visibleWidth(label));
        const rightDashes = "─".repeat(remainingWidth);
        const dividerText = `${left}${label}${rightDashes}`;
        return [this.theme.palette.textMuted(dividerText)];
    }
}
//# sourceMappingURL=session_divider.js.map