import { randomUUID } from "node:crypto";
import { commitCanonicalPlanningEvents } from "../persistence/planning-canonical-mutation-hook.js";
import { isGitTaskStateCanonicalAuthority } from "../persistence/task-state-canonical-authority.js";
export async function publishPhaseJournalPlanningEvents(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;
}
export function newPhaseNoteId() {
    return randomUUID();
}
