export const ARTIFACT_DELIVERY_MODES = [
    "manual-only",
    "summary",
    "summary-with-actions",
    "auto-files",
    "auto-zip",
    "images-only",
    "off",
];
export function isArtifactDeliveryMode(value) {
    return typeof value === "string" && ARTIFACT_DELIVERY_MODES.includes(value);
}
export function parseArtifactDeliveryMode(value, fallback) {
    const normalized = value?.trim().toLowerCase();
    return isArtifactDeliveryMode(normalized) ? normalized : fallback;
}
export function artifactDeliveryModeFromAutoSend(enabled) {
    return enabled ? "auto-files" : "manual-only";
}
export function resolveArtifactDeliveryPolicy(input) {
    const mode = input.authUser?.user.preferences?.artifactDelivery ??
        input.channelAccess?.artifactDelivery ??
        channelDefaultMode(input.config, input.channelId);
    return artifactDeliveryPolicy(mode);
}
export function artifactDeliveryPolicy(mode) {
    return {
        mode,
        sendSummary: ["summary", "summary-with-actions", "auto-files", "auto-zip", "images-only"].includes(mode),
        includeActions: mode === "summary-with-actions",
        autoSendFiles: mode === "auto-files" || mode === "images-only",
        autoSendZip: mode === "auto-zip",
        imagesOnly: mode === "images-only",
    };
}
function channelDefaultMode(config, channelId) {
    if (channelId === "telegram")
        return config.telegramArtifactDeliveryMode;
    if (channelId === "discord")
        return config.discordArtifactDeliveryMode;
    if (channelId === "slack")
        return config.slackArtifactDeliveryMode;
    if (channelId === "matrix")
        return config.matrixArtifactDeliveryMode;
    return config.artifactDeliveryMode;
}
