export const SSE_HEADERS = {
    "Content-Type": "text/event-stream",
    "Cache-Control": "no-cache",
    Connection: "keep-alive",
};
export function formatSseEvent(event) {
    const lines = [];
    if (event.id !== undefined) {
        lines.push(`id: ${event.id}`);
    }
    if (event.event !== undefined) {
        lines.push(`event: ${event.event}`);
    }
    const dataLines = event.data
        .replaceAll("\r\n", "\n")
        .replaceAll("\r", "\n")
        .split("\n");
    for (const dataLine of dataLines) {
        lines.push(`data: ${dataLine}`);
    }
    return `${lines.join("\n")}\n\n`;
}
