import type { GeoJsonBbox } from "@trackunit/geo-json-utils"; import { type Entity, type MapInteractionState } from "@trackunit/react-map-adapter-shared"; import type { CategoryKey, ControlConfig } from "../controls/types"; import type { MapApi } from "../core/types"; import type { LayerHandle } from "./types"; /** * Return type of `useLayers`. */ export type UseLayersReturn = Readonly<{ /** Shared interaction state across all layers */ interaction: MapInteractionState; /** Select an entity (or null to clear selection). Works across all layer types. */ select: (entity: Entity | null) => void; /** Hover an entity (or null to clear hover). Works across all layer types. */ hover: (entity: Entity | null) => void; /** Clear all interaction state (selection and hover) */ clearAll: () => void; /** * Lazily compute combined bounds of all layers. * Calls each layer's getBounds() and merges the results. */ getBounds: () => GeoJsonBbox | null; /** True while any layer is loading */ loading: boolean; /** Resolves when ALL layers have their initial data */ ready: Promise; /** * Aggregated controls from all layers, keyed by semantic area. * All four CategoryKey areas are always present (empty arrays for areas with no controls). */ controls: Readonly>>; /** Layer handles (passed to Layers component for rendering) */ handles: ReadonlyArray; }>; /** * `useLayers` -- aggregates layer handles and manages shared interaction state. * * This is the central hook that ties all layers together: * - Shared hover/select interaction via a reducer (cross-layer, single entity at a time) * - Combined bounds across all layers (lazy, cached) * - Loading/ready coordination * - Aggregated controls * * @example * ```tsx * const fleet = useMarkers({ ... }); * const shapes = useShapes({ ... }); * const layers = useLayers(api, [fleet, shapes]); * * // layers.interaction.selectedEntity * // layers.getBounds() * // layers.ready * * return ( * * * * ); * ``` */ export declare const useLayers: (api: MapApi, layers: ReadonlyArray) => UseLayersReturn;