import type { Group, Space } from "@rakazo/contracts"; /** The project's own main conversation, where the user talks to its main agent. */ export function projectMainGroup>( groups: readonly T[], spaceId: string, ): T | undefined { return groups.find((group) => group.spaceId === spaceId && group.kind === "main"); } /** Non-default project space without any conversation yet, not even its main one. */ export function isEmptyProjectSpace( spaceId: string | null | undefined, spaces: readonly Pick[], groups: readonly Pick[], homeSpaceId: string | undefined, ): boolean { if (!spaceId || !homeSpaceId || spaceId === homeSpaceId) return false; const space = spaces.find((item) => item.id === spaceId); if (!space || space.isDefault) return false; return !groups.some((group) => group.spaceId === spaceId); }