import { isValidEmail } from "@/lib/validation"; const HTML_ESCAPE_MAP = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'", } as const; function escapeHtml(value: string): string { return value.replace(/[&<>"']/g, (char) => HTML_ESCAPE_MAP[char as keyof typeof HTML_ESCAPE_MAP] ); } export function plainTextToComposerBody(text: string): string { if (!text) return ""; return text .replace(/\r\n?/g, "\n") .split(/\n{2,}/) .map((paragraph) => `
${escapeHtml(paragraph).replace(/\n/g, "
")}