@collabdt/core 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/dist/core/components/ui/Comments/Comment.d.ts +3 -1
  2. package/dist/core/components/ui/Comments/Comment.d.ts.map +1 -1
  3. package/dist/core/components/ui/Comments/Comment.js +3 -1
  4. package/dist/core/components/ui/Comments/Comment.js.map +1 -1
  5. package/dist/core/components/ui/Sensors/Sensor.d.ts +3 -1
  6. package/dist/core/components/ui/Sensors/Sensor.d.ts.map +1 -1
  7. package/dist/core/components/ui/Sensors/Sensor.js +3 -1
  8. package/dist/core/components/ui/Sensors/Sensor.js.map +1 -1
  9. package/dist/core/components/viewers/map/MapViewer.d.ts.map +1 -1
  10. package/dist/core/components/viewers/map/MapViewer.js +31 -3
  11. package/dist/core/components/viewers/map/MapViewer.js.map +1 -1
  12. package/dist/core/components/viewers/map/datasets/src/useOrganizationalDatasets.js +1 -1
  13. package/dist/core/components/viewers/map/datasets/src/useOrganizationalDatasets.js.map +1 -1
  14. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/index.d.ts +2 -1
  15. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/index.d.ts.map +1 -1
  16. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/index.js +4 -1
  17. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/index.js.map +1 -1
  18. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/index.d.ts +2 -1
  19. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/index.d.ts.map +1 -1
  20. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/index.js +3 -1
  21. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/index.js.map +1 -1
  22. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/NonDatabaseBuildingPopover.d.ts +2 -1
  23. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/NonDatabaseBuildingPopover.d.ts.map +1 -1
  24. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/NonDatabaseBuildingPopover.js +116 -112
  25. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/NonDatabaseBuildingPopover.js.map +1 -1
  26. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/OpenDataFeaturePopover.d.ts +2 -1
  27. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/OpenDataFeaturePopover.d.ts.map +1 -1
  28. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/OpenDataFeaturePopover.js +52 -48
  29. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/OpenDataFeaturePopover.js.map +1 -1
  30. package/dist/core/components/viewers/map/src/MapLayers/index.d.ts.map +1 -1
  31. package/dist/core/components/viewers/map/src/MapLayers/index.js +3 -1
  32. package/dist/core/components/viewers/map/src/MapLayers/index.js.map +1 -1
  33. package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/index.d.ts.map +1 -1
  34. package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/index.js +2 -2
  35. package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/index.js.map +1 -1
  36. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.d.ts.map +1 -1
  37. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.js +92 -76
  38. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.js.map +1 -1
  39. package/dist/core/components/viewers/map/src/MapLayers/src/CommentLayer/index.d.ts.map +1 -1
  40. package/dist/core/components/viewers/map/src/MapLayers/src/CommentLayer/index.js +104 -109
  41. package/dist/core/components/viewers/map/src/MapLayers/src/CommentLayer/index.js.map +1 -1
  42. package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.d.ts +1 -0
  43. package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.d.ts.map +1 -1
  44. package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.js +13 -19
  45. package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.js.map +1 -1
  46. package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/utils/CustomModelLayer.d.ts.map +1 -1
  47. package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/utils/CustomModelLayer.js +2 -2
  48. package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/utils/CustomModelLayer.js.map +1 -1
  49. package/dist/core/components/viewers/map/src/MapLayers/src/MapPopupStack.d.ts +3 -0
  50. package/dist/core/components/viewers/map/src/MapLayers/src/MapPopupStack.d.ts.map +1 -0
  51. package/dist/core/components/viewers/map/src/MapLayers/src/MapPopupStack.js +88 -0
  52. package/dist/core/components/viewers/map/src/MapLayers/src/MapPopupStack.js.map +1 -0
  53. package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/index.d.ts.map +1 -1
  54. package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/index.js +79 -99
  55. package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/index.js.map +1 -1
  56. package/dist/core/components/viewers/map/src/MapLayers/src/PlaceOnMap.js.map +1 -1
  57. package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.d.ts.map +1 -1
  58. package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.js +125 -121
  59. package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.js.map +1 -1
  60. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteLayer.d.ts.map +1 -1
  61. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteLayer.js +67 -35
  62. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteLayer.js.map +1 -1
  63. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/{SiteContextMenu.d.ts → SiteMenu.d.ts} +4 -5
  64. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteMenu.d.ts.map +1 -0
  65. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/{SiteContextMenu.js → SiteMenu.js} +8 -9
  66. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteMenu.js.map +1 -0
  67. package/dist/core/components/viewers/map/src/MapLayers/src/clusterPopupEntry.d.ts +23 -0
  68. package/dist/core/components/viewers/map/src/MapLayers/src/clusterPopupEntry.d.ts.map +1 -0
  69. package/dist/core/components/viewers/map/src/MapLayers/src/clusterPopupEntry.js +88 -0
  70. package/dist/core/components/viewers/map/src/MapLayers/src/clusterPopupEntry.js.map +1 -0
  71. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/BuildingVisibility.d.ts +3 -0
  72. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/BuildingVisibility.d.ts.map +1 -0
  73. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/BuildingVisibility.js +28 -0
  74. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/BuildingVisibility.js.map +1 -0
  75. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/MapCustomization.d.ts.map +1 -1
  76. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/MapCustomization.js +3 -1
  77. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/MapCustomization.js.map +1 -1
  78. package/dist/core/components/viewers/map/src/SimpleMap.js +1 -1
  79. package/dist/core/components/viewers/map/src/SimpleMap.js.map +1 -1
  80. package/dist/core/components/viewers/map/src/tools/AddTools/AddFile/FileAdder.js +1 -1
  81. package/dist/core/components/viewers/map/src/tools/AddTools/AddFile/FileAdder.js.map +1 -1
  82. package/dist/core/components/viewers/map/src/tools/AddTools/AddSite/SiteAdder.d.ts.map +1 -1
  83. package/dist/core/components/viewers/map/src/tools/AddTools/AddSite/SiteAdder.js.map +1 -1
  84. package/dist/core/components/viewers/map/src/tools/measureMapTool.d.ts.map +1 -1
  85. package/dist/core/components/viewers/map/src/tools/measureMapTool.js +1 -1
  86. package/dist/core/components/viewers/map/src/tools/measureMapTool.js.map +1 -1
  87. package/dist/core/components/viewers/map/utils/MapEventManager/MapClickManager.d.ts +12 -5
  88. package/dist/core/components/viewers/map/utils/MapEventManager/MapClickManager.d.ts.map +1 -1
  89. package/dist/core/components/viewers/map/utils/MapEventManager/MapClickManager.js +46 -12
  90. package/dist/core/components/viewers/map/utils/MapEventManager/MapClickManager.js.map +1 -1
  91. package/dist/core/components/viewers/map/utils/MapEventManager/MapHoverManager.d.ts +1 -1
  92. package/dist/core/components/viewers/map/utils/MapEventManager/MapHoverManager.d.ts.map +1 -1
  93. package/dist/core/components/viewers/map/utils/MapEventManager/MapHoverManager.js +1 -1
  94. package/dist/core/components/viewers/map/utils/MapEventManager/MapHoverManager.js.map +1 -1
  95. package/dist/core/components/viewers/map/utils/getOsmIdFromMartin.d.ts +1 -1
  96. package/dist/core/components/viewers/map/utils/getOsmIdFromMartin.d.ts.map +1 -1
  97. package/dist/core/components/viewers/map/utils/getOsmIdFromMartin.js.map +1 -1
  98. package/dist/core/components/viewers/map/utils/mapStyleSpec.d.ts +4 -0
  99. package/dist/core/components/viewers/map/utils/mapStyleSpec.d.ts.map +1 -1
  100. package/dist/core/components/viewers/map/utils/mapStyleSpec.js +3 -1
  101. package/dist/core/components/viewers/map/utils/mapStyleSpec.js.map +1 -1
  102. package/dist/core/components/viewers/map/utils/modelMatrix.d.ts +8 -0
  103. package/dist/core/components/viewers/map/utils/modelMatrix.d.ts.map +1 -0
  104. package/dist/core/components/viewers/map/utils/modelMatrix.js +13 -0
  105. package/dist/core/components/viewers/map/utils/modelMatrix.js.map +1 -0
  106. package/dist/core/components/viewers/map/utils/validateBounds.d.ts +5 -10
  107. package/dist/core/components/viewers/map/utils/validateBounds.d.ts.map +1 -1
  108. package/dist/core/components/viewers/map/utils/validateBounds.js +5 -6
  109. package/dist/core/components/viewers/map/utils/validateBounds.js.map +1 -1
  110. package/dist/core/i18n/messages/en.json +15 -4
  111. package/dist/core/i18n/messages/es.json +15 -4
  112. package/dist/core/i18n/messages/fr.json +15 -4
  113. package/dist/core/store/Map/context.d.ts.map +1 -1
  114. package/dist/core/store/Map/context.js +3 -1
  115. package/dist/core/store/Map/context.js.map +1 -1
  116. package/dist/core/store/Map/reducer.d.ts +10 -1
  117. package/dist/core/store/Map/reducer.d.ts.map +1 -1
  118. package/dist/core/store/Map/reducer.js +20 -0
  119. package/dist/core/store/Map/reducer.js.map +1 -1
  120. package/dist/core/types/map.d.ts +17 -1
  121. package/dist/core/types/map.d.ts.map +1 -1
  122. package/package.json +5 -5
  123. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteContextMenu.d.ts.map +0 -1
  124. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteContextMenu.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.tsx"],"sourcesContent":["\"use client\"\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n\nimport * as React from \"react\";\nimport { Popup } from \"react-map-gl/maplibre\";\n\nimport { useBuildings } from \"../../../../../../../hooks/buildings/buildings\";\nimport { useBuildingsContext } from \"../../../../../../../store\";\nimport { useBimContext } from \"../../../../../../../store/BIM/context\";\nimport { MapContext } from \"../../../../../../../store/Map/context\";\nimport { ViewerNames } from \"../../../../../../../types/dbTypes\";\nimport { useBuildingSensorColours } from \"../../../../../../ui/Sensors/useBuildingSensorColours\";\nimport { MapLayerClickPriority } from \"../../../../utils/MapEventManager/MapClickManager\";\nimport { maptilerKeyForRequest } from \"../../../../utils/mapStyleSpec\";\nimport MapFeaturePopoverMenu from \"../../../MapFeaturePopoverMenu\";\n\nimport {\n buildingColourExpression,\n DEFAULT_COLOUR_EXPRESSION,\n osmColourEntries,\n type PaintExpression,\n} from \"./buildingColourExpression\";\nimport { BuildingSensorMarkers } from \"./src/BuildingSensorMarkers\";\n\nimport type { MapMouseEvent } from \"maplibre-gl\";\n\nconst LAYER_ID = \"maptiler-3d-buildings\";\nconst OWN_SOURCE_ID = \"cdt-buildings\";\nconst REUSABLE_SOURCE_IDS = [\"openmaptiles\", \"maptiler_planet\", \"carto\"] as const;\n\nfunction buildLayerFilter() {\n return [\n \"all\",\n [\"!=\", [\"get\", \"hide_3d\"], true],\n [\"!=\", [\"get\", \"hide_3d\"], \"true\"],\n ];\n}\n\nfunction buildHeightExpression(hiddenBimOsmIds: string[]) {\n return [\n \"case\",\n [\n \"any\",\n [\"in\", [\"to-string\", [\"id\"]], [\"literal\", hiddenBimOsmIds]],\n [\"in\", [\"to-string\", [\"coalesce\", [\"get\", \"osm_id\"], \"\"]], [\"literal\", hiddenBimOsmIds]],\n ],\n 0.1,\n [\"coalesce\", [\"get\", \"height\"], 5],\n ];\n}\n\n// Null when there is nothing to draw buildings from so the layer is skipped rather than 403ing.\nfunction resolveBuildingSource(map: any, maptilerKey?: string): string | null {\n if (maptilerKey?.trim()) return addOwnBuildingSource(map, maptilerKey);\n\n const reusable = REUSABLE_SOURCE_IDS.find((id) => map.getSource(id));\n if (reusable) return reusable;\n\n const key = maptilerKeyForRequest(maptilerKey);\n return key ? addOwnBuildingSource(map, key) : null;\n}\n\nfunction addOwnBuildingSource(map: any, key: string): string {\n if (!map.getSource(OWN_SOURCE_ID)) {\n map.addSource(OWN_SOURCE_ID, {\n type: \"vector\",\n url: `https://api.maptiler.com/tiles/buildings/tiles.json?key=${key}`,\n });\n }\n return OWN_SOURCE_ID;\n}\n\nfunction addBuildingLayer(map: any, hiddenBimOsmIds: string[], colourExpr: PaintExpression, maptilerKey?: string) {\n try {\n if (map.getLayer(LAYER_ID)) return;\n\n const sourceId = resolveBuildingSource(map, maptilerKey);\n if (!sourceId) return;\n\n // Insert below road labels so buildings don't cover text\n const beforeId = map.getLayer(\"road_label\") ? \"road_label\" : undefined;\n\n map.addLayer({\n id: LAYER_ID,\n type: \"fill-extrusion\",\n source: sourceId,\n \"source-layer\": \"building\",\n minzoom: 14,\n filter: buildLayerFilter(),\n paint: {\n // Seeded rather than hardcoded: `styledata` re-adds this layer after any setStyle, and\n // the paint effect below will not re-run for it, so the colours would be lost.\n \"fill-extrusion-color\": colourExpr,\n \"fill-extrusion-height\": buildHeightExpression(hiddenBimOsmIds),\n \"fill-extrusion-base\": [\"coalesce\", [\"get\", \"render_min_height\"], 0],\n \"fill-extrusion-opacity\": [\n \"interpolate\", [\"linear\"], [\"zoom\"],\n 14, 0.6,\n 16, 0.8,\n ],\n },\n }, beforeId);\n } catch {\n // Map style may be in a transitional state during layer addition\n }\n}\n\nexport function BuildingLayer({ maptilerKey }: { maptilerKey?: string }) {\n const { state: mapState } = React.useContext(MapContext);\n const { map, mapClickManager } = mapState.map;\n const { setCompareItems } = useBuildingsContext();\n const { buildings } = useBuildings();\n const { state: bimState } = useBimContext();\n const { bimModelsAddedToMap } = bimState.bim;\n\n const [hoveredFeature, setHoveredFeature] = React.useState<string | number | null>(null);\n const [clickedFeature, setClickedFeature] = React.useState<any>(null);\n const [buildingByOsmId, setBuildingByOsmId] = React.useState<Record<string, { id: number }>>({});\n\n // Footprints are tinted by the average reading of the legend's sensor type. Nothing is polled\n // and nothing changes colour until a type is pinned in the legend and switched on.\n const sensorColours = useBuildingSensorColours(ViewerNames.map);\n const { averages, colourKey } = sensorColours;\n\n const osmColours = React.useMemo(\n () => osmColourEntries(averages, buildings ?? []),\n [averages, buildings],\n );\n\n const colourExpr = React.useMemo(\n () => buildingColourExpression({\n osmColours,\n clickedKey: clickedFeature?.id ?? null,\n hoveredKey: hoveredFeature,\n }),\n [osmColours, clickedFeature, hoveredFeature],\n );\n\n // Read by the add-layer effect, which must not re-run when only the colours change.\n const colourExprRef = React.useRef<PaintExpression>(DEFAULT_COLOUR_EXPRESSION);\n colourExprRef.current = colourExpr;\n\n const hiddenBimOsmIds = React.useMemo(\n () => Array.from(new Set(\n (bimModelsAddedToMap || [])\n .map((model: any) => model?.building?.buildingOsmId)\n .filter((value: unknown): value is string | number => value !== null && value !== undefined)\n .map((value) => String(value))\n )),\n [bimModelsAddedToMap],\n );\n\n React.useEffect(() => {\n if (!buildings || !Array.isArray(buildings) || buildings.length === 0) {\n setBuildingByOsmId({});\n return;\n }\n\n const mapping: Record<string, { id: number }> = {};\n buildings.forEach((building: any) => {\n if (building.buildingOsmId != null) {\n mapping[String(building.buildingOsmId)] = { id: building.id };\n }\n });\n\n setBuildingByOsmId((prevMapping) => {\n const newKeys = Object.keys(mapping);\n const prevKeys = Object.keys(prevMapping);\n\n if (newKeys.length !== prevKeys.length) {\n return mapping;\n }\n\n const hasChanges = newKeys.some((key) => mapping[key]?.id !== prevMapping[key]?.id);\n return hasChanges ? mapping : prevMapping;\n });\n }, [buildings]);\n\n // Add the layer imperatively\n React.useEffect(() => {\n if (!map) return;\n\n if (map.isStyleLoaded()) {\n addBuildingLayer(map, hiddenBimOsmIds, colourExprRef.current, maptilerKey);\n }\n\n const onStyleLoad = () => addBuildingLayer(map, hiddenBimOsmIds, colourExprRef.current, maptilerKey);\n map.on(\"styledata\", onStyleLoad);\n\n return () => {\n try {\n map.off(\"styledata\", onStyleLoad);\n if (map.getLayer(LAYER_ID)) {\n map.removeLayer(LAYER_ID);\n }\n if (map.getSource(OWN_SOURCE_ID)) {\n map.removeSource(OWN_SOURCE_ID);\n }\n } catch {\n // Map may have been destroyed before cleanup runs\n }\n };\n }, [map, hiddenBimOsmIds, maptilerKey]);\n\n React.useEffect(() => {\n if (!map || !map.getLayer(LAYER_ID)) return;\n\n map.setFilter(LAYER_ID, buildLayerFilter() as any);\n map.setPaintProperty(LAYER_ID, \"fill-extrusion-height\", buildHeightExpression(hiddenBimOsmIds) as any);\n }, [map, hiddenBimOsmIds]);\n\n // Register click, hover, and mouse leave handlers\n React.useEffect(() => {\n if (!map || !mapClickManager) return;\n\n const handleClick = (e: MapMouseEvent) => {\n if (!map.getLayer(LAYER_ID)) return;\n const clicked = map.queryRenderedFeatures(e.point, { layers: [LAYER_ID] });\n const feature = clicked?.[0];\n if (!feature) {\n setClickedFeature(null);\n return;\n }\n\n const properties = feature.properties || {};\n const lng = e.lngLat.lng;\n const lat = e.lngLat.lat;\n const coordinates = [lng, lat];\n\n // Use MVT feature.id (OSM ID) or fall back to properties\n const featureId = feature.id || properties.osm_id || `temp-${Date.now()}`;\n const normalizedOsmId = String(featureId);\n const dbId = buildingByOsmId[normalizedOsmId]?.id || null;\n const _name = Object.entries(properties).find(\n ([key]) => key.toLowerCase().includes(\"name\")\n )?.[1] || undefined;\n\n const featureClone: any = {\n ...feature,\n id: featureId,\n properties: {\n ...properties,\n coordinates,\n _name,\n osm_id: normalizedOsmId,\n isBuilding: true,\n isDbBuilding: Boolean(dbId),\n dbId,\n _popupNonce: Date.now(),\n },\n };\n\n setClickedFeature(featureClone);\n };\n\n const handleHover = (e: MapMouseEvent) => {\n if (!map.getLayer(LAYER_ID)) return;\n const hovered = map.queryRenderedFeatures(e.point, { layers: [LAYER_ID] });\n\n if (hovered[0]) {\n map.getCanvas().style.cursor = \"pointer\";\n const hoveredId = hovered[0].id || hovered[0].properties?.osm_id || null;\n setHoveredFeature(hoveredId);\n } else {\n map.getCanvas().style.cursor = \"\";\n setHoveredFeature(null);\n }\n };\n\n const handleMouseLeave = () => {\n map.getCanvas().style.cursor = \"\";\n setHoveredFeature(null);\n };\n\n mapClickManager.register(\n LAYER_ID,\n MapLayerClickPriority.BuildingLayersClickPriority,\n handleClick\n );\n map.on(\"mousemove\", LAYER_ID, handleHover);\n map.on(\"mouseleave\", LAYER_ID, handleMouseLeave);\n\n return () => {\n mapClickManager.unregister(LAYER_ID);\n map.off(\"mousemove\", LAYER_ID, handleHover);\n map.off(\"mouseleave\", LAYER_ID, handleMouseLeave);\n };\n }, [map, mapClickManager, buildingByOsmId, hiddenBimOsmIds]);\n\n // Single writer for fill-extrusion-color: hover, click and sensor colours are merged into one\n // expression upstream, so there is no second effect to race with. `colourExpr` only changes\n // when a highlight moves or a sensor colour actually differs, not on every 15s poll.\n React.useEffect(() => {\n if (!map || !map.getLayer(LAYER_ID)) return;\n map.setPaintProperty(LAYER_ID, \"fill-extrusion-color\", colourExpr);\n }, [map, colourExpr]);\n\n return (\n <>\n <BuildingSensorMarkers buildings={buildings ?? []} sensorColours={sensorColours} />\n {clickedFeature && clickedFeature.properties?.coordinates && (\n <Popup\n anchor=\"bottom\"\n closeButton={true}\n closeOnClick={false}\n focusAfterOpen={true}\n key={`maptiler-${clickedFeature.id}-${clickedFeature.properties._popupNonce}`}\n latitude={clickedFeature.properties.coordinates[1]}\n longitude={clickedFeature.properties.coordinates[0]}\n onClose={() => setClickedFeature(null)}\n >\n <MapFeaturePopoverMenu\n feature={clickedFeature}\n onCloseAction={() => {\n setClickedFeature(null);\n setCompareItems([]);\n }}\n />\n </Popup>\n )}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6SI,mBACE,KADF;AAvSJ,YAAY,WAAW;AACvB,SAAS,aAAa;AAEtB,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AACpC,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AACzC,SAAS,6BAA6B;AACtC,SAAS,6BAA6B;AACtC,OAAO,2BAA2B;AAElC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,6BAA6B;AAItC,MAAM,WAAW;AACjB,MAAM,gBAAgB;AACtB,MAAM,sBAAsB,CAAC,gBAAgB,mBAAmB,OAAO;AAEvE,SAAS,mBAAmB;AAC1B,SAAO;AAAA,IACL;AAAA,IACA,CAAC,MAAM,CAAC,OAAO,SAAS,GAAG,IAAI;AAAA,IAC/B,CAAC,MAAM,CAAC,OAAO,SAAS,GAAG,MAAM;AAAA,EACnC;AACF;AAEA,SAAS,sBAAsB,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C,UAAI,IAAI,cAAc,UAAU,gBAAgB;AAAA,IAClD;AAAA,EACF,GAAG,CAAC,KAAK,iBAAiB,iBAAiB,eAAe,CAAC;AAK3D,QAAM,UAAU,MAAM;AACpB,QAAI,CAAC,OAAO,CAAC,IAAI,SAAS,QAAQ,EAAG;AACrC,QAAI,iBAAiB,UAAU,wBAAwB,UAAU;AAAA,EACnE,GAAG,CAAC,KAAK,UAAU,CAAC;AAEpB,SACE,iCACE;AAAA,wBAAC,yBAAsB,WAAW,gCAAa,CAAC,GAAG,eAA8B;AAAA,IAChF,oBAAkB,oBAAe,eAAf,mBAA2B,gBAC5C;AAAA,MAAC;AAAA;AAAA,QACC,QAAO;AAAA,QACP,aAAa;AAAA,QACb,cAAc;AAAA,QACd,gBAAgB;AAAA,QAEhB,UAAU,eAAe,WAAW,YAAY,CAAC;AAAA,QACjD,WAAW,eAAe,WAAW,YAAY,CAAC;AAAA,QAClD,SAAS,MAAM,kBAAkB,IAAI;AAAA,QAErC;AAAA,UAAC;AAAA;AAAA,YACC,SAAS;AAAA,YACT,eAAe,MAAM;AACnB,gCAAkB,IAAI;AACtB,8BAAgB,CAAC,CAAC;AAAA,YACpB;AAAA;AAAA,QACF;AAAA;AAAA,MAXK,YAAY,eAAe,EAAE,IAAI,eAAe,WAAW,WAAW;AAAA,IAY7E;AAAA,KAEJ;AAEJ;","names":["_a"]}
1
+ {"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.tsx"],"sourcesContent":["\"use client\"\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n\nimport { useTranslations } from \"next-intl\";\nimport * as React from \"react\";\n\nimport { useBuildings } from \"../../../../../../../hooks/buildings/buildings\";\nimport { useBuildingsContext } from \"../../../../../../../store\";\nimport { useBimContext } from \"../../../../../../../store/BIM/context\";\nimport { MapContext } from \"../../../../../../../store/Map/context\";\nimport { ViewerNames } from \"../../../../../../../types/dbTypes\";\nimport { useBuildingSensorColours } from \"../../../../../../ui/Sensors/useBuildingSensorColours\";\nimport { MapLayerClickPriority } from \"../../../../utils/MapEventManager/MapClickManager\";\nimport { maptilerKeyForRequest } from \"../../../../utils/mapStyleSpec\";\nimport MapFeaturePopoverMenu from \"../../../MapFeaturePopoverMenu\";\n\nimport {\n buildingColourExpression,\n DEFAULT_COLOUR_EXPRESSION,\n osmColourEntries,\n type PaintExpression,\n} from \"./buildingColourExpression\";\nimport { BuildingSensorMarkers } from \"./src/BuildingSensorMarkers\";\n\nimport type { PopupEntry } from \"../../../../../../../types/map\";\nimport type { DataDrivenPropertyValueSpecification, MapGeoJSONFeature, MapMouseEvent } from \"maplibre-gl\";\n\nconst LAYER_ID = \"maptiler-3d-buildings\";\nconst OWN_SOURCE_ID = \"cdt-buildings\";\nconst REUSABLE_SOURCE_IDS = [\"openmaptiles\", \"maptiler_planet\", \"carto\"] as const;\n\nfunction buildLayerFilter() {\n return [\n \"all\",\n [\"!=\", [\"get\", \"hide_3d\"], true],\n [\"!=\", [\"get\", \"hide_3d\"], \"true\"],\n ];\n}\n\nfunction buildHeightExpression(hiddenBimOsmIds: string[]) {\n return [\n \"case\",\n [\n \"any\",\n [\"in\", [\"to-string\", [\"id\"]], [\"literal\", hiddenBimOsmIds]],\n [\"in\", [\"to-string\", [\"coalesce\", [\"get\", \"osm_id\"], \"\"]], [\"literal\", hiddenBimOsmIds]],\n ],\n 0.1,\n [\"coalesce\", [\"get\", \"height\"], 5],\n ];\n}\n\n// Null when there is nothing to draw buildings from so the layer is skipped rather than 403ing.\nfunction resolveBuildingSource(map: any, maptilerKey?: string): string | null {\n if (maptilerKey?.trim()) return addOwnBuildingSource(map, maptilerKey);\n\n const reusable = REUSABLE_SOURCE_IDS.find((id) => map.getSource(id));\n if (reusable) return reusable;\n\n const key = maptilerKeyForRequest(maptilerKey);\n return key ? addOwnBuildingSource(map, key) : null;\n}\n\nfunction addOwnBuildingSource(map: any, key: string): string {\n if (!map.getSource(OWN_SOURCE_ID)) {\n map.addSource(OWN_SOURCE_ID, {\n type: \"vector\",\n url: `https://api.maptiler.com/tiles/buildings/tiles.json?key=${key}`,\n });\n }\n return OWN_SOURCE_ID;\n}\n\n// Basemaps such as maptiler streets-v2 extrude buildings themselves, which double-draws ours.\nfunction removeBasemapBuildingLayers(map: any, sourceId: string) {\n const basemapSources = new Set<string>([...REUSABLE_SOURCE_IDS, sourceId]);\n\n for (const layer of map.getStyle()?.layers ?? []) {\n const isDuplicate =\n layer.id !== LAYER_ID &&\n layer.type === \"fill-extrusion\" &&\n layer[\"source-layer\"] === \"building\" &&\n basemapSources.has(layer.source);\n\n if (isDuplicate) map.removeLayer(layer.id);\n }\n}\n\nfunction addBuildingLayer(map: any, hiddenBimOsmIds: string[], colourExpr: PaintExpression, maptilerKey?: string) {\n try {\n if (map.getLayer(LAYER_ID)) return;\n\n const sourceId = resolveBuildingSource(map, maptilerKey);\n if (!sourceId) return;\n\n removeBasemapBuildingLayers(map, sourceId);\n\n // Insert below road labels so buildings don't cover text\n const beforeId = map.getLayer(\"road_label\") ? \"road_label\" : undefined;\n\n map.addLayer({\n id: LAYER_ID,\n type: \"fill-extrusion\",\n source: sourceId,\n \"source-layer\": \"building\",\n minzoom: 14,\n filter: buildLayerFilter(),\n paint: {\n // Seeded rather than hardcoded: `styledata` re-adds this layer after any setStyle, and\n // the paint effect below will not re-run for it, so the colours would be lost.\n \"fill-extrusion-color\": colourExpr,\n \"fill-extrusion-height\": buildHeightExpression(hiddenBimOsmIds),\n \"fill-extrusion-base\": [\"coalesce\", [\"get\", \"render_min_height\"], 0],\n \"fill-extrusion-opacity\": [\n \"interpolate\", [\"linear\"], [\"zoom\"],\n 14, 0.6,\n 16, 0.8,\n ],\n },\n }, beforeId);\n } catch {\n // Map style may be in a transitional state during layer addition\n }\n}\n\nexport function BuildingLayer({ maptilerKey }: { maptilerKey?: string }) {\n const { state: mapState, dispatch: mapDispatch } = React.useContext(MapContext);\n const { map, mapClickManager, show3dBuildings, popupStack } = mapState.map;\n const t = useTranslations(\"DatabaseBuildingPopover\");\n const { setCompareItems } = useBuildingsContext();\n const { buildings } = useBuildings();\n const { state: bimState } = useBimContext();\n const { bimModelsAddedToMap } = bimState.bim;\n\n const [hoveredFeature, setHoveredFeature] = React.useState<string | number | null>(null);\n const entryFeaturesRef = React.useRef<Record<string, any>>({});\n\n const closePopups = React.useCallback(\n () => mapDispatch({ type: \"SET_POPUP_STACK\", payload: null }),\n [mapDispatch],\n );\n const [buildingByOsmId, setBuildingByOsmId] = React.useState<Record<string, { id: number }>>({});\n\n // Footprints are tinted by the average reading of the legend's sensor type. Nothing is polled\n // and nothing changes colour until a type is pinned in the legend and switched on.\n const sensorColours = useBuildingSensorColours(ViewerNames.map);\n const { averages, colourKey } = sensorColours;\n\n const osmColours = React.useMemo(\n () => osmColourEntries(averages, buildings ?? []),\n [averages, buildings],\n );\n\n const activeEntry = popupStack ? popupStack.entries[popupStack.activeIndex] : null;\n const clickedKey = activeEntry?.layerId === LAYER_ID\n ? entryFeaturesRef.current[activeEntry.id]?.id ?? null\n : null;\n\n const colourExpr = React.useMemo(\n () => buildingColourExpression({\n osmColours,\n clickedKey,\n hoveredKey: hoveredFeature,\n }),\n [osmColours, clickedKey, hoveredFeature],\n );\n\n // Read by the add-layer effect, which must not re-run when only the colours change.\n const colourExprRef = React.useRef<PaintExpression>(DEFAULT_COLOUR_EXPRESSION);\n colourExprRef.current = colourExpr;\n\n const hiddenBimOsmIds = React.useMemo(\n () => Array.from(new Set(\n (bimModelsAddedToMap || [])\n .map((model: any) => model?.building?.buildingOsmId)\n .filter((value: unknown): value is string | number => value !== null && value !== undefined)\n .map((value) => String(value))\n )),\n [bimModelsAddedToMap],\n );\n\n React.useEffect(() => {\n if (!buildings || !Array.isArray(buildings) || buildings.length === 0) {\n setBuildingByOsmId({});\n return;\n }\n\n const mapping: Record<string, { id: number }> = {};\n buildings.forEach((building: any) => {\n if (building.buildingOsmId != null) {\n mapping[String(building.buildingOsmId)] = { id: building.id };\n }\n });\n\n setBuildingByOsmId((prevMapping) => {\n const newKeys = Object.keys(mapping);\n const prevKeys = Object.keys(prevMapping);\n\n if (newKeys.length !== prevKeys.length) {\n return mapping;\n }\n\n const hasChanges = newKeys.some((key) => mapping[key]?.id !== prevMapping[key]?.id);\n return hasChanges ? mapping : prevMapping;\n });\n }, [buildings]);\n\n // Add the layer imperatively\n React.useEffect(() => {\n if (!map) return;\n\n if (map.isStyleLoaded()) {\n addBuildingLayer(map, hiddenBimOsmIds, colourExprRef.current, maptilerKey);\n }\n\n const onStyleLoad = () => addBuildingLayer(map, hiddenBimOsmIds, colourExprRef.current, maptilerKey);\n map.on(\"styledata\", onStyleLoad);\n\n return () => {\n try {\n map.off(\"styledata\", onStyleLoad);\n if (map.getLayer(LAYER_ID)) {\n map.removeLayer(LAYER_ID);\n }\n if (map.getSource(OWN_SOURCE_ID)) {\n map.removeSource(OWN_SOURCE_ID);\n }\n } catch {\n // Map may have been destroyed before cleanup runs\n }\n };\n }, [map, hiddenBimOsmIds, maptilerKey]);\n\n React.useEffect(() => {\n if (!map || !map.getLayer(LAYER_ID)) return;\n\n map.setFilter(LAYER_ID, buildLayerFilter() as any);\n map.setPaintProperty(LAYER_ID, \"fill-extrusion-height\", buildHeightExpression(hiddenBimOsmIds) as any);\n }, [map, hiddenBimOsmIds]);\n\n React.useEffect(() => {\n if (!map) return;\n\n const applyVisibility = () => {\n if (!map.getLayer(LAYER_ID)) return;\n map.setLayoutProperty(LAYER_ID, \"visibility\", show3dBuildings ? \"visible\" : \"none\");\n };\n\n applyVisibility();\n map.on(\"styledata\", applyVisibility);\n\n return () => {\n map.off(\"styledata\", applyVisibility);\n };\n }, [map, show3dBuildings]);\n\n // Register click, hover, and mouse leave handlers\n React.useEffect(() => {\n if (!map || !mapClickManager) return;\n\n const resolvePopups = (e: MapMouseEvent, hits: MapGeoJSONFeature[]): PopupEntry[] => {\n entryFeaturesRef.current = {};\n const coordinates: [number, number] = [e.lngLat.lng, e.lngLat.lat];\n\n return hits.map((feature) => {\n const properties = feature.properties || {};\n\n // Use MVT feature.id (OSM ID) or fall back to properties\n const featureId = feature.id || properties.osm_id || `temp-${Date.now()}`;\n const normalizedOsmId = String(featureId);\n const dbId = buildingByOsmId[normalizedOsmId]?.id || null;\n const _name = Object.entries(properties).find(\n ([key]) => key.toLowerCase().includes(\"name\")\n )?.[1] || undefined;\n\n const featureClone: any = {\n ...feature,\n id: featureId,\n properties: {\n ...properties,\n coordinates,\n _name,\n osm_id: normalizedOsmId,\n isBuilding: true,\n isDbBuilding: Boolean(dbId),\n dbId,\n },\n };\n\n const id = `${LAYER_ID}:${normalizedOsmId}`;\n entryFeaturesRef.current[id] = featureClone;\n\n return {\n id,\n layerId: LAYER_ID,\n priority: MapLayerClickPriority.BuildingLayersClickPriority,\n title: (_name as string) || t(\"fallbackName\"),\n coordinates,\n render: (header) => (\n <MapFeaturePopoverMenu\n header={header}\n feature={featureClone}\n onCloseAction={() => {\n closePopups();\n setCompareItems([]);\n }}\n />\n ),\n };\n });\n };\n\n const handleHover = (e: MapMouseEvent) => {\n if (!map.getLayer(LAYER_ID)) return;\n const hovered = map.queryRenderedFeatures(e.point, { layers: [LAYER_ID] });\n\n if (hovered[0]) {\n map.getCanvas().style.cursor = \"pointer\";\n const hoveredId = hovered[0].id || hovered[0].properties?.osm_id || null;\n setHoveredFeature(hoveredId);\n } else {\n map.getCanvas().style.cursor = \"\";\n setHoveredFeature(null);\n }\n };\n\n const handleMouseLeave = () => {\n map.getCanvas().style.cursor = \"\";\n setHoveredFeature(null);\n };\n\n mapClickManager.register(\n LAYER_ID,\n MapLayerClickPriority.BuildingLayersClickPriority,\n resolvePopups\n );\n map.on(\"mousemove\", LAYER_ID, handleHover);\n map.on(\"mouseleave\", LAYER_ID, handleMouseLeave);\n\n return () => {\n mapClickManager.unregister(LAYER_ID);\n map.off(\"mousemove\", LAYER_ID, handleHover);\n map.off(\"mouseleave\", LAYER_ID, handleMouseLeave);\n };\n }, [map, mapClickManager, buildingByOsmId, hiddenBimOsmIds, t, closePopups, setCompareItems]);\n\n // Single writer for fill-extrusion-color: hover, click and sensor colours are merged into one\n // expression upstream, so there is no second effect to race with. `colourExpr` only changes\n // when a highlight moves or a sensor colour actually differs, not on every 15s poll.\n React.useEffect(() => {\n if (!map || !map.getLayer(LAYER_ID)) return;\n // The spec union cannot describe an expression assembled at runtime, so the structural type is asserted here.\n map.setPaintProperty(\n LAYER_ID,\n \"fill-extrusion-color\",\n colourExpr as DataDrivenPropertyValueSpecification<string>,\n );\n }, [map, colourExpr]);\n\n return (\n <>\n <BuildingSensorMarkers buildings={buildings ?? []} sensorColours={sensorColours} />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8SY,SA6DR,UA7DQ;AAxSZ,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAEvB,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AACpC,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AACzC,SAAS,6BAA6B;AACtC,SAAS,6BAA6B;AACtC,OAAO,2BAA2B;AAElC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,6BAA6B;AAKtC,MAAM,WAAW;AACjB,MAAM,gBAAgB;AACtB,MAAM,sBAAsB,CAAC,gBAAgB,mBAAmB,OAAO;AAEvE,SAAS,mBAAmB;AAC1B,SAAO;AAAA,IACL;AAAA,IACA,CAAC,MAAM,CAAC,OAAO,SAAS,GAAG,IAAI;AAAA,IAC/B,CAAC,MAAM,CAAC,OAAO,SAAS,GAAG,MAAM;AAAA,EACnC;AACF;AAEA,SAAS,sBAAsB,iBAA2B;AACxD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE;AAAA,MACA,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,eAAe,CAAC;AAAA,MAC1D,CAAC,MAA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;AAAA,MACA;AAAA,IACF;AAAA,EACF,GAAG,CAAC,KAAK,UAAU,CAAC;AAEpB,SACE,gCACE,8BAAC,yBAAsB,WAAW,gCAAa,CAAC,GAAG,eAA8B,GACnF;AAEJ;","names":["_a","_b"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/CommentLayer/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAqE9B,eAAO,MAAM,YAAY,yBA6YxB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/CommentLayer/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAwG9B,eAAO,MAAM,YAAY,yBAqXxB,CAAA"}
@@ -24,7 +24,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
24
24
  import { useSession } from "next-auth/react";
25
25
  import { useTranslations } from "next-intl";
26
26
  import * as React from "react";
27
- import { Source, Layer, Popup, Marker } from "react-map-gl/maplibre";
27
+ import { Source, Layer, Marker } from "react-map-gl/maplibre";
28
28
  import { toast } from "sonner";
29
29
  import { useComments, useDeleteComments } from "../../../../../../../hooks/comments/comments";
30
30
  import { useUser, useUsers } from "../../../../../../../hooks/users/users";
@@ -36,7 +36,33 @@ import Comment from "../../../../../../ui/Comments/Comment";
36
36
  import { UserAvatar } from "../../../../../../ui/UserAvatar";
37
37
  import { extractCoordinatesFromFeature } from "../../../../utils/extractCoordinates";
38
38
  import { MapLayerClickPriority } from "../../../../utils/MapEventManager/MapClickManager";
39
+ import { buildClusterEntry, clusterSpecFromFeature } from "../clusterPopupEntry";
39
40
  import { createClusterLayer, createClusterCountLayer, createUnclusteredPointLayer } from "../mapLayersUtils";
41
+ const COMMENT_ENTRY_PREFIX = "comments:";
42
+ const COMMENT_CLUSTER_LAYER_ID = "comments-clusters";
43
+ const CommentPopupCard = ({ header, comment, currentUserId, onEdit, onReply, onRemove, onClose }) => {
44
+ var _a, _b, _c, _d;
45
+ const { user: author } = useUser(comment.authorId != null ? String(comment.authorId) : "");
46
+ const isAuthor = currentUserId === String(comment.authorId);
47
+ return /* @__PURE__ */ jsx(
48
+ Comment,
49
+ {
50
+ header,
51
+ userName: comment.authorName || "",
52
+ userImage: (_b = (_a = author == null ? void 0 : author.imageFileId) != null ? _a : comment.imageFileId) != null ? _b : null,
53
+ userImageFileId: (_d = (_c = author == null ? void 0 : author.imageFileId) != null ? _c : comment.imageFileId) != null ? _d : null,
54
+ text: comment.text,
55
+ createdAt: comment.createdAt,
56
+ showActions: true,
57
+ canEdit: isAuthor,
58
+ canDelete: isAuthor,
59
+ onEdit: isAuthor ? () => onEdit(comment.id) : void 0,
60
+ onReply: () => onReply(comment.id),
61
+ onRemove: isAuthor ? () => onRemove(comment.id) : void 0,
62
+ onClose
63
+ }
64
+ );
65
+ };
40
66
  const CommentAvatarMarker = ({ feature, isHighlighted, isFocused, onMouseEnter, onMouseLeave, onClick, onDoubleClick, center, offset }) => {
41
67
  var _a, _b, _c, _d, _e, _f, _g;
42
68
  const authorId = (_a = feature.properties) == null ? void 0 : _a.authorId;
@@ -83,13 +109,11 @@ const CommentLayer = () => {
83
109
  const clusterCountLayer = createClusterCountLayer("comments");
84
110
  const unclusteredPointLayer = createUnclusteredPointLayer("comments");
85
111
  const t = useTranslations("CommentLayers");
86
- const { state: mapState } = React.useContext(MapContext);
87
- const { map, mapClickManager } = mapState.map;
112
+ const { state: mapState, dispatch: mapDispatch } = React.useContext(MapContext);
113
+ const { map, mapClickManager, popupStack } = mapState.map;
88
114
  const { comments } = useComments();
89
115
  const { users } = useUsers();
90
116
  const user = (_a = useSession().data) == null ? void 0 : _a.user;
91
- const [popupInfo, setPopUpInfo] = React.useState(null);
92
- const { user: popupAuthor } = useUser((popupInfo == null ? void 0 : popupInfo.authorId) != null ? String(popupInfo.authorId) : "");
93
117
  const { deleteComments } = useDeleteComments();
94
118
  const { state: menusState, dispatch: menusDispatch, setIsSidebarOpen } = React.useContext(MenusContext);
95
119
  const { commentsVisibleInViewer, currentCommentId, focusedCommentId, focusRequestId } = menusState.menus;
@@ -105,6 +129,42 @@ const CommentLayer = () => {
105
129
  menusDispatch({ type: "SET_CURRENT_COMMENT_ID", payload: { commentId } });
106
130
  menusDispatch({ type: "REQUEST_COMMENT_ACTION", payload: { commentId, action } });
107
131
  }, [menusDispatch, setIsSidebarOpen]);
132
+ const closePopups = React.useCallback(
133
+ () => mapDispatch({ type: "SET_POPUP_STACK", payload: null }),
134
+ [mapDispatch]
135
+ );
136
+ const handleRemoveComment = React.useCallback((id) => {
137
+ toast.success(t("commentDeleted"));
138
+ const replyIds = comments.filter((c) => c.replyToId === id).map((c) => c.id);
139
+ void deleteComments({ ids: [id, ...replyIds] });
140
+ closePopups();
141
+ }, [comments, deleteComments, closePopups, t]);
142
+ const buildCommentEntry = React.useCallback((comment) => ({
143
+ id: `${COMMENT_ENTRY_PREFIX}${comment.id}`,
144
+ layerId: "comments-unclustered-points",
145
+ priority: MapLayerClickPriority.CommentLayersClickPriority,
146
+ title: comment.authorName || t("commentTitle"),
147
+ coordinates: [comment.longitude, comment.latitude],
148
+ render: (header) => /* @__PURE__ */ jsx(
149
+ CommentPopupCard,
150
+ {
151
+ header,
152
+ comment,
153
+ currentUserId: user == null ? void 0 : user.id,
154
+ onEdit: (id) => requestSidebarAction(id, "edit"),
155
+ onReply: (id) => requestSidebarAction(id, "reply"),
156
+ onRemove: handleRemoveComment,
157
+ onClose: closePopups
158
+ }
159
+ )
160
+ }), [user == null ? void 0 : user.id, requestSidebarAction, handleRemoveComment, closePopups, t]);
161
+ const openComment = React.useCallback((comment) => {
162
+ mapDispatch({ type: "SET_POPUP_STACK", payload: { entries: [buildCommentEntry(comment)] } });
163
+ }, [mapDispatch, buildCommentEntry]);
164
+ const openCommentId = React.useMemo(() => {
165
+ const active = popupStack == null ? void 0 : popupStack.entries[popupStack.activeIndex];
166
+ return (active == null ? void 0 : active.id.startsWith(COMMENT_ENTRY_PREFIX)) ? Number(active.id.slice(COMMENT_ENTRY_PREFIX.length)) : null;
167
+ }, [popupStack]);
108
168
  const [spider, setSpider] = React.useState(null);
109
169
  const spiderCloseTimer = React.useRef(null);
110
170
  const cancelSpiderClose = React.useCallback(() => {
@@ -117,13 +177,13 @@ const CommentLayer = () => {
117
177
  cancelSpiderClose();
118
178
  spiderCloseTimer.current = setTimeout(() => setSpider(null), 150);
119
179
  }, [cancelSpiderClose]);
120
- const openPopupFromFeature = React.useCallback((feature) => {
180
+ const commentFromFeature = React.useCallback((feature) => {
121
181
  var _a2, _b;
122
- if (!feature || feature.properties.point_count) return;
123
- if (feature.geometry.type !== "Point") return;
182
+ if (!feature || feature.properties.point_count) return null;
183
+ if (feature.geometry.type !== "Point") return null;
124
184
  const [longitude, latitude] = feature.geometry.coordinates;
125
185
  const p = feature.properties;
126
- setPopUpInfo({
186
+ return {
127
187
  id: Number(p.id),
128
188
  authorId: Number(p.authorId),
129
189
  organizationId: (_a2 = feature.properties) == null ? void 0 : _a2.organizationId,
@@ -135,8 +195,12 @@ const CommentLayer = () => {
135
195
  authorName: p.authorName,
136
196
  imageFileId: p.imageFileId,
137
197
  viewer: ViewerNames.map
138
- });
198
+ };
139
199
  }, []);
200
+ const openPopupFromFeature = React.useCallback((feature) => {
201
+ const comment = commentFromFeature(feature);
202
+ if (comment) openComment(comment);
203
+ }, [commentFromFeature, openComment]);
140
204
  const eligibleComments = comments.filter((comment) => comment.viewer === ViewerNames.map).map((comment) => {
141
205
  var _a2, _b;
142
206
  const user2 = users.find((u) => u.id === comment.authorId);
@@ -148,29 +212,17 @@ const CommentLayer = () => {
148
212
  const eligibleCommentsRef = React.useRef(eligibleComments);
149
213
  eligibleCommentsRef.current = eligibleComments;
150
214
  React.useEffect(() => {
151
- if (popupInfo && !comments.find((c) => c.id === popupInfo.id)) {
152
- setPopUpInfo(null);
215
+ if (openCommentId != null && !comments.find((c) => c.id === openCommentId)) {
216
+ closePopups();
153
217
  }
154
- }, [comments, popupInfo]);
218
+ }, [comments, openCommentId, closePopups]);
155
219
  React.useEffect(() => {
156
220
  if (focusedCommentId == null || !map) return;
157
221
  const target = eligibleCommentsRef.current.find((c) => c.id === focusedCommentId);
158
222
  if (!target || target.longitude == null || target.latitude == null) return;
159
223
  map.flyTo({ center: [target.longitude, target.latitude], zoom: Math.max(map.getZoom(), 17), duration: 800 });
160
- setPopUpInfo({
161
- id: target.id,
162
- authorId: target.authorId,
163
- organizationId: target.organizationId,
164
- visible: target.visible,
165
- longitude: target.longitude,
166
- latitude: target.latitude,
167
- text: target.text,
168
- createdAt: target.createdAt,
169
- authorName: target.authorName,
170
- imageFileId: target.imageFileId,
171
- viewer: ViewerNames.map
172
- });
173
- }, [focusRequestId, map]);
224
+ openComment(target);
225
+ }, [focusRequestId, map, openComment]);
174
226
  const geojsonCommentData = React.useMemo(() => {
175
227
  const convertDataToGeojson = (commentData) => {
176
228
  const commentFeatures = commentData.map((comment) => {
@@ -206,16 +258,14 @@ const CommentLayer = () => {
206
258
  }, [eligibleComments]);
207
259
  React.useEffect(() => {
208
260
  if (!map) return;
209
- const showCommentPopUp = (e, features) => {
210
- openPopupFromFeature(features == null ? void 0 : features[0]);
211
- };
261
+ const resolveComments = (_e, features) => features.map((feature) => commentFromFeature(feature)).filter((comment) => comment !== null).map(buildCommentEntry);
212
262
  const mouseEnterChangeCursor = () => {
213
263
  map.getCanvas().style.cursor = "pointer";
214
264
  };
215
265
  const mouseLeaveChangeCursor = () => {
216
266
  map.getCanvas().style.cursor = "";
217
267
  };
218
- mapClickManager.register("comments-unclustered-points", MapLayerClickPriority.CommentLayersClickPriority, showCommentPopUp);
268
+ mapClickManager.register("comments-unclustered-points", MapLayerClickPriority.CommentLayersClickPriority, resolveComments);
219
269
  map.on("mouseenter", "comments-unclustered-points", mouseEnterChangeCursor);
220
270
  map.on("mouseleave", "comments-unclustered-points", mouseLeaveChangeCursor);
221
271
  return () => {
@@ -223,15 +273,7 @@ const CommentLayer = () => {
223
273
  map.off("mouseenter", "comments-unclustered-points", mouseEnterChangeCursor);
224
274
  map.off("mouseleave", "comments-unclustered-points", mouseLeaveChangeCursor);
225
275
  };
226
- }, [map, mapClickManager, openPopupFromFeature]);
227
- const handleRemoveComment = () => {
228
- if ((popupInfo == null ? void 0 : popupInfo.id) == null) return;
229
- toast.success(t("commentDeleted"));
230
- const id = popupInfo.id;
231
- const replyIds = comments.filter((c) => c.replyToId === id).map((c) => c.id);
232
- void deleteComments({ ids: [id, ...replyIds] });
233
- setPopUpInfo(null);
234
- };
276
+ }, [map, mapClickManager, commentFromFeature, buildCommentEntry]);
235
277
  React.useEffect(() => {
236
278
  if (!map) return;
237
279
  const close = () => setSpider(null);
@@ -244,21 +286,21 @@ const CommentLayer = () => {
244
286
  }, [map]);
245
287
  React.useEffect(() => {
246
288
  if (!map) return;
247
- const zoomInToDecluster = (e) => {
248
- var _a2;
249
- const feature = (_a2 = e.features) == null ? void 0 : _a2[0];
250
- if (!feature || !feature.properties.cluster_id) return;
251
- const clusterId = feature.properties.cluster_id;
252
- if (!("coordinates" in feature.geometry)) return;
253
- const [lng, lat] = feature.geometry.coordinates;
254
- const source = map.getSource("comments");
255
- source.getClusterExpansionZoom(clusterId).then(
256
- (zoom) => {
257
- map.easeTo({ center: [lng, lat], zoom });
289
+ const resolveCluster = (_e, features) => {
290
+ const feature = features[0];
291
+ const spec = feature && clusterSpecFromFeature(feature);
292
+ if (!spec) return [];
293
+ return [buildClusterEntry(__spreadValues({
294
+ map,
295
+ sourceId: "comments",
296
+ layerId: COMMENT_CLUSTER_LAYER_ID,
297
+ title: t("commentTitle"),
298
+ priority: MapLayerClickPriority.CommentLayersClickPriority,
299
+ leafLabel: (leaf) => {
300
+ var _a2, _b, _c, _d;
301
+ return String((_d = (_c = (_a2 = leaf.properties) == null ? void 0 : _a2.authorName) != null ? _c : (_b = leaf.properties) == null ? void 0 : _b.text) != null ? _d : "");
258
302
  }
259
- ).catch((error) => {
260
- console.error(error);
261
- });
303
+ }, spec))];
262
304
  };
263
305
  const expandClusterOnHover = (e) => {
264
306
  var _a2;
@@ -280,61 +322,15 @@ const CommentLayer = () => {
280
322
  map.getCanvas().style.cursor = "";
281
323
  scheduleSpiderClose();
282
324
  };
283
- map.on("click", "comments-clusters", zoomInToDecluster);
284
- map.on("mouseenter", "comments-clusters", expandClusterOnHover);
285
- map.on("mouseleave", "comments-clusters", mouseLeaveCluster);
325
+ mapClickManager.register(COMMENT_CLUSTER_LAYER_ID, MapLayerClickPriority.CommentLayersClickPriority, resolveCluster);
326
+ map.on("mouseenter", COMMENT_CLUSTER_LAYER_ID, expandClusterOnHover);
327
+ map.on("mouseleave", COMMENT_CLUSTER_LAYER_ID, mouseLeaveCluster);
286
328
  return () => {
287
- map.off("click", "comments-clusters", zoomInToDecluster);
288
- map.off("mouseenter", "comments-clusters", expandClusterOnHover);
289
- map.off("mouseleave", "comments-clusters", mouseLeaveCluster);
329
+ mapClickManager.unregister(COMMENT_CLUSTER_LAYER_ID);
330
+ map.off("mouseenter", COMMENT_CLUSTER_LAYER_ID, expandClusterOnHover);
331
+ map.off("mouseleave", COMMENT_CLUSTER_LAYER_ID, mouseLeaveCluster);
290
332
  };
291
- }, [map, cancelSpiderClose, scheduleSpiderClose]);
292
- const renderPopup = () => {
293
- var _a2, _b, _c, _d;
294
- if (!popupInfo) return null;
295
- return /* @__PURE__ */ jsxs(
296
- Popup,
297
- {
298
- className: "noBorderPopup",
299
- longitude: popupInfo.longitude,
300
- latitude: popupInfo.latitude,
301
- closeOnClick: false,
302
- onClose: () => setPopUpInfo(null),
303
- anchor: "bottom",
304
- style: { height: "50px", border: "none", boxShadow: "none" },
305
- offset: [0, 10],
306
- children: [
307
- /* @__PURE__ */ jsx(
308
- Comment,
309
- {
310
- userName: popupInfo.authorName || "",
311
- userImage: (_b = (_a2 = popupAuthor == null ? void 0 : popupAuthor.imageFileId) != null ? _a2 : popupInfo.imageFileId) != null ? _b : null,
312
- userImageFileId: (_d = (_c = popupAuthor == null ? void 0 : popupAuthor.imageFileId) != null ? _c : popupInfo.imageFileId) != null ? _d : null,
313
- text: popupInfo.text,
314
- createdAt: popupInfo.createdAt,
315
- showActions: true,
316
- canEdit: user.id === String(popupInfo.authorId),
317
- canDelete: user.id === String(popupInfo.authorId),
318
- onEdit: user.id === String(popupInfo.authorId) ? () => requestSidebarAction(popupInfo.id, "edit") : void 0,
319
- onReply: () => requestSidebarAction(popupInfo.id, "reply"),
320
- onRemove: user.id === String(popupInfo.authorId) ? handleRemoveComment : void 0,
321
- onClose: () => setPopUpInfo(null)
322
- }
323
- ),
324
- /* @__PURE__ */ jsx("style", { children: `
325
- .noBorderPopup .maplibregl-popup-content {
326
- border: none !important;
327
- box-shadow: none !important;
328
- background: transparent !important;
329
- }
330
- .noBorderPopup .maplibregl-popup-tip {
331
- display: none !important;
332
- }
333
- ` })
334
- ]
335
- }
336
- );
337
- };
333
+ }, [map, mapClickManager, cancelSpiderClose, scheduleSpiderClose, t]);
338
334
  const [unclusteredFeatures, setUnclusteredFeatures] = React.useState([]);
339
335
  React.useEffect(() => {
340
336
  if (!map) return;
@@ -376,10 +372,9 @@ const CommentLayer = () => {
376
372
  /* @__PURE__ */ jsx(Layer, __spreadValues({}, clusterLayer)),
377
373
  /* @__PURE__ */ jsx(Layer, __spreadValues({}, clusterCountLayer)),
378
374
  /* @__PURE__ */ jsx(Layer, __spreadValues({}, unclusteredPointLayer)),
379
- renderPopup(),
380
375
  unclusteredFeatures.filter((feature) => {
381
376
  var _a2;
382
- return ((_a2 = feature.properties) == null ? void 0 : _a2.id) !== (popupInfo == null ? void 0 : popupInfo.id);
377
+ return ((_a2 = feature.properties) == null ? void 0 : _a2.id) !== openCommentId;
383
378
  }).map((feature) => {
384
379
  var _a2, _b, _c, _d;
385
380
  return /* @__PURE__ */ jsx(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/CommentLayer/index.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { useSession } from 'next-auth/react'\nimport { useTranslations } from 'next-intl'\nimport * as React from 'react'\nimport { Source, Layer, Popup, Marker } from 'react-map-gl/maplibre'\nimport { toast } from 'sonner'\n\nimport { useComments, useDeleteComments } from '../../../../../../../hooks/comments/comments'\nimport { useUser, useUsers } from '../../../../../../../hooks/users/users'\nimport { MapContext, MenusContext } from '../../../../../../../store'\nimport { ViewerNames, type Comment as IComment } from '../../../../../../../types/dbTypes'\nimport { commentRingShadow, markerOcclusionProps } from '../../../../../../../utils/markerUtils'\nimport { Avatar } from '../../../../../../ui/Avatar'\nimport Comment from '../../../../../../ui/Comments/Comment'\nimport { UserAvatar } from '../../../../../../ui/UserAvatar'\nimport { extractCoordinatesFromFeature } from '../../../../utils/extractCoordinates'\nimport { MapLayerClickPriority } from '../../../../utils/MapEventManager/MapClickManager'\nimport { createClusterLayer, createClusterCountLayer, createUnclusteredPointLayer } from '../mapLayersUtils'\n\nimport type { ClickCallback } from '../../../../utils/MapEventManager/MapClickManager';\nimport type { MapGeoJSONFeature, MapLayerMouseEvent } from 'maplibre-gl'\n\ntype MapComment = IComment & {\n authorName?: string\n imageFileId?: number | null\n}\n\nconst CommentAvatarMarker = ({ feature, isHighlighted, isFocused, onMouseEnter, onMouseLeave, onClick, onDoubleClick, center, offset }: { feature: MapGeoJSONFeature; isHighlighted?: boolean; isFocused?: boolean; onMouseEnter?: () => void; onMouseLeave?: () => void; onClick?: () => void; onDoubleClick?: () => void; center?: [number, number]; offset?: [number, number] }) => {\n const authorId = feature.properties?.authorId\n const { user: author } = useUser(authorId != null ? String(authorId) : '')\n const userName = feature.properties?.authorName\n const userImageFileId = feature.properties?.imageFileId\n const resolvedImageFileId = author?.imageFileId ?? userImageFileId ?? null\n\n // When part of an expanded (spiderfied) cluster, position at the cluster\n // center and fan out with a pixel offset instead of the feature's own coords.\n const coords = center ? { lng: center[0], lat: center[1] } : extractCoordinatesFromFeature(feature)\n if (!coords) return null\n\n const scale = isFocused ? 1.25 : isHighlighted ? 1.2 : 1\n\n return (\n <Marker key={String(feature.properties?.id ?? `${coords.lng},${coords.lat}`)} longitude={coords.lng} latitude={coords.lat} anchor=\"center\" offset={offset} {...markerOcclusionProps}>\n <div\n title={onDoubleClick ? 'Double click to zoom' : undefined}\n style={{\n width: '36px',\n height: '36px',\n borderRadius: '50%',\n boxShadow: commentRingShadow({ highlight: isHighlighted, focused: isFocused }),\n transition: 'all 0.2s ease-in-out',\n transform: `scale(${scale})`,\n overflow: 'hidden',\n cursor: onClick || onDoubleClick ? 'pointer' : undefined,\n }}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onClick={onClick}\n onDoubleClick={onDoubleClick}\n >\n <Avatar className=\"h-full w-full\">\n <UserAvatar\n imageFileId={resolvedImageFileId}\n name={userName}\n className=\"h-full w-full rounded-full object-cover\"\n />\n </Avatar>\n </div>\n </Marker>\n )\n}\n\nexport const CommentLayer = () => {\n const [hoveredCommentId, setHoveredCommentId] = React.useState<number | null>(null)\n const clusterLayer = createClusterLayer('comments')\n const clusterCountLayer = createClusterCountLayer('comments')\n const unclusteredPointLayer = createUnclusteredPointLayer('comments')\n\n // global map state\n\n const t = useTranslations('CommentLayers')\n\n const { state: mapState } = React.useContext(MapContext)\n const { map, mapClickManager } = mapState.map\n const { comments } = useComments()\n const { users } = useUsers()\n const user = useSession().data?.user\n\n const [popupInfo, setPopUpInfo] = React.useState<(Partial<IComment> & { authorName?: string; imageFileId?: number | null }) | null>(null)\n const { user: popupAuthor } = useUser(popupInfo?.authorId != null ? String(popupInfo.authorId) : '')\n const { deleteComments } = useDeleteComments()\n const { state: menusState, dispatch: menusDispatch, setIsSidebarOpen } = React.useContext(MenusContext)\n const { commentsVisibleInViewer, currentCommentId, focusedCommentId, focusRequestId } = menusState.menus\n\n const focusComment = React.useCallback((commentId?: number) => {\n if (commentId == null) return\n menusDispatch({ type: 'SET_CURRENT_COMMENT_ID', payload: { commentId } })\n menusDispatch({ type: 'SET_FOCUSED_COMMENT_ID', payload: { commentId } })\n }, [menusDispatch])\n\n // Edit/reply from the popup card open the comment's editor/reply box in the sidebar,\n // matching the BIM comment card behaviour.\n const requestSidebarAction = React.useCallback((commentId: number | undefined, action: 'edit' | 'reply') => {\n if (commentId == null) return\n setIsSidebarOpen(true)\n menusDispatch({ type: 'SET_SIDEBAR_SELECTED_TAB', payload: { selectedTab: 'communication' } })\n menusDispatch({ type: 'SET_CURRENT_COMMENT_ID', payload: { commentId } })\n menusDispatch({ type: 'REQUEST_COMMENT_ACTION', payload: { commentId, action } })\n }, [menusDispatch, setIsSidebarOpen])\n\n // Hover-to-expand (spiderfy) state for clusters\n const [spider, setSpider] = React.useState<{ center: [number, number]; features: MapGeoJSONFeature[] } | null>(null)\n const spiderCloseTimer = React.useRef<ReturnType<typeof setTimeout> | null>(null)\n\n const cancelSpiderClose = React.useCallback(() => {\n if (spiderCloseTimer.current) {\n clearTimeout(spiderCloseTimer.current)\n spiderCloseTimer.current = null\n }\n }, [])\n\n const scheduleSpiderClose = React.useCallback(() => {\n cancelSpiderClose()\n spiderCloseTimer.current = setTimeout(() => setSpider(null), 150)\n }, [cancelSpiderClose])\n\n const openPopupFromFeature = React.useCallback((feature?: MapGeoJSONFeature) => {\n if (!feature || feature.properties.point_count) return\n if (feature.geometry.type !== 'Point') return\n const [longitude, latitude] = feature.geometry.coordinates\n const p = feature.properties as MapComment\n setPopUpInfo({\n id: Number(p.id),\n authorId: Number(p.authorId),\n organizationId: feature.properties?.organizationId,\n visible: feature.properties?.visible,\n longitude,\n latitude,\n text: p.text,\n createdAt: p.createdAt,\n authorName: p.authorName,\n imageFileId: p.imageFileId,\n viewer: ViewerNames.map,\n })\n }, [])\n\n const eligibleComments = comments\n .filter((comment) => comment.viewer === ViewerNames.map)\n .map((comment) => {\n const user = users.find(u => u.id === comment.authorId)\n return {\n ...comment,\n authorName: user?.name ?? 'Unknown User',\n imageFileId: user?.imageFileId ?? null,\n }\n })\n\n // Keep the latest comments available to the focus effect without re-running it every render.\n const eligibleCommentsRef = React.useRef(eligibleComments)\n eligibleCommentsRef.current = eligibleComments\n\n // Close popup if the comment was deleted\n React.useEffect(() => {\n if (popupInfo && !comments.find((c) => c.id === popupInfo.id)) {\n setPopUpInfo(null)\n }\n }, [comments, popupInfo])\n\n // Fly to a comment when it is focused (double-clicked here or in the sidebar) and open its card.\n React.useEffect(() => {\n if (focusedCommentId == null || !map) return\n const target = eligibleCommentsRef.current.find((c) => c.id === focusedCommentId)\n if (!target || target.longitude == null || target.latitude == null) return\n map.flyTo({ center: [target.longitude, target.latitude], zoom: Math.max(map.getZoom(), 17), duration: 800 })\n setPopUpInfo({\n id: target.id,\n authorId: target.authorId,\n organizationId: target.organizationId,\n visible: target.visible,\n longitude: target.longitude,\n latitude: target.latitude,\n text: target.text,\n createdAt: target.createdAt,\n authorName: target.authorName,\n imageFileId: target.imageFileId,\n viewer: ViewerNames.map,\n })\n }, [focusRequestId, map])\n\n const geojsonCommentData = React.useMemo(() => {\n const convertDataToGeojson = (commentData: MapComment[]): GeoJSON.FeatureCollection<GeoJSON.Point, { [key: string]: any }> => {\n const commentFeatures: GeoJSON.Feature<GeoJSON.Point, { [key: string]: any }>[] = commentData\n .map((comment: MapComment) => {\n const { longitude, latitude, id, text, createdAt, authorId, organizationId, visible, authorName, imageFileId } = comment\n\n return {\n type: 'Feature',\n geometry: {\n type: 'Point',\n coordinates: [longitude, latitude],\n },\n properties: {\n id: Number(id),\n organizationId,\n visible,\n longitude,\n latitude,\n authorId: Number(authorId),\n authorName,\n imageFileId,\n text,\n createdAt,\n viewer: ViewerNames.map,\n },\n }\n })\n\n const commentFC: GeoJSON.FeatureCollection<GeoJSON.Point, { [key: string]: any }> = {\n type: 'FeatureCollection',\n features: commentFeatures,\n }\n return commentFC\n }\n return convertDataToGeojson(eligibleComments)\n }, [eligibleComments])\n\n // event listeners for comment unclustered points\n React.useEffect(() => {\n if (!map) return\n const showCommentPopUp: ClickCallback = (e: MapLayerMouseEvent, features: MapGeoJSONFeature[]) => {\n openPopupFromFeature(features?.[0])\n }\n\n const mouseEnterChangeCursor = () => {\n map.getCanvas().style.cursor = 'pointer'\n }\n const mouseLeaveChangeCursor = () => {\n map.getCanvas().style.cursor = ''\n }\n\n // event listener for clicking on single point to show comment, hover to change cursor\n mapClickManager.register('comments-unclustered-points', MapLayerClickPriority.CommentLayersClickPriority, showCommentPopUp)\n\n map.on('mouseenter', 'comments-unclustered-points', mouseEnterChangeCursor)\n map.on('mouseleave', 'comments-unclustered-points', mouseLeaveChangeCursor)\n return () => {\n mapClickManager.unregister('comments-unclustered-points')\n map.off('mouseenter', 'comments-unclustered-points', mouseEnterChangeCursor)\n map.off('mouseleave', 'comments-unclustered-points', mouseLeaveChangeCursor)\n }\n }, [map, mapClickManager, openPopupFromFeature])\n\n const handleRemoveComment = () => {\n if (popupInfo?.id == null) return\n toast.success(t('commentDeleted'))\n // Cascade: delete the comment together with its replies (the DB does not cascade).\n const id = popupInfo.id\n const replyIds = comments.filter((c) => c.replyToId === id).map((c) => c.id)\n void deleteComments({ ids: [id, ...replyIds] })\n setPopUpInfo(null)\n }\n\n // Close the spiderfied cluster when the map moves (positions would be stale)\n React.useEffect(() => {\n if (!map) return\n const close = () => setSpider(null)\n map.on('movestart', close)\n map.on('zoomstart', close)\n return () => {\n map.off('movestart', close)\n map.off('zoomstart', close)\n }\n }, [map])\n\n // event listeners for clustered points\n React.useEffect(() => {\n if (!map) return\n\n const zoomInToDecluster = (e: MapLayerMouseEvent) => {\n const feature = e.features?.[0] // only proceed if this is actually a cluster\n if (!feature || !feature.properties.cluster_id) return\n\n const clusterId = feature.properties.cluster_id as number\n\n // Check if geometry has coordinates (not a GeometryCollection)\n if (!('coordinates' in feature.geometry)) return\n const [lng, lat] = feature.geometry.coordinates as [number, number]\n\n const source = map.getSource('comments') as any\n source.getClusterExpansionZoom(clusterId).then(\n (zoom: number) => {\n map.easeTo({ center: [lng, lat], zoom })\n },\n )\n .catch((error) => {\n console.error(error)\n })\n }\n\n // Hover a cluster to expand (spiderfy) its members\n const expandClusterOnHover = (e: MapLayerMouseEvent) => {\n map.getCanvas().style.cursor = 'pointer'\n const feature = e.features?.[0]\n if (!feature || !feature.properties.cluster_id) return\n if (!('coordinates' in feature.geometry)) return\n const center = feature.geometry.coordinates as [number, number]\n const clusterId = feature.properties.cluster_id as number\n\n const source = map.getSource('comments') as any\n source.getClusterLeaves(clusterId, Infinity, 0)\n .then((leaves: MapGeoJSONFeature[]) => {\n cancelSpiderClose()\n setSpider({ center, features: leaves })\n })\n .catch((error: unknown) => {\n console.error(error)\n })\n }\n\n const mouseLeaveCluster = () => {\n map.getCanvas().style.cursor = ''\n scheduleSpiderClose()\n }\n\n // Hover expands the cluster; click still zooms in to decluster as a fallback\n map.on('click', 'comments-clusters', zoomInToDecluster)\n map.on('mouseenter', 'comments-clusters', expandClusterOnHover)\n map.on('mouseleave', 'comments-clusters', mouseLeaveCluster)\n return () => {\n map.off('click', 'comments-clusters', zoomInToDecluster)\n map.off('mouseenter', 'comments-clusters', expandClusterOnHover)\n map.off('mouseleave', 'comments-clusters', mouseLeaveCluster)\n }\n }, [map, cancelSpiderClose, scheduleSpiderClose])\n\n const renderPopup = () => {\n if (!popupInfo) return null\n return (\n <Popup\n className=\"noBorderPopup\"\n longitude={popupInfo.longitude}\n latitude={popupInfo.latitude}\n closeOnClick={false}\n onClose={() => setPopUpInfo(null)}\n anchor=\"bottom\"\n style={{ height: '50px', border: 'none', boxShadow: 'none' }}\n offset={[0, 10]}\n >\n <Comment\n userName={popupInfo.authorName || ''}\n userImage={popupAuthor?.imageFileId ?? popupInfo.imageFileId ?? null}\n userImageFileId={popupAuthor?.imageFileId ?? popupInfo.imageFileId ?? null}\n text={popupInfo.text}\n createdAt={popupInfo.createdAt}\n showActions\n canEdit={user.id === String(popupInfo.authorId)}\n canDelete={user.id === String(popupInfo.authorId)}\n onEdit={user.id === String(popupInfo.authorId) ? () => requestSidebarAction(popupInfo.id, 'edit') : undefined}\n onReply={() => requestSidebarAction(popupInfo.id, 'reply')}\n onRemove={user.id === String(popupInfo.authorId) ? handleRemoveComment : undefined}\n onClose={() => setPopUpInfo(null)}\n />\n {/* inline styles to override MapLibre’s Pop up CSS */}\n <style>\n {`\n .noBorderPopup .maplibregl-popup-content {\n border: none !important;\n box-shadow: none !important;\n background: transparent !important;\n }\n .noBorderPopup .maplibregl-popup-tip {\n display: none !important;\n }\n `}\n </style>\n </Popup>\n )\n }\n\n // Track unclustered comments to display avatars\n const [unclusteredFeatures, setUnclusteredFeatures] = React.useState<MapGeoJSONFeature[]>([])\n\n React.useEffect(() => {\n if (!map) return\n\n const updateUnclusteredFeatures = () => {\n const allFeatures = map.querySourceFeatures('comments')\n const unclusteredOnly = allFeatures.filter(\n (f) => !f.properties?.cluster && !f.properties?.point_count\n )\n\n // Deduplicate by id\n const uniqueFeatures = new Map()\n unclusteredOnly.forEach((f) => uniqueFeatures.set(f.properties.id, f))\n setUnclusteredFeatures(Array.from(uniqueFeatures.values()))\n }\n\n const onSourceData = (e: any) => {\n if (e?.sourceId === 'comments') updateUnclusteredFeatures()\n }\n\n map.on('sourcedata', onSourceData)\n map.on('moveend', updateUnclusteredFeatures)\n map.on('zoomend', updateUnclusteredFeatures)\n\n updateUnclusteredFeatures()\n\n return () => {\n map.off('sourcedata', onSourceData)\n map.off('moveend', updateUnclusteredFeatures)\n map.off('zoomend', updateUnclusteredFeatures)\n }\n }, [map])\n\n return (\n <>\n {commentsVisibleInViewer.includes(ViewerNames.map) &&\n <Source\n id=\"comments\"\n type=\"geojson\"\n data={geojsonCommentData}\n cluster={true}\n clusterMaxZoom={14}\n clusterRadius={40}\n >\n <Layer {...clusterLayer} />\n <Layer {...clusterCountLayer} />\n <Layer {...unclusteredPointLayer} />\n\n {renderPopup()}\n {unclusteredFeatures\n .filter((feature) => feature.properties?.id !== popupInfo?.id)\n .map((feature) => (\n <CommentAvatarMarker\n key={String(feature.properties?.id)}\n feature={feature}\n isHighlighted={currentCommentId === feature.properties?.id || hoveredCommentId === feature.properties?.id}\n isFocused={focusedCommentId === feature.properties?.id}\n onMouseEnter={() => setHoveredCommentId(feature.properties?.id)}\n onMouseLeave={() => setHoveredCommentId(null)}\n onDoubleClick={() => focusComment(feature.properties?.id)}\n />\n ))}\n\n {/* Spiderfied cluster members shown on hover */}\n {spider && spider.features.map((feature, i) => {\n const n = spider.features.length\n const angle = (2 * Math.PI * i) / n - Math.PI / 2\n const radius = Math.min(60, 24 + n * 4)\n const offset: [number, number] = [Math.cos(angle) * radius, Math.sin(angle) * radius]\n const id = feature.properties?.id\n return (\n <CommentAvatarMarker\n key={`spider-${String(id)}`}\n feature={feature}\n center={spider.center}\n offset={offset}\n isHighlighted={currentCommentId === id || hoveredCommentId === id}\n isFocused={focusedCommentId === id}\n onMouseEnter={() => { cancelSpiderClose(); setHoveredCommentId(id) }}\n onMouseLeave={() => { scheduleSpiderClose(); setHoveredCommentId(null) }}\n onClick={() => { openPopupFromFeature(feature); setSpider(null) }}\n onDoubleClick={() => { focusComment(id); setSpider(null) }}\n />\n )\n })}\n </Source>}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiEU,SAkWN,UAlWM,KAqRJ,YArRI;AA5DV,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,YAAY,WAAW;AACvB,SAAS,QAAQ,OAAO,OAAO,cAAc;AAC7C,SAAS,aAAa;AAEtB,SAAS,aAAa,yBAAyB;AAC/C,SAAS,SAAS,gBAAgB;AAClC,SAAS,YAAY,oBAAoB;AACzC,SAAS,mBAA6C;AACtD,SAAS,mBAAmB,4BAA4B;AACxD,SAAS,cAAc;AACvB,OAAO,aAAa;AACpB,SAAS,kBAAkB;AAC3B,SAAS,qCAAqC;AAC9C,SAAS,6BAA6B;AACtC,S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ers/src/CommentLayer/index.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { useSession } from 'next-auth/react'\nimport { useTranslations } from 'next-intl'\nimport * as React from 'react'\nimport { Source, Layer, Marker } from 'react-map-gl/maplibre'\nimport { toast } from 'sonner'\n\nimport { useComments, useDeleteComments } from '../../../../../../../hooks/comments/comments'\nimport { useUser, useUsers } from '../../../../../../../hooks/users/users'\nimport { MapContext, MenusContext } from '../../../../../../../store'\nimport { ViewerNames, type Comment as IComment } from '../../../../../../../types/dbTypes'\nimport { commentRingShadow, markerOcclusionProps } from '../../../../../../../utils/markerUtils'\nimport { Avatar } from '../../../../../../ui/Avatar'\nimport Comment from '../../../../../../ui/Comments/Comment'\nimport { UserAvatar } from '../../../../../../ui/UserAvatar'\nimport { extractCoordinatesFromFeature } from '../../../../utils/extractCoordinates'\nimport { MapLayerClickPriority } from '../../../../utils/MapEventManager/MapClickManager'\nimport { buildClusterEntry, clusterSpecFromFeature } from '../clusterPopupEntry'\nimport { createClusterLayer, createClusterCountLayer, createUnclusteredPointLayer } from '../mapLayersUtils'\n\nimport type { PopupEntry } from '../../../../../../../types/map'\nimport type { MapGeoJSONFeature, MapLayerMouseEvent, MapMouseEvent } from 'maplibre-gl'\n\ntype MapComment = IComment & {\n authorName?: string\n imageFileId?: number | null\n}\n\nconst COMMENT_ENTRY_PREFIX = 'comments:'\nconst COMMENT_CLUSTER_LAYER_ID = 'comments-clusters'\n\nconst CommentPopupCard = ({ header, comment, currentUserId, onEdit, onReply, onRemove, onClose }: {\n header?: React.ReactNode\n comment: MapComment & { authorName?: string; imageFileId?: number | null }\n currentUserId?: string\n onEdit: (id: number) => void\n onReply: (id: number) => void\n onRemove: (id: number) => void\n onClose: () => void\n}) => {\n const { user: author } = useUser(comment.authorId != null ? String(comment.authorId) : '')\n const isAuthor = currentUserId === String(comment.authorId)\n\n return (\n <Comment\n header={header}\n userName={comment.authorName || ''}\n userImage={author?.imageFileId ?? comment.imageFileId ?? null}\n userImageFileId={author?.imageFileId ?? comment.imageFileId ?? null}\n text={comment.text}\n createdAt={comment.createdAt}\n showActions\n canEdit={isAuthor}\n canDelete={isAuthor}\n onEdit={isAuthor ? () => onEdit(comment.id) : undefined}\n onReply={() => onReply(comment.id)}\n onRemove={isAuthor ? () => onRemove(comment.id) : undefined}\n onClose={onClose}\n />\n )\n}\n\nconst CommentAvatarMarker = ({ feature, isHighlighted, isFocused, onMouseEnter, onMouseLeave, onClick, onDoubleClick, center, offset }: { feature: MapGeoJSONFeature; isHighlighted?: boolean; isFocused?: boolean; onMouseEnter?: () => void; onMouseLeave?: () => void; onClick?: () => void; onDoubleClick?: () => void; center?: [number, number]; offset?: [number, number] }) => {\n const authorId = feature.properties?.authorId\n const { user: author } = useUser(authorId != null ? String(authorId) : '')\n const userName = feature.properties?.authorName\n const userImageFileId = feature.properties?.imageFileId\n const resolvedImageFileId = author?.imageFileId ?? userImageFileId ?? null\n\n // When part of an expanded (spiderfied) cluster, position at the cluster\n // center and fan out with a pixel offset instead of the feature's own coords.\n const coords = center ? { lng: center[0], lat: center[1] } : extractCoordinatesFromFeature(feature)\n if (!coords) return null\n\n const scale = isFocused ? 1.25 : isHighlighted ? 1.2 : 1\n\n return (\n <Marker key={String(feature.properties?.id ?? `${coords.lng},${coords.lat}`)} longitude={coords.lng} latitude={coords.lat} anchor=\"center\" offset={offset} {...markerOcclusionProps}>\n <div\n title={onDoubleClick ? 'Double click to zoom' : undefined}\n style={{\n width: '36px',\n height: '36px',\n borderRadius: '50%',\n boxShadow: commentRingShadow({ highlight: isHighlighted, focused: isFocused }),\n transition: 'all 0.2s ease-in-out',\n transform: `scale(${scale})`,\n overflow: 'hidden',\n cursor: onClick || onDoubleClick ? 'pointer' : undefined,\n }}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onClick={onClick}\n onDoubleClick={onDoubleClick}\n >\n <Avatar className=\"h-full w-full\">\n <UserAvatar\n imageFileId={resolvedImageFileId}\n name={userName}\n className=\"h-full w-full rounded-full object-cover\"\n />\n </Avatar>\n </div>\n </Marker>\n )\n}\n\nexport const CommentLayer = () => {\n const [hoveredCommentId, setHoveredCommentId] = React.useState<number | null>(null)\n const clusterLayer = createClusterLayer('comments')\n const clusterCountLayer = createClusterCountLayer('comments')\n const unclusteredPointLayer = createUnclusteredPointLayer('comments')\n\n // global map state\n\n const t = useTranslations('CommentLayers')\n\n const { state: mapState, dispatch: mapDispatch } = React.useContext(MapContext)\n const { map, mapClickManager, popupStack } = mapState.map\n const { comments } = useComments()\n const { users } = useUsers()\n const user = useSession().data?.user\n\n const { deleteComments } = useDeleteComments()\n const { state: menusState, dispatch: menusDispatch, setIsSidebarOpen } = React.useContext(MenusContext)\n const { commentsVisibleInViewer, currentCommentId, focusedCommentId, focusRequestId } = menusState.menus\n\n const focusComment = React.useCallback((commentId?: number) => {\n if (commentId == null) return\n menusDispatch({ type: 'SET_CURRENT_COMMENT_ID', payload: { commentId } })\n menusDispatch({ type: 'SET_FOCUSED_COMMENT_ID', payload: { commentId } })\n }, [menusDispatch])\n\n // Edit/reply from the popup card open the comment's editor/reply box in the sidebar,\n // matching the BIM comment card behaviour.\n const requestSidebarAction = React.useCallback((commentId: number | undefined, action: 'edit' | 'reply') => {\n if (commentId == null) return\n setIsSidebarOpen(true)\n menusDispatch({ type: 'SET_SIDEBAR_SELECTED_TAB', payload: { selectedTab: 'communication' } })\n menusDispatch({ type: 'SET_CURRENT_COMMENT_ID', payload: { commentId } })\n menusDispatch({ type: 'REQUEST_COMMENT_ACTION', payload: { commentId, action } })\n }, [menusDispatch, setIsSidebarOpen])\n\n const closePopups = React.useCallback(\n () => mapDispatch({ type: 'SET_POPUP_STACK', payload: null }),\n [mapDispatch],\n )\n\n const handleRemoveComment = React.useCallback((id: number) => {\n toast.success(t('commentDeleted'))\n // Cascade: delete the comment together with its replies (the DB does not cascade).\n const replyIds = comments.filter((c) => c.replyToId === id).map((c) => c.id)\n void deleteComments({ ids: [id, ...replyIds] })\n closePopups()\n }, [comments, deleteComments, closePopups, t])\n\n const buildCommentEntry = React.useCallback((comment: MapComment): PopupEntry => ({\n id: `${COMMENT_ENTRY_PREFIX}${comment.id}`,\n layerId: 'comments-unclustered-points',\n priority: MapLayerClickPriority.CommentLayersClickPriority,\n title: comment.authorName || t('commentTitle'),\n coordinates: [comment.longitude, comment.latitude],\n render: (header) => (\n <CommentPopupCard\n header={header}\n comment={comment}\n currentUserId={user?.id}\n onEdit={(id) => requestSidebarAction(id, 'edit')}\n onReply={(id) => requestSidebarAction(id, 'reply')}\n onRemove={handleRemoveComment}\n onClose={closePopups}\n />\n ),\n }), [user?.id, requestSidebarAction, handleRemoveComment, closePopups, t])\n\n const openComment = React.useCallback((comment: MapComment) => {\n mapDispatch({ type: 'SET_POPUP_STACK', payload: { entries: [buildCommentEntry(comment)] } })\n }, [mapDispatch, buildCommentEntry])\n\n const openCommentId = React.useMemo(() => {\n const active = popupStack?.entries[popupStack.activeIndex]\n return active?.id.startsWith(COMMENT_ENTRY_PREFIX)\n ? Number(active.id.slice(COMMENT_ENTRY_PREFIX.length))\n : null\n }, [popupStack])\n\n // Hover-to-expand (spiderfy) state for clusters\n const [spider, setSpider] = React.useState<{ center: [number, number]; features: MapGeoJSONFeature[] } | null>(null)\n const spiderCloseTimer = React.useRef<ReturnType<typeof setTimeout> | null>(null)\n\n const cancelSpiderClose = React.useCallback(() => {\n if (spiderCloseTimer.current) {\n clearTimeout(spiderCloseTimer.current)\n spiderCloseTimer.current = null\n }\n }, [])\n\n const scheduleSpiderClose = React.useCallback(() => {\n cancelSpiderClose()\n spiderCloseTimer.current = setTimeout(() => setSpider(null), 150)\n }, [cancelSpiderClose])\n\n const commentFromFeature = React.useCallback((feature?: MapGeoJSONFeature): MapComment | null => {\n if (!feature || feature.properties.point_count) return null\n if (feature.geometry.type !== 'Point') return null\n const [longitude, latitude] = feature.geometry.coordinates\n const p = feature.properties as MapComment\n return {\n id: Number(p.id),\n authorId: Number(p.authorId),\n organizationId: feature.properties?.organizationId,\n visible: feature.properties?.visible,\n longitude,\n latitude,\n text: p.text,\n createdAt: p.createdAt,\n authorName: p.authorName,\n imageFileId: p.imageFileId,\n viewer: ViewerNames.map,\n } as MapComment\n }, [])\n\n const openPopupFromFeature = React.useCallback((feature?: MapGeoJSONFeature) => {\n const comment = commentFromFeature(feature)\n if (comment) openComment(comment)\n }, [commentFromFeature, openComment])\n\n const eligibleComments = comments\n .filter((comment) => comment.viewer === ViewerNames.map)\n .map((comment) => {\n const user = users.find(u => u.id === comment.authorId)\n return {\n ...comment,\n authorName: user?.name ?? 'Unknown User',\n imageFileId: user?.imageFileId ?? null,\n }\n })\n\n // Keep the latest comments available to the focus effect without re-running it every render.\n const eligibleCommentsRef = React.useRef(eligibleComments)\n eligibleCommentsRef.current = eligibleComments\n\n // Close popup if the comment was deleted\n React.useEffect(() => {\n if (openCommentId != null && !comments.find((c) => c.id === openCommentId)) {\n closePopups()\n }\n }, [comments, openCommentId, closePopups])\n\n // Fly to a comment when it is focused (double-clicked here or in the sidebar) and open its card.\n React.useEffect(() => {\n if (focusedCommentId == null || !map) return\n const target = eligibleCommentsRef.current.find((c) => c.id === focusedCommentId)\n if (!target || target.longitude == null || target.latitude == null) return\n map.flyTo({ center: [target.longitude, target.latitude], zoom: Math.max(map.getZoom(), 17), duration: 800 })\n openComment(target)\n }, [focusRequestId, map, openComment])\n\n const geojsonCommentData = React.useMemo(() => {\n const convertDataToGeojson = (commentData: MapComment[]): GeoJSON.FeatureCollection<GeoJSON.Point, { [key: string]: any }> => {\n const commentFeatures: GeoJSON.Feature<GeoJSON.Point, { [key: string]: any }>[] = commentData\n .map((comment: MapComment) => {\n const { longitude, latitude, id, text, createdAt, authorId, organizationId, visible, authorName, imageFileId } = comment\n\n return {\n type: 'Feature',\n geometry: {\n type: 'Point',\n coordinates: [longitude, latitude],\n },\n properties: {\n id: Number(id),\n organizationId,\n visible,\n longitude,\n latitude,\n authorId: Number(authorId),\n authorName,\n imageFileId,\n text,\n createdAt,\n viewer: ViewerNames.map,\n },\n }\n })\n\n const commentFC: GeoJSON.FeatureCollection<GeoJSON.Point, { [key: string]: any }> = {\n type: 'FeatureCollection',\n features: commentFeatures,\n }\n return commentFC\n }\n return convertDataToGeojson(eligibleComments)\n }, [eligibleComments])\n\n // event listeners for comment unclustered points\n React.useEffect(() => {\n if (!map) return\n const resolveComments = (_e: MapMouseEvent, features: MapGeoJSONFeature[]): PopupEntry[] =>\n features\n .map((feature) => commentFromFeature(feature))\n .filter((comment): comment is MapComment => comment !== null)\n .map(buildCommentEntry)\n\n const mouseEnterChangeCursor = () => {\n map.getCanvas().style.cursor = 'pointer'\n }\n const mouseLeaveChangeCursor = () => {\n map.getCanvas().style.cursor = ''\n }\n\n // event listener for clicking on single point to show comment, hover to change cursor\n mapClickManager.register('comments-unclustered-points', MapLayerClickPriority.CommentLayersClickPriority, resolveComments)\n\n map.on('mouseenter', 'comments-unclustered-points', mouseEnterChangeCursor)\n map.on('mouseleave', 'comments-unclustered-points', mouseLeaveChangeCursor)\n return () => {\n mapClickManager.unregister('comments-unclustered-points')\n map.off('mouseenter', 'comments-unclustered-points', mouseEnterChangeCursor)\n map.off('mouseleave', 'comments-unclustered-points', mouseLeaveChangeCursor)\n }\n }, [map, mapClickManager, commentFromFeature, buildCommentEntry])\n\n // Close the spiderfied cluster when the map moves (positions would be stale)\n React.useEffect(() => {\n if (!map) return\n const close = () => setSpider(null)\n map.on('movestart', close)\n map.on('zoomstart', close)\n return () => {\n map.off('movestart', close)\n map.off('zoomstart', close)\n }\n }, [map])\n\n // event listeners for clustered points\n React.useEffect(() => {\n if (!map) return\n\n const resolveCluster = (_e: MapMouseEvent, features: MapGeoJSONFeature[]): PopupEntry[] => {\n const feature = features[0]\n const spec = feature && clusterSpecFromFeature(feature)\n if (!spec) return []\n\n return [buildClusterEntry({\n map,\n sourceId: 'comments',\n layerId: COMMENT_CLUSTER_LAYER_ID,\n title: t('commentTitle'),\n priority: MapLayerClickPriority.CommentLayersClickPriority,\n leafLabel: (leaf) => String(leaf.properties?.authorName ?? leaf.properties?.text ?? ''),\n ...spec,\n })]\n }\n\n // Hover a cluster to expand (spiderfy) its members\n const expandClusterOnHover = (e: MapLayerMouseEvent) => {\n map.getCanvas().style.cursor = 'pointer'\n const feature = e.features?.[0]\n if (!feature || !feature.properties.cluster_id) return\n if (!('coordinates' in feature.geometry)) return\n const center = feature.geometry.coordinates as [number, number]\n const clusterId = feature.properties.cluster_id as number\n\n const source = map.getSource('comments') as any\n source.getClusterLeaves(clusterId, Infinity, 0)\n .then((leaves: MapGeoJSONFeature[]) => {\n cancelSpiderClose()\n setSpider({ center, features: leaves })\n })\n .catch((error: unknown) => {\n console.error(error)\n })\n }\n\n const mouseLeaveCluster = () => {\n map.getCanvas().style.cursor = ''\n scheduleSpiderClose()\n }\n\n // Hover expands the cluster; a click contributes one entry listing its contents\n mapClickManager.register(COMMENT_CLUSTER_LAYER_ID, MapLayerClickPriority.CommentLayersClickPriority, resolveCluster)\n map.on('mouseenter', COMMENT_CLUSTER_LAYER_ID, expandClusterOnHover)\n map.on('mouseleave', COMMENT_CLUSTER_LAYER_ID, mouseLeaveCluster)\n return () => {\n mapClickManager.unregister(COMMENT_CLUSTER_LAYER_ID)\n map.off('mouseenter', COMMENT_CLUSTER_LAYER_ID, expandClusterOnHover)\n map.off('mouseleave', COMMENT_CLUSTER_LAYER_ID, mouseLeaveCluster)\n }\n }, [map, mapClickManager, cancelSpiderClose, scheduleSpiderClose, t])\n\n // Track unclustered comments to display avatars\n const [unclusteredFeatures, setUnclusteredFeatures] = React.useState<MapGeoJSONFeature[]>([])\n\n React.useEffect(() => {\n if (!map) return\n\n const updateUnclusteredFeatures = () => {\n const allFeatures = map.querySourceFeatures('comments')\n const unclusteredOnly = allFeatures.filter(\n (f) => !f.properties?.cluster && !f.properties?.point_count\n )\n\n // Deduplicate by id\n const uniqueFeatures = new Map()\n unclusteredOnly.forEach((f) => uniqueFeatures.set(f.properties.id, f))\n setUnclusteredFeatures(Array.from(uniqueFeatures.values()))\n }\n\n const onSourceData = (e: any) => {\n if (e?.sourceId === 'comments') updateUnclusteredFeatures()\n }\n\n map.on('sourcedata', onSourceData)\n map.on('moveend', updateUnclusteredFeatures)\n map.on('zoomend', updateUnclusteredFeatures)\n\n updateUnclusteredFeatures()\n\n return () => {\n map.off('sourcedata', onSourceData)\n map.off('moveend', updateUnclusteredFeatures)\n map.off('zoomend', updateUnclusteredFeatures)\n }\n }, [map])\n\n return (\n <>\n {commentsVisibleInViewer.includes(ViewerNames.map) &&\n <Source\n id=\"comments\"\n type=\"geojson\"\n data={geojsonCommentData}\n cluster={true}\n clusterMaxZoom={14}\n clusterRadius={40}\n >\n <Layer {...clusterLayer} />\n <Layer {...clusterCountLayer} />\n <Layer {...unclusteredPointLayer} />\n\n {unclusteredFeatures\n .filter((feature) => feature.properties?.id !== openCommentId)\n .map((feature) => (\n <CommentAvatarMarker\n key={String(feature.properties?.id)}\n feature={feature}\n isHighlighted={currentCommentId === feature.properties?.id || hoveredCommentId === feature.properties?.id}\n isFocused={focusedCommentId === feature.properties?.id}\n onMouseEnter={() => setHoveredCommentId(feature.properties?.id)}\n onMouseLeave={() => setHoveredCommentId(null)}\n onDoubleClick={() => focusComment(feature.properties?.id)}\n />\n ))}\n\n {/* Spiderfied cluster members shown on hover */}\n {spider && spider.features.map((feature, i) => {\n const n = spider.features.length\n const angle = (2 * Math.PI * i) / n - Math.PI / 2\n const radius = Math.min(60, 24 + n * 4)\n const offset: [number, number] = [Math.cos(angle) * radius, Math.sin(angle) * radius]\n const id = feature.properties?.id\n return (\n <CommentAvatarMarker\n key={`spider-${String(id)}`}\n feature={feature}\n center={spider.center}\n offset={offset}\n isHighlighted={currentCommentId === id || hoveredCommentId === id}\n isFocused={focusedCommentId === id}\n onMouseEnter={() => { cancelSpiderClose(); setHoveredCommentId(id) }}\n onMouseLeave={() => { scheduleSpiderClose(); setHoveredCommentId(null) }}\n onClick={() => { openPopupFromFeature(feature); setSpider(null) }}\n onDoubleClick={() => { focusComment(id); setSpider(null) }}\n />\n )\n })}\n </Source>}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgDI,SA+XA,UA/XA,KAiYA,YAjYA;AA3CJ,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,YAAY,WAAW;AACvB,SAAS,QAAQ,OAAO,cAAc;AACtC,SAAS,aAAa;AAEtB,SAAS,aAAa,yBAAyB;AAC/C,SAAS,SAAS,gBAAgB;AAClC,SAAS,YAAY,oBAAoB;AACzC,SAAS,mBAA6C;AACtD,SAAS,mBAAmB,4BAA4B;AACxD,SAAS,cAAc;AACvB,OAAO,aAAa;AACpB,SAAS,kBAAkB;AAC3B,SAAS,qCAAqC;AAC9C,SAAS,6BAA6B;AACtC,SAAS,mBAAmB,8BAA8B;AAC1D,SAAS,oBAAoB,yBAAyB,mCAAmC;AAUzF,MAAM,uBAAuB;AAC7B,MAAM,2BAA2B;AAEjC,MAAM,mBAAmB,CAAC,EAAE,QAAQ,SAAS,eAAe,QAAQ,SAAS,UAAU,QAAQ,MAQzF;AA3CN;AA4CE,QAAM,EAAE,MAAM,OAAO,IAAI,QAAQ,QAAQ,YAAY,OAAO,OAAO,QAAQ,QAAQ,IAAI,EAAE;AACzF,QAAM,WAAW,kBAAkB,OAAO,QAAQ,QAAQ;AAE1D,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,UAAU,QAAQ,cAAc;AAAA,MAChC,YAAW,4CAAQ,gBAAR,YAAuB,QAAQ,gBAA/B,YAA8C;AAAA,MACzD,kBAAiB,4CAAQ,gBAAR,YAAuB,QAAQ,gBAA/B,YAA8C;AAAA,MAC/D,MAAM,QAAQ;AAAA,MACd,WAAW,QAAQ;AAAA,MACnB,aAAW;AAAA,MACX,SAAS;AAAA,MACT,WAAW;AAAA,MACX,QAAQ,WAAW,MAAM,OAAO,QAAQ,EAAE,IAA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;AAAA;AAAA;AAAA,YANnD,QAAOA,MAAA,QAAQ,eAAR,gBAAAA,IAAoB,EAAE;AAAA,UAOpC;AAAA,SACD;AAAA,QAGF,UAAU,OAAO,SAAS,IAAI,CAAC,SAAS,MAAM;AA5crD,cAAAA;AA6cQ,gBAAM,IAAI,OAAO,SAAS;AAC1B,gBAAM,QAAS,IAAI,KAAK,KAAK,IAAK,IAAI,KAAK,KAAK;AAChD,gBAAM,SAAS,KAAK,IAAI,IAAI,KAAK,IAAI,CAAC;AACtC,gBAAM,SAA2B,CAAC,KAAK,IAAI,KAAK,IAAI,QAAQ,KAAK,IAAI,KAAK,IAAI,MAAM;AACpF,gBAAM,MAAKA,MAAA,QAAQ,eAAR,gBAAAA,IAAoB;AAC/B,iBACE;AAAA,YAAC;AAAA;AAAA,cAEC;AAAA,cACA,QAAQ,OAAO;AAAA,cACf;AAAA,cACA,eAAe,qBAAqB,MAAM,qBAAqB;AAAA,cAC/D,WAAW,qBAAqB;AAAA,cAChC,cAAc,MAAM;AAAE,kCAAkB;AAAG,oCAAoB,EAAE;AAAA,cAAE;AAAA,cACnE,cAAc,MAAM;AAAE,oCAAoB;AAAG,oCAAoB,IAAI;AAAA,cAAE;AAAA,cACvE,SAAS,MAAM;AAAE,qCAAqB,OAAO;AAAG,0BAAU,IAAI;AAAA,cAAE;AAAA,cAChE,eAAe,MAAM;AAAE,6BAAa,EAAE;AAAG,0BAAU,IAAI;AAAA,cAAE;AAAA;AAAA,YATpD,UAAU,OAAO,EAAE,CAAC;AAAA,UAU3B;AAAA,QAEJ,CAAC;AAAA;AAAA;AAAA,EACH,GACA;AAEJ;","names":["_a","user"]}
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import type { Organization } from '../../../../../../../types/dbTypes';
3
3
  export declare const SUBDIVISION_LINE_WIDTH: readonly ["interpolate", readonly ["linear"], readonly ["zoom"], 4, readonly ["case", readonly ["boolean", readonly ["feature-state", "hover"], false], 0.5, 0.5], 8, readonly ["case", readonly ["boolean", readonly ["feature-state", "hover"], false], 1.4, 1.4], 10, readonly ["case", readonly ["boolean", readonly ["feature-state", "hover"], false], 3, 1.7], 14, readonly ["case", readonly ["boolean", readonly ["feature-state", "hover"], false], 4.6, 2.4], 15, readonly ["case", readonly ["boolean", readonly ["feature-state", "hover"], false], 5, 2.4]];
4
+ export declare const SUBDIVISION_LINE_OPACITY: readonly ["interpolate", readonly ["linear"], readonly ["zoom"], 9, 1, 9.5, 0];
4
5
  export declare const CountryLayer: ({ organization, maptilerKey }: {
5
6
  organization?: Organization;
6
7
  maptilerKey?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAW9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAWtE,eAAO,MAAM,sBAAsB,2iBAOzB,CAAA;AAwIV,eAAO,MAAM,YAAY,GAAI,+BAA+B;IAAE,YAAY,CAAC,EAAE,YAAY,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,sBA2GhH,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAW9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAWtE,eAAO,MAAM,sBAAsB,2iBAOzB,CAAA;AAEV,eAAO,MAAM,wBAAwB,gFAI3B,CAAA;AAsHV,eAAO,MAAM,YAAY,GAAI,+BAA+B;IAAE,YAAY,CAAC,EAAE,YAAY,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,sBA4GhH,CAAA"}