"use client"; import { useEffect, useMemo, useState } from "react"; import { Bell, BellRing, ChevronDown, Clock3, Languages, MapPinned, Palette, Settings, Smartphone, Thermometer, Wind } from "lucide-react"; import type { LucideIcon } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; import { LanguageToggle } from "@/components/ui/language-toggle"; import { ThemeToggle } from "@/components/ui/theme-toggle"; import { useMeteoStationPositions } from "@/hooks/use-meteo-stations"; import { useWeatherStations } from "@/hooks/use-weather-stations"; import { DEFAULT_STATION_ID } from "@/lib/constants"; import { useI18n } from "@/lib/i18n"; import { locateSynopStations } from "@/lib/location-utils"; import { decodeBase64UrlKey, deletePushSubscription, fetchVapidPublicKey, savePushSubscription, sendTestPushNotification } from "@/lib/notification-api"; import { formatProvinceName, getProvinceForSelection, PROVINCES } from "@/lib/provinces"; import { useWeatherStore } from "@/lib/store"; import { TEMPERATURE_UNITS, WIND_SPEED_UNITS } from "@/lib/weather-utils"; import type { Province } from "@/types/province"; import type { TemperatureUnit, WindSpeedUnit } from "@/types/units"; type NotificationSupportStatus = "checking" | "unconfigured" | "unsupported" | "needs-install" | "default" | "denied" | "granted"; function isStandaloneApp() { if (typeof window === "undefined") return false; const navigatorWithStandalone = window.navigator as Navigator & { standalone?: boolean }; return window.matchMedia("(display-mode: standalone)").matches || navigatorWithStandalone.standalone === true; } function isAppleMobilePlatform() { if (typeof window === "undefined") return false; const userAgent = window.navigator.userAgent; const platform = window.navigator.platform; const isIPadOSDesktopMode = platform === "MacIntel" && window.navigator.maxTouchPoints > 1; return /iPad|iPhone|iPod/.test(userAgent) || isIPadOSDesktopMode; } function getNotificationSupportStatus(): NotificationSupportStatus { if (typeof window === "undefined") return "checking"; if (!("Notification" in window) || !("serviceWorker" in navigator) || !("PushManager" in window)) return "unsupported"; if (isAppleMobilePlatform() && !isStandaloneApp()) return "needs-install"; return Notification.permission; } function SettingsRow({ icon: Icon, title, description, children }: { icon: typeof Settings; title: string; description: string; children: React.ReactNode }) { return (

{title}

{description}

{children}
); } function SwitchIndicator({ checked, disabled }: { checked: boolean; disabled?: boolean }) { return (