import type { MouseEvent } from 'react'; import type { SceneCanvas, SceneHotspot } from '../../src/contracts/scene'; import { sceneViewBox } from './scene-coordinate-map'; export interface ResolvedHotspot extends SceneHotspot { href: string } interface Props { label: string; canvas: SceneCanvas; hotspots: ResolvedHotspot[]; onFocus: (id: string | null) => void; onActivate: (hotspot: ResolvedHotspot, event: MouseEvent) => void } /** Real anchors drawn as invisible hit shapes in room coordinates. Modified clicks and new-tab opens are left to the browser. */ export function HotspotOverlay({ label, canvas, hotspots, onFocus, onActivate }: Props) { return ( {hotspots.map(h => ( onFocus(h.id)} onMouseLeave={() => onFocus(null)} onFocus={() => onFocus(h.id)} onBlur={() => onFocus(null)} onClick={event => { if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0) return; onActivate(h, event); }}> ))} ); }