/**
 * The single Slack notification factory. Dispatches a discriminated
 * SlackNotificationEvent to the per-event template assembler and returns a
 * SlackMessage. Pure: no I/O, no env. Both packages/eval and packages/api
 * call this instead of owning their own formatters.
 */
import { adminAlertMessage, askAnswerMessage, digestMessage, reportMessage, } from "./templates.js";
function assertNever(value) {
    throw new Error(`Unhandled SlackNotificationEvent: ${JSON.stringify(value)}`);
}
export function buildSlackMessage(event, options) {
    switch (event.kind) {
        case "report":
            return reportMessage(event.report, options);
        case "digest":
            return digestMessage(event.digest, event.cadence, options);
        case "admin-alert":
            return adminAlertMessage(event.alert, options);
        case "ask-answer":
            return askAnswerMessage(event.outcome, options, event.channelName);
        default:
            return assertNever(event);
    }
}
