"use client" import type { Email } from "@/lib/email-data" export type ListMailIndex = { emailById: Map scheduledIds: Set } export function buildListMailIndex(emails: Email[]): ListMailIndex { const emailById = new Map() const scheduledIds = new Set() for (const e of emails) { emailById.set(e.id, e) if (e.labels?.includes("scheduled")) scheduledIds.add(e.id) } return { emailById, scheduledIds } } export type MailRowFlags = { isRead: boolean isStarred: boolean isImportant: boolean } export function useMailRowFlags(email: Email): MailRowFlags { return { isRead: email.read, isStarred: email.starred, isImportant: email.important, } }