import { Zap, X, Power, Radio } from 'lucide-react'; import { cn } from '@/lib/utils'; import { useI18n } from '@/lib/i18n'; export type TGChannel = { ptt?: boolean; band?: number; mode?: number; mode_str?: string; flex?: string; freq_mhz?: number; bypass?: boolean; antenna?: number; }; export type TGStatus = { connected: boolean; host?: string; last_error?: string; fwd_dbm?: number; fwd_w?: number; swr_db?: number; vswr?: number; freq_mhz?: number; operate?: boolean; bypass?: boolean; tuning?: boolean; active?: number; antenna?: number; three_way?: boolean; message?: string; a?: TGChannel; b?: TGChannel; relay_c1?: number; relay_l?: number; relay_c2?: number; }; // swrColour picks a status colour for the VSWR readout: green ≤1.5, amber ≤2.0, // red above (the usual "safe / caution / high" ATU thresholds). function swrColour(vswr?: number): string { if (!vswr || vswr <= 0) return 'text-muted-foreground'; if (vswr <= 1.5) return 'text-success'; if (vswr <= 2.0) return 'text-warning'; return 'text-danger'; } // ChanRow — a compact A/B channel line in the docked widget. Highlights the // active channel (green) or TX (red), shows the source + frequency + antenna, // and clicking it makes that channel active. function ChanRow({ letter, ch, active, onSelect, t }: { letter: 'A' | 'B'; ch: TGChannel; active: boolean; onSelect: () => void; t: (k: string, v?: any) => string; }) { const ptt = !!ch.ptt; const cls = ptt ? 'bg-gradient-to-r from-red-500 to-rose-600 text-white border-red-400/40' : active ? 'bg-gradient-to-r from-emerald-500 to-emerald-600 text-white border-emerald-400/40' : 'bg-card/70 text-foreground/80 border-border hover:bg-muted/60'; const src = ch.mode_str || '—'; const freq = ch.freq_mhz && ch.freq_mhz > 0 ? `${ch.freq_mhz.toFixed(3)}` : '—'; return ( ); } // TunerGeniusPanel — compact docked widget for a 4O3A Tuner Genius XL ATU. Shows // the live SWR / forward power, the two RF channels (A / B, click to activate), // and Tune / Bypass / Operate. A fuller card (TunerCard) is shown in the FlexRadio // panel and Station Control. export function TunerGeniusPanel({ status, onTune, onBypass, onOperate, onActivate, onClose }: { status: TGStatus; onTune: () => void; onBypass: (on: boolean) => void; onOperate: (on: boolean) => void; onActivate: (ch: number) => void; onClose: () => void; }) { const { t } = useI18n(); const vswr = status.vswr && status.vswr > 0 ? status.vswr : undefined; const active = status.active ?? 1; return (