"use client"; import { MapContainer, TileLayer, CircleMarker, Tooltip } from "react-leaflet"; import "leaflet/dist/leaflet.css"; import { getLocalizedCountryName } from "../lib/localization"; import { useTheme } from "next-themes"; import { useEffect, useState } from "react"; interface CountryData { code: string; count: number; coordinates: [number, number]; } interface MapProps { countryData: CountryData[]; maxCount: number; } const Map = ({ countryData, maxCount }: MapProps) => { const { theme } = useTheme(); const [mounted, setMounted] = useState(false); useEffect(() => { setMounted(true); }, []); // Don't render until mounted to avoid hydration mismatch if (!mounted) { return
; } const isDark = theme === "dark"; // Use different tile layers based on theme const tileLayerUrl = isDark ? "https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png" : "https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png"; const tileLayerAttribution = isDark ? '© OpenStreetMap contributors © CARTO' : '© OpenStreetMap contributors © CARTO'; return (