import { commitCanonicalPlanningEvents } from "../task-engine/persistence/planning-canonical-mutation-hook.js";
import { isGitTaskStateCanonicalAuthority } from "../task-engine/persistence/task-state-canonical-authority.js";
export async function publishIdeasPlanningEvents(input) {
    if (!isGitTaskStateCanonicalAuthority(input.ctx)) {
        return null;
    }
    const canonical = await commitCanonicalPlanningEvents({
        ctx: input.ctx,
        store: input.store,
        planning: input.planning,
        events: input.events,
        policyApproval: input.policyApproval
    });
    if (canonical && !canonical.ok) {
        return canonical;
    }
    if (canonical !== null) {
        await input.store.load();
    }
    return null;
}
