// Builds the default reply/forward quote header and runs it through the // emailHooks.onBuildQuoteHeader transform so plugins can replace it (e.g. // with an Outlook-style From/Sent/To/Cc/Subject block). // // This module is the single source of truth for the default header strings - // the composer keeps the same defaults inline as a fallback, but production // flow goes through here. import { formatDateTime } from "@/lib/utils"; import { emailHooks } from "@/lib/plugin-hooks"; import type { QuoteHeader, QuoteHeaderContext } from "@/lib/plugin-types"; interface BuildArgs { mode: "reply" | "replyAll" | "forward"; email: { from?: { email?: string; name?: string }[]; to?: { email?: string; name?: string }[]; cc?: { email?: string; name?: string }[]; subject?: string; receivedAt?: string; }; newTo: string[]; newCc: string[]; locale: string; timeFormat: "12h" | "24h"; unknownLabel: string; } function defaultHeader(args: BuildArgs): QuoteHeader { const { mode, email, timeFormat, unknownLabel } = args; const date = email.receivedAt ? formatDateTime(email.receivedAt, timeFormat, { weekday: "short", year: "numeric", month: "short", day: "numeric", }) : ""; const from = email.from?.[0]; const fromStr = from ? `${from.name || from.email}` : unknownLabel; const subject = email.subject || ""; if (mode === "forward") { const text = `---------- Forwarded message ----------\nFrom: ${fromStr}\nDate: ${date}\nSubject: ${subject}\n`; const html = `