import { getHappeningStore } from "./store.js";
import { getTopHappeningTree } from "./get-happening-tree.js";
import { ok } from "../../is.js";
export async function deleteHappening(happeningId) {
    const store = getHappeningStore();
    return store.delete(happeningId);
}
export async function deleteHappeningTree(happeningId) {
    const tree = await getTopHappeningTree(happeningId);
    const identifiers = [...new Set(getIdentifiers(tree))];
    ok(identifiers.includes(happeningId));
    await Promise.all(identifiers.map(deleteHappening));
    function getIdentifiers(tree) {
        return [
            tree.id,
            ...tree.children.flatMap(getIdentifiers)
        ];
    }
}
//# sourceMappingURL=delete-happening.js.map