//#region src/v2/features/app/helpers/group-workspaces.ts
/**
* Groups workspaces into team and local categories.
* Team workspaces are listed first (if not viewing local workspaces),
* followed by local workspaces.
*
* @param workspaces - Array of workspaces to group
* @param currentTeamUid - Current team identifier ('local' for local team)
* @returns Array of workspace groups with labels and options
*/
function groupWorkspacesByTeam(workspaces, currentTeamUid) {
	const workspacesByTeam = workspaces.reduce((acc, workspace) => {
		const teamUid = workspace.teamUid;
		if (!acc[teamUid]) acc[teamUid] = [];
		acc[teamUid].push({
			id: workspace.id,
			label: workspace.label
		});
		return acc;
	}, {});
	const result = [];
	if (currentTeamUid !== "local") {
		const teamWorkspaces = workspacesByTeam[currentTeamUid] ?? [];
		if (teamWorkspaces.length > 0) result.push({
			label: "Team Workspaces",
			options: teamWorkspaces
		});
	}
	result.push({
		label: "Local Workspaces",
		options: workspacesByTeam["local"] ?? []
	});
	return result;
}
//#endregion
export { groupWorkspacesByTeam };

//# sourceMappingURL=group-workspaces.js.map