import { showFlashMessage } from "./helpers"; // Add custom CSS for popup styling const addPopupStyles = () => { if (!document.querySelector('#area-popup-styles')) { const style = document.createElement('style'); style.id = 'area-popup-styles'; style.textContent = ` .area-form-popup, .area-info-popup { background: transparent !important; } .area-form-popup .leaflet-popup-content-wrapper, .area-info-popup .leaflet-popup-content-wrapper { background: transparent !important; padding: 0 !important; margin: 0 !important; border-radius: 0 !important; box-shadow: none !important; border: none !important; } .area-form-popup .leaflet-popup-content, .area-info-popup .leaflet-popup-content { margin: 0 !important; padding: 0 1rem 0 0 !important; background: transparent !important; border-radius: 1rem !important; overflow: hidden !important; width: 100% !important; max-width: none !important; } .area-form-popup .leaflet-popup-tip, .area-info-popup .leaflet-popup-tip { background: transparent !important; border: none !important; box-shadow: none !important; } .area-form-popup .leaflet-popup, .area-info-popup .leaflet-popup { margin-bottom: 0 !important; } .area-form-popup .leaflet-popup-close-button, .area-info-popup .leaflet-popup-close-button { right: 1.25rem !important; top: 1.25rem !important; width: 1.5rem !important; height: 1.5rem !important; padding: 0 !important; color: oklch(var(--bc) / 0.6) !important; background: oklch(var(--b2)) !important; border-radius: 0.5rem !important; border: 1px solid oklch(var(--bc) / 0.2) !important; font-size: 1rem !important; font-weight: bold !important; line-height: 1 !important; display: flex !important; align-items: center !important; justify-content: center !important; transition: all 0.2s ease !important; } .area-form-popup .leaflet-popup-close-button:hover, .area-info-popup .leaflet-popup-close-button:hover { background: oklch(var(--b3)) !important; color: oklch(var(--bc)) !important; border-color: oklch(var(--bc) / 0.3) !important; } `; document.head.appendChild(style); } }; export function handleAreaCreated(areasLayer, layer, apiKey) { // Add popup styles addPopupStyles(); const radius = layer.getRadius(); const center = layer.getLatLng(); const formHtml = `
Radius: ${Math.round(data.radius)} meters