// Tiny DOM-builder helper shared by the dashboard and the per-agent UI. There // is no `html` attribute on purpose: content is built from nodes and text, so a // string from the API can never become markup. // // `el(tag, attrs, ...children)` creates an element, applying `attrs` as // either the `class` special case or plain attributes, and // appending `children` (strings become text nodes, `null`/`undefined` // entries are skipped so callers can inline conditional children). // `tag` can be any custom element's tag name too (e.g. `el('hive-btn', // { variant: 'danger' }, 'label')`) — `document.createElement` upgrades // it automatically if the tag is already registered. export const el = (tag, attrs = {}, ...children) => { const e = document.createElement(tag); for (const [k, v] of Object.entries(attrs)) { if (k === "class") e.className = v; else e.setAttribute(k, v); } for (const c of children) { if (c == null) continue; e.append(c.nodeType ? c : document.createTextNode(c)); } return e; };