function escapeHtml(value: string): string { return value .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, ''') } export interface BookingEmailInput { serviceName: string date: string time: string contact: { name: string; phone: string; email: string; notes: string } } export function buildBookingNotificationEmail(input: BookingEmailInput): { subject: string; html: string } { const serviceName = escapeHtml(input.serviceName) const name = escapeHtml(input.contact.name) const phone = escapeHtml(input.contact.phone) const email = escapeHtml(input.contact.email) const notesLine = input.contact.notes ? `

Notes: ${escapeHtml(input.contact.notes)}

` : '' return { subject: `New booking: ${input.serviceName} on ${input.date}`, html: `

${name} booked ${serviceName} on ${escapeHtml(input.date)} at ${escapeHtml(input.time)}.

` + `

Phone: ${phone}
Email: ${email}

${notesLine}`, } } export interface InquiryEmailInput { productName: string contact: { name: string; email: string; notes: string } } export function buildInquiryNotificationEmail(input: InquiryEmailInput): { subject: string; html: string } { const productName = escapeHtml(input.productName) const name = escapeHtml(input.contact.name) const email = escapeHtml(input.contact.email) const notesLine = input.contact.notes ? `

Notes: ${escapeHtml(input.contact.notes)}

` : '' return { subject: `New inquiry: ${input.productName}`, html: `

${name} (${email}) asked about ${productName}.

${notesLine}`, } }