import { Container, Text } from "@earendil-works/pi-tui";
function styleTitle(title, theme) {
    const { palette } = theme;
    const parts = title.split(" ");
    const appName = parts[0] ?? title;
    const suffix = parts.slice(1).join(" ");
    if (!suffix) {
        return palette.brandAccent(title);
    }
    return `${palette.brandAccent(appName)} ${palette.textMuted(suffix)}`;
}
function styleBodyLine(line, theme) {
    const { palette } = theme;
    const parts = line.split(/(`[^`]+`)/g);
    return parts
        .filter((part) => part.length > 0)
        .map((part) => {
        if (part.startsWith("`") && part.endsWith("`")) {
            return palette.codeInlineText(part.slice(1, -1));
        }
        return palette.textMuted(part);
    })
        .join("");
}
export class AppIntroComponent extends Container {
    theme;
    constructor(theme, model) {
        super();
        this.theme = theme;
        this.update(model);
    }
    update(model) {
        const title = styleTitle(model.title, this.theme);
        const body = model.body
            .split("\n")
            .map((line) => styleBodyLine(line, this.theme))
            .join("\n");
        const content = `\n${title}\n\n${body}`;
        this.clear();
        this.addChild(new Text(content, 1, 0));
    }
}
//# sourceMappingURL=app_intro.js.map