"use client"; import { useEffect } from "react"; import { MapContainer, Marker, TileLayer, useMapEvents } from "react-leaflet"; import L from "leaflet"; type LatLng = { lat: number; lng: number }; let iconConfigured = false; const ensureLeafletIcons = () => { if (iconConfigured) return; delete (L.Icon.Default.prototype as { _getIconUrl?: () => string })._getIconUrl; L.Icon.Default.mergeOptions({ iconRetinaUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon-2x.png", iconUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png", shadowUrl: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-shadow.png" }); iconConfigured = true; }; function MapClickHandler({ onPick }: { onPick: (coords: LatLng) => void }) { useMapEvents({ click(event) { onPick({ lat: event.latlng.lat, lng: event.latlng.lng }); } }); return null; } export default function MapPicker({ value, onChange }: { value: LatLng | null; onChange: (coords: LatLng) => void; }) { useEffect(() => { ensureLeafletIcons(); }, []); const center = value || { lat: 52.52, lng: 13.405 }; return (