// The console's building blocks in Dashtreme's markup: cards with a title row and rule, data/static widgets (label, // value, icon, delta, sparkline, progress), colour static widgets, border alerts, breadcrumb page heads, progress lists. import { useId, useLayoutEffect, useRef, useState, type ReactNode } from 'react' import { createPortal } from 'react-dom' // Semantic icon names (the server sends these with status widgets) → Boxicons. const ICONS: Record = { payments: 'bx-money', receipt: 'bx-receipt', candlestick: 'bx-line-chart', psychology: 'bx-chip', block: 'bx-block', upgrade: 'bx-up-arrow-circle', neurology: 'bx-brain', swap: 'bx-transfer-alt', model_training: 'bx-analyse', sensors: 'bx-broadcast', history: 'bx-history', visibility: 'bx-show', query_stats: 'bx-search-alt', savings: 'bx-coin-stack', dashboard: 'bx-grid-alt', trades: 'bx-transfer', database: 'bx-data', link: 'bx-link', settings: 'bx-cog', shield: 'bx-shield-quarter', logs: 'bx-terminal', info: 'bx-info-circle', warning: 'bx-error', error: 'bx-error-circle', success: 'bx-check-circle', play: 'bx-play', stop: 'bx-stop', pause: 'bx-pause', reset: 'bx-reset', undo: 'bx-undo', refresh: 'bx-refresh', score: 'bx-target-lock', wallet: 'bx-wallet', bell: 'bx-bell', search: 'bx-search', download: 'bx-download', external: 'bx-link-external', copy: 'bx-copy', folder: 'bx-folder-open', terminal: 'bx-terminal', autorenew: 'bx-sync', race: 'bx-flag', category: 'bx-category', pulse: 'bx-pulse', rocket: 'bx-rocket', lock: 'bx-lock', key: 'bx-key', trash: 'bx-trash', time: 'bx-time', fly: 'bx-bug', wealth: 'bx-wallet-alt', pnl: 'bx-dollar-circle', count: 'bx-list-check', open: 'bx-briefcase-alt-2', drawdown: 'bx-trending-down', up: 'bx-trending-up', target: 'bx-bullseye', calendar: 'bx-calendar', layers: 'bx-layer', chart: 'bx-bar-chart-alt-2', percent: 'bx-pie-chart-alt-2', } export function Icon({ name, className = '' }: { name?: string | null; className?: string }) { if (!name) return null const cls = name.startsWith('bx') ? name : ICONS[name] || 'bx-circle' return