// A slide drawn exactly as the TV draws it (@xenia/signage), in a box of the playlist's shape // (plan step 5.6a). The slide is laid out on a full-size 1920 × 1080 (or 1080 × 1920) frame and // scaled down to the box, so text, rows and menu pages match a real TV, not a small window. // `editor` = { selected, onSelect, onPlace, label } (2026-11-21): the widgets can be picked, moved // and sized on it (WidgetCanvas). import { useEffect, useRef, useState } from 'react' import { boardPages, SlideView, WIDGET_HOSTS } from '@xenia/signage' import WidgetCanvas from './WidgetCanvas' const LONG = 1920 const SHORT = 1080 export default function SlidePreview({ slide, media, venue, orientation = 'landscape', page = 0, playing = false, className = '', testid = 'signage-preview', editor = null }) { const [now, setNow] = useState(() => new Date()) const box = useRef(null) const [scale, setScale] = useState(0) useEffect(() => { const id = setInterval(() => setNow(new Date()), 1000) return () => clearInterval(id) }, []) const tall = orientation === 'portrait' const w = tall ? SHORT : LONG const h = tall ? LONG : SHORT useEffect(() => { const el = box.current if (!el) return undefined const measure = () => setScale(el.clientWidth / w) measure() const ro = new ResizeObserver(measure) ro.observe(el) return () => ro.disconnect() }, [w]) const pages = slide?.kind === 'menu' ? boardPages(slide, 0, w, h) : null return (