import { t } from "./i18n.js"; export const $ = (id) => document.getElementById(id); export function csv(value) { return String(value || "").split(",").map((item) => item.trim()).filter(Boolean); } export function escapeHtml(value) { return String(value ?? "") .replaceAll("&", "&") .replaceAll("<", "<") .replaceAll(">", ">") .replaceAll('"', """) .replaceAll("'", "'"); } export function chip(value) { return `${escapeHtml(value)}`; } export function table(headers, rows) { if (!rows.length) { return `
${escapeHtml(t("table.no_data"))}
`; } return ` ${headers.map((header) => ``).join("")}${rows.map((row) => `${row.map((cell) => ``).join("")}`).join("")}
${escapeHtml(header)}
${String(cell ?? "")}
`; } let toastTimer = null; export function toast(message) { const node = document.getElementById("toast"); if (!node) return; node.textContent = message; node.classList.add("show"); if (toastTimer) window.clearTimeout(toastTimer); toastTimer = window.setTimeout(() => node.classList.remove("show"), 2400); }