function normalizePromptBlock(block) {
    if (!block || typeof block !== 'object')
        return null;
    if (block.enabled === false)
        return null;
    const id = typeof block.id === 'string' ? block.id.trim() : '';
    const text = typeof block.text === 'string' ? block.text.trim() : '';
    if (!id || !text)
        return null;
    return {
        id,
        scope: block.scope,
        text,
    };
}
export function dedupePromptBlocksV1(blocks) {
    const out = [];
    const seen = new Set();
    for (const candidate of blocks) {
        if (!candidate)
            continue;
        const normalized = normalizePromptBlock(candidate);
        if (!normalized)
            continue;
        if (seen.has(normalized.id))
            continue;
        seen.add(normalized.id);
        out.push(normalized);
    }
    return out;
}
export function buildPromptPlanV1(args) {
    return {
        modality: args.modality,
        blocks: dedupePromptBlocksV1(args.blocks),
    };
}
export function renderPromptBlocksV1(blocks) {
    return dedupePromptBlocksV1(blocks)
        .map((block) => block.text)
        .join('\n\n')
        .trim();
}
export function renderPromptPlanV1(plan) {
    return renderPromptBlocksV1(plan.blocks);
}
export function buildPromptPlanDiagnosticsV1(plan) {
    return {
        modality: plan.modality,
        blockIds: plan.blocks.map((block) => block.id),
        scopes: plan.blocks.map((block) => block.scope),
    };
}
//# sourceMappingURL=promptPlanV1.js.map