import { html, SafeHtml, safeUrl } from "./html.js" /** Email renderizzata: oggetto, HTML (layout comune) e testo semplice. */ export type RenderedEmail = { subject: string; html: string; text: string } const BRAND = "ITI TECHNOLOGY" const COLOR = "#0b5c7a" const FOOTER_TEXT = `${BRAND} · trattamento acqua, energia rinnovabile, comfort e mobilità elettrica` /** Pulsante (link) in stile brand; l'URL passa da safeUrl. */ export const button = (label: string, url: string) => html`
${label}
` export const paragraph = (content: SafeHtml | string) => html`

${content}

` /** Tabella chiave/valore (riepiloghi d'ordine, preventivi, prenotazioni). */ export function table(rows: readonly (readonly [string, SafeHtml | string])[], opts: { boldLast?: boolean } = {}) { return html` ${rows.map( ([label, value], i) => html``, )}
${label} ${value}
` } /** * Layout comune: intestazione brand, contenuto, piè di pagina. HTML semplice a tabelle con stili * inline (compatibile con i client di posta). `preheader` = anteprima mostrata nella lista messaggi. */ export function layout(opts: { subject: string; preheader: string; body: SafeHtml; text: string }): RenderedEmail { const page = html` ${opts.subject} ${opts.preheader}
${BRAND}
${opts.body}
${FOOTER_TEXT}
Questa è un'email automatica.
` return { subject: opts.subject, html: page.value, text: `${opts.text.trim()}\n\n--\n${FOOTER_TEXT}\n`, } }