"use client"; import { ReactNode } from "react"; import { useShallow } from "zustand/react/shallow"; import { persistBackgroundLayerVisibility } from "@/uhm/lib/editor/background/backgroundVisibilityStorage"; import { BACKGROUND_LAYER_OPTIONS, BackgroundLayerId, DEFAULT_BACKGROUND_LAYER_VISIBILITY, HIDDEN_BACKGROUND_LAYER_VISIBILITY, } from "@/uhm/lib/map/styles/backgroundLayers"; import { GEO_TYPE_KEYS } from "@/uhm/lib/map/geo/geoTypeMap"; import { useEditorStore } from "@/uhm/store/editorStore"; type Props = { topContent?: ReactNode; width?: number; }; export default function BackgroundLayersPanel({ topContent, width = 240, }: Props) { const { visibility, setBackgroundVisibility, geometryVisibility, setGeometryVisibility, } = useEditorStore( useShallow((state) => ({ visibility: state.backgroundVisibility, setBackgroundVisibility: state.setBackgroundVisibility, geometryVisibility: state.geometryVisibility, setGeometryVisibility: state.setGeometryVisibility, })) ); const updateBackgroundVisibility = ( updater: (prev: typeof visibility) => typeof visibility ) => { setBackgroundVisibility((prev) => { const next = updater(prev); persistBackgroundLayerVisibility(next); return next; }); }; const handleToggleLayer = (id: BackgroundLayerId) => { updateBackgroundVisibility((prev) => ({ ...prev, [id]: !prev[id], })); }; const handleShowAll = () => { updateBackgroundVisibility(() => ({ ...DEFAULT_BACKGROUND_LAYER_VISIBILITY })); }; const handleHideAll = () => { updateBackgroundVisibility(() => ({ ...HIDDEN_BACKGROUND_LAYER_VISIBILITY })); }; return ( ); } const secondaryButtonStyle = { border: "1px solid #334155", borderRadius: 6, background: "#0b1220", color: "#cbd5e1", cursor: "pointer", fontSize: 12, fontWeight: 700, padding: "6px 8px", } as const;