import 'leaflet/dist/leaflet.css';
import L from 'leaflet';
import { useEffect, useRef } from 'react';
import type { DayView, Station } from '../api/traffic';
import { addSwisstopoBaseLayers, escapeHtml } from '../map/baseLayers';
import { FlowAnimator } from '../traffic/flowAnimator';
import { sumCounts } from '../traffic/vehicleClasses';
interface TrafficMapProps {
stations: Station[];
day: DayView | null;
hour: number;
selectedCode: number | null;
onSelect: (code: number) => void;
onAnimatorReady: (animator: FlowAnimator) => void;
}
const THURGAU_CENTER: L.LatLngTuple = [47.57, 9.1];
const DATA_ATTRIBUTION =
'Kanton Thurgau';
export function TrafficMap({
stations,
day,
hour,
selectedCode,
onSelect,
onAnimatorReady,
}: TrafficMapProps) {
const containerRef = useRef(null);
const mapRef = useRef(null);
const animatorRef = useRef(null);
const roadsRef = useRef(null);
const markersRef = useRef